/* Show Tree practice -- qlcconsole's Show Tree in a browser, for the course.
   Layout: Library | Tree | Page | Rig Overview, like the app's tab; the Run
   tab swaps in the cue list, GO bar and a large stage. Dark, as the app is
   (a lighting desk stays dark in a dark room): one look, set on purpose. */
:root {
  --bg: #121419;          /* the window */
  --panel: #1b1e25;       /* panes */
  --raised: #252933;      /* buttons, rows */
  --line: #2f3440;        /* dividers */
  --fg: #e4e7ee;          /* text */
  --muted: #98a0ae;       /* secondary text */
  --dim: #6c7381;         /* tracked (grey) rows */
  --select: #2f63b8;      /* selection, as the app's */
  --select-fg: #ffffff;
  --accent: #5d9cff;      /* links, focus */
  --go: #3f9a4a;          /* GO */
  --go-hi: #4fb35b;
  --note: #e7a33c;        /* practice notice, hints */
  --note-bg: #2b2416;
  --bad: #e5675c;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 var(--ui);
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app {
  display: flex; flex-direction: column;
  height: 100%;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 8px;
  gap: 6px;
}

/* ---- the practice notice ---- */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  background: var(--note-bg); color: var(--note);
  border: 1px solid #5a4520; border-radius: 6px;
  padding: 6px 10px; font-size: 13px;
}
.notice b { color: #ffd08a; }
.notice .spacer { flex: 1; }
.notice button {
  background: transparent; border: 1px solid #6b5426; color: #ffd08a;
  border-radius: 4px; padding: 2px 9px; cursor: pointer;
}
.notice button:hover { background: #3a2f1a; }

/* ---- toolbar ---- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn {
  background: var(--raised); border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 11px; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #4a5263; }
.btn:disabled { opacity: .42; cursor: default; }
.btn.primary { background: var(--select); border-color: var(--select); color: var(--select-fg); }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.status {
  margin-left: auto; min-width: 0; max-width: 100%;
  padding: 3px 9px; border-radius: 4px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.status.flash { color: var(--fg); outline: 2px solid var(--note); }
.status.err { color: var(--bad); }

/* ---- the Show Tree tab ---- */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view > * { flex: 1; }
.tree-view {
  display: grid; gap: 6px; min-height: 0; height: 100%;
  grid-template-columns: minmax(170px, 210px) minmax(190px, 250px) minmax(260px, 1fr) minmax(320px, 1.15fr);
  grid-template-areas: "lib tree page stage";
}
.pane {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
}
.pane > h2 {
  margin: 0; padding: 5px 9px; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center;
}
.pane > h2 .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 400; }
.scroll { overflow: auto; min-height: 0; flex: 1; }
.lib { grid-area: lib; }
.treepane { grid-area: tree; }
.page { grid-area: page; }
.stagepane { grid-area: stage; }

/* Library */
.filter { margin: 6px; padding: 4px 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
.libtree { padding: 0 4px 8px; user-select: none; }
.libtree details { margin-left: 12px; }
.libtree > details { margin-left: 0; }
.libtree summary { cursor: pointer; padding: 2px 4px; border-radius: 3px; list-style: none; }
.libtree summary::-webkit-details-marker { display: none; }
.libtree summary::before { content: "▸"; display: inline-block; width: 1em; color: var(--muted); }
.libtree details[open] > summary::before { content: "▾"; }
.libtree summary.folder::after { content: ""; }
.item {
  display: flex; align-items: center; gap: 7px; margin-left: 26px;
  padding: 2px 6px; border-radius: 3px; cursor: grab; touch-action: manipulation;
}
.item:hover { background: var(--raised); }
.item.picked { background: var(--note); color: #1b1408; }
.item .sw { width: 13px; height: 13px; border-radius: 2px; flex: none; border: 1px solid #0006; }
.item .n { color: var(--muted); }
.item.picked .n { color: #3d2c0c; }
.icon { width: 13px; text-align: center; flex: none; color: var(--muted); font-size: 11px; }

/* Tree */
.tree { padding: 4px 0; user-select: none; }
.row {
  display: flex; align-items: center; gap: 6px; padding: 2px 8px; cursor: pointer;
  white-space: nowrap; min-width: 0;
}
.row .label { overflow: hidden; text-overflow: ellipsis; }
.row .tag { margin-left: auto; color: var(--muted); font-size: 12px; padding-left: 8px; }
.row:hover { background: var(--raised); }
.row.sel { background: var(--select); color: var(--select-fg); }
.row.sel .tag { color: #dfe8ff; }
.row.prod .label { font-weight: 600; }
.row.d1 { padding-left: 22px; }
.row.d2 { padding-left: 36px; }
.row.d3 { padding-left: 58px; }
.row.tracked { color: var(--dim); }
.row.tracked.sel { color: #cfd6e4; background: #3a4150; }
.row.droptarget, .layerrow.droptarget, .dropbox.droptarget { outline: 2px solid var(--note); outline-offset: -2px; }
.empty { color: var(--muted); padding: 10px; }

/* Page */
.pagebody { padding: 10px 12px 16px; display: grid; gap: 10px; align-content: start; }
.field { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: center; }
.field > label, .field > .k { color: var(--muted); }
.field input[type=text], .field input[type=number], .field select, .cmd input, .dlg input[type=text], textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; min-width: 0; width: 100%;
}
.field .v { min-width: 0; }
.layers { display: grid; gap: 4px; }
.layerrow {
  border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; cursor: pointer;
  display: flex; gap: 10px; align-items: baseline; background: var(--bg); min-width: 0;
}
.layerrow .g { font-weight: 600; white-space: nowrap; }
.layerrow .vals { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layerrow.tracked { color: var(--dim); border-style: dotted; }
.layerrow.tracked .vals { white-space: normal; }
.layerrow.tracked .g, .layerrow.tracked .vals { color: var(--dim); font-weight: 400; }
.layerrow.sel { border-color: var(--select); box-shadow: inset 0 0 0 1px var(--select); }
.dropbox {
  border: 2px dashed #4b5262; border-radius: 6px; padding: 14px 10px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.dropbox.ready { border-color: var(--note); color: var(--note); }
.adder { display: flex; gap: 6px; }
.adder select { flex: 1; min-width: 0; }
.hint { color: var(--note); font-size: 13px; }
.sub { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--raised); cursor: pointer; font-size: 13px;
}
.chip .sw { width: 12px; height: 12px; border-radius: 2px; border: 1px solid #0006; }
.chip.on { background: var(--select); border-color: var(--select); color: var(--select-fg); }
.chip.tracked { border-style: dashed; border-color: var(--dim); color: #b9c0cc; }
.chip:disabled { opacity: .4; cursor: default; }
.welcome { display: grid; gap: 8px; }
.welcome h3 { margin: 0; font-size: 16px; text-wrap: balance; }
.welcome ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; }

/* Stage */
.stagepane { position: relative; }
.stagebar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button { background: var(--raised); border: 0; padding: 1px 8px; cursor: pointer; font-size: 12px; text-transform: none; letter-spacing: 0; }
.seg button.on { background: var(--select); color: #fff; }
.canvaswrap { position: relative; flex: 1; min-height: 180px; background: #0b0c10; }
.canvaswrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stagecap {
  position: absolute; left: 8px; top: 6px; font-size: 12px; color: #c9cfdb;
  background: #0b0c10b3; padding: 1px 6px; border-radius: 3px; pointer-events: none;
}
.steps { border-top: 1px solid var(--line); padding: 6px 10px 8px; max-height: 42%; overflow: auto; }
.steps summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.steps ol { margin: 6px 0 0; padding-left: 0; list-style: none; display: grid; gap: 2px; font-size: 13px; }
.steps li { display: flex; gap: 7px; }
.steps li::before { content: "○"; color: var(--dim); flex: none; }
.steps li.done { color: var(--muted); }
.steps li.done::before { content: "✓"; color: var(--go-hi); }

/* Command line */
.cmd { display: flex; gap: 8px; align-items: center; }
.cmd label { color: var(--muted); }
.cmd input { font-family: var(--mono); font-size: 13px; flex: 1; }
.cmdmsg { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

/* Tabs (bottom, as the app's) */
.tabs { display: flex; gap: 4px; border-top: 1px solid var(--line); padding-top: 6px; }
.tab {
  background: transparent; border: 0; border-top: 2px solid transparent;
  padding: 4px 14px; cursor: pointer; color: var(--muted);
}
.tab.on { color: var(--fg); border-top-color: var(--accent); }
.tabs .key { margin-left: auto; color: var(--dim); font-size: 12px; align-self: center; }
.panes-switch { display: none; }

/* ---- Run tab ---- */
.run-view {
  display: grid; gap: 6px; height: 100%; min-height: 0;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 1.4fr);
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "rhead rhead" "rlist rstage" "rnext rnext" "rgo rgo";
}
.rhead { grid-area: rhead; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.rhead h2 { margin: 0; font-size: 20px; text-wrap: balance; }
.mode { margin-left: auto; background: var(--select); color: #fff; font-weight: 700; padding: 1px 10px; border-radius: 3px; letter-spacing: .04em; }
.rlist { grid-area: rlist; }
.rstage { grid-area: rstage; }
.cuetable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cuetable th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.cuetable td { padding: 6px 8px; font-size: 16px; cursor: pointer; }
.cuetable tr.next td { font-weight: 700; }
.cuetable tr.done td { color: var(--dim); }
.cuetable tr.live td { color: #9fe0a6; }
.cuetable td.state { width: 92px; font-size: 13px; font-weight: 700; color: var(--fg); }
.cuetable tr.live td.state { color: var(--go-hi); }
.bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--go-hi); width: 0; }
.rnext { grid-area: rnext; display: grid; gap: 2px; }
.rnext .state { font-weight: 700; font-size: 16px; }
.rnext .what { font-size: 16px; border: 1px solid var(--line); border-radius: 4px; padding: 5px 10px; background: var(--panel); }
.rgo { grid-area: rgo; display: grid; grid-template-columns: 1fr 3fr 1fr; gap: 6px; }
.gobtn {
  background: var(--go); border: 2px solid var(--go-hi); color: #fff; font-size: 30px; font-weight: 800;
  border-radius: 6px; padding: 12px; cursor: pointer; letter-spacing: .04em;
}
.gobtn:hover { background: var(--go-hi); }
.gobtn:disabled { background: var(--raised); border-color: var(--line); color: var(--dim); cursor: default; }
.sidebtn { background: var(--raised); border: 1px solid var(--line); border-radius: 6px; font-size: 18px; color: var(--muted); cursor: pointer; }
.sidebtn:hover { color: var(--fg); }

/* ---- dialogs ---- */
.scrim { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.dlg {
  background: var(--panel); border: 1px solid #454c5b; border-radius: 8px; padding: 16px;
  width: min(460px, 100%); display: grid; gap: 10px; max-height: 90vh; overflow: auto;
}
.dlg h3 { margin: 0; font-size: 16px; }
.dlg p { margin: 0; color: var(--muted); }
.dlg .btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg textarea { min-height: 120px; font-family: var(--mono); font-size: 12px; }

/* ---- narrower screens ---- */
@media (max-width: 1250px) {
  .tree-view {
    grid-template-columns: minmax(160px, 200px) minmax(180px, 240px) 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(240px, 42%);
    grid-template-areas: "lib tree page" "stage stage stage";
  }
}
@media (max-width: 760px) {
  .app { height: auto; min-height: 100%; }
  .panes-switch { display: flex; grid-area: sw; }
  .panes-switch .tab { flex: 1; border-top: 0; border-bottom: 2px solid transparent; padding: 6px 4px; }
  .panes-switch .tab.on { border-bottom-color: var(--accent); }
  .tree-view {
    grid-template-columns: 1fr; grid-template-rows: auto auto auto;
    grid-template-areas: "stage" "sw" "one";
    height: auto;
  }
  .tree-view .lib, .tree-view .treepane, .tree-view .page { grid-area: one; height: 58vh; }
  .tree-view[data-pane="lib"] .treepane, .tree-view[data-pane="lib"] .page,
  .tree-view[data-pane="tree"] .lib, .tree-view[data-pane="tree"] .page,
  .tree-view[data-pane="page"] .lib, .tree-view[data-pane="page"] .treepane { display: none; }
  .stagepane .canvaswrap { min-height: 0; height: auto; aspect-ratio: 16 / 10; flex: none; max-width: 100%; }
  .steps { max-height: none; }
  .run-view {
    grid-template-columns: 1fr; height: auto;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "rhead" "rstage" "rnext" "rgo" "rlist";
  }
  .rstage .canvaswrap { min-height: 0; aspect-ratio: 16 / 10; flex: none; }
  .gobtn { font-size: 24px; padding: 10px; }
  .status { margin-left: 0; flex-basis: 100%; }
  .cmdmsg { display: none; }
  .tabs .key { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
