:root {
  --bg: #f4f5f3; --panel: #ffffff; --ink: #1b2120; --muted: #5b6561; --faint: #8b948f; --line: #dde1dd; --line2: #eef0ee;
  --accent: #1d7a4e; --accent-ink: #ffffff; --accent-2: #e6f2eb; --bad: #b3261e; --bad-2: #fbecea; --ans: #f3f5f8; --ans-line: #c9d3e0;
  --c-back: #1f5fa8; --c-link: #c0392b; --c-tail: #252b29; --c-phos: #b06400; --c-head: #0f766e; --c-ring: #252b29; --c-sugar: #5b6561;
  --hit: rgba(29, 122, 78, .2);
  --r: 10px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111413; --panel: #181c1b; --ink: #e6eae7; --muted: #a2aca7; --faint: #78827d; --line: #2b3230; --line2: #212725;
  --accent: #3fb37a; --accent-ink: #08130d; --accent-2: #15301f; --bad: #f2877c; --bad-2: #36191a; --ans: #1b2028; --ans-line: #33405a;
  --c-back: #82b3f0; --c-link: #f08b7f; --c-tail: #e2e6e3; --c-phos: #f0b35a; --c-head: #5fd0c2; --c-ring: #e2e6e3; --c-sugar: #a2aca7;
  --hit: rgba(63, 179, 122, .28);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }

/* layout */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.main { padding: 28px 40px 72px; min-width: 0; }
.wrap { max-width: 1240px; }

/* sidebar */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 8px 16px; }
.brand-m { color: var(--accent); display: grid; place-items: center; }
.brand b { display: block; font-size: 15px; font-weight: 680; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: 14px; }
.nav:hover { background: var(--line2); }
.nav.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.nav-c { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav.on .nav-c { color: var(--accent); }
.nav-h { margin: 16px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.side-f { margin-top: auto; padding: 16px 6px 0; }

/* buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .45; cursor: default; border-color: var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
.sel { width: 100%; height: 34px; margin-top: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; }
.sel:focus, .step-v:focus, .btn:focus-visible, .seg-b:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-b { height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.seg-b:hover { border-color: var(--faint); }
.seg-b.on { border-color: var(--accent); background: var(--accent-2); color: var(--accent); font-weight: 600; }
.step { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.step-b { width: 36px; height: 34px; border: 0; background: var(--line2); color: var(--ink); font-size: 18px; cursor: pointer; }
.step-b:disabled { opacity: .4; cursor: default; }
.step-v { width: 64px; height: 34px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--panel); color: var(--ink); text-align: center; font: inherit; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.step-v::-webkit-inner-spin-button, .step-v::-webkit-outer-spin-button { -webkit-appearance: none; }
.chk { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--faint); }
.chip.on { border-color: var(--accent); background: var(--accent-2); }
.chip:disabled { opacity: .45; cursor: default; }
.chip.sm { height: 26px; padding: 0 7px; font-size: 12px; }
.gi { display: inline-flex; color: var(--ink); }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); text-decoration: underline; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.title-row .acts { display: flex; gap: 8px; }

/* home */
.hero { padding: 8px 0 22px; max-width: 820px; }
.hero h1 { font-size: 30px; }
.lead { color: var(--muted); font-size: 16px; margin: 8px 0 18px; }
.hero-s { display: flex; align-items: center; gap: 18px; }
.stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; margin-left: 6px; }
.bar-o { flex: 1; max-width: 360px; height: 8px; border-radius: 99px; background: var(--line2); overflow: hidden; }
.bar-o.thin { height: 5px; max-width: none; margin: 12px 0; }
.bar-i { height: 100%; background: var(--accent); border-radius: 99px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-p { color: var(--muted); font-size: 14px; margin: 6px 0 0; flex: 1; }
.card-f { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-f .acts { display: flex; gap: 6px; }
.mixc { border-style: dashed; }
.mixc .card-p { margin-bottom: 14px; }
.foot { display: flex; gap: 18px; align-items: center; margin-top: 28px; font-size: 13px; }

/* learn */
.learn { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 18px; align-items: start; }
.pts { padding: 18px 20px; position: sticky; top: 20px; }
.pts ul { margin: 10px 0 0; padding-left: 18px; }
.pts li { margin: 0 0 9px; }
.pts .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.symkey { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line2); font-size: 13px; }
.ex { display: grid; gap: 14px; }
.ex-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fig { margin: 0; padding: 12px 14px 10px; }
.fig figcaption { font-size: 13px; color: var(--muted); padding-top: 4px; border-top: 1px solid var(--line2); }
.art { overflow-x: auto; padding: 4px 0 8px; }
.art svg { margin: 0 auto; }

/* challenges */
.dots { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0 14px; }
.dot { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--muted); text-decoration: none; font-variant-numeric: tabular-nums; }
.dot:hover { border-color: var(--faint); }
.dot.s { border-color: var(--accent); color: var(--accent); }
.dot.m { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dot.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.prompt { padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 var(--r) var(--r) 0; margin-bottom: 14px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.prompt-t { font-size: 17px; font-weight: 560; }
.tag { display: inline-block; font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.work { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
.ctl { padding: 16px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.fld-l { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.fld-s { font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.ctl > .hint { padding-top: 12px; border-top: 1px solid var(--line2); }
.sugars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.su { display: grid; grid-template-columns: 18px 16px minmax(0, 1fr) auto auto 24px; align-items: center; gap: 6px; }
.su .sel { margin: 0; height: 30px; font-size: 13px; padding: 0 6px; }
.su-n { font-size: 12px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.x { width: 24px; height: 26px; border: 0; background: none; color: var(--faint); font-size: 18px; cursor: pointer; border-radius: 6px; }
.x:hover { background: var(--line2); color: var(--ink); }
.adds { display: flex; flex-wrap: wrap; gap: 6px; }
.col { display: grid; gap: 12px; min-width: 0; }
.stage { padding: 12px 14px 12px; }
.stage-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line2); }
.stage-t { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; background: var(--c-tail); }
.sw.p-back { background: var(--c-back); } .sw.p-link { background: var(--c-link); } .sw.p-phos { background: var(--c-phos); } .sw.p-head { background: var(--c-head); }
.canvas { min-height: 300px; display: flex; align-items: center; overflow-x: auto; padding: 14px 0; }
.canvas svg { margin: 0 auto; flex: none; }
.empty { margin: auto; color: var(--muted); }
.msg { font-size: 13px; color: var(--bad); padding: 6px 10px; background: var(--bad-2); border-radius: 7px; }
.readout { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.readout:empty { display: none; }
.id { border-top: 1px solid var(--line2); padding-top: 10px; }
.id-k { font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.id-t { font-size: 17px; font-weight: 620; color: var(--ink); margin: 2px 0 4px; }
.id-l { margin: 0; padding-left: 18px; font-size: 14px; }
.actions { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.fb:empty { display: none; }
.fb { border-radius: var(--r); padding: 14px 18px; border: 1px solid var(--line); }
.fb.good { background: var(--accent-2); border-color: var(--accent); }
.fb.bad { background: var(--bad-2); border-color: var(--bad); }
.fb.ans { background: var(--ans); border-color: var(--ans-line); }
.fb-t { font-weight: 680; font-size: 15px; }
.fb.good .fb-t { color: var(--accent); }
.fb.bad .fb-t { color: var(--bad); }
.fb ul { margin: 6px 0 4px; padding-left: 18px; }
.fb p { margin: 6px 0; }
.fb .art { background: var(--panel); border-radius: 8px; margin: 10px 0 4px; border: 1px solid var(--line); }
.fb-f { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }

/* structure drawings */
.mol { display: block; overflow: visible; }
.mol .bd { stroke: var(--c-tail); stroke-width: .055; stroke-linecap: round; fill: none; pointer-events: none; }
.mol .bd.p-back { stroke: var(--c-back); }
.mol .bd.p-link { stroke: var(--c-link); }
.mol .bd.p-phos { stroke: var(--c-phos); }
.mol .bd.p-head { stroke: var(--c-head); }
.mol .bd.p-ring { stroke: var(--c-ring); }
.mol .bd.p-sugar { stroke: var(--c-sugar); }
.mol text { pointer-events: none; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
.mol .lab { font-size: .42px; font-weight: 520; fill: var(--ink); }
.mol .lab.p-back { fill: var(--c-back); }
.mol .lab.p-link { fill: var(--c-link); }
.mol .lab.p-phos { fill: var(--c-phos); }
.mol .lab.p-head { fill: var(--c-head); }
.mol .lab.p-ring { fill: var(--c-link); }
.mol .num { font-size: .23px; fill: var(--faint); text-anchor: middle; }
.mol .glyph > * { stroke: var(--ink); stroke-width: .035; }
.mol .glab { font-size: .2px; fill: var(--muted); text-anchor: middle; }
.mol .box { fill: var(--panel); stroke: var(--c-tail); stroke-width: .03; }
.mol .box.p-head { stroke: var(--c-head); }
.mol .box.p-sugar { stroke: var(--c-sugar); stroke-dasharray: .08 .06; }
.mol .boxt { font-size: .24px; fill: var(--muted); text-anchor: middle; }
.mol .hit { stroke: transparent; stroke-width: .42; stroke-linecap: round; cursor: pointer; }
.mol .hit:hover { stroke: var(--hit); }
.mol .site { fill: transparent; stroke: var(--accent); stroke-width: .035; stroke-dasharray: .09 .07; cursor: pointer; }
.mol .site:hover { fill: var(--hit); }
.mol .site.on { stroke-dasharray: none; }

/* general structures: piece palette */
.pal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.pc { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 44px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.pc:hover { border-color: var(--faint); }
.pc.on { border-color: var(--accent); background: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent); }
.pc:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pc b { font-size: 14px; font-weight: 600; white-space: nowrap; }
.pc small { font-size: 11.5px; color: var(--muted); }
.att { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.att li { display: grid; grid-template-columns: 112px minmax(0, 1fr) 24px; align-items: center; gap: 8px; font-size: 13px; min-height: 26px; }
.att-k { color: var(--muted); }
.att-v { font-weight: 550; }
.fig figcaption b { color: var(--ink); font-weight: 650; }
