:root {
  --bg: #0d090c;
  --panel: #140d12;
  --bar: #1c1219;
  --fg: #f6d9e3;
  --dim: #8c6b7a;
  --faint: #4a3540;
  --accent: #ff4d8d;
  --hot: #ff2e63;
  --soft: #ffb3cb;
  --deep: #9e1840;
  --gold: #ffd479;
  --mint: #8ff0c4;
  --sky: #9cc8ff;
  --lilac: #d3a6ff;
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #241119 0%, var(--bg) 60%);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
@media (min-width: 700px) { body { font-size: 15px; } }

.window {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  max-width: 980px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
@media (min-width: 700px) {
  .window {
    inset: 4vh 4vw;
    border: 1px solid #3a2330; border-radius: 12px; overflow: hidden;
    box-shadow: 0 30px 80px -20px #ff2e6333, 0 0 0 1px #00000080;
    background: var(--panel);
  }
}

.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; background: var(--bar); border-bottom: 1px solid #2c1a24;
  font-size: 12px; color: var(--dim); user-select: none;
}
.dots { display: flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.dots.ghost { visibility: hidden; }

.term {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 14px 16px 24px;
  -webkit-overflow-scrolling: touch;
  cursor: text;
  text-shadow: 0 0 6px #ff4d8d22;
}
.term::-webkit-scrollbar { width: 6px; }
.term::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 3px; }

.row { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.5em; }
.line { position: relative; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.line.hidden { visibility: hidden; }
#kb {
  position: absolute; left: 0; top: 0; width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; font-size: 16px; /* 16px stops iOS zooming */
  caret-color: transparent; color: transparent; background: transparent;
}
.cursor {
  display: inline-block; width: .6em; height: 1.15em; vertical-align: -.2em;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  animation: blink 1.05s steps(1) infinite;
}
.cursor.inline { margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* prompt + colors */
.pu { color: var(--accent); font-weight: 700; }
.pp { color: var(--sky); font-weight: 700; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.acc { color: var(--accent); }
.hot { color: var(--hot); }
.soft { color: var(--soft); }
.gold { color: var(--gold); }
.mint { color: var(--mint); }
.sky { color: var(--sky); }
.lilac { color: var(--lilac); }
.b { font-weight: 700; }
.err { color: #ff7a7a; }
.ok { color: var(--mint); }
code.k {
  font: inherit; color: var(--gold);
  background: #ffd47914; padding: 0 .3em; border-radius: 3px;
}
.ascii { margin: 0; line-height: 1.15; color: var(--accent); text-shadow: 0 0 10px #ff4d8d66; }

/* help table */
.help { display: grid; grid-template-columns: max-content 1fr; gap: 2px 2.5ch; margin: 4px 0 4px 2ch; }
.help .c { color: var(--gold); }

/* chips */
.chips {
  flex: none; display: flex; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #2c1a24; background: #110b0fee;
  transition: opacity .2s;
}
.chips:empty { display: none; }
.chips.busy { opacity: .35; pointer-events: none; }
.chip {
  font: inherit; font-size: 13px; color: var(--fg);
  background: #ff4d8d14; border: 1px solid #ff4d8d55; border-radius: 999px;
  padding: 7px 13px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, transform .1s;
}
.chip:hover { background: #ff4d8d2a; }
.chip:active { transform: scale(.95); }
.chip.new { border-color: var(--accent); box-shadow: 0 0 12px #ff4d8d44; animation: pulse 2s ease-in-out infinite; }
.chip.done { color: var(--dim); border-color: #ff4d8d30; background: transparent; }
.chip.done::after { content: " ✓"; color: var(--mint); }
.chip.quiet { color: var(--dim); border-color: var(--faint); background: transparent; }
@keyframes pulse { 50% { box-shadow: 0 0 20px #ff4d8d88; } }

/* progress */
.bar-fill { color: var(--accent); }
.bar-empty { color: var(--faint); }

/* spinning heart */
.heart3d { width: fit-content; margin: 6px auto 0; line-height: 1; font-size: .78em; letter-spacing: 0; }
.heart3d .h0 { color: #5c0f27; }
.heart3d .h1 { color: var(--deep); }
.heart3d .h2 { color: var(--hot); text-shadow: 0 0 6px #ff2e6380; }
.heart3d .h3 { color: var(--soft); text-shadow: 0 0 8px #ff4d8d; }
.hint { color: var(--dim); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }

/* I LOVE YOU */
.big {
  position: relative; display: flex; flex-wrap: wrap; justify-content: center;
  gap: .9em 3ch; padding: 1.6em 0 1.4em; margin: 4px 0;
}
.word { display: flex; gap: 1.2ch; }
.glyph {
  margin: 0; line-height: 1; color: var(--accent);
  text-shadow: 0 0 12px #ff2e63aa;
  animation:
    drop .7s cubic-bezier(.2, 1.5, .4, 1) backwards,
    wave 2.2s ease-in-out infinite,
    shimmer 2.2s ease-in-out infinite;
  animation-delay:
    calc(var(--i) * 110ms),
    calc(var(--i) * 140ms + 1.2s),
    calc(var(--i) * 140ms + 1.2s);
}
@keyframes drop { from { transform: translateY(-160%) scale(.6); opacity: 0; } }
@keyframes wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.45em); } }
@keyframes shimmer {
  0%, 100% { color: var(--accent); }
  50% { color: var(--soft); text-shadow: 0 0 18px #ff4d8d; }
}
.floaty {
  position: absolute; bottom: 0; pointer-events: none; color: var(--hot);
  animation: rise var(--d, 3s) ease-out forwards;
  text-shadow: 0 0 8px #ff2e63;
}
@keyframes rise {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--x, 0), -9em) scale(1.1); opacity: 0; }
}
.scramble { font-weight: 700; color: var(--soft); letter-spacing: .25em; }

/* letter / code viewer */
.file {
  margin: 8px 0; border: 1px solid #2f1d27; border-radius: 8px; overflow: hidden;
  background: #0f0a0d;
}
.file-head {
  display: flex; justify-content: space-between; gap: 1ch;
  padding: 6px 12px; background: #1a1016; border-bottom: 1px solid #2f1d27;
  color: var(--dim); font-size: 12px;
}
.file-head b { color: var(--fg); font-weight: 400; }
.code-body { padding: 10px 0; }
.cl { display: flex; min-height: 1.5em; }
.gut { flex: none; width: 4ch; padding-right: 1.5ch; text-align: right; color: var(--faint); user-select: none; }
.code { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 12px; }
.t-comment { color: #7d6a74; font-style: italic; }
.t-string { color: var(--mint); }
.t-number { color: var(--gold); }
.t-keyword { color: var(--lilac); }
.t-fn { color: var(--sky); }
.t-ident { color: var(--fg); }
.t-love { color: var(--accent); font-weight: 700; text-shadow: 0 0 8px #ff4d8d88; }
.t-punct { color: #c99aad; }

/* CRT feel */
.scanlines {
  pointer-events: none; position: fixed; inset: 0; z-index: 10;
  background: repeating-linear-gradient(to bottom, #ffffff05 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
  .glyph, .floaty, .chip.new, .hint { animation: none !important; }
}
