/* Black & white theme; phones get CapCut's Android editor layout (bottom). */
:root {
  --bg: #000000;
  --panel: #141414;
  --panel-2: #1f1f1f;
  --panel-3: #2b2b2b;
  --line: #2a2a2a;
  --text: #ffffff;
  --muted: #8f8f8f;
  --accent: #ffffff;
  --accent-2: #e2e2e2;
  --accent-ink: #000000;
  --danger: #ffffff;
  --pro: #ffffff;
  /* the timeline keeps CapCut's colourful tracks (one colour per kind) */
  --main: #1f5f66;
  --overlay: #3b4f8f;
  --text-track: #8a4bd8;
  --sticker: #d97a2b;
  --effect: #b0428c;
  --filter: #2e8f6b;
  --audio: #1c7a3d;
  --keyframe: #ffd84d;
  --tl-h: 290px;
  --tab-w: 68px;
  --lib-w: 330px;
  --insp-w: 300px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) var(--tl-h);
  overflow: hidden;
  user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
}
.brand:hover { color: var(--text); background: var(--panel-2); }
.project-name {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  width: 220px;
  font-weight: 600;
  min-width: 0;
}
.project-name:hover, .project-name:focus { border-color: var(--line); outline: none; background: var(--bg); }
.top-center { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.top-right { display: flex; align-items: center; gap: 10px; }
.live-badge { color: var(--muted); font-size: 12px; white-space: nowrap; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover:not(:disabled) { background: var(--panel-3); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.ratio {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover { background: var(--accent-2); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------------------------------------------------------- workspace */
.workspace {
  display: grid;
  grid-template-columns: var(--tab-w) var(--lib-w) minmax(0, 1fr) var(--insp-w);
  min-height: 0;
}
.tabs {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  overflow-y: auto;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.tab svg { width: 22px; height: 22px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active svg { filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.35)); }

.library {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.lib-head { padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.lib-head h3 { margin: 0; font-size: 14px; }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.subtab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.subtab.active { color: var(--text); background: var(--panel-3); }
.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 7px 0; outline: none; }
.search svg { width: 14px; height: 14px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}
.chip.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.lib-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 16px; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
  padding: 0;
  overflow: hidden;
  text-align: left;
  color: var(--text);
}
.card:hover { border-color: var(--accent); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card .thumb {
  aspect-ratio: 1;
  background: #0b0b0c center / cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.card .thumb img, .card .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb.contain img { object-fit: contain; }
.card .name {
  display: block;
  padding: 4px 6px 5px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--pro);
  color: #2b1e00;
}
.badge.left { left: 4px; right: auto; background: rgba(0,0,0,0.65); color: #fff; font-weight: 600; }
.card .add {
  position: absolute;
  right: 5px;
  bottom: 26px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  display: none;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}
.card:hover .add { display: grid; }
.lib-empty { color: var(--muted); padding: 24px 8px; text-align: center; }
.lib-more { display: flex; justify-content: center; padding: 12px; color: var(--muted); }
.drop-zone {
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  margin-bottom: 12px;
}
.drop-zone.over { border-color: var(--accent); color: var(--accent); }
.song {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
}
.song:hover { background: var(--panel-2); }
.song img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--panel-3); }
.song .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .a { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  color: var(--text);
}
.round.accent { background: var(--accent); color: var(--accent-ink); }
.round svg { width: 14px; height: 14px; }
.section-title { margin: 14px 0 8px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.text-presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.text-preset {
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b0b0c;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}
.text-preset:hover { border-color: var(--accent); }

/* -------------------------------------------------------------- stage */
.stage-wrap {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 44px;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.stage { position: relative; display: grid; place-items: center; padding: 16px; min-height: 0; overflow: hidden; }
.stage-box { position: relative; background: #000; box-shadow: 0 0 0 1px var(--line); }
.stage-box canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; overflow: hidden; }
.sel-box {
  position: absolute;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
  cursor: move;
  touch-action: none;
}
.sel-box .h {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  touch-action: none;
}
.sel-box .h.br { right: -7px; bottom: -7px; cursor: nwse-resize; }
.sel-box .h.tl { left: -7px; top: -7px; cursor: nwse-resize; }
.sel-box .h.tr { right: -7px; top: -7px; cursor: nesw-resize; }
.sel-box .h.bl { left: -7px; bottom: -7px; cursor: nesw-resize; }
.sel-box .h.rot { left: 50%; bottom: -30px; margin-left: -7px; cursor: grab; background: var(--accent); }
.empty-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
  padding: 12px;
}
.empty-hint p { margin: 0; }
.empty-icon { font-size: 34px; color: var(--text); }
.player-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.time { font-variant-numeric: tabular-nums; font-size: 12px; }
.dim { color: var(--muted); }
.play-btn {
  margin-left: calc(50% - 150px);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--bg);
  display: grid;
  place-items: center;
}
.play-btn svg { width: 16px; height: 16px; }
.play-btn .i-pause { display: none; }
body.playing .play-btn .i-pause { display: block; }
body.playing .play-btn .i-play { display: none; }
.player-spacer { flex: 1; }
.preview-status { color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------- inspector */
.inspector {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}
.insp-tabs { display: flex; gap: 2px; padding: 10px 10px 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; flex-wrap: wrap; }
.insp-tab { border: 0; background: transparent; color: var(--muted); padding: 7px 9px; font-weight: 600; border-bottom: 2px solid transparent; }
.insp-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.insp-body { padding: 12px 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.insp-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; word-break: break-all; }
.insp-title .kind { word-break: normal; white-space: nowrap; }
.insp-title .kind { font-size: 11px; font-weight: 600; color: var(--muted); padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; }
.group { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h4 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.row { display: grid; grid-template-columns: 86px minmax(0, 1fr) 54px; gap: 8px; align-items: center; }
.row > label { color: var(--muted); font-size: 12px; }
.row input[type="range"] { width: 100%; }
.num {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 5px;
  font-size: 12px;
  text-align: right;
}
.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  resize: vertical;
}
.field:focus, .num:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
  min-width: 34px;
}
.seg button.active { border-color: var(--accent); color: var(--accent); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--panel-3); padding: 0; }
.swatch.active { border-color: var(--accent); }
.swatch.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--panel-2); }
input[type="color"] { width: 28px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); padding: 1px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.anim-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.anim-grid .card .thumb { aspect-ratio: 1.2; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
input[type="range"] { accent-color: var(--accent); }
.font-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.font-item { display: flex; align-items: center; gap: 6px; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 4px; min-height: 34px; text-align: left; }
.font-item img { height: 22px; max-width: 100%; opacity: 0.95; }
.font-item:hover { background: var(--panel-2); }
.font-item.active { border-color: var(--accent); }

/* ----------------------------------------------------------- timeline */
.timeline {
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-height: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 5;
}
.tl-toolbar { display: flex; align-items: center; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.tool {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 12px;
}
.tool svg { width: 16px; height: 16px; }
.tool:hover:not(:disabled) { background: var(--panel-3); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tl-spacer { flex: 1; }
.zoom { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.zoom input { width: 140px; }
.tl-body { position: relative; min-height: 0; }
.tl-scroll { position: absolute; inset: 0; overflow: auto; }
.tl-content { position: relative; min-height: 100%; }
.tl-ruler {
  position: sticky;
  top: 0;
  height: 24px;
  background: var(--panel);
  z-index: 3;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.tick { position: absolute; bottom: 0; width: 1px; background: #4a4a52; height: 5px; }
.tick.major { height: 10px; background: #6a6a73; }
.tick-label { position: absolute; top: 2px; font-size: 10px; color: var(--muted); transform: translateX(3px); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-rows { position: relative; padding: 8px 0 30px; display: flex; flex-direction: column; gap: 5px; }
.tl-row { position: relative; height: 30px; }
.tl-row.main { height: 58px; }
.tl-row.audio { height: 38px; }
.tl-row.main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  pointer-events: none;
}
.tl-row.drop-target { background: rgba(0, 194, 214, 0.1); }
.item {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  padding: 0 8px;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  touch-action: none;
}
.item .label { position: relative; z-index: 1; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,0.8); pointer-events: none; }
.item.media { background: var(--main) left center / auto 100% repeat-x; align-items: flex-start; padding-top: 3px; }
.item.overlay-media { background-color: var(--overlay); }
.item.text { background: var(--text-track); }
.item.sticker { background: var(--sticker); }
.item.effect { background: var(--effect); }
.item.filter { background: var(--filter); }
.item.audio { background: var(--audio) left center / 100% 100% no-repeat; align-items: flex-start; padding-top: 2px; }
.item.slot::after {
  content: "Replace";
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: 10px;
  background: rgba(0,0,0,0.6);
  padding: 1px 6px;
  border-radius: 4px;
}
.item.selected { box-shadow: inset 0 0 0 2px #fff; z-index: 2; }
.item.dragging { opacity: 0.85; z-index: 4; cursor: grabbing; }
.item .grip {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 9px;
  cursor: ew-resize;
  z-index: 2;
  display: none;
}
.item .grip.l { left: 0; border-radius: 6px 0 0 6px; }
.item .grip.r { right: 0; border-radius: 0 6px 6px 0; }
.item.selected .grip { display: block; background: #fff; }
.item.selected .grip::after { content: ""; position: absolute; top: 35%; bottom: 35%; left: 3px; width: 2px; background: #333; border-radius: 2px; }
.item .kf {
  position: absolute;
  bottom: 3px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--keyframe);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  transform: rotate(45deg);
  z-index: 1;
  pointer-events: none;
}
.item .fx-dot { position: absolute; left: 6px; bottom: 4px; font-size: 9px; background: rgba(0,0,0,0.55); padding: 0 5px; border-radius: 4px; z-index: 1; }
.trans-btn {
  position: absolute;
  top: 18px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.3);
  background: #111;
  color: #fff;
  display: grid;
  place-items: center;
  z-index: 3;
  padding: 0;
}
.trans-btn svg { width: 12px; height: 12px; }
.trans-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.trans-btn.selected { box-shadow: 0 0 0 2px #fff; }
.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 24px;
  width: 0;
  z-index: 6;
  pointer-events: none;
}
.tl-playhead::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; }
.tl-playhead span {
  position: absolute;
  top: 0;
  left: -6px;
  width: 12px;
  height: 14px;
  background: #fff;
  border-radius: 2px 2px 6px 6px;
  pointer-events: auto;
  cursor: ew-resize;
}
.tl-empty { position: absolute; left: 24px; top: 40px; color: var(--muted); }
.snap-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent); z-index: 5; pointer-events: none; }

/* -------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal-card {
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; user-select: text; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.slots .slot {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
  padding: 0;
  text-align: left;
}
.slots .slot .thumb { aspect-ratio: 3 / 4; background: #000 center / cover no-repeat; position: relative; }
.slots .slot .thumb video, .slots .slot .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slots .slot .meta { padding: 6px 8px; font-size: 11px; display: flex; justify-content: space-between; color: var(--muted); }
.slots .slot .num { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.65); border-radius: 5px; padding: 1px 6px; font-size: 11px; font-weight: 700; width: auto; border: 0; text-align: left; }
.slots .slot.filled { border-color: var(--accent); }
.slots .slot.linked { opacity: 0.55; }
.slots .slot .check { position: absolute; top: 6px; right: 6px; background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; font-weight: 900; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.progress { height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.export-video { width: 100%; max-height: 52vh; background: #000; border-radius: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 12px; }
.kv span:nth-child(odd) { color: var(--muted); }

/* ------------------------------------------------------------ loading */
.loading {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8,8,10,0.86);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--panel-3);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.toasts { position: fixed; bottom: calc(var(--tl-h) + 14px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; pointer-events: none; }
.toast { background: #2b2b31; border: 1px solid var(--line); color: var(--text); padding: 8px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: 80vw; }
.toast.error { border-color: var(--danger); }
.toast.ok { border-color: var(--accent); }

/* --------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  :root { --lib-w: 290px; --insp-w: 270px; }
}
@media (max-width: 1020px) {
  :root { --lib-w: 250px; --insp-w: 240px; --tl-h: 250px; }
  .live-badge { display: none; }
  .project-name { width: 140px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* tablets: the clip tools keep their icons (names stay in the tooltips) */
  .tl-toolbar { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .tl-toolbar .tool > span { display: none; }
  .zoom input { width: 90px; }
}
/* ---- clip tools: crop, chroma key, keyframe curves, speed curve, projects, shortcuts ---- */
.seg.actions .btn.small { flex: 1 1 auto; }
.kf-curve { display: flex; flex-direction: column; gap: 6px; }
.kf-curve > label { color: var(--muted); font-size: 12px; }
.swatch-big { width: 28px; height: 28px; border-radius: 6px; border: 2px solid var(--panel-3); display: inline-block; }
.overlay.picking { cursor: crosshair; }
.overlay.picking .sel-box { pointer-events: none; }
.curve-editor { width: 100%; height: auto; color: var(--muted); background: var(--panel-2); border-radius: 8px; touch-action: none; }
.curve-editor .curve-pt { fill: var(--panel); stroke: var(--accent); stroke-width: 2; cursor: ns-resize; }
.curve-editor .curve-pt:hover { fill: var(--accent); }
.crop-dialog { display: flex; flex-direction: column; gap: 12px; }
.crop-wrap { display: grid; place-items: center; background: #000; border-radius: 8px; padding: 14px; overflow: hidden; }
.crop-stage { position: relative; touch-action: none; user-select: none; } /* handles may sit on the picture's edge */
.crop-pic { display: block; width: 100%; height: 100%; }
.crop-rect { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); outline: 2px solid #fff; cursor: move;
  background-image: linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)), linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.35)), linear-gradient(90deg, rgba(255,255,255,.35), rgba(255,255,255,.35)), linear-gradient(90deg, rgba(255,255,255,.35), rgba(255,255,255,.35));
  background-size: 100% 1px, 100% 1px, 1px 100%, 1px 100%; background-position: 0 33.33%, 0 66.66%, 33.33% 0, 66.66% 0; background-repeat: no-repeat; }
.crop-rect .ch { position: absolute; width: 14px; height: 14px; background: #fff; border-radius: 2px; }
.crop-rect .ch.tl { left: -7px; top: -7px; cursor: nwse-resize; }
.crop-rect .ch.br { right: -7px; bottom: -7px; cursor: nwse-resize; }
.crop-rect .ch.tr { right: -7px; top: -7px; cursor: nesw-resize; }
.crop-rect .ch.bl { left: -7px; bottom: -7px; cursor: nesw-resize; }
.projects { display: flex; flex-direction: column; gap: 8px; }
.project-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.project-row img, .project-row .ph { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--panel-3); display: block; }
.project-row .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-row.current { border-color: var(--accent); }
.shortcuts { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 18px; font-size: 13px; }
.shortcuts kbd { background: var(--panel-3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font: 12px ui-monospace, monospace; }
.save-state { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* desktop-only / phone-only pieces; the bottom panels are plain columns on desktop */
.sheet { display: contents; }
.sheet-head { display: none; }
@media (min-width: 761px) {
  .m-only { display: none !important; }
}
/* touch screens have no hover: keep the library's add buttons visible */
@media (hover: none) {
  .card .add { display: grid; }
}

/* ======================= phone: CapCut Android editor =======================
   top bar (close · ratio · Export) / preview / player bar (time · play · undo redo
   fullscreen) / timeline with a fixed centre playhead / bottom tool bar. Library
   and properties open as bottom panels with a check mark, like the app. */
@media (max-width: 760px) {
  .d-only { display: none !important; }
  :root {
    --row-bar: calc(44px + env(safe-area-inset-top, 0px));
    --row-player: 40px;
    --row-tl: clamp(150px, 27vh, 224px);
    --row-tools: calc(62px + env(safe-area-inset-bottom, 0px));
    --sheet-h: min(56vh, 480px);
  }
  html, body { height: 100%; }
  body {
    height: 100vh;
    height: 100dvh;
    grid-template-rows: var(--row-bar) minmax(0, 1fr) var(--row-player) var(--row-tl) var(--row-tools);
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }
  body.sheet-open { --row-player: 0px; --row-tl: 0px; --row-tools: var(--sheet-h); }
  body.m-full { --row-bar: env(safe-area-inset-top, 0px); --row-tl: 0px; --row-tools: env(safe-area-inset-bottom, 0px); }
  .workspace, .stage-wrap, .timeline { display: contents; }
  .timeline::before { content: none; }

  /* top bar */
  .topbar { grid-row: 1; gap: 6px; padding: env(safe-area-inset-top, 0px) 10px 0 4px; background: #000; border: 0; overflow: hidden; }
  .brand { padding: 8px; color: var(--text); }
  .brand span, #projectsBtn, .project-name, .save-state, .live-badge, #shortcutsBtn, #undoBtn, #redoBtn { display: none; }
  .top-center { display: contents; }
  .ratio { margin-left: auto; height: 30px; padding: 0 6px; border: 0; border-radius: 6px; background: var(--panel-2); font-weight: 700; font-size: 12px; }
  .top-right { gap: 8px; }
  #exportBtn { height: 30px; padding: 0 14px; border-radius: 6px; font-size: 13px; }
  #exportBtn svg { display: none; }
  body.m-full .topbar > * { display: none; }

  /* preview */
  .stage { grid-row: 2; padding: 0; background: #000; }
  .stage-box { box-shadow: none; }
  .empty-hint { font-size: 12px; }

  /* player bar */
  .player-bar { grid-row: 3; position: relative; gap: 0; padding: 0 6px 0 14px; border: 0; background: #000; overflow: hidden; }
  #timeNow, #timeTotal, .player-bar .time.dim, .preview-status { display: none; }
  #mTime { font-size: 12px; font-variant-numeric: tabular-nums; }
  .play-btn { position: absolute; left: 50%; top: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; background: none; color: #fff; }
  .play-btn svg { width: 26px; height: 26px; }
  .player-bar .icon-btn { width: 36px; height: 36px; }
  .player-bar .icon-btn:disabled { opacity: 0.3; }
  body.sheet-open .player-bar, body.sheet-open .tl-body, body.sheet-open .tabs, body.sheet-open .tl-toolbar { visibility: hidden; }
  body.m-full .player-bar { grid-row: 3; }
  body.m-full .tl-body, body.m-full .tabs, body.m-full .tl-toolbar { display: none !important; }

  /* timeline: fixed centre playhead, drag with a finger, pinch to zoom */
  .tl-body { grid-row: 4; background: #000; min-height: 0; }
  .tl-scroll { scrollbar-width: none; touch-action: pan-x pan-y; overscroll-behavior: contain; }
  .tl-scroll::-webkit-scrollbar { display: none; }
  .tl-playhead { display: none; }
  .tl-center { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; z-index: 7; pointer-events: none; box-shadow: 0 0 3px rgba(0, 0, 0, 0.6); }
  .tl-ruler { height: 22px; background: #000; border-bottom: 0; cursor: default; }
  .tick { background: #555; }
  .tick.major { background: #777; }
  .tl-rows { padding: 6px 0 18px; gap: 6px; }
  .tl-row { height: 26px; }
  .tl-row.main { height: 52px; }
  .tl-row.audio { height: 34px; }
  .tl-row.main::before { display: none; }
  .tl-empty { left: calc(50% + 12px); top: 16px; font-size: 12px; white-space: nowrap; }
  .item { border-radius: 4px; font-size: 10px; padding: 0 6px; touch-action: pan-x pan-y; }
  .item.selected { touch-action: none; }
  .item .grip { width: 16px; }
  .item.selected .grip::after { left: 7px; }
  .trans-btn { top: 15px; width: 22px; height: 22px; margin-left: -11px; }
  .tl-add { position: absolute; right: 10px; top: 50%; margin-top: -18px; z-index: 8; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 6px; background: #fff; color: #000; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }

  /* bottom tool bar: library tabs, or the selected clip's tools */
  .tabs, .tl-toolbar {
    grid-row: 5;
    flex-direction: row; align-items: flex-start; gap: 0;
    height: auto; padding: 2px 4px env(safe-area-inset-bottom, 0px);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    background: #000; border: 0; border-top: 1px solid rgba(255, 255, 255, 0.07);
  }
  .tabs::-webkit-scrollbar, .tl-toolbar::-webkit-scrollbar { display: none; }
  .tabs { display: flex; }
  .tl-toolbar { display: none; }
  body.has-sel .tabs { display: none; }
  body.has-sel .tl-toolbar { display: flex; }
  .tab, .tl-toolbar .tool {
    flex: none; flex-direction: column; justify-content: center; gap: 5px;
    width: 64px; height: 58px; padding: 0; border-radius: 0;
    color: #fff; font-size: 11px; white-space: nowrap;
  }
  .tab svg, .tl-toolbar .tool svg { width: 24px; height: 24px; }
  .tl-toolbar .tool > span { display: inline; }
  .tab.active svg { filter: none; }
  .tl-toolbar .tool:hover:not(:disabled) { background: none; }
  .tl-toolbar .tool:disabled { opacity: 0.3; }
  .tl-toolbar .tool.active { color: #fff; }
  .tl-toolbar .m-back { position: sticky; left: -4px; z-index: 1; width: 48px; background: #000; box-shadow: 8px 0 8px -6px #000; }
  .tl-spacer, #fitBtn, .zoom { display: none; }
  .tool.m-hide { display: none !important; }

  /* bottom panels */
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; flex-direction: column;
    height: var(--sheet-h);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #181818; border-radius: 12px 12px 0 0;
    transform: translateY(105%); visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s;
  }
  body.sheet-lib #libSheet, body.sheet-insp #inspSheet { transform: none; visibility: visible; }
  .sheet-head {
    display: flex; align-items: center; justify-content: space-between; flex: none;
    height: 46px; padding: 0 4px 0 16px; font-size: 15px; font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .sheet-done { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: #fff; }
  .library, .inspector { flex: 1; min-height: 0; background: transparent; border: 0; }
  .inspector { display: block; overflow-y: auto; }
  .library .lib-head h3 { display: none; }
  .lib-head { padding: 10px 12px 6px; }
  .lib-scroll { padding: 4px 12px 16px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.four { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .card { background: #242424; border-radius: 6px; }
  .card .add { width: 26px; height: 26px; }
  .insp-tabs { background: #181818; padding: 4px 8px 0; }
  .insp-body { padding: 12px 14px 28px; }

  /* dialogs slide up from the bottom */
  .modal { padding: 0; place-items: end stretch; }
  .modal-card { width: 100% !important; max-height: 92vh; border: 0; border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .modal-body { padding: 14px; }
  .slots { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kv { grid-template-columns: 90px 1fr; }
  /* finger-sized handles on the preview and in the crop dialog */
  .sel-box .h { width: 20px; height: 20px; }
  .sel-box .h.br { right: -11px; bottom: -11px; }
  .sel-box .h.tl { left: -11px; top: -11px; }
  .sel-box .h.tr { right: -11px; top: -11px; }
  .sel-box .h.bl { left: -11px; bottom: -11px; }
  .sel-box .h.rot { bottom: -38px; margin-left: -11px; }
  .crop-rect .ch { width: 22px; height: 22px; }
  .crop-rect .ch.tl { left: -11px; top: -11px; }
  .crop-rect .ch.br { right: -11px; bottom: -11px; }
  .crop-rect .ch.tr { right: -11px; top: -11px; }
  .crop-rect .ch.bl { left: -11px; bottom: -11px; }
  .toasts { bottom: calc(var(--row-tools) + var(--row-tl) + 12px); }
  body.sheet-open .toasts { bottom: calc(var(--sheet-h) + 12px); }
}

/* "Apply all" switch (filters, effects, transitions, animations) */
.apply-all { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px 0 8px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.apply-all-box { width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--muted); display: grid; place-items: center; }
.apply-all.on { color: var(--text); border-color: var(--text); }
.apply-all.on .apply-all-box { background: var(--accent); border-color: var(--accent); }
.apply-all.on .apply-all-box::after { content: ''; width: 8px; height: 4px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink); transform: rotate(-45deg) translate(1px, -1px); }
.lib-head .apply-all { margin-top: 6px; }
.apply-all-row { display: flex; justify-content: flex-end; margin: 4px 0 8px; }
.lib-head .apply-all { align-self: flex-start; }
