:root {
  --bg: #0a0a1a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f0f0f0;
  --text-dim: rgba(255, 255, 255, 0.5);
  --primary: #f59e0b;
  --primary-glow: rgba(245, 158, 11, 0.2);
  --accent: #f43f5e;
  --success: #10b981;
  --danger: #ef4444;
  --nav-h: 72px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

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

/* ---------- PARTICLES ---------- */
#particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ---------- VIEWS ---------- */
.view {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  padding: calc(var(--safe-t) + 16px) 20px calc(var(--nav-h) + var(--safe-b) + 12px);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1;
}
.view::-webkit-scrollbar { display: none; }
.view.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.view-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 24px;
}
.view-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  width: 100%;
}
.section-title {
  font-size: 17px;
  font-weight: 600;
  width: 100%;
  margin-top: 4px;
}

/* ---------- GREETING ---------- */
.greeting {
  font-size: 15px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 24px;
}

/* ---------- TIMER ---------- */
.timer-wrapper {
  position: relative;
  width: 260px; height: 260px;
  margin: 8px 0;
}
.timer-svg { width: 100%; height: 100%; }
.timer-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.05);
  stroke-width: 6;
}
.timer-progress {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 553;
  stroke-dashoffset: 553;
  transition: stroke-dashoffset 1s linear;
}
.timer-inner {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.timer-time {
  font-size: 54px;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  transition: color 0.3s ease;
}
.timer-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-top: 2px;
}
.timer-wrapper.running .timer-time { color: var(--primary); }
.timer-wrapper.break-mode .timer-time { color: var(--success); }

/* ---------- BUTTONS ---------- */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: 50px;
  padding: 14px 36px;
  transition: all 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #d97706);
  color: #000;
  box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:active { background: var(--surface-hover); }
.btn-small {
  padding: 8px 20px;
  font-size: 14px;
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn.hidden { display: none; }

.timer-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 20px var(--primary-glow); }
  50% { box-shadow: 0 4px 36px rgba(245, 158, 11, 0.4); }
}
.btn-primary.pulsing { animation: pulse-glow 2s ease-in-out infinite; }

/* ---------- SESSION INFO ---------- */
.session-info {
  display: flex;
  gap: 10px;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.stat-icon { font-size: 14px; }

/* ---------- SOUND INDICATOR ---------- */
.sound-indicator {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 20px;
  text-align: center;
}

/* ---------- REWARD OVERLAY ---------- */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.reward-container {
  width: 100%; height: 100%;
  position: relative;
  background: var(--bg);
}
.reward-container img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.reward-container img.loaded { opacity: 1; }
.reward-content {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 40px 24px calc(var(--safe-b) + 32px);
  background: linear-gradient(transparent, rgba(0,0,0,0.7) 20%, rgba(0,0,0,0.92));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.reward-badge {
  display: inline-block;
  background: var(--primary);
  color: #000;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 16px;
  border-radius: 50px;
  letter-spacing: 0.5px;
}
.reward-quote {
  font-size: 17px;
  font-weight: 300;
  line-height: 1.5;
  text-align: center;
  max-width: 340px;
  color: rgba(255,255,255,0.9);
  font-style: italic;
}
.reward-duration {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- STATS ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}
.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
}
.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- GALLERY ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
}
.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.gallery-item:active img { transform: scale(1.05); }
.gallery-item .gallery-date {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4px;
  font-size: 9px;
  color: white;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  text-align: center;
}
.empty-state {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
  grid-column: 1 / -1;
}

/* ---------- SETTINGS ---------- */
.settings-group {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
}
.setting-item + .setting-item {
  border-top: 1px solid var(--border);
}
.setting-item label { font-size: 15px; }
.setting-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text-dim);
}
.btn-adjust {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-adjust:active { background: var(--surface-hover); }
select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  font-family: inherit;
}
.app-info {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding-top: 12px;
}
.app-info p + p { margin-top: 4px; }

/* ---------- PHOTO VIEWER ---------- */
.photo-viewer {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 200;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.photo-viewer.active {
  opacity: 1;
  pointer-events: auto;
}
.photo-viewer img {
  max-width: 95%;
  max-height: 75%;
  object-fit: contain;
  border-radius: 8px;
}
.photo-viewer-close {
  position: absolute;
  top: calc(var(--safe-t) + 16px);
  right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-viewer-info {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(10, 10, 26, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 24px;
  transition: color 0.2s ease;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--primary); }

/* ---------- LOADING ---------- */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

/* ---------- RESPONSIVE ---------- */
@media (min-height: 800px) {
  .greeting { margin-top: 40px; }
  .timer-wrapper { width: 280px; height: 280px; margin: 16px 0; }
  .timer-time { font-size: 60px; }
}
@media (min-height: 900px) {
  .greeting { margin-top: 56px; }
  .timer-wrapper { width: 300px; height: 300px; margin: 24px 0; }
}
