/* DefenseDesk — case-file workspace for criminal defense.
   Dark by default (ink-blue + parchment, brass accent from courtroom fittings); light for print and bright rooms.
   Signature element: the case caption, set like a pleading caption. Everything else stays quiet. */

@font-face { font-family: "Public Sans"; src: url("/static/fonts/public-sans.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("/static/fonts/source-serif-4.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }

:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #121922; --panel: #19222d; --raised: #202b38; --line: #2b3847; --line-strong: #3a4a5d;
  --ink: #e6e1d6; --muted: #93a0b2; --faint: #6b788a;
  --brass: #d1a14a; --brass-ink: #1a1408; --brass-soft: rgba(209, 161, 74, .13);
  --link: #8db4e6;
  --good: #79c497; --good-soft: rgba(121, 196, 151, .12);
  --bad: #e5837a; --bad-soft: rgba(229, 131, 122, .12);
  --warn: #e3b45c; --warn-soft: rgba(227, 180, 92, .12);
  --ai: #b6a2ea; --ai-soft: rgba(182, 162, 234, .13);
  --mark: rgba(209, 161, 74, .35);
  --shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3; --panel: #ffffff; --raised: #f6f7f9; --line: #d9dee5; --line-strong: #bcc5d0;
  --ink: #1b2430; --muted: #5b6676; --faint: #8a94a2;
  --brass: #94661a; --brass-ink: #ffffff; --brass-soft: rgba(148, 102, 26, .1);
  --link: #1f4f8a;
  --good: #24663b; --good-soft: #e6f3ea; --bad: #a3271f; --bad-soft: #fbeceb;
  --warn: #835600; --warn-soft: #fbf1dd; --ai: #5b3a96; --ai-soft: #efe9fb;
  --mark: #ffe58a; --shadow: 0 1px 2px rgba(20, 30, 45, .06);
}
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    color-scheme: light;
    --bg: #eef0f3; --panel: #ffffff; --raised: #f6f7f9; --line: #d9dee5; --line-strong: #bcc5d0;
    --ink: #1b2430; --muted: #5b6676; --faint: #8a94a2;
    --brass: #94661a; --brass-ink: #ffffff; --brass-soft: rgba(148, 102, 26, .1);
    --link: #1f4f8a;
    --good: #24663b; --good-soft: #e6f3ea; --bad: #a3271f; --bad-soft: #fbeceb;
    --warn: #835600; --warn-soft: #fbf1dd; --ai: #5b3a96; --ai-soft: #efe9fb;
    --mark: #ffe58a; --shadow: 0 1px 2px rgba(20, 30, 45, .06);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; font: 14.5px/1.5 "Public Sans", system-ui, sans-serif; font-feature-settings: "tnum" 1;
       background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 3px; }
h1 { font: 600 24px/1.2 "Source Serif 4", Georgia, serif; margin: 0 0 4px; letter-spacing: -.005em; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 650; margin: 16px 0 8px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
p { max-width: 75ch; }

/* ---------- top bar ---------- */
header.top { display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 54px;
             background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font: 650 18px "Source Serif 4", Georgia, serif; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
header.top nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
header.top nav a { color: var(--muted); padding: 6px 10px; border-radius: 5px; font-size: 14px; white-space: nowrap; }
header.top nav a:hover { color: var(--ink); background: var(--raised); text-decoration: none; }
header.top nav a.on { color: var(--ink); background: var(--raised); }
header.top form.search { display: flex; gap: 6px; }
header.top form.search input { width: 200px; min-width: 120px; }
header.top form.search button, .case-search button { padding: 6px 12px; }
.who { display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); white-space: nowrap; }
.who a { color: var(--muted); }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.linkish:hover { color: var(--ink); }

main { max-width: 1260px; margin: 0 auto; padding: 24px 22px 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel.flat { box-shadow: none; background: transparent; }
.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1320px) { header.top form.search input { width: 140px; } .brand { font-size: 0; gap: 0; } }
@media (max-width: 900px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  header.top form.search { display: none; }
  header.top { gap: 10px; overflow-x: auto; }
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* ---------- the case caption (signature) ---------- */
.caption { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; padding: 6px 0 14px;
           border-bottom: 2px solid var(--brass); margin-bottom: 4px; }
.caption .parties { font: 600 30px/1.15 "Source Serif 4", Georgia, serif; letter-spacing: -.01em; }
.caption .parties .v { font-style: italic; font-weight: 400; color: var(--muted); margin: 0 .18em; }
.caption .docket { text-align: right; font: 500 15px "Source Serif 4", Georgia, serif; }
.caption .docket small { display: block; font: 12.5px "Public Sans", sans-serif; color: var(--muted); }
.caption .facts { grid-column: 1 / -1; display: flex; gap: 8px 18px; flex-wrap: wrap; color: var(--muted); font-size: 13.5px; }
.caption .facts b { color: var(--ink); font-weight: 600; }
.case-search { display: flex; gap: 6px; }
.case-search input { width: 200px; }

.tabs { display: flex; gap: 4px; margin: 0 0 20px; overflow-x: auto; }
.tabs a { padding: 10px 12px 9px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 14px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }

/* ---------- tables, forms, buttons ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 7px 9px; }
td { border-bottom: 1px solid var(--line); padding: 9px; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--raised) 60%, transparent); }

input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 5px;
                          background: var(--raised); color: var(--ink); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
textarea { width: 100%; min-height: 76px; resize: vertical; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 13px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.fields input, .fields select, .w100 { width: 100%; }
button, .btn { font: 600 13.5px "Public Sans", sans-serif; display: inline-block; padding: 7px 14px; border-radius: 5px;
               border: 1px solid var(--brass); background: var(--brass); color: var(--brass-ink); cursor: pointer; line-height: 1.3; }
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); font-weight: 500; }
.btn.ghost:hover, button.ghost:hover { border-color: var(--brass); filter: none; }
.btn.small, button.small { padding: 3px 9px; font-size: 12.5px; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); font-weight: 500; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
form.inline { display: inline; }

/* ---------- badges, flashes, citations ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 10px;
         background: var(--raised); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; vertical-align: 1px; }
.badge.ai { background: var(--ai-soft); color: var(--ai); border-color: transparent; }
.badge.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.court { background: var(--brass-soft); color: var(--brass); border-color: transparent; }
/* exhibit labels look like the sticker that goes on the paper */
.exhibit { display: inline-block; font: 600 12px "Source Serif 4", Georgia, serif; padding: 1px 7px; border: 1.5px solid var(--brass);
           color: var(--brass); border-radius: 3px; white-space: nowrap; }
.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.err { background: var(--bad-soft); color: var(--bad); }
.flash.info { background: var(--brass-soft); color: var(--ink); border-color: var(--brass-soft); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; }
.cite { font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--line-strong); padding: 2px 10px; margin-top: 5px; }
.cite q { font-style: italic; color: var(--ink); opacity: .9; }
.cite.unv { border-color: var(--warn); }
.draft td { background: color-mix(in srgb, var(--ai-soft) 50%, transparent); }
.due-over { color: var(--bad); font-weight: 600; }
.done { color: var(--faint); text-decoration: line-through; }
.empty { color: var(--muted); padding: 22px; text-align: center; }

/* ---------- document pages and media ---------- */
.page { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; background: var(--panel); }
.page .ph { display: flex; justify-content: space-between; padding: 7px 12px; border-bottom: 1px solid var(--line);
            background: var(--raised); font-size: 12.5px; color: var(--muted); border-radius: 6px 6px 0 0; }
.page pre { white-space: pre-wrap; margin: 0; padding: 14px; font: 13px/1.6 "Source Serif 4", Georgia, serif; max-height: 560px; overflow: auto; }
.page:target { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }
.player { position: sticky; top: 54px; background: var(--bg); padding: 8px 0; z-index: 2; }
.player video, .player audio { width: 100%; max-height: 430px; background: #000; border-radius: 6px; display: block; }
.seg { display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; padding: 6px 8px; border-radius: 5px; }
.seg:hover { background: var(--raised); }
.seg.now { background: var(--brass-soft); }
.seg .ts { font: 600 12.5px "Public Sans", sans-serif; color: var(--link); cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.seg .acts { visibility: hidden; }
.seg:hover .acts, .seg:focus-within .acts { visibility: visible; }
.transcript { max-height: 70vh; overflow: auto; }

/* ---------- upload progress ---------- */
.progress { margin-top: 12px; display: none; }
.progress.on { display: block; }
.progress .bar { height: 8px; border-radius: 4px; background: var(--raised); border: 1px solid var(--line); overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--brass); transition: width .2s linear; }
.progress .label { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- proceedings chain ---------- */
.chain { list-style: none; margin: 0; padding: 0; position: relative; }
.chain > li { position: relative; padding: 0 0 18px 30px; }
.chain > li::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 2px; background: var(--line-strong); }
.chain > li:last-child::before { display: none; }
.chain .dot { position: absolute; left: 0; top: 4px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--bg); }
.chain .current .dot { border-color: var(--brass); background: var(--brass); }
.chain .decided .dot { border-color: var(--muted); background: var(--muted); }
.chain .court-name { font: 600 17px "Source Serif 4", Georgia, serif; }

/* ---------- metric tiles (admin) ---------- */
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.tile .v { font: 600 26px "Source Serif 4", Georgia, serif; }
.tile .k { font-size: 12.5px; color: var(--muted); }

/* ---------- guidance ---------- */
.issue { border-left: 3px solid var(--brass); padding: 4px 0 4px 14px; margin-bottom: 16px; }
.issue h4 { margin: 0 0 4px; font: 600 16px "Source Serif 4", Georgia, serif; }

dialog { border: 1px solid var(--line-strong); border-radius: 8px; padding: 20px; max-width: 580px; width: 92vw; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(5, 9, 14, .55); }
.auth { max-width: 400px; margin: 70px auto; }
.auth input { width: 100%; }
.auth .brand { font-size: 26px; margin-bottom: 4px; }
.auth .brand img { width: 36px; height: 36px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* ---------- help ---------- */
.help { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
.help nav a { display: block; padding: 5px 0; color: var(--muted); }
.help nav a.on { color: var(--ink); font-weight: 600; }
.help article { max-width: 820px; }
.help article h2 { font: 600 21px "Source Serif 4", Georgia, serif; margin: 28px 0 8px; }
.help article h2:first-child { margin-top: 0; }
.help article p, .help article li { line-height: 1.65; }
.help figure { margin: 14px 0 22px; }
.help figure img { width: 100%; border: 1px solid var(--line); border-radius: 6px; display: block; }
.help figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
@media (max-width: 900px) { .help { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  header.top, .tabs, button, .btn, dialog { display: none !important; }
  body, html { background: #fff; color: #000; }
  .panel { border: 0; box-shadow: none; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Time sheets */
th.r, td.r { text-align: right; }
table.sheet th, table.sheet td { padding-left: 6px; padding-right: 6px; }
table.sheet th.today { color: var(--brass); }
table.sheet td.zero { color: var(--muted); }
table.sheet tfoot th { border-top: 1px solid var(--line); padding-top: 8px; }
.facts-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; color: var(--muted); }
.facts-row b { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.stats .big { font-family: "Source Serif 4", Georgia, serif; font-size: 28px; font-weight: 600; color: var(--ink); }
.timer.on { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.timer-clock { font-size: 26px; font-weight: 600; color: var(--brass); }
.nav-timer { color: var(--brass) !important; font-variant-numeric: tabular-nums; }
