/* Discovery Loop shared design system (D-025).
   Language borrowed from the Clearlaw obligations-tracker mockups: warm paper
   surfaces, serif headings (legal gravitas), sans UI, mono for identifiers and
   numbers, semantic color used sparingly as badges/accent bars. Variable NAMES
   are kept identical to the earlier per-page palettes so existing markup and
   inline styles keep working — only the values and components changed. */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #f8f6f1;
  --bg-warm: #f3f0e8;
  --card: #ffffff;
  --ink: #2c2a26;
  --text: #2c2a26;
  --muted: #6f675e;
  --line: #e2ddd4;
  --line-strong: #c8c0b4;
  --accent: #35567a;          /* steel ink-blue: action color that sits on paper */
  --accent-soft: #e9eef5;
  --brand: #7a1f2b;           /* oxblood: Estoc brand identity (the mark) — NOT an action color */
  --brand-soft: #f3e6e8;
  --ok: #2d6a4f;   --ok-soft: #e8f5e9;
  --warn: #9a6b00; --warn-soft: #f7edd4;
  --red: #c43030;  --red-soft: #fde8e8;
  --green: #2d6a4f;
  --wp: #7b48a8;   --wp-soft: #f0e8f8;   /* work product */
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 13.5px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- app frame ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 22px; display: flex; align-items: center; gap: 4px; height: 52px;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: 18px; }
.brand-mark { width: 22px; height: 26px; display: block; flex: none; }
.brand-name { display: flex; flex-direction: column; line-height: 1; font-family: var(--serif); }
.brand-name b { font-weight: 600; font-size: 18px; color: var(--ink); letter-spacing: -0.01em; }
.brand-name small { font-family: var(--sans); font-weight: 600; font-size: 8px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.topbar a {
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 600;
  padding: 0 12px; height: 52px; display: inline-flex; align-items: center;
  border-bottom: 2px solid transparent;
}
.topbar a:hover { color: var(--ink); }
.topbar a.here, .topbar a[class*="here"] { color: var(--accent); border-bottom-color: var(--accent); }
.spacer { flex: 1; }
.wrap { max-width: 1020px; margin: 0 auto; padding: 22px 24px 70px; }

/* ---------- typography ---------- */
h1 { font-family: var(--serif); font-size: 21px; font-weight: 600; margin: 8px 0 14px; letter-spacing: -0.01em; }
h1 .meta { font-family: var(--sans); font-weight: 400; }
h2 { font-family: var(--serif); font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.sub { color: var(--muted); font-size: 13px; margin: -6px 0 16px; max-width: 68ch; }
.meta { color: var(--muted); font-size: 12px; }
.mono, .timer { font-family: var(--mono); font-size: 12px; }
.timer { font-weight: 600; }

/* ---------- surfaces ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px;
}
.card.item { border-left: 4px solid var(--line-strong); padding: 14px 18px; }
.card.item.approved { border-left-color: var(--ok); }
.card.item.edited   { border-left-color: var(--accent); }
.card.item.followup { border-left-color: var(--warn); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--muted); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.07em; background: var(--bg-warm);
}
tr.rowlink { cursor: pointer; }
tr.rowlink:hover { background: var(--bg-warm); }
td .mono { color: var(--muted); }

/* ---------- badges / pills ---------- */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 3px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.p-ok   { background: var(--ok-soft);   color: var(--ok); }
.p-warn { background: var(--warn-soft); color: var(--warn); }
.p-info { background: var(--accent-soft); color: var(--accent); }
.p-red  { background: var(--red-soft);  color: var(--red); }
.p-gray { background: var(--bg-warm);   color: var(--muted); }
.p-wp   { background: var(--wp-soft);   color: var(--wp); }

/* ---------- verbatim / answers / flags (review anatomy) ---------- */
.orig {
  font-family: var(--serif); font-size: 12.5px; color: var(--muted);
  background: var(--bg-warm); border-left: 3px solid var(--line-strong);
  border-radius: 0 6px 6px 0; padding: 9px 12px; margin: 8px 0; white-space: pre-wrap;
}
.answer {
  background: var(--card); border: 1px dashed var(--line-strong); border-radius: 6px;
  padding: 9px 12px; font-size: 13px; margin: 8px 0;
}
.answer b {
  display: block; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 3px;
}
.flag {
  background: var(--red-soft); border-left: 3px solid var(--red);
  border-radius: 0 6px 6px 0; padding: 8px 12px; font-size: 12.5px; margin: 6px 0;
}
.flag .sev { font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; }
.flag .src { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.wp-note { font-size: 11px; color: var(--wp); font-family: var(--sans); font-weight: 600; }
.preview { margin: 8px 0; white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
mark.confirm { background: #f6dc90; border-radius: 2px; padding: 0 3px; font-weight: 600; }
.confirm-count { color: var(--warn); font-size: 11px; font-weight: 700; font-family: var(--mono); }

/* ---------- forms ---------- */
label { display: block; font-size: 11px; font-weight: 600; margin: 12px 0 4px;
        text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
input, select, textarea {
  width: 100%; font-family: var(--sans); font-size: 13.5px; padding: 9px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea.resp { min-height: 120px; resize: vertical; line-height: 1.6; }
.row { display: flex; gap: 14px; } .row > div { flex: 1; }
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: 8px; background: var(--bg-warm); border-style: dashed; }

/* ---------- buttons ---------- */
button, a.btn {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  border-radius: 6px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #2b4763; }
button.okbtn { background: var(--ok); border-color: var(--ok); color: #fff; }
button.warnbtn { background: var(--card); color: var(--warn); border-color: var(--warn); }
button.danger { background: var(--card); color: var(--red); border-color: var(--red); }
button:disabled { opacity: 0.45; cursor: default; }
.linkbtn { background: none; border: none; color: var(--accent); cursor: pointer;
           font-size: 12px; padding: 2px 4px; font-family: var(--sans); }
.linkbtn:hover { text-decoration: underline; border: none; }

/* ---------- messages / banners / states ---------- */
#msg { min-height: 20px; font-size: 12.5px; margin-top: 8px; white-space: pre-wrap; }
#msg.err { color: var(--red); } #msg.ok { color: var(--ok); }
.banner { border-radius: 6px; padding: 11px 14px; font-weight: 600; margin-bottom: 12px; font-size: 13px; }
.b-passed { background: var(--red-soft); color: var(--red); border-left: 4px solid var(--red); }
.b-urgent { background: var(--warn-soft); color: var(--warn); border-left: 4px solid var(--warn); }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: 6px;
          padding: 11px 14px; font-size: 12.5px; margin-bottom: 14px; border-left: 4px solid var(--warn); }
.empty {
  text-align: center; color: var(--muted); padding: 42px 20px; font-size: 13px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg-warm);
}
.empty .hint { font-size: 12px; margin-top: 6px; }
.empty a { color: var(--accent); }

.trail, pre.trail {
  background: var(--bg-warm); border-left: 3px solid var(--line-strong);
  border-radius: 0 6px 6px 0; padding: 11px 14px; font-size: 12px;
  white-space: pre-wrap; font-family: var(--mono); line-height: 1.7; margin: 8px 0;
}
.linkbox { background: var(--ok-soft); border-radius: 6px; padding: 12px 14px;
           word-break: break-all; font-family: var(--mono); font-size: 12.5px; }

.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--accent-soft);
        border-top-color: var(--accent); border-radius: 50%; animation: dlspin 0.8s linear infinite;
        vertical-align: -2px; }
@keyframes dlspin { to { transform: rotate(360deg); } }

.login-box { max-width: 380px; margin: 90px auto; }
.login-box h1, .login-box h2 { text-align: center; }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
a.back { color: var(--accent); text-decoration: none; font-size: 12.5px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- app shell: sidebar rail (D-028, per the obligations tracker) ---------- */
.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--card); border-right: 1px solid var(--line);
  padding: 14px 10px 12px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 2px 10px 16px; font-size: 16px; margin-right: 0; }
.side-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 0 10px 6px;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: block; padding: 7px 10px; border-radius: 6px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 13px;
  border-left: 3px solid transparent; height: auto;
}
.side-nav a:hover { background: var(--bg-warm); color: var(--ink); }
.side-nav a.here { background: var(--bg-warm); color: var(--accent); border-left-color: var(--accent); }
.side-foot {
  margin-top: auto; padding: 10px 10px 0; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.7;
}
.content { min-width: 0; }
.content .wrap { max-width: 1080px; margin: 0; padding: 16px 28px 60px; }
/* On the sign-in screen show only the brand — nav / identity / sign-out don't
   apply until you're authed. CSS-only via :has() so it covers every page; the
   sidebar element stays (grid intact, login not squished — cf. F-19). */
.app:has(.login-box) :is(.side-label, .side-nav, .side-foot) { display: none; }
.page-head {
  padding: 10px 28px; border-bottom: 1px solid var(--line); background: var(--card);
  font-size: 12.5px; color: var(--muted); min-height: 20px;
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center;
             gap: 4px; border-right: none; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0 12px 0 4px; }
  .side-label { display: none; }
  .side-nav { flex-direction: row; }
  .side-foot { margin: 0 4px 0 auto; padding: 0; border: none; }
}

/* Review: per-set tabs (test-run-2 feedback) */
.set-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 15; background: var(--bg, #fff);
  padding: 10px 0; border-bottom: 1px solid var(--line-strong); margin-bottom: 14px; }
.set-tab { border: 1px solid var(--line-strong); background: var(--card); border-radius: 6px;
  padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
  box-shadow: 0 1px 2px rgba(30,25,15,0.07); }
.set-tab:hover { color: var(--ink); }
.set-tab.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.set-tab .meta { font-weight: 400; margin-left: 6px; }
.set-tab .pill { margin-left: 6px; }
.tab-filter { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* D-040 P0 — promoted components (design review 2026-07)
   Recording = RED (universal convention; this dot governs billable accrual).
   Purple is reserved for work product ONLY; direction chips are accent-family:
   inbound (responding) = filled, outbound (their responses / propounding) =
   outlined. */
.rec-state { font-size: 12px; white-space: nowrap; }
.rec-state.on { color: var(--red); font-weight: 600; }
.rec-state.off { color: var(--muted); }
.dirchip { font-size: 10px; letter-spacing: .05em; font-weight: 700;
  text-transform: uppercase; padding: 2px 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.dirchip.out { background: transparent; border: 1px solid var(--accent);
  color: var(--accent); }
.wp-note { color: var(--wp); font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; }

/* D-042 — shell notification surface (badge + toast) and the delta band */
.nav-badge { display: inline-block; margin-left: 8px; min-width: 18px; text-align: center;
  background: var(--red); color: #fff; border-radius: 9px; font-size: 10px;
  font-weight: 700; padding: 1px 5px; font-family: var(--mono); }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex;
  gap: 12px; align-items: center; max-width: 380px; padding: 12px 14px;
  background: var(--card, #fff); border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); font-size: 12.5px; }
.toast + .toast { bottom: 92px; }
.toast-x { background: none; border: none; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 0 2px; }
.delta-band { border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }
.delta-band .row { display: flex; gap: 10px; align-items: baseline; padding: 3px 0;
  font-size: 13px; }
.delta-band .ts { font-family: var(--mono); font-size: 11px; color: var(--muted);
  white-space: nowrap; }
.done-banner { border-left: 3px solid var(--ok); background: #eef6ee;
  border-radius: 6px; padding: 12px 14px; margin: 10px 0; display: flex;
  gap: 12px; align-items: center; }

/* D-043 P3 — trust surface. The §6 boundary gets a VISUAL expression: any
   line's status (privileged vs servable) is identifiable from the background
   alone, without reading a label. Purple = privileged, only (D-040). */
.wp-zone { background: var(--wp-soft); border-left: 3px solid var(--wp);
  border-radius: 4px; padding: 8px 10px; margin: 8px 0; }
.wp-zone::before { content: "ATTORNEY WORK PRODUCT — NEVER SERVED";
  display: block; color: var(--wp); font-size: 10px; font-weight: 700;
  letter-spacing: .05em; margin-bottom: 4px; }
.servable-zone { background: #fff; border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent); border-radius: 4px; padding: 8px 10px;
  margin: 8px 0; }
.servable-zone::before { content: "SERVABLE — GOES TO OPPOSING COUNSEL";
  display: block; color: var(--accent); font-size: 10px; font-weight: 700;
  letter-spacing: .05em; margin-bottom: 4px; }

/* one sub-item card language (was .flag / .finding / .req, three styles) */
.subcard { border-left: 3px solid var(--warn); padding: 8px 10px; margin: 8px 0;
  background: var(--bg-warm); border-radius: 4px; }
.subcard.sev-high { border-left-color: var(--red); }
.subcard.sev-low { border-left-color: var(--muted); }
.subcard.excluded { opacity: .45; border-left-color: var(--muted); }

/* refusal panel — legal-consequence refusals never arrive via alert() */
.refusal-panel { border: 1px solid var(--red); border-left: 3px solid var(--red);
  background: var(--red-soft); border-radius: 6px; padding: 12px 14px; margin: 10px 0; }
.refusal-panel h3 { margin: 0 0 6px; color: var(--red); font-size: 13px; }
.refusal-panel li { font-size: 12.5px; margin: 2px 0; }

/* inline confirm bar (bulk approvals restate their scope at commitment) */
.confirm-bar { display: flex; gap: 10px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--warn); border-left: 3px solid var(--warn);
  background: #fdf6e3; border-radius: 6px; margin: 8px 0; font-size: 13px; }

/* state craft: loading + error states, keyboard focus */
.loading-state { display: flex; gap: 10px; align-items: center; color: var(--muted);
  padding: 40px 0; justify-content: center; font-size: 13px; }
.error-state { border: 1px solid var(--line-strong); border-left: 3px solid var(--red);
  background: var(--card, #fff); border-radius: 6px; padding: 16px; margin: 14px 0;
  font-size: 13px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }

/* D-044 — working-set rail */
.dl-done { padding: 0 14px; display: flex; flex-direction: column; gap: 6px; }
.dl-done-item { display: flex; flex-direction: column; text-decoration: none;
  color: var(--ink); font-size: 12px; padding: 5px 8px; border-radius: 5px;
  border-left: 2px solid var(--ok); background: var(--bg-warm); }
.dl-done-item span { color: var(--muted); font-size: 11px; }
.dl-done-item:hover { background: var(--accent-soft); }
.dlk-overlay { position: fixed; inset: 0; background: rgba(30,25,20,.35);
  z-index: 200; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh; }
.dlk-box { width: min(560px, 90vw); background: var(--card, #fff);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); overflow: hidden; }
.dlk-box input { width: 100%; border: none; border-bottom: 1px solid var(--line);
  padding: 14px 16px; font-size: 14px; outline: none; background: transparent; }
.dlk-row { display: flex; gap: 10px; align-items: baseline; padding: 9px 16px;
  text-decoration: none; color: var(--ink); font-size: 13px; }
.dlk-row.on, .dlk-row:hover { background: var(--accent-soft); }
