/* ============================================================
   CitationChecker — design tokens + components
   Light default, [data-theme="dark"] override
   ============================================================ */

:root {
  /* No webfonts are loaded over the network (see index.html) — this app
     handles confidential legal documents and shouldn't phone home to a font
     CDN on every launch. Named webfonts stay first in each stack so anyone
     who happens to have them installed locally still gets them; everything
     after that is a system-font fallback chain that degrades gracefully
     across macOS, Windows, and Linux. */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font-serif: "Source Serif 4", ui-serif, "Iowan Old Style", "Apple Garamond", Georgia, serif;

  --bg: #fbfbfa;
  --bg-elev: #ffffff;
  --bg-sunken: #f3f3f1;
  --bg-row-hover: #f6f6f4;
  --border: #e6e5e1;
  --border-strong: #d2d1cc;
  --border-subtle: #efeeea;

  --ink-1: #0e1116;
  --ink-2: #353a43;
  --ink-3: #5d636e;
  --ink-4: #8a909a;
  --ink-5: #b3b8bf;

  --accent: #2f3b52;
  --accent-hover: #1f2a3e;
  --accent-ink: #ffffff;

  --ok: #2f7a4f;
  --ok-bg: #e6f1ea;
  --ok-border: #b9d8c4;
  --warn: #a76910;
  --warn-bg: #fbeed6;
  --warn-border: #e8caa0;
  --bad: #a92e2e;
  --bad-bg: #f7e3e1;
  --bad-border: #e5b6b1;
  --info: #2a5b8a;
  --info-bg: #e1ecf6;
  --info-border: #b6cfe3;
  --unverified: #6b4ea0;
  --unverified-bg: #ece5f6;
  --unverified-border: #cbb9e6;

  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-1: 0 1px 0 rgba(14,17,22,.04), 0 1px 2px rgba(14,17,22,.04);
  --shadow-2: 0 1px 0 rgba(14,17,22,.04), 0 4px 12px rgba(14,17,22,.06);
  --shadow-pop: 0 12px 32px rgba(14,17,22,.12), 0 2px 6px rgba(14,17,22,.08);
}

/* ── Compact /run screen (ported from the hosted sister fork) ── */
.run-ui-screen{padding:24px 56px 34px!important}
.run-ui-content{max-width:980px!important;margin:0 auto!important}
.run-ui-content>div:first-child{margin-bottom:20px!important}
.run-ui-content h1{font-size:32px!important}
.run-ui-content h1+p{font-size:14px!important;max-width:650px!important;line-height:1.55!important}
.run-ui-dropzone{min-height:220px;box-sizing:border-box;margin-bottom:16px!important;display:flex;flex-direction:column;align-items:center;justify-content:center;border-style:dashed!important}
.run-ui-dropzone .dropzone__icon{width:36px;height:36px;margin-bottom:16px}
.run-ui-dropzone .help{font-size:13px;margin:8px 0 20px!important}
.run-ui-picked-preview{margin-bottom:16px!important}
.run-ui-picked-preview>.panel{min-height:68px;box-sizing:border-box;padding:12px 16px!important}
.run-ui-ready-chip{display:inline-flex;align-items:center;height:24px;padding:0 9px;border-radius:5px;border:1px solid var(--ok-border,#b9dec8);background:var(--ok-bg,#effaf3);color:var(--ok,#287a4b);font-size:11.5px;white-space:nowrap}
.run-ui-options-row{display:grid;grid-template-columns:minmax(0,1fr) 230px;align-items:stretch;gap:28px;margin-bottom:18px}
.run-ui-advanced{padding:0!important;margin:0!important;overflow:hidden;min-width:0;align-self:stretch}
.run-ui-advanced-toggle{display:flex;width:100%;min-height:56px;align-items:center;justify-content:space-between;gap:20px;padding:0 20px;border:0;background:transparent;color:var(--ink-1);font:500 14px var(--font-sans);cursor:pointer}
.run-ui-advanced:not(.is-open) .run-ui-advanced-toggle{height:100%}
.run-ui-advanced-toggle:hover{background:var(--bg-row-hover,rgba(0,0,0,.03))}
.run-ui-advanced-label{display:flex;align-items:center;gap:10px}
.run-ui-advanced-chevron{font-size:22px;line-height:1;color:var(--ink-3);transition:transform .15s ease}
.run-ui-advanced.is-open .run-ui-advanced-chevron{transform:rotate(90deg)}
.run-ui-advanced-summary{color:var(--ink-3);font-weight:400}
.run-ui-advanced-details{border-top:1px solid var(--border-subtle);padding:16px}
.run-ui-advanced-details[hidden]{display:none!important}
.run-ui-advanced-details #settings-grid{margin:0!important}
.run-ui-settings-stack{display:grid!important;grid-template-columns:1fr!important;gap:0!important}
.run-ui-settings-stack>div:first-child{border:0!important;padding:4px 12px 12px!important}
.run-ui-provider-panel-hidden,.run-ui-multi-model-note-hidden,.run-ui-advanced-option-hidden{display:none!important}
.run-ui-worker-section{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px;padding-top:14px;border-top:1px solid var(--border-subtle)}
.run-ui-worker-control{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:12px;margin:0!important;padding:12px 14px;border:1px solid var(--border);border-radius:var(--r);background:var(--bg-sunken)}
.run-ui-multi-model-setting{padding:0 0 14px;margin-bottom:14px;border-bottom:1px solid var(--border-subtle)}
.run-ui-multi-model-setting>.toggle{margin-bottom:7px;cursor:pointer}
.run-ui-actions{justify-content:flex-end!important;gap:20px!important;align-items:flex-start}
.run-ui-actions #btn-cancel[hidden]{display:none!important}
.run-ui-model-picker{display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;justify-self:end;width:230px;min-width:0;min-height:56px}
.run-ui-model-select{display:none!important}
.run-ui-model-menu{position:relative;width:230px;min-width:0}
.run-ui-model-trigger{display:flex;width:100%;height:56px;align-items:center;justify-content:space-between;gap:14px;padding:0 16px;border:1px solid var(--border);border-radius:var(--r-md);background:var(--bg-elev);color:var(--ink-1);font:500 14px var(--font-sans);cursor:pointer;text-align:left}
.run-ui-model-trigger:hover,.run-ui-model-trigger[aria-expanded="true"]{border-color:var(--border-strong);background:var(--bg-row-hover)}
.run-ui-model-trigger:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.run-ui-model-chevron{color:var(--ink-3);font-size:16px;transform:translateY(-1px)}
.run-ui-model-popover{position:absolute;top:calc(100% + 7px);right:0;width:100%;box-sizing:border-box;z-index:80;padding:6px;background:var(--bg-elev);border:1px solid var(--border);border-radius:var(--r-md);box-shadow:var(--shadow-pop,0 10px 28px rgba(0,0,0,.18))}
.run-ui-model-popover[hidden]{display:none!important}
.run-ui-model-option{position:relative;display:flex;width:100%;min-height:40px;align-items:center;padding:8px 11px;border:0;border-radius:6px;background:transparent;color:var(--ink-1);font:400 14px var(--font-sans);text-align:left;cursor:pointer}
.run-ui-model-option:hover,.run-ui-model-option:focus-visible{background:var(--bg-row-hover);outline:none}
.run-ui-model-option.is-selected{font-weight:500;background:var(--bg-sunken)}
.run-ui-model-menu.is-multi .run-ui-model-option{padding-left:38px}
.run-ui-model-menu.is-multi .run-ui-model-option:before{content:"";position:absolute;left:12px;width:15px;height:15px;box-sizing:border-box;border:1px solid var(--border-strong);border-radius:4px;background:var(--bg-elev)}
.run-ui-model-menu.is-multi .run-ui-model-option.is-selected:before{border-color:var(--accent);background:var(--accent)}
.run-ui-model-menu.is-multi .run-ui-model-option.is-selected:after{content:"✓";position:absolute;left:15px;top:50%;transform:translateY(-52%);color:white;font-size:10px;font-weight:700}
.run-ui-model-done{display:flex;width:100%;height:38px;align-items:center;justify-content:center;margin-top:6px;border:0;border-top:1px solid var(--border-subtle);background:transparent;color:var(--ink-1);font:600 13px var(--font-sans);cursor:pointer}
.run-ui-model-done:hover,.run-ui-model-done:focus-visible{background:var(--bg-row-hover);outline:none}
.run-ui-model-count{margin-top:6px;font-size:12px;line-height:16px;text-align:left}
.run-ui-model-count[hidden],.run-ui-model-done[hidden]{display:none!important}
.run-ui-submit{display:flex;flex-direction:column;align-items:center;gap:7px}
.run-ui-ready{font-size:12px;line-height:1.2;white-space:nowrap;text-align:center}
.run-ui-actions #btn-run{min-width:200px;height:52px;justify-content:center;font-size:14px}

@media(max-width:760px){
  .run-ui-screen{padding:28px 18px!important}
  .run-ui-content h1{font-size:27px!important}
  .run-ui-dropzone{min-height:225px}
  .run-ui-options-row{grid-template-columns:1fr;gap:12px}
  .run-ui-advanced-summary{display:none}
  .run-ui-advanced-details #settings-grid{grid-template-columns:1fr!important}
  .run-ui-actions{align-items:stretch!important;flex-direction:column!important}
  .run-ui-model-picker{justify-content:stretch;justify-self:stretch;width:100%;min-height:56px}
  .run-ui-model-menu{width:100%}
  .run-ui-worker-section{grid-template-columns:1fr}
  .run-ui-actions #btn-run{width:100%}
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-elev: #14171c;
  --bg-sunken: #0a0c10;
  --bg-row-hover: #181b21;
  --border: #232830;
  --border-strong: #30363f;
  --border-subtle: #1a1d23;

  --ink-1: #ecedef;
  --ink-2: #c8cbd0;
  --ink-3: #8a909a;
  --ink-4: #5e646e;
  --ink-5: #3e434c;

  --accent: #e5e6e8;
  --accent-hover: #ffffff;
  --accent-ink: #0e1116;

  --ok: #6fb98a;
  --ok-bg: #16261d;
  --ok-border: #2a4a36;
  --warn: #d9a35a;
  --warn-bg: #2a200f;
  --warn-border: #4a3a1c;
  --bad: #e07873;
  --bad-bg: #2a1715;
  --bad-border: #4c2825;
  --info: #7bb0e0;
  --info-bg: #112334;
  --info-border: #25425e;
  --unverified: #b39ae0;
  --unverified-bg: #1d1630;
  --unverified-border: #382a52;

  --shadow-1: 0 1px 0 rgba(0,0,0,.4);
  --shadow-2: 0 1px 0 rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.4);
  --shadow-pop: 0 16px 40px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.4);
}

/* ====== reset + layout ====== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  font-family: var(--font-sans);
  font-feature-settings: "ss01","cv11";
  -webkit-font-smoothing: antialiased;
  color: var(--ink-1);
  font-size: 14px;
  line-height: 1.45;
}

#app { height: 100%; }

:root { --footer-h: 32px; }

.screen-wrap {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: var(--footer-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.screen-wrap[hidden] { display: none !important; }

/* ====== site footer ====== */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--footer-h);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-3);
}
.site-footer .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--ink-3);
}
.site-footer .brand .dot {
  width: 6px; height: 6px; border-radius: 2px;
  background: var(--ink-4);
  transform: rotate(45deg);
}
.footer-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11.5px;
  color: var(--ink-3);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  cursor: pointer;
}
.footer-link:hover { color: var(--ink-1); text-decoration-color: var(--ink-3); }

/* ====== license modal ====== */
.license-text {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  max-height: 50vh;
  overflow: auto;
}

.screen-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.screen-wrap * { box-sizing: border-box; }

.mono { font-family: var(--font-mono); font-feature-settings: "ss02","ss03"; }
.num { font-variant-numeric: tabular-nums; }

/* ====== top chrome ====== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  height: 56px;
  flex-shrink: 0;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--ink-1);
}
.topbar .brand .dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--ink-1);
  transform: rotate(45deg);
}
.topbar .brand small {
  color: var(--ink-4);
  font-weight: 400;
  margin-left: 8px;
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
}
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  font-family: inherit;
}
.topbar-btn:hover { background: var(--bg-sunken); }
.topbar-btn.active { background: var(--bg-sunken); border-color: var(--border); }
.manual-status-slot:empty { display: none; }
.manual-status-btn {
  border-color: var(--info-border);
  background: var(--info-bg);
  color: var(--info);
}
.manual-status-btn:hover { background: color-mix(in srgb, var(--info) 12%, var(--info-bg)); }
.manual-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--info);
  animation: pulse 1.4s ease-in-out infinite;
}
.case-doc-slot:empty { display: none; }
.case-doc-progress {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info);
  font-size: 12px;
  font-weight: 500;
}
.case-doc-error {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid var(--bad-border, var(--border));
  background: var(--bad-bg, transparent);
  color: var(--bad);
  font-size: 12px;
  font-weight: 500;
}
.case-doc-error .manual-status-dot { background: var(--bad); }

/* ====== breadcrumb ====== */
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.crumb-link {
  color: var(--ink-3);
  text-decoration: none;
  cursor: pointer;
  background: none; border: none; padding: 0; font: inherit;
}
.crumb-link:hover { color: var(--ink-1); }
.crumb .sep { color: var(--ink-5); }

/* ====== buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink-1);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--bg-sunken); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--primary:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--bg-sunken); }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn--danger { color: var(--bad); border-color: var(--bad-border); background: var(--bad-bg); }
.btn--ok { color: var(--ok); border-color: var(--ok-border); background: var(--ok-bg); }

/* ====== export menu ====== */
.export-menu { position: relative; display: inline-flex; }
.export-menu__pop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 1000;
  min-width: 168px;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.export-menu__pop[hidden] { display: none; }
.export-menu__item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: calc(var(--r-md) - 3px);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.export-menu__item:hover,
.export-menu__item:focus-visible { background: var(--bg-sunken); color: var(--ink-1); }

/* ====== form bits ====== */
.label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: -0.005em;
}
.help { font-size: 12px; color: var(--ink-3); line-height: 1.5; }

.input, .select {
  height: 36px; padding: 0 12px;
  font-family: inherit; font-size: 13.5px;
  color: var(--ink-1);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  outline: none;
}
.input:focus, .select:focus {
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink-2) 12%, transparent);
}

/* ====== toggle ====== */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  width: 32px; height: 18px;
  background: var(--ink-5);
  border-radius: 999px;
  position: relative;
  transition: background .15s ease;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle--on .toggle-track { background: var(--ink-1); }
.toggle--on .toggle-thumb { transform: translateX(14px); }
[data-theme="dark"] .toggle--on .toggle-thumb { background: var(--bg); }

/* ====== question mark tooltip ====== */
.qm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--ink-5);
  color: var(--ink-4);
  font-size: 9.5px;
  font-weight: 600;
  cursor: help;
  font-family: var(--font-sans);
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background .1s, color .1s;
}
.qm:hover { background: var(--ink-5); color: var(--bg-elev); border-color: var(--ink-5); }
.qm-wrap { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.qm-pop {
  position: fixed;
  z-index: 1000;
  width: 260px;
  max-width: calc(100vw - 24px);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
  box-shadow: var(--shadow-pop);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  pointer-events: none;
  white-space: normal;
  overflow-wrap: break-word;
}
.qm-pop .pop-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-4);
  margin-bottom: 4px;
  font-weight: 600;
}
.qm-pinned .qm { background: var(--ink-1); color: var(--bg-elev); border-color: var(--ink-1); }
.qm-pinned .qm-pop { pointer-events: auto; }

/* ====== panel ====== */
.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.metric-action {
  padding: 14px 16px;
  border-right: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background .12s ease;
}
.metric-action:hover,
.metric-action:focus-visible {
  background: var(--bg-sunken);
  outline: none;
}

/* ====== chips ====== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--ink-2);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-4); }
.chip--ok    { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-border); }
.chip--ok    .dot { background: var(--ok); }
.chip--warn  { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip--warn  .dot { background: var(--warn); }
.chip--bad   { color: var(--bad);  background: var(--bad-bg);  border-color: var(--bad-border); }
.chip--bad   .dot { background: var(--bad); }
.chip--info  { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip--info  .dot { background: var(--info); }
.chip--unverified { color: var(--unverified); background: var(--unverified-bg); border-color: var(--unverified-border); }
.chip--unverified .dot { background: var(--unverified); }
.chip--mute  { color: var(--ink-3); background: var(--bg-sunken); border-color: var(--border); }
.chip--mute  .dot { background: var(--ink-4); }
.chip--sq { border-radius: var(--r-sm); }

/* ====== score pill ====== */
.score {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
.score-bar {
  width: 36px; height: 4px;
  background: var(--bg-sunken);
  border-radius: 2px;
  overflow: hidden;
}
.score-bar > i { display: block; height: 100%; border-radius: 2px; }
.score--ok   { color: var(--ok); }
.score--ok   .score-bar > i { background: var(--ok); }
.score--warn { color: var(--warn); }
.score--warn .score-bar > i { background: var(--warn); }
.score--bad  { color: var(--bad); }
.score--bad  .score-bar > i { background: var(--bad); }
.score--mute { color: var(--ink-4); }
.score--mute .score-bar > i { background: var(--ink-5); }

/* ====== table ====== */
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl thead th {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.tbl thead th.sortable { cursor: pointer; }
.tbl thead th.sortable .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  color: var(--ink-4);
  font-size: 9px;
}
.tbl thead th.sorted { color: var(--ink-1); }
.tbl thead th.sorted .sort-arrow { color: var(--ink-1); }
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  color: var(--ink-1);
}
.tbl tbody tr:hover { background: var(--bg-row-hover); }
.tbl tbody tr.expanded { background: var(--bg-row-hover); }
.tbl tbody tr.expanded > td { border-bottom-color: transparent; }
.tbl tbody tr.subrow { background: var(--bg-sunken); }
.tbl tbody tr.subrow:hover { background: var(--bg-sunken); }
.tbl tbody tr.subrow > td { border-bottom: 1px solid var(--border-subtle); }
.tbl tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody td.cell-mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: -0.01em; }

.row-toggle {
  width: 18px; height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.row-toggle:hover { background: var(--border); color: var(--ink-1); }
.row-toggle svg { transition: transform .15s ease; }
.row-toggle.open svg { transform: rotate(90deg); }

/* ====== simple-view citation validity ====== */
.validity-various {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.validity-various:hover { text-decoration: underline; }
.validity-caret { display: inline-block; font-size: 9px; transition: transform .15s ease; }
.validity-caret.open { transform: rotate(90deg); }
.validity-list {
  list-style: none;
  margin: 6px 0 2px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
}
.validity-list li { white-space: nowrap; }

/* ====== filter chips ====== */
.filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s;
}
.filter-chip:hover { background: var(--bg-sunken); }
.filter-chip.active { background: var(--ink-1); color: var(--bg-elev); border-color: var(--ink-1); }
.filter-chip .count { font-size: 11px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.filter-chip.active .count { color: color-mix(in srgb, var(--bg-elev) 70%, transparent); }

/* ====== dropzone ====== */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  padding: 36px 28px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
  cursor: default;
}
.dropzone:hover { border-color: var(--ink-3); background: var(--bg-sunken); }
.dropzone--active { border-color: var(--ink-1); border-style: solid; background: var(--bg-sunken); }
.dropzone__icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  margin-bottom: 12px;
}

/* ====== progress bar ====== */
.bar {
  height: 4px; width: 100%;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block; height: 100%;
  background: var(--ink-1);
  border-radius: 999px;
  transition: width .3s ease;
}

/* ====== rationale ====== */
.rationale {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
.rationale .lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  font-weight: 600;
  margin-bottom: 2px;
}
.canlii-meta {
  gap: 10px;
}
.canlii-meta > div + div {
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

/* ====== extraction-health notice ====== */
.notice--warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 16px;
}
.notice--warn .notice-icon {
  color: var(--warn);
  font-size: 14px;
  line-height: 1.4;
  flex-shrink: 0;
}
.notice--warn .notice-title {
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 3px;
}
.notice--warn .notice-body ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.notice--warn .notice-body li {
  margin-bottom: 2px;
}

/* "More info" expander inside a notice (e.g. identity-unconfirmed citations) */
.notice-more-info {
  margin-top: 8px;
}
.notice-more-info > summary {
  display: inline-block;
  cursor: pointer;
  list-style: none;
  appearance: none;
  padding: 3px 10px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-sm, 6px);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-1);
  user-select: none;
}
.notice-more-info > summary::-webkit-details-marker {
  display: none;
}
.notice-more-info > summary::after {
  content: ' ▸';
  font-weight: 400;
}
.notice-more-info[open] > summary::after {
  content: ' ▾';
}
.notice-more-info > summary:hover {
  background: var(--warn-bg);
}
.notice-more-info-body {
  margin-top: 6px;
}
.notice-more-info-body ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

/* danger variant — e.g. AI scoring failed, results incomplete */
.notice--bad {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bad-bg);
  border: 1px solid var(--bad-border);
  border-radius: var(--r-md);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 16px;
}
.notice--bad .notice-icon {
  color: var(--bad);
  font-size: 14px;
  line-height: 1.4;
  flex-shrink: 0;
}
.notice--bad .notice-title {
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: 3px;
}

.pin-context-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--bad);
  border-radius: var(--r-sm);
  min-width: 24px;
  height: 22px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.pin-context-btn:hover {
  background: var(--bad-bg);
  border-color: var(--bad-border);
}
.pin-context-btn--valid {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}
.pin-context-btn--valid:hover,
.pin-context-btn--valid:focus-visible {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, var(--ok-bg));
  border-color: var(--ok);
}
.pin-context-btn--invalid {
  color: var(--bad);
  background: var(--bad-bg);
  border-color: var(--bad-border);
}
.pin-context-btn--unknown {
  color: var(--ink-3);
  background: var(--bg-sunken);
  border-color: var(--border);
}
.pin-context-btn--unknown:hover,
.pin-context-btn--unknown:focus-visible {
  color: var(--ink-1);
  background: var(--bg-elev);
  border-color: var(--border-strong);
}
.pin-context-btn[aria-expanded="true"] {
  box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 3px currentColor;
}
.pin-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}
.pin-compare > div {
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
}
.pin-compare .lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  font-weight: 600;
  margin-bottom: 4px;
}
.legislation-provision + .legislation-provision {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
.legislation-provision__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.legislation-provision__head .lbl {
  margin-bottom: 0;
}
.legislation-provision__text {
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
  white-space: pre-wrap;
}
.legislation-pin-analysis {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
}
.legislation-pin-analysis__title {
  margin-bottom: 10px;
  color: var(--ink-1);
  font-weight: 600;
}
.legislation-pin-analysis__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 16px;
}
.legislation-pin-analysis .lbl {
  margin-bottom: 3px;
  color: var(--ink-4);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.legislation-pin-analysis__explanation {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
@media (max-width: 760px) {
  .pin-compare { grid-template-columns: 1fr; }
  .legislation-pin-analysis__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ====== system vs. manual status (opened citation row) ====== */
.status-compare {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 12px 4px;
}
.status-compare__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.status-compare__lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  font-weight: 600;
}

/* ====== utilities ====== */
.muted  { color: var(--ink-3); }
.faint  { color: var(--ink-4); }
.row    { display: flex; align-items: center; gap: 8px; }
.col    { display: flex; flex-direction: column; }
.h-divider { width: 1px; background: var(--border); align-self: stretch; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .35; transform: scale(.7); }
}

/* ====== manual case text upload modal ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(14, 17, 22, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, .6); }

.modal-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 500px;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-panel--wide {
  max-width: 760px;
}
.modal-panel h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--ink-1);
  line-height: 1.3;
}
.modal-panel .modal-cite {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.modal-panel .modal-body {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}
.modal-panel .modal-body strong { color: var(--ink-1); font-weight: 600; }

.manual-case-current {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  padding: 12px 13px;
}
.manual-case-current-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 7px;
}
.manual-case-current-body {
  font-size: 13px;
  color: var(--ink-2);
}
.manual-case-current-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.manual-case-preview {
  max-height: 110px;
  overflow: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  font: 12px/1.45 var(--font-mono);
  color: var(--ink-2);
  white-space: pre-wrap;
}

.modal-file-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.modal-file-zone:hover, .modal-file-zone.drag-over {
  border-color: var(--ink-2);
  background: var(--bg-sunken);
}
.modal-file-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.modal-file-zone .zone-label {
  font-size: 13px;
  color: var(--ink-3);
  pointer-events: none;
}
.modal-file-zone .zone-label strong { color: var(--ink-2); font-weight: 500; }
.modal-file-zone .zone-picked {
  font-size: 13px;
  color: var(--ink-1);
  font-weight: 500;
  pointer-events: none;
}

.modal-footer {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
}
.modal-status {
  font-size: 13px;
  margin-right: auto;
  min-width: 0;
  flex: 1;
  color: var(--ink-3);
}
.modal-status.ok  { color: var(--ok); }
.modal-status.err { color: var(--bad); }
.modal-status.is-running {
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  border-radius: var(--r);
  padding: 8px 10px;
  color: var(--ink-2);
}
.modal-progress-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-1);
}
.modal-progress-detail {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
}
.modal-progress-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.manual-queue-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.manual-queue-summary > div {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  background: var(--bg-sunken);
}
.manual-queue-summary strong {
  display: block;
  font: 600 20px var(--font-mono);
  color: var(--ink-1);
}
.manual-queue-summary span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
}
.manual-queue-section { margin-top: 16px; }
.manual-queue-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
}
.manual-queue-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
}
.manual-queue-row:first-of-type { border-top: 0; }
.manual-queue-main { min-width: 0; }
.manual-queue-title {
  color: var(--ink-1);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.manual-queue-detail {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 12px;
}
.manual-queue-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--ink-4);
}
.manual-queue-empty {
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-4);
  font-size: 12.5px;
}

.timing-total {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--ink-3);
}
.timing-total strong {
  color: var(--ink-1);
  font-weight: 500;
}
.timing-table {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.timing-detail {
  margin-top: 3px;
  color: var(--ink-4);
  font-size: 12px;
  line-height: 1.35;
}

.batch-map {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-elev);
}
.batch-map-head,
.batch-map-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(260px, 1.1fr);
  gap: 12px;
  align-items: center;
}
.batch-map-head {
  padding: 9px 12px;
  background: var(--bg-sunken);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.batch-map-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
}
.batch-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 12.5px;
}
.batch-citation-select {
  width: 100%;
  min-width: 0;
}

/* A2AJ "no case file" → single chip-button that signals both the negative
   state and the action. Replaces the old ✕ + ↑ + ? trio. */
.btn-upload-case {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  letter-spacing: .01em;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease;
  vertical-align: middle;
}
.btn-upload-case .upload-arrow {
  font-size: 12.5px;
  line-height: 1;
  color: var(--ink-4);
  transition: color .12s ease, transform .12s ease;
}
.btn-upload-case:hover,
.btn-upload-case:focus-visible {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
  border-style: solid;
  outline: none;
}
.btn-upload-case:hover .upload-arrow,
.btn-upload-case:focus-visible .upload-arrow {
  color: var(--info);
  transform: translateY(-1px);
}

.btn-manual-case {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info);
  cursor: pointer;
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
  vertical-align: middle;
}
.btn-manual-case .dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--info);
}
.btn-manual-case:hover,
.btn-manual-case:focus-visible {
  background: color-mix(in srgb, var(--info) 13%, var(--info-bg));
  border-color: var(--info);
  outline: none;
  transform: translateY(-1px);
}

/* CanLII ✓ rendered as a pill-link so it visually announces "click to open"
   instead of looking identical to the A2AJ ✓ (which is just a status icon). */
.canlii-case-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.canlii-case-link .canlii-check { font-size: 12.5px; line-height: 1; }
.canlii-case-link .canlii-label { font-weight: 600; }
.canlii-case-link .canlii-ext { font-size: 11px; opacity: .8; transition: transform .12s ease, opacity .12s ease; }
.canlii-case-link:hover,
.canlii-case-link:focus-visible {
  background: color-mix(in srgb, var(--ok) 18%, var(--ok-bg));
  border-color: var(--ok);
  box-shadow: 0 1px 0 var(--ok-border);
  outline: none;
}
.canlii-case-link:hover .canlii-ext,
.canlii-case-link:focus-visible .canlii-ext {
  transform: translate(1px, -1px);
  opacity: 1;
}
.canlii-case-link--warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}
.canlii-case-link--warn:hover,
.canlii-case-link--warn:focus-visible {
  background: color-mix(in srgb, var(--warn) 18%, var(--warn-bg));
  border-color: var(--warn);
  box-shadow: 0 1px 0 var(--warn-border);
}
.canlii-case-link--info {
  border-color: var(--border-strong);
  background: var(--bg-sunken);
  color: var(--ink-2);
}
.canlii-case-link--info:hover,
.canlii-case-link--info:focus-visible {
  background: var(--bg-elev);
  border-color: var(--ink-3);
  box-shadow: 0 1px 0 var(--border);
}

/* A2AJ "Found" → green check + label + download affordance, sibling of
   .canlii-case-link but themed around downloading the case-text Word doc. */
.a2aj-found-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.a2aj-found-link .canlii-check { font-size: 12.5px; line-height: 1; }
.a2aj-found-link .canlii-label { font-weight: 600; }
.a2aj-found-link .a2aj-download { font-size: 12px; opacity: .8; transition: transform .12s ease, opacity .12s ease; }
.a2aj-found-link:hover,
.a2aj-found-link:focus-visible {
  background: color-mix(in srgb, var(--ok) 18%, var(--ok-bg));
  border-color: var(--ok);
  box-shadow: 0 1px 0 var(--ok-border);
  outline: none;
}
.a2aj-found-link--warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}
.a2aj-found-link--warn:hover,
.a2aj-found-link--warn:focus-visible {
  background: color-mix(in srgb, var(--warn) 18%, var(--warn-bg));
  border-color: var(--warn);
  box-shadow: 0 1px 0 var(--warn-border);
}
.a2aj-found-link:hover .a2aj-download,
.a2aj-found-link:focus-visible .a2aj-download {
  transform: translateY(1px);
  opacity: 1;
}

/* Small badge shown on the A2AJ "Found" button when text came from HuggingFace fallback */
.a2aj-fallback-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  vertical-align: middle;
  pointer-events: none;
}

/* ====== legislation citations (docs/legislation-contract.md §7) ======
   Sibling button/link styles for the laws-status cell, mirroring the
   case-flow classes above (.btn-upload-case / .btn-manual-case /
   .a2aj-found-link) exactly, so a legislation row's affordances read as part
   of the same visual system rather than a bolted-on variant. The type badge
   itself needs no dedicated rule — it reuses .chip.chip--info.chip--sq as-is. */
.btn-upload-legislation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  letter-spacing: .01em;
  transition: background .12s ease, color .12s ease, border-color .12s ease, transform .12s ease;
  vertical-align: middle;
}
.btn-upload-legislation .upload-arrow {
  font-size: 12.5px;
  line-height: 1;
  color: var(--ink-4);
  transition: color .12s ease, transform .12s ease;
}
.btn-upload-legislation:hover,
.btn-upload-legislation:focus-visible {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
  border-style: solid;
  outline: none;
}
.btn-upload-legislation:hover .upload-arrow,
.btn-upload-legislation:focus-visible .upload-arrow {
  color: var(--info);
  transform: translateY(-1px);
}

.btn-manual-legislation {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info);
  cursor: pointer;
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
  vertical-align: middle;
}
.btn-manual-legislation .dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--info);
}
.btn-manual-legislation:hover,
.btn-manual-legislation:focus-visible {
  background: color-mix(in srgb, var(--info) 13%, var(--info-bg));
  border-color: var(--info);
  outline: none;
  transform: translateY(-1px);
}

/* Legislation "Found" → green check + label + external-link affordance
   (opens source_url_en directly), sibling of .a2aj-found-link. */
.legislation-found-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  color: var(--ok);
  font: 500 11.5px var(--font-sans);
  line-height: 1;
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.legislation-found-link .canlii-check { font-size: 12.5px; line-height: 1; }
.legislation-found-link .canlii-label { font-weight: 600; }
.legislation-found-link .a2aj-download { font-size: 12px; opacity: .8; transition: transform .12s ease, opacity .12s ease; }
.legislation-found-link:hover,
.legislation-found-link:focus-visible {
  background: color-mix(in srgb, var(--ok) 18%, var(--ok-bg));
  border-color: var(--ok);
  box-shadow: 0 1px 0 var(--ok-border);
  outline: none;
}
.legislation-found-link:hover .a2aj-download,
.legislation-found-link:focus-visible .a2aj-download {
  transform: translate(1px, -1px);
  opacity: 1;
}

/* ====== CanLII-for-legislation (docs/canlii-legislation-contract.md §7) ======
   Legislation rows now also get a CanLII existence check (a secondary signal
   alongside the A2AJ laws corpus check above). It deliberately needs NO new
   rules here: the CanLII button/link for a legislation row reuses
   .canlii-case-link / .canlii-case-link--warn as-is (app.js's mark() and
   simpleCanliiCell()), and the new "Wrong statute" / "Repealed" / "Found on
   CanLII" per-instance badges reuse the existing .chip.chip--sq.chip--{bad,
   warn,info,ok} system with inline sizing, exactly like every other
   per-instance badge in the expanded table (nameMismatchBadge,
   fullTextUnverifiedBadge, legislationInstanceBadgeHtml's existing branches,
   etc.). All of it is already theme-aware via the --bad/--warn/--info/--ok
   custom properties, so light/dark both fall out for free. */

.instance-action {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: 270px;
}
.instance-action__meta {
  display: grid;
  gap: 4px;
  justify-items: start;
  max-width: 100%;
}
.instance-action__meta .chip {
  display: flex;
  align-items: flex-start;
  height: auto !important;
  min-height: 0;
  max-width: 100%;
  margin-top: 0 !important;
  padding: 3px 6px !important;
  white-space: normal;
  line-height: 1.25;
}
.instance-action__meta .chip .dot {
  flex: 0 0 5px;
  width: 5px;
  height: 5px;
  margin-top: 4px;
}
.instance-action__meta .btn {
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
}

/* Segmented review-decision group: Accept / Fraud / Ignore read as one
   control with three options rather than three loose buttons. */
.review-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elev);
}
.review-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font: 500 11.5px var(--font-sans);
  letter-spacing: .01em;
  height: 28px;
  padding: 0 11px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
  border-right: 1px solid var(--border-subtle);
}
.review-btn:last-child { border-right: none; }
.review-btn:hover { background: var(--bg-sunken); color: var(--ink-1); }
.review-btn:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.review-btn.is-active { color: var(--bg-elev); font-weight: 600; }
.review-btn--ok.is-active { background: var(--ok); }
.review-btn--danger.is-active { background: var(--bad); }
.review-btn--ghost.is-active { background: var(--ink-3); }

/* ── Settings modal ── */
.settings-overlay .modal-panel {
  padding: 0;
  gap: 0;
  max-height: 90vh;
  overflow-y: auto;
}
.settings-overlay .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 1;
}
.settings-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.settings-db-opt {
  flex: 1;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  user-select: none;
}
.settings-db-opt:hover { border-color: var(--ink-3); background: var(--bg-sunken); }
.settings-db-opt.selected { border-color: var(--ink-1); background: var(--bg-sunken); }

/* ── Multi-model: document-page tab bar ──
   Hidden entirely (never rendered) when there's a single sentinel variant, so
   with the feature off the document page is visually identical to before —
   see modelTabBarHtml in app.js. Styled as a segmented control, distinct from
   .filter-row's pill chips so the two rows read as separate concerns even
   though the tab bar sits directly above the filter row. */
.model-tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  margin-bottom: 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: fit-content;
  max-width: 100%;
}
.model-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font: 12.5px var(--font-sans);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s, color .1s;
}
.model-tab:hover { color: var(--ink-1); background: var(--bg-elev); }
.model-tab.is-active {
  background: var(--bg-elev);
  color: var(--ink-1);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
[data-theme="dark"] .model-tab.is-active { box-shadow: 0 1px 2px rgba(0,0,0,.35); }
.model-tab:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }

/* ── Multi-model: run-form model chips ──
   The removable chips assembled in the "Models to run" picker (renderProviderPanel
   / multiModelPickerHtml). Reuses .chip's color language but adds an inline
   remove control the base chip doesn't have. */
.model-config-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
}
.model-config-chip__remove {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  opacity: .65;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
}
.model-config-chip__remove:hover { opacity: 1; background: rgba(0,0,0,.08); }
[data-theme="dark"] .model-config-chip__remove:hover { background: rgba(255,255,255,.12); }

/* Multi-model per-model review context (task E) — the "Reviewed under
   <model>" / "Unreviewed under this model" notes reuse .chip.chip--sq.chip--mute
   as-is (see siblingReviewBadgeHtml in app.js), so no dedicated rule is
   needed here; in the Regular view it sits in .instance-action__meta
   alongside the other per-instance badges, in Simple View inside the
   review-group column. */

/* ── Model comparison (docs/model-comparison-plan.md) ──────────────
   The Compare button lives inside .model-tab-bar as the last element,
   tinted blue (--info) rather than the tabs' gray, in both idle and
   selected states — see modelTabBarHtml/renderCompareView in app.js. */
.model-tab--compare {
  margin-left: auto;
  color: var(--info);
  background: var(--info-bg);
}
.model-tab--compare:hover { background: color-mix(in srgb, var(--info) 18%, var(--info-bg)); color: var(--info); }
.model-tab--compare.is-active {
  background: var(--info);
  color: var(--bg-elev);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
[data-theme="dark"] .model-tab--compare.is-active { box-shadow: 0 1px 2px rgba(0,0,0,.35); }

/* The All/Differences segmented control reuses .model-tab-bar/.model-tab
   verbatim (same gray-segmented look as the model tabs) — only spacing
   differs, so it reads as a sibling control rather than a new widget. */
.compare-toggle { margin: 4px 0 16px; }
/* …but the filter labels are fixed text, not user model names, so the
   220px .model-tab ellipsis cap must not apply — with the live AI Assist
   count appended ("Differences only + AI Assist 2/6") it truncated the
   count into "2/…" (user-reported). */
.compare-toggle .model-tab { max-width: none; }

/* The matrix scrolls horizontally in its own container — the page body
   itself must never scroll sideways (realistic case is 2-4 models, but nothing
   stops this from growing). */
.compare-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
}
/* min-content, NOT max-content: under max-content sizing every 1fr track
   resolves to the widest unwrapped line of its cells, so one long rationale
   paragraph stretched the entire matrix off-screen (user-reported). With
   min-content the matrix is exactly as wide as its minimum tracks
   (220px meta + 190px per model) or the container, whichever is larger —
   text wraps inside each column, and only a genuinely too-narrow viewport
   (many models) engages the wrapper's own horizontal scrollbar. */
.compare-matrix { min-width: min-content; }

.compare-cit-group + .compare-cit-group { border-top: 1px solid var(--border); }
.compare-cit-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-1);
  position: sticky;
  left: 0;
  width: fit-content;
  min-width: 100%;
}

.compare-row {
  display: grid;
  grid-template-columns: 220px repeat(var(--cmp-cols, 2), minmax(190px, 1fr));
  border-bottom: 1px solid var(--border-subtle);
}
.compare-row:last-child { border-bottom: none; }
.compare-row:hover:not(.compare-header-row) { background: var(--bg-row-hover); }

/* AI-judgment disagreement (row.diff.differs) — a blue-tinted highlight,
   matching the Compare button's own blue so "this is a compare-mode finding"
   reads as one visual language. Deliberately a different hue from the
   enrichment-differs chip (purple/--unverified) so the two signals are never
   confused (plan §4/§5). */
.compare-row--diff {
  background: color-mix(in srgb, var(--info) 6%, transparent);
  box-shadow: inset 3px 0 0 var(--info);
}
.compare-row--diff:hover { background: color-mix(in srgb, var(--info) 11%, transparent); }

.compare-header-row {
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 1;
}
.compare-header-cell { padding: 10px 12px; }
.compare-header-cell__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-header-cell__count { font-size: 11px; margin-top: 2px; }

.compare-cell {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  /* Long unbroken tokens (URLs, case identifiers) must break inside the
     column rather than widening its min-content and forcing the matrix
     wider than the viewport. */
  overflow-wrap: anywhere;
}
.compare-cell--meta {
  gap: 4px;
  color: var(--ink-3);
  font-size: 11px;
}
.compare-row-toggle {
  cursor: pointer;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.compare-row-toggle:focus-visible { outline: 2px solid var(--info); outline-offset: -2px; }
.compare-delta {
  font: 11px var(--font-mono);
  color: var(--ink-2);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Breathing room between the Rel/Pin Diff numbers and the "?" help icon. */
.compare-delta .qm-wrap { margin-left: 7px; }

.compare-cell--absent {
  color: var(--ink-4);
  background: repeating-linear-gradient(135deg, var(--bg-sunken) 0 8px, var(--bg-elev) 8px 16px);
  justify-content: center;
  align-items: center;
  font-size: 11.5px;
}

.compare-cell__scores { display: flex; gap: 10px; font-size: 11.5px; color: var(--ink-3); }
.compare-cell__verdict { font-size: 12px; color: var(--ink-2); }

/* Differing-field highlight — marks BOTH (or all) sides of a mismatch, never
   just one (plan §5). Distinct from .compare-row--diff so a field can be
   pointed to precisely even when scanning a wide row. */
.compare-field--diff {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  box-shadow: 0 0 0 1px var(--warn-border);
}

/* Enrichment-differs — deliberately the unverified/purple hue, never warn or
   info, so it reads as its own category of pipeline-noise signal rather than
   an AI disagreement (plan §4). */
.compare-enrichment-chip { margin-left: 2px; }

.compare-rationale-row {
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.compare-cell--rationale {
  font-size: 12px;
  color: var(--ink-2);
  gap: 8px;
}
.compare-cell--rationale .lbl {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink-4);
  margin-bottom: 2px;
}

.compare-empty {
  padding: 48px 20px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
}

/* ── AI Assist column (compare mode, "Differences only + AI Assist") ──
   A per-row comparative summary of what the models disagreed about. Shares
   .compare-cell's box model so it joins the same grid/--cmp-cols as every
   other column (see compareInstanceRowHtml/compareAiCellHtml in app.js) —
   only the text treatment differs, reading as prose rather than a score. */
.compare-cell--ai {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-2);
  white-space: normal;
}
.compare-cell--ai-empty {
  color: var(--ink-4);
  font-size: 11.5px;
  justify-content: center;
  align-items: center;
}

/* ── Document delete flow (model-aware) ──
   The choice modal's two options, styled like .settings-db-opt's selectable
   cards but as plain buttons (there's no "selected" state — clicking one
   acts immediately/advances). The safe action (delete just this model) stays
   visually neutral/primary; only the document-wide option gets the danger
   treatment, so the two read at a glance as "safe" vs "destructive". */
.delete-choice-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 2px;
}
.delete-choice-opt {
  appearance: none;
  text-align: left;
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.delete-choice-opt:hover { border-color: var(--ink-3); background: var(--bg-sunken); }
.delete-choice-opt:disabled { opacity: .6; cursor: default; }
.delete-choice-opt__title { font-size: 13.5px; font-weight: 600; color: var(--ink-1); margin-bottom: 3px; }
.delete-choice-opt__detail { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
.delete-choice-opt--danger { border-color: var(--bad-border); background: var(--bad-bg); }
.delete-choice-opt--danger:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bad-bg)); }
.delete-choice-opt--danger .delete-choice-opt__title { color: var(--bad); }
.delete-choice-opt--danger .delete-choice-opt__detail { color: var(--ink-2); }
