/* H Engine studios · on-device image generation, video upscale, lyric auto-sync.
   Uses the site tokens (--blue, --ink, --muted, --line, --theme-*) so light/dark follow theme.css. */
.he{--he-accent:#2f6ae0;--he-well:#1d2027;--he-well-2:#262a33;--he-well-ink:#e9ecf2;--he-ok:#1f9d6b;--he-warn:#c98a12;--he-err:#d14343;--he-radius:14px;--he-shadow:0 1px 0 #1f26330a,0 12px 32px -18px #1f263340;
  max-width:1480px;margin:22px auto 72px;padding:0 24px;color:var(--ink);font-variant-numeric:tabular-nums}
html[data-theme="dark"] .he{--he-well:#0d1016;--he-well-2:#161b24;--he-shadow:0 1px 0 #0006,0 16px 40px -20px #000a}
html[data-theme="dark"] .he-stage-wrap{box-shadow:0 0 0 1px var(--line),0 16px 40px -20px #000a}
.he *{box-sizing:border-box}
.he button{font:inherit;color:inherit}
.he :focus-visible{outline:3px solid #a4c4ff;outline-offset:2px}

/* header */
.he-head{display:flex;align-items:flex-end;gap:18px;flex-wrap:wrap;margin:0 0 18px}
.he-head-main{flex:1 1 360px;min-width:0}
.he-back{display:inline-block;color:var(--muted);font-size:13px;margin-bottom:10px}
.he-back:hover{color:var(--blue)}
.he-head h1{margin:0;font-size:clamp(28px,3.2vw,40px);line-height:1.15;letter-spacing:-1.2px;font-weight:750}
.he-head p{margin:8px 0 0;color:var(--muted);font-size:15px;line-height:1.55;max-width:62ch}
.he-head-side{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.he-chip-device{display:inline-flex;align-items:center;gap:9px;min-height:40px;padding:0 14px;border:1px solid var(--line);border-radius:999px;background:var(--theme-surface,#fff);font-size:13px;white-space:nowrap;max-width:100%}
.he-chip-device b{font-weight:650}
.he-chip-device small{color:var(--muted)}
.he-dot{width:8px;height:8px;border-radius:50%;background:#9aa2af;flex:none}
.he-dot[data-state="pro"],.he-dot[data-state="standard"],.he-dot[data-state="on"]{background:var(--he-ok)}
.he-dot[data-state="lite"],.he-dot[data-state="busy"]{background:var(--he-warn)}
.he-dot[data-state="none"],.he-dot[data-state="off"]{background:var(--he-err)}
.he-dot[data-state="busy"]{animation:he-pulse 1.2s ease-in-out infinite}
@keyframes he-pulse{50%{opacity:.35}}

/* layout */
.he-grid{display:grid;grid-template-columns:minmax(300px,370px) minmax(0,1fr) minmax(220px,280px);gap:16px;align-items:start}
.he-grid.he-grid-2{grid-template-columns:minmax(300px,380px) minmax(0,1fr)}
@media (max-width:1240px){.he-grid{grid-template-columns:minmax(290px,350px) minmax(0,1fr)}.he-grid>.he-side-right{grid-column:1/-1}}
@media (max-width:820px){.he{padding:0 16px}.he-grid,.he-grid.he-grid-2{grid-template-columns:minmax(0,1fr)}}
.he-panel{background:var(--theme-surface,#fff);border:1px solid var(--line);border-radius:var(--he-radius);box-shadow:var(--he-shadow);padding:20px;min-width:0}
.he-panel+.he-panel{margin-top:14px}
.he-panel h2{margin:0 0 14px;font-size:16px;letter-spacing:-.2px;font-weight:700;display:flex;align-items:center;gap:8px;justify-content:space-between}
.he-panel h2 small{font-weight:500;color:var(--muted);font-size:12px}
.he-sec{padding:16px 0;border-top:1px solid var(--line)}
.he-sec:first-of-type{border-top:0;padding-top:0}
.he-sec h3{margin:0 0 10px;font-size:13px;font-weight:700;display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.he-sec h3 small{font-weight:500;color:var(--muted);font-size:12px}
.he-help{margin:8px 0 0;color:var(--muted);font-size:12px;line-height:1.6}
.he-help a{color:var(--blue);text-decoration:underline;text-underline-offset:2px}

/* form */
.he-field{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:600;color:var(--ink);margin:0 0 10px;min-width:0}
.he-field>span{display:flex;justify-content:space-between;gap:8px}
.he-field>span output,.he-field>span small{font-weight:500;color:var(--muted)}
.he textarea,.he input[type=text],.he input[type=number],.he select{width:100%;border:1px solid var(--line);border-radius:10px;padding:10px 12px;background:var(--theme-control,#fff);color:var(--ink);font:inherit;font-size:14px;font-weight:400;min-height:40px}
.he textarea{resize:vertical;line-height:1.55;min-height:112px}
.he textarea:focus,.he input:focus,.he select:focus{border-color:var(--blue);outline:none;box-shadow:0 0 0 3px #4c86fb26}
.he input[type=range]{width:100%;accent-color:var(--blue)}
.he input[type=color]{width:40px;height:36px;padding:2px;border:1px solid var(--line);border-radius:8px;background:var(--theme-control,#fff)}
.he-row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.he-row3{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.he-inline{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.he-check{display:flex;gap:9px;align-items:flex-start;font-size:13px;line-height:1.5;cursor:pointer;margin:6px 0}
.he-check input{margin-top:3px;accent-color:var(--blue)}
.he-count{display:block;text-align:right;color:var(--muted);font-size:11px;font-weight:500;margin-top:4px}

/* segmented + chips */
.he-seg{display:flex;flex-wrap:wrap;gap:4px;padding:4px;border:1px solid var(--line);border-radius:11px;background:var(--theme-soft,#f3f5fa)}
.he-seg button{flex:1 1 0;min-height:36px;padding:0 10px;border-radius:8px;border:0;background:transparent;font-size:13px;font-weight:600;color:var(--muted);cursor:pointer;white-space:nowrap}
.he-seg button[aria-pressed="true"]{background:var(--theme-surface,#fff);color:var(--ink);box-shadow:0 1px 2px #1f263322,0 0 0 1px var(--line)}
.he-seg button:disabled{opacity:.45;cursor:not-allowed}
.he-seg button small{display:block;font-weight:500;font-size:10px;color:var(--muted);line-height:1.2}
.he-seg.he-seg-tall button{padding:7px 8px;line-height:1.25}
.he-chips{display:flex;flex-wrap:wrap;gap:6px}
.he-chips button{border:1px solid var(--line);border-radius:999px;padding:7px 12px;background:var(--theme-surface,#fff);font-size:12.5px;cursor:pointer;min-height:34px}
.he-chips button:hover{border-color:var(--blue)}
.he-chips button[aria-pressed="true"]{background:var(--theme-accent-soft,#eaf1ff);border-color:var(--blue);color:var(--blue);font-weight:650}

/* buttons */
.he-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:42px;padding:0 16px;border-radius:10px;border:1px solid var(--line);background:var(--theme-surface,#fff);font-size:14px;font-weight:650;cursor:pointer;text-decoration:none;white-space:nowrap}
.he-btn:hover:not(:disabled){border-color:var(--blue);color:var(--blue)}
.he-btn:disabled{opacity:.5;cursor:not-allowed}
.he-btn svg{width:17px;height:17px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.he-btn-primary{background:var(--he-accent);border-color:var(--he-accent);color:#fff}
.he-btn-primary:hover:not(:disabled){filter:brightness(1.06);color:#fff}
.he-btn-big{min-height:52px;font-size:15.5px;width:100%;border-radius:12px}
.he-btn-quiet{border-color:transparent;background:transparent;color:var(--muted);padding:0 10px}
.he-btn-danger:hover:not(:disabled){border-color:var(--he-err);color:var(--he-err)}
.he-btn-row{display:flex;gap:8px;flex-wrap:wrap}
.he-btn-row>.he-btn{flex:1 1 auto}
kbd{font:600 11px/1 inherit;padding:2px 5px;border:1px solid var(--line);border-bottom-width:2px;border-radius:4px;color:var(--muted)}

/* stage */
.he-stage-wrap{background:var(--he-well);border-radius:var(--he-radius);overflow:hidden;box-shadow:var(--he-shadow);color:var(--he-well-ink);display:flex;flex-direction:column;min-width:0}
.he-stage{position:relative;min-height:min(70vh,640px);display:grid;place-items:center;padding:18px;overflow:hidden;isolation:isolate}
.he-stage canvas,.he-stage img,.he-stage video{max-width:100%;max-height:min(66vh,600px);display:block;border-radius:6px;box-shadow:0 18px 50px -18px #000c}
.he-stage-empty{text-align:center;max-width:380px;color:#aeb5c2;font-size:14px;line-height:1.6}
.he-stage-empty b{display:block;color:var(--he-well-ink);font-size:18px;margin-bottom:6px;letter-spacing:-.3px}
.he-stage-empty svg{width:44px;height:44px;stroke:#6f7a8c;fill:none;stroke-width:1.4;margin-bottom:10px}
.he-stage-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 12px;background:var(--he-well-2);border-top:1px solid #ffffff10}
.he-stage-bar .he-btn{background:#ffffff0d;border-color:#ffffff1f;color:var(--he-well-ink);min-height:38px;font-size:13px}
.he-stage-bar .he-btn:hover:not(:disabled){border-color:#8fb2ff;color:#fff}
.he-stage-bar .he-btn-primary{background:var(--he-accent);border-color:var(--he-accent)}
.he-stage-meta{margin-left:auto;font-size:12px;color:#aeb5c2;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
.he-stage-veil{position:absolute;inset:0;display:grid;place-items:center;background:#0d1016b8;backdrop-filter:blur(2px);z-index:3;text-align:center;padding:24px}
.he-stage-veil[hidden]{display:none}
.he-veil-box{width:min(420px,100%)}
.he-veil-box>b{display:block;font-size:16px;margin-bottom:6px}
.he-veil-box p{margin:0 0 14px;color:#b9c0cc;font-size:13px;line-height:1.55}

/* progress */
.he-progress{height:6px;border-radius:99px;background:#7f8aa033;overflow:hidden}
.he-progress>i{display:block;height:100%;width:0;background:var(--blue);border-radius:inherit;transition:width .25s ease}
.he-progress.is-indeterminate>i{width:35%;animation:he-indet 1.3s ease-in-out infinite}
@keyframes he-indet{0%{transform:translateX(-110%)}100%{transform:translateX(320%)}}
.he-progress-meta{display:flex;justify-content:space-between;gap:10px;margin-top:7px;font-size:12px;color:var(--muted)}
.he-stage .he-progress-meta{color:#b9c0cc}

/* compare slider */
.he-compare{position:relative;display:inline-block;max-width:100%;line-height:0;touch-action:none;user-select:none}
.he-compare img{max-height:min(66vh,600px)}
.he-compare .he-compare-top{position:absolute;inset:0;overflow:hidden;clip-path:inset(0 calc(100% - var(--split,50%)) 0 0)}
.he-compare .he-compare-top img{width:100%;height:100%;object-fit:contain;box-shadow:none}
.he-compare-handle{position:absolute;top:0;bottom:0;left:var(--split,50%);width:2px;background:#fff;transform:translateX(-1px);box-shadow:0 0 0 1px #0004;pointer-events:none}
.he-compare-handle:after{content:"";position:absolute;top:50%;left:50%;width:30px;height:30px;margin:-15px;border-radius:50%;background:#fff;box-shadow:0 2px 10px #0006}
.he-compare-label{position:absolute;top:10px;padding:4px 8px;border-radius:6px;background:#000a;color:#fff;font-size:11px;line-height:1.3;pointer-events:none}
.he-compare-label.l{left:10px}.he-compare-label.r{right:10px}

/* setup card */
.he-setup{background:var(--theme-surface,#fff);border:1px solid var(--line);border-radius:var(--he-radius);padding:18px;color:var(--ink);text-align:left}
.he-setup h3{margin:0 0 4px;font-size:16px}
.he-setup>p{margin:0 0 12px;color:var(--muted);font-size:13px;line-height:1.55}
.he-asset{display:grid;grid-template-columns:1fr auto;gap:2px 10px;padding:10px 0;border-top:1px solid var(--line);font-size:13px}
.he-asset b{font-weight:600}
.he-asset:first-of-type{border-top:0}
.he-asset span{color:var(--muted);font-size:12px;text-align:right}
.he-asset .he-progress{grid-column:1/-1;margin-top:6px;height:4px}
.he-asset[data-state="ready"] span{color:var(--he-ok)}
.he-setup-total{display:flex;justify-content:space-between;font-size:13px;font-weight:650;margin:10px 0 14px;padding-top:10px;border-top:1px solid var(--line)}

/* gallery */
.he-gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:8px}
.he-thumb{position:relative;aspect-ratio:1;border-radius:9px;overflow:hidden;border:1px solid var(--line);background:var(--theme-soft,#eef1f6);cursor:pointer;padding:0}
.he-thumb img{width:100%;height:100%;object-fit:cover;display:block}
.he-thumb[aria-current="true"]{outline:3px solid var(--blue);outline-offset:1px}
.he-thumb small{position:absolute;left:5px;bottom:5px;padding:2px 5px;border-radius:5px;background:#000a;color:#fff;font-size:10px}
.he-empty-note{color:var(--muted);font-size:13px;line-height:1.6;margin:0}

/* candidates strip under stage */
.he-strip{display:flex;gap:8px;padding:10px 12px;background:var(--he-well-2);border-top:1px solid #ffffff10;overflow-x:auto}
.he-strip[hidden]{display:none}
.he-strip button{flex:none;width:76px;height:76px;padding:0;border-radius:8px;overflow:hidden;border:2px solid transparent;background:#0003;cursor:pointer}
.he-strip button[aria-current="true"]{border-color:#8fb2ff}
.he-strip img{width:100%;height:100%;object-fit:cover;display:block}

/* text layer overlay */
.he-overlay{position:absolute;inset:0;pointer-events:none}
.he-layer-handle{position:absolute;pointer-events:auto;cursor:move;border:1px dashed #ffffffb0;border-radius:4px;box-shadow:0 0 0 1px #0005}
.he-layer-handle[hidden]{display:none}

/* status line */
.he-status{font-size:13px;color:var(--muted);margin:10px 0 0;min-height:20px;line-height:1.5}
.he-status.is-error{color:var(--he-err)}
.he-status.is-ok{color:var(--he-ok)}

/* dialog */
.he-dialog{border:1px solid var(--line);border-radius:16px;padding:0;width:min(560px,calc(100vw - 32px));background:var(--theme-surface,#fff);color:var(--ink);box-shadow:0 30px 80px -20px #0008}
.he-dialog::backdrop{background:#0c111b80}
.he-dialog-body{padding:22px}
.he-dialog h2{margin:0 0 6px;font-size:19px}
.he-dialog table{width:100%;border-collapse:collapse;font-size:13px;margin:12px 0}
.he-dialog td{padding:9px 4px;border-top:1px solid var(--line);vertical-align:middle}
.he-dialog td:last-child{text-align:right;white-space:nowrap}
.he-dialog .he-dialog-foot{display:flex;justify-content:space-between;gap:8px;padding:14px 22px;border-top:1px solid var(--line);flex-wrap:wrap}

/* video specifics */
.he-drop{border:1.5px dashed #ffffff40;border-radius:12px;padding:38px 24px;text-align:center;color:#c3c9d4;cursor:pointer;width:min(560px,100%)}
.he-drop.is-over{border-color:#8fb2ff;background:#8fb2ff14}
.he-drop b{display:block;color:var(--he-well-ink);font-size:18px;margin-bottom:6px}
.he-facts{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:13px;margin:0}
.he-facts dt{color:var(--muted)}
.he-facts dd{margin:0;text-align:right;font-weight:600;overflow-wrap:anywhere}
.he-duo{display:grid;grid-template-columns:1fr 1fr;gap:10px;width:100%;align-items:center}
.he-duo figure{margin:0;min-width:0;position:relative}
.he-duo figcaption{position:absolute;z-index:2;left:8px;top:8px;padding:3px 7px;border-radius:6px;background:#000b;color:#fff;font-size:11px}
.he-duo video,.he-duo canvas,.he-duo img{width:100%;max-height:min(58vh,540px);object-fit:contain;background:#000}
@media (max-width:820px){.he-duo{grid-template-columns:1fr}}
.he-duo-hint{position:absolute;inset:0;display:grid;place-items:center;text-align:center;padding:18px;color:#9aa3b2;font-size:13px;line-height:1.6;pointer-events:none}
.he-duo-hint[hidden]{display:none}
.he-tilemap{position:absolute;inset:0;display:grid;pointer-events:none}
.he-tilemap i{border:1px solid #8fb2ff33;transition:background .2s}
.he-tilemap i.on{background:#8fb2ff26}
.he-time{display:flex;gap:8px;align-items:center}
.he-time input{flex:1}

/* lyric auto-sync block (inside the lyric studio sidebar) */
.he-sync{margin:10px 0;padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--theme-soft,#f4f6fb)}
.he-sync b{font-size:13px}
.he-sync p{margin:4px 0 10px;font-size:12px;color:var(--muted);line-height:1.5}
.he-sync .he-row{margin-bottom:8px}
.he-sync select{min-height:34px;padding:6px 8px;font-size:12.5px}
.he-sync .he-btn{min-height:38px;font-size:13px;width:100%}
.he-sync .he-progress{margin-top:10px}

@media (prefers-reduced-motion:reduce){.he *{animation:none!important;transition:none!important}}

/* Audio converter */
.he-audio-list{display:flex;flex-direction:column;gap:12px;min-height:420px;transition:outline-color .15s;outline:2px dashed transparent;outline-offset:-6px}
.he-audio-list.he-audio-over{outline-color:var(--he-accent)}
.he-audio-bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.he-audio-bar>b{font-size:15px}
.he-audio-bar-actions{margin-left:auto;display:flex;gap:6px;flex-wrap:wrap}
.he-audio-drop{border-color:var(--line);color:var(--muted);display:flex;flex-direction:column;gap:6px;align-items:center;justify-content:center;text-align:center;min-height:220px;cursor:pointer;background:transparent}
.he-audio-drop b{color:var(--text,inherit);font-size:15px}
.he-audio-drop span{font-size:12.5px}
.he-audio-drop:focus-visible{outline:2px solid var(--he-accent);outline-offset:2px}
.he-audio-drop-compact{min-height:0;padding:12px;flex-direction:row;gap:10px}
.he-audio-drop-compact span{display:none}
.he-audio-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.he-audio-item{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:var(--theme-surface,#fff)}
.he-audio-item[data-state="running"]{border-color:var(--he-accent)}
.he-audio-item[data-state="error"]{border-color:#d9534f66}
.he-audio-main{min-width:0;display:flex;flex-direction:column;gap:4px}
.he-audio-main b{font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.he-audio-main small{color:var(--muted);font-size:12px}
.he-audio-main audio{width:100%;max-width:420px;height:32px;margin-top:4px}
.he-audio-main .he-progress{margin-top:4px}
.he-audio-side{display:flex;align-items:center;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.he-audio-to{font-size:13px;font-weight:600;color:var(--he-accent)}
.he-audio-to small{display:block;font-weight:400;color:var(--muted);font-size:11.5px;text-align:right}
.he-audio-ok{font-size:12.5px;color:#1f8a4c;font-weight:600}
.he-audio-pct{font-variant-numeric:tabular-nums;font-weight:600;font-size:13px}
.he-audio-err{color:#c0392b}
@media (max-width:700px){.he-audio-item{grid-template-columns:1fr}.he-audio-side{justify-content:flex-start}.he-audio-bar-actions{margin-left:0}}
