/* «Экспресс Мандаринки» Mini App. Colours follow the learner's Telegram theme (telegram-web-app.js sets
   --tg-theme-*); the mandarin accent marks progress and the one primary action per screen. */

:root {
  --bg: var(--tg-theme-secondary-bg-color, #f0f0f3);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #6b6b70);
  --sep: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.16));
  --link: var(--tg-theme-link-color, #2481cc);
  --link-ink: var(--link); /* darkened below where color-mix works */

  --brand: #ff8a00;
  --on-brand: #2b1700;
  --brand-ink: #a64d00;
  --brand-soft: rgba(255, 138, 0, 0.13);
  --track: rgba(120, 120, 128, 0.16);
  --press: rgba(120, 120, 128, 0.12);
  --ok: #1e9e58;
  --ok-ink: #137a41;
  --ok-soft: rgba(30, 158, 88, 0.13);
  --bad: #e5484d;
  --bad-ink: #c0282d;
  --bad-soft: rgba(229, 72, 77, 0.12);
  --lantern: #d9412a;
  /* tone colours (Pleco-like: 1 red, 2 green, 3 blue, 4 purple, neutral grey) */
  --t1: #d02b2b;
  --t2: #127237;
  --t3: #2563d9;
  --t4: #8b3fd3;

  --r: 14px;
  --r-lg: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 150ms;
  --base: 220ms;
  --slow: 420ms;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --han: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "Kaiti", var(--han);
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabs-h: 56px;
  --z-tabs: 10;
  --z-layer: 20;
  --z-sheet: 30;
  --z-toast: 40;
}

/* Secondary text is derived from the theme's own text colour: Telegram's hint grey is too faint for body text. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --hint: color-mix(in srgb, var(--text) 68%, var(--card));
    /* Telegram's iOS link blue is 3.5:1 on its light grey: pulled toward the text colour it clears 4.5:1 in both themes */
    --link-ink: color-mix(in srgb, var(--link) 80%, var(--text));
  }
}

[data-scheme="dark"] {
  --on-brand: #231300;
  --brand-ink: #ffa640;
  --brand-soft: rgba(255, 138, 0, 0.18);
  --track: rgba(120, 120, 128, 0.3);
  --press: rgba(120, 120, 128, 0.22);
  --ok: #34c276;
  --ok-ink: #4fd18a;
  --ok-soft: rgba(52, 194, 118, 0.16);
  --bad: #ff6369;
  --bad-ink: #ff7a7f;
  --bad-soft: rgba(255, 99, 105, 0.16);
  --lantern: #ff7a52;
  --t1: #ff6b6b;
  --t2: #45c97c;
  --t3: #6fa3ff;
  --t4: #c38cff;
}

/* ---- base ---------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.locked { overflow: hidden; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.han { font-family: var(--han); }
.kai { font-family: var(--kai); }
.hint { color: var(--hint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.i-s { width: 18px; height: 18px; }
.i-fill { fill: currentColor; stroke: none; }
.flip { transform: scaleX(-1); }

.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--hint); }

/* ---- shell: tab content, tab bar, layers --------------------------------------------------------- */

/* one comfortable column on wide screens (Telegram Desktop, tablets): side padding centres everything */
:root { --side: max(0px, calc((100vw - 600px) / 2)); }
#view { padding: 0 var(--side) calc(var(--tabs-h) + var(--safe-b) + 24px); }
.tab { animation: tab-in var(--base) var(--ease); }
@keyframes tab-in { from { opacity: 0; transform: translateY(6px); } }

#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabs);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 0 max(4px, var(--side)) var(--safe-b);
  background: var(--card);
  border-top: 0.5px solid var(--sep);
}
#tabs button {
  appearance: none; border: 0; background: none; cursor: pointer;
  min-height: var(--tabs-h); padding: 6px 0 5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--hint); font: 500 11px/1.2 var(--font);
}
#tabs button > svg { border-radius: 14px; width: 52px; height: 28px; padding: 2px 13px; transition: background-color var(--base) var(--ease); }
#tabs button[aria-current="page"] { color: var(--text); font-weight: 600; }
#tabs button[aria-current="page"] > svg { background: var(--brand-soft); color: var(--brand-ink); }

.layer {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: var(--z-layer);
  padding: 0 var(--side);
  background: var(--bg);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px);
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
.layer.in { opacity: 1; transform: none; }
.layer.out { opacity: 0; transform: translateY(10px); transition-duration: var(--fast); }
.layer-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.sheet-wrap {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: var(--z-sheet);
  padding: 0 var(--side);
  display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(0, 0, 0, 0);
  transition: background-color var(--base) var(--ease);
}
.sheet-wrap.in { background: rgba(0, 0, 0, 0.36); }
.sheet {
  max-height: 86vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 16px calc(16px + var(--safe-b));
  transform: translateY(100%);
  transition: transform var(--base) var(--ease);
}
.sheet-wrap.in .sheet { transform: none; }
.sheet-wrap.out { background: rgba(0, 0, 0, 0); }
.sheet-wrap.out .sheet { transform: translateY(100%); transition-duration: var(--fast); }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--track); margin: 0 auto 12px; }
.sheet h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.sheet .lead { color: var(--hint); margin-bottom: 16px; }
.sheet .stack { display: grid; gap: 10px; margin-top: 18px; }
.sheet .prose { font-size: 15px; line-height: 1.5; white-space: pre-line; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); z-index: var(--z-toast);
  margin: 0 auto; max-width: 420px; padding: 12px 16px; border-radius: var(--r);
  background: var(--text); color: var(--card); font-size: 15px; text-align: center;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
#toast.show { opacity: 1; transform: none; }

/* ---- page scaffolding ------------------------------------------------------------------------------ */

.page-head { padding: 18px 16px 14px; }
.title { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
.page-head .sub { margin-top: 4px; color: var(--hint); font-size: 15px; }
.page-head .bar { margin-top: 12px; }
.group-title { margin: 22px 32px 7px; color: var(--hint); font-size: 14px; font-weight: 500; }
.note { margin: 8px 32px 0; color: var(--hint); font-size: 13px; line-height: 1.4; }

.section { margin: 0 16px; background: var(--card); border-radius: var(--r); overflow: hidden; }
.section + .section { margin-top: 12px; }
.pad-block { padding: 16px; }

.row {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 54px; padding: 10px 16px;
  background: none; border: 0; text-align: left; color: inherit; font: inherit;
}
button.row, a.row { cursor: pointer; text-decoration: none; transition: background-color var(--fast); }
button.row:active, a.row:active { background: var(--press); }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 58px; border-top: 0.5px solid var(--sep); }
.row.flat + .row::before, .row + .row.flat::before { left: 16px; }
.row .grow { flex: 1; min-width: 0; }
.row .t, .row .s { display: block; }
.row .t { font-size: 16px; line-height: 1.3; }
.row .s { margin-top: 2px; color: var(--hint); font-size: 14px; line-height: 1.3; }
.row .v { color: var(--hint); font-size: 16px; white-space: nowrap; }
.row .chev { width: 18px; height: 18px; color: var(--hint); }
.ic {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-ink);
}
.ic .i { width: 19px; height: 19px; stroke-width: 2; }
.ic.ok { background: var(--ok-soft); color: var(--ok-ink); }
.ic.bad { background: var(--bad-soft); color: var(--bad-ink); }
.ic.plain { background: var(--track); color: var(--text); }

/* ---- controls ------------------------------------------------------------------------------------------ */

.btn {
  appearance: none; border: 0; cursor: pointer;
  width: 100%; min-height: 52px; padding: 8px 18px; border-radius: var(--r);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font: 600 17px/1.2 var(--font); text-align: center;
  transition: transform var(--fast) var(--ease), background-color var(--fast);
}
.btn:active { transform: scale(0.98); }
.btn small { font-size: 13px; font-weight: 500; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-plain { background: var(--card); color: var(--text); }
.btn-quiet { background: var(--track); color: var(--text); }
.btn-link { background: none; color: var(--link-ink); min-height: 44px; font-weight: 500; }
.btn[aria-busy="true"] { pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; width: 16px; height: 16px; margin-top: 4px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

.icon-btn {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--hint);
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none;
}
.icon-btn:active { background: var(--press); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 32px; padding: 0 11px 0 8px; border-radius: 16px;
  background: var(--card); font-size: 15px; font-weight: 600; white-space: nowrap;
}
.chip .i { width: 20px; height: 20px; }
.chip .mandarin { color: var(--brand); }
.chip .lantern { color: var(--hint); }
.chip.lit .lantern { color: var(--lantern); }
button.chip { border: 0; cursor: pointer; }
/* small controls keep their look but get a 44 px tall tap area */
button.chip, .flag, .filter, .segmented button, .mini-play, .palette.small .cell { position: relative; }
button.chip::after, .flag::after, .filter::after, .segmented button::after, .mini-play::after, .palette.small .cell::after {
  content: ""; position: absolute; inset: 50% 0 auto; height: 44px; transform: translateY(-50%);
}

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px;
  font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand-ink); white-space: nowrap;
}
.tag.ok { background: var(--ok-soft); color: var(--ok-ink); }
.tag.bad { background: var(--bad-soft); color: var(--bad-ink); }
.tag.plain { background: var(--track); color: var(--text); }

.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > i {
  display: block; height: 100%; background: var(--brand);
  transform-origin: 0 50%; transform: scaleX(calc(var(--p, 0) / 100)); transition: transform var(--slow) var(--ease);
}
.bar.ok > i { background: var(--ok); }
.bar.bad > i { background: var(--bad); }
.bar.thick { height: 8px; border-radius: 4px; }

.ring { display: block; flex: none; }
.ring-track { fill: none; stroke: var(--track); }
.ring-fill { fill: none; stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset var(--slow) var(--ease); }
.ring.ok .ring-fill { stroke: var(--ok); }
.ring.bad .ring-fill { stroke: var(--bad); }
.ring.anim .ring-fill { animation: ring-in 800ms var(--ease) both; }
@keyframes ring-in { from { stroke-dashoffset: var(--c); } }

.switch {
  appearance: none; flex: none; cursor: pointer; margin: 0;
  width: 51px; height: 31px; border-radius: 16px; background: var(--track); position: relative;
  transition: background-color var(--base) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--base) var(--ease);
}
.switch:checked { background: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

.select {
  appearance: none; -webkit-appearance: none; border: 0; cursor: pointer;
  max-width: 55%; min-height: 36px; padding: 6px 26px 6px 10px; border-radius: 10px;
  background: var(--track) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 9px center;
  color: var(--text); font: 500 15px/1.2 var(--font); text-align: right; text-align-last: right;
}
input.select[type="date"] { padding-right: 10px; background-image: none; min-width: 140px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 2px; border-radius: 10px; background: var(--track); }
.segmented button {
  appearance: none; border: 0; cursor: pointer; min-height: 34px; border-radius: 8px; background: none;
  font: 500 15px/1 var(--font); color: var(--text);
  transition: background-color var(--fast);
}
.segmented button[aria-pressed="true"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.skel { border-radius: var(--r); background: var(--track); animation: skel 1.2s ease-in-out infinite alternate; }
@keyframes skel { from { opacity: 0.55; } to { opacity: 1; } }

.state { padding: 48px 24px; text-align: center; }
.state .i { width: 40px; height: 40px; color: var(--hint); margin-bottom: 12px; }
.state h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.state p { color: var(--hint); margin-bottom: 18px; }
.state .btn { max-width: 280px; }

/* ---- home ------------------------------------------------------------------------------------------------ */

.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 16px 14px; }
.home-head .sub { color: var(--hint); font-size: 15px; }
.home-head .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-head .chips { display: flex; gap: 6px; flex: none; }

.ticket { position: relative; display: flex; margin: 0 16px; background: var(--card); border-radius: var(--r-lg); }
.ticket-main { flex: 1; min-width: 0; padding: 16px 14px 16px 16px; }
.ticket-head { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; margin-bottom: 10px; }
.ticket-head b { font-size: 17px; font-weight: 600; }
.ticket-head span { max-width: 100%; color: var(--hint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-head .stamp { margin: 3px 0 1px 2px; }
.ticket-line {
  display: block; width: 100%; padding: 6px 0; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 8px;
}
.ticket-line:active { background: var(--press); }
.ticket-line .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; margin-bottom: 6px; }
.ticket-line .lbl span:last-child { color: var(--hint); }
.ticket-line.done .lbl span:last-child { color: var(--ok-ink); font-weight: 600; }
.ticket-stub {
  position: relative; flex: none; width: 84px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-left: 2px dashed var(--sep);
}
.ticket-stub::before, .ticket-stub::after {
  content: ""; position: absolute; left: -10px; width: 18px; height: 18px; border-radius: 50%; background: var(--bg);
}
.ticket-stub::before { top: -9px; }
.ticket-stub::after { bottom: -9px; }
.ticket-stub .lantern { width: 30px; height: 30px; color: var(--hint); }
.ticket.stamped .ticket-stub .lantern { color: var(--lantern); }
.ticket-stub b { font-size: 28px; line-height: 1.05; font-weight: 700; }
.ticket-stub span { color: var(--hint); font-size: 13px; }
.stamp {
  flex: none; padding: 3px 9px; border: 2px solid var(--brand-ink); border-radius: 8px;
  color: var(--brand-ink); font: 700 12px/1.1 var(--font); letter-spacing: 0.06em; text-transform: uppercase;
  transform: rotate(-6deg);
}
.stamp.pressed { animation: stamp-in 320ms var(--ease) both; }
@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-14deg) scale(1.8); }
  to { opacity: 1; transform: rotate(-6deg) scale(1); }
}

.cta { margin: 14px 16px 0; }
.cta .btn { min-height: 60px; }
.cta small { color: var(--on-brand); }

.banner { display: flex; gap: 12px; align-items: flex-start; margin: 14px 16px 0; padding: 14px 16px; border-radius: var(--r); background: var(--brand-soft); }
.banner .i { color: var(--brand-ink); margin-top: 1px; }
.banner p { font-size: 15px; line-height: 1.4; }
.banner .btn { margin-top: 10px; min-height: 44px; font-size: 15px; width: auto; padding: 6px 14px; }

.mini-track { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--hint); }
.mini-track .bar { flex: 1; }

/* ---- route ------------------------------------------------------------------------------------------------ */

.rail { position: relative; padding: 4px 16px 8px 16px; }
.st { position: relative; display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; padding-bottom: 18px; }
.st::before {
  /* the track to the next station: two rails with sleepers */
  content: ""; position: absolute; left: 13px; top: 30px; bottom: -2px; width: 14px;
  background:
    linear-gradient(var(--rail, var(--track)), var(--rail, var(--track))) left / 2.5px 100% no-repeat,
    linear-gradient(var(--rail, var(--track)), var(--rail, var(--track))) right / 2.5px 100% no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 7px, var(--rail, var(--track)) 7px 9px);
  opacity: 0.9;
}
.st:last-child::before { display: none; }
.st.done { --rail: var(--brand); }
.node {
  position: relative; z-index: 1; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card); border: 2.5px solid var(--track); color: var(--hint);
}
.st.done .node { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.st.current .node { border-color: var(--brand); color: var(--brand-ink); }
.node .i { width: 20px; height: 20px; stroke-width: 2.2; }
.node .han { font-size: 15px; font-weight: 600; }
.st-body { min-width: 0; padding-top: 1px; }
.st-name, .st-meta { display: flex; }
.st-name { align-items: baseline; gap: 8px; flex-wrap: wrap; }
.st-name .han { font-size: 20px; font-weight: 600; }
.st-name b { font-size: 17px; font-weight: 600; }
.st-meta { color: var(--hint); font-size: 14px; margin-top: 2px; }
.st.locked .st-name { color: var(--hint); }
button.st-toggle { appearance: none; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; width: 100%; }

.chapters { margin-top: 12px; background: var(--card); border-radius: var(--r); overflow: hidden; }
.chapter { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 8px 14px; border: 0; background: none; text-align: left; cursor: pointer; }
.chapter:active { background: var(--press); }
.chapter + .chapter::before { content: ""; position: absolute; top: 0; right: 0; left: 62px; border-top: 0.5px solid var(--sep); }
.chapter .ring-wrap { position: relative; width: 36px; height: 36px; flex: none; }
.chapter .ring-wrap .i { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; color: var(--brand-ink); }
.chapter .grow { flex: 1; min-width: 0; }
.chapter .t, .chapter .s { display: block; }
.chapter .t { font-size: 16px; }
.chapter .s { color: var(--hint); font-size: 13px; margin-top: 1px; }
.chapter .here { color: var(--brand-ink); }
.chapter .train { width: 22px; height: 22px; color: var(--brand-ink); }
.chapter .chev { width: 18px; height: 18px; color: var(--hint); flex: none; }
.st-actions { margin-top: 12px; }

.word-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.word-list li + li { border-top: 0.5px solid var(--sep); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid var(--hint); }
.dot.learned { background: var(--ok); border-color: var(--ok); }
.dot.learning { border-color: var(--brand); background: linear-gradient(90deg, var(--brand) 50%, transparent 50%); }
.word-list .w { flex: 1; min-width: 0; }
.word-list .w .han { font-size: 20px; margin-right: 6px; }
.word-list .w .py { font-size: 15px; }
.word-list .w .ru { color: var(--hint); font-size: 14px; margin-top: 1px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; color: var(--hint); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- study hub ---------------------------------------------------------------------------------------------- */

.lesson-card { margin: 0 16px; padding: 18px 16px 16px; background: var(--card); border-radius: var(--r-lg); }
.lesson-card .top { display: flex; justify-content: space-between; align-items: baseline; }
.lesson-card h2 { font-size: 20px; font-weight: 600; }
.lesson-card .figures { display: flex; gap: 24px; margin: 14px 0 16px; }
.lesson-card .figures b { display: block; font-size: 30px; line-height: 1.1; font-weight: 700; }
.lesson-card .figures span { color: var(--hint); font-size: 14px; }

/* ---- players (lesson, handwriting, exam, onboarding) --------------------------------------------------- */

.player-head {
  position: relative; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; min-height: 56px; flex: none;
}
.player-head .bar { flex: 1; }
.player-head .count { font-size: 15px; font-weight: 600; color: var(--hint); min-width: 44px; text-align: right; }
.player-head .timer { display: inline-flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 600; }
.player-head .timer.low { color: var(--bad-ink); }
.player-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 8px 16px 16px; }
.player-body > .step { margin: auto 0; }
.player-body > .step.top { margin: 8px 0 auto; }
.player-foot { flex: none; padding: 10px 16px calc(12px + var(--safe-b)); }
.player-foot:empty { display: none; }

.step { animation: step-in var(--base) var(--ease); }
@keyframes step-in { from { opacity: 0; transform: translateX(14px); } }
.kicker { color: var(--hint); font-size: 14px; font-weight: 500; text-align: center; margin-bottom: 6px; }
.hero-han { font-family: var(--kai); font-weight: 400; line-height: 1.15; text-align: center; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.hero-py { text-align: center; font-size: 24px; font-weight: 500; margin-top: 4px; }
.hero-ru { text-align: center; font-size: 19px; margin-top: 6px; text-wrap: balance; }
.ask { text-align: center; font-size: 17px; color: var(--hint); margin: 10px 0 20px; text-wrap: balance; }
.ask b { color: var(--text); font-weight: 600; }

.sound-btn {
  appearance: none; border: 0; cursor: pointer; margin: 14px auto 0;
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px; border-radius: 22px;
  background: var(--brand-soft); color: var(--brand-ink); font: 600 15px/1 var(--font);
}
.sound-btn.big { width: 96px; height: 96px; padding: 0; border-radius: 50%; justify-content: center; margin: 8px auto 4px; }
.sound-btn.big .i { width: 40px; height: 40px; }
.playing .i { animation: pulse 900ms ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

.examples { margin-top: 24px; background: var(--card); border-radius: var(--r); }
.examples li { display: flex; gap: 10px; padding: 12px 14px; }
.examples li + li { border-top: 0.5px solid var(--sep); }
.examples .zh { font-family: var(--han); font-size: 19px; line-height: 1.35; }
.examples .py { color: var(--hint); font-size: 14px; margin-top: 2px; }
.examples .ru { font-size: 15px; margin-top: 3px; }
.mini-play { appearance: none; border: 0; background: none; cursor: pointer; color: var(--brand-ink); width: 36px; height: 36px; margin: -4px -4px 0 -6px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.mini-play:active { background: var(--press); }
.mini-play .i { width: 20px; height: 20px; }

.options { display: grid; gap: 10px; }
.opt {
  appearance: none; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 12px 16px; border-radius: var(--r);
  background: var(--card); border: 1.5px solid transparent; color: var(--text);
  font: 500 17px/1.3 var(--font); text-align: left;
  transition: background-color var(--fast), border-color var(--fast), transform var(--fast) var(--ease), color var(--fast);
}
.opt:active { transform: scale(0.985); }
.opt .mark { margin-left: auto; width: 22px; height: 22px; stroke-width: 2.4; }
.options.han .opt { font-family: var(--kai); font-size: 26px; font-weight: 400; justify-content: center; }
.options.han .opt .mark { position: absolute; right: 14px; }
.options.han .opt { position: relative; }
.options.py .opt { justify-content: center; font-size: 20px; }
.options.py .opt .mark { position: absolute; right: 14px; }
.options.py .opt { position: relative; }
.opt.chosen { border-color: var(--brand); background: var(--brand-soft); }
.opt.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok-ink); }
.opt.bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); animation: shake 280ms var(--ease); }
.opt.ok-pop { animation: pop 260ms var(--ease); }
.opt.muted { color: var(--hint); }
.options.locked .opt { cursor: default; }
.options.locked .opt:active { transform: none; }
.dont-know { margin-top: 4px; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }
@keyframes pop { 50% { transform: scale(1.025); } }

.feedback {
  margin: 0 -16px calc(-12px - var(--safe-b)); padding: 16px 16px calc(14px + var(--safe-b));
  border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--card);
  animation: feedback-in var(--base) var(--ease);
}
@keyframes feedback-in { from { transform: translateY(100%); } }
.feedback .fb-head { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 700; }
.feedback.ok .fb-head { color: var(--ok-ink); }
.feedback.bad .fb-head { color: var(--bad-ink); }
.feedback .gain { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 15px; font-weight: 600; }
.feedback .gain .i { width: 18px; height: 18px; color: var(--brand); }
.feedback .fb-word { margin-top: 8px; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.feedback .fb-word .han { font-size: 20px; }
.feedback .fb-right { margin-top: 4px; font-size: 15px; }
.feedback .fb-note { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 15px; color: var(--brand-ink); font-weight: 600; }
.feedback .fb-note .i { width: 20px; height: 20px; }
.feedback .btn { margin-top: 14px; }

.float-gain { position: absolute; right: 16px; top: 40px; color: var(--brand-ink); font-weight: 700; pointer-events: none; animation: float-up 700ms var(--ease) forwards; }
@keyframes float-up { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-18px); } }

.finale { text-align: center; }
.finale .art { width: 88px; height: 88px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.finale .art .i { width: 44px; height: 44px; stroke-width: 2; }
.finale .art.ok { background: var(--ok-soft); color: var(--ok-ink); }
.finale h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; text-wrap: balance; }
.finale p { color: var(--hint); font-size: 16px; line-height: 1.45; text-wrap: balance; }
.finale .facts { display: flex; justify-content: center; gap: 22px; margin: 20px 0 4px; }
.finale .facts b { display: block; font-size: 26px; font-weight: 700; color: var(--text); }
.finale .facts span { font-size: 13px; color: var(--hint); }
.seal {
  width: 132px; height: 132px; margin: 0 auto 18px; border-radius: 50%;
  border: 3px solid var(--brand-ink); color: var(--brand-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transform: rotate(-8deg);
}
.seal .han { font-size: 30px; font-weight: 700; line-height: 1; }
.seal span { font: 700 12px/1.2 var(--font); letter-spacing: 0.08em; text-transform: uppercase; }
.seal.pressed { animation: seal-in 360ms var(--ease) both; }
@keyframes seal-in { from { opacity: 0; transform: rotate(-20deg) scale(1.8); } to { opacity: 1; transform: rotate(-8deg) scale(1); } }

/* handwriting */
.write-body { align-items: center; }
.write-body .hero-py { margin-top: 0; font-size: 28px; }
.write-body .hero-ru { margin-top: 2px; font-size: 17px; color: var(--hint); }
.pad {
  width: min(340px, 84vw, 48vh); height: min(340px, 84vw, 48vh); margin: 14px auto 0;
  background: var(--card); border-radius: 18px; overflow: hidden; position: relative;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pad svg { display: block; width: 100%; height: 100%; }
.pad .grid line { stroke: var(--sep); stroke-width: 1.5; stroke-dasharray: 5 5; }
.pad .frame { fill: none; stroke: var(--brand); stroke-width: 3; opacity: 0.55; }
.msg { min-height: 44px; margin-top: 12px; padding: 10px 14px; border-radius: 12px; text-align: center; font-size: 15px; width: 100%; max-width: 360px; }
.msg.ok { background: var(--ok-soft); color: var(--ok-ink); font-weight: 600; }
.msg.warn { background: var(--brand-soft); color: var(--brand-ink); }
.msg.err { background: var(--bad-soft); color: var(--bad-ink); }

/* ---- exams ----------------------------------------------------------------------------------------------------- */

.exam-card { margin: 0 16px; padding: 16px; background: var(--card); border-radius: var(--r-lg); }
.exam-card + .exam-card { margin-top: 12px; }
.exam-card .top { display: flex; align-items: center; gap: 10px; }
.exam-card h2 { font-size: 20px; font-weight: 700; }
.exam-card .city { color: var(--hint); font-size: 15px; }
.exam-card .top .tag { margin-left: auto; }
.exam-card .parts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; color: var(--hint); font-size: 14px; }
.exam-card .parts span { display: inline-flex; align-items: center; gap: 5px; }
.exam-card .parts .i { width: 16px; height: 16px; }
.exam-card .best { margin-top: 10px; font-size: 15px; }
.exam-card .actions { display: grid; gap: 8px; margin-top: 14px; }
.exam-card .sections { display: flex; gap: 8px; }
.exam-card .sections .btn { min-height: 44px; font-size: 14px; padding: 6px 8px; }

.exam-body .prompt-text { font-family: var(--han); font-size: 26px; line-height: 1.5; text-align: center; margin: 4px 0 6px; overflow-wrap: anywhere; }
.exam-body .prompt-text.long { font-size: 21px; }
.exam-body .prompt-plain { font-size: 20px; text-align: center; margin: 4px 0 6px; }
.sec-dots { display: flex; gap: 4px; flex: 1; }
.sec-dots .bar { flex: var(--n) 1 0; }

.score { position: relative; width: 168px; height: 168px; margin: 0 auto 14px; }
.score .ring { width: 168px; height: 168px; }
.score .val { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score .val b { font-size: 40px; font-weight: 700; line-height: 1; }
.score .val span { font-size: 13px; color: var(--hint); margin-top: 4px; }
.score .tick { stroke: var(--hint); stroke-width: 2; stroke-linecap: round; }
.parts-list { margin-top: 18px; text-align: left; }
.parts-list li { padding: 8px 0; }
.parts-list .lbl { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 6px; }
.mistakes li { padding: 12px 16px; }
.mistakes li + li { border-top: 0.5px solid var(--sep); }
.mistakes .q { color: var(--hint); font-size: 13px; }
.mistakes .p { font-family: var(--han); font-size: 18px; margin-top: 2px; }
.mistakes .a { margin-top: 6px; font-size: 15px; display: grid; gap: 2px; }
.mistakes .a .no { color: var(--bad-ink); }
.mistakes .a .yes { color: var(--ok-ink); }
.mistakes .w { margin-top: 6px; font-size: 14px; color: var(--hint); }
.mistakes .w .han { color: var(--text); font-size: 16px; }

.history li .t .tag { margin-left: 6px; vertical-align: 1px; }

/* ---- exam simulation ------------------------------------------------------------------------------------------- */

.head-title { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-head .exam-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.exam-head .exam-title b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-head .exam-title span { font-size: 13px; color: var(--hint); }
.exam .sec-dots { flex: none; display: flex; gap: 4px; padding: 0 16px 6px; }
.sec-dots .bar.done > i { background: var(--ok); }
.exam-card .parts span.off { text-decoration: line-through; }
.exam-card .parts .han { font-size: 13px; }

.listen .qnum { text-align: center; font-size: 34px; font-weight: 600; margin: 2px 0 12px; }
.listen-status { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 26px; color: var(--brand-ink); font-size: 16px; font-weight: 600; }
.listen-status .i { width: 22px; height: 22px; }
.bar.slot { max-width: 240px; height: 4px; margin: 10px auto 0; }

.options.lettered .opt { gap: 12px; justify-content: flex-start; text-align: left; }
.options.lettered .otext { flex: 1; min-width: 0; }
.letter {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--track); color: var(--text); font: 600 14px/1 var(--font);
}
.opt.chosen .letter { background: var(--brand); color: var(--on-brand); }
.opt.ok .letter { background: var(--ok-ink); color: var(--card); }
.opt.bad .letter { background: var(--bad-ink); color: var(--card); }
.options.han.lettered .opt { font-size: 24px; }
.options.locked .opt { cursor: default; }

.q-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.q-head .kicker { margin: 0; text-align: left; }
.flag {
  appearance: none; flex: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px 0 9px; border-radius: 18px; border: 1.5px solid var(--sep);
  background: var(--card); color: var(--hint); font: 500 14px/1 var(--font);
}
.flag .i { width: 18px; height: 18px; }
.flag.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }

.nav-row { display: flex; align-items: center; gap: 10px; }
.nav-row > .btn { width: auto; flex: 1; min-height: 50px; }
.nav-row > .btn:first-child { flex: 0 0 60px; }
.nav-row > .btn:last-child { flex: 0 0 auto; min-width: 60px; padding: 0 20px; }
.nav-row > span { flex: 1; }
.report-foot .btn-quiet { flex: 0 0 auto; width: auto; padding: 0 22px; } /* .btn is width:100% */
.grid-btn { flex-direction: row; gap: 8px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:active { transform: none; }

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; margin: 14px 0 4px; }
.palette.big { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
.palette.small { display: flex; gap: 6px; margin: 10px -16px 14px; padding: 4px 16px 6px; overflow-x: auto; scrollbar-width: none; }
.palette.small::-webkit-scrollbar { display: none; }
.palette.small .cell { flex: 0 0 42px; }
.cell {
  appearance: none; position: relative; cursor: pointer; min-height: 48px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px solid var(--sep); background: var(--card); color: var(--text); font: 600 15px/1 var(--font);
}
.palette.small .cell { min-height: 40px; }
.cell .n { font-size: 13px; font-weight: 500; color: var(--hint); }
.cell b { font-size: 17px; }
.cell.on { border-color: var(--brand); background: var(--brand-soft); }
.cell.on .n { color: var(--brand-ink); }
.cell.empty { border-style: dashed; }
.cell.flagged .i { position: absolute; top: 3px; right: 3px; width: 12px; height: 12px; color: var(--brand-ink); }
.cell.current { outline: 2px solid var(--text); outline-offset: 1px; }
.cell.good { border-color: var(--ok); background: var(--ok-soft); }
.cell.good .n { color: var(--ok-ink); }
.cell.bad { border-color: var(--bad); background: var(--bad-soft); }
.cell.bad .n { color: var(--bad-ink); }

.typed-sentence { font-family: var(--han); font-size: 24px; line-height: 2.3; text-align: center; overflow-wrap: anywhere; }
.blank { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 4px; line-height: 1.2; }
.blank .py { font-family: var(--font); font-size: 15px; color: var(--brand-ink); }
.hanzi-input {
  width: 72px; height: 50px; border: 0; border-bottom: 2.5px solid var(--brand); border-radius: 8px 8px 0 0;
  background: var(--card); color: var(--text); text-align: center; font: 400 28px/1 var(--han);
}
.hanzi-input:focus { outline: none; background: var(--brand-soft); }
.typed-hint { margin-top: 8px; font-size: 13px; text-align: center; }

.order .built {
  min-height: 66px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border-radius: var(--r); border: 1.5px dashed var(--sep); background: var(--card); font-size: 15px;
}
.order .pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.chip-word {
  appearance: none; cursor: pointer; min-width: 48px; min-height: 48px; padding: 6px 14px; border-radius: 12px;
  border: 1.5px solid var(--sep); background: var(--card); color: var(--text); font: 400 22px/1.2 var(--han);
}
.chip-word.on { border-color: var(--brand); background: var(--brand-soft); }
.order .end { font: 400 22px var(--han); }
.btn-link.inline { display: inline; width: auto; min-height: 0; padding: 0; border: 0; background: none; font: inherit; font-weight: 500; color: var(--link-ink); cursor: pointer; }
.order .btn-link.inline { display: block; margin: 14px auto 0; }
.lead-sm { color: var(--hint); font-size: 15px; line-height: 1.45; }

.brief-body { padding: 4px 16px 24px; }
.brief-body .lead { margin: 4px 0 16px; color: var(--hint); font-size: 16px; line-height: 1.45; }
.brief-body .section { margin: 0; }
.rules { display: grid; gap: 10px; margin: 0 0 18px; }
.rules li { display: flex; gap: 10px; font-size: 15px; line-height: 1.4; }
.rules .i { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--ok-ink); stroke-width: 2.4; }
.sound-check { padding: 14px 16px; border-radius: var(--r); background: var(--card); }
.sound-check .btn { flex-direction: row; gap: 8px; }
.sound-check .hint { margin-top: 8px; font-size: 14px; }

.report { padding: 8px 16px 24px; }
.report .group-title.flush { margin: 22px 16px 7px; }
.report .section { margin: 0; }
.note.flush { margin: 12px 4px 0; }
.hint.small { margin-top: 6px; font-size: 13px; }
.row .v.good { color: var(--ok-ink); font-weight: 600; }
.score-card { padding: 18px 16px; border-radius: var(--r-lg); background: var(--card); text-align: center; }
.score-card .big { margin: 4px 0 6px; }
.score-card .big b { font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.score-card .big span { margin-left: 6px; font-size: 17px; color: var(--hint); }
.verdict { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 600; color: var(--bad-ink); }
.score-card.ok .verdict { color: var(--ok-ink); }
.verdict .i { width: 20px; height: 20px; stroke-width: 2.4; }
.delta { margin-top: 6px; font-size: 14px; color: var(--hint); }
.delta.up { color: var(--ok-ink); }
.delta.down { color: var(--bad-ink); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  appearance: none; cursor: pointer; flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 18px;
  background: var(--card); color: var(--text); font: 500 14px/1 var(--font); white-space: nowrap;
}
.filter .num { margin-left: 2px; color: var(--hint); }
.filter.on { background: var(--text); color: var(--card); }
.filter.on .num { color: inherit; }
.q-review { padding: 16px; border-radius: var(--r-lg); background: var(--card); }
.q-review .kicker { text-align: left; }
.q-review .options .opt { background: var(--bg); }
.q-review .sound-btn { margin: 0 0 10px; }
.verdict-line { display: flex; align-items: center; gap: 6px; margin: 2px 0 10px; font-size: 18px; font-weight: 700; }
.q-review.ok .verdict-line { color: var(--ok-ink); }
.q-review.bad .verdict-line { color: var(--bad-ink); }
.verdict-line .i { width: 22px; height: 22px; stroke-width: 2.4; }
.answers { display: grid; gap: 6px; margin: 4px 0 8px; font-size: 16px; }
.answers .no { color: var(--bad-ink); }
.answers .yes { color: var(--ok-ink); }
.answers b { font-family: var(--han); font-weight: 500; }
.explain { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--sep); font-size: 15px; line-height: 1.45; }
.explain .w .han { font-size: 20px; }
.explain .zh { margin-top: 8px; font-family: var(--han); font-size: 18px; }
.explain .py { color: var(--hint); font-size: 14px; }

/* ---- progress ---------------------------------------------------------------------------------------------------- */

.ready-card { margin: 0 16px; padding: 18px 16px; background: var(--card); border-radius: var(--r-lg); display: flex; gap: 16px; align-items: center; }
.ready-card .gauge { position: relative; width: 112px; height: 112px; flex: none; }
.ready-card .gauge .val { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ready-card .gauge b { font-size: 30px; font-weight: 700; line-height: 1; }
.ready-card .gauge span { font-size: 12px; color: var(--hint); margin-top: 3px; }
.ready-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.ready-card p { font-size: 14px; color: var(--hint); line-height: 1.4; }
.ready-card p + p { margin-top: 4px; }
.forecast { margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--r); background: var(--card); display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.4; }
.forecast .i { color: var(--brand-ink); flex: none; }
.forecast.late .i { color: var(--bad-ink); }
.forecast.ok .i { color: var(--ok-ink); }

.heat { padding: 14px 16px 12px; }
.heat-grid { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat-grid i { display: block; height: 15px; border-radius: 3px; background: var(--track); }
.heat-grid i.l1 { background: rgba(255, 138, 0, 0.3); }
.heat-grid i.l2 { background: rgba(255, 138, 0, 0.52); }
.heat-grid i.l3 { background: rgba(255, 138, 0, 0.76); }
.heat-grid i.l4 { background: var(--brand); }
.heat-grid i.today { outline: 2px solid var(--text); outline-offset: -1px; }
.heat-grid i.future { background: none; }
.heat-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; margin-top: 10px; color: var(--hint); font-size: 13px; }
.heat-scale { display: inline-flex; align-items: center; gap: 3px; }
.heat-scale i { width: 10px; height: 10px; border-radius: 2px; background: var(--track); }

.skill .lbl { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 6px; }
.skill .lbl span:last-child { color: var(--hint); }
.skill + .skill { margin-top: 14px; }

.leeches { display: flex; flex-wrap: wrap; gap: 8px; }
.leech { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px; border-radius: 10px; background: var(--bad-soft); }
.leech .han { font-size: 18px; color: var(--text); }
.leech span:last-child { color: var(--bad-ink); font-size: 13px; }

.chart .plot { position: relative; height: 110px; margin-top: 18px; }
.chart .bars, .chart .labels { display: flex; gap: 6px; }
.chart .bars { position: absolute; top: 0; right: 0; bottom: 0; left: 0; align-items: flex-end; }
.chart .bars i, .chart .labels span { flex: 1; max-width: 30px; }
.chart .bars i { display: block; border-radius: 6px 6px 3px 3px; background: var(--brand); }
.chart .bars i.pass { background: var(--ok); }
.chart .labels { margin-top: 6px; }
.chart .labels span { text-align: center; font-size: 12px; color: var(--hint); }
.chart .line { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--hint); z-index: 1; }
.chart .line span { position: absolute; right: 0; top: -19px; font-size: 12px; color: var(--hint); }

.board li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.board li + li { border-top: 0.5px solid var(--sep); }
.board .pos { width: 22px; text-align: right; color: var(--hint); font-weight: 600; }
.board .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li.me { background: var(--brand-soft); }
.board li.me .name { font-weight: 600; }

/* ---- profile ------------------------------------------------------------------------------------------------------ */

.profile-head { display: flex; align-items: center; gap: 14px; padding: 8px 16px 16px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); font-size: 24px; font-weight: 700; flex: none; }
.profile-head h2 { font-size: 22px; font-weight: 700; }
.profile-head p { color: var(--hint); font-size: 15px; }
.perks li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 15px; }
.perks .i { width: 20px; height: 20px; color: var(--ok-ink); stroke-width: 2.4; margin-top: 1px; }
.plans { display: grid; gap: 10px; margin-top: 14px; }
.plan { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border-radius: var(--r); border: 1.5px solid var(--sep); background: var(--card); cursor: pointer; text-align: left; }
.plan:active { transform: scale(0.99); }
.plan.best { border-color: var(--brand); }
.plan .grow { flex: 1; }
.plan b { font-size: 17px; }
.plan .s { color: var(--hint); font-size: 14px; margin-top: 2px; }
.plan .price { font-size: 17px; font-weight: 700; white-space: nowrap; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 15px; cursor: pointer; }
.check-row input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--brand); }
.plan .price s { color: var(--hint); font-size: 15px; font-weight: 500; margin-right: 5px; }

/* ---- promo codes ------------------------------------------------------------------------------------------------- */
.field {
  appearance: none; -webkit-appearance: none; border: 0; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 10px;
  background: var(--track); color: var(--text); font: 500 16px/1.2 var(--font); /* 16px: iOS doesn't zoom into it */
}
.field::placeholder { color: var(--hint); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 600; letter-spacing: 0.03em; }
.promo-form { display: flex; gap: 8px; margin-top: 12px; }
.promo-form .field { flex: 1; text-transform: uppercase; letter-spacing: 0.04em; }
.promo-form .field::placeholder { text-transform: none; letter-spacing: 0; }
.promo-form .btn { width: auto; flex: none; min-height: 44px; padding: 0 16px; font-size: 15px; }
.promo-on { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--brand-soft); color: var(--brand-ink); font-size: 15px; line-height: 1.35; }
.promo-on .grow { flex: 1; min-width: 0; }
.promo-on .btn-link.inline { color: var(--brand-ink); min-height: 44px; }
.pad-block > .promo-form:first-child, .pad-block > .promo-on:first-child { margin-top: 0; }
.promo-admin .row .field { width: 132px; text-align: right; }
.promo-admin .row .field[type="date"] { width: auto; }
.promo-admin .row .field.wide { width: 60%; text-align: left; }
.promo-item { align-items: flex-start; }
.promo-item .s { overflow-wrap: anywhere; }
.promo-made { display: grid; gap: 6px; margin: 4px 0 16px; }
.promo-made .code { font-size: 22px; }
.promo-made .link { color: var(--hint); font-size: 14px; overflow-wrap: anywhere; }
.promo-made ul { display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; font-size: 15px; }
.btn.inline-icon { flex-direction: row; gap: 8px; }

/* ---- onboarding ----------------------------------------------------------------------------------------------------- */

.welcome-art { width: 100%; max-width: 420px; margin: 0 auto 8px; display: block; }
.welcome-art .trk { fill: none; stroke: var(--track); stroke-width: 6; stroke-linecap: round; }
.welcome-art .trk-done { fill: none; stroke: var(--brand); stroke-width: 6; stroke-linecap: round; }
.welcome-art .stop { fill: var(--card); stroke: var(--hint); stroke-width: 2.5; }
.welcome-art .stop.on { fill: var(--brand); stroke: var(--brand); }
.welcome-art text { fill: var(--hint); font: 500 11px var(--han); }
.welcome-art text.on { fill: var(--text); font-weight: 600; }
.welcome-art .engine { color: var(--brand-ink); }
.onb h1 { font-size: 28px; font-weight: 700; line-height: 1.15; margin-bottom: 10px; text-wrap: balance; }
.onb .lead { font-size: 17px; line-height: 1.45; color: var(--hint); }
.onb .lead + .lead { margin-top: 10px; }
.onb .steps { display: flex; gap: 5px; flex: 1; }
.onb .steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--track); }
.onb .steps i.on { background: var(--brand); }
.choices { display: grid; gap: 10px; margin-top: 18px; }
.choice {
  appearance: none; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 16px; border-radius: var(--r); border: 1.5px solid transparent;
  background: var(--card); font: 500 17px/1.3 var(--font); text-align: left; color: var(--text);
  transition: border-color var(--fast), background-color var(--fast), transform var(--fast) var(--ease);
}
.choice:active { transform: scale(0.985); }
.choice .grow { flex: 1; }
.choice .chev { width: 18px; height: 18px; color: var(--hint); }
.choice .s { display: block; color: var(--hint); font-size: 14px; font-weight: 400; margin-top: 2px; }
.choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.choices.grid { grid-template-columns: repeat(3, 1fr); }
.choices.grid .choice { justify-content: center; text-align: center; flex-direction: column; gap: 0; min-height: 64px; }
.choices.grid .choice b { font-size: 22px; }
.choices.grid .choice span { font-size: 13px; color: var(--hint); font-weight: 400; }
.hint-box { margin-top: 14px; padding: 12px 14px; border-radius: var(--r); background: var(--card); font-size: 15px; line-height: 1.45; color: var(--hint); }

/* ---- reduced motion -------------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .layer, .sheet, .sheet-wrap, #toast, .bar > i, .ring-fill, .switch::after { transition-duration: 1ms !important; }
  .layer { transform: none !important; }
}
