:root {
  --bg: #070b18;
  --bg-soft: rgba(255, 255, 255, 0.06);
  --card: rgba(12, 17, 36, 0.7);
  --card-strong: rgba(16, 22, 45, 0.88);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef3ff;
  --muted: #a8b2d8;
  --pink: #ff7ec9;
  --violet: #9c8cff;
  --cyan: #79e6ff;
  --gold: #ffd87a;
  --good: #80ffbe;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --ease: 240ms ease;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 0%, rgba(121, 230, 255, 0.14), transparent 26%),
    radial-gradient(circle at 100% 10%, rgba(255, 126, 201, 0.14), transparent 30%),
    linear-gradient(180deg, #09101d 0%, #070b18 35%, #050710 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  background: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% -5%, rgba(255,255,255,0.16), transparent 25%);
  pointer-events: none;
}

.noise,
.aurora {
  position: fixed;
  inset: -10%;
  pointer-events: none;
}

.noise {
  opacity: 0.08;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,255,255,0.35) 0 0.7px, transparent 0.8px),
    radial-gradient(circle at 75% 65%, rgba(255,255,255,0.22) 0 0.6px, transparent 0.8px);
  background-size: 22px 22px, 16px 16px;
  mix-blend-mode: screen;
}

.aurora {
  filter: blur(70px);
  opacity: 0.28;
  animation: floatAura 18s ease-in-out infinite alternate;
}

.aurora-a {
  background: radial-gradient(circle at 25% 30%, rgba(121, 230, 255, 0.6), transparent 28%);
}

.aurora-b {
  background: radial-gradient(circle at 75% 32%, rgba(255, 126, 201, 0.55), transparent 30%);
  animation-duration: 22s;
}

.app-shell {
  position: relative;
  width: min(100%, 540px);
  margin: 0 auto;
  padding: 18px 16px calc(96px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.15rem);
  letter-spacing: -0.03em;
}

h2 {
  font-size: clamp(1.75rem, 5.4vw, 2.45rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

h3 {
  font-size: 1.18rem;
  letter-spacing: -0.03em;
}

.eyebrow {
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
  line-height: 1.5;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px;
  overflow: hidden;
}

.card + .card {
  margin-top: 16px;
}

.hero {
  min-height: 330px;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 90px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.04));
  pointer-events: none;
}

.moon-stage {
  position: relative;
  min-height: 140px;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06), rgba(255,255,255,0.01));
}

.halo,
.moon,
.spark {
  position: absolute;
  border-radius: 999px;
}

.halo {
  inset: 22% auto auto 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(255,126,201,0.28), transparent 60%);
  animation: pulse 5s ease-in-out infinite;
}

.halo-b {
  width: 210px;
  height: 210px;
  background: radial-gradient(circle, rgba(121,230,255,0.2), transparent 62%);
  animation-delay: -2s;
}

.moon {
  top: 50%;
  left: 50%;
  width: 86px;
  height: 86px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 30% 30%, #ffffff 0%, #ebefff 40%, #cfd7ff 68%, rgba(207,215,255,0.8) 100%);
  box-shadow:
    0 0 45px rgba(255,255,255,0.4),
    inset -10px -14px 18px rgba(146, 151, 196, 0.35);
}

.moon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 72% 35%, transparent 0 23%, rgba(111,125,192,0.18) 24% 31%, transparent 32%),
              radial-gradient(circle at 35% 68%, rgba(111,125,192,0.16) 0 10%, transparent 11%),
              radial-gradient(circle at 56% 56%, rgba(111,125,192,0.12) 0 8%, transparent 9%);
}

.spark {
  width: 7px;
  height: 7px;
  background: white;
  box-shadow: 0 0 18px rgba(255,255,255,0.75);
  animation: twinkle 3s linear infinite;
}

.spark-a { top: 22%; left: 24%; }
.spark-b { right: 18%; top: 28%; animation-delay: -1s; }
.spark-c { bottom: 25%; left: 28%; width: 5px; height: 5px; animation-delay: -2s; }

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

.quick-stats > div {
  padding: 14px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255,255,255,0.06);
  text-align: center;
}

.quick-stats span {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.quick-stats small {
  color: var(--muted);
  font-size: 0.76rem;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.badge {
  border-radius: 999px;
  background: rgba(255, 216, 122, 0.12);
  color: var(--gold);
  border: 1px solid rgba(255, 216, 122, 0.25);
  padding: 9px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
}

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

.mood-chip {
  padding: 14px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid transparent;
  color: var(--text);
  transition: transform var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.mood-chip.selected {
  background: linear-gradient(135deg, rgba(156,140,255,0.22), rgba(255,126,201,0.18));
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 10px 30px rgba(156,140,255,0.22);
  transform: translateY(-1px);
}

.slider-wrap,
.textarea-label,
.prompt-line {
  margin-top: 16px;
}

.slider-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  margin-bottom: 10px;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(121,230,255,0.4), rgba(255,126,201,0.42));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(7, 11, 24, 0.85);
  box-shadow: 0 8px 18px rgba(0,0,0,0.25);
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(7, 11, 24, 0.85);
}

textarea {
  width: 100%;
  margin-top: 8px;
  resize: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 18px;
  padding: 14px 15px;
  line-height: 1.45;
}

textarea::placeholder {
  color: rgba(235, 241, 255, 0.42);
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.card-actions.compact {
  margin-top: 12px;
}

.pill-button,
.icon-button,
.nav-item {
  transition: transform var(--ease), opacity var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.pill-button {
  padding: 13px 16px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid transparent;
}

.pill-button.primary {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  box-shadow: 0 16px 30px rgba(156, 140, 255, 0.28);
}

.pill-button.subtle {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.08);
}

.pill-button:active,
.icon-button:active,
.nav-item:active,
.mood-chip:active {
  transform: scale(0.98);
}

.prompt-line {
  color: var(--gold);
  font-size: 0.92rem;
}

.breath-area {
  display: grid;
  gap: 18px;
  align-items: center;
}

.breath-orb-wrap {
  position: relative;
  width: 212px;
  height: 212px;
  margin: 6px auto 0;
}

.breath-ring,
.breath-orb {
  position: absolute;
  inset: 0;
}

.breath-ring {
  transform: rotate(-90deg);
}

.breath-ring circle {
  fill: none;
  stroke: rgba(255,255,255,0.12);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1s linear;
}

.breath-orb {
  inset: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.65), rgba(255,255,255,0.12) 18%, rgba(156,140,255,0.22) 40%, rgba(255,126,201,0.16) 60%, rgba(7,11,24,0.3) 100%);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  transform: scale(0.9);
  transition: transform 3s ease;
  box-shadow: 0 0 40px rgba(156,140,255,0.24);
}

.breath-orb.active-inhale {
  transform: scale(1.06);
}

.breath-orb.active-hold {
  transform: scale(1.02);
}

.breath-orb.active-exhale {
  transform: scale(0.86);
}

#breathPhase {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

#breathCountdown {
  color: var(--muted);
}

.ritual-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.garden-card {
  padding-bottom: 14px;
}

#gardenCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1.66 / 1;
  border-radius: 24px;
  background: radial-gradient(circle at 50% 15%, rgba(255,255,255,0.16), rgba(255,255,255,0.02) 28%, rgba(5, 7, 16, 0.9) 72%),
              linear-gradient(180deg, rgba(16,22,45,0.8), rgba(9,12,24,0.92) 55%, rgba(7, 10, 18, 1));
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 -40px 60px rgba(0,0,0,0.22);
}

.garden-hint {
  color: var(--muted);
  margin-top: 10px;
  font-size: 0.9rem;
}

.history-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.history-day {
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  padding: 10px 8px;
  min-height: 88px;
  display: grid;
  align-content: end;
  gap: 8px;
}

.history-bar {
  border-radius: 999px;
  width: 100%;
  min-height: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.06));
  align-self: end;
}

.history-label {
  color: var(--muted);
  font-size: 0.75rem;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.insight-panel {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}

.insight-panel span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 0.84rem;
}

.insight-panel strong {
  display: block;
  font-size: 1.08rem;
  line-height: 1.25;
  margin-bottom: 8px;
}

.insight-panel.wide {
  grid-column: 1 / -1;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(calc(100% - 22px), 520px);
  padding: 10px;
  border-radius: 999px;
  background: rgba(10, 15, 30, 0.84);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(18px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.nav-item {
  padding: 12px 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
}

.nav-item.active {
  color: white;
  background: rgba(255,255,255,0.08);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  width: min(92vw, 420px);
  padding: 14px 16px;
  background: rgba(10, 15, 30, 0.95);
  color: white;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  backdrop-filter: blur(16px);
  text-align: center;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 60;
}

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

.hidden {
  display: none !important;
}

.memory-dialog {
  width: min(92vw, 420px);
  border: 0;
  padding: 0;
  background: transparent;
}

.memory-dialog::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
}

.memory-card {
  padding: 18px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(16,22,45,0.96), rgba(10,15,30,0.98));
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  box-shadow: var(--shadow);
}

.memory-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.close-button {
  flex-shrink: 0;
}

.memory-date {
  margin-top: 10px;
  color: var(--gold);
  font-size: 0.9rem;
}

.memory-note {
  margin-top: 14px;
  line-height: 1.6;
  color: var(--text);
}

.memory-swatches {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.memory-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,126,201,0.8), rgba(121,230,255,0.8));
  box-shadow: 0 0 20px rgba(255,255,255,0.18);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.focused-garden #gardenCanvas {
  aspect-ratio: 1 / 1.2;
}

@media (min-width: 600px) {
  .app-shell {
    width: min(100%, 720px);
  }

  .hero {
    grid-template-columns: 1.08fr 0.92fr;
    align-items: center;
  }

  .hero-copy,
  .quick-stats {
    grid-column: 1 / 2;
  }

  .moon-stage {
    grid-column: 2 / 3;
    grid-row: 1 / span 2;
    min-height: 100%;
  }

  .mood-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .breath-area {
    grid-template-columns: 220px 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(0.96); opacity: 0.55; }
  50% { transform: translateX(-50%) scale(1.08); opacity: 0.78; }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.3); }
}

@keyframes floatAura {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(0, 18px, 0) rotate(8deg); }
}

body.surprise-mode .aurora-a {
  background: radial-gradient(circle at 18% 30%, rgba(255, 216, 122, 0.58), transparent 26%);
}

body.surprise-mode .aurora-b {
  background: radial-gradient(circle at 75% 32%, rgba(128, 255, 190, 0.48), transparent 30%);
}

body.surprise-mode .moon {
  background: radial-gradient(circle at 35% 32%, #fff7de 0%, #ffe7b5 42%, #ffcf6d 72%, rgba(255,207,109,0.8) 100%);
}
