:root {
  --canvas: #FAFAFB;
  --surface: #FFFFFF;
  --sunken: #F4F5F7;
  --ink: #0A0A0F;
  --ink-soft: #1F2028;
  --ink-muted: #6B7280;
  --ink-dim: #A0A3AE;
  --hairline: #E8E8ED;
  --hairline-strong: #DCDCE3;
  --accent: #6E3BFF;
  --accent-deep: #4C1FD7;
  --accent-wash: #F2EDFF;
  --accent-glow: rgba(110, 59, 255, 0.12);
  --success: #14A572;
  --warn: #D97706;
  --danger: #D93951;
  --sans: 'Inter', system-ui, sans-serif;
  --display: 'Outfit', 'Inter', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  min-width: 1280px;
}
button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- app shell ---------- */
/* Fixed-viewport shell: the window never scrolls — .main owns vertical
   scroll and .nav owns its own. min-width keeps the desktop layout intact
   on narrow windows (horizontal scroll instead of squeezed panels). */
.app { height: 100vh; min-width: 1024px; overflow: hidden; display: grid; grid-template-columns: 240px 1fr; grid-template-rows: 48px 1fr; grid-template-areas: "nav top" "nav main"; }
.app.nav-collapsed { grid-template-columns: 56px 1fr; }

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 40;
}
.topbar .crumb { color: var(--ink-muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.topbar .crumb .sep { color: var(--ink-dim); }
.topbar .crumb .cur { color: var(--ink-soft); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar .tenant-switch {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  color: var(--ink-soft);
  transition: all 140ms;
}
.topbar .tenant-switch:hover { background: var(--sunken); border-color: var(--hairline-strong); }
.topbar .tenant-switch .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--success); box-shadow: 0 0 0 3px rgba(20,165,114,0.18); }
.topbar .search {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--sunken);
  color: var(--ink-muted);
  width: 280px;
}
.topbar .search:hover { background: var(--surface); border-color: var(--hairline-strong); }
.topbar .search .kbd { margin-left: auto; }
.topbar .env {
  padding: 3px 8px; border-radius: 4px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.06em;
  border: 1px solid var(--hairline);
  background: var(--sunken);
  color: var(--ink-soft);
}
.topbar .env.prod { color: var(--danger); border-color: rgba(217,57,81,0.25); background: rgba(217,57,81,0.06); }
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 999px;
  background: linear-gradient(135deg, #6E3BFF, #0A0A0F);
  color: white; font-size: 11px; font-weight: 600;
  display: grid; place-items: center; cursor: pointer;
}
.topbar .icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--ink-muted);
}
.topbar .icon-btn:hover { background: var(--sunken); color: var(--ink-soft); }

.logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  color: var(--ink);
  font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: -0.02em;
  min-width: 228px;
}
.logo-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--ink);
  display: grid; place-items: center;
  position: relative;
}
.logo-mark::after {
  content: ''; position: absolute; inset: 4px;
  background: var(--accent);
  border-radius: 3px;
  clip-path: polygon(0 0, 100% 0, 100% 60%, 60% 60%, 60% 100%, 0 100%);
}

/* ---------- left nav (dark) ---------- */
.nav {
  grid-area: nav;
  background: var(--ink);
  color: #C7C9D1;
  display: flex; flex-direction: column;
  border-right: 1px solid #000;
  /* Own scroll context: on short windows the group list scrolls while the
     brand head and account footer stay pinned (sticky rules below). Before
     this, items overflowed a fixed 100vh column and clipped under the
     footer. */
  height: 100%; min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 45;
}
.nav .nav-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--ink);
  flex-shrink: 0;
  display: flex; align-items: center;
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid #1a1b24;
}
.nav .nav-head .brand {
  display: flex; align-items: center; gap: 9px;
  color: #fff; font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: -0.02em;
  flex: 1;
}
.nav .nav-head .brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.nav .nav-head .brand .mark::before {
  content: ''; position: absolute; inset: 5px;
  background: #0A0A0F;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 60%, 0 100%);
}
.nav .collapse {
  background: transparent; border: 1px solid transparent;
  color: #777985; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 5px;
}
.nav .collapse:hover { background: #1a1b24; color: #fff; }

.nav .group { padding: 14px 8px 6px; }
.nav .group-label {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #5a5c68;
  padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: #A9ABB6;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  border-left: 2px solid transparent;
  margin-left: -2px;
  position: relative;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: #15161e; color: #fff; }
.nav-item.active { background: #15161e; color: #fff; border-left-color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  font-family: var(--mono); font-size: 10.5px;
  color: #5a5c68;
}
.nav-item.active .count { color: var(--accent); }
.nav-item .icon { width: 16px; height: 16px; color: currentColor; flex: 0 0 16px; }

.nav-divider { height: 1px; background: #1a1b24; margin: 10px 12px; }
.nav-footer {
  margin-top: auto;
  position: sticky; bottom: 0; z-index: 2;
  background: var(--ink);
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid #1a1b24;
  display: flex; align-items: center; gap: 10px;
}
.nav-footer .ava {
  width: 28px; height: 28px; border-radius: 6px;
  background: linear-gradient(135deg, #6E3BFF, #0A0A0F);
  display: grid; place-items: center;
  color: #fff; font-size: 11px; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.nav-footer .who { font-size: 12.5px; color: #E8E8ED; }
.nav-footer .org { font-size: 11px; color: #777985; font-family: var(--mono); }

/* Collapsed nav */
.nav.collapsed .brand-text,
.nav.collapsed .group-label,
.nav.collapsed .nav-item .label,
.nav.collapsed .nav-item .count,
.nav.collapsed .nav-footer .who,
.nav.collapsed .nav-footer .org { display: none; }
.nav.collapsed .nav-item { justify-content: center; padding: 8px; }
.nav.collapsed .nav-head { padding: 0; justify-content: center; }
.nav.collapsed .nav-head .brand { justify-content: center; }
.nav.collapsed .collapse { display: none; }

/* ---------- main ---------- */
.main {
  grid-area: main;
  padding: 24px 32px 64px;
  min-width: 0;
  /* Page content scrolls inside the panel, not the window. */
  height: 100%; min-height: 0;
  overflow-y: auto;
}
.main-inner { max-width: 1200px; margin: 0 auto; }

/* ---------- type ---------- */
.h-display {
  font-family: var(--display); font-weight: 600; font-size: 28px;
  letter-spacing: -0.02em; color: var(--ink); margin: 0;
}
.h-section {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0;
}
.p-lead { color: var(--ink-muted); font-size: 14px; margin: 6px 0 0; }
.mono { font-family: var(--mono); }

/* ---------- primitives ---------- */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  border-radius: 4px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  color: var(--ink-soft);
  box-shadow: 0 1px 0 var(--hairline);
}
.kbd.dark { background: #15161e; border-color: #25262f; color: #C7C9D1; box-shadow: 0 1px 0 #000; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 500; font-size: 13px;
  transition: all 120ms;
}
.btn:hover { background: var(--sunken); border-color: var(--ink-dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink-soft); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.dark:hover { background: #1F2028; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.danger { color: var(--danger); border-color: rgba(217,57,81,0.25); }
.btn.danger:hover { background: rgba(217,57,81,0.06); }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.card-pad { padding: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}
.card-head .h-section { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px;
  border-radius: 999px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--sunken); color: var(--ink-soft);
  border: 1px solid var(--hairline);
}
.badge .d { width: 5px; height: 5px; border-radius: 999px; background: var(--ink-dim); }
.badge.ok { background: rgba(20,165,114,0.08); color: var(--success); border-color: rgba(20,165,114,0.2); }
.badge.ok .d { background: var(--success); box-shadow: 0 0 0 3px rgba(20,165,114,0.18); animation: pulse 1.6s infinite; }
.badge.warn { background: rgba(217,119,6,0.08); color: var(--warn); border-color: rgba(217,119,6,0.22); }
.badge.warn .d { background: var(--warn); }
.badge.danger { background: rgba(217,57,81,0.08); color: var(--danger); border-color: rgba(217,57,81,0.22); }
.badge.danger .d { background: var(--danger); }
.badge.accent { background: var(--accent-wash); color: var(--accent-deep); border-color: rgba(110,59,255,0.2); }
.badge.accent .d { background: var(--accent); }
.badge.plain { background: transparent; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; }
  50% { box-shadow: 0 0 0 3px rgba(20,165,114,0.18); }
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: 6px;
  background: var(--sunken);
  border: 1px solid var(--hairline);
  color: var(--ink-soft);
  font-size: 12px; font-weight: 500;
}
.chip.accent { background: var(--accent-wash); color: var(--accent-deep); border-color: rgba(110,59,255,0.18); }

.tag-mono {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-soft);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--sunken);
  border: 1px solid var(--hairline);
  white-space: nowrap;
  max-width: 100%;
}
/* keep the copy icon from being squeezed; let the value clip with an ellipsis
   when the tag is width-constrained, instead of wrapping to multiple lines. */
.tag-mono .tag-mono-val { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tag-mono > svg { flex-shrink: 0; }
.tag-mono.copy { cursor: pointer; transition: all 120ms; }
.tag-mono.copy:hover { border-color: var(--accent); color: var(--accent-deep); }

/* tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table thead th {
  text-align: left; font-weight: 500; font-size: 11px;
  color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline);
  background: var(--sunken);
}
.table thead th:first-child { border-top-left-radius: 10px; }
.table thead th:last-child { border-top-right-radius: 10px; }
/* when a card-head precedes the table, the card provides the radius already */
.card-head + .table thead th:first-child { border-top-left-radius: 0 !important; }
.card-head + .table thead th:last-child { border-top-right-radius: 0 !important; }
/* also covers cases where card-head is a div with that class */
.card > .card-head ~ .table thead th:first-child { border-top-left-radius: 0 !important; }
.card > .card-head ~ .table thead th:last-child { border-top-right-radius: 0 !important; }
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.table tbody tr { transition: background 120ms; }
.table tbody tr:hover { background: var(--sunken); cursor: pointer; }
.table tbody tr.selected { background: var(--accent-wash); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody td.num { font-family: var(--mono); font-size: 12.5px; }

/* segmented */
.seg {
  display: inline-flex; padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  gap: 2px;
}
.seg button {
  height: 26px; padding: 0 12px;
  border: none; background: transparent;
  border-radius: 6px;
  color: var(--ink-muted); font-size: 12.5px; font-weight: 500;
}
.seg button:hover { color: var(--ink-soft); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(10,10,15,0.06); }
.seg.accent button.active { background: var(--accent-wash); color: var(--accent-deep); }

/* tabs */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--hairline);
  padding: 0 0 0 4px;
}
.tabs button {
  position: relative;
  height: 36px; padding: 0 14px;
  background: transparent; border: none;
  color: var(--ink-muted); font-size: 13px; font-weight: 500;
}
.tabs button:hover { color: var(--ink-soft); }
.tabs button.active { color: var(--ink); }
.tabs button.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--accent);
}

/* ---------- grid backdrop ---------- */
.grid-bg {
  background-image: radial-gradient(circle, var(--hairline-strong) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center;
}

/* ---------- KPI tile ---------- */
.kpi {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.kpi .label { font-size: 12px; color: var(--ink-muted); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.kpi .delta { font-family: var(--mono); font-size: 11px; font-weight: 500; }
.kpi .delta.up { color: var(--success); }
.kpi .delta.dn { color: var(--danger); }
.kpi .spark { height: 36px; }

/* health strip */
.health-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; }
.health-cell { padding: 12px 16px; border-right: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 4px; }
.health-cell:last-child { border-right: none; }
.health-cell .name { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--ink); }
.health-cell .meta { font-size: 11.5px; color: var(--ink-muted); font-family: var(--mono); }

/* activity */
.activity { max-height: 520px; overflow: auto; }
.activity-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px dashed var(--hairline); }
.activity-item:last-child { border-bottom: none; }
.activity-item .dot { margin-top: 6px; width: 8px; height: 8px; border-radius: 999px; background: var(--ink-dim); flex-shrink: 0; }
.activity-item .dot.create { background: var(--success); }
.activity-item .dot.edit { background: var(--accent); }
.activity-item .dot.fail { background: var(--danger); }
.activity-item .when { font-family: var(--mono); font-size: 11px; color: var(--ink-muted); margin-top: 2px; }
.activity-item .msg { font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.activity-item .msg .em { font-weight: 600; color: var(--ink); }

/* ---------- personality card ---------- */
.pcard {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
  transition: border-color 140ms, transform 140ms;
  cursor: pointer;
}
.pcard:hover { border-color: var(--ink-muted); transform: translateY(-1px); }
.pcard .h { display: flex; align-items: flex-start; gap: 10px; }
.pcard .avatar {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-family: var(--display); font-weight: 600;
  flex-shrink: 0;
}
.pcard h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); }
.pcard .desc { font-size: 13px; color: var(--ink-muted); margin: 3px 0 0; line-height: 1.5; }
.pcard .feats { display: flex; flex-wrap: wrap; gap: 6px; }
.pcard .meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--ink-muted); border-top: 1px solid var(--hairline); padding-top: 10px; }

/* ---------- logs panel ---------- */
.logs-panel {
  background: var(--ink);
  color: #C7C9D1;
  font-family: var(--mono); font-size: 12px;
  border-radius: 10px;
  border: 1px solid #1a1b24;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.logs-panel .lp-head {
  padding: 10px 14px;
  border-bottom: 1px solid #1a1b24;
  display: flex; align-items: center; gap: 8px;
  background: #07070b;
}
.logs-panel .lp-title {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #777985;
}
.logs-panel .lp-body {
  padding: 10px 14px;
  flex: 1;
  overflow: auto;
  line-height: 1.65;
}
.logs-panel .ln { display: flex; gap: 10px; }
.logs-panel .ts { color: #5a5c68; min-width: 62px; flex-shrink: 0; }
.logs-panel .lv { min-width: 48px; flex-shrink: 0; font-weight: 600; }
.logs-panel .lv.info { color: #8db4ff; }
.logs-panel .lv.ok { color: #3cd899; }
.logs-panel .lv.warn { color: #ffb65c; }
.logs-panel .lv.err { color: #ff7087; }
.logs-panel .k { color: #c99bff; }
.logs-panel .s { color: #E8E8ED; }
.logs-panel .c { color: #5a5c68; }

/* ---------- chat ---------- */
.chat-canvas { background: var(--canvas); border: 1px solid var(--hairline); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; }
.chat-messages { flex: 1 1 0; min-height: 0; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.msg-row { display: flex; gap: 12px; max-width: 760px; }
.msg-row.you { margin-left: auto; flex-direction: row-reverse; }
.msg-ava {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  flex-shrink: 0;
  background: var(--sunken); color: var(--ink-soft);
  border: 1px solid var(--hairline);
}
.msg-row.you .msg-ava { background: var(--ink); color: #fff; border-color: var(--ink); }
.msg-bubble {
  padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.55;
  max-width: calc(100% - 40px);
}
.msg-row.you .msg-bubble { background: var(--ink); color: #fff; border-radius: 10px 10px 2px 10px; }
.msg-row.asst .msg-bubble { color: var(--ink-soft); background: transparent; padding: 4px 0; max-width: 680px; }
.msg-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }

/* ---------- shared conversations ---------- */
.msg-author { font-size: 11px; font-weight: 600; margin: 0 2px 3px; }
.convo-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px; border-bottom: 1px solid var(--hairline);
  flex-shrink: 0; background: var(--surface); border-radius: 10px 10px 0 0;
}
.badge-shared {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--accent-wash); color: var(--accent-deep);
  border: 1px solid rgba(110,59,255,0.18);
}
.participant-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 999px; font-size: 12px;
  background: var(--sunken); border: 1px solid var(--hairline); color: var(--ink);
}
.participant-chip .px {
  cursor: pointer; opacity: 0.55; display: inline-flex; border: none;
  background: none; padding: 0; color: inherit;
}
.participant-chip .px:hover { opacity: 1; color: var(--danger); }
.chat-item .cshare { margin-top: 3px; }

.tool-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--accent-wash); color: var(--accent-deep);
  border: 1px solid rgba(110,59,255,0.16);
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  margin: 0 4px 4px 0;
}
.src-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  background: var(--sunken); border: 1px solid var(--hairline);
  font-family: var(--mono); font-size: 11px; color: var(--ink-muted);
  margin: 0 4px 4px 0;
}

.chat-composer {
  border-top: 1px solid var(--hairline);
  padding: 12px 14px;
  background: var(--surface);
  flex-shrink: 0;
}
.chat-composer .row { display: flex; align-items: flex-end; gap: 10px; }
.chat-composer textarea {
  display: block; width: 100%; box-sizing: border-box;
  resize: none; border: none; outline: none; background: transparent;
  font: inherit; font-size: 14px; line-height: 1.5;
  padding: 6px 0; min-height: 24px; max-height: 160px;
  overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chat-composer textarea::-webkit-scrollbar { width: 0; height: 0; display: none; }
.chat-composer .tools { display: flex; align-items: center; gap: 4px; margin-top: 6px; color: var(--ink-muted); font-size: 12px; }

/* ---------- drawer (resolved policy) ---------- */
.policy {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.policy h4 {
  font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 0;
}
.policy .row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; padding: 4px 0;
  border-bottom: 1px dashed var(--hairline);
}
.policy .row:last-child { border-bottom: none; }
.policy .row .k { color: var(--ink-muted); }
.policy .row .v { font-family: var(--mono); color: var(--ink); }

/* Resolved-policy rows reused inside the playground side panel. */
.sp-body .row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; padding: 4px 0;
  border-bottom: 1px dashed var(--hairline);
}
.sp-body .row:last-child { border-bottom: none; }
.sp-body .row .k { color: var(--ink-muted); }
.sp-body .row .v { font-family: var(--mono); color: var(--ink); text-align: right; min-width: 0; }

/* ---------- code block ---------- */
.code {
  background: var(--sunken);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono); font-size: 12px;
  line-height: 1.65;
  color: var(--ink-soft);
  overflow: auto;
}
.code .k { color: var(--accent-deep); }
.code .s { color: var(--success); }
.code .c { color: var(--ink-dim); }
.code .n { color: var(--warn); }

/* ---------- command palette ---------- */
.palette-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,10,15,0.5);
  backdrop-filter: blur(3px);
  display: grid; place-items: start center;
  padding-top: 12vh;
  animation: fadeIn 120ms;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.palette {
  width: 620px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(10,10,15,0.24), 0 2px 8px rgba(10,10,15,0.08);
  overflow: hidden;
  animation: slideDown 180ms;
}
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.palette input {
  width: 100%; padding: 14px 18px;
  border: none; outline: none;
  font-size: 15px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}
.palette .results { max-height: 380px; overflow: auto; padding: 6px; }
.palette .result {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer;
}
.palette .result.focused { background: var(--accent-wash); }
.palette .result .icon { width: 18px; height: 18px; color: var(--ink-muted); }
.palette .result.focused .icon { color: var(--accent); }
.palette .result .t { flex: 1; font-size: 13.5px; color: var(--ink-soft); }
.palette .result .cat { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
.palette .group-h { padding: 8px 12px 4px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- toast ---------- */
.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(10,10,15,0.25);
  display: flex; align-items: center; gap: 10px;
  min-width: 240px;
  animation: toastIn 160ms;
}
.toast .d { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* shimmer */
.shimmer {
  position: relative; overflow: hidden;
}
.shimmer::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(110,59,255,0.09), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* empty state */
.empty {
  padding: 40px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border: 1px dashed var(--hairline-strong);
  border-radius: 10px;
  text-align: center;
  background: var(--surface);
}
.empty .icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-wash); color: var(--accent-deep);
  display: grid; place-items: center;
}

/* status pulse for jobs */
.status-pulse { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; }
.status-pulse .d { width: 7px; height: 7px; border-radius: 999px; }
.status-pulse.proc .d { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 1.4s infinite; }
.status-pulse.ok .d { background: var(--success); }
.status-pulse.fail .d { background: var(--danger); }

/* dropdown */
.dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(10,10,15,0.12);
  padding: 6px;
  min-width: 260px;
  z-index: 50;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.dropdown-item:hover { background: var(--sunken); }
.dropdown-item.selected { background: var(--accent-wash); color: var(--accent-deep); }
.dropdown-item .slug { font-family: var(--mono); font-size: 12px; color: var(--ink); flex: 1; }
.dropdown-item .name { font-size: 12px; color: var(--ink-muted); }
.dropdown-footer { padding: 6px; border-top: 1px solid var(--hairline); margin-top: 4px; }

/* input */
.field {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  background: var(--surface);
}
.field input {
  border: none; outline: none; background: transparent;
  flex: 1; font-size: 13px;
}
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field .mono { font-family: var(--mono); font-size: 12px; color: var(--ink-muted); }

/* toggle */
.toggle {
  position: relative; width: 30px; height: 17px;
  border-radius: 999px; background: var(--hairline-strong);
  cursor: pointer; transition: background 150ms;
  flex-shrink: 0;
}
.toggle .k { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; background: #fff; border-radius: 999px; transition: left 160ms; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.toggle.on { background: var(--accent); }
.toggle.on .k { left: 15px; }

/* utils */
.row-f { display: flex; align-items: center; gap: 8px; }
.col-f { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--ink-muted); }
.dim { color: var(--ink-dim); }
.strong { color: var(--ink); font-weight: 600; }

/* ---------- side panel (Chats/Log) ---------- */
.side-panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: background 180ms, border-color 180ms, color 180ms;
}
.side-panel.dark { background: var(--ink); border-color: #1a1b24; color: #C7C9D1; }

.sp-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px 0;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.side-panel.dark .sp-tabs { border-bottom-color: #1a1b24; background: #07070b; }
.sp-tabs button {
  position: relative;
  flex: 1; height: 38px;
  background: transparent; border: none;
  color: var(--ink-muted);
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.sp-tabs button:hover { color: var(--ink); }
.side-panel.dark .sp-tabs button { color: #777985; }
.side-panel.dark .sp-tabs button:hover { color: #E8E8ED; }
.sp-tabs button.active { color: var(--accent-deep); }
.side-panel.dark .sp-tabs button.active { color: var(--accent); }
.sp-tabs button.active::after {
  content: ''; position: absolute; bottom: -1px; left: 10%; right: 10%; height: 2px;
  background: var(--accent);
}
.sp-tabs .sp-close {
  width: 28px; height: 28px; padding: 0; flex: 0 0 28px;
  border-radius: 6px; background: transparent; border: none;
  color: var(--ink-muted);
  display: grid; place-items: center;
  margin: 4px;
}
.sp-tabs .sp-close:hover { background: var(--sunken); color: var(--ink); }
.side-panel.dark .sp-tabs .sp-close { color: #777985; }
.side-panel.dark .sp-tabs .sp-close:hover { background: #15161e; color: #fff; }

.sp-sub { padding: 10px 12px; border-bottom: 1px solid #1a1b24; display: flex; justify-content: flex-start; }
.sp-body { flex: 1; overflow: auto; padding: 6px; display: flex; flex-direction: column; }
.sp-body.log { padding: 10px 14px; font-family: var(--mono); font-size: 12px; line-height: 1.65; }

.chat-item {
  position: relative;
  display: flex; gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 120ms;
}
.chat-item:hover { background: var(--sunken); }
.chat-item.active { background: var(--accent-wash); border-left-color: var(--accent); }
.chat-item .cp {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}
.chat-item .ct {
  font-size: 13px; color: var(--ink);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-item .cw { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; font-family: var(--mono); }
.chat-del {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border: none; background: transparent;
  border-radius: 5px;
  color: var(--ink-dim);
  display: grid; place-items: center;
  opacity: 0; transition: opacity 120ms, background 120ms;
}
.chat-item:hover .chat-del { opacity: 1; }
.chat-del:hover { background: rgba(217,57,81,0.1); color: var(--danger); }

.side-panel.dark .sp-body .ln { display: flex; gap: 10px; }
.side-panel.dark .sp-body .ts { color: #5a5c68; min-width: 62px; flex-shrink: 0; }
.side-panel.dark .sp-body .lv { min-width: 48px; flex-shrink: 0; font-weight: 600; }
.side-panel.dark .sp-body .lv.info { color: #8db4ff; }
.side-panel.dark .sp-body .lv.ok { color: #3cd899; }
.side-panel.dark .sp-body .lv.warn { color: #ffb65c; }
.side-panel.dark .sp-body .lv.err { color: #ff7087; }
.side-panel.dark .sp-body .k { color: #c99bff; }
.side-panel.dark .sp-body .s { color: #E8E8ED; }
.side-panel.dark .sp-body .c { color: #5a5c68; }

/* ---------- staged files panel (Phase-1) ---------- */
.staged-uploader {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline);
}
.staged-list { display: flex; flex-direction: column; }
.staged-row {
  border-bottom: 1px solid var(--hairline);
}
.staged-row-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 120ms;
}
.staged-row-head:hover { background: var(--sunken); }
.staged-row-name {
  font-size: 13px; color: var(--ink); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.staged-row-meta {
  margin-top: 2px;
  font-size: 11.5px; color: var(--ink-muted);
  display: flex; gap: 5px; flex-wrap: wrap;
}
.staged-row-body {
  padding: 6px 12px 12px 30px;
  background: var(--sunken);
  display: flex; flex-direction: column; gap: 10px;
}
.staged-section-h {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-dim); margin-bottom: 4px;
}
.staged-summary {
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.5;
  white-space: pre-wrap;
}
.staged-row-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px dashed var(--hairline);
}

/* key-value table — used by staged-file extracted_fields and context fields */
.kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.kv-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--hairline);
}
.kv-table td {
  padding: 4px 8px 4px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--hairline);
}
.kv-table td.k {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--accent-deep);
  white-space: nowrap;
  width: 1%;
}
.kv-table td.v {
  color: var(--ink);
  word-break: break-word;
}
.kv-table.wide { table-layout: auto; }
.kv-table.wide td.k { width: auto; }

/* ---------- workflow context panel (Phase-2) ---------- */
.sp-subtabs {
  display: flex; gap: 0;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
  overflow-x: auto;
}
.sp-subtabs button {
  background: transparent; border: none;
  padding: 6px 10px;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
.sp-subtabs button:hover { color: var(--ink); }
.sp-subtabs button.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}
.sp-subtabs button .ct {
  font-size: 10px;
  color: var(--ink-dim);
  background: var(--sunken);
  padding: 1px 5px;
  border-radius: 8px;
}

.ctx-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--hairline);
}
.ctx-list {
  display: flex; flex-direction: column;
  padding: 6px;
}
.ctx-empty { padding: 24px 14px; text-align: center; font-size: 13px; }
.ctx-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--hairline);
  display: flex; flex-direction: column; gap: 4px;
}
.ctx-item-head {
  display: flex; align-items: center; gap: 6px;
}
.ctx-item-title {
  flex: 1; min-width: 0;
  font-size: 12.5px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ctx-item-body {
  font-size: 12px; color: var(--ink-soft); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ctx-prov {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-muted);
  text-decoration: none;
}
a.ctx-prov:hover { color: var(--accent-deep); text-decoration: underline; }

.ctx-admin {
  display: flex; gap: 6px; align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--hairline);
  background: var(--sunken);
}

/* ---------- composer attach chip ---------- */
.composer-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.composer-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 8px;
  border: 1px solid var(--hairline);
  background: var(--accent-wash);
  border-radius: 999px;
  max-width: 100%;
}
.composer-chip[data-status="uploading"] {
  animation: chip-pulse 1.2s ease-in-out infinite;
}
.composer-chip[data-status="error"] {
  border-color: var(--danger);
  background: rgba(217,57,81,0.08);
}
@keyframes chip-pulse {
  0%, 100% { background: var(--accent-wash); }
  50%      { background: rgba(20,165,114,0.22); }
}
.msg-attachments {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.msg-attachment {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
}
.msg-attachment-name {
  font-size: 11.5px; color: var(--ink);
  max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-attachment-meta {
  font-family: var(--mono);
  font-size: 10px; color: var(--ink-muted);
}
.composer-chip-name {
  font-size: 12px; color: var(--ink);
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.composer-chip-meta {
  font-family: var(--mono);
  font-size: 10.5px; color: var(--ink-muted);
}
.composer-chip-x {
  width: 18px; height: 18px;
  border: none; background: transparent;
  border-radius: 999px;
  color: var(--ink-dim);
  display: grid; place-items: center;
  cursor: pointer;
}
.composer-chip-x:hover { background: rgba(217,57,81,0.1); color: var(--danger); }

/* lineage */
.lineage {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; background: var(--sunken); border: 1px solid var(--hairline);
  border-radius: 10px;
}
.lineage .node {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}
.lineage .node.current { border-color: var(--accent); background: var(--accent-wash); }
.lineage .arrow { margin-left: 18px; color: var(--ink-dim); font-family: var(--mono); }

/* ---------- workbooks / memory ---------- */
.coll-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 4px;
  background: var(--sunken);
  color: var(--ink-dim);
  border: 1px solid var(--hairline);
}
.coll-icon.on { background: var(--accent-wash); color: var(--accent-deep); border-color: rgba(110,59,255,0.25); }
.coll-icon.on.write { background: rgba(217,119,6,0.12); color: var(--warn); border-color: rgba(217,119,6,0.3); }

.coll-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 120ms;
}
.coll-row:hover { background: var(--sunken); }
.coll-row.active { background: var(--accent-wash); border-left-color: var(--accent); }

/* forensic activity timeline */
.forensic { background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; }
.f-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  background: var(--sunken);
}
.f-body { padding: 6px 0; }
.f-entry { display: flex; gap: 12px; padding: 14px 18px; }
.f-entry:not(:last-child) { border-bottom: 1px dashed var(--hairline); }
.f-gutter { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 78px; flex-shrink: 0; }
.f-op {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; border-radius: 4px;
  letter-spacing: 0.1em;
}
.f-op.insert { background: rgba(20,165,114,0.12); color: var(--success); }
.f-op.update { background: rgba(110,59,255,0.12); color: var(--accent-deep); }
.f-op.delete { background: rgba(217,57,81,0.12); color: var(--danger); }
.f-line { flex: 1; width: 1px; background: var(--hairline); min-height: 16px; }

.f-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.f-diff {
  display: flex; gap: 10px; align-items: stretch;
  background: var(--sunken);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono); font-size: 12px;
}
.f-diff-col { flex: 1; min-width: 0; }
.f-diff-col.full { flex: 1 1 auto; }
.f-diff-h { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-dim); font-weight: 600; margin-bottom: 4px; }
.f-diff-row { display: flex; gap: 8px; padding: 2px 0; }
.f-diff-row .k { color: var(--ink-muted); min-width: 80px; }
.f-diff-row .v { color: var(--ink); }
.f-diff-row .v.add { color: var(--success); background: rgba(20,165,114,0.08); padding: 0 4px; border-radius: 3px; }
.f-diff-row .v.del { color: var(--danger); background: rgba(217,57,81,0.08); padding: 0 4px; border-radius: 3px; }
.f-diff-row .v.strike { text-decoration: line-through; opacity: 0.7; }
.f-diff-arrow { display: flex; align-items: center; color: var(--ink-dim); font-family: var(--mono); }

.f-params { font-size: 12px; }
.f-params summary { cursor: pointer; color: var(--ink-muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; user-select: none; }
.f-params summary:hover { color: var(--accent-deep); }

/* memory */
.mem-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.mem-item:hover { background: var(--sunken); }
.score-bar {
  width: 44px; height: 6px; border-radius: 3px;
  background: var(--hairline); overflow: hidden; flex-shrink: 0;
}
.score-bar > div { height: 100%; }

/* drawer */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10,10,15,0.35);
  animation: fadeIn 140ms ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 460px;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(10,10,15,0.08);
  animation: slideRight 200ms ease-out;
}
@keyframes slideRight { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-body { padding: 16px 18px; overflow: auto; flex: 1; }

/* ---------- auth page ---------- */
/* Idea #1 — Aurora / mesh-gradient drift. The aurora is a single full-bleed
   layer behind both columns; the card floats as frosted glass so the colour
   bleeds through, and the right column carries a quiet brand hero. */
.auth-root {
  position: fixed; inset: 0; z-index: 200;
  display: grid; grid-template-columns: minmax(440px, 560px) 1fr;
  min-width: 1100px;
  background: #04060f;
  font-family: var(--sans);
  isolation: isolate;
}

.auth-col-left {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 56px;
  background: transparent;
}

.auth-card {
  width: 100%; max-width: 428px;
  padding: 34px 32px;
  background: linear-gradient(160deg, rgba(20,24,48,0.72), rgba(10,12,28,0.62));
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 30px 80px rgba(2,3,10,0.6),
    0 0 0 1px rgba(120,80,255,0.06);
  display: flex; flex-direction: column; gap: 0;
}

/* Wordmark */
.auth-wordmark {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--display); font-size: 18px; font-weight: 600;
  color: #fff; letter-spacing: -0.02em;
  margin-bottom: 20px;
  white-space: nowrap;
}
.auth-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent); position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 0 12px rgba(110,59,255,0.5);
  flex-shrink: 0;
}
.auth-mark::before {
  content: ''; position: absolute; inset: 5px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 60%, 0 100%);
}

/* Step dots */
.auth-dots {
  display: flex; gap: 6px; margin-bottom: 24px;
}
.auth-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.15);
  transition: background 300ms, width 300ms;
}
.auth-dot.active { background: var(--accent); width: 18px; box-shadow: 0 0 8px rgba(110,59,255,0.6); }
.auth-dot.filled { background: var(--accent-deep); }

/* Steps */
.auth-step {
  display: none; flex-direction: column; gap: 12px;
  animation: auth-fade-in 180ms ease-out;
}
.auth-step.visible { display: flex; }
@keyframes auth-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.auth-heading {
  font-family: var(--display); font-size: 22px; font-weight: 600;
  color: #fff; letter-spacing: -0.02em; margin: 0 0 4px;
}
.auth-sub {
  font-size: 13.5px; color: rgba(255,255,255,0.45); margin: 0 0 8px; line-height: 1.5;
}

/* Labels & inputs */
.auth-label {
  display: flex; flex-direction: column; gap: 5px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.06em;
}
.auth-input {
  height: 36px; padding: 0 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  font-family: var(--sans); font-size: 14px; color: #fff;
  outline: none; transition: border-color 120ms, box-shadow 120ms;
}
.auth-input::placeholder { color: rgba(255,255,255,0.22); }
.auth-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110,59,255,0.2);
  background: rgba(110,59,255,0.06);
}
.auth-input.error { border-color: var(--danger); }
.auth-input.error:focus { box-shadow: 0 0 0 3px rgba(217,57,81,0.15); }

.auth-textarea {
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  font-family: var(--mono); font-size: 12px; color: #fff;
  outline: none; resize: none; transition: border-color 120ms, box-shadow 120ms;
}
.auth-textarea::placeholder { color: rgba(255,255,255,0.22); }
.auth-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110,59,255,0.2);
  background: rgba(110,59,255,0.06);
}
.auth-textarea.error { border-color: var(--danger); }

.auth-error {
  font-size: 12px; color: #ff6b81; margin-top: -4px;
}

/* Buttons */
.auth-btn-primary {
  height: 36px; padding: 0 16px;
  border-radius: 8px; border: none;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: background 120ms;
}
.auth-btn-primary:hover:not(:disabled) { background: var(--accent-deep); }
.auth-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-btn-ghost {
  height: 36px; padding: 0 16px;
  border-radius: 8px; border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.8);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  gap: 8px; transition: background 120ms, border-color 120ms;
}
.auth-btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.auth-btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.auth-link {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: rgba(160,130,255,0.9); font-weight: 500;
  text-align: center; padding: 4px 0;
  transition: color 120ms;
}
.auth-link:hover { color: #c4b0ff; }

/* Divider */
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: rgba(255,255,255,0.25); margin: 2px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.08);
}

/* OTP cells */
.auth-otp-cell {
  width: 40px; height: 44px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; background: rgba(255,255,255,0.05);
  font-family: var(--mono); font-size: 20px; font-weight: 600;
  color: #fff; text-align: center; outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.auth-otp-cell:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110,59,255,0.25), 0 0 12px rgba(110,59,255,0.3);
  background: rgba(110,59,255,0.08);
}
.auth-otp-cell.error { border-color: var(--danger); }

/* Success state */
.auth-success-icon {
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin: 8px auto 0;
  box-shadow: 0 0 0 8px var(--accent-wash);
  animation: auth-pop 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes auth-pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.auth-redirect-bar {
  height: 3px; background: var(--hairline); border-radius: 999px;
  overflow: hidden; margin-top: 12px;
}
.auth-redirect-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  animation: auth-progress 1.6s linear forwards;
}
@keyframes auth-progress { from { width: 0; } to { width: 100%; } }

/* Spinner */
.auth-spinner {
  width: 14px; height: 14px; border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: auth-spin 600ms linear infinite;
  display: inline-block;
}
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* Right column — aurora hero */
.auth-col-right {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: flex-start;
  overflow: hidden;
  padding: 0 7vw;
  background: transparent;
}

.auth-hero {
  position: relative; z-index: 2;
  max-width: 460px;
  display: flex; flex-direction: column; gap: 18px;
  /* Branding only — not interactive. Can't be selected/copied, and the mouse
     passes straight through so it never shows a text caret and never blocks the
     aurora reveal underneath. */
  user-select: none; -webkit-user-select: none;
  pointer-events: none;
  cursor: default;
}
.auth-hero-eyebrow {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: rgba(196,176,255,0.7);
}
.auth-hero-title {
  font-family: var(--display); font-weight: 600;
  font-size: 46px; line-height: 1.05; letter-spacing: -0.03em;
  margin: 0; color: #fff;
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(80,40,200,0.35);
}
.auth-hero-sub {
  font-size: 15.5px; line-height: 1.6; margin: 0;
  color: rgba(226,224,245,0.62);
  max-width: 400px;
  text-wrap: pretty;
}

.auth-aurora {
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 78% 12%, #0d1230 0%, transparent 55%),
    radial-gradient(120% 100% at 10% 90%, #0a0a22 0%, transparent 60%),
    #04060f;
}
/* Slow global hue + saturation drift on the whole field, so where the blobs
   overlap the mixed colours continuously morph into one another — the single
   biggest source of *temporal* colour variety. Wide range + extra waypoints so
   greens drift to teal/blue, magentas to rose/coral, and back. */
@media (prefers-reduced-motion: no-preference) {
  .auth-aurora-stage { animation: aurora-hue 48s ease-in-out infinite; }
}
.auth-aurora-stage { position: absolute; inset: 0; will-change: filter; }
@keyframes aurora-hue {
  0%,100% { filter: hue-rotate(0deg) saturate(1); }
  16%     { filter: hue-rotate(34deg) saturate(1.18); }
  33%     { filter: hue-rotate(-26deg) saturate(1.28); }
  50%     { filter: hue-rotate(52deg) saturate(1.12); }
  67%     { filter: hue-rotate(-40deg) saturate(1.24); }
  84%     { filter: hue-rotate(18deg) saturate(1.16); }
}
.auth-aurora-blob {
  position: absolute;
  border-radius: 46% 54% 58% 42% / 48% 44% 56% 52%;
  mix-blend-mode: screen;
  filter: blur(64px);
  will-change: transform;
}
/* hover starfield — sits above the cloud, below grain/vignette so the edge
   feather + vignette keep it inside the aurora. ignores pointer events. */
.auth-aurora-stars {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
}
@media (prefers-reduced-motion: no-preference) {
  .auth-aurora-blob { animation-duration: var(--dur, 24s); animation-iteration-count: infinite; animation-timing-function: cubic-bezier(0.42,0,0.58,1); }
}
/* a1 · violet — sweeps from the hero across the seam */
.auth-aurora .a1 {
  width: 52vw; height: 52vw; left: 38%; top: -18%;
  border-radius: 46% 54% 58% 42% / 48% 44% 56% 52%;
  background: radial-gradient(circle, rgba(132,84,255,0.92) 0%, rgba(110,59,255,0.34) 42%, transparent 70%);
  opacity: 0.8; --dur: 23s;
  animation-name: aurora-a1;
  animation-timing-function: cubic-bezier(0.45,0.05,0.4,1);
}
/* a2 · rose-magenta — wanders the centre, crossing violet + indigo */
.auth-aurora .a2 {
  width: 46vw; height: 46vw; left: 22%; top: 24%;
  border-radius: 62% 38% 44% 56% / 56% 50% 50% 44%;
  background: radial-gradient(circle, rgba(234,82,184,0.78) 0%, rgba(186,40,168,0.28) 45%, transparent 70%);
  opacity: 0.64; --dur: 29s;
  animation-name: aurora-a2;
  animation-timing-function: cubic-bezier(0.5,0.02,0.5,1);
}
/* a3 · deep indigo — large, low, rolls behind the card and back */
.auth-aurora .a3 {
  width: 58vw; height: 58vw; left: -20%; top: 30%;
  border-radius: 40% 60% 55% 45% / 60% 42% 58% 40%;
  background: radial-gradient(circle, rgba(78,40,212,0.86) 0%, rgba(58,30,170,0.3) 46%, transparent 72%);
  opacity: 0.72; --dur: 33s;
  animation-name: aurora-a3;
  animation-timing-function: cubic-bezier(0.55,0,0.45,1);
}
/* a4 · electric blue — cool counterpoint, travels top-left ↔ centre */
.auth-aurora .a4 {
  width: 40vw; height: 40vw; left: 2%; top: -22%;
  border-radius: 54% 46% 38% 62% / 44% 58% 42% 56%;
  background: radial-gradient(circle, rgba(64,120,255,0.66) 0%, rgba(48,80,220,0.24) 46%, transparent 72%);
  opacity: 0.58; --dur: 26s;
  animation-name: aurora-a4;
  animation-timing-function: cubic-bezier(0.4,0,0.5,1);
}
/* a5 · AURORA GREEN — the signature northern-lights hue. Mid-size, orbits the
   heart of the cloud so its green keeps mixing into the blues + magentas. */
.auth-aurora .a5 {
  width: 36vw; height: 36vw; left: 50%; top: 42%;
  border-radius: 50% 50% 60% 40% / 52% 48% 52% 48%;
  background: radial-gradient(circle, rgba(60,224,150,0.6) 0%, rgba(34,180,150,0.22) 48%, transparent 72%);
  opacity: 0.5; --dur: 21s;
  animation-name: aurora-a5;
  animation-timing-function: cubic-bezier(0.37,0,0.63,1);
}
/* a6 · cool cyan — the largest + slowest layer, a long single diagonal drift
   at a calm, different pace under the others */
.auth-aurora .a6 {
  width: 68vw; height: 68vw; left: 28%; top: 4%;
  border-radius: 58% 42% 47% 53% / 38% 56% 44% 62%;
  background: radial-gradient(circle, rgba(72,202,236,0.46) 0%, rgba(54,118,212,0.2) 46%, transparent 72%);
  opacity: 0.4; --dur: 44s;
  animation-name: aurora-a6;
  animation-timing-function: cubic-bezier(0.5,0.05,0.5,0.95);
}
/* a7 · rose-pink spark — small, fast figure-eight that keeps the heart of the
   cloud shimmering with warm moving highlights */
.auth-aurora .a7 {
  width: 22vw; height: 22vw; left: 60%; top: 30%;
  border-radius: 50% 50% 52% 48% / 54% 46% 54% 46%;
  background: radial-gradient(circle, rgba(255,142,212,0.7) 0%, rgba(214,96,200,0.22) 50%, transparent 74%);
  opacity: 0.5; --dur: 15s;
  animation-name: aurora-a7;
  animation-timing-function: cubic-bezier(0.36,0,0.64,1);
}
/* a8 · teal — small, quick vertical bob + drift on the right, adds a fresh
   blue-green note and a different motion axis from everything else */
.auth-aurora .a8 {
  width: 28vw; height: 28vw; left: 66%; top: 6%;
  border-radius: 48% 52% 46% 54% / 50% 50% 50% 50%;
  background: radial-gradient(circle, rgba(46,214,196,0.56) 0%, rgba(34,150,180,0.2) 50%, transparent 74%);
  opacity: 0.46; --dur: 18s;
  animation-name: aurora-a8;
  animation-timing-function: cubic-bezier(0.45,0.05,0.55,0.95);
}
/* a9 · coral / red — the rare high-altitude aurora note. Small + low opacity so
   it only kisses warmth into the magentas; slow S-curve across the upper cloud. */
.auth-aurora .a9 {
  width: 30vw; height: 30vw; left: 44%; top: -10%;
  border-radius: 56% 44% 52% 48% / 46% 54% 46% 54%;
  background: radial-gradient(circle, rgba(255,118,128,0.5) 0%, rgba(226,72,118,0.18) 48%, transparent 72%);
  opacity: 0.34; --dur: 37s;
  animation-name: aurora-a9;
  animation-timing-function: cubic-bezier(0.5,0,0.5,1);
}
/* a10 · deep azure — a cool blue-violet counterweight low on the right, broad +
   unhurried, an orbit that pulls the palette back toward blue between flares. */
.auth-aurora .a10 {
  width: 42vw; height: 42vw; left: 54%; top: 40%;
  border-radius: 52% 48% 44% 56% / 56% 46% 54% 44%;
  background: radial-gradient(circle, rgba(86,120,255,0.6) 0%, rgba(58,72,206,0.22) 47%, transparent 73%);
  opacity: 0.48; --dur: 31s;
  animation-name: aurora-a10;
  animation-timing-function: cubic-bezier(0.42,0.04,0.5,1);
}

/* Larger, multi-waypoint travel paths: blobs cross the whole panel so the
   violet / magenta / indigo / blue fields slide THROUGH each other and the
   overlap colours flow and re-mix continuously. */
@keyframes aurora-a1 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.8; }
  25%     { transform: translate(-22%, 16%) scale(1.22) rotate(40deg); opacity: 0.64; }
  50%     { transform: translate(-34%, 30%) scale(0.92) rotate(-20deg); opacity: 0.86; }
  75%     { transform: translate(-12%, 10%) scale(1.12) rotate(24deg); opacity: 0.7; }
}
@keyframes aurora-a2 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.64; }
  25%     { transform: translate(26%, -18%) scale(1.24) rotate(-36deg); opacity: 0.5; }
  50%     { transform: translate(40%, 8%) scale(0.88) rotate(28deg); opacity: 0.74; }
  75%     { transform: translate(14%, 22%) scale(1.1) rotate(-16deg); opacity: 0.56; }
}
@keyframes aurora-a3 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.72; }
  30%     { transform: translate(28%, -14%) scale(1.18) rotate(30deg); opacity: 0.56; }
  60%     { transform: translate(40%, 18%) scale(0.94) rotate(-22deg); opacity: 0.78; }
  80%     { transform: translate(16%, 26%) scale(1.08) rotate(12deg); opacity: 0.62; }
}
@keyframes aurora-a4 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.58; }
  33%     { transform: translate(34%, 26%) scale(1.28) rotate(44deg); opacity: 0.42; }
  66%     { transform: translate(18%, 44%) scale(0.9) rotate(-30deg); opacity: 0.64; }
}
/* a5 green — wide orbital loop so the signature green keeps re-mixing on all
   sides, breathing brighter/dimmer as it travels */
@keyframes aurora-a5 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.5; }
  25%     { transform: translate(-26%, 18%) scale(1.18) rotate(60deg); opacity: 0.64; }
  50%     { transform: translate(-4%, 34%) scale(0.84) rotate(120deg); opacity: 0.4; }
  75%     { transform: translate(22%, 14%) scale(1.12) rotate(60deg); opacity: 0.58; }
}
/* a6 — one long, slow diagonal roll across the panel and back, breathing wide */
@keyframes aurora-a6 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.4; }
  50%     { transform: translate(-28%, 24%) scale(1.18) rotate(-24deg); opacity: 0.52; }
}
/* a7 rose — quick figure-eight wander, warm highlight pulsing */
@keyframes aurora-a7 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.5; }
  25%     { transform: translate(-16%, 14%) scale(1.22) rotate(30deg); opacity: 0.62; }
  50%     { transform: translate(10%, 26%) scale(0.84) rotate(-18deg); opacity: 0.34; }
  75%     { transform: translate(22%, 8%) scale(1.12) rotate(22deg); opacity: 0.56; }
}
/* a8 teal — vertical bob + slight drift on a different motion axis */
@keyframes aurora-a8 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.46; }
  33%     { transform: translate(-10%, 30%) scale(1.16) rotate(-20deg); opacity: 0.58; }
  66%     { transform: translate(8%, 52%) scale(0.9) rotate(16deg); opacity: 0.36; }
}
/* a9 coral — slow S-curve across the upper cloud, warmth pulsing in + out */
@keyframes aurora-a9 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.34; }
  25%     { transform: translate(18%, 14%) scale(1.2) rotate(-18deg); opacity: 0.46; }
  50%     { transform: translate(-8%, 30%) scale(0.86) rotate(14deg); opacity: 0.24; }
  75%     { transform: translate(-24%, 12%) scale(1.1) rotate(-8deg); opacity: 0.42; }
}
/* a10 azure — broad slow orbit that keeps pulling the palette back to blue */
@keyframes aurora-a10 {
  0%,100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 0.48; }
  25%     { transform: translate(-20%, -16%) scale(1.16) rotate(34deg); opacity: 0.38; }
  50%     { transform: translate(-30%, 8%) scale(0.92) rotate(-22deg); opacity: 0.56; }
  75%     { transform: translate(-14%, 24%) scale(1.1) rotate(18deg); opacity: 0.42; }
}

/* fine grain — kills gradient banding, adds a premium film texture */
.auth-aurora-grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: overlay;
  pointer-events: none;
}
/* vignette — darkens edges so the card and hero stay legible */
.auth-aurora-vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(130% 120% at 50% 0%, transparent 40%, rgba(4,6,15,0.55) 100%),
    linear-gradient(90deg, rgba(4,6,15,0.5) 0%, transparent 30%, transparent 70%, rgba(4,6,15,0.35) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .auth-aurora-stage,
  .auth-aurora-blob { animation: none !important; }
}
