/* ============================================================
   AI Studio — tema gelap, mobile-first, Bahasa Indonesia
   ============================================================ */
:root {
  --bg: #0b0e14;
  --surface: #131a28;
  --surface2: #1a2336;
  --border: #26314a;
  --text: #e7eaf3;
  --muted: #8b93a7;
  --primary1: #7c3aed;
  --primary2: #a78bfa;
  --accent: #0891b2;
  --success: #34d399;
  --danger: #f87171;
  --radius: 16px;
  --nav-h: 64px;
  --submit-top: auto;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  background: radial-gradient(1200px 500px at 50% -10%, #171d33 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: Inter, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
body.auth-locked #screen-setup,
body.auth-locked #app-main,
body.auth-locked #bottom-nav,
body.auth-locked #jobs-card { display: none !important; }
body.auth-locked > :not(#auth-gate):not(script):not(noscript) { display: none !important; }
.auth-gate { display: none; min-height: 100dvh; padding: 24px; place-items: center; background: radial-gradient(circle at 50% 10%, #252342, #0b0e14 60%); }
body.auth-locked .auth-gate { display: grid; }
.auth-gate-card { width: min(100%, 420px); padding: 32px; border: 1px solid #34394f; border-radius: 24px; background: #171d2b; box-shadow: 0 24px 80px #0008; }
.auth-gate-card h1 { margin: 18px 0 8px; }
.auth-gate-card .btn { width: 100%; margin: 16px 0; }
.sr-only, input.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  min-width: 0; min-height: 0; padding: 0; margin: 0; border: 0;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.mono { font-family: ui-monospace, monospace; word-break: break-all; }
.break { word-break: break-all; }

/* ---------- Layar setup ---------- */
#screen-setup {
  position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2140 0%, var(--bg) 60%);
  overflow-y: auto;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
}
body:not(.needs-setup) #screen-setup { display: none; }
.setup-card {
  max-width: 400px; margin: min(8vh, 72px) auto 0;
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent), var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px; padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.setup-card .logo {
  width: 68px; height: 68px; margin: 0 auto 12px;
  display: grid; place-items: center;
  font-size: 34px; color: #fff;
  background: linear-gradient(135deg, var(--primary1), var(--primary2));
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(124,58,237,.45);
}
.setup-card h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: .3px; }
.setup-card .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.setup-card label {
  display: block; text-align: left; margin: 14px 2px 6px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}
input[type="url"], input[type="password"], input[type="text"], input[type="number"], textarea {
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--primary1);
  box-shadow: 0 0 0 3px rgba(124,58,237,.25);
}
textarea { resize: vertical; min-height: 74px; }
.setup-msg { margin-top: 14px; font-size: 13px; border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }
.setup-msg.ok  { background: rgba(52,211,153,.12); color: var(--success); }
.setup-msg.err { background: rgba(248,113,113,.12); color: var(--danger); }
.setup-foot { margin-top: 20px; font-size: 11.5px; color: var(--muted); opacity: .75; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; user-select: none;
  border-radius: 13px; padding: 12px 18px; min-height: 48px;
  font-size: 15px; font-weight: 700; color: var(--text);
  transition: transform .08s, filter .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--primary1), var(--primary2));
  box-shadow: 0 8px 24px rgba(79,70,229,.4);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost {
  background: var(--surface2);
  border: 1px solid var(--border);
}
.btn.big { width: 100%; margin-top: 18px; padding: 15px; font-size: 16.5px; border-radius: 15px; }
.btn.sm { padding: 9px 12px; font-size: 13px; border-radius: 10px; min-height: 48px; }
.btn.danger-ghost {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(248,113,113,.4);
  color: var(--danger);
  margin-top: 12px;
}
.btn-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.icon-btn {
  background: rgba(11,14,20,.65); backdrop-filter: blur(6px);
  border: 1px solid var(--border); color: var(--text);
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn.danger { color: var(--danger); }

/* ---------- App utama ---------- */
#app-main {
  max-width: 520px; margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 120px + env(safe-area-inset-bottom));
}
body.needs-setup #app-main,
body.needs-setup #bottom-nav,
body.needs-setup #jobs-card { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 2px 12px;
  background: linear-gradient(180deg, rgba(11,14,20,.92), rgba(11,14,20,.55) 80%, transparent);
  backdrop-filter: blur(8px);
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .3px; }
.brand .conn { margin: 5px 0 0 40px; font-size: 10px; font-weight: 400; letter-spacing: 0; }
.brand .dot { width: 5px; height: 5px; }
.header-node { margin-left: 3px; padding-left: 8px; border-left: 1px solid var(--border); color: var(--accent); font-weight: 700; }
.pull-refresh { position: fixed; z-index: 29; top: calc(env(safe-area-inset-top) + 58px); left: 50%; display: flex; align-items: center; gap: 7px; padding: 7px 11px; color: var(--muted); background: rgba(19,26,40,.94); border: 1px solid var(--border); border-radius: 999px; font-size: 10px; opacity: 0; pointer-events: none; transform: translate(-50%, calc(-48px + var(--pull-y, 0px))); transition: opacity .12s, transform .12s; }
.pull-refresh.visible { opacity: 1; }
.pull-refresh.ready { color: var(--accent); border-color: rgba(34,211,238,.5); }
.pull-refresh.ready span, .pull-refresh.refreshing span { transform: rotate(180deg); }
.settings-intro { margin: 18px 0 24px; }
.settings-intro h2 { margin: 5px 0 8px; font-size: 30px; letter-spacing: -.8px; }
.settings-intro p { max-width: 44ch; margin: 0; }
.settings-eyebrow { color: #76cddd; font-size: 10px; letter-spacing: 2px; font-weight: 700; }
#tab-settings .card { padding: 22px; margin-bottom: 16px; border-radius: 20px; }
#tab-settings h3 { margin: 0 0 16px; font-size: 16px; }
#tab-settings .settings-primary { background: linear-gradient(135deg,rgba(8,145,178,.09),transparent 70%),var(--surface); border-color: #294751; }
#tab-settings .btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
#tab-settings .btn-row .btn { flex: 1 1 150px; }
#tab-settings .kv { gap: 16px; padding: 12px 0; align-items: start; }
#tab-settings .kv b { text-align: right; min-width: 0; }
.settings-details { margin-top: 12px; color: var(--muted); font-size: 12px; }
.settings-details summary { padding: 10px 0; cursor: pointer; }
.header-action[aria-pressed="true"] { border-color: var(--accent); color: #76cddd; }
#bottom-nav [data-tab="generate"] { order: 0; }
#bottom-nav [data-tab="edit"] { order: 1; }
#bottom-nav [data-tab="upscale"] { order: 3; }
#bottom-nav [data-tab="video"] { order: 4; }
.logo-mini {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; margin-right: 8px; vertical-align: middle;
  background: linear-gradient(135deg, var(--primary1), var(--primary2));
  border-radius: 9px; font-size: 16px;
}
.conn { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.header-action {
  width: 48px; height: 48px; display: grid; place-items: center;
  color: var(--text); background: var(--surface2); border: 1px solid var(--border); border-radius: 14px;
}
.header-action svg, .video-segment svg, .nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.bad { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

.tab h2 { font-size: 21px; margin: 8px 0 14px; }
.tab h2 .hint { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.fld-label { display: block; margin: 14px 2px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fld-label .req { color: var(--danger); }
.fld-label small { font-weight: 400; opacity: .8; }
.counter { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Opsi lanjutan */
.adv {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.adv summary {
  cursor: pointer; font-weight: 700; font-size: 13.5px; color: var(--accent);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: '⚙️'; }
.adv[open] summary { margin-bottom: 4px; }
.chip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip {
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); border-radius: 12px; padding: 10px 4px;
  font-size: 13px; font-weight: 600; cursor: pointer; line-height: 1.25;
}
.chip small { color: var(--muted); font-weight: 500; font-size: 11px; }
.chip.active {
  border-color: var(--primary1);
  background: linear-gradient(180deg, rgba(124,58,237,.22), rgba(124,58,237,.08));
  box-shadow: 0 0 0 3px rgba(124,58,237,.18);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin-top: 4px; }
input[type="range"] { width: 100%; accent-color: var(--primary1); height: 34px; }

/* ---------- Dropzone edit ---------- */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 190px;
  display: grid; place-items: center;
  text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  overflow: hidden;
}
.dropzone.dragover { border-color: var(--accent); background: rgba(34,211,238,.06); }
.dropzone.has-img { cursor: default; border-style: solid; }
.dz-icon { font-size: 40px; margin-bottom: 6px; }
#edit-empty p, #upscale-empty p { color: var(--muted); font-size: 13.5px; margin: 0; }
#edit-preview, #upscale-preview {
  width: 100%; max-height: 320px; object-fit: contain;
  border-radius: 12px;
}
.dz-meta {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(11,14,20,.78); backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 999px;
  font-size: 11.5px; color: var(--accent);
}
.dropzone .icon-btn { position: absolute; top: 10px; right: 10px; z-index: 5; }
.dropzone .dz-replace {
  position: absolute; right: 10px; bottom: 10px; z-index: 5;
  width: auto; margin: 0; padding: 6px 10px;
  background: rgba(11,14,20,.82); backdrop-filter: blur(6px);
}

/* ---------- Riwayat ---------- */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.cell {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 14px; overflow: hidden;
  background: linear-gradient(110deg, var(--surface2) 30%, #202b44 50%, var(--surface2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border: 1px solid var(--border);
  cursor: pointer;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.cell img, .cell video {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .35s;
  position: relative; z-index: 1;
}
.cell img.loaded, .cell video.loaded { opacity: 1; }
.archive-cell { animation: none; min-height: 190px; }
.archive-state { position: absolute; inset: 38px 10px; display: flex; flex-direction: column; gap: 8px; justify-content: center; text-align: center; font-size: 12px; overflow: auto; }
.archive-state:empty { display: none; }
.history-prompt { display: none; }
.history-prompt:empty { display: none; }
.history-prompt span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.copy-prompt { flex: 0 0 22px; width: 22px; height: 22px; padding: 2px; color: #dfe4ef; background: transparent; border: 0; opacity: .82; }
.copy-prompt svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
#history-notice { line-height: 1.6; }
.history-toolbar { display:flex; gap:8px; margin-bottom:14px; }
.history-toolbar .btn { width:auto; margin:0; display:inline-flex; align-items:center; gap:6px; }
.history-toolbar svg, .history-hide svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
#history-hidden.active { color:var(--accent); border-color:color-mix(in srgb,var(--accent) 55%,var(--border)); }
.history-hide { position:absolute; top:42px; right:6px; z-index:3; width:32px; height:32px; padding:7px; border:0; border-radius:10px; display:flex; align-items:center; justify-content:center; background:rgba(11,14,20,.75); color:#dfe4ef; cursor:pointer; }
.history-hide:disabled { opacity:.45; }
#history-more { margin: 16px auto; }
#enhance-dialog { width: min(540px, calc(100vw - 32px)); max-height: 85dvh; overflow: auto; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 22px; }
#enhance-dialog::backdrop { background: rgba(0,0,0,.7); }
#enhance-status { line-height: 1.6; }
#enhance-dialog [hidden] { display: none !important; }
.cell .badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 9.5px; font-weight: 800; letter-spacing: .8px;
  padding: 3px 8px; border-radius: 999px; color: #fff;
}
.badge.t2i  { background: rgba(124,58,237,.85); }
.badge.edit { background: rgba(34,211,238,.8); color: #06232a; }
.cell .when {
  position: absolute; left: 8px; right: 8px; bottom: 6px; z-index: 2;
  font-size: 10px; color: #dfe4ef;
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
}
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.empty-icon { font-size: 46px; margin-bottom: 8px; }

/* ---------- Setelan ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 6px 0; font-size: 13.5px; }
.kv span { color: var(--muted); flex-shrink: 0; }
.kv b { text-align: right; font-weight: 600; }

/* ---------- Kartu job melayang ---------- */
#jobs-card {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  width: min(492px, calc(100% - 28px));
  z-index: 40;
  display: flex; flex-direction: column; gap: 8px;
}
.job {
  display: flex; align-items: center; gap: 12px;
  background: rgba(19,26,40,.92); backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
  animation: slideup .25s ease-out;
}
@keyframes slideup { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.job .txt { flex: 1; min-width: 0; }
.job .t1 { font-weight: 700; font-size: 13.5px; }
.job .t2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.job .j-phase { color: var(--accent); font-weight: 600; }
.job.failed { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px);} 75% { transform: translateX(4px);} }
.spin {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 3px solid rgba(124,58,237,.25);
  border-top-color: var(--primary1);
  border-radius: 50%;
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Nav bawah ---------- */
#bottom-nav {
  position: fixed; z-index: 45;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(13,17,27,.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.viewport-tracked #bottom-nav {
  top: var(--nav-top);
  bottom: auto;
  transform: translateZ(0);
}
.nav-btn {
  background: none; border: none; color: var(--muted);
  min-width: 0; min-height: 48px; padding-inline: 2px;
  font-size: 10px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer;
}
.nav-btn span { line-height: 1; transition: transform .15s; }
.nav-btn.active { color: var(--text); }
.nav-btn.active svg { color: #a78bfa; transform: translateY(-2px) scale(1.08); }

/* ---------- Viewer ---------- */
#viewer { position: fixed; inset: 0; z-index: 70; }
.viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(5,7,12,.88); backdrop-filter: blur(10px);
}
.viewer-panel {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}
.viewer-panel > img {
  flex: 1; min-height: 0;
  object-fit: contain;
  border-radius: 14px;
  margin-top: 44px;
}
.viewer-panel > button.icon-btn {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px; z-index: 2;
}
.viewer-info {
  margin: 12px 2px;
  font-size: 12px; color: var(--muted);
  max-height: 64px; overflow-y: auto;
  white-space: pre-wrap;
}
.viewer-actions { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr; gap: 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: calc(var(--nav-h) + 86px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: min(460px, calc(100% - 40px));
  background: #222c44; color: var(--text);
  border: 1px solid var(--border);
  padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 90;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.ok { border-color: rgba(52,211,153,.5); }
#toast.err { border-color: rgba(248,113,113,.5); }

@media (min-width: 560px) {
  body::before {
    content: '';
    position: fixed; inset: 0;
    background:
      radial-gradient(600px 300px at 85% 90%, rgba(79,70,229,.12), transparent),
      radial-gradient(500px 260px at 12% 15%, rgba(124,58,237,.10), transparent);
    pointer-events: none;
  }
}

/* Referensi tambahan */
.refs-row{display:flex;gap:10px;margin-bottom:14px}
.ref-box{position:relative;flex:1;max-width:46%;aspect-ratio:1/1;border:1.5px dashed #39415a;border-radius:14px;background:#10141f;display:flex;align-items:center;justify-content:center;overflow:hidden;cursor:pointer}
.ref-box img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.ref-add{font-size:12px;color:#8b93a8;padding:6px;text-align:center}
.ref-box.has-img{border-style:solid;border-color:#5b8def}
.ref-box.has-img .ref-add{display:none}
.ref-x{position:absolute;top:4px;right:4px;z-index:2;width:26px;height:26px;padding:0}

/* ---------- Topbar kanan: akun ---------- */
.top-right{display:flex;align-items:center;gap:10px}
.acct-btn{
  background:var(--surface2);border:1px solid var(--border);color:var(--text);
  border-radius:999px;padding:7px 13px;font-size:12.5px;font-weight:700;cursor:pointer;
  max-width:150px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.acct-btn:active{transform:scale(.96)}

/* ---------- Mode panel (inpaint/outpaint) ---------- */
#edit-modes { margin-bottom: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#edit-modes .chip { min-width: 0; min-height: 58px; font-size: 12px; padding: 8px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
#edit-modes .chip span { white-space: nowrap; }
#edit-modes .chip.active { box-shadow: none; }
#edit-modes svg, #tab-settings svg, .upload-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
#tab-edit h2 { margin-bottom: 5px; }
#tab-edit [data-process-node] { display: inline-block; margin: 0 10px 12px 0; }
#edit-engine-hint { display: inline-block; margin: 0 0 12px; color: var(--accent); }
#tab-edit .dropzone { min-height: 135px; }
#tab-edit .upload-icon { width: 28px; height: 28px; margin-top: 18px; }
#tab-edit .dropzone p { margin: 8px 0 18px; }
#tab-edit .dropzone small { font-size: 11px; color: var(--muted); }
#tab-edit .refs-row { gap: 8px; }
#tab-edit .ref-box { height: 90px; min-height: 0; }
#tab-edit .mode-panel { padding: 10px 12px; }
#tab-edit .mode-hint { margin: 0 0 8px; }
#tab-edit .adv summary::before { content: '+'; font-size: 18px; }
#tab-edit .adv[open] summary::before { content: '-'; }
#edit-asset-notice:empty, #edit-model-note:empty { display: none; }
.edit-model-field { width: 100%; min-width: 0; margin-top: 12px; }
.edit-model-field select { width: 100%; min-width: 0; text-overflow: ellipsis; }
#tab-settings .settings-intro { margin: 8px 0 16px; }
#tab-settings .settings-intro h2 { font-size: 22px; margin: 0; }
#tab-settings .card { padding: 16px; margin-bottom: 12px; border-radius: 16px; }
#tab-settings h3 { margin: 0 0 10px; font-size: 14px; }
.settings-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
#tab-settings .settings-heading h3 { margin: 0; }
#tab-settings .icon-btn { width: 36px; height: 36px; flex-shrink: 0; }
#tab-settings .kv { padding: 8px 0; font-size: 12px; }
.settings-user > div { display: flex; align-items: center; gap: 6px; min-width: 0; }
.settings-user b { overflow-wrap: anywhere; }
.machine-controls { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-top: 8px; }
#tab-settings .btn { min-height: 40px; padding: 9px 10px; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#tab-settings .btn-row { margin-top: 10px; }
#tab-settings .small { font-size: 11px; line-height: 1.5; margin: 8px 0; }
#tab-settings .settings-details { font-size: 11px; margin-top: 6px; }
#set-msg:empty, #set-comfy-status:empty { display: none; }
#set-comfy-status { overflow-wrap: anywhere; }
.settings-footer { text-align: center; }
.mode-panel{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:14px;margin:14px 0;
}
.mode-hint{margin:0 0 10px;font-size:12.5px;color:var(--muted);line-height:1.5}
.mask-status.ok{color:var(--success);font-weight:600}
.op-sides{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.badge.inpaint  { background: rgba(245,158,11,.85); }
.badge.outpaint { background: rgba(16,185,129,.85); }
.badge.upscale  { background: rgba(236,72,153,.88); }
.badge.i2v, .badge.t2v, .badge.ref2v { background: rgba(8,145,178,.9); }

/* ---------- Video discovery ---------- */
#video-modes { margin-bottom: 14px; }
.video-segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.video-segment {
  min-height: 64px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; font-size: 11px; font-weight: 700;
}
.video-segment i { color: var(--accent); font-style: normal; }
.video-segment.active { color: var(--text); border-color: var(--primary1); background: rgba(124,58,237,.14); box-shadow: inset 0 0 0 1px rgba(167,139,250,.25); }
.video-panel {
  padding: 14px;
  background: rgba(34,211,238,.04);
  border: 1px solid rgba(34,211,238,.18);
  border-radius: var(--radius);
}
.video-file-row { display: grid; gap: 6px; }
.video-reference-sockets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.video-drop { min-height: 138px; margin-bottom: 12px; border-width: 1.5px; }
.video-drop p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.video-drop .upload-icon { width: 30px; height: 30px; fill: none; stroke: var(--accent); stroke-width: 1.4; }
.video-drop > img, .video-drop > video { display: block; width: 100%; height: 100%; min-height: 138px; max-height: 230px; object-fit: contain; background: #090c12; }
.video-drop > video { pointer-events: none; }
.video-drop .icon-btn { position: absolute; z-index: 4; top: 8px; right: 8px; width: 34px; height: 34px; }
.video-drop .dz-meta { left: 8px; bottom: 8px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input[type="file"]:not(.sr-only) { width: 100%; min-height: 48px; padding: 9px; color: var(--muted); background: var(--surface2); border: 1px dashed var(--border); border-radius: 12px; }
input[type="file"]:not(.sr-only)::file-selector-button { min-height: 32px; margin-right: 8px; color: var(--text); background: rgba(124,58,237,.22); border: 1px solid rgba(167,139,250,.35); border-radius: 9px; }
.video-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.video-options label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.video-options .video-seed { grid-column: auto; }
.video-audio-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(132px, .75fr); gap: 10px; margin-top: 12px; }
.video-audio-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface2); cursor: pointer; }
.video-audio-toggle > span { display: grid; gap: 1px; min-width: 0; }
.video-audio-toggle b { color: var(--text); font-size: 13px; }
.video-audio-toggle small { color: var(--muted); font-size: 10px; line-height: 1.2; }
.video-audio-toggle input { appearance: none; position: relative; flex: 0 0 38px; width: 38px; height: 22px; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); cursor: pointer; }
.video-audio-toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .16s ease; }
.video-audio-toggle input:checked { background: var(--accent); }
.video-audio-toggle input:checked::after { transform: translateX(16px); background: #fff; }
.video-panel > .video-audio-toggle { margin-top: 12px; }
.video-lora { display: grid; gap: 8px; margin-top: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: rgba(15,23,42,.55); }
.video-lora-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.video-lora-row { display: grid; grid-template-columns: minmax(0,1fr) 72px 32px; gap: 7px; align-items: center; margin-top: 7px; }
.video-lora-row input, .lora-password { min-width: 0; min-height: 44px; padding: 8px 10px; }
.lora-password { width: 100%; }
.lora-access { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: center; }
.video-audio-source { display: grid; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.video-audio-source .sel { min-height: 32px; padding: 5px 8px; }
.video-audio-source.is-disabled { opacity: .45; }
@media (max-width: 420px) { .video-audio-row { grid-template-columns: 1fr; } }
.video-scale-field input[type="number"] { min-width: 0; }
.video-scale-field input[type="range"] { height: 20px; }
.duration-custom { margin-top: 2px; }
.field-error { margin-top: 10px; padding: 9px 11px; color: #fecaca; background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.35); border-radius: 10px; font-size: 12px; }
.video-discovery-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 12px 0;
}
.video-discovery-row span { flex: 1; }
.ok-text { color: var(--success); }
.err-text { color: var(--danger); }
.setup-msg.warn { border-color: rgba(245,158,11,.45); color: #fcd28a; background: rgba(245,158,11,.08); }

.recovery-card, .update-card {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px; margin: 4px 0 16px; color: var(--text);
  background: linear-gradient(135deg, rgba(245,158,11,.13), rgba(19,26,40,.96));
  border: 1px solid rgba(245,158,11,.35); border-radius: var(--radius);
}
.recovery-card p, .update-card p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.update-card { position: fixed; z-index: 58; left: 12px; right: 12px; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); max-width: 520px; margin-inline: auto; box-shadow: 0 18px 50px rgba(0,0,0,.5); }

@media (max-width: 390px) {
  .nav-btn { font-size: 8.5px; }
}

@media (min-width: 760px) {
  #app-main { max-width: 760px; }
  .video-options { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .video-options label:last-child:nth-child(odd) { grid-column: auto; }
}

@media (orientation: landscape) and (max-height: 560px) {
  :root { --nav-h: 56px; }
  .topbar { position: relative; padding-top: max(8px, env(safe-area-inset-top)); }
  .video-segment { min-height: 52px; flex-direction: row; }
  .viewer-stage > img, .viewer-stage > video { max-height: calc(100dvh - 112px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Modal generik ---------- */
.modal{position:fixed;inset:0;z-index:80;display:grid;place-items:center;padding:18px}
.modal-backdrop{position:absolute;inset:0;background:rgba(5,7,12,.86);backdrop-filter:blur(8px)}
.modal-panel{
  position:relative;z-index:1;width:min(480px,100%);
  max-height:calc(100dvh - 36px);overflow-y:auto;
  background:var(--surface);border:1px solid var(--border);
  border-radius:20px;padding:20px 18px;
  box-shadow:0 24px 70px rgba(0,0,0,.55);
}
.modal-panel h3{margin:0 0 10px;font-size:16.5px}
.confirm-panel{width:min(360px,100%);padding:20px}
.confirm-panel p{margin:0 0 18px;color:var(--muted);line-height:1.55;white-space:pre-wrap}
.confirm-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.confirm-actions .btn{margin:0}

/* ---------- Editor mask ---------- */
#me-stage{
  position:relative;margin:6px auto 12px;border-radius:12px;overflow:hidden;
  border:1px solid var(--border);background:#000;line-height:0;
  touch-action:none;
}
#me-stage canvas{display:block;width:100%;height:auto}
#me-stage .me-draw{position:absolute;inset:0;width:100%;height:100%;cursor:crosshair;touch-action:none}
.me-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:4px}
.me-brush{
  display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--muted);
  flex:1;min-width:170px;
}
.me-brush input[type="range"]{flex:1;height:30px}
.me-brush b{min-width:22px;text-align:right;color:var(--text)}

/* ===== v11: overscroll fix, textarea besar, keyboard, model, hapus riwayat, preview ===== */
html { background-color: #0b0e14; overscroll-behavior: none; }
body { overscroll-behavior: none; background-attachment: scroll; }
textarea#gen-prompt, textarea#edit-prompt { min-height: 170px; font-size: 15px; line-height: 1.55; padding: 12px; }
textarea#edit-prompt { min-height: 120px; }
#comfy-recovery.in-settings { display: none; }
select.sel { width: 100%; margin-top: 4px; padding: 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface2); color: var(--text); font-size: 14px; }
.enh { margin-top: 10px; width: auto; display: inline-block; font-size: 13.5px; padding: 9px 14px; border-radius: 11px; }
.cell { position: relative; }
.cell .del { position: absolute; top: 6px; right: 6px; z-index: 3; width: 32px; height: 32px; border-radius: 10px; border: none; background: rgba(11,14,20,.75); color: #ffb3b3; font-size: 15px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.j-step { margin-top: 4px; font-size: 12px; color: var(--muted); }
.viewer-actions { flex-wrap: wrap; gap: 8px; }
#btn-view-ba { font-weight: 600; }
.j-prev { margin: 8px 0 2px; width: 100%; max-height: 230px; object-fit: contain; background: #000; border-radius: 10px; display: none; }
.j-prev.on { display: block; }
/* ================= v13 (26 Agu): layout preview live + viewer compact ================= */
.job { flex-wrap: wrap; row-gap: 8px; }
.j-live { width: 100%; order: 99; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 4px; padding: 8px; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; }
.j-prev {
  display: none;
  margin: 0;
  width: 100%;
  height: clamp(180px, 38vh, 360px);
  object-fit: contain;
  background: #05070b;
  border-radius: 8px;
  box-shadow: 0 2px 14px rgba(0,0,0,.45);
  image-rendering: auto;
}
.j-prev.on { display: block; }
.j-step { margin: 0; font-size: 12px; color: var(--muted); text-align: center; letter-spacing: .02em; }
.j-live { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; min-height: 44px; }
.j-live:disabled { cursor: default; opacity: 1; }
.j-live:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.j-preview-hint { color: var(--muted); font-size: 10px; }
.j-live.is-collapsed { flex-direction: row; justify-content: space-between; gap: 12px; padding: 8px 12px; }
.j-live.is-collapsed .j-prev { display: none; }
.j-live.is-collapsed .j-step { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.j-live.is-collapsed .j-preview-hint { flex-shrink: 0; }
.viewer-panel { padding: 10px 10px 12px; }
.viewer-panel > img { max-height: 72vh; max-height: 76dvh; width: auto; max-width: 100%; object-fit: contain; }
.viewer-info { font-size: 11px; line-height: 1.45; max-height: 52px; overflow-y: auto; opacity: .85; margin: 8px 0; }
.viewer-actions { display: flex; flex-wrap: nowrap; justify-content: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.viewer-actions::-webkit-scrollbar { display: none; }
.viewer-actions .btn { flex: 0 0 42px; width: 42px; height: 42px; margin: 0; padding: 9px; border-radius: 50%; }
.viewer-actions .btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
/* ================= v14 (26 Agu): viewer info overlay + keyboard UX ================= */
.viewer-stage { position: relative; max-width: 100%; display: flex; justify-content: center; cursor: pointer; }
.viewer-stage > img { display: block; max-height: 70vh; max-height: 74dvh; width: auto; max-width: 100%; object-fit: contain; transition: filter .18s ease; }
.viewer-stage.info-on > img { filter: brightness(.62) saturate(.9); }
.viewer-info { position: absolute; left: 0; right: 0; bottom: 0; max-height: none; overflow: visible; margin: 0; padding: 30px 14px 12px; font-size: 11.5px; line-height: 1.5; color: #eef2f9; text-align: left; white-space: pre-wrap; word-break: break-word; background: linear-gradient(180deg, rgba(5,8,14,0) 0%, rgba(5,8,14,.45) 26%, rgba(5,8,14,.93) 100%); border-radius: 0 0 14px 14px; opacity: 0; pointer-events: none; transition: opacity .18s ease; }
.viewer-stage.info-on .viewer-info { opacity: 1; }
body.kb #btn-gen, body.kb #btn-edit { position: sticky; bottom: 10px; z-index: 40; box-shadow: 0 8px 26px rgba(0,0,0,.55); }
/* ================= v17 (26 Agu): timer persisten + viewer/keyboard mobile ================= */
#viewer { display: block; padding: 0; }
.viewer-panel {
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: calc(54px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
}
.viewer-stage {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  align-items: center;
}
.viewer-stage > img {
  max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  border-radius: 14px;
}
.viewer-actions { flex: 0 0 auto; margin: 0; padding-top: 2px; }
body.kb #app-main { padding-bottom: calc(var(--nav-h) + var(--focus-room, 200px) + env(safe-area-inset-bottom)); }
body.kb textarea#gen-prompt, body.kb textarea#edit-prompt {
  min-height: min(170px, var(--entry-max-height));
  height: min(170px, var(--entry-max-height));
  max-height: var(--entry-max-height);
  overflow-y: auto;
  resize: none;
}
body.kb #btn-gen, body.kb #btn-edit {
  position: fixed;
  top: var(--submit-top);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 440px);
  z-index: 46;
  margin: 0;
  box-shadow: 0 8px 26px rgba(0,0,0,.55);
}
body.kb #btn-gen:active, body.kb #btn-edit:active { transform: translateX(-50%) scale(.97); }

@media (max-height: 560px) {
  .viewer-panel { gap: 12px; padding-top: calc(46px + env(safe-area-inset-top)); }
  .viewer-stage > img { max-height: calc(100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

/* ================= v18: custom controls + multi-server ================= */
#gen-sizes { grid-template-columns: repeat(2, 1fr); }
.custom-size {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  margin-top: 8px;
  padding: 2px 12px 10px;
  background: rgba(34,211,238,.05);
  border: 1px solid rgba(34,211,238,.2);
  border-radius: 13px;
}
.custom-size p { grid-column: 1 / -1; margin: 8px 0 0; }
.step-label { display: flex; align-items: center; gap: 7px; }
input.step-number {
  width: 72px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 9px;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
}
.row2 > div > small.muted { display: block; margin-top: -2px; font-size: 10.5px; line-height: 1.3; }
#set-server-select { margin-bottom: 12px; }
.model-routing-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.model-routing-row > div { min-width: 0; }
@media (max-width: 560px) {
  .model-routing-row { grid-template-columns: minmax(0, 1fr); }
}

/* ================= v22: media viewer + Android UX ================= */
.viewer-stage > video {
  display: block; width: auto; max-width: 100%;
  max-height: calc(100dvh - 150px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  object-fit: contain; border-radius: 14px; background: #000;
}
.viewer-stage.info-on > video { filter: brightness(.62) saturate(.9); }
.viewer-stage > video { width: min(100%, 960px); min-width: 0; min-height: 160px; aspect-ratio: 16 / 9; background: #000; }
.viewer-before-wrap { position: absolute; inset: 0; z-index: 2; display: flex; justify-content: center; overflow: hidden; clip-path: inset(0 calc(100% - var(--compare-x, 50%)) 0 0); pointer-events: none; }
.viewer-before-wrap img { display: block; width: auto; max-width: 100%; max-height: 70vh; max-height: 74dvh; object-fit: contain; }
.viewer-compare-line { position: absolute; z-index: 3; top: 0; bottom: 0; left: var(--compare-x, 50%); width: 2px; background: rgba(255,255,255,.94); box-shadow: 0 0 0 1px rgba(0,0,0,.35); pointer-events: none; }
.viewer-compare-line::after { content: '↔'; position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 30px; height: 30px; color: #071018; background: white; border-radius: 50%; font-size: 14px; transform: translate(-50%,-50%); }
.viewer-stage:has(.viewer-before-wrap:not(.hidden)) { touch-action: none; cursor: ew-resize; }
.viewer-stage.can-compare, .viewer-stage.can-compare img { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: none; }
.viewer-playback { text-align: center; flex: 0 0 auto; }
.viewer-playback p:empty { display: none; }
.viewer-playback .btn { margin: 4px; }
.video-size-estimate { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin:6px 0 16px; padding:8px; border:1px solid var(--border); border-radius:12px; font-size:12px; color:var(--muted); overflow-wrap:anywhere; }
.video-size-estimate span { display:flex; min-width:0; flex-direction:column; gap:2px; padding:7px 8px; border-radius:9px; background:rgba(255,255,255,.035); }
.video-size-estimate b { font-size:10px; font-weight:600; color:var(--muted); }
.video-size-estimate strong { font-size:13px; font-weight:700; color:var(--text); }
.top-right { gap: 8px; }
.setup-advanced { text-align: left; }
.setup-advanced label { margin-top: 12px; }
.draft-status { margin: 0 0 10px; font-size: 11px; }
.draft-status:empty { display: none; }
.draft-status.draft-error { color: var(--danger); }
.prompt-input-wrap { position: relative; }
.prompt-tools { display: flex; justify-content: flex-end; gap: 6px; margin: 6px 0 2px; }
.prompt-tool { display: grid; place-items: center; width: 34px; height: 32px; padding: 0; border: 1px solid rgba(148,163,184,.24); border-radius: 9px; color: var(--muted); background: var(--surface2); cursor: pointer; touch-action: manipulation; }
.prompt-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prompt-tool:active { color: var(--text); transform: scale(.94); }
.prompt-clear.is-empty { opacity: .32; }
.draft-image-preview { display: block; max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 10px; margin: 8px 0; }

@media (max-width: 390px) {
  .video-reference-sockets { grid-template-columns: 1fr 1fr; gap: 8px; }
  .video-drop { min-height: 122px; }
  .video-drop > img, .video-drop > video { min-height: 122px; }
  .header-node { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.translate-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; font-weight: 600; }
.translate-toggle small { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; }
.translate-toggle input { appearance: none; position: relative; flex: 0 0 42px; width: 42px; height: 26px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface2); padding: 0; margin: 0; cursor: pointer; }
.translate-toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); }
.translate-toggle input:checked { background: var(--accent); }
.translate-toggle input:checked::after { left: 19px; background: white; }
.translate-toggle input:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
#translate-dialog { box-sizing: border-box; position: fixed; inset: auto; top: calc(var(--visible-top, 0px) + 12px); left: 50%; transform: translateX(-50%); margin: 0; width: min(540px, calc(100vw - 24px)); max-height: calc(var(--visible-height, 100dvh) - 24px); overflow: auto; overscroll-behavior: contain; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 18px; padding: 20px; }
#translate-dialog::backdrop { background: rgba(0,0,0,.72); }
#translate-dialog h3 { margin: 0 0 12px; }
#translate-dialog details { font-size: 13px; margin: 12px 0; }
#translate-original { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: auto; }
#translate-result { min-height: 96px; max-height: min(220px, 30dvh); resize: vertical; }
.translate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.translate-actions .btn { white-space: normal; min-height: 44px; font-size: 13px; padding: 10px; }
.translate-actions [hidden] { display: none; }

/* v65: screenshot-led, responsive creation workspace */
:root {
  --bg: #050b18;
  --surface: #0e192b;
  --surface2: #15243b;
  --border: #243b61;
  --text: #f4f7ff;
  --muted: #a5b4cf;
  --primary1: #792cff;
  --primary2: #b44cff;
  --accent: #55b9ff;
  --nav-h: 74px;
}
body { background: radial-gradient(900px 520px at 0% 4%, #102957 0%, transparent 62%), radial-gradient(700px 480px at 100% 18%, #17234d 0%, transparent 60%), #050b18; }
#app-main { max-width: 900px; padding-inline: 17px; }
.topbar { margin-inline: -3px; padding: calc(10px + env(safe-area-inset-top)) 12px 12px; border: 1px solid rgba(98,147,226,.18); border-radius: 22px; background: linear-gradient(110deg, rgba(13,33,67,.92), rgba(9,19,39,.83)); box-shadow: 0 16px 42px rgba(0,0,0,.24), inset 0 1px rgba(255,255,255,.04); backdrop-filter: blur(16px); }
.brand { font-size: 20px; }
.brand .logo-mini { width: 40px; height: 40px; border-radius: 12px; font-size: 22px; box-shadow: 0 7px 22px rgba(124,44,255,.35); }
.brand .conn { margin-left: 48px; font-size: 11px; }
.top-right { gap: 8px; }
.header-action { width: 48px; height: 48px; border-radius: 15px; background: linear-gradient(145deg, #142844, #10192b); border-color: #29466f; }
.create-hub { margin: 20px 0 18px; }
.create-heading { display: grid; grid-template-columns: minmax(0,1fr) minmax(142px, 220px); align-items: center; gap: 14px; margin: 0 3px 18px; }
.create-copy h1 { margin: 0 0 2px; font-size: clamp(27px, 6vw, 36px); line-height: 1.06; letter-spacing: -.055em; }
.create-copy p { max-width: 35ch; margin: 7px 0 0; color: #b1c0da; font-size: 14px; line-height: 1.42; }
.engine-control { display: block; min-width: 0; padding: 8px 10px 9px; border: 1px solid rgba(160,119,255,.62); border-radius: 15px; background: linear-gradient(130deg, rgba(90,37,203,.48), rgba(34,24,78,.86)); box-shadow: 0 5px 26px rgba(101,46,255,.21), inset 0 1px rgba(255,255,255,.1); }
.engine-control > span { display: block; color: #d6caff; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.engine-control select.sel { margin-top: 3px; padding: 4px 18px 4px 0; border: 0; border-radius: 0; background-color: transparent; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.engine-control select.sel option { color: #111827; }
.engine-control .small { display: block; margin: 5px 0 0; font-size: 10px; line-height: 1.3; }
.create-model-note { min-height: 0; margin: -10px 4px 10px; font-size: 11px; }
#create-edit-model-field { border-color: rgba(160,119,255,.62); }
#edit-model-note:empty, #gen-model-note:empty { display: none; }
#edit-modes.create-mode-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; margin: 0 0 16px; }
.create-mode-grid .chip { min-width: 0; min-height: 98px; padding: 10px 5px; display: flex; flex-direction: column; justify-content: center; gap: 5px; color: #eff5ff; border: 1px solid #243d68; border-radius: 19px; background: linear-gradient(145deg, rgba(22,43,74,.95), rgba(13,25,45,.96)); box-shadow: 0 6px 18px rgba(0,0,0,.2), inset 0 1px rgba(255,255,255,.045); }
.create-mode-grid .chip svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; color: #d7e5ff; }
.create-mode-grid .chip span { max-width: 100%; color: #f6f8ff; font-size: 13px; line-height: 1.2; text-align: center; white-space: normal; }
.create-mode-grid .chip small { color: #b3c2de; font-size: 10px; line-height: 1.2; font-weight: 500; text-align: center; }
.create-mode-grid .chip.active { border-color: #ce84ff; color: #fff; background: linear-gradient(145deg, #7e25f0 0%, #4b16c4 48%, #321574 100%); box-shadow: 0 0 0 1px rgba(208,134,255,.32), 0 0 24px rgba(146,55,255,.5), inset 0 1px rgba(255,255,255,.28); }
.create-mode-grid .chip.active svg { color: #fff; filter: drop-shadow(0 0 5px rgba(229,197,255,.6)); }
.angle-controls { margin: 0 0 16px; padding: 13px 14px 10px; border: 1px solid rgba(84,161,255,.42); border-radius: 17px; background: linear-gradient(130deg,rgba(15,47,88,.85),rgba(12,22,42,.94)); }
.angle-controls-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.angle-controls-heading b, .angle-controls-heading small { display: block; }
.angle-controls-heading b { font-size: 14px; }
.angle-controls-heading small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.angle-controls-heading > span { color: #91ceff; font-size: 10px; text-align: right; }
.camera-orbit { position: relative; width: min(100%, 430px); aspect-ratio: 320 / 220; margin: 10px auto 0; overflow: hidden; border: 1px solid rgba(91,128,184,.26); border-radius: 16px; background: radial-gradient(ellipse at 50% 55%, rgba(23,43,71,.7), rgba(5,10,20,.97) 70%); perspective: 700px; touch-action: none; user-select: none; }
.camera-grid { position: absolute; inset: 36% -18% -70%; opacity: .42; transform: perspective(240px) rotateX(59deg); transform-origin: 50% 0; background-image: linear-gradient(rgba(82,110,148,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(82,110,148,.25) 1px, transparent 1px); background-size: 24px 18px; mask-image: linear-gradient(to bottom, transparent, #000 25%, transparent 90%); }
.camera-image-plane { position: absolute; z-index: 1; left: 50%; top: 45%; display: grid; width: 25%; height: 53%; place-items: center; overflow: hidden; border: 1px solid rgba(212,226,255,.7); border-radius: 5px; background: linear-gradient(145deg, rgba(81,101,134,.76), rgba(25,37,58,.9)); box-shadow: 0 8px 28px rgba(0,0,0,.5), 0 0 18px rgba(80,152,255,.16); transform-style: preserve-3d; transition: transform .12s ease-out; }
.camera-image-plane img { display: block; width: 100%; height: 100%; object-fit: cover; }
.camera-image-plane img, .camera-image-plane span { backface-visibility: hidden; }
.camera-image-plane::after { content: 'CAMERA VIEW'; position: absolute; inset: 0; display: none; place-items: center; color: #90a8cc; font-size: 8px; letter-spacing: .12em; background-color: #101a2a; background-image: linear-gradient(rgba(107,139,184,.18) 1px, transparent 1px), linear-gradient(90deg, rgba(107,139,184,.18) 1px, transparent 1px); background-size: 10px 10px; transform: rotateY(180deg); backface-visibility: hidden; }
.camera-image-plane.has-image::after { display: grid; }
.camera-image-plane img[hidden], .camera-image-plane span[hidden] { display: none; }
.camera-image-plane span { max-width: 90%; color: #c2d1eb; font-size: clamp(7px,1.7vw,10px); text-align: center; }
.camera-orbit > svg { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; overflow: visible; }
.camera-orbit-shadow { fill: none; stroke: rgba(238,43,143,.15); stroke-width: 11; }
.camera-orbit-track { fill: none; stroke: #e93191; stroke-width: 3.5; stroke-linecap: round; }
.camera-orbit-horizontal-hit, .camera-orbit-vertical-hit { stroke: transparent; stroke-width: 24; pointer-events: stroke; cursor: grab; }
.camera-orbit-vertical { fill: none; stroke: #02ddc7; stroke-width: 3.5; stroke-linecap: round; pointer-events: none; }
.camera-zoom-guide { fill: none; stroke: rgba(255,194,15,.68); stroke-width: 2; pointer-events: none; }
.camera-zoom-hit { fill: none; stroke: transparent; stroke-width: 22; pointer-events: stroke; cursor: grab; }
.camera-handle { stroke: rgba(255,255,255,.78); stroke-width: 1.5; cursor: grab; filter: drop-shadow(0 2px 5px rgba(0,0,0,.75)); touch-action: none; }
.camera-handle:active { cursor: grabbing; }
.camera-handle:focus-visible { outline: none; stroke: white; stroke-width: 3; }
.camera-handle-horizontal { fill: #f02c9a; }
.camera-handle-vertical { fill: #05dbc6; }
.camera-handle-zoom { fill: #ffc400; }
.camera-readouts { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; width: min(100%,430px); margin: 0 auto; padding: 8px 6px 6px; border: 1px solid rgba(238,43,143,.2); border-top: 0; border-radius: 0 0 12px 12px; background: rgba(7,11,20,.62); text-align: center; }
.camera-readouts div { display: grid; gap: 2px; }
.camera-readouts small { color: #a9adc0; font-size: 9px; letter-spacing: .04em; }
.camera-readouts b { color: #f3339d; font-size: 13px; font-variant-numeric: tabular-nums; }
.camera-readouts div:nth-child(2) b { color: #14e0cb; }
.camera-readouts div:nth-child(3) b { color: #ffd02e; }
.camera-prompt { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 8px; margin: 8px 2px 0; color: #9eb1d0; font-size: 10px; }
.camera-prompt code { color: #dce7fb; font-size: 10px; overflow-wrap: anywhere; }
.angle-disclaimer { margin: 7px 0 0; color: #93a7c6; font-size: 10px; line-height: 1.4; }
.tab h2 { margin-top: 12px; }
#tab-generate .model-routing-row { margin: 0 0 8px; padding: 0; border: 0; }
#tab-generate .fld-label, #tab-edit .fld-label { margin-top: 13px; }
#tab-generate textarea#gen-prompt, #tab-edit textarea#edit-prompt { min-height: 118px; border-radius: 17px; background: linear-gradient(150deg, #13243d, #101c30); border-color: #29456f; font-size: 15px; }
#tab-generate .counter, #tab-edit .counter { color: #adc3e8; font-size: 11px; }
#tab-edit .dropzone { min-height: 160px; border: 1px dashed #3471ba; border-radius: 18px; background: linear-gradient(145deg, rgba(20,42,73,.9), rgba(11,22,39,.94)); }
#tab-edit .dropzone .upload-icon { width: 31px; height: 31px; margin-top: 26px; }
#tab-edit .dropzone p { color: #d9e5f8; }
.reference-card { position: relative; overflow: hidden; margin: 12px 0 15px; padding: 13px 14px 12px; border: 1px dashed #3284db; border-radius: 19px; background: linear-gradient(125deg, rgba(11,31,59,.96), rgba(12,26,49,.88)); }
.reference-copy { position: relative; z-index: 1; display: flex; align-items: flex-start; gap: 10px; }
.reference-copy b { font-size: 14px; }
.reference-copy small { color: #cad7ec; font-size: 11px; }
.reference-copy p { margin: 4px 0 0; color: #a9bfdc; font-size: 11px; line-height: 1.4; }
.reference-title { min-width: 0; }
.reference-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; color: white; border-radius: 10px; background: linear-gradient(145deg,#254ec0,#233379); }
.reference-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reference-enable-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 43px; margin-top: 10px; padding: 7px 9px; border: 1px solid rgba(82,124,190,.36); border-radius: 12px; background: rgba(8,18,34,.48); cursor: pointer; }
.reference-enable-toggle > span { display: grid; gap: 2px; color: var(--text); font-size: 12px; font-weight: 650; }
.reference-enable-toggle small { color: var(--muted); font-size: 10px; font-weight: 400; }
.reference-enable-toggle input { appearance: none; position: relative; flex: 0 0 38px; width: 38px; height: 22px; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); cursor: pointer; }
.reference-enable-toggle input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .16s ease; }
.reference-enable-toggle input:checked { background: var(--accent); }
.reference-enable-toggle input:checked::after { transform: translateX(16px); background: #fff; }
.reference-enable-toggle input:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.reference-slot-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 1px 6px; color: var(--muted); }
.reference-slot-heading small { font-size: 10px; }
.reference-slot-heading b { color: #b8d4ff; font-size: 10px; white-space: nowrap; }
.refs-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; transition: opacity .15s ease; }
.refs-grid.is-disabled { opacity: .48; }
.reference-card .ref-box { position: relative; min-width: 0; height: 64px; border: 1px dashed #394b67; border-radius: 10px; background: rgba(12,21,38,.78); display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.reference-card .ref-box[aria-disabled="true"] { cursor: not-allowed; }
.reference-card .ref-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reference-card .ref-box.has-img { border-style: solid; border-color: #5b8def; }
.reference-card .ref-add { position: relative; z-index: 1; padding: 4px; color: #a9bfdc; font-size: 10px; text-align: center; line-height: 1.2; }
.reference-card .ref-box.has-img .ref-add { display: none; }
.reference-card .ref-x { position: absolute; z-index: 2; top: 3px; right: 3px; width: 21px; height: 21px; padding: 0; }
.reference-card .refs-row { margin: 0; }
#edit-model-field { display: none; }
#tab-edit .edit-model-field { display: none; }
#tab-generate .adv, #tab-edit .adv { border-radius: 17px; border-color: #263f66; background: linear-gradient(135deg, rgba(17,36,63,.95), rgba(12,23,41,.98)); }
#tab-generate .adv summary, #tab-edit .adv summary { gap: 9px; min-height: 32px; font-size: 14px; }
#tab-generate .adv summary::before, #tab-edit .adv summary::before { content: ''; width: 31px; height: 31px; border-radius: 10px; background: linear-gradient(145deg,#324ec0,#263875); }
#tab-generate .btn.big, #tab-edit .btn.big { margin-top: 14px; border-radius: 17px; box-shadow: 0 8px 25px rgba(104,40,255,.34); }
#bottom-nav { grid-template-columns: repeat(3,1fr); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: rgba(8,14,27,.92); border-top-color: rgba(73,104,159,.34); }
.nav-btn { gap: 5px; font-size: 11px; }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: #e6dcff; }
.nav-btn.active svg { color: #b25cff; }

@media (max-width: 430px) {
  #app-main { padding-inline: 14px; }
  .create-heading { grid-template-columns: minmax(0,1fr) 142px; gap: 9px; margin-inline: 0; }
  .create-copy h1 { font-size: 27px; }
  .create-copy p { font-size: 12px; }
  .engine-control { padding-inline: 8px; }
  .engine-control select.sel { font-size: 12px; }
  #edit-modes.create-mode-grid { gap: 7px; }
  .create-mode-grid .chip { min-height: 91px; padding-inline: 3px; border-radius: 15px; }
  .create-mode-grid .chip span { font-size: 11px; }
  .create-mode-grid .chip small { font-size: 9px; }
  .refs-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .reference-card .ref-box { height: 57px; }
}
@media (max-width: 360px) {
  .create-heading { grid-template-columns: minmax(0,1fr) 126px; }
  .create-copy h1 { font-size: 24px; }
  .engine-control select.sel { font-size: 11px; }
  .create-mode-grid .chip span { font-size: 10px; }
  .angle-controls { padding: 11px 10px 9px; }
  .angle-controls-heading > span { max-width: 45%; }
  .camera-orbit { width: 100%; }
  .camera-readouts { width: 100%; }
}

.invite-code-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; }
.invite-code-row code { flex: 1; min-width: 0; padding: 12px 10px; border: 1px solid #52618a; border-radius: 10px; background: #111827; color: #e9ddff; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-align: center; overflow-wrap: anywhere; }
.owner-allowed-users { display: grid; gap: 8px; }
.owner-allowed-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid rgba(105,124,165,.25); border-radius: 12px; background: rgba(15,22,37,.7); }
.owner-allowed-row > span { min-width: 0; overflow-wrap: anywhere; }
