:root {
  --bg: #07111d;
  --ink: rgba(247, 252, 255, 0.92);
  --muted: rgba(223, 238, 248, 0.62);
  --faint: rgba(223, 238, 248, 0.32);
  --glass: rgba(7, 17, 29, 0.52);
  --glass-strong: rgba(9, 23, 37, 0.78);
  --line: rgba(202, 229, 244, 0.18);
  --aura: rgba(111, 215, 231, 0.36);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

body {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  overscroll-behavior: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#garden {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  background: radial-gradient(circle at 50% 25%, #162d44, #07111d 55%, #02060d);
}

.app-shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100dvh;
  padding: calc(18px + var(--safe-top)) 18px calc(16px + var(--safe-bottom));
  pointer-events: none;
}

.top-bar,
.bottom-panel,
.drawer,
.toast {
  pointer-events: auto;
}

.top-bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
}

.icon-button,
.round-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 15, 26, 0.36);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.icon-button span {
  display: block;
  width: 16px;
  height: 1.5px;
  margin: 2px 0;
  border-radius: 999px;
  background: rgba(244, 252, 255, 0.78);
}

.text-icon {
  font-size: 19px;
  line-height: 1;
  opacity: 0.88;
}

.text-icon.is-on {
  text-shadow: 0 0 22px rgba(119, 234, 247, 0.78);
  border-color: rgba(158, 234, 246, 0.34);
}

.session-pill {
  justify-self: center;
  min-width: 128px;
  padding: 12px 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 15, 26, 0.34);
  color: rgba(239, 250, 255, 0.74);
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(20px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.breath-surface {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  outline: none;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
}

.mantra-wrap {
  position: relative;
  text-align: center;
  transform: translate3d(0, -6vh, 0);
  transition: opacity 500ms ease;
}

.mantra-wrap::before {
  content: "";
  position: absolute;
  inset: -48px -70px;
  z-index: -1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(135, 232, 244, 0.09), transparent 62%);
  filter: blur(2px);
  opacity: var(--breath, 0.22);
  transform: scale(calc(0.86 + var(--breath, 0) * 0.28));
}

.mantra-kicker {
  margin: 0 0 12px;
  color: rgba(210, 239, 249, 0.46);
  font-size: 11px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
}

#mantraText {
  margin: 0;
  max-width: min(82vw, 720px);
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: clamp(44px, 12vw, 100px);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.055em;
  color: rgba(246, 252, 255, 0.92);
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.26),
    0 20px 60px rgba(63, 211, 236, 0.17),
    0 -14px 80px rgba(255, 255, 255, 0.08);
}

.touch-orb {
  position: absolute;
  left: calc(var(--touch-x, 50) * 1%);
  top: calc(var(--touch-y, 56) * 1%);
  width: 132px;
  height: 132px;
  margin: -66px 0 0 -66px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(214, 255, 255, 0.08), rgba(82, 205, 227, 0.03) 45%, transparent 70%);
  border: 1px solid rgba(190, 245, 255, 0.07);
  opacity: calc(0.2 + var(--breath, 0) * 0.58);
  transform: scale(calc(0.62 + var(--breath, 0) * 0.56));
  filter: blur(0.5px);
  transition: left 280ms ease, top 280ms ease;
}

.touch-orb-core {
  position: absolute;
  inset: 38%;
  border-radius: 999px;
  background: rgba(227, 255, 255, 0.34);
  box-shadow: 0 0 34px rgba(119, 237, 251, 0.48);
}

.breath-hint {
  position: absolute;
  left: 50%;
  bottom: 7vh;
  width: min(84vw, 420px);
  margin: 0;
  transform: translateX(-50%);
  color: rgba(223, 241, 248, 0.56);
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  transition: opacity 300ms ease, transform 300ms ease;
}

.is-breathing .breath-hint {
  opacity: 0.2;
  transform: translateX(-50%) translateY(8px);
}

.bottom-panel {
  display: grid;
  gap: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(7, 17, 29, 0.42), rgba(4, 11, 19, 0.68));
  backdrop-filter: blur(24px);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.duration-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.duration-chip,
.tone-chip,
.preset-button,
.secondary-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: rgba(237, 249, 255, 0.72);
  cursor: pointer;
}

.duration-chip {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
}

.duration-chip.is-active,
.tone-chip.is-active,
.preset-button.is-active {
  color: rgba(248, 254, 255, 0.96);
  border-color: rgba(151, 237, 249, 0.32);
  background: linear-gradient(180deg, rgba(120, 227, 241, 0.19), rgba(120, 227, 241, 0.07));
  box-shadow: 0 0 34px rgba(68, 214, 238, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.11);
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-row > div {
  padding: 13px 14px;
  border: 1px solid rgba(226, 246, 255, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: rgba(222, 239, 247, 0.46);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.stat-row strong {
  font-size: 16px;
  font-weight: 520;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
  background: rgba(0, 3, 8, 0.34);
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.drawer.is-open {
  opacity: 1;
  visibility: visible;
}

.drawer-card {
  width: min(100%, 760px);
  max-height: min(84dvh, 820px);
  margin: 0 auto;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  border: 1px solid rgba(223, 244, 255, 0.16);
  border-bottom: 0;
  border-radius: 32px 32px 0 0;
  background: linear-gradient(180deg, rgba(13, 30, 47, 0.93), rgba(5, 12, 22, 0.96));
  backdrop-filter: blur(28px);
  box-shadow: 0 -28px 90px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(24px);
  transition: transform 260ms ease;
}

.drawer.is-open .drawer-card {
  transform: translateY(0);
}

.drawer-handle {
  width: 46px;
  height: 5px;
  margin: 4px auto 18px;
  border-radius: 999px;
  background: rgba(226, 244, 255, 0.22);
}

.drawer-header,
.section-heading-row,
.time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.drawer-header h2 {
  margin: 2px 0 0;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.eyebrow,
.section-label {
  margin: 0;
  color: rgba(208, 234, 245, 0.54);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.round-button {
  flex: 0 0 auto;
  font-size: 30px;
  line-height: 1;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 22px 0;
  border-top: 1px solid rgba(223, 244, 255, 0.1);
}

.mantra-input,
.time-input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(226, 246, 255, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(250, 254, 255, 0.94);
  outline: none;
}

.mantra-input {
  padding: 0 16px;
  font-size: 18px;
}

.time-input {
  max-width: 142px;
  padding: 0 14px;
  color-scheme: dark;
}

.preset-grid,
.tone-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.preset-button,
.tone-chip,
.secondary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 14px;
  font-size: 13px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 34px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(226, 246, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  left: 3px;
  top: 3px;
  border-radius: 999px;
  background: rgba(239, 250, 255, 0.82);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
  transition: transform 200ms ease;
}

.switch input:checked + span {
  border-color: rgba(144, 237, 247, 0.34);
  background: rgba(96, 220, 239, 0.22);
}

.switch input:checked + span::before {
  transform: translateX(24px);
}

.helper-copy {
  margin: 0;
  color: rgba(217, 236, 246, 0.48);
  font-size: 12px;
  line-height: 1.45;
}

.ghost-button {
  width: 100%;
  color: rgba(248, 209, 209, 0.7);
  border-color: rgba(255, 174, 174, 0.18);
  background: rgba(255, 110, 110, 0.045);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(118px + var(--safe-bottom));
  z-index: 20;
  width: min(86vw, 420px);
  padding: 13px 16px;
  border: 1px solid rgba(226, 246, 255, 0.18);
  border-radius: 18px;
  background: rgba(5, 14, 24, 0.82);
  color: rgba(241, 251, 255, 0.86);
  text-align: center;
  font-size: 14px;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translateX(-50%) translateY(18px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100%, 720px);
    margin: 0 auto;
    padding-inline: 26px;
  }

  .bottom-panel {
    margin-bottom: 12px;
  }
}

@media (max-height: 700px) {
  .mantra-wrap {
    transform: translate3d(0, -3vh, 0);
  }

  #mantraText {
    font-size: clamp(38px, 10vw, 76px);
  }

  .breath-hint {
    bottom: 3vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
