:root {
  --bg: #fafafa; --fg: #111; --accent: #111;
  --line: color-mix(in srgb, var(--fg) 16%, transparent);
  --soft: color-mix(in srgb, var(--fg) 6%, transparent);
  --dim: color-mix(in srgb, var(--fg) 60%, transparent);
  --gap: 12px; --spin: 6s; --round: 1;
  /* every form sets its text in --sans; app.js points it at one of these four as the model hears the voice of the text */
  --plain: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --sans: var(--plain);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: var(--bg); color: var(--fg); font-family: var(--sans); }

#bg, #sky, #sky *, #under, #weather { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#weather { z-index: 4; }
#sky i { opacity: 0; display: none; }
#sky canvas { animation: twinkle 2.6s ease-in-out infinite alternate; }
#sky canvas + canvas { animation-duration: 3.7s; animation-direction: alternate-reverse; }
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #sky canvas { animation: none; } }

#box, .slot { margin: 0; border: 1px solid var(--line); color: var(--fg); font-family: var(--sans); line-height: 1.5; }
#box {
  position: fixed; z-index: 5; resize: none; outline: none; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 78%, transparent); caret-color: var(--accent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#box::placeholder { color: var(--dim); }
#box:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }

/* clears the text; rides on the right end of the text box, only while there is text */
#clear {
  position: fixed; z-index: 6; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  font: 16px/24px var(--plain); color: var(--dim); background: var(--soft);
}
#clear:hover, #clear:focus-visible { color: var(--fg); background: var(--line); }

/* ---- layers: every form is a full-viewport screen. While the model is undecided each
   contender is scaled down into a tile around the text box (--s is its current scale,
   --card is 1 as a tile and 0 once it has taken over the screen). ---- */
#layers { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
#layers > section {
  position: absolute; inset: 0; display: none; pointer-events: none;
  will-change: transform, opacity; --s: 1; --card: 0; --pop: 0;
}
#layers > section.live { pointer-events: auto; }
.screen {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: calc(7vmin * var(--card) * var(--round));
  background: color-mix(in srgb, var(--bg) calc(var(--card) * 80%), transparent);
  outline: calc((1.5px + 4px * var(--pop)) / var(--s)) solid color-mix(in srgb, var(--accent) calc(var(--pop) * 100%), color-mix(in srgb, var(--fg) calc(var(--card) * 42%), transparent));
  box-shadow: 0 calc(10px / var(--s)) calc(30px / var(--s)) rgb(0 0 0 / calc(var(--card) * 14%));
}
.tag {
  position: absolute; left: -100%; right: -100%; top: calc(100% + 7px / var(--s)); text-align: center; white-space: nowrap;
  font: calc(11px / var(--s)) var(--mono); letter-spacing: .04em; color: var(--fg); opacity: var(--card);
}
.slot {
  position: absolute; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
  border-width: calc(1px / var(--s)); background: color-mix(in srgb, var(--bg) 60%, transparent); opacity: var(--card);
}

.col { position: absolute; left: 50%; transform: translateX(-50%); width: min(92vw, var(--w, 820px)); }
.dim { color: var(--dim); }
button.pill {
  font: 600 clamp(15px, 2.4vh, 22px) var(--sans); color: var(--bg); background: var(--accent);
  border: 0; border-radius: 999px; padding: 1.2vh 3.4vh; cursor: pointer;
}
.btn {
  font: 500 clamp(12px, 1.9vh, 16px) var(--sans); color: var(--fg); background: var(--soft);
  border: 1px solid var(--line); border-radius: 999px; padding: .7vh 1.6vh; cursor: pointer;
}
.btn:hover, .btn.sel { background: var(--line); }
#toast {
  position: fixed; top: 16px; left: 50%; z-index: 9; transform: translate(-50%, -20px); opacity: 0; transition: .2s;
  background: var(--fg); color: var(--bg); padding: 6px 14px; border-radius: 999px; font: 13px var(--sans); pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* signal chips */
#chips { position: fixed; top: 14px; right: 14px; display: flex; gap: 6px; z-index: 6; }
#chips span { font: 11px var(--mono); padding: 3px 8px; border-radius: 999px; border: 1px solid var(--accent); color: var(--accent); background: color-mix(in srgb, var(--bg) 70%, transparent); opacity: 0; }

/* readout */
#hud { position: fixed; left: 12px; bottom: 12px; z-index: 6; text-align: left; white-space: pre; cursor: pointer;
  font: 11px/1.5 var(--mono); color: var(--dim); border: 0; padding: 6px 10px; border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 72%, transparent); }
#hud:empty { display: none; }
#hud.off { opacity: .35; background: none; }
@media (max-width: 640px) { #hud { left: 6px; bottom: 4px; padding: 2px 8px; } }
#hud b { color: var(--accent); font-weight: 400; }
