:root {
  color-scheme: light;
  --ink: #2b2550;
  --muted: #625c7b;
  --paper: #fffaf5;
  --lilac: #dcd2ff;
  --mint: #bfeedd;
  --peach: #ffdccb;
  --gold: #ffd98a;
  --display: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper) radial-gradient(ellipse at 85% 12%, #eee6ff 0, transparent 38%) no-repeat; font: 600 15px/1.6 var(--body); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a, input, select, textarea, summary, [tabindex] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px dashed #7b43ac; outline-offset: 4px; }
.wrap { width: min(1160px, calc(100% - 48px)); margin-inline: auto; }
.skip-link { position: absolute; z-index: 3; left: 16px; top: -90px; padding: 12px; background: var(--ink); color: white; }
.skip-link:focus { top: 10px; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; padding: 22px 0; border-bottom: 1.5px solid #ded7e8; }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 800 24px var(--display); text-decoration: none; }
.brand img { object-fit: contain; }
.brand span { padding-left: 9px; border-left: 1.5px solid #c9c1db; font-size: 16px; font-weight: 600; }
.back-link { font-size: 13px; text-underline-offset: 4px; }
.hero { display: grid; grid-template-columns: 1fr 300px; align-items: center; gap: 24px; padding: 46px 0 38px; }
.kicker, .step-tag { font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.kicker { margin: 0 0 12px; color: #8251a2; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: var(--display); line-height: 1.15; }
h1 { font-size: clamp(36px, 5vw, 58px); font-weight: 800; letter-spacing: -.025em; }
h1 span { color: #7754ae; }
.lead { margin: 17px 0; color: var(--muted); line-height: 1.75; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badges span { padding: 4px 11px; border: 1px solid #d5c9e4; border-radius: 20px; font-size: 11px; background: #fffdf9; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 240px; background: radial-gradient(circle, #e0d4ff 0 48%, transparent 49%); }
.hero-art img { max-width: 70%; height: auto; object-fit: contain; transform: rotate(-6deg); }
.float-label { position: absolute; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 10px; background: white; box-shadow: 0 3px 0 var(--ink); font: 700 13px var(--display); }
.top-label { top: 0; left: 8px; transform: rotate(-6deg); }
.bottom-label { bottom: 0; right: 2px; transform: rotate(4deg); background: var(--gold); }
.doodle { position: absolute; font: 700 25px var(--display); }
.d1 { right: 22px; top: 30px; transform: rotate(12deg); }
.d2 { left: 0; bottom: 48px; font-size: 18px; transform: rotate(-12deg); }
.tabbar { display: flex; gap: 8px; padding: 7px; border: 2px solid var(--ink); border-radius: 18px; background: #f0ebf9; margin-bottom: 26px; }
.tabbar button { display: flex; flex: 1; justify-content: center; align-items: center; gap: 8px; min-height: 49px; padding: 9px 12px; border: 2px solid transparent; border-radius: 12px; background: transparent; font: 700 17px var(--display); }
.tabbar button[aria-selected="true"] { border-color: var(--ink); background: var(--lilac); box-shadow: 0 3px 0 var(--ink); }
.tabbar button:hover:not([aria-selected="true"]) { background: white; }
.tabbar button span { font-size: 21px; }
.workspace { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: start; }
.input-panels { min-width: 0; }
.panel, .result-panel { min-width: 0; padding: 26px; border: 2.5px solid var(--ink); border-radius: 22px; background: white; box-shadow: 0 5px 0 var(--ink); }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.step-tag { color: var(--muted); font-size: 10px; }
.pill { padding: 4px 9px; border: 1px solid #d7cbec; border-radius: 20px; background: #f2ecff; font-size: 10px; }
.pill.mint { background: #e4f6ed; border-color: #b9daca; }
.pill.peach { background: #fff0e8; border-color: #ebc8b7; }
h2 { font-size: 25px; }
.muted { margin: 10px 0 22px; color: var(--muted); font-size: 14px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field { min-width: 0; margin-bottom: 18px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 800; }
label small { color: var(--muted); font-weight: 600; }
input, select, textarea { width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px; border: 1.5px solid #bdb3ce; border-radius: 10px; background: #fffdfa; font-size: 16px; }
input, textarea { font-family: var(--mono); font-weight: 500; }
textarea { resize: vertical; font-size: 18px; }
input:hover, select:hover, textarea:hover { border-color: #7754ae; }
.formula-display { margin: 2px 0 22px; padding: 19px 16px; border: 1.5px dashed #bda7df; border-radius: 12px; background: #f5f0ff; font: 500 clamp(18px, 2.3vw, 24px) var(--mono); text-align: center; overflow-wrap: anywhere; }
.hint { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding-top: 6px; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 16px; min-height: 44px; padding: 9px 15px; border: 2px solid var(--ink); border-radius: 11px; background: white; box-shadow: 0 3px 0 var(--ink); font: 700 14px var(--display); transition: transform .15s, box-shadow .15s; }
.btn.primary { background: var(--lilac); }
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.btn:disabled { cursor: not-allowed; opacity: .5; }
.text-btn { min-height: 44px; padding: 5px 0; border: 0; background: transparent; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.local-note { display: flex; gap: 8px; margin: 20px 4px 0; color: var(--muted); font-size: 11px; }
.local-note span { color: #7754ae; }
.result-panel { position: sticky; top: 24px; background: #eff9f3; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #34815d; box-shadow: 0 0 0 4px #d4efdd; }
#result-label { margin-bottom: 4px; }
.result-number { margin: 4px 0; line-height: 1.4; overflow-wrap: anywhere; }
#result-value { font: 700 clamp(28px, 3.2vw, 42px) var(--display); letter-spacing: -.02em; }
#result-unit { font: 600 20px var(--display); }
.rounding-note { margin: 0 0 27px; color: var(--muted); font-size: 10px; }
h3 { font-size: 18px; }
.result-steps { display: grid; gap: 14px; list-style: none; counter-reset: steps; padding: 0; margin: 17px 0 22px; }
.result-steps li { position: relative; min-height: 25px; padding-left: 36px; font-size: 14px; overflow-wrap: anywhere; white-space: pre-line; }
.result-steps li::before { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid #b5cebd; border-radius: 8px; background: white; counter-increment: steps; content: counter(steps); font-size: 11px; }
.result-note { padding: 12px 14px; border-radius: 10px; background: #dfeee4; font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.result-actions .btn { flex: 1; font-size: 12px; white-space: nowrap; padding-inline: 10px; }
.action-status { min-height: 20px; margin: 12px 0 0; font-size: 11px; color: var(--muted); }
.notice { padding: 14px; border: 1px solid #a93c4d; border-radius: 12px; background: #fff0f2; color: #8d2438; font-size: 13px; overflow-wrap: anywhere; }
.error { margin-top: 20px; }
.unit-pair { display: grid; grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr); align-items: center; gap: 10px; }
.swap-btn { width: 44px; height: 44px; margin-top: 7px; padding: 0; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--mint); font-size: 21px; }
.examples { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: -4px 0 19px; font-size: 11px; }
.examples button { min-height: 44px; padding: 5px 9px; border: 1px solid #c9bcdb; border-radius: 8px; background: #f6f1fc; font-size: 12px; }
.examples button:hover { background: var(--lilac); }
code { font: 500 12px var(--mono); overflow-wrap: anywhere; }
.syntax-help { margin-top: 24px; padding-top: 16px; border-top: 1px dashed #d1c5df; font-size: 13px; color: var(--muted); }
summary { cursor: pointer; font-weight: 800; color: var(--ink); padding-block: 4px; }
.syntax-help ul { padding-left: 18px; }
.syntax-help li + li { margin-top: 9px; }
.teacher-note { display: flex; align-items: flex-start; gap: 18px; margin: 35px 0 48px; padding: 22px 26px; border: 1.5px solid #dfc798; border-radius: 16px; background: #fff5df; }
.teacher-note h2 { font-size: 20px; }
.teacher-note p { margin: 7px 0 0; font-size: 12px; color: var(--muted); line-height: 1.8; }
.note-icon { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 2px solid var(--ink); border-radius: 50%; background: var(--gold); font: 700 21px var(--display); }
footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding: 24px 0 30px; border-top: 1.5px solid #ded7e8; color: var(--muted); font-size: 11px; }
footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
footer a { text-decoration: none; }
footer a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr 1fr; gap: 18px; }
  .panel, .result-panel { padding: 20px; }
  .two-col { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr 230px; }
  .hero-art { min-height: 210px; }
}
@media (max-width: 700px) {
  .wrap { width: calc(100% - 32px); }
  .topbar { padding: 16px 0; gap: 10px; }
  .brand { font-size: 21px; }
  .brand img { width: 30px; height: 36px; }
  .brand span { font-size: 13px; }
  .back-link { font-size: 11px; }
  .hero { grid-template-columns: 1fr; padding: 32px 0 28px; }
  .hero-art { display: none; }
  .hero h1 { font-size: clamp(34px, 8vw, 48px); }
  .lead { font-size: 14px; }
  .tabbar { gap: 3px; padding: 5px; border-radius: 13px; margin-bottom: 20px; }
  .tabbar button { flex-direction: column; gap: 0; font-size: 12px; padding: 6px 3px; line-height: 1.4; }
  .tabbar button span { font-size: 20px; }
  .workspace { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
  .teacher-note { padding: 18px; margin: 26px 0 32px; gap: 12px; }
  #result-value { font-size: 38px; }
}
@media (max-width: 380px) {
  .two-col { grid-template-columns: 1fr; }
  .unit-pair { gap: 6px; }
  .unit-pair select { padding-inline: 5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
@media print {
  body { background: white; color: black; font-size: 12pt; }
  .wrap { width: 100%; }
  .topbar, .hero-art, .kicker, .lead, .badges, .tabbar, .input-panels, .teacher-note, .result-actions, .action-status, footer, .skip-link, .live-dot { display: none !important; }
  .hero { display: block; padding: 0 0 24px; }
  h1, .hero h1 { font-size: 22pt; }
  h1 br { display: none; }
  h1 span { color: black; }
  .workspace { display: block; }
  .result-panel { position: static; border: 1px solid #777; box-shadow: none; background: white; break-inside: avoid; }
  #result-value { font-size: 30pt; }
  .result-note { background: white; border-top: 1px solid #aaa; }
}
