/* ============================================================
   Focus Room — Premium Utility / Apple-adjacent design system
   ============================================================ */

@property --session-color {
  syntax: '<color>';
  initial-value: #0A84FF;
  inherits: true;
}
@property --breath-color {
  syntax: '<color>';
  initial-value: #5AC8FA;
  inherits: true;
}

:root {
  --bg-primary:    #0C0C0E;
  --bg-secondary:  #141416;
  --bg-tertiary:   #1C1C1F;
  --border:        #2A2A2E;
  --border-strong: #38383C;
  --text-primary:  #F2F2F7;
  --text-secondary:#8E8E93;
  --text-tertiary: #48484A;
  --accent:        #0A84FF;
  --accent-hover:  #409CFF;
  --accent-soft:   rgba(10, 132, 255, 0.14);
  --success:       #30D158;
  --warning:       #FF9F0A;
  --session-color: #0A84FF;
  --breath-color:  #5AC8FA;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --t-xs: 12px;
  --t-sm: 14px;
  --t-md: 16px;
  --t-lg: 20px;
  --t-xl: 28px;
  --t-2xl: 48px;
  --radius: 12px;
  --radius-pill: 999px;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.08);
}

[data-theme="light"] {
  --bg-primary:    #F5F5F7;
  --bg-secondary:  #FFFFFF;
  --bg-tertiary:   #F0F0F2;
  --border:        #E4E4E8;
  --border-strong: #D4D4DA;
  --text-primary:  #1C1C1E;
  --text-secondary:#6E6E73;
  --text-tertiary: #AEAEB2;
  --accent-soft:   rgba(10, 132, 255, 0.10);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
html { background: var(--bg-primary); transition: background 0.3s ease; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--t-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; transition: all 0.18s ease-in-out; }
button:hover { opacity: 0.82; }
button:active { transform: scale(0.97); }
input { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, .preset:focus-visible, .sound-chip:focus-visible,
.nav-item:focus-visible, .mood-face:focus-visible, .exercise-card:focus-visible { opacity: 1; }

[data-lucide] { width: 20px; height: 20px; stroke-width: 1.75; display: block; }

/* ===== Layout ===== */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; position: relative; padding-bottom: 88px; }

.screen { display: none; padding: max(env(safe-area-inset-top), 56px) 24px 24px; animation: fadeIn 0.2s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (display-mode: standalone) {
  .screen { padding-top: max(env(safe-area-inset-top), 20px); }
}
body.standalone .screen { padding-top: max(env(safe-area-inset-top), 20px); }

/* ===== Top-right cluster ===== */
.top-actions {
  position: fixed; top: max(env(safe-area-inset-top), 16px); right: 16px;
  z-index: 250; display: flex; align-items: center; gap: 8px; pointer-events: auto;
}
@media (min-width: 512px) { .top-actions { right: calc(50% - 224px); } }

/* ===== Segmented control ===== */
.seg { display: flex; align-items: center; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius-pill); overflow: hidden; height: 36px; }
.seg button { padding: 0 16px; height: 100%; font-size: var(--t-sm); font-weight: 600; color: var(--text-tertiary); border-radius: 0; transition: background 0.2s, color 0.2s; }
.seg button:hover { opacity: 1; color: var(--text-secondary); }
.seg button.active { background: var(--accent); color: #fff; }
.seg button:active { transform: none; }

/* ===== Topbar ===== */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; padding-right: 56px; }
.topbar h1 { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.topbar .sub { font-size: var(--t-sm); color: var(--text-secondary); font-weight: 400; margin-top: 3px; }
/* Premium focus header: greeting is bigger */
#screen-focus .topbar h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; }
.focus-sub { font-size: var(--t-sm); color: var(--text-secondary); font-weight: 400; margin-top: 4px; letter-spacing: 0; }
.focus-cta { font-size: var(--t-sm); color: var(--text-tertiary); font-weight: 400; margin-top: 2px; letter-spacing: 0; }

.icon-btn { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-secondary); }
.icon-btn [data-lucide] { width: 22px; height: 22px; }
.icon-btn:hover { opacity: 1; color: var(--text-primary); border-color: var(--border-strong); }

/* ===== Timer card ===== */
.timer-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

/* Background image layers inside the timer card */
.timer-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  opacity: 0; transition: opacity 0.6s ease; will-change: opacity;
}
.timer-bg.show { opacity: 1; }
/* Dark scrim — only visible when a scene is active */
.timer-bg-scrim {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.48);
  opacity: 0; transition: opacity 0.6s ease;
  pointer-events: none;
}
.timer-card.has-theme .timer-bg-scrim { opacity: 1; }

/* All timer UI sits above the bg layers */
.timer-inner {
  position: relative; z-index: 1;
  padding: 24px; display: flex; flex-direction: column; align-items: center;
  transition: color 0.3s ease;
}

/* When scene is active: card text becomes white */
.timer-card.has-theme .timer-inner { color: rgba(255,255,255,0.95); }
.timer-card.has-theme .ring-time { color: #fff; }
.timer-card.has-theme .ring-state { color: rgba(255,255,255,0.75); }
.timer-card.has-theme .session-note { color: rgba(255,255,255,0.6); }
.timer-card.has-theme .ring-bg { stroke: rgba(255,255,255,0.15); }
.timer-card.has-theme .btn-ghost { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.85); }
.timer-card.has-theme .preset { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.18); color: rgba(255,255,255,0.75); }
.timer-card.has-theme .preset.active { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.5); color: #fff; }
.timer-card.has-theme .sound-section { border-top-color: rgba(255,255,255,0.12); }
.timer-card.has-theme .sound-title { color: rgba(255,255,255,0.5); }
.timer-card.has-theme .sound-chip { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.16); color: rgba(255,255,255,0.80); }
.timer-card.has-theme .sound-chip:hover { border-color: rgba(255,255,255,0.35); color: #fff; }
.timer-card.has-theme .minimal-btn { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.20); color: rgba(255,255,255,0.75); }
.timer-card.has-theme input[type=range] { background: rgba(255,255,255,0.15); }
.timer-card.has-theme .vol-row .vi { color: rgba(255,255,255,0.5); }

/* ===== Presets ===== */
.presets { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; justify-content: center; }
.preset {
  padding: 7px 16px; border-radius: var(--radius-pill); background: var(--bg-tertiary);
  border: 1px solid var(--border); font-size: var(--t-sm); font-weight: 500; color: var(--text-secondary);
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.preset:hover { opacity: 1; color: var(--text-primary); }
.preset.active {
  background: color-mix(in srgb, var(--this-color) 12%, transparent);
  border-color: var(--this-color); color: var(--this-color);
}
.preset.active:hover { opacity: 0.9; }

/* ===== Ring ===== */
.ring-box { position: relative; width: 260px; height: 260px; margin-bottom: 24px; }
.ring-box svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--bg-tertiary); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--session-color); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke 0.3s ease; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-time { font-family: var(--font-mono); font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.ring-time.tick { animation: tickPulse 1s ease-out; }
@keyframes tickPulse { 0% { transform: scale(0.97); } 35% { transform: scale(1); } 100% { transform: scale(1); } }
.ring-time .dgt { display: inline-block; }
.ring-time .dgt.flip { animation: digitSlide 0.22s ease-in-out; }
/* Pre-session countdown digit (3 · 2 · 1 · Start) */
.ring-time .count { font-size: 80px; line-height: 1; font-weight: 600; }
.ring-time .count.word { font-size: 36px; letter-spacing: 0.02em; }
@keyframes digitSlide { from { transform: translateY(-0.2em); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.ring-state { font-size: var(--t-sm); color: var(--text-secondary); margin-top: 6px; letter-spacing: 0.02em; }
.ring-box.pulse { animation: pulse 0.5s ease; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }

/* ===== Timer controls ===== */
.timer-controls { display: flex; gap: 16px; align-items: center; }
.btn-primary { width: 64px; height: 64px; border-radius: 50%; background: var(--session-color); color: #fff; display: flex; align-items: center; justify-content: center; transition: background 0.3s ease; }
.btn-primary [data-lucide] { width: 26px; height: 26px; }
.btn-ghost { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-tertiary); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.btn-ghost:hover { opacity: 1; color: var(--text-primary); }
.session-note { margin-top: 14px; text-align: center; font-size: var(--t-sm); color: var(--text-tertiary); min-height: 18px; }

/* ===== Scene / Sound selector ===== */
.sound-section { width: 100%; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.sound-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.sound-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em; font-weight: 600; color: var(--text-tertiary); }
.vol-row { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 160px; }
.vol-row .vi { color: var(--text-tertiary); width: 15px; height: 15px; flex-shrink: 0; }
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; height: 3px; border-radius: 4px; background: var(--bg-tertiary); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: var(--accent); cursor: pointer; }
#breathe-vol-slider::-webkit-slider-thumb { background: var(--breath-color); }
#breathe-vol-slider::-moz-range-thumb { background: var(--breath-color); }

/* Minimal button — full width, above the chip grid */
.minimal-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  font-size: var(--t-sm); font-weight: 500; color: var(--text-secondary);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.minimal-btn [data-lucide] { width: 16px; height: 16px; }
.minimal-btn:hover { opacity: 1; color: var(--text-primary); border-color: var(--border-strong); }
.minimal-btn.active {
  background: var(--bg-tertiary); border-color: var(--accent);
  color: var(--accent); box-shadow: 0 0 0 1px var(--accent);
}

/* 2-column sound chip grid */
.sound-chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: 100%; }
.sound-chip {
  position: relative; min-height: 76px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 12px 8px; border-radius: var(--radius);
  background: var(--bg-tertiary); border: 1px solid var(--border);
  font-size: 13px; font-weight: 500; color: var(--text-secondary); overflow: hidden;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}
/* Thumbnail background — applied when the chip has a scene image */
.chip-thumb {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  background-image: var(--chip-thumb, none);
  opacity: 0.28; transition: opacity 0.3s;
}
.sound-chip.active .chip-thumb { opacity: 0.45; }
/* A subtle gradient from the chip color overlays the thumbnail for readability */
.chip-thumb-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, color-mix(in srgb, var(--chip-color) 60%, transparent) 0%, transparent 60%);
  opacity: 0; transition: opacity 0.3s;
}
.sound-chip.active .chip-thumb-overlay { opacity: 1; }

.sound-chip .chip-ico { display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.sound-chip .chip-ico [data-lucide] { width: 20px; height: 20px; }
.sound-chip .chip-label { line-height: 1.1; text-align: center; position: relative; z-index: 1; }
.sound-chip:hover { opacity: 1; color: var(--text-primary); border-color: var(--border-strong); }
.sound-chip:active { transform: scale(0.97); }
/* Active state: filled with the chip's accent color */
.sound-chip.active {
  background: var(--chip-color);
  border-color: var(--chip-color); color: #fff;
  box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--chip-color) 75%, transparent);
}
.sound-chip.active:hover { opacity: 1; color: #fff; }
.sound-chip.active .chip-ico [data-lucide] { color: #fff; }

/* Animated 3-bar wave — only shown in active chip */
.chip-wave { display: none; align-items: flex-end; gap: 2px; height: 10px; position: relative; z-index: 1; }
.sound-chip.active .chip-wave { display: flex; }
.chip-wave i { width: 3px; height: 100%; border-radius: 2px; background: rgba(255,255,255,0.9); transform-origin: bottom; animation: waveBounce 0.9s ease-in-out infinite; }
.chip-wave i:nth-child(1) { animation-delay: 0s; }
.chip-wave i:nth-child(2) { animation-delay: 0.18s; }
.chip-wave i:nth-child(3) { animation-delay: 0.36s; }
@keyframes waveBounce { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

/* ===== Daily focus + quote card ===== */
.daily-card { margin-top: 20px; padding: 20px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.daily-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em; font-weight: 600; color: var(--text-tertiary); margin-bottom: 8px; }
.daily-msg { font-size: var(--t-sm); color: var(--text-secondary); line-height: 1.55; }
.daily-divider { height: 1px; background: var(--border); margin: 16px 0; }
.daily-quote .q { font-family: Georgia, Palatino, 'Times New Roman', serif; font-style: italic; font-size: var(--t-sm); color: var(--text-primary); line-height: 1.6; font-weight: 400; }
.daily-quote .a { font-size: var(--t-xs); color: var(--text-tertiary); margin-top: 7px; }

/* ===== Breathe ambient sound section ===== */
.breathe-sound-section { margin-top: 24px; padding: 20px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--card-shadow); }

/* ===== Exam next hero ===== */
.exam-next-hero {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  box-shadow: var(--card-shadow);
}
.enh-left { flex: 1; min-width: 0; }
.enh-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em; font-weight: 600; color: var(--text-tertiary); margin-bottom: 4px; }
.enh-name { font-size: var(--t-lg); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enh-days { font-size: var(--t-sm); font-weight: 600; color: var(--accent); white-space: nowrap; padding: 6px 12px; border-radius: var(--radius-pill); background: var(--accent-soft); }

/* ===== Exams ===== */
.add-btn { width: 100%; padding: 14px; border-radius: var(--radius); background: var(--bg-secondary); border: 1px dashed var(--border-strong); color: var(--text-secondary); font-size: var(--t-sm); font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 16px; box-shadow: var(--card-shadow); }
.add-btn [data-lucide] { width: 17px; height: 17px; }
.add-btn:hover { opacity: 1; color: var(--text-primary); border-color: var(--accent); }

.exam-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--card-shadow); }
.exam-card.done { opacity: 0.5; }
.exam-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.exam-title { font-size: var(--t-md); font-weight: 600; margin-bottom: 3px; letter-spacing: -0.01em; }
.exam-date { font-size: var(--t-xs); color: var(--text-secondary); }
.exam-badge { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill); white-space: nowrap; }
.b-green { background: rgba(48,209,88,0.12); color: var(--success); }
.b-amber { background: rgba(255,159,10,0.12); color: var(--warning); }
.b-red { background: rgba(255,69,58,0.12); color: #FF453A; }
.b-done { background: var(--bg-tertiary); color: var(--text-tertiary); }

.progress-row { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; }
.progress-track { flex: 1; height: 5px; border-radius: var(--radius-pill); background: var(--bg-tertiary); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-pill); background: var(--accent); transition: width 0.4s ease; }
.progress-pct { font-size: var(--t-xs); font-weight: 600; color: var(--text-secondary); min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

.topics { margin-top: 6px; display: flex; flex-direction: column; }
.topic { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.topic:last-child { border-bottom: none; }
.topic-check { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: transparent; }
.topic-check [data-lucide] { width: 13px; height: 13px; }
.topic-check.checked { background: var(--success); border-color: var(--success); color: #fff; }
.topic-check.checked + .topic-label { color: var(--text-tertiary); text-decoration: line-through; }
.topic-label { font-size: var(--t-sm); flex: 1; }
.topic-del { color: var(--text-tertiary); opacity: 0; padding: 4px; display: flex; }
.topic-del [data-lucide] { width: 15px; height: 15px; }
.topic:hover .topic-del { opacity: 1; }

.topic-add { display: flex; gap: 8px; margin-top: 10px; }
.topic-add input { flex: 1; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-tertiary); font-size: var(--t-sm); color: var(--text-primary); outline: none; }
.topic-add input:focus { border-color: var(--accent); }
.topic-add button { padding: 0 14px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; }
.topic-add button [data-lucide] { width: 15px; height: 15px; }

.exam-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.exam-actions button { flex: 1; padding: 8px; border-radius: 8px; font-size: var(--t-sm); font-weight: 500; background: var(--bg-tertiary); color: var(--text-secondary); }
.exam-actions button:hover { opacity: 1; color: var(--text-primary); }
.exam-actions .pass { color: var(--success); }

/* ===== Calendar ===== */
.cal { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 24px; box-shadow: var(--card-shadow); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head .m { font-size: var(--t-md); font-weight: 600; }
.cal-nav { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.cal-nav [data-lucide] { width: 17px; height: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-tertiary); font-weight: 600; padding-bottom: 8px; }
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: var(--t-sm); position: relative; color: var(--text-primary); }
.cal-day.empty { visibility: hidden; }
.cal-day.today { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; position: absolute; bottom: 3px; }
.cal-legend { display: flex; gap: 14px; justify-content: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.cal-legend span { font-size: 11px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.cal-legend .ld { width: 7px; height: 7px; border-radius: 50%; }

/* ===== Calm (Breathe) ===== */
/* Two views inside one screen: an exercise grid and an immersive session. */
#screen-breathe .calm-session-view { display: none; }
#screen-breathe[data-view="session"] .calm-grid-view { display: none; }
#screen-breathe[data-view="session"] .calm-session-view { display: flex; }

/* --- Exercise grid: premium cards, the primary decision --- */
.exercise-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.exercise-card {
  position: relative; overflow: hidden; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 16px; min-height: 132px; border-radius: 18px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.exercise-card:hover { opacity: 1; border-color: color-mix(in srgb, var(--ex-color) 55%, var(--border)); }
.exercise-card:active { transform: scale(0.97); }
.ex-glow {
  position: absolute; top: -45%; right: -35%; width: 150px; height: 150px;
  border-radius: 50%; background: var(--ex-color); opacity: 0.16; filter: blur(30px); pointer-events: none;
}
.ex-icon {
  position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
  background: color-mix(in srgb, var(--ex-color) 16%, transparent); color: var(--ex-color);
}
.ex-icon [data-lucide] { width: 21px; height: 21px; }
.ex-name { position: relative; z-index: 1; font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); line-height: 1.2; }
.ex-benefit { position: relative; z-index: 1; font-size: var(--t-xs); color: var(--text-secondary); margin-top: 3px; }
.ex-pattern {
  position: relative; z-index: 1; margin-top: auto; padding-top: 12px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--ex-color); letter-spacing: 0.06em;
}

/* --- Session view: immersive single-exercise experience --- */
.calm-session-view {
  position: relative; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100dvh - 140px); padding: 4px 0 8px;
}
.session-bg {
  position: absolute; inset: -24px; z-index: 0; pointer-events: none;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 0.9s ease;
}
.session-bg.show { opacity: 0.16; }
.session-bg-scrim {
  position: absolute; inset: -24px; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 44%, color-mix(in srgb, var(--breath-color) 20%, transparent), transparent 62%);
  transition: opacity 0.6s ease;
}
.calm-session-view.running .session-bg-scrim { opacity: 1.4; }
.session-intro, .breathe-orb-box, .breathe-instr, .breathe-desc,
.breathe-btn, .ambient-section, .session-back { position: relative; z-index: 1; }

.session-back {
  position: absolute; top: 0; left: 0; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-secondary); box-shadow: var(--card-shadow);
  transition: opacity 0.5s ease, color 0.2s ease;
}
.session-back:hover { opacity: 1; color: var(--text-primary); }
.session-back [data-lucide] { width: 22px; height: 22px; }

.session-intro { text-align: center; margin-bottom: 8px; transition: opacity 0.6s ease; }
.session-name { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); }
.session-benefit { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--breath-color); margin-top: 5px; }

.breathe-orb-box { width: 260px; height: 260px; display: flex; align-items: center; justify-content: center; position: relative; margin-top: 24px; }
.orb-ring { position: absolute; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--breath-color) 30%, transparent); animation: ringPulse 7s ease-in-out infinite; }
.orb-ring-1 { width: 190px; height: 190px; opacity: 0.7; animation-delay: 0s; }
.orb-ring-2 { width: 228px; height: 228px; opacity: 0.4; animation-delay: 0.5s; }
.orb-ring-3 { width: 260px; height: 260px; opacity: 0.2; animation-delay: 1s; }
@keyframes ringPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.breathe-orb {
  width: 152px; height: 152px; border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, color-mix(in srgb, var(--breath-color) 55%, #fff), var(--breath-color) 72%);
  box-shadow: 0 0 64px color-mix(in srgb, var(--breath-color) 30%, transparent),
              inset 0 -8px 24px color-mix(in srgb, var(--breath-color) 50%, #000 20%);
  display: flex; align-items: center; justify-content: center;
  transform: scale(0.5);
  transition: transform 0.4s ease-in-out, background 0.3s, box-shadow 0.3s;
}
.breathe-count { font-family: var(--font-mono); font-size: var(--t-xl); font-weight: 600; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,0.2); }
.breathe-instr { font-size: var(--t-lg); font-weight: 500; color: var(--breath-color); margin-top: 30px; min-height: 28px; text-align: center; transition: opacity 0.3s, color 0.3s; }
.breathe-desc { font-size: var(--t-sm); color: var(--text-secondary); text-align: center; max-width: 300px; margin: 12px auto 0; line-height: 1.65; transition: opacity 0.6s ease; }
.breathe-btn {
  margin-top: 22px; padding: 15px 52px; border-radius: var(--radius-pill);
  background: var(--breath-color); color: #fff; font-size: var(--t-md); font-weight: 600;
  box-shadow: 0 10px 28px -10px color-mix(in srgb, var(--breath-color) 75%, transparent);
  transition: background 0.3s, box-shadow 0.3s, transform 0.18s;
}

.ambient-section {
  width: 100%; margin-top: 28px; padding: 18px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--card-shadow);
  transition: opacity 0.6s ease;
}

/* Immersive running state — everything but the orb recedes */
.calm-session-view.running .session-intro,
.calm-session-view.running .breathe-desc,
.calm-session-view.running .ambient-section { opacity: 0; pointer-events: none; }
.calm-session-view.running .session-back { opacity: 0.3; }
.navbar, .top-actions { transition: opacity 0.6s ease-in-out; }
body.breathing .navbar, body.breathing .top-actions { opacity: 0.12; pointer-events: none; }

/* ===== Overview ===== */
.streak-hero { display: flex; align-items: center; gap: 18px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 14px; box-shadow: var(--card-shadow); }
.streak-flame { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; background: rgba(255,159,10,0.12); color: var(--warning); display: flex; align-items: center; justify-content: center; }
.streak-flame [data-lucide] { width: 26px; height: 26px; }
.streak-num { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.streak-label { font-size: var(--t-sm); color: var(--text-secondary); margin-top: 2px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--card-shadow); }
.stat .v { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .v.stat-v-sm { font-size: var(--t-md); font-weight: 600; letter-spacing: -0.01em; }
.stat .l { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

.mood-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; box-shadow: var(--card-shadow); }
.card-title { font-size: var(--t-md); font-weight: 600; margin-bottom: 14px; letter-spacing: -0.01em; }
.mood-bars { display: flex; align-items: flex-end; gap: 5px; height: 64px; }
.mood-bar { flex: 1; border-radius: 3px 3px 0 0; background: var(--bg-tertiary); min-height: 4px; transition: height 0.4s; }
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--card-shadow); }
.log-item .ld { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.log-item .lt { flex: 1; font-size: var(--t-sm); }
.log-item .lm { font-size: var(--t-xs); color: var(--text-tertiary); }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-tertiary); }
.empty-state .ei { display: flex; justify-content: center; margin-bottom: 16px; opacity: 0.4; }
.empty-state .ei [data-lucide] { width: 32px; height: 32px; }
.empty-state .et { font-size: var(--t-sm); line-height: 1.65; }

/* ===== Nav ===== */
.navbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: color-mix(in srgb, var(--bg-secondary) 90%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--border); display: flex; padding: 8px 8px max(env(safe-area-inset-bottom), 8px); z-index: 50; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px; border-radius: var(--radius); color: var(--text-tertiary); }
.nav-item:hover { opacity: 1; color: var(--text-secondary); }
.nav-item .ni { width: 22px; height: 22px; }
.nav-item .nl { font-size: 11px; font-weight: 500; }
.nav-item.active { color: var(--accent); }
.nav-item.active:hover { opacity: 1; }

/* ===== Modal ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: flex-end; justify-content: center; z-index: 100; animation: fadeIn 0.2s; }
.modal-overlay.show { display: flex; }
.modal { background: var(--bg-secondary); width: 100%; max-width: 480px; border: 1px solid var(--border); border-bottom: none; border-radius: 20px 20px 0 0; padding: 24px 24px max(env(safe-area-inset-bottom), 24px); animation: slideUp 0.28s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h3 { font-size: var(--t-lg); font-weight: 600; margin-bottom: 22px; letter-spacing: -0.02em; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: var(--t-sm); color: var(--text-secondary); font-weight: 500; margin-bottom: 7px; }
.field input { width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-tertiary); font-size: var(--t-md); color: var(--text-primary); outline: none; }
.field input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 22px; }
.modal-actions button { flex: 1; padding: 14px; border-radius: var(--radius); font-size: var(--t-md); font-weight: 600; }
.modal-actions .cancel { background: var(--bg-tertiary); color: var(--text-secondary); }
.modal-actions .save { background: var(--accent); color: #fff; }

/* ===== Settings ===== */
.settings-overlay { z-index: 300; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.sheet-head h3 { margin-bottom: 0; }
.sheet-close { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--bg-tertiary); color: var(--text-secondary); }
.sheet-close:hover { opacity: 1; color: var(--text-primary); }
.sheet-close [data-lucide] { width: 17px; height: 17px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-row:last-of-type { border-bottom: none; }
.set-label { font-size: var(--t-sm); font-weight: 500; color: var(--text-primary); }
.set-action { padding: 7px 14px; border-radius: var(--radius-pill); background: var(--bg-tertiary); border: 1px solid var(--border); font-size: var(--t-sm); font-weight: 600; color: var(--text-secondary); }
.set-action:hover { opacity: 1; color: var(--text-primary); border-color: var(--border-strong); }
.set-action:disabled { cursor: default; opacity: 0.6; }
.danger-btn { width: 100%; margin-top: 22px; padding: 14px; border-radius: var(--radius); background: rgba(255,69,58,0.10); color: #FF453A; font-size: var(--t-md); font-weight: 600; transition: background 0.2s; }
.danger-btn:hover { opacity: 1; background: rgba(255,69,58,0.18); }
.danger-btn.confirm { background: #FF453A; color: #fff; }

/* ===== Onboarding ===== */
.onboard { position: fixed; inset: 0; background: var(--bg-primary); z-index: 200; display: none; flex-direction: column; align-items: center; justify-content: center; padding: 48px 32px; }
.onboard.show { display: flex; }
.onboard-slide { display: none; flex-direction: column; align-items: center; text-align: center; max-width: 360px; width: 100%; animation: fadeIn 0.3s; }
.onboard-slide.active { display: flex; }
.onboard-ico { width: 72px; height: 72px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin-bottom: 24px; }
.onboard-ico [data-lucide] { width: 32px; height: 32px; }
.onboard h2 { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.025em; margin-bottom: 8px; }
.onboard p { font-size: var(--t-md); color: var(--text-secondary); margin-bottom: 24px; line-height: 1.65; }
.onboard input { width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-secondary); font-size: var(--t-md); color: var(--text-primary); outline: none; margin-bottom: 14px; text-align: center; -webkit-appearance: none; appearance: none; }
.onboard input:focus { border-color: var(--accent); }
/* Date field wrapper */
.ob-date-wrap { width: 100%; margin-bottom: 14px; }
.ob-date-label { display: block; font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); margin-bottom: 6px; text-align: left; }
/* Restore native appearance so iOS Safari renders the date picker correctly */
.ob-date-inner { position: relative; }
.ob-date-wrap input[type="date"] { -webkit-appearance: auto; appearance: auto; margin-bottom: 0; color: var(--text-primary); min-height: 52px; cursor: pointer; }
/* Overlay hint — visible when no date selected; pointer-events:none lets taps reach the input */
.ob-date-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: var(--t-md); color: var(--text-tertiary); background: var(--bg-secondary); border-radius: var(--radius); border: 1px solid var(--border); pointer-events: none; transition: opacity 0.15s; }
.onboard-btn { width: 100%; padding: 14px; border-radius: var(--radius); background: var(--accent); color: #fff; font-size: var(--t-md); font-weight: 600; }
.onboard-skip { margin-top: 14px; font-size: var(--t-sm); color: var(--text-tertiary); }
.onboard-dots { display: flex; gap: 8px; position: absolute; bottom: max(env(safe-area-inset-bottom), 40px); }
.onboard-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); transition: all 0.3s; }
.onboard-dots span.active { background: var(--accent); width: 24px; border-radius: 4px; }
.ob-logo-img { width: 80px; height: 80px; object-fit: contain; margin-bottom: 24px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text-primary); color: var(--bg-primary); padding: 13px 22px; border-radius: var(--radius-pill); font-size: var(--t-sm); font-weight: 500; opacity: 0; transition: all 0.28s; z-index: 150; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Mood prompt ===== */
.mood-prompt { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none; align-items: center; justify-content: center; z-index: 90; padding: 24px; animation: fadeIn 0.3s; }
.mood-prompt.show { display: flex; }
.mood-box { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 20px; padding: 24px; width: 100%; max-width: 360px; text-align: center; animation: slideUp 0.3s; box-shadow: 0 8px 40px rgba(0,0,0,0.18); }
.mood-box h3 { font-size: var(--t-lg); font-weight: 600; margin-bottom: 6px; letter-spacing: -0.02em; }
.mood-box p { font-size: var(--t-sm); color: var(--text-tertiary); margin-bottom: 22px; }
.mood-faces { display: flex; justify-content: space-between; gap: 8px; }
.mood-face { flex: 1; aspect-ratio: 1; border-radius: var(--radius); background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.mood-face [data-lucide] { width: 24px; height: 24px; }
.mood-face:hover { opacity: 1; color: var(--text-primary); }
.mood-face.sel { background: var(--accent-soft); color: var(--accent); transform: scale(1.05); }
.mood-skip { margin-top: 14px; font-size: var(--t-sm); color: var(--text-tertiary); }

/* ===== Splash ===== */
#splash { position: fixed; inset: 0; z-index: 9999; background: #F7F7F7; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.splash-logo { width: 120px; height: 120px; object-fit: contain; animation: splashLogoIn 0.65s cubic-bezier(0.25,0.1,0.25,1) both; }
.splash-wordmark { font-size: 24px; font-weight: 700; color: #1C1C1E; letter-spacing: -0.025em; animation: splashTitleIn 0.5s ease-out 0.18s both; }
@keyframes splashLogoIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes splashTitleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Session-complete flash ===== */
.flash-overlay { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 9998; }
.flash-overlay.show { animation: flashFade 0.3s ease-out forwards; }
@keyframes flashFade { from { opacity: 0.85; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
