/* FlexPi — premium design system */
:root {
  --bg:        #0c0a1a;
  --bg-2:      #131129;
  --surface:   rgba(255,255,255,0.045);
  --surface-2: rgba(255,255,255,0.07);
  --stroke:    rgba(255,255,255,0.09);
  --stroke-2:  rgba(255,255,255,0.16);
  --text:      #f4f3fb;
  --muted:     #a39fc4;
  --faint:     #6f6a93;
  --pi:        #7b5cff;   /* Pi violet */
  --pi-2:      #a37bff;
  --gold:      #ffcb5e;
  --good:      #3ddc97;
  --bad:       #ff6b8a;
  --radius:    20px;
  --radius-sm: 13px;
  --shadow:    0 18px 50px -20px rgba(0,0,0,0.7);
  --maxw:      720px;
  --ease:      cubic-bezier(.4,.1,.2,1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% -10%, #1d1640 0%, var(--bg) 55%) fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1,h2,h3,h4 { font-family: 'Sora', sans-serif; letter-spacing: -0.02em; line-height: 1.1; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

#app { max-width: var(--maxw); margin: 0 auto; padding: 0 18px calc(110px + env(safe-area-inset-bottom)); }

/* boot */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; z-index: 50; }
.boot span { font-family: 'Sora'; font-weight: 800; letter-spacing: .04em; color: var(--muted); }
.boot-ring { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--stroke); border-top-color: var(--pi-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- header ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 26px 2px 18px; }
.brand { display: flex; align-items: center; gap: 11px; font-family: 'Sora'; font-weight: 800; font-size: 20px; }
.brand .mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-content: center;
  background: linear-gradient(140deg, var(--pi-2), var(--pi)); box-shadow: 0 8px 22px -8px var(--pi); }
.brand .mark svg { width: 19px; height: 19px; stroke-width: 2.4; color: #fff; }
.brand b { background: linear-gradient(90deg,#fff,#c9bfff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chip { font-size: 12px; font-weight: 600; color: var(--pi-2); background: rgba(123,92,255,.14);
  border: 1px solid rgba(123,92,255,.28); padding: 6px 11px; border-radius: 999px; }

/* ---- generic surfaces ----
   Design rule: segment with whitespace + hairline dividers, NOT bordered boxes.
   See .rule / .stat dividers / list-row border-tops below. */
.card { padding: 20px 2px; }
.rule { height: 1px; background: var(--stroke); border: 0; margin: 22px 0; }
.section-title { display:flex; align-items:baseline; justify-content:space-between; margin: 28px 2px 8px; }
.section-title h2 { font-size: 19px; font-weight: 700; }
.section-title a { font-size: 13px; color: var(--pi-2); font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 15px; padding: 14px 20px; border-radius: 14px; transition: transform .15s var(--ease), filter .2s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--pi-2), var(--pi)); color: #fff;
  box-shadow: 0 14px 32px -12px var(--pi); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text); }
.btn-block { display: flex; width: 100%; }
.btn svg { width: 18px; height: 18px; }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 11px; }

/* one-tap "repeat last workout" CTA on Home — a button (allowed), not a box */
.quick-repeat { margin-top: 22px; }
.quick-repeat .qr-name { min-width: 0; font-weight: 600; opacity: .82;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-repeat .qr-name::before { content: '·'; margin: 0 7px; opacity: .55; }

/* ---- login ---- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 30px; padding: 30px 6px calc(60px + env(safe-area-inset-bottom)); }
.login .hero-mark { width: 76px; height: 76px; border-radius: 24px; display: grid; place-content: center; margin-bottom: 6px;
  background: linear-gradient(140deg, var(--pi-2), var(--pi)); box-shadow: 0 22px 50px -16px var(--pi); }
.login .hero-mark svg { width: 40px; height: 40px; color: #fff; stroke-width: 2.2; }
.login h1 { font-size: 40px; font-weight: 800; }
.login h1 b { color: var(--pi-2); }
.login p.lead { color: var(--muted); font-size: 16px; line-height: 1.5; max-width: 30ch; }
.login .perks { display: flex; flex-wrap: wrap; gap: 8px; }
.login .perks span { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--stroke);
  padding: 8px 13px; border-radius: 999px; display:inline-flex; gap:7px; align-items:center; }
.login .perks svg { width: 14px; height: 14px; color: var(--gold); }
.login .free-note { font-size: 13px; color: var(--faint); }
.login .free-note b { color: var(--gold); }
.dev-login { display: flex; gap: 9px; }
.dev-login input { flex: 1; }

input, select, textarea {
  width: 100%; font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 13px; padding: 13px 15px;
  transition: border-color .2s, background .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--stroke-2); background: rgba(255,255,255,.1); }
input::placeholder, textarea::placeholder { color: var(--faint); }
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a39fc4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; background-size: 18px; }

/* ---- stat row (open, split by hairline rules — no tiles) ---- */
.stats { display: grid; grid-template-columns: repeat(3,1fr); margin: 18px 0 4px; }
.stat { padding: 4px 6px; text-align: center; }
.stat + .stat { border-left: 1px solid var(--stroke); }
.stat .v { font-family: 'Sora'; font-size: 28px; font-weight: 800; line-height: 1; }
.stat .v small { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 8px; }
.stat.streak .v { color: var(--gold); }

/* ---- "this week" activity strip (day-dots, hairline-separated — no box) ---- */
.week { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--stroke); }
.week-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.week-title { font-family: 'Sora'; font-weight: 700; font-size: 15px; }
.week-count { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.week-count.met { color: var(--good); }
.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wd-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-content: center;
  background: var(--surface-2); border: 1px solid var(--stroke); color: #fff; transition: all .2s var(--ease); }
.wd-dot svg { width: 15px; height: 15px; stroke-width: 2.6; }
.wd.on .wd-dot { background: linear-gradient(135deg, var(--pi-2), var(--pi)); border-color: transparent;
  box-shadow: 0 6px 16px -8px var(--pi); }
.wd.today .wd-dot { border-color: var(--pi-2); }
.wd.on.today .wd-dot { border-color: #fff; }
.wd.fut .wd-dot { opacity: .4; }
.wd-l { font-size: 11px; color: var(--faint); font-weight: 600; }
.wd.today .wd-l { color: var(--pi-2); }

/* ---- routine list (divided rows, not cards) ---- */
.routines { display: grid; }
.rcard { position: relative; display: block; text-align: left;
  padding: 16px 4px; border-top: 1px solid var(--stroke); border-radius: 10px;
  transition: background .18s var(--ease); }
.rcard:first-child { border-top: 0; }
.rcard:hover { background: rgba(255,255,255,.022); }
.rcard:active { background: rgba(255,255,255,.05); }
.rcard .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.rcard h3 { font-size: 16.5px; font-weight: 700; }
.rcard p { font-size: 13.5px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.meta { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.rcard .meta { margin-top: 11px; }
/* tags: lightweight labels, no borders/boxes */
.tag { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tag.lvl-beginner { color: var(--good); }
.tag.lvl-intermediate { color: var(--gold); }
.tag.lvl-advanced { color: var(--bad); }
.tag.mine { color: var(--pi-2); }
.meta .tag + .tag::before { content: '·'; margin-right: 7px; color: var(--faint); font-weight: 700; }

.filter-row { display: flex; gap: 18px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 6px;
  border-bottom: 1px solid var(--stroke); scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter { white-space: nowrap; font-size: 13.5px; font-weight: 600; color: var(--muted); padding: 4px 1px;
  position: relative; transition: color .18s; }
.filter.active { color: var(--text); }
.filter.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -11px; height: 2px;
  border-radius: 2px; background: linear-gradient(90deg, var(--pi-2), var(--pi)); }

/* ---- ad slot (open, hairline-separated — no card) ---- */
.adslot { margin: 22px 0 6px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.adslot .ad-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 10px; }
.adslot iframe { width: 100%; border: 0; display: block; border-radius: var(--radius-sm); }
.adslot .ad-placeholder { display: grid; place-items: center; gap: 5px; height: 84px; color: var(--faint); text-align: center; }
.adslot .ad-placeholder b { color: var(--muted); font-weight: 600; }
.adslot .ad-placeholder small { font-size: 11px; }

/* ---- detail / session ---- */
.back-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 600; padding: 18px 2px 8px; }
.back-btn svg { width: 17px; height: 17px; }
.detail-head h1 { font-size: 28px; font-weight: 800; margin: 4px 0 8px; }
.ex-list { display: grid; margin-top: 4px; }
.ex { display: flex; align-items: center; gap: 14px; padding: 14px 2px; border-top: 1px solid var(--stroke); }
.ex:first-child { border-top: 0; }
.ex .idx { width: 22px; flex: none; font-family: 'Sora'; font-weight: 700; font-size: 15px; color: var(--pi-2); }
.ex .body { flex: 1; min-width: 0; }
.ex .body h4 { font-size: 15px; font-weight: 600; }
.ex .body .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.ex .body .note { font-size: 12px; color: var(--faint); margin-top: 3px; font-style: italic; }
.ex .reps { font-family: 'Sora'; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }

.sticky-cta { position: fixed; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: var(--maxw); margin: 0 auto; padding: 0 18px; pointer-events: none; }
.sticky-cta .btn { pointer-events: auto; }

/* session runner */
/* live elapsed-workout clock in the header — a quiet inline readout, not a box */
.run-elapsed { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-family: 'Sora'; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.run-elapsed svg { width: 15px; height: 15px; color: var(--faint); flex: none; }
/* exercise stepper in the header — back-nav control (like .done/.ex-modal-x) + the N/total chip */
.run-steps { display: flex; align-items: center; gap: 10px; }
.run-prev { flex: none; width: 31px; height: 31px; border-radius: 10px; display: grid; place-content: center;
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--muted); transition: color .2s, opacity .2s; }
.run-prev svg { width: 17px; height: 17px; }
.run-prev:hover:not(:disabled) { color: var(--pi-2); }
.run-prev:disabled { opacity: .3; cursor: default; }
/* "up next" preview — a quiet hairline-separated line, not a box */
.up-next { display: flex; align-items: center; justify-content: center; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--stroke); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.up-next span { color: var(--muted); text-transform: none; letter-spacing: normal; font-family: 'Sora'; font-weight: 700; font-size: 14px; }
.up-next span::before { content: '·'; margin: 0 9px; color: var(--faint); }
.runner-ex { text-align: center; padding: 8px 0 4px; }
.runner-ex .step { font-size: 13px; color: var(--pi-2); font-weight: 700; letter-spacing: .04em; }
.runner-ex h1 { font-size: 30px; margin: 10px 0 6px; }
.runner-title { display: inline-flex; align-items: center; gap: 9px; margin: 10px 0 6px;
  font-family: 'Sora'; font-weight: 800; font-size: 30px; letter-spacing: -.02em; color: var(--text); line-height: 1.1; }
.runner-title .swap-ic { width: 17px; height: 17px; color: var(--faint); flex: none; transition: color .2s; }
.runner-title:active .swap-ic, .runner-title:hover .swap-ic { color: var(--pi-2); }
.runner-ex .target { font-size: 17px; color: var(--muted); }
.runner-addex { display: block; width: 100%; margin-top: 9px; padding: 11px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--muted); transition: color .2s; }
.runner-addex:hover { color: var(--pi-2); }
/* optional workout note — the revealed field just needs a little breathing room */
.run-note-field { margin-top: 12px; margin-bottom: 0; }
.set-grid { display: grid; gap: 9px; margin: 18px 0; }
.set-row { display: grid; grid-template-columns: 40px 1fr 1fr 44px; gap: 9px; align-items: center; }
.set-row .sn { font-family:'Sora'; font-weight:700; color: var(--muted); text-align:center; }
.set-row input { text-align: center; padding: 11px; }
.set-row .done { display:grid; place-content:center; height:44px; border-radius: 12px; background: var(--surface-2); border:1px solid var(--stroke); color: var(--faint); }
.set-row .done.on { background: rgba(61,220,151,.16); border-color: rgba(61,220,151,.4); color: var(--good); }
.set-row .done svg { width: 20px; height: 20px; }
.set-head { display: grid; grid-template-columns: 40px 1fr 1fr 44px; gap: 9px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; padding: 0 2px; }
.set-head span { text-align: center; }
.set-actions { display: flex; gap: 10px; }
.set-actions .btn { flex: 1; }

.last-perf { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; margin-top: 12px; }
.last-perf .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.last-perf span:not(.lbl) { font-size: 12.5px; font-weight: 600; color: var(--muted); font-family: 'Sora'; }
.last-perf.best { margin-top: 8px; }
.last-perf.best .lbl { color: var(--gold); }
.last-perf.best span:not(.lbl) { color: color-mix(in srgb, var(--gold) 75%, #fff); }

.rest-timer { text-align:center; font-family:'Sora'; }
.rest-timer .rest-lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.rest-timer .t { font-size: 50px; font-weight: 800; line-height: 1.05; }
.rest-timer.run .t { color: var(--gold); }
/* circular rest countdown — a data-mark ring (like the rank bar), not a box */
.rest-ring { position: relative; width: 168px; height: 168px; margin: 2px auto 0; }
.rest-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest-ring circle { fill: none; stroke-width: 6; }
.rest-ring .ring-track { stroke: var(--stroke); }
.rest-ring .ring-prog { stroke: var(--gold); stroke-linecap: round;
  stroke-dasharray: 339.29; stroke-dashoffset: 0;
  transition: stroke-dashoffset .25s linear; filter: drop-shadow(0 0 5px rgba(255,203,94,.4)); }
.rest-ring-c { position: absolute; inset: 0; display: grid; place-content: center; gap: 3px; }
.rest-adj { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.rest-adj .btn-sm { min-width: 64px; }

/* builder */
.builder-ex { display: grid; }
.bex { padding: 15px 0; border-top: 1px solid var(--stroke); }
.bex:first-child { border-top: 0; padding-top: 4px; }
.bex .r1 { display: flex; gap: 9px; align-items: center; }
.bex .r1 input { flex: 1; }
.bex .r2 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.bex .r2 .f { display: flex; flex-direction: column; gap: 5px; margin: 0; }
.bex .r2 .f > span { font-size: 11px; font-weight: 600; color: var(--faint); padding-left: 2px; }
.bex .r2 input { font-size: 13px; padding: 10px; }
.bex .r3 { display: flex; flex-direction: column; gap: 5px; margin: 10px 0 0; }
.bex .r3 > span { font-size: 11px; font-weight: 600; color: var(--faint); padding-left: 2px; }
.bex .r3 > span small { font-weight: 500; color: var(--faint); opacity: .8; }
.bex .r3 input { font-size: 13px; padding: 10px; width: 100%; }
.bex .del { flex: none; width: 42px; height: 42px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--stroke); color: var(--bad); display: grid; place-content: center; }
.bex .del svg { width: 17px; height: 17px; }
/* reorder controls — stacked up/down, quieter than delete */
.bex-ord { flex: none; display: flex; flex-direction: column; gap: 3px; }
.bex .ord { width: 30px; height: 19px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--stroke); color: var(--muted); display: grid; place-content: center; transition: color .15s, opacity .15s; }
.bex .ord svg { width: 13px; height: 13px; }
.bex .ord:disabled { opacity: .3; }
.bex .ord:not(:disabled):active { color: var(--pi-2); }
.bex .ord:not(:disabled):hover { color: var(--pi-2); }

/* exercise-name autocomplete (popover menu) */
.bex .r1 .ex-pick { flex: 1; position: relative; min-width: 0; }
.ex-pick input { width: 100%; }
.ex-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 45;
  max-height: 300px; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-2); border: 1px solid var(--stroke-2); border-radius: 14px;
  box-shadow: var(--shadow); padding: 5px; }
.ex-menu .grp { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--pi-2); padding: 11px 10px 5px; position: sticky; top: 0; background: var(--bg-2); }
.ex-menu .grp.none { color: var(--muted); text-transform: none; letter-spacing: normal; font-weight: 500;
  font-size: 13px; line-height: 1.5; padding: 12px 10px; position: static; }
.ex-menu .opt { display: block; width: 100%; text-align: left; padding: 10px; border-radius: 9px;
  font-size: 14px; color: var(--text); transition: background .12s; }
.ex-menu .opt:hover, .ex-menu .opt:active { background: var(--surface-2); }

/* full-screen exercise picker (bottom sheet) — runner swap/add */
.ex-modal { position: fixed; inset: 0; z-index: 82; display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(8,6,18,.6); backdrop-filter: blur(6px); animation: fade .2s var(--ease); }
.ex-modal-card { width: 100%; max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column;
  max-height: 82vh; background: var(--bg-2); border-top: 1px solid var(--stroke-2);
  border-radius: 24px 24px 0 0; padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); animation: sheet .3s var(--ease); }
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
.ex-modal-card::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--stroke-2); margin: 0 auto 12px; }
.ex-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 12px;
  font-family: 'Sora'; font-weight: 700; font-size: 16px; }
.ex-modal-x { width: 32px; height: 32px; border-radius: 9px; color: var(--muted); font-size: 15px; background: var(--surface-2); }
#exSearch { margin-bottom: 10px; flex: none; }
.ex-modal-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ex-modal-list .grp { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--pi-2); padding: 11px 8px 5px; position: sticky; top: 0; background: var(--bg-2); }
.ex-modal-list .grp.none { color: var(--muted); text-transform: none; letter-spacing: normal; font-weight: 500;
  font-size: 13px; line-height: 1.5; padding: 14px 8px; position: static; }
.ex-modal-list .opt { display: block; width: 100%; text-align: left; padding: 12px 10px; border-radius: 10px;
  font-size: 15px; color: var(--text); transition: background .12s; }
.ex-modal-list .opt:hover, .ex-modal-list .opt:active { background: var(--surface-2); }

/* history (divided rows + open accordion) */
.hentry { border-top: 1px solid var(--stroke); }
.hentry:first-child { border-top: 0; }
.hrow { width: 100%; text-align: left; display: flex; align-items: center; gap: 14px; padding: 15px 2px; transition: background .2s; }
.hrow:hover { background: rgba(255,255,255,.022); }
.hrow .cal { flex: none; width: 44px; text-align: center; }
.hrow .cal .d { font-family:'Sora'; font-size: 20px; font-weight: 800; line-height: 1; }
.hrow .cal .m { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.hrow .info { flex: 1; min-width: 0; }
.hrow .info h4 { font-size: 15px; font-weight: 600; }
.hrow .info .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.hrow .hcaret { flex: none; width: 18px; height: 18px; color: var(--faint); transition: transform .25s var(--ease); }
.hentry.open .hrow .hcaret { transform: rotate(180deg); }
.hdetail { display: grid; gap: 11px; padding: 4px 2px 16px 60px; animation: fade .25s var(--ease); }
.hdetail-top { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.hex { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hex-name { font-size: 13.5px; font-weight: 600; color: var(--text); min-width: 0; }
.hex-sets { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.hex-sets span { font-size: 12.5px; font-weight: 600; color: var(--muted); font-family: 'Sora'; }
.hex-sets .none, .hdetail > .none { color: var(--faint); font-style: italic; font-family: inherit; font-weight: 500; }
.hnote { font-size: 13.5px; font-style: italic; color: var(--muted); line-height: 1.45; }
.hdel { align-self: flex-start; margin-top: 2px; padding: 4px 0; font-size: 12.5px; font-weight: 600; color: var(--faint); transition: color .2s; }
.hdel:hover { color: var(--bad); }

/* personal records (divided rows, hairline-separated — no box) */
.pr-list { display: grid; margin-top: 4px; }
.pr-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 13px 2px; border-top: 1px solid var(--stroke); }
.pr-row:first-child { border-top: 0; }
.pr-main { min-width: 0; }
.pr-name { font-size: 14.5px; font-weight: 600; color: var(--text); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-sub { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 2px;
  font-variant-numeric: tabular-nums; }
.pr-best { flex: none; display: flex; align-items: baseline; gap: 10px; }
.pr-best b { font-family: 'Sora'; font-weight: 800; font-size: 15px;
  color: color-mix(in srgb, var(--gold) 75%, #fff); }
.pr-best span { font-size: 11.5px; color: var(--faint); font-weight: 600; }

/* progress chart (8-week trend — bars are data marks, hairline-separated, no box) */
.prog { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--stroke); }
.prog-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.prog-title { font-family: 'Sora'; font-weight: 700; font-size: 15px; }
.prog-sum { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.prog-chart { display: flex; align-items: flex-end; gap: 7px; height: 96px; }
.pbar { flex: 1; display: flex; align-items: flex-end; height: 100%; }
.pbar-fill { width: 100%; min-height: 3px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--pi-2), var(--pi)); transition: height .6s var(--ease); }
.pbar.now .pbar-fill { box-shadow: 0 0 14px -2px var(--pi); }
.pbar.empty .pbar-fill { background: var(--surface-2); }
.prog-x { display: flex; gap: 7px; margin-top: 8px; }
.prog-x span { flex: 1; text-align: center; font-size: 10px; color: var(--faint); font-weight: 600; }

/* preference row — hairline-separated; the toggle is a segmented pill (allowed) */
.pref { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--stroke); }
.pref-l { font-family: 'Sora'; font-weight: 700; font-size: 15px; }
.pref-l small { display: block; font-family: 'Inter', system-ui, sans-serif; font-weight: 500;
  font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.seg-b.seg-n { min-width: 34px; padding: 7px 10px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--stroke); }
.seg-b { min-width: 46px; padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--muted); transition: color .2s, background .2s; }
.seg-b.on { color: #fff; background: linear-gradient(135deg, var(--pi-2), var(--pi));
  box-shadow: 0 6px 16px -8px var(--pi); }

/* empty states */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .e-ic { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-content: center; background: color-mix(in srgb, var(--pi) 14%, transparent); }
.empty .e-ic svg { width: 26px; height: 26px; color: var(--pi-2); }
.empty h3 { font-size: 18px; margin-bottom: 7px; }
.empty p { font-size: 14px; max-width: 28ch; margin: 0 auto 18px; line-height: 1.5; }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #1c1838; border: 1px solid var(--stroke-2); color: var(--text); padding: 12px 18px; border-radius: 13px;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s var(--ease); z-index: 60; max-width: 90%; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- gamification: rank (open block, hairline-separated) ---- */
.rank-card { --rank: var(--pi-2); margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--stroke); }
.rank-top { display: flex; align-items: center; gap: 13px; }
.rank-badge { width: 42px; height: 42px; flex: none; border-radius: 13px; display: grid; place-content: center; font-size: 22px;
  background: color-mix(in srgb, var(--rank) 22%, transparent); box-shadow: 0 8px 22px -12px var(--rank); }
.rank-meta { flex: 1; min-width: 0; }
.rank-name { font-family: 'Sora'; font-weight: 800; font-size: 18px; color: color-mix(in srgb, var(--rank) 60%, #fff); }
.rank-pts { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.rank-pts span { color: var(--faint); font-weight: 500; }
.rankbar { height: 9px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin: 14px 0 9px; }
.rankbar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--rank), color-mix(in srgb, var(--rank) 50%, #fff));
  box-shadow: 0 0 14px -2px var(--rank); transition: width .9s var(--ease); }
.rank-next { font-size: 12.5px; color: var(--muted); }
.rank-next b { color: var(--text); font-weight: 700; }

/* points badge (history) */
.hpts { flex: none; font-family: 'Sora'; font-weight: 800; font-size: 16px; color: var(--gold);
  display: flex; align-items: baseline; gap: 2px; }
.hpts small { font-size: 10px; font-weight: 700; color: var(--muted); }

/* finish celebration overlay */
.celebrate { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(123,92,255,.22), rgba(8,6,18,.86)); backdrop-filter: blur(8px);
  animation: fade .3s var(--ease); }
.cel-card { width: 100%; max-width: 380px; text-align: center; background: var(--bg-2); border: 1px solid var(--stroke-2);
  border-radius: 26px; padding: 30px 22px 22px; box-shadow: var(--shadow); animation: pop .45s var(--ease); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cel-burst { --rank: var(--pi); width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 26px; display: grid; place-content: center;
  font-size: 44px; background: color-mix(in srgb, var(--rank) 22%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--rank) 45%, transparent); box-shadow: 0 16px 40px -12px var(--rank); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.cel-card h1 { font-size: 26px; font-weight: 800; }
.cel-sub { color: var(--muted); font-size: 14.5px; margin-top: 6px; }
.cel-vol { font-family: 'Sora'; font-size: 12.5px; color: var(--faint); margin-top: 4px; letter-spacing: .01em; }
.cel-vol b { color: var(--text); font-weight: 700; }
.cel-points { font-family: 'Sora'; font-weight: 800; font-size: 52px; color: var(--gold); margin: 16px 0 4px; line-height: 1; }
.cel-points small { font-size: 18px; color: var(--muted); margin-left: 4px; }
.cel-break { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0 6px; }
.cel-break span { font-size: 12px; color: var(--faint); background: var(--surface); border: 1px solid var(--stroke);
  padding: 7px 11px; border-radius: 999px; display: inline-flex; gap: 6px; }
.cel-break b { color: var(--good); font-weight: 700; }
.cel-prs { margin: 12px 0 4px; padding: 13px; border-radius: 16px;
  background: color-mix(in srgb, var(--gold) 11%, var(--surface)); border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--stroke)); }
.cel-prs-h { font-family: 'Sora'; font-weight: 800; font-size: 14px; color: var(--gold); margin-bottom: 9px; }
.cel-prs span { display: inline-flex; gap: 6px; align-items: baseline; font-size: 12.5px; color: var(--muted); font-family: 'Sora';
  background: var(--surface-2); border: 1px solid var(--stroke); padding: 5px 11px; border-radius: 999px; margin: 3px; }
.cel-prs span b { color: var(--text); font-weight: 700; }

/* nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around; align-items: center;
  max-width: var(--maxw); margin: 0 auto; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(14,12,30,.82); backdrop-filter: blur(20px); border-top: 1px solid var(--stroke); }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--faint); font-size: 10.5px; font-weight: 600; padding: 5px 12px; transition: color .2s; flex: 1; }
.nav-btn svg { width: 23px; height: 23px; }
.nav-btn.active { color: var(--pi-2); }
.nav-fab { flex: none; width: 56px; height: 56px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--pi-2), var(--pi)); box-shadow: 0 12px 26px -8px var(--pi); margin-top: -22px; }
.nav-fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.nav-fab span { display: none; }

/* misc */
.row-gap { display: grid; gap: 13px; }
.center { text-align: center; }
.mt { margin-top: 18px; }
.fade-in { animation: fade .35s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (min-width: 560px) { .login h1 { font-size: 48px; } }
