:root {
  /* paper-warm neutrals */
  --bg: oklch(98.5% 0.004 80);
  --bg-panel: oklch(99.5% 0.002 80);
  --bg-sunken: oklch(96% 0.005 80);
  --bg-hover: oklch(95% 0.006 80);
  --line: oklch(90% 0.006 80);
  --line-strong: oklch(82% 0.008 80);
  --ink: oklch(22% 0.01 80);
  --ink-dim: oklch(45% 0.01 80);
  --ink-mute: oklch(62% 0.008 80);

  /* teal accent */
  --accent: oklch(52% 0.09 195);
  --accent-soft: oklch(93% 0.03 195);
  --accent-ink: oklch(38% 0.1 195);

  /* signal */
  --red: oklch(55% 0.14 25);
  --red-soft: oklch(94% 0.03 25);
  --amber: oklch(68% 0.12 75);
  --amber-soft: oklch(94% 0.04 75);
  --green: oklch(55% 0.1 150);
  --green-soft: oklch(94% 0.03 150);

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  --font-ui: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'Instrument Serif', Georgia, serif;

  --row-h: 36px;
  --topbar-h: 48px;
}

[data-accent="indigo"] {
  --accent: oklch(52% 0.12 265);
  --accent-soft: oklch(94% 0.03 265);
  --accent-ink: oklch(38% 0.13 265);
}
[data-accent="crimson"] {
  --accent: oklch(52% 0.14 15);
  --accent-soft: oklch(94% 0.03 15);
  --accent-ink: oklch(38% 0.15 15);
}

[data-density="compact"] {
  --row-h: 30px;
  --topbar-h: 42px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }

/* ----------- App shell ----------- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
  background: var(--bg);
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 0 14px;
  gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600; letter-spacing: -0.01em;
}
.brand-mark {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
}
.brand-name { font-size: 13.5px; }
.brand-tag {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute); padding: 2px 6px;
  border: 1px solid var(--line); border-radius: 3px;
  margin-left: 2px;
}
.topbar-crumbs {
  display: flex; align-items: center; gap: 6px;
  color: var(--ink-dim); font-size: 12.5px;
  margin-left: 18px;
}
.topbar-crumbs span.sep { color: var(--ink-mute); }
.topbar-crumbs b { font-weight: 500; color: var(--ink); }

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}
.chip-kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-dim);
  padding: 2px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 3px; background: var(--bg-panel);
}

/* Language toggle (EN / 中文) lives in the topbar and on the login card. */
.lang-toggle {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg-panel); overflow: hidden;
  font-family: var(--font-mono); font-size: 10.5px;
}
.lang-toggle button {
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-mute);
  padding: 3px 8px; line-height: 1.4;
  font: inherit;
}
.lang-toggle button + button { border-left: 1px solid var(--line); }
.lang-toggle button:hover { color: var(--ink); background: var(--bg-hover); }
.lang-toggle button[data-active="true"] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }

/* When the document is Chinese, prefer CJK-capable system stacks so text
   doesn't render in a thin fallback glyph set. */
html[lang="zh-Hans"] body,
html[lang="zh-Hans"] input,
html[lang="zh-Hans"] button,
html[lang="zh-Hans"] textarea {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", var(--font-sans);
}
html[lang="zh-Hans"] h1,
html[lang="zh-Hans"] h2,
html[lang="zh-Hans"] .login-hero h1 {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif CJK SC", var(--font-serif);
}

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: white;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 10px 8px;
  display: flex; flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-section {
  font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 600;
  color: var(--ink-mute);
  padding: 10px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px; border-radius: var(--r-sm);
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 12.5px;
  border: none; background: transparent;
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink); }
.nav-item[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.nav-count {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute);
  padding: 0 5px;
  border: 1px solid var(--line); border-radius: 3px;
}
.nav-item[data-active="true"] .nav-count {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.main { overflow: hidden; display: flex; flex-direction: column; }

/* ----------- Queue list ----------- */
.queue {
  display: grid;
  grid-template-columns: var(--queue-left-w, 380px) 6px 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.queue-divider {
  cursor: ew-resize;
  background: transparent;
  border-left: 1px solid var(--line);
  position: relative;
  user-select: none;
}
.queue-divider:hover, .queue-divider[data-dragging="true"] {
  background: var(--line);
}
.queue-divider::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 24px;
  border-radius: 2px;
  background: var(--ink-mute);
  opacity: 0.4;
}
.queue-left {
  border-right: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex; flex-direction: column;
  min-height: 0;
}
.queue-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.queue-header h2 {
  margin: 0; font-size: 14.5px; font-weight: 600;
}
.queue-stats {
  display: flex; gap: 12px; font-size: 11.5px; color: var(--ink-dim);
  font-family: var(--font-mono);
}
.queue-stats b { color: var(--ink); font-weight: 500; }
.search {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.search input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: inherit; color: var(--ink);
}
.search input::placeholder { color: var(--ink-mute); }
.filter-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.filter-pill {
  padding: 2px 8px; font-size: 11.5px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink-dim);
  cursor: pointer;
}
.filter-pill[data-active="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

.queue-list {
  overflow-y: auto; flex: 1;
}
.queue-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  position: relative;
}
.queue-row:hover { background: var(--bg-hover); }
.queue-row[data-active="true"] {
  background: var(--bg-sunken);
}
.queue-row[data-active="true"]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
}
.queue-row-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px;
  background: var(--line-strong);
}
.queue-row-dot[data-status="needs-review"] { background: var(--amber); }
.queue-row-dot[data-status="in-progress"] { background: var(--accent); }
.queue-row-dot[data-status="approved"] { background: var(--green); }
.queue-row-dot[data-status="rejected"] { background: var(--red); }

.queue-row-main { min-width: 0; }
.queue-row-title {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-row-meta {
  display: flex; gap: 8px; margin-top: 4px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute);
}
.queue-row-meta .sep { color: var(--line-strong); }

.queue-row-right {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.quality-bar {
  width: 36px; height: 4px; background: var(--bg-sunken);
  border-radius: 2px; overflow: hidden;
  border: 1px solid var(--line);
}
.quality-bar > span { display: block; height: 100%; background: var(--accent); }

/* ----------- Queue right (detail) ----------- */
.queue-right { overflow-y: auto; padding: 24px 32px; }
.qr-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.qr-head h1 {
  margin: 0; font-size: 20px; letter-spacing: -0.01em; font-weight: 600;
}
.qr-head .qr-id {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-mute);
  margin-top: 4px;
}
.qr-actions { margin-left: auto; display: flex; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg-panel);
  color: var(--ink); cursor: pointer;
  font-size: 12.5px; font-weight: 500;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.btn.primary:hover { background: oklch(32% 0.01 80); }
.btn.accent {
  background: var(--accent); color: white; border-color: var(--accent);
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-dim); }
.btn.ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn .kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  opacity: 0.7;
}

/* ----------- Editor (tabbed page) ----------- */
.workspace { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.ws-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-panel);
}
.ws-crumbs {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-mute);
  padding-bottom: 10px;
}
.ws-crumbs b { color: var(--ink); font-weight: 500; }
.ws-status {
  margin-left: auto; padding-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.ws-saving { font-size: 11.5px; color: var(--ink-mute); font-family: var(--font-mono); }
.tabs { display: flex; gap: 0; padding: 0 20px; margin-top: 2px; align-items: flex-end; }
.tab {
  padding: 8px 14px; font-size: 12.5px; font-weight: 500;
  color: var(--ink-dim); border: none; background: transparent;
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink); }
.tab[data-active="true"] {
  color: var(--ink); border-bottom-color: var(--accent);
}
.tab .tab-num {
  font-family: var(--font-mono); font-size: 10px;
  background: var(--bg-sunken); color: var(--ink-mute);
  padding: 1px 5px; border-radius: 3px; margin-right: 4px;
}
.tab[data-active="true"] .tab-num {
  background: var(--accent-soft); color: var(--accent-ink);
}
.tab .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--amber);
}

.ws-body { flex: 1; overflow: auto; }

/* ----------- Editor three-pane ----------- */
.editor {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  height: 100%;
}
.editor-main { overflow-y: auto; padding: 20px 24px 80px; }
.editor-side {
  border-left: 1px solid var(--line);
  background: var(--bg-panel);
  overflow-y: auto; padding: 18px 20px;
}

.section {
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-panel);
}
.section-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.section-head h3 {
  margin: 0; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.section-head .section-hint {
  font-size: 11.5px; color: var(--ink-mute); font-weight: 400;
  margin-left: auto;
}
.section-body { padding: 12px 14px; }

.field {
  display: grid; grid-template-columns: 140px 1fr;
  gap: 10px; padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.field:last-child { border-bottom: none; }
.field-label {
  font-size: 12px; color: var(--ink-dim);
  padding-top: 5px;
  font-family: var(--font-mono);
}
.field-value { min-width: 0; }

.inp, .ta {
  width: 100%; font: inherit;
  padding: 5px 8px; border: 1px solid var(--line);
  background: var(--bg); border-radius: var(--r-sm);
  color: var(--ink); outline: none;
  resize: vertical;
}
.inp:focus, .ta:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.ta { font-family: var(--font-ui); min-height: 60px; line-height: 1.5; }
.ta.mono { font-family: var(--font-mono); font-size: 12px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  background: var(--bg-sunken); color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 3px;
  font-size: 11px; font-family: var(--font-mono);
}
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.tag.green { background: var(--green-soft); color: oklch(38% 0.1 150); border-color: transparent; }
.tag.red { background: var(--red-soft); color: oklch(38% 0.15 25); border-color: transparent; }
.tag.amber { background: var(--amber-soft); color: oklch(40% 0.13 75); border-color: transparent; }

.diff-edited {
  position: relative;
}
.diff-edited::before {
  content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px; width: 2px;
  background: var(--amber);
}

.list-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg);
  margin-bottom: 6px;
  font-family: var(--font-mono); font-size: 12px;
}
.list-row:hover { background: var(--bg-hover); }
.list-row .grab { color: var(--ink-mute); cursor: grab; }

.tool-card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  margin-bottom: 8px; background: var(--bg);
}
.tool-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tool-card-head .tool-name {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
}
.tool-card-head .tool-kind {
  font-size: 10.5px; padding: 1px 6px; border-radius: 3px;
}
.tool-card-head .tool-kind[data-kind="read"] { background: var(--bg-sunken); color: var(--ink-dim); }
.tool-card-head .tool-kind[data-kind="write"] { background: var(--amber-soft); color: oklch(40% 0.13 75); }
.tool-card-body {
  padding: 8px 10px; font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-dim); background: var(--bg-sunken);
}
.tool-card-body code { color: var(--ink); }

.side-meta { font-size: 12px; color: var(--ink-dim); }
.side-meta dt { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 10px; }
.side-meta dd { margin: 2px 0 0; color: var(--ink); }
.side-meta dd.mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ----------- Simulator ----------- */
.sim {
  display: grid;
  grid-template-columns: minmax(420px, 1fr);
  grid-template-rows: auto 1fr auto;
  height: 100%;
  overflow: hidden;
  position: relative;
}
.sim-context, .sim-right {
  position: absolute; top: 0; bottom: 0; width: 280px;
  background: var(--bg-panel); z-index: 5;
  transition: transform .2s ease;
}
.sim-context { left: 0; border-right: 1px solid var(--line); transform: translateX(-100%); }
.sim-right { right: 0; border-left: 1px solid var(--line); transform: translateX(100%); }
.sim[data-ctx="open"] .sim-context { transform: translateX(0); box-shadow: 4px 0 24px -10px oklch(20% 0.01 80 / 0.15); }
.sim[data-ann="open"] .sim-right { transform: translateX(0); box-shadow: -4px 0 24px -10px oklch(20% 0.01 80 / 0.15); }
@media (min-width: 1180px) {
  .sim {
    grid-template-columns: 240px minmax(0, 1fr) 320px;
    grid-template-rows: auto 1fr;
  }
  .sim-context, .sim-right { position: static; transform: none !important; box-shadow: none !important; width: auto; }
}
@media (min-width: 1500px) {
  .sim { grid-template-columns: 280px minmax(0, 1fr) 380px; }
}
.sim-context { overflow-y: auto; padding: 16px; }
.sim-center { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.sim-right { overflow-y: auto; padding: 16px; }
.sim-panel-toggle {
  position: absolute; z-index: 10; top: 72px;
  width: 28px; height: 56px;
  border: 1px solid var(--line); background: var(--bg-panel);
  cursor: pointer; font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-dim); display: grid; place-items: center;
}
.sim-panel-toggle.left { left: 0; border-left: none; border-radius: 0 6px 6px 0; }
.sim-panel-toggle.right { right: 0; border-right: none; border-radius: 6px 0 0 6px; }
@media (min-width: 1180px) { .sim-panel-toggle { display: none; } }

.sim-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-panel);
}
.sim-toolbar .model-pill {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-family: var(--font-mono); font-size: 11.5px;
  background: var(--bg);
}
.sim-toolbar .live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px var(--green-soft); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.transcript {
  flex: 1; overflow-y: auto;
  padding: 20px 40px;
  background: var(--bg);
}
.turn {
  margin-bottom: 18px; display: grid;
  grid-template-columns: 68px 1fr;
  gap: 14px;
  position: relative;
}
.turn[data-selected="true"] .bubble {
  box-shadow: 0 0 0 2px var(--accent);
}
.turn-role {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute); padding-top: 10px;
  text-align: right;
}
.turn-role b { color: var(--ink-dim); display: block; font-weight: 500; }
.turn-idx { color: var(--line-strong); margin-right: 4px; }

.bubble {
  padding: 10px 14px; border-radius: var(--r-lg);
  background: var(--bg-panel); border: 1px solid var(--line);
  max-width: 640px;
  cursor: pointer;
  position: relative;
}
.bubble[data-role="user"] {
  background: var(--bg-sunken);
}
.bubble[data-role="assistant"] { background: var(--bg-panel); }
.bubble[data-role="tool"] {
  background: var(--bg);
  font-family: var(--font-mono); font-size: 12px;
  padding: 0; overflow: hidden;
  max-width: 720px;
}
.bubble-tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px dashed var(--line);
  background: var(--bg-sunken);
}
.bubble-tool-head .tname {
  color: var(--accent-ink); font-weight: 500;
}
.bubble-tool-body {
  padding: 10px 12px; font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.55;
  white-space: pre-wrap;
}
.bubble-tool-body .ret { color: var(--ink); }
.bubble-tool-body .key { color: var(--ink-mute); }

.turn-score {
  position: absolute; right: -44px; top: 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.score-btn {
  width: 32px; height: 24px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--bg-panel);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  cursor: pointer; color: var(--ink-dim);
  display: grid; place-items: center;
}
.score-btn:hover { background: var(--bg-hover); color: var(--ink); }
.score-btn[data-v="2"][data-active="true"] { background: var(--green); color: white; border-color: var(--green); }
.score-btn[data-v="1"][data-active="true"] { background: var(--amber); color: white; border-color: var(--amber); }
.score-btn[data-v="0"][data-active="true"] { background: var(--red); color: white; border-color: var(--red); }

.composer {
  padding: 12px 24px; border-top: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex; flex-direction: column; gap: 8px;
}
.composer-row {
  display: flex; gap: 8px; align-items: flex-end;
}
.composer-input {
  flex: 1; padding: 9px 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg);
  font: inherit; resize: none; min-height: 38px; max-height: 120px;
  outline: none;
}
.composer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-persona {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--ink-dim);
}
.composer-persona .persona-chip {
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-weight: 500;
}

/* ----------- Annotator right panel ----------- */
.annot-group {
  margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg);
}
.annot-group-head {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-dim);
}
.annot-group-body { padding: 10px 12px; }
.score-row {
  display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 8px;
  padding: 4px 0;
}
.score-row-label { font-size: 12.5px; }
.score-row-label span { color: var(--ink-mute); font-size: 11px; }
.score-pips {
  display: flex; gap: 2px;
}
.pip {
  width: 18px; height: 6px; border-radius: 2px;
  background: var(--bg-sunken); border: 1px solid var(--line);
  cursor: pointer;
}
.pip[data-filled="true"] { background: var(--accent); border-color: var(--accent); }

.overall {
  display: flex; align-items: baseline; gap: 6px;
  padding: 12px; margin-bottom: 14px;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.overall-score { font-size: 28px; font-weight: 600; font-family: var(--font-mono); color: var(--accent-ink); letter-spacing: -0.02em; }
.overall-max { font-size: 14px; color: var(--ink-mute); font-family: var(--font-mono); }
.overall-label { margin-left: auto; text-align: right; font-size: 11.5px; color: var(--ink-dim); }

.final-reward-breakdown {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono); font-size: 11.5px;
  display: flex; flex-direction: column; gap: 4px;
}
.final-reward-row {
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 8px; align-items: baseline;
  color: var(--ink-dim);
}
.final-reward-row .frr-label { color: var(--ink-dim); }
.final-reward-row .frr-score { color: var(--ink); font-weight: 600; text-align: right; }
.final-reward-row .frr-weight { color: var(--ink-mute); font-size: 10.5px; min-width: 54px; text-align: right; }
.final-reward-formula { color: var(--ink-mute); font-size: 10.5px; margin-top: 4px; }
.final-reward-secondary {
  margin-top: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-mute);
  display: flex; justify-content: space-between; gap: 8px;
}

/* ----------- Login ----------- */
.login-wrap {
  min-height: 100vh; background: var(--bg);
  display: grid; grid-template-columns: 1fr 1.1fr;
}
.login-left {
  padding: 48px 56px; display: flex; flex-direction: column;
  background: var(--bg-panel); border-right: 1px solid var(--line);
  justify-content: space-between;
}
.login-h {
  display: flex; align-items: center; gap: 10px;
}
.login-h .brand-name { font-size: 15px; }
.login-hero { max-width: 460px; margin-top: 80px; }
.login-hero .eyebrow {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--accent-ink); letter-spacing: 0.08em; text-transform: uppercase;
}
.login-hero h1 {
  font-family: var(--font-serif); font-weight: 400;
  font-size: 46px; line-height: 1.05; letter-spacing: -0.01em;
  margin: 14px 0 18px;
}
.login-hero p {
  font-size: 14.5px; line-height: 1.55; color: var(--ink-dim);
  margin: 0; max-width: 440px;
}
.login-foot { font-size: 11.5px; color: var(--ink-mute); display: flex; gap: 20px; font-family: var(--font-mono); }

.login-right {
  padding: 48px 64px;
  display: flex; flex-direction: column; justify-content: center;
  position: relative;
}
.login-card {
  max-width: 360px; width: 100%; margin: 0 auto;
}
.login-card h2 {
  font-size: 20px; margin: 0 0 6px;
}
.login-card p.sub { margin: 0 0 24px; color: var(--ink-dim); font-size: 13px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 11.5px; color: var(--ink-dim); font-family: var(--font-mono); margin-bottom: 5px; }
.form-field input {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-sm);
  font: inherit; outline: none;
}
.form-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-opts {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--ink-dim); margin: -4px 0 14px;
}
.login-opts label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.login-opts a { color: var(--accent-ink); text-decoration: none; }
.btn-login {
  width: 100%; padding: 10px 12px;
  background: var(--ink); color: var(--bg); border: none;
  border-radius: var(--r-sm); font: inherit; font-weight: 500;
  cursor: pointer;
}
.btn-login:hover { background: oklch(32% 0.01 80); }
.login-alt {
  margin-top: 14px;
  display: grid; gap: 8px;
}
.btn-sso {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); background: var(--bg-panel);
  border-radius: var(--r-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; font-weight: 500;
}
.btn-sso:hover { background: var(--bg-hover); }

.login-bg-stripes {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  opacity: 0.35;
}
.login-bg-stripes svg { width: 100%; height: 100%; }

.credential-hint {
  margin-top: 22px; padding: 10px 12px;
  background: var(--accent-soft); color: var(--accent-ink);
  border-radius: var(--r-sm); font-size: 11.5px;
  font-family: var(--font-mono);
}

.nav-section-action {
  margin-left: auto;
  width: 18px; height: 18px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--bg); cursor: pointer; font-size: 13px;
  line-height: 1; color: var(--ink-dim);
}
.nav-section-action:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ----------- Cohorts page ----------- */
.cohorts { overflow-y: auto; height: 100%; padding: 24px 32px; background: var(--bg); }
.cohorts-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.cohorts-head h1 { margin: 4px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.cohorts-head p { margin: 0; color: var(--ink-dim); font-size: 13px; max-width: 620px; }
.cohorts-head code { font-family: var(--font-mono); font-size: 11.5px; background: var(--bg-sunken); padding: 1px 5px; border-radius: 3px; }
.cohorts-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 20px; }
.kpi { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--bg-panel); }
.kpi-l { font-size: 11px; color: var(--ink-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-v { font-size: 22px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; margin-top: 2px; }
.cohorts-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.cohorts-table { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-panel); overflow: hidden; }
.cohorts-table-head { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.cohorts-table-head h3 { margin: 0; font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.cohorts-table-grid { display: grid; grid-template-columns: 1.6fr 1.1fr 0.6fr 1.4fr 0.7fr 1fr; gap: 12px; padding: 10px 14px; align-items: center; }
.cohorts-thr { font-size: 11px; color: var(--ink-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.cohorts-row { border-bottom: 1px solid var(--line); cursor: pointer; font-size: 12.5px; }
.cohorts-row:last-child { border-bottom: none; }
.cohorts-row:hover { background: var(--bg-hover); }
.cohorts-row[data-active="true"] { background: var(--bg-sunken); position: relative; }
.cohorts-row[data-active="true"]::before { content:""; position:absolute; left:0; top:0; bottom:0; width:2px; background: var(--accent); }
.progress { display: flex; height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.progress-approved { background: var(--green); }
.progress-inprog { background: var(--accent); }
.progress-rejected { background: var(--red); }
.cohorts-health { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-panel); align-self: start; position: sticky; top: 0; }
.mini-stat { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; background: var(--bg); }
.mini-l { font-size: 10.5px; color: var(--ink-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.04em; }
.mini-v { font-size: 20px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; margin-top: 2px; }
.mini-s { font-size: 10.5px; color: var(--ink-mute); font-family: var(--font-mono); margin-top: 2px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 50px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.spark span { flex: 1; background: var(--accent); border-radius: 1px; min-height: 2px; opacity: 0.85; }
.finding-row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.finding-row:last-of-type { border-bottom: none; }
.assignee-row { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.assignee-row:last-of-type { border-bottom: none; }

/* ----------- Modal / upload ----------- */
.modal-backdrop { position: fixed; inset: 0; background: oklch(20% 0.01 80 / 0.35); backdrop-filter: blur(2px); z-index: 200; display: grid; place-items: center; padding: 40px; }
.modal { width: min(880px, 100%); max-height: 90vh; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: 0 20px 60px -10px oklch(20% 0.01 80 / 0.3); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--bg-panel); }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-stepper { display: flex; gap: 16px; margin-left: 8px; }
.modal-step { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-mute); font-family: var(--font-mono); }
.modal-step-n { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; }
.modal-step[data-state="active"] { color: var(--ink); }
.modal-step[data-state="active"] .modal-step-n { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.modal-step[data-state="done"] .modal-step-n { background: var(--green); color: white; border-color: var(--green); }
.modal-body { flex: 1; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--bg-panel); }
.drop-zone { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--bg-sunken); cursor: pointer; }
.drop-zone[data-drag="true"] { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone code { font-family: var(--font-mono); background: var(--bg); padding: 1px 5px; border-radius: 3px; }
.upload-tip { padding: 10px 12px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 11.5px; }
.upload-tip b { font-weight: 600; font-size: 12px; }
.upload-tip span { color: var(--ink-dim); }
.preview { padding: 20px 22px; display: grid; gap: 18px; }
.preview-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.preview-section-label { font-size: 11px; color: var(--ink-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.distro { display: grid; gap: 5px; }
.distro-row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.distro-bar { height: 6px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.distro-bar span { display: block; height: 100%; background: var(--accent); }
.issue-row { display: grid; grid-template-columns: 50px 80px 1fr; gap: 8px; padding: 6px 12px; border-bottom: 1px dashed var(--line); font-size: 12px; align-items: center; }
.issue-row:last-child { border-bottom: none; }
.issue-row code { font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim); }
.sample-json { margin: 0; background: var(--bg-sunken); padding: 12px; border-radius: 6px; font-family: var(--font-mono); font-size: 11px; line-height: 1.55; color: var(--ink-dim); max-height: 220px; overflow: auto; }

/* ----------- Docs page ----------- */
.docs { display: grid; grid-template-columns: minmax(0,1fr) 240px; height: 100%; background: var(--bg); overflow: hidden; }
.docs-scroll { overflow-y: auto; height: 100%; }
.docs-inner { max-width: 780px; margin: 0 auto; padding: 36px 40px 80px; }
.docs-hero { padding-bottom: 24px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.doc-section { padding: 22px 0 8px; border-bottom: 1px solid var(--line); }
.doc-section:last-of-type { border-bottom: none; }
.doc-section > h2 { font-family: var(--font-serif); font-size: 26px; font-weight: 400; letter-spacing: -0.01em; margin: 0 0 14px; color: var(--ink); }
.doc-section > h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; color: var(--ink); }
.doc-section p { font-size: 13.5px; line-height: 1.65; color: var(--ink-dim); margin: 0 0 12px; }
.doc-section p b, .doc-section li b { color: var(--ink); font-weight: 600; }
.doc-section code { font-family: var(--font-mono); font-size: 11.5px; background: var(--bg-sunken); padding: 1px 5px; border-radius: 3px; color: var(--ink); border: 1px solid var(--line); }
.doc-code {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
  background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; margin: 10px 0 14px; color: var(--ink);
  overflow-x: auto; white-space: pre;
}
.doc-callout {
  border-left: 2px solid var(--accent); background: var(--accent-soft);
  padding: 10px 14px; border-radius: 0 4px 4px 0; font-size: 12.5px; color: var(--ink);
  margin: 10px 0 14px; line-height: 1.6;
}
.doc-rule {
  display: flex; gap: 10px; font-size: 12.5px; color: var(--ink-dim);
  padding: 8px 12px; margin: 6px 0;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-panel);
  line-height: 1.55;
}
.doc-rule b { color: var(--ink); font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 10px 0 14px; }
.doc-table th, .doc-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-dim); }
.doc-table th { font-size: 10.5px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-mute); font-weight: 500; border-bottom: 1px solid var(--line-strong); background: var(--bg-sunken); }
.doc-table td code { font-size: 11.5px; }
.doc-table tr:last-child td { border-bottom: none; }
.docs-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-mute); font-family: var(--font-mono); }
.docs-foot a { text-decoration: none; }
.docs-toc { border-left: 1px solid var(--line); padding: 36px 18px 36px 12px; background: var(--bg-panel); overflow-y: auto; }
.toc-item { display: block; width: 100%; text-align: left; padding: 5px 10px; border: none; background: transparent; font: inherit; font-size: 12px; color: var(--ink-mute); border-radius: var(--r-sm); cursor: pointer; line-height: 1.4; }
.toc-item:hover { color: var(--ink); background: var(--bg-hover); }
.toc-item[data-active="true"] { color: var(--accent-ink); background: var(--accent-soft); font-weight: 500; }
.docs-toc-card { margin: 18px 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.docs-toc-card code { font-family: var(--font-mono); font-size: 10.5px; background: var(--bg-sunken); padding: 1px 4px; border-radius: 3px; }

/* ----------- Converter panel (Docs §11) ----------- */
.converter-panel {
  margin: 14px 0; padding: 14px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--bg-panel);
}
.converter-head { margin-bottom: 12px; }
.converter-head h3 { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--ink); }
.converter-sub { font-size: 12px; color: var(--ink-mute); line-height: 1.5; }
.converter-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.converter-row-block { display: block; }
.converter-label {
  font-size: 11px; color: var(--ink-mute); font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
  display: block; margin-bottom: 4px;
}
.converter-row .converter-label { margin-bottom: 0; min-width: 110px; }
.converter-select { max-width: 280px; }
.converter-warn-banner {
  background: var(--amber-soft); color: oklch(36% 0.13 75);
  border: 1px solid var(--amber); border-left-width: 2px;
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 12px;
  margin: 0 0 10px;
}
.converter-actions { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.converter-error {
  background: var(--red-soft); color: oklch(34% 0.15 25);
  border: 1px solid var(--red); border-left-width: 2px;
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 12.5px;
  margin: 6px 0 10px; line-height: 1.55;
}
.converter-error b { font-family: var(--font-mono); font-size: 11.5px; margin-right: 4px; }
.converter-error-hint { color: var(--ink-mute); font-size: 11.5px; margin-top: 2px; font-family: var(--font-mono); }
.converter-warnings {
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: 8px 12px; margin: 6px 0 10px; font-size: 12px; color: var(--ink-dim);
  background: var(--bg);
}
.converter-warnings-h {
  font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-mute); margin-bottom: 4px;
}
.converter-warnings ul { margin: 0; padding-left: 18px; line-height: 1.55; }
.converter-toast {
  font-size: 11.5px; color: var(--ink-mute); font-family: var(--font-mono);
  margin-left: 6px;
}
.converter-toast-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 6px 0 0;
  font-size: 12.5px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg);
}
.converter-toast-row b { color: var(--ink); font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; }
.converter-toast-row > span { flex: 1; }
.converter-toast-pending { color: var(--ink-mute); }
.converter-toast-ok {
  border-color: transparent; background: var(--accent-soft); color: var(--accent-ink);
}
.converter-toast-err {
  border-color: transparent; background: var(--red-soft); color: oklch(34% 0.15 25);
}
.converter-toast-x { padding: 2px 8px; font-size: 14px; line-height: 1; }

/* ----------- Tweaks panel ----------- */
.tweaks-panel {
  position: fixed; bottom: 18px; right: 18px;
  width: 280px; background: var(--bg-panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: 0 10px 40px -10px oklch(20% 0.01 80 / 0.25);
  padding: 14px 16px 16px;
  z-index: 100;
}
.tweaks-panel h4 {
  margin: 0 0 10px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim);
  display: flex; align-items: center; gap: 8px;
}
.tweak-row { margin-bottom: 12px; font-size: 12px; }
.tweak-row-label { display: block; margin-bottom: 4px; color: var(--ink-dim); font-family: var(--font-mono); font-size: 11px; }
.tweak-options { display: flex; gap: 4px; }
.tweak-opt {
  flex: 1; padding: 5px 8px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg);
  cursor: pointer; font-size: 11.5px; text-align: center;
}
.tweak-opt[data-active="true"] {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}

/* misc */
.kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-dim);
  padding: 1px 5px;
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 3px; background: var(--bg-panel);
}
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* queue bulk-assign bar (manager only; shown when selection > 0) */
.queue-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-panel, var(--bg));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--ink-dim);
}
.queue-bulk-bar b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }
::-webkit-scrollbar-track { background: transparent; }
