:root {
  --bg: #0e0f14;
  --panel: #15161d;
  --panel-2: #1c1d26;
  --line: #2a2c38;
  --text: #e7e8ee;
  --muted: #8b8ea0;
  --accent: #466bff;
  --accent-2: #2a1fd0;
  --danger: #ff5a6e;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, .button, .touchbar, .sheet-tabs { touch-action: manipulation; }

button, .button, input, select {
  font: inherit;
  color: inherit;
}
button, .button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 11px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: #3d4152; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.toggle[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent); }
button#btn-blackout[aria-pressed='true'] { background: #5a1020; border-color: var(--danger); }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.4; cursor: default; }

input[type='text'], input[type='number'], select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 7px;
  min-width: 0;
}
input[type='color'] {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
input[type='range'] { width: 100%; accent-color: var(--accent); }

/* ---------- Editor layout ---------- */
body.editor {
  display: grid;
  grid-template-columns: 230px 1fr 290px;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'top top top' 'left stage right';
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  grid-area: top;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  min-height: 52px;
  padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.logo {
  width: 20px; height: 20px; border-radius: 5px;
  background: conic-gradient(from 45deg, var(--accent), #ff4fa3, #2de2c4, var(--accent));
  clip-path: polygon(50% 0, 100% 30%, 100% 75%, 50% 100%, 0 75%, 0 30%);
}
.group { display: flex; align-items: center; gap: 6px; }
.group.right { margin-left: auto; position: relative; }
.drawer-toggle, .more-toggle, .sheet-tabs, .touch-help, .scrim { display: none; }
.status { color: var(--muted); font-size: 12px; }
.status.ok { color: #4ade80; }
.bpm { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.bpm input { width: 64px; }
.beat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: 0.2; }
.meter { width: 70px; height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
#meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4ade80, #facc15, #ff5a6e); }

.panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
}
.panel.left { grid-area: left; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.panel.right { grid-area: right; border-left: 1px solid var(--line); }
.panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 0 0 10px; }
.panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 16px 0 8px; }

.add-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.add-row button { padding: 6px 4px; }

.surface-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.surface-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.surface-list li:hover { background: var(--panel-2); }
.surface-list li.sel { background: var(--panel-2); border-color: var(--accent); }
.surface-list li.hidden-surface .name { color: var(--muted); text-decoration: line-through; }
.surface-list .swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.surface-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.surface-list .kind { color: var(--muted); font-size: 11px; }
.surface-list .eye { padding: 2px 6px; font-size: 11px; }

.help { margin-top: auto; padding-top: 12px; color: var(--muted); font-size: 12px; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.help dt { color: var(--text); }
.help dd { margin: 0; }

/* ---------- Stage ---------- */
.stage-wrap {
  grid-area: stage;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background:
    radial-gradient(circle at 50% 40%, #191b26 0, var(--bg) 70%);
}
.stage-box {
  --stage-pad: 48px;
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
  touch-action: none;
}
.stage {
  position: relative;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  background-color: #07070a;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 6.25% 11.111%;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line), 0 30px 80px -30px rgba(0,0,0,.8);
}
.stage canvas, .stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage svg { overflow: visible; touch-action: none; user-select: none; }

.face { fill: transparent; stroke: rgba(255,255,255,.35); stroke-width: 1.5; cursor: move; }
.face.hidden-surface { stroke-dasharray: 4 4; stroke: rgba(255,255,255,.2); }
.face.sel { stroke: #fff; stroke-width: 2; }
.mesh { stroke: rgba(70,107,255,.45); stroke-width: 1; fill: none; pointer-events: none; }
.ellipse-guide { stroke: rgba(255,255,255,.5); stroke-dasharray: 3 3; fill: none; pointer-events: none; }
.vertex { cursor: grab; }
.vertex .hit { fill: transparent; }
.vertex .ring { fill: rgba(0,0,0,.25); stroke: #fff; stroke-width: 2; }
.vertex .core { fill: var(--accent); }
.vertex.active .ring { stroke: var(--accent); stroke-width: 3; fill: rgba(70,107,255,.25); }
.vertex.snapped .ring { stroke: #4ade80; }
.vertex text { fill: #fff; font-size: 10px; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: #000; stroke-width: 3px; }
.frame-label { fill: var(--muted); font-size: 11px; }

/* ---------- Inspector ---------- */
.field { margin-bottom: 12px; }
.field > label, .field > .label { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 5px; font-size: 12px; }
.field > label output { color: var(--text); font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.full { width: 100%; }

.visual-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.visual-tile {
  padding: 0; overflow: hidden; display: flex; flex-direction: column;
  border-radius: 8px; border: 1px solid var(--line);
}
.visual-tile img { width: 100%; aspect-ratio: 16 / 10; display: block; background: #000; }
.visual-tile span { padding: 4px; font-size: 11px; }
.visual-tile[aria-pressed='true'] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; line-height: 1.6; }
.note { color: var(--muted); font-size: 11px; margin-top: 6px; line-height: 1.5; }

/* ---------- Output window ---------- */
body.output { background: #000; overflow: hidden; cursor: default; }
body.output.idle { cursor: none; }
body.output canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
body.output canvas[hidden] { display: none; }
body.output.calibrating { cursor: none; }
body.output.calibrating .hint { display: none; }
.hint {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(20,20,28,.85); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; text-align: center;
  transition: opacity .5s; max-width: 90vw;
}
.hint span { color: var(--muted); }
.hint.gone { opacity: 0; pointer-events: none; }

/* Phone camera page */
body.phone { background: #000; overflow: hidden; }
body.phone video { position: fixed; inset: 0; width: 100vw; height: 100vh; object-fit: contain; background: #000; }
.phone-bar {
  position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(20,20,28,.88); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 15px;
}
.phone-bar input, .phone-bar button { font-size: 16px; padding: 10px; width: 100%; }
.phone-bar .status { font-size: 14px; }
.phone-urls { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.phone-urls svg { width: 168px; height: 168px; background: #fff; border-radius: 6px; }
.phone-urls a { color: var(--text); word-break: break-all; font-size: 11px; }

/* ---------- Pairing ---------- */
.pair-badge { font-size: 12px; color: #facc15; border-color: rgba(250,204,21,.4); }
.pair-badge.ok { color: #4ade80; border-color: rgba(74,222,128,.4); }
.pair-dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px;
}
.pair-dialog::backdrop { background: rgba(0,0,0,.6); }
.pair-dialog h2 { font-size: 16px; margin: 0 0 12px; }
.pair-dialog h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 18px 0 8px; }
.pair-dialog p { line-height: 1.5; }
.pair-dialog .field label { display: block; color: var(--muted); margin-bottom: 5px; font-size: 12px; }
.pair-grid { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: start; }
.pair-qr svg { width: 200px; height: 200px; background: #fff; border-radius: 8px; display: block; }
.pair-steps { margin: 0 0 10px; padding-left: 18px; line-height: 1.5; }
.pair-urls { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.pair-urls code, .phone-urls code { word-break: break-all; font-size: 12px; }
.pair-code { font-size: 28px; font-weight: 700; letter-spacing: 3px; font-variant-numeric: tabular-nums; margin: 4px 0; }
.pair-devices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pair-devices li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.pair-devices .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair-devices .seen { color: var(--muted); font-size: 11px; }
.pair-devices .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pair-devices .dot.on { background: #4ade80; }
.pair-devices input { flex: 1; }
.pair-foot { display: flex; justify-content: flex-end; margin-top: 12px; }
@media (max-width: 560px) {
  .pair-grid { grid-template-columns: 1fr; justify-items: center; }
}

/* ---------- Camera view ---------- */
#camview { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; border-radius: 6px; background: #000; }
body.cam-mode #camview { display: block; }
body.cam-mode .stage { background-image: none; }
body.cam-mode .stage svg { overflow: hidden; }
body.cam-mode:not(.cam-preview) #preview { visibility: hidden; }
body.cam-mode.cam-preview #preview { opacity: 0.55; }
.proj-frame { fill: none; stroke: #facc15; stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }
.calib-tap { fill: none; stroke: #facc15; stroke-width: 2; pointer-events: none; }
body.cam-mode .face { stroke: rgba(255,255,255,.7); filter: drop-shadow(0 0 1px #000); }
.cambar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px;
  padding: 6px 12px 0;
}
.cambar[hidden] { display: none; }
.cam-status { color: var(--muted); font-size: 12px; line-height: 1.4; text-align: center; flex: 1 1 260px; }
.cam-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cam-help p { margin: 0 0 8px; line-height: 1.45; }

/* ---------- Touch toolbar ---------- */
.touchbar {
  display: none;
  flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 8px 14px;
  padding: 8px 12px 12px;
}
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-target { min-width: 72px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.touchbar button { min-width: 44px; min-height: 44px; font-size: 16px; padding: 6px 10px; }
.touchbar, .touchbar button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* Touch screens: larger targets, no keyboard help, 16px inputs so iOS does
   not zoom the page on focus. */
@media (pointer: coarse) {
  .touchbar { display: flex; }
  .help:not(.touch-help) { display: none; }
  .touch-help { display: block; }
  button, .button { min-height: 40px; padding: 8px 12px; }
  input[type='text'], input[type='number'], select { font-size: 16px; min-height: 40px; }
  input[type='range'] { height: 32px; }
  input[type='color'] { height: 40px; }
  .surface-list li { min-height: 46px; }
  .surface-list .eye { min-height: 34px; }
}

/* ---------- Tablet portrait and small laptops: surface list as a drawer ---------- */
@media (max-width: 1099px) {
  body.editor {
    grid-template-columns: 1fr 290px;
    grid-template-areas: 'top top' 'stage right';
  }
  .drawer-toggle { display: inline-block; }
  .panel.left {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0;
    width: min(300px, 86vw);
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 20px 0 60px -20px rgba(0,0,0,.7);
    visibility: hidden;
  }
  body.drawer-open .panel.left { transform: none; visibility: visible; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.45); }
  .brand-name { display: none; }
  .topbar { gap: 8px 12px; }
  .more-toggle { display: inline-block; }
  .file-group {
    display: none;
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    flex-direction: column; align-items: stretch;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 8px; min-width: 140px; box-shadow: 0 20px 50px -20px rgba(0,0,0,.8);
  }
  .file-group .button { text-align: center; }
  body.more-open .file-group { display: flex; }
}

/* ---------- Phone: stage on top, panels in a tabbed sheet below ---------- */
@media (max-width: 767px) {
  body.editor {
    grid-template-columns: 1fr;
    /* The stage row shrinks before the panel drops below 150 px. */
    grid-template-rows: auto minmax(0, auto) auto minmax(150px, 1fr);
    grid-template-areas: 'top' 'stage' 'tabs' 'sheet';
  }
  .stage-wrap { overflow: hidden; }
  .stage-box {
    --stage-pad: 16px;
    flex: 0 1 auto;
    width: 100%;
    min-height: 120px;
    aspect-ratio: var(--aspect, 1.7778);
    max-height: 46dvh;
  }
  .cambar, .touchbar { flex: none; }
  .stage-wrap { padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left); }
  .touchbar { display: flex; padding-top: 0; }
  .topbar .history, .drawer-toggle, .meter, #output-status { display: none; }
  .topbar { gap: 6px 8px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  /* Let every control flow on its own so the bar wraps to two rows. */
  .topbar .group { display: contents; }
  .more-toggle { margin-left: auto; }
  .topbar .file-group { display: none; right: 10px; top: 100%; }
  body.more-open .topbar .file-group { display: flex; }
  .topbar button, .topbar .button { min-height: 36px; padding: 6px 9px; }
  .topbar input[type='number'] { min-height: 36px; padding: 4px 6px; }
  .bpm input { width: 58px; }
  .bpm-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .touchbar { gap: 6px 10px; padding-left: 8px; padding-right: 8px; }
  .touchbar button { min-width: 42px; padding: 6px 8px; }
  .tb-target { min-width: 64px; }
  .sheet-tabs {
    grid-area: tabs;
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    padding: 6px 10px; border-top: 1px solid var(--line); background: var(--panel);
  }
  .sheet-tabs button { min-height: 40px; }
  .sheet-tabs button[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent); }
  .panel.left, .panel.right {
    grid-area: sheet;
    position: static; transform: none; visibility: visible; width: auto; box-shadow: none;
    border: 0; min-height: 0;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  body[data-sheet='left'] .panel.right, body[data-sheet='right'] .panel.left { display: none; }
  .scrim:not([hidden]) { display: none; }
  .visual-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 767px) {
  body.cam-mode .stage-box { max-height: 60dvh; }
  .cam-status { font-size: 11px; flex-basis: 100%; }
}

/* ---------- Phone in landscape: stage left, panels right ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  body.editor {
    grid-template-columns: 1fr minmax(240px, 34vw);
    grid-template-rows: auto auto 1fr;
    grid-template-areas: 'top top' 'stage tabs' 'stage sheet';
  }
  .drawer-toggle, .topbar .history, .meter, #output-status, .brand { display: none; }
  .topbar { min-height: 0; gap: 6px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .topbar .group { display: contents; }
  .more-toggle { margin-left: auto; }
  .topbar .file-group { display: none; right: 10px; top: 100%; }
  body.more-open .topbar .file-group { display: flex; }
  .topbar button, .topbar .button { min-height: 34px; padding: 5px 9px; }
  .topbar input[type='number'] { min-height: 34px; }
  .stage-box { --stage-pad: 10px; }
  .stage-wrap { padding-left: env(safe-area-inset-left); }
  .touchbar { gap: 4px 8px; padding: 4px 8px 6px; }
  .touchbar button { min-width: 40px; min-height: 38px; padding: 4px 8px; }
  .cambar { padding-top: 4px; }
  .sheet-tabs {
    grid-area: tabs; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    padding: 6px 8px; background: var(--panel); border-left: 1px solid var(--line);
  }
  .panel.left, .panel.right {
    grid-area: sheet; position: static; transform: none; visibility: visible; width: auto; box-shadow: none;
    border-left: 1px solid var(--line); min-height: 0;
    padding-right: max(14px, env(safe-area-inset-right));
  }
  .sheet-tabs button[aria-pressed='true'] { background: var(--accent-2); border-color: var(--accent); }
  body[data-sheet='left'] .panel.right, body[data-sheet='right'] .panel.left { display: none; }
  .scrim:not([hidden]) { display: none; }
}

/* ---------- Perform mode ---------- */
.perform {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.perform[hidden] { display: none; }
.perform canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.perform-corner { position: absolute; left: 0; top: 0; width: 64px; height: 64px; }
.perform-exit {
  position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top));
  min-height: 44px; background: rgba(20,20,28,.9);
}
.perform-exit[hidden] { display: none; }
.perform .hint { bottom: max(24px, env(safe-area-inset-bottom)); }
body.performing { cursor: none; }
body.performing .perform-exit { cursor: pointer; }

/* ---------- Clip editor ---------- */
.clip-dialog { width: min(920px, calc(100vw - 32px)); }
.clip-src { color: var(--muted); font-weight: 400; margin-left: 6px; }
.clip-surface { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.clip-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.clip-view {
  position: relative; width: min(100%, calc(58dvh * var(--a, 1.78)));
  max-height: 58dvh; background: #000; border-radius: 6px; touch-action: none; user-select: none;
  -webkit-user-select: none;
}
.clip-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
.clip-mask { position: absolute; inset: 0; overflow: hidden; border-radius: 6px; pointer-events: none; }
.clip-hole { position: absolute; box-shadow: 0 0 0 9999px rgba(0,0,0,.6); }
.clip-other {
  position: absolute; border: 1.5px dashed rgba(255,255,255,.65); cursor: pointer;
}
.clip-other span {
  position: absolute; left: 4px; top: 3px; font-size: 11px; background: rgba(0,0,0,.6);
  padding: 1px 5px; border-radius: 4px; white-space: nowrap; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis;
}
.clip-rect { position: absolute; outline: 2px solid #fff; cursor: move; }
.clip-h {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.clip-h[data-h='nw'] { left: 0; top: 0; cursor: nwse-resize; }
.clip-h[data-h='n'] { left: 50%; top: 0; cursor: ns-resize; }
.clip-h[data-h='ne'] { left: 100%; top: 0; cursor: nesw-resize; }
.clip-h[data-h='e'] { left: 100%; top: 50%; cursor: ew-resize; }
.clip-h[data-h='se'] { left: 100%; top: 100%; cursor: nwse-resize; }
.clip-h[data-h='s'] { left: 50%; top: 100%; cursor: ns-resize; }
.clip-h[data-h='sw'] { left: 0; top: 100%; cursor: nesw-resize; }
.clip-h[data-h='w'] { left: 0; top: 50%; cursor: ew-resize; }
@media (pointer: coarse) {
  .clip-h { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
}
.clip-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 12px; }
.clip-fields label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.clip-fields input { width: 76px; }
.clip-transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clip-transport #clip-play { min-width: 70px; }
.clip-clock { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline {
  position: relative; height: 34px; margin: 12px 7px 0; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line); touch-action: none; cursor: pointer;
}
.tl-range { position: absolute; top: 0; bottom: 0; background: rgba(70,107,255,.3); }
.tl-handle {
  position: absolute; top: -4px; bottom: -4px; width: 12px; margin-left: -6px; border-radius: 4px;
  background: var(--accent); border: 2px solid #fff; cursor: ew-resize;
}
.tl-head { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: #fff; pointer-events: none; }
.clip-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
