@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400;500;600&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --primary: #80CBC4;
  --secondary: #4DB6AC;
  --accent: #26A69A;
  --warm: #00897B;
  --light: #E0F2F1;
  --bg: #1a1118;
  --bg-card: #2a1f25;
  --bg-card-hover: #352830;
  --text: #FFF8E1;
  --text-muted: #c9a88c;
  --text-dim: #8a7068;
  --shadow: rgba(211, 47, 47, 0.15);
  --glow: rgba(255, 152, 0, 0.2);
  --ring-bg: rgba(255, 248, 225, 0.08);
  --ring-progress: #FF9800;
}

::selection {
  background: var(--primary);
  color: var(--light);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 80px;
  position: relative;
}

/* Header */
.app-header {
  text-align: center;
  padding: 2rem 1.5rem 1rem;
  position: relative;
  overflow: hidden;
}

.header-glow {
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--shadow) 0%, transparent 70%);
  pointer-events: none;
}

.app-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--light);
  position: relative;
}

.app-subtitle {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

/* Main */
.app-main {
  flex: 1;
  padding: 0 1.25rem;
}

/* Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: rgba(26, 17, 24, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 248, 225, 0.06);
  padding: 0.5rem 1rem;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s ease;
  font-family: 'DM Sans', sans-serif;
  min-height: 48px;
}

.tab-btn.active {
  color: var(--accent);
}

.tab-icon {
  font-size: 1.3rem;
}

.tab-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Fade In Animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

/* Timer Setup */
.timer-container {
  padding-top: 1rem;
}

.setup-section {
  margin-bottom: 1.75rem;
}

.setup-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.duration-btn {
  padding: 0.75rem 0.5rem;
  border: 1px solid rgba(255, 248, 225, 0.1);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.duration-btn:hover {
  background: var(--bg-card-hover);
}

.duration-btn.selected {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-color: var(--secondary);
  color: var(--light);
  box-shadow: 0 4px 20px var(--shadow);
}

.sound-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.sound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid rgba(255, 248, 225, 0.1);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.sound-btn:hover {
  background: var(--bg-card-hover);
}

.sound-btn.selected {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-color: var(--secondary);
  color: var(--light);
  box-shadow: 0 4px 20px var(--shadow);
}

.sound-emoji {
  font-size: 1.3rem;
}

.sound-name {
  font-size: 0.7rem;
  font-weight: 500;
}

.btn-start {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
  color: var(--light);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  box-shadow: 0 8px 32px var(--shadow);
  transition: transform 0.2s ease;
  min-height: 56px;
}

.btn-start:hover {
  transform: scale(1.02);
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.btn-start-icon {
  font-size: 1.2rem;
}

/* Timer Active */
.timer-active {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2rem;
}

.timer-ring-container {
  position: relative;
  width: 260px;
  height: 260px;
  margin-bottom: 2.5rem;
}

.timer-ring {
  width: 100%;
  height: 100%;
}

.timer-ring-bg {
  stroke: var(--ring-bg);
}

.timer-ring-progress {
  stroke: var(--ring-progress);
  transition: stroke-dashoffset 1s linear;
  filter: drop-shadow(0 0 8px var(--glow));
}

.timer-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.timer-time {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.2rem;
  font-weight: 300;
  color: var(--light);
  letter-spacing: 0.05em;
}

.timer-sound-label {
  font-size: 1.5rem;
  margin-top: 0.25rem;
  display: block;
}

.timer-controls {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.btn-control {
  flex: 1;
  padding: 0.85rem;
  border: none;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
}

.btn-pause {
  background: var(--bg-card);
  color: var(--accent);
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.btn-resume {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--light);
  box-shadow: 0 4px 16px var(--shadow);
}

.btn-cancel {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid rgba(255, 248, 225, 0.08);
}

.btn-control:hover {
  transform: scale(1.02);
}

/* Complete Screen */
.complete-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 3rem;
}

.complete-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.complete-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--light);
  margin-bottom: 0.5rem;
}

.complete-text {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.complete-quote {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--text-dim);
  padding: 1.25rem;
  border-left: 2px solid var(--accent);
  margin-bottom: 2rem;
  text-align: left;
  max-width: 300px;
}

.btn-primary {
  padding: 0.85rem 2rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform 0.2s ease;
  min-height: 48px;
}

.btn-primary:hover {
  transform: scale(1.02);
}

/* Stats */
.stats-container {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

.stats-hero {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.stat-streak {
  background: linear-gradient(135deg, var(--bg-card), rgba(211, 47, 47, 0.15)) !important;
  border: 1px solid rgba(255, 87, 34, 0.2) !important;
  text-align: center;
  padding: 1.5rem 3rem !important;
}

.stat-flame {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 248, 225, 0.06);
  border-radius: 14px;
  padding: 1.1rem;
  text-align: center;
}

.stat-wide {
  margin-bottom: 0.75rem;
}

.stat-icon {
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--light);
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.15rem;
}

/* Week Chart */
.week-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-align: center;
}

.week-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 100px;
  gap: 0.25rem;
}

.week-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.week-bar-container {
  width: 100%;
  max-width: 28px;
  height: 70px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.week-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, var(--primary), var(--accent));
  height: var(--bar-height, 0%);
  min-height: 3px;
  transition: height 0.5s ease;
}

.week-day {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* Session Log */
.log-container {
  padding-top: 0.5rem;
  padding-bottom: 1rem;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.25rem;
}

.log-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--light);
}

.log-count {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.log-group {
  margin-bottom: 1.25rem;
}

.log-date-header {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid rgba(255, 248, 225, 0.05);
  border-radius: 10px;
  margin-bottom: 0.4rem;
  animation: slideIn 0.3s ease forwards;
  animation-delay: var(--item-delay, 0s);
  opacity: 0;
  animation-fill-mode: both;
  transition: background 0.2s ease;
}

.log-item:hover {
  background: var(--bg-card-hover);
}

.log-item-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.log-item-duration {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--accent);
  min-width: 40px;
}

.log-item-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.log-item-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.log-item-sound {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.log-item-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.log-item:hover .log-item-delete {
  opacity: 1;
}

.log-item-delete:hover {
  color: var(--primary);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 1rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.empty-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Skeleton */
.skeleton-card {
  background: var(--bg-card);
  border-radius: 14px;
  height: 80px;
  margin-bottom: 0.75rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.7; }
}

/* Focus styles */
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 360px) {
  .duration-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sound-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .timer-time {
    font-size: 2.5rem;
  }

  .timer-ring-container {
    width: 220px;
    height: 220px;
  }
}


<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to Ember Glow, your personal meditation companion. The warm, dark interface is designed to create a calm atmosphere.", "view": "user", "highlight_selector": ".app-header", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Choose your meditation duration — 5, 10, 15, or 20 minutes. Each button lights up when selected.", "view": "user", "highlight_selector": ".duration-grid", "wait_for": "user_interaction"},
  {"step": 3, "narration": "Pick an ambient sound to accompany your session: rain, ocean waves, bells, or meditate in silence.", "view": "user", "highlight_selector": ".sound-grid", "wait_for": "user_interaction"},
  {"step": 4, "narration": "Tap 'Begin Meditation' to start. A glowing ring shows your progress as time counts down.", "view": "user", "highlight_selector": ".btn-start", "wait_for": "user_interaction"},
  {"step": 5, "narration": "During meditation, you can pause or end your session at any time with these controls.", "view": "user", "highlight_selector": ".timer-controls", "wait_for": "tap_to_continue"},
  {"step": 6, "narration": "Check the Stats tab to see your meditation streak, total time, average session length, and a weekly chart.", "view": "user", "highlight_selector": ".tab-btn:nth-child(2)", "wait_for": "user_interaction"},
  {"step": 7, "narration": "The History tab shows all your completed sessions grouped by date, with duration and sound details.", "view": "user", "highlight_selector": ".tab-btn:nth-child(3)", "wait_for": "user_interaction"}
]
-->

.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}

.auth-screen {
  width: 100%;
  text-align: center;
  position: relative;
  padding: 3rem 1.5rem;
}

.auth-status,
.auth-loading {
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 248, 225, 0.12);
}

.user-avatar-fallback {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--light);
  font-weight: 600;
  border: 1px solid rgba(255, 248, 225, 0.12);
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 0.9rem;
  color: var(--light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.btn-logout {
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 248, 225, 0.08);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.btn-logout:hover {
  background: var(--bg-card-hover);
  color: var(--light);
}

@media (max-width: 360px) {
  .auth-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-logout {
    width: 100%;
  }
}

.presence-panel {
  margin: 0 0 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.presence-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.presence-title {
  margin: 0;
  font-size: 1rem;
}

.presence-count {
  font-size: 0.85rem;
  opacity: 0.8;
}

.presence-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.presence-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.presence-avatar,
.presence-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 700;
}

.presence-meta {
  display: flex;
  flex-direction: column;
}

.presence-name {
  font-weight: 600;
}

.presence-status,
.presence-empty {
  font-size: 0.9rem;
  opacity: 0.8;
}

.analytics-chart-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 248, 225, 0.06);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.analytics-chart-header {
  margin-bottom: 0.9rem;
}

.analytics-chart-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--light);
  margin-bottom: 0.2rem;
}

.analytics-chart-subtitle {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.analytics-chart-canvas-wrap {
  position: relative;
  height: 220px;
}

.analytics-chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.empty-chart-state {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  border: 1px dashed rgba(255, 248, 225, 0.08);
  border-radius: 12px;
}

.ai-analysis-card {
  text-align: left;
}

.ai-analysis-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.ai-analysis-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--light);
  margin-top: 0.1rem;
}

.ai-analysis-state,
.ai-analysis-content {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.ai-analysis-loading {
  color: var(--text-dim);
}

.ai-analysis-error {
  color: #ff9a9a;
}

.ai-analysis-content {
  color: var(--text-muted);
}

.share-card {
  text-align: left;
}

.share-card-copy {
  margin-bottom: 1rem;
}

.share-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--light);
  margin-top: 0.15rem;
  margin-bottom: 0.35rem;
}

.share-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.share-actions {
  display: grid;
  gap: 0.75rem;
}

.btn-share {
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--light);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform 0.2s ease, opacity 0.2s ease;
  min-height: 48px;
}

.btn-share:hover {
  transform: scale(1.02);
}

.share-link {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 248, 225, 0.08);
  background: var(--bg-card-hover);
  color: var(--text-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  outline: none;
}

.share-link:focus {
  border-color: rgba(255, 152, 0, 0.35);
}
