:root {
  --bg-color: #0A0B1A;
  --card-bg: #12132D;
  --accent-soft: #D4C1EC;   /* lilac */
  --accent-glow: #FFD580;   /* gold */
  --biolume: #4ADE80;       /* sheep/green */
  --text-primary: #F0F0FF;
  --text-secondary: #9A9CB0;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --border-radius: 10px;
}

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

html, body {
  height: 100%;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(140, 110, 200, 0.25), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(80, 150, 200, 0.18), transparent 60%),
    var(--bg-color);
  animation: skyDrift 120s ease-in-out infinite alternate;
  z-index: -1;
}

@keyframes skyDrift {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(60deg); }
}

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  z-index: 20;
  pointer-events: none;
}
.brand {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent-soft);
  letter-spacing: 0.5px;
}
.star {
  color: var(--accent-soft);
  opacity: 0.65;
  font-size: 12px;
}

/* =========== pager =========== */
.pager {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.pager::-webkit-scrollbar { display: none; }

.page {
  flex: 0 0 100vw;
  height: 100vh;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 20px 80px;
}

.pager-dots {
  position: fixed;
  bottom: 22px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 20;
}
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
}
.dot.is-active {
  background: var(--accent-soft);
  transform: scale(1.3);
}

/* =========== widget card (shared) =========== */
.widget-container {
  width: 100%;
  max-width: 360px;
  height: 520px;
  max-height: 88vh;
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(212, 193, 236, 0.05);
  border: 1px solid rgba(212, 193, 236, 0.1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.widget-header {
  padding: 16px 18px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}
.title-label {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  color: var(--accent-soft);
  letter-spacing: 0.5px;
}
.ref-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-secondary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.visualizer-stage {
  flex-grow: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* moon / play trigger shared */
.moon-trigger {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-soft);
  background: rgba(212, 193, 236, 0.05);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(3px);
  z-index: 10;
}
.moon-trigger:hover {
  background: rgba(212, 193, 236, 0.15);
  box-shadow: 0 0 15px rgba(212, 193, 236, 0.25);
}
.moon-svg { width: 22px; height: 22px; fill: var(--accent-soft); transition: transform 0.4s ease; }
.soundscape-card.is-playing .moon-svg { transform: rotate(-15deg); }

/* presets / track pills */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
  justify-content: center;
}
.preset-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.preset-pill:hover { color: var(--text-primary); }
.preset-pill.is-active {
  color: var(--accent-soft);
  border-color: rgba(212, 193, 236, 0.35);
  background: rgba(212, 193, 236, 0.08);
}
.meditation-card .preset-pill.is-active {
  color: var(--accent-glow);
  border-color: rgba(255, 213, 128, 0.35);
  background: rgba(255, 213, 128, 0.08);
}

/* widget footer */
.widget-footer {
  padding: 14px 18px 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  background: linear-gradient(transparent, rgba(10, 11, 26, 0.6));
  z-index: 5;
}
.status-group { display: flex; flex-direction: column; min-width: 0; }
.status-label {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.main-readout {
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-style: italic;
}
.timer-display {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-soft);
  opacity: 0.85;
}
.mini-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(212, 193, 236, 0.08);
  color: var(--accent-soft);
  border: 1px solid rgba(212, 193, 236, 0.25);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.mini-btn:hover { background: rgba(212, 193, 236, 0.18); }
.mini-btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.08);
}

/* =========== page 1: soundscape =========== */
#firefly-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hue-drift { animation: hueDrift 120s linear infinite; }
@keyframes hueDrift {
  0%   { filter: hue-rotate(0deg)   saturate(1); }
  50%  { filter: hue-rotate(180deg) saturate(1.2); }
  100% { filter: hue-rotate(360deg) saturate(1); }
}

/* =========== page 2: meditation =========== */
.meditation-card { background: linear-gradient(180deg, #1A1A2E 0%, #08080C 100%); }
.breath-stage { min-height: 240px; }
.breath-orb {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--accent-soft);
  filter: blur(28px);
  opacity: 0.4;
  animation: breathe 8s ease-in-out infinite;
  position: absolute;
}
.breath-orb-secondary {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: var(--accent-glow);
  filter: blur(22px);
  opacity: 0.22;
  animation: breathe 8s ease-in-out infinite reverse;
  position: absolute;
}
@keyframes breathe {
  0%, 100% { transform: scale(1);   opacity: 0.3; }
  50%      { transform: scale(1.7); opacity: 0.6; }
}
.breath-text {
  position: relative;
  z-index: 5;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--text-primary);
  text-shadow: 0 0 14px rgba(209, 196, 233, 0.5);
  transition: opacity 1.2s ease;
}

.progress-row { padding: 0 18px 8px; }
.progress-bar {
  height: 2px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent-glow);
  box-shadow: 0 0 8px rgba(255, 213, 128, 0.4);
  transition: width 0.3s linear;
}

/* =========== page 3: counting sheep =========== */
.sheep-card { background-color: #0B0E14; }
.stars-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #eee, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 40px 70px, #fff, rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 150px 40px, #ddd, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 280px 120px, #fff, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 100px 150px, #999, rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 60px 220px, #eee, rgba(0,0,0,0)),
    radial-gradient(1px 1px at 220px 300px, #fff, rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 200px 420px, #eee, rgba(0,0,0,0));
  opacity: 0.45;
  pointer-events: none;
}
.visualizer-area {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.hill {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  width: 100%;
  height: 45%;
  pointer-events: none;
}

.sheep {
  position: absolute;
  width: 56px; height: 42px;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.sheep svg { width: 100%; height: 100%; display: block; overflow: visible; }

.miss-flash {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.miss-flash.show { opacity: 0.85; }

.sheep-footer { align-items: center; }
.count-row { display: flex; gap: 18px; }
.stat-block { display: flex; flex-direction: column; }
.count { font-size: 20px; font-weight: 500; color: var(--text-primary); }
.count.muted { color: var(--text-secondary); font-size: 14px; }
.label {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-top: 2px;
}
.sheep-controls { display: flex; gap: 8px; align-items: center; }

.cloud-btn {
  width: 44px; height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.cloud-btn:hover { background: rgba(255, 255, 255, 0.1); }
.cloud-icon {
  width: 18px; height: 12px;
  background: var(--text-secondary);
  border-radius: 6px;
  position: relative;
}
.cloud-icon::before {
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  background: inherit;
  border-radius: 50%;
  top: -5px; left: 3px;
}
.cloud-btn.is-active .cloud-icon {
  background: #A5B4FC;
  box-shadow: 0 0 10px rgba(165, 180, 252, 0.4);
}

@media (max-height: 600px) {
  .widget-container { height: 94vh; }
  .page { padding: 50px 16px 60px; }
}
