:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel2: #1e2430;
  --line: #2a3140;
  --text: #eef1f6;
  --dim: #8d97a8;
  --gold: #d9b168;
  --green: #33c47a;
  --amber: #e8a33d;
  --red: #e0503f;
  --blue: #4d8ff0;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
        "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100vh; }

a { color: var(--blue); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 140px; }

/* ── top bar ─────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(13,15,20,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .3px; color: var(--gold); white-space: nowrap; }
.brand small { display: block; font-weight: 400; color: var(--dim); letter-spacing: 0; font-size: 11px; }
.spacer { flex: 1 1 auto; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line);
  font-size: 13px; color: var(--dim); white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.pill.ok { color: #bff0d5; border-color: #26694a; background: #14301f; }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.warn { color: #f3ddb4; border-color: #6b5320; background: #2e2410; }
.pill.warn .dot { background: var(--amber); }
.pill.bad { color: #f6cfc8; border-color: #6f2c22; background: #2f1512; }
.pill.bad .dot { background: var(--red); }

/* ── buttons ─────────────────────────────────────────── */

button, .btn {
  font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { border-color: #3d485c; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--gold); color: #17130a; border-color: var(--gold); font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}

/* ── now playing ─────────────────────────────────────── */

.now {
  background: linear-gradient(180deg, #1b2130, #151922);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin: 16px 0;
}
.now-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--dim); }
.now-title { font-size: 26px; font-weight: 700; margin: 4px 0 2px; line-height: 1.2; }
.now-title.idle { color: var(--dim); font-weight: 500; }
.now-ko { font-size: 19px; color: var(--gold); margin-bottom: 6px; }
.now-times { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums;
             color: var(--dim); font-size: 14px; }
.bar { height: 8px; background: #0a0c11; border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s linear; }
.bar.loop > i { background: var(--blue); }
.next { font-size: 14px; color: var(--dim); margin-top: 10px; }
.next b { color: var(--text); font-weight: 600; }

/* ── cue rows ────────────────────────────────────────── */
/* One row per cue rather than a card grid: eight or nine cues visible at once
   on a laptop, and the Play buttons line up in a column the eye can run down. */

.cues { display: flex; flex-direction: column; gap: 6px; }

.cue {
  position: relative;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; flex-wrap: wrap;
}
.cue.playing {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(217,177,104,.12), rgba(217,177,104,.02) 40%, var(--panel));
  box-shadow: inset 3px 0 0 var(--gold);
}
.cue.fading { border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.cue.noaudio .cue-body { opacity: .62; }

.cue-fire {
  flex: 1 1 320px; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  text-align: left; background: transparent; border: 0; border-radius: 0;
  padding: 9px 6px 9px 14px; cursor: pointer; min-height: 58px;
}
.cue-fire:hover { background: rgba(255,255,255,.025); }
.cue-num {
  flex: none; width: 24px; font-size: 12px; color: var(--dim);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
}
.cue-body { flex: 1 1 auto; min-width: 0; }
/* English and Korean share a line: it keeps every row the same height and puts
   three more cues on screen without dropping either label. */
.cue-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cue-en { font-size: 15.5px; font-weight: 650; line-height: 1.25; }
.cue-ko { font-size: 15px; color: var(--gold); line-height: 1.25; }
.cue-sub {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 2px; font-size: 12px; color: var(--dim);
}
.cue-note { color: var(--dim); }
.cue-meta { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.cue-ctrls { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 12px 8px 4px; }
.cue-btn { min-width: 74px; padding: 8px 12px; font-size: 13.5px; border-radius: 8px; }
.cue-btn.loop { color: var(--dim); }
.cue-btn.loop.on { color: #bcd8ff; border-color: #2b4a78; background: #14243a; }
.cue-btn.play { font-weight: 600; }
.cue.playing .cue-btn.play { background: var(--gold); color: #17130a; border-color: var(--gold); }

.tag { padding: 2px 7px; border-radius: 6px; background: #212836; border: 1px solid var(--line); }
.tag.on { color: #bcd8ff; border-color: #2b4a78; background: #14243a; }
.tag.missing { color: #f6cfc8; border-color: #6f2c22; background: #2f1512; }
.tag.cached { color: #bff0d5; border-color: #26694a; background: #14301f; }

.cue-editrow {
  display: none; flex: 1 1 100%;
  padding: 10px 12px 12px; border-top: 1px solid var(--line); background: #10141b;
}
.cue.editing .cue-editrow { display: block; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
label.f { display: block; font-size: 11.5px; color: var(--dim); margin-bottom: 3px; }
input[type=text], input[type=number], input[type=password], select {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: #0b0e13; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
.rowbtns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* one row per song inside a cue */
.tracklist { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.track {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  background: #0b0e13; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
.track-n { flex: none; width: 18px; text-align: center; color: var(--dim); font-size: 12px; }
.track select.track-media { flex: 1 1 200px; min-width: 0; font-size: 13px; padding: 5px 7px; }
.track .f2 { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--dim); }
.track .f2 input { width: 62px; padding: 4px 6px; font-size: 13px; }
.track-len { font-size: 12px; color: var(--dim); min-width: 44px; }

/* ── panic bar ───────────────────────────────────────── */

.panicbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(13,15,20,.96); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.panicbar-inner { max-width: 1180px; margin: 0 auto; width: 100%;
                  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panic {
  flex: 1 1 260px; min-height: 62px;
  background: var(--red); border-color: var(--red); color: #fff;
  font-size: 19px; font-weight: 700; letter-spacing: .4px; border-radius: 12px;
}
.panic:hover { background: #ef6250; border-color: #ef6250; }
.panic small { display: block; font-size: 11.5px; font-weight: 500; opacity: .85; letter-spacing: 0; }

.vol { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; }
.vol input[type=range] { flex: 1; accent-color: var(--gold); height: 30px; }
.vol .val { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 13px; min-width: 42px; text-align: right; }

/* ── panels / misc ───────────────────────────────────── */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 16px; margin: 16px 0; }
.panel h2 { margin: 0 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); }
.hidden { display: none !important; }
.muted { color: var(--dim); }
.small { font-size: 13px; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--dim); }
.drop.over { border-color: var(--gold); color: var(--gold); background: #1a1710; }
.banner { border-radius: var(--radius); padding: 12px 14px; margin: 14px 0;
          display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.info { background: #14243a; border: 1px solid #2b4a78; }
.banner.warn { background: #2e2410; border: 1px solid #6b5320; }
table.log { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.log td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.log td:first-child { width: 74px; color: var(--dim); }
.pass { color: var(--green); } .fail { color: var(--red); } .skip { color: var(--dim); }

/* ── login ───────────────────────────────────────────── */

.login { max-width: 380px; margin: 14vh auto; padding: 0 20px; text-align: center; }
.login h1 { color: var(--gold); font-size: 22px; margin-bottom: 4px; }
.login p { color: var(--dim); font-size: 14px; margin-top: 0; }
.login form { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.login .err { color: var(--red); font-size: 14px; min-height: 20px; }

/* ── remote ──────────────────────────────────────────── */

body.remote .wrap { max-width: 620px; }
body.remote .cues { gap: 8px; }
body.remote .cue-fire { padding: 13px 6px 13px 14px; min-height: 62px; }
body.remote .cue-en { font-size: 16.5px; }
body.remote .now-title { font-size: 22px; }
.disconnected-veil {
  position: fixed; inset: 0; z-index: 60; background: rgba(10,12,17,.93);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px;
}
.disconnected-veil h2 { color: var(--red); margin: 0 0 8px; }

@media (max-width: 640px) {
  .now-title { font-size: 21px; }
  .panic { font-size: 17px; min-height: 58px; }
  /* Narrow screens: let the controls drop under the label rather than
     squeezing the cue name into two characters. */
  .cue-fire { flex: 1 1 100%; padding-right: 14px; }
  .cue-ctrls { flex: 1 1 100%; padding: 0 12px 10px 50px; }
  .cue-btn { flex: 1; }

  /* ...except on the remote, where stacking costs so much height that only
     three cues fit on a phone. One Play button beside the label fits fine. */
  /* basis 0, not auto: with auto the label's own width is the basis, so a long
     cue name shoves the Play button onto its own line. */
  body.remote .cue-fire { flex: 1 1 0; min-width: 0; padding: 11px 4px 11px 14px; }
  body.remote .cue-ctrls { flex: none; padding: 8px 12px 8px 4px; }
  body.remote .cue-btn { flex: none; min-width: 70px; padding: 12px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
