/* editor.css — dark, calm, gold-accented theme for the choreography editor */

:root {
  --bg: #050008;
  --bg2: #0a0612;
  --ink: #FFF0DC;
  --gold: #FFB43C;
  --dim: #837b96; /* keep secondary text readable on the dark panels (≥4.5:1 on #0c0916) */
  --line: rgba(255, 240, 220, .10);
  --panel: #0c0916;
  --danger: #ff6a4d;

  /* Font scale — bump these to resize the whole UI in one place.
     --fs-body drives the dense control text (forms, inputs, lists) that must stay readable. */
  --fs-body: 15px;       /* form rows, inputs, dropdowns, list rows — primary reading text */
  --fs-secondary: 14px;  /* .dim captions, active list, warnings */
  --fs-label: 13px;      /* uppercase section / eyebrow headers */
  --fs-tiny: 12px;       /* chips, fallback tags, tiny meta */
  --fs-btn: 15px;        /* buttons */
  --fs-btn-mini: 13px;   /* compact buttons */
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over rules that set an explicit display
   (display:flex on a panel would otherwise override [hidden]'s display:none). */
[hidden] { display: none !important; }

/* themed thin scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 240, 220, .16) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 240, 220, .14); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 240, 220, .26); }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 90% at 50% -10%, #120a1e 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  margin: 0;
  letter-spacing: .01em;
}
.topbar h1 em { font-style: italic; color: var(--gold); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---- buttons ---- */
button {
  background: #160f24;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-btn);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: .15s;
}
button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
button:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
button:disabled { opacity: .35; cursor: not-allowed; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
button.mini {
  font-size: var(--fs-btn-mini);
  padding: 4px 10px;
  border-radius: 6px;
}
button.mini.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---- restore banner ---- */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: rgba(255, 180, 60, .08);
  border-bottom: 1px solid rgba(255, 180, 60, .25);
  font-size: var(--fs-body);
  flex: none;
}

/* ---- main stage ---- */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 430px;
  gap: 16px;
  padding: 14px 18px;
  min-height: 0;
}
.ring-pane { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; }
.ringbox { aspect-ratio: 1/1; height: 100%; max-height: 100%; max-width: 100%; }
canvas#ring { width: 100%; height: 100%; display: block; }

/* ---- side pane: now strip / cue list / editor / lab ---- */
.side-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.now-strip {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--fs-body);
  padding: 0 4px;
}
.panel {
  background: linear-gradient(180deg, var(--panel), #080611);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.eyebrow {
  font-size: var(--fs-label);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--dim);
}
.big {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 25px;
  margin: 2px 0;
}
.dim { color: var(--dim); font-size: var(--fs-secondary); line-height: 1.5; }
.small { font-size: var(--fs-label); }
.head { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.head h4 {
  font-size: var(--fs-label);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0 0 8px;
}
.active-list { font-size: var(--fs-secondary); }
.arow { display: flex; align-items: center; gap: 7px; padding: 2px 0; color: var(--dim); }
.arow b { color: var(--ink); font-weight: 500; }
.arow .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.warnings { color: var(--danger); font-size: var(--fs-secondary); margin-top: 6px; max-height: 110px; overflow-y: auto; }

.cue-list-panel { flex: none; display: flex; flex-direction: column; padding: 10px 12px; }
.editor-panel { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.panel-head h4 {
  font-size: var(--fs-label);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}

.cue-list {
  height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0712;
  font-size: var(--fs-secondary);
}
.cue-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 240, 220, .04);
  white-space: nowrap;
}
.cue-row:hover { background: rgba(255, 240, 220, .04); }
.cue-row.selected { background: rgba(255, 180, 60, .12); }
.cue-row.playing .t { color: var(--gold); }
.cue-row .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cue-row .t {
  font-family: ui-monospace, monospace;
  color: var(--dim);
  min-width: 58px;
}
.cue-row b { font-weight: 500; }
.cue-row .fx { color: var(--dim); overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cue-row .chip, .chip {
  font-size: var(--fs-tiny);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--dim);
}
.fallback { color: var(--danger); font-size: var(--fs-tiny); }

/* ---- cue editor form ---- */
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}
.cueid {
  font-family: ui-monospace, monospace;
  font-size: var(--fs-body);
  color: var(--gold);
  letter-spacing: .04em;
}
.editor-actions { display: flex; gap: 6px; }

.form-section {
  font-size: var(--fs-label);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 8px;
}
/* compact row: label left, controls right; wraps under the label when narrow */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  flex-wrap: wrap;
  margin: 8px 0;
  font-size: var(--fs-body);
}
.form-row > label, .row-head label { color: var(--dim); flex: none; display: inline-flex; align-items: center; gap: 5px; }

/* info icon: small circled "i" with a hover tooltip explaining each setting */
.info-i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--dim);
  color: var(--dim);
  font-size: 10px;
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  cursor: help;
  flex: none;
  user-select: none;
}
.info-i:hover, .info-i:focus { border-color: var(--gold); color: var(--gold); outline: none; }
label.cb .info-i { margin-left: 1px; }
.form-ctrl {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
  min-width: 0;
}
/* stacked row: header line (label … value ƒ) above a full-width control (slider/chip/textarea) */
.form-row.stacked { display: block; margin: 10px 0; }
.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}
.row-head label { color: var(--dim); }
.row-aux { display: flex; align-items: center; gap: 6px; }
.form-row.stacked input[type=range] { display: block; width: 100%; }

select, input[type=text], input[type=number], textarea {
  background: #0a0712;
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-body);
  border-radius: 6px;
  padding: 4px 6px;
  max-width: 100%;
  min-width: 0;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--gold); }

/* native number spinners can't be themed — hide them; .stepper adds app-styled ▴/▾ buttons */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.stepper { display: inline-flex; align-items: stretch; }
.stepper input[type=number] { border-radius: 6px 0 0 6px; border-right: none; }
.step-btns {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 0 6px 6px 0;
  overflow: hidden;
  background: #160f24;
}
.step-btns button {
  flex: 1;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--dim);
  font-size: 9px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
}
.step-btns button:first-child { border-bottom: 1px solid var(--line); }
.step-btns button:hover { color: var(--gold); background: #1d1430; }
textarea { width: 100%; resize: vertical; }
input.num { width: 60px; }
input.time { width: 86px; font-family: ui-monospace, monospace; }
input[type=color] { background: none; border: 1px solid var(--line); border-radius: 6px; width: 44px; height: 26px; padding: 1px; }

/* ---- range sliders, themed; tall hit area + full-width track for precise control ---- */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 50px;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 240, 220, .14);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 1px solid #5a3d12;
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(255, 180, 60, .35);
}
input[type=range]:hover::-webkit-slider-thumb { box-shadow: 0 0 10px rgba(255, 180, 60, .6); }
input[type=range]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 240, 220, .14);
}
input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 1px solid #5a3d12;
  box-shadow: 0 0 6px rgba(255, 180, 60, .35);
}

label.cb { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); font-size: var(--fs-secondary); }
input[type=checkbox] { accent-color: var(--gold); width: 15px; height: 15px; }

.swatch {
  display: inline-block;
  width: 56px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
/* clickable swatch that opens the visual palette picker */
.swatch-btn {
  padding: 0;
  width: 64px;
  height: 22px;
  cursor: pointer;
  transition: .15s;
}
.swatch-btn:hover { border-color: var(--gold); box-shadow: 0 0 6px rgba(255, 180, 60, .4); }
.curve-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, monospace;
  font-size: var(--fs-tiny);
  color: var(--gold);
  border: 1px dashed rgba(255, 180, 60, .4);
  border-radius: 6px;
  padding: 3px 8px;
  white-space: nowrap;
  cursor: pointer;
}
.curve-chip.wide { display: flex; width: 100%; padding: 5px 10px; }
.curve-chip.wide:hover { border-style: solid; }
button.fbtn {
  font-family: ui-monospace, monospace;
  font-style: italic;
  min-width: 26px;
  flex: none;
}
button.fbtn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 180, 60, .1);
}

/* ---- bottom bar ---- */
.bottombar {
  flex: none;
  padding: 8px 18px 14px;
  border-top: 1px solid var(--line);
}
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.clock {
  font-family: 'Spline Sans Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: .06em;
  min-width: 162px;
}

.tl { user-select: none; }
.tl-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}
.tl-zoom { margin-left: auto; display: flex; gap: 4px; }
.tl-bar {
  position: relative;
  height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #0a0712;
  touch-action: none;
}
.tl-section {
  position: absolute;
  top: 0; bottom: 0;
  border-right: 1px solid rgba(255, 240, 220, .07);
  pointer-events: none;
}
.tl-section span {
  position: absolute;
  top: 3px; left: 4px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  max-width: 95%;
}
.tl-tick {
  position: absolute;
  bottom: 0;
  min-width: 2px;
  border-radius: 1px;
  opacity: .85;
  pointer-events: none;
}
.tl-head {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--ink);
  box-shadow: 0 0 8px var(--ink);
  pointer-events: none;
}
.tl-labels {
  position: relative;
  height: 18px;
  width: 100%;
  color: var(--dim);
  font-size: 13px;
  margin-top: 4px;
  font-family: 'Spline Sans Mono', ui-monospace, monospace;
}
.tl-labels span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.tl-labels span:first-child { transform: none; }

/* ---- modals (palette library, curve editor, palette picker) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: linear-gradient(180deg, var(--panel), #080611);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(680px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 22px;
}
.modal-actions { display: flex; gap: 8px; }
.modal-body { overflow-y: auto; padding: 10px 16px 16px; }

.pal-row {
  display: grid;
  grid-template-columns: 130px 70px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 240, 220, .05);
}
.pal-name { width: 100%; }
.pal-swatch { width: 70px; height: 20px; }
.pal-stops { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pal-stop { position: relative; display: inline-flex; }
.pal-stop input[type=color] { width: 34px; height: 24px; }
.stop-rm {
  position: absolute;
  top: -7px; right: -7px;
  width: 15px; height: 15px;
  line-height: 11px;
  padding: 0;
  border-radius: 50%;
  font-size: 10px;
  background: #2a1020;
}

/* ---- palette picker (visual chooser) ---- */
.pp-modal { width: min(560px, 92vw); }
.pp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.pp-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0712;
  cursor: pointer;
  text-align: left;
}
.pp-card:hover { border-color: var(--gold); }
.pp-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.pp-bar { height: 34px; border-radius: 5px; border: 1px solid var(--line); }
.pp-name { font-size: var(--fs-secondary); color: var(--ink); }

/* ---- curve editor ---- */
.curve-dlg { width: min(560px, 92vw); }
/* in the dialog, controls sit right after their label (left-aligned column), not pushed right */
.curve-dlg .form-row { justify-content: flex-start; }
.curve-dlg .form-row > label { min-width: 76px; }
.curve-dlg .form-ctrl { margin-left: 0; justify-content: flex-start; }
#cvCanvas {
  width: 100%;
  height: 140px;
  margin-top: 8px;
  border-radius: 8px;
  background: #0a0712;
  border: 1px solid var(--line);
  touch-action: none;
}

/* ---- preview mode & effect lab ---- */
.preview-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  background: rgba(255, 180, 60, .1);
  border: 1px solid rgba(255, 180, 60, .4);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: var(--fs-secondary);
  letter-spacing: .12em;
  color: var(--gold);
  white-space: nowrap;
}
button.active-preview {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 180, 60, .12);
}
.lab-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; }
.lab-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(0, 1fr);
  gap: 10px;
}
.lab-list {
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a0712;
  font-size: var(--fs-secondary);
}
.lab-group {
  font-size: var(--fs-tiny);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 7px 8px 3px;
  border-bottom: 1px solid rgba(255, 240, 220, .05);
}
.lab-item {
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lab-item:hover { background: rgba(255, 240, 220, .05); }
.lab-item.selected { background: rgba(255, 180, 60, .14); color: var(--gold); }
.lab-form { overflow-y: auto; overflow-x: hidden; min-height: 0; padding-right: 4px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
}

/* ---- short screens (laptops): side-pane panels go side by side ----
   Instead of stacking cue list above the editor/lab in a narrow column (which
   leaves the lab form a few rows tall), the side pane widens into two columns:
   cue list on the left at full height, cue editor on the right. The Effect Lab,
   whose body is already a list+form pair, spans the full widened pane. */
@media (max-height: 880px) {
  .stage { grid-template-columns: 1fr minmax(660px, 840px); }
  .side-pane {
    display: grid;
    grid-template-columns: minmax(210px, 270px) 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    overflow: hidden;
  }
  .now-strip { grid-column: 1 / -1; }
  .cue-list-panel { grid-row: 2; grid-column: 1; min-height: 0; }
  .cue-list { height: auto; flex: 1; min-height: 100px; }
  .editor-panel { grid-row: 2; grid-column: 2; }
  .lab-panel { grid-row: 2; grid-column: 1 / -1; }
}
