/* App styles on top of lantern.css (tokens, fonts, family bar and footer). Night only. */
:root {
  --tl-h: 34vh;
  --field: #120f16;            /* inputs, readouts: a step below ground */
  --sel: color-mix(in srgb, var(--site) 22%, var(--surface));
  /* Timeline canvas colours (read by app.js; canvas needs plain colour values). */
  --tl-ground: #15121a;
  --tl-lane-a: #1d1924;
  --tl-lane-b: #1a1620;
  --tl-sep: #2c2633;
  --tl-orig: #110e15;
  --tl-wave: #b9a98f;
  --tl-wave-off: #4a4252;
  --tl-ruler: #241f2c;
  --tl-tick-minor: #4f4559;
  --tl-tick: #74688a;
  --tl-label: #a99e8e;
  --tl-faint: #7a6f80;
  --tl-line: #3a3242;
  --tl-head: #1d1924;
  --tl-btn: #2f2937;
  --tl-ink: #efe6d6;
  --tl-site: #62c0d8;
  --tl-danger: #ff8d8d;
  --tl-missing: #4a1e26;
  --tl-muted-cue: #2f2937;
  --tl-font: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font: 14px/1.35 var(--font-sans);
  font-variant-numeric: lining-nums;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) var(--tl-h) auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: transparent; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 3px 10px; cursor: pointer; font-weight: 500;
}
button:hover { border-color: var(--site); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--site); outline-offset: 2px; }
button.primary { background: var(--site); border-color: var(--site); color: var(--on-site); font-weight: 700; }
button.primary:hover { background: color-mix(in srgb, var(--site) 85%, var(--ink)); }
button.danger:hover { color: var(--danger); border-color: var(--danger); }
input[type=number], input:not([type]), select, textarea, #projName, #clipSearch {
  background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px 6px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--site); border-color: var(--site); }
input[type=range], input[type=checkbox] { accent-color: var(--site); }
kbd {
  background: var(--raised); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--radius-sm);
  padding: 0 4px; font: 11px ui-monospace, monospace;
}
code { font: 12px ui-monospace, monospace; }

/* family bar and footer: slim, so the work area keeps its room */
.lantern-bar .lantern-path { color: var(--bar-ink); }
.lantern-foot { padding-block: 5px; }

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 10px; background: var(--surface); border-bottom: 1px solid var(--line);
}
#topbar .group { display: flex; align-items: center; gap: 6px; }
#topbar .group.right { margin-left: auto; }
#topbar label { color: var(--ink-muted); }
#projName { width: 220px; font: 700 16px/1.2 var(--font-display); letter-spacing: .02em; }
#fps { width: 72px; }

/* main */
main { display: grid; grid-template-columns: 250px minmax(0, 1fr) 310px; min-height: 0; }
aside { background: var(--surface); min-height: 0; overflow: auto; padding: 8px; }
#library { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
#inspector { border-left: 1px solid var(--line); }
.paneTitle { font: 500 15px/1.3 var(--font-display); letter-spacing: .1em; color: var(--ink-muted); }
.hint { color: var(--ink-muted); font-size: 13px; }
.muted { color: var(--ink-muted); }

#clipList { list-style: none; margin: 0; padding: 0; flex: 1; overflow: auto; min-height: 60px; }
#clipList li {
  display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: var(--radius-sm);
  cursor: grab; user-select: none;
}
#clipList li:hover { background: var(--raised); }
#clipList li.sel { background: var(--sel); }
#clipList .aud { padding: 0 6px; font-size: 10px; line-height: 18px; }
#clipList .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#clipList .dur { color: var(--ink-muted); font-size: 12px; font-variant-numeric: lining-nums tabular-nums; }
#missing {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--radius-sm); padding: 6px; font-size: 13px; max-height: 120px; overflow: auto;
}

/* center */
#center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#videoWrap { flex: 1; min-height: 0; position: relative; background: #000; display: flex; align-items: center; justify-content: center; }
#videoWrap.dragover { outline: 2px dashed var(--site); outline-offset: -6px; }
video { max-width: 100%; max-height: 100%; display: block; }
#videoEmpty { position: absolute; color: var(--ink-muted); text-align: center; padding: 20px; pointer-events: none; }
#transport {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--surface); border-top: 1px solid var(--line); flex-wrap: wrap;
}
#transport .play { width: 44px; font-size: 15px; }
#timeDisplay { display: flex; gap: 12px; margin: 0 10px; font: 13px ui-monospace, "JetBrains Mono", monospace; font-variant-numeric: lining-nums tabular-nums; }
#tSec { color: var(--ink); min-width: 80px; }
#tTc { color: var(--site); }
#tFrame { color: var(--ink-muted); }
.vol { display: flex; align-items: center; gap: 4px; color: var(--ink-muted); font-size: 13px; }
.vol input { width: 90px; }
#transport .vol:first-of-type { margin-left: auto; }

/* inspector */
#inspector .field { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; }
#inspector .field > label, #inspector .lbl { color: var(--ink-muted); font: 500 13px/1.3 var(--font-display); letter-spacing: .08em; }
#inspector .row { display: flex; gap: 6px; align-items: center; }
#inspector .row > * { min-width: 0; }
#inspector .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#inspector input[type=number] { width: 100%; }
#inspector .slider { display: grid; grid-template-columns: 1fr 74px; gap: 6px; align-items: center; }
#inspector select, #inspector textarea { width: 100%; }
#inspector textarea { min-height: 50px; resize: vertical; }
#inspector .readout {
  background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px;
  font: 12px ui-monospace, monospace; color: var(--ink-muted); white-space: pre-line;
}
#inspector .buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#inspector h3 { margin: 4px 0 0; font: 700 17px/1.2 var(--font-display); letter-spacing: .02em; word-break: break-all; }
#inspector .sect { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 4px; }
#trimCanvas { width: 100%; height: 44px; display: block; background: var(--field); border-radius: var(--radius-sm); border: 1px solid var(--line); }
#inspector .warn { color: var(--danger); font-size: 13px; }
#summary { margin: 10px 0; }
#summary table { width: 100%; border-collapse: collapse; font-size: 13px; }
#summary td { padding: 2px 0; }
#summary td:last-child { text-align: right; font-variant-numeric: lining-nums tabular-nums; }

/* timeline */
#timelineArea { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-top: 1px solid var(--line); background: var(--surface); position: relative; }
#tlResize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; cursor: ns-resize; z-index: 5; }
#tlToolbar { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
#tlToolbar button { padding: 2px 9px; }
#status { margin-left: auto; color: var(--ink-muted); font-size: 13px; }
#tlScroll { flex: 1; min-height: 0; overflow: auto; position: relative; }
#tlSpacer { position: relative; }
#timeline { position: sticky; left: 0; top: 0; display: block; touch-action: none; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(8, 6, 10, .6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modalBox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px 20px; max-width: 640px; max-height: 90vh; overflow: auto; }
.modalBox h2 { margin-top: 0; font: 700 24px/1.1 var(--font-display); letter-spacing: .02em; }
.modalBox td { padding: 3px 12px 3px 0; vertical-align: top; }
.modalBox h3 { margin: 18px 0 4px; font: 500 15px/1.3 var(--font-display); letter-spacing: .1em; color: var(--ink-muted); }
.modalBox p { margin: 6px 0; max-width: 65ch; }
.modalBox .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.modalBox .buttons { display: flex; gap: 8px; margin-top: 14px; }
.modalBox code { background: var(--field); padding: 0 4px; border-radius: var(--radius-sm); }
#latPad {
  width: 120px; height: 56px; border-radius: var(--radius-md); background: var(--raised); border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center; font: 700 15px var(--font-display); letter-spacing: .1em; color: var(--ink-muted);
  user-select: none; cursor: pointer;
}
#latPad.hit { background: var(--site); color: var(--on-site); }
#latPad.active { border-color: var(--site); }
#latFlash { width: 56px; height: 56px; border-radius: var(--radius-round); background: var(--raised); border: 1px solid var(--line); }
#latFlash.on { background: var(--site); box-shadow: 0 0 24px var(--site); }
.latRow #latRange { flex: 1; }
.latRow #latNum { width: 80px; }
#btnLatency.on { border-color: var(--site); color: var(--site); }
#toast {
  position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%);
  background: var(--raised); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 80vw;
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
