:root {
  --bg: #f6f6f7;
  --panel: #ffffff;
  --ink: #16161a;
  --ink-soft: #44434d;
  --muted: #8b8a96;
  --line: #e7e6ec;
  --line-soft: #efeef3;
  --accent: #4f46b8;
  --accent-soft: #ece9fb;

  --lavender: #ece4fb;
  --lavender-ink: #5b50aa;
  --mint: #def3e7;
  --mint-ink: #2c7a55;
  --peach: #fbe2cf;
  --peach-ink: #a35a32;
  --sky: #dde9f8;
  --sky-ink: #3f6c9d;
  --rose: #fbdce6;
  --rose-ink: #a44a6e;

  --radius-lg: 10px;
  --radius: 6px;
  --radius-sm: 4px;

  --shadow: none;
  --shadow-sm: 0 1px 2px rgba(20, 18, 38, 0.04);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }

/* ------ Auth ------ */
body.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.auth-card {
  width: min(380px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand h1 { font-size: 22px; margin: 12px 0 4px; font-weight: 600; letter-spacing: -0.02em; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
}
.brand-mark.big { width: 48px; height: 48px; border-radius: var(--radius-lg); font-size: 20px; }

.auth-form { display: grid; gap: 12px; }
.auth-form label { display: grid; gap: 6px; }
.auth-form label > span { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }
.input {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 12px; transition: border-color .12s;
}
.input:focus-within { border-color: var(--accent); }
.input i { color: var(--muted); }
.input input {
  flex: 1; border: 0; background: transparent; outline: none;
  padding: 10px 0; font: inherit; color: var(--ink);
}
.input .reveal { background: transparent; border: 0; color: var(--muted); padding: 6px; }

.flash {
  background: #fff5f0; color: #b85e3a; border: 1px solid #f4d4c0;
  border-radius: var(--radius); padding: 8px 10px; font-size: 12.5px;
}
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: var(--radius);
  padding: 10px 14px; font-weight: 500; font-size: 13.5px;
  transition: background .12s, border-color .12s;
}
.primary:hover { background: #2a2937; border-color: #2a2937; }
.primary:disabled { background: var(--muted); border-color: var(--muted); cursor: not-allowed; }
.primary.big { padding: 12px 14px; font-size: 14px; }

.auth-lead { color: var(--ink-soft); text-align: center; margin: 0 0 4px; font-size: 13px; }
.auth-hint { color: var(--muted); font-size: 11.5px; text-align: center; margin: 4px 0 0; line-height: 1.55; }
.auth-hint em { color: var(--ink); font-style: normal; font-weight: 500; }
.auth-status {
  margin-top: 4px; padding: 8px 10px; border-radius: var(--radius);
  font-size: 12.5px; text-align: center;
  background: var(--line-soft); color: var(--ink-soft); border: 1px solid var(--line);
}
.auth-status.ok { background: var(--mint); color: var(--mint-ink); border-color: transparent; }
.auth-status.error { background: #fff0ec; color: #b85e3a; border-color: #f4d4c0; }

/* ------ App shell ------ */
body.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-weight: 500; font-size: 13px;
  transition: background .1s, color .1s;
}
.nav-item i { width: 14px; color: var(--muted); transition: color .1s; font-size: 13px; }
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item:hover i { color: var(--ink-soft); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active i { color: var(--accent); }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px; border-top: 1px solid var(--line);
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  text-transform: uppercase; font-size: 12px;
}
.user-name { font-weight: 500; font-size: 12.5px; }
.user-role { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.logout {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: var(--radius-sm); color: var(--muted); font-size: 12px;
}
.logout:hover { background: var(--line-soft); color: var(--ink); }

.main { padding: 18px 24px 32px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.crumbs strong { color: var(--ink); font-weight: 500; }
.crumbs .tiny { font-size: 9px; }
.top-actions { display: flex; gap: 4px; }
.ghost {
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 10px; font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .1s, border-color .1s, color .1s;
}
.ghost:hover { background: var(--line-soft); color: var(--ink); border-color: var(--line); }

/* ------ Dashboard hero ------ */
.dash { display: grid; gap: 16px; }
.hero {
  display: grid; grid-template-columns: 1fr auto; gap: 20px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.hero h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.02em; }
.hero .lead { margin: 0; color: var(--muted); font-size: 13px; }
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat {
  width: 80px; padding: 10px 12px; border-radius: var(--radius);
  display: grid; gap: 1px; text-align: left;
}
.stat .num { font-size: 18px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.stat .lab { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.stat.lavender { background: var(--lavender); }
.stat.lavender .lab { color: var(--lavender-ink); }
.stat.mint { background: var(--mint); }
.stat.mint .lab { color: var(--mint-ink); }
.stat.peach { background: var(--peach); }
.stat.peach .lab { color: var(--peach-ink); }
.stat.sky { background: var(--sky); }
.stat.sky .lab { color: var(--sky-ink); }

/* ------ Chat ------ */
.chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: grid; grid-template-rows: auto 1fr auto auto auto;
  min-height: 520px;
  overflow: hidden;
  position: relative;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.ciara-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 13px;
}
.chat-title { font-weight: 600; font-size: 13.5px; }
.chat-sub { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.live { background: #4caf80; }
.chat-tools { margin-left: auto; display: flex; gap: 4px; }
.chat-tools .ghost { padding: 4px 8px; font-size: 12px; }

.chat-stream {
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto;
  max-height: 60vh;
}
.msg { display: flex; }
.msg.ai { justify-content: flex-start; }
.msg.me { justify-content: flex-end; }
.bub {
  max-width: 70%;
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--lavender); color: var(--lavender-ink);
  white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px;
}
.msg.ai .bub { background: var(--lavender); color: var(--lavender-ink); }
.msg.me .bub { background: var(--mint); color: var(--mint-ink); }
.bub.thinking { color: var(--muted); font-style: italic; background: var(--line-soft); }

.chat-input {
  display: flex; align-items: end; gap: 6px;
  padding: 8px 10px; border-top: 1px solid var(--line); background: var(--panel);
}
.chat-input textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  font: inherit; padding: 8px 4px; max-height: 160px; font-size: 13.5px;
}
.chat-input .primary { padding: 8px 12px; }
.chat-suggest {
  display: flex; gap: 6px; padding: 0 10px 10px; flex-wrap: wrap;
}
.chip {
  background: var(--line-soft); border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: var(--radius); padding: 4px 10px; font-size: 12px;
  transition: background .1s, color .1s, border-color .1s;
}
.chip:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }

/* ------ Chat attachments ------ */
.bub { display: flex; flex-direction: column; gap: 6px; }
.bub-atts {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.bub-atts a { display: block; line-height: 0; }
.bub-atts img {
  max-width: 260px; max-height: 260px;
  border-radius: var(--radius-sm);
  display: block;
  object-fit: cover;
}
.bub-text { white-space: pre-wrap; word-wrap: break-word; }
.bub:has(.bub-atts):not(:has(.bub-text)) { padding: 6px; background: transparent; }
.msg.me .bub:has(.bub-atts):not(:has(.bub-text)),
.msg.ai .bub:has(.bub-atts):not(:has(.bub-text)) { background: transparent; }

.chat-attachments {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 10px 0;
}
.att-chip {
  position: relative;
  width: 64px; height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--line-soft);
  border: 1px solid var(--line);
}
.att-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-chip.uploading img { opacity: 0.55; }
.att-chip.error { border-color: #d97a5c; }
.att-status {
  position: absolute; inset: auto 0 0 0;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 10px; text-align: center; padding: 1px 0;
}
.att-status.err { background: #d97a5c; }
.att-x {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff;
  border: 0; cursor: pointer;
  display: grid; place-items: center;
  font-size: 10px;
  padding: 0;
}
.att-x:hover { background: rgba(0,0,0,0.85); }

.chat-drop {
  position: absolute; inset: 0;
  background: rgba(118, 116, 198, 0.12);
  backdrop-filter: blur(2px);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  display: none;
  align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 10;
}
.chat-drop.active { display: flex; }
.chat-drop-inner {
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  color: var(--accent);
  font-size: 14px; font-weight: 500;
}
.chat-drop-inner i { font-size: 28px; }

/* ------ Section pages ------ */
.section { display: grid; gap: 16px; }
.section-head {
  display: flex; align-items: end; justify-content: space-between; gap: 12px;
}
.section-head h1 { font-size: 22px; margin: 0 0 2px; font-weight: 600; letter-spacing: -0.02em; }
.section-head .lead { margin: 0; color: var(--muted); font-size: 13px; }
.section-actions { display: flex; gap: 6px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.card {
  position: relative; display: grid; grid-template-columns: auto 1fr; gap: 12px;
  align-items: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color .12s;
}
.card:hover { border-color: #d8d6e0; }
.card-icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
}
.card.lavender .card-icon { background: var(--lavender); color: var(--lavender-ink); }
.card.mint .card-icon { background: var(--mint); color: var(--mint-ink); }
.card.peach .card-icon { background: var(--peach); color: var(--peach-ink); }
.card.sky .card-icon { background: var(--sky); color: var(--sky-ink); }
.card.rose .card-icon { background: var(--rose); color: var(--rose-ink); }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.tag {
  font-size: 10px; padding: 2px 7px; border-radius: var(--radius-sm);
  background: var(--line-soft); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500;
}
.card.lavender .tag { background: var(--lavender); color: var(--lavender-ink); }
.card.mint .tag { background: var(--mint); color: var(--mint-ink); }
.card.peach .tag { background: var(--peach); color: var(--peach-ink); }
.card.sky .tag { background: var(--sky); color: var(--sky-ink); }
.card-more {
  position: absolute; top: 8px; right: 8px;
  background: transparent; border: 0; color: var(--muted); padding: 4px 6px;
  border-radius: var(--radius-sm); font-size: 12px;
}
.card-more:hover { background: var(--line-soft); color: var(--ink); }

/* ------ Git ------ */
.git-section .lead code {
  background: var(--line-soft); padding: 1px 5px; border-radius: var(--radius-sm);
  font-size: 12px; color: var(--ink-soft);
}
.git-error {
  background: #fff0ec; color: #b85e3a; border: 1px solid #f4d4c0;
  border-radius: var(--radius); padding: 10px 12px; font-size: 13px;
}
.git-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.git-commit { background: var(--panel); }
.git-row {
  display: grid; grid-template-columns: auto auto auto 1fr auto;
  align-items: center; gap: 12px;
  padding: 10px 14px;
  font-size: 13px;
}
.git-hash {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; color: var(--accent);
  background: var(--accent-soft); padding: 2px 6px; border-radius: var(--radius-sm);
}
.git-time { color: var(--muted); font-size: 12px; min-width: 72px; }
.git-msg { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.git-buttons { display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.git-row:hover .git-buttons { opacity: 1; }
.git-buttons .ghost { padding: 4px 8px; font-size: 12px; }
.git-diff {
  margin: 0; padding: 12px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; line-height: 1.55;
  background: #fafaff;
  border-top: 1px solid var(--line);
  white-space: pre; overflow-x: auto;
  max-height: 60vh; overflow-y: auto;
  color: var(--ink-soft);
}
.git-diff .d-meta { color: var(--muted); }
.git-diff .d-hunk { color: var(--accent); }
.git-diff .d-ins { color: var(--mint-ink); background: #effaf3; display: inline-block; width: 100%; }
.git-diff .d-del { color: #b85e3a; background: #fff5f0; display: inline-block; width: 100%; }
.git-empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel); border-radius: var(--radius-lg); border: 1px solid var(--line); }

/* ------ Responsive ------ */
@media (max-width: 900px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
  .nav-item span { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(4, 1fr); }
}

/* ------ Chat attachments / drop zone ------ */
.chat-drop {
  position: absolute; inset: 0;
  border-radius: inherit;
  background: rgba(124, 92, 255, 0.08);
  border: 2px dashed var(--accent, #7c5cff);
  display: none;
  align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 5;
}
.chat-drop.active { display: flex; }
.chat-drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-weight: 600; color: var(--accent, #7c5cff);
  background: var(--panel, #fff);
  padding: 18px 28px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.chat-drop-inner i { font-size: 28px; }

.chat-attachments {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 14px 0;
}
.att-chip {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel-2, #f6f6f9);
  flex: 0 0 auto;
}
.att-chip img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.att-chip.uploading img { opacity: 0.5; }
.att-chip.error { border-color: #d9534f; }
.att-status {
  position: absolute; left: 4px; bottom: 4px;
  background: rgba(0,0,0,0.55); color: #fff;
  border-radius: 4px; padding: 0 6px;
  font-size: 11px; line-height: 16px;
}
.att-status.err { background: #d9534f; }
.att-x {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  padding: 0;
}
.att-x:hover { background: rgba(0,0,0,0.8); }

.bub-atts {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.bub-atts a { display: block; }
.bub-atts img {
  max-width: 240px; max-height: 240px;
  border-radius: 8px;
  display: block;
}
