:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --fg: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #2563eb;
  --danger: #f87171;
  --card: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 50% -10%, #17233f 0%, var(--bg) 60%);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  min-height: 100dvh;
  display: flex;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-top)) 20px calc(24px + var(--safe-bot));
  width: 100%;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}
.screen.active { display: flex; }

header h1 {
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: 0.3px;
}
.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
  color: var(--fg);
}
label > span { color: var(--muted); }
label input[type="number"] {
  width: 92px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--fg);
  font-size: 16px;
  text-align: right;
  -moz-appearance: textfield;
}
label input[type="number"]::-webkit-outer-spin-button,
label input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
label.switch {
  justify-content: space-between;
}
label.switch input {
  width: 44px; height: 26px; appearance: none; background: #26324a;
  border-radius: 999px; position: relative; transition: background .2s; cursor: pointer;
}
label.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #e2e8f0; border-radius: 50%; transition: transform .2s;
}
label.switch input:checked { background: var(--accent-2); }
label.switch input:checked::after { transform: translateX(18px); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 14px 18px;
  font-size: 16px;
  transition: transform .05s ease, background .15s ease, opacity .15s;
  user-select: none;
}
button:active { transform: scale(0.98); }

button.big { padding: 18px 20px; font-size: 18px; font-weight: 600; }
button.primary {
  background: linear-gradient(180deg, #38bdf8 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}
button.secondary {
  background: var(--card);
  color: var(--fg);
  border-color: var(--border);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 20px;
  line-height: 1;
}
button.hidden { display: none; }

.how { color: var(--muted); font-size: 14px; line-height: 1.5; }
.how summary { cursor: pointer; padding: 8px 0; color: var(--fg); }
.how ol { padding-left: 20px; }
.how .warn {
  margin-top: 10px; color: var(--danger); font-size: 13px;
  padding: 10px 12px; border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 12px; background: rgba(248, 113, 113, 0.06);
}

/* SESSION */
#session {
  justify-content: space-between;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .spacer { flex: 1; }
.roundInfo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  text-align: center;
}
#roundLabel { font-size: 13px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
#phaseLabel { font-size: 16px; color: var(--fg); font-weight: 600; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 0;
}

.orb {
  --size: min(72vw, 320px);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(125, 211, 252, 0.35), rgba(37, 99, 235, 0.15) 55%, transparent 70%);
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.15) inset, 0 20px 60px rgba(0, 0, 0, 0.5);
  transition: transform 200ms ease;
}
.orb-inner {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #7dd3fc, #2563eb 60%, #0b1220 100%);
  box-shadow: 0 10px 40px rgba(37, 99, 235, 0.4);
  transform-origin: center;
  transform: scale(0.55);
  transition: transform var(--orb-dur, 2000ms) ease-in-out;
  opacity: 0.95;
}
.orb.inhale .orb-inner { transform: scale(1); }
.orb.exhale .orb-inner { transform: scale(0.55); }
.orb.hold   .orb-inner { transform: scale(0.55); }
.orb.holdFull .orb-inner { transform: scale(1); }

.orb-text {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #f8fafc;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
#bigText { font-size: 28px; font-weight: 700; letter-spacing: 1px; }
#subText { font-size: 16px; opacity: 0.85; margin-top: 4px; }

.counter {
  font-size: 42px;
  font-variant-numeric: tabular-nums;
  font-weight: 300;
  color: var(--fg);
  min-height: 48px;
}
.hint {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.controls button { width: 100%; }

/* DONE */
#done .card { text-align: left; font-size: 15px; line-height: 1.6; color: var(--muted); }
#summary strong { color: var(--fg); }

/* iOS safe area padding on session controls */
@media (max-height: 700px) {
  .orb { --size: min(60vw, 260px); }
  #bigText { font-size: 24px; }
  .counter { font-size: 34px; }
}
