/* VMH Looper — styled after the VMH business pipeline app:
   Velvet Motion Haus red, near-black, warm off-white, Inter. */

@font-face {
  font-family: 'Inter';
  src: url('assets/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --background: #fafaf9;
  --surface: #ffffff;
  --foreground: #171412;
  --muted: #6b6763;
  --border: #e7e4df;
  --brand-primary: #ce1c1c;
  --brand-primary-ink: #ffffff;
  --brand-secondary: #161616;
  --brand-accent: #f5f4f0;
  --brand-tint: #fbeaea;
  --surface-2: #fcfcfb;
  --surface-3: #ecebe8;
  --stripe-1: #f3f2ef;
  --stripe-2: #e9e7e3;
  --text-2: #3f3b38;
  --active-bg: #161616;
  --active-text: #ffffff;
  --tint-border: #f3caca;
  --badge-bg: #f5f5f5;
  --badge-border: #e5e5e5;
  --badge-text: #525252;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --danger-bg: #fef2f2;
  --danger-bg-hover: #fee2e2;
  --danger-border: #fecaca;
  --danger-text: #b91c1c;
  --scroll: #dcd9d4;
  --scroll-hover: #c4c0ba;
  --topbar: rgba(255, 255, 255, .92);
  --preview-bg: #1b1a19;
  color-scheme: light;
  --radius: 6px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 50px rgba(22, 22, 22, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--background);
  color: var(--foreground);
  font: 14px/1.45 'Inter', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#app { height: 100%; }
.view { height: 100%; display: flex; flex-direction: column; }
.spacer { flex: 1; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
code { font: 12px ui-monospace, Consolas, monospace; color: var(--muted); user-select: text; word-break: break-all; }
.hint { color: var(--muted); margin: 0; }
.hint.small, .small.hint { font-size: 12px; }

/* ---------- controls ---------- */
button {
  font: inherit; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--foreground);
  cursor: pointer; transition: background .12s, filter .12s, border-color .12s; white-space: nowrap;
}
button:hover { background: var(--brand-accent); }
button.primary { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-ink); box-shadow: var(--shadow); }
button.primary:hover { filter: brightness(1.1); }
button.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
button.danger:hover { background: var(--danger-bg-hover); }
button.small { padding: 5px 10px; font-size: 12px; }
button.link { border: none; background: none; color: var(--brand-primary); padding: 2px 6px; }
button.icon { width: 28px; height: 28px; padding: 0; border: none; background: none; color: var(--muted); font-size: 18px; }
button.icon:hover { background: var(--brand-tint); color: var(--brand-primary); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, .playlist-row:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 1px; }

input[type=text], input[type=number], select {
  font: inherit; font-size: 13px; color: var(--foreground);
  padding: 6px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
input[type=text]:focus, input[type=number]:focus, select:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px var(--brand-tint); }
input.num { width: 72px; }
input[type=checkbox], input[type=range] { accent-color: var(--brand-primary); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.inline-field { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.field-row.buttons { margin-top: 16px; }
.field-label { width: 64px; font-size: 12px; font-weight: 600; color: var(--muted); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.segmented button { border: none; border-radius: 0; padding: 6px 11px; font-size: 12px; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: none; }
.segmented button.active { background: var(--active-bg); color: var(--active-text); }

.badge {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; border: 1px solid var(--badge-border); background: var(--badge-bg); color: var(--badge-text);
}
.badge.video { background: var(--active-bg); border-color: var(--active-bg); color: var(--active-text); }
.badge.image { background: var(--brand-tint); border-color: var(--tint-border); color: var(--brand-primary); }
.badge.warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 20px; flex: none;
  background: var(--topbar); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 4px; display: block; }
.brand-mark.sm { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-text span { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- library ---------- */
.library-main { flex: 1; overflow: auto; padding: 32px 20px 48px; }
.library-main > * { max-width: 960px; margin-left: auto; margin-right: auto; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.library-list { display: flex; flex-direction: column; }
.playlist-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 16px;
  padding: 14px 20px; border-bottom: 1px solid var(--border); cursor: default; position: relative; transition: background .1s;
}
.playlist-row:last-child { border-bottom: none; }
.playlist-row::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.playlist-row:hover { background: var(--surface-2); }
.playlist-row.selected { background: var(--brand-accent); }
.playlist-row.selected::before { background: var(--brand-primary); }
.pl-name { font-weight: 600; font-size: 15px; }
.pl-meta { color: var(--muted); font-size: 12px; grid-row: 2; }
.pl-actions { grid-row: 1 / 3; grid-column: 2; display: flex; gap: 6px; align-items: center; opacity: .55; transition: opacity .1s; }
.playlist-row:hover .pl-actions, .playlist-row.selected .pl-actions { opacity: 1; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* ---------- editor ---------- */
.name-input { font-size: 16px !important; font-weight: 700; width: 320px; border-color: transparent !important; background: transparent !important; }
.name-input:hover { border-color: var(--border) !important; }
.name-input:focus { background: var(--surface) !important; border-color: var(--brand-primary) !important; }
.dirty { font-size: 12px; color: var(--brand-primary); font-weight: 600; }
.settings-bar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap; flex: none;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1.1fr) minmax(320px, 1.1fr); gap: 16px; padding: 16px 20px 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: none; }
.panel-head h3 { font-size: 13px; font-weight: 700; }
.panel-head .count { font-size: 12px; color: var(--muted); }
.browser > .hint { padding: 10px 16px; border-top: 1px solid var(--border); flex: none; }

.crumbs { padding: 8px 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.crumbs a { color: var(--foreground); font-weight: 600; cursor: pointer; }
.crumbs a:hover { color: var(--brand-primary); }
.crumbs button { margin-left: auto; }
.browser-grid { flex: 1; overflow: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; align-content: start; }
.tile { border-radius: 8px; padding: 5px; cursor: pointer; border: 1px solid transparent; }
.tile:hover { background: var(--brand-accent); border-color: var(--border); }
.tile-name { font-size: 11px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.thumb { aspect-ratio: 16 / 9; border-radius: 5px; background: var(--surface-3) center / cover no-repeat; position: relative; overflow: hidden; }
.thumb.video::after { content: '▶'; position: absolute; left: 5px; bottom: 4px; font-size: 9px; color: #fff; background: rgba(22,22,22,.75); border-radius: 3px; padding: 1px 4px; }
.thumb.broken { background: repeating-linear-gradient(45deg, var(--stripe-1), var(--stripe-1) 6px, var(--stripe-2) 6px, var(--stripe-2) 12px); }
.folder-icon { display: flex; align-items: center; justify-content: center; font-size: 30px; background: var(--brand-accent); color: var(--muted); }

.queue-list { flex: 1; overflow: auto; padding: 6px; }
.queue-empty { margin: 10px; padding: 48px 20px; text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: 10px; }
.q-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: grab; border: 1px solid transparent; position: relative; }
.q-row:hover { background: var(--surface-2); border-color: var(--border); }
.q-row.selected { background: var(--brand-accent); border-color: var(--border); box-shadow: inset 3px 0 0 var(--brand-primary); }
.q-row.missing .q-name { color: var(--warn); }
.q-row .thumb { width: 88px; flex: none; }
.q-index { width: 20px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.q-info { flex: 1; min-width: 0; }
.q-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { display: flex; gap: 5px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.q-dur { font-size: 11px; color: var(--muted); }
.q-row.drop-before::before, .q-row.drop-after::after { content: ''; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--brand-primary); border-radius: 2px; }
.q-row.drop-before::before { top: -2px; }
.q-row.drop-after::after { bottom: -2px; }

.framing { overflow: hidden; }
.framing > :not(.panel-head) { margin-left: 16px; margin-right: 16px; }
.preview-wrap { margin-top: 16px; display: flex; justify-content: center; align-items: center; background: var(--preview-bg); border-radius: 8px; padding: 12px 12px 36px; position: relative; }
.preview-canvas { flex: none; cursor: grab; box-shadow: 0 0 0 1px rgba(255,255,255,.15); }
.preview-canvas:active { cursor: grabbing; }
.preview-under { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.preview-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; text-align: center; padding: 12px; }
.zoom-label { font-size: 12px; color: var(--muted); width: 44px; font-variant-numeric: tabular-nums; }
.framing input[type=range] { flex: 1; min-width: 120px; }

/* ---------- output canvas & layers (shared by player + preview) ---------- */
.lp-canvas { position: relative; overflow: hidden; background: #000; container-type: size; }
.lp-layer { position: absolute; inset: 0; overflow: hidden; will-change: opacity; }
.lp-media { position: absolute; object-fit: fill; display: block; max-width: none; }
.lp-bg { position: absolute; object-fit: cover; filter: blur(4cqmax) brightness(.6) saturate(1.1); }

/* ---------- player ---------- */
.view.player { background: #000; position: fixed; inset: 0; }
.view.player.idle { cursor: none; }
.canvas-host { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.player-canvas { width: min(100vw, calc(100vh * var(--ar))); height: min(100vh, calc(100vw / var(--ar))); }
.controls {
  position: absolute; left: 50%; bottom: 20px; transform: translate(-50%, 16px); width: min(1100px, calc(100vw - 40px));
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 14px;
  background: rgba(22, 22, 22, .88); backdrop-filter: blur(14px); color: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.08);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100000;
}
.controls.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.controls .ctl { background: transparent; border: none; color: #fff; width: 36px; height: 36px; padding: 0; font-size: 16px; border-radius: 8px; }
.controls .ctl:hover { background: rgba(255,255,255,.12); }
.controls .ctl.exit:hover { background: var(--brand-primary); }
.controls .time { font-size: 12px; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.75); width: 42px; text-align: center; }
.controls .scrub { flex: 1; min-width: 120px; accent-color: var(--brand-primary); }
.controls .now-title { font-size: 12px; color: rgba(255,255,255,.7); max-width: 32%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 6px; }
.player-error { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #fff; background: rgba(22,22,22,.9); border-left: 3px solid var(--brand-primary); padding: 16px 22px; border-radius: 8px; display: none; }
.player-error.show { display: block; }

/* ---------- modal & toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(22, 22, 22, .45); display: flex; align-items: center; justify-content: center; z-index: 200000; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 40px)); max-height: calc(100vh - 60px); overflow: auto; padding: 22px 24px 18px; border-top: 4px solid var(--brand-primary); }
.modal h2 { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.modal p { margin: 0 0 10px; color: var(--text-2); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.settings-section { padding: 12px 0; border-top: 1px solid var(--border); }
.settings-section:first-child { border-top: none; padding-top: 0; }
.settings-section h4 { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.kv { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; padding: 3px 0; }
.kv > span:first-child { color: var(--muted); flex: none; }

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); max-width: min(640px, calc(100vw - 40px));
  background: var(--brand-secondary); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 300000;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--brand-primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }

/* ---------- v1.1: sound + library sources ---------- */
.settings-bar { flex-direction: column; align-items: stretch; gap: 8px; }
.settings-row { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; }
.row-label { width: 56px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-primary); }
.soundtrack-slot {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; min-width: 320px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.soundtrack-slot.empty { border-style: dashed; }
.soundtrack-slot.drop { border-color: var(--brand-primary); background: var(--brand-tint); }
.soundtrack-slot input[type=range] { width: 120px; }
.st-icon { color: var(--brand-primary); font-weight: 700; }
.st-name { font-size: 13px; font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-name.none { font-weight: 400; color: var(--muted); }
.st-name.missing { color: var(--warn); }
.source-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.source-select { flex: 1; min-width: 0; font-weight: 600; }
.audio-icon { display: flex; align-items: center; justify-content: center; font-size: 30px; background: var(--brand-tint); color: var(--brand-primary); }
.unavailable { grid-column: 1 / -1; padding: 24px 12px; text-align: center; }
.unavailable p { margin-top: 6px; word-break: break-all; }
.hint.pad { padding: 16px; }
.segmented button:disabled { opacity: .45; }

/* ---------- v1.2: item settings (trim, sections, clip info) ---------- */
.item-body { padding-bottom: 18px; }
.item-section { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.item-section h4 { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-primary); margin-bottom: 2px; }
.trim { margin-top: 12px; user-select: none; }
.trim-track { position: relative; height: 28px; border-radius: 6px; background: var(--surface-3); cursor: pointer; touch-action: none; }
.trim-sel { position: absolute; top: 0; bottom: 0; background: rgba(206, 28, 28, .18); border-top: 2px solid var(--brand-primary); border-bottom: 2px solid var(--brand-primary); }
.trim-h {
  position: absolute; top: -3px; bottom: -3px; width: 12px; margin-left: -6px; border-radius: 4px;
  background: var(--brand-primary); cursor: ew-resize; box-shadow: 0 1px 3px rgba(0,0,0,.3); touch-action: none; z-index: 2;
}
.trim-h::after { content: ''; position: absolute; left: 5px; top: 9px; bottom: 9px; width: 2px; background: rgba(255,255,255,.8); border-radius: 1px; }
.trim-playhead { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--brand-secondary); pointer-events: none; z-index: 1; }
.trim-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.trim-len { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.time-input { width: 78px; font-variant-numeric: tabular-nums; text-align: center; }
.clip-info { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.clip-info summary { cursor: pointer; padding: 9px 12px; font-size: 13px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
.clip-info summary::-webkit-details-marker { display: none; }
.clip-info summary::before { content: 'ⓘ'; color: var(--brand-primary); font-weight: 700; }
.info-body { padding: 2px 12px 10px; }
.info-body .kv { font-size: 12.5px; border-top: 1px dashed var(--border); padding: 5px 0; }
.info-body .kv > span:last-child { text-align: right; overflow-wrap: anywhere; user-select: text; }
.info-body .kv.warn > span:last-child, .warn-text { color: var(--warn); }

/* ---------- v1.3 ---------- */
.zoom-unit { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.zoom-box { width: 66px; text-align: right; }
.same-shape { background: var(--brand-accent); border-radius: 6px; padding: 8px 10px; margin: 2px 0 6px; }
.modal-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.modal-head h2 { margin-bottom: 0; }
.creator-mark { margin-left: auto; display: flex; align-items: center; gap: 10px; text-align: right; }
.creator-mark img { width: 34px; height: 34px; border-radius: 4px; }
.creator-mark .cm-text { display: flex; flex-direction: column; line-height: 1.25; }
.creator-mark strong { font-size: 13px; font-weight: 700; }
.creator-mark span { font-size: 11px; color: var(--muted); letter-spacing: .02em; }

/* ---------- v1.4: rotation + true-shape preview ---------- */
.preview-caption { position: absolute; left: 12px; right: 12px; bottom: 8px; display: flex; gap: 8px; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; }
.preview-caption .rot-note { color: #ffb4b4; }
.rot-value { min-width: 38px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.player-canvas.rotated { position: absolute; left: 50%; top: 50%; }

/* ---------- v1.5: pinned preview, simpler rotation ---------- */
.item-fixed { flex: none; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.item-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-top: 10px; padding-bottom: 18px; }
.segmented.inactive { opacity: .45; }
.segmented.inactive button { cursor: not-allowed; }
button.toggled { background: var(--active-bg); border-color: var(--active-bg); color: var(--active-text); }
.btn-note { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-primary); }
button.toggled .btn-note { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- v1.6: trim fold-out ---------- */
.fold { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); margin-bottom: 4px; }
.fold summary { cursor: pointer; padding: 9px 12px; font-size: 13px; list-style: none; display: flex; align-items: center; gap: 10px; }
.fold summary::-webkit-details-marker { display: none; }
.fold-title { font-weight: 700; }
.fold-title::before { content: '✂'; color: var(--brand-primary); margin-right: 8px; }
.trim-status { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trim-status.on { color: var(--brand-primary); font-weight: 600; }
.fold .trim { margin: 4px 12px 12px; }
.fold-actions { display: flex; justify-content: flex-end; padding: 8px 12px 10px; }
.preview-under { margin-top: 8px; }

/* play button sits in the preview's bottom strip */
.preview-wrap { padding-bottom: 44px; }
.preview-caption { align-items: center; bottom: 7px; }
.preview-caption > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.preview-caption button { margin-left: auto; flex: none; padding: 4px 12px; font-size: 12px; }

/* ---------- v1.7: play preview in header, bigger preview ---------- */
.preview-wrap { padding: 10px !important; }
.preview-caption { display: none; }
.head-actions { display: flex; gap: 6px; }
.head-actions button { padding: 5px 12px; font-size: 12px; }
.preview-wrap .rot-note { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #ffb4b4; background: rgba(0,0,0,.55); padding: 2px 7px; border-radius: 999px; pointer-events: none; }
.fold-title::before { content: none; }

/* ---------- v1.8: clear fold chevrons ---------- */
.fold summary, .clip-info summary { gap: 10px; }
.clip-info summary { font-weight: 400; }
.ci-title { font-weight: 700; }
.fold-chevron {
  margin-left: 4px; flex: none; width: 26px; height: 26px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-accent); border: 1px solid var(--border); transition: background .12s;
}
.clip-info .fold-chevron { margin-left: auto; }
.fold-chevron::before {
  content: ''; width: 8px; height: 8px; margin-top: -4px;
  border-right: 2.5px solid var(--foreground); border-bottom: 2.5px solid var(--foreground);
  transform: rotate(45deg); transition: transform .15s, margin .15s;
}
details[open] > summary .fold-chevron::before { transform: rotate(-135deg); margin-top: 4px; }
summary:hover .fold-chevron { background: var(--brand-tint); border-color: var(--tint-border); }

/* ---------- v1.8: dark mode ---------- */
:root[data-theme="dark"] {
  --background: #121110;
  --surface: #1c1b19;
  --surface-2: #22211f;
  --surface-3: #2e2c29;
  --stripe-1: #2a2826;
  --stripe-2: #333130;
  --foreground: #f2f0ec;
  --text-2: #d6d1ca;
  --muted: #a39e97;
  --border: #35322e;
  --brand-primary: #e02b2b;
  --brand-accent: #272522;
  --brand-tint: #3b1a1a;
  --tint-border: #5e2424;
  --active-bg: #f2f0ec;
  --active-text: #161616;
  --badge-bg: #2a2826;
  --badge-border: #3b3834;
  --badge-text: #d0cbc4;
  --warn: #f5a524;
  --warn-bg: #2d2411;
  --warn-border: #6b5014;
  --danger-bg: #3a1717;
  --danger-bg-hover: #4a1c1c;
  --danger-border: #6b2222;
  --danger-text: #ff8a8a;
  --scroll: #3b3834;
  --scroll-hover: #4b4742;
  --topbar: rgba(28, 27, 25, .94);
  --preview-bg: #0b0a09;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, .6); }
:root[data-theme="dark"] .brand-mark { box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
.settings-section .segmented + .hint { margin-top: 8px; }

/* ---------- v2: VMH Cloud (managed mode, pairing) ---------- */
.cloud-btn { border-color: var(--border); }
.cloud-btn.on { background: var(--brand-tint); border-color: var(--tint-border); color: var(--brand-primary); }
.managed-banner {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 18px !important;
  background: var(--brand-tint); border: 1px solid var(--tint-border); border-radius: var(--radius-lg);
}
.managed-banner > span { font-size: 22px; color: var(--brand-primary); }
.managed-banner > div { flex: 1; font-size: 13px; color: var(--text-2); }
.managed-idle { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.managed-idle.show { display: flex; }
.managed-card { text-align: center; color: #f2f0ec; max-width: 560px; padding: 24px; }
.managed-card h2 { font-size: 26px; margin: 14px 0 8px; }
.managed-card p { margin: 6px 0; color: #cfcac3; }
.managed-card .dim { color: #8f8a84; font-size: 13px; }
.managed-logo { width: 64px; height: 64px; border-radius: 8px; }
.managed-status { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.45); z-index: 100001; }
.managed-status.show { display: flex; }
.managed-panel {
  width: min(520px, calc(100vw - 40px)); background: rgba(22,22,22,.94); color: #f2f0ec; border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08); border-top: 4px solid var(--brand-primary); padding: 20px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  font-size: 14px;
}
.managed-panel .kv { border-top: 1px solid rgba(255,255,255,.08); padding: 8px 0; }
.managed-panel .kv > span:first-child { color: #a39e97; }
.managed-panel .kv > span:last-child { text-align: right; }
.mp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mp-head img { width: 40px; height: 40px; border-radius: 5px; }
.mp-head div { display: flex; flex-direction: column; flex: 1; }
.mp-head div span { font-size: 12px; color: #a39e97; }
.mp-dot { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.mp-dot.on { background: rgba(34,197,94,.15); color: #4ade80; }
.mp-dot.off { background: rgba(245,165,36,.15); color: #f5a524; }
.mp-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.mp-actions button:not(.primary) { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.1); color: #f2f0ec; }
.mp-hint { font-size: 11px; color: #8f8a84; margin: 12px 0 0; text-align: right; }
.view.pairing { background: #0f0e0d; color: #f2f0ec; align-items: center; justify-content: center; text-align: center; }
.pair-body { max-width: 720px; padding: 24px; }
.pair-logo { width: 72px; height: 72px; border-radius: 8px; }
.pair-body h1 { font-size: 30px; margin: 18px 0 10px; }
.pair-lead { color: #cfcac3; font-size: 17px; }
.pair-code {
  font: 800 88px/1 'Inter', system-ui; letter-spacing: .08em; margin: 26px 0; color: #fff;
  padding: 18px 34px; border-radius: 18px; background: #1c1b19; border: 2px solid var(--brand-primary); display: inline-block;
}
.pair-dim { color: #8f8a84; font-size: 14px; }
.pair-actions { margin-top: 26px; display: flex; gap: 10px; justify-content: center; }
.pair-actions button { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #f2f0ec; }

/* touch: move buttons instead of drag-to-reorder */
.q-move { display: none; }
@media (pointer: coarse) { .q-move { display: inline-flex; } }
