/* Jaizz Chat — white neon + red: a Chicago cabaret / jazz lounge sign (design spec "5a").
 * White neon is the main sign color (logo, bulbs, your messages, SEND);
 * red is the accent (chips, "CHAT LOUNGE", chord charts, links).
 */
:root {
  color-scheme: dark;
  --bg: #0e0c10;
  --surface: rgba(20, 17, 14, 0.9);   /* bot bubbles */
  --surface-2: #1d1916;               /* code, tool output */
  --input-bg: rgba(14, 12, 10, 0.9);
  --ink: #eee6d6;                     /* bot message text */
  --muted: #c8bfae;                   /* tagline */
  --faint: #857c6c;                   /* fine print, status line */
  --border: rgba(244, 239, 230, 0.3);
  --white: #f4efe6;                   /* neon white */
  --white-rgb: 244, 239, 230;
  --on-white: #140000;                /* text on white fills */
  --red: #e50914;
  --red-rgb: 229, 9, 20;
  --red-light: #ffc4c6;               /* text inside red outlines */
  /* The accent the shared parts use (docs page, charts, lists) is the red. */
  --neon: var(--red);
  --neon-rgb: var(--red-rgb);
  --on-neon: #fff4f4;
  --error: #ff8a8f;
  --glow: 0 0 6px rgba(var(--red-rgb), 0.65), 0 0 16px rgba(var(--red-rgb), 0.35);
  --font-logo: "Monoton", "Limelight", system-ui, sans-serif;
  --font-display: "Limelight", "Space Grotesk", system-ui, serif;
  --font-body: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Spotlight on the sign, a darker floor, and faint pinstripes. */
html {
  background-color: var(--bg);
  background-image:
    radial-gradient(640px 440px at 50% 70px, rgba(var(--white-rgb), 0.16), transparent 70%),
    radial-gradient(ellipse at 50% 110%, rgba(0, 0, 0, 0.9), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 22px);
}

body {
  margin: 0 auto;
  max-width: 720px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
  color: var(--ink);
  font: 16px/1.55 var(--font-body);
}

::selection { background: rgba(var(--red-rgb), 0.4); }

a { color: var(--red-light); }

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

header {
  position: relative;
  padding: 30px 20px 22px;
  border-bottom: 1px solid transparent; /* the visible divider is header::before */
}
body:not(.docs) header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}
/* Headings on the docs page: a small red neon sign in Limelight. */
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--red-light);
  text-shadow: 0 0 6px var(--red), 0 0 16px var(--red);
}
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 1.12rem; }
body.docs .tagline { font-size: 1rem; }
.fine { margin: 0; color: var(--faint); font-size: 0.82rem; line-height: 1.7; }
.fine a { color: var(--white); text-decoration: none; font-size: 0.9rem; }
.fine a:hover { color: var(--red-light); text-shadow: 0 0 6px var(--red); }

/* ---------- the sign ----------
   JAIZZ is a white tube, CHAT LOUNGE a red one:
   - on load each sputters on (a tube is lit or dark glass, never see-through,
     so those keyframes use step-end), JAIZZ first;
   - then both glows breathe slowly: a little brighter, back, a little softer, back;
   - now and then the "C" tube buzzes;
   - a pulse of current runs along the divider under the header.
   Shadows, colors and a background only, so nothing on the page moves. */
.neon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin: 4px 0 16px;
  text-shadow: none;
  /* Kept translucent so the glow never fills the gaps between Monoton's lines. */
  --logo-lit: #f8f4ec;
  --logo-glow: 0 0 2px rgba(255, 250, 240, 0.9), 0 0 8px rgba(244, 239, 230, 0.55), 0 0 22px rgba(244, 239, 230, 0.35), 0 0 48px rgba(220, 214, 200, 0.25);
  --logo-dim: #bdb7ad;
  --logo-dim-glow: 0 0 2px rgba(var(--white-rgb), 0.5), 0 0 6px rgba(var(--white-rgb), 0.25);
  --logo-off: #2c2826;
  --sub-lit: var(--red-light);
  --sub-glow: 0 0 6px var(--red), 0 0 16px var(--red);
  --sub-dim: #b98587;
  --sub-dim-glow: 0 0 4px rgba(var(--red-rgb), 0.5), 0 0 8px rgba(var(--red-rgb), 0.25);
  --sub-off: #3a1f20;
}
.neon .logo {
  font-family: var(--font-logo);
  font-size: clamp(44px, 15vw, 66px);
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--logo-lit);
  text-shadow: var(--logo-glow);
  animation: logo-on 1.2s step-end backwards, logo-breathe 5s ease-in-out 1.8s infinite;
}
.neon .sub {
  font-family: var(--font-display);
  font-size: clamp(17px, 5vw, 22px);
  letter-spacing: 0.3em;
  margin-right: -0.3em; /* the spacing after the last letter would push it off-centre */
  line-height: 1.2;
  color: var(--sub-lit);
  text-shadow: var(--sub-glow);
  animation: sub-on 1.2s step-end 0.45s backwards, sub-breathe 5s ease-in-out 1.8s infinite;
}
@keyframes logo-on {
  0%        { color: var(--logo-off); text-shadow: none; }
  12%       { color: var(--logo-lit); text-shadow: var(--logo-glow); }
  17%       { color: var(--logo-off); text-shadow: none; }
  32%       { color: var(--logo-dim); text-shadow: var(--logo-dim-glow); }
  36%       { color: var(--logo-off); text-shadow: none; }
  50%       { color: var(--logo-lit); text-shadow: var(--logo-glow); }
  54%       { color: var(--logo-off); text-shadow: none; }
  63%, 100% { color: var(--logo-lit); text-shadow: var(--logo-glow); }
}
@keyframes sub-on {
  0%        { color: var(--sub-off); text-shadow: none; }
  12%       { color: var(--sub-lit); text-shadow: var(--sub-glow); }
  17%       { color: var(--sub-off); text-shadow: none; }
  32%       { color: var(--sub-dim); text-shadow: var(--sub-dim-glow); }
  36%       { color: var(--sub-off); text-shadow: none; }
  50%       { color: var(--sub-lit); text-shadow: var(--sub-glow); }
  54%       { color: var(--sub-off); text-shadow: none; }
  63%, 100% { color: var(--sub-lit); text-shadow: var(--sub-glow); }
}
/* Breathing: a 5 s sine around the normal glow. */
/* JAIZZ: a gentle peak (the lines stay crisp) and a deeper, dimmer low point. */
@keyframes logo-breathe {
  0%, 50%, 100% { color: #f8f4ec; text-shadow: 0 0 2px rgba(255, 250, 240, 0.9), 0 0 8px rgba(244, 239, 230, 0.55), 0 0 22px rgba(244, 239, 230, 0.35), 0 0 48px rgba(220, 214, 200, 0.25); }
  25%           { color: #fffdf8; text-shadow: 0 0 3px rgba(255, 250, 240, 0.95), 0 0 10px rgba(244, 239, 230, 0.65), 0 0 28px rgba(244, 239, 230, 0.42), 0 0 60px rgba(220, 214, 200, 0.3); }
  75%           { color: #d3ccbf; text-shadow: 0 0 1px rgba(255, 250, 240, 0.6), 0 0 5px rgba(244, 239, 230, 0.28), 0 0 14px rgba(244, 239, 230, 0.14), 0 0 30px rgba(220, 214, 200, 0.08); }
}
@keyframes sub-breathe {
  0%, 50%, 100% { text-shadow: 0 0 6px #e50914, 0 0 16px #e50914; }
  25%           { text-shadow: 0 0 7px #e50914, 0 0 22px #e50914; }
  75%           { text-shadow: 0 0 5px rgba(229, 9, 20, 0.7), 0 0 11px rgba(229, 9, 20, 0.45); }
}
/* The buzzing "C": brightness only, so it keeps breathing with the other letters. */
.neon .buzz { display: inline-block; animation: neon-buzz 12s step-end 2s infinite; }
@keyframes neon-buzz {
  0%, 34.5%, 80.5%, 83.1%, 100% { filter: none; }
  34%, 80%, 81.3%, 82.7%        { filter: brightness(0.2); }
  81.7%                         { filter: brightness(0.55); }
}

/* The divider under the header (::before) and the current running through it
   (::after, drawn on top): a soft white pulse that eases in and out like a sine. */
header::before, header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  pointer-events: none;
}
header::before { background: rgba(var(--white-rgb), 0.25); }
body:not(.docs) header::after {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.45) 25%, #fff 50%, rgba(255, 255, 255, 0.45) 75%, rgba(255, 255, 255, 0)) no-repeat;
  background-size: 22% 100%;
  background-position: -30% 0;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8)) drop-shadow(0 0 6px rgba(var(--white-rgb), 0.6));
  /* The first run is the power-on surge (steady speed, so the bulbs can light in step
     with it); after that it repeats every 5 s, in time with the breathing glow. */
  animation: current-intro 1.6s linear, current 5s cubic-bezier(0.45, 0.05, 0.55, 0.95) 6.8s infinite;
}
@keyframes current-intro {
  from { background-position: -30% 0; }
  to   { background-position: 130% 0; }
}
@keyframes current {
  0%        { background-position: -30% 0; }
  45%, 100% { background-position: 130% 0; }
}

/* ---------- marquee bulbs: they keep time ----------
   Each bulb is two layers: the outer <i> flicks on once at load, as the power-on surge
   on the divider passes beneath it (left to right); the inner <b> is the bulb that keeps time. At rest it brightens on beats 2 and 4, like a
   hi-hat on the backbeat (100 bpm: one bar = 2.4 s). While an answer is on its way the
   light chases across in swung eighths; when it lands, the band hits two stabs. */
.marquee { display: flex; gap: 9px; }
/* The surge crosses the middle of the line at 0.8 s; each bulb lights as it passes. */
.marquee i { display: block; animation: bulb-on 0.3s step-end backwards; }
.marquee i:nth-child(1) { animation-delay: 0.665s; }
.marquee i:nth-child(2) { animation-delay: 0.71s; }
.marquee i:nth-child(3) { animation-delay: 0.755s; }
.marquee i:nth-child(4) { animation-delay: 0.8s; }
.marquee i:nth-child(5) { animation-delay: 0.845s; }
.marquee i:nth-child(6) { animation-delay: 0.89s; }
.marquee i:nth-child(7) { animation-delay: 0.935s; }
@keyframes bulb-on {
  0%        { opacity: 0.08; }
  1%        { opacity: 1; }    /* the surge passes: on */
  30%       { opacity: 0.15; } /* one sputter */
  45%, 100% { opacity: 1; }
}
.marquee b {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.88;
  box-shadow: 0 0 6px var(--white), 0 0 12px var(--white);
  animation: backbeat 2.4s 2s infinite;
}
@keyframes backbeat {
  0%, 24.9%, 37%, 74.9%, 87%, 100% { opacity: 0.88; box-shadow: 0 0 6px #f4efe6, 0 0 12px #f4efe6; animation-timing-function: ease-out; }
  25%, 75% { opacity: 1; box-shadow: 0 0 8px #fff, 0 0 18px #f4efe6, 0 0 30px rgba(244, 239, 230, 0.6); animation-timing-function: ease-out; }
}
/* Waiting: a light chases across in swung eighths (long-short, about 167 bpm).
   Negative delays start each bulb mid-cycle, so the chase begins at once, left to right. */
body.busy .marquee b { animation: chase 1.44s linear infinite; }
body.busy .marquee i:nth-child(2) b { animation-delay: -1.2s; }
body.busy .marquee i:nth-child(3) b { animation-delay: -1.08s; }
body.busy .marquee i:nth-child(4) b { animation-delay: -0.84s; }
body.busy .marquee i:nth-child(5) b { animation-delay: -0.72s; }
body.busy .marquee i:nth-child(6) b { animation-delay: -0.48s; }
body.busy .marquee i:nth-child(7) b { animation-delay: -0.36s; }
@keyframes chase {
  0%        { opacity: 1; box-shadow: 0 0 8px #fff, 0 0 18px #f4efe6, 0 0 30px rgba(244, 239, 230, 0.6); animation-timing-function: ease-out; }
  18%, 100% { opacity: 0.3; box-shadow: 0 0 4px rgba(244, 239, 230, 0.5); }
}
/* The answer lands: two stabs, all bulbs together ("ba-DUM"). */
body.hit .marquee b { animation: stabs 0.7s ease-out; }
@keyframes stabs {
  0%   { opacity: 1; box-shadow: 0 0 10px #fff, 0 0 22px #f4efe6, 0 0 40px rgba(244, 239, 230, 0.7); }
  22%  { opacity: 0.35; box-shadow: 0 0 4px rgba(244, 239, 230, 0.5); }
  32%  { opacity: 1; box-shadow: 0 0 10px #fff, 0 0 22px #f4efe6, 0 0 40px rgba(244, 239, 230, 0.7); }
  100% { opacity: 0.88; box-shadow: 0 0 6px #f4efe6, 0 0 12px #f4efe6; }
}

/* Hidden until the web fonts are in (script in index.html); animations wait too. */
html.fonts-loading body { visibility: hidden; }
html.fonts-loading .neon *, html.fonts-loading .marquee i, html.fonts-loading .marquee b,
html.fonts-loading header::after { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .neon *, .marquee i, .marquee b, header::after, textarea { animation: none !important; }
  .marquee b { opacity: 1; }
}

/* Docs page: the link back sits top right. */
.topnav { float: right; padding-top: 8px; font-size: 0.9rem; }
.topnav a { color: var(--red-light); text-decoration: none; }
.topnav a:hover { text-shadow: var(--glow); }

/* ---------- example prompts: red neon chips ---------- */

.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.examples[hidden] { display: none; }
.chip {
  padding: 7px 13px;
  border: 1px solid var(--red);
  border-radius: 4px;
  background: transparent;
  color: var(--red-light);
  font-size: 0.9rem;
  box-shadow: 0 0 8px rgba(var(--red-rgb), 0.35), inset 0 0 6px rgba(var(--red-rgb), 0.2);
  transition: box-shadow 0.15s, color 0.15s;
}
.chip:hover { color: #fff; box-shadow: 0 0 12px rgba(var(--red-rgb), 0.6), inset 0 0 8px rgba(var(--red-rgb), 0.35); }

/* ---------- chat ---------- */

#chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px 0;
}

.msg {
  max-width: 84%;
  padding: 13px 16px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  line-height: 1.5;
}
.msg.user {
  align-self: flex-end;
  max-width: 72%;
  padding: 11px 15px;
  background: var(--white);
  color: var(--on-white);
  border-radius: 14px 4px 14px 14px;
  font-weight: 500;
  box-shadow: 0 0 18px rgba(var(--white-rgb), 0.5);
}
.msg.pending { display: flex; align-items: center; gap: 10px; color: var(--muted); }

/* Thinking indicator: three little bulbs bouncing in a swing feel (long-short)
   + a shimmer across the label. */
.dots { display: inline-flex; gap: 5px; }
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(var(--white-rgb), 0.8);
  opacity: 0.3;
  animation: dot-swing 0.9s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.3s; }
.dots i:nth-child(3) { animation-delay: 0.45s; }
@keyframes dot-swing {
  0%        { opacity: 1; transform: translateY(-4px) scale(1); animation-timing-function: ease-out; }
  30%, 100% { opacity: 0.3; transform: translateY(0) scale(0.8); }
}
.thinking-label {
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, #fff 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) {
  .dots i, .thinking-label { animation: none; }
  .dots i { opacity: 0.7; }
  .thinking-label { color: var(--muted); background: none; }
}
.msg.error { align-self: flex-start; color: var(--error); border: 1px solid var(--error); background: transparent; }

/* ---------- composer ---------- */

#composer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 16px 0 22px;
  background: linear-gradient(rgba(14, 12, 16, 0), var(--bg) 18px);
}

textarea {
  flex: 1;
  resize: none;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  overflow-y: hidden; /* app.js turns scrolling on past 160px */
}
textarea::placeholder { color: #7d7462; white-space: nowrap; overflow: hidden; }
textarea:focus {
  outline: none;
  border-color: var(--white);
  box-shadow: 0 0 0 1px rgba(var(--white-rgb), 0.6), 0 0 16px -4px rgba(var(--white-rgb), 0.7);
}
/* Clicking into the box strikes it on like a neon tube: two quick flickers, then lit. */
textarea:focus { animation: tube-strike 0.5s step-end; }
@keyframes tube-strike {
  0%        { border-color: var(--border); box-shadow: none; }
  14%       { border-color: var(--white); box-shadow: 0 0 0 1px rgba(var(--white-rgb), 0.6), 0 0 16px -4px rgba(var(--white-rgb), 0.7); }
  24%       { border-color: var(--border); box-shadow: none; }
  44%       { border-color: rgba(var(--white-rgb), 0.55); box-shadow: 0 0 0 1px rgba(var(--white-rgb), 0.25), 0 0 8px -4px rgba(var(--white-rgb), 0.5); }
  54%       { border-color: var(--border); box-shadow: none; }
  68%, 100% { border-color: var(--white); box-shadow: 0 0 0 1px rgba(var(--white-rgb), 0.6), 0 0 16px -4px rgba(var(--white-rgb), 0.7); }
}

button { font: inherit; border: 0; cursor: pointer; }

#send {
  padding: 0 22px;
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(var(--red-rgb), 0.8), 0 0 26px rgba(var(--red-rgb), 0.45);
  transition: box-shadow 0.15s, transform 0.05s;
}
#send:hover { box-shadow: 0 0 12px rgba(var(--red-rgb), 0.95), 0 0 32px rgba(var(--red-rgb), 0.6); }
#send:active { transform: translateY(1px); }
#send:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

footer { padding: 0 0 16px; color: var(--faint); font-size: 0.8rem; min-height: 1.2em; }

/* Wider screens: inset the conversation and the composer, like the design. */
@media (min-width: 640px) {
  #chat { padding: 26px 32px; }
  #composer { padding: 16px 32px 26px; }
  footer { padding: 0 32px 16px; }
}

/* ---------- rendered markdown ---------- */

.msg.md { white-space: normal; }
.msg.md p { margin: 0 0 8px; }
.msg.md > :last-child { margin-bottom: 0; }
.msg.md ul, .msg.md ol { margin: 0 0 8px; padding-left: 20px; }
.msg.md li { margin: 2px 0; }
.msg.md li::marker { color: var(--neon); }
.msg.md strong { color: #fff; }
.msg.md code, .tools pre, .code-block {
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.msg.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.msg.md table { border-collapse: collapse; margin: 4px 0 8px; font-size: 0.9em; display: block; overflow-x: auto; }
.msg.md th, .msg.md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.code-block {
  margin: 4px 0 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
}
.code-block code { background: none; padding: 0; }

/* ---------- chord charts ---------- */

.msg.md:has(.chart) { max-width: 100%; width: 100%; }

.chart {
  margin: 4px 0 10px;
  padding: 12px 12px 8px;
  background: var(--bg);
  border: 1px solid rgba(var(--neon-rgb), 0.45);
  border-radius: 10px;
  box-shadow: inset 0 0 24px -12px rgba(var(--neon-rgb), 0.6);
  overflow-x: auto;
}
.chart-title {
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.chart-note { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.chart-row {
  display: grid;
  grid-template-columns: 2.2em repeat(4, minmax(4.2em, 1fr));
  min-width: 300px;
}
.chart-row.section-start { margin-top: 8px; }
.chart-title + .chart-row.section-start { margin-top: 0; }
.chart-label {
  align-self: center;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--neon);
  text-shadow: var(--glow);
  font-size: 0.85rem;
}
.chart-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 8px;
  min-height: 2.4em;
  padding: 4px 8px;
  border-left: 1px solid rgba(var(--red-rgb), 0.4);
}
.chart-label + .chart-bar { border-left: 2px solid var(--red); }
.chart-bar:last-child { border-right: 2px solid var(--red); }
.chord {
  color: var(--red-light);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
}

/* ---------- tool trace ---------- */

.tools {
  align-self: flex-start;
  max-width: 88%;
  margin-top: -6px;
  font-size: 0.8rem;
  color: var(--faint);
}
.tools summary { cursor: pointer; }
.tools summary:hover { color: var(--red-light); }
.tool-call { margin: 6px 0 0 12px; }
.tool-head { font-family: var(--font-mono); overflow-wrap: anywhere; }
.tools pre {
  margin: 4px 0 0;
  padding: 8px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ---------- docs page ---------- */

body.docs { display: block; }
.docs main { padding: 8px 0 24px; }
.docs section { margin: 30px 0; }
.docs h2 {
  font-size: 1.2rem;
  margin: 0 0 10px;
  color: #fff;
  letter-spacing: 0.01em;
}
.docs h2::before { content: "▍"; color: var(--neon); text-shadow: var(--glow); margin-right: 6px; }
.docs p, .docs li { max-width: 68ch; }
.docs li::marker { color: var(--neon); }
.docs code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.flow { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.flow li {
  counter-increment: step;
  position: relative;
  padding: 10px 12px 10px 50px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.flow li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 11px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--neon);
  color: var(--neon);
  box-shadow: var(--glow);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  line-height: 24px;
}
.flow .who {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon);
}

.live-status { color: var(--muted); font-style: italic; }
.live-status.warn { color: var(--error); font-style: normal; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--neon);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: -4px 0 14px -8px rgba(var(--neon-rgb), 0.8);
}
.tool-card h3 { margin: 0 0 6px; font-size: 1rem; }
.tool-card h3 code { font-size: 0.9rem; color: var(--neon); }
.tool-title { color: var(--muted); font-weight: 400; }
.tool-card p { margin: 0 0 8px; }
.params { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 4px 0 8px; display: block; overflow-x: auto; }
.params th, .params td { text-align: left; border-top: 1px solid var(--border); padding: 6px 10px 6px 0; vertical-align: top; }
.params th { color: var(--muted); font-weight: 400; border-top: 0; }
.req { color: var(--neon); font-size: 0.72rem; }
.hints, .muted { color: var(--muted); font-size: 0.8rem; margin: 0; }

pre.code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
}

.docs-footer { border-top: 1px solid var(--border); padding: 12px 0 24px; color: var(--muted); font-size: 0.85rem; }

/* ---------- chord chart ---------- */

.sheet {
  align-self: stretch;
  margin-top: -4px;
  padding: 14px 14px 16px;
  background: #110e0c;
  border: 1px solid rgba(var(--red-rgb), 0.5);
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(var(--red-rgb), 0.25), inset 0 0 30px -16px rgba(var(--red-rgb), 0.7);
  overflow-x: auto;
  --bar-line: rgba(229, 9, 20, 0.8);
  --chord: var(--red-light);
}
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.sheet-title { font: 700 1.1rem/1.2 "Roboto Condensed", var(--font-body); color: #fff; text-align: center; }
.sheet-style, .sheet-composer { font: 500 0.78rem/1.2 "Roboto Condensed", var(--font-body); color: var(--muted); }
.sheet-composer { text-align: right; }
.sheet-sub { text-align: center; color: var(--muted); font-size: 0.72rem; margin: 2px 0 10px; }

.sheet-grid { min-width: 340px; }
.sheet-row { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 10px; }
.sheet-row.has-label { margin-top: 22px; }

.bar {
  position: relative;
  min-height: 52px;
  border-left: 1.5px solid var(--bar-line);
  padding: 6px 4px 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.bar.empty { border-left: 0; }
.bar.row-end { border-right: 1.5px solid var(--bar-line); }
.bar.after-close { border-left-color: transparent; }
.bar.open-double { border-left: 4px double var(--bar-line); }
.bar.open-repeat { border-left: 4px solid var(--bar-line); box-shadow: inset 3px 0 0 -1.5px #110e0c, inset 4.5px 0 0 -1.5px var(--bar-line); }
.bar.open-repeat::before, .bar.close-repeat::after {
  content: ""; position: absolute; top: 50%; width: 4px; height: 14px; transform: translateY(-50%);
  background: radial-gradient(circle, var(--bar-line) 1.6px, transparent 2px) 0 0 / 4px 7px repeat-y;
}
.bar.open-repeat::before { left: 5px; }
.bar.close-repeat::after { right: 5px; }
.bar.close-double { border-right: 4px double var(--bar-line); }
.bar.close-repeat { border-right: 4px solid var(--bar-line); padding-right: 12px; }
.bar.close-final { border-right: 5px solid var(--bar-line); box-shadow: inset -7px 0 0 -5.5px var(--bar-line); }

.lbl {
  position: absolute; top: -19px; left: -2px;
  min-width: 16px; padding: 0 3px; text-align: center;
  font: 700 0.75rem/16px "Roboto Condensed", var(--font-body);
  background: var(--neon); color: var(--on-neon); border-radius: 2px;
}
.tsig {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center;
  font: 700 0.8rem/0.9 "Roboto Condensed", var(--font-body); color: var(--chord);
}
.bar:has(.tsig) .chords { padding-left: 12px; }
.bar.open-repeat .tsig { left: 13px; }
.bar.open-repeat:has(.tsig) .chords { padding-left: 20px; }
.ending { border-top: 1.5px solid var(--bar-line); margin-top: 4px; }
.ending-start { box-shadow: inset 0 0 0 0 transparent; }
.ending-start::after {
  content: ""; position: absolute; left: -1.5px; top: -1.5px; width: 1.5px; height: 12px; background: var(--bar-line);
}
.ending-num { position: absolute; top: 1px; left: 4px; font: 700 0.68rem/1 "Roboto Condensed", var(--font-body); color: var(--chord); }
.sym { position: absolute; top: -2px; right: 4px; font-family: "Apple Symbols", "Noto Music", "Segoe UI Symbol", serif; font-size: 1rem; color: var(--chord); }
.cmt { font: italic 500 0.66rem/1.1 "Roboto Condensed", var(--font-body); color: var(--muted); margin-top: 2px; }

.chords { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.ch { white-space: nowrap; color: var(--chord); font-family: "Roboto Condensed", var(--font-body); line-height: 1; }
.ch .rt { font-weight: 700; font-size: 1.45rem; }
.ch .rt.nc { font-size: 0.95rem; }
.ch .ac { font-weight: 700; font-size: 0.85rem; vertical-align: 0.6em; margin-left: 1px; }
.ch .ac.pre { margin-left: 0; margin-right: 1px; }
.ch .ql { font-weight: 700; font-size: 0.8rem; margin-left: 1px; }
.ch .bs { display: block; font-weight: 700; font-size: 0.75rem; margin-left: 6px; color: #f3d6d7; }
.rpt { font: 700 1.5rem/1 "Roboto Condensed", var(--font-body); color: var(--chord); margin-left: 30%; }
.rpt sup { font-size: 0.6rem; }

@media (max-width: 480px) {
  .ch .rt { font-size: 1.15rem; }
  .ch .ql { font-size: 0.7rem; }
  .bar { min-height: 44px; padding-left: 6px; }
}

/* ---------- chart menu, setlist, toast ---------- */

.sheet-wrap { position: relative; align-self: stretch; }
.sheet-wrap .sheet-head { padding-right: 34px; } /* room for the ⋯ button */
.sheet-menu-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 34px; height: 30px; border-radius: 6px;
  border: 1px solid rgba(var(--red-rgb), 0.55);
  background: rgba(var(--red-rgb), 0.12);
  color: var(--red-light); font-size: 1.1rem; line-height: 1;
}
.sheet-menu-btn:hover, .sheet-menu-btn[aria-expanded="true"] { color: #fff; box-shadow: 0 0 10px rgba(var(--red-rgb), 0.6); }
.sheet-menu {
  position: absolute; top: 42px; right: 8px; z-index: 3;
  display: flex; flex-direction: column; min-width: 200px; padding: 6px;
  background: var(--surface-2);
  border: 1px solid rgba(var(--red-rgb), 0.6); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 12px rgba(var(--red-rgb), 0.25);
}
.sheet-menu[hidden] { display: none; }
.sheet-menu button { padding: 11px 12px; border-radius: 5px; background: transparent; color: var(--ink); font-size: 0.95rem; text-align: left; }
.sheet-menu button:hover, .sheet-menu button:focus-visible { background: rgba(var(--red-rgb), 0.18); color: #fff; outline: none; }
.sheet-menu button:disabled { opacity: 0.6; cursor: progress; }

.setlist-btn {
  position: absolute; top: 12px; right: 0; z-index: 2;
  padding: 6px 10px 6px 12px; border-radius: 4px;
  border: 1px solid var(--red); background: rgba(14, 12, 10, 0.85);
  color: var(--red-light); font-size: 0.85rem;
  box-shadow: 0 0 8px rgba(var(--red-rgb), 0.35);
}
.setlist-btn[hidden] { display: none; }
.setlist-btn:hover { color: #fff; box-shadow: 0 0 12px rgba(var(--red-rgb), 0.6); }
.setlist-btn .count {
  display: inline-block; min-width: 1.5em; margin-left: 4px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: var(--on-neon); font-weight: 600; text-align: center;
}

.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 20; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 9px 14px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink); font-size: 0.9rem;
  border: 1px solid rgba(var(--red-rgb), 0.6); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}
.toast[hidden] { display: none; }

.setlist {
  width: min(520px, calc(100vw - 32px)); max-height: min(82dvh, 640px); padding: 18px;
  border: 1px solid rgba(var(--red-rgb), 0.6); border-radius: 12px;
  background: #120f0d; color: var(--ink);
  box-shadow: 0 0 24px rgba(var(--red-rgb), 0.3);
}
.setlist::backdrop { background: rgba(0, 0, 0, 0.72); }
.sl-head { display: flex; align-items: center; justify-content: space-between; }
.sl-head h2 { margin: 0; font: 400 1.5rem/1.2 var(--font-display); color: var(--red-light); text-shadow: 0 0 6px var(--red); }
.sl-close { width: 36px; height: 36px; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.5rem; line-height: 1; }
.sl-close:hover { color: #fff; }
.sl-name { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 10px; color: var(--faint); font-size: 0.8rem; }
.sl-name input, .sl-name select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--input-bg); color: var(--ink); font: inherit; font-size: 1rem;
}
.sl-name input:focus, .sl-name select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 8px rgba(var(--red-rgb), 0.4); }
.sl-items { max-height: 46dvh; margin: 0; padding: 0; overflow-y: auto; list-style: none; counter-reset: sl; }
.sl-items li {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid rgba(var(--white-rgb), 0.1); counter-increment: sl;
}
.sl-items li::before { content: counter(sl) "."; min-width: 1.6em; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.sl-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sl-key { margin-left: 8px; color: var(--faint); font-size: 0.85rem; }
.sl-tools { display: flex; gap: 4px; }
.sl-tools button { width: 36px; height: 36px; border-radius: 6px; background: rgba(var(--white-rgb), 0.06); color: var(--ink); font-size: 1rem; }
.sl-tools button:hover:not(:disabled) { background: rgba(var(--red-rgb), 0.25); color: #fff; }
.sl-tools button:disabled { opacity: 0.3; cursor: default; }
.sl-empty { color: var(--muted); font-size: 0.9rem; }
.sl-empty[hidden] { display: none; }
.sl-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sl-primary {
  flex: 1; padding: 11px 14px; border-radius: 6px;
  background: var(--red); color: var(--on-neon); font-weight: 600;
  box-shadow: 0 0 10px rgba(var(--red-rgb), 0.6);
}
.sl-secondary { padding: 11px 14px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--muted); }
.sl-primary:disabled, .sl-secondary:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
