/* Boom Studio — tokens first, then layout, then the parts. */

:root {
  --bg: #0a0d14;
  --bg-raise: #10141d;
  --panel: #121722;
  --panel-2: #171d2a;
  --line: #232b3b;
  --line-soft: #1b2230;
  --text: #eef2f9;
  --muted: #94a0b8;
  --dim: #66718a;
  --accent: #f7c312;
  --accent-ink: #17140a;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --radius: 10px;
  --radius-lg: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 60px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-raise);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.brand-mark i { display: block; width: 5px; border-radius: 3px; }
.brand-mark i:nth-child(1) { height: 20px; background: #e11d2e; }
.brand-mark i:nth-child(2) { height: 24px; background: #f7c312; }
.brand-mark i:nth-child(3) { height: 16px; background: #0e9bd8; }
.brand-name { font-weight: 650; letter-spacing: -.01em; font-size: 15px; }

.title-field { flex: 1 1 auto; min-width: 0; }
.title-field input {
  width: 100%;
  max-width: 420px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 15px;
  font-weight: 500;
}
.title-field input:hover { border-color: var(--line); }
.title-field input:focus { border-color: var(--accent); background: var(--panel); outline: none; }

.topbar-meta { display: flex; gap: 14px; align-items: center; }

.mini-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.mini-field input {
  width: 58px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 13px;
  color: var(--text);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 550;
  font-size: 13px;
  transition: background-color .15s ease, border-color .15s ease, transform .08s ease;
}
.btn:hover { background: #1d2534; border-color: #2d374b; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffd641; border-color: #ffd641; }
.btn-quiet { background: transparent; }
.btn-wide { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-icon svg { width: 18px; height: 18px; fill: currentColor; }

.link-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 2px 0; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr) 288px;
  height: calc(100vh - 60px);
  min-height: 0;
}

.sidebar, .inspector {
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
  min-height: 0;
  scrollbar-width: thin;
}
.sidebar { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  margin-bottom: 12px;
}
.tab {
  flex: 1;
  padding: 7px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel-2); color: var(--text); }

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

.hint { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.hint code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-label { color: var(--muted); font-size: 12px; min-width: 44px; }

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.seg button:hover { color: var(--text); }
.seg button.is-active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

textarea, select, .drop {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  font-size: 13px;
}
textarea { font-family: var(--mono); resize: vertical; line-height: 1.5; }
select { cursor: pointer; }

.drop {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px 12px;
  border-style: dashed;
  cursor: pointer;
  color: var(--muted);
  transition: border-color .15s ease, background-color .15s ease;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: #1a1c14; }
.drop strong { color: var(--text); font-weight: 550; font-size: 13px; }
.drop span { font-size: 11.5px; }
.drop-small { padding: 12px; }

.track-list { display: flex; flex-direction: column; gap: 6px; }
.track-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 7px;
  font-size: 12.5px; background: var(--bg);
}
.track-row input { accent-color: var(--accent); }

.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--line-soft); border-radius: 8px;
  background: var(--bg); cursor: pointer; text-align: left; width: 100%;
  transition: border-color .15s ease, background-color .15s ease;
}
.preset-row:hover { border-color: var(--accent); background: var(--panel-2); }
.preset-row small { color: var(--dim); font-size: 11px; }

/* ---------- tubes ---------- */

.panel-tubes { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head h2 { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }

.lane-colors { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.lane-color-row {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 6px; border-radius: 7px;
}
.lane-color-row:hover { background: var(--bg); }
.lane-color-row input[type="color"] {
  width: 26px; height: 26px; padding: 0; border: 1px solid var(--line);
  border-radius: 7px; background: none; cursor: pointer;
}
.lane-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.lane-color-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.lane-color-name { font-size: 12.5px; font-weight: 600; min-width: 26px; }
.lane-color-hex { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-left: auto; }

/* ---------- stage ---------- */

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.stage-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-bottom: 1px solid var(--line-soft);
}
.stage-meta { display: flex; gap: 12px; align-items: center; margin-left: auto; color: var(--muted); font-size: 12px; }
.warn { color: var(--accent); }

.canvas-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  position: relative;
}
.canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #0d1119;
  box-shadow: var(--shadow);
  touch-action: none;
}

.live-video {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #000;
  box-shadow: var(--shadow);
}
.empty-hint {
  position: absolute;
  color: var(--dim);
  font-size: 13px;
  pointer-events: none;
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
}

.transport {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-top: 1px solid var(--line-soft); background: var(--panel);
}
.scrub { flex: 1; accent-color: var(--accent); }
.clock { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 92px; }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.check input { accent-color: var(--accent); }

/* ---------- inspector ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.render-box { display: flex; flex-direction: column; gap: 9px; }
.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.render-status { font-size: 12px; color: var(--muted); line-height: 1.45; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 50; max-width: 90vw;
}
.toast.is-error { border-color: var(--danger); color: #ffd7d7; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .shell { grid-template-columns: 280px minmax(0, 1fr); }
  .inspector {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: start;
  }
  .shell { height: auto; min-height: calc(100vh - 60px); }
  .stage { min-height: 62vh; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .topbar-meta { order: 3; width: 100%; }
  .title-field { flex: 1 1 120px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 46vh; }
  .canvas-wrap { padding: 8px; }
  .transport { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
