:root {
  --bg: #FAF6F3; --card: #FFFFFF; --ink: #2A2130; --muted: #857A89; --line: #EDE5E8; --soft: #F3EDF0;
  --a: #E07A5F; --a-t: #FCEDE8;
  --b: #9469AC; --b-t: #F2EAF6;
  --c: #D25E87; --c-t: #FBE7EF;
  --d: #3F9384; --d-t: #E3F2EF;
  --spin: #5F82C4; --spin-t: #EAF0FA;
  --ok: #3F9384; --up: #C2577D;
  --tabs-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --r: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17131A; --card: #221C26; --ink: #F4EEF2; --muted: #A99FAD; --line: #342B38; --soft: #2A232E;
    --a-t: #3A2723; --b-t: #2E2437; --c-t: #3A2330; --d-t: #1E3330; --spin-t: #222B3B;
    --a: #F0927A; --b: #B18AC8; --c: #EA7CA2; --d: #5DB3A3; --spin: #86A4DB; --ok: #5DB3A3; --up: #EA7CA2;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.35 ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { padding: calc(var(--safe-t) + 4px) 0 calc(var(--tabs-h) + var(--safe-b) + 16px); min-height: 100dvh; }
.c-a { --k: var(--a); --kt: var(--a-t); } .c-b { --k: var(--b); --kt: var(--b-t); }
.c-c { --k: var(--c); --kt: var(--c-t); } .c-d { --k: var(--d); --kt: var(--d-t); }
.c-spin { --k: var(--spin); --kt: var(--spin-t); }

/* ---------- tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); z-index: 20; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.tabs svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--ink); }

/* ---------- week (fits one screen) */
.week { height: calc(100dvh - var(--safe-t) - 4px - var(--tabs-h) - var(--safe-b)); display: flex; flex-direction: column; overflow: hidden; }
#app.fit { padding-bottom: 0; }
.wk-head { padding: 8px 18px 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.wk-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.wk-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.wk-tally { display: flex; gap: 6px; flex-shrink: 0; }
.tally { font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--kt); color: var(--k); white-space: nowrap; }
.days { flex: 1; min-height: 0; display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 0 12px 10px; }
.day { display: grid; grid-template-columns: 42px 1fr; gap: 8px; min-height: 0; }
.dlabel { display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12px; color: var(--muted); }
.dlabel b { font-size: 11px; letter-spacing: .06em; font-weight: 700; }
.dlabel span { font-size: 19px; font-weight: 800; color: var(--ink); line-height: 1.1; }
.day.today .dlabel { background: var(--ink); color: var(--bg); }
.day.today .dlabel span { color: var(--bg); }
.day.past .item:not(.done) { opacity: .72; }
.ditems { display: flex; gap: 6px; min-width: 0; min-height: 0; }
.item { position: relative; flex: 1; cursor: pointer; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: var(--r); background: var(--kt); overflow: hidden; }
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--k); }
.item .txt { flex: 1; min-width: 0; }
.item .t1 { font-size: 12px; font-weight: 700; color: var(--k); letter-spacing: .02em; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.item .t2 { font-size: 17px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t3 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.spin.compact { flex: 0 0 96px; padding: 8px 6px 8px 12px; }
.item.spin.compact .t2 { font-size: 15px; }
.day.today .item { box-shadow: 0 0 0 2px var(--k) inset; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--k); opacity: .25; }
.dots i.on { opacity: 1; }
.chk { flex-shrink: 0; width: 44px; height: 44px; margin: -6px -4px -6px 0; display: grid; place-items: center; }
.chk i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--k) 55%, transparent); display: grid; place-items: center; transition: transform .15s; }
.chk i svg { width: 15px; height: 15px; stroke-width: 3; opacity: 0; color: #fff; }
.done .chk i { background: var(--k); border-color: var(--k); }
.done .chk i svg { opacity: 1; }
.chk:active i { transform: scale(.88); }
.item.compact .chk { position: absolute; top: 2px; right: 0; width: 38px; height: 38px; margin: 0; }
.item.compact .chk i { width: 22px; height: 22px; }
.item.spin.compact .t1 { padding-right: 22px; }
.wk-nav { display: flex; gap: 4px; }
.wk-nav button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--soft); }
.wk-nav button svg { width: 16px; height: 16px; }

/* ---------- generic page */
.page { padding: 0 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 44px; margin: 0 -6px 4px; position: sticky; top: 0; z-index: 5; background: var(--bg); }
.back { display: flex; align-items: center; gap: 2px; font-weight: 600; color: var(--muted); padding: 8px 6px; font-size: 15px; }
.back svg { width: 20px; height: 20px; }
.pill-btn { font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 999px; background: var(--soft); display: inline-flex; align-items: center; gap: 6px; }
.pill-btn svg { width: 16px; height: 16px; }
.h-sec { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 22px 2px 10px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: 0 1px 0 var(--line); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- session */
.hero { border-radius: 22px; padding: 18px; background: var(--kt); position: relative; overflow: hidden; }
.hero .mono { position: absolute; right: 14px; top: -6px; font-size: 92px; font-weight: 900; color: var(--k); opacity: .16; line-height: 1; }
.hero .t1 { color: var(--k); font-weight: 800; font-size: 13px; letter-spacing: .05em; }
.hero h1 { font-size: 28px; font-weight: 850; letter-spacing: -.02em; margin: 2px 0 4px; }
.hero .focus { font-size: 14px; color: var(--muted); }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12.5px; font-weight: 700; padding: 5px 9px; border-radius: 999px; background: var(--card); color: var(--ink); }
.hero .note { margin-top: 10px; font-size: 14px; }
.warm { margin-top: 10px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--soft); }
.warm svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--k); }
.exlist { display: flex; flex-direction: column; gap: 10px; }
.ex { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--r); background: var(--card); box-shadow: 0 1px 0 var(--line); position: relative; }
.ex .thumb { width: 76px; height: 76px; border-radius: 12px; flex-shrink: 0; }
.ex .info { flex: 1; min-width: 0; }
.ex .n { font-weight: 800; font-size: 16px; line-height: 1.2; }
.ex .tgt { font-size: 14px; font-weight: 700; color: var(--k); margin-top: 3px; }
.ex .last { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex .prog { display: flex; gap: 4px; margin-top: 6px; }
.ex .prog i { width: 18px; height: 5px; border-radius: 3px; background: var(--line); }
.ex .prog i.on { background: var(--k); }
.ex.complete { background: color-mix(in srgb, var(--kt) 70%, var(--card)); }
.ex .go { color: var(--muted); width: 18px; height: 18px; flex-shrink: 0; }
.ex .rm { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); }
.ex .rm svg { width: 16px; height: 16px; }
.pairwrap { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 14px; }
.pairwrap::before { content: ""; position: absolute; left: 3px; top: 18px; bottom: 18px; width: 3px; border-radius: 2px; background: var(--k); opacity: .5; }
.pairlabel { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--k); margin: 2px 0 -4px 14px; }
.pool { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pchip { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 14px; background: var(--card); box-shadow: 0 1px 0 var(--line); text-align: left; }
.pchip .thumb { width: 44px; height: 44px; border-radius: 9px; flex-shrink: 0; }
.pchip .n { font-size: 13.5px; font-weight: 700; line-height: 1.2; }
.pchip .m { font-size: 11.5px; color: var(--muted); }
.pchip.on { box-shadow: 0 0 0 2px var(--k) inset; background: var(--kt); }
.cta { display: block; width: 100%; padding: 16px; margin-top: 18px; border-radius: 16px; background: var(--ink); color: var(--bg); font-weight: 800; font-size: 17px; text-align: center; }
.cta.k { background: var(--k); color: #fff; }
.cta.ghost { background: var(--soft); color: var(--ink); }

/* ---------- media (two-frame loop: start ↔ end) */
.media { position: relative; overflow: hidden; background: #fff; }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media img.f1 { animation: frame 2.8s ease-in-out infinite; }
@keyframes frame { 0%, 30% { opacity: 0; } 45%, 80% { opacity: 1; } 95%, 100% { opacity: 0; } }
.media.big { aspect-ratio: 4 / 3; border-radius: 20px; }
.media.big img { object-fit: contain; }
.media .lbl { position: absolute; left: 10px; bottom: 10px; font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: rgba(42, 33, 48, .78); color: #fff; }
.media .lbl.l1 { animation: frame 2.8s ease-in-out infinite; }
.media .lbl.l0 { animation: frame-inv 2.8s ease-in-out infinite; }
@keyframes frame-inv { 0%, 30% { opacity: 1; } 45%, 80% { opacity: 0; } 95%, 100% { opacity: 1; } }
.media .vid { position: absolute; right: 10px; bottom: 10px; font-size: 13px; font-weight: 800; padding: 6px 11px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: #2A2130; display: flex; align-items: center; gap: 5px; }
.media .vid svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.media .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--k); background: var(--kt); font-weight: 900; font-size: 22px; }
.media.paused img.f1, .media.paused .lbl { animation-play-state: paused; }
.media.thumb .noimg { font-size: 18px; }
@media (prefers-reduced-motion: reduce) { .media img.f1 { animation-duration: 6s; } }

/* ---------- exercise */
.exname { font-size: 26px; font-weight: 850; letter-spacing: -.02em; margin-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--kt); color: var(--k); }
.target { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.target div { background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: 0 1px 0 var(--line); }
.target b { display: block; font-size: 20px; font-weight: 850; }
.target span { font-size: 12px; color: var(--muted); font-weight: 600; }
.effort { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.suggest { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--kt); font-size: 14.5px; font-weight: 650; display: flex; gap: 10px; align-items: center; }
.suggest svg { width: 20px; height: 20px; color: var(--k); flex-shrink: 0; }
.sets { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.set { display: grid; grid-template-columns: 30px 1fr 1fr 48px; gap: 8px; align-items: center; background: var(--card); border-radius: 14px; padding: 8px 8px 8px 12px; box-shadow: 0 1px 0 var(--line); }
.set .no { font-weight: 800; color: var(--muted); font-size: 15px; }
.step { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; background: var(--soft); border-radius: 11px; height: 52px; }
.step button { height: 52px; display: grid; place-items: center; font-size: 22px; font-weight: 600; color: var(--muted); }
.step input { width: 100%; min-width: 0; height: 52px; text-align: center; border: 0; background: transparent; font-size: 19px; font-weight: 800; padding: 0 0 12px; border-radius: 0; outline: none; -moz-appearance: textfield; }
.step input::-webkit-outer-spin-button, .step input::-webkit-inner-spin-button { -webkit-appearance: none; }
.step input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.stepwrap { position: relative; }
.stepwrap .u { position: absolute; left: 0; right: 0; bottom: 6px; font-size: 9.5px; font-weight: 700; color: var(--muted); text-align: center; pointer-events: none; }
.tick { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--muted); }
.tick svg { width: 22px; height: 22px; stroke-width: 3; }
.set.logged .tick { background: var(--k); color: #fff; }
.set.logged { background: color-mix(in srgb, var(--kt) 60%, var(--card)); }
.addset { margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--muted); padding: 8px 4px; }
.how { margin-top: 6px; }
.how ol { margin: 0; padding: 0 0 0 0; list-style: none; counter-reset: c; display: flex; flex-direction: column; gap: 10px; }
.how li { counter-increment: c; display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 15px; }
.how li::before { content: counter(c); width: 26px; height: 26px; border-radius: 50%; background: var(--kt); color: var(--k); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.range { margin-top: 12px; padding: 12px 14px; border-radius: 14px; border: 1.5px dashed color-mix(in srgb, var(--k) 45%, transparent); font-size: 14.5px; }
.range b { color: var(--k); }
.tipline { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
.notein { width: 100%; border: 0; border-radius: 14px; background: var(--card); box-shadow: 0 1px 0 var(--line); padding: 12px 14px; font-size: 15px; }
.hist { display: flex; flex-direction: column; gap: 6px; }
.hist div { display: flex; justify-content: space-between; font-size: 14px; padding: 9px 12px; border-radius: 12px; background: var(--card); box-shadow: 0 1px 0 var(--line); }
.hist span { color: var(--muted); }
.navrow { display: flex; gap: 8px; margin-top: 18px; }
.navrow .cta { margin-top: 0; }

/* ---------- sheet */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; background: rgba(23, 19, 26, .38); animation: fade .18s ease-out; }
.sheet .panel { width: 100%; max-height: 82dvh; overflow: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--safe-b) + 18px); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 21px; font-weight: 850; margin-bottom: 4px; }
.alt { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px; border-radius: 16px; background: var(--card); box-shadow: 0 1px 0 var(--line); margin-top: 8px; }
.alt .thumb { width: 60px; height: 60px; border-radius: 11px; flex-shrink: 0; }
.alt .n { font-weight: 800; }
.alt .m { font-size: 13px; color: var(--muted); }
.alt.cur { box-shadow: 0 0 0 2px var(--k) inset; background: var(--kt); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- timer */
.timer { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + 10px); z-index: 30; border-radius: 18px; background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .22); overflow: hidden; }
.timer .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--k, var(--c)); transition: width 1s linear; }
.timer .tt { flex: 1; }
.timer .tt b { font-size: 22px; font-weight: 850; font-variant-numeric: tabular-nums; }
.timer .tt span { font-size: 12.5px; opacity: .7; display: block; }
.timer button { padding: 9px 12px; border-radius: 12px; background: rgba(255, 255, 255, .14); font-weight: 800; font-size: 14px; }
.timer.end { background: var(--ok); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 12px); z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 14.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: fade .2s; max-width: 92vw; text-align: center; }

/* ---------- progress */
.prow { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--card); box-shadow: 0 1px 0 var(--line); margin-bottom: 8px; }
.prow .n { font-weight: 800; font-size: 15px; }
.prow .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.prow .gain { font-size: 13px; font-weight: 800; color: var(--up); margin-top: 3px; }
.spark { width: 96px; height: 40px; }
.spark path { stroke: var(--k); stroke-width: 2.4; }
.spark circle { fill: var(--k); stroke: none; }
.grid-wk { display: grid; grid-template-columns: 54px repeat(9, 1fr); gap: 5px; align-items: center; font-size: 12px; }
.grid-wk .wl { color: var(--muted); font-weight: 700; }
.grid-wk i { aspect-ratio: 1; border-radius: 6px; background: var(--soft); }
.grid-wk i.on { background: var(--k); }
.grid-wk .hd { font-size: 10.5px; font-weight: 800; color: var(--muted); text-align: center; }
.mform { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mform label { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.mform input { border: 0; border-radius: 12px; background: var(--card); box-shadow: 0 1px 0 var(--line); padding: 11px 12px; font-size: 17px; font-weight: 700; width: 100%; }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14.5px; background: var(--card); border-radius: var(--r); }

/* ---------- guide */
.rule { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 13px 14px; border-radius: var(--r); background: var(--card); box-shadow: 0 1px 0 var(--line); margin-bottom: 8px; }
.rule .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--kt); color: var(--k); font-weight: 900; }
.rule b { display: block; font-size: 15.5px; }
.rule span { font-size: 14px; color: var(--muted); }
.setrow { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--card); box-shadow: 0 1px 0 var(--line); margin-bottom: 8px; gap: 10px; }
.setrow input[type=date] { border: 0; background: var(--soft); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.credit { font-size: 12px; color: var(--muted); margin-top: 18px; text-align: center; }
