/* Analytical Zero Public: styles. Loaded from 'self' only (style-src 'self'); no inline styles anywhere. */
:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #d9dee6;
  --text: #15191f;
  --text-2: #545e6c;
  --accent: #1f63c4;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #0b7a33;
  --warn: #8a5a00;
  --s1: #257de0; --s2: #f47230; --s3: #00b894; --s4: #f2a600;
  --gain: #00a07f; --loss: #ec4647;
  --grid: #e6e9ee; --axis: #9aa3af;
  --flag-bg: #fff4e0; --flag-ink: #6b4400;
  --radius: 14px;
  --gutter: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14171c; --surface: #1d2127; --surface-2: #262b33; --border: #343b45;
    --text: #eef1f5; --text-2: #a9b2bf; --accent: #5b9cf0; --accent-ink: #0d1117;
    --danger: #ff8a80; --ok: #4fd18b; --warn: #f0b64a;
    --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
    --gain: #00a888; --loss: #eb6263; --grid: #2b313a; --axis: #6b7584;
    --flag-bg: #3a2c12; --flag-ink: #ffd89a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c; --surface: #1d2127; --surface-2: #262b33; --border: #343b45;
  --text: #eef1f5; --text-2: #a9b2bf; --accent: #5b9cf0; --accent-ink: #0d1117;
  --danger: #ff8a80; --ok: #4fd18b; --warn: #f0b64a;
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --gain: #00a888; --loss: #eb6263; --grid: #2b313a; --axis: #6b7584;
  --flag-bg: #3a2c12; --flag-ink: #ffd89a;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font);
  padding: 0 var(--safe-r) 0 var(--safe-l);
  overflow-x: hidden;
}
h1 { font-size: 1.5rem; line-height: 1.2; margin: 8px 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 12px; top: calc(var(--safe-t) + 8px); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- header and navigation ---- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-t) + 10px) var(--gutter) 10px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { flex: none; }
.mark-bg { fill: #16324f; }
.mark-ring { fill: none; stroke: #e8f1ff; stroke-width: 2.6; }
.mark-slash { stroke: #4fd1b5; stroke-width: 2.6; stroke-linecap: round; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1rem; white-space: nowrap; }
.brand-sub { font-size: 0.78rem; color: var(--text-2); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.pill { font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--warn); }

.update-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px var(--gutter); font-size: 0.86rem;
  background: var(--flag-bg); color: var(--flag-ink); border-bottom: 1px solid var(--border);
}
.update-bar span { flex: 1 1 12em; }
.provenance-banner {
  margin: 0; padding: 8px var(--gutter); font-size: 0.8rem; color: var(--text-2); background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.provenance-banner strong { color: var(--text); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 4px calc(var(--safe-r) + 4px) calc(var(--safe-b) + 4px) calc(var(--safe-l) + 4px);
}
.tabs a {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 4px 2px; text-align: center;
  font-size: 0.74rem; font-weight: 600; color: var(--text-2); text-decoration: none; border-radius: 10px; line-height: 1.15;
}
.tabs a[aria-current="page"] { color: var(--accent); background: var(--surface-2); }

main { padding: 12px var(--gutter) calc(var(--safe-b) + 84px); max-width: 1180px; margin: 0 auto; outline: none; }
.lede { color: var(--text-2); max-width: 70ch; }

/* ---- cards, forms ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; min-width: 0; }
.hint { color: var(--text-2); font-size: 0.82rem; font-weight: 400; }
h2 .hint { margin-left: 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; font-weight: 600; min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 10px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 10px; min-height: 44px; width: 100%; min-width: 0;
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 14px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 10px; }
.form-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: end; }
.form-row label[for] { grid-column: 1 / -1; }
.form-row input { grid-column: 1 / 2; }
.form-row .btn-quiet { grid-column: 1 / -1; justify-self: start; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.btn {
  font: inherit; font-weight: 600; font-size: 0.95rem; border: 1px solid transparent; border-radius: 10px; min-height: 44px; padding: 9px 16px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-quiet { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 36px; padding: 5px 10px; font-size: 0.82rem; }
.form-error { color: var(--danger); font-weight: 600; }
fieldset.legs { border: 0; padding: 0; margin: 0 0 6px; min-width: 0; }
fieldset.legs legend { font-weight: 700; font-size: 0.9rem; margin-bottom: 6px; }
.leg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 8px; padding: 10px 0; border-top: 1px solid var(--border); align-items: end; }
.leg label { font-size: 0.78rem; }
.leg .btn { align-self: end; }

.research-flag { background: var(--flag-bg); color: var(--flag-ink); border-radius: 10px; padding: 8px 12px; font-size: 0.85rem; }

/* ---- results ---- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px; min-width: 0; }
.tile-v { font-size: 1.22rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-l { font-size: 0.78rem; color: var(--text-2); }
.prov { font-size: 0.76rem; color: var(--text-2); margin: 6px 0 8px; }
.table-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child { text-align: left; }
table.data thead th { color: var(--text-2); font-weight: 600; font-size: 0.78rem; }
.kv { display: grid; grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr); gap: 6px 12px; margin: 0 0 10px; }
.kv dt { color: var(--text-2); font-size: 0.85rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 0.82rem; }
.checks { padding-left: 1.2em; margin: 0; }
.checks li { margin: 3px 0; }
details.method summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details.method p { color: var(--text-2); font-size: 0.88rem; margin-top: 8px; }

/* ---- charts ---- */
.chart-box { position: relative; width: 100%; min-height: 120px; }
.chart { display: block; max-width: 100%; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero, .chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { stroke: var(--axis); }
.chart .ax-label { fill: var(--text-2); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .ax-title { fill: var(--text-2); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1 { stroke: var(--s1); } .chart .line.s2 { stroke: var(--s2); }
.chart .line.s3 { stroke: var(--s3); } .chart .line.s4 { stroke: var(--s4); }
.chart .band-outer { fill: var(--s1); fill-opacity: 0.14; stroke: none; }
.chart .band-inner { fill: var(--s1); fill-opacity: 0.3; stroke: none; }
.chart .bar { fill: var(--s1); }
.chart .bar.bar-down { fill: var(--s2); }
.chart .ref { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .ref-label { fill: var(--text-2); font-size: 10.5px; font-family: var(--font); }
.chart .area-gain { fill: var(--gain); fill-opacity: 0.22; }
.chart .area-loss { fill: var(--loss); fill-opacity: 0.2; }
.chart .be-dot { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 0.76rem; line-height: 1.35;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart-tip .tip-head { font-weight: 700; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0; margin: 8px 0 0; font-size: 0.8rem; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 4px; border-radius: 2px; background: var(--s1); }
.swatch.s2 { background: var(--s2); } .swatch.s3 { background: var(--s3); } .swatch.s4 { background: var(--s4); }
.swatch.band-inner { height: 10px; background: var(--s1); opacity: 0.45; }
.swatch.band-outer { height: 10px; background: var(--s1); opacity: 0.2; }

/* ---- share sheet fallback and toast ---- */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 18px var(--gutter) calc(var(--safe-b) + 18px);
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 76px); z-index: 30;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 0.85rem; margin: 0;
}

/* ---- wider screens (iPad, landscape) ---- */
@media (min-width: 760px) {
  :root { --gutter: 24px; }
  .tabs {
    position: static; bottom: auto; display: flex; justify-content: center; gap: 6px;
    border-top: 0; border-bottom: 1px solid var(--border); background: var(--bg); padding: 6px var(--gutter);
  }
  .tabs a { font-size: 0.9rem; min-height: 40px; padding: 6px 16px; }
  main { padding-bottom: calc(var(--safe-b) + 32px); }
  .split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
  .split .inputs { position: sticky; top: calc(var(--safe-t) + 76px); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .toast { bottom: calc(var(--safe-b) + 24px); }
  .sheet { align-items: center; }
  .sheet-body { border-radius: 18px; }
  h1 { font-size: 1.8rem; }
}
@media (min-width: 1100px) {
  .split { grid-template-columns: 400px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) {
  .chart .line { stroke: CanvasText; } .chart .bar { fill: CanvasText; }
}
h1:focus:not(:focus-visible), h1[tabindex="-1"]:focus { outline: none; }
