/* ═══════════════════════════════════════════════════════════════════
   Media Master — Editor ("The Cutting Room")
   Video trim · Audio trim · Image crop — built on the site's tokens.
   ═══════════════════════════════════════════════════════════════════ */
:root {
    --ed-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
    --ed-sel: rgba(255, 45, 85, .16);
    --ed-sel-line: #ff2d55;
    --ed-key: #fb923c;
    --ease-out-expo: cubic-bezier(.16, 1, .3, 1);
}

/* four tabs */
.tab-bar.tabs-4 { max-width: 600px; }
.tabs-4 .tab-slider { width: calc(25% - 4px); }
.tabs-4 .tab-slider.mid { left: calc(25%); }
.tabs-4 .tab-slider.right { left: calc(50%); }
.tabs-4 .tab-slider.far { left: calc(75%); }

/* mode chips */
.ed-modes { display: flex; justify-content: center; gap: 8px; margin: 0 auto 18px; flex-wrap: wrap; }
.ed-chip {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px;
    background: var(--black-4); border: 1px solid rgba(255, 255, 255, .06); color: var(--gray-1);
    font-size: .78rem; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.ed-chip:hover { border-color: rgba(255, 255, 255, .14); color: var(--white); }
.ed-chip.active { background: var(--red-dim); border-color: rgba(255, 45, 85, .35); color: #fff; box-shadow: 0 0 24px rgba(255, 45, 85, .12); }
.ed-chip:focus-visible, .ed-btn:focus-visible, .ed-handle:focus-visible, .ed-tool:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* workspace */
.ed-section { padding: 10px 24px 60px; }
.ed-work {
    max-width: 1180px; margin: 0 auto; background: var(--grad-surface); border: 1px solid rgba(255, 255, 255, .05);
    border-radius: 22px; padding: 22px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    opacity: 0; transform: translateY(28px); transition: opacity .7s var(--ease-out-expo), transform .7s var(--ease-out-expo);
}
.ed-work.in { opacity: 1; transform: none; }
.ed-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.ed-top .file-meta { flex: 1; min-width: 0; }
.ed-top .file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 520px; }
.ed-facts { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-fact { font-family: var(--ed-mono); font-size: .68rem; color: var(--gray-2); background: var(--black-4); padding: 4px 9px; border-radius: 6px; letter-spacing: .02em; }
.ed-fact.gpu { color: #86efac; background: rgba(52, 211, 153, .1); }

.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .ed-grid { grid-template-columns: 1fr; } }

/* stage */
.ed-stage { position: relative; background: #000; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255, 255, 255, .06); aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.ed-stage video, .ed-stage audio, .ed-stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.ed-stage video { width: 100%; height: 100%; object-fit: contain; }
.ed-stage.audio { aspect-ratio: auto; min-height: 170px; background: linear-gradient(180deg, #0c0c0d, #060607); flex-direction: column; gap: 10px; }
.ed-stage .ed-pending { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--gray-1); font-size: .82rem; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }

/* crop overlay (video + image) */
.ed-cropper { position: absolute; inset: 0; pointer-events: none; }
.ed-cropper.on { pointer-events: auto; cursor: crosshair; }
.ed-cropbox { position: absolute; border: 1.5px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); cursor: move; }
.ed-cropbox::before, .ed-cropbox::after { content: ''; position: absolute; pointer-events: none; opacity: .45; }
.ed-cropbox::before { left: 33.333%; right: 33.333%; top: 0; bottom: 0; border-left: 1px solid #fff; border-right: 1px solid #fff; }
.ed-cropbox::after { top: 33.333%; bottom: 33.333%; left: 0; right: 0; border-top: 1px solid #fff; border-bottom: 1px solid #fff; }
.ed-cropbox .h { position: absolute; width: 14px; height: 14px; background: #fff; border-radius: 3px; box-shadow: 0 1px 6px rgba(0, 0, 0, .6); }
.ed-cropbox .h.nw { left: -7px; top: -7px; cursor: nwse-resize; } .ed-cropbox .h.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.ed-cropbox .h.sw { left: -7px; bottom: -7px; cursor: nesw-resize; } .ed-cropbox .h.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.ed-cropbox .h.n { left: calc(50% - 7px); top: -7px; cursor: ns-resize; } .ed-cropbox .h.s { left: calc(50% - 7px); bottom: -7px; cursor: ns-resize; }
.ed-cropbox .h.w { left: -7px; top: calc(50% - 7px); cursor: ew-resize; } .ed-cropbox .h.e { right: -7px; top: calc(50% - 7px); cursor: ew-resize; }
.ed-croplabel { position: absolute; left: 0; top: -26px; font-family: var(--ed-mono); font-size: .66rem; color: #fff; background: rgba(0, 0, 0, .7); padding: 3px 7px; border-radius: 5px; white-space: nowrap; }

/* transport */
.ed-transport { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.ed-tool {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 38px; height: 36px; padding: 0 12px; border-radius: 10px;
    background: var(--black-4); border: 1px solid rgba(255, 255, 255, .06); color: var(--gray-1); font-size: .74rem; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.ed-tool:hover { color: #fff; border-color: rgba(255, 255, 255, .16); }
.ed-tool.active { color: #fff; background: var(--red-dim); border-color: rgba(255, 45, 85, .4); }
.ed-tool.play { width: 44px; background: var(--grad-red); color: #fff; border: none; }
.ed-time { font-family: var(--ed-mono); font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--white); }
.ed-time span { color: var(--gray-2); }
.ed-spacer { flex: 1; }
.ed-kbd { font-family: var(--ed-mono); font-size: .62rem; color: var(--gray-2); display: none; gap: 10px; }
@media (min-width: 900px) { .ed-kbd { display: flex; } }
.ed-kbd b { color: var(--gray-1); font-weight: 600; background: var(--black-5); padding: 1px 5px; border-radius: 4px; }

/* timeline — the signature element */
.ed-timeline { margin-top: 14px; user-select: none; -webkit-user-select: none; touch-action: none; }
.ed-tl-track {
    position: relative; height: 84px; border-radius: 12px; overflow: hidden; background: var(--black-3); border: 1px solid rgba(255, 255, 255, .06);
    cursor: crosshair;
}
.ed-tl-track.audio { height: 120px; }
.ed-strip { position: absolute; inset: 0; background-repeat: no-repeat; background-size: 100% 100%; opacity: .9; }
.ed-strip.loading { background: linear-gradient(90deg, var(--black-4) 25%, var(--black-6) 50%, var(--black-4) 75%); background-size: 200% 100%; animation: edShimmer 1.4s linear infinite; }
@keyframes edShimmer { from { background-position: 200% 0 } to { background-position: -200% 0 } }
.ed-wave { position: absolute; inset: 0; background-repeat: no-repeat; background-size: 100% 100%; opacity: .95; }
.ed-wave-mini { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background-size: 100% 100%; background-repeat: no-repeat; opacity: .55; }
.ed-dim { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, .66); pointer-events: none; }
.ed-sel { position: absolute; top: 0; bottom: 0; background: var(--ed-sel); border-left: 2px solid var(--ed-sel-line); border-right: 2px solid var(--ed-sel-line); box-shadow: inset 0 0 0 1px rgba(255, 45, 85, .25), 0 0 24px rgba(255, 45, 85, .25); cursor: grab; }
.ed-sel:active { cursor: grabbing; }
.ed-handle {
    position: absolute; top: 50%; width: 18px; height: 44px; margin-top: -22px; border-radius: 7px; background: var(--ed-sel-line);
    box-shadow: 0 2px 10px rgba(0, 0, 0, .6); cursor: ew-resize; display: flex; align-items: center; justify-content: center; z-index: 3;
}
.ed-handle::after { content: ''; width: 2px; height: 16px; background: rgba(255, 255, 255, .8); border-radius: 2px; }
.ed-handle.in { left: 0; } .ed-handle.out { right: 0; }
.ed-sel { min-width: 40px; }
.ed-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 8px #fff; pointer-events: none; z-index: 4; }
.ed-playhead::before { content: ''; position: absolute; top: -1px; left: -5px; border: 6px solid transparent; border-top: 8px solid #fff; }
.ed-keys { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; pointer-events: none; }
.ed-keys i { position: absolute; bottom: 0; width: 2px; height: 6px; background: var(--ed-key); opacity: .75; }
.ed-tl-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .7rem; color: var(--gray-2); flex-wrap: wrap; gap: 8px; }
.ed-tl-meta .ed-time { font-size: .72rem; }
.ed-snap { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.ed-snap input { accent-color: var(--ed-key); }

/* side panel */
.ed-panel { display: flex; flex-direction: column; gap: 14px; }
.ed-card { background: var(--black-3); border: 1px solid rgba(255, 255, 255, .05); border-radius: 14px; padding: 14px; }
.ed-card h4 { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gray-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.ed-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--black-5); padding: 4px; border-radius: 10px; }
.ed-seg button { padding: 9px 6px; border-radius: 8px; font-size: .74rem; font-weight: 600; color: var(--gray-2); background: transparent; transition: var(--transition); }
.ed-seg button.on { background: var(--black-7); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
.ed-seg button small { display: block; font-size: .6rem; font-weight: 500; color: var(--gray-2); margin-top: 2px; }
.ed-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid rgba(255, 255, 255, .04); font-size: .76rem; color: var(--gray-1); }
.ed-row:first-of-type { border-top: 0; }
.ed-row label { flex: 1; }
.ed-row .ed-val { font-family: var(--ed-mono); font-size: .7rem; color: var(--white); min-width: 44px; text-align: right; }
.ed-row input[type=range] { flex: 1.4; accent-color: var(--red); min-width: 90px; }
.ed-row select, .ed-row input[type=number], .ed-row input[type=text] { background: var(--black-5); color: var(--white); border: 1px solid rgba(255, 255, 255, .08); border-radius: 8px; padding: 6px 8px; font-size: .74rem; min-width: 84px; font-family: var(--font); }
.ed-row input[type=number] { width: 84px; font-family: var(--ed-mono); }
.ed-row input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }
.ed-presets { display: flex; gap: 6px; flex-wrap: wrap; }
.ed-presets button { padding: 6px 10px; border-radius: 8px; font-size: .68rem; font-weight: 600; background: var(--black-5); color: var(--gray-1); border: 1px solid rgba(255, 255, 255, .06); transition: var(--transition); }
.ed-presets button.on, .ed-presets button:hover { color: #fff; border-color: rgba(255, 45, 85, .4); background: var(--red-dim); }
.ed-note { font-size: .7rem; color: var(--gray-2); line-height: 1.5; margin-top: 8px; }
.ed-note.warn { color: #fcd34d; }
.ed-disabled { opacity: .35; pointer-events: none; }

/* render */
.ed-render { margin-top: 18px; display: grid; grid-template-columns: 1fr; gap: 10px; }
.ed-btn { padding: 15px 18px; border-radius: 14px; background: var(--grad-red); color: #fff; font-size: .9rem; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; transition: var(--transition); position: relative; overflow: hidden; }
.ed-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(255, 45, 85, .25); }
.ed-btn:disabled { opacity: .5; cursor: not-allowed; }
.ed-btn.ghost { background: var(--black-4); color: var(--gray-1); border: 1px solid rgba(255, 255, 255, .08); }
.ed-progress { display: none; background: var(--black-3); border: 1px solid rgba(255, 255, 255, .05); border-radius: 14px; padding: 14px 16px; }
.ed-progress.on { display: block; animation: cardIn .4s var(--spring); }
.ed-prog-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.ed-prog-pct { font-family: var(--ed-mono); font-size: 1.3rem; font-weight: 700; color: #fff; }
.ed-prog-meta { font-family: var(--ed-mono); font-size: .68rem; color: var(--gray-2); display: flex; gap: 12px; }
.ed-prog-track { height: 6px; border-radius: 99px; background: var(--black-5); overflow: hidden; }
.ed-prog-bar { height: 100%; width: 0; border-radius: 99px; background: var(--grad-red); transition: width .5s var(--ease-out-expo); box-shadow: 0 0 14px rgba(255, 45, 85, .5); }
.ed-prog-bar.err { background: #ef4444; }
.ed-prog-bar.done { background: linear-gradient(90deg, #34d399, #86efac); box-shadow: 0 0 14px rgba(52, 211, 153, .5); }
.ed-prog-msg { font-size: .74rem; color: var(--gray-1); margin-top: 8px; min-height: 1.1em; }
.ed-prog-msg.err { color: #f87171; }
.ed-result { display: none; margin-top: 10px; align-items: center; gap: 12px; background: rgba(52, 211, 153, .07); border: 1px solid rgba(52, 211, 153, .25); border-radius: 14px; padding: 12px 14px; }
.ed-result.on { display: flex; animation: cardIn .4s var(--spring); }
.ed-result .info { flex: 1; font-size: .78rem; color: var(--white); min-width: 0; }
.ed-result .info small { display: block; color: var(--gray-2); font-size: .68rem; margin-top: 2px; }
.ed-result a { padding: 10px 14px; border-radius: 10px; background: #34d399; color: #04130c; font-weight: 700; font-size: .76rem; text-decoration: none; white-space: nowrap; }
.ed-result a:hover { background: #6ee7b7; }

/* image editor */
.ed-stage.image { aspect-ratio: auto; min-height: 320px; max-height: 70vh; background: repeating-conic-gradient(#0f0f0f 0 25%, #151515 0 50%) 0 0 / 22px 22px; }
.ed-stage.image img { max-height: 70vh; object-fit: contain; transition: filter .15s; }
.ed-imgwrap { position: relative; display: inline-block; max-width: 100%; max-height: 70vh; }

@media (prefers-reduced-motion: reduce) {
    .ed-work { transition: none; }
    .ed-strip.loading { animation: none; }
    .ed-prog-bar { transition: none; }
}
@media (max-width: 600px) {
    .ed-section { padding: 6px 12px 40px; }
    .ed-work { padding: 14px; border-radius: 16px; }
    .ed-handle { width: 24px; margin-left: -12px; margin-right: -12px; }
    .ed-tl-track { height: 70px; }
}
