:root {
  --bg: #050805;
  --bg-raised: #0a120a;
  --green: #33ff33;
  --green-bright: #39ff14;
  --green-dim: #1f8f1f;
  --green-faint: #134d13;
  --amber: #ffb000;
  --red: #ff5a4f;
  --cyan: #4fe0ff;
  --glow: 0 0 2px currentColor, 0 0 8px rgba(51, 255, 51, 0.5);
  --mono: "JetBrains Mono", "IBM Plex Mono", "Courier New", monospace;
  /* Fallbacks cover math alphabets, enclosed letters and odd symbols. */
  /* Generated text: Noto Sans Mono has every combining mark, so zalgo stacks. */
  --display: "Noto Sans Mono", "JetBrains Mono", var(--symbols), monospace;
  --symbols: "Noto Sans Math", "Noto Sans Symbols 2", "Segoe UI Symbol", "Segoe UI Historic", "Apple Symbols", "Noto Sans";
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--green);
  min-height: 100%;
}

body {
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.5;
  text-shadow: var(--glow);
  overflow-x: hidden;
  animation: flicker 7s infinite ease-in-out;
}

[hidden] { display: none !important; }

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

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.25) 2px,
    rgba(0, 0, 0, 0.25) 3px
  );
  mix-blend-mode: multiply;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 55%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

a { color: var(--green-bright); text-underline-offset: 3px; text-decoration-color: var(--green-dim); }

:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 2px;
}

/* ---- header ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.back-link { text-decoration: none; }
.back-link:hover { text-decoration: underline; }

.copy-format {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green-dim);
  text-shadow: none;
  font-size: 14px;
}

.title {
  font-size: clamp(40px, 11vw, 88px);
  line-height: 1;
  letter-spacing: 0.08em;
  margin: 56px 0 28px;
  color: var(--green-bright);
  overflow-wrap: anywhere;
  font-family: var(--display);
}

.hint, .dim {
  color: var(--green-dim);
  text-shadow: none;
}

.hint { margin: 0 0 20px; }
.small { font-size: 14px; }

/* ---- form controls ---- */

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

select, input[type="text"], input[type="search"], input[type="number"], textarea {
  background: var(--bg-raised);
  color: var(--green);
  border: 1px solid var(--green-dim);
  border-radius: 0;
  padding: 4px 8px;
  text-shadow: var(--glow);
}

select { cursor: pointer; }
select option { background: var(--bg); color: var(--green); }

input[type="number"] { width: 5em; }

input[type="range"] {
  accent-color: var(--green-bright);
  width: 100%;
  min-width: 0;
}

input[type="checkbox"] {
  accent-color: var(--green-bright);
  width: 16px;
  height: 16px;
  margin: 0;
}

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
  font-family: var(--display);
}

.btn, .chip {
  background: none;
  border: 1px solid var(--green-dim);
  color: var(--green);
  padding: 4px 12px;
  cursor: pointer;
  text-shadow: var(--glow);
}

.btn:hover, .chip:hover {
  border-color: var(--green-bright);
  color: var(--green-bright);
  background: rgba(57, 255, 20, 0.08);
}

.btn.primary {
  background: var(--green);
  color: var(--bg);
  border-color: var(--green);
  font-weight: 700;
  text-shadow: none;
  box-shadow: 0 0 10px rgba(51, 255, 51, 0.45);
}

.btn.primary:hover {
  background: var(--green-bright);
  color: var(--bg);
}

.btn.primary::before { content: "[ "; }
.btn.primary::after { content: " ]"; }

.chip { font-size: 14px; padding: 2px 10px; }

/* ---- tabs ---- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  border-bottom: 1px solid var(--green-dim);
  margin-bottom: 20px;
}

.tabs button {
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  color: var(--green-dim);
  text-shadow: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs button:hover { color: var(--green); }

.tabs button[aria-selected="true"] {
  color: var(--green-bright);
  text-shadow: var(--glow);
  border-bottom-color: var(--green-bright);
}

/* ---- source ---- */

.source { margin-bottom: 20px; }

.prompt-label {
  display: block;
  color: var(--green-dim);
  text-shadow: none;
  font-size: 14px;
  margin-bottom: 4px;
}

/* ---- zalgo ---- */

.presets, .clean-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 28px;
  padding: 16px;
  border: 1px dashed var(--green-faint);
  margin-bottom: 16px;
}

.slider {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr) 3.5em;
  align-items: center;
  gap: 10px;
}

.slider output { text-align: right; }

.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.field > span:first-child { color: var(--green-dim); text-shadow: none; }
.field.check > span { color: var(--green); text-shadow: var(--glow); }
.field.check { cursor: pointer; }
.field.grow { flex: 1; }
.field.grow input { flex: 1; min-width: 0; }

.seed input { width: 9em; }

.controls .wide { grid-column: 1 / -1; }
.controls p { margin: 0; }

.preview-bar, .weird-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 12px;
}

.output {
  --lh: 2.6em;
  font-size: 32px;
  line-height: var(--lh);
  min-height: 3em;
  padding: 0.3em 0.5em;
  border: 1px solid var(--green-dim);
  background: var(--bg-raised);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  color: var(--green-bright);
}

.output[data-font="mono"] { font-family: var(--display); }
.output[data-font="sans"] { font-family: "Noto Sans", system-ui, var(--symbols), sans-serif; }
.output[data-font="serif"] { font-family: "Noto Serif", Georgia, var(--symbols), serif; }

/* Sparklines and bars have no tall marks to leave room for. */
.output.tight { --lh: 1.6em; min-height: 0; }

/* One line-height band per line, so you can see how far the marks spill. */
.output.lines {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--lh) - 1px),
    var(--green-faint) calc(var(--lh) - 1px),
    var(--green-faint) var(--lh)
  );
  background-origin: content-box;
}

.output-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.stats {
  margin: 0;
  color: var(--green-dim);
  text-shadow: none;
  font-size: 13px;
}

/* ---- styles list ---- */

.group-heading {
  font-size: 14px;
  font-weight: 400;
  color: var(--green-dim);
  text-shadow: none;
  margin: 24px 0 6px;
}

.group-heading::before { content: "$ ls "; }

.style-row {
  display: grid;
  grid-template-columns: 11em minmax(0, 1fr);
  gap: 2px 16px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--green-faint);
  padding: 10px 8px;
  cursor: pointer;
}

.style-row:hover { background: rgba(57, 255, 20, 0.07); }
.style-row:hover .style-name::before { content: "> "; color: var(--green-bright); }

.style-name {
  color: var(--green-dim);
  text-shadow: none;
  font-size: 14px;
  padding-top: 4px;
}

.style-value {
  font-family: var(--display);
  font-size: 20px;
  color: var(--green-bright);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.6;
}

.style-note {
  grid-column: 2;
  font-size: 13px;
  color: var(--amber);
  text-shadow: none;
}

/* ---- weird library ---- */

.lib-section .dim { margin: 0 0 10px; max-width: 70ch; }

.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.lib-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--green-faint);
  padding: 10px;
  cursor: pointer;
}

.lib-card:hover { border-color: var(--green-bright); }

.lib-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 56px;
  font-size: 28px;
  font-family: var(--display);
  overflow: hidden;
  color: var(--green-bright);
}

.lib-glyph.tag, .cp-glyph.tag {
  border: 1px dashed var(--green-dim);
  font-size: 12px;
  color: var(--amber);
  text-shadow: none;
}

.lib-glyph.space {
  flex-direction: column;
  gap: 6px;
  border: 1px dashed var(--green-faint);
}

.space-bar {
  display: inline-block;
  white-space: pre;
  height: 18px;
  line-height: 18px;
  min-width: 1px;
  background: var(--green-dim);
  box-shadow: 0 0 6px rgba(51, 255, 51, 0.4);
}

.space-tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--cyan);
  text-shadow: none;
}

.lib-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-name { font-size: 14px; }
.lib-cp { font-size: 12px; color: var(--green-dim); text-shadow: none; }
.lib-note { font-size: 12px; color: var(--green-dim); text-shadow: none; line-height: 1.4; }

/* ---- inspector ---- */

#i-text { margin-bottom: 12px; }
.clean-bar .btn.primary { margin-left: auto; }

.flags {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.flag {
  font-size: 13px;
  border: 1px solid currentColor;
  padding: 2px 8px;
  text-shadow: none;
}

.cps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cp {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
  padding: 4px 4px 2px;
  border: 1px solid var(--green-faint);
  background: var(--bg-raised);
}

.cp-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 30px;
  padding: 0 3px;
  font-size: 20px;
  font-family: var(--display);
  overflow: hidden;
}

.cp-code {
  font-size: 10px;
  color: var(--green-dim);
  text-shadow: none;
}

.cp-plain .cp-glyph.tag { color: var(--green-dim); border-color: transparent; }
.cp-newline { border-style: dashed; }

.cp-invisible, .flag.cp-invisible { border-color: var(--amber); color: var(--amber); }
.cp-mark, .flag.cp-mark { border-color: var(--red); color: var(--red); }
.cp-space, .flag.cp-space { border-color: var(--cyan); color: var(--cyan); }
.cp-control, .flag.cp-control { border-color: var(--red); color: var(--red); }
.cp-styled, .flag.cp-styled { border-color: var(--green-bright); }
.cp-odd, .flag.cp-odd { border-color: var(--amber); color: var(--amber); }
.flag.cp-plain { color: var(--green-dim); }

.cp-invisible .cp-glyph.tag, .cp-space .cp-glyph.tag { color: inherit; border-color: currentColor; }

/* ---- studio ---- */

/* The CRT overlay would tint the artwork, so the studio shows true colour. */
body[data-tab="studio"] { animation: none; }
body[data-tab="studio"] .scanlines,
body[data-tab="studio"] .vignette { display: none; }
body[data-tab="studio"] .wrap { max-width: 1240px; }

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
}

.studio-stage {
  position: sticky;
  top: 16px;
  min-width: 0;
}

#s-canvas {
  display: block;
  margin: 0 auto;
  border: 1px solid var(--green-dim);
  box-shadow: 0 0 18px rgba(51, 255, 51, 0.15);
}

/* Checkerboard behind a transparent artboard. */
#s-canvas.transparent {
  background: repeating-conic-gradient(#1b1f1b 0% 25%, #2a302a 0% 50%) 0 0 / 20px 20px;
}

.studio-stage .stats { margin: 10px 0; }

.export-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 8px;
}

.studio-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.studio-controls fieldset {
  border: 1px dashed var(--green-faint);
  margin: 0;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.studio-controls legend {
  color: var(--green-dim);
  text-shadow: none;
  font-size: 13px;
  padding: 0 6px;
}

.studio-controls legend::before { content: "# "; }

.studio-controls .slider {
  grid-template-columns: 7.2em minmax(0, 1fr) 3.2em;
  font-size: 14px;
  gap: 8px;
}

.studio-controls .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}

.studio-controls .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.studio-controls .field { font-size: 14px; }
.studio-controls select { max-width: 100%; }
.studio-controls .field select { min-width: 0; }
.studio-controls input[type="number"] { width: 6em; }
.studio-controls .seed input { width: 8.5em; }

input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--green-dim);
  cursor: pointer;
}

.msg {
  margin-top: 16px;
  border: 1px dashed var(--green-faint);
  padding: 10px 12px 12px;
}

.msg summary {
  cursor: pointer;
  color: var(--green-bright);
}

.msg summary::marker { color: var(--green-dim); }

.msg-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  margin: 10px 0;
}

.msg-controls .slider {
  grid-template-columns: 6.5em minmax(0, 1fr) 3.5em;
  font-size: 14px;
  gap: 8px;
}

/* A phone-width chat screen with a "sent" bubble, using the system font the
   apps use, and wrapping anywhere so an over-wide design visibly breaks. */
.chat {
  max-width: 390px;
  padding: 16px 12px;
  background: #0f1115;
  border-radius: 14px;
  display: flex;
  justify-content: flex-end;
}

.bubble {
  max-width: 274px;
  padding: 8px 12px;
  border-radius: 18px;
  background: #0a7cff;
  color: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Segoe UI Symbol", sans-serif;
  font-size: 15px;
  line-height: 1.33;
  white-space: pre-wrap;
  word-break: break-all;
  text-shadow: none;
}

.stats.warn { color: var(--amber); }

@media (max-width: 860px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .studio-stage { position: static; }
}

/* ---- misc ---- */

.cursor-line { margin: 32px 0 0; }

.cursor {
  display: inline-block;
  animation: blink 1s steps(1) infinite;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 4;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  background: var(--green);
  color: var(--bg);
  font-weight: 700;
  padding: 8px 16px;
  box-shadow: 0 0 16px rgba(51, 255, 51, 0.5);
  text-shadow: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  overflow-wrap: anywhere;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast::before { content: "> "; }

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  42% { opacity: 1; }
  43% { opacity: 0.94; }
  44% { opacity: 1; }
  71% { opacity: 1; }
  72% { opacity: 0.96; }
  73% { opacity: 1; }
}

@media (max-width: 640px) {
  .controls { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .style-row { grid-template-columns: minmax(0, 1fr); }
  .style-note { grid-column: 1; }
  .title { margin-top: 36px; }
  .output.tight { font-size: 24px; }
  .clean-bar .btn.primary { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  body { animation: none; }
  .cursor { animation: none; opacity: 1; }
  .toast { transition: none; }
}
