/* app.css — workbench chrome for the Lyric Video Engine.
   Dark, instrument-like, and deliberately quiet: the only thing on this page
   that should attract the eye is the panel. */

@font-face {
  font-family: 'First Time Writing!';
  src: url('assets/fonts/FirstTimeWriting.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #05070a;
  --bg-raise: #0b1016;
  --bg-sunk: #070b10;
  --line: #1b2531;
  --line-soft: #141c25;
  --ink: #e6edf5;
  --ink-dim: #8b9bad;
  --ink-faint: #5b6b7d;
  --accent: #6fd8ff;
  --accent-warm: #ffcf7a;
  --radius: 10px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 20% -10%, #0f1a24 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 110%, #101a16 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100vh;
}

h1, h2 { margin: 0; font-weight: 600; }

/* --- top bar ----------------------------------------------------------- */

.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 16, 0.86);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.bar__id { display: flex; align-items: baseline; gap: 10px; }
.bar__id h1 { font-size: 16px; letter-spacing: 0.01em; }
.bar__sub { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  align-self: center;
}
.bar__controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }

/* --- controls ---------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint);
}
select, input[type="number"], input[type="text"], textarea {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
}
select:focus-visible, input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="range"] { accent-color: var(--accent); }

.btn {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .06s;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: #2c3b4d; background: #101923; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #04222e; font-weight: 600; }
.btn--primary:hover { background: #8ce2ff; border-color: #8ce2ff; }
.btn--ghost { background: transparent; color: var(--ink-dim); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.toggle {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  cursor: pointer; user-select: none;
}
.toggle input { accent-color: var(--accent); }

/* --- layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 460px);
  gap: 20px;
  padding: 20px;
  align-items: start;
}
@media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } }

.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* --- synced song ------------------------------------------------------- */

.songcard {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(111, 216, 255, .07), transparent 45%), var(--bg-raise);
}
.songcard__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.songcard__copy { display: flex; flex-direction: column; gap: 2px; }
.songcard__copy strong { font-size: 16px; font-weight: 600; }
.songcard__copy > span:last-child { color: var(--ink-dim); font-size: 12px; }
.songcard__eyebrow {
  color: var(--accent); font-family: var(--mono); font-size: 9px;
  letter-spacing: .1em; text-transform: uppercase;
}
.songcard__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.presentation-mode .songcard__actions a,
.presentation-mode #songBtn { display: none; }
.syncstatus {
  display: flex; align-items: center; gap: 7px;
  min-height: 24px;
  color: var(--ink-dim); font-family: var(--mono); font-size: 10px;
}
.syncstatus__dot {
  width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%;
  background: var(--ink-faint); box-shadow: 0 0 0 transparent;
}
.syncstatus__dot.is-ready { background: var(--accent); box-shadow: 0 0 9px rgba(111, 216, 255, .7); }
.syncstatus__dot.is-playing { background: #65ef9b; box-shadow: 0 0 9px rgba(101, 239, 155, .7); }
.syncstatus__dot.is-warning { background: var(--accent-warm); box-shadow: 0 0 9px rgba(255, 207, 122, .65); }

/* --- the panel mock ---------------------------------------------------- */
/* Mimics the acrylic carrier those transparent modules ship in: the glass
   sits proud of the PCB, with the breakout pins visible below it. */

.glass {
  position: relative;
  align-self: center;
  padding: 18px 18px 0;
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(160, 220, 255, .10), rgba(120, 180, 220, .03) 40%, transparent 70%);
  border: 1px solid rgba(150, 210, 240, .22);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .03) inset,
    0 24px 60px -20px rgba(0, 0, 0, .9);
}
.glass::before {
  /* specular streak across the acrylic */
  content: ''; position: absolute; inset: 0; border-radius: 14px; pointer-events: none;
  background: linear-gradient(112deg, transparent 30%, rgba(255,255,255,.07) 45%, transparent 52%);
}
.glass__panel {
  background: #010306;
  border-radius: 3px;
  overflow: hidden;
  line-height: 0;
  box-shadow: 0 0 40px -6px rgba(110, 200, 255, .28);
}
#screen { display: block; image-rendering: pixelated; }
.glass__legs {
  display: flex; justify-content: center; gap: 14px;
  padding: 9px 0 11px;
  font-family: var(--mono); font-size: 8px; letter-spacing: .14em;
  color: rgba(150, 200, 230, .38);
}

/* --- now playing ------------------------------------------------------- */

.nowplaying {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-raise);
  min-height: 40px;
}
.nowplaying__tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase;
  color: #04222e; background: var(--accent);
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
}
.nowplaying__text { font-size: 14px; flex: 1; min-width: 0; }
.hand-font-ready .nowplaying__text {
  font-family: 'First Time Writing!', var(--sans);
  font-size: 19px;
  line-height: 1;
}
.nowplaying__why { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }

/* --- transport --------------------------------------------------------- */

.transport {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-raise);
}
.transport #scrub { flex: 1; min-width: 80px; }
#playBtn { min-width: 44px; font-size: 13px; }
.time { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); white-space: nowrap; }

.opts { border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--bg-raise); }
.opts > summary {
  cursor: pointer; padding: 10px 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-dim);
}
.opts__grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 14px; padding: 4px 12px 14px;
}

/* --- right panel ------------------------------------------------------- */

.panelbox {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raise);
  overflow: hidden;
  position: sticky; top: 72px;
}
@media (max-width: 1080px) { .panelbox { position: static; } }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 11px 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink-dim); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); background: rgba(111, 216, 255, .05); }

.tabpane { display: none; padding: 14px; flex-direction: column; gap: 12px; }
.tabpane.is-active { display: flex; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; align-items: center; }

#source {
  width: 100%; min-height: 300px; resize: vertical;
  line-height: 1.55; font-size: 12px;
}
.alignstatus {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 150px);
  gap: 12px; align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(111, 216, 255, .28);
  border-radius: 7px;
  background: rgba(111, 216, 255, .055);
}
.alignstatus[hidden] { display: none; }
.alignstatus__copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alignstatus__copy strong { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink); }
.alignstatus__copy span { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.alignstatus progress { width: 100%; height: 7px; accent-color: var(--accent); }
.alignstatus[data-tone="done"] { border-color: rgba(101, 239, 155, .42); }
.alignstatus[data-tone="error"] { border-color: rgba(255, 207, 122, .5); }
.alignstatus[data-tone="error"] .alignstatus__copy strong { color: var(--accent-warm); }
.hint { margin: 0; font-size: 11px; color: var(--ink-faint); line-height: 1.6; }
.hint code { font-family: var(--mono); color: var(--ink-dim); }

/* --- shot list --------------------------------------------------------- */

.shots { display: flex; flex-direction: column; gap: 4px; max-height: 62vh; overflow-y: auto; }
.shot {
  display: grid;
  grid-template-columns: 52px 1fr 116px;
  gap: 8px; align-items: center;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--bg-sunk);
  cursor: pointer;
}
.shot:hover { border-color: var(--line); }
.shot.is-current { border-color: var(--accent); background: rgba(111, 216, 255, .07); }
.shot.is-interlude .shot__text { color: var(--ink-faint); font-style: italic; }
.shot__t { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.shot__text { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot__why { display: block; font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.shot select { font-size: 10px; padding: 3px 4px; width: 100%; }
.shot select.is-locked { border-color: var(--accent-warm); color: var(--accent-warm); }

/* --- export ------------------------------------------------------------ */

.sizecard {
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  color: var(--ink-dim);
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: 6px; padding: 10px 12px;
  white-space: pre-wrap;
}
.sizecard b { color: var(--ink); font-weight: 600; }
.exportgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.log {
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
  color: var(--ink-dim); background: var(--bg-sunk);
  border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 10px 12px; margin: 0;
  max-height: 190px; overflow: auto; white-space: pre-wrap;
}

/* --- tap modal --------------------------------------------------------- */

.tapmodal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(3, 6, 10, .78); backdrop-filter: blur(4px);
}
.tapmodal[hidden] { display: none; }
.tapmodal__inner {
  width: min(460px, 92vw);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.tapmodal__inner h2 { font-size: 15px; }
.tapmodal__inner p { margin: 0; font-size: 12px; color: var(--ink-dim); line-height: 1.6; }
.tapmodal__next {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px; border-radius: 8px; background: var(--bg-sunk); border: 1px solid var(--line-soft);
}
.tapmodal__next span {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-faint);
}
.tapmodal__next strong { font-size: 15px; font-weight: 500; }
.tapmodal__clock { font-family: var(--mono); font-size: 26px; text-align: center; color: var(--accent); }
kbd {
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px;
}

/* --- sync tab ----------------------------------------------------------- */

.wave {
  width: 100%; height: 160px; display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-sunk);
  touch-action: none;
  cursor: text;
}
.syncnext {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  background: var(--bg-sunk); border: 1px solid var(--line-soft);
}
.syncnext span {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-faint);
}
.syncnext strong { font-weight: 500; font-size: 13px; }
.syncsel {
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
  padding: 8px 10px; border-radius: 6px;
  background: var(--bg-sunk); border: 1px solid var(--line-soft);
  color: var(--ink-dim);
}
.syncsel b { color: var(--accent-warm); }
#spRedirect { display: block; margin-top: 4px; word-break: break-all; color: var(--ink-dim); }

/* --- draw tab ----------------------------------------------------------- */

.spritecanvas {
  width: 100%; height: 320px; display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-sunk);
  touch-action: none;
  cursor: crosshair;
}
.toolrow { gap: 6px; }
.tool.is-active { border-color: var(--accent); color: var(--accent); }
.framestrip {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px;
  min-height: 62px; align-items: center;
}
.framestrip figure {
  margin: 0; padding: 3px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-sunk);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 0 0 auto;
}
.framestrip figure.is-active { border-color: var(--accent); background: rgba(111,216,255,.08); }
.framestrip figcaption { font-family: var(--mono); font-size: 9px; color: var(--ink-faint); }
.framestrip canvas { display: block; image-rendering: pixelated; border-radius: 2px; }

/* Sprite picker stacks under the treatment select in a shot row. */
.shot__controls { display: flex; flex-direction: column; gap: 3px; }
.shot__controls select { width: 100%; }
.shot__controls select.sprite { font-size: 9px; color: var(--ink-faint); }
