/* Cut-nika v3 — CapCut-like dark pro editor
   Accent #FE2C55 · system fonts only · mobile-tolerant */

:root {
  --bg: #0a0a0c;
  --bg-elev: #121216;
  --bg-panel: #1a1a20;
  --bg-hover: #25252e;
  --bg-deep: #08080a;
  --line: rgba(255, 255, 255, 0.06);
  --line2: rgba(255, 255, 255, 0.12);
  --text: #f2f2f5;
  --muted: #8b8b96;
  --accent: #fe2c55;
  --accent-2: #25f4ee;
  --accent-soft: rgba(254, 44, 85, 0.14);
  --accent-glow: rgba(254, 44, 85, 0.35);
  --ok: #2ddf8c;
  --warn: #ffb020;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --top: 52px;
  --dock: 60px;
  --timeline: 168px;
  --left: 228px;
  --right: 300px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --shadow-panel: 0 0 0 1px var(--line);
  --ease: 0.14s ease;
}

/* ── Reset / base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
}
input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
::selection {
  background: var(--accent-soft);
  color: #fff;
}

/* ── App shell ── */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--top) minmax(0, 1fr) var(--dock) var(--timeline);
  background: var(--bg);
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3) 0 14px;
  background: linear-gradient(180deg, #16161c 0%, var(--bg-elev) 100%);
  border-bottom: 1px solid var(--line);
  z-index: 40;
  min-width: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.brand img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--line), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.brand em {
  font-style: normal;
  background: linear-gradient(105deg, var(--accent) 0%, #ff6b8a 48%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.top-mid {
  display: flex;
  gap: var(--space-2);
  flex: 1;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}
.top-right {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

/* Free W×H rail — always visible */
.size-rail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: var(--space-2);
  padding: 4px 10px;
  height: 34px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--line2);
  flex-shrink: 1;
  min-width: 0;
}
.size-rail-lab {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  flex-shrink: 0;
}
.size-rail input {
  width: 68px;
  max-width: 12vw;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: var(--bg-deep);
  border: 1px solid var(--line);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.size-rail input:focus {
  border-color: var(--accent);
  outline: none;
}
.size-rail input::-webkit-outer-spin-button,
.size-rail input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.size-rail input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.size-x {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
.size-rail-hint {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0.85;
}

/* Buttons */
.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--line2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--ease), border-color var(--ease), filter var(--ease);
  white-space: nowrap;
  font-size: 13px;
}
.btn:hover {
  border-color: rgba(254, 44, 85, 0.45);
  background: #2e2e38;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:disabled:hover {
  border-color: var(--line2);
  background: var(--bg-hover);
}
.btn-import {
  background: var(--accent-soft);
  border-color: rgba(254, 44, 85, 0.35);
  color: #fff;
  font-weight: 600;
}
.btn-import:hover {
  background: rgba(254, 44, 85, 0.28);
  border-color: var(--accent);
}
.btn-ico {
  font-size: 15px;
  line-height: 1;
  opacity: 0.95;
}
.btn-accent {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-accent:hover {
  filter: brightness(1.08);
  background: var(--accent);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* Engine pill */
.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  max-width: 160px;
}
.pill #engine-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}
.pill.ready .dot {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.pill.loading .dot {
  background: var(--accent-2);
  animation: blink 1s infinite;
}
.pill.err .dot {
  background: var(--accent);
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

/* ── Workspace ── */
.workspace {
  display: grid;
  grid-template-columns: var(--left) minmax(0, 1fr) var(--right);
  min-height: 0;
  overflow: hidden;
}

/* Left media library */
.left {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px 7px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.drop {
  margin: 4px 10px 8px;
  padding: 16px 12px;
  text-align: center;
  border: 1.5px dashed var(--line2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
  flex-shrink: 0;
}
.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.drop b {
  display: block;
  color: var(--text);
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
}
.media-list {
  flex: 1;
  overflow: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
}
.m-card {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 9px;
  padding: 7px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
  min-width: 0;
}
.m-card:hover {
  border-color: var(--line2);
  background: #1e1e26;
}
.m-card.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(254, 44, 85, 0.15);
}
.m-thumb {
  width: 60px;
  height: 44px;
  border-radius: var(--radius-xs);
  background: #000;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.m-thumb img,
.m-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.m-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}
.m-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Center preview */
.center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, #181822 0%, transparent 70%),
    var(--bg);
}
.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: var(--space-3);
  position: relative;
}
.frame {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--line);
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-width: 260px;
  min-height: 148px;
}
#pv-video,
#pv-image {
  max-width: min(960px, 100%);
  max-height: calc(100vh - var(--top) - var(--dock) - var(--timeline) - 96px);
  max-height: calc(100dvh - var(--top) - var(--dock) - var(--timeline) - 96px);
  display: block;
  background: #000;
}
.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  pointer-events: auto;
  cursor: pointer;
  text-align: center;
  padding: var(--space-5);
  z-index: 2;
}
.stage-empty:hover {
  color: var(--text);
}
.stage-empty .ico {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-bottom: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--line2);
  opacity: 0.9;
  color: var(--muted);
}
.empty-title {
  font-size: 14px;
  font-weight: 500;
  color: #c8c8d0;
}
.empty-sub {
  font-size: 11px;
  opacity: 0.75;
  max-width: 280px;
  line-height: 1.5;
}

/* Transport bar */
.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  background: rgba(10, 10, 12, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
  min-width: 0;
}
.play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 13px;
  box-shadow: 0 2px 14px var(--accent-glow);
  transition: filter var(--ease), transform var(--ease);
}
.play:hover {
  filter: brightness(1.08);
}
.play:active {
  transform: scale(0.96);
}
.t-label {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
  min-width: 118px;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.seek {
  flex: 1;
  min-width: 48px;
  height: 4px;
}
.transport-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Right inspector */
.right {
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.insp-title {
  padding: 13px 14px 10px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.insp-body {
  flex: 1;
  overflow: auto;
  padding: 12px 14px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
}
.sec {
  margin-bottom: 18px;
}
.sec h4 {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.field {
  margin-bottom: 12px;
}
.field > label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}
.field > label b {
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.field input[type="number"],
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  border: 1px solid var(--line2);
  transition: border-color var(--ease);
}
.field textarea {
  height: auto;
  min-height: 68px;
  padding: 8px 10px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: none;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}
.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--muted);
  transition: border-color var(--ease), color var(--ease), background var(--ease);
}
.chip:hover,
.chip.on {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent-soft);
}
.fx-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}
.fx-card {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color var(--ease), box-shadow var(--ease), color var(--ease);
}
.fx-card .swatch {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background: linear-gradient(135deg, #333, #111);
}
.fx-card span {
  position: relative;
  z-index: 1;
  padding: 0 4px;
  text-align: center;
}
.fx-card:hover {
  border-color: var(--line2);
  color: var(--text);
}
.fx-card.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  color: #fff;
}
.info {
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  word-break: break-all;
}
.info strong {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
}
.handle-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Bottom tool dock ── */
.dock {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  z-index: 20;
}
.dock::-webkit-scrollbar {
  display: none;
}
.dock-item {
  min-width: 68px;
  padding: 7px 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 5px 2px;
  transition: background var(--ease), color var(--ease);
  flex-shrink: 0;
}
.dock-item .di {
  font-size: 18px;
  line-height: 1;
  height: 22px;
  display: grid;
  place-items: center;
}
.dock-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.dock-item.on {
  color: var(--accent);
  background: var(--accent-soft);
}
.dock-item.on .di {
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* ── Multi-track timeline ── */
.timeline {
  background: var(--bg-deep);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 15;
}
.tl-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  min-height: 28px;
}
.tl-bar-title {
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #a0a0aa;
}
.tl-sel {
  margin-left: auto;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.tl-body {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
  -webkit-overflow-scrolling: touch;
}
.tl-tracks {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 100%;
  padding: 0 10px 0 0;
}
.tl-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 100%;
}
.tl-label {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: transparent;
  user-select: none;
}
.tl-lane-wrap {
  flex: 1;
  min-width: 0;
  overflow: visible;
}
.tl-lane {
  position: relative;
  height: 42px;
  width: 100%;
  min-width: 480px;
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: visible;
}
.tl-lane.audio {
  height: 28px;
  opacity: 0.92;
}
.tl-lane.fx {
  height: 24px;
  opacity: 0.75;
  background: #14141a;
}
.tl-clip {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  right: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, #c9183b 0%, var(--accent) 42%, #ff5c7a 100%);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: #fff;
  z-index: 1;
}
.tl-clip-grip {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.tl-clip-grip.left {
  left: 4px;
}
.tl-clip-grip.right {
  right: 4px;
}
.tl-clip.audio-clip {
  background: linear-gradient(90deg, #0e8f8a, var(--accent-2));
  top: 3px;
  bottom: 3px;
  font-weight: 500;
  font-size: 10px;
}
.tl-clip.fx-clip {
  background: linear-gradient(90deg, #5b4bdb, #8b7cf8);
  top: 3px;
  bottom: 3px;
  font-size: 10px;
}

/* In–out range + handles */
.tl-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(37, 244, 238, 0.1);
  border-left: 2px solid var(--accent-2);
  border-right: 2px solid var(--accent-2);
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 20px rgba(37, 244, 238, 0.06);
}
.tl-handle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 22px;
  border-radius: 3px;
  background: var(--accent-2);
  box-shadow: 0 0 8px rgba(37, 244, 238, 0.55);
  z-index: 3;
}
.tl-handle.in {
  left: -5px;
}
.tl-handle.out {
  right: -5px;
}
.tl-handle::after {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 2px;
  width: 1px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 3px 0 0 rgba(0, 0, 0, 0.35);
}

/* Playhead */
.tl-head {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.75);
  z-index: 5;
  pointer-events: none;
}
.tl-head::before {
  content: "";
  position: absolute;
  top: -5px;
  left: -5px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #fff;
}

/* Progress / toast */
#progress-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(var(--timeline) + var(--dock) + 18px);
  transform: translateX(-50%);
  width: min(440px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 100;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}
#progress-wrap.hidden {
  display: none;
}
.p-track {
  height: 6px;
  background: var(--bg-deep, #0a0a0e);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0;
  grid-column: 1;
}
#progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.12s linear;
  border-radius: 99px;
}
#progress-text {
  font-size: 12px;
  color: var(--muted);
  grid-column: 1;
}
#btn-cancel-job {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}
#toast-host {
  position: fixed;
  top: calc(var(--top) + 10px);
  right: 14px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 28px));
}
.toast {
  min-width: 180px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--line2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  font-size: 12px;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: pre-wrap;
  line-height: 1.45;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.ok {
  border-color: rgba(45, 223, 140, 0.4);
}
.toast.err {
  border-color: rgba(254, 44, 85, 0.5);
}

.hidden {
  display: none !important;
}

/* ── Mobile / tablet tolerant ── */
@media (max-width: 1100px) {
  :root {
    --left: 200px;
    --right: 260px;
  }
  .size-rail-hint {
    display: none;
  }
  .size-rail input {
    width: 56px;
  }
}

@media (max-width: 900px) {
  :root {
    --left: 0px;
    --right: 100%;
    --timeline: 148px;
    --dock: 56px;
  }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) minmax(170px, 36vh);
  }
  /* Media library becomes horizontal strip above preview */
  .left {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 108px;
    overflow: hidden;
  }
  .left .panel-hd {
    writing-mode: horizontal-tb;
    flex-direction: column;
    justify-content: center;
    padding: 8px 6px;
    border-right: 1px solid var(--line);
    flex-shrink: 0;
  }
  .left .panel-hd span {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.12em;
    margin-bottom: 6px;
  }
  .left .drop {
    display: none;
  }
  .left .media-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
    gap: 8px;
  }
  .left .m-card {
    grid-template-columns: 1fr;
    width: 92px;
    flex-shrink: 0;
    padding: 6px;
  }
  .left .m-thumb {
    width: 100%;
    height: 48px;
  }
  .left .m-sub {
    display: none;
  }
  .right {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .size-rail {
    margin-left: 0;
  }
  .top-mid {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .brand em {
    display: none;
  }
  .pill {
    max-width: 100px;
  }
  #engine-txt {
    max-width: 56px;
  }
  .transport {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px 10px;
  }
  .t-label {
    min-width: 0;
    order: 2;
    flex: 1;
  }
  .seek {
    order: 3;
    flex: 1 1 100%;
  }
  .transport-actions {
    order: 2;
  }
  .dock-item {
    min-width: 56px;
    padding: 6px 8px;
    font-size: 10px;
  }
  .tl-lane {
    min-width: 320px;
  }
  .tl-sel {
    max-width: 42%;
    font-size: 10px;
  }
  .fx-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 560px) {
  :root {
    --top: 48px;
    --timeline: 132px;
  }
  .topbar {
    padding: 0 8px;
    gap: 6px;
  }
  .btn-import span.btn-ico + * ,
  .btn#btn-import {
    font-size: 12px;
  }
  #btn-import-more,
  #btn-engine {
    display: none;
  }
  .size-rail {
    padding: 3px 8px;
    height: 30px;
  }
  .size-rail input {
    width: 48px;
    font-size: 11px;
  }
  .btn-accent {
    padding: 0 10px;
    height: 30px;
    font-size: 12px;
  }
  .transport-actions .btn {
    padding: 0 8px;
  }
  .tl-label {
    width: 28px;
    font-size: 9px;
  }
  .tl-lane {
    height: 34px;
  }
  .tl-lane.audio {
    height: 22px;
  }
  .tl-lane.fx {
    height: 18px;
  }
  .tl-handle {
    height: 18px;
    width: 7px;
  }
  .row {
    grid-template-columns: 1fr;
  }
}

/* Safe areas (notch / home indicator) */
@supports (padding: env(safe-area-inset-bottom)) {
  .timeline {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .topbar {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .dock {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
