/* ============ Hekmet Studio — IZDAX-style dark RTL theme ============ */
:root{
  /* palette (measured from reference) */
  --bg:#0A0A0A;
  --bg-side:#0D0D0D;
  --card:#141415;
  --card-2:#161617;
  --input:#1A1A1B;
  --border:#242424;
  --border-2:#2C2C2D;
  --border-3:#303032;
  --text:#EDEDED;
  --text-2:#B4B4B4;
  --text-dim:#8A8A8A;
  --text-faint:#6E6E6E;
  --btn:#F2F2F2;
  --amber:#D9941F;
  --slate:#3C4D60;
  --danger:#e06a5e;
  --ok:#5fbf7e;
  --warn:#d9941f;
  --radius:12px;
  --shadow:0 12px 40px rgba(0,0,0,.55);

  /* legacy aliases kept so older inline styles keep resolving */
  --bg-soft:#0D0D0D;
  --bg-card:#141415;
  --bg-input:#1A1A1B;
  --accent:#f2f2f2;
  --accent-2:#b4b4b4;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:"UKIJ Tuz","Segoe UI","Microsoft YaHei",Tahoma,Arial,sans-serif;
  background-color:var(--bg);
  background-image:radial-gradient(circle, rgba(255,255,255,.055) 1px, transparent 1.3px);
  background-size:22px 22px;
  color:var(--text);
  font-size:14px;
  line-height:1.7;
}
[dir="ltr"] body{font-family:"Segoe UI","Microsoft YaHei",Arial,sans-serif}
.hidden{display:none!important}
.muted{color:var(--text-dim);font-size:12px}
*::-webkit-scrollbar{width:8px;height:8px}
*::-webkit-scrollbar-thumb{background:#262627;border-radius:8px}
*::-webkit-scrollbar-track{background:transparent}

/* ---------- base controls ---------- */
input,textarea,select{
  width:100%;padding:11px 13px;margin:6px 0;background:var(--input);
  border:1px solid var(--border-2);border-radius:10px;color:var(--text);
  font-family:inherit;font-size:13.5px;outline:none;transition:border .15s, background .15s;
}
input::placeholder,textarea::placeholder{color:var(--text-faint)}
input:focus,textarea:focus,select:focus{border-color:#4a4a4c}
textarea{resize:vertical}
select option{background:#141415;color:var(--text)}
input[type=range]{accent-color:var(--btn);background:transparent;border:none;padding:0}
label{display:block;margin:10px 0 4px;color:#fff;font-size:13px;font-weight:600}
button{cursor:pointer;font-family:inherit;color:inherit}
.f-label{display:block;font-size:13.5px;font-weight:600;color:#fff;margin:0 0 8px}
.card-title{font-size:16px;font-weight:700;color:#fff;margin:0 0 12px}

.btn-primary{
  background:var(--btn);color:#0a0a0a;border:1px solid var(--btn);
  padding:10px 20px;border-radius:10px;font-size:13.5px;font-weight:700;
  transition:background .15s,border-color .15s;margin-top:8px;display:inline-flex;
  align-items:center;justify-content:center;gap:7px;
}
.btn-primary:hover{background:#fff;border-color:#fff}
.btn-primary:disabled{opacity:.45;cursor:not-allowed}
.btn-block{width:100%;padding:13px 18px;margin-top:16px;font-size:14px}
.btn-generate{margin-top:18px}
.btn-secondary{
  display:inline-flex;align-items:center;gap:6px;background:var(--input);
  border:1px solid #333;color:var(--text);padding:9px 14px;border-radius:10px;
  font-size:13px;transition:.15s;
}
.btn-secondary:hover{border-color:#4a4a4c;background:#202021}
.btn-secondary svg{width:15px;height:15px}
.btn-sm{padding:6px 11px;font-size:12px}
.btn-sm svg{width:13px;height:13px}
.btn-ghost-sm{
  background:transparent;border:1px solid var(--border-2);color:var(--text-2);
  padding:8px 14px;border-radius:9px;font-size:13px;white-space:nowrap;
}
.btn-ghost-sm:hover{border-color:#4a4a4c;color:#fff}

/* ---------- segmented & pill groups ---------- */
.seg{
  display:inline-flex;gap:2px;background:var(--card-2);
  border:1px solid #262627;border-radius:10px;padding:3px;
}
.seg-btn{
  appearance:none;background:transparent;border:0;color:#9f9f9f;
  padding:8px 16px;border-radius:8px;font-family:inherit;font-size:13px;
  font-weight:500;transition:.15s;white-space:nowrap;
}
.seg-btn:hover{color:#fff}
.seg-btn.active{background:var(--btn);color:#0a0a0a;font-weight:700}
.seg-sm .seg-btn{padding:5px 12px;font-size:12px}
.pill-row{display:flex;flex-wrap:wrap;gap:8px}
.pill-btn{
  background:var(--input);border:1px solid var(--border-2);color:var(--text-2);
  padding:7px 14px;border-radius:9px;font-family:inherit;font-size:13px;transition:.15s;
}
.pill-btn:hover{border-color:#3d3d3f;color:#fff}
.pill-btn.active{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}

/* ============ Login ============ */
.login-screen{
  min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px;
  background-color:#080808;
  background-image:radial-gradient(circle, rgba(255,255,255,.05) 1px, transparent 1.3px);
  background-size:22px 22px;
}
.login-card{
  position:relative;background:var(--card);border:1px solid #2a2a2a;border-radius:16px;
  padding:30px 30px 24px;width:100%;max-width:420px;box-shadow:var(--shadow);
}
.login-title{font-size:27px;font-weight:800;color:#fff;line-height:1.2}
.login-sub{color:var(--text-dim);font-size:13px;margin:6px 0 18px}
.login-tabs{display:flex;width:100%;margin-bottom:18px}
.login-tabs .seg-btn{flex:1}
.login-form{display:flex;flex-direction:column}
.login-form .f-label{margin-top:12px}
.input-icon{position:relative;margin:0}
.input-icon svg{
  position:absolute;inset-inline-start:13px;top:50%;transform:translateY(-50%);
  width:18px;height:18px;color:var(--text-faint);pointer-events:none;
}
.input-icon input{margin:0;padding-inline-start:42px}
.login-hint{margin-top:18px;font-size:11.5px;color:var(--text-faint);text-align:center}
.login-hint b{color:var(--text-dim)}

/* ============ Layout ============ */
.app{display:flex;min-height:100vh}
.sidebar{
  width:220px;background:var(--bg-side);border-inline-end:1px solid #1F1F1F;
  display:flex;flex-direction:column;position:fixed;inset-block:0;inset-inline-start:0;
  z-index:30;transition:transform .25s;
}
.brand{display:flex;align-items:center;gap:10px;padding:20px 18px;font-weight:700;font-size:15.5px;color:#fff;white-space:nowrap}
.brand img{width:28px;height:28px;border-radius:7px}
.brand em{font-style:normal;font-weight:600;color:#a8a8a8}
.nav{flex:1;padding:8px 0;overflow-y:auto}
.nav-item{
  position:relative;display:flex;align-items:center;gap:12px;height:42px;margin:2px 10px;
  padding:0 12px;border-radius:9px;color:var(--text-2);cursor:pointer;font-size:14px;
  transition:background .15s,color .15s;user-select:none;
}
.nav-item:hover{background:rgba(255,255,255,.045);color:#fff}
.nav-item.active{color:#fff;font-weight:700}
.nav-item.active::before{
  content:'';position:absolute;inset-inline-start:-10px;top:50%;transform:translateY(-50%);
  width:3px;height:20px;background:#fff;border-radius:3px;
}
.nav-item .ni{width:19px;height:19px;flex-shrink:0}
.nav-sep{height:1px;background:#1f1f1f;margin:10px 18px}
.sidebar-foot{border-top:1px solid #1f1f1f;padding:8px 0}
.nav-logout .ni{width:19px;height:19px;flex-shrink:0}
.nav-logout{
  display:flex;align-items:center;gap:12px;width:calc(100% - 20px);margin:2px 10px;
  padding:0 12px;height:42px;background:none;border:0;color:var(--text-2);
  font-family:inherit;font-size:14px;border-radius:9px;text-align:start;transition:.15s;
}
.nav-logout:hover{background:rgba(255,255,255,.045);color:#fff}
.side-user{
  font-size:11px;color:var(--text-faint);padding:6px 22px 2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.main{flex:1;margin-inline-start:220px;min-width:0;display:flex;flex-direction:column;min-height:100vh}

.top-tools{
  display:flex;align-items:center;gap:10px;padding:10px 18px;height:56px;
  position:sticky;top:0;z-index:20;
  background:linear-gradient(to bottom,rgba(10,10,10,.9) 0%,rgba(10,10,10,.65) 65%,rgba(10,10,10,0));
}
.tools-spacer{flex:1}
.icon-tool{
  display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;
  background:transparent;border:0;border-radius:9px;color:var(--text-2);transition:.15s;
}
.icon-tool:hover{background:var(--input);color:#fff}
.icon-tool svg{width:19px;height:19px}
.lang-select{width:auto;margin:0;padding:7px 10px;background:var(--card);border-color:var(--border-2);color:var(--text-2);font-size:13px}
.menu-btn{
  display:none;align-items:center;justify-content:center;width:36px;height:36px;
  background:transparent;border:0;border-radius:9px;color:var(--text-2);
}
.menu-btn:hover{background:var(--input);color:#fff}
.menu-btn svg{width:19px;height:19px}
.page{display:none;padding:12px 16px 20px;flex:1;animation:fade .2s}
.page.active{display:block}
@keyframes fade{from{opacity:0;transform:translateY(5px)}to{opacity:1}}
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:20px}

/* ============ Chat ============ */
.chat-wrap{display:flex;flex-direction:column;max-width:940px;margin:0 auto;height:calc(100vh - 92px);width:100%}
.chat-messages{flex:1;overflow-y:auto;padding:12px 6px;display:flex;flex-direction:column;gap:14px}
.message{display:flex}
.message.user{justify-content:flex-end}
.msg-bubble{max-width:78%;padding:11px 15px;border-radius:15px;white-space:pre-wrap;word-wrap:break-word;font-size:14.5px;line-height:1.85}
.message.user .msg-bubble{background:var(--btn);color:#0a0a0a;border-end-end-radius:5px;font-weight:500}
.message.assistant .msg-bubble{background:var(--card);border:1px solid var(--border);border-end-start-radius:5px}
.typing{color:var(--text-dim);font-style:italic}
.chat-input-bar{
  flex-shrink:0;display:flex;gap:8px;align-items:flex-end;
  background:var(--card);border:1px solid var(--border-2);border-radius:16px;padding:7px;
}
.chat-input-bar textarea{
  flex:1;margin:0;max-height:140px;background:transparent;border:0!important;
  padding:9px 8px;font-size:14.5px;resize:none;line-height:1.6;
}
.chat-input-bar .icon-tool{width:38px;height:38px;flex-shrink:0}
.btn-icon-send{
  width:38px;height:38px;flex-shrink:0;background:var(--btn);color:#0a0a0a;border:0;
  border-radius:11px;display:flex;align-items:center;justify-content:center;
}
.btn-icon-send svg{width:18px;height:18px}
.btn-icon-send:disabled{opacity:.4;cursor:not-allowed}

/* ---------- Home hero (IZDAX-style landing) ---------- */
.hero{flex:1;display:flex;flex-direction:column;min-height:100%}
.hero-main{
  flex:1;position:relative;display:flex;flex-direction:column;align-items:center;
  justify-content:center;gap:22px;text-align:center;padding:30px 12px;
}
.hero-main::before,.hero-main::after{
  content:'';position:absolute;border:1px solid rgba(255,255,255,.045);
  border-radius:50%;pointer-events:none;
}
.hero-main::before{width:260px;height:260px;top:-20px;inset-inline-start:10%}
.hero-main::after{width:170px;height:170px;bottom:-30px;inset-inline-end:8%}
.hero-wordmark{
  font-size:clamp(42px,6.2vw,68px);font-weight:800;color:#fff;line-height:1.15;
  letter-spacing:-.5px;
}
.hero-wordmark .studio{color:#9d9d9d;font-weight:700}
.hero-desc{max-width:660px;font-size:15.5px;color:#a8a8a8;line-height:1.9}
.hl-amber{
  color:#f0ead8;font-weight:700;border-bottom:3px solid var(--amber);
  padding-bottom:1px;border-radius:2px;white-space:nowrap;
}
.pill-tag{
  display:inline-block;background:var(--slate);color:#eef3f8;font-weight:600;
  border-radius:6px;padding:1px 9px;margin:0 2px;white-space:nowrap;
}
.hero-actions{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;margin-top:6px}
.hero-actions .btn-primary{margin:0;padding:12px 24px;font-size:14.5px}
.hero-actions .btn-secondary{padding:12px 22px;font-size:14.5px;border-color:#333}
.hero-actions svg{width:16px;height:16px}

.hero-cards{flex-shrink:0;border-top:1px solid #1d1d1d;padding-top:20px;margin-top:10px}
.hero-cards-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.hero-overline{display:block;font-size:10.5px;font-weight:700;letter-spacing:3px;color:var(--text-faint)}
.hero-cards-title{font-size:19px;font-weight:800;color:#fff;margin-top:3px}
.hero-cards-hint{font-size:12.5px;color:var(--text-faint)}
.hero-card-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.hero-card{
  display:flex;align-items:center;gap:12px;background:var(--card);
  border:1px solid var(--border);border-radius:12px;padding:15px 16px;
  cursor:pointer;transition:.18s;text-align:start;
}
.hero-card:hover{border-color:#3d3d3d;background:#171718}
.hc-ico{
  width:38px;height:38px;flex-shrink:0;border:1px solid var(--border-2);border-radius:9px;
  background:var(--input);display:flex;align-items:center;justify-content:center;color:#cfcfcf;
}
.hc-ico svg{width:18px;height:18px}
.hc-text{display:flex;flex-direction:column;min-width:0}
.hc-text b{font-size:14px;color:#fff;font-weight:700}
.hc-text small{font-size:11.5px;color:var(--text-faint)}
.hc-arrow{margin-inline-start:auto;color:var(--text-faint);flex-shrink:0}
.hc-arrow svg{width:16px;height:16px}

/* ============ Create: studio 3-column layout ============ */
.create-tabs{display:none}
.create-panel{display:none}
.create-panel.active{display:block}
.studio-grid{
  display:grid;grid-template-columns:272px minmax(390px,460px) minmax(0,1fr);
  gap:14px;align-items:stretch;
}
.studio-col{
  background:var(--card);border:1px solid var(--border);border-radius:12px;
  padding:18px;display:flex;flex-direction:column;min-height:calc(100vh - 96px);
}
.studio-title{font-size:22px;font-weight:800;color:#fff;line-height:1.25;margin-bottom:6px}
.studio-note{font-size:12px;color:var(--text-dim);margin-bottom:14px}

/* history column */
.col-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.col-head h3{font-size:15px;font-weight:700;color:#fff}
.col-title{font-size:15px;font-weight:700;color:#fff;margin-bottom:14px}
.count-badge{
  min-width:26px;text-align:center;background:var(--input);border:1px solid var(--border-2);
  border-radius:7px;padding:1px 8px;font-size:12px;color:var(--text-2);
}
.hist-actions{display:flex;gap:8px;margin:14px 0 2px}
.hist-list{flex:1;display:flex;flex-direction:column;gap:8px;margin-top:10px;overflow-y:auto}
.empty-mini{
  border:1px dashed var(--border-3);border-radius:12px;color:var(--text-faint);
  font-size:13px;display:flex;align-items:center;justify-content:center;
  min-height:210px;text-align:center;padding:20px;
}
.hist-card{
  display:flex;gap:10px;align-items:center;border:1px solid var(--border);border-radius:10px;
  padding:8px;cursor:pointer;background:#101011;transition:.15s;
}
.hist-card:hover{border-color:#3d3d3d}
.hist-thumb{
  width:48px;height:48px;border-radius:8px;object-fit:cover;flex-shrink:0;
  background:var(--input);display:flex;align-items:center;justify-content:center;font-size:20px;
}
.hist-body{min-width:0;flex:1}
.hist-prompt{
  font-size:12px;color:var(--text-2);line-height:1.5;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
.hist-date{font-size:10px;color:var(--text-faint);margin-top:2px}

/* form column */
.field-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:16px 0 8px}
.field-head .f-label{margin:0}
.form-block{margin-top:16px}
.form-block>.f-label{margin-bottom:8px}
.drop-zone{
  border:1px dashed var(--border-3);border-radius:12px;min-height:116px;padding:16px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;
  color:var(--text-faint);cursor:pointer;text-align:center;transition:.15s;
}
.drop-zone:hover{border-color:#4a4a4c;color:var(--text-dim)}
.drop-zone.has-file{border-style:solid;border-color:#3a3a3a;background:#111112}
.drop-zone img{max-height:170px;border-radius:10px;display:none}
.drop-zone.has-file img{display:block}
.drop-zone.has-file .drop-hint{display:none}
.drop-hint{font-size:12.5px}

/* video frame tiles */
.frame-row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.frame-tile{
  position:relative;display:flex;align-items:center;gap:12px;border:1px dashed var(--border-3);
  border-radius:12px;padding:12px;cursor:pointer;transition:.15s;
}
.frame-tile:hover{border-color:#4a4a4c}
.frame-tile.is-disabled{opacity:.45;cursor:not-allowed}
.frame-tile.has-file{border-style:solid;border-color:#3a3a3a;background:#111112}
.frame-thumb{
  position:relative;width:64px;height:64px;border-radius:10px;background:var(--input);
  display:flex;align-items:center;justify-content:center;overflow:hidden;flex-shrink:0;
}
.frame-thumb img{width:100%;height:100%;object-fit:cover;display:none}
.frame-tile.has-file .frame-thumb img{display:block}
.frame-tile.has-file .frame-tag{display:none}
.frame-tag{font-size:12px;color:var(--text-dim)}
.frame-meta{display:flex;flex-direction:column;gap:2px;min-width:0}
.frame-meta b{font-size:13px;color:var(--text);font-weight:600}
.frame-meta small{font-size:11px;color:var(--text-faint)}
.frame-clear{
  position:absolute;top:6px;inset-inline-end:6px;width:22px;height:22px;border-radius:6px;
  border:1px solid #333;background:var(--input);color:var(--text-2);font-size:11px;line-height:1;
}
.field-note{font-size:11.5px;color:var(--text-dim);margin:8px 0 0}
.counts-note{font-size:11.5px;color:var(--text-dim);margin:10px 0 0}

/* multi reference images (r2v) */
.ref-multi{margin-top:12px}
.ref-multi-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.ref-multi-head .f-label{margin:0}
.ref-multi-head .counts-note{margin:0}
.ref-tiles{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-start}
.ref-add{
  width:84px;height:84px;border:1.5px dashed var(--border-3);border-radius:10px;background:transparent;
  color:var(--text-dim);display:flex;align-items:center;justify-content:center;cursor:pointer;transition:.15s;
}
.ref-add svg{width:22px;height:22px}
.ref-add:hover{border-color:#4a4a4c;color:#fff}
.ref-item{display:flex;flex-direction:column;gap:5px;width:84px}
.ref-tile{
  width:84px;height:84px;border-radius:10px;overflow:hidden;position:relative;
  border:1px solid var(--border-3);background:var(--input);
}
.ref-tile img{width:100%;height:100%;object-fit:cover;display:block}
.ref-tile .ref-num{
  position:absolute;top:4px;inset-inline-start:4px;min-width:20px;height:20px;padding:0 5px;border-radius:6px;
  background:var(--btn);color:#0a0a0a;font-size:11px;font-weight:700;
  display:flex;align-items:center;justify-content:center;line-height:1;
}
.ref-tile .ref-x{
  position:absolute;top:4px;inset-inline-end:4px;width:20px;height:20px;border-radius:50%;
  background:rgba(0,0,0,.65);border:1px solid #555;color:#fff;font-size:10px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;line-height:1;z-index:2;
}
.ref-tile .ref-x:hover{background:#000;border-color:#888}
.ref-tile .ref-voice{
  position:absolute;bottom:4px;inset-inline-end:4px;width:22px;height:22px;border-radius:50%;
  background:rgba(0,0,0,.65);border:1px solid #555;color:#fff;font-size:10px;cursor:pointer;
  display:flex;align-items:center;justify-content:center;line-height:1;z-index:2;padding:0;
}
.ref-tile .ref-voice:hover{background:#000;border-color:#888}
.ref-tile .ref-voice.on{background:var(--btn);border-color:var(--btn);color:#0a0a0a}
.ref-voice-add,.ref-voice-name,.ref-tts-add{
  width:100%;box-sizing:border-box;background:transparent;border:1px solid var(--border-3);
  border-radius:7px;color:var(--text-dim);font-size:10px;padding:4px 4px;cursor:pointer;
  font-family:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.ref-voice-add:hover,.ref-tts-add:hover{border-color:#4a4a4c;color:#fff}
.ref-voice-name{color:var(--text-2);border-style:dashed}
.ref-tts-box{display:flex;flex-direction:column;gap:3px}
.ref-tts-text{
  width:100%;box-sizing:border-box;background:var(--input);border:1px solid var(--border-3);
  border-radius:7px;color:var(--text);font-size:10px;padding:4px 5px;font-family:inherit;
  resize:none;min-height:40px;line-height:1.4;
}
.ref-tts-text:focus{border-color:#4a4a4c;outline:none}
.ref-tts-bar{display:flex;gap:3px;align-items:center}
.ref-tts-lang{
  flex:1;background:transparent;border:1px solid var(--border-3);border-radius:6px;
  color:var(--text-dim);font-size:9px;padding:2px 0;cursor:pointer;font-family:inherit;
}
.ref-tts-lang.on{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}
.ref-tts-x,.ref-tts-gender{
  background:transparent;border:1px solid var(--border-3);border-radius:6px;
  color:var(--text-dim);font-size:9px;padding:2px 5px;cursor:pointer;font-family:inherit;
}
.ref-tts-x:hover,.ref-tts-gender:hover{border-color:#4a4a4c;color:#fff}
.ref-item .ref-role{
  width:100%;box-sizing:border-box;background:var(--input);border:1px solid var(--border-3);
  border-radius:7px;color:var(--text);font-size:11px;padding:5px 7px;font-family:inherit;text-align:center;
}
.ref-item .ref-role::placeholder{color:var(--text-dim)}
.ref-item .ref-role:focus{border-color:#4a4a4c;outline:none}
.ref-chips{display:flex;gap:7px;flex-wrap:wrap;margin-top:8px}
.ref-chip{
  background:transparent;border:1px solid var(--border-3);color:var(--text-2);border-radius:999px;
  padding:5px 12px;font-size:12px;cursor:pointer;font-family:inherit;transition:.15s;
}
.ref-chip:hover{border-color:#4a4a4c;color:#fff;background:rgba(242,242,242,.1)}

/* ===== character cards: image + voice slot + dialogue in ONE frame ===== */
.char-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:12px;align-items:start}
.char-add{
  min-height:100px;border:1.5px dashed var(--border-3);border-radius:12px;background:transparent;
  color:var(--text-dim);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;
  cursor:pointer;transition:.15s;font-family:inherit;font-size:12.5px;
}
.char-add svg{width:22px;height:22px}
.char-add:hover{border-color:#4a4a4c;color:#fff}
.char-card{
  background:var(--input);border:1px solid var(--border-2);border-radius:12px;padding:10px;
  display:flex;flex-direction:column;gap:8px;
}
.char-head{display:flex;align-items:center;gap:8px}
.char-num{
  min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--btn);color:#0a0a0a;
  font-size:12px;font-weight:700;display:flex;align-items:center;justify-content:center;line-height:1;
}
.char-token{font-size:11px;color:var(--text-dim);border:1px solid var(--border-3);border-radius:6px;padding:2px 6px}
.char-x{
  margin-inline-start:auto;width:24px;height:24px;border-radius:7px;border:1px solid var(--border-3);
  background:transparent;color:var(--text-2);cursor:pointer;font-size:11px;line-height:1;font-family:inherit;
}
.char-x:hover{background:#3a1414;border-color:#7a3030;color:#fff}
.char-body{display:flex;gap:10px;align-items:flex-start}
.char-img{
  width:94px;height:94px;flex:0 0 auto;border-radius:10px;overflow:hidden;
  border:1px solid var(--border-3);background:var(--card);
}
.char-img img{width:100%;height:100%;object-fit:cover;display:block}
.char-fields{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}
.char-role{
  width:100%;box-sizing:border-box;background:var(--card);border:1px solid var(--border-3);
  border-radius:8px;color:var(--text);font-size:12.5px;padding:6px 9px;font-family:inherit;
}
.char-role:focus{border-color:#4a4a4c;outline:none}
.char-voice-slot{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.char-voice-chip{
  background:var(--btn);border:1px solid var(--btn);color:#0a0a0a;border-radius:7px;
  font-size:11px;padding:4px 8px;cursor:pointer;font-family:inherit;max-width:100%;font-weight:600;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.char-voice-add{
  background:transparent;border:1px dashed var(--border-3);color:var(--text-dim);border-radius:7px;
  font-size:11px;padding:4px 9px;cursor:pointer;font-family:inherit;
}
.char-voice-add:hover{border-color:#4a4a4c;color:#fff}
.char-dlg-text{
  width:100%;box-sizing:border-box;background:var(--card);border:1px solid var(--border-3);
  border-radius:8px;color:var(--text);font-size:12.5px;padding:7px 9px;font-family:inherit;
  resize:vertical;min-height:46px;line-height:1.45;
}
.char-dlg-text:focus{border-color:#4a4a4c;outline:none}
.char-dlg-bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.char-seg-group{display:flex;align-items:center;gap:4px}
.char-seg-label{font-size:10.5px;color:var(--text-faint)}
.char-seg{
  background:transparent;border:1px solid var(--border-3);border-radius:6px;color:var(--text-dim);
  font-size:11px;padding:3px 8px;cursor:pointer;font-family:inherit;transition:.15s;
}
.char-seg:hover{border-color:#4a4a4c;color:#fff}
.char-seg.active{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}
.char-seg.is-disabled{cursor:not-allowed;opacity:.45}

/* ===== draft autosave bar ===== */
.draft-bar{display:flex;align-items:center;gap:10px;min-height:20px;margin-bottom:2px}
.draft-state{font-size:11.5px;color:var(--text-faint)}
.draft-bar .mini-btn{font-size:11px;padding:3px 9px}

/* ===== video studio v2 (izdax 2-column layout) ===== */
.studio-grid2{display:grid;grid-template-columns:minmax(300px,380px) minmax(0,1fr);gap:14px;align-items:start}
.studio-grid2 .studio-history{min-height:calc(100vh - 96px)}
.studio-main{display:flex;flex-direction:column;gap:14px;min-width:0}
.studio-card{
  background:var(--card);border:1px solid var(--border);border-radius:12px;padding:20px;
  display:flex;flex-direction:column;
}
.summary-row{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  background:var(--input);border:1px solid var(--border-2);border-radius:10px;
  padding:8px 12px;margin-top:16px;
}
.summary-row span{font-size:12.5px;color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.settings-block{overflow:hidden}
.opt-grid{display:flex;gap:10px}
.opt-btn{
  flex:1;background:transparent;border:1px solid var(--border-3);color:var(--text-2);
  border-radius:12px;padding:13px 10px;font-size:13.5px;cursor:pointer;transition:.15s;font-family:inherit;
}
.opt-btn:hover{border-color:#4a4a4c;color:#fff}
.opt-btn.active{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}
.ratio-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.ratio-tile{
  background:transparent;border:1px solid var(--border-3);border-radius:12px;
  padding:14px 6px 12px;display:flex;flex-direction:column;align-items:center;gap:5px;
  color:var(--text-2);cursor:pointer;transition:.15s;font-family:inherit;font-size:13px;
}
.ratio-tile:hover{border-color:#4a4a4c;color:#fff}
.ratio-tile.active{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}
.ratio-tile small{font-size:11px;opacity:.65}
.ratio-tile.is-disabled{opacity:.35;cursor:not-allowed}
.ratio-tile.is-disabled:hover{border-color:var(--border-3);color:var(--text-2)}
.rrect{display:block;border:1.5px solid currentColor;border-radius:3px;width:26px;height:18px}
.r-43{width:24px;height:18px}
.r-11{width:18px;height:18px}
.r-34{width:14px;height:18px}
.r-916{width:11px;height:18px}
.r-auto{width:26px;height:18px;border-style:dashed}
.dur-row2{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.dur-row2 input[type=range]{flex:1;min-width:140px;accent-color:var(--btn)}
.dur-row2 input[type=number]{width:78px;margin:0}
.btn-danger-ghost{color:#e88a8a}
.btn-danger-ghost:hover{color:#ff9c9c;border-color:#5a3030}
.hist-card{position:relative}
.hist-check{
  position:absolute;top:6px;inset-inline-end:6px;width:18px;height:18px;border-radius:50%;
  border:1.5px solid #555;background:rgba(0,0,0,.55);display:flex;align-items:center;
  justify-content:center;font-size:10px;color:transparent;z-index:2;cursor:pointer;
}
.hist-card.sel{border-color:#f2f2f2}
.hist-card.sel .hist-check{background:var(--btn);border-color:var(--btn);color:#0a0a0a}

/* duration row */
.dur-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.dur-row input[type=number]{width:92px;margin:0}
.dur-unit{font-size:12px;color:var(--text-dim)}
.dur-quick{display:flex;gap:7px}

/* result column */
.studio-result-list{margin-top:0}
.studio-result-col .empty-state{margin-top:0}
.studio-result-col:has(.result-item) .empty-state{display:none}
.empty-state{
  flex:1;min-height:340px;border:1px dashed var(--border-3);border-radius:12px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;
  color:var(--text-faint);
}
.empty-art{display:flex;flex-direction:column;align-items:center;gap:0}
.empty-main{width:60px;height:60px;color:#414144}
.empty-sub{width:48px;height:48px;color:#333336;margin-top:-14px}
.empty-state p{font-size:13px}

/* script single panel */
.studio-single{
  max-width:680px;margin:0 auto;background:var(--card);border:1px solid var(--border);
  border-radius:12px;padding:22px;
}
.form-grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:6px}
.form-grid-2 label{margin-top:4px}

/* ============ legacy create bits still in use ============ */
.opt-row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:10px 0}
.opt-row label{margin:0;white-space:nowrap}
.opt-row select{width:auto;margin:0}
.result-list{margin-top:18px;display:flex;flex-direction:column;gap:14px}
.result-item{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:14px}
.studio-result-list .result-item{background:#101011;margin-top:0}
.result-item img{width:100%;border-radius:10px;display:block}
.result-item video{width:100%;border-radius:10px}
.result-meta{color:var(--text-dim);font-size:13px;margin:6px 0}
.result-item pre{white-space:pre-wrap;word-wrap:break-word;font-family:inherit;line-height:1.9}
.progress-track{background:var(--input);border-radius:6px;height:7px;overflow:hidden;margin:8px 0}
.progress-bar{background:var(--btn);height:100%;width:5%;transition:width .5s}

/* ============ Outputs / upload ============ */
.output-box{
  background:var(--input);border:1px dashed var(--border-2);border-radius:10px;
  padding:14px;min-height:60px;margin-top:12px;white-space:pre-wrap;word-wrap:break-word;color:var(--text);
}
.upload-zone{
  border:1px dashed var(--border-3);border-radius:var(--radius);padding:42px;text-align:center;
  color:var(--text-dim);cursor:pointer;transition:.15s;margin-top:10px;background:rgba(255,255,255,.01)
}
.upload-zone:hover{border-color:#4a4a4c;color:var(--text)}
.progress-wrap{display:flex;align-items:center;gap:10px;margin-top:14px;color:var(--text-dim)}
.spinner{width:18px;height:18px;border:2px solid var(--border-2);border-top-color:var(--btn);
  border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ============ Voice ============ */
#sttBtn.recording{background:var(--danger);border-color:var(--danger);color:#fff;animation:pulse 1.2s infinite}
@keyframes pulse{0%,100%{box-shadow:0 0 0 0 rgba(224,106,94,.45)}50%{box-shadow:0 0 0 10px rgba(224,106,94,0)}}

/* ============ Assets ============ */
.filter-row{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:18px}
.filter-btn{
  background:var(--card);border:1px solid var(--border-2);color:var(--text-2);
  padding:8px 16px;border-radius:20px;font-size:13px;transition:.15s;
}
.filter-btn:hover{border-color:#4a4a4c;color:#fff}
.filter-btn.active{background:var(--btn);border-color:var(--btn);color:#0a0a0a;font-weight:700}
.assets-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:14px}
.asset-card{
  background:var(--card);border:1px solid var(--border);border-radius:var(--radius);
  overflow:hidden;cursor:pointer;transition:.18s;
}
.asset-card:hover{transform:translateY(-2px);border-color:#3d3d3d}
.asset-card img,.asset-card video{width:100%;height:170px;object-fit:cover;display:block}
.asset-thumb-ph{height:170px;display:flex;align-items:center;justify-content:center;font-size:40px;background:var(--input)}
.asset-info{padding:10px 12px}
.asset-type{font-size:11px;color:var(--text-2);text-transform:uppercase;letter-spacing:.5px}
.asset-prompt{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:3px 0;color:var(--text)}
.asset-date{font-size:11px;color:var(--text-faint)}

/* ============ Admin ============ */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:14px}
.stat-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:18px}
.stat-card .num{font-size:28px;font-weight:800;color:#fff}
.stat-card .lbl{font-size:13px;color:var(--text-dim)}
.data-table{width:100%;border-collapse:collapse;font-size:13px}
.data-table th,.data-table td{padding:10px 8px;border-bottom:1px solid var(--border);text-align:start}
.data-table th{color:var(--text-dim);font-weight:600}
.badge{padding:2px 9px;border-radius:20px;font-size:11px}
.badge.admin{background:#262627;color:#fff}
.badge.user{background:var(--input);color:var(--text-2)}
.badge.active{background:rgba(95,191,126,.14);color:var(--ok)}
.badge.disabled{background:rgba(224,106,94,.14);color:var(--danger)}
.mini-btn{
  background:var(--input);border:1px solid var(--border-2);color:var(--text-2);
  border-radius:7px;padding:6px 11px;font-size:12px;margin-inline-end:4px;transition:.15s;
}
.mini-btn:hover{border-color:#4a4a4c;color:#fff}
.mini-btn.danger:hover{border-color:var(--danger);color:var(--danger)}

/* ============ Toast ============ */
.toast{
  position:fixed;inset-block-end:24px;inset-inline-start:50%;
  transform:translateX(-50%) translateY(80px);
  background:var(--card);border:1px solid var(--border-2);color:var(--text);
  padding:12px 22px;border-radius:12px;box-shadow:var(--shadow);z-index:100;
  opacity:0;transition:.3s;max-width:90vw;font-size:13.5px;
}
.toast.show{transform:translateX(-50%) translateY(0);opacity:1}
.toast.error{border-color:rgba(224,106,94,.5);color:#f0a197}
.toast.success{border-color:rgba(95,191,126,.5);color:#9edfb4}

/* ============ Responsive ============ */
@media (max-width:1180px){
  .studio-grid{grid-template-columns:1fr;gap:12px}
  .studio-grid2{grid-template-columns:1fr;gap:12px}
  .studio-grid2 .studio-history{min-height:auto}
  .studio-col{min-height:auto}
  .hist-list{max-height:280px}
  .empty-state{min-height:240px}
}
@media (max-width:860px){
  .sidebar{transform:translateX(100%)}
  [dir="ltr"] .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .main{margin-inline-start:0}
  .menu-btn{display:inline-flex}
  .page{padding:12px}
  .chat-wrap{height:calc(100vh - 80px)}
  .hero-card-grid{grid-template-columns:1fr}
  .hero-main::before,.hero-main::after{display:none}
  .form-grid-2{grid-template-columns:1fr}
}

/* ---- typed-dialogue modal + per-ref voice chips ---- */
.modal-back{position:fixed;inset:0;background:rgba(0,0,0,.62);display:none;align-items:center;justify-content:center;z-index:200;padding:16px}
.modal-back.open{display:flex}
.modal-card{background:#17171a;border:1px solid var(--border-3);border-radius:14px;padding:18px;width:min(460px,100%);display:flex;flex-direction:column;gap:10px;box-shadow:0 18px 50px rgba(0,0,0,.5)}
.modal-title{margin:0;font-size:16px}
.modal-card textarea{background:var(--input);border:1px solid var(--border-3);border-radius:9px;color:var(--text);font-size:13px;padding:9px 11px;font-family:inherit;resize:vertical;min-height:90px;line-height:1.5}
.modal-card textarea:focus{border-color:#4a4a4c;outline:none}
.modal-card .opt-row{justify-content:flex-end;gap:8px}
.ref-voice-chips{display:flex;flex-wrap:wrap;gap:4px}
.ref-voice-chips button{flex:1 1 auto}
.ref-tts-chip{
  background:transparent;border:1px solid var(--btn);border-radius:7px;color:var(--text-2);
  font-size:10px;padding:4px 4px;cursor:pointer;font-family:inherit;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.ref-tts-chip:hover{color:#fff}

/* ===== Duration estimate + dialogue preview ===== */
.char-dlg-preview{background:none;border:1px solid rgba(127,127,127,.35);color:var(--mut);border-radius:6px;font-size:12px;padding:2px 8px;cursor:pointer}
.char-dlg-preview:hover:not(:disabled){color:var(--pri);border-color:var(--pri)}
.char-dlg-preview:disabled{opacity:.5;cursor:wait}
.char-dlg-est{font-size:12px;color:var(--mut);margin-inline-start:auto}
.dur-est-btn{margin-top:8px}
.dur-est-result{margin-top:8px;font-size:13px;color:var(--mut);line-height:1.8}
.dur-est-total{margin-top:2px}
.dur-est-total b{font-size:15px}
.dur-est-warn{color:var(--warn);font-size:12px}
