:root {
  --eazo-safe-area-top: max(56px, env(safe-area-inset-top, 0px));
  --eazo-safe-area-bottom: max(34px, env(safe-area-inset-bottom, 0px));
  --plum-0: #120819;
  --plum-1: #211029;
  --plum-2: #39203e;
  --cream: #fff1d9;
  --ink: #2d1727;
  --rose: #ff91ad;
  --apricot: #ffc37e;
  --slate: #aeb8cc;
  color-scheme: dark;
  font-family: "Quicksand", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; overflow-x: hidden; }
body {
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 14%, rgba(255, 143, 179, .16), transparent 32%),
    radial-gradient(circle at 80% 72%, rgba(174, 184, 204, .14), transparent 35%),
    linear-gradient(160deg, #2b1435 0%, #160a24 48%, #080b18 100%);
}

.app {
  min-height: 100svh;
  padding: var(--eazo-safe-area-top) 16px var(--eazo-safe-area-bottom);
  position: relative;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.sky, .vignette { position: fixed; inset: 0; pointer-events: none; }
.sky { overflow: hidden; z-index: 0; }
.vignette {
  z-index: 1;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(5, 4, 12, .46) 100%);
}
.star {
  position: absolute;
  width: var(--s);
  height: var(--s);
  left: var(--x);
  top: var(--y);
  border-radius: 999px;
  background: rgba(255, 241, 217, var(--a));
  box-shadow: 0 0 calc(var(--s) * 3.2) rgba(255, 195, 126, .75);
  animation: twinkle var(--d) ease-in-out infinite;
  animation-delay: var(--delay);
  opacity: calc(var(--a) * var(--star-mood, .72));
}
.star.near {
  background: rgba(255, 165, 191, .94);
  box-shadow: 0 0 11px rgba(255, 143, 179, .88), 0 0 22px rgba(255, 195, 126, .28);
  opacity: var(--near-stars, .45);
}
@keyframes twinkle { 0%, 100% { transform: scale(.72); opacity: .34; } 50% { transform: scale(1.12); opacity: 1; } }

.sheet {
  z-index: 2;
  width: min(100%, 430px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: stretch;
  max-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom));
}

.topbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}
.brand {
  font-family: "Caveat", cursive;
  font-size: clamp(30px, 8vw, 40px);
  line-height: .9;
  letter-spacing: .01em;
  color: #ffe2bc;
  text-shadow: 0 0 22px rgba(255, 143, 179, .24);
  white-space: nowrap;
}
.lang {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 12px;
  border: 1px solid rgba(255, 241, 217, .24);
  background: rgba(255, 241, 217, .09);
  color: #fff0d6;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.lang-icon { color: rgba(255, 195, 126, .85); font-size: 14px; }
.lang select {
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #fff0d6;
  font: 700 14px/1 "Quicksand", sans-serif;
  cursor: pointer;
  padding-right: 4px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.lang select option { color: #2d1727; background: #fff1d9; }

.lang-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(255, 241, 217, .24);
  background: rgba(255, 241, 217, .07);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  flex: 0 0 auto;
}
.lang-seg {
  min-height: 38px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 240, 214, .62);
  font: 700 14px/1 "Quicksand", sans-serif;
  cursor: pointer;
  outline: none;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.lang-seg:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 195, 126, .7);
}
.lang-seg[aria-pressed="true"] {
  color: #2d1727;
  background: linear-gradient(180deg, #ffd79a, #ffb0c2);
  box-shadow: 0 2px 10px rgba(255, 143, 179, .32);
}

.stage {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.stage::-webkit-scrollbar { display: none; }

.moon-wrap {
  display: grid;
  place-items: center;
  padding-top: 2px;
  flex: 0 0 auto;
}
.halo {
  --halo-color: #ffd0d9;
  width: clamp(136px, 39vw, 180px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(255,255,255,.36) 0 38%, rgba(255,255,255,.05) 61%, transparent 70%),
    radial-gradient(circle, color-mix(in srgb, var(--halo-color), white 18%) 0 40%, transparent 71%);
  box-shadow: 0 0 28px color-mix(in srgb, var(--halo-color), transparent 36%), 0 0 72px color-mix(in srgb, var(--halo-color), transparent 66%);
  animation: breathe 4.6s ease-in-out infinite;
  transition: background-color .28s ease, box-shadow .28s ease;
}
@keyframes breathe { 0%,100% { transform: scale(.985); } 50% { transform: scale(1.025); } }

.face-svg { width: 88%; height: 88%; overflow: visible; filter: drop-shadow(0 14px 18px rgba(14, 4, 20, .25)); }
.face-skin, .mouth, .brows, .eyes, .blush { transition: all .26s ease; }
.face-skin { fill: #fff1d9; }
.eyes { fill: #341829; }
.blush { fill: #ff9eb7; opacity: var(--blush, .38); }
.mouth { fill: none; stroke: #341829; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.brows { stroke: #341829; stroke-width: 4.5; stroke-linecap: round; }

.heart-row { margin-top: -4px; display: flex; align-items: center; gap: 8px; justify-content: center; min-height: 24px; }
.heart {
  width: 24px; height: 24px;
  transform: scale(var(--heart-scale, .82));
  transition: transform .25s ease, filter .25s ease;
  filter: drop-shadow(0 0 10px rgba(255,143,179,.52));
}
.heart path.bg { fill: rgba(214,222,237,.26); }
.heart path.fill { fill: url(#heartFill); clip-path: inset(calc((1 - var(--heart-fill, .5)) * 100%) 0 0 0); transition: clip-path .25s ease; }
.mood-word { font-family: "Caveat", cursive; font-size: 23px; color: rgba(255, 241, 217, .86); white-space: nowrap; }

.chat {
  flex: 0 0 auto;
  background: rgba(18, 8, 25, .36);
  border: 1px solid rgba(255, 241, 217, .16);
  border-radius: 32px;
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 50px rgba(0,0,0,.2);
  backdrop-filter: blur(10px);
}
.compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}
.message {
  min-height: 54px;
  max-height: 112px;
  overflow: auto;
  border-radius: 23px;
  background: var(--cream);
  color: var(--ink);
  padding: 12px 15px;
  font-family: "Caveat", cursive;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.05;
  box-shadow: 0 9px 0 rgba(255, 195, 126, .16), inset 0 -1px 0 rgba(45,23,39,.08);
  word-break: break-word;
}
.message.empty { color: rgba(45,23,39,.42); }
.cursor {
  display: inline-block;
  width: 2px;
  height: .85em;
  margin-left: 3px;
  vertical-align: -0.08em;
  background: rgba(45,23,39,.58);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.send {
  min-width: 72px;
  min-height: 54px;
  border: 0;
  border-radius: 22px;
  color: #311321;
  background: linear-gradient(145deg, #ffd29b, #ff93b2);
  font: 800 18px/1 "Caveat", cursive;
  box-shadow: 0 10px 24px rgba(255, 143, 179, .24), inset 0 1px 0 rgba(255,255,255,.42);
  cursor: pointer;
  white-space: nowrap;
}
.hint {
  margin: 9px 8px 0;
  color: rgba(255, 241, 217, .82);
  font: 600 13px/1.25 "Quicksand", sans-serif;
  text-align: center;
}

.chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 2px 0 4px;
  min-width: 0;
}
.chip {
  min-height: 44px;
  max-width: 100%;
  border: 1px solid rgba(255, 241, 217, .22);
  border-radius: 999px;
  padding: 0 14px;
  background:
    radial-gradient(circle at 24% 25%, rgba(255,255,255,.46) 0 2px, transparent 3px),
    linear-gradient(145deg, rgba(255, 241, 217, .24), rgba(255, 208, 217, .11));
  color: #fff4df;
  font: 700 18px/1 "Caveat", cursive;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 10px 24px rgba(0,0,0,.12);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: transform .16s ease, background .2s ease, border-color .2s ease;
}
.chip.last {
  border-color: rgba(255, 195, 126, .7);
  background:
    radial-gradient(circle at 24% 25%, rgba(255,255,255,.68) 0 2px, transparent 3px),
    linear-gradient(145deg, rgba(255, 195, 126, .34), rgba(255, 143, 179, .24));
}
.chip:active, .send:active, .result-actions button:active, .details-toggle:active { transform: translateY(1px) scale(.985); }

.terminal {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-bottom: 4px;
}
.terminal.show { display: flex; }
.reply {
  align-self: flex-start;
  max-width: min(88%, 360px);
  border-radius: 24px 24px 24px 8px;
  background: rgba(255, 241, 217, .92);
  color: #351927;
  padding: 12px 16px;
  font: 700 24px/1.08 "Caveat", cursive;
  box-shadow: 0 16px 32px rgba(0,0,0,.18);
  word-break: break-word;
}
.result-card {
  background: rgba(255, 241, 217, .94);
  color: #321725;
  border-radius: 30px;
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.7);
}
.result-top { display: grid; grid-template-columns: 82px minmax(0,1fr); gap: 12px; align-items: center; }
.mini-face { width: 82px; height: 82px; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.42), transparent 72%); }
.result-title { margin: 0 0 5px; font-family: "Caveat", cursive; font-size: 29px; line-height: 1; }
.sent-text { margin: 0; font-size: 13px; line-height: 1.28; font-weight: 700; color: rgba(50,23,37,.74); word-break: break-word; }
.cost-line { margin: 11px 0 0; font-size: 13px; line-height: 1.25; font-weight: 700; color: #5b3249; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.result-actions button, .details-toggle {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 14px;
  font: 800 14px/1 "Quicksand", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.replay { background: linear-gradient(145deg, #ffc37e, #ff91ad); color: #321725; }
.share { background: rgba(50, 23, 37, .1); color: #321725; border: 1px solid rgba(50,23,37,.12) !important; }
.share-note { display: none; margin-top: 8px; font-size: 12px; font-weight: 700; color: #8a3a52; text-align: center; }
.share-note.show { display: block; }
.details { margin-top: 10px; }
.details-toggle { width: 100%; background: rgba(50, 23, 37, .08); color: #321725; }
.ledger { display: none; margin: 8px 0 0; padding: 0; list-style: none; max-height: 160px; overflow: auto; }
.ledger.open { display: block; }
.ledger li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px solid rgba(50,23,37,.1); font-size: 13px; font-weight: 700; }
.delta.pos { color: #bd4366; }
.delta.neg { color: #65718a; }

.hidden { display: none !important; }

@media (min-width: 760px) {
  .sheet { width: min(92vw, 860px); display: grid; grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr); grid-template-rows: auto 1fr; gap: 14px 20px; }
  .topbar { grid-column: 1 / -1; }
  .stage { display: contents; }
  .moon-wrap { align-self: center; }
  .play-area { align-self: center; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .terminal.show { grid-column: 2; align-self: center; max-height: calc(100svh - var(--eazo-safe-area-top) - var(--eazo-safe-area-bottom) - 70px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
