/* =====================================================================
   PharmEase – styles
   Brand: a calm, professional pharmacy. Pharmacy green and clinical
   blue on a clean off-white, with a friendly mentor (Ellis).
   Type: Source Serif 4 for headings, Source Sans 3 for reading.
   Layout: sidebar · route · progress rail; Ellis lives bottom-right.
   ===================================================================== */

:root {
  /* surfaces & text */
  --bg: #f3f7f5;
  --surface: #ffffff;
  --surface-2: #ecf2ef;
  --line: #d9e4df;
  --line-strong: #bfcfc8;
  --ink: #13283a;
  --muted: #5a6c78;

  /* pharmacy palette */
  --brand: #0a7a4c;       /* pharmacy green */
  --brand-deep: #075a38;
  --brand-soft: #e0f1e8;
  --on-brand: #ffffff;
  --blue: #1d5fa8;        /* clinical blue */
  --blue-soft: #e4eef9;

  /* weighting */
  --high: #b3261e;   --high-deep: #8c1c16;   --high-soft: #fbe9e7;
  --medium: #b86200; --medium-deep: #8a4900; --medium-soft: #fdf0e0;
  --low: #1d6fb0;    --low-deep: #155489;    --low-soft: #e4effa;
  --core: #4f4a9c;   --core-deep: #3b3779;   --core-soft: #ecebf8;

  --ok: #0a7a4c; --ok-deep: #075a38; --ok-soft: #e0f1e8;
  --bad: #b3261e; --bad-deep: #8c1c16; --bad-soft: #fbe9e7;
  --locked: #e6ece9; --locked-ink: #95a5ad;
  --scrim: rgba(19, 40, 58, .45);
  --shadow: 0 1px 2px rgba(19, 40, 58, .05), 0 8px 22px -16px rgba(19, 40, 58, .3);
  --mascot-bg: #d6ece1;

  --r: 12px;
  --r-sm: 8px;
  --font-head: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1a1c; --surface: #132427; --surface-2: #192e31; --line: #23393c; --line-strong: #31494d;
    --ink: #e7f0ee; --muted: #9db1b4;
    --brand: #3ec88a; --brand-deep: #6fdba8; --brand-soft: #123a2c; --on-brand: #04241a;
    --blue: #7fb3ec; --blue-soft: #172a40;
    --high: #f07f74; --high-deep: #f6a39b; --high-soft: #3b1c1a;
    --medium: #f0a64e; --medium-deep: #f6c07f; --medium-soft: #3a2a14;
    --low: #6fb2ec; --low-deep: #9dccf3; --low-soft: #15293c;
    --core: #a9a4ec; --core-deep: #c7c3f4; --core-soft: #24233f;
    --ok: #3ec88a; --ok-deep: #6fdba8; --ok-soft: #123a2c;
    --bad: #f07f74; --bad-deep: #f6a39b; --bad-soft: #3b1c1a;
    --locked: #1d2f32; --locked-ink: #6c8285;
    --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --mascot-bg: #1f4537;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1a1c; --surface: #132427; --surface-2: #192e31; --line: #23393c; --line-strong: #31494d;
  --ink: #e7f0ee; --muted: #9db1b4;
  --brand: #3ec88a; --brand-deep: #6fdba8; --brand-soft: #123a2c; --on-brand: #04241a;
  --blue: #7fb3ec; --blue-soft: #172a40;
  --high: #f07f74; --high-deep: #f6a39b; --high-soft: #3b1c1a;
  --medium: #f0a64e; --medium-deep: #f6c07f; --medium-soft: #3a2a14;
  --low: #6fb2ec; --low-deep: #9dccf3; --low-soft: #15293c;
  --core: #a9a4ec; --core-deep: #c7c3f4; --core-soft: #24233f;
  --ok: #3ec88a; --ok-deep: #6fdba8; --ok-soft: #123a2c;
  --bad: #f07f74; --bad-deep: #f6a39b; --bad-soft: #3b1c1a;
  --locked: #1d2f32; --locked-ink: #6c8285;
  --scrim: rgba(0, 0, 0, .6);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --mascot-bg: #1f4537;
  color-scheme: dark;
}

.w-high   { --w: var(--high);   --w-deep: var(--high-deep);   --w-soft: var(--high-soft); }
.w-medium { --w: var(--medium); --w-deep: var(--medium-deep); --w-soft: var(--medium-soft); }
.w-low    { --w: var(--low);    --w-deep: var(--low-deep);    --w-soft: var(--low-soft); }
.w-core   { --w: var(--core);   --w-deep: var(--core-deep);   --w-soft: var(--core-soft); }

/* ---------------- base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 600; }
p, dl, dd { margin: 0; }
a { color: var(--blue); }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
svg { flex: none; }
.scribble { font-style: italic; color: var(--brand-deep); font-weight: 500; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- layout ---------------- */
.app {
  display: grid; grid-template-columns: 230px minmax(0, 1fr) 300px; gap: 40px;
  max-width: 1320px; margin: 0 auto; min-height: 100vh;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.main { padding-block: 40px 140px; min-width: 0; width: 100%; max-width: 680px; }
.rail { padding-block: 92px 140px; display: flex; flex-direction: column; gap: 18px; align-self: start; }

/* ---------------- sidebar ---------------- */
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding-block: 32px 22px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-left: 6px; }
.logo-mark { width: 36px; height: 36px; }
.logo-word { font-family: var(--font-head); font-weight: 700; font-size: 1.45rem; letter-spacing: -.01em; }
.logo-word span { color: var(--brand); }
.logo-tag { font-size: .8rem; color: var(--muted); margin: 2px 0 28px 52px; letter-spacing: .02em; }
.topnav { display: grid; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 1rem;
  border-left: 3px solid transparent; transition: background .15s, color .15s;
}
.nav-link svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-deep); border-left-color: var(--brand); }
.top-stats { margin-top: auto; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 14px; padding: 14px 12px; border-top: 1px solid var(--line); }
.ts { display: inline-flex; align-items: center; gap: 5px; }
.ts svg { width: 17px; height: 17px; }
.ts-streak svg { fill: var(--medium); }
.ts-xp svg { fill: var(--brand); }
.ts b { font-size: 1.02rem; }
.ts-k { display: none; }
.ts-avatar { justify-self: end; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; color: #fff; font-weight: 700; font-size: .78rem; background: hsl(var(--h, 160) 40% 38%); }

/* ---------------- greeting ---------------- */
.hello { position: relative; padding: 10px 0 0; margin-bottom: 34px; max-width: 580px; }
.blob { display: none; }
.hello h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(2rem, 4.4vw, 2.7rem); line-height: 1.08; letter-spacing: -.015em; }
.hello-name { color: var(--brand); }
.hello-story { margin-top: 14px; max-width: 52ch; font-size: 1.06rem; }
.hello-note { margin-top: 10px; font-size: .95rem; }
.eyebrow { font-size: .76rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.page-head { margin-bottom: 28px; display: grid; gap: 6px; max-width: 620px; }
.page-head h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.1; }
.page-head-offset { margin-left: 0; }
.lede { color: var(--muted); max-width: 62ch; }
.exam b { color: var(--brand-deep); }
.exam-link { font-weight: 600; }

/* ---------------- cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.card h3 { font-size: 1rem; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-head a { font-size: .88rem; font-weight: 600; text-decoration: none; }
.stack { display: grid; gap: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.stat-ico { grid-row: span 2; }
.stat-ico svg { width: 20px; height: 20px; }
.stat-streak .stat-ico svg { fill: var(--medium); }
.stat-xp .stat-ico svg { fill: var(--brand); }
.stat b { font-size: 1.3rem; }
.stat .k { font-size: .78rem; color: var(--muted); }
.goal { display: grid; gap: 8px; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: .92rem; }
.goal-head .num { color: var(--brand-deep); font-weight: 700; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transform-origin: left; animation: grow .8s cubic-bezier(.2, .8, .2, 1) both; }
.meter.done i { background: var(--brand); }
@keyframes grow { from { transform: scaleX(0); } }
.narrow-only { display: none; margin-bottom: 28px; }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; font-size: .94rem; }
.legend b { color: var(--w-deep); }
.legend p { color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--w); display: inline-block; }

/* ---------------- buttons, inputs, chips, tags ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--r-sm); padding: 10px 20px;
  font-weight: 600; font-size: 1rem; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { background: var(--locked); color: var(--locked-ink); cursor: default; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-deep); }
.btn-secondary { background: var(--surface); color: var(--brand-deep); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--brand); background: var(--brand-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad-deep); border-color: var(--bad); justify-self: start; }
.btn-danger[data-armed] { background: var(--bad); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: .92rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px; font-size: .9rem; }
.link-btn:hover { color: var(--bad-deep); }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; padding: 6px; border-radius: var(--r-sm); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.input { width: 100%; min-width: 0; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 400 1rem var(--font); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.code-input { font-size: .82rem; }
.chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--w-soft, var(--surface-2)); color: var(--w-deep, var(--muted)); }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.tag-next { background: var(--brand); color: var(--on-brand); }
.tag-daily { background: var(--blue-soft); color: var(--blue); }
.tag-refresh { background: var(--medium-soft); color: var(--medium-deep); }

/* ---------------- today's pick ---------------- */
.daily { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; padding: 18px 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--blue); box-shadow: var(--shadow); }
.daily-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); }
.daily-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.daily-body { display: grid; gap: 2px; }
.daily-k { font-size: .76rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.daily h3 { font-family: var(--font-head); font-size: 1.2rem; line-height: 1.2; }
.daily-body p:last-child { font-size: .9rem; color: var(--muted); }
.daily .btn { grid-column: 2; justify-self: start; margin-top: 8px; padding: 7px 16px; }

/* ---------------- detours ---------------- */
.detours { display: grid; margin: 0 0 48px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.detour { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; text-align: left; background: none; border: 0; cursor: pointer; padding: 14px 18px; color: var(--ink); }
.detour + .detour { border-top: 1px solid var(--line); }
.detour:hover:not(:disabled) { background: var(--surface-2); }
.detour-k { font-weight: 700; color: var(--brand-deep); }
.detour-arrow { color: var(--brand); font-weight: 700; transition: transform .2s; }
.detour:hover:not(:disabled) .detour-arrow { transform: translateX(4px); }
.detour:disabled { cursor: default; color: var(--muted); }
.detour:disabled .detour-k { color: var(--muted); }
.detour:disabled .detour-arrow { visibility: hidden; }

/* ---------------- the route ---------------- */
.route-intro { display: grid; gap: 8px; }
.route-intro h2 { font-family: var(--font-head); font-size: 1.8rem; font-weight: 700; }
.route-intro p { color: var(--muted); max-width: 60ch; }
.route-progress { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-top: 4px; }
.route-progress .num { font-weight: 700; color: var(--brand-deep); }
.stage { margin-top: 40px; }
.stage-2, .stage-3 { margin-left: 0; }
.stage-head { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: baseline; padding: 0 0 14px 58px; }
.stage-k { grid-column: 1 / -1; font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.stage-head h3 { font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; }
.stage-count { font-weight: 600; color: var(--muted); }
.stage-head p { grid-column: 1 / -1; color: var(--muted); font-size: .95rem; }

.stops { list-style: none; margin: 0; padding: 0; }
.stop { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 14px; padding-bottom: 12px; }
.stop-rail { position: relative; }
.stop-rail::before, .stop-rail::after { content: ""; position: absolute; left: 50%; width: 2px; margin-left: -1px; background-image: linear-gradient(var(--line-strong) 50%, transparent 0); background-size: 2px 8px; }
.stop-rail::before { top: -12px; height: 42px; }
.stop-rail::after { top: 30px; bottom: -12px; }
.stop.line-in .stop-rail::before, .stop.line-out .stop-rail::after { background: var(--brand); }
.stops .stop:first-child .stop-rail::before, .stops .stop:last-child .stop-rail::after { display: none; }
.stop-dot { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 1; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 3px solid var(--w); color: var(--w); transition: transform .2s; }
.stop:hover .stop-dot { transform: translateX(-50%) scale(1.1); }
.stop-dot svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.st-locked .stop-dot { background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--locked-ink); }
.st-locked .stop-dot svg { width: 13px; height: 13px; stroke-width: 2; }
.st-complete .stop-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.st-refresh .stop-dot { border-style: dashed; }
.st-current .stop-dot { background: var(--w); color: #fff; box-shadow: 0 0 0 5px var(--w-soft); }

.stop-card { position: relative; width: 100%; text-align: left; cursor: pointer; display: grid; gap: 3px; padding: 15px 48px 15px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.stop-card:hover { border-color: var(--w); transform: translateX(2px); }
.stop-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 2px; }
.stop-num { font-weight: 700; font-size: .85rem; color: var(--muted); }
.stop-name { font-family: var(--font-head); font-weight: 600; font-size: 1.12rem; line-height: 1.3; }
.stop-blurb { font-size: .9rem; color: var(--muted); }
.stop-note { position: absolute; right: 48px; top: 15px; font-size: .82rem; }
.stop-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; font-size: .86rem; color: var(--muted); }
.stop-foot svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.stop-done { color: var(--ok-deep); display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.st-refresh .stop-done { color: var(--medium-deep); }
.stop-lock { display: inline-flex; gap: 6px; align-items: center; }
.mini-meter { width: 120px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.mini-meter i { display: block; height: 100%; background: var(--w); transform-origin: left; animation: grow .8s cubic-bezier(.2, .8, .2, 1) both; }
.stop-go { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--line-strong); transition: color .15s, transform .15s; }
.stop-go svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stop-card:hover .stop-go { color: var(--w); transform: translate(3px, -50%); }
.st-current .stop-card { border-color: var(--w); box-shadow: 0 0 0 3px var(--w-soft), var(--shadow); }
.is-daily .stop-card { border-top: 3px solid var(--blue); }
.st-locked .stop-card { background: var(--surface-2); box-shadow: none; }
.st-locked .stop-name, .st-locked .stop-blurb { color: var(--locked-ink); }
.st-locked .chip { opacity: .7; }
.route-end { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 40px; }
.route-end-art { width: 56px; height: 56px; }
.end-bg { fill: var(--brand); }
.end-cross { fill: #fff; }
.route-end-k { font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.route-end p:last-child { color: var(--muted); }
.route-end b { color: var(--ink); }
.disclaimer { color: var(--muted); font-size: .84rem; max-width: 66ch; margin-top: 48px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------------- revise ---------------- */
body[data-route="revise"] .app { grid-template-columns: 230px minmax(0, 1fr); }
body[data-route="revise"] .rail { display: none; }
body[data-route="revise"] .main { max-width: 1000px; }
body[data-route="revise"] .narrow-only { display: none; }
.revise { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.revise-nav { position: sticky; top: 16px; display: grid; gap: 12px; }
.revise-nav .tabs { margin-bottom: 0; }
.revise-select { display: none; }
.revise-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: calc(100vh - 140px); overflow-y: auto; }
.revise-link { width: 100%; display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: none; text-align: left; cursor: pointer; font-size: .94rem; color: var(--ink); }
.revise-link:hover { background: var(--surface-2); }
.revise-link.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--w), var(--shadow); font-weight: 600; }
.rl-read svg { width: 15px; height: 15px; fill: none; stroke: var(--brand); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.notes { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--w); border-radius: var(--r); padding: 26px 30px; box-shadow: var(--shadow); display: grid; gap: 22px; }
.notes-head { display: grid; gap: 6px; }
.notes-head h2 { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.notes-sec h3 { font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.notes-sec ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.notes-sec li { line-height: 1.55; }
.notes-sec li::marker { color: var(--w); }
.guide-list { list-style: none !important; padding: 0 !important; display: grid; gap: 10px !important; }
.guide-link {
  position: relative; display: grid; gap: 3px; padding: 13px 44px 13px 16px; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--w); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .15s, background .15s, transform .15s;
}
.guide-link:hover { background: var(--surface-2); border-color: var(--w); transform: translateX(2px); }
.guide-src { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-deep); }
.guide-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; line-height: 1.3; color: var(--blue); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--blue) 30%, transparent); text-underline-offset: 3px; }
.guide-what { font-size: .9rem; color: var(--muted); }
.guide-what b { color: var(--ink); font-weight: 600; }
.guide-go { position: absolute; right: 14px; top: 14px; color: var(--muted); }
.guide-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.guide-link:hover .guide-go { color: var(--blue); }
.notes-disclaimer { font-size: .84rem; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm); }
.notes-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- practice index ---------------- */
.filter-tabs { flex-wrap: wrap; }
.idx-group { margin-top: 30px; }
.idx-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-family: var(--font-head); font-size: 1.35rem; font-weight: 700; margin-bottom: 8px; }
.idx-h small { font-family: var(--font); font-size: .88rem; font-weight: 400; color: var(--muted); }
.idx-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--w); align-self: center; }
.idx { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.idx-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; grid-template-areas: "code main btn" "code meta btn"; column-gap: 14px; row-gap: 2px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); }
.idx-row:first-child { border-top: 0; }
.idx-row:hover { background: var(--surface-2); }
.idx-code { grid-area: code; width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; background: var(--w-soft); color: var(--w-deep); font-weight: 700; font-size: .78rem; }
.idx-main { grid-area: main; display: grid; min-width: 0; }
.idx-main b { font-weight: 600; }
.idx-main span { font-size: .88rem; color: var(--muted); }
.idx-meta { grid-area: meta; font-size: .82rem; color: var(--muted); }
.idx-row .btn { grid-area: btn; }
.idx-row.is-locked .idx-code { background: var(--surface-2); color: var(--locked-ink); }

/* ---------------- your pharmacist: avatar & levels ---------------- */
.pav { width: 100%; height: 100%; display: block; }
.ts-me { justify-self: end; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.ts-av { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); transition: transform .2s; }
.ts-me:hover .ts-av { transform: scale(1.08) rotate(-4deg); }
.ts-lvl { font-size: .74rem; font-weight: 700; color: var(--brand-deep); background: var(--brand-soft); padding: 1px 7px; border-radius: 99px; }
.player-card { grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 14px; }
.pc-av { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; display: block; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--brand); transition: transform .25s; }
.pc-av:hover { transform: scale(1.05) rotate(-3deg); }
.pc-body { display: grid; gap: 5px; min-width: 0; }
.pc-name { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.pc-title { font-size: .9rem; font-weight: 600; color: var(--muted); }
.pc-lvl { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--on-brand); background: var(--brand); padding: 1px 8px; border-radius: 99px; margin-right: 4px; }
.profile-av { width: 112px; height: 112px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--brand); flex: none; }
.profile-head > div { display: grid; gap: 6px; justify-items: start; }
.profile-meter { width: min(320px, 100%); }
.wardrobe-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.wardrobe-row li { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 12px 8px; border: 1px solid var(--line); border-radius: var(--r); }
.wardrobe-row b { font-size: .86rem; line-height: 1.2; }
.wardrobe-row small { font-size: .74rem; color: var(--muted); }
.wr-av { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; }
.wardrobe-row .is-locked .wr-av { filter: grayscale(1); opacity: .4; }
.wardrobe-row .is-current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.wardrobe-row .is-current small { color: var(--brand-deep); font-weight: 700; }
.avatar-svg { background: none; overflow: hidden; }

.picker { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 16px; align-items: start; }
.picker-preview { display: grid; gap: 6px; justify-items: center; text-align: center; }
.picker-preview .pav { width: 120px; height: 120px; border-radius: 50%; box-shadow: 0 0 0 3px var(--brand-soft); }
.picker-preview p { font-size: .76rem; }
.picker-opts { display: grid; gap: 6px; min-width: 0; }
.po-k { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.po-row { display: flex; flex-wrap: wrap; gap: 6px; }
.po-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; transition: transform .15s; }
.po-swatch:hover { transform: scale(1.1); }
.po-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--brand); }
.po-chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 5px 12px; font-size: .86rem; font-weight: 600; cursor: pointer; }
.po-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.po-check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; margin-top: 6px; }
.po-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#onboard .modal, #avatarModal .modal { width: min(560px, 100%); }

.level-modal { text-align: center; justify-items: center; }
.lvl-avatar { width: 150px; height: 150px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 5px var(--surface), 0 0 0 8px #c9a227; animation: lvl-pop .7s cubic-bezier(.3, 1.5, .5, 1); }
.lvl-k { font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #8e6f12; }
.level-modal h2 { font-size: 2.4rem; }
.lvl-title { font-family: var(--font-head); font-size: 1.25rem; font-weight: 600; color: var(--brand-deep); }
.lvl-outfit { background: var(--brand-soft); color: var(--brand-deep); padding: 8px 14px; border-radius: var(--r-sm); }
@keyframes lvl-pop { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }

.made-by-banner { display: flex; gap: 12px; align-items: flex-start; margin-top: 44px; padding: 14px 16px; border-radius: var(--r); background: var(--brand-soft); color: var(--ink); font-size: .94rem; }
.made-by-banner b { color: var(--brand-deep); }
.made-by-pill { display: inline-flex; align-items: center; gap: 8px; justify-self: start; padding: 4px 12px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-deep); font-size: .82rem; font-weight: 700; }
.mb-cross { flex: none; width: 18px; height: 18px; background: var(--brand); clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%); margin-top: 2px; }
.made-by-pill .mb-cross { width: 14px; height: 14px; margin: 0; }
.logo-tag { color: var(--brand-deep) !important; font-weight: 700; line-height: 1.3; }
.logo-tag span { display: block; color: var(--muted); font-weight: 500; font-size: .74rem; margin-top: 2px; }

/* lesson rewards */
.combo { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 3px 10px; border-radius: 99px; background: var(--medium-soft); color: var(--medium-deep); font-weight: 700; font-size: .86rem; }
.combo svg { width: 15px; height: 15px; fill: var(--medium); }
.combo.hot { background: var(--high); color: #fff; }
.combo.hot svg { fill: #ffd27a; }
.combo.pop { animation: combo-pop .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes combo-pop { 40% { transform: scale(1.25) rotate(-4deg); } }
.exam-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px; font-size: .72rem; font-weight: 700; color: var(--blue); background: var(--blue-soft); }
.lucky-tag { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; color: #6b5310; background: linear-gradient(90deg, #f7e6ad, #f2d675, #f7e6ad); background-size: 200% 100%; animation: shimmer 2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.r-player { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.r-player-av { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; }
.r-player-body { display: grid; gap: 5px; }
.lvl-new { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; background: #c9a227; color: #fff; font-size: .72rem; font-weight: 700; animation: combo-pop .6s ease 1.1s; }
.r-goal { font-weight: 700; color: var(--brand-deep); background: var(--brand-soft); padding: 10px 14px; border-radius: var(--r-sm); }
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 120; }

/* ---------------- badges & achievements ---------------- */
.medal {
  --m: #b8743f; --m-hi: #e2a877; --m-lo: #8a522a;
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 68px; height: 68px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--m-hi), var(--m) 55%, var(--m-lo));
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35), 0 3px 0 var(--m-lo), 0 8px 18px -10px rgba(19, 40, 58, .5);
}
.medal svg { width: 46%; height: 46%; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .2)); }
.medal svg .fill { fill: #fff; stroke: none; }
.tier-bronze { --m: #b8743f; --m-hi: #e2a877; --m-lo: #7f4a24; }
.tier-silver { --m: #8d99a6; --m-hi: #d4dbe2; --m-lo: #5f6b78; }
.tier-gold   { --m: #c9a227; --m-hi: #f2d675; --m-lo: #8e6f12; }
.tier-plat   { --m: #0a7a4c; --m-hi: #5fd3a0; --m-lo: #055233; }
.medal.locked { filter: grayscale(1); opacity: .38; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35); }
.medal-lock { position: absolute; right: -2px; bottom: -2px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line-strong); }
.medal-lock svg { width: 13px; height: 13px; stroke: var(--muted); filter: none; }
.medal-sm { width: 42px; height: 42px; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .35), 0 2px 0 var(--m-lo); }

.ach-summary { display: grid; gap: 10px; max-width: 520px; margin-bottom: 10px; }
.ach-count { display: flex; align-items: baseline; gap: 10px; }
.ach-count b { font-family: var(--font-head); font-size: 2.4rem; font-weight: 700; color: var(--brand-deep); line-height: 1; }
.ach-count span { color: var(--muted); font-weight: 600; }
.ach-group { margin-top: 30px; }
.ach-h { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; }
.ach-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ach {
  display: grid; justify-items: center; align-content: start; gap: 6px; text-align: center;
  padding: 16px 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  transition: transform .2s, box-shadow .2s;
}
.ach b { font-size: .98rem; line-height: 1.25; margin-top: 4px; }
.ach small { font-size: .82rem; color: var(--muted); line-height: 1.35; }
.ach:not(.is-unlocked) b { color: var(--muted); }
.ach.is-unlocked { box-shadow: var(--shadow); }
.ach.is-unlocked:hover { transform: translateY(-3px); }
.ach.is-unlocked:hover .medal { animation: shine .7s ease; }
.ach-date { font-size: .76rem; font-weight: 600; color: var(--brand-deep); margin-top: 2px; }
.ach-progress { display: grid; justify-items: center; gap: 4px; margin-top: 4px; font-size: .76rem; color: var(--muted); }
.ach-progress .mini-meter { width: 100px; }
.ach-progress .mini-meter i { background: var(--brand); }
@keyframes shine { 40% { transform: rotate(-12deg) scale(1.08); } 70% { transform: rotate(6deg); } }

.rail-badges .rb-row { display: flex; gap: 8px; flex-wrap: wrap; }

.r-badges { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid #c9a227; border-radius: var(--r); padding: 14px 16px; display: grid; gap: 10px; }
.r-badges-k { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8e6f12; }
.r-badges ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.r-badges li { display: flex; align-items: center; gap: 12px; }
.r-badges li span:last-child { display: grid; }
.r-badges small { color: var(--muted); font-size: .84rem; }
.r-badges-link { font-weight: 600; font-size: .9rem; }

.badge-pop {
  position: fixed; z-index: 95; top: max(18px, env(safe-area-inset-top, 0px)); left: 50%;
  display: flex; align-items: center; gap: 14px; width: min(400px, calc(100% - 32px));
  padding: 12px 18px 12px 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 5px solid #c9a227; border-radius: 14px;
  box-shadow: 0 20px 40px -18px rgba(19, 40, 58, .55);
  transform: translate(-50%, -140%); transition: transform .45s cubic-bezier(.3, 1.4, .5, 1);
}
.badge-pop.show { transform: translate(-50%, 0); }
.badge-pop.show .medal { animation: shine .9s ease .2s; }
.bp-text { display: grid; min-width: 0; }
.bp-k { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8e6f12; }
.bp-text b { font-family: var(--font-head); font-size: 1.1rem; }
.bp-text small { color: var(--muted); font-size: .84rem; }

/* ---------------- mascot ---------------- */
.mascot {
  position: fixed; z-index: 45;
  right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px));
  display: flex; align-items: flex-end; gap: 10px; pointer-events: none;
}
.mascot-face {
  pointer-events: auto; width: 86px; height: 86px; padding: 0; border: 3px solid var(--surface); border-radius: 50%;
  background: none; cursor: pointer; box-shadow: 0 10px 24px -10px rgba(19, 40, 58, .5);
  animation: bob 3.2s ease-in-out infinite; transition: transform .2s;
}
.mascot-face:hover { transform: scale(1.06) rotate(-4deg); }
.mascot-face svg, .welcome-mascot svg { width: 100%; height: 100%; display: block; }
.m-bg { fill: var(--mascot-bg); }
.m-shirt { fill: #0a7a4c; }
.m-cross { stroke: #0a7a4c; }
.m-eyes { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.mascot-bubble {
  pointer-events: auto; position: relative; max-width: 290px; margin-bottom: 40px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px;
  padding: 12px 34px 12px 14px; font-size: .94rem; line-height: 1.45; box-shadow: 0 14px 30px -16px rgba(19, 40, 58, .45);
  animation: float 4.2s ease-in-out infinite;
}
.mascot-bubble.show { animation: bubble-in .35s cubic-bezier(.3, 1.4, .5, 1), float 4.2s ease-in-out .35s infinite; }
.mascot-bubble::after { content: ""; position: absolute; right: -7px; bottom: 14px; width: 12px; height: 12px; background: var(--surface); border-right: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); }
.mascot-name { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin-bottom: 2px; }
.mascot-close { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.mascot-close:hover { background: var(--surface-2); color: var(--ink); }
body.in-lesson .mascot { display: none; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-2deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px) scale(.94); } }

/* ---------------- sheet & modals ---------------- */
.sheet-backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--scrim); padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal-backdrop { z-index: 80; }
.sheet, .modal { width: min(480px, 100%); max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: 16px; box-shadow: 0 30px 60px -28px rgba(19, 40, 58, .6); animation: rise .25s ease-out; }
.modal { padding: 28px; display: grid; gap: 14px; }
.modal h2 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; }
.welcome-top { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; align-items: center; }
.welcome-mascot { width: 110px; height: 110px; animation: bob 3.2s ease-in-out infinite; }
.welcome-bubble { position: relative; background: var(--brand-soft); border-radius: 14px; padding: 12px 14px; font-size: .96rem; line-height: 1.45; }
.welcome-bubble::before { content: ""; position: absolute; left: -7px; top: 50%; width: 14px; height: 14px; background: var(--brand-soft); transform: translateY(-50%) rotate(45deg); }
.welcome-bubble p { position: relative; }
.sheet-card { padding: 24px; display: grid; gap: 14px; }
.sheet-top { display: flex; align-items: center; gap: 14px; }
.sheet-top h2 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; line-height: 1.15; }
.sheet-top .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mono { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--w); color: #fff; font-weight: 700; font-size: .8rem; }
.perk { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); font-size: .94rem; }
.perk svg { width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.perk-daily { background: var(--blue-soft); }
.perk-refresh { background: var(--medium-soft); }
.perk-locked { background: var(--surface-2); color: var(--muted); }
.sheet-progress { display: grid; gap: 8px; }
.sheet-progress .meter i { background: var(--w); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.facts div { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.facts dt { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.facts dd { font-weight: 700; font-size: 1.15rem; }
.sheet-actions { display: grid; gap: 6px; margin-top: 4px; }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 90; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: var(--r-sm); font-size: .95rem; max-width: calc(100% - 32px); text-align: center; }

/* ---------------- tabs & leaderboard ---------------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--surface-2); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 6px 13px; border-radius: 7px; font-weight: 600; font-size: .92rem; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--brand-deep); box-shadow: var(--shadow); }
.lb { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lb-row { display: grid; grid-template-columns: 26px 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 8px; border-radius: var(--r-sm); }
.lb-row.you { background: var(--brand-soft); }
.rank { font-weight: 700; color: var(--muted); text-align: center; }
.lb-row.top1 .rank { color: var(--medium); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: hsl(var(--h, 160) 40% 38%); color: #fff; font-weight: 700; font-size: .8rem; }
.avatar-lg { width: 68px; height: 68px; font-size: 1.4rem; }
.lb-name { display: grid; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.lb-name em { font-style: normal; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin-left: 6px; }
.lb-name small { color: var(--muted); font-size: .8rem; font-weight: 400; }
.lb-xp { font-weight: 700; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 8px; }
.friend-tools { gap: 22px; margin-top: 20px; }
.ft-block { display: grid; gap: 8px; }
.code-row { display: flex; gap: 10px; }
.form-msg { font-size: .9rem; min-height: 1.2em; }
.form-msg.error { color: var(--bad-deep); }
.friend-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.friend-list li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; }

/* ---------------- profile ---------------- */
.profile-head { grid-template-columns: auto 1fr; align-items: center; gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; }
.kpis span { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpis b { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; }
main .card + .card { margin-top: 18px; }
.table-wrap { overflow-x: auto; }
.topic-table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.topic-table th { text-align: left; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 2px solid var(--line-strong); }
.topic-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.topic-table td:nth-child(2) { white-space: normal; font-weight: 600; min-width: 160px; }
.topic-table .r { text-align: right; }
.status { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: .78rem; font-weight: 600; }
.status.st-complete { background: var(--ok-soft); color: var(--ok-deep); }
.status.st-refresh { background: var(--medium-soft); color: var(--medium-deep); }
.status.st-current, .status.st-open { background: var(--blue-soft); color: var(--blue); }
.status.st-locked { background: var(--surface-2); color: var(--muted); }
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: grid; gap: 6px; font-size: .94rem; font-weight: 600; }
.field em { font-style: normal; color: var(--muted); font-weight: 400; }
.field.toggle { grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.field.toggle input { width: 18px; height: 18px; accent-color: var(--brand); }
.field-actions { grid-column: 1 / -1; }
.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

/* ---------------- lesson ---------------- */
.lesson { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; }
.lesson-top { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; width: 100%; padding-top: max(14px, env(safe-area-inset-top, 0px)); padding-bottom: 14px; padding-left: max(16px, calc((100% - 920px) / 2)); padding-right: max(16px, calc((100% - 920px) / 2)); }
.close-btn.armed { color: var(--bad-deep); font-weight: 700; font-size: .92rem; }
.bar { flex: 1; min-width: 40px; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width .45s ease; }
.timer { display: inline-flex; align-items: center; gap: 7px; flex: none; justify-content: center; min-width: 72px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-weight: 700; font-size: .95rem; }
.timer::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timer.warn { color: var(--medium-deep); background: var(--medium-soft); }
.timer.warn::before { background: var(--medium); }
.timer.urgent { color: #fff; background: var(--bad); animation: pulse 1s ease-in-out infinite; }
.timer.urgent::before { background: #fff; }
.timer.paused { opacity: .55; }
.timer.paused::before { background: var(--muted); }
@keyframes pulse { 50% { opacity: .7; } }
.lives { display: flex; align-items: center; gap: 2px; }
.heart svg { width: 19px; height: 19px; fill: var(--locked); display: block; }
.heart.on svg { fill: var(--high); }
.mode-tag { font-size: .76rem; font-weight: 700; letter-spacing: .04em; color: var(--brand-deep); background: var(--brand-soft); padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.lesson-body { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding-top: 26px; padding-bottom: 230px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.q-eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .86rem; color: var(--muted); margin-bottom: 14px; }
.q-count { margin-left: auto; font-weight: 700; }
.q-text { font-family: var(--font-head); font-weight: 600; font-size: clamp(1.3rem, 2.6vw, 1.6rem); line-height: 1.35; margin-bottom: 26px; }
.options { display: grid; gap: 10px; }
.option { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 14px; text-align: left; cursor: pointer; padding: 13px 16px; border-radius: var(--r); background: var(--surface); border: 1.5px solid var(--line); font-size: 1.02rem; transition: border-color .12s, background .12s; }
.option:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.option .key { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font-weight: 700; font-size: .85rem; color: var(--muted); }
.option.selected { border-color: var(--blue); background: var(--blue-soft); }
.option.selected .key { background: var(--blue); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .key { background: var(--bad); color: #fff; }
.option:disabled { cursor: default; }
.option:disabled:not(.correct):not(.wrong) { opacity: .55; }
.num-answer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; max-width: 440px; }
.num-label { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.num-field { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--r); padding: 4px 16px 4px 4px; }
.num-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.num-input { flex: 1 1 auto; width: 100%; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 600 1.7rem var(--font); font-variant-numeric: tabular-nums; padding: 8px 12px; }
.num-input:focus { outline: none; }
.num-input:disabled { color: var(--ink); }
.num-unit { font-weight: 700; color: var(--muted); white-space: nowrap; }
.num-field.correct { border-color: var(--ok); background: var(--ok-soft); }
.num-field.wrong { border-color: var(--bad); background: var(--bad-soft); }
.num-hint { font-size: .9rem; color: var(--muted); }
.num-hint.error { color: var(--bad-deep); font-weight: 600; }
.lesson-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--surface); border-top: 1px solid var(--line); padding-top: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.foot-inner { max-width: 920px; margin: 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 24px; }
.foot-inner .btn { min-width: 150px; }
.fb { flex: 1; min-width: 0; max-height: 38vh; overflow-y: auto; display: grid; gap: 4px; }
.fb-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.fb-answer { font-weight: 600; }
.fb-text { font-size: .97rem; line-height: 1.55; max-width: 72ch; }
.fb-source { font-size: .82rem; color: var(--muted); }
.lesson-foot.is-correct { background: var(--ok-soft); border-top: 2px solid var(--ok); }
.lesson-foot.is-correct .fb-title { color: var(--ok-deep); }
.lesson-foot.is-wrong { background: var(--bad-soft); border-top: 2px solid var(--bad); }
.lesson-foot.is-wrong .fb-title, .lesson-foot.is-wrong .fb-answer { color: var(--bad-deep); }
.results { display: grid; gap: 14px; }
.r-title { font-family: var(--font-head); font-weight: 700; font-size: 2.1rem; line-height: 1.1; }
.r-sub { color: var(--muted); max-width: 56ch; }
.r-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.r-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; }
.r-stats span { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.r-stats b { font-family: var(--font-head); font-size: 1.6rem; font-weight: 700; }
.r-stats small { color: var(--muted); font-size: .8rem; }
.r-stats div:nth-child(1) b { color: var(--brand-deep); }
.r-note { font-weight: 600; color: var(--ok-deep); }
.r-level, .r-unlock { font-weight: 600; padding: 12px 14px; border-radius: var(--r-sm); border-left: 4px solid; }
.r-level { background: var(--blue-soft); color: var(--blue); border-color: var(--blue); }
.r-unlock { background: var(--ok-soft); color: var(--ok-deep); border-color: var(--ok); }
.r-unlock.new { background: var(--brand); color: var(--on-brand); border-color: var(--brand-deep); }
.r-h { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; margin-top: 16px; }
.r-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.r-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 6px; }
.r-q { font-weight: 600; }
.r-wrong, .r-right { font-size: .95rem; display: grid; grid-template-columns: 100px 1fr; gap: 8px; }
.r-wrong span, .r-right span { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding-top: 3px; }
.r-wrong { color: var(--bad-deep); }
.r-right { color: var(--ok-deep); }
.r-exp { color: var(--muted); font-size: .94rem; }
.r-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------------- responsive ---------------- */
@media (max-width: 1240px) {
  .app, body[data-route="revise"] .app { grid-template-columns: 210px minmax(0, 1fr); gap: 32px; }
  .rail { display: none; }
  .narrow-only { display: grid; }
}
@media (max-width: 900px) {
  .revise { grid-template-columns: minmax(0, 1fr); }
  .revise-nav { position: static; }
  .revise-list { display: none; }
  .revise-select { display: block; }
}
@media (max-width: 760px) {
  .app, body[data-route="revise"] .app { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .main { padding-block: 24px 190px; }
  .sidebar { position: static; height: auto; padding-block: 16px 0; display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .logo-tag { display: none; }
  .top-stats { margin: 0 0 0 auto; border: 0; padding: 0; gap: 12px; }
  .topnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; display: flex; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--line); padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .66rem; border-left: 0; border-top: 3px solid transparent; border-radius: 0; flex: 1; min-width: 0; text-align: center; }
  .nav-link span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-link.active { border-left: 0; border-top-color: var(--brand); background: none; }
  .mascot { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); right: 12px; }
  .mascot-face { width: 62px; height: 62px; }
  .mascot-bubble { max-width: min(250px, calc(100vw - 100px)); font-size: .88rem; margin-bottom: 26px; }
  .detour { grid-template-columns: minmax(0, 1fr) auto; }
  .detour-k { grid-column: 1 / -1; }
  .stop { grid-template-columns: 36px minmax(0, 1fr); column-gap: 10px; }
  .stop-dot { width: 26px; height: 26px; top: 18px; }
  .stage-head { padding-left: 46px; }
  .stop-card { padding: 14px 40px 14px 14px; }
  .stop-note { position: static; }
  .notes { padding: 20px 18px; }
  .idx-row { grid-template-columns: 50px minmax(0, 1fr); grid-template-areas: "code main" "code meta" ". btn"; }
  .idx-row .btn { justify-self: start; margin-top: 6px; }
  .welcome-top { grid-template-columns: 80px minmax(0, 1fr); }
  .picker { grid-template-columns: minmax(0, 1fr); }
  .picker-preview .pav { width: 96px; height: 96px; }
  .profile-head { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .profile-av { width: 88px; height: 88px; }
  .ts-lvl { display: none; }
  .welcome-mascot { width: 80px; height: 80px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis div:last-child { grid-column: 1 / -1; }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .foot-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .foot-inner .btn { width: 100%; }
  .r-wrong, .r-right { grid-template-columns: 1fr; gap: 0; }
  .lesson-top { gap: 10px; }
  .lives { gap: 0; }
  .heart svg { width: 15px; height: 15px; }
  .timer { min-width: 0; padding: 2px 8px; font-size: .88rem; }
  .sheet-backdrop { align-items: end; }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 600px) { .r-stats { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .code-row { flex-direction: column; } .logo-word { font-size: 1.25rem; } }

/* ---------------- accounts, plans and paywall ---------------- */
.boot { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); color: var(--muted); font-size: .95rem; }
.boot .logo-mark { width: 52px; height: 52px; animation: boot-pulse 1.4s ease-in-out infinite; }
@keyframes boot-pulse { 50% { transform: scale(.92); opacity: .7; } }
.tag-premium { background: var(--core-soft); color: var(--core-deep); }
.tag-save { background: var(--brand-soft); color: var(--brand-deep); margin-left: 6px; }
.perk-premium { background: var(--core-soft); color: var(--core-deep); }
.upsell { background: linear-gradient(var(--core-soft), var(--core-soft)) padding-box; border-color: color-mix(in srgb, var(--core) 35%, var(--line)); }
.upsell h3 { font-family: var(--font-head); font-size: 1.15rem; }
.plan-strip { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.plan-strip h3 { font-family: var(--font-head); font-size: 1.2rem; }
.account-plan h2 { font-family: var(--font-head); font-size: 1.6rem; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.plan { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 8px; align-content: start; background: var(--surface); min-width: 0; }
.plan-best { border: 2px solid var(--brand); }
.plan-k { font-weight: 700; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.plan-price b { font-family: var(--font-head); font-size: 2rem; font-weight: 700; }
.plan-price span { color: var(--muted); margin-left: 2px; }
.plan-perks { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; color: var(--ink); }
.upgrade-sheet { display: grid; gap: 14px; }
.legal-links { margin-top: 18px; font-size: .86rem; color: var(--muted); }
.center { text-align: center; }
@media (max-width: 560px) { .plan-strip { grid-template-columns: 1fr; } }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
