/* FEYDOM STOFDO — dark creative-studio theme. Same token names as before, refined palette. */
:root {
  --bg: #0d0e10; --panel: #141518; --panel2: #1b1d21; --panel3: #23262b; --border: #2a2d33; --border2: #353941;
  --text: #ecebe8; --text2: #b9b8b3; --muted: #85868b; --accent: #d6c3a0; --accent2: #e6d7ba; --accent-ink: #1a1712;
  --ok: #6fbf8e; --warn: #d9a74a; --err: #e0705f; --info: #8fb3d9;
  --r: 6px; --r-sm: 4px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --composer-w: 432px; --topbar-h: 50px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--text2); }
code, .mono { font-family: var(--mono); font-size: 11.5px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 3px; }
kbd { font: 10.5px/1 var(--mono); padding: 2px 5px; border: 1px solid var(--border2); border-bottom-width: 2px; border-radius: 4px; color: var(--text2); background: var(--panel2); }
.hint { color: var(--muted); font-size: 11.5px; margin: 4px 0 0; }
.hint.warn { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
textarea, input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select {
  width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px; font: inherit; transition: border-color .12s;
}
textarea { resize: vertical; line-height: 1.55; }
textarea:hover, input:hover, select:hover { border-color: var(--border2); }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }
select:disabled, input:disabled { opacity: .45; cursor: not-allowed; }
button, .btn { font: inherit; font-size: 12.5px; border-radius: var(--r-sm); padding: 7px 13px; cursor: pointer; border: 1px solid var(--border2);
  background: var(--panel2); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2;
  transition: background .12s, border-color .12s, color .12s; white-space: nowrap; }
button:hover, .btn:hover { background: var(--panel3); border-color: #464b55; }
button:focus-visible, .btn:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--text); border-color: var(--text); color: #111; font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: #fff; border-color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--text2); }
button.ghost:hover { background: var(--panel2); color: var(--text); }
button.small, .btn.small { padding: 5px 10px; font-size: 12px; }
button.big { padding: 11px 16px; font-size: 13.5px; width: 100%; justify-content: center; letter-spacing: .01em; }
.link-btn { background: none; border: none; padding: 0; color: var(--text2); font-size: 11.5px; text-decoration: underline; text-decoration-color: var(--border2); text-underline-offset: 3px; }
.link-btn:hover { background: none; color: var(--text); }
.link-btn.danger:hover { color: var(--err); }
.link-btn:disabled { opacity: .35; text-decoration: none; }
.icon-btn { padding: 6px; background: transparent; border-color: transparent; color: var(--text2); }
.field-label { display: block; margin: 12px 0 5px; font-size: 11.5px; font-weight: 500; color: var(--text2); }
.field-label small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.msg { font-size: 12px; color: var(--muted); }
.msg.error { color: var(--err); } .msg.ok { color: var(--ok); }
.msg b { font-weight: 600; }
.check-inline { display: flex; gap: 7px; align-items: flex-start; margin-top: 10px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.check-inline input { margin: 2px 0 0; accent-color: var(--accent); }
.input-btn { display: flex; }
.input-btn input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-btn button { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 0; padding: 0 11px; font-size: 15px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.switch-col { display: flex; align-items: flex-end; padding-bottom: 8px; }

/* toggle switch: <label class="switch"><input type=checkbox><span></span>Text</label> */
.switch { position: relative; display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12.5px; color: var(--text); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span { width: 28px; height: 16px; border-radius: 8px; background: var(--panel3); border: 1px solid var(--border2); position: relative; flex-shrink: 0; transition: background .15s, border-color .15s; }
.switch > span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); background: var(--accent-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.small { font-size: 12px; }
.toggles { display: flex; flex-direction: column; gap: 9px; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 4px 9px; font-size: 11.5px; background: transparent; color: var(--text2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--text); color: #111; font-weight: 600; }

/* ---------- top bar ---------- */
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--panel); position: relative; z-index: 20; }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/static/fonts/montserrat-latin.woff2) format("woff2"); }
.brand { display: flex; align-items: center; gap: 10px; user-select: none; padding-right: 8px; }
.brand-logo { height: 24px; width: auto; display: block; border-radius: 2px; }
.brand-sub { font-family: "Montserrat", var(--font); font-weight: 500; font-size: 15px; letter-spacing: .02em; color: var(--text); text-transform: lowercase; line-height: 1; }
.project-ctl { display: flex; align-items: center; gap: 8px; padding-left: 14px; border-left: 1px solid var(--border); }
.project-ctl label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.project-ctl input { width: 200px; padding: 5px 9px; background: transparent; }
.topbar-spacer { flex: 1; }
.queue-chip { background: transparent; border-color: var(--border); color: var(--text2); font-size: 12px; padding: 5px 11px; }
.queue-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border2); }
.queue-chip.busy { color: var(--text); border-color: var(--border2); }
.queue-chip.busy .dot { background: var(--warn); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.cmd-btn { background: transparent; border-color: var(--border); color: var(--muted); font-size: 12px; padding: 5px 9px; }
.cmd-btn kbd { margin-left: 4px; }
.banner { background: #2a2416; border-bottom: 1px solid #4a3f26; padding: 9px 16px; font-size: 12.5px; }

.popover { position: fixed; top: calc(var(--topbar-h) + 6px); right: 16px; width: 380px; max-height: 70vh; overflow: auto; z-index: 40;
  background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r); box-shadow: 0 16px 40px rgba(0,0,0,.5); padding: 10px; }
.q-counts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 8px; }
.q-counts span { display: flex; flex-direction: column; align-items: center; font-size: 10.5px; color: var(--muted); padding: 6px 0; background: var(--panel2); border-radius: var(--r-sm); }
.q-counts b { font-size: 15px; color: var(--text); font-weight: 600; }
.q-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 10px 4px 4px; }
.q-row { width: 100%; background: transparent; border: none; padding: 7px 6px; display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; text-align: left; }
.q-name { overflow: hidden; text-overflow: ellipsis; }
.q-state { color: var(--muted); font-size: 11.5px; }
.q-empty { padding: 6px 4px; }

/* ---------- workspace layout ---------- */
.workspace { display: grid; grid-template-columns: var(--composer-w) 1fr; height: calc(100vh - var(--topbar-h)); }
.composer { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--panel); min-height: 0; }
.composer-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 16px; scrollbar-gutter: stable; }
.main { overflow-y: auto; min-width: 0; scrollbar-gutter: stable; }
@media (max-width: 1100px) {
  .workspace { display: block; height: auto; }
  .composer { border-right: none; border-bottom: 1px solid var(--border); }
  .composer-scroll { overflow: visible; }
  .main { overflow: visible; }
  .generate-bar { position: sticky; bottom: 0; }
}

/* composer steps */
.step { padding: 16px 18px 18px; border-bottom: 1px solid var(--border); }
.step-head { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.step-head .link-btn, .step-meta { margin-left: auto; }
.step-n { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border2); color: var(--muted); font-size: 10px; display: grid; place-items: center; font-weight: 600; }
.step-meta { color: var(--muted); font-size: 11px; }

/* references */
.drop { border: 1px dashed var(--border2); border-radius: var(--r); padding: 16px 12px; text-align: center; cursor: pointer; color: var(--muted); transition: border-color .12s, background .12s; }
.drop svg { color: var(--text2); }
.drop p { margin: 4px 0 0; }
.drop strong { color: var(--text); font-weight: 500; }
.drop:hover, body.dragging .drop { border-color: var(--accent); background: rgba(214,195,160,.05); }
body.dragging .drop { border-style: solid; }
.ref-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ref-card { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 8px; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel2); }
.ref-card.role-first_frame { border-color: #4a5a46; } .ref-card.role-last_frame { border-color: #4a4f63; }
.ref-thumb { position: relative; aspect-ratio: 4/3; background: #000; border-radius: var(--r-sm); overflow: hidden; }
.ref-thumb img, .ref-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.audio-thumb { width: 100%; height: 100%; display: grid; place-items: center; font-size: 26px; color: var(--muted); }
.ref-tag { position: absolute; top: 4px; left: 4px; font: 10px var(--mono); background: rgba(0,0,0,.72); padding: 1px 5px; border-radius: 3px; }
.ref-role-badge { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10.5px; font-weight: 600; padding: 3px 6px; background: rgba(0,0,0,.72); }
.role-first_frame .ref-role-badge { color: #a9d39b; } .role-last_frame .ref-role-badge { color: #a8b5e6; }
.role-reference_image .ref-role-badge, .role-reference_video .ref-role-badge, .role-reference_audio .ref-role-badge { color: var(--accent); }
.ref-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ref-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text2); }
.ref-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-labels button { padding: 2px 7px; font-size: 10.5px; border-radius: 10px; background: transparent; color: var(--muted); border-color: var(--border); }
.ref-labels button.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.ref-usage { margin: 0; font-size: 11px; }
.ref-actions { display: flex; gap: 12px; margin-top: auto; }
.ref-progress { position: relative; height: 18px; background: var(--panel3); border-radius: 3px; overflow: hidden; }
.ref-progress i { position: absolute; inset: 0 auto 0 0; background: rgba(214,195,160,.3); transition: width .2s; }
.ref-progress span { position: relative; font-size: 10.5px; padding: 0 6px; line-height: 18px; color: var(--text2); }
.ref-error { font-size: 11px; color: var(--err); }

/* prompt */
.quick-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.quick-actions button { padding: 3px 9px; font-size: 11.5px; border-radius: 12px; background: transparent; color: var(--text2); border-color: var(--border); }
.quick-actions button:hover { color: var(--text); border-color: var(--accent); background: transparent; }
.quick-actions button.busy { color: var(--accent); border-color: var(--accent); }
#prompt { min-height: 150px; font-size: 13px; }
.prompt-tools { display: flex; gap: 14px; align-items: baseline; margin-top: 6px; min-height: 18px; }
.prompt-tools .hint { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-prompt { margin-top: 12px; }
.final-prompt summary { cursor: pointer; font-size: 11.5px; color: var(--text2); }
.final-prompt pre { white-space: pre-wrap; font: 11.5px/1.5 var(--mono); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; margin: 8px 0 0; max-height: 180px; overflow: auto; }

/* product protection */
.protect { background: linear-gradient(var(--panel), var(--panel)) padding-box; border-left: 2px solid var(--accent); }
.protect h3 { color: var(--accent); }
.protect-icon { color: var(--accent); font-size: 11px; }
.protect.off { border-left-color: var(--border2); }
.protect.off h3, .protect.off .protect-icon { color: var(--muted); }
.protect .toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }

/* model picker */
.model-picker { display: flex; flex-direction: column; gap: 6px; }
.model-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; white-space: normal; padding: 9px 11px; background: transparent; border-color: var(--border); }
.model-opt:hover { background: var(--panel2); }
.model-opt.on { border-color: var(--accent); background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
.mo-top { display: flex; align-items: center; gap: 7px; }
.mo-top b { font-weight: 600; font-size: 12.5px; }
.mo-specs { display: flex; gap: 12px; font-size: 11px; color: var(--muted); justify-self: end; }
.mo-specs em { font-style: normal; color: var(--text2); }
.mo-best { grid-column: 1 / -1; font-size: 11.5px; color: var(--text2); }
.mo-id { grid-column: 1 / -1; font: 10px var(--mono); color: var(--muted); display: none; }
.model-opt.on .mo-id { display: block; }
.tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--accent); color: var(--accent); }

/* settings groups */
.group { margin-top: 4px; padding: 10px 0 12px; border-top: 1px solid var(--border); }
.group:first-of-type { border-top: none; padding-top: 0; }
.group-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.group .toggles { margin-top: 8px; }
details.advanced summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; }
details.advanced summary::before { content: "▸"; font-size: 10px; transition: transform .12s; }
details.advanced[open] summary::before { transform: rotate(90deg); }
#extraJson { font: 11.5px var(--mono); }
.draft-box { margin: 8px 0 2px; padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--r); background: var(--panel2); }
.draft-box .switch b { font-weight: 600; }
.draft-box .hint { margin-left: 37px; }

.ratio-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ratio-tiles button { flex-direction: column; gap: 4px; padding: 9px 4px 7px; background: transparent; border-color: var(--border); white-space: normal; }
.ratio-tiles i { display: block; height: 26px; aspect-ratio: var(--w) / var(--h); max-width: 46px; border: 1.5px solid var(--text2); border-radius: 2px; }
.ratio-tiles b { font-size: 12px; font-weight: 600; }
.ratio-tiles span { font-size: 10px; color: var(--muted); line-height: 1.2; text-align: center; }
.ratio-tiles button.on { border-color: var(--accent); background: var(--panel2); }
.ratio-tiles button.on i { border-color: var(--accent); background: rgba(214,195,160,.12); }
.ratio-more { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 7px; }
.ratio-more .hint { margin: 0 4px 0 0; }
.ratio-more button { padding: 2px 8px; font-size: 11px; background: transparent; border-color: var(--border); color: var(--text2); }
.ratio-more button.on { border-color: var(--accent); color: var(--accent); }

/* generate bar */
.generate-bar { border-top: 1px solid var(--border); padding: 12px 18px 12px; background: var(--panel); display: grid; gap: 8px; z-index: 5; }
.takes { display: flex; align-items: center; gap: 4px; }
.takes .hint { margin: 0 6px 0 0; }
.takes button { padding: 3px 0; width: 30px; justify-content: center; font-size: 11.5px; background: transparent; border-color: var(--border); color: var(--text2); }
.takes button.on { background: var(--panel3); border-color: var(--text2); color: var(--text); font-weight: 600; }
.gen-foot { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; min-height: 16px; }
.gen-foot .msg { flex: 1; }
.kbd-hint { margin: 0; white-space: nowrap; }

/* ---------- viewer ---------- */
.viewer { border-bottom: 1px solid var(--border); background: var(--bg); }
.viewer-stage { background: #000; display: grid; place-items: center; height: min(62vh, 680px); min-height: 280px; position: relative; }
.viewer-stage .player { width: 100%; height: 100%; }
.viewer-info { padding: 14px 22px 18px; }
.vi-head { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.vi-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; flex: 1 1 320px; }
.vi-title h2 { margin: 0; font-size: 15px; flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vi-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.vi-actions .fav-btn.on { color: var(--accent); border-color: var(--accent); }
.vi-meta { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 14px 0 10px; }
.vi-meta div { min-width: 0; }
.vi-meta dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.vi-meta dd { margin: 2px 0 0; font-size: 12.5px; }
.vi-prompt summary { cursor: pointer; font-size: 11.5px; color: var(--text2); }
.vi-prompt p { margin: 6px 0 0; color: var(--text2); white-space: pre-wrap; max-width: 90ch; }
.vi-sub { margin-top: 10px; }
.vi-sub .hint { text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
.vi-sub p { margin: 2px 0 0; }
.viewer-empty { height: min(46vh, 460px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted); padding: 24px; }
.viewer-empty b { color: var(--text2); font-weight: 500; font-size: 14px; }
.ve-frame { width: 120px; aspect-ratio: 16/9; border: 1px solid var(--border2); border-radius: 3px; margin-bottom: 10px; }
.viewer-progress { width: min(440px, 86%); display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.viewer-progress b { font-size: 15px; font-weight: 500; }
.vp-bar, .card-progress .bar { height: 2px; background: var(--panel3); border-radius: 1px; overflow: hidden; position: relative; }
.vp-bar::after, .card-progress .bar::after { content: ""; position: absolute; inset: 0; width: 30%; background: var(--accent); animation: slide 1.8s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.vp-steps { list-style: none; display: flex; gap: 4px; padding: 0; margin: 8px 0 0; }
.vp-steps li { flex: 1; font-size: 11px; color: var(--muted); padding-top: 6px; border-top: 2px solid var(--panel3); }
.vp-steps li.done { color: var(--text2); border-color: var(--text2); }
.vp-steps li.now { color: var(--accent); border-color: var(--accent); }
.viewer-failed { width: min(520px, 90%); }

.status-pill { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; padding: 2px 7px; border-radius: 3px; border: 1px solid; }
.status-pill.s-done { color: var(--ok); border-color: rgba(111,191,142,.4); }
.status-pill.s-active { color: var(--warn); border-color: rgba(217,167,74,.4); }
.status-pill.s-queued { color: var(--text2); border-color: var(--border2); }
.status-pill.s-failed { color: var(--err); border-color: rgba(224,112,95,.4); }
.badge { font-size: 10px; font-weight: 600; letter-spacing: .04em; padding: 2px 6px; border-radius: 3px; background: rgba(0,0,0,.6); color: var(--text); border: 1px solid var(--border2); white-space: nowrap; }
.badge.draft { color: #c9b8f0; border-color: #4b4266; }
.badge.k-final { color: var(--ok); border-color: #355a43; }
.badge.k-upscale { color: var(--warn); border-color: #5c4a26; }
.badge.k-edit { color: var(--info); border-color: #34475e; }
.badge.final-pick { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.error-block { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid rgba(224,112,95,.35); border-left: 3px solid var(--err); border-radius: var(--r-sm); background: rgba(224,112,95,.06); }
.error-block b { color: var(--text); font-weight: 600; }
.error-block span { color: var(--text2); font-size: 12px; }
.eb-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }

/* ---------- player ---------- */
.player { position: relative; background: #000; display: grid; place-items: center; overflow: hidden; outline: none; }
.player video { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; display: block; }
.p-big { position: absolute; width: 58px; height: 58px; border-radius: 50%; justify-content: center; background: rgba(13,14,16,.72); border-color: rgba(255,255,255,.18); color: #fff; }
.p-big svg { width: 24px; height: 24px; margin-left: 3px; }
.player.playing .p-big { opacity: 0; pointer-events: none; }
.p-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: rgba(10,10,12,.78); opacity: 0; transition: opacity .15s; }
.player:hover .p-bar, .player:not(.playing) .p-bar, .player:focus-within .p-bar { opacity: 1; }
.p-bar button, .p-bar a { background: transparent; border: none; color: #e6e6e6; padding: 5px; border-radius: 3px; display: inline-flex; }
.p-bar button:hover, .p-bar a:hover { background: rgba(255,255,255,.1); color: #fff; }
.p-loop { opacity: .45; } .p-loop.on { opacity: 1; color: var(--accent) !important; }
.p-time { font: 11px var(--mono); color: #cfcfcf; min-width: 82px; text-align: center; }
.p-track { position: relative; flex: 1; height: 18px; display: flex; align-items: center; }
.p-track::before { content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(255,255,255,.16); border-radius: 2px; }
.p-buf, .p-fill { position: absolute; left: 0; height: 3px; border-radius: 2px; pointer-events: none; }
.p-buf { background: rgba(255,255,255,.22); } .p-fill { background: var(--accent); }
.p-track input { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; padding: 0; }
.player.compact .p-time { min-width: 0; }
.player:fullscreen { width: 100vw; height: 100vh; }

/* ---------- results ---------- */
.results { padding: 14px 22px 90px; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; position: sticky; top: 0; background: var(--bg); padding: 6px 0; z-index: 3; }
.tabs { display: flex; gap: 2px; }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); padding: 6px 11px; }
.tabs button.on { color: var(--text); background: var(--panel2); border-color: var(--border); }
.tabs .n { font-size: 10.5px; color: var(--muted); }
.results-tools { display: flex; gap: 8px; align-items: center; }
.results-tools input { width: 200px; padding: 5px 9px; }
.results-tools select { width: auto; padding: 5px 8px; }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.empty b { color: var(--text2); font-weight: 500; }
.load-more { display: flex; justify-content: center; padding: 18px 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; transition: border-color .12s; contain: content; }
.card:hover { border-color: var(--border2); }
.card.current { border-color: var(--text2); }
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card-thumb { position: relative; aspect-ratio: 16/9; background: #000; cursor: pointer; overflow: hidden; }
.card-thumb img, .card-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-thumb video.lazy-thumb { pointer-events: none; }
.card-thumb video.hover { position: absolute; inset: 0; }
.no-thumb { height: 100%; display: grid; place-items: center; color: var(--muted); }
.card-badges { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.card-dur { position: absolute; bottom: 6px; right: 6px; font: 10.5px var(--mono); background: rgba(0,0,0,.72); padding: 1px 5px; border-radius: 3px; }
.card-check { position: absolute; top: 6px; left: 6px; opacity: 0; transition: opacity .12s; }
.card:hover .card-check, .card.selected .card-check, .card-check:focus-within { opacity: 1; }
.card-check input { position: absolute; opacity: 0; }
.card-check span { display: block; width: 18px; height: 18px; border-radius: 3px; border: 1.5px solid #fff; background: rgba(0,0,0,.5); }
.card-check input:checked + span { background: var(--accent); border-color: var(--accent); }
.card-check input:checked + span::after { content: "✓"; color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; height: 100%; }
.card-progress { height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 0 16px; }
.card-progress b { font-weight: 500; font-size: 12.5px; }
.card-progress span { font: 11px var(--mono); color: var(--muted); }
.card-failed { height: 100%; display: grid; place-items: center; padding: 12px; text-align: center; background: rgba(224,112,95,.06); }
.card-failed b { color: var(--err); font-weight: 500; font-size: 12px; }
.card-body { padding: 9px 11px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-line { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.status-dot.s-done { background: var(--ok); } .status-dot.s-active { background: var(--warn); animation: pulse 1.6s infinite; }
.status-dot.s-queued { background: var(--text2); } .status-dot.s-failed { background: var(--err); }
.status-txt { color: var(--text2); }
.clip-tag { font: 10px var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }
.fav { margin-left: auto; background: none; border: none; padding: 0 2px; font-size: 15px; color: var(--muted); line-height: 1; }
.fav:hover { background: none; color: var(--text); } .fav.on { color: var(--accent); }
.card-title { font-size: 12.5px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; line-height: 1.4; }
.card-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 11px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; margin-top: auto; padding-top: 4px; justify-content: flex-end; align-items: center; }
.card-up { display: flex; gap: 4px; margin-right: auto; }
button.tiny { padding: 4px 8px; font-size: 11px; height: 26px; }
button.up { border-color: var(--accent); color: var(--accent); }
button.up:hover { background: rgba(214,195,160,.1); color: var(--accent2); border-color: var(--accent2); }
.icon-act { background: transparent; border: 1px solid var(--border); color: var(--text2); width: 28px; height: 26px; padding: 0; justify-content: center; font-size: 14px; border-radius: var(--r-sm); text-decoration: none; display: inline-flex; align-items: center; }
.icon-act:hover { color: var(--text); border-color: var(--border2); background: var(--panel2); }

.take-group { grid-column: 1 / -1; border: 1px solid var(--border); border-left: 2px solid var(--accent); border-radius: var(--r); padding: 10px 12px 12px; background: rgba(255,255,255,.012); }
.take-group header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.take-group header b { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.take-group header .hint { margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.take-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }

/* menus, toasts, selection bar */
.menu { position: fixed; z-index: 60; min-width: 240px; background: var(--panel); border: 1px solid var(--border2); border-radius: var(--r); padding: 4px; box-shadow: 0 16px 40px rgba(0,0,0,.55); }
.menu button { width: 100%; background: transparent; border: none; text-align: left; padding: 7px 10px; font-size: 12.5px; color: var(--text); }
.menu button:hover, .menu button:focus { background: var(--panel3); outline: none; }
.menu button.danger { color: var(--err); }
.menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 70; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; background: var(--panel3); border: 1px solid var(--border2); border-radius: var(--r); padding: 9px 10px 9px 13px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 12.5px; animation: tin .18s ease-out; }
.toast span { flex: 1; }
.toast.warn { border-left: 3px solid var(--warn); } .toast.err { border-left: 3px solid var(--err); }
.toast .x { background: none; border: none; color: var(--muted); padding: 0 4px; font-size: 16px; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
.selection-bar { position: fixed; bottom: 18px; left: calc(var(--composer-w) + (100vw - var(--composer-w)) / 2); transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 8px; background: var(--panel3); border: 1px solid var(--border2); border-radius: var(--r); padding: 7px 8px 7px 14px; box-shadow: 0 12px 34px rgba(0,0,0,.5); }
.selection-bar span { font-size: 12.5px; margin-right: 6px; }
@media (max-width: 1100px) { .selection-bar { left: 50%; bottom: 84px; } }

/* ---------- dialogs ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border2); border-radius: var(--r); padding: 22px; width: min(540px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(5,5,6,.7); }
.submit-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 18px; }
.submit-row .msg { flex: 1; }
dialog input[hidden] { display: none; }
#baseUrl { margin-top: 8px; }
.details-pre { white-space: pre-wrap; word-break: break-word; font: 11.5px/1.5 var(--mono); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; max-height: 60vh; overflow: auto; margin: 0; }
.edit-clips { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.edit-clips .clip { display: flex; gap: 8px; align-items: center; background: var(--panel2); border-radius: var(--r-sm); padding: 6px 8px; font-size: 12px; }
.edit-clips .clip b { color: var(--accent); font-family: var(--mono); font-weight: 500; }
.edit-clips .clip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-clips .clip button { padding: 2px 8px; font-size: 11px; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.quick .hint { margin: 0; }
#rgPrompt { min-height: 120px; }

dialog.full { width: calc(100vw - 32px); max-width: none; height: calc(100vh - 32px); max-height: none; padding: 0; display: none; }
dialog.full[open] { display: flex; flex-direction: column; }
.compare-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.compare-head h2 { margin: 0; }
.compare-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compare-grid { flex: 1; overflow: auto; display: grid; gap: 1px; background: var(--border); grid-template-columns: repeat(var(--cols, 2), minmax(260px, 1fr)); }
.cmp-col { background: var(--panel); display: flex; flex-direction: column; min-width: 0; }
.cmp-col.preferred { box-shadow: inset 0 0 0 2px var(--accent); }
.cmp-col .player { aspect-ratio: 16/9; width: 100%; }
.cmp-info { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.cmp-info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.cmp-info dt { color: var(--muted); }
.cmp-info dd { margin: 0; }
.cmp-prompt { font-size: 12px; color: var(--text2); max-height: 120px; overflow: auto; white-space: pre-wrap; margin: 0; }
.cmp-actions { display: flex; gap: 6px; flex-wrap: wrap; }

dialog.cmd { padding: 0; width: min(560px, calc(100vw - 32px)); margin-top: 14vh; }
#cmdInput { border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; font-size: 14px; background: transparent; }
#cmdList { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
#cmdList li { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px; }
#cmdList li.on { background: var(--panel3); }
#cmdList li .hint { margin: 0; }
#cmdList li.disabled { opacity: .4; }
table.keys { border-collapse: collapse; width: 100%; }
table.keys td { padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
table.keys td:first-child { width: 150px; white-space: nowrap; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .project-ctl { border-left: none; padding-left: 0; order: 5; width: 100%; }
  .project-ctl input { flex: 1; width: auto; }
  .cmd-btn, #logoutBtn { display: none; }
  .workspace { height: auto; }
  .step { padding: 14px; }
  .ref-card { grid-template-columns: 96px 1fr; }
  .protect .toggles { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr; }
  .viewer-stage { height: auto; aspect-ratio: 16/9; min-height: 0; }
  .viewer-info { padding: 12px 14px; }
  .results { padding: 12px 14px 120px; }
  .results-tools { width: 100%; } .results-tools input { flex: 1; width: auto; }
  .jobs { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .compare-grid { grid-template-columns: 1fr; }
  .popover { left: 12px; right: 12px; width: auto; }
}

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); padding: 26px; }
.login { width: min(360px, 100%); }
.login .brand { justify-content: center; margin-bottom: 22px; padding: 0; }
.login .brand-logo { height: 34px; } .login .brand-sub { font-size: 21px; }
.login button { width: 100%; margin-top: 12px; justify-content: center; }
