:root {
  color-scheme: dark;
  --bg: #0b1118; --surface: #101923; --surface-2: #14212d; --surface-3: #192936;
  --text: #eaf2f8; --muted: #8fa3b3; --border: #263745; --accent: #52d3c6;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent); --danger: #ff7b7b; --warning: #f0bf62; --ok: #69d795;
  --shadow: 0 20px 60px rgba(0,0,0,.3); --radius: 12px; --tap: 44px; --viewport-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
}

:root[data-theme="light"] { color-scheme: light; --bg:#f4f7f9; --surface:#fff; --surface-2:#eef3f6; --surface-3:#e5edf2; --text:#15212b; --muted:#5d7180; --border:#cbd7de; --shadow:0 20px 60px rgba(30,50,65,.18); }

@media (prefers-color-scheme: light) { :root[data-theme="system"] { color-scheme: light; --bg:#f4f7f9; --surface:#fff; --surface-2:#eef3f6; --surface-3:#e5edf2; --text:#15212b; --muted:#5d7180; --border:#cbd7de; --shadow:0 20px 60px rgba(30,50,65,.18); }
 }

:root[data-accent="violet"] { --accent:#a88bff; }
 :root[data-accent="amber"] { --accent:#e4ad45; }
 :root[data-accent="green"] { --accent:#66cf8f; }

* { box-sizing: border-box; }

html, body, #app { margin:0; width:100%; height:100%; min-height:0; background:var(--bg); overflow:hidden; }

body, button, input, textarea, select { font:inherit; }

button, input, textarea, select { color:inherit; }

button { cursor:pointer; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

.app-shell { width:100%; height:var(--viewport-height); min-height:0; display:flex; flex-direction:column; overflow:hidden; }

.topbar { height:64px; display:grid; grid-template-columns:minmax(240px,1fr) minmax(220px,440px) auto auto; align-items:center; gap:12px; padding:8px 14px; border-bottom:1px solid var(--border); background:var(--surface); }

.brand, .model-trigger { min-height:48px; border:0; background:transparent; display:flex; align-items:center; gap:10px; text-align:left; border-radius:10px; padding:6px 8px; }

.brand:hover, .model-trigger:hover { background:var(--surface-2); }

.brand-mark { width:36px; height:36px; display:grid; place-items:center; border:1px solid color-mix(in srgb,var(--accent) 55%,var(--border)); background:var(--accent-soft); color:var(--accent); border-radius:9px; font-weight:800; letter-spacing:-.04em; }

.brand-title, .model-trigger-name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.group { display:flex; flex-direction:column; gap:3px; min-width:0; }

.top-status { display:flex; gap:6px; }

.desktop-grid { flex:1; min-height:0; display:grid; grid-template-columns:260px minmax(0,1fr) 320px; }

.pane { min-width:0; min-height:0; background:var(--surface); }

.left-pane { border-right:1px solid var(--border); padding:14px 10px; display:flex; flex-direction:column; gap:12px; overflow:auto; }

.center-pane { background:var(--bg); overflow:hidden; min-height:0; }

.right-pane { border-left:1px solid var(--border); padding:12px; overflow:auto; }

.section-title, .view-heading, .run-head, .overlay-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }

.section-label, .eyebrow { font-size:.69rem; font-weight:800; letter-spacing:.09em; text-transform:uppercase; color:var(--muted); }

.workspace-row, .thread-row, .file-row { width:100%; border:0; background:transparent; text-align:left; color:inherit; }

.workspace-row { min-height:58px; display:flex; gap:10px; align-items:center; padding:8px; border-radius:10px; }

.workspace-row.active, .thread-row.active { background:var(--accent-soft); }

.workspace-icon, .file-icon { flex:0 0 auto; width:34px; height:34px; display:grid; place-items:center; border:1px solid var(--border); border-radius:8px; font:700 .72rem ui-monospace, monospace; }

.thread-list { display:flex; flex-direction:column; gap:3px; }

.thread-row { min-height:44px; padding:10px; border-radius:9px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.storage-summary { margin-top:auto; display:flex; flex-direction:column; gap:8px; padding:10px; border-top:1px solid var(--border); }

.meter { height:5px; overflow:hidden; border-radius:99px; background:var(--surface-3); }
 .meter-fill { height:100%; display:block; background:var(--accent); }

.chat-view { height:100%; min-height:0; display:grid; grid-template-rows:auto minmax(0,1fr) auto; overflow:hidden; }

.view-heading { padding:18px 20px 12px; }

h1,h2,p { margin:0; }
 h1 { font-size:1.22rem; letter-spacing:-.02em; }
 h2 { font-size:.95rem; }

.message-list { min-height:0; overflow:auto; overscroll-behavior:contain; padding:10px max(20px, calc((100% - 820px)/2)); display:flex; flex-direction:column; gap:12px; }

.message { max-width:82%; padding:14px 16px; border:1px solid var(--border); background:var(--surface); border-radius:14px; box-shadow:0 4px 16px rgba(0,0,0,.08); }

.message.user { align-self:flex-end; background:var(--accent-soft); border-color:color-mix(in srgb,var(--accent) 30%,var(--border)); }

.message-role { color:var(--muted); font-size:.67rem; font-weight:800; letter-spacing:.1em; margin-bottom:7px; }

.message-content { white-space:pre-wrap; line-height:1.62; }

.message-meta { margin-top:9px; color:var(--muted); font-size:.76rem; }

.composer { margin:0 max(12px, calc((100% - 860px)/2)) 14px; border:1px solid var(--border); background:var(--surface); border-radius:15px; box-shadow:var(--shadow); padding:8px; }

.composer textarea { width:100%; min-height:62px; max-height:190px; resize:vertical; border:0; outline:0; background:transparent; padding:8px 10px; line-height:1.5; }

.composer-toolbar { display:flex; align-items:center; gap:7px; min-height:44px; }

.composer-spacer { flex:1; }
.composer-status { min-height:24px; padding:0 10px 4px; color:var(--muted); font-size:.76rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.composer-status.ready { color:var(--muted); }
.composer-status.blocked { color:var(--warning); }
.cost-hint { color:var(--muted); font-variant-numeric:tabular-nums; font-size:.78rem; }

.send-button, .primary-button { min-height:44px; padding:0 18px; border:0; border-radius:10px; background:var(--accent); color:#071313; font-weight:800; }

.secondary-button, .filter-button, .compare-button, .danger-button { min-height:44px; padding:0 12px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); }

.secondary-button:hover, .filter-button.active, .compare-button.active { border-color:var(--accent); background:var(--accent-soft); }

.danger-button { border-color:color-mix(in srgb,var(--danger) 50%,var(--border)); color:var(--danger); }

.icon-button { width:44px; height:44px; border:0; border-radius:9px; background:transparent; display:grid; place-items:center; color:inherit; font-size:1.15rem; }

.icon-button:hover { background:var(--surface-2); }

.toggle-chip, .tag, .status-pill, .confidence { display:inline-flex; align-items:center; min-height:26px; padding:3px 8px; border:1px solid var(--border); border-radius:999px; font-size:.72rem; white-space:nowrap; }

.toggle-chip.active, .tag { background:var(--surface-2); }
.status-pill.ok { color:var(--ok); }
.status-pill.warn { color:var(--warning); }
.status-pill.error { color:var(--danger); }
.status-pill.busy { color:var(--accent); }

.side-panel { padding:12px 4px 15px; border-bottom:1px solid var(--border); }
.side-title { margin-bottom:10px; color:var(--muted); font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; }

.model-summary, .forecast, .policy-list, .connection-summary { display:flex; flex-direction:column; gap:9px; }

.model-id, code { font-family:ui-monospace,SFMono-Regular,Consolas,monospace; font-size:.78rem; overflow-wrap:anywhere; color:var(--muted); }

.clamp { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.tag-row { display:flex; gap:5px; flex-wrap:wrap; }

.kv { display:flex; justify-content:space-between; gap:12px; font-size:.84rem; }
.tabular { font-variant-numeric:tabular-nums; }

.workspace-view { height:100%; overflow:auto; padding:20px max(18px,calc((100% - 920px)/2)); display:flex; flex-direction:column; gap:18px; }

.file-grid { border:1px solid var(--border); border-radius:12px; overflow:hidden; background:var(--surface); }

.file-row { min-height:62px; display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:11px; padding:8px 12px; border-bottom:1px solid var(--border); }

.file-row:last-child { border-bottom:0; }
.file-row:hover { background:var(--surface-2); }
.file-name { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-time { color:var(--muted); font-size:.75rem; }

.quick-editor, .run-card, .metric, .usage-table, .settings-form { border:1px solid var(--border); border-radius:12px; background:var(--surface); padding:14px; }

.file-create-form, .settings-form { display:flex; flex-direction:column; gap:12px; }
.file-create-form input,.file-create-form textarea,.settings-form input,.settings-form select,.model-controls input { width:100%; min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); padding:10px; }

.run-card { max-width:860px; width:100%; align-self:center; }
.run-timeline { display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.run-step { display:grid; grid-template-columns:12px 1fr auto; align-items:start; gap:10px; }
.step-dot { width:8px; height:8px; margin-top:5px; border-radius:99px; background:var(--muted); }
.step-dot.completed { background:var(--ok); }
.step-dot.failed { background:var(--danger); }
.step-dot.executing_tool,.step-dot.requesting_model { background:var(--accent); }

.metric-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; }
.metric { display:flex; flex-direction:column; gap:6px; }
.metric-value { font-size:1.35rem; font-variant-numeric:tabular-nums; }

.usage-table { padding:0; overflow:hidden; }
.usage-row { display:grid; grid-template-columns:90px minmax(140px,1fr) 100px 100px 90px; gap:10px; align-items:center; min-height:48px; padding:7px 12px; border-bottom:1px solid var(--border); }
.usage-row.header { min-height:36px; color:var(--muted); font-size:.74rem; font-weight:800; background:var(--surface-2); }

.segmented { display:flex; gap:4px; padding:4px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.segment { flex:1; min-height:44px; border:0; border-radius:7px; background:transparent; }
.segment.active { background:var(--surface); box-shadow:0 1px 8px rgba(0,0,0,.12); color:var(--accent); }
.field { display:flex; flex-direction:column; gap:7px; }
.field-label { color:var(--muted); font-size:.79rem; font-weight:700; }

.overlay-backdrop { position:fixed; inset:0; z-index:20; background:rgba(0,0,0,.55); display:flex; justify-content:flex-end; align-items:stretch; }

.overlay { background:var(--surface); box-shadow:var(--shadow); border-left:1px solid var(--border); overflow:auto; }
.model-sheet { width:min(680px,92vw); }
.modal { width:min(560px,92vw); }
.overlay-head { min-height:64px; padding:8px 14px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface); z-index:2; }

.model-picker { padding:12px; }
.model-controls { display:grid; grid-template-columns:1fr auto auto auto; gap:8px; position:sticky; top:64px; background:var(--surface); padding-bottom:10px; z-index:1; }
.model-list { display:flex; flex-direction:column; gap:8px; }
.model-row { display:grid; grid-template-columns:1fr auto; gap:8px; border:1px solid var(--border); border-radius:11px; padding:8px; }
.model-row.selected { border-color:var(--accent); }
.model-main { border:0; background:transparent; text-align:left; color:inherit; padding:5px; }
.comparison-table { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; padding:10px; margin-bottom:10px; background:var(--surface-2); border-radius:10px; }

.preview-wrap,.workspace-drawer { padding:14px; display:flex; flex-direction:column; gap:12px; }
.artifact-frame { width:100%; min-height:70vh; border:1px solid var(--border); border-radius:10px; background:white; }
.code-preview { margin:0; padding:14px; border:1px solid var(--border); border-radius:10px; background:var(--bg); white-space:pre-wrap; overflow:auto; min-height:50vh; }

.empty-state { padding:26px; display:flex; flex-direction:column; gap:6px; align-items:center; justify-content:center; text-align:center; }
.muted { color:var(--muted); font-size:.8rem; }
.offline-banner { padding:7px 12px; background:color-mix(in srgb,var(--warning) 18%,var(--surface)); color:var(--warning); text-align:center; font-size:.8rem; }

.mobile-nav { display:none; }

@media (max-width: 980px) { .desktop-grid { grid-template-columns:minmax(0,1fr); }
.left-pane,.right-pane { display:none; }
.topbar { grid-template-columns:minmax(0,1fr) minmax(160px,260px) auto; }
.top-status { display:none; }
.center-pane { padding-bottom:68px; }
.mobile-nav { display:grid; grid-template-columns:repeat(5,1fr); position:fixed; left:0; right:0; bottom:0; z-index:10; min-height:64px; padding-bottom:env(safe-area-inset-bottom); border-top:1px solid var(--border); background:var(--surface); }
.mobile-nav-item { min-height:60px; border:0; background:transparent; color:var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; font-size:.68rem; }
.mobile-nav-item.active { color:var(--accent); }
.nav-icon { font-size:1.1rem; }
.metric-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
.usage-row { grid-template-columns:72px minmax(110px,1fr) 75px 70px; }
.usage-row > :nth-child(5) { display:none; }
 }

@media (max-width: 620px) { .topbar { height:58px; padding:5px 7px; grid-template-columns:minmax(0,1fr) minmax(118px,42vw) 44px; }
.brand-title { font-size:.85rem; }
.brand .muted { display:none; }
.brand-mark { width:32px;height:32px; }
.model-trigger { padding:4px; }
.model-trigger .eyebrow { display:none; }
.model-trigger-name { font-size:.78rem; }
.message-list { padding:8px 10px; }
.message { max-width:94%; padding:12px; }
.view-heading { padding:12px; }
.view-heading p { display:none; }
.composer { margin:0 8px 8px; padding:6px; }
.composer-status { padding:0 8px 4px; }
.cost-hint { max-width:88px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.composer-toolbar { overflow-x:auto; }
.composer-toolbar .toggle-chip:nth-of-type(2),.composer-toolbar .toggle-chip:nth-of-type(3) { display:none; }
.workspace-view { padding:14px 10px; }
.metric-grid { gap:7px; }
.metric { padding:10px; }
.metric-value { font-size:1.05rem; }
.usage-table { overflow-x:auto; }
.usage-row { min-width:520px; }
.model-controls { grid-template-columns:1fr auto auto; }
.model-controls .secondary-button { grid-column:1/-1; }
.model-sheet,.modal { width:100vw; border-left:0; }
.overlay-backdrop { align-items:flex-end; }
.overlay { max-height:92dvh; border-radius:16px 16px 0 0; border-top:1px solid var(--border); }
.comparison-table { grid-template-columns:1fr; }
.file-row { grid-template-columns:auto minmax(0,1fr); }
.file-time { display:none; }
 }


/* Height-constrained Android landscape. The visual viewport drives --viewport-height. */
@media (max-width: 980px) and (orientation: landscape) and (max-height: 520px) {
  .topbar {
    height:48px; min-height:48px; padding:2px 8px;
    grid-template-columns:minmax(180px,1fr) minmax(170px,34vw) auto auto; gap:6px;
  }
  .brand, .model-trigger { min-height:44px; padding:3px 6px; }
  .brand-mark { width:32px; height:32px; }
  .desktop-grid, .center-pane, .chat-view, .message-list { min-height:0; }
  .center-pane { padding-bottom:48px; }
  .view-heading { min-height:40px; padding:4px 10px; }
  .view-heading p { display:none; }
  .message-list { padding:4px 10px; gap:6px; }
  .message { padding:8px 10px; border-radius:10px; }
  .message-role { margin-bottom:3px; }
  .message-meta { margin-top:4px; }
  .composer { margin:0 8px 4px; padding:3px 5px; border-radius:11px; }
  .composer textarea { min-height:40px; max-height:54px; padding:3px 6px; resize:none; }
  .composer-toolbar { min-height:44px; gap:4px; overflow:hidden; }
  .composer-toolbar .toggle-chip { display:none; }
  .cost-hint { max-width:220px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .mobile-nav { min-height:44px; height:calc(44px + env(safe-area-inset-bottom)); }
  .mobile-nav-item { min-height:44px; flex-direction:row; gap:5px; font-size:.66rem; }
  .nav-icon { font-size:.86rem; }
}

.run-changes { margin-top:12px; padding-top:12px; border-top:1px solid var(--border); display:flex; flex-direction:column; gap:8px; }
.file-change { border:1px solid var(--border); border-radius:9px; overflow:hidden; background:var(--surface-2); }
.file-change-summary { min-height:44px; padding:8px 10px; display:flex; align-items:center; justify-content:space-between; gap:12px; cursor:pointer; }
.file-diff { margin:0; max-height:260px; overflow:auto; padding:10px; border-top:1px solid var(--border); background:var(--bg); color:var(--text); white-space:pre-wrap; overflow-wrap:anywhere; font: .76rem/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; }

.pending-attachments { display:flex; gap:7px; overflow-x:auto; padding:2px 2px 7px; }
.attachment-chip { min-width:190px; max-width:320px; min-height:48px; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:4px 5px 4px 10px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); }
.attachment-chip .group { overflow:hidden; }
.attachment-chip strong { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.attachment-destination { min-height:44px; max-width:118px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); padding:0 7px; }
.message-attachments { display:flex; gap:5px; flex-wrap:wrap; margin-top:9px; }
@media (max-width: 980px) and (orientation: landscape) and (max-height: 520px) { .attachment-destination { display:none; } .pending-attachments { max-height:52px; } }

.usage-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.usage-breakdowns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.usage-breakdown { min-width:0; border:1px solid var(--border); border-radius:12px; background:var(--surface); padding:14px; display:flex; flex-direction:column; gap:9px; }
@media (max-width: 620px) { .usage-actions { justify-content:flex-start; } .usage-breakdowns { grid-template-columns:1fr; } }

.image-preview {
  display: block; max-width: 100%; max-height: 65vh; margin: auto; object-fit: contain; border-radius: 12px;
}
.markdown-preview { max-width: 860px; padding: 16px; line-height: 1.65; }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 { margin: 1em 0 .45em; }
.markdown-preview p, .markdown-preview ul, .markdown-preview blockquote { margin: .6em 0; }
.markdown-preview blockquote { padding-left: 12px; border-left: 3px solid var(--accent); color: var(--muted); }
.csv-preview { overflow: auto; max-height: 65vh; }
.csv-preview table { border-collapse: collapse; min-width: 100%; }
.csv-preview th, .csv-preview td { padding: 8px 10px; border: 1px solid var(--border); text-align: left; white-space: nowrap; }
.csv-preview th { position: sticky; top: 0; background: var(--panel); }

/* 0.3 workspace, conversation, approval, editor and diagnostics UX */
.secondary-button, .filter-button, .compare-button, .danger-button, .send-button, .primary-button { min-width:44px; }
.workspace-list { display:flex; flex-direction:column; gap:4px; }
.workspace-row { flex:0 0 auto; }
.workspace-row.active { background:var(--accent-soft); }
.thread-card { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px; border:1px solid transparent; border-radius:10px; overflow:hidden; }
.thread-card.active { border-color:color-mix(in srgb,var(--accent) 50%,var(--border)); background:var(--accent-soft); }
.thread-card .thread-row { border-radius:0; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:7px; }
.thread-stats { color:var(--muted); font-size:.68rem; font-variant-numeric:tabular-nums; white-space:nowrap; }
.thread-actions { display:flex; align-items:center; opacity:.28; transition:opacity .16s ease; }
.thread-card:hover .thread-actions,.thread-card:focus-within .thread-actions,.thread-card.active .thread-actions { opacity:1; }
.thread-actions .icon-button { width:36px; min-width:36px; height:44px; border-radius:6px; font-size:.9rem; }

.file-editor-layout { flex:1; min-height:540px; display:grid; grid-template-columns:minmax(220px,290px) minmax(0,1fr); border:1px solid var(--border); border-radius:13px; overflow:hidden; background:var(--surface); }
.file-tree { min-width:0; overflow:auto; border-right:1px solid var(--border); background:var(--surface); }
.file-tree > .group { position:sticky; top:0; z-index:2; padding:8px; background:var(--surface); border-bottom:1px solid var(--border); display:grid; grid-template-columns:minmax(0,1fr) 44px 44px; align-items:center; gap:5px; }
.file-tree .file-row { border-radius:0; }
.code-editor-panel { min-width:0; min-height:0; display:flex; flex-direction:column; background:var(--bg); overflow:hidden; }
.editor-toolbar { min-height:58px; padding:7px 10px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; border-bottom:1px solid var(--border); background:var(--surface); }
.unsaved-indicator { min-height:28px; padding:5px 12px; color:var(--muted); font-size:.74rem; border-bottom:1px solid var(--border); }
.unsaved-indicator.dirty { color:var(--warning); background:color-mix(in srgb,var(--warning) 8%,transparent); }
.textarea-editor { flex:1; min-height:0; display:grid; grid-template-columns:auto minmax(0,1fr); overflow:hidden; background:var(--bg); }
.line-numbers { margin:0; min-width:48px; padding:12px 8px; overflow:hidden; text-align:right; user-select:none; color:var(--muted); background:var(--surface-2); border-right:1px solid var(--border); font: .78rem/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; }
.textarea-editor textarea { width:100%; height:100%; min-height:420px; resize:none; border:0; outline:0; padding:12px; background:var(--bg); color:var(--text); white-space:pre; overflow:auto; tab-size:2; font: .78rem/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; }

.catalog-banner { display:flex; flex-wrap:wrap; align-items:center; gap:7px 12px; padding:10px 12px; margin-bottom:10px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.catalog-banner.source-official { border-color:color-mix(in srgb,var(--ok) 55%,var(--border)); }
.catalog-banner.source-cache { border-color:color-mix(in srgb,var(--warning) 55%,var(--border)); }
.catalog-banner.source-demo { border-color:color-mix(in srgb,var(--accent) 55%,var(--border)); }
.model-row-actions { display:flex; align-items:center; gap:4px; }
.manual-model-form { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; margin:10px 0; }
.manual-model-form input { min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); padding:10px; }
.preset-panel { margin:12px 0; padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); display:flex; flex-wrap:wrap; gap:7px; align-items:center; }

.workspace-manage-row { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; padding:8px; border:1px solid var(--border); border-radius:10px; }
.workspace-main { min-height:52px; border:0; background:transparent; color:inherit; text-align:left; display:flex; align-items:center; gap:10px; padding:5px; }
.workspace-manage-actions { display:flex; align-items:center; }
.workspace-form,.thread-form { padding:14px; display:flex; flex-direction:column; gap:12px; }

.approval-view,.delete-confirmation { padding:16px; display:flex; flex-direction:column; gap:14px; }
.approval-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.approval-section { border:1px solid var(--border); border-radius:10px; padding:10px; background:var(--surface-2); min-width:0; }
.approval-section pre { margin:8px 0 0; max-height:220px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; font:.76rem/1.5 ui-monospace,SFMono-Regular,Consolas,monospace; }
.approval-actions { position:sticky; bottom:0; display:flex; justify-content:flex-end; gap:8px; padding:10px; margin:0 -16px -16px; border-top:1px solid var(--border); background:var(--surface); }

.diagnostic-summary { display:flex; flex-direction:column; gap:9px; padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--surface); }
.diagnostic-summary > .group { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:start; gap:9px; padding:8px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); }
.error-text { color:var(--danger); overflow-wrap:anywhere; }

@media (max-width:980px) {
  .file-editor-layout { min-height:calc(var(--viewport-height) - 152px); grid-template-columns:minmax(170px,35vw) minmax(0,1fr); }
  .thread-actions { opacity:1; }
}
@media (max-width:620px) {
  .file-editor-layout { display:flex; flex-direction:column; min-height:auto; border-radius:10px; overflow:visible; }
  .file-tree { max-height:34vh; border-right:0; border-bottom:1px solid var(--border); }
  .code-editor-panel { min-height:52vh; }
  .textarea-editor textarea { min-height:38vh; }
  .editor-toolbar { align-items:stretch; }
  .editor-toolbar .secondary-button,.editor-toolbar .danger-button { padding:0 8px; font-size:.72rem; }
  .approval-grid { grid-template-columns:1fr; }
  .manual-model-form { grid-template-columns:1fr; }
  .thread-card { grid-template-columns:minmax(0,1fr); }
  .thread-actions { justify-content:flex-end; border-top:1px solid var(--border); }
  .workspace-manage-row { grid-template-columns:1fr; }
  .workspace-manage-actions { justify-content:flex-end; }
}
@media (max-width:980px) and (orientation:landscape) and (max-height:520px) {
  .file-editor-layout { min-height:calc(var(--viewport-height) - 100px); grid-template-columns:minmax(160px,27vw) minmax(0,1fr); }
  .file-tree { max-height:none; border-right:1px solid var(--border); border-bottom:0; }
  .code-editor-panel { min-height:0; }
  .textarea-editor textarea { min-height:180px; }
  .overlay { max-height:calc(var(--viewport-height) - 8px); }
  .approval-view { padding:9px; gap:8px; }
  .approval-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
.preset-panel input { min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface); padding:10px; }
.file-tree input { width:100%; min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); padding:9px; }
.left-pane > input { width:100%; min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface-2); padding:9px; }
.thread-actions .icon-button { width:44px; min-width:44px; }
.model-note-panel { display:grid; grid-template-columns:minmax(160px,.7fr) minmax(200px,1fr) auto; gap:8px; align-items:center; margin:10px 0; padding:10px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); }
.model-note-panel input { min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--surface); padding:10px; }
@media (max-width:620px) { .model-note-panel { grid-template-columns:1fr; } }
