:root {
  --bg: #f4f7fd; --panel: #ffffff; --ink: #16203a; --dim: #5a6784; --line: #dde4f2;
  --accent: #1f78b4; --accent2: #c2407e; --good: #158a4f; --bad: #c0392b;
  --shadow: 0 1px 2px rgba(22,32,58,0.08), 0 8px 24px rgba(22,32,58,0.06);
}
html[data-theme="dark"] {
  --bg: #0d1220; --panel: #151c2e; --ink: #e8edf8; --dim: #93a1bd; --line: #222b40;
  --accent: #8fd3ff; --accent2: #ff9ecb; --good: #5ee39a; --bad: #ff7a86;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.35);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
header.top { padding: 18px 20px 0; max-width: 960px; margin: 0 auto; position: relative; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
.sub { margin: 4px 0 12px; color: var(--dim); font-size: 14px; }
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.tab {
  background: none; border: 1px solid transparent; border-bottom: none; color: var(--dim);
  padding: 8px 13px; border-radius: 8px 8px 0 0; cursor: pointer; font: inherit; font-size: 14px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--panel); border-color: var(--line); font-weight: 600; }
#themeBtn { position: absolute; top: 18px; right: 20px; }
main { max-width: 960px; margin: 0 auto; padding: 16px 20px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.panel[hidden] { display: none !important; }
.stage { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.stage.two { gap: 12px; flex-wrap: wrap; align-items: flex-start; }
canvas { max-width: 100%; height: auto; min-width: 0; border-radius: 10px; background: var(--panel); display: block; touch-action: pan-y; }
#blowCanvas, #db3d, #frCanvas { touch-action: none; }
#blowBtn { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 6px; }
button { font: inherit; border-radius: 8px; cursor: pointer; padding: 8px 14px; border: 1px solid var(--line); }
button.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; color: var(--ink); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type="range"] { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
input[type="range"] { padding: 0; min-width: 200px; }
label { color: var(--dim); font-size: 14px; }
label.chk { display: inline-flex; gap: 5px; align-items: center; }
output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 64px; display: inline-block; }
.note { color: var(--dim); font-size: 13.5px; margin: 8px 0 0; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hud { display: grid; grid-template-columns: auto auto; gap: 2px 12px; align-content: start; padding: 8px 12px; font-size: 13px; }
.hud .k { color: var(--dim); }
.hud .v { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 12px 0 4px; }
.ro { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
.ro .k { display: block; color: var(--dim); font-size: 12px; }
.ro .v { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.side { flex: 1 1 280px; min-width: 260px; }
.prose { line-height: 1.62; }
.prose h2 { font-size: 19px; margin: 22px 0 6px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 15.5px; margin: 16px 0 4px; }
.prose p, .prose li { color: var(--ink); }
.prose .lead { font-size: 16px; }
.prose blockquote { margin: 10px 0; padding: 8px 14px; border-left: 3px solid var(--accent2); color: var(--dim); font-style: italic; }
.tablewrap { overflow-x: auto; margin: 10px 0; }
table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
th, td { text-align: right; padding: 5px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--dim); font-weight: 600; }
.tag { display: inline-block; font-size: 11px; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--dim); }
.ok { color: var(--good); } .bad { color: var(--bad); }
footer { max-width: 960px; margin: 0 auto; padding: 0 20px 34px; color: var(--dim); font-size: 13px; }
@media (max-width: 720px) { .stage.two { flex-direction: column; align-items: center; } .hud { grid-template-columns: auto auto; } }
select { max-width: 100%; min-width: 0; }
