:root {
  color-scheme: dark;
  --bg: #06100c;
  --surface: #0e1814;
  --surface-raised: #14211b;
  --surface-active: #1c3026;
  --line: #2a3d34;
  --line-strong: #466052;
  --ink: #f4f7f4;
  --muted: #a8b6ae;
  --subtle: #7f9187;
  --accent: #c5ed78;
  --accent-ink: #17200f;
  --phase: #c5ed78;
  --danger: #f19c8e;
  --radius: 14px;
  --z-sticky: 20;
  --z-skip: 40;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% 20%, rgba(52, 108, 77, 0.17), transparent 32rem),
    var(--bg);
  color: var(--ink);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #e2ffab;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: var(--z-skip);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  transform: translate(-50%, -180%);
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  --phase: var(--accent);
}

.app-shell[data-phase="exhale"] {
  --phase: #75dbc3;
}

.app-shell[data-phase="complete"] {
  --phase: #f0cf6c;
}

.app-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 24px 12px 122px;
  border-bottom: 1px solid rgba(80, 105, 91, 0.55);
  background: rgba(6, 16, 12, 0.96);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.brand-pulse {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.brand-lockup p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.header-rate {
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.header-rate strong {
  color: var(--ink);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  width: min(100% - 40px, 1240px);
  min-height: 620px;
  margin: 24px auto 0;
  grid-template-columns: minmax(330px, 430px) minmax(420px, 1fr);
  gap: 22px;
}

.session-panel,
.breath-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.session-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 3vw, 40px);
  background: var(--surface);
}

.research-label {
  align-self: flex-start;
  margin: 0 0 16px;
  padding: 5px 9px;
  border-radius: 7px;
  background: #1b2c23;
  color: #cce7d6;
  font-size: 0.72rem;
  font-weight: 700;
}

.session-panel h2 {
  max-width: 14ch;
  margin: 0;
  font-size: 2.25rem;
  line-height: 1.08;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.hero-body {
  max-width: 58ch;
  margin: 18px 0 0;
  color: #bdc9c1;
  font-size: 0.95rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.pace-facts {
  display: grid;
  margin: 28px 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.pace-facts div {
  min-width: 0;
  padding: 15px 12px 15px 0;
}

.pace-facts div + div {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.pace-facts dt {
  color: var(--subtle);
  font-size: 0.68rem;
}

.pace-facts dd {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.duration-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.duration-fieldset legend {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 720;
}

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

.duration-button {
  display: flex;
  min-width: 0;
  min-height: 66px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 180ms ease-out,
    background-color 180ms ease-out,
    color 180ms ease-out,
    transform 180ms ease-out;
}

.duration-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-active);
  color: var(--ink);
}

.duration-button:active:not(:disabled) {
  transform: translateY(1px);
}

.duration-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.duration-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.duration-button strong {
  font-size: 1.12rem;
  font-variant-numeric: tabular-nums;
}

.duration-button span {
  overflow: hidden;
  font-size: 0.67rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duration-help {
  margin: 10px 0 0;
  color: var(--subtle);
  font-size: 0.69rem;
  line-height: 1.5;
}

.session-actions {
  display: flex;
  margin-top: 22px;
  gap: 9px;
}

.session-actions[hidden] {
  display: none;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 11px 18px;
  border-radius: 10px;
  font-weight: 750;
  cursor: pointer;
  transition:
    background-color 180ms ease-out,
    border-color 180ms ease-out,
    color 180ms ease-out,
    transform 180ms ease-out;
}

.primary-button {
  flex: 1 1 auto;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.primary-button:hover {
  border-color: #d9ff90;
  background: #d9ff90;
}

.secondary-button {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--surface-active);
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.breath-stage {
  display: flex;
  min-width: 0;
  min-height: 620px;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 43%, rgba(197, 237, 120, 0.12), transparent 15rem),
    #09130f;
}

.stage-status {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 0.74rem;
}

.stage-status > span:last-child {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.stage-status strong {
  color: var(--ink);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.breath-visual {
  position: relative;
  display: grid;
  width: min(52vh, 360px);
  height: min(52vh, 360px);
  min-width: 290px;
  min-height: 290px;
  place-items: center;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-track,
.progress-value {
  fill: none;
  stroke-width: 2;
}

.progress-track {
  stroke: #263a30;
}

.progress-value {
  stroke: var(--phase);
  stroke-linecap: round;
  transition: stroke 220ms ease-out;
}

.breath-orb {
  display: grid;
  width: 174px;
  height: 174px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--phase) 18%, #102019);
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.35));
  transform: scale(var(--orb-scale, 0.68));
  will-change: transform;
}

.orb-core {
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background: var(--phase);
  transition:
    background-color 220ms ease-out,
    opacity 220ms ease-out;
}

.phase-seconds {
  position: absolute;
  color: var(--ink);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  pointer-events: none;
}

.phase-copy {
  max-width: 42ch;
  margin-top: -14px;
  text-align: center;
}

.phase-copy h2 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: -0.025em;
}

.phase-copy p {
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.session-progress {
  width: min(100%, 520px);
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.progress-heading,
.progress-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--subtle);
  font-size: 0.68rem;
}

.progress-heading strong,
.progress-caption strong {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 5px;
  margin: 9px 0;
  overflow: hidden;
  border-radius: 3px;
  background: #26382f;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--phase);
}

.app-shell[data-status="paused"] .breath-orb {
  opacity: 0.58;
}

.app-shell[data-status="complete"] .orb-core {
  opacity: 0.75;
}

.support-grid {
  display: grid;
  width: min(100% - 40px, 1240px);
  margin: 54px auto 0;
  grid-template-columns: 1.35fr 1fr;
  gap: 42px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.support-grid article {
  min-width: 0;
}

.support-grid h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.support-grid p {
  max-width: 70ch;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.source-list {
  display: flex;
  margin: 16px 0 0;
  padding: 0;
  flex-wrap: wrap;
  gap: 8px 16px;
  list-style: none;
}

.source-list a {
  color: #c7ead6;
  font-size: 0.72rem;
  line-height: 1.45;
  text-underline-offset: 3px;
}

.source-list a:hover {
  color: var(--ink);
}

.safety-note {
  padding-left: 24px;
  border-left: 1px solid var(--line-strong);
}

.safety-note h2 {
  color: #ffd0c7;
}

.app-footer {
  display: flex;
  width: min(100% - 40px, 1240px);
  margin: 42px auto 0;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 28px;
  color: var(--subtle);
  font-size: 0.68rem;
}

.app-footer p {
  margin: 0;
}

.app-footer span {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff4d8;
  color: #352b18;
  text-align: center;
}

@media (max-width: 900px) {
  .workspace {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  .session-panel {
    min-height: auto;
  }

  .session-panel h2 {
    max-width: 18ch;
  }

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

@media (max-width: 600px) {
  .app-header {
    min-height: 64px;
    gap: 10px;
    padding: 9px 12px 9px 108px;
  }

  .brand-pulse {
    width: 34px;
    height: 34px;
  }

  .brand-lockup p {
    display: none;
  }

  .brand-lockup h1 {
    font-size: 0.93rem;
  }

  .header-rate strong {
    font-size: 1rem;
  }

  .workspace {
    width: calc(100% - 16px);
    margin-top: 8px;
    gap: 8px;
  }

  .session-panel,
  .breath-stage {
    border-radius: 12px;
  }

  .session-panel {
    padding: 19px 16px;
  }

  .research-label {
    margin-bottom: 11px;
  }

  .session-panel h2 {
    max-width: 16ch;
    font-size: 1.75rem;
  }

  .hero-body {
    margin-top: 12px;
    font-size: 0.85rem;
  }

  .pace-facts {
    margin: 20px 0;
  }

  .pace-facts div {
    padding-block: 12px;
  }

  .pace-facts dt {
    font-size: 0.62rem;
  }

  .pace-facts dd {
    font-size: 0.74rem;
  }

  .duration-button {
    min-height: 60px;
    padding-inline: 8px;
  }

  .duration-button span {
    font-size: 0.61rem;
  }

  .session-actions {
    margin-top: 17px;
  }

  .breath-stage {
    min-height: 440px;
    padding: 16px;
  }

  .breath-visual {
    width: 292px;
    height: 292px;
    min-width: 0;
    min-height: 0;
  }

  .breath-orb {
    width: 148px;
    height: 148px;
  }

  .phase-copy {
    margin-top: -8px;
  }

  .phase-copy h2 {
    font-size: 1.45rem;
  }

  .support-grid {
    width: calc(100% - 32px);
    margin-top: 34px;
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }

  .safety-note {
    padding-top: 22px;
    padding-left: 0;
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .app-footer {
    width: calc(100% - 32px);
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .app-header {
    min-height: 58px;
    padding-block: 8px;
  }

  .workspace {
    width: calc(100% - 20px);
    min-height: calc(100dvh - 68px);
    margin-top: 10px;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 10px;
  }

  .session-panel {
    padding: 15px 17px;
  }

  .research-label {
    margin-bottom: 8px;
  }

  .session-panel h2 {
    max-width: 17ch;
    font-size: 1.4rem;
  }

  .hero-body,
  .duration-help {
    display: none;
  }

  .pace-facts {
    margin: 13px 0;
  }

  .pace-facts div {
    padding-block: 9px;
  }

  .duration-button {
    min-height: 54px;
  }

  .session-actions {
    margin-top: 12px;
  }

  .primary-button,
  .secondary-button {
    min-height: 42px;
    padding-block: 8px;
  }

  .breath-stage {
    min-height: calc(100dvh - 68px);
    padding: 14px 18px;
  }

  .breath-visual {
    width: min(54vh, 286px);
    height: min(54vh, 286px);
    min-width: 210px;
    min-height: 210px;
  }

  .breath-orb {
    width: 136px;
    height: 136px;
  }

  .phase-copy {
    margin-top: -10px;
  }

  .phase-copy h2 {
    font-size: 1.25rem;
  }

  .phase-copy p {
    margin-top: 4px;
    font-size: 0.7rem;
  }

  .session-progress {
    padding-top: 9px;
  }

  .support-grid {
    margin-top: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .breath-orb {
    transform: scale(0.82) !important;
  }
}

@media (forced-colors: active) {
  .duration-button[aria-pressed="true"],
  .primary-button {
    border: 2px solid ButtonText;
  }

  .progress-value,
  .progress-bar span {
    stroke: Highlight;
    background: Highlight;
  }
}
