:root {
  --bg:        #0d0f14;
  --surface:   #131620;
  --card:      #1b1f2e;
  --elevated:  #1e2230;
  --border:    #252a3a;
  --border2:   #2a2f40;
  --accent:    #6c63ff;
  --accent2:   #9b59b6;
  --accentGlow:rgba(108,99,255,.2);
  --text:      #e8eaf2;
  --muted:     #7a7f96;
  --success:   #22c55e;
  --error:     #ef4444;
  --warning:   #f59e0b;
  --radius:    10px;
  --sidebar-w: 220px;
  --header-h:  52px;
}

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html{height:100%;overscroll-behavior:none}
body{min-height:100%;background:var(--bg);color:var(--text);
  font-family:'Segoe UI',system-ui,-apple-system,sans-serif;font-size:14px;line-height:1.55;
  -webkit-font-smoothing:antialiased;overscroll-behavior:none;display:flex}

/* ─── SIDEBAR ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 200;
  transition: transform 250ms cubic-bezier(.32,.72,0,1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 16px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.01em;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}

.sidebar-logo-text { color: var(--text); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1;
}

.snav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  text-decoration: none;
  transition: background 150ms, color 150ms;
}

.snav-item:hover { background: var(--card); color: var(--text); }
.snav-item.active { background: var(--accentGlow); color: var(--accent); font-weight: 600; }

.snav-icon  { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.snav-label { flex: 1; }

.sidebar-credits {
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-top: 1px solid var(--border);
  min-height: 44px;
}

/* ─── MAIN AREA ─────────────────────────────────────────────── */
#appMain {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── HEADER ────────────────────────────────────────────────── */
#appHeader {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-menu-btn {
  display: none;
  background: none; border: none;
  color: var(--muted); font-size: 20px;
  cursor: pointer; padding: 4px 6px;
  border-radius: 6px;
  transition: color 150ms;
}

.header-menu-btn:hover { color: var(--text); }

.header-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

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

.header-credits {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accentGlow);
  border: 1px solid rgba(108,99,255,.3);
  padding: 5px 12px;
  border-radius: 20px;
  min-width: 80px;
  text-align: center;
}

.btn-header-logout {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}
.btn-header-logout:hover { border-color: var(--error); color: var(--error); }

/* ─── PAGES ─────────────────────────────────────────────────── */
.page {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.page.active { display: flex; }

/* ─── MODELS SECTION ────────────────────────────────────────── */
.models-section {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.section-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.model-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.model-grid::-webkit-scrollbar { display: none; }

.model-chip {
  flex-shrink: 0;
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  min-width: 130px;
  max-width: 180px;
  transition: border-color 150ms, background 150ms, transform 150ms;
}

.model-chip:hover { border-color: rgba(108,99,255,.5); background: var(--elevated); }
.model-chip:active { transform: scale(.97); }
.model-chip.active { border-color: var(--accent); background: rgba(108,99,255,.1); }

.model-chip-name {
  font-size: 12px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-chip-desc {
  font-size: 10px; color: var(--muted); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.model-chip-tag {
  display: inline-block; margin-top: 6px;
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent);
  background: rgba(108,99,255,.12); border-radius: 4px;
  padding: 2px 6px;
}
.model-chip.active .model-chip-tag { background: rgba(108,99,255,.25); }

/* ─── WORKSPACE ─────────────────────────────────────────────── */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ws-panel {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.ws-controls {
  width: 380px;
  min-width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 0 0 80px;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.ws-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ─── CONTROLS ──────────────────────────────────────────────── */
.ctrl-block {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.ctrl-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: 8px;
}

.ctrl-opt {
  font-size: 10px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  color: var(--muted); opacity: .7;
}

.ctrl-textarea {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 150ms;
  line-height: 1.55;
}
.ctrl-textarea::placeholder { color: var(--muted); }
.ctrl-textarea:focus { border-color: var(--accent); }

.ctrl-input {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms;
}
.ctrl-input::placeholder { color: var(--muted); }
.ctrl-input:focus { border-color: var(--accent); }

.ctrl-select {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color 150ms;
  cursor: pointer;
}
.ctrl-select:focus { border-color: var(--accent); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
  text-align: center;
  padding: 20px 16px;
}
.drop-zone:hover, .drop-zone.drag {
  border-color: var(--accent);
  background: rgba(108,99,255,.06);
}
.dz-icon { font-size: 24px; opacity: .5; margin-bottom: 6px; }
.dz-text { font-size: 13px; font-weight: 600; color: var(--text); }
.dz-sub  { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Preview */
.preview-wrap { position: relative; border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.preview-img  { width: 100%; max-height: 180px; object-fit: cover; display: block; }
.remove-btn   {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px;
  background: rgba(0,0,0,.65); border: none; border-radius: 50%;
  color: var(--text); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 150ms;
}
.remove-btn:hover { background: rgba(239,68,68,.7); }

/* URL row */
.url-row { display: flex; gap: 8px; margin-top: 8px; }
.url-row .ctrl-input { flex: 1; min-width: 0; }

/* Params grid */
.params-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.param-item { display: flex; flex-direction: column; gap: 5px; }
.param-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
}
.seed-row { display: flex; gap: 6px; align-items: center; }
.seed-row .ctrl-input { flex: 1; min-width: 0; }

/* Buttons */
.btn-sm {
  flex-shrink: 0;
  background: var(--elevated);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text); font-size: 12px; font-weight: 700;
  padding: 9px 14px; cursor: pointer;
  min-height: 40px;
  transition: border-color 150ms, color 150ms;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.btn-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--elevated);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 150ms;
}
.btn-icon:hover { border-color: var(--accent); }

/* Toggle */
.toggle-row {
  width: 100%; background: none; border: none;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 0;
  transition: color 150ms;
}
.toggle-row:hover { color: var(--text); }
.toggle-arrow {
  font-size: 18px; line-height: 1;
  transition: transform 250ms;
  display: inline-block;
}
.toggle-row.open .toggle-arrow { transform: rotate(90deg); }

/* Actions */
.ctrl-actions {
  padding: 16px 20px;
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--surface) 40%);
  z-index: 5;
}

.btn-generate {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: var(--radius);
  color: #fff; font-size: 14px; font-weight: 700;
  padding: 13px 18px; cursor: pointer;
  min-height: 48px;
  letter-spacing: .01em;
  transition: opacity 150ms, transform 150ms;
  box-shadow: 0 4px 20px rgba(108,99,255,.3);
}
.btn-generate:hover { opacity: .9; }
.btn-generate:active { transform: scale(.98); }
.btn-generate:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-cancel {
  background: var(--elevated);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 13px 16px; cursor: pointer; min-height: 48px;
  transition: border-color 150ms, color 150ms;
  white-space: nowrap;
}
.btn-cancel:hover { border-color: var(--error); color: var(--error); }

/* ─── RESULT PANEL ──────────────────────────────────────────── */
.result-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 400px; flex: 1;
  gap: 12px; padding: 40px;
  text-align: center;
}
.rp-icon  { font-size: 48px; opacity: .15; }
.rp-title { font-size: 18px; font-weight: 700; color: var(--text); opacity: .4; }
.rp-sub   { font-size: 13px; color: var(--muted); max-width: 280px; line-height: 1.6; }

.result-wrapper {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.result-header {
  display: flex; align-items: center;
  justify-content: space-between;
}

.result-title { font-size: 16px; font-weight: 700; }
.result-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; }

.badge {
  font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
  letter-spacing: .02em;
}
.badge.done {
  background: rgba(34,197,94,.12); color: var(--success);
  border: 1px solid rgba(34,197,94,.25);
}

.result-image-wrap {
  flex: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--card);
  display: flex; align-items: center;
  min-height: 280px;
}
.result-image-wrap img {
  width: 100%; height: 100%;
  object-fit: contain; display: block;
  cursor: pointer;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-action {
  background: var(--elevated);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text); font-size: 12px; font-weight: 600;
  padding: 11px 10px; cursor: pointer;
  text-align: center; min-height: 42px;
  transition: border-color 150ms, background 150ms;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-action:hover { border-color: var(--accent); }
.btn-action.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent; color: #fff; grid-column: 1/-1;
  box-shadow: 0 2px 12px rgba(108,99,255,.25);
}
.btn-action.primary:hover { opacity: .9; border-color: transparent; }

/* History strip */
.history-strip {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.history-strip::-webkit-scrollbar { display: none; }
.history-thumb {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: 7px; border: 2px solid var(--border2);
  cursor: pointer; flex-shrink: 0;
  transition: border-color 150ms;
}
.history-thumb.active { border-color: var(--accent); }

/* Progress */
.progress-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 16px;
  padding: 60px 24px; flex: 1;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-label { font-size: 14px; font-weight: 600; }
.progress-bar-wrap {
  width: 200px; height: 4px;
  background: var(--border2); border-radius: 2px; overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px; transition: width .5s ease;
}

/* ─── BATCH SLOTS ───────────────────────────────────────────── */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 0 8px;
}

.slot-card {
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 150ms;
}
.slot-card.running { border-color: var(--accent); }
.slot-card.done    { border-color: rgba(34,197,94,.4); }
.slot-card.error   { border-color: rgba(239,68,68,.4); }

.slot-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.slot-num {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: rgba(108,99,255,.12);
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.slot-title { font-size: 13px; font-weight: 600; flex: 1; }
.slot-status {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .04em;
}
.slot-status.idle    { background: var(--bg); color: var(--muted); border: 1px solid var(--border2); }
.slot-status.pending,
.slot-status.running { background: rgba(108,99,255,.15); color: var(--accent); border: 1px solid rgba(108,99,255,.3); }
.slot-status.done    { background: rgba(34,197,94,.1); color: var(--success); border: 1px solid rgba(34,197,94,.25); }
.slot-status.error   { background: rgba(239,68,68,.1); color: var(--error); border: 1px solid rgba(239,68,68,.25); }

.slot-url-row { display: flex; gap: 6px; }
.slot-url-input {
  flex: 1; background: var(--bg);
  border: 1.5px solid var(--border2); border-radius: var(--radius);
  color: var(--text); padding: 7px 10px; font-size: 12px; outline: none;
  transition: border-color 150ms; min-width: 0;
}
.slot-url-input::placeholder { color: var(--muted); }
.slot-url-input:focus { border-color: var(--accent); }
.slot-upload-label {
  flex-shrink: 0;
  background: var(--elevated); border: 1.5px solid var(--border2);
  border-radius: var(--radius); color: var(--muted);
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  display: flex; align-items: center; min-height: 36px;
  transition: border-color 150ms, color 150ms;
}
.slot-upload-label:hover { border-color: var(--accent); color: var(--accent); }

.slot-prompt {
  width: 100%; background: var(--bg);
  border: 1.5px solid var(--border2); border-radius: var(--radius);
  color: var(--text); padding: 8px 10px; font-size: 13px;
  font-family: inherit; resize: none; min-height: 58px; outline: none;
  transition: border-color 150ms;
}
.slot-prompt::placeholder { color: var(--muted); }
.slot-prompt:focus { border-color: var(--accent); }

.slot-preview { width: 100%; max-height: 130px; object-fit: cover;
  border-radius: var(--radius); display: none; cursor: pointer; }
.slot-preview.visible { display: block; }

.slot-progress { height: 3px; background: var(--border2); border-radius: 2px; overflow: hidden; display: none; }
.slot-progress.visible { display: block; }
.slot-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px; width: 60%;
  animation: barPulse 1.5s ease-in-out infinite;
}
@keyframes barPulse { 0%,100%{opacity:1}50%{opacity:.5} }

.slot-actions { display: flex; gap: 8px; }
.btn-slot-run {
  flex: 1; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: var(--radius);
  color: #fff; font-size: 12px; font-weight: 700;
  padding: 9px 12px; cursor: pointer; min-height: 38px;
  transition: opacity 150ms;
}
.btn-slot-run:disabled { opacity: .4; cursor: not-allowed; }
.btn-slot-run:not(:disabled):hover { opacity: .88; }
.btn-slot-clear {
  background: var(--elevated); border: 1.5px solid var(--border2);
  border-radius: var(--radius); color: var(--muted);
  padding: 9px 12px; font-size: 12px; cursor: pointer; min-height: 38px;
  transition: color 150ms, border-color 150ms;
}
.btn-slot-clear:hover { color: var(--error); border-color: rgba(239,68,68,.4); }

/* ─── PROFILE TAB ───────────────────────────────────────────── */
.profile-wrap {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  padding: 40px 24px;
  max-width: 500px; margin: 0 auto; width: 100%;
}
.profile-card {
  text-align: center;
  background: var(--card); border: 1.5px solid var(--border2);
  border-radius: 16px; padding: 32px 40px; width: 100%;
}
.profile-avatar {
  width: 70px; height: 70px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
}
.profile-balance-label { font-size: 12px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; }
.profile-balance-val { font-size: 32px; font-weight: 800;
  color: var(--text); letter-spacing: -.02em; }
.info-table { width: 100%;
  background: var(--card); border: 1.5px solid var(--border2);
  border-radius: var(--radius); overflow: hidden; }
.info-row {
  display: flex; align-items: center;
  justify-content: space-between; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-key { font-size: 12px; color: var(--muted); }
.info-val { font-size: 13px; font-weight: 600; color: var(--text); }
.btn-logout {
  background: none; border: 1.5px solid rgba(239,68,68,.4);
  border-radius: var(--radius); color: var(--error);
  font-size: 14px; font-weight: 600; padding: 12px 32px;
  cursor: pointer; min-height: 48px; min-width: 220px;
  transition: background 150ms, border-color 150ms;
}
.btn-logout:hover { background: rgba(239,68,68,.1); border-color: var(--error); }

/* ─── TOAST ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9000; display: flex; flex-direction: column-reverse;
  gap: 8px; max-width: 360px; pointer-events: none;
}
.toast {
  background: var(--elevated); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 11px 16px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  animation: toastIn 200ms ease;
  pointer-events: all;
}
@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.toast.success { border-color: rgba(34,197,94,.4); }
.toast.error   { border-color: rgba(239,68,68,.4); }
.toast.warning { border-color: rgba(245,158,11,.4); }
.toast-icon { font-size: 15px; line-height: 1; flex-shrink: 0; }
.toast-text { font-size: 13px; color: var(--text); line-height: 1.4; }

/* ─── SIDEBAR BACKDROP (mobile) ─────────────────────────────── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.65); z-index: 190;
}

/* ─── BATCH workspace wrapper ───────────────────────────────── */
.batch-params { width: 100%; max-width: 100%; }
#page-batch .workspace { padding: 16px 24px; gap: 16px; overflow-y: auto; flex: 1; }

/* ─── MOBILE ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open { display: block; }
  .header-menu-btn { display: flex; }
  #appMain { margin-left: 0; }

  .workspace { flex-direction: column; overflow: visible; }
  .ws-controls {
    width: 100%; min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
  }
  .ws-result { min-height: 360px; }
  .ctrl-actions { position: static; background: none; }
  .models-section { padding: 14px 16px 12px; }
  .ctrl-block { padding: 12px 16px; }
  .workspace { padding: 0; }
  #page-batch .workspace { padding: 12px 16px; }
  .toast-container { bottom: 16px; right: 16px; left: 16px; max-width: 100%; }
  .params-grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 901px) {
  #appMain { overflow: hidden; height: 100vh; }
  #page-generate { height: calc(100vh - var(--header-h)); overflow: hidden; }
  .workspace { height: 100%; overflow: hidden; }
  .ws-controls { height: 100%; }
  .ws-result    { height: 100%; }
}
