/* CQA — Conversation Quality Analytics. Plain CSS, no external fonts or libraries.
   Theme tokens: light corporate (default — white cards, deep-green sidebar, green accents) and dark (optional). */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f4;
  --bg-elev: #f9fbfa;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #edf1ef;
  --hover: #f1f5f3;
  --border: #e1e7e4;
  --border-strong: #cdd7d2;
  --text: #15221d;
  --text-2: #3a4a44;
  --muted: #5b6a64;
  --faint: #6b7a74;

  --accent: #1a7f3c;
  --accent-2: #2fa84f;
  --accent-fill: #1a7f3c;
  --accent-fill-hover: #156a32;
  --accent-ink: #ffffff;
  --accent-soft: rgba(26, 127, 60, 0.08);
  --accent-line: rgba(26, 127, 60, 0.34);

  --yes: #1a7f3c;
  --yes-ink: #157034;
  --yes-soft: rgba(47, 168, 79, 0.12);
  --no: #c4323d;
  --no-soft: rgba(196, 50, 61, 0.08);
  --na: #6a7973;
  --na-soft: rgba(106, 121, 115, 0.11);
  --warn: #a86200;
  --warn-ink: #965700;
  --warn-soft: rgba(229, 160, 40, 0.15);
  --info: #1f62b3;
  --info-soft: rgba(31, 98, 179, 0.08);
  --crit: #c4323d;
  --crit-soft: rgba(196, 50, 61, 0.07);

  --header-bg: #0f3a2e;
  --header-solid: #0f3a2e;
  --header-text: #ffffff;
  --header-muted: #b7d0c5;
  --header-border: #0b2d23;
  --nav-accent: #4cc771;

  --bubble-client: #f2f5f3;
  --bubble-operator: #eaf5ee;
  --bubble-operator-border: rgba(26, 127, 60, 0.24);
  --turn-active: #fff3d1;
  --turn-active-line: #e0a32e;
  --wave-client: #4a7fc1;
  --wave-operator: #2fa84f;
  --wave-bot: #b5c0bb;

  --shadow-1: 0 1px 2px rgba(16, 40, 30, 0.05), 0 1px 1px rgba(16, 40, 30, 0.03);
  --shadow-2: 0 1px 2px rgba(16, 40, 30, 0.04), 0 10px 28px -8px rgba(16, 40, 30, 0.16);
  --shadow-3: 0 28px 70px -14px rgba(10, 30, 22, 0.32), 0 4px 14px rgba(10, 30, 22, 0.08);
  --scrim: rgba(10, 25, 20, 0.38);
  --sidebar-bg: linear-gradient(180deg, #0f3a2e 0%, #0d3429 55%, #0b2e24 100%);
  --glow-accent: rgba(47, 168, 79, 0.35);
  --row-flash: rgba(47, 168, 79, 0.16);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f0e;
  --bg-elev: #0f1413;
  --surface: #131a18;
  --surface-2: #18211e;
  --surface-3: #1e2a26;
  --hover: #1c2723;
  --border: #24302b;
  --border-strong: #33423b;
  --text: #e6eeea;
  --text-2: #b4c2bc;
  --muted: #84948d;
  --faint: #5b6a64;

  --accent: #4cc771;
  --accent-2: #2fa84f;
  --accent-fill: #2f9a4f;
  --accent-fill-hover: #37ad5a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(76, 199, 113, 0.10);
  --accent-line: rgba(76, 199, 113, 0.36);

  --yes: #4cc771;
  --yes-ink: #4cc771;
  --yes-soft: rgba(76, 199, 113, 0.13);
  --no: #f06a74;
  --no-soft: rgba(240, 106, 116, 0.13);
  --na: #93a29c;
  --na-soft: rgba(147, 162, 156, 0.14);
  --warn: #f0b04d;
  --warn-ink: #f0b04d;
  --warn-soft: rgba(240, 176, 77, 0.13);
  --info: #74b3f2;
  --info-soft: rgba(116, 179, 242, 0.12);
  --crit: #f0586a;
  --crit-soft: rgba(240, 88, 106, 0.12);

  --header-bg: #0c1d17;
  --header-solid: #0c1d17;
  --header-text: #e6eeea;
  --header-muted: #8fa89d;
  --header-border: #16291f;
  --nav-accent: #4cc771;

  --bubble-client: #18211e;
  --bubble-operator: #14281f;
  --bubble-operator-border: rgba(76, 199, 113, 0.24);
  --turn-active: rgba(240, 176, 77, 0.16);
  --turn-active-line: #f0b04d;
  --wave-client: #74a6e0;
  --wave-operator: #4cc771;
  --wave-bot: #4a5752;

  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 30px 80px -10px rgba(0, 0, 0, 0.7), 0 4px 14px rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 0, 0, 0.55);
  --sidebar-bg: linear-gradient(180deg, #0d2019 0%, #0b1a15 100%);
  --glow-accent: rgba(76, 199, 113, 0.35);
  --row-flash: rgba(76, 199, 113, 0.16);
}

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --r-sm: 6px;
  --r: 9px;
  --r-lg: 14px;
  --r-xl: 18px;
  --header-h: 52px;
  --gap: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-spring: cubic-bezier(0.22, 1.18, 0.36, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 320ms;
  --dur-4: 520ms;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
::selection { background: var(--accent-line); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.strong { font-weight: 600; }
.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); white-space: nowrap; border: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.hidden { display: none !important; }
.skip-link { position: absolute; left: -999px; top: 4px; z-index: 100; background: var(--accent-fill); color: var(--accent-ink); padding: 6px 10px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── Header ───────── */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid var(--header-border);
  backdrop-filter: saturate(1.4) blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.brand-sub { font-size: 10.5px; color: var(--header-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.nav { display: flex; align-items: stretch; height: 100%; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 0 11px; color: var(--header-muted); font-weight: 500; white-space: nowrap;
  text-decoration: none; transition: color 0.15s var(--ease);
}
.nav a:hover { color: var(--header-text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--header-text); }
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px;
  background: var(--nav-accent); border-radius: 2px 2px 0 0;
}
.nav .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--nav-accent); color: #08261b; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.header-tools .seg { --seg-bg: rgba(255, 255, 255, 0.06); --seg-border: rgba(255, 255, 255, 0.1); }
.header-tools .seg button { color: var(--header-muted); }
.header-tools .seg button[aria-pressed="true"] { background: #ffffff; color: #0f3a2e; }
.header-tools select.compact { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); color: var(--header-text); }
.header-tools select.compact option { color: #0b1f18; background: #fff; }
.icon-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r); border: 1px solid transparent; background: transparent; cursor: pointer; color: inherit;
}
.icon-btn:hover { background: var(--hover); }
.app-header .icon-btn { color: var(--header-muted); }
.app-header .icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--header-text); }
.role-label { color: var(--header-muted); }
.nav-toggle { display: none; }
.seg .short { display: none; }
.demo-banner { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: var(--info-soft); color: var(--text-2); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.demo-banner svg { width: 15px; height: 15px; flex: none; color: var(--info); }
.offline-banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--crit-soft); color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--crit) 45%, transparent); font-size: 13px; }
.offline-banner svg { color: var(--crit); width: 16px; height: 16px; flex: none; }
.panel-head h2 { font-size: 14px; }
.priv-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 13px; font-size: 11.5px; font-weight: 650; text-decoration: none; white-space: nowrap; border: 1px solid transparent; }
.priv-badge:hover { text-decoration: none; filter: brightness(1.15); }
.priv-badge svg { width: 14px; height: 14px; flex: none; }
.priv-badge .priv-tiny { display: none; }
.priv-badge { position: relative; }
.priv-badge .warn-dot { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--header-solid); }
.priv-warnings ul li + li { margin-top: 3px; }
.cascade-line { display: inline-flex; align-items: center; gap: 4px; }
.cascade-line svg, .crit-card .cf .chip svg { width: 12px; height: 12px; }
.cascade-box .check.strong { font-weight: 600; }
.precedents { margin: 10px 14px 0; padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }
.precedents summary { cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.precedents summary svg { width: 14px; height: 14px; }
.priv-badge.ok { background: rgba(76, 199, 113, 0.18); color: #c9f0d5; border-color: rgba(76, 199, 113, 0.45); }
.priv-badge.warn { background: rgba(240, 176, 77, 0.18); color: #ffe0a8; border-color: rgba(240, 176, 77, 0.45); }
.priv-badge.neutral { background: rgba(255, 255, 255, 0.07); color: var(--header-muted); border-color: rgba(255, 255, 255, 0.14); }
.priv-mode { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); }
.priv-mode.ok { border-color: color-mix(in srgb, var(--yes) 45%, transparent); background: var(--yes-soft); }
.priv-mode.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }
.priv-mode svg { width: 16px; height: 16px; }
.prompt-preview { margin: 0; max-height: 52vh; overflow: auto; padding: 12px; border-radius: var(--r); background: var(--bg-elev); border: 1px solid var(--border); font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
mark.ph { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 2px; font-weight: 700; }
.table.mini td { padding: 4px 8px; }
.insights { margin: 12px 14px 0; padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; scroll-margin: 12px; }
.insights h3 { font-size: 13.5px; }
.insights svg { width: 15px; height: 15px; }
.insights.churn-high { border-color: color-mix(in srgb, var(--crit) 40%, var(--border)); }
.insights.churn-medium { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.insights.churn-low { border-color: color-mix(in srgb, var(--yes) 40%, var(--border)); }
.ins-box { padding: 8px 10px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); }
.ins-box.tip { border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.ins-box.gap { border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.ins-box p { margin-top: 3px; line-height: 1.5; }
ul.risk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.risk-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.risk-item:first-child { padding-top: 0; }
.risk-item:last-child { border-bottom: 0; padding-bottom: 0; }
.tip-cell { max-width: 520px; }
.tip-cell summary { cursor: pointer; list-style: none; }
.tip-cell summary::-webkit-details-marker { display: none; }
.tip-cell .tip-first { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tip-cell details[open] .tip-first { -webkit-line-clamp: unset; display: block; }
.ck-toggle { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; padding: 0; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.ck-toggle:focus-visible { box-shadow: var(--focus-ring); }
.ck-readonly .edit-only { display: none !important; }
ul.queue { list-style: none; margin: 0; padding: 2px; }
ul.queue > li { display: block; }
.health { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.health.ok { background: var(--nav-accent); }
.health.bad { background: var(--crit); }
.health.mock { background: var(--warn); }
.mock-pill { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: #1b1100; background: var(--warn); padding: 2px 6px; border-radius: 4px; }

/* ───────── Layout ───────── */
.view { display: block; min-height: calc(100vh - var(--header-h)); outline: none; }
.page { padding: 22px 28px 48px; max-width: 1680px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .title { display: flex; flex-direction: column; gap: 2px; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { flex: 1 1 auto; }
.panel-body { padding: 14px; }
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 12px 0; border: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }

/* ───────── Controls ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 550; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.06s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.outline { background: transparent; }
.btn.accent-outline { background: transparent; border-color: var(--accent-line); color: var(--accent); }
.btn.accent-outline:hover { background: var(--accent-soft); }
.btn.danger { color: var(--no); border-color: color-mix(in srgb, var(--no) 40%, transparent); background: transparent; }
.btn.danger:hover { background: var(--no-soft); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 11.5px; border-radius: 5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn svg, .icon-btn svg { width: 16px; height: 16px; flex: none; }
.btn.sm svg { width: 14px; height: 14px; }

input[type="text"], input[type="number"], input[type="search"], input:not([type]), select, textarea {
  height: 32px; padding: 0 10px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
  min-width: 0;
}
textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select { padding-right: 28px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select.compact, input.compact { height: 28px; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--no); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-2); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .field > .label { font-size: 12px; color: var(--text-2); font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field .err { font-size: 11.5px; color: var(--no); }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; user-select: none; }
.search { position: relative; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 30px; width: 240px; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--seg-bg, var(--surface-2)); border: 1px solid var(--seg-border, var(--border)); }
.seg button {
  height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.seg.accent button[aria-pressed="true"] { background: var(--accent-fill); color: var(--accent-ink); }

/* ───────── Chips & badges ───────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.chip.sm { height: 18px; padding: 0 6px; font-size: 10.5px; border-radius: 9px; }
.chip.outline { background: transparent; border-color: var(--border-strong); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.yes { background: var(--yes-soft); color: var(--yes); }
.chip.no { background: var(--no-soft); color: var(--no); }
.chip.na { background: var(--na-soft); color: var(--na); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-lang { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border-strong); color: var(--text-2); }

.ans {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 24px; padding: 0 9px; border-radius: 6px;
  font-weight: 700; font-size: 12px; letter-spacing: 0.01em; white-space: nowrap;
}
.ans.yes { background: var(--yes-soft); color: var(--yes); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--yes) 30%, transparent); }
.ans.no { background: var(--no-soft); color: var(--no); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--no) 30%, transparent); }
.ans.na { background: var(--na-soft); color: var(--na); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--na) 30%, transparent); }
.ans.score { background: var(--info-soft); color: var(--info); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 30%, transparent); }
.ans.score.hi { background: var(--yes-soft); color: var(--yes); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--yes) 30%, transparent); }
.ans.score.mid { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 30%, transparent); }
.ans.score.lo { background: var(--no-soft); color: var(--no); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--no) 30%, transparent); }
.ans.crit { background: var(--crit); color: #fff; }
.ans.ok { background: var(--yes-soft); color: var(--yes); }

.score-pill { display: inline-flex; align-items: baseline; gap: 3px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-pill.hi { color: var(--yes); }
.score-pill.mid { color: var(--warn); }
.score-pill.lo { color: var(--no); }

/* ───────── Table ───────── */
.table-wrap { overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; background: var(--surface-2); padding: 0 10px; height: 34px;
  border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th .sort-ind { display: inline-block; width: 10px; margin-left: 3px; color: var(--accent); }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.selected { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.center, .table th.center { text-align: center; }
.table .cell-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: min(440px, 30vw); }
.table .ch-ic { display: inline-flex; color: var(--muted); }
.table .ch-ic svg { width: 15px; height: 15px; }
.table .cell-id a { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.table .cell-id .preview { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .w-check { width: 34px; }

/* ───────── Progress ───────── */
.progress { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 4px; transition: width 0.4s var(--ease); }
.progress > span.err { background: var(--no); }
.progress.indeterminate > span { width: 30% !important; animation: indet 1.2s infinite var(--ease); }
@keyframes indet { from { left: -30%; } to { left: 100%; } }
.job-panel { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 140%); margin-bottom: 14px; }
.job-panel.done { border-color: var(--border); background: var(--surface); }
.job-items { display: flex; flex-wrap: wrap; gap: 3px; }
.job-items span { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-3); }
.job-items span.running { background: var(--accent); animation: pulse 1s infinite alternate; }
.job-items span.done { background: var(--accent-2); }
.job-items span.error { background: var(--no); }
@keyframes pulse { from { opacity: 0.45; } to { opacity: 1; } }
.ai-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r); border: 1px dashed var(--info); background: var(--info-soft); font-size: 13px; }
.ai-box .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-box .expl { white-space: pre-wrap; line-height: 1.5; }
.job-panel.error { border-color: color-mix(in srgb, var(--no) 50%, transparent); }

/* ───────── States ───────── */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { width: 40px; height: 40px; color: var(--faint); }
.empty h2, .empty h3 { color: var(--text); font-size: 15px; }
.empty p { max-width: 440px; font-size: 13px; }
.error-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--no-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--no) 35%, transparent); }
.error-box svg { color: var(--no); width: 18px; height: 18px; flex: none; margin-top: 1px; }
.note-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.note-box.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.note-box.ok { background: var(--yes-soft); border-color: color-mix(in srgb, var(--yes) 35%, transparent); }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(15, 58, 46, 0.06), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.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); } }
.loading-center { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }

/* ───────── Toasts & modal ───────── */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 240px; max-width: 420px; padding: 10px 14px; border-radius: var(--r);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px; animation: toast-in 0.2s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.modal-scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in 0.15s; }
@keyframes fade-in { from { opacity: 0; } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-2); animation: modal-in 0.18s var(--ease); }
.modal.wide { width: min(820px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ───────── Dialog card ───────── */
.card-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: var(--gap); padding: 18px 24px 22px; height: calc(100vh - var(--header-h)); min-height: 560px; }
.card-col { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.card-col-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex: none; flex-wrap: wrap; }
.card-col-body { flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs .cid { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.meta-strip { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.meta-strip b { color: var(--text-2); font-weight: 600; }

.audio-bar { padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audio-bar audio { flex: 1 1 260px; height: 34px; min-width: 200px; }

.transcript { padding: 12px 14px 40px; display: flex; flex-direction: column; gap: 6px; }
.turn { position: relative; display: flex; gap: 10px; padding: 3px 6px; margin: 0 -6px; border-radius: var(--r); scroll-margin: 80px; }
.turn .gutter { flex: none; width: 46px; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; padding-top: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--faint); line-height: 1.2; }
.turn .gutter .idx { color: var(--muted); font-weight: 600; }
.turn .body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.turn .who { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bubble { display: inline-block; max-width: min(620px, 92%); padding: 7px 11px; border-radius: 10px; background: var(--bubble-client); border: 1px solid var(--border); white-space: pre-wrap; word-wrap: break-word; line-height: 1.45; }
.turn.client .body { align-items: flex-start; }
.turn.client .bubble { border-top-left-radius: 3px; }
.turn.operator .body { align-items: flex-end; }
.turn.operator .who { justify-content: flex-end; color: var(--accent); }
.turn.operator .bubble { background: var(--bubble-operator); border-color: var(--bubble-operator-border); border-top-right-radius: 3px; }
.turn.bot .bubble, .turn.system .bubble { background: transparent; border: 1px dashed var(--border-strong); color: var(--muted); font-size: 12.5px; max-width: 100%; }
.turn.system .bubble { font-style: italic; border-style: dotted; }
.bubble.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.analysis { font-size: 12.5px; color: var(--text-2); }
.analysis summary { cursor: pointer; color: var(--muted); font-size: 12px; width: fit-content; }
.analysis summary:hover { color: var(--text); }
.analysis p { margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; line-height: 1.5; }
.turn.bot .who, .turn.system .who { color: var(--faint); }
.turn.muted-flag .bubble { opacity: 0.55; }
.turn.has-audio { cursor: pointer; }
.turn.has-audio:hover .bubble { border-color: var(--accent-line); }
.turn .flags { display: inline-flex; gap: 4px; }
.turn .cite-badges { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.cite-badge { font-family: var(--mono); font-size: 10px; font-weight: 700; height: 16px; padding: 0 5px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); border: 0; cursor: pointer; display: inline-flex; align-items: center; }
.cite-badge.no, .cite-badge.crit { background: var(--no-soft); color: var(--no); }
.cite-badge.yes { background: var(--yes-soft); color: var(--yes); }
.cite-badge:hover { filter: brightness(1.2); }
.turn.in-range { background: var(--info-soft); }
.turn.in-range::before { content: ""; position: absolute; left: -2px; top: 2px; bottom: 2px; width: 3px; border-radius: 2px; background: var(--info); }
.turn.range-start::after { content: attr(data-range-label); position: absolute; right: 6px; top: -9px; font-size: 10px; font-weight: 700; color: var(--info); background: var(--surface); padding: 0 4px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--info) 40%, transparent); }
.turn.flash .bubble { animation: flash 1.8s var(--ease); }
@keyframes flash {
  0%, 40% { box-shadow: 0 0 0 2px var(--turn-active-line); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.turn.active { background: var(--turn-active); }
.turn.active::before { content: ""; position: absolute; left: -2px; top: 2px; bottom: 2px; width: 3px; border-radius: 2px; background: var(--turn-active-line); }
.turn.evidence-focus .bubble { box-shadow: 0 0 0 2px var(--turn-active-line); }
.marker { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.marker::before, .marker::after { content: ""; height: 1px; flex: 1; background: var(--border-strong); }
.marker.accent { color: var(--accent); }
.marker.accent::before, .marker.accent::after { background: var(--accent-line); }
.marker.warn { color: var(--warn); }
.marker.warn::before, .marker.warn::after { background: color-mix(in srgb, var(--warn) 40%, transparent); }

/* Score hero */
.score-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; padding: 16px; border-bottom: 1px solid var(--border); align-items: center; }
.score-ring { position: relative; width: 112px; height: 112px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-ring .val b { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.score-ring .val span { font-size: 11px; color: var(--muted); margin-top: 3px; }
.score-change { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.score-change s { color: var(--muted); }
.delta { font-weight: 700; padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }
.delta.up { background: var(--yes-soft); color: var(--yes); }
.delta.down { background: var(--no-soft); color: var(--no); }
.sections { display: flex; flex-direction: column; gap: 7px; }
.sec-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; align-items: center; font-size: 12.5px; }
.sec-row .bar { grid-column: 1 / -1; }
.sec-row .bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.sec-row .bar > span { display: block; height: 100%; border-radius: 3px; background: var(--accent-2); }
.sec-row .bar > span.mid { background: var(--warn); }
.sec-row .bar > span.lo { background: var(--no); }
.crit-banner { display: flex; gap: 12px; align-items: center; margin: 12px 16px 0; padding: 10px 12px; border-radius: var(--r); background: var(--crit-soft); border: 1px solid color-mix(in srgb, var(--crit) 45%, transparent); }
.crit-banner .ic { width: 28px; height: 28px; border-radius: 50%; background: var(--crit); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.crit-banner .ic svg { width: 16px; height: 16px; }
.crit-banner b { color: var(--crit); }
.eval-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 16px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface-2); }

/* Criterion card */
.crit-list { padding: 12px 14px 24px; display: flex; flex-direction: column; gap: 10px; }
.crit-section-title { display: flex; align-items: baseline; gap: 8px; margin: 8px 2px 0; }
.crit-section-title:first-child { margin-top: 0; }
.crit-card { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); transition: border-color 0.15s, box-shadow 0.15s; scroll-margin: 12px; }
.crit-card:hover { border-color: var(--border-strong); }
.crit-card.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.crit-card.is-na { background: transparent; border-style: dashed; }
.crit-card.is-crit-hit { border-color: color-mix(in srgb, var(--crit) 55%, transparent); background: var(--crit-soft); }
.crit-card .ch { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px 6px; }
.crit-card .code { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 4px; padding: 2px 5px; margin-top: 2px; flex: none; }
.crit-card .ttl { flex: 1 1 auto; min-width: 0; }
.crit-card .ttl h3 { font-size: 13.5px; line-height: 1.3; }
.crit-card .ttl .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.crit-card .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.crit-card .pts { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.crit-card .pts b { color: var(--text); font-size: 13px; }
.crit-card .cb { padding: 0 12px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.crit-card .expl { font-size: 13px; color: var(--text); line-height: 1.5; }
.crit-card .na-reason { font-size: 12.5px; color: var(--text-2); padding: 6px 9px; border-radius: 6px; background: var(--na-soft); }
.crit-card .na-reason b { color: var(--na); }
.crit-card .cf { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.ev-list { display: flex; flex-direction: column; gap: 5px; }
.ev-chip {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; text-align: left; padding: 6px 9px;
  border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); font-size: 12.5px; line-height: 1.4;
  transition: border-color 0.12s, background 0.12s;
}
.ev-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.ev-chip .ref { flex: none; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; margin-top: 1px; }
.ev-chip .q { flex: 1 1 auto; min-width: 0; font-style: italic; }
.ev-chip .q::before { content: "«"; } .ev-chip .q::after { content: "»"; }
.ev-chip.range .ref { color: var(--info); background: var(--info-soft); }
.ev-chip.range .q { font-style: normal; }
.ev-chip.range .q::before, .ev-chip.range .q::after { content: ""; }
.conf { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.conf .pip { width: 7px; height: 7px; border-radius: 2px; background: var(--surface-3); }
.conf .pip.on { background: var(--accent-2); }
.conf.low .pip.on { background: var(--warn); }
.conf.low { color: var(--warn); }
.review-note { font-size: 12px; padding: 6px 9px; border-radius: 6px; background: var(--info-soft); color: var(--text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.appeal-inline { font-size: 12.5px; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.appeal-inline.open { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }

/* History */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; gap: 0; }
.timeline li { position: relative; padding: 0 0 12px 20px; font-size: 12.5px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent-2); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 17px; bottom: -2px; width: 1px; background: var(--border-strong); }
.timeline li:last-child::after { display: none; }
.timeline li.appeal::before { border-color: var(--warn); }
.timeline li.decision::before { border-color: var(--info); background: var(--info); }
.timeline .when { color: var(--muted); font-size: 11.5px; }

/* ───────── Appeals ───────── */
.md-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.md-layout > :first-child { position: sticky; top: calc(var(--header-h) + 14px); }
.queue { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - var(--header-h) - 150px); overflow: auto; padding: 2px; }
.q-item { text-align: left; display: flex; flex-direction: column; gap: 5px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); width: 100%; }
.q-item:hover { border-color: var(--border-strong); background: var(--hover); }
.q-item[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-item .top { display: flex; align-items: center; gap: 8px; }
.q-item .cmt { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fragment { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--r); background: var(--bg-elev); border: 1px solid var(--border); max-height: 420px; overflow: auto; }
.fragment .turn { margin: 0; }
.fragment .gap-mark { text-align: center; color: var(--faint); font-size: 11px; letter-spacing: 0.3em; padding: 2px 0; }
.decision-form { display: flex; flex-direction: column; gap: 12px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.radio-card { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface-2); cursor: pointer; font-size: 13px; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 2px; }
.level-opts { display: flex; flex-direction: column; gap: 5px; }
.level-opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-radius: 7px; border: 1px solid var(--border); cursor: pointer; font-size: 12.5px; background: var(--surface); }
.level-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.level-opt .lv { font-family: var(--mono); font-weight: 700; min-width: 26px; color: var(--text); }
.result-banner { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--accent-soft); border: 1px solid var(--accent-line); flex-wrap: wrap; }
.result-banner .big { font-family: var(--font-display); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ───────── Checklist editor ───────── */
.ck-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--gap); align-items: start; }
.ck-side { position: sticky; top: calc(var(--header-h) + 14px); display: flex; flex-direction: column; gap: 12px; }
.weight-meter { display: flex; flex-direction: column; gap: 8px; }
.weight-meter .big { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.weight-meter .big.ok { color: var(--yes); }
.weight-meter .big.bad { color: var(--no); }
.weight-meter .big.warn { color: var(--warn); }
.weight-stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); gap: 1px; }
.weight-stack > span { height: 100%; min-width: 2px; }
.ck-crit { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); transition: border-color 0.15s; }
.ck-crit.changed { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.ck-crit.added { border-color: var(--accent-line); }
.ck-crit.invalid { border-color: color-mix(in srgb, var(--no) 55%, transparent); }
.ck-crit-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; user-select: none; }
.ck-crit-head:hover { background: var(--hover); border-radius: var(--r-lg); }
.ck-crit-head .chev { transition: transform 0.15s; color: var(--muted); width: 16px; height: 16px; flex: none; }
.ck-crit.open .ck-crit-head .chev { transform: rotate(90deg); }
.ck-crit-body { display: none; padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.ck-crit.open .ck-crit-body { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 12px; padding-top: 12px; }
.ck-crit-body .span-6 { grid-column: span 6; }
.ck-crit-body .span-3 { grid-column: span 3; }
.ck-crit-body .span-2 { grid-column: span 2; }
.ck-crit-body .span-1 { grid-column: span 1; }
.levels { display: flex; flex-direction: column; gap: 6px; }
.level-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) 30px; gap: 6px; align-items: center; }
.sec-editor { display: flex; flex-direction: column; gap: 6px; }
.sec-editor .sec-row-ed { display: grid; grid-template-columns: 140px minmax(0, 1fr) 30px; gap: 6px; }
.version-item { display: flex; flex-direction: column; gap: 2px; padding: 7px 9px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: left; color: var(--text); width: 100%; }
.version-item[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.version-item:hover { border-color: var(--border-strong); }
.err-list { margin: 0; padding-left: 18px; color: var(--no); font-size: 12px; display: flex; flex-direction: column; gap: 2px; }

/* ───────── Dashboard ───────── */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: var(--gap); }
.kpi { padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .v { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.accent .v { color: var(--accent); }
.kpi.crit .v { color: var(--crit); }
.kpi.warn .v { color: var(--warn); }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 230px) minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar-row .lbl { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.hbar-row .lbl .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--surface-3); gap: 1px; }
.stack > span { height: 100%; display: block; }
.stack .s-yes { background: var(--yes); }
.stack .s-no { background: var(--no); }
.stack .s-na { background: var(--na); opacity: 0.55; }
.track { height: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--accent-2); border-radius: 4px; }
.track > span.mid { background: var(--warn); }
.track > span.lo { background: var(--no); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.histo { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.histo .col-bar { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.histo .col-bar span.b { width: 100%; background: var(--accent-2); border-radius: 3px 3px 0 0; min-height: 1px; }
.histo .col-bar .c { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.histo-axis { display: flex; gap: 4px; margin-top: 4px; }
.histo-axis span { flex: 1 1 0; text-align: center; font-size: 10.5px; color: var(--muted); }

/* ───────── Settings ───────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ───────── Responsive ───────── */
@media (max-width: 1100px) {
  .table .hide-md { display: none; }
}
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ck-layout { grid-template-columns: minmax(0, 1fr) 260px; }
}
@media (max-width: 1280px) {
  .priv-badge .priv-text { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 1180px) {
  .brand-text, .header-tools .role-label { display: none; }
  .nav a { padding: 0 8px; }
  .priv-badge .priv-text { display: none; }
  .priv-badge .priv-tiny { display: inline; }
}
@media (max-width: 1000px) {
  .card-layout { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; }
  .card-col.transcript-col { max-height: 52vh; }
  .card-col.eval-col .card-col-body { overflow: visible; }
  .md-layout { grid-template-columns: minmax(0, 1fr); }
  .md-layout > :first-child { position: static; }
  .queue { max-height: 300px; }
  .ck-layout { grid-template-columns: minmax(0, 1fr); }
  .ck-side { position: static; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .brand-text { display: none; }
}
@media (max-width: 860px) {
  .app-header { gap: 8px; padding: 0 10px; }
  .nav a { padding: 0 7px; font-size: 13px; }
  .nav a[aria-current="page"]::after { left: 6px; right: 6px; }
  .header-tools { gap: 6px; }
  .header-tools .seg button { padding: 0 7px; font-size: 12px; }
  .table td, .table th { padding-left: 6px; padding-right: 6px; }
  .page { padding: 14px 12px 32px; }
  .card-layout { padding: 10px 12px 16px; }
  .header-tools .role-label { display: none; }
  .search input { width: 180px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .hbar-row { grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) 52px; }
  .ck-crit.open .ck-crit-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ck-crit-body .span-6, .ck-crit-body .span-3 { grid-column: span 2; }
  .ck-crit-body .span-2, .ck-crit-body .span-1 { grid-column: span 1; }
  .score-hero { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .table .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .app-header { position: relative; gap: 6px; padding: 0 8px; }
  .nav-toggle { display: inline-flex; flex: none; }
  .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 45; flex-direction: column; height: auto;
    background: var(--header-solid); border-bottom: 1px solid var(--header-border); box-shadow: var(--shadow-2); padding: 4px 0 8px; overflow: visible; }
  .app-header.nav-open .nav { display: flex; }
  .app-header .nav a { padding: 12px 18px; font-size: 14px; }
  .app-header .nav a[aria-current="page"]::after { left: 0; right: auto; top: 8px; bottom: 8px; width: 3px; height: auto; border-radius: 0 2px 2px 0; }
  .header-tools { margin-left: auto; min-width: 0; }
  .health { display: none; }
  .priv-badge { padding: 0 7px; }
  .priv-badge .priv-text, .priv-badge .priv-tiny { display: none; }
  .table .hide-xs { display: none; }
  .job-panel .num { white-space: nowrap; }
  .page { padding: 12px 10px 28px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .toolbar { justify-content: flex-start; }
  .toolbar > .spacer { display: none; }
  .search, .search input { width: 100%; }
  .card-layout { padding: 8px; gap: 10px; }
  .card-col-head { padding: 8px 10px; }
  .transcript { padding: 8px 8px 24px; }
  .turn .gutter { width: 34px; }
  .bubble { max-width: 100%; }
  .crit-list { padding: 8px; }
  .crit-card .ch { flex-wrap: wrap; }
  .crit-card .right { flex-direction: row; align-items: center; width: 100%; justify-content: flex-start; }
  .score-ring { width: 92px !important; height: 92px !important; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { margin-top: 6px; }
  .ck-crit.open .ck-crit-body { grid-template-columns: minmax(0, 1fr); }
  .ck-crit-body .span-6, .ck-crit-body .span-3, .ck-crit-body .span-2, .ck-crit-body .span-1 { grid-column: span 1; }
  .ck-crit-head { flex-wrap: wrap; }
  .sec-editor .sec-row-ed { grid-template-columns: 90px minmax(0, 1fr) 30px; }
  .level-row { grid-template-columns: 64px minmax(0, 1fr) 30px; }
  .hbar-row { grid-template-columns: minmax(0, 1fr) 48px !important; }
  .hbar-row > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .hbar-row > :nth-child(4) { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .kpi .v { font-size: 22px; }
  .modal-scrim { padding: 8px; }
  .modal-body { padding: 12px; }
  .toasts { left: 8px; right: 8px; }
  .toast { min-width: 0; max-width: none; }
  .radio-cards { grid-template-columns: minmax(0, 1fr); }
  .table .cell-id { max-width: 46vw; }
  .q-item .cmt { -webkit-line-clamp: 3; }
}
@media (max-width: 420px) {
  .brand { display: none; }
  .seg .full { display: none; }
  .seg .short { display: inline; }
}
@media (max-width: 380px) {
  .header-tools .seg button { padding: 0 7px; font-size: 12px; }
  .header-tools select.compact { padding-right: 22px; }
  .kpis { grid-template-columns: minmax(0, 1fr) !important; }
  .btn { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ───────── Answer icons, why-lowered, waveform, critical view, inline weight ───────── */
.ans svg { width: 13px; height: 13px; flex: none; }
.nav a svg { display: none; width: 18px; height: 18px; flex: none; opacity: 0.85; }
.tools-row { display: flex; align-items: center; gap: 10px; }
.why-lowered { margin: 0 16px; padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 10px; }
.why-lowered.ok { flex-direction: row; align-items: center; color: var(--yes); background: var(--yes-soft); border-color: transparent; }
.why-lowered.ok svg { width: 16px; height: 16px; }
.why-lowered h3 { font-size: 14.5px; }
.why-lowered ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.why-row { display: flex; flex-direction: column; gap: 8px; align-items: stretch; padding: 11px 0; border-top: 1px solid var(--border); }
.why-row:first-child { border-top: 0; padding-top: 2px; }
.why-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.why-main p { color: var(--text-2); line-height: 1.45; }
.why-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.why-row .code { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-3); border-radius: 4px; padding: 1px 5px; }
.wave { width: 100%; display: flex; flex-direction: column; gap: 4px; }
.wave-canvas-wrap { position: relative; width: 100%; }
.wave canvas { display: block; width: 100%; height: 76px; cursor: pointer; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
.wave-meta { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.wave-meta i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.wave-meta .time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.crit-item { padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--crit) 28%, var(--border)); background: var(--surface); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 8px; }
.crit-item .quote { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 7px; background: var(--crit-soft); color: var(--text); font-size: 13px; text-decoration: none; }
.crit-item .quote:hover { text-decoration: none; filter: brightness(0.98); outline: 1px solid color-mix(in srgb, var(--crit) 35%, transparent); }
.crit-item .quote .ref { flex: none; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--crit); }
.crit-item .quote .q { font-style: italic; }
.crit-list-page { display: flex; flex-direction: column; gap: 12px; }
.w-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.w-inline input { width: 58px; height: 26px; padding: 0 6px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.results-chip { cursor: help; }

/* ───────── Desktop: deep-green left sidebar (corporate layout) ───────── */
@media (min-width: 1001px) {
  :root { --header-h: 0px; --sidebar-w: 236px; }
  body { padding-left: var(--sidebar-w); }
  .app-header {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); height: auto; z-index: 30;
    flex-direction: column; align-items: stretch; gap: 0; padding: 18px 12px 14px;
    background: var(--header-solid); border-bottom: 0; border-right: 1px solid var(--header-border);
    backdrop-filter: none; overflow-y: auto;
  }
  .brand { padding: 2px 8px 20px; }
  .brand-text, .header-tools .role-label { display: flex; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-name { font-size: 15px; }
  .nav { flex-direction: column; height: auto; gap: 2px; overflow: visible; }
  .nav a, .app-header .nav a { height: 40px; padding: 0 12px; border-radius: 8px; gap: 11px; font-size: 14px; color: var(--header-muted); }
  .nav a svg { display: inline-block; }
  .nav a:hover { background: rgba(255, 255, 255, 0.07); color: var(--header-text); }
  .nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.12); color: var(--header-text); font-weight: 600; }
  .nav a[aria-current="page"]::after, .app-header .nav a[aria-current="page"]::after { left: 0; right: auto; top: 9px; bottom: 9px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .nav .count { margin-left: auto; }
  .header-tools { margin: auto 0 0; flex-direction: column; align-items: stretch; gap: 10px; padding: 16px 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.1); }
  .header-tools .role-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
  .header-tools .seg { width: 100%; }
  .header-tools .seg button { flex: 1 1 0; }
  .header-tools .seg .full { display: inline; }
  .header-tools .seg .short { display: none; }
  .priv-badge { justify-content: flex-start; height: auto; min-height: 32px; white-space: normal; line-height: 1.3; border-radius: 8px; padding: 7px 10px; }
  .priv-badge .priv-text { display: inline; max-width: none; overflow: visible; }
  .priv-badge .priv-tiny { display: none; }
  .tools-row { justify-content: space-between; }
  .tools-row select.compact { flex: 1 1 auto; }
  .nav-toggle { display: none; }
  .mock-pill { align-self: flex-start; }
}
@media (min-width: 1001px) and (max-width: 1400px) {
  .table .hide-md { display: none; }
  .card-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); padding: 16px 18px 18px; }
}
@media (max-width: 640px) {
  .page .seg, .modal .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .page .seg::-webkit-scrollbar, .modal .seg::-webkit-scrollbar { display: none; }
  .page .seg button, .modal .seg button { flex: none; }
  .page-head .toolbar > * { max-width: 100%; }
}

/* ═══════════ Premium polish + motion (docs/DESIGN_PLAN.md) ═══════════
   Motion is driven by lib/motion.js (WAAPI, content visible by default). These rules carry the resting styles,
   the CSS-only state animations, and the reduced-motion-safe fallbacks. */

/* Browser surfaces */
html { scrollbar-color: var(--border-strong) transparent; }
body { caret-color: var(--accent); }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.page-head { margin-bottom: 18px; }
.page-head .sub { font-size: 13px; }

/* Surfaces & elevation */
.panel, .kpi, .table-wrap { box-shadow: var(--shadow-1); }
.card-col { border-radius: var(--r-xl); box-shadow: var(--shadow-1); }
.kpi { padding: 14px 16px 13px; gap: 6px; }
.kpi .k { font-size: 11px; letter-spacing: 0.06em; }
.kpi .v { font-size: 30px; letter-spacing: -0.03em; }
.score-hero { background: radial-gradient(120% 160% at 0% 0%, var(--accent-soft), transparent 58%); }
.crit-item { border-radius: var(--r-lg); }

/* Sidebar: gradient depth + a single gliding active pill (placed by lib/motion.js) */
@media (min-width: 1001px) {
  .app-header { background: var(--sidebar-bg); }
  .nav { position: relative; }
  .nav a, .app-header .nav a { position: relative; z-index: 1; transition: color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out); }
  .nav a svg { transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2); }
  .nav a:hover svg { transform: translateX(1px); opacity: 1; }
  .nav.has-pill a[aria-current="page"], .app-header .nav.has-pill a[aria-current="page"] { background: transparent; }
  .nav.has-pill a[aria-current="page"]::after, .app-header .nav.has-pill a[aria-current="page"]::after { display: none; }
  .nav-pill { position: absolute; left: 0; top: 0; z-index: 0; border-radius: 8px; background: rgba(255, 255, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 6px 18px -8px rgba(0, 0, 0, 0.45); pointer-events: none; }
  .nav-pill::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--nav-accent); }
}

/* Segmented controls: sliding thumb (lib/motion.js) + visible focus on the pressed option */
.seg { position: relative; }
.seg > button { position: relative; z-index: 1; transition: color var(--dur-2) var(--ease-out); }
.seg > .seg-thumb { position: absolute; left: 0; top: 0; z-index: 0; border-radius: 6px; background: var(--surface-3); box-shadow: var(--shadow-1); pointer-events: none; }
.seg.accent > .seg-thumb { background: var(--accent-fill); }
.header-tools .seg > .seg-thumb { background: #ffffff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.seg.has-thumb > button[aria-pressed="true"] { background: transparent; box-shadow: none; }
.seg button:focus-visible, .seg.has-thumb > button[aria-pressed="true"]:focus-visible { box-shadow: var(--focus-ring); }

/* Buttons: crisp feedback */
.btn { transition: background-color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.btn:active:not([disabled]):not([aria-disabled="true"]) { transform: scale(0.97); }
.btn.primary { box-shadow: 0 1px 2px rgba(16, 40, 30, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn.primary:hover:not([disabled]) { transform: translateY(-1px); box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--accent-fill) 75%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn.primary:active:not([disabled]) { transform: scale(0.97); }
.icon-btn { transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease-out); }
.icon-btn:active { transform: scale(0.92); }

/* Interactive cards lift; static cards never do */
.q-item, .version-item, .ev-chip, .radio-card, .level-opt, .crit-item .quote {
  transition: border-color var(--dur-2) var(--ease-out), background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
.q-item:hover, .version-item:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.ev-chip:hover { transform: translateX(2px); }
.crit-item .quote:hover { transform: translateX(2px); }
.crit-card { transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-3) var(--ease-out); }

/* Table: row affordance + live-update flash */
.table tbody tr { transition: background-color var(--dur-1) var(--ease); }
.table .cell-id a { display: inline-flex; align-items: center; gap: 6px; }
.table .cell-id a::after { content: ""; width: 5px; height: 5px; border-top: 1.6px solid currentColor; border-right: 1.6px solid currentColor; transform: translateX(-4px) rotate(45deg); opacity: 0; transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out); }
.table tbody tr:hover .cell-id a::after, .table .cell-id a:focus-visible::after { opacity: 1; transform: rotate(45deg); }
.table tbody tr.row-updated { animation: row-flash 1.8s var(--ease-out); }
@keyframes row-flash { 0%, 25% { background-color: var(--row-flash); } 100% { background-color: transparent; } }

/* Score ring: halo on lock-in + floating delta after an appeal */
.score-ring { --ring-color: var(--accent); }
.score-ring::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 2px solid var(--ring-color); opacity: 0; pointer-events: none; }
.score-ring.locked::after { animation: ring-halo 950ms var(--ease-out); }
@keyframes ring-halo { 0% { opacity: 0.55; transform: scale(0.95); } 100% { opacity: 0; transform: scale(1.18); } }
.ring-delta { position: absolute; left: 50%; top: -8px; z-index: 2; transform: translateX(-50%); padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; color: #fff; box-shadow: var(--shadow-2); pointer-events: none; }
.ring-delta.up { background: var(--accent-fill); }
.ring-delta.down { background: var(--no); }

/* Gross-error banner: one light sweep + icon pulse when the card opens */
.crit-banner { position: relative; overflow: hidden; }
.crit-banner.sweep::after { content: ""; position: absolute; inset: 0; pointer-events: none; transform: translateX(-100%);
  background: linear-gradient(100deg, transparent 15%, color-mix(in srgb, var(--crit) 16%, transparent) 50%, transparent 85%);
  animation: crit-sweep 1.4s 0.35s var(--ease-out) both; }
@keyframes crit-sweep { to { transform: translateX(100%); } }
.crit-banner.sweep .ic { animation: crit-ic 1.5s 0.3s var(--ease-out) both; }
@keyframes crit-ic { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--crit) 50%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }

/* Evidence target: row wash + bubble ring that expands once (scale is added by lib/motion.js pulseTurn) */
.bubble { position: relative; }
.turn.flash { animation: flash-row 1.8s var(--ease-out); }
@keyframes flash-row { 0%, 30% { background-color: var(--turn-active); } 100% { background-color: transparent; } }
.turn.flash .bubble { animation: flash-bubble 1.8s var(--ease-out); }
@keyframes flash-bubble { 0% { box-shadow: 0 0 0 0 var(--turn-active-line); } 12%, 50% { box-shadow: 0 0 0 2px var(--turn-active-line); } 100% { box-shadow: 0 0 0 2px transparent; } }
.turn.flash .bubble::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--turn-active-line); pointer-events: none; animation: flash-ring 950ms var(--ease-out) forwards; }
@keyframes flash-ring { 0% { opacity: 0.9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.05, 1.3); } }

/* Read progress at the top of each card column (scroll-driven where supported) */
@supports (animation-timeline: scroll()) {
  .card-col-body::before { content: ""; position: sticky; top: 0; z-index: 4; display: block; height: 2px; margin-bottom: -2px; pointer-events: none;
    background: linear-gradient(90deg, var(--accent-2), var(--accent)); transform-origin: left center; transform: scaleX(0);
    animation: read-progress linear both; animation-timeline: scroll(nearest block); }
  @keyframes read-progress { to { transform: scaleX(1); } }
}

/* Job progress: sheen while running, smooth state change, drawn check on finish */
.job-panel { transition: border-color var(--dur-4) var(--ease-out), background-color var(--dur-4) var(--ease-out); }
.progress > span { overflow: hidden; }
.job-panel:not(.done):not(.error) .progress:not(.indeterminate) > span::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent); animation: sheen 1.7s var(--ease) infinite; }
@keyframes sheen { to { transform: translateX(100%); } }
.job-panel.done > .row > svg:first-child { color: var(--yes); }
.job-panel.done > .row > svg:first-child path { stroke-dasharray: 26; animation: draw-check 0.6s 0.1s var(--ease-out) both; }
@keyframes draw-check { from { stroke-dashoffset: 26; } to { stroke-dashoffset: 0; } }
.job-items span { transition: background-color var(--dur-3) var(--ease-out); }

/* Toasts: icon disc instead of a side stripe, spring in, time-left bar */
.toasts { gap: 10px; }
.toast { position: relative; overflow: hidden; align-items: center; padding: 11px 14px 12px 11px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3); animation: toast-in 420ms var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translateX(32px) scale(0.98); } }
.toast-ic { width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--info-soft); color: var(--info); }
.toast-ic svg { width: 15px; height: 15px; }
.toast.ok .toast-ic { background: var(--yes-soft); color: var(--yes-ink); }
.toast.err .toast-ic { background: var(--no-soft); color: var(--no); }
.toast-time { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--info); opacity: 0.55; transform-origin: left center; animation: toast-time linear forwards; }
.toast.ok .toast-time { background: var(--yes); }
.toast.err .toast-time { background: var(--no); }
@keyframes toast-time { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Modals: blurred scrim, rise-in, exit handled in lib/dom.js */
.modal-scrim { backdrop-filter: blur(3px) saturate(1.05); animation: fade-in var(--dur-2) var(--ease-out); }
.modal-scrim.closing { pointer-events: none; }
.modal { border-radius: var(--r-xl); border-color: var(--border); box-shadow: var(--shadow-3); animation: modal-in 320ms var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.965); } }

/* Checklist: one-shot glow for new criteria / versions */
.ck-crit { transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out); }
.ck-crit.just-added, .ck-crit.glow, .version-item.just-added { animation: ck-glow 1.8s var(--ease-out); }
@keyframes ck-glow { 0%, 30% { box-shadow: 0 0 0 1px var(--accent), 0 0 0 5px var(--accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
.weight-meter .big { transition: color var(--dur-3) var(--ease-out); }

/* Route-shaped loading skeleton (appears only after 140 ms) */
.route-skel { animation: skel-in var(--dur-3) 140ms var(--ease-out) backwards; }
@keyframes skel-in { from { opacity: 0; } }
.route-skel .skeleton { border-radius: var(--r); background: var(--surface-3); }
.skeleton::after { animation: shimmer 1.6s var(--ease) infinite; }
.route-skel .sk-sub { margin: 9px 0 20px; }
.sk-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.route-skel .sk-block { border-radius: var(--r-lg); }
.sk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sk-panel { padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.sk-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 13px 4px; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.route-skel.sk-dialog { max-width: none; padding: 18px 24px 22px; }
.sk-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr); gap: 16px; height: calc(100vh - var(--header-h) - 40px); min-height: 520px; }
.sk-col { display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow: hidden; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.route-skel .sk-bubble { border-radius: 12px; }
.route-skel .sk-bubble.op { align-self: flex-end; }
.sk-hero { display: flex; align-items: center; gap: 18px; }
.route-skel .sk-ring { width: 112px; height: 112px; border-radius: 50%; flex: none; }
@media (max-width: 1000px) {
  .sk-card { grid-template-columns: minmax(0, 1fr); height: auto; }
  .sk-grid { grid-template-columns: minmax(0, 1fr); }
  .route-skel.sk-dialog { padding: 12px; }
}

/* Mobile: burger panel drops in; comfortable targets; KPIs stay two-up */
@keyframes nav-drop { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 1000px) {
  .app-header.nav-open .nav { animation: nav-drop var(--dur-3) var(--ease-out); }
}
@media (max-width: 640px) {
  .seg button { min-height: 32px; }
  .kpi .v { font-size: 24px; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .k { font-size: 10.5px; letter-spacing: 0.04em; }
  .kpi .v { font-size: 21px; }
}

/* Contrast: chip inks a step darker than the fills (WCAG AA on the soft tints) */
.ans.yes, .chip.yes, .chip.accent, .ans.score.hi, .ans.ok { color: var(--yes-ink); }
.chip.warn, .ans.score.mid { color: var(--warn-ink); }

/* Theme switch: circular reveal (View Transitions); keep the rest of the page still */
.vt-theme::view-transition-old(root), .vt-theme::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.vt-theme::view-transition-old(root) { z-index: 1; }
.vt-theme::view-transition-new(root) { z-index: 2; }

@media (prefers-reduced-motion: reduce) {
  .card-col-body::before { display: none; }
  .modal-scrim { backdrop-filter: none; }
}

/* Count-up digits inherit the host number style (e.g. .score-ring .val span would shrink them) */
.count-vis, .score-ring .val .count-vis { font: inherit; color: inherit; letter-spacing: inherit; margin: 0; }

/* Inline loading state: shimmer lines (lib/dom.js loading()) */
.loading-center.loading-block { display: block; padding: 16px; color: inherit; animation: skel-in var(--dur-3) 150ms var(--ease-out) backwards; }
.loading-block .sk-line { height: 11px; margin: 11px 0; background: var(--surface-3); border-radius: var(--r-sm); }

/* Adaptive checklist: removed criteria / no gold labels on the dashboard */
.hbar-row.is-removed { opacity: 0.55; }
.hbar-row.is-removed .stack { filter: grayscale(1); }
.no-gold-note { justify-self: start; display: inline-flex; align-items: center; height: 20px; padding: 0 9px; border-radius: 10px; border: 1px dashed var(--border-strong); color: var(--muted); white-space: nowrap; }

/* Criterion compiler («Сгенерировать пояснения») */
.cc-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-running { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 160%); font-size: 13px; }
.cc-running .cc-head { display: flex; align-items: center; gap: 8px; }
.cc-running .cc-time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.cc-scan { position: relative; height: 3px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.cc-scan::after { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 38%; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--accent-2), transparent); animation: cc-scan 1.5s var(--ease) infinite; }
@keyframes cc-scan { from { transform: translateX(-100%); } to { transform: translateX(270%); } }
.cc-result { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--accent-line); background: var(--surface); box-shadow: var(--shadow-1); font-size: 13px; }
.cc-result .cc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-result .cc-head svg { width: 15px; height: 15px; color: var(--accent); }
.cc-result ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.cc-result .cc-warn li { color: var(--warn-ink); }
.cc-result details summary { cursor: pointer; color: var(--muted); font-size: 12px; width: fit-content; }
.cc-result details p { margin-top: 6px; white-space: pre-wrap; line-height: 1.5; color: var(--text-2); }
.cc-changed { animation: cc-changed 2.6s var(--ease-out); }
@keyframes cc-changed { 0%, 45% { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
.val-warnings { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: var(--r); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); font-size: 12px; }
.val-warnings b { color: var(--warn-ink); }
.val-warnings ul { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 2px; color: var(--text-2); }
.val-warnings.autofix { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.val-warnings.autofix b { color: var(--info); }

/* Checklist editor: View Transitions for criterion cards (views/checklist.js morphCriteria) */
::view-transition-group(*.ck-card) { animation-duration: .32s; animation-timing-function: cubic-bezier(.16,1,.3,1); overflow: clip; overflow-clip-margin: 12px; border-radius: var(--r-lg); }
::view-transition-old(*.ck-card), ::view-transition-new(*.ck-card) { animation-duration: .22s; }
::view-transition-old(*.ck-card):only-child { animation: ck-vt-out .18s cubic-bezier(.4,0,1,1) both; }
::view-transition-new(*.ck-card):only-child { animation: ck-vt-in .32s cubic-bezier(.16,1,.3,1) both; }
@keyframes ck-vt-out { to { opacity: 0; transform: scale(.96); } }
@keyframes ck-vt-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
::view-transition-group(ckvt-side), ::view-transition-group(ckvt-removed) { animation-duration: .32s; animation-timing-function: cubic-bezier(.16,1,.3,1); }
