:root {
  --bg: #0c0d0e;
  --bg-elevated: #17181a;
  --bg-inset: #090a0a;
  --bg-raised: var(--bg-elevated);
  --paper: #ece6d8;
  --paper-dim: #a39c8d;
  --ink: #ece6d8;
  --ink-soft: #a39c8d;
  --ink-faint: #6e6858;
  --gold: #c9a44c;
  --gold-bright: #e3c374;
  --oxblood: #b4483a;
  --oxblood-bright: #d1614f;
  --line: #2b2b28;
  --line-bright: #423f38;
  --rule: var(--line);
  --rule-strong: var(--line-bright);
  --accent: var(--gold);
  --accent-soft: rgba(201, 164, 76, 0.14);
  --accent-ink: #1a1509;
  --good: #8fbf8f;
  --good-soft: rgba(143, 191, 143, 0.12);
  --warn: var(--gold-bright);
  --risk: var(--oxblood-bright);
  --risk-soft: rgba(180, 72, 58, 0.12);
  --serif: "Fraunces", "Iowan Old Style", serif;
  --sans: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); scrollbar-gutter: stable; }
body { background: var(--bg); color: var(--paper); font-family: var(--sans); line-height: 1.6; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
input, textarea, button { font-family: inherit; font-size: inherit; }
a { color: var(--gold); }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media print { .grain { display: none; } }

.gate-card, .btn-primary, .btn-secondary { font-family: var(--sans); }

/* ---------- gate ---------- */
.view-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; position: relative; z-index: 1; }
.gate-card { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 4px; padding: 2.75rem 2.5rem 2.5rem; max-width: 400px; text-align: center; }
.gate-kicker { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.6rem; }
.gate-card h1 { font-family: var(--serif); font-size: 1.5rem; margin: 0 0 0.75rem; }
.gate-card p { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 1.5rem; }

.btn-primary {
  display: inline-block; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 4px;
  padding: 0.7rem 1.2rem; font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
}
.btn-primary:hover { background: var(--gold-bright); }
.btn-secondary {
  background: var(--bg-raised); color: var(--accent); border: 1.5px solid var(--accent); border-radius: 4px;
  padding: 0.55rem 1rem; font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.btn-secondary:hover { background: var(--accent-soft); }

/* ---------- masthead (identical to the account portal's, per Gee —
   same banner across all three screens, not a distinct surface) ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse 900px 300px at 15% -20%, rgba(201, 164, 76, 0.08), transparent);
  position: relative; z-index: 1;
}
.masthead-inner {
  max-width: 1100px; margin: 0 auto; padding: 28px 32px 24px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.wordmark-kicker {
  display: block; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 10px;
}
.wordmark h1 { font-family: var(--serif); font-size: 34px; font-weight: 500; letter-spacing: -0.01em; margin: 0; color: var(--paper); }
.wordmark-em { font-style: normal; font-weight: 600; color: var(--paper); }
.masthead-side { display: flex; align-items: center; gap: 20px; padding-bottom: 6px; }
.masthead-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.masthead .link-btn {
  margin: 0; display: inline; font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  color: var(--paper-dim); text-decoration: none; border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1px; transition: color 0.15s ease, border-color 0.15s ease;
}
.masthead .link-btn:hover { color: var(--gold-bright); border-color: var(--gold); }

.stage { max-width: 1100px; margin: 0 auto; padding: 2.25rem 32px 4rem; }

/* ---------- search hero ---------- */
.search-hero { margin-bottom: 2.25rem; }
.search-hero h2 { font-family: var(--serif); font-size: 1.7rem; font-weight: 600; margin: 0 0 0.3rem; }
.search-hint { color: var(--ink-faint); font-size: 0.85rem; margin: 0 0 1.1rem; }
.search-bar input {
  width: 100%; font-size: 1.05rem; padding: 0.85rem 1.1rem; border: 1.5px solid var(--rule-strong);
  border-radius: 6px; background: var(--bg-raised); color: var(--ink);
}
.search-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.results-empty { color: var(--ink-faint); font-size: 0.88rem; padding: 1rem 0.2rem; }
.results-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 5px;
  padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.12s ease;
}
.result-row:hover { border-color: var(--accent); }
.result-row.active { border-color: var(--accent); background: var(--accent-soft); }
.result-name { font-weight: 700; font-size: 0.94rem; }
.result-meta { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-faint); }
.result-count { font-size: 0.78rem; color: var(--accent); font-weight: 600; white-space: nowrap; }

/* ---------- two-column: report + chat ---------- */
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.col-panel { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 6px; padding: 1.4rem 1.5rem; min-width: 0; }
.panel-label { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.9rem; }

.report-placeholder { color: var(--ink-faint); font-size: 0.88rem; padding: 2rem 0.5rem; text-align: center; }
.report-print-only { display: none; }
.report-head h3 { font-family: var(--serif); font-size: 1.25rem; margin: 0 0 0.15rem; }
.report-dni { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-faint); margin-bottom: 1rem; }
.report-case { border-top: 1px solid var(--rule); padding-top: 0.75rem; margin-top: 0.75rem; }
.report-case:first-child { border-top: none; margin-top: 0; }
.report-case-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.25rem; }
.report-case-meta { font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 0.35rem; }
.report-case-signals { font-size: 0.82rem; color: var(--warn); }
.report-actions { margin-top: 1.25rem; }

/* ---------- chat ---------- */
.chat-log { display: flex; flex-direction: column; gap: 0.65rem; max-height: 340px; overflow-y: auto; margin-bottom: 0.9rem; }
.chat-msg { font-size: 0.86rem; padding: 0.6rem 0.8rem; border-radius: 5px; line-height: 1.5; }
.chat-msg-assistant { background: var(--bg-elevated); border: 1px solid var(--rule); color: var(--paper); align-self: flex-start; }
.chat-msg-user { background: var(--bg); border: 1px solid var(--rule); align-self: flex-end; }
.chat-msg-error { background: var(--risk-soft); color: var(--risk); }
.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; padding: 0.6rem 0.75rem; border: 1px solid var(--rule-strong); border-radius: 4px; }
.chat-form input:focus { outline: none; border-color: var(--accent); }

/* ---------- new-request panel ---------- */
.request-panel .request-hint { font-size: 0.82rem; color: var(--ink-faint); margin: -0.4rem 0 1rem; }
.request-form { display: flex; flex-direction: column; gap: 0.75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.request-form input {
  padding: 0.6rem 0.75rem; border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--bg-raised); color: var(--ink);
}
.request-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.request-form .btn-primary { align-self: flex-start; }
.form-error { background: var(--risk-soft); color: var(--risk); border-left: 3px solid var(--risk); padding: 0.55rem 0.75rem; border-radius: 3px; font-size: 0.82rem; }
.form-success { background: var(--good-soft); color: var(--good); border-left: 3px solid var(--good); padding: 0.55rem 0.75rem; border-radius: 3px; font-size: 0.82rem; }

/* ---------- print ---------- */
@media print {
  .masthead, .search-hero, #chat-panel, .request-panel, .no-print { display: none !important; }
  .two-col { display: block; }
  .stage { padding: 0; max-width: none; }
  .col-panel { border: none; padding: 0; }
  .report-print-only { display: block; }
  .report-print-header { margin-bottom: 1.5rem; border-bottom: 2px solid #2e3f6e; padding-bottom: 0.75rem; }
  .report-print-brand { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; color: #2e3f6e; }
  .report-print-sub { font-size: 0.85rem; color: #444; }
  .report-footer-note { margin-top: 2rem; font-size: 0.72rem; color: #666; border-top: 1px solid #ccc; padding-top: 0.75rem; }

  /* Printing must never depend on the (now dark/gold) live theme
     tokens — hardcode every color a printed report actually shows,
     the same way webapp/static/styles.css's own print block does,
     so a page printed after this reskin still comes out as a normal
     black-on-white document instead of pale text on a dark/gold page. */
  html, body { background: #fff !important; color: #1d2129 !important; }
  .report-head h3 { color: #1d2129; }
  .report-dni { color: #666; }
  .report-case { border-top-color: #ccc; }
  .report-case-name { color: #1d2129; }
  .report-case-meta { color: #666; }
  .report-case-signals { color: #9c5f1f; }
}
