:root {
  --bg: #0b0b0b; --bg2: #100f0e; --panel: #171614; --panel2: #1f1d1b; --line: #2c2926;
  --text: #ece7e1; --muted: #a39d96; --dim: #6d6862;
  --gold: #d9b26a; --gold-d: #a8833f; --red: #d0506a; --red-d: #9b3349; --blue: #8fb3d9; --blue-d: #5f86ae;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--sans); font-size: 16px; line-height: 1.45; min-height: 100vh; overflow-x: hidden;
  background: radial-gradient(ellipse 90% 40% at 50% -10%, #2a0e15 0%, rgba(11,11,11,0) 70%) fixed, var(--bg); }
a { color: var(--gold); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 32px; line-height: 1.1; }
h2 { font-family: var(--serif); font-size: 22px; color: var(--gold); }
h3 { font-size: 18px; }
p { margin: 8px 0; }
ol, ul { padding-left: 20px; margin: 8px 0; }
li { margin: 4px 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 13.5px; } .center { text-align: center; } .r { text-align: right; white-space: nowrap; }
.gold { color: var(--gold); } .red { color: var(--red); }
.kicker { font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; color: var(--gold); }
.row { display: flex; align-items: center; } .between { justify-content: space-between; } .gap { gap: 10px; flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.row.center { justify-content: center; }

.wrap { max-width: 560px; margin: 0 auto; padding: 12px 16px calc(110px + var(--safe-b)); }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(11,11,11,.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-family: var(--serif); letter-spacing: .22em; font-size: 18px; font-weight: 600; }
.stats { display: flex; gap: 6px; }
.stat { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; }
.stat svg { width: 17px; height: 17px; fill: var(--dim); }
.stat.streak.on svg { fill: var(--red); } .stat.streak.on b { color: var(--red); }
.stat.xp svg { fill: var(--blue); } .stat.lvl b { color: var(--gold); }
.sub { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; padding: calc(12px + var(--safe-t)) 16px 12px;
  background: rgba(11,11,11,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.sub h1 { font-size: 26px; }
.back { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 28px; line-height: 1; flex: none; }

/* Cards */
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 12px 0; color: var(--text); text-decoration: none; }
.card.link:active { transform: scale(.99); }
.card.hero h1 { margin: 6px 0 4px; }
.card.glow { border-color: var(--red); box-shadow: 0 0 0 1px var(--red), 0 0 24px rgba(208,80,106,.25); }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lede { font-family: var(--serif); font-style: italic; font-size: 19px; color: #d6cfc6; }
.alert { background: var(--panel2); border-left: 4px solid var(--blue); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 14.5px; }
.alert.gold { border-left-color: var(--gold); } .alert.bad { border-left-color: var(--red); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; }
.pill.blue { border-color: var(--blue); color: var(--blue); }
.bar { height: 12px; border-radius: 999px; background: var(--panel2); overflow: hidden; margin: 10px 0; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--red), #e2738a); border-radius: inherit; transition: width .4s; }
.bar.gold i { background: linear-gradient(90deg, var(--gold-d), var(--gold)); }
.done-badge { display: inline-flex; gap: 6px; align-items: center; color: var(--gold); font-weight: 700; margin: 8px 0 10px; }
.done-badge .ck { width: 22px; height: 22px; stroke: var(--gold); }

/* Buttons — chunky, pressable */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 16px; border: 0;
  font-weight: 800; letter-spacing: .06em; text-transform: uppercase; font-size: 14.5px; cursor: pointer; text-decoration: none; user-select: none;
  transition: transform .06s, box-shadow .06s; }
.btn.primary { background: var(--gold); color: #1b1408; box-shadow: 0 5px 0 var(--gold-d); }
.btn.primary:active { transform: translateY(5px); box-shadow: 0 0 0 var(--gold-d); }
.btn.danger { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d); }
.btn.danger:active { transform: translateY(5px); box-shadow: none; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 2px solid var(--line); box-shadow: 0 4px 0 #0f0e0d; }
.btn.ghost:active { transform: translateY(4px); box-shadow: none; }
.btn.danger-text { color: var(--red); }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 12px; border-radius: 10px; box-shadow: 0 3px 0 #0f0e0d; }
.btn.wide { display: flex; width: 100%; margin-top: 10px; }
.btn.big { min-height: 58px; font-size: 16.5px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.file-btn { cursor: pointer; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 18px; cursor: pointer; flex: none; }

/* Quests */
.quests { list-style: none; padding: 0; margin: 4px 0 0; }
.quests li a { display: flex; align-items: center; gap: 12px; padding: 10px 2px; color: var(--text); text-decoration: none; border-top: 1px solid var(--line); }
.quests .tick { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.quests li.ok .tick { background: var(--gold); border-color: var(--gold); }
.quests li.ok .tick .ck { width: 18px; stroke: #1b1408; }
.quests li.ok a { color: var(--muted); text-decoration: line-through; }

/* Path */
.path { padding: 8px 0 24px; overflow: hidden; }
.unit { margin: 26px 0 8px; padding: 16px; border-radius: var(--r); background: linear-gradient(135deg, #2b1018, #171614 70%); border: 1px solid #3a1c24; }
.unit h2 { font-size: 26px; color: var(--text); }
.week { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 18px 4px 6px; color: var(--muted); }
.week.current { color: var(--gold); }
.node-row { position: relative; display: flex; flex-direction: column; align-items: center; margin: 10px 0 14px; transform: translateX(var(--x)); }
.node { display: grid; place-items: center; width: 72px; height: 66px; border-radius: 50%; text-decoration: none; font-weight: 800; font-size: 22px;
  background: var(--panel2); color: var(--dim); box-shadow: 0 7px 0 #0d0c0b; border: 2px solid var(--line); transition: transform .08s; }
.node:active { transform: translateY(5px); box-shadow: 0 2px 0 #0d0c0b; }
.node .ck { width: 34px; height: 34px; stroke: #1b1408; }
.node.done { background: var(--gold); border-color: var(--gold); box-shadow: 0 7px 0 var(--gold-d); }
.node.today, .node.active { background: var(--red); border-color: #e57890; color: #fff; box-shadow: 0 7px 0 var(--red-d), 0 0 0 6px rgba(208,80,106,.22); animation: pulse 1.6s ease-in-out infinite; }
.node.missed { opacity: .55; } .node.missed .x { color: var(--red); font-size: 28px; }
.node.future { color: var(--muted); }
.bubble { position: absolute; top: -30px; background: var(--text); color: var(--bg); font-weight: 800; font-size: 12px; letter-spacing: .12em; padding: 5px 10px; border-radius: 10px; animation: bob 1.4s ease-in-out infinite; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--text); border-bottom: 0; }
.node-cap { margin-top: 12px; font-size: 13px; text-align: center; line-height: 1.25; }
@keyframes pulse { 0%,100% { box-shadow: 0 7px 0 var(--red-d), 0 0 0 4px rgba(208,80,106,.25); } 50% { box-shadow: 0 7px 0 var(--red-d), 0 0 0 12px rgba(208,80,106,.05); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Lesson */
.group { padding: 12px 16px; }
.ex-line { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.group .ex-line:first-of-type, .group .kicker + .ex-line { border-top: 0; }
.code { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); color: var(--gold); font-weight: 800; font-size: 14px; }
.target { margin-top: 4px; font-weight: 600; }
.sticky-cta { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--bg) 30%); }

/* Runner */
.run-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(11,11,11,.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.run-top .bar { flex: 1; margin: 0; height: 16px; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); min-width: 56px; text-align: right; }
.run-wrap { padding-top: 4px; }
.run-head { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 2px 0; }
.setno { font-weight: 800; color: var(--text); }
.ex-card { border-width: 2px; }
.ex-name { font-size: 30px; }
.target-big { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 12px 0 8px; }
.target-big .load { font-size: 28px; font-weight: 800; color: var(--gold); }
.target-big .times { color: var(--dim); font-size: 22px; }
.target-big .reps { font-size: 40px; font-weight: 800; line-height: 1; }
.target-big .side { color: var(--muted); }
.target-big.sm .reps { font-size: 26px; } .target-big.sm .load { font-size: 22px; }
.rec { font-size: 14.5px; padding: 8px 10px; border-radius: 10px; background: var(--panel2); border-left: 4px solid var(--blue); }
.rec.up, .rec.confirm { border-left-color: var(--gold); } .rec.up-hard, .rec.down, .rec.buy { border-left-color: var(--red); }
.last { margin-top: 8px; font-size: 14.5px; } .last .kicker { margin-right: 6px; font-size: 10.5px; }
details.form { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.form summary { cursor: pointer; color: var(--gold); font-weight: 700; font-size: 14px; list-style: none; padding: 4px 0; }
details.form summary::-webkit-details-marker { display: none; }
details.form summary::before { content: "＋ "; } details.form[open] summary::before { content: "－ "; }
.run-cta { margin: 14px 0; }
.set-timer { text-align: center; font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); margin: 8px 0; }
.rest { padding: 26px 16px; }
.ring { --p: 1; width: 190px; height: 190px; margin: 14px auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--blue) calc(var(--p) * 360deg), var(--panel2) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: var(--panel); }
.ring span { position: relative; font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; }
.trophy { font-size: 54px; line-height: 1; }

/* Log form */
.log-card h2 { margin-bottom: 4px; }
.log-item { padding: 12px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.log-title { font-weight: 700; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); font-weight: 700; font-size: 14px; cursor: pointer; }
.chip.on { border-color: var(--gold); background: rgba(217,178,106,.16); color: var(--gold); }
.chip[disabled] { opacity: .35; cursor: not-allowed; text-decoration: line-through; }
.chip.sm { min-height: 34px; min-width: 40px; padding: 4px 8px; }
.stepper { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.step { width: 58px; height: 58px; border-radius: 16px; border: 0; background: var(--panel2); font-size: 30px; font-weight: 700; box-shadow: 0 5px 0 #0d0c0b; cursor: pointer; border: 2px solid var(--line); }
.step:active { transform: translateY(5px); box-shadow: none; }
.stepval { flex: 1; display: flex; flex-direction: column; align-items: center; }
.stepval input { width: 100%; max-width: 140px; text-align: center; font-size: 40px; font-weight: 800; background: transparent; border: 0; border-bottom: 2px solid var(--line); padding: 2px; -moz-appearance: textfield; }
.stepval input::-webkit-outer-spin-button, .stepval input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepval span { font-size: 12.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.rir { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .rir .muted { margin-right: 4px; }

/* Overview */
.ov { list-style: none; padding: 0; margin: 6px 0 4px; }
.ov li { margin: 0; }
.ov-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 6px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer; font-size: 14.5px; }
.ov li.cur .ov-btn { background: rgba(208,80,106,.08); border-radius: 10px; }
.ov li.ok .grow { color: var(--muted); }
.ov-code { width: 52px; font-weight: 800; color: var(--gold); flex: none; font-size: 13px; }
.dots { display: flex; gap: 3px; align-items: center; flex: none; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; }
.dots i.f { background: var(--gold); }
.dots b { width: 6px; }

/* Summary */
.celebrate { position: relative; overflow: hidden; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0 6px; }
.tile { background: var(--panel2); border: 2px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.tile b { display: block; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.tile.gold { border-color: var(--gold); } .tile.gold b { color: var(--gold); }
.tile.red { border-color: var(--red); } .tile.red b { color: var(--red); }
.prs { list-style: none; padding: 0; } .prs li { display: flex; align-items: center; gap: 8px; }
.star { width: 20px; height: 20px; fill: var(--gold); flex: none; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: 0; animation: fall 1.8s ease-in forwards; transform: rotate(var(--r)); }
@keyframes fall { 0% { opacity: 1; transform: translateY(0) rotate(var(--r)); } 100% { opacity: 0; transform: translateY(420px) rotate(calc(var(--r) + 540deg)); } }
.xp-float { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 60; font-weight: 800; font-size: 26px; color: var(--gold); pointer-events: none; animation: rise 1.2s ease-out forwards; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -60px) scale(1); } }

/* Forms, tables, charts */
.field { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); color: var(--text); font-size: 16px; }
.field.sm { width: auto; min-height: 40px; padding: 6px 8px; }
.field:focus { border-color: var(--gold); outline: none; }
textarea.field { resize: vertical; }
.body-form label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 10px; }
.body-form label .field { margin-top: 4px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.toggle input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--gold); flex: none; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--gold); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; padding: 6px 4px; border-bottom: 1px solid var(--gold); }
.tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.skip td { color: var(--dim); }
.list { list-style: none; padding: 0; margin: 4px 0; }
.list li { border-top: 1px solid var(--line); }
.list li a, .list li > span:first-child { display: flex; gap: 10px; align-items: center; padding: 11px 2px; color: var(--text); text-decoration: none; }
.list li:not(:has(a)) { display: flex; gap: 10px; padding: 10px 2px; font-size: 14.5px; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 10px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; min-height: 34px; }
.seg button.on { background: var(--gold); color: #1b1408; }
.seg.wide { display: flex; width: 100%; margin-top: 8px; } .seg.wide button { flex: 1; min-height: 42px; font-size: 15px; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ylab { fill: var(--dim); font-size: 10px; text-anchor: end; font-family: var(--sans); }
.chart .xlab { fill: var(--dim); font-size: 10px; font-family: var(--sans); } .chart .xlab.end { text-anchor: end; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.raw { stroke: rgba(143,179,217,.5); stroke-width: 1.4; } .chart .dot.raw { fill: var(--blue); }
.chart .ln.avg { stroke: var(--gold); stroke-width: 2.6; } .chart .dot.avg { fill: var(--gold); }
.chart .ln.raw2 { stroke: rgba(208,80,106,.5); stroke-width: 1.4; } .chart .dot.raw2 { fill: var(--red); }
.chart .ln.avg2 { stroke: var(--text); stroke-width: 2.6; }
.chart-empty { padding: 28px 8px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; margin-top: 8px; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.lg { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.lg.raw { background: var(--blue); } .lg.avg { background: var(--gold); } .lg.raw2 { background: var(--red); } .lg.avg2 { background: var(--text); }

/* Bottom nav */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(16,15,14,.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tab { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; text-decoration: none; color: var(--dim); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tab svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; }
.tab.on { color: var(--gold); background: rgba(217,178,106,.1); }

/* Modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 80; }
.modal { position: fixed; z-index: 81; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.modal h3 { font-family: var(--serif); font-size: 24px; } .modal p { color: var(--muted); }
.modal .field { margin-top: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; } .modal-actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 90; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) { h1 { font-size: 36px; } .tiles { grid-template-columns: repeat(4, 1fr); } }
