/* Layout: single phone-width column, bottom tab bar; workout runs as a full-screen layer.
   Palette borrows from competition bumper plates (blue 20, red 25, yellow 15, green 10) on chalk-grey rubber. */
:root {
  --bg: #e9ecef;
  --surface: #ffffff;
  --surface-2: #f3f5f7;
  --ink: #11151a;
  --ink-2: #48515c;
  --ink-3: #626b77;
  --line: #d3d8de;
  --accent: #1d4fd8;
  --accent-ink: #ffffff;
  --accent-soft: #dbe5fc;
  --hi: #e9b512;
  --good: #1d8549;
  --bad: #c43a2c;
  --p25: #d23b2d;
  --p20: #1d4fd8;
  --p15: #e9b512;
  --p10: #23894f;
  --p5: #f4f5f6;
  --p2: #2a2f36;
  --p1: #aab2bb;
  --shadow: 0 1px 2px rgba(17, 21, 26, .06), 0 6px 20px rgba(17, 21, 26, .06);
  --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f13; --surface: #161a20; --surface-2: #1d232b; --ink: #eef1f4; --ink-2: #b3bbc5; --ink-3: #7f8996;
    --line: #2a313b; --accent: #6b95ff; --accent-ink: #0c0f13; --accent-soft: #1b2950; --hi: #f3c845;
    --good: #45c27a; --bad: #f0604f; --p5: #e3e6ea; --p2: #50565e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0f13; --surface: #161a20; --surface-2: #1d232b; --ink: #eef1f4; --ink-2: #b3bbc5; --ink-3: #7f8996;
  --line: #2a313b; --accent: #6b95ff; --accent-ink: #0c0f13; --accent-soft: #1b2950; --hi: #f3c845;
  --good: #45c27a; --bad: #f0604f; --p5: #e3e6ea; --p2: #50565e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell ---------- */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px calc(96px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 4px; }
.brand { white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: .02em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.brand .plate { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 0 7px var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.topbar .chip { font-size: 12px; padding: 4px 8px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.hot { color: var(--bad); }
.chip.lvl { color: var(--accent); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { background: none; border: 0; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); }

.section-title { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.card { background: var(--surface); border-radius: var(--r); border: 1px solid var(--line); padding: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 11px 16px; font-weight: 600; text-decoration: none; color: var(--ink); min-height: 44px; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; font-family: var(--display); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }

/* ---------- Today ---------- */
.today { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.today-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.daynum { font-family: var(--display); font-weight: 800; line-height: .85; font-size: 84px; letter-spacing: -.01em; }
.daynum small { display: block; font-size: 15px; letter-spacing: .18em; color: var(--ink-3); margin-bottom: 6px; line-height: 1; }
.daytype { text-align: right; min-width: 0; }
.daytype h2 { font-family: var(--display); font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 1; }
.daytype p { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); letter-spacing: .02em; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: color-mix(in srgb, var(--hi) 22%, transparent); color: var(--ink); }
.ex-preview { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ex-preview li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.ex-preview li:first-child { border-top: 0; }
.ex-preview .phase { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; padding-top: 12px; }
.ex-preview .sx { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ex-preview .nm { min-width: 0; }
.locked-note { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; color: var(--ink-2); font-size: 14px; }
.locked-note svg { width: 20px; height: 20px; flex: none; }

.notice { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; background: var(--accent-soft); border-radius: var(--r); padding: 12px 14px; }
.notice p { margin: 0; font-size: 14px; flex: 1 1 200px; }
.notice .row { flex-wrap: nowrap; }

/* Day ladder */
.ladder { list-style: none; margin: 0; padding: 0; position: relative; }
.ladder::before { content: ""; position: absolute; left: 17px; top: 18px; bottom: 18px; width: 2px; background: var(--line); }
.rung { position: relative; display: grid; grid-template-columns: 36px 1fr auto; gap: 12px; align-items: center; padding: 7px 0; }
.node { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); font-family: var(--display); font-weight: 800; font-size: 15px; color: var(--ink-3); position: relative; z-index: 1; }
.node svg { width: 16px; height: 16px; }
.rung.done .node { background: var(--good); border-color: var(--good); color: #fff; }
.rung.now .node { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 5px var(--accent-soft); }
.rung .t { font-weight: 600; font-size: 14.5px; }
.rung .t span { font-weight: 400; color: var(--ink-3); }
.rung.locked .t { color: var(--ink-3); }
.rung .s { font-family: var(--display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-3); font-weight: 600; }
.week i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: block; }
.week i.on { background: var(--good); border-color: var(--good); }
.week i.today { border-color: var(--accent); }

/* ---------- Progress ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.tile b { display: block; font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile span { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 10px; font-family: var(--body); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-readout { font-size: 13px; color: var(--ink-2); min-height: 20px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.heat i { width: 100%; aspect-ratio: 1; min-width: 12px; border-radius: 3px; background: var(--surface-2); display: block; }
.heat i.l1 { background: color-mix(in srgb, var(--good) 45%, var(--surface-2)); }
.heat i.l2 { background: color-mix(in srgb, var(--good) 75%, var(--surface-2)); }
.heat i.l3 { background: var(--good); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.hbar { display: grid; grid-template-columns: 84px 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 5px; background: var(--accent); }
.hbar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.list li:first-child { border-top: 0; }
.list .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .r small { display: block; color: var(--ink-3); font-size: 12px; }
.empty { color: var(--ink-3); font-size: 14px; padding: 8px 0; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; min-width: 0; }

/* ---------- Library ---------- */
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filters button { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lib-item { width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.lib-item:first-child { border-top: 0; }
.lib-item b { display: block; font-weight: 600; }
.lib-item small { color: var(--ink-3); }
.lib-item .warn { color: var(--bad); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ---------- Settings ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field + .field { margin-top: 18px; }
.field > label, .field > .lbl { font-weight: 700; font-size: 14px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.opt b { font-size: 14px; }
.opt small { color: var(--ink-3); font-size: 12px; line-height: 1.3; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input { flex: 1; accent-color: var(--accent); }
.slider-row output { font-family: var(--display); font-weight: 800; font-size: 30px; min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.inj { display: flex; flex-wrap: wrap; gap: 6px; }
.inj button { border: 1.5px solid var(--line); background: var(--surface); padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: 13.5px; }
.inj button[aria-pressed="true"] { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 0; }
input[type="number"], input[type="text"], input[type="search"] { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; }

/* ---------- Workout layer ---------- */
.layer {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.layer-inner {
  max-width: 560px; margin: 0 auto; min-height: 100%;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 0;
  display: flex; flex-direction: column; gap: 14px;
}
.wo-top { display: flex; align-items: center; gap: 10px; }
.wo-top .clock { font-family: var(--display); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; flex: 1; text-align: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.phase-label { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.ex-title { font-family: var(--display); font-weight: 800; font-size: 38px; line-height: .95; text-transform: uppercase; }
.ex-sub { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.target { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.target div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.target b { display: block; font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.target span { font-size: 11px; color: var(--ink-3); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.suggest { font-size: 13.5px; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }
.suggest b { color: var(--ink); }
.plates { display: flex; align-items: center; gap: 3px; height: 54px; margin-top: 8px; }
.plates .bar-end { width: 30px; height: 10px; background: var(--p1); border-radius: 2px; }
.plates .collar { width: 6px; height: 22px; background: var(--ink-3); border-radius: 2px; }
.plates .pl { width: 12px; border-radius: 3px; display: grid; place-items: center; }
.plates .pl-label { font-size: 12px; color: var(--ink-2); margin-left: 10px; font-variant-numeric: tabular-nums; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.stepper .lbl { text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.stepper .ctl { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 4px; }
.stepper button { height: 44px; border-radius: 10px; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 700; }
.stepper input { width: 100%; min-width: 0; border: 0; background: transparent; text-align: center; font-family: var(--display); font-weight: 800; font-size: 30px; padding: 0; font-variant-numeric: tabular-nums; }
.set-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.set-dots span { padding: 4px 9px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.set-dots span.done { background: var(--good); border-color: var(--good); color: #fff; }
.set-dots span.cur { border-color: var(--accent); color: var(--accent); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools .btn { flex: 1 1 0; min-width: 0; padding: 9px 8px; font-size: 13.5px; }
.cues { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.mistake { font-size: 13.5px; color: var(--ink-2); margin: 8px 0 0; }
.mistake b { color: var(--bad); }
.next-up { font-size: 13.5px; color: var(--ink-3); text-align: center; }
.next-up b { color: var(--ink-2); }
.spacer { flex: 1; }

.ring-wrap { display: grid; place-items: center; padding: 10px 0; }
.ring { position: relative; width: min(56vw, 220px); aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--surface-2); }
.ring .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.ring.work .prog { stroke: var(--bad); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .center b { font-family: var(--display); font-weight: 800; font-size: 60px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring .center span { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* Sheet & dialog */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(8, 10, 14, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 88%; overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet h3 { font-family: var(--display); font-weight: 800; font-size: 28px; text-transform: uppercase; line-height: 1; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 0; }
.swap-list button { width: 100%; text-align: left; background: var(--surface-2); border: 0; border-radius: 10px; padding: 12px; margin-top: 6px; display: block; }
.swap-list small { color: var(--ink-3); display: block; }

/* Summary */
.summary-score { text-align: center; padding: 8px 0; }
.summary-score b { font-family: var(--display); font-weight: 800; font-size: 120px; line-height: .9; display: block; font-variant-numeric: tabular-nums; }
.summary-score span { font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.lvlbar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.lvlbar div { height: 100%; background: var(--hi); border-radius: 5px; }
.pr { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 0; }
.pr .medal { width: 22px; height: 22px; border-radius: 50%; background: var(--hi); display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #1a1400; flex: none; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 80; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); }

@media (max-width: 380px) {
  .daynum { font-size: 70px; }
  .ex-title { font-size: 32px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .opts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Exercise figures ---------- */
.fig { display: block; width: 100%; height: auto; }
.fig .lb, .fig .tr, .fig .nk, .fig .ftp { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
.fig .lb { stroke-width: 7; }
.fig .tr { stroke-width: 12; }
.fig .nk { stroke-width: 6; }
.fig .ftp { stroke-width: 5; }
.fig .trf { fill: var(--ink); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.fig .hd { fill: var(--ink); }
.fig .far .lb, .fig .far .ftp { stroke: color-mix(in srgb, var(--ink) 38%, var(--surface)); }
.fig .eq { fill: none; stroke: var(--ink-3); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.fig .eq.thick { stroke-width: 5; stroke: var(--ink-2); }
.fig .eqf { fill: var(--surface-2); stroke: var(--ink-3); stroke-width: 2; stroke-linejoin: round; }
.fig .cb { fill: none; stroke: var(--ink-3); stroke-width: 1.6; }
.fig .cb.dash { stroke-dasharray: 4 3; }
.fig .pl { fill: var(--accent); }
.fig .plh { fill: var(--surface); }
.fig .dbf { fill: var(--ink-2); }
.fig .fl { stroke: var(--line); stroke-width: 3; stroke-linecap: round; }
.fig-box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.fig-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fig-pair figure { margin: 0; background: var(--surface-2); border-radius: 12px; padding: 4px; text-align: center; }
.fig-pair figcaption { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding-bottom: 4px; }
.thumb { width: 52px; height: 50px; flex: none; background: var(--surface-2); border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.thumb .fig { width: 46px; height: 46px; }
.ex-row { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 12px; cursor: pointer; border-radius: 10px; }
.ex-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ex-row .nm { flex: 1; min-width: 0; }
.ex-row .nm b { display: block; font-weight: 600; }
.ex-row .nm small { display: block; color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-preview li:has(.ex-row) { padding: 7px 0; }
.lib-item .thumb { margin-right: 2px; }
.demo { display: grid; grid-template-columns: 42% 1fr; gap: 12px; align-items: center; }
.demo .fig-box { all: unset; box-sizing: border-box; cursor: pointer; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.demo-txt { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.demo-txt p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
.demo-txt .btn { min-height: 38px; padding: 7px 12px; font-size: 13.5px; align-self: flex-start; }
.sheet .fig-box .fig { max-height: 260px; }
.sheet-top { position: sticky; top: -18px; z-index: 2; margin: -18px 0 -4px; padding: 12px 0 6px; background: var(--surface); display: flex; }
.back-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 8px 16px 8px 10px; font-weight: 600; min-height: 42px; }
.back-btn svg { width: 18px; height: 18px; }
.video { position: relative; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-cap { margin: -6px 0 0; font-size: 12px; color: var(--ink-3); }
.video-link { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); background: var(--surface-2); border-radius: 12px; padding: 12px; }
.video-link .play { width: 46px; height: 46px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; flex: none; }
.video-link .play svg { width: 20px; height: 20px; margin-left: 2px; }
.vl-txt { min-width: 0; }
.vl-txt b { display: block; font-size: 14px; }
.vl-txt small { color: var(--ink-3); }
.sheet > *, .layer-inner > * { flex-shrink: 0; }

/* ---------- UX pass: pinned actions and page headers ---------- */
.startbar { max-width: 560px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 4px max(16px, env(safe-area-inset-left, 0px)); }
.startbar .btn.big { min-height: 54px; }
.sb-sub { font-family: var(--body); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 13px; opacity: .85; margin-left: 4px; }
.app.has-startbar { padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
.page-head { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.page-head .ex-title { font-size: 30px; }
.wo-cta { position: sticky; bottom: 0; z-index: 3; margin: 0 -16px; padding: 18px 16px calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--bg) 20px); }
.wo-cta .row { flex-wrap: nowrap; }
.wo-cta .row > .btn:not(.big) { flex: 0 0 auto; min-width: 96px; }
.wo-cta .row > .btn.big { flex: 1 1 auto; }
.empty-state { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.empty-state b { font-size: 17px; }
.empty-state p { margin: 0; color: var(--ink-2); }
.ex-nav { display: grid; grid-template-columns: 44px 1fr 44px; gap: 10px; align-items: center; }
.ex-nav-mid { min-width: 0; text-align: center; }
.ex-nav .ex-title { font-size: 30px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.wo-list li.cur { background: var(--accent-soft); border-radius: 10px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.wo-row { all: unset; box-sizing: border-box; flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.wo-row .nm { min-width: 0; }
.wo-row .nm b { display: block; font-weight: 600; }
.wo-row .nm small { display: block; color: var(--ink-3); font-size: 12.5px; }
.wo-end { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; border-top: 1px solid var(--line); }
