:root {
  color-scheme: dark;
  --bg: #11140f;
  --panel: rgba(18, 24, 20, 0.82);
  --panel-strong: rgba(26, 34, 29, 0.96);
  --line: rgba(216, 224, 207, 0.2);
  --text: #f2f5ee;
  --muted: #aab7a5;
  --accent: #83e6c5;
  --accent-2: #f2c86b;
  --accent-3: #7ca7ff;
  --danger: #ff8f8f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, rgba(131, 230, 197, 0.16), transparent 30%),
    radial-gradient(circle at 80% 10%, rgba(242, 200, 107, 0.12), transparent 28%),
    linear-gradient(135deg, #0e1514 0%, #15180f 48%, #161119 100%);
}

button,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.practice-panel {
  width: min(960px, 100%);
  min-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  padding: clamp(20px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 34%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 7vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: 0;
  max-width: 9ch;
}

.session-pill {
  min-width: 104px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.session-pill span:first-child {
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 850;
}

.breathing-stage {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 30px;
}

.box-wrap {
  width: min(520px, 78vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.breath-box {
  --progress: 0;
  position: relative;
  width: 82%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid rgba(242, 245, 238, 0.16);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 60px rgba(131, 230, 197, 0.08);
}

.box-glow {
  position: absolute;
  inset: 17%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(131, 230, 197, 0.18), transparent 58%),
    radial-gradient(circle, rgba(124, 167, 255, 0.11), transparent 62%);
  filter: blur(8px);
  transform: scale(var(--orb-scale, 0.9));
  transition: transform 900ms ease, opacity 900ms ease;
}

.path {
  position: absolute;
  background: rgba(242, 245, 238, 0.18);
  overflow: hidden;
}

.path::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left;
}

.path-top,
.path-bottom {
  left: 0;
  width: 100%;
  height: 4px;
}

.path-right,
.path-left {
  top: 0;
  width: 4px;
  height: 100%;
}

.path-top {
  top: 0;
}

.path-right {
  right: 0;
}

.path-bottom {
  bottom: 0;
}

.path-left {
  left: 0;
}

.path-right::after,
.path-left::after {
  background: linear-gradient(180deg, var(--accent-2), var(--accent-3));
  transform: scaleY(0);
  transform-origin: top;
}

.path-bottom::after {
  transform-origin: right;
}

.path-left::after {
  transform-origin: bottom;
}

.breath-box[data-step="0"] .path-top::after,
.breath-box[data-step="1"] .path-top::after,
.breath-box[data-step="2"] .path-top::after,
.breath-box[data-step="3"] .path-top::after {
  transform: scaleX(var(--top-fill, 0));
}

.breath-box[data-step="1"] .path-right::after,
.breath-box[data-step="2"] .path-right::after,
.breath-box[data-step="3"] .path-right::after {
  transform: scaleY(var(--right-fill, 0));
}

.breath-box[data-step="2"] .path-bottom::after,
.breath-box[data-step="3"] .path-bottom::after {
  transform: scaleX(var(--bottom-fill, 0));
}

.breath-box[data-step="3"] .path-left::after {
  transform: scaleY(var(--left-fill, 0));
}

.traveler {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  left: calc(var(--dot-x, 0) * 1%);
  top: calc(var(--dot-y, 0) * 1%);
  transform: translate(-50%, -50%);
  background: var(--text);
  box-shadow:
    0 0 0 8px rgba(131, 230, 197, 0.14),
    0 0 28px rgba(131, 230, 197, 0.78);
}

.center-orb {
  position: absolute;
  inset: 29%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: 50%;
  border: 1px solid rgba(242, 245, 238, 0.2);
  background: rgba(15, 20, 18, 0.72);
}

.center-orb span {
  color: var(--muted);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 750;
}

.center-orb strong {
  font-size: clamp(3rem, 12vw, 6.5rem);
  line-height: 0.85;
}

.phase-strip {
  width: min(600px, 100%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.phase {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-weight: 780;
}

.phase.active {
  color: #0d1815;
  background: var(--accent);
  border-color: transparent;
}

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

.primary-button,
.icon-button,
.duration-control select {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  min-width: 142px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  color: #0d1815;
  background: var(--accent);
  font-weight: 850;
}

.button-icon {
  width: 18px;
  text-align: center;
  font-size: 0.84rem;
}

.icon-button {
  width: 48px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
  font-size: 1.5rem;
}

.duration-control {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.94rem;
  font-weight: 750;
}

.duration-control select {
  color: var(--text);
  background: var(--panel-strong);
  padding: 0 32px 0 12px;
}

.primary-button:hover,
.icon-button:hover,
.duration-control select:hover {
  filter: brightness(1.06);
}

.primary-button:focus-visible,
.icon-button:focus-visible,
.duration-control select:focus-visible {
  outline: 3px solid rgba(131, 230, 197, 0.36);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .practice-panel {
    min-height: calc(100vh - 28px);
    gap: 20px;
  }

  .topbar {
    align-items: stretch;
  }

  .session-pill {
    min-width: 82px;
  }

  .box-wrap {
    width: min(390px, 84vw);
  }

  .phase-strip {
    gap: 6px;
  }

  .phase {
    min-height: 38px;
    font-size: 0.82rem;
  }

  .duration-control {
    width: 100%;
    justify-content: space-between;
  }
}
