@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./fonts/chakra-400.woff2") format("woff2");
}
@font-face {
  font-family: "Chakra Petch";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("./fonts/chakra-600.woff2") format("woff2");
}
@font-face {
  font-family: "Orbitron";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./fonts/orbitron-700.woff2") format("woff2");
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #8a8a8a;
  --faint: #5a5a5a;
  --line: #222;
  --fill: #111;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --pad: clamp(14px, 4.2vw, 20px);
  --sans: "Chakra Petch", "Tahoma", "Segoe UI", sans-serif;
  --display: "Orbitron", "Chakra Petch", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 200ms;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: var(--app-height, 100%);
  min-height: -webkit-fill-available;
}
html { background: var(--bg); }

body {
  margin: 0;
  color: var(--fg);
  font-family: var(--sans);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { appearance: none; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
input, textarea { background: transparent; border: 0; outline: none; }

.app {
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  width: min(100%, 440px);
  height: var(--app-height, 100dvh);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.app.onboarding { grid-template-rows: minmax(0, 1fr); }

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-t)) max(var(--pad), var(--safe-r)) 10px max(var(--pad), var(--safe-l));
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-size: clamp(13px, 4vw, 16px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.brand .mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.top-meta {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.view {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--pad) max(var(--pad), var(--safe-r)) var(--pad) max(var(--pad), var(--safe-l));
}

.view-warmup,
.view-onboard {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
}

.view-body { width: 100%; }

.card {
  border: 1px solid var(--line);
  padding: clamp(14px, 4vw, 16px);
  width: 100%;
}

.card + .card, .stack > * + * { margin-top: 10px; }

.kicker {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.h1 {
  font-family: var(--display);
  font-size: clamp(22px, 6.4vw, 26px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 8px 0;
}

.h2 {
  font-family: var(--display);
  font-size: clamp(14px, 4.2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 6px;
}

.lede { color: var(--muted); line-height: 1.4; font-size: 14px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  padding: 12px;
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: clamp(18px, 5.5vw, 22px);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.stat span { color: var(--muted); font-size: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: 100%;
}
.btn.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
}
.btn.soft {
  background: var(--fill);
  color: var(--fg);
  border: 1px solid var(--line);
}
.btn.small { min-height: 36px; width: auto; padding: 0 12px; font-size: 12px; }
.btn.danger { background: transparent; color: var(--fg); border: 1px solid var(--fg); }

.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 0 max(var(--safe-r), 0px) var(--safe-b) max(var(--safe-l), 0px);
}

.nav button {
  min-height: 56px;
  color: var(--faint);
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.nav button svg { width: 18px; height: 18px; }
.nav button.active { color: var(--fg); }

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  padding: 3px 8px;
  font-family: var(--display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 0 0 auto;
}
.pill.good { border-color: var(--fg); color: var(--fg); }
.pill.warn, .pill.bad, .pill.neutral { color: var(--muted); }

.plan { margin-top: 10px; }
.plan strong {
  font-family: var(--display);
  font-size: clamp(16px, 5vw, 20px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }

.stepper {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  gap: 8px;
  align-items: center;
}
.stepper button {
  height: 56px;
  border: 1px solid var(--line);
  font-size: 24px;
  color: var(--fg);
}
.stepper .value { text-align: center; min-width: 0; }
.stepper .value b {
  display: block;
  font-family: var(--display);
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}
.stepper .value span { color: var(--muted); font-size: 12px; }

.sets { display: grid; gap: 8px; margin-top: 12px; }
.set-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 10px 12px;
}
.set-row em {
  font-style: normal;
  color: var(--muted);
  font-weight: 700;
}
.pr-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg);
  display: inline-block;
  margin-left: 6px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}
.tabs button {
  min-height: 40px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.tabs button.on { background: var(--fg); color: var(--bg); }

.overlay {
  position: fixed;
  top: var(--app-top, 0px);
  left: 0;
  right: 0;
  height: var(--app-height, 100dvh);
  z-index: 40;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vh, 28px);
  padding: max(20px, var(--safe-t)) max(20px, var(--safe-r)) max(20px, var(--safe-b)) max(20px, var(--safe-l));
}

.overlay-actions {
  width: min(320px, 100%);
}

.ring {
  width: min(70vw, 38dvh, 280px);
  aspect-ratio: 1;
  position: relative;
  margin-inline: auto;
  flex: 0 0 auto;
}
.overlay .ring {
  width: min(78vw, 46dvh, 300px);
  margin-top: 0;
}

.ring canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.ring-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.ring-inner b {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: clamp(28px, 11vw, 48px);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding-left: 0.04em;
  line-height: 1;
  white-space: nowrap;
}
.ring-inner span {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 1.15em);
  color: var(--muted);
  text-align: center;
}

.warmup-icon {
  width: clamp(56px, 16vw, 72px);
  height: clamp(56px, 16vw, 72px);
  margin: 10px auto 14px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.warmup-icon svg { width: 50%; height: 50%; stroke: var(--fg); fill: none; stroke-width: 1.6; }

.field { margin-top: 12px; }
.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 12px;
  font-size: 16px;
}
.field textarea { min-height: 88px; resize: vertical; }

.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.toggle:last-child { border-bottom: 0; }
.switch {
  width: 44px;
  height: 26px;
  border: 1px solid var(--fg);
  position: relative;
  flex: 0 0 auto;
}
.switch.on { background: var(--fg); }
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--fg);
}
.switch.on i { transform: translateX(18px); background: var(--bg); }

.chart-wrap { height: min(200px, 28dvh); margin-top: 8px; }
.chart-wrap canvas { width: 100%; height: 100%; }

.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 10px;
}
.heat i {
  aspect-ratio: 1;
  background: var(--fill);
  display: block;
}
.heat i.on { background: var(--fg); }
.heat i.mid { background: #555; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(12px + var(--safe-t));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--fg);
  color: var(--bg);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.hidden { display: none !important; }

.onboard {
  width: min(100%, 400px);
  margin: 0 auto;
  padding: 8px 0 12px;
}

.tiny { color: var(--faint); font-size: 12px; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }

.ios-steps {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.ios-steps li {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 14px;
}
.ios-steps b { color: var(--fg); width: 16px; }

@media (max-height: 700px) {
  .warmup-icon { margin: 6px auto 8px; }
  .h1 { margin: 4px 0; }
  .view-warmup .lede { font-size: 13px; }
  .ring { width: min(58vw, 30dvh, 220px); }
  .overlay .ring { width: min(70vw, 40dvh, 260px); }
}

@media (min-width: 441px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav button, .tabs button, .stepper button, .switch, .pill {
    transition:
      transform var(--t) var(--ease),
      background var(--t) var(--ease),
      color var(--t) var(--ease),
      border-color var(--t) var(--ease),
      opacity var(--t) var(--ease);
  }
  .btn:active, .stepper button:active, .nav button:active, .tabs button:active {
    transform: scale(0.97);
  }
  .switch i {
    transition: transform 180ms var(--ease), background 180ms var(--ease);
  }
  .view-body.enter {
    animation: rise 280ms var(--ease);
  }
  .overlay {
    animation: fade 220ms var(--ease);
  }
  .overlay.leave {
    animation: fade-out 160ms var(--ease) forwards;
  }
  .overlay .ring {
    animation: pop 320ms var(--ease);
  }
  .toast {
    animation: toast-in 240ms var(--ease);
  }
  .toast.leave {
    animation: toast-out 180ms var(--ease) forwards;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { opacity: 0.8; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translate(-50%, 0); }
  to { opacity: 0; transform: translate(-50%, -8px); }
}
