/* ============ Light Video Editor — dark editor theme ============ */
:root {
  --bg: #14161a;
  --bg2: #1b1e24;
  --bg3: #23272f;
  --line: #2e333d;
  --fg: #e8eaf0;
  --dim: #9aa3b2;
  --accent: #4f8cff;
  --accent2: #35c98e;
  --danger: #ff5d5d;
  --radius: 10px;
  --dock-h: 0px;
  /* mobile tool-dock height — overridden in the mobile media query */
  --font: system-ui, "Segoe UI", "Noto Sans Myanmar", "Myanmar Text", "Pyidaungsu", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  /* content must never force horizontal overflow */
  overflow: hidden;
  overscroll-behavior: none;
}

button,
label.btn {
  touch-action: manipulation;
}

/* ---------------- topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.brand-logo {
  color: var(--accent);
  font-size: 20px;
}

.brand-name em {
  font-style: normal;
  color: var(--dim);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: background .15s, border-color .15s, opacity .15s;
  user-select: none;
}

.btn:hover:not(:disabled) {
  background: #2b303a;
  border-color: #3d4452;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #3d7bf0;
}

.btn-accent {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #06281c;
  font-weight: 700;
}

.btn-accent:hover {
  background: #2bb882;
}

.btn-danger {
  color: #ff8a8a;
}

.btn-danger:hover:not(:disabled) {
  background: #3a2426;
  border-color: #59383c;
}

.btn-small {
  padding: 5px 9px;
  font-size: 12.5px;
}

.btn-mini {
  padding: 2px 7px;
  font-size: 12px;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--fg);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
}

.icon-btn:hover {
  background: var(--bg3);
}

.icon-btn i {
  display: block;
  font-size: 17px;
}

.tab-btn i,
.menu-item i,
.item-title i,
.exp-title i,
summary i,
.dlg h3 i,
.ph-icon i,
.brand i {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 6px;
}

.tab-btn i {
  margin-right: 5px;
}

.ph-icon i {
  display: block;
  font-size: 42px;
}

kbd {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: 11px;
  font-family: inherit;
}

/* ---------------- layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

.panel {
  background: var(--bg2);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
  min-width: 0;
}

.stage {
  display: grid;
  grid-template-rows: 1fr auto auto;
  /* Constrain the implicit column: without this the timeline's scroll
     content sized the column past the container, pushing the preview,
     transport and timeline off the right edge of the screen. */
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  min-width: 0;
}

/* ---------------- tabs ---------------- */
.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 5;
}

.tab-btn {
  flex: 1;
  padding: 9px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--dim);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--fg);
}

.tab-btn.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

.tab {
  display: none;
  padding: 12px;
}

.tab.active {
  display: block;
}

/* ---------------- generic form ---------------- */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.row.end {
  justify-content: flex-end;
}

.space-between {
  justify-content: space-between;
}

.label {
  font-size: 12.5px;
  color: var(--dim);
}

.dim {
  color: var(--dim);
  font-weight: 400;
  font-size: 12px;
}

.hint {
  font-size: 12px;
  color: var(--dim);
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  margin: 6px 0;
  line-height: 1.6;
}

.hint.dim {
  background: none;
  border: none;
  padding: 4px 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  color: var(--dim);
  margin: 6px 0;
}

.field>span {
  display: flex;
  justify-content: space-between;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.span2 {
  grid-column: span 2;
}

.checks {
  flex-direction: row;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.checks label {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--fg);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: 30px;
  padding: 1px 2px;
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 6px;
}

input[type="number"],
input[type="text"],
select,
textarea {
  background: var(--bg3);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 1px solid var(--accent);
}

.num {
  width: 90px;
}

.field input[type="text"] {
  width: 100%;
}

.num.narrow {
  width: 70px;
}

output {
  font-size: 11.5px;
  color: var(--fg);
  text-align: right;
}

.box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px 8px;
  margin: 8px 0;
  background: #191c21;
}

.box summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 700;
  font-size: 13px;
}

.empty {
  color: var(--dim);
  font-size: 12.5px;
  text-align: center;
  padding: 14px 6px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin: 8px 0;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* list rows (segments, cues, tracks, overlays, fonts) */
.item {
  background: var(--bg3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.item.active {
  border-color: var(--accent2);
}

.item-head {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}

.item-title {
  font-size: 12.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  color: var(--dim);
  font-size: 12px;
}

.item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.item textarea {
  width: 100%;
  min-height: 44px;
  resize: vertical;
  line-height: 1.6;
}

.time-inputs {
  display: flex;
  gap: 5px;
  align-items: center;
}

.time-inputs input {
  width: 104px;
  font-size: 12px;
  padding: 4px 6px;
}

.time-inputs .arrow {
  color: var(--dim);
}

/* ---------------- viewport ---------------- */
.viewport {
  position: relative;
  background:
    radial-gradient(1200px 500px at 50% -10%, #1d2433 0%, transparent 60%),
    #0b0c0f;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.vp-box {
  position: relative;
  background: #000;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .5);
  border-radius: 4px;
  overflow: hidden;
}

.vp-box video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.vp-box .vp-video {
  object-fit: contain;
  display: none;
  /* source elements stay hidden until the active clip is shown */
}

.vp-box canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}

.placeholder.hidden {
  display: none;
}

.ph-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  border: 2px dashed var(--line);
  padding: 36px 48px;
  border-radius: 16px;
}

.ph-icon {
  font-size: 42px;
}

/* ---------------- transport ---------------- */
.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  min-width: 0;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  min-width: 130px;
}

.seek {
  flex: 1;
  min-width: 60px;
}

/* ---------------- timeline ---------------- */
.timeline {
  position: relative;
  background: #101216;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  user-select: none;
  max-height: min(45vh, 340px);
}

.tl-tools {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
}

.tl-zoom-label {
  min-width: 52px;
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.tl-scroll {
  overflow: auto;
  padding: 4px 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: #333a46 transparent;
}

.tl-inner {
  position: relative;
  min-width: 100%;
}

.tl-ruler {
  position: relative;
  height: 22px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.tl-tick {
  position: absolute;
  top: 0;
  height: 100%;
  border-left: 1px solid var(--line);
  padding-left: 4px;
  font-size: 10.5px;
  color: var(--dim);
  pointer-events: none;
}

.tl-lane {
  position: relative;
  height: 34px;
  /* = 6px padding + one ROW_H(28) row — matches timeline-ui.js */
  margin-top: 4px;
  background: var(--bg3);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
}

.tl-lane.lane-overlay,
.tl-lane.lane-audio {
  height: auto;
  min-height: 34px;
}

.tl-sub-lane {
  position: relative;
  height: 12px;
  margin-top: 4px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}

.seg {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(#3b6fd4, #2f5cb5);
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-size: 10.5px;
  color: #dbe7ff;
  overflow: hidden;
  white-space: nowrap;
  cursor: grab;
}

.seg.at-playhead {
  background: linear-gradient(#5b8df0, #3f6fd8);
}

.seg.dragging {
  cursor: grabbing;
  box-shadow: 0 0 0 2px #fff;
  z-index: 5;
  opacity: .92;
}

.seg .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: ew-resize;
  background: rgba(0, 0, 0, .25);
  z-index: 2;
}

.seg .handle.l {
  left: 0;
  border-radius: 4px 0 0 4px;
}

.seg .handle.r {
  right: 0;
  border-radius: 0 4px 4px 0;
}

.seg .seg-label {
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.drop-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ffd166;
  z-index: 6;
  pointer-events: none;
}

.drop-line.horizontal {
  left: 0;
  right: 0;
  width: auto;
  height: 2px;
}

.bar {
  position: absolute;
  border-radius: 5px;
  background: #8a5cf6;
  font-size: 10.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px;
  overflow: hidden;
  white-space: nowrap;
  cursor: grab;
}

.bar.audio {
  background: #d99a2b;
}

.bar.selected {
  outline: 2px solid #fff;
  z-index: 3;
}

.bar.dragging {
  cursor: grabbing;
  opacity: .9;
  box-shadow: 0 0 0 2px #fff;
}

.bar .grip {
  flex: none;
  cursor: grab;
  font-size: 11px;
  letter-spacing: -2px;
  opacity: .8;
  user-select: none;
}

.bar .grip i {
  display: block;
  font-size: 13px;
  letter-spacing: 0;
  pointer-events: none;
}

.bar .handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: ew-resize;
}

.bar .handle.l {
  left: 0;
}

.bar .handle.r {
  right: 0;
}

.bar .bar-label {
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.sub-cue {
  position: absolute;
  top: 1px;
  bottom: 1px;
  background: var(--accent2);
  border-radius: 3px;
  min-width: 2px;
}

.sub-cue.active {
  background: #7dffd0;
}

.tl-playhead {
  position: absolute;
  top: 4px;
  bottom: 6px;
  width: 0;
  border-left: 2px solid #ff5d5d;
  pointer-events: none;
  z-index: 4;
}

.tl-playhead::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -6px;
  border: 6px solid transparent;
  border-top-color: #ff5d5d;
}

/* ---------------- overlay props ---------------- */
.props {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 10px;
  background: #191c21;
}

/* ---------------- export dialog ---------------- */
dialog {
  background: var(--bg2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(430px, 92vw);
  max-height: 90vh;
  overflow: auto;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
}

.dlg {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dlg h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.exp-card {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  width: 300px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exp-title {
  font-weight: 700;
  font-size: 13px;
}

.exp-bar {
  height: 10px;
  background: var(--bg3);
  border-radius: 6px;
  overflow: hidden;
}

#expBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .3s;
}

.exp-meta {
  font-size: 12px;
  color: var(--dim);
}

/* ---------------- viewport export overlay ---------------- */
.vp-export {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 16, .72);
  backdrop-filter: blur(3px);
}

.vp-export[hidden] {
  display: none;
}

.vpe-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  color: var(--fg);
}

.vpe-icon {
  font-size: 44px;
  line-height: 1;
  color: var(--accent2);
  animation: vpe-spin 1.4s linear infinite;
}

.vpe-icon i {
  display: block;
  font-size: 44px;
}

@keyframes vpe-spin {
  to {
    transform: rotate(360deg);
  }
}

.vpe-title {
  font-weight: 700;
  font-size: 15px;
}

.vpe-bar {
  width: min(340px, 70vw);
  height: 11px;
}

.vpe-meta {
  font-size: 12px;
  color: var(--dim);
}

.vpe-inner .btn-danger {
  color: #fff;
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #232833;
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  max-width: 80vw;
}

.toast.error {
  border-color: var(--danger);
}

.toast a {
  color: var(--accent);
}

/* ---------------- exporting lock ---------------- */
body.exporting .panel,
body.exporting .transport,
body.exporting .timeline,
body.exporting .topbar {
  pointer-events: none;
  opacity: .75;
}

body.exporting #exportBtn {
  display: none;
}

/* ---------------- project name + menu ---------------- */
button.proj-name {
  background: none;
  font-family: inherit;
  cursor: pointer;
}

button.proj-name:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--bg3);
}

.proj-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-size: 13px;
  text-align: left;
  padding: 7px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: default;
}

.menu-wrap {
  position: relative;
}

.menu-btn {
  font-size: 17px;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  max-width: 85vw;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
  padding: 6px;
  z-index: 90;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.menu-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 10px 2px;
}

.menu-sep {
  height: 1px;
  background: var(--line);
  margin: 5px 6px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  margin: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.menu-item:hover {
  background: rgba(255, 255, 255, .07);
}

.menu-item:disabled {
  color: var(--dim);
  opacity: .5;
  cursor: default;
  pointer-events: none;
}

.menu-item i {
  font-size: 16px;
  color: var(--accent);
  width: 18px;
  text-align: center;
}

.menu-item:first-child {
  border-radius: 0;
}

/* dialogs with lists get a max width so rows don't feel cramped */
#openDialog .dlg,
#helpDialog .dlg,
#aboutDialog .dlg {
  min-width: min(92vw, 420px);
}

#openList {
  max-height: 55vh;
  overflow: auto;
  margin: 8px 0;
}

.save-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
}

.save-row:hover {
  border-color: var(--accent);
}

.save-row .sv-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  color: var(--text);
}

.save-row .sv-main:hover {
  opacity: .85;
}

.save-row .btn-mini {
  margin-left: auto;
}

.save-row .sv-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-row .sv-meta {
  color: var(--dim);
  font-size: 12px;
  margin-top: 2px;
}

.help ul,
.help ol {
  margin: 4px 0 8px;
  padding-left: 20px;
  color: var(--text);
}

.help li {
  margin: 3px 0;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #333a46;
  border-radius: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================================
   Native-editor polish (all sizes)
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-label {
  display: inline;
}

#expName {
  width: 100%;
}

.transport #playBtn {
  font-size: 20px;
  padding: 6px 12px;
}

/* depth on timeline clips — reads like a real NLE track */
.seg {
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16);
}

.bar {
  border: 1px solid rgba(255, 255, 255, .14);
}

/* drag surfaces must not scroll/zoom the page mid-drag (touch) */
.tl-ruler,
.tl-lane,
.tl-sub-lane,
.seg,
.bar,
#canvas {
  touch-action: none;
}

.tl-scroll {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* mobile-only elements */
.sheet-handle,
.vp-play {
  display: none;
}

dialog[open] {
  animation: dlg-in .16s ease-out;
}

@keyframes dlg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.985);
  }
}

.toast {
  animation: toast-in .22s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ============================================================
   Mobile / touch layout — bottom-sheet tools (CapCut-style)
   <=860px: stage fills the screen, tools become a slide-up sheet
   whose collapsed strip (handle + tab bar) is a fixed bottom dock.
   ============================================================ */
@media (max-width: 860px) {
  :root {
    --dock-h: 70px;
  }

  /* 16px handle + 54px tab bar */

  /* ---- topbar: compact, icon-first ---- */
  .topbar {
    padding: 6px 8px calc(6px + env(safe-area-inset-top, 0px));
    gap: 6px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .brand {
    gap: 5px;
  }

  .brand-logo {
    font-size: 18px;
  }

  .brand-name {
    font-size: 13px;
  }

  .brand-name em {
    display: none;
  }

  .topbar .btn {
    padding: 9px 10px;
    min-height: 42px;
    font-size: 15px;
  }

  .btn-label:not(.keep-mobile) {
    display: none;
  }

  #addVideoBtn {
    padding: 9px;
  }

  /* ---- layout: full-width stage; panel leaves the flow ---- */
  .layout {
    display: flex;
    flex-direction: column;
  }

  .stage {
    flex: 1;
    min-height: 0;
    min-width: 0;
    padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
  }

  /* ---- tools = slide-up bottom sheet ---- */
  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    height: min(52vh, 440px);
    height: min(52dvh, 440px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -14px 40px rgba(0, 0, 0, .55);
    transform: translateY(calc(100% - var(--dock-h)));
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    z-index: 40;
  }

  .panel.open {
    transform: translateY(0);
  }

  .sheet-handle {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 16px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
  }

  .sheet-handle span {
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: #4b5261;
  }

  .tabs {
    position: static;
    flex: none;
    height: 54px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 8px 2px;
    font-size: 11.5px;
  }

  .tab {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- transport: touch-sized ---- */
  .transport {
    padding: 6px 8px;
    gap: 6px;
  }

  .time {
    min-width: 0;
    font-size: 12.5px;
  }

  .seek {
    min-height: 32px;
  }

  .icon-btn {
    padding: 7px 9px;
    font-size: 18px;
  }

  .btn:not(.btn-mini) {
    min-height: 40px;
  }

  .btn-mini {
    padding: 5px 9px;
    min-height: 30px;
  }

  /* ---- timeline: chunkier lanes, bigger trim handles ---- */
  .timeline {
    max-height: min(42vh, 320px);
  }

  .tl-tools {
    padding: 4px 8px;
    gap: 4px;
  }

  .tl-tools .icon-btn,
  .tl-tools .tl-zoom-label {
    min-height: 34px;
  }

  .tl-ruler {
    height: 26px;
  }

  .tl-sub-lane {
    height: 14px;
  }

  .seg {
    font-size: 11px;
  }

  .seg .handle,
  .bar .handle {
    width: 13px;
  }

  .bar .grip {
    padding: 0 7px;
    font-size: 12px;
  }

  /* ---- preview play control — only while the sheet covers transport ---- */
  .vp-play {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(14, 16, 22, .6);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
    font-size: 17px;
    padding: 0;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 6;
  }

  .vp-play i {
    font-size: 20px;
    display: flex;
  }

  .panel.open~.stage .placeholder.hidden~.vp-play {
    display: flex;
  }

  /* ---- misc mobile ---- */
  .hint.dim {
    display: none;
  }

  /* keyboard shortcuts — no keyboard on touch */
  .ph-inner {
    padding: 22px 26px;
  }

  .ph-icon {
    font-size: 34px;
  }

  .ph-icon i {
    font-size: 34px;
  }

  .toast {
    bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + 12px);
  }

  .exp-card {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + 10px);
  }

  .dlg {
    padding: 14px;
  }

  /* iOS zooms the page when a focused text input is <16px */
  input[type="number"],
  input[type="text"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* ---- very narrow phones: give the scrubber room ---- */
@media (max-width: 640px) {

  #backBtn,
  #fwdBtn {
    display: none;
  }
}

/* ---- phone landscape: every vertical pixel counts ---- */
@media (max-width: 860px) and (max-height: 500px) {
  :root {
    --dock-h: 58px;
  }

  /* 12px handle + 46px tab bar */
  .sheet-handle {
    height: 12px;
  }

  .tabs {
    height: 46px;
  }

  .tab-btn {
    padding: 6px 2px;
    font-size: 11px;
  }

  .topbar .btn {
    min-height: 36px;
    padding: 6px 9px;
    font-size: 15px;
  }

  .transport {
    padding: 4px 8px;
  }

  .timeline {
    max-height: min(42vh, 160px);
  }

  .panel {
    height: min(76vh, 320px);
  }
}