/* Atheya shell in the Unsloth Studio idiom: white sidebar, flat nav rows, one calm
   accent, large radius, hairline borders, no shadows. Loads after workspace.css
   and overrides its palette tokens. */

/* Palette: owner's cream set (2026-09-20), Unsloth layout only. */
:root, html[data-resolved-theme="light"], html[data-theme="light"], html[data-theme="system"] {
  --bg: #faf9f5;
  --shell: #f4f3ed;
  --surface: #ffffff;
  --card: #ffffff;
  --hover: #eeece4;
  --accent: #c96442;
  --text: #1f1e1b;
  --muted: #87867f;
  --border: #e8e6de;
  --danger: #b5482f;
  --ok: #5f8a5a;
  --shadow: none;
  --cyan-glow: rgba(201, 100, 66, 0.18);
  --ws-ok: #5f8a5a;
  --ws-warn: #c08a3e;
  --ws-err: #b5482f;
  --ws-info: #6b7d94;
  --ws-primary: #c96442;
  --ws-radius: 14px;
  --ws-radius-sm: 10px;
  --radius-lg: 18px;
  --nav-fg: #3a3834;
  --nav-icon: #8f8c84;
  --input: #f3f2ec;
  --atheya-ok-light: #5f8a5a;
  --atheya-error-light: #b5482f;
  color-scheme: light;
}
html[data-resolved-theme="dark"], html[data-resolved-theme="dark"][data-theme] {
  --bg: #262624;
  --shell: #1f1e1c;
  --surface: #30302e;
  --card: #30302e;
  --hover: #3a3936;
  --accent: #d97757;
  --text: #ecebe6;
  --muted: #9b9a93;
  --border: #3b3a36;
  --danger: #d98a74;
  --ok: #8fb08a;
  --shadow: none;
  --ws-ok: #8fb08a;
  --ws-warn: #d7a763;
  --ws-err: #d98a74;
  --ws-info: #9aabbf;
  --ws-primary: #d97757;
  --nav-fg: #ecebe6;
  --nav-icon: #9b9a93;
  --input: #2c2b28;
  color-scheme: dark;
}
html[data-resolved-theme="dark"] .ws-primary { color: #1f1e1b; }

/* ---------- Base surfaces ---------- */
html body, html[data-resolved-theme="light"] body, html[data-theme="system"] body { background: var(--bg) !important; color: var(--text); font-family: "Inter Variable", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif; }
html body .app, html body .topbar, html body .view-panel, html body .messages, html body .workspace { background: var(--bg) !important; }
html body .sidebar { background: var(--shell) !important; border-right: 1px solid var(--border) !important; padding: 10px 8px !important; gap: 4px !important; width: 232px; }
html body .composer, html body .view-card, html body .hero-panel, html body .monitor-card, html body .kpi-card, html body .agent-card, html body .employee-workspace, html body .ops-table-card, html body .memory-create-form { background: var(--card) !important; border: 1px solid var(--border) !important; box-shadow: none !important; border-radius: var(--ws-radius) !important; }
html body .primary, html body button.primary, html body .ws-primary, html body .composer button:not(.attach-button), html body .top-action.active { background: var(--ws-primary) !important; color: #fff !important; border-color: var(--ws-primary) !important; box-shadow: none !important; }
html body .secondary { background: var(--input) !important; border: 1px solid transparent !important; color: var(--text) !important; }
html body input, html body textarea, html body select { border-radius: var(--ws-radius-sm); }
html body .studio-privacy, html body .disclaimer { color: var(--muted); }

/* ---------- Sidebar (Unsloth idiom) ---------- */
html body .sidebar-head { padding: 6px 8px 10px !important; display: flex; align-items: center; gap: 8px; }
html body .brand.small { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
html body .brand-mark { width: 24px !important; height: 24px !important; border-radius: 7px !important; }
html body .brand.small strong { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
html body .brand.small span#connection-label { display: none; }
.shell-beta { font-size: 9px; letter-spacing: .08em; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; text-transform: uppercase; }
.shell-search { width: 26px; height: 26px; border: 0; background: transparent; color: var(--nav-icon); border-radius: 8px; cursor: pointer; font-size: 14px; display: grid; place-items: center; min-height: 0; padding: 0; }
.shell-search:hover { background: var(--hover); color: var(--text); }
html body .new-chat { display: none !important; }
html body .nav-stack { display: flex; flex-direction: column; gap: 1px; padding: 0 !important; }
html body .nav-stack .nav-item { display: flex !important; align-items: center; gap: 9px; height: 30px; min-height: 0 !important; padding: 0 8px !important; border-radius: 9px !important; font-size: 13px !important; font-weight: 500; color: var(--nav-fg) !important; background: transparent !important; border: 0 !important; box-shadow: none !important; text-decoration: none; }
html body .nav-stack .nav-item:hover { background: var(--hover) !important; }
html body .nav-stack .nav-item.active { background: var(--hover) !important; font-weight: 600; }
html body .nav-stack .nav-item .nav-icon { width: 16px; height: 16px; display: inline-grid; place-items: center; color: var(--nav-icon) !important; opacity: 1; font-size: 13px; }
html body .nav-stack .nav-item .nav-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
html body .nav-stack .nav-item.active .nav-icon { color: var(--text) !important; }
html body .nav-stack .nav-item .nav-badge { margin-left: auto; background: var(--ws-warn); color: #fff; }
.nav-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.nav-tag { margin-left: auto; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
html body .history { padding: 8px 4px 0 !important; }
html body .history .section-label { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; padding: 4px 8px; }
html body .history-search { display: none !important; }
html body .history-search.shown { display: block !important; }
html body .history-row, html body .history-item { min-height: 28px !important; padding: 5px 8px !important; border-radius: 8px !important; font-size: 13px !important; }
html body .sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px !important; display: flex; align-items: center; gap: 8px; }
html body .sidebar-bottom .side-action { display: none !important; }
.shell-user { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 6px; border-radius: 9px; }
.shell-user .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: 0 0 26px; }
.shell-user strong { display: block; font-size: 12px; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-user small { display: block; font-size: 11px; color: var(--muted); line-height: 1.2; }
.shell-gear { width: 28px; height: 28px; border: 0; background: transparent; color: var(--nav-icon); border-radius: 8px; cursor: pointer; min-height: 0; padding: 0; display: grid; place-items: center; }
.shell-gear:hover { background: var(--hover); color: var(--text); }
.shell-gear svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* ---------- Top bar ---------- */
html body .topbar { border-bottom: 0 !important; padding: 8px 14px !important; min-height: 44px; gap: 8px; align-items: center; }
html body .topbar-title { display: none !important; }
html body .topbar .live-chip { font-size: 11px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
html body #studio-command-button, html body #export-chat-txt-button, html body #export-chat-doc-button, html body #import-chat-button, html body #share-button, html body #status-panel-button { display: none !important; }
html body #settings-top-button { display: none !important; }
.shell-model { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; min-height: 0; }
.shell-model:hover { background: var(--hover); }
.shell-model .caret { color: var(--muted); font-size: 10px; }
.shell-model-pop { position: absolute; top: 44px; left: 12px; width: 420px; max-height: 70vh; overflow: auto; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 10px; z-index: 40; box-shadow: 0 12px 32px rgba(0,0,0,.08); }
.shell-model-pop[hidden] { display: none; }
.shell-model-pop input { width: 100%; box-sizing: border-box; border: 0; background: var(--input); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 13px; margin-bottom: 8px; }
.shell-model-pop .tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.shell-model-pop .tabs button { border: 1px solid transparent; background: transparent; border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; min-height: 0; }
.shell-model-pop .tabs button.active { border-color: var(--border); color: var(--text); background: var(--card); }
.shell-model-pop .row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 10px; text-align: left; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; min-height: 0; }
.shell-model-pop .row:hover { background: var(--hover); }
.shell-model-pop .row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 6px; }
.shell-model-pop .row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-model-pop .row .desc { display: block; font-size: 11px; color: var(--muted); white-space: normal; }
.shell-model-pop .row .size { font-size: 10px; color: var(--muted); background: var(--input); border-radius: 6px; padding: 2px 6px; }
.shell-model-pop .row.active { background: var(--hover); font-weight: 600; }
.shell-top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.shell-more { width: 30px; height: 30px; border: 0; background: transparent; color: var(--nav-icon); border-radius: 8px; cursor: pointer; font-size: 16px; min-height: 0; padding: 0; }
.shell-more:hover { background: var(--hover); color: var(--text); }
.shell-menu { position: absolute; right: 0; top: 36px; min-width: 200px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 6px; z-index: 40; box-shadow: 0 12px 32px rgba(0,0,0,.08); }
.shell-menu[hidden] { display: none; }
.shell-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; min-height: 0; }
.shell-menu button:hover { background: var(--hover); }

/* ---------- Chat surface ---------- */
html body .ops-overview { display: none !important; }
html body .conversation-panel .conversation-head { display: none !important; }
html body .workspace { border: 0 !important; border-radius: 0 !important; padding: 0 !important; }
html body .messages { max-width: 820px; margin: 0 auto; padding: 24px 20px 160px; }
html body .message.user .message-card { background: var(--input) !important; border-radius: 18px !important; }
html body .composer-shell { max-width: 820px; margin: 0 auto; padding: 0 16px 14px; display: flex; flex-direction: column; background: linear-gradient(transparent, var(--bg) 30%) !important; }
html body .composer-shell .attachment-list { order: 0; }
html body .composer-shell .composer { order: 1; border: 1px solid var(--border) !important; border-bottom: 0 !important; border-radius: 20px 20px 0 0 !important; background: var(--card) !important; padding: 10px 12px 4px !important; margin: 0 !important; box-shadow: none !important; }
html body .composer-shell .studio-composer-toolbar { order: 2; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 20px 20px; background: var(--card); padding: 4px 10px 8px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
html body .composer-shell .disclaimer { order: 3; text-align: center; font-size: 11px; margin: 8px 0 0; }
html body .composer textarea { font-size: 14px; }
html body .composer .attach-button { background: transparent !important; border: 0 !important; color: var(--muted) !important; font-size: 18px; }
html body .composer button:not(.attach-button) { width: 32px !important; height: 32px !important; border-radius: 50% !important; padding: 0 !important; }
html body .quick-actions { display: flex !important; gap: 2px; align-items: center; }
html body .quick-actions button { border: 0 !important; background: transparent !important; color: var(--muted) !important; font-size: 12px !important; padding: 5px 9px !important; border-radius: 8px !important; min-height: 0 !important; }
html body .quick-actions button.active { color: var(--text) !important; background: var(--hover) !important; }
html body .quick-actions .chat-model-picker { display: none !important; }
html body .chat-file-actions { margin-left: auto; display: flex; gap: 2px; }
html body .chat-file-actions button { border: 0 !important; background: transparent !important; color: var(--muted) !important; font-size: 12px !important; padding: 5px 8px !important; border-radius: 8px !important; min-height: 0 !important; }
html body .chat-file-actions button:hover, html body .quick-actions button:hover { background: var(--hover) !important; color: var(--text) !important; }
html body .empty-state h1, html body .messages .empty-title { font-size: 26px; font-weight: 500; letter-spacing: -.01em; }

/* ---------- Generic page frame for new screens ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 22px 28px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-shrink: 0; }
.page-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.page-tabs button { border: 0; background: transparent; padding: 8px 12px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 0; }
.page-tabs button.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.card { border: 1px solid var(--border); border-radius: var(--ws-radius); background: var(--card); padding: 16px; }
.card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.card p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { border: 1px solid var(--border); border-radius: var(--ws-radius); padding: 12px 14px; background: var(--card); }
.stat span { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stat strong { display: block; font-size: 20px; font-weight: 600; margin-top: 4px; }
.stat small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--input); color: var(--muted); }
.badge.ok { color: var(--ws-ok); background: color-mix(in srgb, var(--ws-ok) 12%, transparent); }
.badge.warn { color: var(--ws-warn); background: color-mix(in srgb, var(--ws-warn) 14%, transparent); }
.badge.err { color: var(--ws-err); background: color-mix(in srgb, var(--ws-err) 12%, transparent); }
.badge.info { color: var(--ws-info); background: color-mix(in srgb, var(--ws-info) 12%, transparent); }
.badge.fmt-gguf { color: #3b82f6; background: rgba(59,130,246,.12); }
.badge.fmt-mlx { color: #d97706; background: rgba(217,119,6,.12); }
.badge.fmt-safetensors { color: #db2777; background: rgba(219,39,119,.12); }
.soon { font-size: 11px; color: var(--muted); border: 1px dashed var(--border); border-radius: 999px; padding: 2px 8px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.field input, .field textarea, .field select { font: inherit; font-size: 13px; color: var(--text); background: var(--input); border: 1px solid transparent; border-radius: 10px; padding: 9px 11px; min-height: 0; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--border); background: var(--card); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { min-height: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--ws-primary); border-color: var(--ws-primary); color: #fff; font-weight: 600; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.mono { font-family: var(--ws-mono); font-size: 12px; }
.bar { height: 6px; border-radius: 3px; background: var(--input); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Model hub ---------- */
.hub-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.hub-toolbar input { flex: 1; font: inherit; font-size: 13px; background: var(--input); border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; min-height: 0; }
.hub-list { display: flex; flex-direction: column; gap: 8px; }
.hub-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--ws-radius); background: var(--card); }
.hub-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.hub-row[data-running="true"] .dot { background: var(--ws-ok); }
.hub-row[data-installed="false"] .dot { background: var(--ws-warn); }
.hub-row .title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hub-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.hub-row .sub .mono { color: var(--muted); }
.hub-row .right { display: flex; align-items: center; gap: 8px; }
.hub-detail { margin-top: 8px; padding: 12px 14px; border-radius: 12px; background: var(--input); font-size: 12px; line-height: 1.6; }
.hub-detail code { font-family: var(--ws-mono); font-size: 12px; background: var(--card); padding: 1px 6px; border-radius: 6px; }

/* ---------- Settings dialog ---------- */
.shell-dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.28); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; }
.shell-dialog-backdrop[hidden] { display: none; }
.shell-dialog { width: min(1040px, 100%); height: min(720px, 100%); background: var(--card); border: 1px solid var(--border); border-radius: 20px; display: grid; grid-template-columns: 220px 1fr; overflow: hidden; }
.shell-dialog-nav { border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; background: var(--shell); }
.shell-dialog-nav .label { font-size: 11px; color: var(--muted); padding: 6px 8px 4px; }
.shell-dialog-nav button, .shell-dialog-nav a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 0; background: transparent; border-radius: 9px; font: inherit; font-size: 13px; color: var(--nav-fg); text-align: left; cursor: pointer; min-height: 0; text-decoration: none; }
.shell-dialog-nav button:hover, .shell-dialog-nav a:hover { background: var(--hover); }
.shell-dialog-nav button.active { background: var(--hover); font-weight: 600; }
.shell-dialog-nav .nav-icon { width: 14px; color: var(--nav-icon); font-size: 12px; text-align: center; }
.shell-dialog-body { position: relative; overflow: auto; min-width: 0; }
.shell-dialog-close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border: 0; background: transparent; border-radius: 8px; font-size: 18px; color: var(--muted); cursor: pointer; z-index: 2; min-height: 0; padding: 0; }
.shell-dialog-close:hover { background: var(--hover); color: var(--text); }
.shell-dialog-body > .view-panel, .shell-dialog-body > .settings { position: static !important; display: block !important; width: auto !important; height: auto !important; max-width: none !important; padding: 22px 28px !important; margin: 0 !important; border: 0 !important; box-shadow: none !important; transform: none !important; }
.shell-dialog-body > .settings .settings-head button { display: none; }
.shell-dialog-body .view-head { margin-bottom: 14px; }
.shell-dialog-body .view-head h1 { font-size: 20px; }
.shell-dialog-body #settings-tabs { display: none !important; }
.shell-general { padding: 22px 28px; }
.shell-general h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.shell-general .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.shell-general .row:last-child { border-bottom: 0; }
.shell-general .row .t { font-size: 13px; font-weight: 500; }
.shell-general .row .d { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 520px; }
.shell-general select { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--text); min-height: 0; }
.shell-general h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 4px; }

@media (max-width: 860px) { .shell-dialog { grid-template-columns: 1fr; height: 100%; } .shell-dialog-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); } .shell-dialog-nav .label { display: none; } .page { padding: 16px; } .shell-model-pop { width: calc(100vw - 24px); } }

/* Fixes after first render */
.shell-search svg, .shell-gear svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
html body #companion-open { background: transparent !important; border: 1px solid var(--border) !important; color: var(--text) !important; border-radius: 9px !important; padding: 5px 10px !important; font-size: 12px !important; min-height: 0 !important; box-shadow: none !important; }
html body #companion-open:hover { background: var(--hover) !important; }
.shell-dialog-body .settings, html body .shell-dialog-body aside.settings { position: static !important; display: block !important; width: auto !important; max-width: none !important; height: auto !important; max-height: none !important; padding: 0 !important; margin: 0 !important; border: 0 !important; box-shadow: none !important; transform: none !important; background: transparent !important; inset: auto !important; overflow: visible !important; }
.shell-dialog-body .settings .settings-head { display: none !important; }
.shell-dialog-body .settings .settings-block { border: 0 !important; padding: 12px 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 0 !important; background: transparent !important; }
.shell-dialog-body .settings .settings-block:last-child { border-bottom: 0 !important; }

/* Composer: the legacy shell is absolutely positioned (left: sidebar, right: 0) and
   grid-based; keep that box, lay the pieces out as a centered column inside it. */
:root { --sidebar: 232px; }
html body .composer-shell { position: absolute !important; left: var(--sidebar) !important; right: 0 !important; bottom: 0 !important; width: auto !important; max-width: none !important; margin: 0 !important; display: flex !important; flex-direction: column !important; align-items: stretch !important; padding: 10px 16px 14px !important; row-gap: 0 !important; }
html body .composer-shell > * { width: 100%; max-width: 820px; margin-left: auto !important; margin-right: auto !important; box-sizing: border-box; }
html body .composer-shell .composer { width: 100% !important; max-width: 820px !important; display: grid !important; grid-template-columns: 40px minmax(0, 1fr) 40px !important; align-items: end; }
html body .composer-shell .composer textarea { width: 100% !important; min-width: 0 !important; }
html body .composer-shell .studio-composer-toolbar { max-width: 820px; }
html body .composer-shell .disclaimer { white-space: normal; }
@media (max-width: 760px) { :root { --sidebar: 0px; } html body .composer-shell { left: 0 !important; } }

/* Composer v3: deterministic centered grid, independent of legacy margins. */
html body .composer-shell { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; justify-items: center !important; align-items: start !important; row-gap: 0 !important; column-gap: 0 !important; }
html body .composer-shell > * { width: min(820px, 100%) !important; max-width: 820px !important; margin: 0 !important; justify-self: center !important; grid-column: 1 !important; box-sizing: border-box !important; }
html body .composer-shell .composer { width: min(820px, 100%) !important; max-width: 820px !important; margin: 0 !important; position: static !important; left: auto !important; right: auto !important; transform: none !important; }
html body .composer-shell .studio-composer-toolbar { width: min(820px, 100%) !important; max-width: 820px !important; margin: 0 !important; grid-column: 1 !important; }
html body .composer-shell .attachment-list { width: min(820px, 100%) !important; }
html body .composer-shell .disclaimer { width: min(820px, 100%) !important; margin: 8px 0 0 !important; }

/* Media pages: responsive form/result split and gallery cards */
.media-layout { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 14px; }
.media-card { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.media-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--input); }
.media-card audio { width: 100%; }
.media-meta strong { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta small { color: var(--muted); font-size: 11px; }
.ws-danger { color: var(--ws-err) !important; border-color: color-mix(in srgb, var(--ws-err) 40%, var(--border)) !important; }

/* ---------- Responsive layer ---------- */
@media (max-width: 1100px) { .media-layout { grid-template-columns: 1fr; } .hub-row { grid-template-columns: 8px 1fr; } .hub-row .right { grid-column: 2; justify-content: flex-start; } .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .page { padding: 14px; } .page-head { flex-direction: column; } .page-head .actions { width: 100%; } .field-row { grid-template-columns: 1fr; } .bots-grid { grid-template-columns: 1fr; } .shell-model-pop { left: 8px; width: calc(100vw - 16px); } }
@media (max-width: 760px) { html body .sidebar { width: min(300px, 86vw); } html body .topbar { flex-wrap: wrap; padding: 6px 10px !important; } html body .topbar .live-chip { display: none; } .stat-row { grid-template-columns: 1fr 1fr; } .stat strong { font-size: 17px; } .shell-dialog { border-radius: 0; height: 100dvh; } .shell-dialog-backdrop { padding: 0; } html body .composer-shell { padding: 8px 8px 10px !important; } html body .messages { padding: 14px 12px 150px; } }

/* Composer v4: in normal flow at the bottom of the chat column (no absolute
   positioning, no dependence on the sidebar width). Same column as messages. */
html body .chat { display: flex !important; flex-direction: column !important; min-height: 0 !important; height: 100vh !important; height: 100dvh !important; position: relative !important; }
html body .chat > .topbar { flex: 0 0 auto; }
html body .chat > .workspace, html body .chat > .view-panel { flex: 1 1 auto !important; min-height: 0 !important; }
html body .chat > .workspace { overflow: auto !important; padding-bottom: 24px !important; }
html body .composer-shell { position: static !important; flex: 0 0 auto !important; left: auto !important; right: auto !important; bottom: auto !important; width: 100% !important; box-sizing: border-box !important; background: var(--bg) !important; padding: 6px 16px 12px !important; }
body.non-chat-view .composer-shell, body.settings-open .composer-shell { display: none !important; }
html body .messages { padding-bottom: 24px !important; }

/* Chat column: single centered column, no legacy two-column grid. */
html body .workspace { display: block !important; grid-template-columns: none !important; padding: 0 16px 8px !important; }
html body .conversation-panel { display: flex !important; flex-direction: column !important; width: 100% !important; max-width: 820px !important; min-width: 0 !important; margin: 0 auto !important; min-height: 0 !important; }
html body .messages { width: 100% !important; max-width: none !important; padding: 20px 4px 24px !important; }
html body .message { max-width: 100%; }
html body .message.user .message-card { max-width: 78%; margin-left: auto; }
.shell-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13px; z-index: 80; max-width: min(560px, 90vw); }
.shell-toast[data-tone="error"] { background: var(--ws-err); color: #fff; }
.shell-toast[hidden] { display: none; }
.loss-chart { width: 100%; height: auto; display: block; }

/* Hub: "Добавить модель" native dialog */
dialog.hub-dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--card); color: var(--text); padding: 0; width: min(640px, 92vw); max-height: 90vh; box-shadow: 0 24px 60px rgba(0,0,0,.18); }
dialog.hub-dialog::backdrop { background: rgba(0,0,0,.28); }
.hub-dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.hub-dialog-body h2 { margin: 0; font-size: 18px; }
.hub-dialog-body h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }
.hub-dialog-body p { margin: 0; font-size: 13px; color: var(--muted); }
.hub-dialog-body input[type="text"], .hub-dialog-body select { width: 100%; }
@media (max-width: 640px) { .hub-dialog-body .field-row { flex-direction: column; } }

/* Cloud models */
.shell-model-pop .row .dot[data-privacy="cloud"] { background: #6b8fc9; }
.shell-model-pop .row .dot[data-running="true"] { background: var(--ws-ok, #3f9a5a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ws-ok, #3f9a5a) 22%, transparent); }
.shell-model-pop .row .dot[data-running="false"] { background: var(--border, #c9c4bb); box-shadow: none; }
.shell-model-pop .row .cloud-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #4f6fa8; background: rgba(107,143,201,.14); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.hub-cloud-form input, .hub-cloud-form select { width: 100%; }

/* Video: image-to-video picker */
.i2v-preview { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.i2v-preview img { width: 96px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.i2v-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 8px; max-height: 220px; overflow: auto; }
.i2v-pick button { padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--card); overflow: hidden; aspect-ratio: 4/3; cursor: pointer; min-height: 0; }
.i2v-pick button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.i2v-pick button:hover { border-color: var(--accent); }

/* Telegram users (settings → Общие) */
.tg-users { display: flex; flex-direction: column; gap: 6px; }
.tg-user { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; }
.tg-user[data-status="pending"] { border-color: var(--accent); }
.tg-user .d { font-size: 12px; color: var(--muted); }

/* Hub: model state badges */
.badge.off { color: var(--muted); background: var(--input); }
.badge.hub-transition { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); animation: hub-pulse 1.6s ease-in-out infinite; }
@keyframes hub-pulse { 50% { opacity: .55; } }

/* Hub: memory per model + total */
.hub-row .sub .mem { color: var(--muted); }
.hub-row .sub .mem-on { color: var(--accent); font-weight: 600; }
.hub-mem { margin: 14px 0 8px; display: flex; flex-direction: column; gap: 10px; }
.hub-mem-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.hub-mem-head span { color: var(--muted); }
.hub-mem-list { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.hub-mem-list b { color: var(--text); }
.hub-mem p { margin: 0; font-size: 11px; color: var(--muted); }

/* Fine Tune page */
.ft-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .ft-grid { grid-template-columns: 1fr; } }
.ft-card { display: flex; flex-direction: column; gap: 10px; }
.ft-card h3 { margin: 0; font-size: 14px; }
.ft-card .field > span { display: flex; flex-direction: column; gap: 2px; }
.ft-card .field small { font-size: 11px; color: var(--muted); font-weight: 400; }
.ft-card textarea { width: 100%; min-height: 130px; }
.ft-range { display: flex; align-items: center; gap: 12px; }
.ft-range input { flex: 1; }
.ft-range .mono { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ft-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.ft-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ft-status { font-size: 12px; color: var(--muted); margin-left: 4px; }
.ft-answer { white-space: pre-wrap; font-size: 14px; line-height: 1.55; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); min-height: 120px; }
.ft-prompt { white-space: pre-wrap; font-size: 11px; max-height: 320px; overflow: auto; margin: 8px 0 0; }
html body .ft-card .field > span, html body .ft-card .field small, html body .ft-range .mono { text-transform: none; letter-spacing: 0; }
html body .ft-card .field > span { font-size: 12px; color: var(--text); font-weight: 600; }
html body .ft-card select, html body .ft-card input[type="text"] { width: 100%; }

/* Training: data wizard */
.tr-intro ol { margin: 6px 0 8px; padding-left: 20px; display: grid; gap: 6px; font-size: 13px; }
.tr-note { margin: 0; font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.tr-set { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tr-drop { border: 1.5px dashed var(--border); border-radius: 14px; padding: 22px; display: grid; gap: 6px; text-align: center; cursor: pointer; background: var(--bg); }
.tr-drop span { font-size: 12px; color: var(--muted); }
.tr-drop.over, .tr-drop:hover { border-color: var(--accent); }
.tr-files { display: grid; gap: 6px; margin-top: 10px; }
.tr-file { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.tr-file .tr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-file small { color: var(--muted); }
.tr-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.tr-status { font-size: 12px; color: var(--muted); min-height: 16px; margin: 8px 0 0; }

/* Head model */
.shell-model-pop .head-tag { flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; }
.shell-model-pop .make-head { flex: 0 0 auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; display: none; cursor: pointer; white-space: nowrap; }
.shell-model-pop .row:hover .make-head, .shell-model-pop .make-head:focus { display: inline-block; }
.shell-model-pop .row:hover .make-head ~ .size { display: none; }
.shell-model-pop .make-head:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .shell-model-pop .make-head { display: inline-block; } .shell-model-pop .make-head ~ .size { display: none; } }
.badge.head { color: var(--accent); border-color: var(--accent); background: transparent; }
.hub-head { margin: 0 0 16px; display: grid; gap: 8px; }
.hub-head-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hub-head-top > div:first-child { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hub-head-kicker { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hub-head-top strong { font-size: 17px; }
.hub-head-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hub-head-pick select { width: auto; max-width: 320px; min-height: 0; padding: 6px 10px; border-radius: 10px; }
.hub-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hub-head-pending { font-size: 13px; color: var(--accent); }

/* Image engine picker */
.engine-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.engine-pick button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-height: 0; }
.engine-pick button:hover { border-color: var(--accent); }
.engine-pick button.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
.engine-pick b { font-size: 14px; }
.engine-pick small { font-size: 11px; color: var(--muted); line-height: 1.35; }
@media (max-width: 480px) { .engine-pick { grid-template-columns: 1fr; } }

/* Login: remember me + recovery */
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -2px; }
.auth-form .auth-check { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.auth-form .auth-check input { width: 16px; height: 16px; min-height: 0; margin: 0; padding: 0; accent-color: var(--accent, #c96442); flex: 0 0 16px; }
.auth-form .auth-check span { color: inherit; font-size: 13px; text-transform: none; letter-spacing: normal; font-weight: 400; }
.auth-link { background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-size: 13px; color: var(--accent, #c96442); cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
#recover-step2 { display: grid; gap: 12px; }
#recover-step2.hidden { display: none; }

/* «Глубже»: pill with icon and word; filled when on. */
html body .chat-file-actions button.deep-button { display: inline-flex !important; align-items: center; gap: 5px; height: 32px; align-self: center; border: 1px solid var(--border) !important; border-radius: 999px !important; padding: 0 12px 0 9px !important; margin-right: 4px; white-space: nowrap; font-size: 13px !important; }
html body .chat-file-actions button.deep-button svg { flex: 0 0 auto; }
html body .chat-file-actions button.deep-button.active { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }

/* Presentation cards: slide thumbnails drawn from the deck (decks.js); click opens a slide viewer. */
.deck-preview { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px; scroll-snap-type: x mandatory; }
.deck-preview > span { color: var(--muted); font-size: 13px; }
.deck-thumb { flex: 0 0 196px; padding: 0 !important; border: 1px solid var(--border) !important; border-radius: 8px !important; overflow: hidden; background: none !important; cursor: zoom-in; scroll-snap-align: start; min-height: 0 !important; }
.deck-thumb:hover { border-color: var(--accent) !important; }
.deck-slide { container-type: inline-size; position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; text-align: left; }
.artifact-card .artifact-download { white-space: nowrap; flex: 0 0 auto; }
.deck-lightbox { width: min(1100px, 94vw); max-width: none; padding: 0; border: 0; border-radius: 12px; background: var(--panel, #fff); color: var(--text); }
.deck-lightbox::backdrop { background: rgba(20, 18, 16, .72); }
.deck-lightbox .deck-bar { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px; }
.deck-lightbox .deck-bar button { border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 8px; width: 36px; height: 32px; font-size: 18px; cursor: pointer; }
.deck-lightbox .deck-bar button[data-close] { margin-left: auto; }
.deck-lightbox .deck-count { color: var(--muted); font-size: 13px; min-width: 60px; text-align: center; }
.deck-lightbox .deck-notes { margin: 0; padding: 0 16px 14px; color: var(--muted); font-size: 13px; }

/* Live progress of creative jobs (stage · step · time) */
.live-progress { display:grid; grid-template-columns:auto 1fr auto; gap:6px 10px; align-items:center; font-size:12px; color:var(--text, inherit); }
.live-progress .pulse { width:9px; height:9px; border-radius:50%; background:var(--accent, #c4623c); animation: lp-pulse 1.1s ease-in-out infinite; }
.live-progress .lp-time { color:var(--muted); font-variant-numeric: tabular-nums; }
.live-progress .lp-bar { grid-column:1 / -1; height:4px; border-radius:2px; background:var(--line, rgba(0,0,0,.08)); overflow:hidden; }
.live-progress .lp-bar i { display:block; height:100%; width:0; background:var(--accent, #c4623c); transition:width .5s ease; }
.live-progress.indeterminate .lp-bar i { width:30% !important; animation: lp-slide 1.4s ease-in-out infinite; }
@keyframes lp-pulse { 0%,100% { opacity:.35; transform:scale(.85); } 50% { opacity:1; transform:scale(1.1); } }
@keyframes lp-slide { 0% { margin-left:-30%; } 100% { margin-left:100%; } }

/* Image page modes: field groups hidden per tab (create / edit / upscale). */
.page .field[hidden], .page .field-row[hidden], .page label.field[hidden] { display: none; }
