:root {
  /* Never pure black (#000000 is transparent on the additive waveguide). */
  --bg-primary: #1C1E21;
  --bg-secondary: #25282C;
  --bg-tertiary: #2E3236;
  --bg-card: #34383D;

  --text-primary: #FFFFFF;
  --text-secondary: #C8CCD1;
  --text-muted: #9197A0;

  /* Warm accent during FOCUS, cool accent during BREAK. */
  --accent-focus: #FFB066;   /* warm amber, 4.5:1+ on #1C1E21 */
  --accent-break: #5FD0FF;   /* cool cyan, 4.5:1+ on #1C1E21 */

  --focus-ring: #00D4FF;
  --focus-glow: rgba(0, 212, 255, 0.4);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

/* color theme switches per session type via body class */
body.break { --accent: var(--accent-break); }
body { --accent: var(--accent-focus); }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header (settings) --- */
.header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 {
  font-size: 24px;
  font-weight: 700;
  flex: 1;
}
.back-btn {
  background: transparent;
  color: var(--text-primary);
  font-size: 24px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  line-height: 1;
}

/* --- Focus states (critical for D-pad) --- */
.focusable {
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  border: 2px solid transparent;
  cursor: pointer;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ==================== TIMER STAGE ==================== */
.timer-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 20px 4px;
}

.session-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.session-label {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--accent);
}

/* completed-session dots */
.cycle-dots {
  display: flex;
  gap: 9px;
  height: 12px;
  align-items: center;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--text-muted);
}
.dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

/* circular progress ring + countdown */
.ring-wrap {
  position: relative;
  width: 360px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring {
  position: absolute;
  width: 360px;
  height: 360px;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  /* circumference for r=112: 2*pi*112 = 703.7 */
  stroke-dasharray: 703.7;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.4s linear;
}

.countdown {
  position: relative;
  font-size: 104px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--text-primary);
  line-height: 1;
}

.streak-line {
  font-size: 16px;
  color: var(--text-secondary);
}
.streak-line span { color: var(--accent); font-weight: 700; }

/* ==================== NAV BAR ==================== */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 18px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary {
  background: var(--accent);
  color: #1C1E21;
}

/* ==================== SETTINGS CONTENT ==================== */
.content {
  flex: 1;
  padding: 14px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.section-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 6px;
}

.preset-row { display: flex; gap: 10px; }
.chip {
  flex: 1;
  padding: 14px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.chip:focus { background: var(--bg-card); }
.chip.active {
  background: var(--accent-focus);
  color: #1C1E21;
}

.counter {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}
.counter-btn {
  width: 64px;
  height: 64px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.counter-btn:focus { background: var(--bg-card); }
.counter-value {
  flex: 1;
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.counter-unit {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 6px;
}

.settings-note {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 10px;
  line-height: 1.4;
}

/* ==================== COMPLETION PULSE ==================== */
.pulse {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background: var(--accent-focus);
  opacity: 0;
}
.pulse.hidden { display: none; }
.pulse.flash-focus {
  background: var(--accent-focus);
  animation: pulseFade 1.1s ease-out;
}
.pulse.flash-break {
  background: var(--accent-break);
  animation: pulseFade 1.1s ease-out;
}
@keyframes pulseFade {
  0%   { opacity: 0; }
  18%  { opacity: 0.55; }
  100% { opacity: 0; }
}

/* --- Utility --- */
.hidden { display: none !important; }
