/* Workspace V3 is the reference surface for the whole product. Keep its
   component rules here, but source every token from the shared design system. */
@import url("/static/styles/tokens.css?v=a8c61fb8");
@import url("/static/styles/components/scrollbars.css?v=a8c61fb8");
/* Keyboard focus — every interactive surface gets the same accent ring.
   :where() keeps specificity at (0,1,0) so the fields that already draw their
   own focus treatment (textarea/select box-shadow, .mode-toggle glow) still win. */
:where(button,[role="button"],[role="radio"],[tabindex="0"],a):focus-visible{outline:2px solid rgba(var(--accent-rgb),.6);outline-offset:2px}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#222;border-radius:999px}
::-webkit-scrollbar-thumb:hover{background:var(--accent)}
* {scrollbar-width:thin;scrollbar-color:#222 transparent}
html,body{height:100%;background:var(--bg);font-family:var(--sans);color:var(--text);-webkit-font-smoothing:antialiased;overflow-x:hidden}
body::before{content:'';position:fixed;inset:0;background-image:linear-gradient(rgba(var(--accent-rgb),.03) 1px,transparent 1px),linear-gradient(90deg,rgba(var(--accent-rgb),.03) 1px,transparent 1px);background-size:40px 40px;pointer-events:none;z-index:0}
body::after{content:'';position:fixed;top:-200px;left:50%;transform:translateX(-50%);width:800px;height:400px;background:radial-gradient(ellipse,rgba(var(--accent-rgb),.06) 0%,transparent 70%);pointer-events:none;z-index:0}
.skip-link{position:absolute;left:-9999px;top:0;z-index:10000;background:var(--accent);color:#fff;padding:8px 16px;text-decoration:none}
.skip-link:focus{left:0}

/* Landing */
.landing{position:relative;z-index:1;max-width:760px;margin:0 auto;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:24px;gap:18px}
.logo-mark{width:54px;height:54px;background:linear-gradient(135deg,var(--accent),var(--accent2));border-radius:13px;display:flex;align-items:center;justify-content:center;font-family:var(--brand);font-weight:800;font-size:20px;color:var(--text);box-shadow:0 0 28px rgba(207,59,52,.35)}
.landing h1{font-family:var(--brand);font-weight:800;font-size:38px;letter-spacing:-1px}
.landing h1 span{color:var(--accent)}
.landing p{color:var(--muted2);font-size:15px;max-width:460px;line-height:1.6}
.pill-row{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin-top:4px}
.mini-pill{font-size:12px;color:var(--muted2);border:1px solid var(--border);background:var(--surface);border-radius:999px;padding:5px 12px}

/* Buttons */
/* THE primary action (Gerar): solid brand red, not a translucent maroon glass
   that got lost against the dark canvas. Reserve backdrop-blur for surfaces that
   actually float; a primary button should read as one confident, solid color. */
.btn-primary{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:14px 24px;background:linear-gradient(135deg,#ec5842,var(--accent));border:1px solid rgba(var(--brick-rgb),.55);border-radius:var(--radius);color:#fff;font-family:var(--sans);font-weight:700;font-size:14px;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;box-shadow:0 6px 22px rgba(var(--brick-rgb),.32),inset 0 1px 0 rgba(255,255,255,.12)}
.btn-primary:hover{transform:translateY(-1px);background:linear-gradient(135deg,#f26a52,#dc4a3e);border-color:rgba(var(--brick-rgb),.75);box-shadow:0 10px 30px rgba(var(--brick-rgb),.42),inset 0 1px 0 rgba(255,255,255,.14)}
.btn-primary:active{transform:translateY(0)}
.btn-primary:disabled{opacity:.5;cursor:not-allowed;transform:none}
/* Ghost = etiqueta de placa em mono (mesma família do .mpm-v2-tag do picker). */
.btn-ghost{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:9px 14px;background:transparent;border:1px solid rgba(var(--cream-rgb),.16);border-radius:6px;color:rgba(var(--cream-rgb),.62);font-family:var(--mono);font-size:10px;font-weight:500;letter-spacing:.08em;text-transform:uppercase;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s}
.btn-ghost:hover{border-color:rgba(var(--brick-rgb),.5);color:rgb(var(--brick-rgb))}

/* Modal */
/* ── Overlook app-header (matches main frontend) ── */
#app-header{position:fixed;top:0;left:0;right:0;height:var(--header-h);display:flex;align-items:center;background:var(--surface);border-bottom:1px solid var(--border);z-index:100}
#app-header .header-left{display:flex;align-items:center;padding:0 24px;height:100%;border-right:1px solid var(--border)}
#app-header .header-home{appearance:none;background:none;border:0;padding:0;margin:0;color:inherit;cursor:pointer;display:flex;align-items:center;gap:0;height:100%;border-radius:4px;transition:opacity .15s}
#app-header .header-home:hover{opacity:.75}
#app-header .logo-mark{width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;color:var(--accent);flex-shrink:0}
#app-header .logo-mark svg{width:100%;height:100%;display:block}
#app-header .logo-text{font-family:var(--sans);font-size:14px;font-weight:300;letter-spacing:.5em;color:var(--text);text-transform:lowercase;white-space:nowrap;margin-left:14px;padding-right:.5em}
#app-header .header-center{display:flex;align-items:center;gap:8px;padding:0 20px;font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:.06em;flex:1}
#app-header .breadcrumb-sep{color:var(--border)}
#app-header .breadcrumb-active{color:var(--text);font-weight:600}
#app-header .breadcrumb-sub{color:var(--muted2);font-size:9px;letter-spacing:.04em}
#app-header .header-right{display:flex;align-items:center;gap:12px;padding:0 24px}
#app-header .credits-badge{display:flex;align-items:center;gap:8px;padding:5px 12px;background:transparent;border:1px solid var(--border);border-radius:var(--radius-sm);cursor:pointer;transition:border-color .15s;font-family:var(--sans);font-size:12px;color:var(--muted2);line-height:1}
#app-header .credits-badge:hover{border-color:var(--green)}
#app-header .credits-badge svg{color:var(--green);flex-shrink:0}
#app-header .credits-label{font-size:11px;font-weight:500;color:var(--muted2);letter-spacing:.02em;text-transform:uppercase}
#app-header .credits-value{font-family:var(--mono);font-size:12px;font-weight:700;color:var(--green)}
#app-header .version-tag{font-family:var(--mono);font-size:9px;color:var(--muted2);padding:3px 8px;border:1px solid var(--border);border-radius:var(--radius-sm);letter-spacing:.06em}

.modal-header-banner{display:flex;align-items:center;justify-content:space-between;padding:14px 20px;border-bottom:1px solid var(--border);background:linear-gradient(180deg,rgba(255,255,255,.02),transparent),var(--surface2);box-shadow:inset 0 1px 0 rgba(255,255,255,.04);flex-shrink:0}
.modal-header-banner .header-left{display:flex;align-items:center;gap:12px}
.modal-header-banner .logo-mark{width:32px;height:32px;background:linear-gradient(135deg,var(--accent),var(--accent2));border-radius:8px;display:flex;align-items:center;justify-content:center;font-family:var(--brand);font-weight:800;font-size:13px;color:#000;flex-shrink:0;box-shadow:0 0 14px rgba(207,59,52,.25)}
.modal-header-banner .header-title{font-family:var(--serif);font-weight:500;font-size:18px;letter-spacing:.01em;line-height:1.2;color:var(--cream)}
.modal-header-banner .header-sub{font-size:9px;color:rgba(var(--cream-rgb),.42);margin-top:2px;font-family:var(--mono);letter-spacing:.18em;text-transform:uppercase}
.modal-header-banner .header-right{display:flex;align-items:center;gap:8px;margin-left:auto}
.overlay{position:fixed;left:0;right:0;bottom:0;top:var(--header-h);z-index:50;background:rgba(0,0,0,.72);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);display:flex;align-items:center;justify-content:center;padding:20px;opacity:0;pointer-events:none;transition:opacity .25s}
.overlay.open{opacity:1;pointer-events:auto}
.modal{position:relative;width:100%;max-width:1280px;height:calc(90vh - var(--header-h));max-height:calc(95vh - var(--header-h));overflow:hidden;background:linear-gradient(180deg,#100c0b 0%,#0b0808 100%);border:1px solid rgba(var(--cream-rgb),.12);border-radius:var(--radius);box-shadow:inset 0 1px 0 rgba(255,255,255,.05),0 1px 2px rgba(0,0,0,.5),0 12px 32px rgba(0,0,0,.45),0 32px 90px rgba(0,0,0,.6);display:flex;flex-direction:column;transform:translateY(14px) scale(.985);transition:transform .25s cubic-bezier(.22,1,.36,1)}
.overlay.open .modal{transform:none}

.modal-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1px solid var(--border)}
.modal-head .title{font-family:var(--serif);font-weight:500;font-size:19px;letter-spacing:.01em;color:var(--cream);display:flex;align-items:center;gap:10px}
.dot{width:7px;height:7px;border-radius:50%;background:var(--green);box-shadow:0 0 8px var(--green);animation:pulse 2s infinite}
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.5;transform:scale(.8)}}
.x-btn{background:transparent;border:1px solid var(--border);border-radius:var(--radius-sm);color:var(--muted2);width:32px;height:32px;cursor:pointer;font-size:16px;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s}
.x-btn:hover{border-color:rgba(255,255,255,.2);color:var(--text)}
.modal-x{position:absolute;top:14px;right:14px;z-index:3}

/* title (inside the model-badge box) */
.model-title{font-family:var(--sans);font-size:15px;font-weight:700;letter-spacing:.08em;color:var(--text)}

/* model badge card */
.model-badge{display:flex;align-items:center;gap:10px;padding:10px 12px;background:linear-gradient(168deg,#171110 0%,#0e0a09 100%);border:1px solid rgba(var(--cream-rgb),.10);border-radius:12px;margin-bottom:12px;flex-shrink:0}
.model-badge-icon{width:40px;height:40px;flex-shrink:0;display:flex;align-items:center;justify-content:center;border:1px solid rgba(var(--cream-rgb),.12);border-radius:10px;color:rgba(var(--brick-rgb),.92);background:transparent}
.model-badge-icon svg{width:20px;height:20px}
.model-badge-info{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.model-badge-name{font-family:var(--serif);font-size:15px;font-weight:500;color:var(--cream);letter-spacing:.01em}
.model-badge-provider{font-family:var(--mono);font-size:9px;color:rgba(var(--cream-rgb),.45);text-transform:uppercase;letter-spacing:.18em}
.model-badge-tag{font-family:var(--mono);font-size:9px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;padding:3px 9px;border-radius:4px;background:transparent;border:1px solid rgba(var(--brick-rgb),.32);color:rgba(var(--brick-rgb),.92);flex-shrink:0}

.label-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}
.label-row .field-label{margin-bottom:0}
.label-hint{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:.02em}
.label-hint .hint-ico{width:11px;height:11px;vertical-align:-2px;margin-right:3px;color:var(--accent);opacity:.8}
.select-wrapper{position:relative}
.credits-cost{font-weight:500;opacity:.85;margin-left:4px}

/* upload zone */
.upload-zone{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;min-height:86px;padding:14px 18px;border:1px dashed rgba(var(--cream-rgb),.18);border-radius:var(--radius-sm);background:rgba(15,12,11,.3);cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;color:var(--muted2);font-size:12px;line-height:1.35;text-align:center;flex-shrink:0;overflow:hidden}
.upload-zone svg{width:20px;height:20px;color:var(--accent);opacity:.8;flex:0 0 auto}
.ws3-upload-icon{width:20px;height:20px;color:var(--accent);opacity:.8;flex:0 0 auto}
.upload-zone span{display:block;max-width:100%}
.upload-zone:hover{border-color:rgba(var(--accent-rgb),.45);background:rgba(var(--accent-rgb),.04);color:var(--text-secondary, #e9e1d5)}
.upload-zone.dragover{border-color:rgba(var(--accent-rgb),.65);background:rgba(var(--accent-rgb),.08)}
/* compact upload zone when thumbnails are already shown */
.upload-zone.has-thumbs{padding:8px 14px;flex-direction:row;gap:8px;justify-content:center;min-height:40px}
.upload-zone.has-thumbs svg{width:16px;height:16px;flex-shrink:0}
.upload-zone.has-thumbs .upload-hint{display:none}
.upload-hint{font-size:10px;color:var(--muted)}
/* Seedance Frames: two side-by-side single-image dropzones (first / last frame) */
.frames-row{display:flex;gap:12px}
.frame-slot{flex:1;min-width:0;display:flex;flex-direction:column;gap:8px}
.frame-zone{min-height:104px}
.frame-zone.disabled{opacity:.45;cursor:not-allowed;pointer-events:none}
/* Frame preview fills the slot width and adopts the (cropped) image's aspect —
   no fixed 56px square. The remove ✕ stays pinned top-right. */
.frame-slot .thumbs-grid{display:block;overflow:visible;margin-bottom:0}
.frame-slot .thumb-cell{width:100%;height:auto;border-radius:var(--radius-sm);cursor:default}
.frame-slot .thumb-cell:hover{transform:none;box-shadow:none;border-color:var(--accent)}
.frame-slot .thumb-cell img{width:100%;height:auto;object-fit:contain;display:block}
.frame-slot .thumb-remove{width:22px;height:22px;font-size:13px;top:6px;right:6px}
.upload-preview{display:flex;align-items:center;gap:12px;padding:10px;border:1px solid var(--border);border-radius:var(--radius-sm);background:var(--surface2)}
.upload-preview img{width:56px;height:56px;object-fit:cover;border-radius:8px;border:1px solid var(--border);flex-shrink:0}
.upload-preview-meta{display:flex;flex-direction:column;gap:6px;min-width:0;flex:1}
.upload-preview-meta span{font-size:12px;color:var(--text-secondary, #e9e1d5);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.upload-remove{align-self:flex-start;background:transparent;border:1px solid var(--border);color:var(--muted2);font-family:var(--sans);font-size:11px;border-radius:8px;padding:4px 10px;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s}
.upload-remove--clear{margin-top:8px}
.upload-remove:hover{border-color:var(--red);color:var(--red)}

/* multi-thumb grid (image-to-image, 0–5 references) — horizontal scroll, never grows vertically */
.thumbs-grid{display:flex;flex-direction:row;gap:6px;max-width:100%;margin-bottom:8px;overflow-x:auto;overflow-y:hidden;flex-shrink:0;padding-bottom:2px}
.thumbs-grid::-webkit-scrollbar{height:3px}
.thumbs-grid::-webkit-scrollbar-thumb{background:#333;border-radius:999px}
.thumb-cell{position:relative;width:56px;height:56px;flex-shrink:0;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface2);transition:transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s, box-shadow 0.2s;z-index:1;cursor:pointer}
.thumb-cell:hover{transform:scale(1.25);z-index:10;border-color:var(--accent);box-shadow:0 8px 24px rgba(0,0,0,0.6)}
.thumb-cell img{width:100%;height:100%;object-fit:cover;display:block}
.thumb-remove{position:absolute;top:2px;right:2px;background:rgba(0,0,0,.6);color:#fff;border:0;border-radius:4px;font-size:11px;width:16px;height:16px;cursor:pointer;line-height:1;display:flex;align-items:center;justify-content:center;transition:background .15s}
.thumb-remove:hover{background:var(--red)}

/* Per-reference role chip (PixVerse Fusion: Personagem / Cenário). Sits on the
   bottom edge of the thumbnail and cycles the role on click — the label is the
   role the reference HAS, not the one the click would set (the tooltip says
   that). The cell keeps the standard 56px of every other reference thumbnail;
   the chip shrinks to fit instead of the grid growing. Hovering scales the
   whole cell, so the label is legible on demand. */
.thumb-type{position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;gap:1px;border:0;padding:1px 2px;background:rgba(0,0,0,.72);color:var(--text);font-family:var(--mono);font-size:6.5px;font-weight:700;letter-spacing:0;text-transform:uppercase;line-height:1.25;text-align:center;cursor:pointer;z-index:3;white-space:nowrap;overflow:hidden;transition:background .15s,color .15s}
.thumb-type-caret{font-size:6px;opacity:.85;line-height:1}
.thumb-type[data-type="subject"]{background:rgba(207,59,52,.86);color:#fff}
.thumb-type[data-type="background"]{background:rgba(0,0,0,.78);color:var(--muted)}
.thumb-type:hover{background:var(--accent);color:#0a0a0a}

/* "@image" reference: numbered thumbnails (Seedance/Happy Horse Ref) + the
   type-@ autocomplete menu. The number IS the index sent to KIE. */
.thumb-num{position:absolute;top:2px;left:2px;min-width:15px;height:15px;padding:0 3px;background:var(--accent);color:#0a0a0a;border-radius:4px;font-family:var(--mono);font-size:9px;font-weight:800;line-height:15px;text-align:center;pointer-events:none;z-index:2}
.thumb-cell.insertable{cursor:copy}
/* Reference already cited in the prompt (its token is underlined there). */
.thumb-cell.token-used{box-shadow:0 0 0 2px rgba(207,59,52,.85)}
.ref-mention-tip{margin-top:6px;font-size:11px;color:var(--muted);line-height:1.4}
/* Reference-token underline overlay (see index.html). Every box property here must
   stay in lockstep with the `textarea` rule below or the underline drifts off the
   word: same font, line-height, padding, border width and wrapping. */
.prompt-wrap{position:relative;display:flex;flex-direction:column;min-height:0}
/* Size comes from JS (textarea clientWidth/Height + borders) so the overlay wraps
   over the SAME content width as the textarea even when its scrollbar appears. */
.prompt-highlight{position:absolute;top:0;left:0;z-index:1;pointer-events:none;overflow:hidden;color:transparent;background:transparent;border:1px solid transparent;border-radius:var(--radius-sm);padding:10px 14px;font-family:var(--sans);font-size:13px;line-height:1.6;white-space:pre-wrap;overflow-wrap:break-word;word-break:break-word}
.prompt-highlight mark{color:transparent;background:transparent;border-bottom:2px solid rgba(207,59,52,.85);border-radius:0}
.ref-mention-menu{position:fixed;z-index:9999;max-height:240px;overflow-y:auto;background:var(--surface2);color:var(--text);border:1px solid var(--border);border-radius:10px;box-shadow:0 12px 32px rgba(0,0,0,.55);padding:4px;display:none}
.ref-mention-menu.visible{display:block}
.ref-mention-item{display:flex;align-items:center;gap:8px;padding:5px 6px;border-radius:7px;cursor:pointer}
.ref-mention-item img{width:34px;height:34px;object-fit:cover;border-radius:5px;flex-shrink:0;border:1px solid var(--border)}
.ref-mention-item.active,.ref-mention-item:hover{background:var(--accent);color:#0a0a0a}
/* Stand-in for a reference video whose poster frame has not been decoded yet. */
.ref-mention-vid-fallback{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:5px;flex-shrink:0;border:1px solid var(--border);background:var(--surface);font-size:11px}
.ref-mention-token{font-family:var(--mono);font-size:12px;font-weight:700}

/* audio reference card — shares the video-ref grid (workspacev3.js renderVideoThumbs), but is text/icon based (no frame to thumbnail), so it gets extra width instead of the square video/image cells */
.thumb-cell-audio{width:92px;cursor:default}
.thumb-cell-audio:hover{transform:none;border-color:var(--accent);box-shadow:none}
.audio-thumb{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;width:100%;height:100%;padding:4px 6px;overflow:hidden}
.audio-thumb-icon{font-size:16px;line-height:1}
.audio-thumb-icon svg{width:15px;height:15px;display:block;color:var(--accent);opacity:.8}
.audio-thumb-name{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9px;color:var(--text-secondary)}
.audio-thumb-dur{font-size:8px;color:var(--muted);letter-spacing:.02em}
.upload-zone.disabled{opacity:.45;cursor:not-allowed;border-color:var(--border)}
.upload-zone.disabled:hover{border-color:var(--border);background:rgba(15,15,15,.3);color:var(--muted2)}

.modal-body{display:grid;grid-template-columns:360px 1fr;gap:0;overflow:hidden;flex:1;min-height:0}
.controls{padding:16px 20px;overflow-y:auto;border-right:1px solid rgba(var(--cream-rgb),.08);display:flex;flex-direction:column;gap:0}
.preview{padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:14px;background:transparent}

.section-label{font-family:var(--mono);font-size:9.5px;font-weight:600;letter-spacing:.22em;text-transform:uppercase;color:rgba(var(--cream-rgb),.42);margin-bottom:8px;display:flex;align-items:center;gap:8px}
.section-label::after{content:'';flex:1;height:1px;background:linear-gradient(90deg,rgba(var(--cream-rgb),.12),transparent)}
.field{margin-bottom:12px;min-height:0;position:relative;clear:both}
/* A param the active model tier doesn't use (e.g. Kling Turbo's ghost "Modo"
   select) stays visible instead of disappearing, so switching tiers within one
   workspace (MODEL_VARIANT_GROUPS) doesn't reflow the panel — greyed + locked. */
.field-disabled{opacity:.45}
.field-disabled .vp-input,.field-disabled .mode-toggle{cursor:not-allowed}
/* Keep dense controls (e.g. seedance-2-multi: 9-thumb grid + video ref + 5 video params) from
   being flex-shrunk inside .controls' overflow-y:auto column, which let non-shrinkable inner
   content (.thumbs-grid/.upload-zone/textarea) overflow the field box and visually climb over
   the next field ("trepados"). Applies at all widths — including embed=1 desktop iframes. */
.controls>.field,.controls>#videoParamsField,.controls>.section-label{flex-shrink:0}
/* Field labels — micro-rótulo em mono rastreado, como os .mpm-v2-feature do
   model-picker: o ponto brick (::before) espelha o .mpm-v2-dot dos cards.
   Covers static fields AND the JS-rendered video params (renderVideoParams
   same class). */
.field-label{display:flex;align-items:center;gap:7px;font-family:var(--mono);font-size:9.5px;font-weight:600;color:rgba(var(--cream-rgb),.58);letter-spacing:.18em;text-transform:uppercase;margin-bottom:7px}
.field-label::before{content:'';width:4px;height:4px;border-radius:50%;background:rgba(var(--brick-rgb),.9);flex-shrink:0}
textarea,select{width:100%;background:rgba(0,0,0,.35);border:1px solid rgba(var(--cream-rgb),.10);border-radius:var(--radius-sm);color:var(--text-secondary, #e9e1d5);font-family:var(--sans);font-size:13px;padding:10px 14px;transition:border-color .2s,box-shadow .2s,background .2s;outline:none;appearance:none;box-shadow:inset 0 1px 2px rgba(0,0,0,.45)}
textarea:hover,select:hover{border-color:rgba(var(--cream-rgb),.20)}
textarea{min-height:90px;resize:vertical;line-height:1.6;flex-shrink:1;display:block}
/* <select> dropdowns: accent-red chevron + room for it — unified with the
   ElevenLabs Voice Studio reference (.el-select / .suno-select / .crop-ar-select). */
select{padding-right:32px;cursor:pointer;-webkit-appearance:none;appearance:none;accent-color:var(--accent);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239A3A34' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center}
textarea:focus,select:focus{border-color:rgba(var(--accent-rgb),.45);box-shadow:inset 0 1px 2px rgba(0,0,0,.45),0 0 0 3px rgba(var(--accent-rgb),.10)}
select option{background:var(--surface2)}
select option:checked{background:var(--accent);color:#fff}
/* Model selector */
.model-select-btn{display:flex;justify-content:space-between;align-items:center;width:100%;background:rgba(0,0,0,.35);border:1px solid rgba(var(--cream-rgb),.10);border-radius:var(--radius-sm);color:var(--text-secondary, #e9e1d5);font-family:var(--sans);font-size:12px;padding:8px 12px;cursor:pointer;height:36px;transition:border-color .2s;box-shadow:inset 0 1px 2px rgba(0,0,0,.45)}
.model-select-btn:hover{border-color:rgba(207,59,52,.35)}
.char-counter{font-family:var(--mono);font-size:10px;color:var(--muted);letter-spacing:.02em;text-align:right;margin-top:4px}

.preset-pills{display:flex;flex-wrap:wrap;gap:5px}
.preset-pill{padding:5px 11px;border-radius:999px;border:1px solid var(--border);background:var(--surface2);color:var(--muted2);font-size:11px;font-weight:500;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;user-select:none}
.preset-pill:hover{border-color:rgba(255,255,255,.15);color:var(--text)}
.preset-pill.on{background:rgba(207,59,52,.12);border-color:var(--accent2);color:var(--accent2)}

/* aspect ratio pills — mirrors .v2-param-pill from the main app's workspace-v2 */
.aspect-pills{display:grid;grid-template-columns:repeat(auto-fill,minmax(60px,1fr));gap:6px}
.aspect-pill{padding:8px 4px;background:rgba(15,12,11,.5);border:1px solid rgba(var(--cream-rgb),.10);border-radius:8px;color:rgba(var(--cream-rgb),.70);font-family:var(--mono);font-size:10px;font-weight:600;letter-spacing:.04em;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;text-align:center;appearance:none;line-height:1.2}
.aspect-pill:hover{border-color:rgba(var(--brick-rgb),.35);color:var(--cream)}
.aspect-pill.active{background:linear-gradient(135deg,rgba(207,59,52,.2),rgba(207,59,52,.2));border-color:rgba(207,59,52,.5);color:var(--accent);box-shadow:0 0 12px rgba(207,59,52,.1)}

.select-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(var(--cream-rgb), .10);
  border-radius: var(--radius-sm);
  color: var(--text-secondary, #e9e1d5);
  font-family: var(--sans);
  font-size: 13px;
  padding: 10px 14px;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  cursor: pointer;
  height: 38px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
}
.select-btn:hover {
  border-color: rgba(207, 59, 52, 0.35);
}
.select-btn:focus {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(var(--accent-rgb), 0.10);
}
/* Caret for pseudo-selects (.select-btn) — same accent-red SVG chevron the real
   <select>s draw, replacing the gray "▼" text glyph. */
.select-caret{width:10px;height:10px;flex-shrink:0;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23EC5842' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center/contain no-repeat}

.multishot-header{margin-bottom:6px}
.multishot-label{margin-bottom:0}
.multishot-total{font-family:var(--mono);font-size:12px;font-weight:700;color:var(--text)}
.multishot-list{display:flex;flex-direction:column;gap:12px}
.multishot-add{width:100%;justify-content:center;margin-top:8px}

.actions{display:flex;gap:10px;margin-top:auto;padding-top:12px;border-top:1px solid var(--border);flex-shrink:0}
.actions .btn-primary{flex:1}

/* Preview */
.badge{font-size:11px;padding:3px 10px;border-radius:999px;font-weight:500;background:rgba(245,158,11,.15);color:var(--accent3);border:1px solid rgba(245,158,11,.3)}
.canvas{position:relative;flex:1;min-height:340px;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;background:radial-gradient(ellipse 90% 70% at 50% 38%,rgba(255,255,255,.016),transparent 70%),var(--surface);box-shadow:inset 0 1px 0 rgba(255,255,255,.04);display:flex;align-items:center;justify-content:center}
.canvas.grid{align-items:flex-start;justify-content:stretch;overflow-y:auto}
.canvas.loading{border-color:rgba(207,59,52,.3)}
.canvas.loading::after{content:'';position:absolute;top:0;left:0;right:0;height:2px;background:linear-gradient(90deg,transparent,var(--accent),var(--accent2),transparent);animation:shimmer 1.5s linear infinite}
@keyframes shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}
.canvas img{max-width:100%;max-height:560px;display:block;border-radius:6px}
.result-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;width:100%;padding:10px}
.result-grid.single{grid-template-columns:1fr;margin:auto}
.result-cell{position:relative;display:block;border:1px solid var(--border);border-radius:8px;overflow:hidden;background:var(--surface2);cursor:pointer}
.result-cell img{width:100%;height:100%;object-fit:cover;display:block;border-radius:0;max-height:none;transition:transform .3s}
.result-cell.video-cell{aspect-ratio:16/9}
.result-cell.video-cell video{width:100%;height:100%;object-fit:cover;border-radius:0}
/* Single result: letterbox-fit the whole frame inside the canvas so it never grows
   tall enough to force a scroll. The canvas already has a definite height (flex:1 in
   the preview column); make the cell fill it and let object-fit:contain show the full
   media, centered, regardless of aspect ratio. Drop the 340px min-height for the
   result state so the canvas can shrink and absorb an OPEN history panel without
   pushing the .preview column into overflow-y scroll (video must always fit). */
.canvas.grid:has(.result-grid.single){overflow:hidden;min-height:0}
.result-grid.single{margin:0;padding:0;width:100%;height:100%;min-height:0}
.result-grid.single .result-cell{width:100%;height:100%;max-width:100%;max-height:100%;aspect-ratio:auto;border:0;background:transparent}
.result-grid.single .result-cell video,
.result-grid.single .result-cell img{width:100%;height:100%;max-height:100%;object-fit:contain;border-radius:var(--radius);transition:none}
.result-cell:hover img{transform:scale(1.05)}
.result-open-action{position:absolute;top:8px;right:8px;z-index:2;font-size:11px;font-family:var(--sans);color:#fff;background:rgba(0,0,0,.55);border-radius:6px;padding:3px 8px;opacity:0;transition:opacity .2s;pointer-events:auto}
@media (max-width:639px){.result-open-action{opacity:1;min-width:44px;min-height:44px;display:inline-flex;align-items:center;justify-content:center}}
.result-cell:hover .result-open-action,
.result-cell:focus-visible .result-open-action{opacity:1}
.result-open-action:hover{background:rgba(207,59,52,.7)}
.empty{display:flex;flex-direction:column;align-items:center;gap:12px;color:var(--muted);text-align:center;padding:40px}
.empty .big{font-size:40px;opacity:.4}
.empty .empty-ico{width:44px;height:44px;display:block}
.empty p{font-size:14px;max-width:260px;line-height:1.6}
.ws3-boot{position:fixed;left:0;right:0;bottom:0;top:var(--header-h);z-index:60;display:flex;align-items:center;justify-content:center;background:var(--bg);transition:opacity .2s}
.ws3-boot.hidden{display:none}
.spinner-wrap{display:flex;flex-direction:column;align-items:center;gap:14px;color:var(--muted2)}
.spinner{width:34px;height:34px;border:3px solid rgba(207,59,52,.18);border-top-color:var(--accent);border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.status-line{font-size:13px;color:var(--muted2);font-family:var(--sans)}
/* Plaquinha de "tempo de espera" de fila de parque, versão contida: placa
   escura com hairline marfim e dois rebites laterais, mono uppercase. */
.eta-plaque{position:relative;display:inline-flex;align-items:baseline;gap:8px;margin-top:2px;padding:6px 20px;background:linear-gradient(168deg,rgba(23,17,16,.92),rgba(11,8,8,.92));border:1px solid rgba(var(--cream-rgb),.12);border-radius:6px;font-family:var(--mono);box-shadow:0 8px 18px -12px rgba(0,0,0,.8),inset 0 1px 0 rgba(var(--cream-rgb),.04)}
.eta-plaque::before,.eta-plaque::after{content:'';position:absolute;top:50%;width:4px;height:4px;margin-top:-2px;border-radius:50%;background:rgba(var(--cream-rgb),.22);box-shadow:inset 0 1px 1px rgba(0,0,0,.65)}
.eta-plaque::before{left:8px;animation:etaBulb 3.2s ease-in-out infinite}
.eta-plaque::after{right:8px;animation:etaBulb 3.2s ease-in-out infinite;animation-delay:-1.6s}
/* Rebites piscando alternados, tipo lâmpada de letreiro de parque — lento e discreto. */
@keyframes etaBulb{0%,100%{background:rgba(var(--cream-rgb),.16)}50%{background:rgba(var(--cream-rgb),.45);box-shadow:inset 0 1px 1px rgba(0,0,0,.65),0 0 6px rgba(var(--cream-rgb),.18)}}
.eta-plaque-label{font-size:9px;letter-spacing:.09em;text-transform:uppercase;color:var(--muted)}
.eta-plaque-value{font-size:11px;font-weight:600;letter-spacing:.04em;color:rgba(var(--cream-rgb),.85);white-space:nowrap}
@media (prefers-reduced-motion: reduce){.eta-plaque::before,.eta-plaque::after{animation:none}}
.err{color:var(--red);font-size:13px;line-height:1.5;font-family:var(--sans);padding:16px;text-align:center}
.preview-foot{display:flex;gap:8px}
.preview-foot a,.preview-foot button{flex:1}

/* HISTORY */
/* A placa da mesa de estúdio, como os cards do model-picker: gradiente quente,
   hairline marfim e filete de marca no topo. */
.history-panel{position:relative;background:linear-gradient(168deg,#171110 0%,#0e0a09 55%,#0b0808 100%);border:1px solid rgba(var(--cream-rgb),.10);border-radius:var(--radius);overflow:hidden;flex-shrink:0;margin-top:auto;box-shadow:0 24px 50px -32px rgba(0,0,0,.85)}
.history-panel::before{content:'';position:absolute;top:0;left:18px;right:18px;height:2px;background:linear-gradient(90deg,rgba(var(--brick-rgb),.85),rgba(var(--brick-rgb),.10));opacity:.75;pointer-events:none;z-index:1}
.history-header{display:flex;align-items:center;justify-content:space-between;padding:11px 14px;cursor:pointer;user-select:none}
.history-header-title{font-family:var(--serif);font-size:15px;font-weight:500;letter-spacing:.01em;color:var(--cream);display:flex;align-items:center;gap:8px}
.history-count{font-family:var(--mono);background:transparent;border:1px solid rgba(var(--brick-rgb),.32);color:rgba(var(--brick-rgb),.92);border-radius:4px;padding:1px 8px;font-size:10px}
.history-clear{background:transparent;border:none;color:var(--muted);font-size:11px;font-family:var(--sans);cursor:pointer;padding:2px 4px}
.history-clear:hover{color:var(--red)}
.history-chevron{color:var(--muted);transition:transform .25s;font-size:14px}
.history-panel.open .history-chevron{transform:rotate(180deg)}
.history-list{max-height:0;overflow:hidden;transition:max-height .3s ease}
.history-panel.open .history-list{max-height:300px;overflow-y:auto;border-top:1px solid var(--border)}
.history-empty{padding:16px 14px;font-size:12px;color:var(--muted);line-height:1.5}
.history-item{display:flex;align-items:center;gap:10px;padding:9px 14px;border-bottom:1px solid var(--border);cursor:pointer;transition:background .15s}
.history-item:last-child{border-bottom:none}
.history-item:hover{background:rgba(255,255,255,.035)}
.history-thumb{width:40px;height:40px;border-radius:8px;object-fit:cover;flex-shrink:0;border:1px solid rgba(255,255,255,.08);background:var(--surface2);box-shadow:0 2px 6px rgba(0,0,0,.4)}
.history-meta{flex:1;min-width:0}
.history-prompt{font-size:13px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.history-sub{font-size:11px;color:var(--muted);margin-top:2px;font-family:var(--sans)}
.history-n{background:rgba(var(--accent-rgb),.12);color:var(--accent2);border-radius:4px;padding:1px 6px;font-size:10px;flex-shrink:0}
/* Brighter red tint (var(--accent-text)) instead of raw --accent: DC2626 on near-black
   reads too dim — the button was getting lost under the history list. */
.history-all{width:100%;background:transparent;border:none;border-top:1px solid rgba(var(--cream-rgb),.10);color:rgba(var(--cream-rgb),.85);font-family:var(--mono);font-size:11px;font-weight:600;padding:12px;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;letter-spacing:.14em;text-transform:uppercase;display:flex;align-items:center;justify-content:center;gap:6px}
.history-all:hover{background:rgba(var(--brick-rgb),.08);border-top-color:rgba(var(--brick-rgb),.4);color:rgb(var(--brick-rgb))}
.history-panel:not(.open) .history-all{display:none}

/* GALLERY (ver todas) */
#galleryOverlay{z-index:60}
.gallery{width:100%;max-width:1100px;max-height:92vh;display:flex;flex-direction:column;background:linear-gradient(180deg,#100c0b 0%,#0b0808 100%);border:1px solid rgba(var(--cream-rgb),.12);border-radius:var(--radius);box-shadow:0 48px 120px -30px rgba(0,0,0,.9);transform:translateY(14px) scale(.985);transition:transform .25s}
.overlay.open .gallery{transform:none}
.gallery-head{display:flex;align-items:center;justify-content:space-between;padding:18px 20px;border-bottom:1px solid var(--border);flex-shrink:0}
.gallery-head .title{font-family:var(--serif);font-weight:500;font-size:19px;letter-spacing:.01em;color:var(--cream);display:flex;align-items:center;gap:10px}
.gallery-body{padding:18px 20px;overflow-y:auto;display:flex;flex-direction:column;gap:16px}

/* GALLERY MASONRY */
.gallery-masonry {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* 3 columns for tablet/desktop */
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 639px) {
  .gallery-col {
    display: contents; /* collapse columns container visually */
  }
  .gallery-masonry {
    display: flex;
    flex-direction: column; /* linear stack on mobile */
  }
}

/* Gallery Card Style - mimicking AnimatedImage */
.gallery-card {
  position: relative;
  width: 100%;
  background: var(--surface2);
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease, border-color 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.gallery-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 24px rgba(0,0,0,0.3);
  border-color: rgba(207,59,52,0.4);
}

.gallery-card-media-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 11px;
}

.gallery-card-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}
.gallery-card-media.loaded {
  opacity: 1;
}

/* Hover Overlay on Cards */
.gallery-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 40%, rgba(0, 0, 0, 0) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  pointer-events: none;
  z-index: 2;
}
.gallery-card:hover .gallery-card-overlay {
  opacity: 1;
}

.gallery-card-info {
  color: #fff;
  font-family: var(--sans);
}
.gallery-card-prompt {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.gallery-card-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--sans);
  display: flex;
  align-items: center;
  gap: 8px;
}
.gallery-card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 3;
  pointer-events: auto;
}
.gallery-card:hover .gallery-card-actions {
  opacity: 1;
}
.gallery-card:focus-within .gallery-card-actions {
  opacity: 1;
}
@media (hover:none) {
  .gallery-card-actions { opacity: 1; }
}

.gallery-card-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(15, 15, 15, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
@media (hover:none), (max-width:640px) {
  .gallery-card-btn { width:44px; height:44px; }
}
.gallery-card-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}
.gallery-card-btn.del-btn:hover {
  background: var(--red);
  border-color: var(--red);
}

/* Play Badge for Videos */
.gallery-video-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  pointer-events: none;
  z-index: 2;
  border: 1px solid rgba(255,255,255,0.25);
  transition: transform 0.3s ease;
}
.gallery-card:hover .gallery-video-badge {
  transform: scale(1.1);
}

/* Failed/Generating Cards */
.gallery-card.state-failed, .gallery-card.state-generating {
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.gen-card{border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;background:var(--bg);flex-shrink:0}
.gen-card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 14px;border-bottom:1px solid var(--border)}
.gen-card-prompt{font-size:13px;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gen-card-sub{font-size:11px;color:var(--muted);font-family:var(--sans);flex-shrink:0;white-space:nowrap}
.gen-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px;padding:12px}
.gen-cell{position:relative;min-width:0}
.gen-cell-img,.gen-cell-video{display:block;border-radius:8px;overflow:hidden;border:1px solid var(--border);cursor:pointer;width:100%;aspect-ratio:1;object-fit:cover;transition:transform .3s}
.gen-cell-img:hover{transform:scale(1.05)}
.gen-del{background:transparent;border:1px solid var(--border);color:var(--muted2);font-family:var(--sans);font-size:11px;border-radius:8px;padding:4px 10px;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;flex-shrink:0}
.gen-del:hover{border-color:var(--red);color:var(--red);background:rgba(239,68,68,.06)}
.gen-download-batch{background:transparent;border:1px solid var(--border);color:var(--muted2);font-family:var(--sans);font-size:11px;border-radius:8px;padding:4px 10px;cursor:pointer;transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s;flex-shrink:0}
.gen-download-batch:hover{border-color:var(--accent);color:var(--accent);background:rgba(207,59,52,.06)}
.img-del{position:absolute;top:6px;right:6px;width:24px;height:24px;border:none;border-radius:6px;background:rgba(0,0,0,.6);backdrop-filter:blur(4px);color:#fff;font-size:12px;line-height:1;cursor:pointer;opacity:0;transition:opacity .15s,background .2s;display:flex;align-items:center;justify-content:center}
.gen-cell:hover .img-del,.gen-cell:focus-within .img-del,.img-del:focus-visible{opacity:1}
.img-del:hover{background:var(--red)}
.img-download-single{position:absolute;bottom:6px;right:6px;width:24px;height:24px;border:none;border-radius:6px;background:rgba(0,0,0,.6);backdrop-filter:blur(4px);color:#fff;font-size:12px;line-height:1;cursor:pointer;opacity:0;transition:opacity .15s,background .2s;display:flex;align-items:center;justify-content:center;z-index:2}
.gen-cell:hover .img-download-single,.gen-cell:focus-within .img-download-single,.img-download-single:focus-visible{opacity:1}
.img-download-single:hover{background:var(--accent)}
.hist-del{background:transparent;border:none;color:var(--muted);font-size:13px;cursor:pointer;padding:2px 6px;opacity:0;transition:opacity .15s,color .2s;flex-shrink:0}
.history-item:hover .hist-del,.history-item:focus-within .hist-del,.hist-del:focus-visible{opacity:.6}
.hist-del:hover{color:var(--red);opacity:1}

/* Video parameter slider */
.vp-slider{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:3px;background:linear-gradient(90deg,var(--accent) var(--percent, 0%),rgba(var(--accent-rgb),.15) var(--percent, 0%));outline:none;cursor:pointer}
.vp-slider::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;background:radial-gradient(circle at 35% 30%,var(--accent),var(--accent) 65%);border:2px solid rgba(5,5,6,.9);cursor:pointer;box-shadow:0 1px 3px rgba(0,0,0,.6),0 0 10px rgba(var(--accent-rgb),.35)}
.vp-slider::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:radial-gradient(circle at 35% 30%,var(--accent),var(--accent) 65%);border:2px solid rgba(5,5,6,.9);cursor:pointer;box-shadow:0 1px 3px rgba(0,0,0,.6),0 0 10px rgba(var(--accent-rgb),.35)}

/* The stacked layout's sizing now lives in the responsive block at the end of
   this file (.modal-body became a flex column with a single scroll container),
   which overrode the grid-template/max-height/overflow-y that used to be here.
   Only the border swap was still doing anything, so only it remains. */
@media(max-width:640px){.controls{border-right:none;border-bottom:1px solid var(--border)}}
/* Once the narrow layout stacks controls above the preview, an open history
   panel can consume all remaining flex space. The single-result rule above
   deliberately removes the desktop canvas minimum; restore a bounded stage
   here so an inline video never collapses to an invisible strip. */
@media(max-width:640px){
  .canvas.grid:has(.result-grid.single){min-height:clamp(180px,35dvh,300px);}
}
@media(max-width:600px){.modal-header-banner{padding:10px 14px}.modal-header-banner .logo-mark{width:28px;height:28px;font-size:11px;flex-shrink:0}.modal-header-banner .header-left{min-width:0;flex:1;overflow:hidden}.modal-header-banner .header-left>div:last-child{min-width:0;overflow:hidden}.modal-header-banner .header-title{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.modal-header-banner .header-sub{display:none}.modal-header-banner .header-right{flex-shrink:0;gap:4px}.modal-header-banner .header-right .btn-ghost{font-size:10px;padding:4px 7px;white-space:nowrap}}

/* confirm toast */
.confirm-toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%) translateY(16px);z-index:200;display:flex;flex-direction:column;gap:12px;min-width:320px;max-width:90vw;padding:16px 18px;background:rgba(13,13,13,.95);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid var(--border);border-radius:12px;box-shadow:0 16px 48px rgba(0,0,0,.6);opacity:0;pointer-events:none;transition:opacity .2s,transform .2s}
 .confirm-toast.show{opacity:1;transform:translateX(-50%) translateY(0);pointer-events:auto}
 .ct-msg{font-family:var(--sans);font-size:14px;color:var(--text)}
.ct-check{display:flex;align-items:center;gap:8px;font-family:var(--sans);font-size:12px;color:var(--muted2);cursor:pointer;user-select:none}
.ct-check input{accent-color:var(--accent);width:14px;height:14px;cursor:pointer}
.ct-actions{display:flex;gap:8px;justify-content:flex-end}
.ct-actions button{font-family:var(--sans);font-size:13px;border-radius:8px;padding:8px 16px;cursor:pointer;border:1px solid var(--border);transition:background-color .2s,border-color .2s,color .2s,box-shadow .2s,transform .2s}
.ct-cancel{background:transparent;color:var(--muted2)}
.ct-cancel:hover{border-color:rgba(255,255,255,.2);color:var(--text)}
.ct-confirm{background:linear-gradient(135deg,rgba(185,28,28,.6),rgba(127,29,29,.42));border-color:rgba(var(--accent-rgb),.3);color:#fff;font-weight:600}
.ct-confirm:hover{box-shadow:0 4px 16px rgba(var(--accent-rgb),.3)}

.dev-tag{position:fixed;bottom:20px;right:20px;background:rgba(255,255,255,.03);backdrop-filter:blur(8px);border:1px solid rgba(255,255,255,.07);border-radius:999px;padding:8px 16px;font-family:var(--sans);font-size:11px;color:rgba(255,255,255,.3);z-index:5;user-select:none}

/* mode toggles (fast/quality and video params) — a single segmented control:
   one recessed rail, all options equal width on one row, the selected one a
   raised accent pill. Replaces the old wrapping flex pills, where an odd count
   made the last option wrap to a giant full-width row. */
.mode-toggles{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:3px;min-width:0;padding:3px;background:rgba(0,0,0,.35);border:1px solid rgba(var(--cream-rgb),.08);border-radius:var(--radius);box-shadow:inset 0 1px 2px rgba(0,0,0,.45)}
.mode-toggle{display:flex;align-items:center;justify-content:center;gap:6px;min-width:0;padding:8px 6px;border:1px solid transparent;border-radius:calc(var(--radius) - 4px);background:transparent;font-family:var(--mono);font-size:9.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:rgba(var(--cream-rgb),.55);cursor:pointer;user-select:none;transition:background .18s,color .18s,box-shadow .18s;white-space:normal;line-height:1.25;text-align:center}
button.mode-toggle{appearance:none}
.mode-toggle:hover{color:var(--text);background:rgba(255,255,255,.04)}
.mode-toggle[aria-pressed="true"],.mode-toggle[aria-checked="true"]{background:linear-gradient(180deg,rgba(var(--accent-rgb),.28),rgba(var(--accent-rgb),.14));border-color:rgba(var(--accent-rgb),.45);color:#f87171;box-shadow:inset 0 1px 0 rgba(255,255,255,.08),0 2px 8px rgba(0,0,0,.4)}
.mode-toggle:focus-visible{outline:none;border-color:rgba(var(--accent-rgb),.4);box-shadow:0 0 0 3px rgba(var(--accent-rgb),.08)}

/* Kling Multi-Shot is a boolean action, not a segmented choice. Keep its
   checkbox affordance scoped here so the other .mode-toggle radiogroups stay
   visually unchanged. */
#v3-ms-btn{justify-content:flex-start;text-align:left;padding-inline:10px}
#v3-ms-btn::before{content:"";display:grid;place-items:center;flex:0 0 14px;width:14px;height:14px;border:1px solid rgba(255,255,255,.28);border-radius:4px;background:rgba(0,0,0,.18);box-shadow:inset 0 1px 2px rgba(0,0,0,.35);transition:background .18s,border-color .18s,box-shadow .18s}
#v3-ms-btn:hover::before{border-color:rgba(255,255,255,.5);background:rgba(255,255,255,.06)}
#v3-ms-btn[aria-pressed="true"]::before{content:"✓";color:#fff;font-size:10px;font-weight:700;line-height:1;background:rgb(var(--accent-rgb));border-color:rgba(var(--accent-rgb),.9);box-shadow:0 0 0 2px rgba(var(--accent-rgb),.14)}

/* Video model dynamic params — keep dense Seedance controls from overlapping in the left rail. */
#videoParamsField{display:flex;flex-direction:column;gap:12px;min-width:0}
#videoParamsField .field{margin-bottom:0}
#videoParamsField select,
#videoParamsField input:not([type="checkbox"]):not([type="radio"]):not([type="range"]){min-height:38px;box-sizing:border-box}
/* Resolution controls own their feedback: the global select focus ring used
   to paint outside the field boundary and made the hover/focus look attached
   to the neighboring control. Keep the accent inside the selected input. */
#videoParamsField select:hover{border-color:rgba(var(--cream-rgb),.20)}
#videoParamsField select:focus{border-color:rgba(var(--accent-rgb),.45);box-shadow:inset 0 1px 2px rgba(0,0,0,.45),inset 0 0 0 1px rgba(var(--accent-rgb),.18)}
#videoRefField .upload-zone{min-height:74px;padding:12px 14px}
#videoRefField .upload-zone svg{width:18px;height:18px}

/* canvas empty state — SVG viewfinder replaces the old emoji */
.big{color:var(--accent);opacity:.6;line-height:0}
.empty-viewfinder{width:56px;height:56px}


/* DETAIL MODAL (single image/video, expanded two-column view, click-through
   from a result batch). The panel itself (.dm-panel and everything inside
   it) is shared with the Drive preview lightbox — see
   frontend/styles/components/media-detail-modal.css, linked in index.html.
   Only workspace-specific bits live here: the backdrop's z-index fix (must
   outrank #galleryOverlay's z-index:60 — opening a card from "ver todas"
   leaves both overlays .open at once, and the base .overlay z-index:50 put
   the detail modal BEHIND the gallery grid). */
#detailOverlay{z-index:65}
.dm-folder-menu{max-height:260px;overflow-y:auto}

/* Video from image floating menu */
.v2-ctx-menu {
  position: absolute;
  z-index: 10000;
  min-width: 210px;
  background: rgba(13, 13, 13, 0.95);
  border: 1px solid rgba(207, 59, 52, 0.2);
  border-radius: 12px;
  padding: 6px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 1px rgba(207, 59, 52, 0.3);
  opacity: 0;
  transform: scale(0.95) translateY(-4px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.v2-ctx-menu.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
.v2-ctx-header {
  padding: 8px 12px 6px;
  font-family: var(--sans);
  font-size: 10px;
  color: var(--muted2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  font-weight: 600;
}
.v2-ctx-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted2);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
  text-align: left;
}
.v2-ctx-option:hover {
  background: rgba(207, 59, 52, 0.12);
  color: var(--text);
}
.v2-ctx-option.active {
  background: rgba(207, 59, 52, 0.08);
  color: var(--accent-text);
}

/* Alt Model menu: per-row model letter badge + name/category stack */
.alt-model-menu{max-height:60vh;overflow-y:auto}
.alt-model-badge{width:24px;height:24px;flex-shrink:0;border-radius:6px;background:linear-gradient(135deg,var(--accent),var(--accent2));display:flex;align-items:center;justify-content:center;font-family:var(--brand);font-weight:800;font-size:11px;color:#000}
.alt-model-text{display:flex;flex-direction:column;gap:1px;min-width:0;overflow:hidden}
.alt-model-name{font-size:12px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.alt-model-cat{font-size:9px;color:var(--muted2);text-transform:uppercase;letter-spacing:.5px}

/* Floating reference media preview popover */
.thumb-popover {
  position: fixed;
  z-index: 100000;
  display: inline-flex;
  background: rgba(8,8,8,.92);
  border: 1px solid rgba(207, 59, 52, 0.4);
  border-radius: 12px;
  padding: 4px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 1px rgba(207, 59, 52, 0.4);
  opacity: 0;
  transform: scale(0.95) translateX(-10px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  overflow: hidden;
}
.thumb-popover.visible {
  opacity: 1;
  transform: scale(1) translateX(0);
}
.thumb-popover img {
  display: block;
  max-width: 320px;
  max-height: 320px;
  width: auto;
  height: auto;
  border-radius: 8px;
}
.thumb-popover video {
  display: block;
  width: min(360px, 42vw);
  max-height: 240px;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}

/* ============================================================
   IMAGE CROP MODAL
   ============================================================ */

.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: crop-fade-in 0.2s ease;
}

.crop-modal.hidden {
    display: none;
}

@keyframes crop-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.crop-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.crop-panel {
    position: relative;
    z-index: 1;
    width: 90vw;
    max-width: 720px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid rgba(207, 59, 52, 0.15);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(207, 59, 52, 0.06);
    animation: crop-panel-in 0.25s ease;
}

@keyframes crop-panel-in {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ── */
.crop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(207, 59, 52, 0.1);
}

.crop-title {
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.crop-subtitle {
    font-family: var(--sans);
    font-size: 10px;
    color: rgba(148, 163, 184, 0.5);
    margin-top: 2px;
}

.crop-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Plain text, no icon/border -- deliberately distinct from the square icon
   buttons (rotate/close) it sits next to, so the two aren't mistaken for
   each other at a glance. */
.crop-reset-btn {
    height: 32px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.crop-reset-btn:hover {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent, #cf3b34);
}

.crop-rotate-btn,
.crop-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.crop-rotate-btn:hover {
    background: rgba(207, 59, 52, 0.15);
    border-color: rgba(var(--accent-rgb), 0.3);
    color: var(--accent);
}

.crop-close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ── Body / Canvas ── */
.crop-body {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    /* This is the real clip boundary for the zoomed (transform: scale) canvas --
       .crop-canvas-wrap between them is deliberately overflow: visible (clipping
       there would cap the photo back to its tiny unzoomed box). WebKit/Safari has
       a known bug where overflow: hidden doesn't reliably clip a transformed
       descendant two levels down through an overflow: visible wrapper unless the
       clipping element has its own compositing/containment context. `contain:
       paint` forces that context and makes the clip authoritative in every engine. */
    contain: paint;
}

.crop-canvas-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 60vh;
    line-height: 0;
    user-select: none;
    -webkit-user-select: none;
    overflow: visible;
}

.crop-canvas-wrap canvas {
    display: block;
    border-radius: 6px;
}

/* ── Overlay: darkens outside crop area ── */
.crop-overlay {
    position: absolute;
    cursor: crosshair;
    overflow: visible;
    touch-action: none;
}

/* ── Selection box ── */
.crop-selection {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    cursor: move;
    z-index: 2;
    touch-action: none;
    transition: box-shadow 0.15s;
}

.crop-selection:hover {
    border-color: #cf3b34;
}

/* ── Rule of thirds grid ── */
.crop-grid-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

.crop-grid-h1 { left: 0; right: 0; top: 33.33%; height: 1px; }
.crop-grid-h2 { left: 0; right: 0; top: 66.66%; height: 1px; }
.crop-grid-v1 { top: 0; bottom: 0; left: 33.33%; width: 1px; }
.crop-grid-v2 { top: 0; bottom: 0; left: 66.66%; width: 1px; }

/* ── Corner handles ── */
.crop-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid #cf3b34;
    border-radius: 3px;
    z-index: 3;
    touch-action: none;
    transition: transform 0.1s;
}

.crop-handle:hover {
    transform: scale(1.3);
    background: #cf3b34;
}

.crop-handle-nw { top: -7px; left: -7px; cursor: nw-resize; }
.crop-handle-ne { top: -7px; right: -7px; cursor: ne-resize; }
.crop-handle-sw { bottom: -7px; left: -7px; cursor: sw-resize; }
.crop-handle-se { bottom: -7px; right: -7px; cursor: se-resize; }

/* ── Footer ── */
.crop-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid rgba(207, 59, 52, 0.1);
    flex-wrap: wrap;
}

.crop-zoom-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 160px;
}

.crop-zoom-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: rgba(var(--accent-rgb), 0.15);
    border-radius: 2px;
    outline: none;
}

.crop-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #cf3b34;
    border: 2px solid rgba(15, 15, 15, 0.8);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(207, 59, 52, 0.3);
}

.crop-zoom-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #cf3b34;
    border: 2px solid rgba(15, 15, 15, 0.8);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(207, 59, 52, 0.3);
}

.crop-zoom-pct {
    font-family: var(--mono);
    font-size: 10px;
    color: rgba(148, 163, 184, 0.6);
    min-width: 32px;
    text-align: right;
}

.crop-zoom-icon{flex-shrink:0;opacity:.5}

.crop-ar-select {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.08);
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: 6px;
    padding: 5px 28px 5px 10px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    -webkit-appearance: none;
    appearance: none;
    accent-color: var(--accent, #cf3b34);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23DC2626' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    white-space: nowrap;
}

.crop-ar-select:hover,
.crop-ar-select:focus {
    border-color: rgba(var(--accent-rgb), 0.5);
    background-color: rgba(var(--accent-rgb), 0.12);
}

.crop-ar-select option {
    background: #0a0a0a;
    color: var(--text-secondary);
    font-family: var(--mono);
    font-size: 12px;
}

.crop-ar-select option:checked {
    background: var(--accent);
    color: #fff;
}

.crop-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.crop-btn-cancel {
    padding: 8px 18px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.7);
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.crop-btn-cancel:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.crop-btn-skip {
    padding: 8px 16px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    color: rgba(220, 220, 220, 0.85);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.crop-btn-skip:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

.crop-btn-confirm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #cf3b34, #a72c27);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.crop-btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(207, 59, 52, 0.35);
}

@media (max-width: 640px) {
    .crop-panel {
        width: 96vw;
        max-height: 95vh;
        border-radius: 12px;
    }

    .crop-body {
        padding: 8px;
    }

    .crop-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .crop-actions {
        justify-content: flex-end;
    }
}

/* Embed mode: rendered inside the workspace desktop as an iframe window (?embed=1). Hide own top chrome; zero --header-h so the modal fills the iframe. */
html.ws3-embed { --header-h: 0px; }
html.ws3-embed #app-header { display: none; }
html.ws3-embed #closeBtn { display: none; }
/* The window IS the chrome: no gutters, no dimmer — the modal must meet the
   iframe edges exactly, otherwise the box reads as "cut off" below the Gerar
   button and a black step appears to the right of the toolbar. */
html.ws3-embed .overlay {
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* ...except the media-detail overlay, which renders in-place as a FLOATING
   panel over the workspace (not edge-to-edge like the generation modal). It
   keeps the dimmed backdrop the base .overlay gives it — the transparent rule
   above would otherwise leave it floating over an undimmed, still-interactive
   workspace. */
html.ws3-embed #detailOverlay {
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
html.ws3-embed #galleryOverlay {
    background: rgba(0, 0, 0, 0.86);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 20px;
}
html.ws3-embed .modal {
    max-width: none;
    height: 100vh;
    max-height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}
/* Window titlebar already shows the model name — header-left is redundant in embed mode. */
html.ws3-embed .modal-header-banner .header-left { display: none; }
/* Reuse Prompt / Download are loose elements in the window — no full-width
   banner bar behind them (it visually glued itself over the controls column). */
html.ws3-embed .modal-header-banner {
    background: transparent;
    border-bottom: 0;
    padding-bottom: 0;
}
/* Re-grid the window so the toolbar row exists only over the preview column:
   the controls panel spans both rows and starts at the very top (no dead band
   above the Prompt field). .modal-body dissolves (display:contents) so
   .controls/.preview become grid items of .modal itself. */
html.ws3-embed .modal {
    display: grid;
    grid-template-columns: 360px 1fr;
    grid-template-rows: auto minmax(0, 1fr);
}
html.ws3-embed .modal-header-banner { grid-column: 2; grid-row: 1; }
html.ws3-embed .modal-body { display: contents; }
html.ws3-embed .controls { grid-column: 1; grid-row: 1 / 3; min-height: 0; }
html.ws3-embed .preview { grid-column: 2; grid-row: 2; min-height: 0; }
/* Narrow window: fall back to the stacked single-column flow. The explicit
   grid placements above would otherwise create an implicit second column. */
@media(max-width:640px){
    html.ws3-embed .modal { display: flex; flex-direction: column; }
    html.ws3-embed .modal-body { display: grid; }
    html.ws3-embed .modal-header-banner,
    html.ws3-embed .controls,
    html.ws3-embed .preview { grid-column: auto; grid-row: auto; }
}

/* ── Deep-link detail-first curtain ──
   A window booted with ?task_id exists to show the media detail. Until
   openDetail() fires, keep the workspace chrome invisible (page stays black —
   the ws3Boot spinner/error still shows) so the user never watches a whole
   workspace assemble before the detail pops over it. */
html.ws3-detail-boot #overlay { visibility: hidden; }

/* ── Skeleton loading state ──
   Applied by boot JS while config is in flight. Shimmer animation on key
   chrome elements so the user sees the workspace structure immediately
   instead of a blocking spinner. */
.ws3-skeleton .header-title,
.ws3-skeleton .header-sub,
.ws3-skeleton #ovcCostBtn,
.ws3-skeleton #aspectBtn,
.ws3-skeleton .mode-toggle {
  /* Bones sit barely above the chrome (#0d0d0d) — the surface itself stays
     almost invisible; what animates is a narrow specular sweep with a faint
     brand-red core, not a bright gray wash. Reads as "polished glass catching
     light", not "gray placeholder". */
  background:
    linear-gradient(105deg,
      transparent 40%,
      rgba(229, 57, 53, 0.05) 48%,
      rgba(255, 255, 255, 0.06) 50%,
      rgba(229, 57, 53, 0.05) 52%,
      transparent 60%),
    rgba(255, 255, 255, 0.03);
  background-size: 250% 100%, auto;
  background-repeat: no-repeat;
  animation: ws3-shimmer 2.4s cubic-bezier(.4, 0, .2, 1) infinite;
  color: transparent !important;
  /* Neutralize per-state chrome while loading: the checked .mode-toggle kept
     its accent ring, which read as a broken red-outlined empty box. */
  border-color: rgba(255, 255, 255, 0.06) !important;
  box-shadow: none !important;
  border-radius: 8px;
  pointer-events: none;
  min-width: 80px;
  min-height: 1.2em;
}
/* The cost chip lives INSIDE the red Gerar button — a gray bone there looks like
   debris. Shimmer it as a translucent darkening of the button itself. */
.ws3-skeleton #ovcCostBtn {
  background:
    linear-gradient(105deg,
      transparent 40%,
      rgba(255, 255, 255, 0.10) 50%,
      transparent 60%),
    rgba(0, 0, 0, 0.22);
  background-size: 250% 100%, auto;
  background-repeat: no-repeat;
  border-radius: 999px;
  min-width: 56px;
}
/* Hide the caret glyph inside skeletonized pseudo-selects so the bone reads clean. */
.ws3-skeleton .select-btn .select-caret { opacity: 0; }

/* Disable all user interaction when skeleton is active */
.ws3-skeleton {
  pointer-events: none !important;
}
.ws3-skeleton .header-title { min-width: 140px; }
.ws3-skeleton .header-sub  { min-width: 100px; min-height: 0.9em; }

@keyframes ws3-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ws3-skeleton .header-title,
  .ws3-skeleton .header-sub,
  .ws3-skeleton #ovcCostBtn,
  .ws3-skeleton #aspectBtn,
  .ws3-skeleton .mode-toggle,
  .canvas.loading::after { animation: none; }
  .modal, .gallery { transition: none; }
}

/* ── Multi-shot card styles ── */
.v3-multishot-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.v3-multishot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.v3-multishot-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}
.v3-multishot-remove {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
}
.v3-multishot-dur-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.v3-multishot-dur-label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.v3-multishot-dur-slider {
    flex: 1;
    accent-color: var(--accent);
}
.v3-multishot-dur-slider:focus-visible::-webkit-slider-thumb {
    outline: 2px solid #cf3b34;
    outline-offset: 2px;
}
.v3-multishot-dur-slider:focus-visible::-moz-range-thumb {
    outline: 2px solid #cf3b34;
    outline-offset: 2px;
}
.v3-multishot-dur-val {
    font-size: 13px;
    color: var(--text);
    min-width: 24px;
    text-align: center;
}
.v3-multishot-card textarea {
    min-height: 70px;
    font-size: 13px;
    width: 100%;
    padding: 9px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    resize: vertical;
}
.v3-multishot-add-maxed {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* Card gerando no mini-painel */
.history-item-generating {
  opacity: 0.7;
  cursor: pointer;
}
.history-item-generating:hover {
  opacity: 1;
}
.generating-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2, #141414);
  min-height: 56px;
  border-radius: 8px;
}
.generating-thumb .spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
}
.history-item-generating .history-meta {
  flex: 1;
}
.history-item-generating .history-prompt {
  color: var(--text-muted, #71717a);
  font-style: italic;
}

/* Card gerando na galeria */
.gen-card-generating {
  opacity: 0.8;
  cursor: pointer;
}
.gen-card-generating:hover {
  opacity: 1;
}
.gen-card-prompt-generating {
  color: var(--text-muted, #71717a);
  font-style: italic;
  display: flex;
  align-items: center;
}

/* ============================================================
   MASCOTE — Vigia (loading do canvas principal)
   Ported from "Mascote - Gerando (standalone).html" (Direção A).
   --mx-red inherits the workspace accent instead of hardcoding red.
   ============================================================ */
:root {
  --mx-red: var(--accent, #cf3b34);
  --mx-glow: 0.4;
  --mx-speed: 1;
}

.mxa-loading-wrap, .mxa-err-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: mxaFadeIn 0.35s ease both;
}
.mxa-err-wrap { gap: 14px; }
@keyframes mxaFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mxa {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 128px;
  font-family: var(--mono);
}
.mxa-sky {
  position: relative;
  width: 128px;
  height: 110px;
  overflow: hidden;
}
.mxa-ball {
  position: absolute;
  left: 32px;
  bottom: 8px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--mx-red);
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--mx-red) calc(var(--mx-glow) * 100%), transparent));
  animation: mxaBob calc(3.8s * var(--mx-speed)) ease-in-out infinite;
  /* Transição fluida entre estados: TODA pose estática vive em propriedades
     transicionáveis (bottom do think, geometria do flat) e desliza em vez de
     snapar. transform fica reservado pros loops de keyframe — e a troca de
     estado faz blend do transform mid-flight via JS (setMascotState).
     `transform` PRECISA estar nesta lista (e o JS NÃO pode setar transition
     inline): é ela que leva a pose congelada de volta ao neutro no blend, e
     um transition inline transform-only mataria bottom/geometria no meio da
     troca — o snap de 10px do think e o esmagão seco do flat. */
  transition:
    bottom 0.55s ease,
    left 0.55s ease,
    width 0.55s ease,
    height 0.55s ease,
    border-radius 0.55s ease,
    transform 0.4s ease;
}
.mxa-bar {
  width: 104px;
  height: 4px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--mx-red);
  box-shadow: 0 0 10px color-mix(in srgb, var(--mx-red) 50%, transparent);
  /* `translate` (propriedade separada do transform) carrega a POSE da barra
     (subir pra cabeça no balance) e transiciona; o transform fica livre pros
     loops de keyframe (float/rock/roll) sem um sobrescrever o outro.
     `transform` na lista = caminho do blend de volta ao neutro (ver .mxa-ball). */
  transition: width 0.4s ease, opacity 0.4s ease, translate 0.55s ease, transform 0.4s ease;
  animation: mxaBarFloat calc(3.8s * var(--mx-speed)) ease-in-out infinite;
}
@keyframes mxaBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes mxaBarFloat {
  0%, 100% { transform: translateY(0) scaleX(1); opacity: 1; }
  50%      { transform: translateY(1.5px) scaleX(0.955); opacity: 0.82; }
}

.mxa-eyes {
  position: absolute;
  inset: 0;
  /* bored/balance deslocam o olhar via transform fora de keyframe — transiciona. */
  transition: transform 0.45s ease;
}
.mxa-eye {
  position: absolute;
  top: 22px;
  width: 8px;
  height: 17px;
  border-radius: 4px;
  background: #150707;
  /* Borda declarada JÁ na base (largura 0, cor final): sem isso, a transição
     pro olho-arco do talk/party partia de border-color: currentColor — texto
     claro do canvas — e cada entrada nesses estados dava um flash de anel
     BRANCO nos olhos (a "piscada branca" reportada). */
  border: 0 solid #150707;
  animation: mxaBlink calc(4.6s * var(--mx-speed)) infinite;
  /* Transição fluida entre estados: geometria (tamanho/posição), cor e a
     rotação dos olhos tensos do err morfam em vez de snapar. Quando o estado
     tem keyframes de blink, a animação vence a transition no transform. */
  transition:
    top 0.4s ease,
    left 0.4s ease,
    right 0.4s ease,
    width 0.4s ease,
    height 0.4s ease,
    border-radius 0.4s ease,
    border-width 0.4s ease,
    background-color 0.4s ease,
    border-color 0.4s ease,
    transform 0.4s ease;
}
.mxa-eye.l { left: 16px; }
.mxa-eye.r { right: 16px; }
@keyframes mxaBlink {
  0%, 3%, 100% { transform: scaleY(1); }
  1.5%         { transform: scaleY(0.08); }
}

/* --- think: disco sobe, olhar varre, pontinhos sobem --- */
.mxa.think .mxa-ball {
  bottom: 18px;
  animation: mxaBob calc(5s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.think .mxa-eyes {
  animation: mxaScan calc(3.4s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.think .mxa-eye { height: 13px; animation: none; }
.mxa.think .mxa-bar { width: 88px; opacity: 0.8; }
/* 0%/100% neutros: o blend de estado (setMascotState) traz o transform pro
   repouso antes de soltar o loop — keyframes que já nascem deslocados dariam
   um pulinho seco na entrada. Vale pra TODO keyframe de transform daqui pra
   baixo (mxaSway, mxaBalance idem). */
@keyframes mxaScan {
  0%, 100%  { transform: translate(0, 0); }
  16%, 38%  { transform: translate(4px, -4px); }
  52%, 88%  { transform: translate(-4px, -4px); }
}
.mxa-dot {
  position: absolute;
  right: 18px;
  top: 30px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mx-red);
  /* Extra persistente: vive sempre no DOM, escondido. A animação (que inclui
     opacity nos keyframes) só é ligada no estado .think — ao sair dele, cai
     de volta pro opacity 0 base com transition (fade, não corte). */
  opacity: 0;
  transition: opacity 0.35s ease;
}
/* Longhands, NÃO a shorthand `animation:` — ela reseta todo longhand omitido,
   inclusive animation-delay, e este seletor (0,3,0) vence o .mxa-dot.d2/.d3
   (0,2,0) logo abaixo. Com a shorthand os três dots subiriam em uníssono em
   vez de escalonados. Mesmo cuidado em .mxa.sleep .mxa-z e .mxa.party .mxa-spark. */
.mxa.think .mxa-dot {
  animation-name: mxaRise;
  animation-duration: calc(2.1s * var(--mx-speed));
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.mxa-dot.d2 { right: 28px; animation-delay: calc(0.7s * var(--mx-speed)); }
.mxa-dot.d3 { right: 9px;  animation-delay: calc(1.4s * var(--mx-speed)); }
@keyframes mxaRise {
  0%   { opacity: 0; transform: translateY(10px) scale(0.5); }
  25%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-24px) scale(1.1); }
}

/* --- sleep (latente): zzz sobem --- */
.mxa-z {
  position: absolute;
  right: 16px;
  top: 26px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mx-red);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.mxa-z.z2 { right: 26px; top: 20px; font-size: 10px; animation-delay: calc(1.2s * var(--mx-speed)); }
.mxa.sleep .mxa-z {
  animation-name: mxaZzz;
  animation-duration: calc(2.4s * var(--mx-speed));
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes mxaZzz {
  0%   { opacity: 0; transform: translateY(8px); }
  30%  { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-18px); }
}

/* --- talk: usado quando o balão de piada aparece --- */
.mxa.talk .mxa-ball {
  animation: mxaTalkBob calc(1.6s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.talk .mxa-eye {
  width: 13px;
  height: 13px;
  top: 25px;
  background: transparent;
  border: 3.5px solid transparent;
  border-top-color: #150707;
  border-radius: 50%;
  animation: none;
}
.mxa.talk .mxa-eye.l { left: 13px; }
.mxa.talk .mxa-eye.r { right: 13px; }
@keyframes mxaTalkBob {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-4px); }
  60%      { transform: translateY(-1px); }
}

/* --- err: tremida, olhos tensos, alerta --- */
.mxa.err .mxa-ball {
  transform-origin: bottom center;
  animation: mxaTremble calc(2.6s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.err .mxa-eye { height: 13px; top: 23px; animation: none; }
.mxa.err .mxa-eye.l { transform: rotate(16deg); }
.mxa.err .mxa-eye.r { transform: rotate(-16deg); }
@keyframes mxaTremble {
  0%, 24%, 100% { transform: translateX(0) scaleY(1); }
  4%  { transform: translateX(-2.5px) scaleY(0.96); }
  8%  { transform: translateX(2.5px) scaleY(0.96); }
  12% { transform: translateX(-1.5px) scaleY(0.98); }
  16% { transform: translateX(1.5px) scaleY(0.98); }
  20% { transform: translateX(0) scaleY(1); }
}
.mxa-alert {
  position: absolute;
  right: 13px;
  top: 18px;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #100b0a;
  border: 1px solid #3a1414;
  color: var(--mx-red);
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  transform: rotate(8deg);
  /* Extra persistente: escondido fora do estado .err; entra/sai com fade. */
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mxa.err .mxa-alert {
  opacity: 1;
  animation: mxaAlert calc(1.3s * var(--mx-speed)) ease-in-out infinite;
}
@keyframes mxaAlert {
  0%, 100% { transform: rotate(8deg) scale(1); }
  50%      { transform: rotate(8deg) scale(1.12); }
}

/* --- party: pulos + fagulhas (flash de sucesso) --- */
.mxa.party .mxa-ball {
  animation: mxaHop calc(1.7s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.party .mxa-eye {
  width: 13px;
  height: 13px;
  top: 22px;
  background: transparent;
  border: 3.5px solid transparent;
  border-top-color: #150707;
  border-radius: 50%;
  animation: none;
}
.mxa.party .mxa-eye.l { left: 13px; }
.mxa.party .mxa-eye.r { right: 13px; }
.mxa.party .mxa-bar {
  animation: mxaBarHop calc(1.7s * var(--mx-speed)) ease-in-out infinite;
}
@keyframes mxaHop {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-18px); }
  52%      { transform: translateY(0); }
  68%      { transform: translateY(-7px); }
  82%      { transform: translateY(0); }
}
@keyframes mxaBarHop {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  30%      { transform: scaleX(0.9) translateY(1.5px); opacity: 0.75; }
  52%      { transform: scaleX(1.08); }
  68%      { transform: scaleX(0.96); }
}
.mxa-spark {
  position: absolute;
  width: 3px;
  height: 9px;
  border-radius: 2px;
  background: var(--mx-red);
  /* Extra persistente: escondido fora do .party; os keyframes (que animam
     opacity) só rodam dentro do estado, e a saída faz fade via transition. */
  opacity: 0;
  transition: opacity 0.3s ease;
}
.mxa.party .mxa-spark {
  animation-name: mxaSpark;
  animation-duration: calc(1.7s * var(--mx-speed));
  animation-timing-function: ease-out;
  animation-iteration-count: infinite;
}
.mxa-spark.s1 { left: 24px;  top: 12px; transform: rotate(-35deg); }
.mxa-spark.s2 { left: 62px;  top: 4px;  animation-delay: calc(0.08s * var(--mx-speed)); }
.mxa-spark.s3 { right: 24px; top: 12px; transform: rotate(35deg); animation-delay: calc(0.16s * var(--mx-speed)); }
.mxa-spark.s4 { left: 10px;  top: 32px; transform: rotate(-65deg); animation-delay: calc(0.1s * var(--mx-speed)); }
.mxa-spark.s5 { right: 10px; top: 32px; transform: rotate(65deg); animation-delay: calc(0.2s * var(--mx-speed)); }
@keyframes mxaSpark {
  0%, 28% { opacity: 0; }
  34%     { opacity: 1; }
  60%     { opacity: 0; transform: translateY(-10px) rotate(0deg); }
  100%    { opacity: 0; }
}
.mxa.party .mxa-spark.s1 { animation-name: mxaSparkL; }
.mxa.party .mxa-spark.s4 { animation-name: mxaSparkL; }
@keyframes mxaSparkL {
  0%, 28% { opacity: 0; }
  34%     { opacity: 1; }
  60%     { opacity: 0; transform: translate(-6px, -10px) rotate(-50deg); }
  100%    { opacity: 0; }
}

/* --- stare: olha pro espectador, pisca duplo --- */
.mxa.stare .mxa-eye {
  width: 9px;
  height: 19px;
  top: 20px;
  animation: mxaBlink2 calc(3.4s * var(--mx-speed)) infinite;
}
.mxa.stare .mxa-eye.l { left: 18px; }
.mxa.stare .mxa-eye.r { right: 18px; }
@keyframes mxaBlink2 {
  0%, 7%, 14%, 100% { transform: scaleY(1); }
  3.5%, 10.5%       { transform: scaleY(0.08); }
}

/* --- bored: pálpebras caindo, tudo mais lento --- */
.mxa.bored .mxa-ball { animation-duration: calc(5.5s * var(--mx-speed)); }
.mxa.bored .mxa-bar  { animation-duration: calc(5.5s * var(--mx-speed)); opacity: 0.78; }
.mxa.bored .mxa-eyes { transform: translateY(2px); }
.mxa.bored .mxa-eye {
  height: 8px;
  top: 27px;
  border-radius: 3px;
  animation: mxaBoredBlink calc(5s * var(--mx-speed)) infinite;
}
@keyframes mxaBoredBlink {
  0%, 6%, 100% { transform: scaleY(1); }
  3%           { transform: scaleY(0.1); }
  55%, 75%     { transform: scaleY(0.55); }
  85%          { transform: scaleY(1); }
}

/* --- roll: rola de um lado pro outro --- */
.mxa.roll .mxa-ball {
  animation: mxaRoll calc(5.6s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.roll .mxa-eye { animation: none; }
.mxa.roll .mxa-bar {
  animation: mxaRollBar calc(5.6s * var(--mx-speed)) ease-in-out infinite;
}
@keyframes mxaRoll {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25%      { transform: translateX(-30px) rotate(-200deg); }
  50%      { transform: translateX(0) rotate(0deg); }
  75%      { transform: translateX(30px) rotate(200deg); }
}
@keyframes mxaRollBar {
  0%, 50%, 100% { transform: translateX(0) scaleX(1); }
  25%           { transform: translateX(-12px) scaleX(0.94); }
  75%           { transform: translateX(12px) scaleX(0.94); }
}

/* --- balance: equilibra o horizonte na cabeça --- */
.mxa.balance .mxa-bar {
  /* A SUBIDA é pose (translate, transiciona — a barra desliza até a cabeça
     em vez de teleportar 80px); o keyframe só balança (rotate). */
  translate: 0 -80px;
  animation: mxaBalance calc(3s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.balance .mxa-ball {
  animation: mxaSway calc(3s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.balance .mxa-eyes { transform: translateY(-3px); }
@keyframes mxaBalance {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-7deg); }
  75%      { transform: rotate(7deg); }
}
@keyframes mxaSway {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(5px); }
  75%      { transform: translateX(-5px); }
}

/* --- flat: deitado, panqueca respirando ---
   A panqueca é GEOMETRIA (width/height/left/border-radius transicionam — o
   disco derrete até o chão em vez de esmagar num corte), não scale: o scale
   antigo distorcia os olhos junto (a "achatada esquisita"). Os olhos ganham
   pose própria e a respiração vira um scaleY sutil partindo do neutro. */
.mxa.flat .mxa-ball {
  left: 22px;
  width: 84px;
  height: 34px;
  border-radius: 17px;
  transform-origin: bottom center;
  animation: mxaFlatBreath calc(4.2s * var(--mx-speed)) ease-in-out infinite;
}
.mxa.flat .mxa-eye {
  height: 7px;
  top: 11px;
  border-radius: 3px;
  animation: mxaBoredBlink calc(5s * var(--mx-speed)) infinite;
}
@keyframes mxaFlatBreath {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.07); }
}

/* --- balão de fala (piadas) --- */
.mxa-bub {
  position: absolute;
  /* In Workspace V3 the bubble is appended inside .mxa, unlike the original
     standalone where it is a sibling in a taller wrapper. Anchor it above the
     complete mascot box so multi-line jokes never cover the Vigia's face.
     -12px (was 24px, then 4px): the box already has ~38px of empty sky above
     the ball's head, so any positive gap here just read as the bubble
     floating away from the character (reported twice: "aproximar balão de
     fala do boneco"). talk's bob is small (±4px, see mxaTalkBob), same as
     err's overlap below, so sinking the tail into that empty sky is safe. */
  top: auto;
  bottom: calc(100% - 12px);
  left: 50%;
  transform: translateX(-50%);
  transform-origin: bottom center;
  background: #100b0a;
  border: 1px solid #3a2f2b;
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--text-secondary, #e9e1d5);
  /* max-content keeps short jokes in a tight one-line bubble; the max-width is
     the ceiling where longer ones WRAP. This used to be white-space: nowrap
     ("one line, always") — written when the catalog was all short strings. The
     #1111/#1134 catalogs added 80+ char jokes: at 13px mono, 460px holds ~59
     chars, and with wrapping forbidden the box stopped growing while the text
     kept painting straight through both borders (worse on mobile, where the
     88vw ceiling bites even mid-length lines). Wrapping is safe here: the
     bubble is anchored above the mascot box precisely "so multi-line jokes
     never cover the Vigia's face" (see the top-anchor comment above), and
     .mxa-bub-detail (the error bubble's server-message line, arbitrary length)
     inherits this white-space too. */
  width: max-content;
  max-width: min(88vw, 460px);
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
  /* opacity is set explicitly (not left to mxaPop's fill) so the bubble is
     ALWAYS visible while it's in the DOM. Relying on the animation to fade in
     opacity 0→1 meant any state where mxaPop didn't reach its end — a
     backgrounded/throttled tab freezing the animation at time 0, reduced-motion
     stripping it, an interrupted paint — left the bubble stuck at opacity 0,
     present but invisible (the reported "as falas não aparecem"). mxaPop now
     animates transform only; opacity stays 1. */
  opacity: 1;
  animation: mxaPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 1;
}
/* No estado de erro o disco não pula (só treme no lugar), então o balão pode
   invadir o céu vazio acima da cabeça e ficar colado no Vigia. 16px de
   overlap ainda deixa o badge "!" (top: 18px) e a cabeça (top ~38px) livres. */
.mxa.err .mxa-bub { bottom: calc(100% - 16px); }
.mxa-bub-detail {
  display: block;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid #2a211e;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary, #8a8a8a);
}
.mxa-bub::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: #100b0a;
  border-right: 1px solid #3a2f2b;
  border-bottom: 1px solid #3a2f2b;
  transform: rotate(45deg);
}
@keyframes mxaPop {
  from { transform: translateX(-50%) translateY(8px) scale(0.6); }
  to   { transform: translateX(-50%) translateY(0) scale(1); }
}
/* Saída do balão: pop reverso (transform-only, espelho do mxaPop) aplicado
   via classe .mxa-bub-out ~220ms antes do remove — sem corte seco. Sem
   opacity aqui também: a regra do mxaPop (balão sempre visível enquanto no
   DOM) vale para a saída. */
.mxa-bub.mxa-bub-out { animation: mxaPopOut 0.22s ease-in both; }
@keyframes mxaPopOut {
  from { transform: translateX(-50%) translateY(0) scale(1); }
  to   { transform: translateX(-50%) translateY(8px) scale(0.6); }
}
.mxa-cur {
  display: inline-block;
  color: var(--mx-red);
  font-weight: 700;
  animation: mxaCur 1.1s steps(1) infinite;
}
@keyframes mxaCur {
  0%, 55%  { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ── Reduced motion ──
   Keep the workspace guard local as well as shared: this file is also layered
   directly by the standalone tool workspaces. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------- CUSTOM VIDEO PLAYER (ovp) ---------------- */
.ovp{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:#000;overflow:hidden}
.ovp.ovp-hidden{display:none}
.ovp video{width:100%;height:100%;object-fit:cover;display:block;cursor:pointer}
.detail-img-wrap .ovp{flex:1;align-self:stretch;min-height:0;background:transparent;border-radius:10px}
.detail-img-wrap .ovp video{width:auto;height:auto;max-width:100%;max-height:100%;object-fit:contain;border-radius:10px;background:#000}
.ovp-center{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:56px;height:56px;border-radius:50%;border:1px solid rgba(255,255,255,.14);background:rgba(8,8,10,.62);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;pointer-events:none;transition:opacity .18s ease,background .18s ease,transform .18s ease}
.ovp-center svg{width:20px;height:20px;margin-left:2px}
.ovp.is-paused .ovp-center{opacity:1;pointer-events:auto}
.ovp-center:hover{background:rgba(207,59,52,.82);border-color:rgba(255,255,255,.22);transform:translate(-50%,-50%) scale(1.06)}
.ovp-bar{position:absolute;left:10px;right:10px;bottom:10px;margin:0 auto;max-width:520px;display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:12px;background:rgba(8,8,10,.72);border:1px solid rgba(255,255,255,.08);box-shadow:0 4px 18px rgba(0,0,0,.45);opacity:1;transition:opacity .25s ease,transform .25s ease}
.ovp.is-idle .ovp-bar{opacity:0;transform:translateY(6px);pointer-events:none}
.ovp.is-idle .ovp-center{opacity:0;pointer-events:none}
.ovp.is-idle video{cursor:none}
.ovp-btn{flex:0 0 auto;display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:8px;border:none;background:transparent;color:rgba(255,255,255,.85);cursor:pointer;padding:0;transition:color .15s ease,background .15s ease}
.ovp-btn:hover{color:#fff;background:rgba(255,255,255,.08)}
.ovp-play:hover{color:#ec5842}
.ovp-time{flex:0 0 auto;font-family:var(--sans);font-size:10.5px;font-variant-numeric:tabular-nums;letter-spacing:.02em;color:rgba(255,255,255,.6);min-width:30px;text-align:center}
.ovp-seek{-webkit-appearance:none;appearance:none;flex:1;min-width:40px;height:4px;border-radius:2px;background:linear-gradient(90deg,var(--accent,#cf3b34) var(--percent,0%),rgba(255,255,255,.16) var(--percent,0%));outline:none;cursor:pointer;margin:0}
.ovp-seek::-webkit-slider-thumb{-webkit-appearance:none;width:11px;height:11px;border-radius:50%;background:#fff;border:none;cursor:pointer;box-shadow:0 1px 4px rgba(0,0,0,.5);transition:transform .12s ease,background .12s ease}
.ovp-seek::-moz-range-thumb{width:11px;height:11px;border-radius:50%;background:#fff;border:none;cursor:pointer;box-shadow:0 1px 4px rgba(0,0,0,.5)}
.ovp-seek:hover::-webkit-slider-thumb,.ovp-seek:active::-webkit-slider-thumb{background:var(--accent);transform:scale(1.15)}
.ovp-seek:hover::-moz-range-thumb,.ovp-seek:active::-moz-range-thumb{background:var(--accent)}
.ovp-seek:focus-visible{box-shadow:0 0 0 2px rgba(var(--accent-rgb),.5)}
@media (max-width:639px){
  .ovp-bar{left:6px;right:6px;bottom:6px;gap:6px;padding:5px 8px}
  .ovp-time.ovp-dur{display:none}
}
/* Compact pill inside small multi-cell grids: drop times to keep the seek usable */
.result-grid:not(.single) .ovp-time{display:none}
.result-grid:not(.single) .ovp-bar{max-width:none;left:8px;right:8px;bottom:8px;gap:6px;padding:5px 8px}
.ovp:fullscreen{width:100%;height:100%}
.ovp:fullscreen video{object-fit:contain}

/* ---------------- IMAGE VIEWER (oiv) ---------------- */
.detail-img-wrap.oiv-wrap{overflow:hidden}
.oiv-wrap img#detailImg{object-fit:contain;cursor:zoom-in;will-change:transform;transform-origin:center center;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}
.oiv-wrap.oiv-zoomed img#detailImg{cursor:grab}
.oiv-wrap.oiv-grabbing img#detailImg{cursor:grabbing}
.oiv-bar{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);display:flex;align-items:center;gap:6px;padding:5px 8px;border-radius:12px;background:rgba(8,8,10,.72);border:1px solid rgba(255,255,255,.08);box-shadow:0 4px 18px rgba(0,0,0,.45);opacity:0;pointer-events:none;transition:opacity .2s ease,transform .2s ease;z-index:3}
.oiv-wrap:hover .oiv-bar,.oiv-wrap:focus-within .oiv-bar,.oiv-wrap.oiv-zoomed .oiv-bar{opacity:1;pointer-events:auto}
.oiv-wrap img#detailImg[hidden] ~ .oiv-bar{display:none}
.oiv-btn{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:8px;border:none;background:transparent;color:rgba(255,255,255,.85);cursor:pointer;padding:0;transition:color .15s ease,background .15s ease}
.oiv-btn:hover{color:#fff;background:rgba(255,255,255,.08)}
.oiv-pct{min-width:46px;height:26px;padding:0 6px;border:none;background:transparent;color:rgba(255,255,255,.8);font-family:var(--sans);font-size:11px;font-variant-numeric:tabular-nums;letter-spacing:.02em;cursor:pointer;border-radius:8px;transition:color .15s ease,background .15s ease}
.oiv-pct:hover{color:#fff;background:rgba(255,255,255,.08)}
.oiv-sep{width:1px;height:16px;background:rgba(255,255,255,.12);margin:0 2px}
.detail-img-wrap:fullscreen{background:#0a0a0b;padding:28px}
.detail-img-wrap:fullscreen img#detailImg{border-radius:6px}
@media (max-width:639px){.oiv-bar{bottom:10px;opacity:1;pointer-events:auto}}

/* ============================================================================
   RESPONSIVE PASS — mobile / tablet
   ----------------------------------------------------------------------------
   One consolidated block, appended last so it outranks the per-component
   tweaks scattered above without having to raise anyone's specificity.

   Breakpoints:
     base            → phone (the narrow rules live in the ≤640 block)
     641–1024px      → tablet
     ≥1025px         → desktop (the rules above this block, untouched)
   Plus a pointer-based block for touch affordances, which is orthogonal to
   width: a 1024px iPad and a 375px phone both need it, a 375px-wide desktop
   window does not.
   ============================================================================ */

/* ── Touch: hover-only affordances must not be invisible ──
   These controls live at opacity:0 until :hover. On a touch screen there is no
   hover, so they were unreachable — the per-cell delete/download on results and
   the per-row delete in the history list. */
@media (hover:none) {
  .img-del,
  .img-download-single { opacity: 1; }
  .hist-del { opacity: .6; }
}

/* ── Touch: 44px minimum targets ──
   Sized by pointer coarseness rather than viewport width. Everything below is
   under 44px in at least one axis at desktop sizes. */
@media (pointer:coarse) {
  .modal-header-banner .header-right .btn-ghost { min-height: 44px; }
  .mode-toggle { min-height: 44px; }
  .select-btn { min-height: 44px; }
  .x-btn { width: 44px; height: 44px; }
  .history-header { min-height: 44px; }
  .history-all { min-height: 44px; }
  .hist-del { min-width: 40px; min-height: 40px; }
  .v2-ctx-option { min-height: 44px; }
  .oiv-btn { width: 40px; height: 40px; }
  .oiv-pct { height: 40px; }
  .crop-btn-cancel,
  .crop-btn-skip,
  .crop-btn-confirm,
  .crop-reset-btn,
  .crop-rotate-btn,
  .crop-close-btn { min-height: 44px; }
  /* The ✕ sits inside a 54px thumbnail — growing the box would cover the
     image, so grow only the hit area, and asymmetrically: mostly outward
     (up/right, into the cell's own padding) rather than inward, or a tap on
     the top-right corner of the picture would REMOVE the reference instead of
     opening it. */
  .thumb-remove::after {
    content: '';
    position: absolute;
    inset: -10px -10px -6px -6px;
  }
}

/* ── Dropdown menus: never taller than the screen ──
   .v2-ctx-menu had no max-height, so a long list (aspects, presets, versions)
   ran off the bottom of a phone with no way to scroll to the last option.

   :not() on the two menus that already set their OWN cap — .dm-folder-menu
   (260px) and .alt-model-menu (60vh) both carry .v2-ctx-menu as well, and a
   bare .v2-ctx-menu rule here has equal specificity but comes later in the
   file, so it would silently override both. Those caps are deliberate; this
   rule is only for the menus that had none.

   50dvh, not 70: openMenu() flips a menu that would overflow the bottom to
   sit ABOVE its anchor, so a menu tall enough to reach the bottom from a
   mid-screen anchor is also tall enough to run off the TOP once flipped.
   (The flip now clamps to the viewport top too — see workspacev3.js — but
   keeping the menu short enough to fit either way is the real fix.) */
.v2-ctx-menu:not(.dm-folder-menu):not(.alt-model-menu) {
  max-height: min(50dvh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.dm-folder-menu, .alt-model-menu {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ============================ TABLET: 641–1024px ============================ */
@media (min-width: 641px) and (max-width: 1024px) {
  /* 360px of a 768px viewport left the preview column starved. */
  .modal-body { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); }
  .overlay { padding: 14px; }
  /* The banner wrapped into a ragged two-line block: the subtitle wrapped
     under the title AND the action buttons wrapped under each other. */
  .modal-header-banner .header-sub { display: none; }
  .modal-header-banner .header-right .btn-ghost { white-space: nowrap; }
  .modal-header-banner .header-title { font-size: clamp(14px, 2vw, 18px); }
}

/* ============================== PHONE: ≤640px ============================== */
@media (max-width: 640px) {
  /* 20px of padding on each side cost 11% of a 375px screen. */
  .overlay { padding: 8px; }

  /* dvh, not vh: mobile Safari's vh is the *expanded* viewport, so the bottom
     of the modal (the Gerar button) sat under the URL bar until you scrolled. */
  .modal {
    height: calc(100dvh - var(--header-h) - 16px);
    max-height: calc(100dvh - var(--header-h) - 16px);
  }

  /* ── Header banner: two rows ──
     Was one row with a non-shrinking .header-right. Its four buttons needed
     368px inside a 333px box, so .header-left (logo + model name) was squeezed
     to *zero* width — the model name vanished entirely — and "← Voltar" was
     pushed off the right edge, out of reach. Now: identity on row 1, the four
     actions sharing row 2 at equal width. */
  .modal-header-banner {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 12px;
  }
  .modal-header-banner .header-left {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }
  .modal-header-banner .header-right {
    order: 2;
    flex: 1 1 100%;
    margin-left: 0;
    gap: 6px;
  }
  .modal-header-banner .header-right .btn-ghost {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 4px;
    font-size: 9px;
    letter-spacing: .02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* block, not the inherited inline-flex: text-overflow:ellipsis needs a
       block container. That drops .btn-ghost's justify-content, so the label
       has to be re-centred explicitly. */
    display: block;
    text-align: center;
    line-height: 32px;
  }

  /* ── One scroll container, not two ──
     .controls (max-height:55vh, own scrollbar) stacked above .preview (own
     scrollbar) meant a flick in the wrong half scrolled the wrong panel, and
     the preview was permanently squashed into whatever 45vh was left. The
     stacked layout now scrolls as a single document. */
  .modal-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  .controls {
    max-height: none;
    overflow: visible;
    flex: 0 0 auto;
    padding: 14px 14px 18px;
  }
  .preview {
    overflow: visible;
    flex: 0 0 auto;
    padding: 14px;
  }
  html.ws3-embed .modal-body { display: flex; }

  /* The canvas kept a 340px floor inside a container that no longer had 340px
     to give, so it overflowed its own panel. */
  .canvas { min-height: clamp(200px, 34dvh, 320px); }

  /* Generate is the whole point of the screen — keep it reachable without
     scrolling back down past the history panel. */
  .actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, #0b0808 22%);
  }

  /* Fluid type — big desktop sizes reflowed into 3-line headings on a phone. */
  .modal-header-banner .header-title { font-size: clamp(13px, 3.6vw, 16px); }
  .gallery-head .title,
  .modal-head .title { font-size: clamp(15px, 4.2vw, 19px); }
  .empty p { font-size: clamp(12px, 3.4vw, 14px); max-width: 30ch; }
  .empty { padding: 24px 16px; }

  /* First/last frame slots: two dropzones side by side left ~140px each, so
     the labels wrapped to three lines. Stack them. */
  .frames-row { flex-direction: column; gap: 10px; }

  /* Fixed decoration parked over the sticky Generate button. */
  .dev-tag { display: none; }

  .gallery { max-height: calc(100dvh - var(--header-h) - 16px); }
  .gallery-body { padding: 12px; }
  .gallery-head { padding: 12px 14px; }

  .confirm-toast {
    left: 8px;
    right: 8px;
    min-width: 0;
    max-width: none;
    transform: translateY(16px);
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .confirm-toast.show { transform: translateY(0); }
}

/* ── App header: reclaim the top bar ──
   .logo-text carries .5em letter-spacing and the block has 24px of padding
   either side, so "overlook" alone ate 207px of a 375px screen. */
@media (max-width: 640px) {
  #app-header .header-left { padding: 0 14px; }
  #app-header .header-right { padding: 0 14px; }
  #app-header .logo-text { font-size: 12px; letter-spacing: .28em; margin-left: 10px; }
}

/* ── Crop modal ── */
@media (max-width: 640px) {
  .crop-panel { width: calc(100vw - 16px); max-height: calc(100dvh - 24px); }
  .crop-header { padding: 12px 14px; }
  .crop-subtitle { display: none; }
  .crop-actions { margin-left: 0; width: 100%; }
  .crop-actions button { flex: 1 1 0; }
  .crop-ar-select { min-height: 44px; padding: 8px 28px 8px 12px; }
  /* Corner handles were 14px squares — nearly impossible to grab with a thumb.
     The offsets are half the size, so they have to move with it or the handle
     stops straddling the selection corner. */
  .crop-handle { width: 22px; height: 22px; }
  .crop-handle-nw { top: -11px; left: -11px; }
  .crop-handle-ne { top: -11px; right: -11px; }
  .crop-handle-sw { bottom: -11px; left: -11px; }
  .crop-handle-se { bottom: -11px; right: -11px; }
}
