/* Replay theme: same palette and type as Proof. */
:root {
  --bg: #f0f4f8; --surface: #ffffff; --card: #ffffff; --card2: #f8fafc;
  --border: #e2e8f0; --border2: #cbd5e1;
  --blue: #2563eb; --blue-dim: #dbeafe; --teal: #22d3a5; --navy: #1e3a5f;
  --gold: #d97706; --gold-dim: #fef3c7; --green: #16a34a; --red: #dc2626;
  --text: #1e293b; --text2: #64748b; --text3: #94a3b8;
  --mono: 'DM Mono', ui-monospace, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Syne', 'Inter', system-ui, sans-serif;
  --radius: 12px; --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #0f172a; --card: #111a2e; --card2: #0f172a;
  --border: #1f2a40; --border2: #2b3a55;
  --blue: #60a5fa; --blue-dim: #172554; --gold-dim: #3b2a0a;
  --text: #e2e8f0; --text2: #94a3b8; --text3: #64748b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--text2); } .faint { color: var(--text3); }
.mono, .num { font-family: var(--mono); }
.num { text-align: right; white-space: nowrap; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font: 700 18px var(--display); }
.brand img { width: 28px; height: 28px; }
.brand:hover { text-decoration: none; }
.topbar .crumb { color: var(--text2); font-weight: 500; }
.topbar .spacer { flex: 1; }
.page { max-width: 1120px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; color: var(--text2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--blue); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card h3 { margin-bottom: 6px; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--border2); }
.stat { font: 600 22px var(--mono); }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border2);
  background: var(--surface); color: var(--text); font: 500 14px var(--sans); cursor: pointer; }
.btn:hover { border-color: var(--text3); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ms { width: 100%; justify-content: center; padding: 10px 14px; }
.icon-btn { background: none; border: 0; color: var(--text2); cursor: pointer; padding: 6px; border-radius: 6px; font-size: 16px; }
.icon-btn:hover { background: var(--card2); color: var(--text); }
label { display: block; font-weight: 500; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--text2); margin-top: 4px; }
input[type=text], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border2); border-radius: 8px; background: var(--surface); color: var(--text); font: 14px var(--sans); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-dim); border-color: var(--blue); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; flex: 1; min-width: 180px; }
.inline .field.narrow { flex: 0 0 200px; min-width: 0; }
.inline .field.medium { flex: 0 0 240px; min-width: 0; }
.icon-btn svg { display: block; }
.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin-bottom: 8px; cursor: pointer; }
.radio input { margin-top: 3px; }

/* Badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.req { background: var(--blue-dim); color: var(--blue); }
.badge.opt { background: var(--card2); color: var(--text2); border: 1px solid var(--border); }
.badge.cond { background: var(--gold-dim); color: var(--gold); }
.badge.ok { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.badge.miss { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* File guide */
.fn { margin-bottom: 16px; }
.fn-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.fn-head p { margin: 2px 0 0; color: var(--text2); }
.kind { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.kind .name { font-weight: 600; }
.kind .meta { font-size: 13px; color: var(--text2); }
.kind .how { font-size: 13px; color: var(--text2); margin-top: 2px; }
.kind .files { grid-column: 1 / -1; font-size: 13px; }
.kind .files span { display: inline-block; margin: 2px 8px 0 0; padding: 2px 8px; background: var(--card2); border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 12px; }
.upload-form { grid-column: 1 / -1; background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }

/* Sign-in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin .card { width: 100%; max-width: 340px; text-align: center; padding: 28px; }
.signin img { width: 56px; height: 56px; margin-bottom: 10px; }
.signin h1 { margin-bottom: 4px; }
.signin p { margin: 0 0 20px; color: var(--text2); }
.signin .foot { margin: 16px 0 0; font-size: 12px; color: var(--text3); }
.error { background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--red); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 14px; text-align: left; }

/* Toast */
#toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50; }
#toast .t { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); margin-top: 8px; font-weight: 500; }
#toast .t.err { background: var(--red); }

.empty { text-align: center; padding: 32px; color: var(--text2); }
.banner { background: var(--gold-dim); color: var(--gold); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 500; }

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .page { padding: 16px; }
  .kind { grid-template-columns: 1fr; }
}

/* Utilities (no inline styles: the content security policy blocks them) */
.m-0 { margin: 0; } .mt-0 { margin-top: 0; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mb-16 { margin-bottom: 16px; }
.w-220 { max-width: 220px; } .small-text { font-size: 12px; }
.kind-side { text-align: right; }
.btn-link { margin-left: 4px; }

/* Mapping screen */
.warn-list { margin: 10px 0 0; padding-left: 18px; color: var(--gold); font-size: 13px; }
.ok-note { color: var(--green); font-weight: 500; margin-bottom: 10px; }
.card .error + .btn, .card .ok-note + .btn { margin-top: 2px; }
#problems .error { margin-bottom: 12px; }
td select { min-width: 190px; }
.grid-preview td { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--border); padding: 4px 8px; }
.stat.small-stat { font-size: 16px; }
.stat.good { color: var(--green); } .stat.bad { color: var(--red); }
.totals { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.read-ok { color: var(--green); font-weight: 600; }
details summary { cursor: pointer; color: var(--blue); font-weight: 500; }
.page-head .btn { white-space: nowrap; }
.kind .files span.superseded { opacity: .6; }
#result .card, #map-root > .card + .card { margin-top: 16px; }

/* Discovery */
.followup { margin-top: 6px; color: var(--gold); font-weight: 500; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); margin-top: 16px; }
.grid.two > .card { margin-top: 0; }
#analysis-box > .card, #analysis-box > .grid { margin-top: 16px; }
th.w-220 { width: 220px; }
.kind.excluded { opacity: .7; }
.kind.excluded .name { color: var(--text2); }
.btn.subtle { border-color: transparent; color: var(--text2); }
.btn.subtle:hover { border-color: var(--border2); color: var(--text); }

/* Drop zone */
.dz-field { flex: 2; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 88px; padding: 12px; border: 2px dashed var(--border2); border-radius: 10px; background: var(--surface);
  color: var(--text2); font-weight: 500; text-align: center; cursor: pointer; margin: 0; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--blue); outline: none; }
.dropzone.over { border-color: var(--blue); background: var(--blue-dim); color: var(--blue); }
.dropzone.has-file { border-style: solid; border-color: var(--green); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone .dz-icon { font-size: 18px; line-height: 1; }
.dropzone .dz-file { font-family: var(--mono); }
