/* ================================================================
   WORKOUT — Track-Day Impeccable System
   Sharp, chamfered geometry · condensed italic display · 3D biomechanics
   ================================================================ */
:root {
  --c: 14px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.76, 0, .24, 1);
  --fd: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --fb: 'Barlow', system-ui, sans-serif;
  --accent: #FF5A1F;
  --on-accent: #0B0B0C;
  --rest: #5B8CFF;
  --hdr: 64px;
}

[data-theme="dark"] {
  --bg: #0B0B0C;
  --surface: #151517;
  --surface2: #1E1E21;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .17);
  --text: #F3F1EC;
  --muted: #9A9791;
  --faint: #5C5A56;
  --charge: .11;
  --scrim: rgba(0, 0, 0, .65);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F1EFEA;
  --surface: #FFFFFF;
  --surface2: #E6E3DD;
  --line: rgba(17, 17, 16, .09);
  --line2: rgba(17, 17, 16, .2);
  --text: #121211;
  --muted: #64615C;
  --faint: #A3A09A;
  --accent: #F2520F;
  --rest: #3F6FF0;
  --charge: .14;
  --scrim: rgba(20, 18, 15, .42);
  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 500 16px/1.45 var(--fb);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: hidden;
  caret-color: var(--accent);
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

body.in-session {
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--line2);
}

button, label.btn-line {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  opacity: .4;
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

svg.ic {
  width: 22px;
  height: 22px;
  flex: none;
  display: block;
}

.cut {
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}

.muted {
  color: var(--muted);
}

/* ---------------- Header: fixed, hides on scroll down ---------------- */
.hdr {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: calc(var(--hdr) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg);
  transition: transform .5s var(--ease), box-shadow .3s ease, background-color .35s var(--ease);
}

.hdr.scrolled {
  box-shadow: 0 1px 0 var(--line);
}

.hdr.hide {
  transform: translateY(-100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 800 1.5rem/1 var(--fd);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: block;
  flex: none;
  object-fit: contain;
}

.tabs {
  display: none;
  gap: 2px;
  margin-left: 8px;
}

.tab {
  position: relative;
  height: var(--hdr);
  padding: 0 14px;
  font: 700 1rem/1 var(--fd);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}

.tab:hover, .tab.on {
  color: var(--text);
}

.tab::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0) skewX(-20deg);
  transform-origin: left;
  transition: transform .45s var(--ease);
}

.tab.on::after {
  transform: scaleX(1) skewX(-20deg);
}

.hdr-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.streak {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 44px;
  font: 800 1.5rem/1 var(--fd);
  font-variant-numeric: tabular-nums;
}

.streak .ic {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: transform .3s var(--ease), color .2s;
}

.icon-btn:active {
  transform: scale(.9);
}

@media (min-width: 860px) {
  .tabs {
    display: flex;
  }
}

/* ---------------- Mobile tab bar: icons only ---------------- */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  box-shadow: 0 -1px 0 var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  transition: background-color .35s var(--ease);
}

.tb {
  height: 62px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color .25s;
}

.tb .ic {
  width: 25px;
  height: 25px;
  transition: transform .45s var(--ease);
}

.tb.on {
  color: var(--accent);
}

.tb.on .ic {
  transform: translateY(-1px) scale(1.06);
}

.tb:active .ic {
  transform: scale(.86);
}

@media (min-width: 860px) {
  .tabbar {
    display: none;
  }
}

/* ---------------- Views ---------------- */
main {
  max-width: 1160px;
  margin: 0 auto;
  padding: calc(var(--hdr) + env(safe-area-inset-top) + 8px) max(20px, env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

@media (min-width: 860px) {
  main {
    padding-left: 40px;
    padding-right: 40px;
    padding-bottom: 80px;
  }
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn .55s var(--ease);
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.view-h {
  font: 800 italic clamp(3rem, 12vw, 5.5rem)/.84 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.01em;
  margin: 20px 0 28px;
}

.sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font: 700 1rem/1 var(--fd);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.sec-h span {
  letter-spacing: .04em;
  font-weight: 600;
}

/* ---------------- Today ---------------- */
.today {
  display: grid;
  gap: 30px;
  padding-top: 12px;
}

@media (min-width: 860px) {
  .today {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 72px;
    padding-top: 48px;
    align-items: start;
  }
  .today-side {
    position: sticky;
    top: calc(var(--hdr) + 32px);
  }
}

.today-main {
  display: grid;
  gap: 18px;
  align-content: start;
}

.t-title {
  font: 800 italic clamp(3.4rem, 15vw, 6rem)/.82 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.015em;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.t-title em {
  font-style: italic;
  font-size: .4em;
  line-height: 1;
  color: var(--accent);
  letter-spacing: .02em;
  padding-bottom: .18em;
}

.start {
  --c: 24px;
  position: relative;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
  min-height: clamp(150px, 25vh, 200px);
  padding: 20px 20px 18px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  column-gap: 16px;
  background: var(--accent);
  color: var(--on-accent);
  text-align: left;
  transition: transform .55s var(--ease);
}

.start::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -20%;
  bottom: -20%;
  left: -30%;
  width: 22%;
  background: rgba(255, 255, 255, .26);
  transform: skewX(-22deg);
  animation: sweep 5s var(--ease) 1.4s infinite;
}

@keyframes sweep {
  0% { transform: translateX(0) skewX(-22deg); }
  35%, 100% { transform: translateX(720%) skewX(-22deg); }
}

.start-word {
  grid-column: 1;
  grid-row: 1;
  align-self: end;
  font: 800 italic clamp(3.8rem, 17vw, 6rem)/.78 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.01em;
}

.start-meta {
  grid-column: 1;
  grid-row: 2;
  margin-top: 12px;
  font: 600 .95rem/1 var(--fb);
  opacity: .72;
}

.start-go {
  grid-column: 2;
  grid-row: 1/3;
  align-self: end;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--on-accent);
  color: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 28% 100%, 0 72%);
  transition: transform .5s var(--ease);
}

.start-go .ic {
  width: 30px;
  height: 30px;
}

.start:hover .start-go {
  transform: translateX(5px);
}

.start:active {
  transform: scale(.982);
}

.mods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mod {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 16px;
  background: var(--surface);
  font: 700 1.05rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background-color .2s, transform .35s var(--ease);
}

.mod .ic {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.mod em {
  margin-left: auto;
  font: 500 .85rem/1 var(--fb);
  font-style: normal;
  color: var(--muted);
  letter-spacing: 0;
  text-transform: none;
}

.mod:hover {
  background: var(--surface2);
}

.mod:active {
  transform: scale(.97);
}

.state-card {
  --c: 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  align-items: center;
  padding: 26px 24px;
  background: var(--surface);
}

.state-card .big {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  grid-row: 1/3;
}

.state-card .big .ic {
  width: 44px;
  height: 44px;
}

.state-card.done .big {
  background: var(--accent);
  color: var(--on-accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 28% 100%, 0 72%);
}

.state-card.rest .big {
  color: var(--rest);
}

.state-card b {
  font: 800 italic 2.6rem/.9 var(--fd);
  text-transform: uppercase;
}

.state-card p {
  color: var(--muted);
  font-size: .95rem;
}

.state-card .acts {
  grid-column: 1/-1;
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.banner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  padding: 18px;
  background: var(--surface);
  animation: viewIn .6s var(--ease);
}

.banner > .ic {
  color: var(--accent);
  width: 24px;
  height: 24px;
  margin-top: 2px;
  grid-row: 1/3;
}

.banner b {
  font: 800 1.3rem/1.05 var(--fd);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.banner p {
  color: var(--muted);
  font-size: .92rem;
}

.banner .acts {
  grid-column: 2;
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.btn-mini {
  height: 40px;
  padding: 0 16px;
  font: 700 .95rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--surface2);
  transition: transform .3s var(--ease);
}

.btn-mini.acc {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-mini:active {
  transform: scale(.95);
}

.lineup {
  list-style: none;
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  animation: rowIn .7s var(--ease) forwards;
  animation-delay: calc(var(--i) * 70ms + 140ms);
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}

.row-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  background: var(--surface2);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  color: var(--accent);
}

.row-icon .ic {
  width: 24px;
  height: 24px;
}

.row-name {
  font: 700 1.45rem/1 var(--fd);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.row-dose {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font: 800 1.9rem/1 var(--fd);
  font-variant-numeric: tabular-nums;
}

.row-dose i {
  font-style: normal;
  font-size: 1.05rem;
  color: var(--accent);
}

.row-dose small {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 700;
}

.row.done .row-name, .row.done .row-dose {
  color: var(--muted);
}

.row.done .row-icon {
  background: var(--accent);
  color: var(--on-accent);
}

/* ================================================================
   SESSION — full-screen flow: 3D Stage → Rest → Finish
   ================================================================ */
.session {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  transition: opacity .3s ease, visibility 0s linear .3s;
}

.session.open {
  visibility: visible;
  opacity: 1;
  transition: opacity .3s ease;
}

.s-bar {
  flex: none;
  height: calc(62px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 2;
}

.segs {
  flex: 1;
  display: flex;
  gap: 4px;
  height: 8px;
}

.seg {
  flex: 1;
  background: var(--line2);
  transform: skewX(-24deg);
  transition: background-color .5s var(--ease);
}

.seg.done {
  background: var(--accent);
}

.seg.cur {
  background: var(--text);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: .35; }
}

.s-count {
  min-width: 44px;
  text-align: right;
  font: 700 1.05rem/1 var(--fd);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-right: 6px;
}

.panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  position: relative;
}

.panel.show {
  display: flex;
}

/* ---------------- 3D WORKOUT STAGE ---------------- */
.stage {
  --c: 24px;
  flex: 1;
  min-height: 240px;
  background: var(--surface);
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, var(--c) 100%, 0 calc(100% - var(--c)));
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.stage-canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* 3D Overlays: Live Form Cue, Muscle Badges, Controls */
.stage-top {
  position: absolute;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.cue-box {
  background: rgba(11, 11, 12, 0.84);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line2);
  padding: 8px 14px;
  max-width: 75%;
  pointer-events: auto;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.cue-label {
  font: 700 .75rem/1 var(--fd);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}

.cue-text {
  font: 600 .92rem/1.25 var(--fb);
  color: #FFFFFF;
}

.stage-controls {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.stage-btn {
  height: 34px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(11, 11, 12, 0.84);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line2);
  font: 700 .85rem/1 var(--fd);
  text-transform: uppercase;
  color: #FFFFFF;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  transition: background-color .2s;
}

.stage-btn:hover {
  background: var(--surface2);
}

.stage-btn .ic {
  width: 16px;
  height: 16px;
}

.stage-bottom {
  position: absolute;
  bottom: 12px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.muscles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.muscle-tag {
  font: 700 .75rem/1 var(--fd);
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(255, 90, 31, 0.16);
  color: var(--accent);
  border: 1px solid rgba(255, 90, 31, 0.35);
  padding: 4px 8px;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.hint-3d {
  font: 600 .8rem/1 var(--fd);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .7;
}

/* Workout Metrics Bar below 3D Stage */
.w-info {
  padding-top: 20px;
}

.w-info.enter {
  animation: infoIn .7s var(--ease);
}

@keyframes infoIn {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: none; }
}

.w-name {
  font: 800 italic clamp(2.7rem, 11.5vw, 4.8rem)/.86 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.01em;
}

.w-dose {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-top: 10px;
}

.w-num {
  font: 800 clamp(4.8rem, 25vw, 6rem)/.8 var(--fd);
  font-variant-numeric: tabular-nums;
  min-width: 1.1em;
  transition: color .2s;
}

.w-num.lead {
  color: var(--accent);
}

.w-num.bump {
  animation: bump .35s var(--ease);
}

@keyframes bump {
  40% { transform: translateY(-4px) scale(1.04); }
}

.w-unit {
  font: 700 1.25rem/1 var(--fd);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px 6px;
}

.w-set {
  margin-left: auto;
  align-self: flex-end;
  margin-bottom: 8px;
  font: 700 1.05rem/1 var(--fd);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.nudges {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 4px 2px;
}

.nudge {
  width: 34px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: color .2s, transform .25s var(--ease);
}

.nudge .ic {
  width: 18px;
  height: 18px;
}

.nudge:hover {
  color: var(--text);
}

.nudge:active {
  transform: scale(.85);
}

.hold-bar {
  height: 6px;
  background: var(--line2);
  margin-top: 16px;
  display: none;
  overflow: hidden;
}

.hold-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(1);
  transition: transform .12s linear;
}

.w-actions {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 8px;
  margin-top: 20px;
}

.btn-primary {
  --c: 16px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: 800 italic 1.85rem/1 var(--fd);
  letter-spacing: .03em;
  text-transform: uppercase;
  transition: transform .4s var(--ease), filter .2s;
}

.btn-primary .ic {
  width: 26px;
  height: 26px;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-primary:active {
  transform: scale(.97);
}

.sq {
  height: 70px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  transition: transform .3s var(--ease), color .2s;
}

.sq:active {
  transform: scale(.94);
}

.sq.has-note {
  color: var(--accent);
}

@media (min-width: 860px) {
  .panel {
    padding: 12px 48px 48px;
  }
  #sWork.show {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    grid-template-rows: 1fr auto auto 1fr;
    column-gap: 64px;
  }
  #sWork .stage {
    grid-row: 1/-1;
    min-height: 480px;
  }
  #sWork .w-info {
    grid-row: 2;
    padding-top: 0;
  }
  #sWork .w-actions {
    grid-row: 3;
    margin-top: 32px;
  }
}

/* ---------------- Rest — Recharge Chamber ---------------- */
#sRest {
  align-items: center;
  overflow: hidden;
}

.charge {
  position: absolute;
  inset: -62px 0 0 0;
  background: var(--accent);
  opacity: var(--charge);
  transform-origin: bottom;
  transform: scaleY(0);
  transition: transform .25s linear;
  pointer-events: none;
}

.charge::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
  opacity: .9;
}

.ring-wrap {
  position: relative;
  width: min(78vw, 40vh, 380px);
  aspect-ratio: 1;
  margin: auto 0 0;
  flex: none;
}

#ring {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tick {
  stroke: var(--line2);
  stroke-width: 3.2;
  transition: stroke .35s ease;
}

.tick.on {
  stroke: var(--accent);
}

.tick.head {
  stroke: var(--text);
  stroke-width: 5;
}

.breath {
  fill: none;
  stroke: var(--line2);
  stroke-width: 1.5;
  transform-origin: 150px 150px;
  animation: breathe 8s ease-in-out infinite;
}

.breath2 {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  opacity: .35;
  transform-origin: 150px 150px;
  animation: breathe 8s ease-in-out infinite reverse;
}

@keyframes breathe {
  0%, 100% { transform: scale(.82) rotate(0deg); }
  50% { transform: scale(1) rotate(22.5deg); }
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.r-num {
  font: 800 6rem/.82 var(--fd);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.r-breath {
  margin-top: 10px;
  font: 700 .95rem/1 var(--fd);
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity .5s ease;
}

#sRest.final .r-num {
  color: var(--accent);
  animation: thump 1s var(--ease) infinite;
}

@keyframes thump {
  0% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.rest-low {
  width: 100%;
  max-width: 560px;
  display: grid;
  gap: 8px;
  margin-top: auto;
  position: relative;
  z-index: 1;
}

.rate {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
}

.rate-q {
  font: 600 .95rem/1.2 var(--fb);
  color: var(--muted);
}

.rate-q b {
  color: var(--text);
  font-weight: 700;
}

.seg3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.seg3 button {
  height: 44px;
  background: var(--surface2);
  color: var(--muted);
  font: 700 1rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background-color .2s, color .2s, transform .3s var(--ease);
}

.seg3 button.on {
  background: var(--text);
  color: var(--bg);
}

.seg3 button[data-v="hard"].on {
  background: var(--accent);
  color: var(--on-accent);
}

.seg3 button:active {
  transform: scale(.95);
}

.next {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
}

.next-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: var(--surface2);
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  color: var(--accent);
}

.next-icon .ic {
  width: 24px;
  height: 24px;
}

.next-name {
  font: 700 1.35rem/1 var(--fd);
  text-transform: uppercase;
  letter-spacing: .02em;
}

.next-name span {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .06em;
}

.next-dose {
  font: 800 1.8rem/1 var(--fd);
  font-variant-numeric: tabular-nums;
}

.next-dose small {
  font-size: .95rem;
  color: var(--muted);
}

.r-actions {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
}

.btn-skip {
  --c: 16px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--text);
  color: var(--bg);
  font: 800 italic 1.6rem/1 var(--fd);
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: transform .4s var(--ease);
}

.btn-skip:active {
  transform: scale(.97);
}

.plus15 {
  height: 66px;
  background: var(--surface);
  font: 800 1.4rem/1 var(--fd);
  font-variant-numeric: tabular-nums;
  transition: transform .3s var(--ease);
}

.plus15:active {
  transform: scale(.94);
}

/* ---------------- Finish ---------------- */
#sFinish {
  justify-content: center;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.fin-word {
  font: 800 italic clamp(4.8rem, 26vw, 6rem)/.8 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.02em;
  animation: finIn .9s var(--ease);
}

.fin-word i {
  font-style: normal;
  color: var(--accent);
}

@keyframes finIn {
  from { opacity: 0; transform: translateY(30px) skewX(-8deg); }
  to { opacity: 1; transform: none; }
}

.fin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 30px 0 24px;
}

.fin-stats div {
  padding: 16px 0;
  display: grid;
  gap: 4px;
}

.fin-stats div + div {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.fin-stats b {
  font: 800 2.5rem/1 var(--fd);
  font-variant-numeric: tabular-nums;
}

.fin-stats span {
  font-size: .85rem;
  color: var(--muted);
}

.feel {
  display: grid;
  gap: 2px;
}

.feel-row {
  display: grid;
  grid-template-columns: 1fr minmax(0, 230px);
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.feel-row span {
  font: 700 1.15rem/1 var(--fd);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.fin-actions {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 8px;
  margin-top: 26px;
}

/* ---------------- Wipe transition ---------------- */
.wipe {
  position: fixed;
  inset: -10% -40%;
  z-index: 120;
  background: var(--accent);
  transform: translateX(-130%) skewX(-16deg);
  pointer-events: none;
}

.wipe::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 100%;
  width: 9%;
  background: var(--text);
  opacity: .9;
}

.wipe.go {
  animation: wipe .74s var(--ease-io) forwards;
}

@keyframes wipe {
  0% { transform: translateX(-130%) skewX(-16deg); }
  48%, 52% { transform: translateX(0) skewX(-16deg); }
  100% { transform: translateX(130%) skewX(-16deg); }
}

/* ---------------- Sheet Drawer ---------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s var(--ease);
}

.sheet.open {
  opacity: 1;
  pointer-events: auto;
}

.sheet-inner {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  clip-path: polygon(0 20px, 20px 0, 100% 0, 100% 100%, 0 100%);
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .45s var(--ease);
}

.sheet.open .sheet-inner {
  transform: translateY(0);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.sheet-head h3 {
  font: 800 italic 2.2rem/1 var(--fd);
  text-transform: uppercase;
  letter-spacing: -.01em;
}

.field {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--surface2);
  border: 1px solid var(--line);
  font: 600 1rem/1 var(--fb);
  color: var(--text);
  margin-bottom: 12px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

textarea.field {
  height: 120px;
  padding: 14px 16px;
  resize: vertical;
}

.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.btn-line {
  height: 50px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface2);
  font: 700 1rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.btn-line.danger {
  color: #FF4D4D;
}

.fgroup {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.flabel {
  font: 700 .9rem/1 var(--fd);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.segctl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
}

.segctl button {
  height: 44px;
  background: var(--surface2);
  color: var(--muted);
  font: 700 1rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background-color .2s, color .2s;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.segctl button.on {
  background: var(--text);
  color: var(--bg);
}

.hint {
  font-size: .88rem;
  color: var(--muted);
  margin-top: 6px;
}

.btns {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ---------------- History & Calendar ---------------- */
.hist {
  display: grid;
  gap: 24px;
}

.streaks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.streaks div {
  padding: 20px;
  background: var(--surface);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.streaks b {
  display: block;
  font: 800 italic 3.2rem/1 var(--fd);
  margin-bottom: 4px;
}

.streaks b.acc {
  color: var(--accent);
}

.streaks span {
  font: 700 .9rem/1 var(--fd);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.cal {
  background: var(--surface);
  padding: 22px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cal-head h2 {
  font: 800 italic 1.8rem/1 var(--fd);
  text-transform: uppercase;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.wd {
  text-align: center;
  font: 700 .85rem/1 var(--fd);
  color: var(--muted);
  padding: 6px 0 10px;
}

.day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font: 700 1rem/1 var(--fd);
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid transparent;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
  transition: transform .2s;
}

.day.blank {
  background: none;
}

.day.today {
  border-color: var(--accent);
  color: var(--text);
}

.day.full {
  background: var(--accent);
  color: var(--on-accent);
}

.day.short {
  background: color-mix(in srgb, var(--accent) 36%, var(--surface));
  color: var(--text);
}

.day.rest {
  background: var(--rest);
  color: #FFFFFF;
}

.day:not(.blank):not(.future):active {
  transform: scale(.92);
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font: 600 .85rem/1 var(--fb);
  color: var(--muted);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  display: block;
}

/* ---------------- Progress Charts ---------------- */
.prog {
  display: grid;
  gap: 32px;
}

@media (min-width: 860px) {
  .prog {
    grid-template-columns: 340px 1fr;
    gap: 48px;
  }
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 14px 0 10px;
}

.wk {
  display: grid;
  gap: 6px;
  text-align: center;
}

.wk i {
  aspect-ratio: 1;
  background: var(--surface2);
  display: block;
  clip-path: polygon(4px 0, 100% 0, 100% calc(100% - 4px), calc(100% - 4px) 100%, 0 100%, 0 4px);
}

.wk i.full {
  background: var(--accent);
}
.wk i.short {
  background: color-mix(in srgb, var(--accent) 36%, var(--surface));
}
.wk i.rest {
  background: var(--rest);
}

.wk.today i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wk span {
  font: 700 .8rem/1 var(--fd);
  color: var(--muted);
}

.week-sum {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: .9rem;
  color: var(--muted);
}

.week-sum b {
  color: var(--text);
  margin-right: 4px;
}

.ms {
  list-style: none;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.ms li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: .92rem;
}

.ms time {
  font: 700 .85rem/1 var(--fd);
  color: var(--muted);
}

.ms em {
  font-style: normal;
  font-size: .75rem;
  background: var(--surface2);
  padding: 2px 6px;
  margin-left: 8px;
  color: var(--accent);
}

.ex-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.ex-tab {
  height: 42px;
  padding: 0 16px;
  background: var(--surface);
  font: 700 .95rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

.ex-tab.on {
  background: var(--accent);
  color: var(--on-accent);
}

.chart {
  width: 100%;
  height: auto;
  background: var(--surface);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  padding: 20px;
}

.chart line.grid {
  stroke: var(--line);
  stroke-dasharray: 4;
}

.chart text {
  fill: var(--muted);
  font: 600 11px var(--fb);
}

.chart path.area {
  fill: url(#areaGrad);
}

.chart path.ln {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart rect.pt {
  fill: var(--text);
}

.chart text.val {
  fill: var(--accent);
  font: 800 16px var(--fd);
}

/* ---------------- Coach Tab ---------------- */
.lede {
  color: var(--muted);
  font-size: 1.05rem;
  margin: -16px 0 24px;
}

.coach {
  display: grid;
  gap: 32px;
}

@media (min-width: 860px) {
  .coach {
    grid-template-columns: 1.2fr 1fr;
    gap: 56px;
  }
}

.coach-cta {
  width: 100%;
  margin-bottom: 24px;
}

.summary {
  font: 700 1.25rem/1.35 var(--fd);
  letter-spacing: .02em;
  text-transform: uppercase;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
}

.sugg {
  padding: 18px;
  background: var(--surface);
  margin-bottom: 12px;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  animation: viewIn .5s var(--ease);
}

.sugg.done {
  opacity: .5;
}

.sugg-change {
  font: 800 1.45rem/1 var(--fd);
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.sugg-change i {
  font-style: normal;
  color: var(--accent);
}

.sugg-change small {
  color: var(--muted);
  font-size: .95rem;
}

.sugg p {
  color: var(--muted);
  font-size: .92rem;
  margin-bottom: 14px;
}

.sugg .status {
  font: 700 .85rem/1 var(--fd);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.notes {
  list-style: none;
  border-top: 1px solid var(--line);
}

.notes li {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  font-size: .92rem;
}

.notes time {
  font: 700 .85rem/1 var(--fd);
  color: var(--accent);
}

.loading {
  display: flex;
  gap: 6px;
  padding: 20px 0;
}

.loading i {
  width: 8px;
  height: 24px;
  background: var(--accent);
  display: block;
  animation: load 1s ease-in-out infinite;
}

.loading i:nth-child(2) { animation-delay: .15s; }
.loading i:nth-child(3) { animation-delay: .3s; }
.loading i:nth-child(4) { animation-delay: .45s; }

@keyframes load {
  0%, 100% { transform: scaleY(.3); opacity: .4; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ---------------- Toast Notification ---------------- */
.toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 150;
  padding: 12px 20px;
  background: var(--text);
  color: var(--bg);
  font: 700 .95rem/1 var(--fd);
  letter-spacing: .06em;
  text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
