/* Plexus — systematic review & network meta-analysis workbench.
   Layout concept: navy application sidebar (the review workflow) + light slate workspace with white panels;
   data-dense, enterprise-grade components. One sans family (Inter) for UI and headings; mono for search strings and numbers. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eff1f5;
  --surface-hover: #f6f8fb;
  --fg: #0d1526;
  --fg-2: #3a4457;
  --muted: #687387;
  --subtle: #98a1b2;
  --border: #e5e8ee;
  --border-strong: #d3d8e1;
  --accent: #2457d6;
  --accent-hover: #1c47b8;
  --accent-fg: #ffffff;
  --accent-soft: #edf2fe;
  --accent-soft-fg: #1d49bd;
  --ring: rgba(36, 87, 214, 0.22);
  --link: #2457d6;
  --nav-bg: #0b1324;
  --nav-bg-2: #141e35;
  --nav-fg: #a9b4c7;
  --nav-fg-strong: #ffffff;
  --nav-muted: #5f6c85;
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-hover: rgba(255, 255, 255, 0.06);
  --nav-active: rgba(255, 255, 255, 0.08);
  --nav-accent: #7da2ff;
  --good: #0f7a55;
  --good-soft: #e5f5ee;
  --warn: #b25309;
  --warn-soft: #fdf3e5;
  --bad: #be2323;
  --bad-soft: #fdecec;
  --info: #2151cb;
  --info-soft: #ebf1fe;
  --overlay: rgba(10, 20, 40, 0.48);
  --shadow-xs: 0 1px 2px rgba(13, 21, 38, 0.04);
  --shadow-sm: 0 1px 3px rgba(13, 21, 38, 0.07);
  --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.12), 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.28);
  --hl-include: #d6f2e2;
  --hl-exclude: #fbdcda;
  --rob-low: #2e9d4b;
  --rob-some: #e2b10b;
  --rob-high: #c62f2f;
  --rob-ni: #8b95a3;
  --hero-from: #0b1931;
  --hero-to: #173a78;
  --hero-fg: #ffffff;
  --hero-muted: #b9c6df;
  --nav-line: rgba(255, 255, 255, 0.2);
  --nav-done: #4ade9b;
  --nav-done-bg: rgba(74, 222, 155, 0.15);
  --nav-hover-strong: rgba(255, 255, 255, 0.1);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-xl: 1.125rem;
  --fs-2xl: 1.5rem;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --rail-w: 244px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111e;
    --surface: #111a2a;
    --surface-2: #0e1624;
    --surface-3: #182338;
    --surface-hover: #152035;
    --fg: #e5eaf2;
    --fg-2: #c2ccdb;
    --muted: #8b99b1;
    --subtle: #65738c;
    --border: #1f2a3e;
    --border-strong: #2d3a52;
    --accent: #5b8def;
    --accent-hover: #7ba4f5;
    --accent-fg: #06142d;
    --accent-soft: #15254a;
    --accent-soft-fg: #a4c0ff;
    --ring: rgba(91, 141, 239, 0.35);
    --link: #86aaf6;
    --nav-bg: #060d1a;
    --nav-bg-2: #0e1b33;
    --nav-fg: #aab7cd;
    --nav-fg-strong: #ffffff;
    --nav-muted: #5f6f8c;
    --nav-border: rgba(255, 255, 255, 0.07);
    --nav-hover: rgba(255, 255, 255, 0.05);
    --nav-active: rgba(120, 160, 255, 0.14);
    --nav-accent: #7aa2ff;
    --good: #35c08c;
    --good-soft: #0f2a21;
    --warn: #f0a94b;
    --warn-soft: #33260f;
    --bad: #f2736a;
    --bad-soft: #3a1715;
    --info: #78a2f4;
    --info-soft: #13233f;
    --overlay: rgba(0, 0, 0, 0.62);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
    --hl-include: #1c4a2f;
    --hl-exclude: #5a221d;
    --rob-low: #3fb35f;
    --rob-some: #e8bf2a;
    --rob-high: #e5554f;
    --rob-ni: #7d8899;
    --hero-from: #060d1a;
    --hero-to: #122c5c;
    --hero-fg: #ffffff;
    --hero-muted: #a9b8d3;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a111e;
  --surface: #111a2a;
  --surface-2: #0e1624;
  --surface-3: #182338;
  --surface-hover: #152035;
  --fg: #e5eaf2;
  --fg-2: #c2ccdb;
  --muted: #8b99b1;
  --subtle: #65738c;
  --border: #1f2a3e;
  --border-strong: #2d3a52;
  --accent: #5b8def;
  --accent-hover: #7ba4f5;
  --accent-fg: #06142d;
  --accent-soft: #15254a;
  --accent-soft-fg: #a4c0ff;
  --ring: rgba(91, 141, 239, 0.35);
  --link: #86aaf6;
  --nav-bg: #060d1a;
  --nav-bg-2: #0e1b33;
  --nav-fg: #aab7cd;
  --nav-fg-strong: #ffffff;
  --nav-muted: #5f6f8c;
  --nav-border: rgba(255, 255, 255, 0.07);
  --nav-hover: rgba(255, 255, 255, 0.05);
  --nav-active: rgba(120, 160, 255, 0.14);
  --nav-accent: #7aa2ff;
  --good: #35c08c;
  --good-soft: #0f2a21;
  --warn: #f0a94b;
  --warn-soft: #33260f;
  --bad: #f2736a;
  --bad-soft: #3a1715;
  --info: #78a2f4;
  --info-soft: #13233f;
  --overlay: rgba(0, 0, 0, 0.62);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
  --hl-include: #1c4a2f;
  --hl-exclude: #5a221d;
  --rob-low: #3fb35f;
  --rob-some: #e8bf2a;
  --rob-high: #e5554f;
  --rob-ni: #7d8899;
  --hero-from: #060d1a;
  --hero-to: #122c5c;
  --hero-fg: #ffffff;
  --hero-muted: #a9b8d3;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 50;
  background: var(--surface);
}
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; text-wrap: balance; color: var(--fg); }
h1 { font-family: var(--font-title); font-weight: 650; font-size: 1.5rem; letter-spacing: -0.022em; }
h2 { font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.012em; }
h3 { font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.005em; }
h4 { font-size: 0.875rem; font-weight: 650; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.ico-sm { width: 15px; height: 15px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "rail top" "rail main";
  height: 100%;
}

/* sidebar: the project and its 11 steps as a numbered stepper */
.rail {
  grid-area: rail;
  background: var(--nav-bg);
  color: var(--nav-fg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding-left: 10px;
  padding-right: 10px;
  padding-block: 0 env(safe-area-inset-bottom, 0px);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  border-right: 1px solid var(--nav-border);
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 8px; flex: none; color: var(--nav-fg-strong); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-name { font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; color: var(--nav-fg-strong); }
.rail-project { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--nav-bg-2); color: var(--nav-fg-strong); font-size: var(--fs-sm); font-weight: 550; }
.rail-project:hover { text-decoration: none; background: var(--nav-hover-strong); }
.rail-project .rp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-project svg { width: 15px; height: 15px; color: var(--nav-muted); flex: none; }
.rail-nav { display: flex; flex-direction: column; gap: 1px; }
.rail-label { padding: 14px 10px 6px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--nav-muted); }
.rail-link {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--nav-fg);
  font-size: var(--fs-md);
  font-weight: 500;
}
.rail-link:hover { background: var(--nav-hover); color: var(--nav-fg-strong); text-decoration: none; }
.rail-link.active { background: var(--nav-active); color: var(--nav-fg-strong); }
.rail-link .step { display: grid; place-items: center; color: var(--nav-muted); }
.rail-link .step svg { width: 17px; height: 17px; }
.rail-link.active .step, .rail-link:hover .step { color: var(--nav-fg-strong); }
.rail-link .step-no {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--nav-fg);
  box-shadow: inset 0 0 0 1.5px var(--nav-line);
}
.rail-link.done .step-no { background: var(--nav-done-bg); color: var(--nav-done); box-shadow: none; }
.rail-link.done .step-no svg { width: 12px; height: 12px; stroke-width: 3; }
.rail-link.active .step-no { background: var(--nav-accent); color: var(--nav-bg); box-shadow: none; }
.rail-link .count { font-size: 0.6875rem; color: var(--nav-muted); font-variant-numeric: tabular-nums; }
.rail-foot { margin-top: auto; padding: 10px 0 12px; }
.rail-disabled .rail-link:not(.always) { opacity: 0.35; pointer-events: none; }

/* top bar */
.topbar {
  grid-area: top;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: max(32px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-md); color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--fg); text-decoration: none; }
.crumbs .sep { color: var(--border-strong); }
.crumbs .current { color: var(--fg); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .crumb-project { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.topbar .spacer { flex: 1; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; margin-right: 8px; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.save-state:empty { display: none; }
.save-state.dirty { color: var(--warn); }
.save-state.dirty::before { background: var(--warn); }
.avatar-btn { border: 0; background: none; padding: 2px; margin-left: 2px; border-radius: 50%; cursor: pointer; }
.avatar-btn:hover .avatar, .avatar-btn:focus-visible .avatar { box-shadow: 0 0 0 3px var(--ring); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-fg); font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.02em; }
.topbar .menu-toggle { display: none; }

.main {
  grid-area: main;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-left: max(32px, env(safe-area-inset-left, 0px));
  padding-right: max(32px, env(safe-area-inset-right, 0px));
  padding-block: 28px 0;
}
.view { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; padding-bottom: 64px; }
.view.wide { max-width: 1440px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.page-head p.lede { color: var(--muted); margin-top: 4px; max-width: 70ch; font-size: var(--fs-md); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* previous and next step, at the foot of every step page */
.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--border); }
.step-nav .pos { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.step-nav .btn-ghost { color: var(--fg-2); }
@media (max-width: 600px) { .step-nav .pos { display: none; } }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.panel-head h3, .panel-head h4 { min-width: 0; font-size: 0.9375rem; font-weight: 600; }
.panel-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-body.tight { padding: 12px 0 0; gap: 0; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.subtle { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.split-even { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.split.split-list { grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); }
.split.split-list-wide { grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); }
.split.split-menu { grid-template-columns: 240px minmax(0, 1fr); }
.split.split-halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.sticky-col { position: sticky; top: 0; }

/* ---------- KPI tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.stat .l { font-size: var(--fs-sm); color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 8px; }
.stat .l .kpi-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.stat .l .kpi-ico svg { width: 15px; height: 15px; }
.stat .v { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--fg); line-height: 1.2; margin-top: 4px; }
.stat .s { font-size: var(--fs-xs); color: var(--muted); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-weight: 550;
  font-size: var(--fs-md);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { background: var(--surface-hover); border-color: var(--subtle); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 11px; font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-xs { height: 24px; padding: 0 8px; font-size: var(--fs-xs); }
.btn-lg { height: 42px; padding: 0 18px; font-size: 0.9375rem; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn .k { font-family: var(--font-mono); font-size: 0.6875rem; opacity: 0.7; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; line-height: 1.45; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; box-shadow: none; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.on { background: var(--accent-soft); color: var(--accent-soft-fg); border-color: var(--accent); z-index: 1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 550; color: var(--fg-2); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 11px;
  min-width: 0;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input, .select { height: 36px; }
.select { padding-right: 28px; }
.input.sm, .select.sm { height: 32px; padding: 4px 9px; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.textarea { min-height: 60px; resize: vertical; line-height: 1.5; field-sizing: content; max-height: 320px; }
.textarea.mono, .input.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.input.invalid { border-color: var(--bad); background: var(--bad-soft); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input[disabled], .select[disabled] { background: var(--surface-2); color: var(--subtle); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-md); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.inline-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields .field { flex: 1 1 210px; }

.search-box { position: relative; flex: 1 1 220px; min-width: 160px; }
.search-box .input { padding-left: 32px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 12px;
  font: inherit;
  font-weight: 550;
  font-size: var(--fs-md);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count {
  font-size: 0.6875rem;
  margin-left: 6px;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 1px 7px;
  font-weight: 600;
}
.tab.active .count { background: var(--accent-soft); color: var(--accent-soft-fg); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th {
  font-weight: 550;
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.selected td { background: var(--accent-soft); }
.table .actions-cell { white-space: nowrap; text-align: right; }
.table-compact th, .table-compact td { padding: 6px 10px; }
.table td > .input.sm { min-width: 150px; }
.table td > .select.sm { min-width: 160px; }
.table td > .input.sm.num { min-width: 80px; }

/* league table */
.league { border-collapse: separate; border-spacing: 0; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.league td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 7px 9px; text-align: center; min-width: 100px; line-height: 1.4; }
.league td.diag { background: var(--accent-soft); font-weight: 700; color: var(--accent-soft-fg); }
.league td.sig { font-weight: 700; color: var(--fg); }
.league td.nma { background: var(--surface); }
.league td.dir { background: var(--surface-2); color: var(--fg-2); }
.league td.empty { color: var(--subtle); }

/* ---------- pills, badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-3);
  color: var(--fg-2);
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-soft-fg); }
.pill.outline { background: transparent; border-color: var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--subtle); }
.dot.good { background: var(--good); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--info); }
.rob-chip { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 0.75rem; flex: none; }
.rob-low { background: var(--rob-low); } .rob-some { background: var(--rob-some); color: #2b2100; } .rob-high { background: var(--rob-high); } .rob-ni { background: var(--rob-ni); }

/* ---------- callouts ---------- */
.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}
.callout.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.callout.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.callout.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 22%, transparent); }
.callout strong { color: var(--fg); }
.callout ul { margin: 4px 0 0; padding-left: 18px; }
details.callout > summary { cursor: pointer; }

/* ---------- empty state ---------- */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: var(--surface);
}
.empty h3 { color: var(--fg); font-size: 1rem; }
.empty p { max-width: 58ch; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 30px 16px;
  text-align: center;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone svg { color: var(--accent); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-weight: 650; color: var(--fg); font-size: 0.9375rem; }

/* ---------- code / strategy ---------- */
.code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  max-height: 440px;
  overflow: auto;
  color: var(--fg);
}
.code.nowrap { white-space: pre; word-break: normal; }
.term-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 160px auto; gap: 8px; align-items: center; }
.concept { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs); }
.concept-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.concept-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; container-type: inline-size; }
/* In a narrow concept block the term text gets its own line, so it is never squeezed. */
@container (max-width: 560px) {
  .term-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .term-row > :first-child { grid-column: 1 / -1; }
}
.and-sep {
  align-self: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent-soft-fg);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 12px;
  letter-spacing: 0.1em;
}

/* ---------- screening ---------- */
.screen-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.record-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.record-card .rc-body { padding: 24px 28px; display: flex; flex-direction: column; gap: 12px; }
.record-card .rc-title { font-family: var(--font-title); font-size: 1.25rem; font-weight: 680; line-height: 1.35; letter-spacing: -0.015em; max-width: 80ch; }
.record-card .rc-meta { font-size: var(--fs-sm); color: var(--muted); }
.record-card .rc-abstract { font-size: 0.9375rem; line-height: 1.72; color: var(--fg); max-width: 84ch; white-space: pre-line; }
.record-card .rc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  align-items: center;
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -8px 16px -12px rgba(13, 21, 38, 0.18);
}
.decide { min-width: 120px; height: 40px; font-size: var(--fs-md); }
.decide.include { background: var(--good); border-color: var(--good); color: #fff; }
.decide.exclude { background: var(--bad); border-color: var(--bad); color: #fff; }
.decide.maybe { background: var(--surface); border-color: var(--warn); color: var(--warn); }
.decide.include:hover, .decide.exclude:hover { filter: brightness(1.08); background: var(--good); }
.decide.exclude:hover { background: var(--bad); }
.decide.maybe:hover { background: var(--warn-soft); }
mark.hl-inc { background: var(--hl-include); color: inherit; border-radius: 3px; padding: 0 2px; }
mark.hl-exc { background: var(--hl-exclude); color: inherit; border-radius: 3px; padding: 0 2px; }
.vote { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }
.kbd-hint { font-size: var(--fs-xs); color: var(--muted); }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); font-size: 0.7rem; font-family: var(--font-mono); }

/* ---------- list rows ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-width: 0;
  position: relative;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-hover); }
.list-item.active { background: var(--accent-soft); }
.list-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- figures ---------- */
.figure { background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; overflow-x: auto; }
.figure svg { display: block; max-width: none; height: auto; }
.figure.fit svg { max-width: 100%; margin: 0 auto; }
.figure-toolbar { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- dedup compare ---------- */
.compare { display: grid; grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1fr); font-size: var(--fs-sm); }
.compare > div { padding: 8px 12px; border-bottom: 1px solid var(--border); min-width: 0; overflow-wrap: anywhere; }
.compare .k { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.compare .diff { background: var(--warn-soft); }
.compare .head { font-weight: 650; background: var(--surface-2); }

/* ---------- RoB form ---------- */
.q-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.q-row:last-child { border-bottom: 0; }
.q-id { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.answer-group { display: inline-flex; flex-wrap: wrap; gap: 0; box-shadow: var(--shadow-xs); border-radius: var(--radius-sm); }
.answer-group button {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg-2);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 650;
  height: 28px;
  min-width: 38px;
  padding: 0 8px;
  margin-left: -1px;
  cursor: pointer;
}
.answer-group button:hover { background: var(--surface-hover); }
.answer-group button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.answer-group button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.answer-group button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); position: relative; z-index: 1; }
.domain-judge { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- extraction grid ---------- */
.xgrid { border-collapse: collapse; font-size: var(--fs-sm); }
.xgrid th, .xgrid td { border-bottom: 1px solid var(--border); padding: 6px 10px; }
.xgrid th { background: var(--surface-2); font-weight: 650; text-align: left; white-space: nowrap; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.xgrid td .input { height: 32px; padding: 4px 8px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: min(580px, 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.modal.wide { width: min(1000px, 100%); }
.modal.xwide { width: min(1260px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h3 { font-size: 1rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* ---------- toast ---------- */
.toasts {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #f1f5f9;
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 500;
  max-width: 440px;
  border-left: 3px solid var(--nav-accent);
  animation: toast-in 0.18s ease-out;
}
.toast.bad { border-left-color: #f2736a; }
.toast.good { border-left-color: #35c08c; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* ---------- home ---------- */
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
  gap: 32px;
  align-items: center;
  padding: 36px 32px 36px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.home-hero h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -0.028em; max-width: 14em; }
.home-hero .sub { color: var(--muted); font-size: 1rem; line-height: 1.55; margin-top: 12px; max-width: 44ch; }
.home-actions { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; margin-top: 24px; }
.home-link { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 2px; font: inherit; font-weight: 550; color: var(--accent); cursor: pointer; }
.home-link:hover { text-decoration: underline; }
.home-link svg { width: 15px; height: 15px; }
.home-facts { display: flex; gap: 8px 18px; flex-wrap: wrap; margin: 22px 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--muted); }
.home-facts li { display: inline-flex; align-items: center; gap: 6px; }
.home-facts svg { width: 15px; height: 15px; color: var(--good); }
@media (max-width: 1080px) { .home-hero { grid-template-columns: minmax(0, 1fr); padding: 28px 24px; } }
.preview-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 12px;
  box-shadow: 0 12px 32px -16px rgba(13, 21, 38, 0.28);
  overflow: hidden;
  border: 1px solid #e5e8ee;
}
.preview-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; font-size: 0.75rem; color: #475569; font-weight: 600; }
.preview-head .dots { display: inline-flex; gap: 5px; margin-right: 6px; }
.preview-head .dots i { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.preview-body { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 0; align-items: center; }
.preview-body > div { padding: 10px; min-width: 0; }
.preview-body > div + div { border-left: 1px solid #e2e8f0; }
.preview-body svg { width: 100%; height: auto; display: block; }
.pv-table { padding: 6px 6px 4px; }
.pv-title { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.07em; color: #64748b; font-weight: 700; margin: 2px 2px 8px; }
.pv-table table { width: 100%; border-collapse: collapse; font-size: 0.75rem; color: #0f172a; font-variant-numeric: tabular-nums; }
.pv-table th { text-align: left; font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.06em; color: #64748b; font-weight: 700; padding: 4px 4px 6px; border-bottom: 1px solid #e2e8f0; }
.pv-table th.num, .pv-table td.num { text-align: right; }
.pv-table td { padding: 7px 3px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.pv-table td:first-child { font-weight: 600; white-space: normal; }
.pv-muted { color: #94a3b8; }
.pv-bar { display: inline-block; width: 32px; height: 6px; border-radius: 999px; background: #e2e8f0; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.pv-bar i { display: block; height: 100%; background: linear-gradient(90deg, #3d7bff, #1b3fa6); border-radius: 999px; }
.pv-ps { font-weight: 600; }
.pv-note { font-size: 0.625rem; color: #94a3b8; margin: 8px 2px 0; }
.preview-foot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #e2e8f0; }
.preview-foot div { padding: 10px 14px; font-size: 0.6875rem; color: #64748b; }
.preview-foot div + div { border-left: 1px solid #e2e8f0; }
.preview-foot strong { display: block; color: #0f172a; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head p { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
/* projects list (home) */
.project-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow-sm); }
.project-card .pc-name { font-weight: 650; font-size: 0.9375rem; color: var(--fg); }
.project-card .pc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.project-card .pc-meta span { display: inline-flex; align-items: center; gap: 5px; }
.project-card .pc-meta svg { width: 13px; height: 13px; }
.pipeline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pipeline span { font-size: var(--fs-xs); font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--fg-2); }

/* ---------- overview ---------- */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.workflow { display: flex; flex-direction: column; }
.wf-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  position: relative;
}
.wf-item:last-child { border-bottom: 0; }
.wf-item:hover { background: var(--surface-hover); text-decoration: none; }
.wf-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.wf-icon svg { width: 17px; height: 17px; }
.wf-item.done .wf-icon { background: var(--good-soft); color: var(--good); }
.wf-item.current .wf-icon { background: var(--accent); color: var(--accent-fg); }
.wf-item .wf-name { font-weight: 650; color: var(--fg); display: flex; gap: 8px; align-items: center; }
.wf-item .wf-num { font-size: var(--fs-xs); color: var(--subtle); font-weight: 600; font-variant-numeric: tabular-nums; }
.wf-item .wf-line { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.wf-item .progress { margin-top: 8px; max-width: 320px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; color: inherit; }
.stage:hover { border-color: var(--accent); text-decoration: none; }
.stage .st-head { display: flex; align-items: center; gap: 8px; }
.stage .st-num { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); }
.stage .st-name { font-weight: 650; }
.stage .st-line { font-size: var(--fs-sm); color: var(--fg-2); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: var(--fs-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 550; }
.divider-label { display: flex; align-items: center; gap: 10px; font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 650; }
.divider-label::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 5px 7px; background: var(--surface); min-height: 38px; box-shadow: var(--shadow-xs); }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.tag-input input { border: 0; outline: 0; flex: 1 1 120px; font: inherit; background: transparent; color: var(--fg); min-width: 80px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-3); border-radius: 5px; padding: 2px 7px; font-size: var(--fs-sm); font-weight: 500; }
.tag button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 0.95rem; line-height: 1; }
.tag.inc { background: var(--hl-include); }
.tag.exc { background: var(--hl-exclude); }
.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px 36px; max-width: 920px; line-height: 1.75; box-shadow: var(--shadow-xs); }
.report-doc h3 { margin: 20px 0 6px; font-size: 1.0625rem; }
.report-doc p { margin: 0 0 12px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }
.details summary { cursor: pointer; font-weight: 600; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); padding: 3px 9px; border-radius: 999px; background: var(--info-soft); color: var(--info); font-weight: 650; }
.quote { border-left: 3px solid var(--info); padding: 5px 11px; font-size: var(--fs-sm); color: var(--fg-2); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen-layout { grid-template-columns: minmax(0, 1fr); }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 86vw);
    z-index: 60;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
  }
  .app.rail-open .rail { transform: none; }
  .rail-scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; }
  .topbar .menu-toggle { display: inline-flex; }
  .split, .split.split-list, .split.split-list-wide, .split.split-menu, .split.split-halves, .split-even, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .split .sticky-col .list { max-height: 260px !important; }
  .sticky-col { position: static; }
  .term-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .term-row > :first-child { grid-column: 1 / -1; }
  .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 18px 0; }
  .view { padding-bottom: 48px; }
  .topbar { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .crumbs .crumb-home, .crumbs .sep-first { display: none; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 1.3rem; }
  .record-card .rc-body { padding: 18px; }
  .record-card .rc-actions { padding: 12px 18px; }
  .decide { min-width: 0; flex: 1 1 30%; }
  .compare { grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1fr); }
  .q-row { grid-template-columns: 40px minmax(0, 1fr); }
  .q-row .answer-group { grid-column: 1 / -1; }
  .save-state, .crumbs .crumb-project, .crumbs .sep { display: none; }
  .preview-body { grid-template-columns: minmax(0, 1fr); }
  .preview-body > div + div { border-left: 0; border-top: 1px solid #e2e8f0; }
}

/* ---------- Guided tour (js/core/tour.js): pop-up boxes that point at controls ---------- */
.tour-root { position: fixed; inset: 0; z-index: 85; pointer-events: none; }
.tour-root [hidden] { display: none !important; }
.tour-veil { position: fixed; inset: 0; background: rgba(10, 20, 40, 0.38); }
.tour-spot {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--ring);
  transition: left 0.18s ease, top 0.18s ease, width 0.18s ease, height 0.18s ease;
}
.tour-spot.dim { box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px var(--ring), 0 0 0 200vmax rgba(10, 20, 40, 0.32); }
.tour-pop {
  position: fixed;
  width: min(372px, calc(100vw - 24px));
  pointer-events: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-md);
  line-height: 1.55;
  outline: none;
}
.tour-inner { position: relative; max-height: calc(100vh - 24px); overflow-y: auto; padding: 14px 16px 12px; border-radius: inherit; }
.tour-pop.centered { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); width: min(460px, calc(100vw - 24px)); }
.tour-pop.docked { left: 12px !important; right: 12px; top: auto !important; bottom: 12px; width: auto; }
.tour-pop.docked .tour-inner { max-height: 62vh; }
.tour-pop.centered.docked { transform: none; }
.tour-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transform: rotate(45deg);
  z-index: 1;
}
.tour-pop[data-side="right"] .tour-arrow { left: -7px; margin-top: -6px; border-top-color: transparent; border-right-color: transparent; }
.tour-pop[data-side="left"] .tour-arrow { left: auto; right: -7px; margin-top: -6px; border-bottom-color: transparent; border-left-color: transparent; }
.tour-pop[data-side="bottom"] .tour-arrow { top: -7px; margin-left: -6px; border-bottom-color: transparent; border-right-color: transparent; }
.tour-pop[data-side="top"] .tour-arrow { top: auto; bottom: -7px; margin-left: -6px; border-top-color: transparent; border-left-color: transparent; }
.tour-top { display: flex; align-items: center; gap: 2px; margin: -2px -6px 4px 0; }
.tour-kicker { flex: 1; min-width: 0; font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.tour-icon:hover { background: var(--surface-3); color: var(--fg); }
.tour-icon svg { width: 16px; height: 16px; }
.tour-pop h3 { font-size: 1.02rem; font-weight: 650; line-height: 1.35; margin: 0 0 6px; color: var(--fg); }
.tour-body { color: var(--fg-2); }
.tour-body p { margin: 0 0 8px; }
.tour-list { margin: 0 0 8px; padding-left: 18px; }
.tour-list li { margin: 2px 0; }
.tour-eg { font-style: italic; color: var(--muted); }
.tour-missing { margin: 0 0 8px; padding: 6px 10px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: var(--fs-sm); }
.tour-tasks:empty { display: none; }
.tour-tasks { margin: 4px 0 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.tour-sum { font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tour-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tour-checks li { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); color: var(--fg-2); }
.tour-checks li.done { color: var(--fg); }
.tour-checks em { color: var(--muted); font-style: normal; }
.tour-tick { flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); }
.tour-checks li.done .tour-tick { border-color: var(--good); background: var(--good); color: #ffffff; }
.tour-tick svg { width: 11px; height: 11px; stroke-width: 3; }
.tour-note { flex: none; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 1px; }
.tour-go { flex: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent); border-radius: var(--radius-sm); font: inherit; font-size: var(--fs-xs); font-weight: 600; padding: 1px 8px; cursor: pointer; }
.tour-go:hover { background: var(--accent-soft); border-color: var(--accent); }
.tour-hint { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--muted); }
.tour-dots { display: flex; gap: 5px; margin: 2px 0 10px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.tour-dots i.past { background: var(--accent-soft-fg); opacity: 0.5; }
.tour-dots i.on { width: 18px; border-radius: 3px; background: var(--accent); }
.tour-foot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); margin: 0 -16px; padding: 10px 16px 0; }
.tour-grow { flex: 1; min-width: 0; }
.tour-jump { height: 30px; font-size: var(--fs-sm); width: auto; max-width: 190px; padding-top: 0; padding-bottom: 0; }
.tour-pill {
  position: fixed;
  right: 18px;
  bottom: 18px;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--nav-bg);
  color: #ffffff;
  font: inherit;
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}
.tour-pill:hover { background: var(--nav-bg-2); }
.tour-pill svg { width: 16px; height: 16px; color: var(--nav-accent); }
.tour-pill strong { color: var(--nav-accent); font-weight: 650; }
.guide-btn svg { color: var(--accent); }
@media (max-width: 600px) { .guide-btn span { display: none; } }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
@media (max-width: 600px) { .section-head h2 { font-size: 1.0625rem; }
.project-card .pc-open { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 550; }
.project-card .pc-open svg { width: 14px; height: 14px; }
