/* Video merge workspace (owner 16.11, views/merge.js): site greens for go, a softer green for picks (owner 17.11: the blue looked rough), soft grey chips */
:root { --mg-green: #16a34a; --mg-pick: #34b26c; }
html[data-theme="dark"] { --mg-pick: #3ccf7a; }
.mg-wrap { --mg-chip: var(--cmp-chip, #eef0f3); --mg-r: 18px;
  display: grid; gap: 16px; padding-bottom: 32px; }
.mg-headbar { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; row-gap: 2px; }
.mg-crumb { grid-row: span 2; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 12px; background: var(--mg-chip);
  color: var(--text); font-weight: 700; font-size: 13.5px; text-decoration: none; }
.mg-crumb .ico { width: 15px; height: 15px; transform: rotate(180deg); }
.mg-brand { display: flex; align-items: center; gap: 8px; }
.mg-brand .tl-wm { height: 22px; width: auto; }
.mg-brand .tl-wm.wd, html[data-theme="dark"] .mg-brand .tl-wm.wl { display: none; }
html[data-theme="dark"] .mg-brand .tl-wm.wd { display: block; }
.mg-brand .tl-tag { font: 800 11px/1 Manrope, system-ui, sans-serif; letter-spacing: .08em; color: #16a34a; border: 1.5px solid #16a34a; padding: 3px 6px; border-radius: 6px; }
html[data-theme="dark"] .mg-brand .tl-tag { color: #3ccf7a; border-color: #3ccf7a; }
.mg-headbar h1.mg-brand { grid-column: 2; margin: 0; font-size: 0; gap: 10px; }
.mg-headbar h1.mg-brand .tl-wm { height: 30px; }
.mg-headbar h1.mg-brand .tl-tag { font-size: 13px; padding: 4px 8px; border-radius: 7px; }
.mg-headbar p { grid-column: 2; margin: 0; }
.mg-headbar .mg-brand { grid-column: 2; }
.mg-headbar { grid-template-columns: auto 1fr auto; }
.mg-tut { grid-column: 3; grid-row: 1 / span 2; align-self: center; height: 40px; padding-right: 14px; font-size: 13.5px; }
.mg-tut b { font-weight: 800; }
.mg-tut span { opacity: .75; }
@media (max-width: 640px) { .mg-headbar { grid-template-columns: 1fr; } .mg-crumb { grid-row: auto; justify-self: start; } .mg-headbar > * { grid-column: 1 !important; } .mg-tut { grid-row: auto; justify-self: start; } }
.mg-page { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.mg-main { display: grid; gap: 14px; min-width: 0; }
.mg-page.drop-on::after { content: attr(data-drop); position: absolute; inset: -6px; z-index: 20; display: grid; place-items: center;
  border: 2.5px dashed var(--mg-pick); border-radius: 22px; background: color-mix(in srgb, var(--mg-pick) 10%, transparent);
  font-size: 22px; font-weight: 700; color: var(--mg-pick); backdrop-filter: blur(2px); pointer-events: none; animation: mg-in .15s ease-out; }

/* ---------- stage: empty state / player ---------- */
.mg-stage { min-width: 0; }
.mg-empty { display: grid; justify-items: center; gap: 12px; padding: 40px 20px 34px; text-align: center; border-radius: 24px;
  border: 2px dashed var(--line-strong, #d1d5db); background: color-mix(in srgb, var(--mg-pick) 4%, var(--panel, #fff)); }
.mg-empty h2 { margin: 6px 0 0; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.01em; }
.mg-empty p { margin: 0; max-width: 520px; }
.mg-empty-a { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.mg-empty-a .btn { min-width: 170px; justify-content: center; }
/* three clip cards slide together, a spark at each seam */
.mg-anim { position: relative; width: 300px; max-width: 80vw; height: 110px; }
.mg-anim i { position: absolute; top: 18px; width: 96px; height: 70px; border-radius: 12px; box-shadow: 0 10px 24px -12px rgba(0,0,0,.35);
  animation: mg-join 3.6s cubic-bezier(.6,0,.2,1) infinite; }
.mg-anim .c1 { left: 0; background: #3b82f6; --dx: 52px; --r: -6deg; }
.mg-anim .c2 { left: calc(50% - 48px); background: #16a34a; --dx: 0px; --r: 3deg; z-index: 2; }
.mg-anim .c3 { right: 0; background: #f59e0b; --dx: -52px; --r: 7deg; }
.mg-anim .fx { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 4px var(--mg-green), 0 0 24px 8px color-mix(in srgb, var(--mg-green) 60%, transparent); opacity: 0;
  animation: mg-spark 3.6s ease-out infinite; z-index: 3; }
@keyframes mg-join { 0%, 12% { transform: translateX(0) rotate(var(--r)); } 45%, 70% { transform: translateX(var(--dx)) rotate(0); } 100% { transform: translateX(0) rotate(var(--r)); } }
@keyframes mg-spark { 0%, 40% { opacity: 0; transform: scale(.2); } 48% { opacity: 1; transform: scale(1.4); } 62%, 100% { opacity: 0; transform: scale(2.4); } }

.mg-player { display: grid; gap: 10px; }
.mg-frame-wrap { display: grid; place-items: center; padding: 12px; border-radius: 24px; background: #12151b; min-height: 240px; }
.mg-frame { position: relative; overflow: hidden; border-radius: 12px; background: #000; cursor: pointer; aspect-ratio: 16 / 9;
  width: min(100%, calc(min(46vh, 500px) * 16 / 9)); transition: aspect-ratio .25s cubic-bezier(.2,.8,.2,1), width .25s; box-shadow: 0 20px 50px -24px #000; }
.mg-frame[data-aspect="9:16"] { aspect-ratio: 9 / 16; width: auto; height: min(46vh, 500px); }
.mg-frame[data-aspect="1:1"] { aspect-ratio: 1; width: auto; height: min(46vh, 480px); }
.mg-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; will-change: transform, opacity; }
.mg-frame[data-fit="crop"] .mg-layer { object-fit: cover; }
.mg-backdrop { position: absolute; inset: -40px; background: center / cover no-repeat; filter: blur(26px) brightness(.85); transition: background-image .3s; }
.mg-frame[data-fit="crop"] .mg-backdrop { display: none; }
.mg-veil { position: absolute; inset: 0; z-index: 5; opacity: 0; pointer-events: none; }
.mg-ctrl { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 16px; background: var(--mg-chip); }
.mg-play { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--mg-green); color: #fff; box-shadow: 0 6px 16px -8px var(--mg-green); transition: transform .12s; }
.mg-play:hover { transform: scale(1.06); }
.mg-play .ico { width: 18px; height: 18px; }
.mg-time { flex: none; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 86px; text-align: right; }
.mg-bar { --p: 0%; position: relative; flex: 1; height: 26px; }
.mg-bar i { position: absolute; top: 7px; height: 12px; border-radius: 6px; cursor: pointer;
  background: color-mix(in srgb, var(--mg-pick) 16%, var(--panel, #fff)); border: 1.5px solid var(--panel, #fff); transition: background .15s; }
.mg-bar i:nth-child(even) { background: color-mix(in srgb, var(--mg-pick) 30%, var(--panel, #fff)); }
.mg-bar i:hover { background: color-mix(in srgb, var(--mg-pick) 45%, var(--panel, #fff)); }
.mg-head { position: absolute; top: 2px; left: var(--p); width: 0; height: 22px; pointer-events: none; }

/* ---------- strip ---------- */
.mg-strip-wrap { display: grid; gap: 8px; padding: 12px 12px 6px; border-radius: 22px; background: var(--panel, #fff); border: 1px solid var(--line, #e5e7eb); }
.mg-strip-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 0 4px; }
.mg-strip { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 8px 8px 14px; scroll-padding-inline: 8px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.mg-card { position: relative; flex: none; width: 150px; display: grid; gap: 6px; padding: 6px; border-radius: 16px; scroll-snap-align: start;
  background: var(--mg-chip); cursor: grab; touch-action: pan-x; user-select: none; outline: none;
  transition: box-shadow .15s, background .15s, opacity .15s; }
.mg-card:hover { background: color-mix(in srgb, var(--mg-pick) 8%, var(--mg-chip)); }
.mg-card:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mg-pick) 45%, transparent); }
.mg-card.playing { box-shadow: 0 0 0 2.5px var(--mg-green); }
.mg-card.fresh { animation: mg-pop .35s cubic-bezier(.2,1.4,.4,1); }
.mg-card.is-src { opacity: .25; }
.mg-card.loading .mg-thumb { background: var(--line); animation: mg-pulse 1.1s ease-in-out infinite; }
.mg-thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 11px; background: #1b1f27 center / cover no-repeat; overflow: hidden; }
.mg-num { position: absolute; left: 6px; top: 6px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center;
  border-radius: 999px; background: rgba(0,0,0,.62); color: #fff; font-size: 12px; font-weight: 700; }
.mg-len { position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,.62); color: #fff; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.mg-del { position: absolute; right: 5px; top: 5px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s, background .15s; }
.mg-del .ico { width: 14px; height: 14px; }
.mg-del:hover { background: #dc2626; }
.mg-card:hover .mg-del, .mg-card:focus-within .mg-del { opacity: 1; }
@media (hover: none) { .mg-del { opacity: 1; } }
.mg-grip { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); color: rgba(255,255,255,.8); font-size: 11px; letter-spacing: -2px; text-shadow: 0 1px 2px #000; }
.mg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--muted); padding: 0 4px; }
.mg-spin { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; animation: mg-rot .8s linear infinite; }
.mg-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: rotate(-3deg) scale(1.05); box-shadow: 0 24px 40px -16px rgba(0,0,0,.45);
  background: var(--panel, #fff); border-radius: 16px; padding: 6px; display: grid; gap: 6px; opacity: .96; }
/* the transition chip sits ON the seam */
.mg-seam { flex: none; position: relative; z-index: 2; display: grid; place-items: center; width: 34px; height: 34px; margin: 0 -6px; padding: 0;
  border: 2px solid var(--panel, #fff); border-radius: 50%; cursor: pointer; background: var(--mg-pick); color: #fff;
  font-size: 15px; line-height: 1; box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--mg-pick) 70%, transparent); transition: transform .15s, background .15s; }
.mg-seam::before { content: ""; position: absolute; inset: -6px; }        /* 46px hit area */
.mg-seam:hover { transform: scale(1.12); }
.mg-seam.t-cut { background: var(--panel, #fff); color: var(--muted); border-color: var(--line-strong, #d1d5db); box-shadow: none; }
.mg-add { flex: none; display: grid; place-items: center; align-content: center; gap: 4px; width: 118px; height: 118px; margin-left: 12px; padding: 0;
  border: 2px dashed var(--line-strong, #d1d5db); border-radius: 16px; background: none; color: var(--muted); cursor: pointer; font: inherit; transition: border-color .15s, color .15s, background .15s; }
.mg-add + .mg-add { margin-left: 8px; }
.mg-add:hover { border-color: var(--mg-pick); color: var(--mg-pick); background: color-mix(in srgb, var(--mg-pick) 6%, transparent); }
.mg-add .ico { width: 22px; height: 22px; }
.mg-add b { font-size: 13px; }
.mg-add small { font-size: 11.5px; }

/* ---------- side panel ---------- */
.mg-side { position: sticky; top: 76px; display: grid; gap: 12px; }
.mg-box { display: grid; gap: 8px; padding: 14px; border-radius: var(--mg-r); background: var(--panel, #fff); border: 1px solid var(--line, #e5e7eb); }
.mg-box h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mg-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--mg-chip); }
.mg-seg button { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border: 0; border-radius: 10px; background: none; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; transition: background .15s, color .15s, box-shadow .15s; }
.mg-seg button.on { background: var(--panel, #fff); color: var(--text); box-shadow: 0 2px 8px -4px rgba(0,0,0,.25); }
.mg-shape { display: block; border: 2px solid currentColor; border-radius: 4px; }
.mg-shape.s-16x9 { width: 28px; height: 16px; } .mg-shape.s-9x16 { width: 13px; height: 22px; } .mg-shape.s-1x1 { width: 19px; height: 19px; }
.mg-seg button.on .mg-shape { border-color: var(--mg-pick); background: color-mix(in srgb, var(--mg-pick) 14%, transparent); }
.mg-hint { margin: 0; font-size: 12.5px; line-height: 1.45; }
.mg-sum { display: flex; flex-wrap: wrap; gap: 6px; }
.mg-sum span { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: var(--mg-chip); font-size: 12.5px; font-weight: 600; }
.mg-sum .ico { width: 14px; height: 14px; color: var(--muted); }
.neg { color: #dc2626 !important; }
.mg-go, .mg-up { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 52px; font-size: 16px; border-radius: 16px; }
.mg-go em, .mg-up em { font-style: normal; font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.22); }
.mg-go:not(:disabled) { animation: mg-glow 2.6s ease-in-out infinite; }
.mg-up { background: var(--mg-pick); border-color: var(--mg-pick); color: #fff; height: 46px; font-size: 15px; }
.mg-up:hover { filter: brightness(1.06); }
/* processing */
.mg-busy { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; padding: 14px; border-radius: var(--mg-r);
  background: var(--panel, #fff); border: 1.5px solid color-mix(in srgb, var(--mg-green) 45%, transparent); }
.mg-busy > div:nth-child(2) { display: grid; gap: 2px; }
.mg-ring { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; position: relative;
  border: 5px solid var(--mg-chip); border-top-color: var(--mg-green); animation: mg-rot 1s linear infinite; }
.mg-ring b { animation: mg-rot 1s linear infinite reverse; }
.mg-ring b { position: relative; font-size: 14px; font-variant-numeric: tabular-nums; }
.mg-steps { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mg-steps i { height: 5px; border-radius: 3px; background: var(--mg-chip); }
.mg-steps i.ok { background: var(--mg-green); }
.mg-steps i.on { background: var(--mg-green); animation: mg-pulse 1s ease-in-out infinite; }
/* result */
.mg-done { display: grid; gap: 10px; padding: 14px; border-radius: var(--mg-r); background: var(--panel, #fff);
  border: 1.5px solid var(--mg-green); animation: mg-in .35s cubic-bezier(.2,1.2,.4,1); }
.mg-done-h { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.mg-done-h small { grid-column: 2; }
.mg-check { grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--mg-green); color: #fff;
  animation: mg-popc .5s cubic-bezier(.2,1.6,.4,1); }
.mg-out { width: 100%; max-height: 260px; border-radius: 12px; background: #000; }
.mg-done-a { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mg-done-a .btn { justify-content: center; }

/* ---------- transition popover ---------- */
.mg-pop { position: fixed; z-index: 900; display: grid; gap: 12px; padding: 14px; border-radius: 20px; background: var(--panel, #fff);
  border: 1px solid var(--line, #e5e7eb); box-shadow: 0 30px 60px -20px rgba(0,0,0,.35); animation: mg-in .18s ease-out; }
.mg-pop.mg-sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: auto !important; border-radius: 22px 22px 0 0;
  padding-bottom: max(14px, env(safe-area-inset-bottom)); max-height: 78dvh; overflow-y: auto; animation: mg-up .22s cubic-bezier(.2,.9,.3,1); }
.mg-pop-h, .mg-dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mg-x { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 10px; background: var(--mg-chip, #eef0f3); color: inherit; cursor: pointer; }
.mg-trs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mg-tr { position: relative; display: grid; gap: 5px; padding: 5px 5px 7px; border: 1.5px solid transparent; border-radius: 14px;
  background: var(--mg-chip, #eef0f3); color: inherit; cursor: pointer; font: inherit; text-align: center; transition: border-color .15s, transform .12s; }
.mg-tr:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--mg-pick) 40%, transparent); }
.mg-tr.on { border-color: var(--mg-pick); background: color-mix(in srgb, var(--mg-pick) 10%, var(--panel, #fff)); }
.mg-tr b { font-size: 12px; font-weight: 600; }
.mg-tr small { position: absolute; top: 8px; right: 8px; padding: 1px 6px; border-radius: 999px; background: #16a34a; color: #fff; font-size: 10px; font-weight: 700; }
.mg-tr.is-soon { opacity: .75; cursor: not-allowed; }
.mg-pop-f { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mg-dur { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 200px; font-size: 13px; font-weight: 600; }
.mg-dur input { flex: 1; accent-color: var(--mg-pick); }
.mg-dur output { min-width: 40px; font-variant-numeric: tabular-nums; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; }
/* mini looping preview of each transition on the two real neighbour frames */
.mg-mini { position: relative; display: block; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #111; }
.mg-mini i { position: absolute; inset: 0; background: #334 center / cover no-repeat; }
.mg-mini .ma { background-color: #3b82f6; } .mg-mini .mb { background-color: #f59e0b; }
.mg-mini .mv { opacity: 0; }
.mg-mini em { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; filter: drop-shadow(0 0 8px #a855f7); }
.mg-mini .mb, .mg-mini .ma { animation-duration: 2.4s; animation-iteration-count: infinite; animation-timing-function: cubic-bezier(.45,0,.2,1); }
.mg-tr:not(:hover):not(.on) .mg-mini i { animation-play-state: paused; }
.t-fade .mb { animation-name: k-fade; } .t-dissolve .mb { animation-name: k-diss; }
.t-black .mb, .t-white .mb { animation-name: k-mid; } .t-black .mv { background: #000; animation: k-veil 2.4s infinite; } .t-white .mv { background: #fff; animation: k-veil 2.4s infinite; }
.t-slide .ma { animation-name: k-slA; } .t-slide .mb { animation-name: k-slB; }
.t-smooth .ma { animation-name: k-smA; } .t-smooth .mb { animation-name: k-smB; }
.t-zoom .ma { animation-name: k-zmA; } .t-zoom .mb { animation-name: k-fade; }
.t-circle .mb { animation-name: k-circ; } .t-wipe .mb { animation-name: k-wipe; }
.t-blur .ma { animation-name: k-blA; } .t-blur .mb { animation-name: k-blB; }
.t-cut .mb { animation-name: k-cut; } .t-ai .mb { animation-name: k-ai; }
@keyframes k-fade { 0%, 25% { opacity: 0; } 60%, 100% { opacity: 1; } }
@keyframes k-diss { 0%, 25% { opacity: 0; filter: contrast(1.8) saturate(0); } 60%, 100% { opacity: 1; filter: none; } }
@keyframes k-mid { 0%, 44% { opacity: 0; } 45%, 100% { opacity: 1; } }
@keyframes k-veil { 0%, 20% { opacity: 0; } 45% { opacity: 1; } 70%, 100% { opacity: 0; } }
@keyframes k-slA { 0%, 25% { transform: translateX(0); } 60%, 100% { transform: translateX(-100%); } }
@keyframes k-slB { 0%, 25% { transform: translateX(100%); } 60%, 100% { transform: translateX(0); } }
@keyframes k-smA { 0%, 25% { transform: translateX(0); filter: blur(0); opacity: 1; } 60%, 100% { transform: translateX(-50%); filter: blur(4px); opacity: 0; } }
@keyframes k-smB { 0%, 25% { transform: translateX(50%); filter: blur(4px); opacity: 0; } 60%, 100% { transform: translateX(0); filter: blur(0); opacity: 1; } }
@keyframes k-zmA { 0%, 25% { transform: scale(1); } 60%, 100% { transform: scale(1.8); } }
@keyframes k-circ { 0%, 25% { clip-path: circle(0% at 50% 50%); } 60%, 100% { clip-path: circle(75% at 50% 50%); } }
@keyframes k-wipe { 0%, 25% { clip-path: inset(0 100% 0 0); } 60%, 100% { clip-path: inset(0 0 0 0); } }
@keyframes k-blA { 0%, 25% { filter: blur(0); } 60%, 100% { filter: blur(8px); } }
@keyframes k-blB { 0%, 25% { opacity: 0; filter: blur(8px); } 60%, 100% { opacity: 1; filter: blur(0); } }
@keyframes k-cut { 0%, 49% { opacity: 0; } 50%, 100% { opacity: 1; } }
@keyframes k-ai { 0%, 20% { opacity: 0; filter: hue-rotate(0) blur(6px); } 60%, 100% { opacity: 1; filter: hue-rotate(0) blur(0); } }

/* ---------- dialogs (gallery picker, upscale confirm) ---------- */
.mg-dlg { width: min(560px, calc(100vw - 24px)); max-height: 86dvh; padding: 18px; border: 0; border-radius: 22px; background: var(--panel, #fff); color: var(--text);
  box-shadow: 0 40px 80px -24px rgba(0,0,0,.45); overflow: auto; }
.mg-dlg[open] { animation: mg-in .2s ease-out; display: grid; gap: 12px; }
.mg-dlg::backdrop { background: rgba(10,12,16,.5); backdrop-filter: blur(3px); }
.mg-dlg h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; }
.mg-dlg p { margin: 0; }
.mg-dlg-f { display: flex; justify-content: flex-end; gap: 8px; }
.mg-dlg-lib { width: min(820px, calc(100vw - 24px)); }
.mg-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 56dvh; overflow-y: auto; padding: 2px; }
.mg-lib-i { position: relative; display: grid; gap: 4px; padding: 5px; border: 2px solid transparent; border-radius: 14px; background: var(--cmp-chip, #eef0f3); cursor: pointer; font: inherit; color: inherit; }
.mg-lib-i video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; background: #111; pointer-events: none; }
.mg-lib-i small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-lib-i.on { border-color: #16a34a; }
.mg-lib-n { position: absolute; top: 10px; left: 10px; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.mg-lib-i.on .mg-lib-n { background: #16a34a; animation: mg-popc .3s cubic-bezier(.2,1.6,.4,1); }
.mg-lib-empty { grid-column: 1 / -1; padding: 30px; text-align: center; }
.mg-up-file { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; padding: 8px; border-radius: 14px; background: var(--cmp-chip, #eef0f3); }
.mg-up-file video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; background: #000; }
.mg-up-file > div { display: grid; gap: 2px; }
.mg-tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mg-tier { display: grid; gap: 2px; justify-items: center; padding: 10px 6px; border: 1.5px solid var(--line-strong, #d1d5db); border-radius: 14px; background: var(--panel, #fff); color: inherit; cursor: pointer; font: inherit; }
.mg-tier b { font-size: 17px; }
.mg-tier span { font-size: 12.5px; color: var(--muted); }
.mg-tier.on { border-color: var(--mg-pick); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mg-pick) 20%, transparent); }
.mg-warn { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  background: color-mix(in srgb, var(--mg-pick) 8%, transparent); border: 1px solid color-mix(in srgb, var(--mg-pick) 22%, transparent); }
.mg-warn .ico { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--mg-pick); }
.mg-bal { font-size: 13.5px; color: var(--muted); }
.mg-bal b { color: var(--text); }
.mg-up-go { background: var(--mg-pick); border-color: var(--mg-pick); color: #fff; }
.mg-up-go.busy { opacity: .7; pointer-events: none; }

@keyframes mg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mg-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes mg-pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mg-popc { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes mg-rot { to { transform: rotate(360deg); } }
@keyframes mg-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes mg-glow { 0%, 100% { box-shadow: 0 8px 20px -10px #16a34a; } 50% { box-shadow: 0 10px 28px -6px #16a34a; } }
@media (prefers-reduced-motion: reduce) { .mg-wrap *, .mg-pop *, .mg-dlg * { animation: none !important; } }

/* ---------- phones ---------- */
@media (max-width: 1000px) {
  .mg-page { grid-template-columns: minmax(0, 1fr); }
  .mg-side { position: static; }
}
@media (max-width: 640px) {
  .mg-wrap { gap: 10px; }
  .mg-frame-wrap { padding: 8px; border-radius: 18px; min-height: 0; }
  .mg-frame, .mg-frame[data-aspect="9:16"], .mg-frame[data-aspect="1:1"] { max-height: 44vh; }
  .mg-frame[data-aspect="9:16"] { height: 44vh; } .mg-frame[data-aspect="1:1"] { height: auto; width: 100%; }
  .mg-ctrl { gap: 8px; } .mg-time { min-width: 0; font-size: 12px; }
  .mg-strip-wrap { padding: 10px 6px 4px; border-radius: 18px; }
  .mg-card { width: 112px; }
  .mg-add { width: 96px; height: 96px; }
  .mg-trs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mg-side { padding-bottom: 76px; }
  .mg-go, .mg-busy { position: sticky; bottom: 8px; z-index: 6; box-shadow: 0 -10px 30px -18px rgba(0,0,0,.35); }
  .mg-empty { padding: 26px 14px; }
  .mg-empty-a .btn { flex: 1; min-width: 0; }
}

/* ---------- owner 17.11: scrub bar, trim + slow motion editor, music ---------- */
.mg-bar { cursor: pointer; touch-action: none; user-select: none; }
.mg-bar:focus-visible { outline: 2px solid var(--mg-pick); outline-offset: 2px; border-radius: 8px; }
.mg-head::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--text, #111); box-shadow: 0 0 0 3px var(--panel, #fff); transition: transform .12s; }
.mg-bar:hover .mg-head::after, .mg-bar.drag .mg-head::after { transform: scale(1.25); }
.mg-card.sel { box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--mg-pick) 55%, transparent); background: color-mix(in srgb, var(--mg-pick) 10%, var(--mg-chip)); }
.mg-card.sel.playing { box-shadow: 0 0 0 2.5px var(--mg-green); }
.mg-badges { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 3px; }
.mg-badges i { display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 999px; background: rgba(0,0,0,.62); color: #fff;
  font: 700 11px/1 Manrope, system-ui, sans-serif; font-style: normal; }
.mg-badges i .ico { width: 12px; height: 12px; }
.mg-badges i.slow { background: #f59e0b; color: #1f1300; }

.mg-edit { display: grid; gap: 10px; padding: 14px; border-radius: var(--mg-r); background: var(--panel, #fff); border: 1px solid var(--line, #e5e7eb); animation: mg-in .18s ease-out; }
.mg-edit[hidden], .mg-tl [hidden] { display: none !important; }
.mg-ed-h { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mg-ed-h small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-ed-h .mg-x { margin-left: auto; }
.mg-tl { --th: none; position: relative; height: 64px; margin: 4px 7px; border-radius: 10px; background: #111 var(--th) left center / auto 100% repeat-x;
  touch-action: none; user-select: none; cursor: pointer; }
.mg-tl-dim { position: absolute; top: 0; bottom: 0; background: rgba(0,0,0,.62); pointer-events: none; }
.mg-tl-dim:first-child { border-radius: 10px 0 0 10px; }
.mg-tl-dim:nth-child(2) { border-radius: 0 10px 10px 0; }
.mg-tl-sel { position: absolute; top: 0; bottom: 0; box-sizing: border-box; border: 3px solid var(--mg-pick); border-radius: 10px; pointer-events: none; }
.mg-tl-slow { position: absolute; top: 12px; bottom: 12px; display: grid; place-items: center; box-sizing: border-box; border: 2px solid #f59e0b; border-radius: 7px;
  background: rgba(245,158,11,.32); pointer-events: none; }
.mg-tl-slow span { font: 800 12px/1 Manrope, system-ui, sans-serif; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.mg-tl-ph { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45); pointer-events: none; }
.mg-tl-h { position: absolute; top: -5px; bottom: -5px; width: 14px; margin-left: -7px; border-radius: 6px; background: var(--mg-pick); cursor: ew-resize;
  touch-action: none; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .12s; z-index: 2; }
.mg-tl-h::after { content: ""; position: absolute; left: 50%; top: 50%; width: 2px; height: 18px; margin: -9px 0 0 -1px; border-radius: 1px; background: rgba(255,255,255,.9); }
.mg-tl-h.ss, .mg-tl-h.se { top: 8px; bottom: 8px; width: 12px; margin-left: -6px; background: #f59e0b; z-index: 3; }
.mg-tl-h.ss::after, .mg-tl-h.se::after { height: 12px; margin-top: -6px; }
.mg-tl-h.on, .mg-tl-h:hover { transform: scaleX(1.25); }
/* owner 17.11: the trim edges pulse until the user first grabs one, so the option is seen */
.mg-tl-h.hint { animation: mg-hint 1.4s ease-in-out 4; }
@keyframes mg-hint { 0%, 100% { box-shadow: 0 2px 6px rgba(0,0,0,.35); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--mg-pick) 45%, transparent), 0 2px 6px rgba(0,0,0,.35); } }
.mg-tl-h:focus-visible { outline: 2px solid var(--text, #111); outline-offset: 2px; }
.mg-ed-info { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mg-ed-info span { display: inline-flex; align-items: center; gap: 5px; }
.mg-ed-info .ico { width: 14px; height: 14px; }
.mg-ed-info .slow { color: #b45309; font-weight: 700; }
html[data-theme="dark"] .mg-ed-info .slow { color: #fbbf24; }
.mg-ed-a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mg-ed-sp { flex: 1; }
.mg-slow-t.on { border-color: #f59e0b !important; background: rgba(245,158,11,.14) !important; color: #b45309 !important; }
html[data-theme="dark"] .mg-slow-t.on { color: #fbbf24 !important; }
.mg-seg.mg-speed { display: inline-grid; min-width: 150px; }
.mg-seg.mg-speed button { padding: 6px 10px; font-weight: 700; }

.mg-mus-a { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mg-mus-a .btn { justify-content: center; }
.mg-mus-file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mg-mus-file > div { flex: 1; min-width: 0; display: grid; }
.mg-mus-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.mg-mus-ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: var(--mg-green);
  background: color-mix(in srgb, var(--mg-green) 14%, transparent); }
.mg-vol { min-width: 0; }
.mg-vol > span { min-width: 74px; font-size: 12.5px; }
.mg-vol output { min-width: 38px; text-align: right; font-size: 12.5px; }
.mg-snd { display: grid; gap: 6px; max-height: 56vh; overflow: auto; padding: 2px; }
.mg-snd-i { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--mg-chip); cursor: pointer; }
.mg-snd-i:hover, .mg-snd-i:focus-visible { box-shadow: 0 0 0 2px var(--mg-pick); outline: none; }
.mg-snd-i > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.mg-snd-i small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-snd-play { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--mg-green); color: #fff; cursor: pointer; }
.mg-snd-play .ico { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .mg-tl { height: 54px; }
  .mg-tl-h { width: 18px; margin-left: -9px; }
  .mg-tl-h.ss, .mg-tl-h.se { width: 16px; margin-left: -8px; }
  .mg-ed-sp { display: none; }
}

/* sliders (owner 17.11): soft green track, white knob with a green ring, no browser blue */
.mg-wrap input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: none; cursor: pointer; accent-color: var(--mg-pick); }
.mg-wrap input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--mg-pick) 28%, var(--mg-chip, #eef0f3)); }
.mg-wrap input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--mg-pick) 28%, var(--mg-chip, #eef0f3)); }
.mg-wrap input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--mg-pick); }
.mg-wrap input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--mg-pick); box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: transform .12s; }
.mg-wrap input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2.5px solid var(--mg-pick); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.mg-wrap input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
/* owner 19.11: Generate music (1 cr): a full-width green button over the two upload buttons, moods as chips */
.mg-mus-a .mg-gen { grid-column: 1 / -1; }
.mg-gen-cr { margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 800; background: rgba(255,255,255,.22); }
.mg-gen-wait { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 13.5px; }
.mg-gen-spin { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--mg-green) 30%, transparent);
  border-top-color: var(--mg-green); animation: mg-rot .8s linear infinite; }
.mg-dlg-gen { width: min(460px, calc(100vw - 24px)); }
.mg-moods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 16px; }
.mg-mood { padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line-strong, #d1d5db); background: var(--panel, #fff); color: inherit;
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.mg-mood:hover { border-color: var(--mg-green); }
.mg-mood[aria-checked="true"] { border-color: var(--mg-green); background: color-mix(in srgb, var(--mg-green) 12%, var(--panel, #fff)); box-shadow: 0 0 0 1px var(--mg-green); }
@media (max-width: 480px) { .mg-moods { grid-template-columns: 1fr 1fr; } }
