:root {
  --ink: #1b1f3b;
  --ink-2: #4a5072;
  --muted: #6b7194;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e1e5f0;
  --accent: #ffd43b;
  --primary: #4f7cff;
  --primary-ink: #ffffff;
  --good: #2f9e44;
  --good-bg: #ebfbee;
  --bad: #e03131;
  --bad-bg: #fff5f5;
  --hint-bg: #fff9db;
  --code-bg: #1e2140;
  --code-ink: #e6e9ff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27, 31, 59, .06), 0 4px 16px rgba(27, 31, 59, .06);
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --mod: var(--primary);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -.02em; }
/* Some code fonts draw => as ⇒ and === as ≡. Kids must see the real characters. */
code, pre, textarea, .code-line, .gutter { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code { font-family: var(--mono); font-size: .9em; background: #eef1fb; padding: .1em .35em; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--muted); margin: 0 0 .3em; }

/* ---- buttons ---- */
.btn {
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; gap: .4em;
  padding: .6em 1.1em;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover:not(:disabled) { box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #2b3160; }
.btn.big { font-size: 1.1rem; padding: .75em 1.4em; }
.btn.small { font-size: .85rem; padding: .35em .7em; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.icon-btn { font: inherit; background: none; border: 0; cursor: pointer; padding: .3em .45em; border-radius: 8px; color: inherit; }
.icon-btn:hover:not(:disabled) { background: rgba(127, 127, 127, .15); }
.icon-btn:disabled { opacity: .3; cursor: default; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.chip { display: inline-block; font-size: .78rem; font-weight: 700; padding: .2em .65em; border-radius: 99px; background: #eef1fb; color: var(--ink-2); }
.chip.small { font-size: .7rem; padding: .1em .5em; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .55rem max(16px, 2vw);
  background: var(--ink); color: #fff;
}
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: .35em; }
.logo-mark { background: var(--accent); border-radius: 9px; padding: 0 .2em; }
.topbar nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { white-space: nowrap; color: #c9cdf0; text-decoration: none; padding: .35em .7em; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.topbar nav a.active { color: var(--ink); background: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .3rem; }
.points-pill { background: rgba(255, 255, 255, .12); padding: .25em .75em; border-radius: 99px; font-weight: 700; display: inline-block; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem max(16px, 2vw) 4rem; }
.page { max-width: 980px; margin: 0 auto; }

/* ---- login ---- */
.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 2.2rem; width: min(420px, 100%); text-align: center; }
.login-hero { font-size: 3rem; }
.login form { display: grid; gap: .9rem; margin-top: 1.4rem; text-align: left; }
.login label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
input, textarea, select {
  font: inherit; padding: .65em .8em; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 124, 255, .2); }
.form-error { color: var(--bad); margin: 0; font-weight: 600; }

/* ---- home ---- */
.home-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; flex-wrap: wrap; margin: 1rem 0 1.4rem; }
.home-hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
.hl { background: linear-gradient(transparent 60%, var(--accent) 60%); }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 34em; margin: 0 0 1.2rem; }
.hero-stats { display: flex; gap: .8rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1.1rem; text-align: center; min-width: 88px; }
.stat b { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; flex: 1; min-width: 60px; }
.progress span { display: block; height: 100%; background: var(--mod, var(--primary)); border-radius: inherit; transition: width .4s; }
.progress.big { height: 12px; margin-bottom: 2rem; }
.progress.big span { background: linear-gradient(90deg, var(--primary), #12b886); }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.module-card {
  display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; color: inherit; text-decoration: none;
  border-top: 5px solid var(--mod);
  transition: transform .15s, box-shadow .15s;
}
a.module-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(27, 31, 59, .12); }
.module-card.locked { opacity: .55; border-top-color: var(--line); }
.module-card h3 { font-size: 1.15rem; margin: .5rem 0 .3rem; }
.module-card p { color: var(--ink-2); margin: 0 0 1rem; font-size: .95rem; flex: 1; }
.module-top { display: flex; justify-content: space-between; align-items: center; }
.module-num { font-weight: 800; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--mod); }
.module-card.locked .module-num { color: var(--muted); }
.module-badge { font-size: 1.6rem; filter: grayscale(1); opacity: .35; }
.module-badge.earned { filter: none; opacity: 1; }
.module-foot { display: flex; align-items: center; gap: .6rem; }

/* ---- module page ---- */
.module-page { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.step-nav { position: sticky; top: 4.5rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; border-top: 5px solid var(--mod); }
.step-nav h2 { font-size: 1.1rem; }
.step-nav .back { font-size: .85rem; text-decoration: none; display: inline-block; margin-bottom: .8rem; }
.step-nav ol { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: 2px; }
.step-nav li a { display: flex; gap: .5em; align-items: flex-start; padding: .45em .55em; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .92rem; }
.step-nav li a:hover { background: var(--bg); }
.step-nav li a.current { background: var(--ink); color: #fff; font-weight: 600; }
.nav-icon { flex: none; width: 1.4em; text-align: center; }

.step { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(1.1rem, 3vw, 2rem); }
.step-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.step-points { font-size: .85rem; font-weight: 700; color: var(--muted); }
.step-title { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.prose { max-width: 46em; font-size: 1.05rem; }
.prose p, .prose ul, .prose ol { margin: 0 0 .9em; }
.prose li { margin: .25em 0; }
.prose h3 { margin-top: 1.2em; }
.code-sample { background: var(--code-bg); color: var(--code-ink); padding: .9rem 1.1rem; border-radius: 10px; overflow-x: auto; font-size: .92rem; line-height: 1.5; margin: 0 0 1em; }
.code-sample code { background: none; padding: 0; color: inherit; }
.callout { background: var(--hint-bg); border-left: 4px solid var(--accent); padding: .7rem 1rem; border-radius: 0 10px 10px 0; margin: 0 0 1em; }
.step-body { margin-top: 1.2rem; }
.step-foot { margin-top: 1.4rem; display: flex; justify-content: flex-end; }
.step-foot .next { background: var(--mod); border-color: var(--mod); color: #fff; }

.question { font-size: 1.15rem; font-weight: 700; margin: 0 0 .8rem; }
.label { font-weight: 700; margin: 1.3rem 0 .5rem; }

/* choices */
.choices { display: grid; gap: .55rem; margin-bottom: 1rem; }
.choice {
  font: inherit; text-align: left; display: flex; gap: .8em; align-items: center;
  padding: .75em 1em; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--ink-2); }
.choice:disabled { cursor: default; }
.choice .letter { flex: none; width: 1.8em; height: 1.8em; display: grid; place-items: center; border-radius: 8px; background: var(--bg); font-weight: 800; font-size: .85rem; }
.choice[aria-pressed="true"] { border-color: var(--ink); background: #f0f2ff; }
.choice.right { border-color: var(--good); background: var(--good-bg); }
.choice.right .letter { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); opacity: .7; text-decoration: line-through; }
.choices.compact .choice { padding: .6em .9em; font-size: .97rem; }

/* order */
.order-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .45rem; }
.order-item { display: flex; align-items: center; gap: .8rem; padding: .6rem .7rem; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.order-n { flex: none; width: 1.9em; height: 1.9em; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.order-text { flex: 1; }
.order-btns { display: flex; gap: 2px; }

/* bug hunt */
.bug-code { background: var(--code-bg); border-radius: 12px; padding: .4rem 0 .6rem; overflow-x: auto; }
.bug-file { color: #8d93c4; font: 600 .78rem var(--mono); padding: .2rem 1rem .5rem; }
.code-line {
  display: flex; width: 100%; min-width: max-content; text-align: left; background: none; border: 0; cursor: pointer;
  padding: .12rem 1rem .12rem 0; color: var(--code-ink); font: .92rem/1.6 var(--mono); border-left: 4px solid transparent;
}
.code-line:hover { background: rgba(255, 255, 255, .06); }
.code-line .ln { flex: none; width: 3em; text-align: right; padding-right: 1em; color: #6c72a8; user-select: none; }
.code-line code { background: none; padding: 0; color: inherit; white-space: pre; font-size: inherit; }
.code-line[aria-pressed="true"] { background: rgba(255, 212, 59, .18); border-left-color: var(--accent); }
.code-line.miss { background: rgba(224, 49, 49, .25); border-left-color: var(--bad); }
.code-line.hit { background: rgba(47, 158, 68, .3); border-left-color: #51cf66; }
.code-line.squashed code { text-decoration: line-through wavy #ff8787; }
.squash { font-size: 1.05rem; }

/* feedback */
.feedback { margin-top: 1.2rem; padding: 1rem 1.2rem; border-radius: 12px; animation: pop .25s ease-out; }
.feedback p { margin: .2em 0; }
.feedback.good { background: var(--good-bg); border: 2px solid #8ce99a; }
.feedback.bad { background: var(--bad-bg); border: 2px solid #ffc9c9; }
.feedback.hint { background: var(--hint-bg); border: 2px solid #ffe066; }
.fb-title { font-weight: 800; font-size: 1.15rem; }
.pts { background: var(--accent); border-radius: 99px; padding: .05em .6em; font-size: .9rem; margin-left: .3em; }
.rhyme { font-style: italic; margin: .6rem 0; padding: .6rem 1rem; border-left: 4px solid #8ce99a; background: rgba(255, 255, 255, .7); border-radius: 0 8px 8px 0; color: var(--ink-2); }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* build */
.build { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1rem; }
.build-buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }
.checks { margin-top: .8rem; }
.checks .label { margin: 0 0 .4rem; }
.checks ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.checks li { padding: .35rem .6rem; border-radius: 8px; background: var(--bg); font-size: .92rem; }
.checks li.ok { background: var(--good-bg); }
.checks li.no { background: var(--bad-bg); }

.tabbed-editor { border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.editor-tabs { display: flex; background: #151832; }
.editor-tab { font: 600 .82rem var(--mono); color: #8d93c4; background: none; border: 0; padding: .6rem 1rem; cursor: pointer; border-bottom: 3px solid transparent; }
.editor-tab[aria-selected="true"] { color: #fff; background: var(--code-bg); border-bottom-color: var(--accent); }
.code-editor { display: flex; height: 400px; }
.code-editor .gutter { margin: 0; padding: .7rem .6rem .7rem 0; width: 3.2em; flex: none; text-align: right; color: #6c72a8; font: .9rem/1.55 var(--mono); overflow: hidden; user-select: none; }
.code-editor textarea {
  flex: 1; border: 0; border-radius: 0; resize: none; background: transparent; color: var(--code-ink);
  font: .9rem/1.55 var(--mono); padding: .7rem .8rem .7rem .4rem; tab-size: 2; white-space: pre; overflow: auto;
}
.code-editor textarea:focus { box-shadow: none; }

/* preview */
.preview { border-radius: 12px; overflow: hidden; border: 1.5px solid var(--line); background: #fff; }
.preview-bar { display: flex; align-items: center; gap: .7rem; background: #eef1fb; padding: .4rem .7rem; }
.dots { display: flex; gap: 5px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: #ff8787; }
.dots i:nth-child(2) { background: #ffd43b; }
.dots i:nth-child(3) { background: #69db7c; }
.preview-url { font: .78rem var(--mono); color: var(--muted); background: #fff; border-radius: 6px; padding: .1rem .6rem; flex: 1; }
.preview iframe { display: block; width: 100%; border: 0; background: #fff; }
.console { background: #2b0f12; color: #ffc9c9; font-size: .88rem; padding: .5rem .8rem; max-height: 170px; overflow: auto; }
.console-line { display: flex; gap: .5em; padding: .25rem 0; }
.console-line.log { color: #d0d4f7; }
.console-line code { background: none; color: #ff8787; padding: 0; font-size: .8rem; word-break: break-word; }
.console-line.log code { color: #d0d4f7; }
.friendly { color: #fff; font-weight: 600; }

/* answer key */
.answer-key { margin-top: 1.4rem; border: 1.5px dashed var(--line); border-radius: 10px; padding: .5rem .9rem; font-size: .92rem; }
.answer-key summary { cursor: pointer; font-weight: 700; color: var(--muted); }

/* ---- lesson visuals (see md.js) ---- */
.prose > div[class^="v-"] { margin: 1.1rem 0 1.3rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.v-step, .v-card, .v-slot { animation: rise .45s ease-out both; animation-delay: calc(var(--i, 0) * 110ms); }
.v-icon { font-size: 2rem; line-height: 1.1; }

.v-flow { display: flex; align-items: stretch; flex-wrap: wrap; gap: .4rem; }
.v-step {
  flex: 1 1 0; min-width: 110px; max-width: 220px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .2rem;
  background: #fff; border: 2px solid var(--line); border-top: 4px solid var(--mod); border-radius: 12px; padding: .7rem .5rem;
}
.v-step b { font-size: .95rem; line-height: 1.25; }
.v-step span, .v-card span { font-size: .85rem; color: var(--ink-2); line-height: 1.35; }
.v-arrow { align-self: center; color: var(--mod); font-size: 1.3rem; font-weight: 800; }

.v-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.v-card { display: flex; flex-direction: column; gap: .25rem; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: .8rem .9rem; }

.v-anatomy {
  display: grid; grid-template-columns: max-content max-content; align-items: center; gap: .3rem 1.2rem;
  background: var(--code-bg); border-radius: 12px; padding: .8rem 1rem; overflow-x: auto;
}
.v-row { display: contents; }
.v-label { justify-self: start; }
.v-row code { background: none; color: var(--code-ink); padding: 0; font-size: .95rem; white-space: pre; }
.v-row mark { background: rgba(255, 212, 59, .28); color: #ffe066; border-radius: 4px; padding: 0 .15em; }
.v-label { font-size: .82rem; font-weight: 600; color: var(--ink); background: var(--accent); border-radius: 99px; padding: .1em .7em; white-space: nowrap; position: relative; }
.v-label::before { content: "⟵ "; }

.v-compare { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.v-col { background: #fff; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.v-col-head { font-weight: 800; padding: .5rem .8rem; background: var(--bg); border-bottom: 2px solid var(--line); }
.v-col-row { padding: .45rem .8rem; font-size: .95rem; border-top: 1px solid var(--line); }
.v-col-row:first-of-type { border-top: 0; }

.v-array-wrap { overflow-x: auto; }
.v-array { display: flex; gap: 0; width: max-content; }
.v-slot { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.v-box { border: 2px solid var(--ink); margin-left: -2px; padding: .6rem .8rem; min-width: 96px; text-align: center; background: #fff; font-size: .9rem; }
.v-slot:first-child .v-box { border-radius: 10px 0 0 10px; margin-left: 0; }
.v-slot:last-child .v-box { border-radius: 0 10px 10px 0; }
.v-slot code { font-size: .8rem; }
.v-note { font-size: .88rem; color: var(--ink-2); margin: .5rem 0 0; }

.v-meter { display: grid; gap: .45rem; }
.v-meter-row { display: grid; grid-template-columns: minmax(110px, 13em) 1fr auto; align-items: center; gap: .7rem; transition: opacity .3s; }
.v-meter-row.below { opacity: .35; }
.v-meter-row.below .v-meter-label { text-decoration: line-through; }
.v-meter-label { font-size: .9rem; font-weight: 600; }
.v-meter-track { position: relative; height: 14px; background: var(--line); border-radius: 99px; }
.v-meter-bar { display: block; height: 100%; border-radius: inherit; animation: grow .8s ease-out both; transform-origin: left; }
.v-meter-bar.hi { background: #40c057; }
.v-meter-bar.mid { background: #fab005; }
.v-meter-bar.lo { background: #fa5252; }
.v-cut { position: absolute; top: -5px; bottom: -5px; border-left: 2px dashed var(--ink); z-index: 1; }
.v-meter-val { font-size: .85rem; white-space: nowrap; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.v-tree .v-node { border: 2px solid var(--line); border-radius: 10px; padding: .45rem .6rem; background: #fff; }
.v-tree .v-node + .v-node { margin-top: .4rem; }
.v-node-head { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.v-node-head code { font-weight: 700; }
.v-node-head span { font-size: .85rem; color: var(--ink-2); }
.v-kids { margin: .45rem 0 .1rem .9rem; }
.v-node.is-head { background: #f3f0ff; border-color: #d0bfff; }
.v-node.is-body { background: #ebfbee; border-color: #b2f2bb; }

.v-swatches { display: flex; flex-wrap: wrap; gap: .7rem; }
.v-swatch { display: grid; justify-items: center; gap: .2rem; }
.v-swatch span { width: 64px; height: 44px; border-radius: 10px; border: 2px solid var(--line); }
.v-swatch small { color: var(--muted); }

@media (max-width: 640px) {
  .v-flow { flex-direction: column; align-items: stretch; }
  .v-step { max-width: none; flex-direction: row; text-align: left; gap: .7rem; }
  .v-step .v-icon { font-size: 1.6rem; }
  .v-arrow { transform: rotate(90deg); }
  .v-compare { grid-template-columns: 1fr; }
  .v-anatomy { grid-template-columns: max-content; row-gap: .15rem; }
  .v-label { margin-bottom: .45rem; white-space: normal; }
  .v-label::before { content: "↑ "; }
  .v-meter-row { grid-template-columns: 1fr auto; }
  .v-meter-track { grid-column: 1 / -1; grid-row: 2; }
}

/* ---- tables, badges, admin ---- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fafbfe; }
.table .num { text-align: right; }
.table tr.me td { background: #fff9db; }
.table-scroll { overflow-x: auto; }
.lb .table td:first-child { font-size: 1.2rem; width: 3em; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.badge-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; text-align: center; display: grid; gap: .25rem; justify-items: center; }
.badge-emoji { font-size: 2.6rem; filter: grayscale(1); opacity: .3; }
.badge-card.earned .badge-emoji { filter: none; opacity: 1; }
.badge-card:not(.earned) b { color: var(--muted); }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; margin-bottom: 1.2rem; }
.panel .table { box-shadow: none; }
.add-form { display: grid; gap: .7rem; }
.add-form textarea { font-family: var(--mono); font-size: .9rem; }
.add-form .btn { justify-self: start; }
label.inline { display: flex; align-items: center; gap: .5em; font-size: .92rem; }
label.inline input { width: auto; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.new-cards { margin-top: 1.2rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem; }
.login-slip { border: 2px dashed var(--ink-2); border-radius: 12px; padding: .8rem 1rem; background: #fffdf3; }
.slip-title { font-weight: 800; margin-bottom: .3rem; }
.slip-code { font: 700 1.2rem var(--mono); margin-top: .4rem; background: var(--accent); display: inline-block; padding: .1em .5em; border-radius: 6px; }
.actions { white-space: nowrap; }
.badge-row { font-size: 1.1rem; letter-spacing: .05em; }
.pi-key { background: var(--code-bg); color: var(--code-ink); padding: 1rem; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.myapp .preview { margin-top: .8rem; }

/* ---- fx, toasts, modal ---- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.fx-emoji { position: absolute; font-size: 2rem; will-change: transform; }
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: .5rem; z-index: 90; }
.toast { background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 10px; font-weight: 700; box-shadow: var(--shadow); animation: pop .2s ease-out; transition: opacity .4s, transform .4s; }
.toast.good { background: var(--good); }
.toast.bad { background: var(--bad); }
.toast.leaving { opacity: 0; transform: translateY(8px); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(27, 31, 59, .55); display: grid; place-items: center; z-index: 80; padding: 16px; animation: pop .2s; }
.modal { background: var(--card); border-radius: 22px; padding: 2rem 2.2rem; text-align: center; max-width: 380px; width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.badge-glow { width: 120px; height: 120px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, #fff3bf 0%, #ffe066 55%, #fab005 100%); box-shadow: 0 0 0 8px #fff9db, 0 0 40px #ffd43b; animation: spin-in .6s cubic-bezier(.2, 1.4, .4, 1); }
.badge-big { font-size: 3.6rem; }
@keyframes spin-in { from { transform: scale(0) rotate(-180deg); } to { transform: none; } }

/* ---- narrow screens ---- */
@media (max-width: 900px) {
  .module-page { grid-template-columns: minmax(0, 1fr); }
  .step-nav { position: static; }
  .step-nav ol { display: flex; flex-wrap: wrap; gap: .3rem; }
  .step-nav li a span:last-child { display: none; }
  .build { grid-template-columns: minmax(0, 1fr); }
  .code-editor { height: 300px; }
}
@media (max-width: 520px) {
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .hero-stats { width: 100%; }
  .stat { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- printing login cards ---- */
@media print {
  body.printing-cards * { visibility: hidden; }
  body.printing-cards .print-cards, body.printing-cards .print-cards * { visibility: visible; }
  body.printing-cards .print-cards { position: absolute; left: 0; top: 0; width: 100%; grid-template-columns: repeat(2, 1fr); }
  .login-slip { break-inside: avoid; }
}
