/* ──────────────────────────────────────────────────────────────────
   WebQLab — theatrical dark mode
   ────────────────────────────────────────────────────────────────── */

:root {
  --bg:           #0e0e10;
  --bg-2:         #18181b;
  --bg-3:         #1f1f24;
  --panel:        #16161a;
  --panel-hi:     #202026;
  --line:         #2a2a31;
  --line-hi:      #3a3a44;

  --text:         #e7e7ea;
  --text-dim:     #9a9aa3;
  --text-mute:    #61616b;

  --accent:       #4d8fff;        /* QLab-ish selection blue */
  --accent-soft:  #2c4a82;
  --green:        #2ecc71;
  --green-deep:   #19a05a;
  --amber:        #f5b041;
  --red:          #e74c3c;
  --red-deep:     #b1382b;
  --cyan:         #36c5f0;

  --row-h:        30px;
  --mono:         "SF Mono","Menlo","Consolas","Roboto Mono",monospace;
  --sans:         -apple-system,BlinkMacSystemFont,"Helvetica Neue","Segoe UI",sans-serif;

  --shadow-soft:  0 4px 18px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ───── Masthead ───── */

.masthead {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: stretch;
  gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #19191f 0%, #111114 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  min-height: 78px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
}
.brand-mark { color: var(--green); font-size: 18px; }
.brand-name { font-weight: 600; letter-spacing: 0.06em; font-size: 14px; }

.masthead .standby {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: #0a0a0c;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  overflow: hidden;
}
.masthead .standby-label {
  font-size: 10px; letter-spacing: 0.22em; color: var(--amber);
  font-weight: 700;
}
.masthead .standby-q {
  font-size: 26px; font-weight: 600; color: var(--text);
  min-width: 60px;
}
.masthead .standby-name {
  font-size: 18px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.masthead-actions {
  display: flex; gap: 10px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 0 22px;
  height: 100%;
  min-width: 130px;
  border: none;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: white;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn:active { transform: translateY(1px); filter: brightness(0.9); }
.btn-glyph { font-size: 18px; line-height: 1; }
.btn-label { line-height: 1; }

.btn-go {
  background: linear-gradient(180deg, #34d97a 0%, #19a05a 100%);
}
.btn-go:hover { filter: brightness(1.1); }

.btn-stop {
  background: linear-gradient(180deg, #ef4f3f 0%, #b1382b 100%);
}
.btn-stop:hover { filter: brightness(1.1); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ───── Loaders bar ───── */

.loaders {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.file-label {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px 4px 10px;
  cursor: pointer;
}
.file-label-text {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim);
}
.file-label input[type=file] {
  font-size: 11px;
  color: var(--text);
  width: 0; height: 0; opacity: 0; position: absolute;
  pointer-events: none;
}
.file-label::after {
  content: "Choose…";
  font-size: 11px; padding: 3px 9px;
  background: var(--accent-soft); color: white;
  border-radius: 4px; font-weight: 600;
  letter-spacing: 0.04em;
}
.file-label:hover::after { background: var(--accent); }
.file-name {
  font-size: 12px; color: var(--text-dim);
  font-family: var(--mono);
  max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.status-line {
  margin-left: auto;
  font-size: 12px; color: var(--text-dim);
  font-family: var(--mono);
}

/* Show indicator (visible only when auto-loading from a /show-name/ URL) */
.show-indicator {
  display: none;
  align-items: center; gap: 10px;
  padding: 4px 14px 4px 12px;
  background: linear-gradient(90deg, rgba(46,204,113,0.18), rgba(46,204,113,0.04));
  border: 1px solid rgba(46,204,113,0.5);
  border-radius: 6px;
}
.show-indicator .file-label-text { color: var(--green); font-weight: 600; }
.show-indicator .show-name {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}

body.show-mode .show-indicator { display: inline-flex; }
body.show-mode .file-label     { display: none; }
.status-line.ok    { color: var(--green); }
.status-line.warn  { color: var(--amber); }
.status-line.error { color: var(--red); }

/* ───── Main content ───── */

.main {
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 0;
  overflow: hidden;
}

.cue-list-wrap {
  overflow: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
}

/* ───── Cue list table ───── */

.cue-list {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  table-layout: fixed;
}
.cue-list col.c-status  { width: 32px; }
.cue-list col.c-num     { width: 64px; }
.cue-list col.c-name    { width: auto; }
.cue-list col.c-target  { width: 240px; }
.cue-list col.c-pre     { width: 80px; }
.cue-list col.c-action  { width: 90px; }
.cue-list col.c-post    { width: 80px; }
.cue-list col.c-cont    { width: 36px; }

.cue-list thead th {
  position: sticky; top: 0; z-index: 2;
  background: #16161a;
  color: var(--text-mute);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.cue-list thead th.c-num,
.cue-list thead th.c-pre,
.cue-list thead th.c-post,
.cue-list thead th.c-cont,
.cue-list thead th.c-action { text-align: right; }
.cue-list thead th.c-cont   { text-align: center; }

.cue-list tbody tr {
  height: var(--row-h);
  cursor: pointer;
}
.cue-list tbody tr:nth-child(even) { background: rgba(255,255,255,0.012); }
.cue-list tbody tr:hover { background: rgba(255,255,255,0.04); }

.cue-list tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #1a1a1f;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  vertical-align: middle;
  font-family: var(--mono);
}
.cue-list td.c-name { font-family: var(--sans); font-weight: 500; }
.cue-list td.c-num,
.cue-list td.c-pre,
.cue-list td.c-post,
.cue-list td.c-action { text-align: right; color: var(--text-dim); }
.cue-list td.c-num { color: var(--text); font-weight: 600; }
.cue-list td.c-cont { text-align: center; color: var(--cyan); }

.cue-list td.c-target.missing {
  color: var(--red);
}
.cue-list td.c-target.missing::before {
  content: "✕ "; font-weight: 700;
}
.cue-list td.c-target.matched::before {
  content: "♪ "; color: var(--cyan); font-weight: 600;
}
.cue-list td.c-target.group-target {
  color: var(--text-mute);
}

/* Cue type — group vs audio */
.cue-glyph {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
}
.cue-glyph-group { color: var(--amber); font-weight: 700; }
.cue-glyph-audio { color: var(--cyan); }
.cue-name-text   { font-weight: 500; }
.cue-meta {
  margin-left: 10px;
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--mono);
}

.cue-list tr.row-group { background: rgba(245,176,65,0.04); }
.cue-list tr.row-group td.c-name { color: var(--amber); }
.cue-list tr.row-group td.c-action { font-style: italic; color: var(--text-mute); }

/* Fade-stop indicator — small amber glyph inside the cue-meta span
   (the inline "fade-stop 0.10s" text already labels it; this styles
   that text as a small amber pill instead of putting an extra glyph
   into the c-status cell where it conflicts with the standby ▸). */
.cue-list tr.row-fadestop .cue-meta {
  color: var(--amber);
}
.cue-list tr.row-fadestop .cue-meta::before {
  content: "⤓ ";
  margin-right: 2px;
  opacity: 0.85;
}

/* Animations: group firing + fade-stop-others flash */
.cue-list tr.group-firing {
  animation: groupFire 400ms ease-out;
}
@keyframes groupFire {
  0%   { box-shadow: inset 0 0 0 0 var(--amber); background: rgba(245,176,65,0.3); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}
.cue-list tr.fade-stop-flash {
  animation: fadeStopFlash 600ms ease-out;
}
@keyframes fadeStopFlash {
  0%   { background: rgba(231,76,60,0.4); }
  100% { background: transparent; }
}

/* Active panel — fading state */
.active-list li.cue-active.fading {
  border-left-color: var(--amber);
  opacity: 0.7;
}
.active-list li.cue-active.fading .progress-bar {
  background: linear-gradient(90deg, var(--amber), var(--red));
}
.active-list li.cue-active.fading::after {
  content: " · fading";
  font-size: 10px;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Standby row — strong background only.  No ::before glyph in
   c-status (which collides with row-fadestop and was the source of
   the Safari row-collapse bug), no border, no box-shadow.  The
   standby indicator is rendered inline as part of the cue-name cell
   via the .cue-glyph::before rule below. */
.cue-list tbody tr.standby td,
.cue-list tbody tr.standby > td {
  background-color: rgba(245,176,65,0.28) !important;
}
.cue-list tbody tr.standby .cue-glyph::before {
  content: "▸ ";
  color: var(--amber);
  font-weight: 700;
}

.cue-list tbody tr.selected {
  background: rgba(77,143,255,0.18) !important;
}

.cue-list tbody tr.playing td.c-status::before {
  content: "●";
  color: var(--green);
  font-size: 14px;
  animation: pulse 0.9s infinite alternate;
}
.cue-list tbody tr.playing {
  background: rgba(46,204,113,0.07) !important;
}

.cue-list td.c-status {
  text-align: center;
  padding: 0;
  vertical-align: middle;
  font-size: 13px;
  line-height: 1;
}

@keyframes pulse {
  from { opacity: 0.55; }
  to   { opacity: 1; }
}

.empty-row td {
  padding: 40px;
  text-align: center;
  color: var(--text-mute);
  font-style: italic;
  border-bottom: none;
}
.empty-row td code {
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--cyan);
  font-family: var(--mono);
  font-style: normal;
}

/* ───── Side panel ───── */

.side-panel {
  background: var(--panel);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.side-section {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 14px;
}
.side-section h3 {
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 8px;
  font-weight: 700;
}

.active-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.active-list li.active-empty {
  color: var(--text-mute);
  font-style: italic;
  font-size: 12px;
  padding: 6px 8px;
  text-align: center;
}
.active-list li.cue-active {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
}
.active-list li.cue-active .row1 {
  display: flex; justify-content: space-between;
  margin-bottom: 4px;
}
.active-list li.cue-active .q-num { color: var(--text); font-weight: 700; }
.active-list li.cue-active .q-time { color: var(--text-dim); }
.active-list li.cue-active .q-name {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 11px; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.active-list li.cue-active .progress {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.active-list li.cue-active .progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  width: 0%;
  transition: width 0.1s linear;
}
.active-list li.cue-active.has-reverb { border-left-color: var(--cyan); }

.routing-status {
  font-size: 12px;
}
.routing-status > div { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dot {
  display: inline-block;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-mute);
}
.dot-on  { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.dot-off { background: var(--text-mute); }
.routing-meta {
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--mono);
  margin-top: 4px;
  padding-left: 17px;
}

.diag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 0;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ───── Footer ───── */

.footer {
  background: #0a0a0c;
  border-top: 1px solid var(--line);
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text-mute);
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono);
}
.hotkeys kbd {
  background: var(--bg-3);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  margin: 0 2px;
}
.meter {
  font-family: var(--mono);
  font-size: 11px;
}

/* ───── Scrollbar ───── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--line-hi); border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #4a4a55; }
