/* RepTracker — iOS-style light theme with a matching dark theme.
 * Theme: follows the system unless Settings › Appearance picks Light or Dark
 * (stored as html[data-theme]). */

:root {
  color-scheme: light;
  --bg: #ffffff;            /* Today / History / Progress screens */
  --grouped: #f5f5f7;       /* Settings screens */
  --fill: #f5f5f7;          /* gray tiles on the page (notice, streaks, calendar, stats) */
  --card: #ffffff;          /* outlined cards and grouped-list rows */
  --card-border: #e8e8ed;
  --control: #f5f5f7;       /* buttons / chips inside cards */
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #aeaeb2;
  --separator: #ececf0;
  --accent: #0066cc;
  --accent-muted: #7db4e7;  /* disabled minus, disabled Add */
  --on-accent: #ffffff;
  --green: #34c759;
  --red: #ff3b30;
  --ice: #0a84c8;
  --ice-bg: rgba(10, 132, 200, .09);
  --ring-track: #e0e0e0;
  --bar-bg: rgba(255, 255, 255, .94);
  --bar-border: #e5e5ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  /* Progress chart, one color per exercise in order. Checked as a set in each theme: lightness,
     chroma, color-blind separation of neighbors, and at least 3:1 against the chart card. */
  --series-1: var(--accent);
  --series-2: #eb6834;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --radius: 18px;
  --gutter: 22px;
  --tabbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --grouped: #000000;
    --fill: #1c1c1e;
    --card: #1c1c1e;
    --card-border: #2c2c2e;
    --control: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #98989d;
    --text-3: #5b5b60;
    --separator: #38383a;
    --accent: #0a84ff;
    --accent-muted: #1d4f80;
    --green: #30d158;
    --red: #ff453a;
    --ice: #64d2ff;
    --ice-bg: rgba(100, 210, 255, .12);
    --ring-track: #3a3a3c;
    --bar-bg: rgba(22, 22, 24, .94);
    --bar-border: #2c2c2e;
    --shadow: none;
    --series-2: #d95926;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --grouped: #000000;
  --fill: #1c1c1e;
  --card: #1c1c1e;
  --card-border: #2c2c2e;
  --control: #2c2c2e;
  --text: #f5f5f7;
  --text-2: #98989d;
  --text-3: #5b5b60;
  --separator: #38383a;
  --accent: #0a84ff;
  --accent-muted: #1d4f80;
  --green: #30d158;
  --red: #ff453a;
  --ice: #64d2ff;
  --ice-bg: rgba(100, 210, 255, .12);
  --ring-track: #3a3a3c;
  --bar-bg: rgba(22, 22, 24, .94);
  --bar-border: #2c2c2e;
  --shadow: none;
  --series-2: #d95926;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body { min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; transition: background-color .2s; }
html.grouped-bg, html.grouped-bg body { background: var(--grouped); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- layout ---------- */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) calc(var(--safe-right) + var(--gutter)) calc(var(--tabbar-h) + var(--safe-bottom) + 28px) calc(var(--safe-left) + var(--gutter));
}
.view { display: none; }
.view.active { display: block; animation: fade .16s ease-out; }
@keyframes fade { from { opacity: .5; } to { opacity: 1; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.eyebrow { font-size: 17px; font-weight: 600; color: var(--text); opacity: .9; margin-bottom: 2px; }
.large-title { margin: 0; font-size: 40px; line-height: 1.08; font-weight: 800; letter-spacing: -0.02em; }
.page-sub { margin: 8px 0 0; font-size: 17px; color: var(--text-2); }
.section-row { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 0 12px; }
.section-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.footnote { margin: 10px 6px 0; font-size: 14px; line-height: 1.4; color: var(--text-2); }
.footnote:empty { display: none; }
.footnote.center { text-align: center; }
.accent { color: var(--accent) !important; }

.text-btn { color: var(--accent); font-size: 17px; font-weight: 600; padding: 4px 0; }
.text-btn.inline { display: inline-block; margin-top: 6px; font-size: 15px; }
.round-btn {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--fill);
}
.round-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }

.btn-primary {
  height: 48px; padding: 0 26px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 17px;
}
.btn-primary:disabled { background: var(--accent-muted); opacity: 1; cursor: default; }
.btn-primary.block { display: block; width: 100%; }
.btn-primary:active:not(:disabled), .step-btn:active:not(:disabled), .chip-add:active, .round-btn:active { transform: scale(.95); }

/* ---------- Today: notice + streaks ---------- */
.notice {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 16px; border-radius: var(--radius); background: var(--fill);
}
.notice-icon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--accent);
}
.notice-icon svg { width: 20px; height: 20px; fill: none; stroke: var(--on-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notice.frozen .notice-icon { background: var(--ice); }
.notice-title { font-weight: 700; font-size: 17px; }
.notice-body { color: var(--text); opacity: .85; font-size: 16px; margin-top: 2px; overflow-wrap: anywhere; }

.streaks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.streak-tile {
  display: flex; align-items: center; gap: 14px; min-width: 0;
  padding: 16px 14px; border-radius: var(--radius); background: var(--fill);
}
.ring { width: 46px; height: 46px; flex-shrink: 0; transform: rotate(-90deg); }
.ring-track, .ring-fill { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--ring-track); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring-icon { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; transform: rotate(90deg); transform-origin: 24px 24px; }
.streak-label { font-size: 14px; color: var(--text); opacity: .85; line-height: 1.3; }
.streak-value { font-size: 20px; font-weight: 800; margin-top: 4px; line-height: 1.2; }

/* ---------- exercise cards (Today) ---------- */
.ex-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.ex-card {
  padding: 16px 16px 16px 18px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--card-border); box-shadow: var(--shadow);
}
.ex-top { display: flex; align-items: center; gap: 10px; }
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ex-meta { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.step-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.step-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.step-btn.minus { background: var(--control); color: var(--accent); }
.step-btn.minus:disabled { color: var(--accent-muted); opacity: .8; }
.step-btn.plus { background: var(--accent); color: var(--on-accent); }
.count {
  width: 60px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent;
  text-align: center; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.count::-webkit-outer-spin-button, .count::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.quick { display: flex; gap: 8px; margin-top: 12px; }
.chip-add {
  min-width: 48px; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--control); color: var(--accent); font-weight: 700; font-size: 16px;
}
.empty-state { padding: 28px 12px; text-align: center; color: var(--text-2); }

/* ---------- History ---------- */
.cal-card { padding: 16px 12px 14px; border-radius: var(--radius); background: var(--fill); }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.cal-title { font-size: 19px; font-weight: 700; }
.cal-nav { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-nav svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cal-nav:disabled svg { stroke: var(--accent-muted); }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekdays { margin: 12px 0 4px; text-align: center; font-size: 13px; font-weight: 600; color: var(--text); opacity: .8; }
.cal-grid { row-gap: 2px; }
.cal-day {
  position: relative; height: 46px; margin: 0 auto; width: min(46px, 100%);
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px; font-size: 18px; font-variant-numeric: tabular-nums;
  padding-bottom: 6px;
}
.cal-day:disabled { color: var(--text-3); cursor: default; }
.cal-day.today { color: var(--accent); font-weight: 700; }
.cal-day.selected { box-shadow: inset 0 0 0 2.5px var(--accent); font-weight: 700; background: var(--card); }
.cal-day .mark { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); }
.cal-day .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cal-day .flake { font-size: 10px; line-height: 1; color: var(--ice); }

.day-card {
  margin-top: 16px; padding: 18px 16px 8px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--card-border); box-shadow: var(--shadow);
}
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-title { min-width: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.015em; }
.day-sub { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 4px 10px; border-radius: 999px; background: var(--control);
  font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.pill.logged::before { background: var(--green); }
.pill.frozen::before { background: var(--ice); }
.day-rows { margin-top: 8px; }
.day-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.day-row + .day-row { border-top: 1px solid var(--separator); }
.day-row .ex-label { flex: 1; min-width: 0; font-size: 18px; overflow-wrap: anywhere; }
.day-row .step-btn { width: 40px; height: 40px; }

.freeze-action {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 6px 0 10px; padding: 12px 14px; border-radius: 14px;
  background: var(--ice-bg); color: var(--ice); font-weight: 600; font-size: 16px; text-align: left;
}
.freeze-note { margin: 6px 0 12px; font-size: 14px; color: var(--text-2); }
.freeze-card { margin: 6px 0 12px; padding: 12px 14px; border-radius: 14px; background: var(--ice-bg); }
.freeze-card-h { font-weight: 700; color: var(--ice); font-size: 15px; }
.freeze-reason { margin: 4px 0 0; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.freeze-meta { margin-top: 6px; font-size: 13px; color: var(--text-2); }

/* ---------- Progress ---------- */
.legend-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.legend-chip {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 18px 0 14px; border-radius: 999px;
  background: var(--fill); border: 2px solid transparent;
  font-size: 17px; font-weight: 700; color: var(--text);
}
.legend-chip.on { background: var(--card); border-color: var(--accent); }
.legend-chip:not(.on) { color: var(--text-2); }
.legend-chip svg { width: 26px; height: 8px; }
.chart-card {
  padding: 18px 16px 12px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--card-border); box-shadow: var(--shadow);
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chart-title { margin: 0; font-size: 19px; font-weight: 700; }
.chart-wrap { position: relative; height: 210px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--text-2); font-size: 15px; padding: 0 20px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--control); }
.segmented button { height: 32px; min-width: 46px; padding: 0 12px; border-radius: 999px; font-size: 15px; font-weight: 700; color: var(--text); }
.segmented button.active { background: var(--accent); color: var(--on-accent); }
.segmented.small button { height: 30px; min-width: 0; padding: 0 11px; font-size: 14px; font-weight: 600; }

#stats-block { margin-top: 26px; }
#stats-block .section-title { margin-bottom: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px 14px 16px; border-radius: var(--radius); background: var(--fill); min-width: 0; }
.stat-label { font-size: 15px; color: var(--text); opacity: .85; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* ---------- Settings (grouped lists) ---------- */
.group-label { margin: 26px 6px 8px; font-size: 16px; font-weight: 700; color: var(--text); opacity: .85; }
.page-head + .group-label { margin-top: 8px; }
.group { border-radius: var(--radius); background: var(--card); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 12px 16px; text-align: left; color: var(--text); text-decoration: none;
  cursor: default;
}
button.row, a.row { cursor: pointer; }
button.row:active, a.row:active { background: var(--control); }
.row + .row, #push-setup > .row { border-top: 1px solid var(--separator); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 18px; overflow-wrap: anywhere; }
.row-sub { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.row-value { font-size: 17px; color: var(--text); opacity: .8; }
.chev { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: var(--text-3); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-row .row-icon {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--control);
}
.row-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-row .row-title { font-size: 19px; }

/* iOS-style switch */
.switch {
  -webkit-appearance: none; appearance: none; flex-shrink: 0; margin: 0;
  width: 56px; height: 34px; border-radius: 999px; background: var(--ring-track);
  position: relative; cursor: pointer; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(22px); }
.switch:disabled { opacity: .5; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.time-pill {
  height: 40px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--control); color: var(--accent); font-weight: 700; font-size: 18px;
  -webkit-appearance: none; appearance: none; text-align: center; min-width: 116px;
}
.time-pill::-webkit-date-and-time-value { text-align: center; }
.time-pill:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Freeze list rows */
.freeze-row { display: block; padding: 12px 16px; }
.freeze-row + .freeze-row { border-top: 1px solid var(--separator); }
.freeze-row .fr-date { font-weight: 600; font-size: 16px; color: var(--ice); }
.freeze-row .fr-reason { display: block; margin-top: 2px; font-size: 16px; overflow-wrap: anywhere; }
.freeze-row.empty { color: var(--text-2); }

/* Sub-screens */
.back-btn {
  display: inline-flex; align-items: center; gap: 2px; margin: 0 0 10px -8px; padding: 6px 8px 6px 0;
  color: var(--accent); font-size: 18px;
}
.back-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ex-edit-row { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 16px; min-height: 58px; }
.ex-edit-row + .ex-edit-row { border-top: 1px solid var(--separator); }
.ex-edit-row input {
  flex: 1; min-width: 0; height: 44px; padding: 0; border: 0; background: transparent; font-size: 18px;
}
.ex-edit-row input:focus { outline: none; }
.remove-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.remove-btn span { width: 24px; height: 24px; border-radius: 50%; background: var(--red); position: relative; }
.remove-btn span::after { content: ''; position: absolute; left: 6px; right: 6px; top: 11px; height: 2.5px; border-radius: 2px; background: #fff; }
.restore-btn { color: var(--accent); font-weight: 600; font-size: 16px; padding: 8px 4px; }
.ex-edit-row .hidden-name { flex: 1; color: var(--text-2); font-size: 18px; }
.add-row { display: flex; gap: 10px; }
.add-row input {
  flex: 1; min-width: 0; height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1.5px solid var(--card-border); background: var(--card); font-size: 18px;
}
.add-row input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.version { margin-top: 28px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--bar-bg); border-top: 1px solid var(--bar-border);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
}
.tabbar button {
  flex: 1; height: var(--tabbar-h); padding-top: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-2); font-size: 12px; font-weight: 500;
}
.tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar .knob { fill: var(--bar-bg); }
.tabbar button.active { color: var(--accent); font-weight: 700; }
.tabbar button.active svg { stroke-width: 2.2; }

/* ---------- Toast & dialog ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 30;
  max-width: calc(100% - 32px); padding: 11px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast button { margin-left: 12px; color: var(--accent); font-weight: 700; }

dialog {
  width: min(88vw, 340px); padding: 22px 18px 16px; border: 0; border-radius: 20px;
  background: var(--card); color: var(--text); text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
dialog h3 { margin: 0 0 8px; font-size: 18px; }
dialog p { margin: 0 0 16px; color: var(--text-2); font-size: 15px; line-height: 1.4; }
dialog textarea {
  width: 100%; margin-bottom: 4px; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--card-border); background: var(--bg); resize: none; text-align: left;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
dialog textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.dialog-count { text-align: right; font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.dialog-actions { display: flex; flex-direction: column; gap: 8px; }
.dialog-actions button {
  height: 46px; border-radius: 999px; font-weight: 700; font-size: 17px;
  background: var(--accent); color: var(--on-accent);
}
.dialog-actions button:disabled { background: var(--accent-muted); }
.dialog-actions button.secondary { background: var(--control); color: var(--accent); }
.dialog-actions button.danger { background: var(--red); color: #fff; }

/* ---------- Learn (lessons) ---------- */
.tabbar button { min-width: 0; }
.lesson-card {
  padding: 20px 18px 12px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--card-border); box-shadow: var(--shadow);
}
.lc-eyebrow { font-size: 14px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.lc-name { font-size: 26px; font-weight: 800; letter-spacing: -0.015em; margin: 4px 0 10px; }
.lc-why { margin: 12px 0 4px; font-size: 16px; color: var(--text); opacity: .9; }
.lc-meta { font-size: 14px; color: var(--text-2); margin-bottom: 16px; }
.lc-skip { display: block; margin: 8px auto 0; font-size: 15px; }
.area-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.area-chip {
  height: 36px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center;
  background: var(--control); color: var(--text-2); font-size: 15px; font-weight: 600; border: 2px solid transparent;
}
.area-chip.on { background: var(--card); color: var(--accent); border-color: var(--accent); }
.area-chips.static .area-chip { height: 30px; padding: 0 12px; font-size: 14px; }
#view-areas .area-chips { margin-top: 16px; }

/* Body map */
.map-card { padding: 18px 12px 10px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.body-map { width: 100%; max-width: 380px; height: auto; margin: 0 auto; }
.body-map .body-base { fill: var(--control); }
.body-map .zone { fill: var(--ring-track); cursor: pointer; transition: fill .15s; }
.body-map .zone:hover { fill: var(--accent-muted); }
.body-map .zone.on { fill: var(--accent); }
.body-map text { fill: var(--text-2); font-size: 12px; font-weight: 600; text-anchor: middle; }

/* Lesson overlay */
html.lesson-open, html.lesson-open body { overflow: hidden; }
.lesson {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg);
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + var(--gutter)) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + var(--gutter));
}
.lesson > * { width: 100%; max-width: 600px; margin-left: auto; margin-right: auto; }
.lesson-top { display: flex; align-items: center; gap: 12px; }
.lesson-close { width: 40px; height: 40px; margin-left: -8px; display: flex; align-items: center; justify-content: center; }
.lesson-close svg { width: 24px; height: 24px; fill: none; stroke: var(--text-2); stroke-width: 2.4; stroke-linecap: round; }
.lesson-progress { flex: 1; height: 14px; border-radius: 999px; background: var(--ring-track); overflow: hidden; }
.lesson-progress div { height: 100%; width: 0; border-radius: 999px; background: var(--green); transition: width .35s ease; }
.lesson-body { flex: 1; overflow-y: auto; padding: 28px 0 16px; }
.ls-eyebrow { font-size: 15px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.ls-title { margin: 6px 0 14px; font-size: 32px; line-height: 1.12; font-weight: 800; letter-spacing: -0.02em; }
.ls-title.small { font-size: 24px; }
.ls-sub { margin: 26px 0 10px; font-size: 19px; }
.ls-text { font-size: 17px; margin: 14px 0 0; }
.ls-text.muted { color: var(--text-2); }
.ls-text.center { text-align: center; }
.ls-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.ls-steps li {
  counter-increment: s; position: relative; padding: 14px 14px 14px 56px; margin-bottom: 10px;
  border-radius: var(--radius); background: var(--fill); font-size: 17px;
}
.ls-steps li::before {
  content: counter(s); position: absolute; left: 14px; top: 12px; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: var(--accent); color: var(--on-accent); font-weight: 800;
}
.ls-tip { margin-top: 14px; padding: 14px; border-radius: var(--radius); background: var(--ice-bg); font-size: 16px; }
.ls-tip strong { color: var(--ice); }
.ls-options { display: grid; gap: 10px; }
.ls-option {
  padding: 16px; border-radius: var(--radius); text-align: left; font-size: 17px; font-weight: 600;
  background: var(--card); border: 2px solid var(--card-border); border-bottom-width: 4px;
}
.ls-option.picked { border-color: var(--accent); color: var(--accent); }
.ls-option.right { border-color: var(--green); color: var(--green); }
.ls-option.wrong { border-color: var(--red); color: var(--red); }
.ls-option:disabled { cursor: default; }
.ls-big { margin: 30px 0 6px; text-align: center; font-size: 72px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.ls-counter { display: flex; align-items: center; justify-content: center; gap: 24px; }
.ls-counter .ls-big { margin: 20px 0; min-width: 110px; }
.ls-counter .step-btn { width: 56px; height: 56px; }
.ls-feel { display: flex; }
.ls-feel button { flex: 1; }
.ls-log { margin-top: 20px; padding: 12px 16px; border-radius: var(--radius); background: var(--fill); cursor: pointer; }
.lesson-foot { padding-top: 12px; }
.lesson-foot .btn-primary { height: 54px; }
.btn-primary.secondary { background: var(--control); color: var(--accent); }
.ls-verdict { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.lesson.is-right .ls-verdict { color: var(--green); }
.lesson.is-wrong .ls-verdict { color: var(--red); }
.lesson.is-right .lesson-foot .btn-primary { background: var(--green); }
.lesson.is-wrong .lesson-foot .btn-primary { background: var(--red); }

/* Form figures, video link, gems */
.ls-figure { margin: 4px 0 12px; padding: 10px 8px 6px; border-radius: var(--radius); background: var(--fill); }
.ls-figure figcaption { text-align: center; font-size: 14px; font-weight: 600; color: var(--text-2); margin-top: 2px; }
.fig { width: 100%; max-width: 320px; height: auto; margin: 0 auto; }
.fig line { stroke-linecap: round; }
.fig-limb { stroke: var(--accent); stroke-width: 8; }
.fig-torso { stroke: var(--accent); stroke-width: 12; }
.fig-head { fill: var(--accent); }
.fig-ground { stroke: var(--card-border); stroke-width: 3; }
.fig-prop { fill: var(--ring-track); }
.fig-bar { stroke: var(--text-3); stroke-width: 5; }
.ls-video { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 14px; color: var(--accent); font-weight: 700; font-size: 16px; text-decoration: none; }
.ls-tip + .ls-video { margin-top: 14px; }
.ls-video svg, .gem-pill svg, .gem-reward svg, .shop-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ls-video svg { width: 24px; height: 24px; }
.gem-pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 36px; padding: 0 14px;
  border-radius: 999px; background: var(--fill); color: var(--gem); font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums;
}
.gem-pill svg { width: 20px; height: 20px; }
.gem-reward {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 18px; padding: 14px;
  border-radius: var(--radius); background: var(--gem-bg); color: var(--gem); font-size: 24px; font-weight: 800;
  animation: gem-pop .7s cubic-bezier(.3, 1.6, .5, 1) both;
}
.gem-reward svg { width: 30px; height: 30px; animation: gem-spin 1.2s ease-out .2s both; }
.boost-tag { padding: 3px 10px; border-radius: 999px; background: var(--gem); color: var(--bg); font-size: 15px; font-weight: 800; }
.notice.boost { margin-bottom: 16px; }
.notice.boost .notice-icon { background: var(--gem); }
@keyframes gem-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes gem-spin { from { transform: rotateY(0); } to { transform: rotateY(720deg); } }
@media (prefers-reduced-motion: reduce) { .gem-reward, .gem-reward svg { animation: none; } }
.shop-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--card-border); box-shadow: var(--shadow);
}
.shop-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--ice-bg); color: var(--ice); }
.shop-icon svg { width: 22px; height: 22px; }
.shop-buy { height: 40px; padding: 0 20px; font-size: 16px; flex-shrink: 0; }
:root { --gem: #a24bdc; --gem-bg: rgba(162, 75, 220, .1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --gem: #c77dff; --gem-bg: rgba(199, 125, 255, .14); } }
:root[data-theme="dark"] { --gem: #c77dff; --gem-bg: rgba(199, 125, 255, .14); }
