:root {
  --night: #08080b;
  --ink: #f3f1ec;
  --ink-soft: rgba(243, 241, 236, 0.62);
  --ink-faint: rgba(243, 241, 236, 0.38);
  --glass: rgba(22, 22, 28, 0.52);
  --line: rgba(255, 255, 255, 0.11);
  --rose: #f2a7d8;
  --mint: #9fe8cf;
  --gold: #f4d38a;
  --sans: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--night);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 300px;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  /* what is left without WebGL: a still sheen of the film in soft gradients over the night */
  background:
    radial-gradient(ellipse 46% 30% at 38% 30%, rgba(242, 167, 216, 0.22), transparent 70%),
    radial-gradient(ellipse 40% 28% at 64% 38%, rgba(159, 232, 207, 0.18), transparent 70%),
    radial-gradient(ellipse 50% 30% at 50% 58%, rgba(244, 211, 138, 0.12), transparent 70%),
    var(--night);
}

.film {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  display: block;
  opacity: 0;
}

/* a still grain over the film, so the soft light does not band */
.grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.hero {
  width: min(600px, 100% - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(10px, 2.6vh, 22px);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 1px var(--line) inset, 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 10px 24px -16px #000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: clamp(11px, min(1.6vw, 2.6vh), 13px);
  letter-spacing: 0.01em;
}
.pill__tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(100deg, var(--rose), var(--gold) 48%, var(--mint));
  color: #17121a;
  font-weight: 640;
}
.pill__text { color: var(--ink-soft); }

.title {
  font-weight: 520;
  font-variation-settings: "wdth" 104;
  font-size: clamp(30px, min(7.6vw, 10.5vh), 78px);
  line-height: 1.0;
  letter-spacing: -0.035em;
  color: var(--ink);
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.45);
}
.title em {
  font-style: normal;
  font-weight: 440;
  font-variation-settings: "wdth" 112;
  /* the last words carry the colours of the film, moving slowly like it */
  background: linear-gradient(100deg, #fff4fb 0%, var(--rose) 22%, var(--gold) 44%, var(--mint) 66%, #dfe9ff 88%, var(--rose) 110%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

/* ---- the prompt field: dark glass with a 1 px rim that catches the film */
.prompt {
  position: relative;
  width: min(560px, 100%);
  padding: clamp(10px, 1.8vh, 14px) clamp(10px, 1.8vh, 12px) clamp(8px, 1.4vh, 10px) clamp(14px, 2.2vh, 18px);
  border-radius: clamp(16px, 2.8vh, 22px);
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 0 0 1px rgba(255, 255, 255, 0.07) inset,
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 18px 40px -18px rgba(0, 0, 0, 0.85),
    0 40px 80px -40px rgba(0, 0, 0, 0.7);
  text-align: left;
}
/* the rim: a thin iridescent edge whose light follows the pointer (set from the script with --rx) */
.prompt__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: radial-gradient(160px 80px at var(--rx, 30%) 0%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(100deg, rgba(242, 167, 216, 0.5), rgba(244, 211, 138, 0.35) 45%, rgba(159, 232, 207, 0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0.55;
}
.prompt__input {
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: clamp(14px, min(2.2vw, 3vh), 16px);
  line-height: 1.5;
  padding: 2px 0 clamp(8px, 1.6vh, 14px);
  caret-color: var(--rose);
}
.prompt__input::placeholder { color: var(--ink-faint); }

.prompt__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tool {
  appearance: none;
  border: 0;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.tool svg, .model svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--line) inset;
  font-size: 12.5px;
  font-weight: 540;
  color: var(--ink-soft);
}
.model svg { width: 13px; height: 13px; stroke: var(--gold); fill: rgba(244, 211, 138, 0.18); }
.status {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-size: 12.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.is-busy {
  background: linear-gradient(90deg, var(--ink-faint) 0 35%, #fff 50%, var(--ink-faint) 65% 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.send {
  position: relative;
  appearance: none;
  border: 0;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #121016;
  background: linear-gradient(180deg, #ffffff, #e4e0ea);
  box-shadow: 0 1px 0 #fff inset, 0 -1px 0 rgba(0, 0, 0, 0.12) inset, 0 6px 14px -6px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.2);
  -webkit-tap-highlight-color: transparent;
}
.send:focus-visible, .chip:focus-visible, .tool:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }
.send svg { grid-area: 1 / 1; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send__tick { opacity: 0; }
.send__tick path { stroke-dasharray: 14; stroke-dashoffset: 14; }
/* while it thinks: a ring of film colours turns around the button */
.send__ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 20%, var(--rose) 45%, var(--gold) 62%, var(--mint) 80%, transparent 100%);
  -webkit-mask: radial-gradient(circle, transparent 0 calc(50% - 1.6px), #000 calc(50% - 1.2px));
  mask: radial-gradient(circle, transparent 0 calc(50% - 1.6px), #000 calc(50% - 1.2px));
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.chip {
  appearance: none;
  border: 0;
  font: inherit;
  font-size: clamp(12px, min(1.8vw, 2.6vh), 13px);
  font-weight: 520;
  color: var(--ink-soft);
  height: clamp(28px, 4.6vh, 32px);
  padding: 0 14px;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px var(--line) inset;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .chip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset; }
  .tool:hover { color: var(--ink); background: rgba(255, 255, 255, 0.07); }
}
.chip.is-on { color: var(--ink); background: rgba(255, 255, 255, 0.08); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset; }

@media (max-height: 380px) {
  .chips { display: none; }
}

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  fill: #fff;
  stroke: #111;
  stroke-width: 1.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
