:root {
  --bg: #f4efe7;
  --surface: #fffaf3;
  --surface-2: #f0e8dc;
  --line: #e2d7c7;
  --text: #221c17;
  --muted: #6f655b;
  --accent: #c4650f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(196, 101, 15, 0.12);
  --good: #3f8f5a;
  --warn: #c98a12;
  --bad: #c2412d;
  --frame: #191512;
  --frame-ink: #f2a541;
  --shadow: 0 1px 2px rgba(40, 25, 10, 0.06), 0 8px 24px rgba(40, 25, 10, 0.06);
  --radius: 20px;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #110e0c;
    --surface: #1b1714;
    --surface-2: #26201b;
    --line: #322a23;
    --text: #f3ece3;
    --muted: #a49a8f;
    --accent: #f2a541;
    --accent-ink: #1a1208;
    --accent-soft: rgba(242, 165, 65, 0.14);
    --good: #6cc48b;
    --warn: #f2b84b;
    --bad: #f07a62;
    --frame: #0a0807;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }

.wrap { max-width: 520px; margin: 0 auto; padding: 0 16px; }

/* ---------- Header ---------- */
.top {
  padding: calc(20px + env(safe-area-inset-top)) 0 8px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand svg { width: 40px; height: 40px; flex: none; }
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.3; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin: 14px 0;
}
.card h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 21px;
  letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font: 500 13px/1 var(--font-mono);
}

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.01em;
}
.row2 { display: grid; grid-template-columns: 1fr 1.25fr; gap: 12px; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 14px; top: 50%;
  width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
select, .stepper input {
  width: 100%; height: 48px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 38px 0 14px;
  appearance: none; -webkit-appearance: none;
  font-size: 16px;
}
select:focus-visible, .stepper input:focus-visible, button:focus-visible, input[type=range]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.stepper { display: grid; grid-template-columns: 44px 1fr 44px; height: 48px; }
.stepper button {
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 22px; line-height: 1; color: var(--text);
}
.stepper button:first-child { border-radius: 12px 0 0 12px; border-right: 0; }
.stepper button:last-child { border-radius: 0 12px 12px 0; border-left: 0; }
.stepper button:active { background: var(--accent-soft); }
.stepper input {
  border-radius: 0; padding: 0; text-align: center;
  font-family: var(--font-mono); font-weight: 500;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.age-hint strong { color: var(--text); font-weight: 600; }

/* Storage segmented choices */
.storage { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.storage button {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 5px;
  padding: 10px 2px 9px;
  min-height: 74px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12px; font-weight: 500; line-height: 1.15; text-align: center;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.storage button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.storage button[aria-checked="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.storage-desc { margin-top: 8px; }

/* ---------- Result hero ---------- */
.hero { padding: 22px 18px 18px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), #e5573f);
}
.eyebrow {
  font: 500 12px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 10px;
}
.ei-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ei {
  font-family: var(--font-display); font-weight: 700;
  font-size: 64px; line-height: 0.9; letter-spacing: -0.03em;
}
.ei small { font-size: 22px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-right: 6px; }
.stops-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font: 500 14px/1 var(--font-mono); white-space: nowrap;
}
.hero-sub { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.hero-sub strong { color: var(--text); font-weight: 600; }

.bracket {
  margin-top: 14px; padding: 12px 14px;
  background: var(--surface-2); border-radius: 12px;
  font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start;
}
.bracket svg { width: 18px; height: 18px; flex: none; margin-top: 2px; stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bracket b { font-family: var(--font-mono); font-weight: 500; }

.verdict { margin-top: 18px; }
.verdict-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.verdict-title { font-weight: 700; font-size: 17px; }
.verdict-score { font: 500 13px/1 var(--font-mono); color: var(--muted); }
.meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0 8px; }
.meter span { height: 8px; border-radius: 4px; background: var(--surface-2); transition: background .25s; }
.verdict p { margin: 0; color: var(--muted); font-size: 14px; }

.alert {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: rgba(194, 65, 45, 0.1); border: 1px solid rgba(194, 65, 45, 0.35);
  font-size: 14px;
}
.alert strong { color: var(--bad); }

/* ---------- Preview frame ---------- */
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.ghost-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.frame {
  position: relative;
  background: var(--frame);
  border-radius: 6px;
  padding: 22px 10px;
  margin: 0 -6px;
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
}
.frame::before, .frame::after {
  content: ""; position: absolute; left: 10px; right: 10px; height: 9px;
  background-image: repeating-linear-gradient(90deg, transparent 0 7px, rgba(255,250,240,.88) 7px 15px, transparent 15px 22px);
  background-size: 22px 9px;
  border-radius: 2px;
  -webkit-mask: repeating-linear-gradient(90deg, transparent 0 7px, #000 7px 15px, transparent 15px 22px);
  mask: repeating-linear-gradient(90deg, transparent 0 7px, #000 7px 15px, transparent 15px 22px);
  opacity: .9;
}
.frame::before { top: 6px; }
.frame::after { bottom: 6px; }
.frame.slide {
  background: #ece6da;
  padding: 18px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.frame.slide::before, .frame.slide::after { display: none; }
.edge {
  position: absolute; left: 18px; right: 18px;
  display: none; justify-content: space-between;
  font: 500 9px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
  color: #6d6458; pointer-events: none;
}
.frame.slide .edge { display: flex; }
.frame.slide .e-top { top: 5px; }
.frame.slide .e-bottom { bottom: 5px; }

.canvas-box { position: relative; border-radius: 2px; overflow: hidden; line-height: 0; }
canvas#preview { display: block; width: 100%; height: auto; }
.badge {
  position: absolute; top: 10px; left: 10px;
  padding: 5px 9px; border-radius: 999px;
  background: rgba(0,0,0,.6); color: #fff;
  font: 500 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  opacity: 0; transition: opacity .15s; pointer-events: none;
  backdrop-filter: blur(4px);
}
.badge.show { opacity: 1; }
.compare-hint { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 0; }

.slider-field { margin-top: 18px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.slider-head span { font-size: 14px; font-weight: 600; }
.slider-head output { font: 500 13px/1.3 var(--font-mono); color: var(--accent); text-align: right; }
input[type=range] {
  width: 100%; height: 36px; margin: 0;
  background: transparent; -webkit-appearance: none; appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #3a3a3a, var(--line) 50%, #f4e7c8);
}
input[type=range]::-moz-range-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #3a3a3a, var(--line) 50%, #f4e7c8);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
input[type=range]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
}
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.quick button {
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent;
  font-size: 13px; color: var(--muted);
}
.quick button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Traits */
.traits { margin-top: 18px; display: grid; gap: 14px; }
.trait-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.trait-head span:first-child { font-weight: 600; }
.trait-head span:last-child { color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin: 6px 0 5px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s ease; }
.trait p { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Exposure table ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 -18px 12px; padding-left: 18px; padding-right: 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: none; height: 36px; min-width: 52px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
  font: 500 14px/1 var(--font-mono); color: var(--muted);
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ev-list { list-style: none; margin: 0; padding: 0; }
.ev-list li {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 11px 0; border-top: 1px solid var(--line);
}
.ev-list li:first-child { border-top: 0; }
.ev-list svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ev-list .cond { font-size: 14px; line-height: 1.25; }
.ev-list .cond small { display: block; color: var(--muted); font-size: 12px; }
.ev-list .shutter { font: 500 16px/1 var(--font-mono); text-align: right; white-space: nowrap; }
.ev-list .shutter small { display: block; margin-top: 4px; font-size: 11px; color: var(--warn); }
.ev-list .shutter small.bad { color: var(--bad); }

/* ---------- Advice lists ---------- */
.advice { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.advice li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 15px; }
.advice li::before {
  content: ""; width: 8px; height: 8px; margin: 8px 0 0 6px;
  border-radius: 50%; background: var(--accent);
}
.advice li.warn::before { background: var(--bad); }
.advice strong { font-weight: 600; }

details summary {
  cursor: pointer; list-style: none;
  font-family: var(--font-display); font-weight: 600; font-size: 19px;
  display: flex; justify-content: space-between; align-items: center;
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; font: 400 24px/1 var(--font-body); color: var(--muted); }
details[open] summary::after { content: "–"; }
.prose { font-size: 14px; color: var(--muted); }
.prose p { margin: 12px 0 0; }
.prose strong { color: var(--text); }
.prose ul { padding-left: 18px; margin: 8px 0 0; }
.prose li { margin: 4px 0; }

footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 8px 24px 32px;
}

@media (min-width: 560px) {
  .top { padding-top: 36px; }
  .ei { font-size: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
