/* TUI look: one monospace grid, box panels with titles cut into the border,
   inverse-video selection, a tmux-style status bar. */
:root {
  --bg: #0b0e14;
  --bg-2: #0f131b;
  --bg-3: #151a24;
  --fg: #d5dae2;
  --dim: #6b7585;
  --faint: #3a4250;
  --line: #2a313d;
  --accent: #ffb454;
  --cyan: #59c2ff;
  --green: #aad94c;
  --magenta: #d2a6ff;
  --red: #f07178;
  --mono: ui-monospace, 'JetBrains Mono', 'Iosevka Term', 'Fira Code', 'Cascadia Mono', 'SF Mono', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.5 var(--mono); min-height: 100vh; font-variant-ligatures: none; }
/* faint scanlines */
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; font-variant-ligatures: none; }
kbd { font: inherit; color: var(--bg); background: var(--dim); padding: 0 0.4ch; border-radius: 2px; }
::selection { background: var(--accent); color: var(--bg); }

.screen { max-width: 960px; margin: 0 auto; padding: 18px 16px 64px; }

/* ── top bar ───────────────────────────── */
.topbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2ch; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.prompt { color: var(--green); }
.tagline { color: var(--dim); flex: 1; min-width: 0; }
.clock { color: var(--dim); }

/* ── panels ────────────────────────────── */
.panel { position: relative; margin-top: 22px; padding: 14px 16px 12px; border: 1px solid var(--line); border-radius: 4px; }
.panel-title {
  position: absolute; top: -0.78em; left: 12px; margin: 0; padding: 0 1ch;
  font: inherit; font-weight: 400; color: var(--accent); background: var(--bg);
}
.panel-title::before { content: '[ '; color: var(--faint); }
.panel-title::after { content: ' ]'; color: var(--faint); }
.panel-aside {
  position: absolute; top: -0.78em; right: 12px; padding: 0 1ch;
  color: var(--dim); background: var(--bg);
  max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── rooms: the main way around, so they get room ── */
.rooms-panel { border-color: var(--faint); }
.rooms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 10px; }
.room {
  display: grid;
  grid-template-columns: 54px auto 1fr auto;
  grid-template-areas: 'art key name listeners' 'art model model model' 'art now now now';
  gap: 0 1.2ch;
  padding: 8px 1.5ch 8px 8px;
  color: var(--fg);
  text-decoration: none !important;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.room:hover { border-color: var(--dim); background: var(--bg-2); }
.room .key { grid-area: key; color: var(--bg); background: var(--dim); align-self: start; padding: 0 0.6ch; border-radius: 2px; font-weight: 700; }
.room .room-name { grid-area: name; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .room-listeners { grid-area: listeners; color: var(--green); }
.room .room-listeners.zero { color: var(--dim); }
.room .room-model { grid-area: model; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .room-art {
  grid-area: art; width: 54px; height: 54px; align-self: center;
  object-fit: cover; border-radius: 2px; background: var(--bg-3);
}
.room .room-art.empty { display: flex; align-items: center; justify-content: center; color: var(--faint); }
.room .room-now { grid-area: now; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room .room-now::before { content: '▸ '; color: var(--faint); }
.room.active { border-color: var(--accent); background: var(--accent); }
.room.active, .room.active .room-listeners, .room.active .room-model, .room.active .room-now, .room.active .room-now::before { color: var(--bg); }
.room.active .room-art.empty { background: rgba(0, 0, 0, 0.15); color: var(--bg); }
.room.active .key { background: var(--bg); color: var(--accent); }

/* ── player ────────────────────────────── */
.player-body { display: flex; gap: 2.5ch; align-items: flex-start; }
.cover {
  flex: none; position: relative;
  width: 120px; height: 120px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--bg-3); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none !important;
}
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.cover img:not([hidden]) + .cover-empty { display: none; }
.cover-empty { color: var(--faint); font-size: 28px; }
.btn {
  flex: none; font-weight: 700; padding: 4px 1.5ch; margin-top: 10px;
  color: var(--accent); background: transparent;
  border: 1px solid var(--accent); border-radius: 2px;
  cursor: pointer; min-width: 17ch; text-align: center;
}
.btn:hover:not(:disabled), .btn.playing { background: var(--accent); color: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: 1px dashed var(--fg); outline-offset: 2px; }
.now { flex: 1; min-width: 0; }
.title-line { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 0.2ch; }
@keyframes blink { 50% { opacity: 0; } }
.comment { color: var(--dim); min-height: 1.5em; }
.comment:not(:empty)::before { content: '# '; color: var(--faint); }
.meta { display: flex; flex-wrap: wrap; gap: 0 2.5ch; margin-top: 4px; color: var(--dim); }
.meta span:empty { display: none; }
.meta .k { color: var(--faint); }
.meta .v { color: var(--fg); }
.dot { color: var(--faint); }
.dot.live { color: var(--red); }

.spectrum { display: block; width: 100%; height: 60px; margin-top: 12px; }
.progress-line { display: flex; gap: 2ch; margin-top: 6px; white-space: pre; overflow: hidden; }
.bar { flex: 1; min-width: 0; overflow: hidden; color: var(--accent); }
.bar .rest { color: var(--faint); }
.progress-label { color: var(--dim); }

.notice { color: var(--red); margin: 10px 2px 0; }
.notice::before { content: '! '; }

/* ── liner notes ───────────────────────── */
.notes-teaser {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 0; margin: 0;
  color: var(--dim); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notes-teaser::before { content: '▸ '; color: var(--accent); }
.notes-teaser:hover { color: var(--fg); }
.notes-panel:not(.folded) .notes-teaser { display: none; }
.notes-panel.folded .notes-body { display: none; }
.notes-head { color: var(--accent); cursor: pointer; }
.notes-head::before { content: '▾ '; }
.notes-text { margin: 4px 0 0; white-space: pre-wrap; max-width: 78ch; }
.notes-art { margin: 8px 0 0; color: var(--dim); max-width: 78ch; }
.notes-art:not(:empty)::before { content: 'cover prompt: '; color: var(--faint); }
.notes-log-head { margin-top: 18px; color: var(--faint); }
.notes-log-head::before { content: '── '; }
.notes-log { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.notes-log:empty::after { content: 'nothing yet: this is the first set'; color: var(--faint); }
.log-entry { display: grid; grid-template-columns: 48px 1fr; gap: 0 1.5ch; }
.log-entry img, .log-entry .noart { width: 48px; height: 48px; border-radius: 2px; background: var(--bg-3); object-fit: cover; }
.log-entry .noart { display: flex; align-items: center; justify-content: center; color: var(--faint); }
.log-entry > div { min-width: 0; }
.log-entry .log-set, .log-entry .log-titles { display: block; }
.log-entry .log-set { color: var(--accent); }
.log-entry .log-set .when { color: var(--faint); margin-left: 1ch; }
.log-entry .log-titles { color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-entry .log-notes { margin: 2px 0 0; color: var(--dim); max-width: 78ch; }

/* ── pattern ───────────────────────────── */
.roll-wrap { position: relative; height: 180px; }
#roll { display: block; width: 100%; height: 100%; }
.roll-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); pointer-events: none; }
.roll-wrap.playing .roll-hint { display: none; }
.next { color: var(--accent); }

/* ── code ──────────────────────────────── */
.code-wrap { display: flex; overflow-x: auto; }
.gutter, pre#code { margin: 0; font: 13px/1.6 var(--mono); font-variant-ligatures: none; }
.gutter { flex: none; padding-right: 1.5ch; margin-right: 1.5ch; color: var(--faint); text-align: right; border-right: 1px solid var(--line); user-select: none; }
pre#code { flex: 1; color: #c3cad5; }
pre#code.fresh { color: var(--fg); }
.code-panel.folded .code-wrap { display: none; }
.code-panel.folded { padding-bottom: 4px; }
.t-str { color: var(--green); }
.t-num { color: var(--accent); }
.t-fn { color: var(--cyan); }
.t-com { color: var(--dim); font-style: italic; }
.t-label { color: var(--magenta); }
.loc { transition: background 0.2s, color 0.2s; }
.loc.on { background: var(--accent); color: var(--bg); transition: none; }

/* ── status bar (tmux) ─────────────────── */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; gap: 0 2ch; align-items: center;
  padding: 3px 1ch;
  background: var(--bg-3); border-top: 1px solid var(--line);
  color: var(--dim); white-space: nowrap; overflow: hidden;
}
.mode { padding: 0 1ch; font-weight: 700; color: var(--bg); background: var(--dim); }
.mode.on { background: var(--green); }
.keys kbd { margin: 0 0.3ch; }
.sb-right { margin-left: auto; }
.sb-x a { color: var(--dim); }
.sb-x a:hover { color: var(--fg); }

@media (max-width: 640px) {
  body { font-size: 13px; }
  .tagline, .clock { display: none; }
  .player-body { gap: 12px; }
  .cover { width: 84px; height: 84px; }
  .btn { width: 100%; }
  .room { grid-template-columns: 44px auto 1fr auto; }
  .room .room-art { width: 44px; height: 44px; }
  .rooms { grid-template-columns: 1fr; gap: 6px; }
  .room { padding: 6px 1ch; }
  .keys, .sb-right { display: none; }
  .sb-x { margin-left: auto; }
  .panel-aside { max-width: 55%; }
}
