:root {
    --bg: #0b0c0e;
    --card: rgba(15, 16, 19, 0.84);
    --card-solid: #141519;
    --pop: #17181c;
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --text: #e8e9eb;
    --soft: #c4c7cc;
    --dim: #9a9ea6;
    --faint: #6d717a;
    --accent: #f5a524;
    --accent-soft: rgba(245, 165, 36, 0.12);
    --ink: #1c1303;
    --danger: #ff6b5b;
    --rec: #ff4d4d;
    --radius: 12px;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.35 var(--sans);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }

#view {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }

/* ------------------------------------------------------------ HUD frame */

.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}
.hud > *, .hud .bottom > *, .hud .bottom-centre > *, .hud .bottom-stack > * { pointer-events: auto; }
.hud .bottom, .hud .bottom-centre, .hud .bottom-stack, .hud .top-left, .hud .top-centre { pointer-events: none; }
.hud .top-left > *, .hud .top-centre > * { pointer-events: auto; }
.hud .stats { pointer-events: none; }
.hud.collapsed > * { display: none !important; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text);
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--soft);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.mac-dl { font-size: 13px; font-weight: 500; text-decoration: none; color: var(--soft); transition: color 0.12s, border-color 0.12s; }
.mac-dl[hidden] { display: none; }
@media (hover: hover) { .mac-dl:hover { color: var(--text); border-color: var(--line-2); } }
.icon-btn.small { width: 30px; height: 30px; border-radius: 8px; background: transparent; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.icon-btn.on { color: var(--accent); border-color: rgba(245, 165, 36, 0.45); }
.icon-btn.small.on { border-color: transparent; background: var(--accent-soft); }

@media (hover: hover) {
    .icon-btn:hover { color: var(--text); border-color: var(--line-2); }
    .icon-btn.small:hover { background: rgba(255, 255, 255, 0.06); border-color: transparent; }
}

.top-left {
    position: absolute;
    left: calc(16px + var(--safe-l));
    top: calc(16px + var(--safe-t));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}
.row-group { display: flex; gap: 8px; }
.file-pill { max-width: 240px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }

.stats {
    margin: 0;
    padding: 6px 9px;
    font: 10.5px/1.45 var(--mono);
    color: #c9ccd1;
    background: rgba(9, 10, 12, 0.66);
    border-radius: 6px;
    white-space: pre;
}

.top-centre {
    position: absolute;
    top: calc(16px + var(--safe-t));
    left: 50%;
    transform: translateX(-50%);
}
.status {
    height: 30px;
    padding: 0 14px;
    border-radius: 15px;
    font: 600 10px/1 var(--sans);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--soft);
    white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex: none; }
.status[data-mode="refining"] .status-dot,
.status[data-mode="loading"] .status-dot,
.status[data-mode="rendering"] .status-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.status[data-mode="refined"] .status-dot { background: #e8e9eb; }
.status[data-mode="playing"] .status-dot { background: var(--accent); }
.status[data-mode="recording"] { color: #ffd0cc; }
.status[data-mode="recording"] .status-dot { background: var(--rec); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

.top-right {
    position: absolute;
    right: calc(16px + var(--safe-r));
    top: calc(16px + var(--safe-t));
    display: flex;
    gap: 8px;
}
.restore {
    position: fixed;
    right: calc(16px + var(--safe-r));
    top: calc(16px + var(--safe-t));
    z-index: 3;
}

/* ------------------------------------------------------------ bottom bar */

.bottom {
    position: absolute;
    left: calc(16px + var(--safe-l));
    right: calc(16px + var(--safe-r));
    bottom: calc(16px + var(--safe-b));
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "left centre right";
    align-items: end;
    gap: 12px;
}
.bottom-left { grid-area: left; justify-self: start; }
.bottom-right { grid-area: right; justify-self: end; display: flex; align-items: center; gap: 14px; }
.bottom-centre { grid-area: centre; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; }
.bottom-stack { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.preset-chip { height: 46px; padding: 0 10px 0 8px; gap: 10px; }
.preset-icon { display: inline-flex; }
.preset-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.preset-text .preset-name { font-size: 12.5px; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-label, .cell-label {
    white-space: nowrap;
    font: 600 9px/1 var(--sans);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--dim);
}
.output-chip { font: 12px var(--mono); gap: 8px; white-space: nowrap; }

.shutter {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid #f2f2f2;
    background: rgba(0, 0, 0, 0.25);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    transition: transform 0.1s;
}
.shutter span { width: 42px; height: 42px; border-radius: 50%; background: #f7f7f7; transition: background 0.2s, transform 0.12s; }
.shutter:active span { transform: scale(0.9); }
.shutter.busy span { background: var(--accent); animation: pulse 0.9s ease-in-out infinite; }

/* readout strip and dial */

.strip {
    display: grid;
    grid-template-columns: repeat(6, auto);
    padding: 6px 6px;
    border-radius: 12px;
}
.cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 5px 15px 4px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    min-width: 76px;
}
.cell-value { font: 500 15px/1.1 var(--mono); color: var(--text); white-space: nowrap; }
.cell.active { background: var(--accent-soft); }
.cell.active .cell-value, .cell.active .cell-label { color: var(--accent); }
@media (hover: hover) { .cell:hover { background: rgba(255, 255, 255, 0.05); } .cell.active:hover { background: var(--accent-soft); } }

.dial {
    width: min(560px, calc(100vw - 32px));
    padding: 12px 14px 8px;
}
.dial-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.dial-value { font: 500 22px/1.1 var(--mono); color: var(--text); }
.dial-sub { font-size: 12px; color: var(--dim); }
.ruler-wrap { position: relative; height: 50px; margin-top: 8px; cursor: grab; touch-action: none; outline-offset: -2px; }
.ruler-wrap:active { cursor: grabbing; }
.ruler { display: block; width: 100%; height: 50px; }
.ruler-marker { position: absolute; left: 50%; top: 4px; height: 30px; width: 2px; margin-left: -1px; background: var(--accent); border-radius: 1px; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 6px; }
.chip {
    height: 30px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    font: 12px var(--mono);
    color: var(--soft);
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--ink); }

.nav { height: 44px; padding: 4px; gap: 2px; border-radius: 13px; }
.nav-btn {
    height: 34px;
    padding: 0 15px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font: 600 11px/1 var(--sans);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--soft);
    white-space: nowrap;
}
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }
.nav-btn[data-id="move"].active { box-shadow: inset 0 0 0 1.5px var(--accent); background: rgba(245, 165, 36, 0.08); }
@media (hover: hover) { .nav-btn:hover { color: var(--text); } .nav-btn.active:hover { color: var(--accent); } }

/* ------------------------------------------------------------ panels */

.panel {
    position: absolute;
    right: calc(16px + var(--safe-r));
    top: calc(66px + var(--safe-t));
    width: 344px;
    max-height: calc(100% - 66px - 190px - var(--safe-t) - var(--safe-b));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 3;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; }
.panel-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }
.link-btn { border: 0; background: transparent; color: var(--dim); font-size: 12px; padding: 4px 6px; border-radius: 6px; }
@media (hover: hover) { .link-btn:hover { color: var(--text); } }
.tabs { display: flex; gap: 3px; padding: 0 10px 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 1 0 auto;
    height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--dim);
    font-size: 12px;
    white-space: nowrap;
}
.tab.active { background: var(--accent); color: var(--ink); font-weight: 600; }
@media (hover: hover) { .tab:not(.active):hover { color: var(--text); background: rgba(255, 255, 255, 0.05); } }
.panel-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 0 6px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }
.panel-body > .rows { padding: 0 14px 10px; }

.rows { display: flex; flex-direction: column; }
.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
    align-items: center;
    min-height: 32px;
    gap: 10px;
}
.row-label { font-size: 12px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-num:not(.row) { display: flex; align-items: center; gap: 8px; min-width: 0; }

.slider { position: relative; flex: 1; height: 24px; cursor: pointer; touch-action: none; min-width: 40px; }
.sl-track { position: absolute; left: 0; right: 0; top: 50%; height: 3px; margin-top: -1.5px; background: rgba(255, 255, 255, 0.12); border-radius: 2px; overflow: hidden; }
.sl-fill { height: 100%; background: rgba(255, 255, 255, 0.42); }
.sl-thumb { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #f2f2f2; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); transition: transform 0.1s; }
.slider.active .sl-thumb { transform: scale(1.25); background: var(--accent); }
.slider.active .sl-fill { background: var(--accent); }

input.num {
    width: 66px;
    height: 26px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    font: 12px var(--mono);
    text-align: right;
    user-select: text;
    -webkit-user-select: text;
}
input.num:focus { border-color: rgba(245, 165, 36, 0.6); outline: none; }

.check {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    background: transparent;
    color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.check.on { color: #fff; background: rgba(255, 255, 255, 0.08); border-color: transparent; }

.select-wrap { position: relative; min-width: 0; }
.select-wrap .icon { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--dim); }
.select {
    width: 100%;
    height: 28px;
    padding: 0 26px 0 9px;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
}
.select option { background: var(--pop); color: var(--text); }

.colour { display: flex; align-items: center; gap: 8px; }
.swatch { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line-2); border-radius: 5px; background: none; }
.swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 3px; }
.hex { font: 12px var(--mono); color: var(--dim); }

.section { border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; }
.section-head {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
}
.section-head .icon { color: var(--dim); transition: transform 0.15s; transform: rotate(-90deg); }
.section.open > .section-head .icon { transform: none; }
.section:not(.open) > .rows { display: none; }
.section > .rows { padding-bottom: 8px; }

.hint { margin: 6px 0; font-size: 11.5px; line-height: 1.45; color: var(--faint); }
.readouts { margin: 6px 0; padding: 4px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.035); }
.readouts-title { font-size: 12px; font-weight: 600; padding: 6px 0 2px; }
.row-readout { min-height: 26px; }
.readout-value { font: 12px var(--mono); color: var(--text); }

.row-buttons { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; }
.btn {
    height: 28px;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 12px;
    white-space: nowrap;
}
.btn.small { height: 26px; padding: 0 9px; font-size: 11.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
.btn.danger { color: #ff9b8f; }
@media (hover: hover) { .btn:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.09); } .btn.primary:hover { background: #ffb53d; } }

.preset-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 0 6px; }
.preset-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 9px 12px;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.035);
}
.preset-item .preset-name { font-size: 12.5px; font-weight: 600; }
.preset-item .preset-note { font-size: 11.5px; color: var(--dim); }
.preset-item.active { border-color: rgba(245, 165, 36, 0.7); background: var(--accent-soft); }
@media (hover: hover) { .preset-item:hover { border-color: var(--line-2); } }

.aperture-box { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 4px; }
.aperture-preview { width: 112px; height: 112px; }
.ap-ring { fill: none; stroke: rgba(255, 255, 255, 0.15); stroke-width: 0.02; }
.ap-fill { fill: rgba(245, 165, 36, 0.85); }
.credits p { margin: 4px 0; font-size: 11.5px; color: var(--dim); }

/* ------------------------------------------------------------ timeline */

.timeline {
    position: relative;
    width: min(780px, calc(100vw - 32px));
    padding: 6px 10px 8px;
}
.timeline[hidden] { display: none; }
.tl-head { display: flex; align-items: center; gap: 6px; min-height: 36px; flex-wrap: nowrap; }
.tl-clock { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.tl-time { font: 600 15px/1 var(--mono); color: var(--accent); }
.tl-frame { font-size: 11px; color: var(--dim); }
.tl-duration { width: 66px; }
.chip-btn {
    height: 24px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    font: 600 10px/1 var(--sans);
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--dim);
}
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.chip-btn.rec.on { background: var(--rec); border-color: var(--rec); color: #fff; }
.rec-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rec); }
.chip-btn.rec.on .rec-dot { background: #fff; animation: pulse 0.8s ease-in-out infinite; }
.add-key {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 0;
    background: var(--accent);
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    margin-left: 2px;
}
.tl-body {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    margin-top: 4px;
    max-height: min(440px, calc(100vh - 330px));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
.tl-labels { display: flex; flex-direction: column; }
.tl-label { display: flex; align-items: center; gap: 7px; padding-left: 2px; }
.tl-label.lane { align-items: flex-start; padding: 7px 4px 0 18px; gap: 4px; flex-wrap: wrap; align-content: flex-start; }
.track-dot { width: 10px; height: 10px; padding: 0; border-radius: 50%; border: 1.5px solid var(--dim); background: transparent; flex: none; }
.track-dot.on { background: var(--accent); border-color: var(--accent); }
.track-name {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 2px;
    border: 0;
    background: transparent;
    font: 600 9.5px/1 var(--sans);
    letter-spacing: 0.13em;
    color: var(--soft);
}
.track-name .icon { color: var(--faint); transform: rotate(-90deg); transition: transform 0.15s; }
.track-name.open .icon { transform: none; }
.track.off .track-name { color: var(--faint); }
.ch-chip {
    height: 19px;
    padding: 0 6px;
    border-radius: 5px;
    border: 1px solid var(--ch);
    background: transparent;
    color: var(--ch);
    font: 600 10px/1 var(--sans);
}
.ch-chip.on { background: var(--ch); color: #101114; }
.ch-name { font: 10px var(--mono); }
.tl-area { position: relative; min-width: 0; }
.tl-canvas { display: block; width: 100%; touch-action: none; }
.tl-hint { position: absolute; left: 0; right: 0; top: 34px; text-align: center; font-size: 12px; color: var(--dim); pointer-events: none; }

.popover {
    position: absolute;
    z-index: 6;
    padding: 10px;
    background: var(--pop);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 11px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}
.popover[hidden] { display: none; }
.key-pop { width: 300px; }
.pop-title { font-size: 12.5px; font-weight: 600; }
.pop-title span { font-weight: 400; color: var(--dim); }
.pop-label { margin: 9px 0 5px; font: 600 9px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.seg { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); align-items: center; }
.seg-btn { flex: 1; height: 26px; border: 0; border-radius: 6px; background: transparent; font-size: 11.5px; color: var(--soft); }
.seg-btn.active { background: var(--accent); color: var(--ink); font-weight: 600; }
.seg-note { font-size: 10.5px; color: var(--faint); padding: 0 6px; white-space: nowrap; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.menu { min-width: 230px; padding: 6px; }
.menu-item {
    width: 100%;
    min-height: 34px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font-size: 12.5px;
    text-align: left;
}
.menu-item .icon { color: var(--dim); }
.menu-item.two-line { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 7px 10px; }
.menu-item.active { color: var(--accent); }
.menu-note { font-size: 11px; color: var(--dim); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-title { font: 600 9px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); padding: 6px 10px 4px; }
.menu-foot { font-size: 11px; color: var(--faint); padding: 6px 10px 4px; max-width: 260px; line-height: 1.4; }
@media (hover: hover) { .menu-item:hover { background: rgba(255, 255, 255, 0.06); } }
.scene-menu { position: fixed; z-index: 7; }

/* ------------------------------------------------------------ overlays */

.guides {
    position: fixed;
    display: none;
    z-index: 1;
    pointer-events: none;
    stroke: rgba(255, 255, 255, 0.42);
    stroke-width: 1;
    fill: none;
    shape-rendering: crispEdges;
}
.focus-mark {
    position: fixed;
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
    border: 1.5px solid var(--accent);
    border-radius: 5px;
    z-index: 2;
    pointer-events: none;
}
.focus-mark.miss { border-color: rgba(255, 255, 255, 0.5); border-style: dashed; }
.focus-mark.pulse { animation: focus-in 0.9s ease-out forwards; }
@keyframes focus-in {
    0% { transform: scale(1.5); opacity: 0; }
    20% { transform: scale(1); opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; }
}

.drop-zone {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 9, 11, 0.72);
    pointer-events: none;
}
.drop-zone[hidden] { display: none; }
.drop-zone > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 34px 48px;
    border: 1.5px dashed rgba(245, 165, 36, 0.7);
    border-radius: 16px;
    color: var(--text);
}
.drop-zone p { margin: 0; font-size: 14px; }

.progress {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(340px, calc(100vw - 40px));
    padding: 16px 16px 14px;
    z-index: 9;
}
.progress[hidden] { display: none; }
.progress-title { font-size: 13px; font-weight: 600; }
.bar { height: 4px; margin: 11px 0 8px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width 0.15s; }
.bar.indeterminate .bar-fill { width: 30% !important; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.progress-detail { font: 11.5px var(--mono); color: var(--dim); }
.progress .btn { margin-top: 12px; }

#toast {
    position: fixed;
    left: 50%;
    top: calc(58px + var(--safe-t));
    transform: translate(-50%, -6px);
    max-width: min(460px, calc(100vw - 32px));
    padding: 9px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--pop);
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-size: 12.5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s, transform 0.16s;
    z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.error { border-color: rgba(255, 107, 91, 0.5); color: #ffc4bc; }
.toast-action { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0 2px; }

.fatal {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 24px;
    text-align: center;
    z-index: 30;
    background: var(--bg);
}
.fatal h1 { font-size: 18px; margin: 0 0 6px; }
.fatal p { margin: 0; color: var(--soft); max-width: 420px; }
.fatal .mono { font-size: 11.5px; color: var(--dim); margin-top: 8px; }

/* ------------------------------------------------------------ narrow screens (phones) */

@media (max-width: 720px) {
    .top-left { left: calc(10px + var(--safe-l)); top: calc(10px + var(--safe-t)); }
    .top-right { right: calc(10px + var(--safe-r)); top: calc(10px + var(--safe-t)); gap: 6px; }
    .restore { right: calc(10px + var(--safe-r)); top: calc(10px + var(--safe-t)); }
    .row-group { gap: 6px; }
    .icon-btn { width: 34px; height: 34px; border-radius: 10px; }
    .pill { height: 34px; }
    .file-pill { max-width: 128px; padding: 0 10px; }
    .stats { display: none; }
    .top-right [aria-label="Full screen"], .mac-dl { display: none; }
    .top-centre { top: calc(52px + var(--safe-t)); }
    .status { height: 26px; }
    #toast { top: calc(88px + var(--safe-t)); }

    .bottom {
        left: calc(8px + var(--safe-l));
        right: calc(8px + var(--safe-r));
        bottom: calc(10px + var(--safe-b));
        grid-template-columns: 1fr auto;
        grid-template-areas: "centre centre" "left right";
        row-gap: 10px;
    }
    .bottom-centre { width: 100%; min-width: 0; }
    .bottom-stack { width: 100%; min-width: 0; }
    .strip { grid-template-columns: repeat(3, 1fr); width: 100%; padding: 4px; }
    .cell { min-width: 0; padding: 5px 4px 4px; }
    .cell-value { font-size: 14px; }
    .dial { width: 100%; }
    .dial-value { font-size: 19px; }
    .nav { width: 100%; min-width: 0; padding: 3px; gap: 0; }
    .nav-btn { flex: 1 1 0; min-width: 0; padding: 0 2px; font-size: 10px; letter-spacing: 0.06em; }
    .bottom-left, .bottom-right { min-width: 0; }
    .bottom-right { gap: 10px; }
    .preset-chip { height: 44px; padding: 0 8px 0 6px; gap: 7px; }
    .preset-chip > .icon { display: none; }
    .preset-text .preset-name { max-width: 104px; }
    .output-chip { height: 36px; padding: 0 9px; font-size: 11px; gap: 5px; }
    .shutter { width: 52px; height: 52px; }
    .shutter span { width: 38px; height: 38px; }

    .panel {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: auto;
        max-height: 62%;
        border-radius: 16px 16px 0 0;
        padding-bottom: var(--safe-b);
        border-bottom: 0;
    }
    .hud.panel-open .bottom { display: none; }

    .timeline { width: 100%; padding: 4px 6px 6px; }
    .tl-head { gap: 3px; }
    .tl-head [aria-label="Hide the timeline"] { display: none; }
    .tl-head .icon-btn.small { width: 28px; }
    .tl-time { font-size: 14px; }
    .tl-frame { display: none; }
    .tl-duration { width: 56px; }
    .chip-btn { padding: 0 6px; letter-spacing: 0.08em; }
    .tl-body { grid-template-columns: 76px minmax(0, 1fr); max-height: calc(100vh - 360px); }
    .track-name { letter-spacing: 0.05em; font-size: 9px; }
    .tl-label.lane { padding-left: 4px; }
    .key-pop { width: min(300px, calc(100vw - 30px)); }
}

@media (max-width: 380px) {
    .file-pill { max-width: 100px; }
    .top-right .icon-btn[aria-label="Focus peaking"] { display: none; }
}
