/* ============================================================
   Kinetic — design tokens
   Modern, minimal, dark. One accent. Type-led.
   ============================================================ */
:root {
  --bg: #0b0d10;
  --bg-elev: #14171c;
  --bg-elev-2: #1b1f26;
  --line: #252a33;
  --ink: #f5f7fa;
  --ink-dim: #a3acb9;
  --ink-mute: #6b7380;
  --accent: #7cf1c9;      /* mint — fresh, "motion" feel */
  --accent-ink: #05201a;
  --warn: #ffb86b;
  --bad: #ff6b7b;
  --good: #7cf1c9;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
          "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

/* ---------- views ---------- */
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  animation: fade .18s ease-out;
}
.view[hidden] { display: none; }

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

.view-header {
  padding: 22px 20px 10px;
}
.view-header h1 {
  margin: 6px 0 0;
  font-size: 26px;
  letter-spacing: -0.01em;
  font-weight: 600;
}
.view-header p { margin: 6px 0 0; }

.muted { color: var(--ink-dim); }
.small { font-size: 13px; }

/* ---------- camera stage ---------- */
.stage {
  position: relative;
  background: #000;
  aspect-ratio: 3 / 4;
  width: 100%;
  overflow: hidden;
  border-radius: 0;
}
.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stage canvas { pointer-events: none; }

.stage-review { aspect-ratio: 16 / 10; margin: 0 16px; border-radius: var(--radius); }
.stage-review video, .stage-review canvas { border-radius: var(--radius); }

.stage-top {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  pointer-events: none;
}

.chip {
  background: rgba(0,0,0,.45);
  color: var(--ink);
  backdrop-filter: blur(10px);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255,255,255,.08);
}

/* Prominent rep counter — acts as a scoreboard in the top-right of the stage. */
.score {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 8px 16px 9px;
  text-align: center;
  min-width: 86px;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}
.score .score-num {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.score .score-sub {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* Big center-stage verdict — flashes for ~1s after each rep completes. */
.verdict {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 14px 28px;
  border-radius: 18px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
  backdrop-filter: blur(10px);
  border: 2px solid transparent;
  text-align: center;
}
.verdict.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.verdict.good {
  background: color-mix(in oklab, var(--good) 25%, rgba(0,0,0,.55));
  color: var(--good);
  border-color: color-mix(in oklab, var(--good) 60%, transparent);
}
.verdict.bad {
  background: color-mix(in oklab, var(--bad) 25%, rgba(0,0,0,.55));
  color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 60%, transparent);
}
.verdict .sub {
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: .85;
  margin-top: 4px;
  text-transform: none;
}

.stage-feedback {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stage-feedback .fb {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.08);
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
}
.stage-feedback .fb.good { border-color: color-mix(in oklab, var(--good) 40%, transparent); }
.stage-feedback .fb.warn { border-color: color-mix(in oklab, var(--warn) 40%, transparent); color: var(--warn); }
.stage-feedback .fb.bad  { border-color: color-mix(in oklab, var(--bad)  40%, transparent); color: var(--bad); }

/* ---------- controls ---------- */
.controls {
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  color: var(--ink);
}
.field select,
.field input[type="text"],
.field input {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.field select:focus, .field input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 60%, transparent);
  outline-offset: 0;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.btn {
  flex: 1;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease, border-color .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn-primary.active {
  background: var(--bad);
  color: #fff;
}
.btn-big {
  font-size: 17px;
  font-weight: 600;
  padding: 16px;
}
.btn-primary .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}
.btn-primary.active .dot {
  animation: pulse 1s infinite;
}

/* Secondary controls below the big Start button. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 2px;
}
.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.toggle-chip input {
  accent-color: var(--accent);
  margin: 0;
}
.btn-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.btn-link:hover {
  text-decoration-color: var(--accent);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}
.btn-ghost {
  background: transparent;
  flex: 0 0 auto;
  padding: 13px 16px;
}
.link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 14px;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- library list ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list li {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  transition: border-color .15s ease, transform .06s ease;
}
.list li:hover { border-color: var(--accent); }
.list li:active { transform: scale(.995); }
.list li .thumb {
  width: 72px; height: 54px;
  background: #000;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
  font-size: 11px;
}
.list li .meta {
  flex: 1;
  min-width: 0;
}
.list li .meta h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list li .meta small {
  color: var(--ink-dim);
  font-size: 12px;
}
.badge {
  background: color-mix(in oklab, var(--accent) 20%, transparent);
  color: var(--accent);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
}
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--ink-dim);
}

/* ---------- review ---------- */
.review-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.cloud-result {
  margin: 0 16px 20px;
  padding: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--ink-dim);
}
.cloud-result h4 { margin: 0 0 6px; color: var(--ink); font-weight: 600; }

/* ---------- settings ---------- */
.settings-list {
  padding: 0 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- obstacle-runner game ---------- */
.game-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.game-score {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 8px 14px 9px;
  text-align: center;
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}
.game-score-num {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.game-score-sub {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}
.game-lives {
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 18px;
  color: var(--bad);
  letter-spacing: 2px;
}

/* Start / Game-over overlay card */
.game-start {
  position: absolute;
  inset: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 14px;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 24px;
  transition: opacity .18s ease;
}
.game-start[hidden] { display: none; }
.game-start h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.game-start p {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
  max-width: 320px;
}
.game-start .btn {
  flex: 0 0 auto;
  min-width: 160px;
}
.game-start small { font-size: 12px; margin-top: 4px; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in oklab, var(--bg) 85%, black);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.tabbar .tab {
  background: none;
  border: 0;
  color: var(--ink-mute);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.tabbar .tab svg {
  width: 22px; height: 22px;
}
.tabbar .tab.active { color: var(--accent); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 20;
  animation: fade .2s ease-out;
}

/* ---------- responsive: tablet/desktop gets a centered column ---------- */
@media (min-width: 820px) {
  #app, .tabbar { max-width: 520px; margin-inline: auto; }
  body { background: #000; }
  #app { border-inline: 1px solid var(--line); background: var(--bg); }
}
