* {
  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;
}

.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: 32px;
}

.hero h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.hero p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
}

.card,
.panel,
.benefits,
.modal-card {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.main-card {
  padding: 32px 20px;
  margin-bottom: 24px;
}

.circle-stage {
  position: relative;
  min-height: 260px;
  display: grid;
  place-items: center;
  margin-bottom: 24px;
}

.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;
}

.phase-label {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: bold;
  margin-bottom: 8px;
}

.phase-time {
  font-size: 1.5rem;
  font-weight: bold;
}

.timer-wrap {
  text-align: center;
  margin-bottom: 28px;
}

.session-time {
  font-size: 2.3rem;
  font-weight: bold;
  letter-spacing: 1px;
}

.timer-caption {
  color: #94a3b8;
  margin-top: 6px;
}

.controls,
.sound-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.save-session {
  margin-top: 20px;
  text-align: center;
}

.panel {
  padding: 20px;
  margin-bottom: 24px;
}

.panel h3,
.benefits h3 {
  margin-top: 0;
  margin-bottom: 16px;
  text-align: center;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pattern-btn,
.sound-btn,
.btn,
.icon-btn {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  cursor: pointer;
  transition: 0.2s ease;
  font: inherit;
}

.pattern-btn,
.sound-btn {
  border-radius: 14px;
  padding: 14px 10px;
  font-weight: bold;
}

.pattern-btn span {
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.85;
}

.pattern-btn:hover,
.sound-btn:hover,
.btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.pattern-btn.active,
.sound-btn.active {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary1), var(--primary2));
}

.sound-btn.active {
  background: linear-gradient(135deg, var(--indigo1), var(--indigo2));
}

.btn {
  border-radius: 16px;
  padding: 14px 22px;
  font-weight: bold;
}

.btn-primary {
  color: white;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary1), var(--primary2));
}

.btn-secondary {
  background: white;
}

.btn-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #a7f3d0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.benefits {
  padding: 24px;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
}

.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: 0.95rem;
}

.footer {
  text-align: center;
  padding: 24px 16px 28px;
  color: #94a3b8;
  font-size: 0.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) {
  .pattern-grid,
  .benefit-grid {
    grid-template-columns: 1fr;
  }

  .hero h2 {
    font-size: 1.7rem;
  }

  .session-time {
    font-size: 2rem;
  }
}