:root {
  --bg-top: #bfe5e5;
  --bg-mid: #e6f4ee;
  --bg-bottom: #f7e7cf;
  --ink: #14313a;
  --muted: #59727a;
  --panel: rgba(255, 255, 255, 0.66);
  --panel-solid: #f8fbf7;
  --line: rgba(20, 49, 58, 0.14);
  --accent: #2b8f8a;
  --accent-deep: #176864;
  --accent-soft: rgba(43, 143, 138, 0.2);
  --warm: #d99164;
  --shadow: 0 24px 70px rgba(25, 72, 77, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.7) 0 9rem, transparent 9.2rem),
    linear-gradient(165deg, var(--bg-top), var(--bg-mid) 54%, var(--bg-bottom));
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: stretch;
}

.breath-stage,
.settings-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.breath-stage {
  position: relative;
  min-height: calc(100vh - 56px);
  padding: clamp(22px, 4vw, 42px);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.cloud {
  position: absolute;
  width: 190px;
  height: 62px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  filter: blur(1px);
  animation: drift 22s linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 82px;
  height: 82px;
  left: 35px;
  top: -36px;
}

.cloud::after {
  width: 70px;
  height: 70px;
  right: 38px;
  top: -26px;
}

.cloud-one {
  top: 18%;
  left: -220px;
}

.cloud-two {
  top: 62%;
  left: -280px;
  width: 260px;
  opacity: 0.6;
  animation-duration: 31s;
  animation-delay: -9s;
}

.cloud-three {
  top: 39%;
  left: -180px;
  width: 140px;
  opacity: 0.45;
  animation-duration: 28s;
  animation-delay: -16s;
}

@keyframes drift {
  to {
    transform: translateX(calc(100vw + 520px));
  }
}

.session-topbar,
.orb-wrap,
.controls-row {
  position: relative;
  z-index: 1;
}

.session-topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow,
.phase-hint,
.section-heading span,
.stats-grid span,
.time-control span,
.slider-control span,
.toggle-row span {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.session-chip {
  flex: 0 0 auto;
  min-width: 92px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--accent-deep);
  font-weight: 800;
}

.orb-wrap {
  min-height: 480px;
  display: grid;
  place-items: center;
}

.breath-ring {
  width: min(54vh, 430px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.3), transparent 65%),
    conic-gradient(from 180deg, rgba(43, 143, 138, 0.28), rgba(217, 145, 100, 0.24), rgba(43, 143, 138, 0.28));
  transition: transform 1s ease-in-out;
}

.breath-orb {
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 38% 32%, rgba(255, 255, 255, 0.94), rgba(125, 196, 190, 0.74) 42%, rgba(43, 143, 138, 0.46));
  box-shadow: 0 34px 70px rgba(23, 104, 100, 0.28), inset 0 -24px 46px rgba(23, 104, 100, 0.12);
  transform: scale(0.76);
  transition: transform 1s ease-in-out, background 0.8s ease;
}

.orb-glow {
  position: absolute;
  width: 23%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.66);
  transform: translate(-42%, -58%);
}

.orb-core {
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.56);
  background: rgba(255, 255, 255, 0.18);
}

.breath-ring.inhale .breath-orb {
  transform: scale(1);
}

.breath-ring.hold .breath-orb {
  transform: scale(1);
  background: radial-gradient(circle at 38% 32%, rgba(255, 255, 255, 0.94), rgba(231, 173, 126, 0.74) 42%, rgba(217, 145, 100, 0.44));
}

.breath-ring.exhale .breath-orb {
  transform: scale(0.62);
}

.breath-readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  pointer-events: none;
  padding: 30px;
}

.phase-label {
  margin-bottom: 8px;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 850;
}

.countdown {
  margin-bottom: 8px;
  font-size: clamp(4.5rem, 11vw, 8.5rem);
  line-height: 0.86;
  font-weight: 900;
  letter-spacing: 0;
}

.phase-hint {
  width: min(320px, 86%);
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.45;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.primary-action,
.icon-button,
.preset {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-action:hover,
.icon-button:hover,
.preset:hover,
.swatch:hover {
  transform: translateY(-1px);
}

.primary-action {
  min-width: 154px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  box-shadow: 0 14px 30px rgba(43, 143, 138, 0.24);
}

.icon-button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.58);
  color: var(--accent-deep);
  font-size: 1.25rem;
  font-weight: 900;
}

.icon-button.active {
  background: var(--accent-soft);
  border-color: rgba(43, 143, 138, 0.42);
}

.settings-panel {
  min-height: calc(100vh - 56px);
  padding: 18px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section {
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.section-heading {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading span {
  font-size: 0.9rem;
  font-weight: 750;
}

.timing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.time-control {
  display: grid;
  gap: 7px;
}

.time-control span,
.slider-control span {
  font-size: 0.82rem;
  font-weight: 800;
}

.time-control input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.preset-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.preset {
  min-height: 40px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font-weight: 850;
}

.preset.active {
  background: var(--accent-soft);
  border-color: rgba(43, 143, 138, 0.44);
  color: var(--accent-deep);
}

.slider-control {
  display: grid;
  gap: 12px;
}

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

.stats-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.stats-grid div {
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  display: grid;
  align-content: center;
  gap: 6px;
}

.stats-grid span {
  font-size: 0.76rem;
  font-weight: 800;
}

.stats-grid strong {
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.05;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.swatch {
  min-height: 54px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, #9fd2d1, #f3d9b6);
  box-shadow: inset 0 0 0 1px rgba(20, 49, 58, 0.1);
}

.swatch.sunset {
  background: linear-gradient(135deg, #f0b28d, #9cc8d6);
}

.swatch.forest {
  background: linear-gradient(135deg, #8bb99f, #d8d1a4);
}

.swatch.active {
  border-color: var(--accent-deep);
}

.toggle-row {
  margin-top: 14px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.toggle-row span {
  font-weight: 800;
}

.toggle-row input {
  width: 44px;
  height: 24px;
  accent-color: var(--accent);
}

body[data-theme="sunset"] {
  --bg-top: #f1c0a1;
  --bg-mid: #dfe9dc;
  --bg-bottom: #9ec7d7;
  --ink: #352a2f;
  --muted: #725f62;
  --accent: #bd6d55;
  --accent-deep: #874534;
  --accent-soft: rgba(189, 109, 85, 0.2);
  --warm: #3e8394;
}

body[data-theme="forest"] {
  --bg-top: #aacbb9;
  --bg-mid: #eef0d4;
  --bg-bottom: #c7dca8;
  --ink: #1d3028;
  --muted: #5f715f;
  --accent: #5e9c78;
  --accent-deep: #38684d;
  --accent-soft: rgba(94, 156, 120, 0.22);
  --warm: #b29c58;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .breath-stage,
  .settings-panel {
    min-height: auto;
  }

  .breath-stage {
    min-height: 680px;
  }

  .settings-panel {
    margin-bottom: 22px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
    gap: 12px;
  }

  .breath-stage {
    min-height: 610px;
    padding: 18px;
  }

  .session-topbar {
    align-items: flex-start;
  }

  .session-chip {
    min-width: 76px;
    font-size: 0.86rem;
  }

  .orb-wrap {
    min-height: 410px;
  }

  .breath-ring {
    width: min(80vw, 350px);
  }

  .timing-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .controls-row {
    justify-content: stretch;
  }

  .primary-action {
    flex: 1;
  }
}
