:root {
  color-scheme: light;
  --bg: #f7f1e3;
  --surface: #fffdf5;
  --surface-2: #efe5cd;
  --ink: #231c10;
  --muted: #5e543f;
  --line: #d3c4a1;
  --accent: #6d1f14;
  --accent-ink: #ffffff;
  --focus: #1a4fd6;
  --ok: #1e6b2e;
  --bad: #a31616;
  --display-bg: #171208;
  --display-ink: #ffb02e;
  --display-dim: #a07e3e;
  --bar-b: #4a6b2a;
  --radius: 10px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12100a;
  --surface: #1d1810;
  --surface-2: #2a2314;
  --ink: #f2e8d2;
  --muted: #c2b48f;
  --line: #4c4128;
  --accent: #eda07a;
  --accent-ink: #241105;
  --focus: #9db9ff;
  --ok: #8fd694;
  --bad: #ff9d9d;
  --display-bg: #0b0803;
  --display-ink: #ffc35c;
  --display-dim: #9c7f45;
  --bar-b: #7fae4e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "DejaVu Serif", serif;
  line-height: 1.6;
  font-size: 1.0625rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 3rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.topbar .home { font-weight: bold; color: var(--ink); text-decoration: none; flex: none; }
.topnav { display: flex; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { flex: none; padding: 0.5rem 0.6rem; color: var(--muted); text-decoration: none; border-radius: 6px; }
.topnav a[aria-current="true"] { color: var(--ink); font-weight: bold; }
.topbar .spacer { flex: 1; }
.topbar .chip { flex: none; color: var(--accent); }
.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

section { scroll-margin-top: 3.75rem; }

.hero { padding: 2.5rem 0 1rem; max-width: 44rem; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.12;
  margin: 0 0 1rem;
  text-wrap: balance;
}
.deck { font-size: 1.2rem; color: var(--muted); margin: 0 0 1rem; }
.deck strong { color: var(--ink); }
.answer-line {
  font-size: 1.15rem;
  border-left: 4px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1rem;
  margin: 1.25rem 0 0;
}
.answer-line strong { font-variant-numeric: tabular-nums; }

/* ---------- calculator ---------- */
.calc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}
@media (max-width: 46rem) {
  .calc { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.5rem;
}

.field { margin-bottom: 1.25rem; }
.field:last-child { margin-bottom: 0; }
.field > label, .legend {
  display: block;
  font-weight: bold;
  margin-bottom: 0.4rem;
}
.hint { color: var(--muted); font-size: 0.95rem; margin: 0.35rem 0 0; }
.parsed { color: var(--muted); font-size: 0.95rem; min-height: 1.5em; margin: 0.2rem 0 0; font-variant-numeric: tabular-nums; }

.presets { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.presets button {
  font: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 3.5rem;
  min-height: 44px;
  padding: 0.35rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.presets button.on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: bold;
}

input[type="text"], input[type="number"] {
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 100%;
  max-width: 16rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
input[aria-invalid="true"] { border-color: var(--bad); }

.w-row { display: flex; align-items: center; gap: 0.5rem; }
.w-row input { max-width: 9rem; }
.unit { color: var(--muted); font-weight: bold; }

/* LED oven display */
.display {
  background: var(--display-bg);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.55);
}
.display-label {
  color: var(--display-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  margin: 0 0 0.25rem;
}
.display-time {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: clamp(3.4rem, 8vw, 4.6rem);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--display-ink);
  text-shadow: 0 0 18px rgba(255, 176, 46, 0.35);
  margin: 0;
}
.display-sub { color: var(--display-dim); margin: 0.5rem 0 0; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.display-delta { color: var(--display-ink); margin: 0.25rem 0 0; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.error {
  color: var(--bad);
  font-weight: bold;
  margin: 0.75rem 0 0;
  min-height: 1.5em;
}

.btn-row { display: flex; gap: 0.6rem; margin-top: 1rem; flex-wrap: wrap; }
.btn {
  font: inherit;
  font-weight: bold;
  min-height: 44px;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.copy-status { color: var(--muted); font-size: 0.95rem; align-self: center; margin: 0; }

/* comparison bars */
.bars { margin-top: 1.25rem; }
.bar-row { margin-bottom: 0.7rem; }
.bar-row:last-child { margin-bottom: 0; }
.bar-head { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.95rem; margin-bottom: 0.2rem; }
.bar-head strong { font-variant-numeric: tabular-nums; }
.bar-track {
  height: 1.1rem;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  transition: width 0.35s ease-out;
}
#bar-a { background: var(--muted); }
#bar-b { background: var(--bar-b); }

/* ---------- prose sections ---------- */
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.7rem; margin: 3rem 0 0.75rem; line-height: 1.25; }
.prose p { margin: 0 0 1rem; }
.prose a { color: var(--accent); }
.formula {
  font-size: 1.25rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  font-variant-numeric: tabular-nums;
}

table.times {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
table.times caption { text-align: left; padding: 0 0 0.5rem; color: var(--muted); }
table.times th, table.times td {
  padding: 0.55rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
table.times th:first-child, table.times td:first-child { text-align: left; }
table.times thead th { background: var(--surface-2); }
table.times tbody tr:last-child th, table.times tbody tr:last-child td { border-bottom: none; }
table.times td.hl { font-weight: bold; color: var(--accent); }
.table-wrap { overflow-x: auto; }

details.faq {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  padding: 0.75rem 1rem;
}
details.faq summary {
  font-weight: bold;
  cursor: pointer;
  min-height: 44px;
}
details.faq p { margin: 0.5rem 0 0; }

.sources ul { padding-left: 1.25rem; }
.sources li { margin-bottom: 0.5rem; }
.sources a { color: var(--accent); overflow-wrap: anywhere; }

footer.site {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
footer.site a { color: var(--accent); }
footer.site .spacer { flex: 1; }

.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;
}
