:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: rgba(255,255,255,.055);
  --panel-strong: rgba(255,255,255,.09);
  --text: #f4f8fb;
  --muted: rgba(235,244,249,.67);
  --faint: rgba(235,244,249,.43);
  --border: rgba(255,255,255,.12);
  --accent: #52e6ff;
  --accent-dark: #06212a;
  --danger: #ff829d;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 50% -8rem, rgba(82,230,255,.15), transparent 30rem), linear-gradient(180deg,#071018,#0b1722 60%,#071018);
}
button,input,select,a { font: inherit; }
button,a,input[type="range"],select,.dropzone { -webkit-tap-highlight-color: transparent; }
button,a { touch-action: manipulation; }
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1,h2,p { margin: 0; }
h1 { font-size: 1.25rem; letter-spacing: -.03em; }
h2 { font-size: 1rem; letter-spacing: -.02em; }
[hidden] { display: none !important; }
.page { width: min(100%,1220px); margin: 0 auto; padding: 8px 8px calc(18px + env(safe-area-inset-bottom)); }
.panel { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 18px; background: var(--panel); box-shadow: 0 16px 48px rgba(0,0,0,.25); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.topbar { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; margin-bottom: 8px; }
.format-first { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: rgba(0,0,0,.2); }
.format-button { min-width: 58px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; }
.format-button.active { background: var(--accent); color: var(--accent-dark); }
.title-block { min-width: 0; }
.title-block p,.panel-header p,.control-card small,.switch-card small,.footer-note,summary small { color: var(--muted); font-size: .73rem; line-height: 1.35; }
.title-block p { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { flex: 0 0 auto; padding: 5px 8px; border: 1px solid rgba(82,230,255,.25); border-radius: 999px; background: rgba(82,230,255,.08); color: var(--accent); font-size: .68rem; font-weight: 800; white-space: nowrap; }
.layout,.stack { display: grid; gap: 8px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.compact-header p { margin-top: 3px; }
.dropzone { display: grid; gap: 3px; place-items: center; min-height: 76px; padding: 12px; border: 2px dashed var(--border); border-radius: 14px; background: rgba(0,0,0,.17); text-align: center; cursor: pointer; }
.dropzone:hover,.dropzone.active { border-color: var(--accent); background: rgba(82,230,255,.07); }
.dropzone span { color: var(--muted); font-size: .74rem; }
.editor { display: grid; gap: 8px; margin-top: 8px; }
.video-shell { position: relative; overflow: hidden; min-height: 170px; border: 1px solid var(--border); border-radius: 14px; background: #020609; }
.video-shell video { display: block; width: 100%; max-height: 48vh; min-height: 170px; object-fit: contain; background: #020609; }
.video-toggle { position: absolute; left: 8px; bottom: 8px; display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(0,0,0,.68); color: #fff; font-weight: 900; cursor: pointer; }
.muted-badge { position: absolute; right: 8px; bottom: 8px; padding: 5px 7px; border: 1px solid rgba(255,255,255,.14); border-radius: 999px; background: rgba(0,0,0,.62); color: rgba(255,255,255,.72); font-size: .65rem; font-weight: 700; }
.timeline-wrap { display: grid; gap: 6px; }
.timeline-viewport { overflow-x: auto; overflow-y: visible; padding: 10px 0 6px; scrollbar-width: thin; scrollbar-color: rgba(82,230,255,.6) rgba(255,255,255,.05); touch-action: none; overscroll-behavior-x: contain; }
.timeline-track { position: relative; height: 78px; min-width: 1px; margin-inline: 24px; overflow: visible; border: 1px solid var(--border); border-radius: 12px; background: #020609; user-select: none; touch-action: none; }
.timeline-thumbnails { position: absolute; inset: 0; display: flex; overflow: hidden; border-radius: inherit; pointer-events: none; }
.timeline-thumb { flex: 1 0 0; min-width: 0; height: 100%; object-fit: cover; opacity: .76; }
.timeline-placeholder { width: 100%; height: 100%; background: repeating-linear-gradient(90deg,transparent 0 38px,rgba(255,255,255,.04) 38px 39px),linear-gradient(90deg,#07121a,#132331,#07121a); }
.timeline-dim { position: absolute; top: 0; bottom: 0; z-index: 2; background: rgba(0,0,0,.66); pointer-events: none; }
.timeline-dim-left { left: 0; }
.timeline-dim-right { right: 0; }
.timeline-selection { position: absolute; top: 0; bottom: 0; z-index: 3; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); background: rgba(82,230,255,.08); pointer-events: none; }
.trim-handle,.seek-head { position: absolute; top: -7px; bottom: -7px; z-index: 7; width: 44px; padding: 0; border: 0; background: transparent; cursor: ew-resize; transform: translateX(-50%); touch-action: none; }
.trim-handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 15px; width: 14px; border: 1px solid rgba(255,255,255,.72); border-radius: 7px; background: var(--accent); box-shadow: 0 0 0 2px rgba(0,0,0,.55); }
.trim-handle::after { position: absolute; top: 50%; left: 19px; color: var(--accent-dark); font-size: .82rem; font-weight: 900; transform: translateY(-50%); }
.trim-handle-start::after { content: "›"; }
.trim-handle-end::after { content: "‹"; }
.seek-head { z-index: 8; width: 34px; }
.seek-head::before { content: ""; position: absolute; top: 0; bottom: 0; left: 16px; width: 2px; background: #fff; box-shadow: 0 0 7px rgba(0,0,0,.9); }
.seek-head::after { content: ""; position: absolute; top: 0; left: 10px; width: 14px; height: 10px; border-radius: 0 0 7px 7px; background: #fff; }
.trim-values { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.trim-values label,.trim-values>div { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 5px; min-width: 0; padding: 7px 8px; border: 1px solid var(--border); border-radius: 10px; background: rgba(0,0,0,.16); }
.trim-values span { color: var(--faint); font-size: .61rem; font-weight: 800; text-transform: uppercase; }
.trim-values input,.trim-values strong { min-width: 0; width: 100%; padding: 0; border: 0; background: transparent; color: var(--text); font-size: .72rem; font-weight: 800; text-align: right; }
.timeline-toolbar { display: grid; grid-template-columns: auto 30px minmax(70px,1fr) 30px; align-items: center; gap: 5px; color: var(--muted); font-size: .7rem; }
.timeline-toolbar button { min-height: 30px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.045); color: var(--text); cursor: pointer; }
.direction-group,.speed-presets { display: grid; gap: 5px; }
.direction-group { grid-template-columns: repeat(3,minmax(0,1fr)); }
.direction-group button,.speed-presets button { min-height: 38px; min-width: 0; padding: 0 4px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.045); color: var(--text); font-weight: 760; cursor: pointer; }
.direction-group button.active,.speed-presets button.active { border-color: var(--accent); background: var(--accent); color: var(--accent-dark); }
.speed-block { padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.03); }
.label-row,.control-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.label-row { color: var(--muted); font-size: .75rem; }
.speed-presets { grid-template-columns: repeat(7,minmax(0,1fr)); margin: 7px 0; }
.speed-presets button { min-height: 34px; }
input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); }
.controls-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; }
.control-card,.switch-card,.info-card { min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.03); }
.control-card label,.switch-card strong { font-size: .76rem; font-weight: 780; }
.control-card output { color: var(--accent); font-size: .73rem; font-weight: 820; white-space: nowrap; }
.control-card input[type="range"] { margin-top: 7px; }
.control-card small { display: block; margin-top: 3px; }
.select-control { display: grid; gap: 7px; }
.select-control select { min-width: 0; width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 9px; background: #0b1722; color: var(--text); }
.switch-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
.switch-card span { display: grid; gap: 2px; }
.switch-card input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent); }
.info-card { display: grid; gap: 3px; }
.info-card span { color: var(--faint); font-size: .65rem; font-weight: 800; text-transform: uppercase; }
.info-card strong { font-size: .75rem; }
.disabled-control { opacity: .45; }
.format-section { margin-top: 6px; }
.filters-group { margin-top: 6px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255,255,255,.025); }
.filters-group summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px; cursor: pointer; font-size: .78rem; font-weight: 780; }
.filters-group summary::marker { color: var(--accent); }
.filter-grid { padding: 0 7px 7px; }
.result-shell { position: relative; display: grid; min-height: 180px; place-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(45deg,rgba(255,255,255,.045) 25%,transparent 25%,transparent 75%,rgba(255,255,255,.045) 75%),linear-gradient(45deg,rgba(255,255,255,.045) 25%,transparent 25%,transparent 75%,rgba(255,255,255,.045) 75%),#04090d; background-size: 22px 22px; background-position: 0 0,11px 11px; }
.result-shell canvas,.result-shell img { display: block; width: 100%; max-height: 54vh; object-fit: contain; }
.empty-result { position: absolute; max-width: 14rem; padding: 16px; color: var(--muted); font-size: .78rem; line-height: 1.4; text-align: center; pointer-events: none; }
.preview-badge { position: absolute; top: 7px; right: 7px; padding: 4px 7px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: rgba(0,0,0,.62); color: var(--accent); font-size: .63rem; font-weight: 800; }
.output-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; margin-top: 7px; }
.output-stats div { min-width: 0; padding: 7px; border: 1px solid var(--border); border-radius: 10px; background: rgba(0,0,0,.16); }
.output-stats span,.output-stats strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.output-stats span { color: var(--faint); font-size: .59rem; font-weight: 800; text-transform: uppercase; }
.output-stats strong { margin-top: 3px; font-size: .72rem; }
.progress { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.08); }
.progress-bar { width: 0; height: 100%; background: linear-gradient(90deg,var(--accent),#a3f3ff); transition: width .1s linear; }
.error { margin-top: 7px; padding: 8px; border: 1px solid rgba(255,130,157,.32); border-radius: 10px; background: rgba(255,130,157,.1); color: #ffdce4; font-size: .75rem; }
.action-row { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; margin-top: 8px; }
.btn { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 8px 11px; border: 1px solid transparent; border-radius: 11px; text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-dark); font-weight: 850; }
.btn-secondary { border-color: var(--border); background: rgba(255,255,255,.055); color: var(--text); }
.btn:disabled,.btn.disabled { opacity: .42; cursor: not-allowed; pointer-events: none; }
.footer-note { margin-top: 7px; }
@media (min-width: 720px) {
  .page { padding: 12px; }
  .layout { grid-template-columns: minmax(0,1.2fr) minmax(320px,.8fr); }
  .sticky-panel { position: sticky; top: 12px; }
  .output-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 430px) {
  .page { padding-inline: 5px; }
  .panel { padding: 9px; border-radius: 15px; }
  .topbar { grid-template-columns: auto minmax(0,1fr); }
  .topbar>.pill { display: none; }
  .format-button { min-width: 50px; padding-inline: 7px; }
  .title-block p { font-size: .66rem; }
  .control-card,.switch-card,.info-card { padding: 7px; }
  .control-card label,.switch-card strong { font-size: .7rem; }
  .action-row { grid-template-columns: 1fr 1fr; }
  .action-row .btn-primary { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { transition-duration: .001ms !important; scroll-behavior: auto !important; } }
