/* vibes — panel + admin styles. Dark stage palette, warm text, amber for key changes. */
:root {
  --bg: #1b1f26;        /* room */
  --surface: #242a33;   /* boxes */
  --raised: #2f3742;    /* buttons */
  --line: #3a434f;
  --text: #efeae0;      /* warm white */
  --muted: #9aa3ad;
  --amber: #f2b84b;     /* music-stand lamp: key + focus */
  --danger: #f87171;

  --sig-Interlude: #a78bfa;
  --sig-Verse: #60a5fa;
  --sig-PreChorus: #bef264;
  --sig-Chorus: #4ade80;
  --sig-Bridge: #fb923c;
  --sig-Next: #22d3ee;
  --sig-End: #f87171;
  --sig-Down: #f472b6;
  --sig-Up: #facc15;

  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--amber); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 14px; color: var(--muted); }
.muted { color: var(--muted); }
.error { color: var(--danger); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- gate ---------- */
body.gate { display: grid; place-items: center; min-height: 100vh; }
.gate-form { display: grid; gap: 10px; width: min(320px, 90vw); }
.gate-form label { color: var(--muted); }
.gate-form input { padding: 12px 14px; font-size: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.gate-form button { padding: 12px; background: var(--amber); color: #1b1f26; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ---------- panel shell ---------- */
body.panel { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex: none; }
.top-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.set-name { font-weight: 600; white-space: nowrap; }
.set-code { color: var(--muted); white-space: nowrap; font-size: 13px; }
.set-code b { font-family: var(--mono); color: var(--amber); letter-spacing: .08em; font-size: 14px; }
.not-live { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(27,31,38,.94); text-align: center; padding: 20px; }
.not-live[hidden] { display: none; }
.not-live h2 { color: var(--text); font-size: 22px; margin-bottom: 8px; }
.not-live p { color: var(--muted); margin: 0 0 18px; }
.code-pill { display: inline-block; font-family: var(--mono); font-size: 15px; letter-spacing: .1em; padding: 3px 10px; border-radius: 6px; background: var(--raised); color: var(--amber); }
.now { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; gap: 16px; white-space: nowrap; }

.grid { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 260px 1fr; gap: 12px; padding: 12px 16px 16px; }
.songs-col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.main-col { display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex: none; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.btn { background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.big { padding: 14px 0; font-size: 20px; flex: 1; }
.btn.ghost { background: transparent; }
.btn.toggle.on { background: var(--amber); color: #1b1f26; border-color: var(--amber); }

.song-list { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1 1 auto; counter-reset: song; }
.song-list li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 7px; cursor: pointer; counter-increment: song; }
.song-list li::before { content: counter(song) ". "; color: var(--muted); flex: none; }
.song-list li .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-list li .k { color: var(--muted); font-family: var(--mono); font-size: 13px; }
.song-list li:hover { background: var(--raised); }
.song-list li.on { background: var(--amber); color: #1b1f26; }
.song-list li.on::before, .song-list li.on .k { color: #5a4310; }
.song-list li.empty { cursor: default; color: var(--muted); }
.song-list li.empty::before { content: ""; }

.slide-box { flex: none; }
.slide-ctl { display: flex; gap: 8px; padding: 10px 12px 4px; }
.hint { margin: 4px 12px 10px; color: var(--muted); font-size: 12px; }

/* ---------- signal ---------- */
.signal-banner {
  flex: none; padding: 16px 20px; border-radius: 10px; text-align: center;
  font-size: clamp(28px, 4vw, 44px); font-weight: 800; letter-spacing: .02em; line-height: 1.1;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line);
  transition: background .2s, color .2s;
}
.signal-banner[data-signal="Interlude"] { background: var(--sig-Interlude); color: #1b1f26; }
.signal-banner[data-signal="Verse"]     { background: var(--sig-Verse);     color: #1b1f26; }
.signal-banner[data-signal="Pre-Chorus"]{ background: var(--sig-PreChorus); color: #1b1f26; }
.signal-banner[data-signal="Chorus"]    { background: var(--sig-Chorus);    color: #1b1f26; }
.signal-banner[data-signal="Bridge"]    { background: var(--sig-Bridge);    color: #1b1f26; }
.signal-banner[data-signal="Next"]      { background: var(--sig-Next);      color: #1b1f26; }
.signal-banner[data-signal="End"]       { background: var(--sig-End);       color: #1b1f26; }
.signal-banner[data-signal="Down"]      { background: var(--sig-Down);      color: #1b1f26; }
.signal-banner[data-signal="Up"]        { background: var(--sig-Up);        color: #1b1f26; }
.signal-banner.flash { animation: flash .9s ease-out 3; }
@keyframes flash { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.45); } }
@media (prefers-reduced-motion: reduce) { .signal-banner.flash { animation: none; } }

.signal-row { display: grid; grid-template-columns: repeat(10, 1fr); gap: 8px; flex: none; }
.sig { padding: 14px 2px; border-radius: 9px; border: 2px solid var(--c); background: transparent; color: var(--c); font-weight: 700; font-size: 15px; cursor: pointer; }
.sig:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }
.sig.on { background: var(--c); color: #1b1f26; }
.sig[data-signal="Interlude"] { --c: var(--sig-Interlude); }
.sig[data-signal="Verse"]     { --c: var(--sig-Verse); }
.sig[data-signal="Pre-Chorus"]{ --c: var(--sig-PreChorus); }
.sig[data-signal="Chorus"]    { --c: var(--sig-Chorus); }
.sig.clear { --c: var(--muted); border-style: dashed; }
.sig[data-signal="Bridge"]    { --c: var(--sig-Bridge); }
.sig[data-signal="Next"]      { --c: var(--sig-Next); }
.sig[data-signal="End"]       { --c: var(--sig-End); }
.sig[data-signal="Down"]      { --c: var(--sig-Down); }
.sig[data-signal="Up"]        { --c: var(--sig-Up); }

/* ---------- lyrics + chords ---------- */
.two { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.text-scroll { flex: 1 1 auto; overflow: auto; padding: 12px 14px; }
pre.lyrics, pre.chords { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 400; line-height: 1.5; }
pre.lyrics { font-family: var(--sans); }
pre.chords { font-family: var(--mono); }
pre.bold { font-weight: 700; }
.sec-h { color: var(--amber); font-weight: 700; }
.page-break { display: block; text-align: center; font-size: 11px; font-family: var(--sans); font-weight: 400; color: var(--muted); border-top: 1px dashed var(--line); line-height: 1.8; margin: 2px 0; }
.key-ctl { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; padding-right: 8px; border-right: 1px solid var(--line); }
.key-label { font-family: var(--mono); font-weight: 700; color: var(--amber); min-width: 3ch; text-align: center; padding: 0 4px; }
.key-label s { color: var(--muted); font-weight: 400; }
.key-note { font-size: 11px; margin-left: 2px; }
.key-label small { color: var(--muted); font-weight: 400; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #1b1f26; padding: 10px 16px; border-radius: 8px; font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1250px) { .signal-row { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 900px) {
  body.panel { height: auto; overflow: auto; }
  .grid { grid-template-columns: 1fr; padding: 10px; }
  .songs-col, .main-col { display: contents; }
  .signal-banner { order: 1; } .signal-row { order: 2; } .slide-box { order: 3; } .two { order: 4; } .songs-box { order: 5; }
  .song-list { max-height: 40vh; }
  .two { grid-template-columns: 1fr; }
  .text-box { min-height: 40vh; max-height: 70vh; }
  .signal-row { grid-template-columns: repeat(5, 1fr); }
  .sig { font-size: 13px; padding: 12px 2px; }
  .top { flex-wrap: wrap; }
  .now { white-space: normal; }
}

/* ---------- admin ---------- */
body.admin { padding: 0 0 60px; }
.admin .top { position: sticky; top: 0; background: var(--bg); z-index: 2; }
.admin .top h1 { font-size: 18px; }
.admin nav a { margin-left: 16px; }
.admin nav a.on { color: var(--text); border-bottom: 2px solid var(--amber); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 16px; }
.wrap h2.title { font-size: 22px; color: var(--text); margin-bottom: 14px; }
.flash-msg { padding: 10px 14px; border-radius: 8px; background: #2c4a35; border: 1px solid #3f7a52; margin-bottom: 16px; }
.flash-msg.err { background: #4a2c2c; border-color: #7a3f3f; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.list td.actions { text-align: right; white-space: nowrap; }
.inline { display: inline; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { color: var(--muted); font-size: 13px; }
.field input[type=text], .field input[type=date], .field select, .field textarea, .field input[type=file] {
  width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit;
}
.field textarea { min-height: 260px; font-family: var(--mono); font-size: 14px; line-height: 1.5; resize: vertical; }
.field .help { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span { grid-column: 1 / -1; }
.btn.primary { background: var(--amber); color: #1b1f26; border-color: var(--amber); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.thumb { max-width: 240px; border-radius: 6px; border: 1px solid var(--line); display: block; margin-top: 6px; }
.empty-note { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--amber); color: #1b1f26; font-size: 12px; font-weight: 600; margin-left: 8px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } table.list td.actions { white-space: normal; } }
