/* Volume Video - dark theme in ash purple: purple-tinted charcoal with a dusty lilac accent. */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #121016;
  --bg-deep: #0C0B0F;
  --surface: #19171E;
  --surface-2: #221F29;
  --surface-3: #2E2A36;
  --ink: #F1EEF4;
  --ink-2: #BBB5C4;
  --ink-3: #8F8999;
  --line: #2A2631;
  --line-strong: #5F596B;
  --signal: #A999BD;
  --signal-hi: #BEB0D0;
  --on-signal: #17131D;
  --signal-wash: rgb(169 153 189 / 0.10);
  --signal-ring: rgb(169 153 189 / 0.36);
  --danger: #E5574B;
  --danger-hi: #F0695E;
  --ok: #22C55E;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Geist", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, Consolas, monospace;
  --r-sm: 10px;
  --r-md: 14px;
  --r-pill: 999px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font-body);
  user-select: none;
  overflow: hidden;
}

h1, h2 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 20px; font-weight: 700; line-height: 1.1; }
h2 { font-size: 17px; font-weight: 650; }
p { margin: 0; }
.hint { color: var(--ink-3); font-size: 14px; }

/* ---- Buttons ---- */

.btn {
  font: 600 14px/1 var(--font-body);
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 14px;
  height: 38px;
  cursor: pointer;
  transition: background 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 100ms;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible, .pick:focus-visible, .clip-add:focus-visible, .source:focus-visible {
  outline: 3px solid var(--signal-ring);
  outline-offset: 1px;
}
.btn.big { height: 48px; padding: 0 22px; font-size: 16px; border-radius: var(--r-md); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.btn.primary:hover:not(:disabled) { background: var(--signal-hi); border-color: var(--signal-hi); }

.btn.record {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.record:hover:not(:disabled) { background: var(--danger-hi); border-color: var(--danger-hi); }
.btn.record .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.btn.record.on { background: var(--surface-2); border-color: var(--danger); color: var(--ink); }
.btn.record.on:hover:not(:disabled) { background: var(--surface-3); border-color: var(--danger-hi); }
.btn.record.on .dot { border-radius: 2px; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---- Layout ---- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-deep);
}
.logo { border-radius: 9px; }
.brand { flex: 1; }
.brand p { color: var(--ink-3); font-size: 13px; }

main { flex: 1; display: flex; min-height: 0; }

.side {
  width: 330px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-right: 1px solid var(--line);
  min-height: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.clips { flex: 1; min-height: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; }

.pick {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
}
.pick:hover:not(:disabled) { border-color: var(--line-strong); }
.pick:disabled { opacity: 0.5; cursor: default; }
.pick-label { font-size: 12px; color: var(--ink-3); }
.pick-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-name.empty { color: var(--signal); }

.switch[hidden] { display: none; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob {
  width: 40px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  position: relative;
  transition: background 160ms;
  flex: none;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform 160ms var(--ease-out), background 160ms;
}
.switch input:checked + .knob { background: var(--signal); }
.switch input:checked + .knob::after { transform: translateX(16px); background: var(--on-signal); }
.switch input:focus-visible + .knob { outline: 3px solid var(--signal-ring); outline-offset: 1px; }
.switch input:disabled + .knob { opacity: 0.5; }

/* ---- Clip list ---- */

#clip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}
.clip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.clip-thumb {
  width: 60px;
  height: 36px;
  flex: none;
  border-radius: 6px;
  background: #000;
  object-fit: cover;
}
.clip-text { flex: 1; min-width: 0; }
.clip-name { font-size: 12.5px; font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.clip-length { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.clip-add {
  flex: none;
  font: 600 13px/1 var(--font-body);
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--signal);
  background: var(--signal-wash);
  color: var(--signal);
  cursor: pointer;
}
.clip-add:hover { background: var(--signal); color: var(--on-signal); }

/* ---- Preview ---- */

.work { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.stage {
  flex: 1;
  min-height: 0;
  margin: 12px 12px 0;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; }
.bar .gap { flex: 1; }
.bar #play { min-width: 84px; }
.time { font: 14px var(--font-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; margin-left: 6px; }
.zoom { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; }
.zoom input { width: 110px; accent-color: var(--signal); }

/* ---- Timeline ---- */

.timeline {
  height: 150px;
  flex: none;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  position: relative;
}
.tl-inner { position: relative; height: 100%; min-width: 100%; }
.tl-ruler { position: absolute; top: 0; left: 0; right: 0; height: 28px; cursor: pointer; border-bottom: 1px solid var(--line); overflow: hidden; }
.tl-tick { position: absolute; top: 0; height: 100%; border-left: 1px solid var(--line); padding: 6px 0 0 5px; font: 11px var(--font-mono); color: var(--ink-3); pointer-events: none; }
.tl-track { position: absolute; top: 40px; left: 0; right: 0; height: 84px; }
.tl-empty { position: absolute; inset: 28px 0 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }

.clip {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 9px;
  background: var(--surface-3);
  border: 2px solid transparent;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.clip.selected { border-color: var(--signal); background: #322C3D; }
.clip.dragging { opacity: 0.85; z-index: 3; cursor: grabbing; box-shadow: 0 8px 24px -8px #000; }
.clip-body { position: absolute; inset: 0 12px; display: flex; align-items: center; gap: 8px; padding: 0 6px; pointer-events: none; overflow: hidden; }
.clip-body img { height: 46px; border-radius: 5px; flex: none; }
.clip-body .t-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-body .t-len { font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.handle { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; background: rgb(255 255 255 / 0.08); touch-action: none; }
.handle::after { content: ""; position: absolute; top: 28%; bottom: 28%; left: 5px; width: 2px; border-radius: 1px; background: var(--ink-2); }
.handle.left { left: 0; }
.handle.right { right: 0; }
.clip.selected .handle { background: var(--signal); }
.clip.selected .handle::after { background: var(--on-signal); }

.tl-drop { position: absolute; top: 34px; height: 96px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--signal); z-index: 4; pointer-events: none; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--ink); z-index: 5; pointer-events: none; }
.tl-playhead::before { content: ""; position: absolute; top: 0; left: -6px; border: 7px solid transparent; border-top: 9px solid var(--ink); }

/* ---- Dialogs ---- */

.dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 22px;
  width: 400px;
  max-width: calc(100vw - 40px);
}
.dialog.wide { width: 860px; max-height: calc(100vh - 60px); }
.dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }

progress { width: 100%; height: 14px; appearance: none; border: none; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-3); }
progress::-webkit-progress-bar { background: var(--surface-3); }
progress::-webkit-progress-value { background: var(--signal); border-radius: var(--r-pill); transition: width 200ms linear; }

.source-body { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; min-height: 120px; }
.source-group { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  font: 600 13px/1.2 var(--font-body);
  color: var(--ink);
  text-align: left;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.source:hover { border-color: var(--signal); }
.source.current { border-color: var(--signal); background: var(--signal-wash); }
.source img, .source .no-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 7px; }
.source span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toast {
  position: fixed;
  left: 50%;
  top: 78px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  z-index: 20;
  box-shadow: 0 8px 30px -8px #000;
}

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---- Picture shape and clip sound ---- */

.stage { container-type: size; }
.stage[data-shape]:not([data-shape="original"]) video {
  inset: 0;
  margin: auto;
  width: min(100cqw, calc(100cqh * var(--ar, 1)));
  height: min(100cqh, calc(100cqw / var(--ar, 1)));
  background: #000;
  outline: 1px solid var(--line-strong);
}
.stage[data-fill="1"] video { object-fit: cover; }
.shape, .fill, .vol { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; }
.shape select {
  height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font: inherit;
}
.shape select:focus-visible, .fill input:focus-visible, .vol input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.fill { color: var(--ink-2); cursor: pointer; }
.fill input { width: 18px; height: 18px; accent-color: var(--signal); }
.vol input { width: 96px; accent-color: var(--signal); }
.vol span { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---- Music track ---- */

.music-row {
  display: flex; align-items: center; gap: 10px; margin: 0 12px 10px; padding: 8px 12px;
  background: var(--signal-wash); border: 1px solid var(--signal-ring); border-radius: var(--r-sm);
}
.music-note { color: var(--signal); font-size: 18px; }
.music-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* ---- Words on the picture ---- */

.text-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.text-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 12px 10px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.text-input, .text-row select {
  height: 36px; padding: 0 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink); font: inherit;
}
.text-input { flex: 1 1 220px; min-width: 0; }
.text-input:focus-visible, .text-row select:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.timeline.has-texts { height: 184px; }
.tl-texts { position: absolute; top: 130px; left: 0; right: 0; height: 28px; }
.tl-text {
  position: absolute; top: 0; height: 28px; padding: 0 8px; border-radius: 7px; border: 2px solid transparent;
  background: #3A3346; color: var(--ink); font: 600 12px var(--font-body); text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.tl-text.selected { border-color: var(--signal); background: #322C3D; }
.tl-text:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }

/* ---- Tools and their panels ---- */

.tools { display: flex; gap: 8px; padding: 0 12px 10px; }
.tool {
  flex: 0 1 auto; min-width: 96px; height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-2);
  font: 600 14px var(--font-body); cursor: pointer;
}
.tool:hover { color: var(--ink); border-color: var(--ink-3); }
.tool.on { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.tool:focus-visible, .chip:focus-visible { outline: 2px solid var(--signal-hi); outline-offset: 2px; }
.panel {
  display: flex; flex-direction: column; gap: 10px; margin: 0 12px 10px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.panel[hidden] { display: none; }
.panel .hint { margin: 0; }
.panel-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.panel .music-row, .panel .text-row { margin: 0; flex: 1 1 320px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2);
  font: 600 14px var(--font-body); cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--signal-wash); border-color: var(--signal); color: var(--ink); }
.shape-box { display: inline-block; border: 2px solid currentColor; border-radius: 3px; opacity: 0.85; }
.shape-box.tall { width: 9px; height: 16px; }
.shape-box.square { width: 13px; height: 13px; }
.shape-box.portrait { width: 11px; height: 14px; }
.shape-box.wide { width: 18px; height: 10px; }
