:root {
  --bg: #fcfcfb;
  --surface: #ffffff;
  --text: #0b0b0b;
  --muted: #52514e;
  --line: #e4e3df;
  --up: #1a7f37;
  --down: #b42318;
  --accent: #1f3c88;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --surface: #1f1f1d; --text: #f2f1ee; --muted: #a8a7a2; --line: #33322f; --up: #4cc26e; --down: #f26b5b; --accent: #8fa9ef; }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.button { background: var(--accent); color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .button { color: #0b0b0b; } }
.icon-button { background: none; border: 0; color: var(--text); font-size: 22px; padding: 0 4px; cursor: pointer; }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px 24px; }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.45; }
.section-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 22px 0 8px; text-transform: uppercase; letter-spacing: 0.4px; }

.card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.card .when { font-size: 13px; color: var(--muted); }
.card .headline { font-size: 17px; font-weight: 600; margin: 4px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.chip.up { color: var(--up); border-color: currentColor; }
.chip.down { color: var(--down); border-color: currentColor; }
.chip.added { color: var(--accent); border-color: currentColor; }
.open-hint { font-size: 13px; color: var(--accent); margin-top: 10px; }

.runs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.runs .card { padding: 11px 14px; }
.runs .headline { font-size: 15px; margin: 2px 0 6px; }

#report-view { max-width: none; padding: 0; }
#export { border: 0; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

.sheet { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; padding: 8px;
  background: var(--surface); color: var(--text); margin: auto auto calc(16px + env(safe-area-inset-bottom)); }
.sheet::backdrop { background: rgb(0 0 0 / 0.35); }
.sheet form { display: grid; gap: 4px; }
.sheet-title { font-weight: 600; margin: 8px 10px 4px; }
.sheet-item { display: grid; gap: 2px; text-align: left; font: inherit; font-size: 16px; color: var(--accent); background: none;
  border: 0; border-radius: 10px; padding: 11px 10px; cursor: pointer; }
.sheet-item span { font-size: 12px; color: var(--muted); }
.sheet-item:hover, .sheet-item:focus-visible { background: var(--bg); }
.sheet-item:disabled { opacity: 0.5; cursor: default; }
.sheet-item.cancel { color: var(--muted); text-align: center; }
.sheet #export-status { margin: 0 10px 6px; }
.sheet #export-status:empty { display: none; }
#report { display: block; width: 100%; height: calc(100dvh - 54px - env(safe-area-inset-top)); border: 0; background: #fcfcfb; }

.analyze { cursor: default; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.analyze-title { font-weight: 600; font-size: 16px; }
.text-input { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.text-input:focus { outline: none; border-color: var(--accent); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.segmented label { text-align: center; padding: 7px 4px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented label:has(input:checked) { color: #0b0b0b; } }
.button.wide { border: 0; font: inherit; font-weight: 600; padding: 10px; cursor: pointer; }
.button:disabled { opacity: 0.6; cursor: default; }
#analyze-status:empty { display: none; }
#analyze-status { margin: 0; }
.presets { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.preset { font: inherit; font-size: 14px; color: var(--accent); background: none; border: 1px solid currentColor; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.preset:disabled { opacity: 0.6; cursor: default; }
