:root {
  --paper: #f4efe6;
  --surface: #fffdf8;
  --ink: #1c1a16;
  --muted: #625c50;
  --line: #ddd4c4;
  --brand: #0d6b4a;
  --brand-ink: #ffffff;
  --good: #0d6b4a;
  --good-bg: #dff1e7;
  --warn: #8a5a00;
  --warn-bg: #fbecc8;
  --bad: #a3271c;
  --bad-bg: #fbe0dc;
  --flat: #4f4a41;
  --flat-bg: #ebe5d9;
  --radius: 14px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #15130f;
    --surface: #1f1c17;
    --ink: #f3eee4;
    --muted: #b0a898;
    --line: #38332a;
    --brand: #3fbf8c;
    --brand-ink: #08130e;
    --good: #5fd3a2;
    --good-bg: #153527;
    --warn: #f0c25a;
    --warn-bg: #3a2d0c;
    --bad: #ff9c8f;
    --bad-bg: #431a15;
    --flat: #c9c1b2;
    --flat-bg: #2c2820;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
[hidden] { display: none !important; }

.top, main, footer { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 16px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; }

.hero { padding: 20px 0 20px; }
h1 { margin: 0 0 8px; font-size: clamp(2rem, 8vw, 2.9rem); line-height: 1.05; letter-spacing: -0.03em; text-wrap: balance; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; text-wrap: pretty; max-width: 34em; }
h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 20px; }
@media (min-width: 600px) { .card { padding: 24px; } }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--flat-bg); border-radius: 12px; margin-bottom: 16px; }
.segmented button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.14); }

label { display: block; margin: 0 0 6px; font-weight: 600; font-size: 0.95rem; }
.optional { color: var(--muted); font-weight: 400; margin-left: 4px; }
input[type="url"], input[type="text"] { width: 100%; min-height: 48px; padding: 10px 12px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; }
input[type="file"] { width: 100%; min-height: 48px; padding: 8px; border: 1px dashed var(--muted); border-radius: 10px; background: var(--paper); color: var(--ink); font: inherit; }
input[type="file"]::file-selector-button { min-height: 32px; margin-right: 10px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--flat-bg); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.hint { margin: 6px 0 16px; color: var(--muted); font-size: 0.9rem; text-wrap: pretty; }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 600; }

button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.primary { width: 100%; min-height: 52px; border: 0; border-radius: 12px; background: var(--brand); color: var(--brand-ink); font: inherit; font-size: 1.05rem; font-weight: 700; white-space: nowrap; cursor: pointer; }
.primary:disabled { opacity: 0.6; cursor: progress; }
.quiet { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }

/* Result */
.working { display: flex; align-items: center; gap: 12px; }
.spinner { flex: none; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.working p { margin: 0; font-weight: 600; }
.working small { display: block; color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.stamp { display: inline-block; padding: 6px 12px; border-radius: 8px; font-weight: 800; font-size: 0.95rem; letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap; }
.tone-good { background: var(--good-bg); color: var(--good); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-flat { background: var(--flat-bg); color: var(--flat); }

.result-title { margin: 12px 0 2px; font-size: 1.3rem; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; overflow-wrap: anywhere; }
.result-sub { margin: 0 0 14px; color: var(--muted); overflow-wrap: anywhere; }
.summary { margin: 0 0 16px; font-size: 1.05rem; text-wrap: pretty; }

.meter { margin: 0 0 18px; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.meter-head span { color: var(--muted); font-size: 0.95rem; }
.meter-head strong { font: 700 1.5rem/1 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter-track { height: 10px; border-radius: 999px; background: var(--flat-bg); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; }
.meter-fill.tone-good { background: var(--good); }
.meter-fill.tone-warn { background: var(--warn); }
.meter-fill.tone-bad { background: var(--bad); }
.meter-fill.tone-flat { background: var(--flat); }

.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; margin: 0 0 18px; }
.prices div { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.prices dt { color: var(--muted); font-size: 0.85rem; }
.prices dd { margin: 0; font: 700 1.1rem/1.3 var(--mono); overflow-wrap: anywhere; }

h3 { margin: 18px 0 8px; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.findings li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; overflow-wrap: anywhere; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; font-weight: 800; margin-top: 1px; }

.compare { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; }
.compare li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; }
.compare li + li { border-top: 1px solid var(--line); }
.compare .who { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.compare .who a { display: inline-flex; align-items: center; min-height: 44px; margin: -10px 0; color: var(--brand); }
.compare .price { font: 700 1rem/1.5 var(--mono); white-space: nowrap; text-align: right; }
.compare .why { grid-column: 1 / -1; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.plain { margin: 0; text-wrap: pretty; overflow-wrap: anywhere; }
.advice { margin: 18px 0 0; padding: 12px 14px; border-left: 4px solid var(--brand); border-radius: 0 10px 10px 0; background: var(--flat-bg); text-wrap: pretty; }
.source { margin: 16px 0 0; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.notice { margin: 0; font-weight: 600; text-wrap: pretty; }

/* History */
.history { margin-bottom: 28px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.empty { margin: 0; padding: 20px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; text-wrap: balance; }
#history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#history-list li { display: grid; grid-template-columns: 1fr auto; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.open { min-width: 0; display: grid; gap: 4px; padding: 12px; border: 0; border-radius: 12px 0 0 12px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.open .name { font-weight: 600; overflow-wrap: anywhere; }
.open .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 0.88rem; }
.open .stamp { padding: 2px 8px; font-size: 0.72rem; }
.remove { width: 48px; min-height: 48px; border: 0; border-left: 1px solid var(--line); border-radius: 0 12px 12px 0; background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }

footer { padding-bottom: 32px; }
footer p { margin: 0; color: var(--muted); font-size: 0.88rem; text-wrap: pretty; }

/* How it works and questions */
.fine { margin: 8px 0 0; color: var(--muted); font-size: 0.85rem; text-wrap: pretty; }
.about { margin-bottom: 28px; }
.about h2 { margin: 0 0 10px; }
.about h2 + details { margin-top: 0; }
.steps { margin: 0 0 28px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; text-wrap: pretty; }
.steps li::before { content: counter(step); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
details { border-top: 1px solid var(--line); }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 6px 0; font-weight: 600; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; flex: none; color: var(--muted); font-size: 1.3rem; line-height: 1; }
details[open] summary::after { content: "−"; }
details p { margin: 0 0 14px; color: var(--muted); text-wrap: pretty; }

/* Policy pages */
.doc { padding-top: 20px; padding-bottom: 28px; }
.doc h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
.doc h2 { margin: 28px 0 10px; }
.doc p { margin: 0 0 14px; text-wrap: pretty; }
.doc .lede { color: var(--muted); font-size: 1.05rem; }
.doc a, footer a { color: var(--brand); }
.doc > p > a, footer a, details p a { display: inline-flex; align-items: center; min-height: 44px; }
.facts { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.facts div { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px 12px; }
.facts div + div { border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); white-space: nowrap; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
code { font-family: var(--mono); font-size: 0.95em; }
footer nav { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 4px; }
