:root {
  color-scheme: dark;
  --bg-base: #171914;
  --bg-sidebar: #1d201a;
  --bg-surface: #24271f;
  --bg-elevated: #2a2d25;
  --bg-hover: #30342b;
  --text-primary: #e8e4d7;
  --text-secondary: #a8aa9b;
  --text-faint: #74796c;
  --brass: #c3a46c;
  --brass-hover: #d1b57e;
  --botanical: #748873;
  --rose: #9e6c68;
  --danger: #c06d65;
  --success: #76947b;
  --border: #383c32;
  --border-soft: rgba(195, 164, 108, 0.14);
  --shadow-floating: 0 18px 48px rgba(0, 0, 0, 0.32);
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-editorial: Georgia, "Noto Serif SC", "Songti SC", serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; min-height: 0; }

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% -12%, rgba(116, 136, 115, 0.08), transparent 34%),
    var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

::selection { background: rgba(195, 164, 108, 0.24); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3b4035; border: 3px solid transparent; background-clip: padding-box; border-radius: 9px; }

.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.mobile-only { display: none !important; }
.desktop-only { display: inline-grid; }
.muted { color: var(--text-secondary); }
.wide { width: 100%; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--brass);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.app-shell { --sidebar-width: 288px; --preview-width: clamp(520px,46vw,960px); width: 100%; height: 100dvh; min-height: 0; display: grid; grid-template-columns: var(--sidebar-width) minmax(0,1fr) 0; overflow: hidden; }
body.sidebar-collapsed .app-shell { grid-template-columns: 0 minmax(0,1fr) 0; }
body.preview-open .app-shell { grid-template-columns: var(--sidebar-width) minmax(0,1fr) var(--preview-width); }
body.preview-open.sidebar-collapsed .app-shell { grid-template-columns: 0 minmax(0,1fr) var(--preview-width); }
body.sidebar-collapsed .sidebar { visibility: hidden; }

.sidebar {
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 30;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image: linear-gradient(115deg, transparent 0 72%, rgba(195,164,108,.025) 72% 73%, transparent 73%);
  background-size: 36px 36px;
}

.brand-row, .primary-navigation, .history-section, .quota-card, .account-dock { position: relative; z-index: 1; }

.brand-row { height: 76px; padding: 18px 14px 14px 18px; display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px; display: block; object-fit: cover;
  border: 1px solid rgba(195,164,108,.55); border-radius: 10px;
}

.brand-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.brand-copy strong { font: 600 18px/1.25 var(--font-editorial); letter-spacing: .01em; }
.brand-copy span { color: var(--text-faint); font-size: 11px; margin-top: 2px; }
.sidebar-collapse { width: 34px; height: 34px; flex: 0 0 34px; color: var(--text-faint); border-color: transparent; }
.sidebar-collapse:hover { color: var(--text-primary); border-color: var(--border); background: rgba(232,228,215,.035); }

.primary-navigation { padding: 4px 14px 18px; border-bottom: 1px solid var(--border-soft); display: grid; gap: 6px; }

.nav-action {
  width: 100%; min-height: 44px; border: 1px solid transparent; background: transparent;
  border-radius: 10px; padding: 0 13px; display: flex; gap: 11px; align-items: center;
  color: var(--text-secondary); cursor: pointer; text-align: left; transition: 150ms ease-out;
}
.nav-action:hover { color: var(--text-primary); background: rgba(232,228,215,.035); border-color: var(--border-soft); }
.nav-action-primary { color: var(--text-primary); border-color: rgba(195,164,108,.36); background: rgba(195,164,108,.065); }
.nav-action-primary:hover { border-color: rgba(195,164,108,.62); background: rgba(195,164,108,.1); }
.nav-action span:first-child { width: 20px; color: var(--brass); font-size: 19px; text-align: center; }

.history-section { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 16px 10px 12px; }
.section-heading-row { height: 28px; padding: 0 8px 6px; display: flex; align-items: center; justify-content: space-between; }
.section-heading-row h2 { margin: 0; color: var(--text-faint); font-size: 11px; letter-spacing: .08em; font-weight: 650; text-transform: uppercase; }

.history-status { padding: 0 8px; color: var(--text-faint); font-size: 12px; }
.history-status:empty { display: none; }
.history-status.error { margin: 7px 4px 10px; padding: 12px; border: 1px solid rgba(192,109,101,.45); border-radius: 10px; color: #d99a94; background: rgba(192,109,101,.06); }
.history-status button { margin-top: 9px; border: 0; padding: 0; background: none; color: var(--brass); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.history-list { min-height: 0; flex: 1; overflow-y: auto; padding-right: 2px; }
.history-group { margin-top: 13px; }
.history-group:first-child { margin-top: 5px; }
.history-group-title { margin: 0; padding: 0 11px 6px; color: var(--text-faint); font-size: 11px; font-weight: 600; }
.history-item { min-width: 0; position: relative; display: grid; grid-template-columns: minmax(0,1fr) 32px; align-items: center; border-radius: 8px; }
.history-item::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: transparent; }
.history-item:hover { background: rgba(232,228,215,.035); }
.history-item.active { background: rgba(195,164,108,.065); }
.history-item.active::before { background: var(--brass); }
.history-open, .history-more { border: 0; background: none; cursor: pointer; }
.history-open { min-width: 0; height: 39px; padding: 0 6px 0 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.history-item.active .history-open, .history-open:hover { color: var(--text-primary); }
.history-more { width: 28px; height: 28px; border-radius: 7px; color: transparent; opacity: 0; font-size: 18px; line-height: 1; transition: 140ms ease-out; }
.history-item:hover .history-more, .history-more:focus-visible, .history-more[aria-expanded="true"] { color: var(--text-faint); opacity: 1; }
.history-more:hover { color: var(--text-primary); background: rgba(232,228,215,.06); }
.history-menu { display: none; position: absolute; top: 34px; right: 3px; z-index: 45; width: 132px; padding: 5px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-elevated); box-shadow: 0 12px 30px rgba(0,0,0,.52); }
.history-menu.open { display: grid; }
.history-menu.open-upward { top: auto; bottom: 34px; }
.history-menu button { min-height: 34px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text-secondary); text-align: left; cursor: pointer; }
.history-menu button:hover { background: var(--bg-hover); color: var(--text-primary); }
.history-menu button.danger { color: #dba39e; }
.history-menu button.danger:hover { background: rgba(192,109,101,.09); color: #efb0aa; }

.quota-card { flex: 0 0 auto; margin: 0 10px; padding: 12px 10px 10px; border-top: 1px solid var(--border-soft); }
.quota-heading-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.quota-heading-row > div { display: flex; align-items: baseline; gap: 8px; }
.quota-kicker { color: var(--text-faint); font-size: 8px; font-weight: 700; letter-spacing: .13em; }
.quota-heading-row strong { color: var(--text-secondary); font-size: 11px; font-weight: 650; }
.quota-refresh { width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--text-faint); cursor: pointer; }
.quota-refresh:hover { color: var(--text-primary); background: rgba(232,228,215,.045); }
.quota-refresh:disabled { opacity: .45; cursor: wait; }
.quota-status { min-height: 18px; color: var(--text-faint); font-size: 10px; line-height: 1.45; }
.quota-status.error { color: #c98e88; }
.quota-windows { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.quota-window { min-width: 0; }
.quota-window-heading { height: 20px; display: flex; align-items: baseline; justify-content: space-between; gap: 5px; }
.quota-window-heading strong { color: var(--text-secondary); font-size: 10px; font-weight: 650; }
.quota-reset { min-width: 0; color: var(--text-faint); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quota-row { display: grid; grid-template-columns: 31px minmax(0,1fr) 28px; align-items: center; gap: 5px; min-height: 17px; color: var(--text-faint); font-size: 8.5px; }
.quota-row b { color: var(--text-faint); font-size: 8.5px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.quota-track { height: 4px; overflow: hidden; border-radius: 999px; background: rgba(232,228,215,.07); }
.quota-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--botanical); transition: width 220ms ease-out; }
.quota-row[data-quota-source="local"] .quota-track i { background: #8e8168; }
.quota-row.total { color: var(--text-secondary); }
.quota-row.total b { color: var(--text-secondary); }
.quota-row.total .quota-track i { background: var(--brass); }
.quota-note { grid-column: 1 / -1; margin: 0; color: #666b60; font-size: 8px; line-height: 1.4; }

.account-dock { width: auto; min-height: 57px; flex: 0 0 auto; margin: 0 10px max(8px,env(safe-area-inset-bottom)); padding: 8px 9px; display: grid; grid-template-columns: 34px minmax(0,1fr) 28px; align-items: center; gap: 9px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.account-dock:hover { border-color: var(--border-soft); background: rgba(232,228,215,.035); }
.account-avatar { width: 34px; height: 34px; display: block; object-fit: cover; border: 1px solid rgba(195,164,108,.5); border-radius: 50%; }
.account-copy { min-width: 0; display: flex; flex-direction: column; }
.account-copy strong { overflow: hidden; color: var(--text-primary); font-size: 12px; font-weight: 600; text-overflow: ellipsis; }
.account-copy small { margin-top: 2px; overflow: hidden; color: var(--text-faint); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.account-gear { color: var(--text-faint); font-size: 15px; text-align: center; }
.account-dock:hover .account-gear { color: var(--brass); }

.main-content { min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-rows: 68px minmax(0,1fr) auto; position: relative; overflow: hidden; }
.top-bar {
  min-width: 0; height: 68px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(56,60,50,.72); background: rgba(23,25,20,.96); z-index: 20;
}
.top-bar-context { min-width: 0; display: flex; align-items: center; gap: 13px; }
.title-stack { min-width: 0; }
.title-stack .eyebrow { margin-bottom: 2px; color: var(--text-faint); }
.title-stack h2 { margin: 0; max-width: min(52vw, 620px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font: 500 17px/1.3 var(--font-ui); }
.top-bar-actions { display: flex; align-items: center; gap: 12px; }
.connection-label { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font-size: 11px; }
.status-indicator { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(118,148,123,.1); }
.status-indicator.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(192,109,101,.1); }

.icon-button {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border: 1px solid transparent;
  border-radius: 9px; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.icon-button:hover { color: var(--text-primary); background: rgba(232,228,215,.045); border-color: var(--border); }
.icon-button.quiet { width: 28px; height: 28px; }
.icon-button.soft { border-color: var(--border); background: rgba(232,228,215,.025); }
.utility-trigger { letter-spacing: .12em; }

.utility-wrap { position: relative; }
.utility-menu {
  position: absolute; top: 48px; right: 0; width: 232px; padding: 8px; z-index: 80;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.utility-menu button { width: 100%; min-height: 50px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
.utility-menu button:hover { background: var(--bg-hover); }
.utility-menu button span { color: var(--text-primary); }
.utility-menu button small { color: var(--text-faint); font-size: 11px; }

.chat-scroll { min-width: 0; min-height: 0; height: 100%; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 44px max(24px, calc((100% - 900px) / 2)) 34px; scroll-behavior: smooth; }
.welcome-state { max-width: 700px; margin: min(18vh,150px) auto 0; text-align: center; }
.welcome-state h1 { margin: 8px 0 14px; font: 500 clamp(30px,4vw,48px)/1.15 var(--font-editorial); letter-spacing: -.02em; }
.welcome-state > p:last-child { max-width: 570px; margin: 0 auto; color: var(--text-secondary); line-height: 1.75; }

.message { width: 100%; position: relative; padding: 24px 4px 28px; border-bottom: 1px solid rgba(56,60,50,.56); }
.message:last-child { border-bottom-color: transparent; }
.message.user { width: min(78%,680px); margin-left: auto; padding: 19px 0 22px; border-bottom-color: transparent; }
.message-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.message.user .message-header { flex-direction: row-reverse; gap: 14px; }
.message-role { display: flex; align-items: center; gap: 9px; color: var(--text-secondary); font-size: 12px; font-weight: 650; letter-spacing: .03em; }
.message-role::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--botanical); }
.message.user .message-role::before { background: var(--brass); }
.message-copy { border: 0; background: transparent; color: var(--text-faint); font-size: 11px; cursor: pointer; opacity: 0; transition: 140ms ease-out; }
.message:hover .message-copy, .message-copy:focus-visible { opacity: 1; }
.message-copy:hover { color: var(--brass); }
.msg-content { color: var(--text-primary); font-size: 15.5px; line-height: 1.82; overflow-wrap: anywhere; }
.message.user .msg-content { white-space: pre-wrap; }
.message.assistant .msg-content > :first-child { margin-top: 0; }
.message.assistant .msg-content > :last-child { margin-bottom: 0; }
.msg-content p { margin: 0 0 1em; }
.msg-content h1, .msg-content h2, .msg-content h3, .msg-content h4 { margin: 1.25em 0 .55em; color: #ece9df; font-family: var(--font-editorial); line-height: 1.35; }
.msg-content h1 { font-size: 1.55em; } .msg-content h2 { font-size: 1.34em; } .msg-content h3 { font-size: 1.16em; } .msg-content h4 { font-size: 1.04em; }
.msg-content ul, .msg-content ol { margin: .45em 0 1em; padding-left: 1.55em; }
.msg-content li { margin: .2em 0; }
.msg-content a { color: #d6bd8f; text-decoration-color: rgba(214,189,143,.48); text-underline-offset: 3px; }
.msg-content code { padding: .12em .36em; border: 1px solid rgba(116,136,115,.2); border-radius: 5px; background: #11130f; color: #d9d4c6; font: .88em/1.45 var(--font-mono); }
.msg-content pre { margin: .8em 0 1.1em; padding: 13px 15px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; background: #11130f; }
.msg-content pre code { padding: 0; border: 0; background: transparent; white-space: pre; }
.msg-content blockquote { margin: .7em 0 1em; padding: .2em 0 .2em 13px; border-left: 2px solid var(--botanical); color: var(--text-secondary); white-space: pre-wrap; }
.msg-content hr { height: 1px; margin: 1.2em 0; border: 0; background: var(--border); }
.message.user .msg-content { padding: 12px 15px; border: 1px solid rgba(195,164,108,.16); border-radius: 16px 16px 4px 16px; background: rgba(195,164,108,.075); color: #ddd7c8; }
.message img { display: block; max-width: 100%; margin-top: 14px; border-radius: 10px; border: 1px solid var(--border); }
.attachment-list { max-width: 760px; margin-top: 13px; display: grid; grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap: 8px; }
.attachment-card { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: rgba(232,228,215,.025); }
.attachment-card-preview { min-width: 0; min-height: 72px; display: grid; grid-template-columns: 76px minmax(0,1fr); align-items: center; gap: 11px; padding: 7px; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.attachment-card-preview:hover { background: rgba(232,228,215,.04); }
.attachment-card-visual { position: relative; width: 76px; height: 58px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(116,136,115,.22); border-radius: 8px; background: #11130f; }
.attachment-thumbnail { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; display: block; margin: 0; border: 0; border-radius: 0; object-fit: cover; }
.attachment-file-icon { color: var(--brass); font: 650 10px/1 var(--font-mono); letter-spacing: .04em; }
.attachment-card-copy { min-width: 0; display: block; }
.attachment-card-copy strong { display: block; overflow: hidden; color: var(--text-primary); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.attachment-card-copy small { display: block; margin-top: 5px; overflow: hidden; color: var(--text-faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-card-download { min-width: 52px; padding: 0 10px; border: 0; border-left: 1px solid var(--border); background: transparent; color: var(--brass); font-size: 10px; cursor: pointer; }
.attachment-card-download:hover { background: rgba(195,164,108,.08); }
.attachment-card.thumbnail-unavailable .attachment-card-visual::after { content: "无法显示"; color: var(--text-faint); font-size: 9px; }

.activity-block { width: 100%; margin: 5px 0 2px; padding: 0 4px 18px; border-bottom: 1px solid rgba(56,60,50,.4); }
.activity-toggle { min-height: 30px; display: inline-flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; color: #676c61; font-size: 11px; cursor: pointer; }
.activity-toggle:hover { color: var(--text-secondary); }
.activity-chevron { display: inline-block; color: var(--botanical); font-size: 18px; line-height: 1; transform: rotate(0deg); transition: transform 140ms ease-out; }
.activity-block.open .activity-chevron { transform: rotate(90deg); }
.activity-items { display: none; margin: 6px 0 0 7px; padding-left: 14px; border-left: 1px solid rgba(116,136,115,.24); }
.activity-block.open .activity-items { display: grid; gap: 0; }
.activity-item { min-width: 0; min-height: 34px; display: grid; grid-template-columns: 24px minmax(0,1fr) auto; align-items: start; column-gap: 7px; padding: 7px 0; border-bottom: 1px solid rgba(56,60,50,.34); color: #777c70; font-size: 11.5px; line-height: 1.55; }
.activity-item:last-child { border-bottom: 0; }
.activity-label { color: #666c61; font: 600 11px/1.4 var(--font-mono); }
.activity-copy { min-width: 0; display: grid; gap: 3px; }
.activity-step-title { color: #858a7d; font-size: 10px; font-weight: 650; }
.activity-text { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.activity-command .activity-text { padding: 5px 7px; border: 1px solid rgba(116,136,115,.16); border-radius: 6px; background: rgba(10,11,9,.3); color: #8d9286; font-family: var(--font-mono); font-size: 10.5px; }
.activity-command.failed .activity-step-title, .activity-file.failed .activity-step-title { color: #c98e88; }
.work-process-block .activity-toggle { color: #8a8f82; }
.work-process-block .activity-items { border-left-color: rgba(195,164,108,.2); }
.work-process-block .activity-item { color: #85897e; }
.work-process-block .activity-text { white-space: pre-wrap; }
.work-process-block .activity-update .activity-step-title,
.work-process-block .activity-reasoning .activity-step-title { color: #b9bcae; }
.activity-item.approval { color: #d9c19b; }
.activity-item.error { color: #d99a94; }
.activity-review { align-self: center; border: 0; background: transparent; color: var(--brass); font-size: 11px; cursor: pointer; }
.activity-overflow { padding: 5px 0; color: #62675d; font-size: 10.5px; }
.approval-card { padding: 10px 11px; border: 1px solid rgba(195,164,108,.42); border-left-width: 2px; border-radius: 8px; background: rgba(195,164,108,.045); font-family: var(--font-ui); }

.composer-anchor { padding: 10px max(18px, calc((100% - 900px) / 2)) max(18px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg-base) 68%, rgba(23,25,20,0)); z-index: 15; }
.inline-approvals { display: grid; gap: 7px; margin-bottom: 8px; }
.inline-approval-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.inline-approval-card .list-copy { min-width: 0; display: grid; gap: 3px; }
.inline-approval-card .list-copy strong { color: #e4d1af; font-size: 12px; }
.inline-approval-card .list-copy small { overflow: hidden; color: var(--text-secondary); font: 10.5px/1.45 var(--font-mono); text-overflow: ellipsis; white-space: nowrap; }
.inline-approval-card .button { min-height: 32px; padding: 0 11px; font-size: 11px; }
.composer-panel { border: 1px solid rgba(195,164,108,.24); border-radius: 16px; background: var(--bg-surface); box-shadow: var(--shadow-floating); overflow: hidden; transition: border-color 150ms ease-out; }
.composer-panel:focus-within { border-color: rgba(195,164,108,.72); }
.composer-meta { min-height: 38px; padding: 10px 14px 0; display: flex; align-items: center; gap: 10px; }
.composer-meta label { color: var(--text-faint); font-size: 11px; }
.select-wrap { position: relative; min-width: 0; max-width: 360px; }
.select-wrap::after { content: "⌄"; position: absolute; right: 8px; top: 50%; transform: translateY(-54%); pointer-events: none; color: var(--brass); }
.select-model { max-width: 100%; height: 30px; padding: 0 27px 0 9px; appearance: none; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elevated); color: var(--text-primary); font-size: 12px; }
.composer-attachments { display: flex; gap: 7px; padding: 8px 14px 3px; overflow-x: auto; overscroll-behavior-x: contain; }
.attachment-card.compact { min-width: 230px; max-width: 310px; flex: 0 0 auto; }
.attachment-card.compact .attachment-card-preview { min-height: 58px; grid-template-columns: 58px minmax(0,1fr); gap: 9px; padding: 5px; }
.attachment-card.compact .attachment-card-visual { width: 58px; height: 46px; border-radius: 7px; }
.composer-panel textarea { display: block; width: 100%; min-height: 64px; max-height: 220px; resize: none; overflow-y: auto; border: 0; outline: 0; padding: 12px 16px 8px; background: transparent; color: var(--text-primary); line-height: 1.55; }
.composer-panel textarea::placeholder { color: #777b6e; }
.composer-actions { min-height: 48px; padding: 3px 8px 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-tools, .send-actions { display: flex; align-items: center; gap: 8px; }
.composer-hint { color: var(--text-faint); font-size: 10px; }

.permission-mode-button { min-height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--border); border-radius: 9px; background: rgba(232,228,215,.025); color: var(--text-secondary); cursor: pointer; font-size: 11px; }
.permission-mode-button:hover, .permission-mode-button[aria-expanded="true"] { border-color: rgba(195,164,108,.42); color: var(--text-primary); background: rgba(195,164,108,.06); }
.permission-mode-button[data-mode="full"] { border-color: rgba(215,113,58,.52); color: #e38b55; }
.permission-mode-icon { color: var(--brass); }
.permission-mode-button[data-mode="full"] .permission-mode-icon { color: #e36f37; }
.permission-mode-menu { position: fixed; z-index: 185; width: min(390px,calc(100vw - 24px)); padding: 8px; border: 1px solid #464b3e; border-radius: 14px; background: #262823; box-shadow: 0 20px 60px rgba(0,0,0,.52); }
.permission-mode-menu > button { width: 100%; min-height: 68px; display: grid; grid-template-columns: 34px minmax(0,1fr) 22px; align-items: center; gap: 8px; padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--text-secondary); cursor: pointer; text-align: left; }
.permission-mode-menu > button:hover { background: rgba(232,228,215,.045); color: var(--text-primary); }
.permission-mode-menu > button[aria-checked="true"] { background: rgba(195,164,108,.07); color: var(--text-primary); }
.permission-mode-menu > button[aria-checked="true"]::after { content: "✓"; color: var(--brass); font-size: 17px; }
.permission-mode-menu > button[data-permission-mode="full"] { color: #d98355; }
.permission-option-icon { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; font-family: var(--font-mono); }
.permission-mode-menu strong, .permission-mode-menu small { display: block; }
.permission-mode-menu strong { font-size: 13px; font-weight: 650; }
.permission-mode-menu small { margin-top: 3px; color: var(--text-faint); font-size: 10.5px; line-height: 1.4; }

.button { min-height: 38px; border: 1px solid var(--border); border-radius: 9px; padding: 0 14px; background: var(--bg-elevated); color: var(--text-primary); cursor: pointer; transition: 140ms ease-out; }
.button:hover:not(:disabled) { border-color: #4c5144; background: var(--bg-hover); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button.primary { border-color: rgba(195,164,108,.58); background: rgba(195,164,108,.12); color: #ead8b8; }
.button.primary:hover:not(:disabled) { border-color: var(--brass); background: rgba(195,164,108,.18); }
.button.secondary { color: var(--text-secondary); background: transparent; }
.button.danger { border-color: rgba(192,109,101,.48); background: rgba(192,109,101,.1); color: #e5aaa4; }
.login-recovery { margin-top: 13px; border-top: 1px solid var(--border); padding-top: 12px; }
.login-recovery summary { color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.login-recovery .muted { margin: 10px 0; font-size: 11px; }
.send-button { min-width: 92px; border-color: var(--brass); background: var(--brass); color: #202119; font-weight: 700; }
.send-button:hover:not(:disabled) { background: var(--brass-hover); border-color: var(--brass-hover); }

.file-preview-drawer { min-width: 0; min-height: 0; height: 100%; position: relative; z-index: 30; display: none; grid-template-rows: 68px minmax(0,1fr); overflow: hidden; border-left: 1px solid #454a3d; background: #1b1d18; box-shadow: -12px 0 36px rgba(0,0,0,.24); }
body.preview-open .file-preview-drawer.open { display: grid; }
.file-preview-header { min-width: 0; padding: 0 13px 0 18px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.file-preview-title-stack { min-width: 0; }
.file-preview-title-stack .eyebrow { margin-bottom: 2px; color: var(--text-faint); }
.file-preview-title-stack h2 { margin: 0; overflow: hidden; font-size: 14px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.file-preview-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
.file-preview-actions .button { min-height: 34px; padding: 0 11px; font-size: 11px; }
.pdf-page-controls { min-height: 38px; display: flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.pdf-page-controls .icon-button { width: 31px; height: 31px; border-color: transparent; font-size: 20px; }
.pdf-page-position { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font: 11px/1 var(--font-mono); }
.pdf-page-position input { width: 42px; height: 30px; padding: 0 5px; border: 1px solid var(--border); border-radius: 6px; outline: 0; background: #11130f; color: var(--text-primary); text-align: center; font: 12px/1 var(--font-mono); appearance: textfield; }
.pdf-page-position input::-webkit-inner-spin-button, .pdf-page-position input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.pdf-page-position input:focus { border-color: rgba(195,164,108,.65); }
.file-preview-body { min-width: 0; min-height: 0; overflow: auto; display: grid; place-items: stretch; background: #11130f; }
.file-preview-text { width: 100%; min-height: 100%; margin: 0; padding: 24px; overflow: auto; color: #c4c6ba; background: #151712; font: 12.5px/1.68 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.file-preview-image { align-self: start; max-width: calc(100% - 40px); max-height: calc(100vh - 108px); margin: 20px auto; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #0d0e0c; }
.file-preview-frame { width: 100%; height: 100%; border: 0; background: #e8e8e8; }
.pdf-single-viewer { width: 100%; height: 100%; min-width: 0; min-height: 0; position: relative; overflow: auto; overscroll-behavior: contain; padding: 10px; background: #242622; }
.pdf-page-list { width: 100%; min-width: 0; display: grid; gap: 16px; }
.pdf-page-slot { width: 100%; min-width: 0; display: flex; align-items: flex-start; justify-content: center; background: #fff; box-shadow: 0 8px 34px rgba(0,0,0,.34); content-visibility: auto; contain-intrinsic-size: auto 1200px; }
.pdf-page-slot.is-loading { background: #f4f3ef; }
.pdf-page-canvas { display: block; width: 100%; height: auto; background: #fff; }
.pdf-page-error { width: 100%; padding: 24px; color: #7e352d; background: #f8ebe8; text-align: center; font-size: 13px; }
.pdf-render-status { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--text-secondary); background: rgba(17,19,15,.62); font-size: 12px; }
.pdf-render-status.hidden { display: none; }
.file-preview-backdrop { display: none; }

.modal-overlay { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(7,8,6,.76); }
.modal-overlay.active { display: flex; }
.modal-content { width: min(620px,100%); max-height: min(82vh,780px); display: flex; flex-direction: column; border: 1px solid #464b3e; border-radius: 14px; background: var(--bg-surface); box-shadow: 0 24px 70px rgba(0,0,0,.5); overflow: hidden; }
.modal-wide { width: min(780px,100%); }
.modal-header { min-height: 72px; padding: 16px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font: 500 22px/1.25 var(--font-editorial); }
.plugin-view-tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid rgba(56,60,50,.7); }
.plugin-view-tab { min-height: 38px; position: relative; padding: 0 12px 9px; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.plugin-view-tab::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 2px; border-radius: 2px; background: transparent; }
.plugin-view-tab:hover { color: var(--text-secondary); }
.plugin-view-tab.active { color: var(--text-primary); }
.plugin-view-tab.active::after { background: var(--brass); }
.plugin-view-tab span { display: inline-grid; min-width: 18px; height: 18px; margin-left: 5px; place-items: center; border-radius: 9px; background: rgba(232,228,215,.06); color: var(--text-faint); font-size: 9px; }
.modal-toolbar { padding: 12px 18px; display: flex; gap: 10px; border-bottom: 1px solid rgba(56,60,50,.7); }
.modal-toolbar input { min-width: 0; flex: 1; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-base); color: var(--text-primary); }
.modal-body { min-height: 110px; overflow-y: auto; padding: 14px 18px 20px; }

.list-item, .plugin-card { padding: 14px 2px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid rgba(56,60,50,.66); }
.list-item:last-child, .plugin-card:last-child { border-bottom: 0; }
.list-copy, .plugin-copy { min-width: 0; }
.list-copy strong, .plugin-copy strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.list-copy small, .plugin-copy small { display: block; margin-top: 4px; color: var(--text-faint); line-height: 1.45; }
.list-actions, .plugin-actions { flex: 0 0 auto; display: flex; gap: 8px; }
.plugin-badge { display: inline-block; margin-left: 7px; padding: 2px 6px; border: 1px solid rgba(116,136,115,.45); border-radius: 999px; color: #9eb29d; font-size: 9px; vertical-align: 2px; }
.empty-panel, .loading-panel, .error-panel { padding: 34px 12px; text-align: center; color: var(--text-secondary); line-height: 1.65; }
.empty-panel .button { display: block; margin: 16px auto 0; }
.error-panel { color: #d99a94; }

.settings-body { display: grid; gap: 16px; }
.settings-section { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: rgba(23,25,20,.42); }
.settings-section h4 { margin: 0 0 8px; }
.danger-zone { border-color: rgba(192,109,101,.3); }
.device-code-result { margin-top: 12px; color: var(--text-secondary); line-height: 1.6; }
.device-code-result code { display: inline-block; margin-top: 8px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; font: 14px var(--font-mono); color: var(--brass); }

.login-view { width: 100%; height: 100%; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login-view::before, .login-view::after { content: ""; position: absolute; width: 44vw; height: 44vw; max-width: 660px; max-height: 660px; border: 1px solid rgba(195,164,108,.08); border-radius: 50%; }
.login-view::before { left: -22vw; bottom: -28vw; }
.login-view::after { right: -24vw; top: -29vw; border-color: rgba(116,136,115,.1); }
.login-ornament { position: absolute; width: min(82vw,720px); height: 1px; top: 20%; background: linear-gradient(90deg,transparent,rgba(195,164,108,.3),transparent); }
.login-panel { width: min(420px,100%); position: relative; z-index: 1; padding: 36px; border: 1px solid var(--border); border-radius: 14px; background: rgba(29,32,26,.94); box-shadow: var(--shadow-floating); }
.login-panel h1 { margin: 4px 0 10px; font: 500 36px/1.2 var(--font-editorial); }
.login-intro { margin: 0 0 30px; color: var(--text-secondary); line-height: 1.65; }
.identity-notice, .modal-note { color: var(--text-secondary); font-size: .78rem; line-height: 1.55; }
.identity-notice { margin: 4px 0 0; }
.modal-note { margin: 0; padding: 0 24px 8px; }
.field-label { display: block; margin-bottom: 7px; color: var(--text-faint); font-size: 11px; }
.login-panel input[type="password"], .login-panel input[type="text"] { width: 100%; height: 46px; border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; background: var(--bg-base); color: var(--text-primary); }
.trust-row { margin: 14px 0 20px; display: flex; align-items: center; gap: 9px; color: var(--text-secondary); font-size: 12px; }
.trust-row input { accent-color: var(--brass); }
.inline-error { margin: 14px 0 0; color: #e0a19b; font-size: 12px; line-height: 1.5; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 360px; padding: 11px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-elevated); box-shadow: var(--shadow-floating); color: var(--text-primary); font-size: 12px; animation: toast-in 160ms ease-out; }
.toast.error { border-color: rgba(192,109,101,.5); color: #e3a59f; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.drop-overlay { position: fixed; inset: 0; z-index: 190; display: grid; place-items: center; padding: 24px; pointer-events: none; visibility: hidden; opacity: 0; background: rgba(8,10,7,.82); backdrop-filter: blur(8px); transition: opacity 120ms ease-out, visibility 120ms; }
.drop-overlay.active { visibility: visible; opacity: 1; }
.drop-overlay-card { width: min(460px,calc(100vw - 40px)); min-height: 220px; display: grid; place-items: center; align-content: center; gap: 10px; border: 1px dashed rgba(224,190,126,.75); border-radius: 20px; background: rgba(29,32,26,.92); box-shadow: 0 24px 80px rgba(0,0,0,.55); text-align: center; }
.drop-overlay-icon { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid rgba(195,164,108,.55); border-radius: 50%; color: var(--brass); font-size: 30px; font-weight: 300; }
.drop-overlay-card strong { color: #eee7d8; font: 500 21px/1.3 var(--font-editorial); }
.drop-overlay-card small { color: var(--text-faint); font-size: 12px; }

.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: inline-grid !important; }
  .desktop-only { display: none !important; }
  .app-shell { display: block; height: 100dvh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw,320px); transform: translateX(-102%); transition: transform 170ms ease-out; box-shadow: 12px 0 40px rgba(0,0,0,.42); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(5,6,4,.65); opacity: 0; visibility: hidden; transition: 170ms ease-out; }
  .sidebar-backdrop.active { opacity: 1; visibility: visible; }
  .brand-row { padding-right: 10px; }
  .brand-copy { flex: 1; }
  .main-content { height: 100dvh; min-height: 0; grid-template-rows: 60px minmax(0,1fr) auto; }
  .top-bar { height: 60px; padding: 0 10px; }
  .top-bar-context { min-width: 0; flex: 1; gap: 5px; }
  .title-stack { min-width: 0; }
  .title-stack .eyebrow, .connection-label span:last-child { display: none; }
  .title-stack h2 { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .top-bar-actions { gap: 4px; }
  .chat-scroll { padding: 25px 17px 20px; }
  .welcome-state { margin-top: 15vh; }
  .welcome-state h1 { font-size: 32px; }
  .message { padding: 20px 1px 23px; }
  .message.user { width: 88%; padding: 14px 0 18px; }
  .msg-content { font-size: 15px; line-height: 1.72; }
  .activity-block { padding: 0 1px 14px; }
  .activity-item { grid-template-columns: 24px minmax(0,1fr); }
  .activity-review { grid-column: 2; justify-self: start; }
  .composer-anchor { padding: 0; }
  .inline-approvals { margin: 0; padding: 0 8px 7px; background: var(--bg-base); }
  .inline-approval-card { grid-template-columns: minmax(0,1fr); gap: 8px; }
  .inline-approval-card .list-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .composer-panel { width: 100%; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 16px 16px 0 0; }
  .composer-meta { padding: 8px 11px 0; }
  .composer-meta label, .composer-hint { display: none; }
  .select-wrap { max-width: calc(100vw - 70px); }
  .composer-panel textarea { min-height: 56px; padding: 10px 12px 6px; }
  .composer-actions { padding: 2px 7px max(7px,env(safe-area-inset-bottom)); }
  .permission-mode-button { width: 44px; padding: 0; justify-content: center; }
  .permission-mode-button #permission-mode-label { display: none; }
  .button { min-height: 42px; }
  .send-button { min-width: 78px; }
  .icon-button { width: 44px; height: 44px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-content, .modal-wide { width: 100%; max-height: 88vh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .modal-header { min-height: 66px; padding: 13px 14px; }
  .modal-toolbar { padding: 10px 14px; }
  .plugin-view-tabs { padding-right: 14px; padding-left: 14px; }
  .modal-body { padding: 10px 14px max(18px,env(safe-area-inset-bottom)); }
  .list-item, .plugin-card { align-items: flex-start; flex-direction: column; gap: 10px; }
  .list-actions, .plugin-actions { width: 100%; }
  .list-actions .button, .plugin-actions .button { flex: 1; }
  .login-panel { padding: 28px 22px; }
  .toast-region { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  .file-preview-drawer { position: fixed; inset: 0; z-index: 170; width: 100%; height: 100dvh; grid-template-rows: 60px minmax(0,1fr); border-left: 0; box-shadow: none; }
  body.preview-open .file-preview-drawer.open { display: grid; }
  .file-preview-header { padding: 0 8px 0 12px; gap: 6px; }
  .file-preview-title-stack .eyebrow { display: none; }
  .file-preview-title-stack h2 { max-width: 105px; font-size: 11px; }
  .pdf-page-controls { gap: 1px; }
  .pdf-page-controls .icon-button { width: 28px; height: 36px; }
  .pdf-page-position { gap: 4px; font-size: 10px; }
  .pdf-page-position input { width: 34px; height: 28px; }
  .file-preview-actions { gap: 1px; }
  .file-preview-actions .button { min-height: 36px; padding: 0 8px; }
  .pdf-single-viewer { padding: 6px; }
  .pdf-page-list { gap: 10px; }
}

@media (min-width: 769px) {
  body:not(.sidebar-collapsed) #toggle-sidebar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
