:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #191c23;
  --panel-2: #20242d;
  --line: #303541;
  --text: #eef2f6;
  --muted: #9aa4b2;
  --brand: #58c7b2;
  --brand-2: #f0c15c;
  --danger: #ff6b6b;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(480px, 1fr) minmax(300px, 380px);
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--brand);
  color: #06110f;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 700;
}

.tool-section {
  border: 1px solid transparent;
  border-radius: 8px;
}

.tool-section .section-title {
  position: sticky;
  top: -18px;
  z-index: 2;
  min-height: 38px;
  padding: 7px 8px;
  margin: 0 -8px 8px;
  border-radius: 8px;
  background: rgba(25, 28, 35, .96);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.tool-section .section-title::before {
  content: "▾";
  color: var(--brand);
  font-size: 12px;
}

.tool-section.collapsed .section-title {
  margin-bottom: 0;
}

.tool-section.collapsed .section-title::before {
  content: "▸";
}

.section-body {
  display: grid;
  gap: 10px;
}

.tool-section.collapsed .section-body {
  display: none;
}

.drop-zone {
  display: grid;
  gap: 6px;
  padding: 18px;
  margin-bottom: 10px;
  border: 1px dashed #566172;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.drop-zone.small {
  padding: 14px;
}

.drop-zone input, .file-btn input {
  display: none;
}

.drop-zone span, .export-card span {
  color: var(--muted);
  font-size: 13px;
}

.job-list, .subtitle-list {
  display: grid;
  gap: 8px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.job {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151820;
}

.job.active {
  border-color: var(--brand);
}

.job button {
  color: inherit;
  text-align: left;
  background: transparent;
}

.job small {
  color: var(--muted);
}

.stage {
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) minmax(118px, auto);
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar, .timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.timeline {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  padding: 12px 18px;
  border-top: 1px solid rgba(88, 199, 178, .28);
  border-bottom: 0;
  background: #151820;
}

.scrub-lane {
  display: grid;
  grid-column: 1 / -1;
  gap: 6px;
}

.scrub-lane span {
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segmented button {
  min-width: 88px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: #06110f;
  background: var(--brand);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.soft-btn, .primary-btn, .icon-btn, .download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  white-space: nowrap;
}

.primary-btn {
  color: #07110f;
  background: var(--brand);
  font-weight: 800;
}

.wide-btn {
  width: 100%;
  margin-bottom: 10px;
}

.icon-btn {
  width: 32px;
  padding: 0;
}

.preview-wrap {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 0;
  padding: 10px 18px;
  overflow: hidden;
  background:
    linear-gradient(45deg, #151820 25%, transparent 25%),
    linear-gradient(-45deg, #151820 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151820 75%),
    linear-gradient(-45deg, transparent 75%, #151820 75%);
  background-color: #101217;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
  background-size: 32px 32px;
}

canvas {
  width: min(100%, calc((100vh - 190px) * 16 / 9));
  max-height: calc(100vh - 190px);
  aspect-ratio: 16 / 9;
  background: #050608;
  box-shadow: 0 18px 80px rgba(0, 0, 0, .42);
  cursor: grab;
  touch-action: none;
}

canvas.dragging {
  cursor: grabbing;
}

video, audio {
  display: none;
}

.placeholder {
  position: absolute;
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.placeholder div {
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
}

.lane {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.lane span, .transport, label {
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--brand) var(--progress, 0%), var(--panel-2) 0);
  border: 1px solid var(--line);
}

.bar.accent {
  background: linear-gradient(90deg, var(--brand-2) var(--progress, 0%), var(--panel-2) 0);
}

.transport {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #07110f;
  background: var(--brand-2);
  font-weight: 800;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

textarea, input, select {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #12151b;
  outline: none;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--brand);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.subtitle {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151820;
  font-size: 13px;
}

.subtitle-fold {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151820;
}

.subtitle-fold summary {
  display: grid;
  gap: 4px;
  padding: 10px;
  cursor: pointer;
}

.subtitle-fold summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.subtitle-scroll {
  display: grid;
  gap: 8px;
  max-height: 260px;
  padding: 0 10px 10px;
  overflow-y: auto;
}

.subtitle time {
  display: block;
  margin-bottom: 4px;
  color: var(--brand);
}

.status {
  min-height: 38px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #12151b;
}

.export-card, .config-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151820;
}

.config-card span {
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .inspector {
    border-left: 0;
  }

  .stage {
    min-height: 560px;
  }

  .timeline {
    grid-template-columns: 1fr;
  }
}
