:root {
  color-scheme: dark;
  --bg-base: #061118;
  --bg-deep: #02070d;
  --bg-radial: rgba(83, 133, 151, 0.18);
  --panel: rgba(8, 22, 32, 0.78);
  --panel-strong: rgba(8, 22, 32, 0.88);
  --panel-border: rgba(166, 212, 218, 0.12);
  --text-main: #edf5f3;
  --text-soft: rgba(237, 245, 243, 0.68);
  --accent: #a7f0d8;
  --accent-soft: rgba(167, 240, 216, 0.08);
  --accent-border: rgba(167, 240, 216, 0.2);
  --surface-soft: rgba(255, 255, 255, 0.03);
  --surface-strong: rgba(255, 255, 255, 0.04);
  --surface-border: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(6, 14, 20, 0.8);
  --drawer-bg: rgba(4, 13, 19, 0.96);
  --backdrop: rgba(2, 7, 13, 0.58);
  --glow-left: rgba(126, 192, 186, 0.42);
  --glow-right: rgba(245, 224, 160, 0.2);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --core-scale: 0.72;
  --core-glow: 0.3;
  --core-highlight: rgba(242, 228, 166, 0.82);
  --core-mid: rgba(117, 214, 191, 0.7);
  --core-deep: rgba(18, 66, 82, 0.95);
  --core-halo: rgba(167, 240, 216, 0.08);
  --top-control-inset: 1.5rem;
  --top-control-height: 3rem;
  --footer-reserve: 5.5rem;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(ellipse 50rem 34rem at 50% -8rem, var(--bg-radial), transparent 85%),
    linear-gradient(180deg, var(--bg-base) 0, var(--bg-deep) 52rem);
  background-color: var(--bg-deep);
  overflow-x: hidden;
  overflow-y: auto;
}

button,
input,
select {
  font: inherit;
}

input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.page-glow {
  position: fixed;
  width: clamp(24rem, 34vw, 38rem);
  height: clamp(24rem, 34vw, 38rem);
  border-radius: 999px;
  filter: blur(64px);
  opacity: 0.2;
  pointer-events: none;
}

.page-glow-left {
  top: -7rem;
  left: -8rem;
  background: var(--glow-left);
}

.page-glow-right {
  right: -8rem;
  bottom: -9rem;
  background: var(--glow-right);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 220ms ease;
}

.language-switcher {
  position: fixed;
  top: max(var(--top-control-inset), env(safe-area-inset-top));
  z-index: 15;
  left: 9.75rem;
  transform: none;
}

body[data-active-mode="selection"] .language-switcher {
  left: 50%;
  transform: translateX(-50%);
}

.language-select {
  min-width: 9rem;
  height: var(--top-control-height);
  padding: 0 2.5rem 0 1rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent-border) 115%, var(--surface-border));
  color: var(--text-main);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel) 92%, rgba(255, 255, 255, 0.02)), color-mix(in srgb, var(--panel-strong) 97%, black)),
    var(--panel);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.2),
    0 0 0 0.22rem color-mix(in srgb, var(--accent-soft) 64%, transparent);
  backdrop-filter: blur(10px);
  appearance: none;
  cursor: pointer;
}

.language-select:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 3px;
}

.drawer-backdrop.is-visible {
  opacity: 1;
}

.app-shell {
  min-height: calc(100vh - var(--footer-reserve));
  min-height: calc(100svh - var(--footer-reserve));
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.meditation-stage {
  width: min(100%, 54rem);
  min-height: calc(100vh - 3rem - var(--footer-reserve));
  min-height: calc(100svh - 3rem - var(--footer-reserve));
  position: relative;
  display: grid;
  place-items: center;
}

.session-experience {
  width: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  align-content: start;
  justify-items: center;
  text-align: center;
  gap: 0.6rem;
  --session-visual-size: min(28rem, 40svh);
}

/* One background and normal-flow rows: nothing slides underneath the brand. */
body:is([data-active-mode="guided"], [data-active-mode="free"]) .app-shell {
  min-height: 100svh;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

body:is([data-active-mode="guided"], [data-active-mode="free"]) .meditation-stage {
  width: 100%;
  min-height: 0;
}

body:is([data-active-mode="guided"], [data-active-mode="free"]) .app-footer {
  display: none;
}

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

.mode-selection-screen {
  width: 100%;
  display: grid;
  place-items: center;
  gap: 1.15rem;
}

.mode-selection-screen[hidden] {
  display: none;
}

.mode-selection-header {
  display: grid;
  justify-items: center;
  gap: 0.28rem;
}

.brand-wordmark {
  margin: 0 0 0.24rem;
  color: color-mix(in srgb, var(--core-highlight) 72%, var(--text-main));
  font-family: "Bodoni 72 Smallcaps", Didot, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-transform: uppercase;
  text-shadow: 0 5px 20px color-mix(in srgb, var(--core-highlight) 22%, transparent);
}

.brand-wordmark-compact {
  margin-bottom: 0.42rem;
  font-size: clamp(0.92rem, 1.6vw, 1.1rem);
  letter-spacing: 0.2em;
  text-indent: 0.2em;
}

.mode-selection-mark {
  width: clamp(4.6rem, 8vw, 5.4rem);
  margin: 0;
}

.mode-selection-eyebrow {
  margin: 0;
  color: color-mix(in srgb, var(--accent) 86%, white 14%);
}

.mode-selection-grid {
  width: min(100%, 28rem);
  display: grid;
  gap: 1rem;
}

.mode-choice-card {
  width: 100%;
  padding: 1.4rem 1.35rem;
  border-radius: 1.75rem;
  text-align: center;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--accent) 16%, transparent), transparent 72%),
    color-mix(in srgb, var(--panel) 94%, black);
  border: 1px solid color-mix(in srgb, var(--accent-border) 115%, var(--surface-border));
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.24),
    0 0 0 0.32rem color-mix(in srgb, var(--accent-soft) 80%, transparent);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.mode-choice-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent-border) 150%, transparent);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.28),
    0 0 0 0.42rem color-mix(in srgb, var(--accent-soft) 110%, transparent);
}

.mode-choice-card:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 3px;
}

.mode-choice-card strong {
  display: block;
  margin-top: 0.25rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(1.9rem, 4vw, 2.35rem);
  line-height: 1;
}

.mode-choice-eyebrow {
  display: block;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.mode-choice-copy {
  display: block;
  margin-top: 0.65rem;
  color: var(--text-soft);
  line-height: 1.65;
}

.stage-top,
.stage-bottom {
  width: 100%;
  display: grid;
  justify-items: center;
}

.stage-top {
  position: relative;
  gap: 0.2rem;
}

.stage-bottom {
  gap: 0.4rem;
}

.stage-toolbar {
  width: 100%;
  display: grid;
  justify-items: center;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: 0.75rem;
}

.stage-left-actions {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-self: start;
  gap: 0.75rem;
}

.stage-return {
  height: var(--top-control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

.stage-heading {
  grid-column: 2;
  grid-row: 1;
  text-align: center;
}

.stage-left-actions .language-switcher {
  position: static;
  transform: none;
  z-index: auto;
}

.brand-mark {
  width: clamp(3.5rem, 5.2vw, 4.3rem);
  margin: 0 auto 0.35rem;
  padding: 0.2rem;
  border-radius: 1.35rem;
  border: 1px solid color-mix(in srgb, var(--accent-border) 125%, var(--surface-border));
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--accent) 18%, transparent), transparent 72%),
    color-mix(in srgb, var(--panel) 92%, black);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.2),
    0 0 0 0.25rem color-mix(in srgb, var(--accent-soft) 110%, transparent);
}

.brand-logo {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 1.15rem;
}

.quick-actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.quick-action {
  padding: 0.82rem 1.05rem;
  border-radius: 999px;
  color: var(--text-main);
  background: var(--panel-strong);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.quick-action:hover {
  transform: translateY(-1px);
}

.quick-action.is-active {
  background: color-mix(in srgb, var(--accent-soft) 165%, transparent);
  border-color: color-mix(in srgb, var(--accent-border) 155%, transparent);
}

.quick-action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 2px;
}

.quick-action.is-locked,
.settings-tab.is-locked {
  opacity: 0.3;
  box-shadow: none;
  filter: saturate(0.25);
}

.quick-action.is-locked:hover,
.settings-tab.is-locked:hover {
  transform: none;
}

.eyebrow {
  margin: 0 0 0.45rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: var(--accent);
}

.breath-stage {
  display: none;
}

.stage-center {
  display: grid;
  place-items: center;
  width: 100%;
  gap: 0.4rem;
}

.free-stage-visual {
  display: grid;
  place-items: center;
  width: min(100%, 24rem);
  min-height: var(--session-visual-size);
}

#freeStageVisual[hidden],
body[data-active-mode="guided"] #freeStageVisual,
body[data-active-mode="selection"] #freeStageVisual {
  display: none !important;
}

body[data-active-mode="free"] #guidedStageVisual,
body[data-active-mode="selection"] #guidedStageVisual {
  display: none !important;
}

.free-timer-shell {
  width: 100%;
  padding: 1rem 1.2rem;
  border-radius: 2rem;
  border: 1px solid color-mix(in srgb, var(--accent-border) 120%, var(--surface-border));
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%),
    color-mix(in srgb, var(--surface-soft) 135%, transparent);
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.22),
    0 0 0 0.45rem color-mix(in srgb, var(--accent-soft) 95%, transparent);
}

.free-timer-label {
  display: block;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: var(--accent);
}

.free-timer-value {
  display: block;
  margin-top: 0.65rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(2.3rem, 6vw, 3.8rem);
  line-height: 1;
}

.free-timer-copy {
  margin: 0.75rem 0 0;
  color: var(--text-soft);
  line-height: 1.58;
}

.orbital-field {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, var(--session-visual-size));
  aspect-ratio: 1;
}

.orbital-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  animation: haloPulse 9s ease-in-out infinite;
}

.orbital-ring-outer {
  inset: 0;
}

.orbital-ring-inner {
  inset: 15%;
  animation-delay: -2s;
}

.breath-core {
  position: relative;
  z-index: 1;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  color: var(--text-main);
  display: grid;
  place-items: center;
  letter-spacing: 0.03em;
  background:
    radial-gradient(circle at 35% 30%, var(--core-highlight), transparent 28%),
    radial-gradient(circle at center, var(--core-mid), var(--core-deep));
  transform: scale(var(--core-scale));
  box-shadow:
    0 0 0 calc(1.5rem * var(--core-glow)) var(--core-halo),
    0 24px 60px rgba(5, 12, 16, 0.5);
  transition:
    transform 180ms linear,
    box-shadow 180ms linear,
    filter 220ms ease;
}

.breath-core-label,
.drawer-title {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.breath-core-label {
  font-size: clamp(1.8rem, 3.2vw, 2.35rem);
}

.session-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.stat-chip {
  min-width: 6.9rem;
  padding: 0.72rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--surface-soft);
}

.stat-label,
.section-heading p,
.control-card output,
.summary-card span,
.history-list-header,
.history-empty,
.history-meta,
.stage-note,
.interaction-hint {
  color: var(--text-soft);
}

.stat-chip strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1rem;
}

.stage-note {
  margin: 0.6rem auto 0;
  max-width: 24rem;
  font-size: 0.94rem;
  line-height: 1.55;
}

.interaction-hint {
  margin: 0.35rem auto 0;
  font-size: 0.88rem;
}

.stage-quote {
  margin: 0;
  max-width: 21rem;
  padding: 0 1rem;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: clamp(0.84rem, 1.2vw, 0.96rem);
  line-height: 1.48;
  color: color-mix(in srgb, var(--text-main) 84%, var(--accent) 16%);
  text-align: center;
  text-wrap: balance;
}

.session-control {
  margin-top: 0.35rem;
  padding: 0.85rem 1.25rem;
  min-width: min(19rem, 70vw);
  border-radius: 999px;
  color: var(--text-main);
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--surface-border) 85%, transparent);
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.session-control:hover {
  transform: translateY(-1px);
}

.session-control.is-active {
  background: color-mix(in srgb, var(--accent-soft) 100%, transparent);
  border-color: color-mix(in srgb, var(--accent-border) 140%, transparent);
}

.stage-bottom {
  display: flex;
  flex-direction: column;
}

.stage-bottom .session-control {
  order: 1;
  align-self: center;
  width: fit-content;
  min-width: min(14rem, calc(100vw - 2rem));
  max-width: calc(100vw - 2rem);
}

.stage-bottom .session-stats {
  order: 2;
}

.stage-bottom .stage-note {
  order: 3;
}

.stage-bottom .interaction-hint {
  order: 4;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(28rem, 100vw);
  height: 100vh;
  padding: 1.25rem;
  background: var(--drawer-bg);
  border-left: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 240ms ease;
}

.side-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.drawer-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  line-height: 0.98;
}

.icon-button,
.ghost-action {
  border-radius: 999px;
  color: var(--text-main);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
}

.icon-button {
  padding: 0.8rem 1rem;
  cursor: pointer;
}

.drawer-panel[hidden] {
  display: none;
}

.settings-tabs {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.2rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab {
  flex: 0 0 auto;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  color: var(--text-main);
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.settings-tab:hover {
  transform: translateY(-1px);
}

.settings-tab.is-active {
  background:
    radial-gradient(circle at top, color-mix(in srgb, var(--accent) 28%, transparent), transparent 80%),
    color-mix(in srgb, var(--accent-soft) 150%, transparent);
  border-color: color-mix(in srgb, var(--accent-border) 165%, transparent);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.settings-panel-stack {
  display: grid;
}

.settings-panel {
  margin-top: 0;
}

.settings-panel[hidden] {
  display: none;
}

.drawer-section + .drawer-section {
  margin-top: 1.5rem;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.section-heading p {
  margin: 0.4rem 0 0;
  line-height: 1.65;
}

.control-grid,
.history-summary {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.control-grid {
  grid-template-columns: 1fr 1fr;
}

.compact-grid {
  grid-template-columns: 1fr;
}

.control-card,
.summary-card,
.history-list-shell {
  padding: 1rem 1rem 1.05rem;
  border-radius: 1.2rem;
  border: 1px solid var(--surface-border);
  background: var(--surface-soft);
}

.gated-upgrade-card {
  border-style: dashed;
  background: color-mix(in srgb, var(--surface-soft) 65%, transparent);
}

.control-card span {
  display: block;
  margin-bottom: 0.35rem;
}

.control-card output {
  display: block;
  margin-bottom: 0.8rem;
}

input[type="range"] {
  width: 100%;
  accent-color: #b3efd8;
}

select {
  width: 100%;
  padding: 0.9rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text-main);
}

input[type="time"] {
  width: 100%;
  padding: 0.9rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.9rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text-main);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.auth-modal-actions {
  grid-template-columns: 1fr;
}

.auth-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.15rem;
}

.auth-choice-option {
  min-height: 4.4rem;
  padding: 0.85rem 1rem;
  border-radius: 1.15rem;
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  background: var(--surface-soft);
  cursor: pointer;
}

.auth-choice-option:hover,
.auth-choice-option.is-active {
  border-color: var(--accent-border);
  background: color-mix(in srgb, var(--accent-soft) 150%, var(--surface-soft));
}

.auth-choice-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.auth-form-content {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.auth-form-content[hidden] {
  display: none;
}

textarea {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--surface-border);
  background: var(--input-bg);
  color: var(--text-main);
  resize: vertical;
}

.switch-card {
  display: grid;
  gap: 0.75rem;
}

.utility-card {
  display: grid;
  gap: 0.9rem;
}

.account-status-card,
.account-form-card,
.account-benefits-card,
.account-preview-card,
.sync-state-card {
  display: grid;
  gap: 0.8rem;
}

.account-status-card strong,
.account-preview-card strong {
  font-size: 1.2rem;
}

.account-verification-card {
  display: grid;
  gap: 0.65rem;
  padding: 0.95rem;
  border-radius: 1rem;
  border: 1px solid color-mix(in srgb, var(--accent-border) 120%, var(--surface-border));
  background: color-mix(in srgb, var(--accent-soft) 75%, transparent);
}

.account-verification-card.is-verified {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--surface-border));
}

.account-verification-card .button-row {
  margin-top: 0.15rem;
}

.account-cloud-preferences {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border-radius: 1.15rem;
  border: 1px solid color-mix(in srgb, var(--accent-border) 95%, var(--surface-border));
  background: color-mix(in srgb, var(--panel) 76%, transparent);
}

.account-cloud-preferences > span {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cloud-preference-row > span:first-child {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.cloud-preference-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.3rem;
  align-items: center;
  width: 100%;
}

.cloud-preference-row strong {
  font-size: 1rem;
}

.cloud-preference-row small {
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.45;
}

.cloud-data-actions {
  margin-top: 0.15rem;
}

.account-benefits-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-soft);
  line-height: 1.68;
}

.inset-card {
  padding: 0;
  border: 0;
  background: transparent;
}

.storage-chip {
  margin-top: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent-border) 135%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 145%, transparent);
}

.stack-actions {
  display: grid;
  gap: 0.75rem;
}

.inline-action {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 999px;
  color: var(--text-main);
  background: color-mix(in srgb, var(--accent-soft) 160%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-border) 145%, transparent);
  cursor: pointer;
}

.inline-action:disabled,
.ghost-action:disabled,
.toggle-row input:disabled + .toggle-ui {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-inline {
  background: var(--surface-strong);
  border-color: var(--surface-border);
}

.danger-action {
  color: #fff4f2;
  background: rgba(176, 58, 55, 0.28);
  border-color: rgba(240, 137, 130, 0.46);
}

.status-copy {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-ui {
  position: relative;
  display: block;
  flex: 0 0 3.3rem;
  width: 3.3rem;
  min-width: 3.3rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--text-soft) 46%, var(--surface-border));
  background: color-mix(in srgb, var(--text-main) 7%, var(--input-bg));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition:
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #edf5f3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transform: translateY(-50%);
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.toggle-row input:checked + .toggle-ui {
  border-color: color-mix(in srgb, var(--accent) 72%, white 8%);
  background: color-mix(in srgb, var(--accent) 22%, var(--input-bg));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent),
    0 0 0 0.12rem color-mix(in srgb, var(--accent) 8%, transparent);
}

.toggle-row input:checked + .toggle-ui::after {
  background: #f5fffc;
  transform: translate(1.3rem, -50%);
}

.toggle-row:hover .toggle-ui {
  border-color: color-mix(in srgb, var(--accent) 46%, var(--text-soft));
}

.toggle-row input:focus-visible + .toggle-ui {
  outline: 2px solid color-mix(in srgb, var(--accent) 78%, white);
  outline-offset: 3px;
}

.privacy-detail {
  font-size: 0.9rem;
}

.privacy-feedback:empty {
  display: none;
}

.diary-data-actions {
  align-items: stretch;
}

.diary-data-actions .ghost-action {
  margin-top: 0;
}

.danger-outline-action {
  color: #ffd9d4;
  border-color: rgba(240, 137, 130, 0.32);
}

.history-summary {
  grid-template-columns: repeat(4, 1fr);
}

.summary-card strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.05rem;
}

.history-list-shell {
  margin-top: 1rem;
}

.diary-editor-card {
  display: grid;
  gap: 0.9rem;
}

.diary-textarea {
  min-height: 11rem;
  line-height: 1.65;
}

.diary-list-shell {
  margin-top: 1rem;
}

.diary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.9rem;
  max-height: 22rem;
  overflow: auto;
}

.diary-item {
  padding-top: 0.95rem;
  border-top: 1px solid var(--surface-border);
}

.diary-entry-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.diary-entry-head strong {
  display: block;
}

.diary-entry-copy {
  margin: 0.65rem 0 0;
  color: var(--text-main);
  line-height: 1.72;
  white-space: pre-wrap;
}

.history-chart-shell {
  margin-top: 1rem;
  padding: 1rem 1rem 1.1rem;
  border-radius: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.history-chart-head,
.history-chart-scale {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.history-chart-head strong {
  text-align: right;
}

.history-chart {
  display: grid;
  grid-template-columns: repeat(52, minmax(0, 1fr));
  align-items: end;
  gap: 0.25rem;
  height: 10rem;
  margin-top: 1rem;
}

.history-bar {
  display: flex;
  align-items: end;
  height: 100%;
}

.history-bar-fill {
  width: 100%;
  min-height: 0.2rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(242, 228, 166, 0.95), rgba(117, 214, 191, 0.88));
  box-shadow: 0 0 24px rgba(167, 240, 216, 0.12);
  opacity: 0.95;
}

.history-bar.is-empty .history-bar-fill {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  opacity: 0.65;
}

.history-chart-scale {
  margin-top: 0.9rem;
  font-size: 0.82rem;
  color: var(--text-soft);
}

.history-list-header,
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.history-list-header {
  padding-bottom: 0.75rem;
  font-size: 0.9rem;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
  max-height: 18rem;
  overflow: auto;
}

.history-empty {
  padding: 1rem 0 0.25rem;
}

.history-item {
  padding-top: 0.8rem;
  border-top: 1px solid var(--surface-border);
}

.history-main strong,
.history-duration {
  display: block;
}

.history-duration {
  text-align: right;
}

.history-meta {
  margin-top: 0.2rem;
  font-size: 0.88rem;
}

.ghost-action {
  width: 100%;
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  cursor: pointer;
}

.account-reset-action,
.account-logout-action {
  margin-top: 0;
}

.account-setup-card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-main);
}

.modal-backdrop[hidden],
.session-modal[hidden],
.account-verification-card[hidden],
.account-verification-card [hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: color-mix(in srgb, var(--backdrop) 120%, transparent);
  backdrop-filter: blur(10px);
}

.session-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.session-modal-card {
  width: min(100%, 32rem);
  padding: 1.5rem;
  border-radius: 1.8rem;
  border: 1px solid var(--surface-border);
  background:
    radial-gradient(circle at top, var(--accent-soft), transparent 38%),
    var(--drawer-bg);
  box-shadow: var(--shadow);
}

.session-modal-card h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 2rem;
  line-height: 1;
}

.privacy-choice-card {
  width: min(100%, 34rem);
}

.email-verification-modal-card {
  width: min(100%, 33rem);
}

.verification-email-address {
  display: grid;
  gap: 0.3rem;
  margin-top: 1.1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  background: var(--surface-soft);
  overflow-wrap: anywhere;
}

.verification-email-address span {
  color: var(--text-soft);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.verification-modal-feedback {
  margin-top: 1rem;
}

.verification-requirement {
  margin: 0.85rem 0 0;
  color: var(--accent);
  line-height: 1.5;
}

.session-modal-copy,
.session-trend {
  color: var(--text-soft);
  line-height: 1.65;
}

.session-modal-copy {
  margin: 0.75rem 0 0;
}

.session-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.wide-card {
  grid-column: 1 / -1;
}

.session-trend {
  margin: 1rem 0 0;
}

.session-storage-note {
  margin-top: 0.7rem;
  font-size: 0.95rem;
}

.modal-action {
  width: 100%;
  margin-top: 1.1rem;
}

.modal-secondary-action {
  width: 100%;
  margin-top: 0.75rem;
}

@keyframes haloPulse {
  0%,
  100% {
    transform: scale(0.95);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.03);
    opacity: 0.65;
  }
}

@media (max-width: 860px) {
  :root {
    --top-control-inset: 1rem;
  }

  body {
    overflow: auto;
  }

  .language-switcher {
    top: max(var(--top-control-inset), env(safe-area-inset-top));
    left: 8.5rem;
    transform: none;
  }

  body[data-active-mode="selection"] .language-switcher {
    left: 50%;
    transform: translateX(-50%);
  }

  .language-select {
    min-width: 7.5rem;
    padding: 0 2rem 0 0.92rem;
    font-size: 0.92rem;
  }

  .app-shell {
    min-height: calc(100svh - var(--footer-reserve));
    padding: 1rem;
  }

  .meditation-stage {
    min-height: calc(100svh - 2rem - var(--footer-reserve));
  }

  .session-experience {
    gap: 0.5rem;
  }

  .side-drawer {
    width: 100vw;
  }

}

@media (max-width: 1200px) and (min-width: 641px) {
  .stage-toolbar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    column-gap: 0.75rem;
    row-gap: 0.75rem;
  }

  .stage-heading {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .stage-left-actions {
    grid-column: 1;
    grid-row: 2;
  }

  .quick-actions {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-height: 920px) {
  :root {
    --top-control-inset: 1rem;
  }

  body {
    overflow: auto;
  }

  .app-shell {
    min-height: calc(100svh - var(--footer-reserve));
    padding: 1rem;
  }

  .meditation-stage {
    min-height: calc(100svh - 2rem - var(--footer-reserve));
  }

  .stage-quote {
    max-width: 19rem;
    font-size: 0.84rem;
  }

  .stat-chip {
    min-width: 6.4rem;
    padding: 0.66rem 0.82rem;
  }
}

@media (max-width: 640px) {
  .session-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 24rem);
  }

  .session-experience {
    padding-top: 0;
  }

  .stage-top {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    padding: 0;
    background: none;
  }

  .stage-toolbar {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    padding-top: 0;
  }

  .stage-heading {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
  }

  .quick-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .stage-left-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .stage-return {
    grid-column: 1;
    width: 100%;
  }

  .stage-left-actions .language-switcher {
    grid-column: 2;
    width: 100%;
  }

  .language-select {
    width: 100%;
  }

  .quick-action {
    flex: 1 1 0;
    min-width: 0;
  }


  .mode-selection-grid {
    width: 100%;
  }

  .control-grid,
  .button-row,
  .auth-choice-actions,
  .history-summary,
  .session-summary-grid {
    grid-template-columns: 1fr;
  }

  .auth-choice-option {
    min-height: 3.8rem;
  }

  .settings-tabs {
    gap: 0.6rem;
    margin-inline: -0.15rem;
    padding-inline: 0.15rem;
  }

  .settings-tab {
    padding: 0.78rem 0.95rem;
  }

  .history-chart-head,
  .history-chart-scale {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-chart-head strong {
    text-align: left;
  }

  .drawer-header {
    flex-direction: column;
  }

  .icon-button {
    width: 100%;
  }

  .session-control {
    min-width: min(18rem, 84vw);
  }
}
