/* V-Calm — mobile-first, dark, calm. No external fonts or assets. */

:root {
  --bg: #0d1626;
  --bg-deep: #08101c;
  --ink: #f4f7fb;
  --ink-dim: rgb(244 247 251 / 0.68);
  --ink-faint: rgb(244 247 251 / 0.42);
  --line: rgb(255 255 255 / 0.12);
  --radius: 22px;
  --font: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgb(255 255 255 / 0.8);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0;
}

/* ---------------- HOME ---------------- */

.home {
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--safe-b) + 24px);
  max-width: 560px;
  margin: 0 auto;
  background: radial-gradient(120% 60% at 50% -10%, rgb(80 120 200 / 0.22), transparent 60%), var(--bg);
}

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.brand-orb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5fe3c9, #7a6cf5);
  box-shadow: 0 0 16px -2px #7a6cf5;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 6px 9px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.08);
  border: 1px solid var(--line);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.streak-pill .flame {
  width: 18px;
  height: 18px;
  fill: rgb(255 255 255 / 0.35);
}

.streak-pill.lit {
  color: var(--ink);
}

.streak-pill.lit .flame {
  fill: #ffb259;
  filter: drop-shadow(0 0 6px rgb(255 160 70 / 0.7));
}

.greeting {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 600;
  margin: 18px 4px 18px;
  letter-spacing: -0.01em;
}

/* Repeat last */
.repeat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  text-align: left;
  background: rgb(255 255 255 / 0.06);
  border: 1px solid var(--line);
  transition: transform 0.15s var(--ease);
}

.repeat:active {
  transform: scale(0.98);
}

.repeat-orb {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orb1), var(--orb2));
  box-shadow: 0 0 18px -4px var(--orb2);
}

.repeat-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-weight: 600;
}

.repeat-kicker {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.repeat-play {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 50%;
  background: var(--ink);
  fill: var(--bg);
}

/* Program cards */
.programs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.card {
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  box-shadow: 0 10px 30px -18px rgb(0 0 0 / 0.8);
  overflow: hidden;
  scroll-margin: 16px;
}

.card-main {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
}

.card-orb {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgb(255 255 255 / 0.35), transparent 50%),
    linear-gradient(135deg, var(--orb1), var(--orb2));
  box-shadow:
    0 0 22px -4px var(--orb2),
    0 0 0 6px rgb(255 255 255 / 0.06);
  transition: transform 0.5s var(--ease);
}

.card.open .card-orb {
  transform: scale(1.12);
}

.card-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 650;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.18);
}

.card-tech {
  font-size: 14px;
  font-weight: 500;
  color: rgb(255 255 255 / 0.85);
  font-variant-numeric: tabular-nums;
}

.card-tag {
  font-size: 13px;
  color: rgb(255 255 255 / 0.62);
}

.chev {
  flex: none;
  width: 10px;
  height: 10px;
  border-right: 2px solid rgb(255 255 255 / 0.55);
  border-bottom: 2px solid rgb(255 255 255 / 0.55);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.3s var(--ease);
}

.card.open .chev {
  transform: rotate(225deg) translate(-2px, -2px);
}

.durations-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s var(--ease);
}

.card.open .durations-wrap {
  grid-template-rows: 1fr;
}

.durations {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 0 16px;
  transition: padding 0.32s var(--ease);
}

.card.open .durations {
  padding: 2px 16px 16px;
}

.dur {
  height: 64px;
  border-radius: 18px;
  background: rgb(255 255 255 / 0.14);
  border: 1px solid rgb(255 255 255 / 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    transform 0.12s var(--ease),
    background 0.2s;
}

.dur:active {
  transform: scale(0.94);
  background: rgb(255 255 255 / 0.28);
}

.dur-n {
  font-size: 24px;
  font-weight: 650;
}

.dur-u {
  font-size: 11px;
  margin-top: 4px;
  color: rgb(255 255 255 / 0.7);
}

.dur.preferred {
  background: rgb(255 255 255 / 0.92);
  color: #142033;
}

.dur.preferred .dur-u {
  color: rgb(20 32 51 / 0.65);
}

.home-foot {
  margin-top: 26px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 14px;
}

.home-foot p {
  margin: 6px 0;
}

.home-foot .fine {
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------------- SESSION ---------------- */

.session,
.done {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 18px);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  overflow: hidden;
}

.session-top {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn,
.icon-btn-spacer {
  width: 44px;
  height: 44px;
  flex: none;
}

.icon-btn {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.18);
}

.icon-btn svg {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.session-meta {
  text-align: center;
  font-weight: 600;
  font-size: 17px;
}

.s-remaining {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.stage {
  position: relative;
  margin: auto 0 0;
  width: min(80vw, 360px, 44dvh);
  aspect-ratio: 1;
  border-radius: 50%;
  flex: none;
}

.stage > * {
  position: absolute;
  pointer-events: none;
}

.glow {
  inset: -22%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--orb1) 0%, transparent 62%);
  opacity: 0.2;
  filter: blur(18px);
}

.ring {
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgb(255 255 255 / 0.32);
}

.shimmer {
  inset: -30%;
  width: 160%;
  height: 160%;
}

/* inset 6% → orb diameter = 88% of stage (ORB_FRACTION in main.js) */
.orb {
  inset: 6%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 26%, rgb(255 255 255 / 0.32), transparent 46%),
    linear-gradient(135deg, var(--orb1), var(--orb2));
  box-shadow:
    0 0 70px -12px var(--orb2),
    inset 0 0 0 7px rgb(255 255 255 / 0.05),
    inset 0 0 0 14px rgb(255 255 255 / 0.04),
    inset 0 0 0 21px rgb(255 255 255 / 0.03);
  transform: scale(0.42);
  will-change: transform;
}

.session.paused .orb,
.session.paused .glow {
  filter: saturate(0.5) brightness(0.85);
}

.cue {
  margin: 34px 0 auto;
  text-align: center;
  min-height: 120px;
}

.cue-label {
  font-size: 34px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.cue-sub {
  margin-top: 6px;
  font-size: 16px;
  color: var(--ink-dim);
  min-height: 1.3em;
}

.cue-count {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 500;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-height: 1.3em;
}

.paused-hint {
  position: absolute;
  top: calc(var(--safe-t) + 70px);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.25);
  color: var(--ink);
}

.volume {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgb(255 255 255 / 0.65);
}

.volume svg {
  width: 20px;
  height: 20px;
  flex: none;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.volume input {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 4px;
  background: rgb(255 255 255 / 0.3);
  outline-offset: 8px;
}

.volume input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.3);
}

.volume input::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.lock-hint {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------------- SLEEP ---------------- */

.sleep {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  padding-bottom: calc(var(--safe-b) + 40px);
  background: #000;
  animation: fade-in 2.5s ease both;
}

.sleep span {
  font-size: 13px;
  color: rgb(255 255 255 / 0.18);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------- DONE ---------------- */

.done {
  justify-content: space-between;
}

.done-body {
  margin: auto 0;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.done-flame {
  width: 96px;
  height: 96px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.1);
}

.done-flame .flame {
  width: 52px;
  height: 52px;
  fill: rgb(255 255 255 / 0.5);
}

.done-flame.lit .flame {
  fill: #ffb259;
  filter: drop-shadow(0 0 14px rgb(255 160 70 / 0.8));
}

.done-flame.grew {
  animation: grow 0.9s var(--ease) both;
}

@keyframes grow {
  0% {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.done h2 {
  font-size: 34px;
  margin: 8px 0 4px;
}

.done-summary {
  margin: 0;
  color: var(--ink-dim);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.done-streak {
  margin: 18px 0 0;
  font-size: 22px;
  font-weight: 650;
}

.done-note {
  margin: 6px 0 0;
  color: var(--ink-dim);
  min-height: 1.3em;
}

.done-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 28px 0 0;
}

.done-stats div {
  padding: 12px 6px;
  border-radius: 16px;
  background: rgb(0 0 0 / 0.16);
}

.done-stats dt {
  font-size: 12px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.done-stats dd {
  margin: 4px 0 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.done-actions {
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  height: 56px;
  border-radius: 999px;
  background: #fff;
  color: #142033;
  font-weight: 650;
  font-size: 17px;
}

.btn.ghost {
  background: rgb(255 255 255 / 0.14);
  color: var(--ink);
  border: 1px solid rgb(255 255 255 / 0.2);
}

.btn:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
