/* ===== Code Route Quest — playful study theme ===== */
:root {
  --bg: #fff8ef;
  --bg-2: #fff1df;
  --surface: #ffffff;
  --surface-2: #fdf6ec;
  --ink: #1f2440;
  --ink-2: #555b7a;
  --ink-3: #8a8fa8;
  --line: #efe3d3;
  --brand: #ff6b4a;
  --brand-ink: #ffffff;
  --accent: #4f46e5;
  --good: #16a34a;
  --good-bg: #dcfce7;
  --bad: #e11d48;
  --bad-bg: #ffe4e6;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --info-bg: #e0f2fe;
  --shadow: 0 2px 0 rgba(31, 36, 64, .06), 0 8px 24px -12px rgba(31, 36, 64, .18);
  --shadow-pop: 0 4px 0 rgba(31, 36, 64, .12);
  --radius: 22px;
  --radius-sm: 14px;
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, sans-serif;
  --font-head: 'Fredoka', 'Nunito', ui-rounded, system-ui, sans-serif;
  --img-bg: #ffffff;
  --sidebar-w: 270px;
  --tc: var(--brand);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141729; --bg-2: #1b1f36; --surface: #1f2440; --surface-2: #262c4d;
    --ink: #f3f1ff; --ink-2: #b9bdd9; --ink-3: #868ab0; --line: #30365c;
    --good-bg: #123524; --bad-bg: #3d1424; --warn-bg: #3b2a0c; --info-bg: #0f2d44;
    --shadow: 0 2px 0 rgba(0,0,0,.25), 0 10px 30px -12px rgba(0,0,0,.6);
    --shadow-pop: 0 4px 0 rgba(0,0,0,.35);
    --img-bg: #f4f4f7;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141729; --bg-2: #1b1f36; --surface: #1f2440; --surface-2: #262c4d;
  --ink: #f3f1ff; --ink-2: #b9bdd9; --ink-3: #868ab0; --line: #30365c;
  --good-bg: #123524; --bad-bg: #3d1424; --warn-bg: #3b2a0c; --info-bg: #0f2d44;
  --shadow: 0 2px 0 rgba(0,0,0,.25), 0 10px 30px -12px rgba(0,0,0,.6);
  --shadow-pop: 0 4px 0 rgba(0,0,0,.35);
  --img-bg: #f4f4f7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 17px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.7rem); }
h3 { font-size: 1.15rem; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; }
.muted { color: var(--ink-2); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink);
  font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
.brand b { color: var(--brand); font-weight: 700; }
.brand-car { display: inline-block; font-size: 1.5rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-4deg); } }
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; margin-left: auto;
  background: var(--surface); border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; }
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; width: 100%; }
.top-stats { display: flex; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  background: var(--surface); border: 2px solid var(--line); font-weight: 800; font-size: .9rem; white-space: nowrap; }
.icon-btn { border: 2px solid var(--line); background: var(--surface); border-radius: 14px; width: 42px; height: 42px;
  display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.icon-btn:hover { transform: translateY(-1px); }
.menu-btn { display: none; }

/* ===== Layout & sidebar ===== */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - 66px); }
.sidebar { position: sticky; top: 66px; height: calc(100vh - 66px); overflow-y: auto; padding: 18px 12px 40px;
  border-right: 2px solid var(--line); background: var(--bg-2); }
.nav-group { margin-bottom: 18px; }
.nav-label { font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; color: var(--ink);
  text-decoration: none; font-weight: 700; font-size: .95rem; }
.nav-link:hover { background: var(--surface); }
.nav-link.active { background: var(--surface); box-shadow: var(--shadow); color: var(--tc); }
.nav-link .emoji { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 10px;
  background: color-mix(in srgb, var(--tc) 18%, transparent); flex: none; }
.nav-link .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link .badge { font-size: .75rem; background: var(--bad); color: white; border-radius: 999px; padding: 0 8px; }
.scrim { display: none; }
main { padding: 28px clamp(16px, 3vw, 44px) 80px; min-width: 0; outline: none; }
.wrap { max-width: 1100px; margin: 0 auto; }
.narrow { max-width: 780px; margin: 0 auto; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: grid; }
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; width: 290px; z-index: 50; transform: translateX(-105%);
    transition: transform .25s ease; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .top-stats { display: none; }
  .brand span:last-child { display: none; }
  .topbar { padding: 10px 16px; gap: 10px; }
  main { padding: 20px 16px 80px; }
}

/* ===== Cards & buttons ===== */
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 16px;
  padding: 12px 20px; font-weight: 800; font-size: 1rem; text-decoration: none; background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--brand) 60%, black); transition: transform .08s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--brand) 60%, black); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.alt { background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: var(--shadow-pop); }
.btn.theme { background: var(--tc); box-shadow: 0 4px 0 color-mix(in srgb, var(--tc) 60%, black); }
.btn.good { background: var(--good); box-shadow: 0 4px 0 color-mix(in srgb, var(--good) 60%, black); }
.btn.small { padding: 8px 14px; font-size: .9rem; border-radius: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 800;
  background: color-mix(in srgb, var(--tc) 16%, transparent); color: color-mix(in srgb, var(--tc) 75%, var(--ink)); }
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
@media (max-width: 420px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* ===== Home hero ===== */
.hero { position: relative; overflow: hidden; border-radius: 28px; padding: 30px; color: #fff;
  background: linear-gradient(135deg, #ff6b4a 0%, #ff8f3f 45%, #ffb938 100%); box-shadow: var(--shadow); }
.hero h1 { color: #fff; margin-bottom: 6px; }
.hero p { margin: 0 0 18px; max-width: 560px; font-weight: 600; opacity: .95; }
.hero .btn { background: #fff; color: #1f2440; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.hero .btn.alt { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.5); }
.hero-inner { position: relative; z-index: 2; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.hero-text { flex: 1 1 320px; }
.road { position: absolute; left: 0; right: 0; bottom: 0; height: 56px; background: #3a3f5c; z-index: 1; }
.road::before { content: ""; position: absolute; left: 0; right: 0; top: 26px; height: 4px;
  background: repeating-linear-gradient(90deg, #ffd84d 0 34px, transparent 34px 64px); animation: lanes 1s linear infinite; }
@keyframes lanes { to { background-position: -64px 0; } }
.road-car { position: absolute; bottom: 14px; font-size: 2rem; z-index: 2; transform: scaleX(-1); animation: drive 9s linear infinite; }
@keyframes drive { from { left: -60px; } to { left: 100%; } }
.hero { padding-bottom: 86px; }
.big-ring { flex: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 22px 0; }
.stat { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .v { font-family: var(--font-head); font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.stat .l { color: var(--ink-2); font-size: .85rem; font-weight: 700; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 34px 0 14px; }
.section-title h2 { margin: 0; }

/* Theme tiles */
.tile { position: relative; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s; overflow: hidden; }
.tile::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: color-mix(in srgb, var(--tc) 14%, transparent); }
.tile:hover { transform: translateY(-3px) rotate(-.4deg); border-color: var(--tc); }
.tile .top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.tile .emo { font-size: 1.9rem; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px;
  background: color-mix(in srgb, var(--tc) 20%, transparent); }
.tile h3 { margin: 0; font-size: 1.08rem; }
.tile .num { font-size: .75rem; font-weight: 800; color: var(--tc); text-transform: uppercase; letter-spacing: .06em; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--tc); border-radius: 999px; transition: width .5s; }

/* Progress ring */
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: color-mix(in srgb, currentColor 18%, transparent); }
.ring .val { transition: stroke-dashoffset .8s ease; stroke-linecap: round; }
.ring b { position: absolute; font-family: var(--font-head); font-weight: 600; }

/* ===== Theme page ===== */
.theme-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 26px; border-radius: 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--tc) 85%, white), var(--tc)); color: #fff; box-shadow: var(--shadow); }
.theme-head h1 { color: #fff; margin: 0; }
.theme-head .emo { font-size: 3rem; width: 84px; height: 84px; display: grid; place-items: center; border-radius: 26px; background: rgba(255,255,255,.22); }
.theme-head .btn { background: #fff; color: #1f2440; box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.sub-block { margin-top: 26px; }
.sub-block h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lesson-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lesson-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--surface);
  border: 2px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; transition: transform .12s, border-color .12s; }
.lesson-item:hover { transform: translateX(3px); border-color: var(--tc); }
.lesson-item .dot { width: 34px; height: 34px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: .9rem;
  background: color-mix(in srgb, var(--tc) 16%, transparent); color: var(--tc); font-weight: 800; }
.lesson-item.done .dot { background: var(--good); color: #fff; }
.lesson-item .meta { font-size: .78rem; color: var(--ink-3); font-weight: 700; }

/* ===== Lesson reader ===== */
.crumbs { font-size: .88rem; font-weight: 700; color: var(--ink-3); display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--tc); }
.lesson-head { border-left: 8px solid var(--tc); padding: 4px 0 4px 18px; margin-bottom: 22px; }
.lesson-head h1 { margin-bottom: 8px; }
.reading-bar { position: fixed; top: 0; left: 0; height: 4px; background: var(--tc); z-index: 60; width: 0; transition: width .1s; }
.lesson-body { font-size: 1.05rem; }
.lesson-body h2 { margin-top: 1.6em; padding-top: .3em; display: flex; gap: 10px; align-items: center; }
.lesson-body h2::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--tc); transform: rotate(45deg); flex: none; }
.lesson-body h3 { margin-top: 1.3em; color: color-mix(in srgb, var(--tc) 70%, var(--ink)); }
.lesson-body p { margin: 0 0 .8em; }
.lesson-body ul { margin: 0 0 1em; padding-left: 0; list-style: none; }
.lesson-body li { position: relative; padding: 4px 0 4px 28px; }
.lesson-body li::before { content: ""; position: absolute; left: 6px; top: .85em; width: 10px; height: 10px; border-radius: 50%;
  background: color-mix(in srgb, var(--tc) 55%, transparent); }
.lesson-body strong.lbl { color: color-mix(in srgb, var(--tc) 70%, var(--ink)); }
.lesson-body .formula { font-family: var(--font-head); font-size: 1.15rem; text-align: center; padding: 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--tc) 12%, var(--surface)); border: 2px dashed color-mix(in srgb, var(--tc) 50%, transparent); }
figure { margin: 18px 0 22px; text-align: center; }
figure img { background: var(--img-bg); border-radius: 18px; border: 2px solid var(--line); cursor: zoom-in; max-height: 560px;
  object-fit: contain; box-shadow: var(--shadow); transition: transform .2s; }
figure img:hover { transform: scale(1.01); }
figure.callout img { max-height: 360px; }
figcaption { font-size: .85rem; color: var(--ink-3); font-weight: 700; margin-top: 6px; }
.tool-callouts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin: 26px 0; }
.tool-card { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 18px; text-decoration: none; color: var(--ink);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface)); border: 2px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
.tool-card:hover { transform: translateY(-2px); }
.tool-card .ico { font-size: 1.9rem; }
.tool-card b { display: block; font-family: var(--font-head); font-weight: 600; }
.lesson-foot { margin-top: 36px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.pager a { display: block; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--line); text-decoration: none; color: var(--ink); background: var(--surface); }
.pager a:hover { border-color: var(--tc); }
.pager small { display: block; color: var(--ink-3); font-weight: 800; font-size: .75rem; text-transform: uppercase; }
.pager .next { text-align: right; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* Glossary term chips */
.term { border-bottom: 2px dotted color-mix(in srgb, var(--accent) 60%, transparent); position: relative; cursor: help; }
.term .fr { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: .72em; font-weight: 800; vertical-align: .12em;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); white-space: nowrap; }
.term .tip { position: absolute; left: 0; bottom: calc(100% + 8px); width: min(300px, 80vw); z-index: 20; display: none;
  background: var(--ink); color: var(--bg); padding: 10px 12px; border-radius: 12px; font-size: .85rem; line-height: 1.4; font-weight: 600; box-shadow: var(--shadow); }
.term:hover .tip, .term:focus .tip { display: block; }

/* ===== Quiz ===== */
.quiz-shell { max-width: 820px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.quiz-top .bar { flex: 1; height: 14px; }
.q-card { background: var(--surface); border: 2px solid var(--line); border-radius: 26px; padding: clamp(18px, 3vw, 30px); box-shadow: var(--shadow); }
.q-text { font-family: var(--font-head); font-size: clamp(1.15rem, 1rem + .6vw, 1.45rem); font-weight: 500; line-height: 1.35; margin: 8px 0 18px; }
.q-hint { font-size: .82rem; font-weight: 800; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 14px 16px; border-radius: 18px;
  border: 2px solid var(--line); background: var(--surface-2); font-weight: 700; transition: transform .08s, border-color .1s, background .1s; }
.opt:hover { border-color: var(--accent); }
.opt .key { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; font-family: var(--font-head);
  font-weight: 700; background: var(--surface); border: 2px solid var(--line); }
.opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.opt.sel .key { background: var(--accent); color: #fff; border-color: var(--accent); }
.opt.right { border-color: var(--good); background: var(--good-bg); }
.opt.right .key { background: var(--good); color: #fff; border-color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.missed { border-style: dashed; border-color: var(--good); }
.opt[disabled] { cursor: default; }
.opt[disabled]:hover { border-color: inherit; }
.feedback { margin-top: 18px; padding: 16px 18px; border-radius: 18px; animation: pop .25s ease; }
.feedback.ok { background: var(--good-bg); border: 2px solid var(--good); }
.feedback.ko { background: var(--bad-bg); border: 2px solid var(--bad); }
.feedback h3 { margin: 0 0 4px; }
.feedback p { margin: 4px 0; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.timer { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 10px 0 0; border: 1px solid var(--line); }
.timer > i { display: block; height: 100%; background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); background-size: 300% 100%; }
.kbd { display: inline-block; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 8px; padding: 0 6px; font-size: .8rem; font-weight: 800; }

.result-hero { text-align: center; padding: 30px 20px; }
.result-hero .emoji-big { font-size: 4rem; line-height: 1; }
.verdict { display: inline-block; font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; padding: 6px 18px; border-radius: 999px; margin: 10px 0; }
.verdict.pass { background: var(--good-bg); color: var(--good); }
.verdict.fail { background: var(--bad-bg); color: var(--bad); }
.theme-bars { display: grid; gap: 10px; }
.theme-bar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 52px; gap: 12px; align-items: center; font-weight: 700; font-size: .9rem; }
.review-item { border-left: 6px solid var(--bad); }
.review-item.ok { border-left-color: var(--good); }

/* Official samples */
.off-card img { width: 100%; border-radius: 16px; border: 2px solid var(--line); cursor: zoom-in; }
.off-opts { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.off-opts .opt { width: auto; padding: 8px; }

/* Glossary */
.g-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 20px; }
.g-filters button { border: 2px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: .85rem; }
.g-filters button.on { background: var(--tc); border-color: var(--tc); color: #fff; }
.g-card { display: flex; flex-direction: column; gap: 6px; }
.g-card .fr { font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; color: var(--accent); display: flex; gap: 8px; align-items: center; }
.g-card .en { font-weight: 800; }
.g-card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.say { border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 10px; width: 32px; height: 32px; }
.text-input { width: 100%; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.text-input:focus { border-color: var(--accent); outline: 0; }

/* Badges */
.badge-card { text-align: center; padding: 18px 12px; }
.badge-card .b-emo { font-size: 2.6rem; filter: grayscale(1); opacity: .35; }
.badge-card.earned .b-emo { filter: none; opacity: 1; animation: wiggle 2s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-10deg); } 20% { transform: rotate(8deg); } 30% { transform: rotate(0); } }
.badge-card b { display: block; font-family: var(--font-head); font-weight: 600; margin-top: 6px; }
.badge-card small { color: var(--ink-3); font-weight: 700; }

/* Search */
.result { display: block; text-decoration: none; color: var(--ink); }
.result:hover { border-color: var(--tc); }
mark { background: #ffe066; color: #1f2440; border-radius: 4px; padding: 0 2px; }

/* Lightbox / toast / confetti */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 25, .88); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 96vw; max-height: 86vh; border-radius: 14px; background: #fff; }
.lightbox p { color: #fff; font-weight: 700; margin: 10px 0 0; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 90; background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 16px; font-weight: 800; box-shadow: var(--shadow); transition: transform .3s cubic-bezier(.2,1.4,.4,1); max-width: 92vw; }
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; top: -20px; z-index: 95; width: 10px; height: 14px; border-radius: 3px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty .e { font-size: 3rem; }
.tag-fr { font-style: italic; color: var(--ink-3); font-weight: 700; }

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