/* ======= Reset & Base ======= */
body {
    margin: 0;
}

#root {
    position: absolute;
    width: 100vw;
    height: 100vh;
}

#canvas {
    width: 100%;
    height: 100%;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #12121e;
  color: #e0e0e8;
  display: flex;
  flex-direction: column;
  transition: background 1.8s ease;
  position: relative;
  animation: bodyBreathe 12s ease-in-out infinite;
}

@keyframes bodyBreathe {
  0%, 100% { background-color: #12121e; }
  50%      { background-color: #1a1a2e; }
}

/* ======= Animated Background Orbs ======= */
.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  will-change: transform, opacity;
  pointer-events: none;
  z-index: 0;
  transition: background 1.8s ease, opacity 1.8s ease;
}

.orb-1 {
  width: 520px;
  height: 520px;
  top: -12%;
  left: -12%;
  background: radial-gradient(circle, rgba(160, 100, 255, 0.45), transparent 70%);
  animation: float1 35s cubic-bezier(0.45, 0.05, 0.4, 0.95) infinite, glowPulse 6s ease-in-out infinite;
}

.orb-2 {
  width: 440px;
  height: 440px;
  bottom: -15%;
  right: -10%;
  background: radial-gradient(circle, rgba(60, 190, 230, 0.40), transparent 70%);
  animation: float2 50s cubic-bezier(0.45, 0.05, 0.4, 0.95) infinite, glowPulse 8s ease-in-out 1s infinite;
}

.orb-3 {
  width: 360px;
  height: 360px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(220, 80, 200, 0.35), transparent 70%);
  animation: float3 42s cubic-bezier(0.45, 0.05, 0.4, 0.95) infinite, glowPulse 7s ease-in-out 0.5s infinite;
}

.orb-4 {
  width: 280px;
  height: 280px;
  top: 75%;
  left: 80%;
  background: radial-gradient(circle, rgba(255, 180, 60, 0.20), transparent 70%);
  animation: float4 38s cubic-bezier(0.45, 0.05, 0.4, 0.95) infinite, glowPulse 9s ease-in-out 2s infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  20% { transform: translate(100px, -100px) scale(1.10); }
  40% { transform: translate(80px, 130px) scale(0.95); }
  60% { transform: translate(-120px, 50px) scale(1.08); }
  80% { transform: translate(-50px, -110px) scale(0.97); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
  25% { transform: translate(-90px, -70px) scale(1.06) rotate(6deg); }
  50% { transform: translate(50px, 110px) scale(0.95) rotate(-4deg); }
  75% { transform: translate(110px, -50px) scale(1.03) rotate(5deg); }
}

@keyframes float3 {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  33% { transform: translate(-38%, -58%) scale(1.12); }
  66% { transform: translate(-62%, -42%) scale(0.94); }
}

@keyframes float4 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-120px, -40px) scale(1.15); }
  50% { transform: translate(-60px, -100px) scale(0.90); }
  75% { transform: translate(40px, -60px) scale(1.05); }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.7; filter: blur(80px); }
  50%      { opacity: 1;   filter: blur(90px); }
}

/* ======= Lighter State Override ======= */
body[data-state="idle"] .orb-1,
body[data-state="paused"] .orb-1,
body[data-state="completed"] .orb-1 {
  background: radial-gradient(circle, rgba(190, 140, 255, 0.30), transparent 70%);
}

body[data-state="idle"] .orb-2,
body[data-state="paused"] .orb-2,
body[data-state="completed"] .orb-2 {
  background: radial-gradient(circle, rgba(120, 210, 240, 0.28), transparent 70%);
}

body[data-state="idle"] .orb-3,
body[data-state="paused"] .orb-3,
body[data-state="completed"] .orb-3 {
  background: radial-gradient(circle, rgba(240, 120, 220, 0.25), transparent 70%);
}

body[data-state="idle"] .orb-4,
body[data-state="paused"] .orb-4,
body[data-state="completed"] .orb-4 {
  background: radial-gradient(circle, rgba(255, 200, 100, 0.16), transparent 70%);
}

body[data-state="idle"],
body[data-state="paused"],
body[data-state="completed"] {
  background: #1c1a2e;
  animation: bodyBreatheIdle 14s ease-in-out infinite;
}

@keyframes bodyBreatheIdle {
  0%, 100% { background-color: #1c1a2e; }
  50%      { background-color: #242040; }
}

/* ======= Top Bar ======= */
.top-bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.app-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.5;
}

.settings-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.08);
}

/* ======= Main Content ======= */
.main-content {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 8px;
}

/* Phase Label */
.phase-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 4px;
  transition: opacity 0.3s;
}

/* Timer */
.timer {
  font-size: clamp(80px, 18vw, 140px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 4px;
  line-height: 1;
  margin: 8px 0 20px;
  transition: color 0.4s;
}

body[data-state="running"] .timer {
  color: #f0f0ff;
}

body[data-state="idle"] .timer,
body[data-state="paused"] .timer,
body[data-state="completed"] .timer {
  color: #c0c0d0;
}

/* Cycle Dots */
.cycle-dots {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
  height: 10px;
  align-items: center;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.4s, transform 0.3s, box-shadow 0.3s;
}

.dot.completed {
  background: rgba(255, 255, 255, 0.5);
}

.dot.active {
  background: #7c5cbf;
  box-shadow: 0 0 12px rgba(124, 92, 191, 0.5);
  transform: scale(1.25);
}

body[data-state="running"] .dot.active {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 12px rgba(124, 92, 191, 0.5); }
  50% { box-shadow: 0 0 20px rgba(124, 92, 191, 0.8); }
}

/* Controls */
.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-primary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f0f0ff;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 3px;
  padding: 16px 60px;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.15s, box-shadow 0.25s;
  min-width: 200px;
  text-transform: uppercase;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.25);
  transform: scale(1.02);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary.running {
  background: rgba(200, 80, 80, 0.15);
  border-color: rgba(200, 80, 80, 0.3);
  color: #ff8a8a;
}

.btn-primary.running:hover {
  background: rgba(200, 80, 80, 0.22);
  border-color: rgba(200, 80, 80, 0.4);
}

.btn-secondary {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 2px;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 20px;
  transition: color 0.2s, background 0.2s;
  text-transform: uppercase;
}

.btn-secondary:hover {
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
}

/* Volume Control */
.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.5;
  transition: opacity 0.3s;
  margin-top: 16px;
}

.volume-control:hover {
  opacity: 1;
}

.volume-control.disabled {
  opacity: 0.2;
  pointer-events: none;
}

.volume-icon {
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.volume-slider::-webkit-slider-thumb:hover {
  background: #fff;
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  border: none;
  cursor: pointer;
}

/* ======= Settings Modal ======= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #181825;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 36px 32px 28px;
  width: 380px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}

.modal-close:hover {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.06);
}

.modal-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 1px;
  margin-bottom: 28px;
  color: #e8e8f0;
}

.settings-group {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-group:last-of-type {
  border-bottom: none;
}

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

.setting-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
}

.setting-input {
  width: 72px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #e0e0e8;
  font-size: 14px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.setting-input:focus {
  border-color: rgba(124, 92, 191, 0.5);
}

.setting-toggle {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.setting-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: transform 0.2s, background 0.2s;
}

.setting-toggle:checked {
  background: rgba(124, 92, 191, 0.6);
}

.setting-toggle:checked::after {
  transform: translateX(18px);
  background: #fff;
}

.btn-save {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: rgba(124, 92, 191, 0.3);
  color: #e0e0f0;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-save:hover {
  background: rgba(124, 92, 191, 0.45);
  transform: scale(1.01);
}

.btn-save:active {
  transform: scale(0.99);
}
