* {
  box-sizing: border-box;
}

:root {
  --bg1: #f8fafc;
  --bg2: #f5f3ff;
  --bg3: #eef2ff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary1: #10b981;
  --primary2: #0f766e;
  --indigo1: #6366f1;
  --indigo2: #7c3aed;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --shadow: 0 18px 40px rgba(99, 102, 241, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg1), var(--bg2), var(--bg3));
  min-height: 100%;
}

body { min-height: 100vh; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: min(100%, 1000px); margin: 0 auto; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(226,232,240,0.8);
}
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-actions { display: flex; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  color: white; font-weight: bold; background: linear-gradient(135deg, #34d399, #14b8a6);
}
.brand h1 { margin: 0; font-size: 1.2rem; }
.main-content { padding-top: 32px; padding-bottom: 32px; }
.hero { text-align: center; margin-bottom: 24px; }
.hero h2 { margin: 0 0 8px; font-size: 2rem; }
.hero p { margin: 0 auto; max-width: 560px; color: var(--muted); }
.card, .benefits, .modal-card {
  background: var(--card); border-radius: var(--radius-xl); box-shadow: var(--shadow);
}
.intro-card, .main-card, .reflection-card, .result-card { padding: 24px 20px; margin-bottom: 24px; }
.main-card { padding-top: 28px; }
.intro-copy h3, .session-title { margin: 0 0 8px; }
.intro-copy p { margin: 0; color: var(--muted); }
.eyebrow {
  text-transform: uppercase; letter-spacing: 1px; font-size: .75rem; color: var(--muted); font-weight: bold;
}
.state-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0;
}
.state-btn, .sound-btn, .reflection-btn, .btn, .icon-btn {
  border: 1px solid var(--border); background: white; color: var(--text);
  cursor: pointer; transition: .2s ease; font: inherit;
}
.state-btn {
  border-radius: 16px; padding: 16px; text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.state-title { font-weight: bold; }
.state-sub { font-size: .86rem; color: var(--muted); }
.state-btn.active {
  border-color: transparent; color: white; background: linear-gradient(135deg, var(--primary1), var(--primary2));
}
.state-btn.active .state-sub { color: rgba(255,255,255,0.88); }
.protocol-preview {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #f0fdf4, #ecfeff); border: 1px solid #d1fae5;
  border-radius: 18px; padding: 16px; margin-bottom: 20px;
}
.protocol-name { font-size: 1.1rem; font-weight: bold; margin-top: 4px; }
.protocol-meta, .protocol-intro { color: var(--muted); }
.protocol-intro { max-width: 420px; }
.session-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px;
}
.status-badge {
  padding: 8px 12px; border-radius: 999px; background: #f8fafc; border: 1px solid var(--border); font-size: .9rem;
}
.circle-stage { position: relative; min-height: 260px; display: grid; place-items: center; margin-bottom: 18px; }
.breathing-circle {
  width: 120px; height: 120px; border-radius: 999px;
  transition: width 1s ease, height 1s ease, background 1s ease, box-shadow 1s ease;
  box-shadow: 0 18px 40px rgba(16, 185, 129, 0.20);
}
.breathing-circle.inhale { background: linear-gradient(135deg, #86efac, #2dd4bf); }
.breathing-circle.hold { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.breathing-circle.exhale { background: linear-gradient(135deg, #2dd4bf, #10b981); }
.circle-label { position: absolute; text-align: center; z-index: 2; width: min(100%, 320px); }
.phase-label {
  text-transform: uppercase; letter-spacing: 1px; font-size: 0.8rem; color: var(--muted); font-weight: bold; margin-bottom: 8px;
}
.phase-cue { font-size: 1rem; margin-bottom: 8px; color: var(--text); }
.phase-time { font-size: 1.5rem; font-weight: bold; }
.timer-wrap { text-align: center; margin-bottom: 24px; }
.session-time { font-size: 2.3rem; font-weight: bold; letter-spacing: 1px; }
.timer-caption { color: #94a3b8; margin-top: 6px; }
.controls, .sound-grid, .reflection-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.center-controls { justify-content: center; }
.sound-panel {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid #edf2f7;
}
.sound-title { text-align: center; margin-bottom: 10px; }
.sound-btn, .reflection-btn {
  border-radius: 14px; padding: 12px 14px; font-weight: bold;
}
.sound-btn.active {
  color: white; border-color: transparent; background: linear-gradient(135deg, var(--indigo1), var(--indigo2));
}
.reflection-btn:hover, .state-btn:hover, .sound-btn:hover, .btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.btn { border-radius: 16px; padding: 14px 22px; font-weight: bold; }
.btn-sm { padding: 10px 14px; border-radius: 12px; }
.btn-primary { color: white; border-color: transparent; background: linear-gradient(135deg, var(--primary1), var(--primary2)); }
.btn-secondary { background: white; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.reflection-grid { margin-top: 18px; }
.result-metrics {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; margin-bottom: 20px;
}
.metric-box {
  padding: 16px; border-radius: 16px; background: #f8fafc; border: 1px solid #e2e8f0; text-align: center;
}
.metric-label { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.metric-value { font-size: 1.8rem; font-weight: bold; }
.benefits { padding: 24px; background: linear-gradient(135deg, #eef2ff, #f5f3ff); }
.benefits h3 { margin-top: 0; margin-bottom: 16px; text-align: center; font-size: .95rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.benefit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.benefit-item { background: rgba(255,255,255,0.7); border-radius: 16px; padding: 16px; }
.benefit-item h4 { margin: 0 0 8px; }
.benefit-item p { margin: 0; color: var(--muted); font-size: .95rem; }
.footer { text-align: center; padding: 24px 16px 28px; color: #94a3b8; font-size: .92rem; margin-top: auto; }
.modal { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-card { position: relative; z-index: 2; width: min(100% - 24px, 520px); margin: 8vh auto 0; padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { margin: 0; }
.icon-btn { border-radius: 10px; padding: 8px 10px; }
.stats-empty { text-align: center; padding: 24px 8px; }
.empty-icon {
  width: 64px; height: 64px; border-radius: 999px; display: grid; place-items: center; background: #f1f5f9; color: #94a3b8; margin: 0 auto 16px; font-size: 1.6rem;
}
.stats-summary { text-align: center; margin-bottom: 20px; }
.session-count { font-size: 2.5rem; font-weight: bold; color: #059669; }
.session-list { display: grid; gap: 10px; }
.session-row {
  display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #f8fafc; border-radius: 14px;
}
.stats-total {
  display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0;
}
.hidden { display: none !important; }

@media (max-width: 700px) {
  .state-grid, .benefit-grid, .result-metrics { grid-template-columns: 1fr; }
  .topbar-inner { align-items: flex-start; padding: 12px 0; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .hero h2 { font-size: 1.7rem; }
  .session-time { font-size: 2rem; }
  .protocol-preview, .session-header { flex-direction: column; align-items: flex-start; }
}
