:root {
  --ink: #101211;
  --surface: #171a18;
  --surface-2: #202421;
  --line: rgba(255,255,255,.13);
  --muted: rgba(255,255,255,.56);
  --acid: #d9ff43;
  --teal: #084550;
  --serif: "Instrument Serif", Georgia, serif;
  --bold: "Montserrat", Arial, sans-serif;
  --safe-top: max(1rem, env(safe-area-inset-top));
  --safe-bottom: max(1rem, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html { background: var(--ink); color-scheme: dark; }

body {
  margin: 0;
  background: var(--ink);
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
}

button, input { color: inherit; font: inherit; }
button { cursor: pointer; }
button, fieldset { border: 0; }

.app-shell {
  width: min(100%, 34rem);
  min-height: 100svh;
  margin: 0 auto;
  background: var(--ink);
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--safe-top) 1.15rem .8rem;
  background: rgba(16,18,17,.86);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.kett-logo {
  color: var(--acid);
  font-family: var(--bold);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -.1em;
  text-decoration: none;
}

.icon-button {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
}

.icon-button svg {
  width: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.view {
  min-height: calc(100svh - 4.5rem);
  padding: 1.4rem 1.15rem calc(2rem + var(--safe-bottom));
}

.view[hidden] { display: none; }

.kicker,
.text-button,
.safety-note {
  font-family: var(--bold);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.kicker { margin: 0; color: var(--muted); }

.intro h1,
.preview-heading h2,
.view-complete h2 {
  margin: 2.2rem 0 1.25rem;
  font-size: clamp(4.35rem, 22vw, 7rem);
  font-weight: 400;
  letter-spacing: -.065em;
  line-height: .76;
}

.intro h1 em,
.preview-heading h2 em,
.view-complete h2 em {
  color: var(--acid);
  font-family: var(--bold);
  font-size: .62em;
  font-style: normal;
  font-weight: 800;
  letter-spacing: -.075em;
  text-transform: uppercase;
}

.intro-copy {
  max-width: 23rem;
  margin: 0 0 3.2rem;
  color: var(--muted);
  font-size: 1.3rem;
}

.setup-form { display: grid; gap: 2.9rem; }

.control-group { min-width: 0; margin: 0; padding: 0; }

.control-group legend {
  width: 100%;
  margin-bottom: 1rem;
  font-family: var(--bold);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.control-group legend span { margin-right: .8rem; color: var(--acid); }

.choice-grid { display: grid; gap: .5rem; }
.choice-grid-4 { grid-template-columns: repeat(4, 1fr); }
.choice-grid-3 { grid-template-columns: repeat(3, 1fr); }
.choice-grid-2 { grid-template-columns: repeat(2, 1fr); }

.choice-grid label,
.choice-stack label { position: relative; display: block; }

.choice-grid input,
.choice-stack input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice-grid label > span {
  display: flex;
  min-height: 4.25rem;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--bold);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
  transition: 180ms ease;
}

.choice-grid-4 label > span { font-size: 1.05rem; }
.choice-grid label small { margin-left: .2rem; color: var(--muted); font-size: .55rem; }

.choice-grid input:checked + span,
.choice-stack input:checked + span {
  border-color: var(--acid);
  background: var(--acid);
  color: var(--ink);
}

.choice-grid input:checked + span small { color: var(--ink); }

.choice-grid input:focus-visible + span,
.choice-stack input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }

.choice-stack { display: grid; border-top: 1px solid var(--line); }

.choice-stack label > span {
  position: relative;
  display: flex;
  min-height: 4.7rem;
  flex-direction: column;
  justify-content: center;
  padding: .8rem 2.8rem .8rem .9rem;
  border-bottom: 1px solid var(--line);
  transition: 180ms ease;
}

.choice-stack label > span::after {
  position: absolute;
  right: .9rem;
  content: "○";
  font-family: var(--bold);
}

.choice-stack input:checked + span::after { content: "●"; }
.choice-stack b { font-family: var(--bold); font-size: .8rem; text-transform: uppercase; }
.choice-stack small { margin-top: .22rem; color: var(--muted); font-size: .92rem; }
.choice-stack input:checked + span small { color: rgba(16,18,17,.65); }

.control-row .choice-grid { margin-bottom: .7rem; }

.weight-field {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--bold);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.weight-field input {
  width: 3.2rem;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: right;
}
.weight-field b { color: var(--muted); }

.primary-button,
.secondary-button {
  display: flex;
  width: 100%;
  min-height: 4.2rem;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  border-radius: 12px;
  font-family: var(--bold);
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-button { background: var(--acid); color: var(--ink); }
.primary-button b { font-size: 1.2rem; }
.secondary-button { justify-content: center; border: 1px solid var(--line); background: transparent; }

.safety-note { margin: 2rem 0 0; color: rgba(255,255,255,.35); line-height: 1.5; }

.last-workout {
  width: 100%;
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--teal);
  text-align: left;
}

.last-workout span { display: flex; flex-direction: column; gap: .3rem; }
.last-workout small, .last-workout strong { font-family: var(--bold); font-size: .58rem; text-transform: uppercase; }
.last-workout b { font-size: 1.25rem; font-weight: 400; }

.text-button { padding: .4rem 0; background: transparent; color: var(--muted); }

.preview-heading h2 { margin-top: 2.2rem; }

.workout-stats,
.completion-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 2.4rem 0 3rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.workout-stats span,
.completion-stats span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: .35rem;
  padding: 1rem .7rem;
  border-right: 1px solid var(--line);
}
.workout-stats span:first-child, .completion-stats span:first-child { padding-left: 0; }
.workout-stats span:last-child, .completion-stats span:last-child { border-right: 0; }
.workout-stats small, .completion-stats small { color: var(--muted); font-family: var(--bold); font-size: .55rem; font-weight: 700; text-transform: uppercase; }
.workout-stats b, .completion-stats b { overflow: hidden; font-size: 1.25rem; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }

.exercise-list { margin: 0; padding: 0; list-style: none; counter-reset: exercise; }

.exercise-item {
  counter-increment: exercise;
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  gap: .8rem;
  align-items: center;
  min-height: 5.7rem;
  border-top: 1px solid var(--line);
}
.exercise-item:last-child { border-bottom: 1px solid var(--line); }
.exercise-item::before { content: counter(exercise, decimal-leading-zero); color: var(--acid); font-family: var(--bold); font-size: .58rem; font-weight: 700; }
.exercise-item span { display: flex; min-width: 0; flex-direction: column; gap: .3rem; }
.exercise-item h3 { overflow: hidden; margin: 0; font-family: var(--bold); font-size: .84rem; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.exercise-item p { margin: 0; color: var(--muted); font-size: .95rem; }
.exercise-item button { padding: .6rem; background: transparent; color: var(--muted); font-family: var(--bold); font-size: .58rem; font-weight: 700; text-transform: uppercase; }

.preview-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: .7rem; margin-top: 2rem; }

.view-player { display: flex; min-height: calc(100svh - 4.5rem); flex-direction: column; }
.view-player[hidden] { display: none; }

.player-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--bold);
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.progress-track { height: 2px; margin-top: 1rem; overflow: hidden; background: var(--line); }
.progress-track i { display: block; width: 0; height: 100%; background: var(--acid); transition: width 300ms ease; }

.player-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 0;
  text-align: center;
}

.phase-label { margin: 0 0 1.5rem; color: var(--acid); font-family: var(--bold); font-size: .65rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }

.timer-ring { position: relative; display: grid; width: min(58vw, 16rem); aspect-ratio: 1; place-items: center; }
.timer-ring svg { position: absolute; width: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 2.5; }
.ring-bg { stroke: var(--line); }
.ring-progress { stroke: var(--acid); stroke-linecap: round; stroke-dasharray: 634.6; stroke-dashoffset: 0; transition: stroke-dashoffset 250ms linear; }
.timer-ring strong { font-family: var(--bold); font-size: clamp(3rem, 15vw, 5rem); font-weight: 700; letter-spacing: -.07em; }

.player-main h2 { max-width: 12ch; margin: 1.8rem 0 .65rem; font-family: var(--bold); font-size: clamp(1.6rem, 8vw, 2.5rem); font-weight: 800; letter-spacing: -.05em; line-height: .95; text-transform: uppercase; }
.player-main > p:last-child { max-width: 24rem; margin: 0; color: var(--muted); font-size: 1.05rem; }

.next-up { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.next-up span { display: flex; flex-direction: column; gap: .2rem; }
.next-up span:last-child { text-align: right; }
.next-up small { color: var(--muted); font-family: var(--bold); font-size: .52rem; font-weight: 700; text-transform: uppercase; }
.next-up b { font-size: 1rem; font-weight: 400; }

.player-controls { display: grid; grid-template-columns: 3.6rem 1fr 3.6rem; gap: .75rem; padding-top: 1rem; }
.round-button, .pause-button { min-height: 3.6rem; border-radius: 50%; background: var(--surface-2); font-family: var(--bold); font-weight: 800; }
.pause-button { border-radius: 10rem; background: var(--acid); color: var(--ink); font-size: .7rem; text-transform: uppercase; }

.view-complete { display: flex; flex-direction: column; justify-content: center; }
.complete-mark { display: grid; width: 4rem; height: 4rem; margin-bottom: 2rem; place-items: center; border-radius: 50%; background: var(--acid); color: var(--ink); font-family: var(--bold); font-size: 1.5rem; font-weight: 800; }
.view-complete h2 { margin-top: 2rem; }
.view-complete .primary-button { margin-top: 1rem; }

@media (min-width: 700px) {
  body { padding: 2rem 0; background: #090a09; }
  .app-shell { min-height: calc(100svh - 4rem); border: 1px solid var(--line); border-radius: 24px; overflow: clip; box-shadow: 0 2rem 7rem rgba(0,0,0,.45); }
  .app-header { position: relative; }
  .view { min-height: calc(100svh - 8.5rem); padding-right: 1.5rem; padding-left: 1.5rem; }
  .view-player { min-height: calc(100svh - 8.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
