:root {
  --bg: #0f1419; --panel: #161c24; --panel2: #1c242e; --line: #2a333f;
  --ink: #e8edf2; --muted: #9aa7b4; --faint: #6b7988;
  --accent: #3b82c4; --accent2: #5aa0e0; --gold: #c9a24b; --star: #e2b43a;
  --good: #3f9e74; --warn: #c98a3a; --bad: #c25b54; --chip: #233041;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f4f6f9; --panel:#fff; --panel2:#f7f9fc; --line:#e2e8f0; --ink:#1a2330; --muted:#54606e; --faint:#8793a0; --chip:#eef2f7; --shadow:0 1px 2px rgba(16,24,40,.06),0 8px 24px rgba(16,24,40,.08); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 32px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; letter-spacing: .2px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 5px; }
.login-card input { width: 100%; padding: 11px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 14.5px; }
.login-card input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.login-card button { width: 100%; margin-top: 20px; padding: 11px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font-size: 15px; font-weight: 600; }
.login-card button:hover { background: var(--accent2); }
.login-err { color: var(--bad); font-size: 13px; margin-top: 12px; min-height: 16px; }
.priv-banner { background: linear-gradient(90deg, #3a2c0e, #2a2410); border: 1px solid var(--gold); color: var(--gold); font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; text-align: center; padding: 6px; border-radius: 6px; margin-bottom: 20px; font-weight: 600; }
@media (prefers-color-scheme: light){ .priv-banner{ background:#fbf3df; color:#8a6d1f; } }

/* ── Shell ── */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.topbar .brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.topbar .matter { color: var(--muted); font-size: 12.5px; border-left: 1px solid var(--line); padding-left: 16px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 12.5px; }
.topbar .who b { color: var(--ink); }
.topbar button.logout { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; font-size: 12.5px; }
.topbar button.logout:hover { color: var(--ink); border-color: var(--faint); }
.priv-strip { background: #241c0a; color: var(--gold); text-align: center; font-size: 11px; letter-spacing: .5px; padding: 4px; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--line); }
@media (prefers-color-scheme: light){ .priv-strip{ background:#fbf3df; color:#8a6d1f; } }

.layout { display: grid; grid-template-columns: 290px 1fr; gap: 0; align-items: start; }
@media (max-width: 900px){ .layout{ grid-template-columns: 1fr; } .sidebar{ position: static !important; height:auto !important; border-right:0; border-bottom:1px solid var(--line);} }

.sidebar { position: sticky; top: 49px; height: calc(100vh - 49px); overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 18px 16px 40px; }
.sidebar h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); margin: 20px 0 8px; }
.sidebar h3:first-child { margin-top: 0; }
.search-box { width: 100%; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 14px; }
.search-box:focus { outline: 2px solid var(--accent); }
.facet { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--muted); }
.facet:hover { background: var(--panel2); color: var(--ink); }
.facet input { accent-color: var(--accent); }
.facet .count { margin-left: auto; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.facet.on { color: var(--ink); }
select.filter { width: 100%; padding: 9px 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 13.5px; }
.clearbtn { margin-top: 14px; width: 100%; padding: 8px; background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 12.5px; }
.clearbtn:hover { color: var(--ink); border-color: var(--faint); }

.main { padding: 20px 26px 80px; min-width: 0; }
.resultbar { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin-bottom: 14px; flex-wrap: wrap; }
.resultbar .n { color: var(--ink); font-weight: 600; }

/* ── Entry cards ── */
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow); overflow: hidden; }
.entry.star { border-left: 3px solid var(--star); }
.entry-head { padding: 14px 18px; cursor: pointer; display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; align-items: start; }
.entry-head:hover { background: var(--panel2); }
.entry .date { font-family: var(--mono); font-size: 12.5px; color: var(--accent2); white-space: nowrap; padding-top: 1px; }
.entry .date .star { color: var(--star); margin-right: 3px; }
.entry .headmain { min-width: 0; }
.entry .title { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.entry .phase { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.entry .people { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { background: var(--chip); color: var(--muted); font-size: 11.5px; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.chip.mark { background: #1d2e42; color: var(--accent2); font-family: var(--mono); font-weight: 600; }
.chip.src { font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; }
.chip.src.archive { background: #13301f; color: var(--good); }
.chip.src.gdrive_doc, .chip.src.ext_or_folder { background: #2e2410; color: var(--warn); }
.chip.src.reconstruction_2026 { background: #241d2e; color: #b48ad0; }
.chip.src.inferred { background: #262626; color: var(--faint); }
.entry .evcount { text-align: right; white-space: nowrap; font-size: 12px; color: var(--muted); }
.entry .evcount .big { display:block; font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.entry .caret { color: var(--faint); font-size: 12px; margin-left: 6px; }

.entry-body { border-top: 1px solid var(--line); padding: 4px 18px 18px; display: none; }
.entry.open .entry-body { display: block; }
.entry .summary { color: var(--muted); font-size: 13.5px; margin: 14px 0; max-width: 72ch; }
.sec-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); margin: 18px 0 8px; }

/* ── Exhibit email rows ── */
.exhibit { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel2); }
.exhibit-head { padding: 10px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; flex-wrap: wrap; }
.exhibit-head:hover { background: var(--panel); }
.exhibit .marktag { background: #1d2e42; color: var(--accent2); font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.exhibit .ex-subj { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 160px; }
.exhibit .ex-meta { color: var(--faint); font-size: 12px; font-family: var(--mono); }
.exhibit .conf { font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.conf.high { background: #13301f; color: var(--good); }
.conf.medium { background: #2e2410; color: var(--warn); }
.conf.low { background: #30201f; color: var(--bad); }
.exhibit .aid { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.exhibit-detail { display: none; border-top: 1px solid var(--line); padding: 12px; }
.exhibit.open .exhibit-detail { display: block; }
.kv { display: grid; grid-template-columns: 70px 1fr; gap: 3px 10px; font-size: 13px; margin-bottom: 10px; }
.kv .k { color: var(--faint); }
.kv .v { color: var(--ink); word-break: break-word; }
.basis { font-size: 12.5px; color: var(--muted); font-style: italic; margin: 6px 0 10px; padding: 8px 10px; background: var(--panel); border-left: 2px solid var(--line); border-radius: 0 6px 6px 0; }
.emailbody { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; max-height: 460px; overflow: auto; font-size: 13px; }
.emailbody.html-body { background: #fff; color: #111; }
.emailbody pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-family: var(--sans); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn { background: var(--chip); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 7px 12px; font-size: 12.5px; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent2); }
.atts { margin-top: 6px; }
.att { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; margin-bottom: 5px; font-size: 12.5px; background: var(--panel); }
.att .fn { flex: 1; word-break: break-word; }
.att .sz { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.att.unavailable { opacity: .55; }
.att.unavailable .fn::after { content: " — not in archive"; color: var(--faint); font-style: italic; }

.external-doc { padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel2); }
.external-doc .dl { font-weight: 600; font-size: 13.5px; }
.external-doc .note { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.loading, .empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); color: var(--ink); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; z-index: 50; }
mark { background: #4a3c12; color: #f0d98a; padding: 0 2px; border-radius: 2px; }
@media (prefers-color-scheme: light){ mark{ background:#fcefb8; color:#5c4a12; } .emailbody.html-body{ background:#fff; } }
