:root {
  --bg-start: #101725;
  --bg-end: #1a2536;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #e5e7eb;
  --muted: #cbd5e1;

  --inhale-1: #86efac;
  --inhale-2: #34d399;
  --hold-1: #c4b5fd;
  --hold-2: #a78bfa;
  --exhale-1: #fda4af;
  --exhale-2: #fb7185;

  --primary: #7dd3fc;
  --primary-strong: #67e8f9;
  --danger: #fca5a5;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  --max-width: 1100px;
}

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

body {
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.5;
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(125, 211, 252, 0.1) 0%, transparent 60%),
    radial-gradient(700px 440px at 100% 0%, rgba(165, 180, 252, 0.1) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-start), var(--bg-end));
}

.app {
  width: min(var(--max-width), 92vw);
  margin: 28px auto;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}

.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.main-panel,
.controls-panel,
.seo-content {
  padding: 18px;
}

h1, h2, h3 { margin: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.35rem, 1.02rem + 1.45vw, 2rem); }
h2 { font-size: 1.04rem; }
h3 { font-size: 0.95rem; margin-bottom: 8px; }

.subtitle { margin: 0; color: var(--muted); }
.controls-header { margin-bottom: 12px; }
.small { margin: 6px 0 0; color: var(--muted); font-size: 0.87rem; }

.breath-stage { display: none; }

.breath-visual {
  width: min(58vw, 290px);
  aspect-ratio: 1;
  margin: 16px auto 8px;
  display: grid;
  place-items: center;
}

.circle {
  --phase-ms: 4000ms;
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 35%, rgba(186, 230, 253, 0.88) 0%, rgba(125, 211, 252, 0.62) 40%, rgba(103, 232, 249, 0.38) 75%, rgba(34, 211, 238, 0.2) 100%);
  border: 1px solid rgba(186, 230, 253, 0.35);
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.12), 0 0 24px rgba(125, 211, 252, 0.16);
  transform: scale(0.92);
  transition:
    transform var(--phase-ms) ease-in-out,
    filter 380ms ease,
    box-shadow 380ms ease,
    background 380ms ease,
    border-color 380ms ease;
  will-change: transform;
}

.circle::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  opacity: 0.7;
  animation: softSpin 14s linear infinite;
  pointer-events: none;
}

.circle-orbit {
  position: absolute;
  top: 7%;
  right: 12%;
  font-size: 1rem;
  opacity: 0.55;
  transform-origin: -92px 92px;
  animation: orbit 8s linear infinite;
  pointer-events: none;
}

.circle-content {
  text-align: center;
  z-index: 1;
  display: grid;
  gap: 2px;
}

.ball-icon {
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.95;
}

.ball-phase-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.ball-countdown {
  font-size: 1.1rem;
  font-weight: 700;
}

.circle.inhale {
  transform: scale(1.03);
  background: radial-gradient(circle at 35% 35%, rgba(220, 252, 231, 0.9) 0%, rgba(134, 239, 172, 0.72) 42%, rgba(52, 211, 153, 0.4) 78%, rgba(16, 185, 129, 0.22) 100%);
  border-color: rgba(134, 239, 172, 0.55);
  box-shadow: inset 0 0 26px rgba(220, 252, 231, 0.18), 0 0 28px rgba(74, 222, 128, 0.22);
}

.circle.hold {
  transform: scale(1.03);
  background: radial-gradient(circle at 35% 35%, rgba(237, 233, 254, 0.92) 0%, rgba(196, 181, 253, 0.72) 42%, rgba(167, 139, 250, 0.42) 78%, rgba(139, 92, 246, 0.22) 100%);
  border-color: rgba(196, 181, 253, 0.52);
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.14), 0 0 24px rgba(167, 139, 250, 0.2);
}

.circle.exhale {
  transform: scale(0.89);
  background: radial-gradient(circle at 35% 35%, rgba(255, 241, 242, 0.92) 0%, rgba(253, 164, 175, 0.72) 42%, rgba(251, 113, 133, 0.42) 78%, rgba(244, 63, 94, 0.24) 100%);
  border-color: rgba(251, 113, 133, 0.52);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.13), 0 0 20px rgba(251, 113, 133, 0.18);
}

/* Distinguish first hold vs second hold (after exhale) */
.circle.hold-in {
  transform: scale(1.03);
  background: radial-gradient(circle at 35% 35%, rgba(237, 233, 254, 0.92) 0%, rgba(196, 181, 253, 0.72) 42%, rgba(167, 139, 250, 0.42) 78%, rgba(139, 92, 246, 0.22) 100%);
  border-color: rgba(196, 181, 253, 0.52);
  box-shadow: inset 0 0 24px rgba(255, 255, 255, 0.14), 0 0 24px rgba(167, 139, 250, 0.2);
}

.circle.hold-out {
  transform: scale(0.89);
  background: radial-gradient(circle at 35% 35%, rgba(237, 233, 254, 0.88) 0%, rgba(196, 181, 253, 0.62) 42%, rgba(167, 139, 250, 0.36) 78%, rgba(139, 92, 246, 0.2) 100%);
  border-color: rgba(196, 181, 253, 0.48);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.12), 0 0 20px rgba(167, 139, 250, 0.16);
}

.progress-wrap { margin-top: 14px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 6px;
}
.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(203, 213, 225, 0.25);
}
.progress > span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
  transition: width 100ms linear;
}

.buttons { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 9px; }
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #0f172a; }
.btn-ghost { background: rgba(203, 213, 225, 0.25); color: var(--text); }
.btn-danger { background: rgba(252, 165, 165, 0.25); color: #fee2e2; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.form-grid { display: grid; gap: 12px; }
.inline-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 6px; }
label { color: var(--muted); font-size: 0.87rem; }
input[type="number"],
select {
  width: 100%;
  border: 1px solid rgba(203, 213, 225, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  padding: 10px 11px;
}

.session-mode,
.audio-guidance {
  border: 1px solid rgba(203, 213, 225, 0.25);
  border-radius: var(--radius-md);
  padding: 10px;
  margin: 0;
}

.session-mode legend,
.audio-guidance legend {
  color: var(--muted);
  padding: 0 6px;
  font-size: 0.85rem;
}

.radio-line,
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 8px;
  color: var(--text);
  font-size: 0.9rem;
}

.radio-line input,
.check-line input {
  margin: 0;
}

.range-line input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.stats {
  margin-top: 14px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.42);
  border: 1px solid rgba(203, 213, 225, 0.2);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  text-align: center;
}
.stat-value { font-size: 1.05rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.79rem; }

.summary-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(203, 213, 225, 0.2);
  background: rgba(15, 23, 42, 0.38);
}
.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}
.summary-list span { color: var(--muted); }

.seo-content h2 { margin-bottom: 10px; }
.seo-content h3 { margin-top: 14px; margin-bottom: 8px; }
.seo-content p,
.seo-content li {
  color: #d7e0f2;
  font-size: 0.95rem;
}
.seo-content ul,
.seo-content ol {
  margin-top: 8px;
  padding-left: 20px;
}

.helper { margin: 10px 0 0; color: var(--muted); font-size: 0.82rem; }

footer {
  width: min(var(--max-width), 92vw);
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

@keyframes orbit {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes softSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

@media (min-width: 900px) {
  .app { grid-template-columns: 1.02fr 0.98fr; }
  .seo-content { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .inline-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .buttons .btn { flex: 1 1 calc(50% - 9px); }
  .breath-visual { width: min(76vw, 280px); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
  .buttons .btn { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .circle,
  .progress > span,
  .circle::before,
  .circle-orbit {
    transition: none !important;
    animation: none !important;
  }
}
