/* Permis CH v2 — Swiss road signage, in motion */
:root {
  --red: #D8232A; --red-deep: #A8141A;
  --green: #00853F; --green-deep: #00612E;
  --blue: #0D5EAF; --blue-deep: #0A4785;
  --yellow: #F5C400;
  --asphalt: #23272B; --asphalt-2: #2E3338;

  --bg: #E9ECEF;
  --surface: #FFFFFF;
  --surface-2: #F3F5F7;
  --surface-3: #E4E8EC;
  --ink: #15191D;
  --ink-2: #454D55;
  --ink-3: #6E7780;
  --line: #D6DBE0;
  --ok: #00853F; --ok-bg: #E2F4EA;
  --bad: #C41E25; --bad-bg: #FCE8E9;
  --focus: #0D5EAF;
  --shadow-1: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .05);
  --shadow-2: 0 2px 4px rgba(16, 24, 32, .06), 0 12px 32px rgba(16, 24, 32, .10);

  --font: 'Atkinson Hyperlegible', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-rtl: 'Vazirmatn', 'Atkinson Hyperlegible', system-ui, sans-serif;
  --nav-h: 70px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151A; --surface: #1C2026; --surface-2: #242930; --surface-3: #2D333B; --ink: #EEF1F4; --ink-2: #B7BFC7; --ink-3: #87909A;
    --line: #333A42; --ok: #3FC27A; --ok-bg: #16302A; --bad: #FF6B70; --bad-bg: #3B1E22; --focus: #6AAAF2;
    --shadow-1: 0 1px 2px rgba(0,0,0,.35); --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151A; --surface: #1C2026; --surface-2: #242930; --surface-3: #2D333B; --ink: #EEF1F4; --ink-2: #B7BFC7; --ink-3: #87909A;
  --line: #333A42; --ok: #3FC27A; --ok-bg: #16302A; --bad: #FF6B70; --bad-bg: #3B1E22; --focus: #6AAAF2;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35); --shadow-2: 0 2px 6px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden; }
[dir="rtl"] body { font-family: var(--font-rtl); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
svg { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0; }
h1 { font-size: clamp(28px, 6.4vw, 44px); font-weight: 700; }
h2 { font-size: 21px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; color: var(--ink-3); }
.sign { display: block; flex: none; }
.sign svg { width: 100%; height: 100%; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--red); display: grid; place-items: center; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.brand-mark svg { width: 20px; height: 20px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); line-height: 1.1; }
@media (max-width: 480px) { .brand small { display: none; } }
.topbar .spacer { flex: 1; }
.xp-chip { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; text-decoration: none; color: var(--ink); }
.xp-chip .flame { width: 16px; height: 16px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink-2); text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; }
.lang-pill { height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 12px; font-weight: 700; font-size: 14px; color: var(--ink-2); }

main { padding: 4px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px); max-width: 880px; width: 100%; margin: 0 auto; min-width: 0; }
main:focus { outline: none; }

.tabbar {
  position: fixed; inset: auto 12px calc(10px + env(safe-area-inset-bottom)) 12px; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: var(--nav-h); padding: 6px; border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); box-shadow: var(--shadow-2);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 16px; text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 700; transition: color .2s; }
.tabbar a svg { width: 23px; height: 23px; transition: transform .35s var(--spring); }
.tabbar a[aria-current="page"] { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.tabbar a[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }
.tabbar .rail-only { display: none; }
@media (min-width: 960px) {
  .shell { grid-template-columns: 236px minmax(0, 1fr); }
  .shell > .topbar { position: fixed; inset: 0 0 auto 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 90%, transparent); }
  .tabbar { position: sticky; top: 0; height: 100vh; inset: auto; grid-template-columns: 1fr; align-content: start; gap: 4px; padding: 90px 14px 20px; border-radius: 0; border: 0; border-inline-end: 1px solid var(--line); box-shadow: none; background: var(--surface); }
  .tabbar a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; font-size: 15px; }
  .tabbar .rail-only { display: flex; }
  main { grid-column: 2; padding-top: 86px; padding-bottom: 60px; }
}

/* ---------- page entrance (one orchestrated moment per view) */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.enter > * { animation: rise .5s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .05s; } .enter > *:nth-child(3) { animation-delay: .1s; } .enter > *:nth-child(4) { animation-delay: .15s; } .enter > *:nth-child(n+5) { animation-delay: .2s; }
::view-transition-old(root) { animation: .18s ease both fadeout; }
::view-transition-new(root) { animation: .28s var(--ease) both fadein; }
@keyframes fadeout { to { opacity: 0; } }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } }

/* ---------- hero: alpine road scene + speedometer */
.hero { position: relative; border-radius: 28px; overflow: hidden; color: #fff; box-shadow: var(--shadow-2); isolation: isolate; min-height: 380px; display: flex; flex-direction: column; }
.hero .scene { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.hero-top { padding: 22px 22px 0; }
.hero-greet { font-size: 15px; opacity: .9; }
.hero h1 { margin-top: 4px; max-width: 16ch; text-shadow: 0 2px 24px rgba(0,0,0,.25); }
.hero-bottom { margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: end; padding: 0 18px 18px; }
.gauge { width: 168px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
.gauge .needle { transform-origin: 100px 100px; transition: transform 1.6s var(--spring); }
.hero-actions { display: grid; gap: 10px; justify-items: stretch; padding-bottom: 6px; }
.hero-actions .btn { width: 100%; }
@media (max-width: 420px) { .hero-bottom { grid-template-columns: 1fr; justify-items: center; } .gauge { width: 190px; } .hero-actions { width: 100%; } }

/* ---------- buttons */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 14px; border: 0; font-weight: 700; font-size: 16px; text-decoration: none; transition: transform .12s var(--ease), box-shadow .2s, filter .2s; overflow: hidden; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-deep); }
.btn-primary:active { box-shadow: 0 1px 0 var(--red-deep); transform: translateY(3px); }
.btn-light { background: #fff; color: var(--ink); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.btn-glass { background: rgba(255,255,255,.16); color: #fff; border: 1.5px solid rgba(255,255,255,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn-plain { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-deep); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn .ripple { position: absolute; border-radius: 50%; transform: scale(0); background: currentColor; opacity: .25; animation: ripple .55s ease-out forwards; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* ---------- level + stats */
.level { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border-radius: 20px; padding: 14px 16px; box-shadow: var(--shadow-1); }
.level-badge { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 700; font-size: 22px; position: relative; }
.level-badge::after { content: ''; position: absolute; inset: 4px; border: 2px solid rgba(255,255,255,.85); border-radius: 12px; }
.level .name { font-weight: 700; }
.level .sub { font-size: 13px; color: var(--ink-3); }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), #3D8BDB); transition: width 1s var(--ease); }
.ring { width: 52px; height: 52px; }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--green); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 1.2s var(--ease); }
.ring text { font-size: 13px; font-weight: 700; fill: var(--ink); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--surface); border-radius: 18px; padding: 14px; box-shadow: var(--shadow-1); }
.tile b { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -.02em; }
.tile span { font-size: 13px; color: var(--ink-3); }

.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head a { font-size: 14px; font-weight: 700; text-decoration: none; }
.page-head { margin: 10px 0 20px; display: grid; gap: 6px; }

/* ---------- quick actions: sign-plate cards */
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.plate { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 148px; padding: 16px; border-radius: 22px; text-decoration: none; color: #fff; overflow: hidden; box-shadow: var(--shadow-1); transition: transform .25s var(--spring); }
.plate:active { transform: scale(.97); }
.plate::before { content: ''; position: absolute; inset: 6px; border: 2px solid rgba(255,255,255,.8); border-radius: 17px; pointer-events: none; }
.plate .sign { width: 44px; height: 44px; }
.plate .t { font-weight: 700; font-size: 17px; line-height: 1.2; margin-top: 12px; }
.plate .s { font-size: 13px; opacity: .88; margin-top: 2px; }
.plate.blue { background: var(--blue); }
.plate.green { background: var(--green); }
.plate.red { background: var(--red); }
.plate.dark { background: var(--asphalt); }
.plate .bg-sign { position: absolute; inset-inline-end: -18px; bottom: -18px; width: 110px; opacity: .14; }
@media (min-width: 700px) { .actions { grid-template-columns: repeat(4, 1fr); } }

/* ---------- rows */
.rows { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-1); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; text-decoration: none; color: var(--ink); border: 0; background: none; width: 100%; text-align: start; transition: background .15s; }
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: var(--surface-2); }
.row .sign { width: 42px; height: 42px; }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 700; }
.row .sub { font-size: 14px; color: var(--ink-3); margin-top: 1px; }
.row .end { color: var(--ink-3); font-size: 14px; font-weight: 700; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
[dir="rtl"] .chev { transform: scaleX(-1); }

/* ---------- route map (course) */
.route { position: relative; padding: 6px 0 6px; }
.route::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 39px; width: 14px; border-radius: 7px; background: var(--asphalt); }
.route::after { content: ''; position: absolute; inset-block: 14px; inset-inline-start: 45px; width: 2px; background: repeating-linear-gradient(180deg, #fff 0 12px, transparent 12px 24px); opacity: .7; }
.stop { position: relative; z-index: 1; display: grid; grid-template-columns: 92px 1fr; align-items: center; text-decoration: none; color: var(--ink); padding: 8px 0; }
.stop .pin { justify-self: start; margin-inline-start: 14px; width: 64px; height: 64px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-2); display: grid; place-items: center; transition: transform .3s var(--spring); }
.stop:hover .pin { transform: scale(1.06) rotate(-3deg); }
.stop .pin .sign { width: 44px; height: 44px; }
.stop .card { background: var(--surface); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow-1); display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.stop .num { font-size: 13px; color: var(--ink-3); font-weight: 700; }
.stop .title { font-weight: 700; line-height: 1.25; }
.stop.done .pin { outline: 3px solid var(--green); outline-offset: 2px; }
.stop.next .card { outline: 2px solid var(--red); }

/* ---------- lesson */
.lesson-hero { display: grid; grid-template-columns: 76px 1fr; gap: 16px; align-items: center; margin: 8px 0 18px; }
.lesson-hero .sign { width: 76px; height: 76px; }
.pri { display: block; }
.pri[dir="ltr"] { text-align: left; } .pri[dir="rtl"] { text-align: right; }
.tr { display: block; color: var(--ink-2); font-size: 15.5px; margin-top: 6px; }
.tr[dir="ltr"] { text-align: left; border-left: 3px solid var(--blue); padding-left: 10px; }
.tr[dir="rtl"] { text-align: right; border-right: 3px solid var(--blue); padding-right: 10px; font-family: var(--font-rtl); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.facts li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 16px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-1); }
.facts .num { width: 32px; height: 32px; border-radius: 50%; background: var(--yellow); color: #1b1b1b; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.sign-strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.sign-strip figure { margin: 0; flex: 0 0 112px; scroll-snap-align: start; text-align: center; font-size: 13px; color: var(--ink-2); background: var(--surface); border-radius: 16px; padding: 12px 8px; box-shadow: var(--shadow-1); }
.sign-strip svg { width: 70px; height: 70px; margin: 0 auto 8px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tool { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.tool svg { width: 16px; height: 16px; }
.tool.speaking { color: var(--blue); border-color: var(--blue); }

/* ---------- signs */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; height: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid-signs { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.flash { display: block; width: 100%; perspective: 900px; border: 0; padding: 0; background: none; aspect-ratio: 4 / 5; }
.flash-inner { display: block; position: relative; width: 100%; height: 100%; transition: transform .6s var(--spring); transform-style: preserve-3d; }
.flash.on .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1); display: grid; place-items: center; padding: 16px; text-align: center; }
.flash-face svg { width: 72%; }
.flash-back { transform: rotateY(180deg); align-content: center; gap: 8px; font-weight: 700; background: var(--blue); color: #fff; }
.flash-back .pri, .flash-back .tr { text-align: center; border: 0; padding: 0; color: #fff; }
.flash-back .tr { opacity: .85; font-weight: 400; }

/* ---------- quiz */
.qbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: 4px 0 14px; }
.qbar .count { font-weight: 700; color: var(--ink-2); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.road-track { position: relative; height: 22px; border-radius: 11px; background: var(--asphalt); overflow: hidden; }
.road-track::before { content: ''; position: absolute; left: 10px; right: 10px; top: 10px; height: 2px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.55) 0 10px, transparent 10px 20px); }
.road-track .fill { position: absolute; inset-block: 0; inset-inline-start: 0; background: color-mix(in srgb, var(--yellow) 30%, transparent); transition: width .5s var(--ease); }
.road-track .car { position: absolute; top: 3px; width: 28px; height: 16px; transition: inset-inline-start .5s var(--ease); }
[dir="rtl"] .road-track .car { transform: scaleX(-1); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; padding: 6px 10px; border-radius: 10px; background: var(--surface); }
.timer.low { color: #fff; background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.qcard { position: relative; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-2); padding: 20px; }
.qcard.slide-in { animation: slidein .45s var(--ease) both; }
@keyframes slidein { from { opacity: 0; transform: translateX(28px); } }
[dir="rtl"] .qcard.slide-in { animation-name: slidein-rtl; }
@keyframes slidein-rtl { from { opacity: 0; transform: translateX(-28px); } }
.qhead { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.qhead.nosign { grid-template-columns: 1fr; }
.qhead .sign { width: 88px; height: 88px; }
.qtext { font-size: 20px; font-weight: 700; line-height: 1.35; }
.qmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.pts { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--ink-2); }
.combo { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 14px; background: color-mix(in srgb, var(--yellow) 25%, transparent); color: #7A5D00; font-size: 13px; font-weight: 700; animation: pop .4s var(--spring); }
:root[data-theme="dark"] .combo { color: var(--yellow); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .combo { color: var(--yellow); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.hint { margin-top: 16px; font-size: 14px; color: var(--ink-3); }
.answers { display: grid; gap: 10px; margin-top: 10px; }
.ans { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; text-align: start; padding: 14px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface); transition: border-color .15s, background .15s, transform .2s var(--spring); }
.ans:active:not([disabled]) { transform: scale(.98); }
.ans .box { width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--ink-3); display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--ink-3); transition: all .2s var(--spring); }
.ans[aria-pressed="true"] { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 7%, var(--surface)); }
.ans[aria-pressed="true"] .box { background: var(--blue); border-color: var(--blue); color: #fff; transform: scale(1.08); }
.ans.ok { border-color: var(--ok); background: var(--ok-bg); }
.ans.ok .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.ans.bad { border-color: var(--bad); background: var(--bad-bg); }
.ans.bad .box { background: var(--bad); border-color: var(--bad); color: #fff; }
.ans.missed { border-style: dashed; border-color: var(--ok); }
.ans .tr { font-size: 14.5px; margin-top: 4px; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.glow { animation: glow .8s ease-out; }
@keyframes glow { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent), var(--shadow-2); } to { box-shadow: 0 0 0 18px transparent, var(--shadow-2); } }
.feedback { margin-top: 16px; padding: 16px; border-radius: 18px; border-inline-start: 5px solid var(--ok); background: var(--ok-bg); animation: rise .35s var(--ease); }
.feedback.bad { border-color: var(--bad); background: var(--bad-bg); }
.feedback h3 { margin-bottom: 6px; }
.qactions { display: flex; gap: 10px; margin-top: 16px; }
.qactions .btn { flex: 1; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.dots button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 700; color: var(--ink-3); }
.dots button.done { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dots button.cur { outline: 2px solid var(--red); outline-offset: 1px; }
.float-xp { position: fixed; z-index: 80; pointer-events: none; font-weight: 700; font-size: 20px; color: var(--ok); animation: floatup 1s var(--ease) forwards; text-shadow: 0 2px 8px rgba(0,0,0,.15); }
@keyframes floatup { from { opacity: 0; transform: translateY(0) scale(.8); } 20% { opacity: 1; transform: translateY(-10px) scale(1.1); } to { opacity: 0; transform: translateY(-70px) scale(1); } }

/* ---------- sprint */
.sprint-sign { width: min(220px, 60vw); margin: 10px auto 18px; transition: transform .25s var(--spring); }
.sprint-sign.pop { animation: pop .35s var(--spring); }
.sprint-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sprint-opts button { min-height: 72px; padding: 10px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; font-size: 15px; line-height: 1.25; transition: transform .15s var(--spring); }
.sprint-opts button:active { transform: scale(.96); }
.sprint-opts button.ok { border-color: var(--ok); background: var(--ok-bg); }
.sprint-opts button.bad { border-color: var(--bad); background: var(--bad-bg); }
.sprint-top { display: flex; justify-content: space-between; align-items: center; }
.sprint-score { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.clock { width: 56px; height: 56px; }
.clock circle { fill: none; stroke-width: 6; }
.clock .fg { stroke: var(--red); transform: rotate(-90deg); transform-origin: 50% 50%; stroke-linecap: round; }

/* ---------- result */
.result { text-align: center; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-2); padding: 30px 20px; overflow: hidden; position: relative; }
.result .big { font-size: 72px; font-weight: 700; line-height: 1; margin: 12px 0 4px; letter-spacing: -.03em; }
.result .badge { display: inline-block; padding: 7px 16px; border-radius: 20px; font-weight: 700; color: #fff; background: var(--ok); animation: pop .5s .3s var(--spring) both; }
.result .badge.fail { background: var(--red); }
.result .sign { width: 84px; height: 84px; margin: 0 auto; animation: pop .6s var(--spring); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- settings */
.field { display: grid; gap: 6px; padding: 14px 16px; }
.field + .field { border-top: 1px solid var(--line); }
.field label { font-weight: 700; font-size: 15px; }
.field select { height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 700; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- sheet + toast */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(10,14,18,.5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 560px; max-height: 80vh; overflow: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .3s var(--ease); }
.sheet::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 26px; } .sheet::before { display: none; } }
.sheet h3 { margin: 4px 4px 12px; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.lang-grid button { min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; text-align: start; padding: 0 12px; }
.lang-grid button[aria-pressed="true"] { border-color: var(--red); color: var(--red); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; z-index: 70; inset-inline: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 700; text-align: center; animation: up .25s var(--ease); }
.install-row { display: none; } .install-row.show { display: block; }
.foot { margin-top: 32px; font-size: 13px; color: var(--ink-3); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* v2 polish */
.brand > span:last-child { white-space: nowrap; }
.xp-chip { white-space: nowrap; flex: none; }
.xp-chip small { font-size: 11px; color: var(--ink-3); font-weight: 700; }
@media (max-width: 400px) { .brand > span:last-child { display: none; } }
.tile.goal { display: grid; justify-items: center; text-align: center; gap: 4px; }
.tile.goal .ring { width: 46px; height: 46px; }
.btn-light { color: #15191D; }
