:root {
  --bg: #f4f7f8; --paper: #fff; --ink: #102a33; --muted: #5d727c;
  --accent: #0f6e6b; --wash: #e7f5f3; --line: #d5e0e4;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #10181c; --paper: #182328; --ink: #e7eef2; --muted: #9aafb8;
  --accent: #7dccc6; --wash: #1d3336; --line: #2c4148; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); overflow-x: hidden; }
button, input, select { font: inherit; font-size: 16px; }
button, a, summary { touch-action: manipulation; }
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.gate { min-height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.card, .panel, .case { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.card { width: min(100%, 420px); padding: 22px 18px; }
h1 { font-family: var(--serif); letter-spacing: -0.04em; line-height: 1.12; margin: 6px 0; }
.eyebrow { margin: 0; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
label { display: block; font-weight: 650; margin: 12px 0 6px; }
input[type="password"], input[type="search"], select {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; background: var(--paper); color: var(--ink);
}
.primary, .quiet { min-height: 44px; border-radius: 8px; padding: 10px 14px; font-weight: 650; }
.primary { border: 0; background: var(--accent); color: #fff; }
.slim { width: auto; }
.quiet { border: 1px solid var(--line); background: transparent; color: var(--ink); }
.error { color: #b54747; min-height: 1.2em; }
.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow: auto; padding: max(12px, env(safe-area-inset-top)) 12px 16px; border-right: 1px solid var(--line); background: var(--paper); }
.brand { font-family: var(--serif); font-size: 32px; font-weight: 700; color: var(--ink); }
.brand-note { margin: 0 0 12px; color: var(--muted); }
.directory { display: grid; gap: 4px; margin-top: 12px; }
.dir-link { display: flex; gap: 10px; align-items: center; min-height: 52px; padding: 6px; border-radius: 10px; color: var(--ink); }
.dir-link[aria-current="page"] { background: var(--wash); }
.face, .monogram { width: 40px; height: 52px; border-radius: 6px; object-fit: cover; flex: none; background: var(--wash); }
.monogram { display: grid; place-items: center; font-weight: 750; color: var(--accent); }
.dir-link span { min-width: 0; }
.dir-link small { display: block; color: var(--muted); font-size: 12px; }
.main-column { min-width: 0; }
.top { position: sticky; top: 0; z-index: 4; display: flex; gap: 8px; align-items: center; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.grow { flex: 1; min-width: 0; margin: 0; }
#main { padding: 8px 12px max(28px, env(safe-area-inset-bottom)); max-width: 920px; }
.panel, .case { padding: 16px; margin: 0 0 12px; }
.identity { display: flex; gap: 14px; align-items: flex-start; }
.identity .face { width: 92px; height: 122px; }
.meta, .alias, .year { color: var(--muted); font-size: 14px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.cases { display: grid; gap: 8px; }
.case-link { display: block; padding: 14px; min-height: 44px; }
.case-link strong, .hit strong { display: block; font-size: 18px; }
.q { border-top: 1px solid var(--line); padding: 14px 0; }
.q h2 { font-size: 18px; line-height: 1.4; margin: 0 0 6px; }
.answer { margin: 8px 0 0; padding-left: 18px; }
.answer b, .stem b { color: var(--accent); }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.focus { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: var(--bg); }
.focus[hidden], #app[hidden], #gate[hidden] { display: none !important; }
.focus-bar, .focus-foot { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--paper); }
.focus-bar { padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.focus-foot { flex-direction: column; align-items: stretch; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.focus-foot p { margin: 0; color: var(--muted); font-size: 12px; }
.focus-who { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; font-weight: 700; }
.focus-who .face { width: 32px; height: 42px; }
.focus-body { flex: 1; overflow: auto; padding: 18px 16px 28px; }
.focus-nav { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; }
.hit { display: block; padding: 14px; margin-bottom: 8px; }
.deck { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 16px 14px 18px; margin: 8px 0 14px; min-height: 62dvh; touch-action: pan-y; }
.deck .topic { margin: 8px 0 0; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.deck h1 { font-size: clamp(28px, 7vw, 40px); margin: 2px 0 6px; }
.deck .ask { font-size: clamp(20px, 4.8vw, 26px); line-height: 1.35; margin: 12px 0; }
.kicker, .hint, .vote-badge { color: var(--muted); font-size: 13px; }
.vote-buttons { display: flex; gap: 8px; }
.vote-badge .up { color: #0f6e6b; font-weight: 750; }
.vote-badge .down { color: #9b3d3d; font-weight: 750; }
.deck.vote-up { box-shadow: inset 0 6px 0 #1f8a72; }
.deck.vote-down { box-shadow: inset 0 -6px 0 #9b3d3d; }
.explain { margin: 8px 0 12px; }
.explain img { width: 100%; max-height: 280px; object-fit: contain; background: #fff; border-radius: 8px; }
.explain figcaption { color: var(--muted); font-size: 12px; line-height: 1.4; }
table.grid { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: 15px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
table.grid th { background: var(--wash); width: 28%; }
table.grid caption { text-align: left; font-weight: 750; color: var(--accent); margin-bottom: 4px; }
.jump { margin-top: 8px; }
.slim-panel h1 { font-size: 28px; }
@media (max-width: 640px) {
  .deck { min-height: 70dvh; }
  table.grid { font-size: 14px; display: block; overflow-x: auto; }
}
@media (max-width: 800px) {
  .workspace { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .directory { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
  .dir-link { flex: none; width: 148px; align-items: flex-start; }
  .top { flex-wrap: wrap; }
  .identity .face { width: 76px; height: 100px; }
}
