:root {
  --bg-0: #0a0b0f;
  --bg-1: #0f1116;
  --bg-2: #14161c;
  --bg-3: #1a1d25;
  --bg-4: #22252f;
  --line-0: rgba(255, 255, 255, 0.04);
  --line-1: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --line-3: rgba(255, 255, 255, 0.18);
  --text-0: #eef0f6;
  --text-1: #b7bcc9;
  --text-2: #848a99;
  --text-3: #5a5f6d;
  --accent: #5cc9f5;
  --accent-soft: rgba(92, 201, 245, 0.16);
  --accent-line: rgba(92, 201, 245, 0.45);
  --warm: #f2b56a;
  --warm-soft: rgba(242, 181, 106, 0.18);
  --danger: #ff6a5c;
  --radius-1: 6px;
  --radius-2: 10px;
  --radius-3: 14px;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 30% -10%, #1a1f2a 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 110%, #121621 0%, transparent 65%),
    #07080b;
  color: var(--text-0);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  min-height: 100%;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ===== App Shell ===== */
.shell {
  width: min(1440px, 100%);
  height: min(1000px, calc(100vh - 32px));
  min-height: 820px;
  max-height: calc(100vh - 32px);
  background: linear-gradient(180deg, #15181f 0%, #0e1016 100%);
  border: 1px solid var(--line-1);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  display: grid;
  grid-template-rows: 44px 1fr;
  position: relative;
}

/* window chrome */
.titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-0);
  background: linear-gradient(180deg, #1a1e27 0%, #141821 100%);
}

.lights {
  display: flex;
  gap: 7px;
}

.light {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.4);
}

.light.r {
  background: linear-gradient(180deg, #ff6057, #d94b43);
}
.light.y {
  background: linear-gradient(180deg, #febc2e, #dba014);
}
.light.g {
  background: linear-gradient(180deg, #28c840, #1faa35);
}

.title-center {
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.title-center .proj-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.title-right {
  justify-self: end;
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--mono);
}

.export-btn {
  padding: 5px 10px;
  background: var(--accent);
  color: #061018;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11.5px;
  cursor: pointer;
  letter-spacing: 0.01em;
}

.export-btn:hover {
  filter: brightness(1.08);
}

/* ===== Main grid ===== */
.main {
  display: grid;
  grid-template-rows: minmax(340px, 1fr) auto auto;
  min-height: 0;
}

.top-row {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 0;
  min-height: 0;
  border-bottom: 1px solid var(--line-0);
}

.panel {
  background: var(--bg-2);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line-0);
}

.panel:last-child {
  border-right: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 24px;
}

.panel-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-1);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line-0);
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: color 0.12s, background 0.12s;
}

.tab:hover {
  color: var(--text-0);
}

.tab.active {
  color: var(--text-0);
  background: var(--bg-3);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.panel-meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
}

/* ===== Media panel ===== */
.drop-zone {
  flex: 1;
  max-height: 100%;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-2);
  background: var(--bg-1);
  padding: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 10px;
  min-height: 0;
  transition: border-color 0.18s, background 0.18s;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-2);
  font-size: 11.5px;
  padding: 2px 4px;
}

.drop-hint button {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--text-0);
  padding: 3px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
}

.drop-hint button:hover {
  border-color: var(--line-3);
  background: var(--bg-3);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  flex: 1;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  padding: 2px;
  min-height: 0;
}

.media-grid::-webkit-scrollbar {
  width: 8px;
}
.media-grid::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
}
.media-grid::-webkit-scrollbar-track {
  background: transparent;
}

.media-card {
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 8px;
  padding: 5px;
  cursor: grab;
  transition: transform 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}

.media-card:hover {
  border-color: var(--line-3);
  transform: translateY(-1px);
}

.media-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.media-card.used::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.media-thumb {
  aspect-ratio: 1;
  background: var(--bg-1);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.media-thumb > * {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-audio-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(180deg, #2a1f0a 0%, #3a2c12 100%);
  padding: 6px;
}

.media-audio-bars {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1px;
}

.media-audio-bars span {
  flex: 1;
  min-width: 1px;
  border-radius: 1px;
  background: linear-gradient(180deg, rgba(242, 181, 106, 0.8), rgba(242, 181, 106, 0.28));
}

.media-audio-label {
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.media-dur {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  border-radius: 0;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.media-type-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  font-family: var(--mono);
  font-size: 9px;
  padding: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.media-name {
  font-size: 11px;
  color: var(--text-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Player ===== */
.player-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  flex: 1;
}

.stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px 12px;
  min-height: 0;
}

.player-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 0 0 10px;
  flex-shrink: 0;
}

.stage {
  position: relative;
  width: min(100%, 460px);
  min-height: 320px;
  background: #000;
  border-radius: var(--radius-2);
  border: 1px solid var(--line-1);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: 100%;
  max-width: 100%;
  box-shadow: 0 40px 80px -20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.stage-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage-hold-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.stage-inner video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  transition: opacity 90ms linear;
}

.stage-empty {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: 20px;
  line-height: 1.5;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, transparent 12%, transparent 85%, rgba(0, 0, 0, 0.35) 100%);
}

.stage-trailer-copy {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.stage-trailer-line {
  position: absolute;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-weight: 800;
  font-size: clamp(26px, 4.2vw, 54px);
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: none;
  white-space: nowrap;
}

.stage-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  pointer-events: none;
}

.stage-hud .rec {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-hud .rec-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--danger);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.stage-hud-b {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

/* ===== Inspector ===== */
.inspector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 0;
}

.prop-group {
  border: 1px solid var(--line-1);
  border-radius: var(--radius-2);
  background: var(--bg-1);
  overflow: hidden;
}

.prop-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-0);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-2);
  font-weight: 600;
}

.prop-group-header .chev {
  color: var(--text-3);
  font-size: 10px;
}

.prop-group-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prop-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.prop-row > label {
  color: var(--text-2);
}

.prop-row > .val {
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 11px;
}

.num-field {
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--text-0);
  font-family: var(--mono);
  font-size: 11px;
  width: 100%;
  outline: none;
}

.num-field:focus {
  border-color: var(--accent-line);
}

.num-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.slider-row {
  display: grid;
  grid-template-columns: 80px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}

.slider-row label {
  color: var(--text-2);
}

.slider-row .sval {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-1);
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-3);
  border-radius: 99px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text-0);
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.5);
}

.effect-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 6px;
  font-size: 11px;
}

.effect-chip.ai {
  border-color: var(--warm-soft);
  background: linear-gradient(180deg, rgba(242, 181, 106, 0.07), rgba(242, 181, 106, 0.02));
}

.effect-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--text-2);
}

.effect-chip.ai .dot {
  background: var(--warm);
  box-shadow: 0 0 6px var(--warm);
}

.effect-chip .name {
  color: var(--text-0);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.effect-chip .val {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
}

.effect-chip .x {
  color: var(--text-3);
  cursor: pointer;
  padding: 0 2px;
}

.effect-chip .x:hover {
  color: var(--text-0);
}

.empty-state {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: 24px 12px;
  line-height: 1.5;
}

.chat-teaser {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line-1);
  border-radius: var(--radius-2);
  background: linear-gradient(180deg, rgba(92, 201, 245, 0.06), rgba(92, 201, 245, 0.01));
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.12s;
}

.chat-teaser:hover {
  border-color: var(--accent-line);
}

.chat-teaser.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-1);
}

.chat-teaser-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-teaser-sub {
  font-size: 11.5px;
  color: var(--text-1);
  line-height: 1.4;
}

.chat-teaser-open {
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line-0);
}

.tool-group {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-right: 1px solid var(--line-0);
  padding-right: 8px;
  margin-right: 8px;
}

.tool-group:last-child {
  border-right: none;
}

.tool-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.tool-btn:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}

.tool-btn .kbd {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 8px;
  color: var(--text-3);
  font-family: var(--mono);
}

.tool-divider {
  flex: 1;
}

.play-btn {
  background: var(--accent);
  color: #061018;
  border: none;
  padding: 0 14px;
  height: 30px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.play-btn:hover {
  filter: brightness(1.08);
}

.shuttle-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--line-1);
  background: var(--bg-3);
  color: var(--text-1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shuttle-btn:hover {
  color: var(--text-0);
  border-color: var(--line-3);
}

/* ===== Timeline ===== */
.timeline {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  background: var(--bg-1);
}

.tl-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-0);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  letter-spacing: 0.01em;
}

.tl-meta .time {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tl-meta .cur {
  color: var(--text-0);
  font-weight: 600;
  font-size: 13px;
  padding: 3px 7px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 5px;
}

.tl-meta .total {
  color: var(--text-2);
}

.tl-meta .fps {
  display: flex;
  gap: 10px;
  color: var(--text-3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.tl-body {
  display: grid;
  grid-template-columns: 60px 1fr;
  flex: 1;
  min-height: 0;
}

.tl-track-labels {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-0);
}

.tl-track-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--line-0);
  position: relative;
}

.tl-track-label .dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--text-3);
  margin-right: 6px;
}

.tl-track-label.v .dot {
  background: var(--accent);
}
.tl-track-label.a .dot {
  background: var(--warm);
}

.tl-viewport {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
}

.tl-viewport::-webkit-scrollbar {
  height: 8px;
}
.tl-viewport::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
}

.tl-ruler {
  height: 26px;
  border-bottom: 1px solid var(--line-1);
  position: relative;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  user-select: none;
}

.ruler-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line-1);
}

.ruler-tick.minor {
  top: 18px;
  background: var(--line-0);
}

.ruler-label {
  position: absolute;
  top: 5px;
  transform: translateX(3px);
  color: var(--text-2);
  font-size: 10px;
}

.tl-tracks {
  display: flex;
  flex-direction: column;
  position: relative;
}

.tl-track {
  position: relative;
  border-bottom: 1px solid var(--line-0);
  background: var(--bg-1);
}

.tl-track.v {
  background: linear-gradient(180deg, #0f1218 0%, #0d0f14 100%);
}

.tl-track.a {
  background: linear-gradient(180deg, #11110f 0%, #0e0e0b 100%);
}

.tl-track.t {
  background: linear-gradient(180deg, #111119 0%, #0d0d14 100%);
}

.tl-track.dragover {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tl-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 11.5px;
  pointer-events: none;
}

.tl-track-label.t .dot {
  background: #d494ff;
}

.text-layer-clip {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 5px;
  border: 1px solid rgba(212, 148, 255, 0.45);
  background: linear-gradient(180deg, rgba(89, 44, 133, 0.82), rgba(59, 31, 92, 0.86));
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 7px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.text-layer-tag {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.06em;
  color: #f3deff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  padding: 0 4px;
  flex-shrink: 0;
}

.text-layer-name {
  font-size: 10px;
  color: #f6ecff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

/* Clips */
.clip {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 6px;
  background: linear-gradient(180deg, #1e4358 0%, #163143 100%);
  border: 1px solid rgba(92, 201, 245, 0.25);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  cursor: grab;
  display: flex;
  flex-direction: column;
  user-select: none;
  transition: border-color 0.12s, transform 0.12s;
}

.clip.audio {
  top: 10px;
  bottom: 10px;
  background: linear-gradient(180deg, #3a2c12 0%, #2a1f0a 100%);
  border-color: rgba(242, 181, 106, 0.25);
}

.clip:hover {
  border-color: rgba(92, 201, 245, 0.5);
}

.clip.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 8px 22px rgba(0, 0, 0, 0.55);
  z-index: 3;
}

.clip.dragging {
  opacity: 0.7;
  cursor: grabbing;
  z-index: 4;
}

.clip-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.28);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.clip-header .ai-mark {
  color: var(--warm);
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(242, 181, 106, 0.2);
  flex-shrink: 0;
}

.clip-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-0);
}

.clip-thumb-strip {
  display: flex;
  height: 100%;
  width: 100%;
}

.clip-thumb-cell {
  flex: 1 1 0;
  min-width: 0;
  background-size: cover;
  background-position: center;
  border-right: 1px solid rgba(0, 0, 0, 0.25);
}

.clip-thumb-cell:last-child {
  border-right: none;
}

.clip-video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.clip-audio-wave {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px;
}

.clip-audio-wave .bar {
  flex: 1;
  background: linear-gradient(180deg, rgba(242, 181, 106, 0.7), rgba(242, 181, 106, 0.25));
  border-radius: 1px;
  min-width: 1px;
}

.clip-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 9px;
  color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.7), transparent);
  pointer-events: none;
  letter-spacing: 0.02em;
}

.clip-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
  background: transparent;
  z-index: 2;
}

.clip-handle.l {
  left: 0;
}
.clip-handle.r {
  right: 0;
}

.clip.selected .clip-handle::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 99px;
  box-shadow: 0 0 6px rgba(92, 201, 245, 0.7);
}

.clip.selected .clip-handle.l::before {
  left: 2px;
}

.clip.selected .clip-handle.r::before {
  right: 2px;
}

/* Playhead */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ffffff;
  left: 0;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}

.playhead-head {
  position: absolute;
  top: -1px;
  left: -6px;
  width: 13px;
  height: 13px;
  background: #fff;
  clip-path: polygon(50% 100%, 0 40%, 0 0, 100% 0, 100% 40%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

/* ===== Chat Drawer ===== */
.chat-drawer {
  position: absolute;
  top: 44px;
  right: 0;
  bottom: 0;
  width: 380px;
  background: linear-gradient(180deg, #161922 0%, #11131a 100%);
  border-left: 1px solid var(--line-2);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.22, 0.8, 0.32, 1);
  z-index: 10;
}

.chat-drawer.open {
  transform: translateX(0);
}

.chat-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
}

.chat-head-close {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.chat-head-close:hover {
  background: var(--bg-3);
  color: var(--text-0);
}

.chat-clip-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: 8px;
}

.chat-clip-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: var(--bg-0);
  background-size: cover;
  background-position: center;
}

.chat-clip-audio-pill {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--warm);
  background: linear-gradient(180deg, rgba(242, 181, 106, 0.18), rgba(242, 181, 106, 0.05));
}

.chat-clip-name {
  font-size: 12px;
  color: var(--text-0);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-clip-meta {
  font-size: 10.5px;
  color: var(--text-2);
  font-family: var(--mono);
  margin-top: 2px;
}

.chat-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.chat-mode-btn {
  border: 1px solid var(--line-1);
  border-radius: 7px;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 11px;
  padding: 6px 8px;
  cursor: pointer;
}

.chat-mode-btn:hover:not(:disabled) {
  border-color: var(--line-3);
  color: var(--text-0);
}

.chat-mode-btn.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-mode-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.chat-mode-meta {
  font-size: 10.5px;
  color: var(--text-2);
  font-family: var(--mono);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-body::-webkit-scrollbar {
  width: 8px;
}
.chat-body::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 4px;
}

.msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  animation: msg-in 0.3s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, #2a6e92 0%, #205577 100%);
  border: 1px solid rgba(92, 201, 245, 0.35);
  color: #eaf7ff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  color: var(--text-0);
  border-bottom-left-radius: 4px;
}

.msg.assistant .action-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 4px 8px;
  background: var(--warm-soft);
  color: var(--warm);
  border: 1px solid rgba(242, 181, 106, 0.35);
  border-radius: 99px;
  font-size: 11px;
  font-family: var(--mono);
}

.msg.assistant .action-chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: var(--warm);
  animation: pulse 1.2s infinite;
}

.typing {
  display: flex;
  gap: 4px;
  padding: 12px;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--text-2);
  animation: typing 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.chat-suggestions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: 99px;
  font-size: 11px;
  color: var(--text-1);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}

.chip:hover {
  border-color: var(--accent-line);
  color: var(--accent);
}

.chat-input-wrap {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line-1);
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.15s;
}

.chat-input:focus-within {
  border-color: var(--accent-line);
}

.chat-input input {
  border: none;
  background: transparent;
  color: var(--text-0);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  padding: 8px 0;
  width: 100%;
}

.chat-input input::placeholder {
  color: var(--text-3);
}

.chat-send {
  background: var(--accent);
  color: #061018;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.chat-send:disabled {
  background: var(--bg-3);
  color: var(--text-3);
  cursor: not-allowed;
}

.chat-send:not(:disabled):hover {
  filter: brightness(1.08);
}

/* ===== Tweaks panel ===== */
.tweaks-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 300px;
  background: rgba(22, 25, 33, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  padding: 14px;
  font-size: 12px;
  z-index: 100;
}

.tweaks-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-2);
  margin-bottom: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tweaks-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11.5px;
}

.tweaks-row label {
  color: var(--text-2);
}

.tweaks-row .val {
  font-family: var(--mono);
  color: var(--text-1);
  font-size: 10.5px;
}

.seg {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 6px;
  padding: 2px;
}

.seg button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: 4px 6px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}

.seg button.active {
  background: var(--bg-3);
  color: var(--text-0);
}

.switch {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--bg-3);
  border-radius: 99px;
  cursor: pointer;
  border: 1px solid var(--line-1);
  transition: background 0.15s;
}

.switch.on {
  background: var(--accent);
  border-color: var(--accent);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: #fff;
  transition: transform 0.15s;
}

.switch.on::after {
  transform: translateX(14px);
}

.swatch-row {
  display: flex;
  gap: 6px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.1s;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch.active {
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px #fff;
}
