:root{--bg:#0b0b0f;--panel:#15151c;--panel2:#1d1d26;--line:#2a2a36;--text:#ececf1;--muted:#8d8d9c;--accent:#f4f4f5;--ok:#3ecf8e;--err:#ff5d6c;--run:#f5b84a;--r:18px}
*{box-sizing:border-box}html,body{margin:0;background:var(--bg);color:var(--text);font:15px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
a{color:var(--text)}code{background:var(--panel2);padding:1px 6px;border-radius:6px;font-size:.9em;word-break:break-all}
.top{display:flex;align-items:center;justify-content:space-between;padding:14px 22px;border-bottom:1px solid var(--line);position:sticky;top:0;background:rgba(11,11,15,.9);backdrop-filter:blur(10px);z-index:5}
.brand{display:flex;gap:10px;align-items:center;font-weight:650;text-decoration:none;letter-spacing:.2px}
.top nav{display:flex;gap:16px;align-items:center}.top nav a{color:var(--muted);text-decoration:none}.top nav a:hover{color:var(--text)}
.wrap{max-width:1180px;margin:0 auto;padding:24px 18px 60px}.narrow{max-width:640px}
.muted{color:var(--muted)}.small{font-size:13px}
.composer{background:var(--panel);border:1px solid var(--line);border-radius:26px;padding:14px;box-shadow:0 20px 60px rgba(0,0,0,.35)}
.composer textarea{width:100%;background:transparent;border:0;outline:0;color:var(--text);font:inherit;font-size:17px;resize:vertical;min-height:96px;padding:8px 10px}
.composer textarea::placeholder{color:#6f6f7d}
.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding-top:8px}
.spacer{flex:1}
.seg{display:flex;background:var(--panel2);border-radius:999px;padding:3px;border:1px solid var(--line)}
.seg button{background:transparent;border:0;color:var(--muted);padding:7px 14px;border-radius:999px;font:inherit;cursor:pointer}
.seg button.on{background:var(--accent);color:#111;font-weight:600}
select,.attach,.btn-ghost{background:var(--panel2);color:var(--text);border:1px solid var(--line);border-radius:999px;padding:8px 12px;font:inherit;cursor:pointer}
select:disabled{opacity:.35;cursor:not-allowed}
.attach:hover,select:hover,.btn-ghost:hover{border-color:#44445a}
.btn-primary{background:var(--accent);color:#111;border:0;border-radius:999px;padding:9px 20px;font:inherit;font-weight:650;cursor:pointer}
.btn-primary:disabled{opacity:.5;cursor:wait}
.btn-ghost.small{padding:5px 10px;font-size:13px}
.thumbs{display:flex;gap:8px;flex-wrap:wrap;padding:0 8px}
.thumb{position:relative;width:64px;height:64px;border-radius:12px;overflow:hidden;border:1px solid var(--line)}
.thumb img{width:100%;height:100%;object-fit:cover}
.thumb span{position:absolute;left:0;right:0;bottom:0;font-size:10px;text-align:center;background:rgba(0,0,0,.65)}
.thumb button{position:absolute;top:2px;right:2px;background:rgba(0,0,0,.7);color:#fff;border:0;border-radius:50%;width:20px;height:20px;cursor:pointer;line-height:20px;padding:0}
.flash{padding:10px 14px;border-radius:12px;background:var(--panel2);border:1px solid var(--line);margin:12px 0}
.flash.error{border-color:rgba(255,93,108,.5);background:rgba(255,93,108,.08)}.flash.ok{border-color:rgba(62,207,142,.5);background:rgba(62,207,142,.08)}
.history{margin-top:34px}.history-head{display:flex;align-items:baseline;justify-content:space-between}.history h2{font-size:18px;margin:0 0 14px}
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px}
.card{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);overflow:hidden;display:flex;flex-direction:column}
.media{background:#000;display:flex;align-items:center;justify-content:center;aspect-ratio:var(--ar,9/16);max-height:480px;position:relative}
.media video,.media img{width:100%;height:100%;object-fit:contain;display:block}
.media .ph{color:var(--muted);font-size:14px;text-align:center;padding:20px}
.spin{width:28px;height:28px;border:3px solid #333;border-top-color:var(--run);border-radius:50%;animation:s 1s linear infinite;margin:0 auto 10px}@keyframes s{to{transform:rotate(360deg)}}
.body{padding:12px 14px;display:flex;flex-direction:column;gap:8px;flex:1}
.prompt{font-size:13.5px;color:#d6d6de;max-height:4.4em;overflow:hidden;cursor:pointer;white-space:pre-wrap}.prompt.open{max-height:none}
.meta{display:flex;flex-wrap:wrap;gap:6px;font-size:12px;color:var(--muted)}
.chip{background:var(--panel2);border:1px solid var(--line);border-radius:999px;padding:2px 8px}
.badge{font-size:12px;border-radius:999px;padding:2px 9px;font-weight:600}
.badge.pending{background:rgba(245,184,74,.15);color:var(--run)}.badge.done{background:rgba(62,207,142,.15);color:var(--ok)}.badge.error{background:rgba(255,93,108,.15);color:var(--err)}
.errmsg{font-size:12.5px;color:#ffb3ba}
.actions{display:flex;gap:8px;margin-top:auto;flex-wrap:wrap}
.actions a,.actions button{font-size:13px;padding:6px 12px;border-radius:999px;border:1px solid var(--line);background:var(--panel2);color:var(--text);text-decoration:none;cursor:pointer;font-family:inherit}
.actions .dl{background:var(--accent);color:#111;border:0;font-weight:600}
.actions .del{color:var(--muted);margin-left:auto}
.refs{display:flex;gap:4px}.refs img{width:30px;height:30px;object-fit:cover;border-radius:6px;border:1px solid var(--line)}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);padding:20px}
.settings label{display:block;margin-bottom:14px;color:var(--muted);font-size:14px}
.settings input{display:block;width:100%;margin-top:6px;background:var(--panel2);border:1px solid var(--line);border-radius:12px;color:var(--text);padding:11px 12px;font:inherit}
.settings details{margin:10px 0 14px}.settings summary{cursor:pointer;color:var(--muted);margin-bottom:12px}
.row{display:flex;gap:10px;flex-wrap:wrap}
.login-page{display:flex;min-height:100vh;align-items:center;justify-content:center;padding:20px}
.login-card{background:var(--panel);border:1px solid var(--line);border-radius:24px;padding:32px 28px;width:100%;max-width:360px;display:flex;flex-direction:column;gap:12px;text-align:center;align-items:center}
.login-card h1{margin:4px 0 0;font-size:22px}.login-card p{margin:0}
.login-card input{width:100%;background:var(--panel2);border:1px solid var(--line);border-radius:12px;color:var(--text);padding:12px;font:inherit}
.login-card .btn-primary{width:100%;padding:12px}
@media (max-width:640px){
  .top{padding:12px 14px}.top nav{gap:12px;font-size:14px}.wrap{padding:16px 12px 50px}
  .composer{border-radius:20px;padding:10px}.composer textarea{font-size:16px;min-height:110px}
  .bar .spacer{display:none}.bar select{flex:1 1 28%;min-width:0}.bar .switch{flex:1 1 100%;padding:4px}.bar .btn-primary{width:100%;padding:12px}
  .gallery{grid-template-columns:1fr}
}
.top nav a.cur{color:var(--text)}
.cast{display:flex;align-items:flex-start;gap:10px;flex-wrap:wrap;padding:8px 8px 4px}
.cast>.muted{padding-top:4px}
.cast-list{display:flex;gap:10px;flex-wrap:wrap}
.cast-chip{display:flex;flex-direction:column;align-items:center;gap:5px;width:84px;background:transparent;border:0;padding:0;color:var(--muted);font:inherit;font-size:12.5px;cursor:pointer;text-align:center}
.cast-pic{position:relative;display:block;width:76px;height:76px;border-radius:18px;overflow:hidden;border:2px solid var(--line);background:#2a2a36;transition:border-color .15s,box-shadow .15s}
.cast-pic img{width:76px!important;height:76px!important;max-width:none;object-fit:cover;display:block;filter:grayscale(.55);opacity:.75;transition:.15s}
.cast-pic .ini{display:flex;width:100%;height:100%;align-items:center;justify-content:center;font-weight:700;font-size:26px;color:var(--text)}
.cast-pic .tick{position:absolute;right:4px;top:4px;width:20px;height:20px;border-radius:50%;background:var(--run);color:#111;font-size:12px;font-weight:800;line-height:20px;display:none}
.cast-name{display:block;max-width:84px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cast-chip:hover .cast-pic{border-color:#555566}
.cast-chip.on{color:var(--text);font-weight:600}
.cast-chip.on .cast-pic{border-color:var(--run);box-shadow:0 0 0 3px rgba(245,184,74,.25)}
.cast-chip.on .cast-pic img{filter:none;opacity:1}
.cast-chip.on .tick{display:block}
.cast-edit{color:var(--muted);padding-top:4px}
.switch{display:flex;align-items:center;gap:8px;font-size:13.5px;color:var(--muted);cursor:pointer;user-select:none;padding:0 4px}
.switch input{display:none}.switch .knob{width:34px;height:20px;border-radius:999px;background:#33333f;position:relative;transition:.2s}
.switch .knob:after{content:"";position:absolute;top:3px;left:3px;width:14px;height:14px;border-radius:50%;background:#aaa;transition:.2s}
.switch input:checked+.knob{background:var(--ok)}.switch input:checked+.knob:after{left:17px;background:#fff}
.switch input:checked~*{color:var(--text)}
.chip.who{color:var(--run);border-color:rgba(245,184,74,.4)}
details.final summary{cursor:pointer;font-size:12.5px;color:var(--muted)}
details.final pre{white-space:pre-wrap;font-size:12px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:10px;max-height:340px;overflow:auto;color:#cfcfd8;margin:6px 0 0}
.chars{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:16px;align-items:start}
.char{font-size:15px}
.char label{display:block;margin-bottom:12px;color:var(--muted);font-size:14px;font-weight:500}
.char input[type=text],.char textarea{display:block;width:100%;margin-top:6px;background:var(--panel2);border:1px solid var(--line);border-radius:12px;color:var(--text);padding:10px 12px;font:inherit;font-size:15px;line-height:1.5}
.char textarea{min-height:10.5em;resize:vertical}
.char h3{margin:0 0 12px;font-size:17px}.char.new{border-style:dashed}
.char-photos{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.char-photos figure{margin:0;width:96px;flex:0 0 96px}
.char-photos img{width:96px!important;height:96px!important;max-width:none;object-fit:cover;border-radius:14px;border:1px solid var(--line);display:block}
.char-photos figcaption{font-size:12px;color:var(--muted);display:flex;flex-direction:column;gap:2px;margin-top:5px}
.char-photos figcaption label{margin:0;font-size:12px;display:flex;gap:5px;align-items:center;font-weight:400}
.nophoto{width:96px;height:96px;border:1px dashed var(--line);border-radius:14px;display:flex;align-items:center;justify-content:center;text-align:center;color:var(--muted);font-size:12px;flex-direction:column}
.auto-rule{margin:-4px 0 12px;font-size:13px;color:var(--muted)}.auto-rule summary{cursor:pointer}.auto-rule p{margin:6px 0 0;line-height:1.45}
.attach.inline{display:inline-block;margin-bottom:12px;color:var(--text);font-size:14px}
@media (max-width:640px){.top{flex-wrap:wrap;gap:8px}.brand{font-size:15px}.top nav{gap:12px;font-size:13.5px;flex-wrap:wrap}.history-head{flex-direction:column;align-items:flex-start;gap:4px}.history-head h2{margin-bottom:2px}.chars{grid-template-columns:1fr}.cast>.muted{width:100%}.cast-chip{width:72px}.cast-pic,.cast-pic img{width:64px!important;height:64px!important}.cast-name{max-width:72px}.char-photos figure{width:84px;flex-basis:84px}.char-photos img{width:84px!important;height:84px!important}}
