:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #111620;
  --panel-2: #161d29;
  --line: #2a3444;
  --text: #f4f7fb;
  --muted: #9aa7b8;
  --hot: #ff3269;
  --gold: #fff02d;
  --cyan: #28d9ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #0c1017;
  padding: 20px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--hot);
  color: white;
  font-weight: 900;
}

.brand strong, .brand span { display: block; }
.brand span { color: var(--muted); font-size: 13px; margin-top: 2px; }

nav { display: grid; gap: 8px; }
button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: .65;
}

.nav-item {
  text-align: left;
  padding: 12px 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.nav-item.active { background: var(--panel-2); color: var(--text); }

main { min-width: 0; }
.topbar {
  height: 96px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 16px; margin-bottom: 16px; }
h3 {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0;
}
p { color: var(--muted); }

.panel { display: none; padding: 24px 28px; }
.panel.active { display: block; }

.split {
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 20px;
}

.workbench, .queue {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b0f16;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 11px;
}

textarea { resize: vertical; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary, .ghost {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}
.primary { background: var(--hot); }
.ghost { background: var(--panel-2); border: 1px solid var(--line); }
.full-width { width: 100%; }
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 800;
}

.mode-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
}
.tab.active { color: var(--text); outline: 1px solid var(--hot); }
.mode-body { display: none; }
.mode-body.active { display: block; }
.auth-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
}
.auth-box summary { cursor: pointer; color: var(--text); margin-bottom: 10px; }

.status {
  display: none;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0f16;
  color: var(--muted);
  padding: 11px 12px;
  min-height: 42px;
  font-size: 13px;
  line-height: 1.35;
}
.status.show { display: block; }
.status.ok {
  border-color: rgba(40, 217, 255, .5);
  color: var(--text);
}
.status.error {
  border-color: rgba(255, 50, 105, .65);
  color: #ffd8e2;
}

.clip-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 210px);
  overflow: auto;
}

.clip-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  border: 1px solid var(--line);
  background: #0d121a;
  border-radius: 8px;
  padding: 10px;
}
.clip-card.active { outline: 2px solid var(--hot); }
.clip-card img {
  width: 112px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 4px;
}
.clip-card strong { display: block; font-size: 13px; line-height: 1.25; }
.clip-card span { color: var(--muted); font-size: 12px; }
.clip-actions { display: flex; gap: 8px; margin-top: 8px; }
.clip-actions button { background: var(--panel-2); padding: 7px 9px; border-radius: 5px; font-size: 12px; }

.editor-shell {
  display: grid;
  grid-template-rows: 44px minmax(260px, 42vh) minmax(250px, 1fr);
  min-height: calc(100vh - 144px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #101010;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #262626;
  background: #202020;
  padding: 0 10px;
}

.tool-strip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.tool-button, .compact {
  min-width: 34px;
  min-height: 30px;
  border-radius: 5px;
  padding: 0 9px;
  background: transparent;
  border: 1px solid transparent;
  color: #c6c6c6;
  font-size: 12px;
  font-weight: 800;
}
.tool-button:hover, .tool-button.active {
  background: #2d2d2d;
  border-color: #3a3a3a;
  color: var(--text);
}

.compact {
  min-width: 58px;
  min-height: 32px;
}

.zoom-control {
  display: grid;
  grid-template-columns: auto 118px;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #b9b9b9;
  font-size: 12px;
}
.zoom-control input { padding: 0; }

.editor-main {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 360px;
  min-height: 0;
  border-bottom: 1px solid #262626;
}

.program-monitor {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  background: #181818;
  border-right: 1px solid #262626;
  padding: 16px;
  min-width: 0;
}

.inspector {
  overflow: auto;
  background: #151515;
  padding: 14px;
}

#previewCanvas {
  width: min(100%, 240px);
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 4px;
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
}

.scrub {
  width: min(100%, 520px);
  padding: 0;
}

#sourceVideo { display: none; }

.tool-section {
  border: 1px solid #303030;
  background: #1d1d1d;
  border-radius: 7px;
  padding: 12px;
  margin-bottom: 10px;
}
.tool-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
}

.toggle {
  display: flex;
  grid-template-columns: unset;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.timeline-panel {
  display: grid;
  grid-template-columns: 150px 1fr;
  min-height: 260px;
  background: #222;
}

.timeline-left {
  display: grid;
  grid-template-rows: 44px 94px 1fr;
  border-right: 1px solid #171717;
  background: #202020;
}

.track-head {
  border-bottom: 1px solid #2b2b2b;
}

.track-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-content: center;
  gap: 4px;
  padding: 0 8px;
  border-bottom: 1px solid #2b2b2b;
}
.track-controls button {
  min-height: 26px;
  border-radius: 4px;
  background: transparent;
  color: #c8c8c8;
  font-size: 11px;
}

.track-name {
  display: grid;
  place-items: start center;
  padding-top: 8px;
  color: #d4d4d4;
  font-size: 12px;
}

.timeline-scroll {
  position: relative;
  overflow: auto hidden;
  background: #242424;
}

.time-ruler {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 44px;
  background:
    repeating-linear-gradient(to right, transparent 0, transparent 47px, rgba(255,255,255,.08) 48px),
    #222;
  border-bottom: 1px solid #2e2e2e;
}

.ruler-tick {
  position: absolute;
  top: 0;
  height: 44px;
  border-left: 1px solid rgba(255,255,255,.16);
  color: #777;
  font-size: 12px;
  padding: 8px 0 0 6px;
}

.timeline-stage {
  position: relative;
  height: 210px;
  min-width: 960px;
  background:
    linear-gradient(to bottom, transparent 0 78px, rgba(0,0,0,.18) 78px 80px, transparent 80px),
    #262626;
}

.timeline-clips {
  position: relative;
  height: 100%;
}

.timeline-clip {
  position: absolute;
  top: 54px;
  height: 86px;
  min-width: 120px;
  border-radius: 4px;
  border: 1px solid rgba(0, 222, 230, .8);
  background: #006c71;
  overflow: hidden;
  cursor: pointer;
}
.timeline-clip.active {
  outline: 2px solid #e8f7ff;
  outline-offset: 2px;
}

.clip-bar {
  position: relative;
  z-index: 2;
  height: 23px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  background: #017078;
  color: #d8ffff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.clip-thumbs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 54px;
  height: 42px;
  overflow: hidden;
}
.clip-thumbs img {
  width: 54px;
  height: 42px;
  object-fit: cover;
}

.waveform {
  height: 20px;
  background:
    repeating-linear-gradient(to right, rgba(42, 224, 226, .35) 0 2px, transparent 2px 5px),
    linear-gradient(to top, rgba(0, 235, 245, .5), rgba(0, 235, 245, .16));
}

.playhead {
  position: absolute;
  z-index: 5;
  top: -44px;
  bottom: 0;
  width: 2px;
  background: #f1f1f1;
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.playhead::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0;
  width: 12px;
  height: 14px;
  border-radius: 3px;
  background: #f1f1f1;
}

.export-log {
  display: grid;
  gap: 10px;
}
.export-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0d121a;
}
.export-item a { color: var(--cyan); }

@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; }
  nav { grid-auto-flow: column; }
  .split, .editor-layout { grid-template-columns: 1fr; }
}
