/* ============================================================
   MOBILITY — design system (shared bones with Lift, teal accent)
   ============================================================ */
:root{
  --bg:#0a0c10;
  --bg-elev:#10141b;
  --card:#151a23;
  --card-2:#1b2230;
  --line:#28303d;
  --line-soft:#1f2631;
  --txt:#f2f5f8;
  --dim:#93a1b1;
  --faint:#5c6a7a;
  --accent:#2dd4bf;
  --accent-deep:#0e9384;
  --accent-ink:#02201c;
  --good:#3fd68b;
  --good-ink:#032410;
  --warn:#ffb340;
  --bad:#ff6060;
  --violet:#a78bfa;
  --shadow:0 8px 28px rgba(0,0,0,.45);
  /* dark-mode "border": a single white ring reads cleaner than a tinted
     border and adapts to any surface underneath */
  --ring:0 0 0 1px rgba(255,255,255,.08);
  --ring-strong:0 0 0 1px rgba(255,255,255,.13);
  --ease-out-soft:cubic-bezier(.2,0,0,1);
  --r-lg:18px; --r-md:14px; --r-sm:11px;
  --tabbar-h:64px;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html{height:100%; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; color-scheme:dark;}

/* Vestibular safety: collapse all motion when the OS asks for it */
@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{
    animation-duration:.01ms !important;
    animation-delay:0ms !important;
    transition-duration:.01ms !important;
  }
}

/* Keyboard focus: branded ring, only on focus-visible (not on tap) */
:is(button, [tabindex]):focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}
body{
  margin:0; min-height:100%;
  background:var(--bg); color:var(--txt);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",system-ui,sans-serif;
  text-rendering:optimizeLegibility;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  overscroll-behavior-y:none;
}
.wrap{max-width:560px; margin:0 auto; padding:14px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);}
h1{font-size:24px; margin:6px 0 2px; letter-spacing:-.3px; font-weight:800; text-wrap:balance;}
h2{font-size:13px; margin:20px 0 8px; color:var(--dim); text-transform:uppercase; letter-spacing:1.2px; font-weight:700; text-wrap:balance;}
.muted{color:var(--dim);}
.faint{color:var(--faint);}
.mono{font-variant-numeric:tabular-nums;}
.big{font-size:clamp(38px,13vw,64px); font-weight:800; line-height:1.02; letter-spacing:-1.5px;}
small{font-size:13px;}

/* ---- layout helpers ---- */
.row{display:flex; gap:10px; align-items:center;}
.row.sb{justify-content:space-between;}
.grow{flex:1; min-width:0;}
.hidden{display:none !important;}

/* ---- cards ---- */
/* border stays transparent so per-card border-color accents (resume card,
   open library card) still render on top of the ring shadow */
.card{
  background:var(--card); border:1px solid transparent;
  box-shadow:var(--ring);
  border-radius:var(--r-lg); padding:16px; margin:12px 0;
}
.card.hero{
  background:linear-gradient(160deg,#132a26 0%, #121722 55%, #141a24 100%);
  box-shadow:var(--ring-strong);
}
.card h2:first-child{margin-top:0;}

/* ---- buttons ---- */
button{
  font-family:inherit; font-size:17px; font-weight:700; color:var(--txt);
  background:var(--card-2); border:1px solid var(--line); border-radius:var(--r-md);
  min-height:54px; padding:0 18px; cursor:pointer; touch-action:manipulation;
  transition-property:scale, filter;
  transition-duration:150ms;
  transition-timing-function:ease-out;
}
button:active{scale:.96;}
button.primary{
  background:linear-gradient(180deg,var(--accent) 0%, var(--accent-deep) 130%);
  border-color:transparent; color:var(--accent-ink);
  box-shadow:0 4px 18px rgba(45,212,191,.22);
}
button.good{
  background:linear-gradient(180deg,var(--good) 0%, #1f9e60 140%);
  border-color:transparent; color:var(--good-ink);
  box-shadow:0 4px 18px rgba(63,214,139,.2);
}
button.danger{background:transparent; border-color:rgba(255,96,96,.5); color:var(--bad);}
button.ghost{background:transparent;}
button.small{min-height:42px; font-size:14px; padding:0 14px; border-radius:var(--r-sm);}
button.block{width:100%;}
button:disabled{opacity:.35; pointer-events:none;}
.btnrow{display:flex; gap:10px; margin-top:10px;}
.btnrow button{flex:1;}

/* full-width toggle rows rendered as real <button>s for keyboard access */
button.rowbtn{
  display:flex; width:100%; background:none; border:none; padding:0;
  min-height:44px; text-align:left; font:inherit; color:inherit; border-radius:8px;
}
button.rowbtn:active{scale:1;}

/* ---- chips ---- */
.chips{display:flex; flex-wrap:wrap; gap:8px;}
button.chip{
  min-height:40px; font-size:14px; font-weight:600; padding:0 14px;
  border-radius:999px; background:var(--card-2); color:var(--dim);
}
button.chip.on{
  background:rgba(45,212,191,.14); border-color:var(--accent-deep); color:var(--accent);
}

/* ---- inputs ---- */
input[type=number],input[type=text],input[type=date],textarea,select{
  font-family:inherit; font-size:19px; font-weight:700; color:var(--txt);
  background:#0d1117; border:1px solid var(--line); border-radius:12px;
  padding:10px 12px; width:100%; min-height:50px; text-align:center;
}
textarea{text-align:left; font-weight:500; font-size:16px; min-height:74px; resize:vertical;}
input:focus,textarea:focus,select:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(45,212,191,.18);}
label.fld{display:block; margin:12px 0;}
label.fld span{display:block; color:var(--dim); font-size:12px; margin-bottom:5px; text-transform:uppercase; letter-spacing:.6px; font-weight:700;}
.fld-grid{display:grid; grid-template-columns:1fr 1fr; gap:0 12px;}

/* toggle switch */
.switch{position:relative; width:52px; height:32px; flex:none;}
.switch input{position:absolute; opacity:0; inset:0; margin:0; cursor:pointer;}
.switch i{
  position:absolute; inset:0; border-radius:999px; background:var(--card-2);
  border:1px solid var(--line); transition:background .15s;
}
.switch i::after{
  content:""; position:absolute; top:3px; left:3px; width:24px; height:24px;
  border-radius:50%; background:var(--dim); transition:transform .15s, background .15s;
}
.switch input:checked + i{background:var(--accent-deep); border-color:var(--accent-deep);}
.switch input:checked + i::after{transform:translateX(20px); background:#fff;}

/* ---- pills ---- */
.pill{
  display:inline-block; font-size:12px; font-weight:800; padding:4px 10px; border-radius:999px;
  background:var(--card-2); border:1px solid var(--line); color:var(--dim); letter-spacing:.5px;
}
.pill.area{background:#122a27; border-color:#1e4a43; color:#7ce4d4; font-weight:700;}
.pill.eq-roller{background:#241a3d; border-color:#4c3a80; color:var(--violet);}
.pill.eq-ball{background:#2d2010; border-color:#6b4d1d; color:#ffcf7c;}
.pill.eq-none{background:#122a27; border-color:#1e4a43; color:#7ce4d4;}

/* ---- stat tiles ---- */
.stats{display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:12px 0;}
.stat{
  background:var(--card); border:none; box-shadow:var(--ring); border-radius:var(--r-md);
  padding:12px 12px 10px; text-align:center;
}
.stat b{display:block; font-size:22px; letter-spacing:-.5px; font-variant-numeric:tabular-nums;}
.stat span{display:block; color:var(--faint); font-size:11px; text-transform:uppercase; letter-spacing:.8px; margin-top:3px; font-weight:700;}

/* ---- suggested list ---- */
.sugglist{font-size:13px; line-height:1.6;}

/* ---- lift-day preset cards ---- */
.liftcards{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:12px 0;}
button.liftcard{
  display:block; text-align:left; padding:14px; min-height:0;
  background:var(--card); border:none; box-shadow:var(--ring); border-radius:var(--r-md);
}
button.liftcard b{display:block; font-size:15px; color:var(--accent);}
button.liftcard span{display:block; color:var(--dim); font-size:12px; font-weight:500; line-height:1.45; margin-top:5px;}

.liftcards > :last-child:nth-child(odd){grid-column:1 / -1;}
.actcards{display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:4px 0 12px;}
button.actcard{
  padding:12px 6px; min-height:0; text-align:center;
  background:var(--card); border:none; box-shadow:var(--ring); border-radius:var(--r-md);
}
button.actcard i{display:block; font-style:normal; font-size:24px; line-height:1;}
button.actcard b{display:block; font-size:13px; margin-top:6px;}
button.actcard span{display:block; color:var(--faint); font-size:11px; font-weight:700; margin-top:2px;}

/* ---- progress bar ---- */
.progressbar{height:5px; background:var(--card-2); border-radius:999px; overflow:hidden; margin:10px 0 4px;}
.progressbar i{display:block; height:100%; background:linear-gradient(90deg,var(--accent),#7ce4d4); width:0; transition:width .25s ease; border-radius:999px;}
.progressbar.itembar{margin:2px 0 10px;}
.progressbar.itembar i{transition:width .2s linear;}

/* ============ PLAYER ============ */
.diagram{
  background:var(--card); border:none; box-shadow:var(--ring); border-radius:var(--r-lg);
  margin:12px 0 10px; padding:8px;
}
.diagram svg{display:block; width:100%; height:auto; max-height:44vh;}

.dg-fig{fill:none; stroke:var(--accent); stroke-width:6; stroke-linecap:round; stroke-linejoin:round;}
.dg-head{fill:var(--accent);}
.dg-roller{fill:#241a3d; stroke:var(--violet); stroke-width:2.5;}
.dg-ball{fill:var(--warn);}
.dg-wall{stroke:var(--line); stroke-width:5; stroke-linecap:round;}
.dg-floor{stroke:var(--line-soft); stroke-width:3; stroke-linecap:round;}
.dg-guide{fill:none; stroke:var(--dim); stroke-width:2; stroke-dasharray:4 5; stroke-linecap:round;}
.dg-missing{fill:var(--faint); font-size:13px;}

/* photo radius = container radius − padding (concentric); the outline is
   pure white at 10% — a tinted outline reads as dirt on the image edge */
.photo{outline:1px solid rgba(255,255,255,.1); outline-offset:-1px;}
.diagram .photo{display:block; width:100%; height:auto; max-height:44vh; object-fit:contain; border-radius:10px; background:#000;}
.photocredit{font-size:10px; color:var(--faint); text-align:right; padding:4px 4px 0;}
.dgfallback{display:none;}
.imgfail .photo, .imgfail .photocredit{display:none;}
.imgfail .dgfallback{display:block;}
.libdg .photo{display:block; width:100%; height:auto; border-radius:4px;}
.libdg .photocredit{padding:2px 2px 0; font-size:9px;}

.plname{font-size:21px; font-weight:800; letter-spacing:-.3px;}
#player.transition .plname{color:var(--dim);}

.timerwrap{display:flex; align-items:baseline; gap:14px; margin-top:6px;}
.staybtn{margin-left:auto; min-height:40px; color:var(--dim);}
#player.transition .staybtn{visibility:hidden;}
.bigtimer{font-size:clamp(44px,15vw,68px); font-weight:800; letter-spacing:-2px; line-height:1;}
#player.paused .bigtimer{color:var(--faint);}
#player.transition .bigtimer{color:var(--accent);}

.sidepill{
  display:none; font-size:12px; font-weight:800; padding:5px 12px; border-radius:999px;
  background:#122a27; border:1px solid #1e4a43; color:#7ce4d4;
  text-transform:uppercase; letter-spacing:.8px;
}
.sidepill.show{display:inline-block;}
.sidepill.two{background:#2d2010; border-color:#6b4d1d; color:#ffcf7c;}

.setup{margin-top:8px; color:var(--txt); font-weight:600;}
.cues{margin:10px 0 0; padding:0 0 0 2px; list-style:none;}
.cues li{
  color:var(--dim); font-size:15px; line-height:1.5; padding:5px 0 5px 22px; position:relative;
}
.cues li::before{
  content:""; position:absolute; left:2px; top:13px; width:8px; height:8px;
  border-radius:50%; background:var(--accent-deep);
}

.playctl{
  display:flex; gap:14px; align-items:center; justify-content:center; margin-top:18px;
}
.playctl button{width:64px; height:64px; min-height:0; padding:0; border-radius:50%;}
.playctl button svg{width:26px; height:26px; display:block; margin:0 auto;}
.playctl .playbtn{width:84px; height:84px; position:relative;}

/* play/pause cross-fade: both icons stay in the DOM and swap with
   opacity + scale + blur (interruptible), never a hard toggle */
.playctl .playbtn svg{
  width:36px; height:36px; position:absolute; top:50%; left:50%;
  translate:-50% -50%;
  transition-property:opacity, scale, filter;
  transition-duration:.3s;
  transition-timing-function:var(--ease-out-soft);
}
/* triangle's visual centre sits left of its box — nudge right */
.playbtn .ic-play{translate:calc(-50% + 2px) -50%; opacity:0; scale:.25; filter:blur(4px);}
.playbtn .ic-pause{opacity:1; scale:1; filter:blur(0);}
#player.paused .ic-play{opacity:1; scale:1; filter:blur(0);}
#player.paused .ic-pause{opacity:0; scale:.25; filter:blur(4px);}

/* ---- feedback scale ---- */
.fb-row{display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 0;}
.fb-name{font-weight:700; font-size:15px;}
.fb-scale{display:flex; gap:6px;}
button.fb{
  width:40px; height:40px; min-height:0; padding:0; border-radius:10px;
  font-size:15px; background:var(--card-2); color:var(--dim);
}
button.fb.on{background:rgba(45,212,191,.16); border-color:var(--accent-deep); color:var(--accent);}

/* ---- area board ---- */
.areaboard{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px;}
.areacell{
  border-radius:var(--r-sm); padding:10px 12px; border:1px solid var(--line-soft);
  background:var(--card-2);
}
.areacell b{display:block; font-size:14px;}
.areacell span{display:block; color:var(--faint); font-size:12px; margin-top:2px; font-weight:600;}
.areacell.fresh{background:#0e2c1c; border-color:#1e5e3c;}
.areacell.fresh span{color:var(--good);}
.areacell.warm{background:#2d2410; border-color:#6b571d;}
.areacell.warm span{color:var(--warn);}
.areacell.stale{background:#321616; border-color:#6e2a2a;}
.areacell.stale span{color:var(--bad);}

/* ---- library ---- */
.libcard{padding:12px; content-visibility:auto; contain-intrinsic-size:auto 110px;}
.libcard.off{opacity:.45;}
.libcard.open{opacity:1; border-color:var(--line);}
.libcard.off.open{opacity:.8;}
.libwhy{
  font-size:14px; line-height:1.5; color:#9fe0d5; background:rgba(45,212,191,.07);
  border:1px solid #1e4a43; border-radius:var(--r-sm); padding:10px 12px; margin-bottom:8px;
}
/* card 18px − card padding 12px = 6px (concentric) */
.libdg{width:104px; flex:none; background:var(--bg-elev); border-radius:6px; padding:2px;}
.libdg svg{display:block; width:100%; height:auto;}

/* ---- history ---- */
.histcard{padding:14px;}
.logitem{padding:9px 0; border-bottom:1px solid var(--line-soft);}
.logitem:last-child{border-bottom:none;}
.logitem .head{display:flex; justify-content:space-between; align-items:center; gap:8px;}

/* ---- chart ---- */
.chart{margin:8px 0 2px;}
.chart svg{display:block; width:100%; height:auto;}
.chart .bar{fill:var(--accent-deep); opacity:.75;}
.chart .bar.today{fill:var(--accent); opacity:1;}
.chart text{fill:var(--faint); font-size:9px; font-family:inherit; font-variant-numeric:tabular-nums;}

/* ---- screens / tab bar ---- */
/* Enter: don't animate the container — stagger its semantic chunks.
   (One-shot enters, so keyframes are the right tool here.) */
.screen{display:none;}
.screen.show{display:block;}
.screen.show > *{animation:riseIn .32s var(--ease-out-soft) both;}
.screen.show > *:nth-child(2){animation-delay:50ms;}
.screen.show > *:nth-child(3){animation-delay:100ms;}
.screen.show > *:nth-child(4){animation-delay:150ms;}
.screen.show > *:nth-child(5){animation-delay:190ms;}
.screen.show > *:nth-child(n+6){animation-delay:220ms;}
/* no filter here: WebKit can leave animated blur stuck at a stale frame
   on load, so enters animate opacity+transform only */
@keyframes riseIn{
  from{opacity:0; transform:translateY(10px);}
  to{opacity:1; transform:none;}
}
@keyframes fadein{from{opacity:0;} to{opacity:1;}}

/* Player item change: re-stagger the content that swapped */
#player.swap .diagram{animation:riseIn .3s var(--ease-out-soft) both;}
#player.swap .timerwrap{animation:riseIn .3s var(--ease-out-soft) 50ms both;}
#player.swap .setup{animation:riseIn .3s var(--ease-out-soft) 100ms both;}
#player.swap .cues{animation:riseIn .3s var(--ease-out-soft) 140ms both;}

#tabbar{
  position:fixed; left:0; right:0; bottom:0; z-index:40;
  background:rgba(13,17,23,.86); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px);
  border-top:1px solid var(--line-soft);
  padding-bottom:env(safe-area-inset-bottom);
}
#tabbar .inner{max-width:560px; margin:0 auto; display:flex; height:var(--tabbar-h);}
#tabbar button{
  flex:1; background:none; border:none; border-radius:0; min-height:0;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  color:var(--faint); font-size:10.5px; font-weight:700; letter-spacing:.5px; text-transform:uppercase;
}
#tabbar button svg{width:23px; height:23px; stroke:currentColor;}
#tabbar button.active{color:var(--accent);}
#tabbar button:active{scale:1;}   /* nav icons stay static — press scale would be distracting */
body.in-session #tabbar{display:none;}

/* ---- confirm sheet ---- */
.confirm{
  position:fixed; inset:0; z-index:55; display:none;
  background:rgba(6,8,11,.72); backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
  align-items:flex-end; justify-content:center; overscroll-behavior:contain;
  padding:20px 16px calc(env(safe-area-inset-bottom) + 24px);
}
.confirm.show{display:flex; animation:fadein .15s ease;}
.confirm.show .sheet{animation:sheetUp .28s var(--ease-out-soft) both;}
/* exit is softer and quicker than the enter */
.confirm.show.closing{animation:fadeout .15s ease-in both;}
.confirm.show.closing .sheet{animation:sheetDown .15s ease-in both;}
@keyframes sheetUp{from{opacity:0; transform:translateY(14px);} to{opacity:1; transform:none;}}
@keyframes sheetDown{to{opacity:0; transform:translateY(12px);}}
@keyframes fadeout{to{opacity:0;}}
.confirm .sheet{
  width:100%; max-width:420px;
  background:var(--card); border:none; box-shadow:var(--shadow), var(--ring-strong);
  border-radius:var(--r-lg);
  padding:20px 18px 16px;
}
.confirm .msg{font-size:16px; font-weight:600; line-height:1.5; text-wrap:pretty;}
.confirm .btnrow{margin-top:16px;}

/* ---- toast ---- */
.toast{
  position:fixed; bottom:calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  left:50%; transform:translateX(-50%) translateY(6px);
  background:#232d39; border:1px solid var(--line); color:var(--txt); padding:12px 20px;
  border-radius:12px; font-weight:600; z-index:60; opacity:0;
  transition:opacity .22s, transform .22s; pointer-events:none; box-shadow:var(--shadow);
  max-width:88vw; text-align:center;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}
.toast.tappable{pointer-events:auto; cursor:pointer;}

/* ---- misc ---- */
.note{font-size:14px; color:var(--dim); margin-top:6px; line-height:1.5; text-wrap:pretty;}
.cues li, .libwhy, .plname, .stat span{text-wrap:pretty;}
.divider{height:1px; background:var(--line-soft); margin:14px 0;}
