:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #eef1ef;
  --surface-strong: #e5e9e6;
  --text: #18201c;
  --muted: #66706a;
  --line: #d8ded9;
  --accent: #147548;
  --accent-strong: #0b5a35;
  --accent-soft: #e0f3e7;
  --blue: #2569a9;
  --blue-soft: #e8f1fa;
  --danger: #b63b34;
  --danger-soft: #fff0ed;
  --amber: #a86609;
  --amber-soft: #fff7e2;
  --shadow: 0 10px 28px rgba(23, 32, 27, 0.11);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { height: 100dvh; overflow: hidden; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.5; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37, 105, 169, 0.25); outline-offset: 2px; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 12px rgba(23, 32, 27, 0.05);
  position: relative;
  z-index: 5;
}
.brand-icon { width: 36px; height: 36px; border-radius: 8px; }
.brand-block { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.brand-block strong { font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connection { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; line-height: 16px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #9da59f; }
.connection.online i { background: #26985a; box-shadow: 0 0 0 3px rgba(38, 152, 90, 0.12); }
.connection.error i { background: var(--danger); }
.approval-indicator { flex: none; height: 28px; display: inline-flex; align-items: center; padding: 0 9px; border: 1px solid #e7c77f; border-radius: 999px; color: #76500d; background: var(--amber-soft); font-size: 11px; font-weight: 700; }
.icon-button { flex: 0 0 40px; width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font-size: 25px; line-height: 38px; }
.icon-button:hover { background: var(--surface-muted); }
.workspace { height: calc(100dvh - 64px); display: grid; grid-template-columns: minmax(270px, 330px) minmax(0, 1fr); }
.sidebar { min-width: 0; border-right: 1px solid var(--line); background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.sidebar-heading { min-height: 68px; flex: 0 0 68px; padding: 0 14px 0 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.sidebar-heading h1 { font-size: 16px; margin: 0; }
.sidebar-heading > div > span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.command-button, .primary-button, .secondary-button, .session-button, .danger-button { min-height: 40px; border-radius: 6px; border: 1px solid transparent; padding: 8px 13px; font-weight: 700; }
.command-button, .primary-button { color: white; background: var(--accent); }
.command-button:hover, .primary-button:hover { background: var(--accent-strong); }
.secondary-button { color: var(--text); background: var(--surface); border-color: var(--line); }
.secondary-button:hover { background: var(--surface-muted); }
.secondary-button.decline { color: var(--danger); border-color: #e9bbb6; }
.session-button { color: #1e5b8d; background: var(--blue-soft); border-color: #bfd5e8; }
.session-button:hover { background: #dcebf7; }
.danger-button { color: var(--danger); background: var(--danger-soft); border-color: #e9bbb6; white-space: nowrap; }
.full-width { width: 100%; }

.thread-list { overflow-y: auto; padding: 8px; }
.thread-row { width: 100%; min-height: 76px; border: 0; border-radius: 6px; background: transparent; padding: 11px 10px; text-align: left; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; color: var(--text); position: relative; }
.thread-row:hover { background: var(--surface-muted); }
.thread-row.selected { background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.thread-row.has-approval { background: var(--amber-soft); }
.thread-row.has-approval.selected { box-shadow: inset 3px 0 0 var(--amber); }
.thread-row strong { min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row p { grid-column: 1 / 3; margin: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-row time { color: var(--muted); font-size: 11px; font-weight: 600; }
.thread-row.has-approval time { color: #835b14; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #99a19b; display: inline-block; margin-right: 7px; }
.status-dot.active { background: #26985a; box-shadow: 0 0 0 3px rgba(38, 152, 90, 0.12); }
.status-dot.error { background: var(--danger); }

.console { min-width: 0; background: var(--bg); overflow: hidden; }
.empty-state { height: 100%; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.empty-state img { width: 60px; height: 60px; opacity: 0.68; }
.empty-state h2 { font-size: 16px; font-weight: 650; }
.thread-view { width: 100%; min-width: 0; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.thread-view > * { min-width: 0; }
.thread-header { min-height: 76px; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.thread-header > div { min-width: 0; }
.thread-heading { flex: 1 1 auto; }
.thread-back-button { display: none; flex: 0 0 42px; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(46,72,70,.16); border-radius: 14px; color: #225b5d; background: rgba(255,255,255,.72); font-size: 24px; box-shadow: 0 5px 14px rgba(37,65,61,.08); }
.thread-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.thread-title-row h2 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-header p { margin: 5px 0 0; color: var(--muted); font: 12px/16px Consolas, "Cascadia Mono", monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state-badge { flex: none; font-size: 11px; padding: 3px 7px; border-radius: 999px; color: #515a54; background: var(--surface-muted); }
.state-badge.active { color: var(--accent-strong); background: var(--accent-soft); }
.state-badge.error { color: var(--danger); background: var(--danger-soft); }

.timeline { width: 100%; min-width: 0; overflow-y: auto; padding: 18px max(18px, calc((100% - 860px) / 2)); scroll-behavior: smooth; }
.timeline-item { max-width: 860px; margin: 0 auto 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; box-shadow: 0 2px 7px rgba(23, 32, 27, 0.035); }
.timeline-item.user { margin-left: auto; max-width: min(700px, 88%); background: var(--blue-soft); border-color: #cadbea; box-shadow: none; }
.item-heading { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 7px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.item-heading i { width: 7px; height: 7px; border-radius: 50%; background: #7d8981; }
.item-heading i.agent { background: var(--accent); }
.item-heading i.command { background: #d35d45; }
.item-body { padding: 12px 14px; font-size: 14px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-body pre { margin: 0; padding: 12px; border-radius: 5px; overflow-x: auto; background: #18201c; color: #eff4ef; font: 12px/1.55 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; }
.item-meta { color: var(--muted); font-size: 12px; }
.timeline-empty { text-align: center; color: var(--muted); margin: 52px 0; }

.approval-panel { padding: 13px max(18px, calc((100% - 860px) / 2)); background: var(--amber-soft); border-top: 1px solid #e6c77e; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; box-shadow: 0 -5px 18px rgba(86, 58, 8, 0.08); }
.approval-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: white; background: var(--amber); font-weight: 800; font-size: 20px; }
.approval-panel.file .approval-icon { background: var(--blue); }
.approval-panel.tool .approval-icon { background: #6f568c; }
.approval-panel.desktop .approval-icon { background: #1e5968; }
.approval-copy { min-width: 0; }
.approval-eyebrow { display: block; color: #7c5614; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.approval-copy strong { display: block; margin-top: 2px; font-size: 14px; }
.approval-copy pre { max-height: 86px; overflow: auto; margin: 5px 0 0; color: #51462e; font: 12px/1.45 Consolas, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.approval-copy p { margin: 5px 0 0; color: var(--muted); font: 11px/1.35 Consolas, monospace; overflow-wrap: anywhere; }
.approval-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.approval-actions button { white-space: nowrap; }

.composer { width: 100%; min-width: 0; min-height: 139px; padding: 8px max(18px, calc((100% - 860px) / 2)) max(12px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr) 48px; gap: 8px; align-items: end; background: var(--surface); border-top: 1px solid var(--line); }
.composer-mode { grid-column: 1 / 3; min-height: 16px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.run-config { grid-column: 1 / 3; min-height: 38px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #f8faf8; }
.config-button { min-width: 0; padding: 5px 10px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; border: 0; border-right: 1px solid var(--line); color: var(--text); background: transparent; text-align: left; }
.config-button:last-child { border-right: 0; }
.config-button:hover { background: var(--blue-soft); }
.config-button span { color: var(--muted); font-size: 10px; }
.config-button strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.config-button i { color: var(--muted); font-style: normal; }
.composer-mode i { width: 7px; height: 7px; border-radius: 50%; background: #8f9892; }
.composer-mode.active i { background: #26985a; }
.composer textarea { width: 100%; min-width: 0; min-height: 52px; max-height: 150px; resize: none; border: 1px solid #b9c2bc; border-radius: 8px; padding: 11px 12px; color: var(--text); background: #fbfcfb; line-height: 1.45; overflow-y: auto; }
.composer textarea:focus { border-color: var(--blue); background: white; }
.send-button { width: 48px; height: 48px; align-self: center; border: 0; border-radius: 50%; background: var(--accent); color: white; font-size: 24px; line-height: 48px; }
.send-button:hover { background: var(--accent-strong); }

.modal { width: min(420px, calc(100vw - 28px)); border: 0; border-radius: 8px; padding: 0; color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(19, 27, 22, 0.5); }
.modal form { padding: 24px; display: grid; gap: 10px; }
.modal img { width: 52px; height: 52px; }
.modal h2 { margin: 3px 0 8px; font-size: 19px; }
.modal label { font-size: 12px; color: var(--muted); font-weight: 700; }
.modal input, .modal textarea { width: 100%; border: 1px solid #b9c2bc; border-radius: 7px; padding: 11px; background: white; color: var(--text); }
.modal textarea { resize: vertical; line-height: 1.45; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 30px); padding: 10px 14px; border-radius: 6px; color: white; background: #202722; box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 720px) {
  .topbar { height: 58px; padding: 0 8px; gap: 6px; }
  .brand-icon { width: 32px; height: 32px; }
  .brand-block strong { font-size: 14px; }
  .approval-indicator { max-width: 78px; overflow: hidden; white-space: nowrap; }
  .workspace { height: calc(100dvh - 58px); display: block; }
  .sidebar { height: 100%; border-right: 0; }
  .console { display: none; height: 100%; }
  .workspace.thread-open .sidebar { display: none; }
  .workspace.thread-open .console { display: block; }
  .thread-back-button { display: grid; }
  .thread-header { min-height: 66px; padding: 9px 11px; }
  .thread-header p { max-width: calc(100vw - 112px); }
  .timeline { padding: 11px 9px; }
  .timeline-item { margin-bottom: 9px; }
  .timeline-item.user { max-width: 94%; }
  .item-body { padding: 10px 11px; font-size: 13px; }
  .approval-panel { padding: 11px 10px; grid-template-columns: 34px minmax(0, 1fr); gap: 9px; }
  .approval-icon { width: 34px; height: 34px; }
  .approval-actions { grid-column: 1 / 3; display: grid; grid-template-columns: 0.8fr 1.2fr 1fr; width: 100%; }
  .approval-actions button { min-width: 0; padding: 7px 6px; font-size: 12px; }
  .composer { min-height: 133px; padding: 8px 9px max(9px, env(safe-area-inset-bottom)); grid-template-columns: minmax(0, 1fr) 46px; gap: 7px; }
  .run-config { min-height: 36px; }
  .config-button { padding: 5px 8px; gap: 5px; }
  .config-button span { font-size: 9px; }
  .config-button strong { font-size: 10px; }
  .send-button { width: 46px; height: 46px; }
  .danger-button { min-height: 36px; padding: 7px 9px; }
}

@media (max-width: 390px) {
  .brand-block strong { max-width: 132px; }
  .approval-indicator { display: none !important; }
  .config-button { padding: 5px 6px; }
  .icon-button { flex-basis: 36px; width: 36px; }
}
.sheet-layer { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(19, 27, 22, 0.5); }
.bottom-sheet { position: relative; width: min(560px, 100%); max-height: min(72dvh, 620px); margin: 0 auto; display: flex; flex-direction: column; border-radius: 10px 10px 0 0; background: var(--surface); box-shadow: 0 -14px 34px rgba(18, 25, 21, 0.22); }
.sheet-handle { width: 38px; height: 4px; margin: 8px auto 1px; border-radius: 2px; background: #cbd2cd; }
.bottom-sheet header { min-height: 66px; padding: 9px 14px 9px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.bottom-sheet header span { color: var(--accent); font-size: 10px; font-weight: 800; }
.bottom-sheet h2 { margin: 2px 0 0; font-size: 17px; }
.sheet-close { width: 36px; height: 36px; border: 0; border-radius: 7px; color: var(--muted); background: var(--surface-muted); font-size: 21px; }
.sheet-options { min-height: 0; overflow-y: auto; padding: 5px 9px max(14px, env(safe-area-inset-bottom)); }
.option-row { width: 100%; min-height: 66px; padding: 9px; display: grid; grid-template-columns: 23px minmax(0, 1fr) auto; align-items: center; gap: 9px; border: 0; border-bottom: 1px solid #edf0ee; color: var(--text); background: transparent; text-align: left; }
.option-row:hover { background: var(--surface-muted); }
.option-row.selected { background: var(--accent-soft); }
.option-radio { width: 18px; height: 18px; border: 2px solid #a9b2ac; border-radius: 50%; position: relative; }
.option-row.selected .option-radio { border-color: var(--accent); }
.option-row.selected .option-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.option-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.option-copy strong { font-size: 13px; }
.option-copy small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.option-tag { padding: 4px 6px; border-radius: 5px; color: #4c5851; background: var(--surface-strong); font-size: 9px; font-weight: 800; }
/* Atelier visual refresh: a warm paper workspace with crisp console controls. */
:root {
  --bg: #e9e5db;
  --surface: rgba(255, 253, 248, 0.94);
  --surface-muted: #f1ecdf;
  --surface-strong: #e5ddce;
  --text: #1d2730;
  --muted: #65727a;
  --line: rgba(65, 75, 77, 0.16);
  --accent: #175f61;
  --accent-strong: #0d484c;
  --accent-soft: #dceeed;
  --blue: #365ba5;
  --blue-soft: #e5ebfa;
  --danger: #b64a40;
  --danger-soft: #fff0eb;
  --amber: #ad7020;
  --amber-soft: #fff4dc;
  --shadow: 0 18px 50px rgba(46, 39, 27, 0.16);
  font-family: "Segoe UI Variable", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

html, body { background: var(--bg); }
body {
  background:
    radial-gradient(circle at 105% -5%, rgba(87, 129, 159, 0.25), transparent 31rem),
    radial-gradient(circle at -8% 110%, rgba(208, 160, 79, 0.17), transparent 29rem),
    repeating-linear-gradient(0deg, rgba(91, 77, 48, 0.024) 0 1px, transparent 1px 5px),
    var(--bg);
}
.topbar {
  height: 70px;
  padding: 0 20px;
  border-bottom-color: rgba(255, 255, 255, 0.76);
  background: linear-gradient(105deg, rgba(27, 45, 52, 0.98), rgba(23, 95, 97, 0.96) 57%, rgba(57, 91, 165, 0.93));
  box-shadow: 0 6px 22px rgba(20, 35, 35, 0.22);
  color: #fbfaf5;
}
.brand-icon {
  width: 42px; height: 42px; border-radius: 14px;
  background: #f8e6ac; padding: 5px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.22);
}
.brand-block { gap: 2px; }
.brand-block strong { font-family: Georgia, "Noto Serif SC", serif; font-size: 17px; letter-spacing: 0.015em; }
.connection { color: rgba(247, 249, 248, 0.77); }
.connection i { background: #b6c1be; }
.connection.online i { background: #8be0ae; box-shadow: 0 0 0 4px rgba(139, 224, 174, 0.14); }
.connection.error i { background: #ffc1b6; }
.approval-indicator { border: 0; color: #573a08; background: #ffd783; box-shadow: 0 2px 10px rgba(0,0,0,.14); }
.icon-button { border-radius: 13px; color: #fff; font-size: 23px; }
.icon-button:hover { background: rgba(255,255,255,.16); }
.workspace { height: calc(100dvh - 70px); gap: 0; }
.sidebar { border-right: 1px solid rgba(72, 70, 61, 0.12); background: rgba(249, 247, 240, 0.72); backdrop-filter: blur(16px); }
.sidebar-heading { min-height: 82px; flex-basis: 82px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--line); }
.sidebar-heading h1 { font-family: Georgia, "Noto Serif SC", serif; font-size: 20px; letter-spacing: .03em; }
.sidebar-heading > div > span { color: #8a6b34; font-weight: 700; }
.command-button, .primary-button { border: 0; border-radius: 12px; background: linear-gradient(135deg, #1b6668, #174f72); box-shadow: 0 7px 14px rgba(27, 86, 93, .19); }
.command-button:hover, .primary-button:hover { background: linear-gradient(135deg, #104e52, #284a91); transform: translateY(-1px); }
.thread-list { padding: 11px; }
.thread-row { min-height: 82px; margin-bottom: 5px; border: 1px solid transparent; border-radius: 15px; padding: 12px; transition: transform .16s ease, background .16s ease, box-shadow .16s ease; }
.thread-row:hover { background: rgba(255,255,255,.8); box-shadow: 0 6px 16px rgba(64,56,42,.07); transform: translateY(-1px); }
.thread-row.selected { border-color: rgba(54,91,165,.18); background: linear-gradient(135deg, #e8ecfb, #eff7f3); box-shadow: 0 7px 17px rgba(39,73,112,.10); }
.thread-row.selected::after { content: ""; position: absolute; right: 10px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(23,95,97,.12); }
.console { background: transparent; }
.empty-state { color: var(--muted); }
.empty-state img { width: 76px; height: 76px; padding: 12px; border-radius: 25px; background: #fbf4df; box-shadow: var(--shadow); opacity: 1; }
.empty-state h2 { font-family: Georgia, "Noto Serif SC", serif; font-size: 20px; font-weight: 600; }
.thread-header { min-height: 82px; padding: 14px 26px; border-bottom-color: rgba(255,255,255,.73); background: rgba(255,253,248,.65); backdrop-filter: blur(16px); }
.thread-title-row h2 { font-family: Georgia, "Noto Serif SC", serif; font-size: 19px; }
.thread-header p { color: #6f776d; }
.state-badge { padding: 5px 9px; color: #51636a; border: 1px solid rgba(70,88,91,.12); background: rgba(255,255,255,.64); }
.state-badge.active { color: #115a5b; border-color: rgba(23,95,97,.15); background: #dcf1ec; }
.timeline { padding-top: 24px; padding-bottom: 24px; }
.timeline-item { border: 1px solid rgba(77, 72, 57, .13); border-radius: 17px; background: rgba(255,253,248,.88); box-shadow: 0 7px 18px rgba(62,54,42,.07); }
.timeline-item.user { border-color: rgba(54,91,165,.16); background: linear-gradient(135deg, #e8edfc, #ecf5fb); box-shadow: 0 7px 17px rgba(41,71,122,.08); }
.item-heading { min-height: 37px; padding: 8px 14px; border-bottom-color: rgba(77,72,57,.10); color: #66736d; letter-spacing: .08em; }
.item-heading i.agent { background: #d29a35; }
.item-body { padding: 14px 16px; font-size: 14px; }
.item-body pre { border-radius: 11px; background: #1f2d31; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.composer { min-height: 152px; padding: 10px max(22px, calc((100% - 860px) / 2)) max(16px, env(safe-area-inset-bottom)); border-top-color: rgba(255,255,255,.85); background: rgba(255,253,248,.82); backdrop-filter: blur(18px); }
.composer-mode { color: #5d716e; font-weight: 700; letter-spacing: .04em; }
.run-config { min-height: 42px; border: 1px solid rgba(62,86,82,.16); border-radius: 13px; background: rgba(240, 237, 226, .74); box-shadow: inset 0 1px 0 rgba(255,255,255,.72); }
.config-button { padding: 6px 12px; }
.config-button:hover { background: rgba(220,238,237,.85); }
.config-button span { color: #7b6b48; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.config-button strong { color: #234f52; font-size: 12px; }
.composer textarea { border-color: rgba(46,72,70,.25); border-radius: 15px; background: rgba(255,255,255,.8); box-shadow: inset 0 1px 3px rgba(50,44,30,.06); }
.composer textarea:focus { border-color: #28787a; box-shadow: 0 0 0 4px rgba(40,120,122,.12); }
.send-button { border-radius: 16px; background: linear-gradient(145deg, #1c7775, #17525d); box-shadow: 0 7px 14px rgba(23,95,97,.24); }
.sheet-backdrop { background: rgba(18, 27, 31, .48); backdrop-filter: blur(3px); }
.bottom-sheet { border-radius: 24px 24px 0 0; background: #fffdf8; box-shadow: 0 -18px 45px rgba(24,30,28,.25); }
.sheet-handle { width: 44px; background: #cdbf9f; }
.bottom-sheet header { min-height: 74px; padding: 9px 16px 9px 22px; }
.bottom-sheet header span { color: #a36a1a; letter-spacing: .11em; }
.bottom-sheet h2 { font-family: Georgia, "Noto Serif SC", serif; font-size: 20px; }
.sheet-close { border-radius: 12px; color: #416265; background: #ebf1ef; }
.option-row { min-height: 72px; border-radius: 13px; margin-bottom: 3px; border-bottom: 0; }
.option-row:hover { background: #f2eee3; }
.option-row.selected { background: linear-gradient(135deg, #ddf0ec, #edf3fb); }
.option-radio { border-color: #adad9f; }
.option-row.selected .option-radio { border-color: #19706f; }
.option-row.selected .option-radio::after { background: #19706f; }
.option-tag { color: #70521d; background: #f7e5b6; }
.modal { border-radius: 22px; background: #fffdf8; }
.modal form { padding: 28px; }
.toast { border-radius: 14px; background: rgba(28,42,42,.95); box-shadow: var(--shadow); }

@media (max-width: 720px) {
  .topbar { height: 64px; padding: 0 10px; }
  .brand-icon { width: 36px; height: 36px; border-radius: 12px; }
  .brand-block strong { font-size: 15px; }
  .workspace { height: calc(100dvh - 64px); }
  .sidebar-heading { min-height: 76px; flex-basis: 76px; }
  .thread-header { min-height: 74px; padding: 10px 13px; gap: 9px; }
  .thread-title-row { gap: 7px; }
  .thread-back-button { flex-basis: 40px; width: 40px; height: 40px; border-radius: 13px; }
  .timeline { padding: 14px 10px 18px; }
  .timeline-item { border-radius: 15px; }
  .composer { min-height: 147px; padding: 9px 10px max(12px, env(safe-area-inset-bottom)); }
  .run-config { min-height: 39px; border-radius: 12px; }
  .send-button { border-radius: 15px; }
}
/* Keyboard-safe viewport, foreground approvals, and mathematical output. */
:root { --topbar-height: 70px; }
body { height: var(--app-height, 100dvh); }
.workspace { height: calc(var(--app-height, 100dvh) - var(--topbar-height)); }
.approval-banner {
  position: fixed;
  z-index: 24;
  top: calc(var(--topbar-height) + 10px);
  inset-block-start: calc(var(--topbar-height) + 10px);
  left: 50%;
  width: min(560px, calc(100vw - 20px));
  min-height: 58px;
  transform: translateX(-50%);
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(130, 79, 18, .24);
  border-radius: 16px;
  color: #3d3020;
  background: rgba(255, 245, 218, .97);
  box-shadow: 0 16px 38px rgba(68, 45, 12, .22);
  backdrop-filter: blur(16px);
  animation: approval-slide .24s ease-out;
}
.approval-banner-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 12px; color: white; background: #b06d16; font-weight: 900;
}
.approval-banner-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.approval-banner-copy strong { font-size: 13px; }
.approval-banner-copy small { color: #78664d; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.approval-banner button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 11px; color: white; background: #805018; font-weight: 800; }
@keyframes approval-slide { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.katex-display { max-width: 100%; margin: .75em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.05em; }
.item-body .katex-error { color: var(--danger); border-bottom: 1px dotted currentColor; }
body.keyboard-open .composer { box-shadow: 0 -10px 30px rgba(32, 45, 44, .14); }

@media (max-width: 720px) {
  :root { --topbar-height: 64px; }
  .approval-banner { top: calc(var(--topbar-height) + 7px); inset-block-start: calc(var(--topbar-height) + 7px); width: calc(100vw - 14px); min-height: 56px; border-radius: 15px; }
}
.thread-view.approval-only { grid-template-rows: auto minmax(0, 1fr) auto; }
.thread-view.approval-only .composer { display: none; }
.thread-view.approval-only .timeline { display: grid; place-content: center; color: var(--muted); text-align: center; }
