:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #fff;
  --ink: #242624;
  --muted: #6e746f;
  --faint: #9aa0a8;
  --accent: #28664d;
  --accent-strong: #1f523d;
  --accent-soft: #e9f3ed;
  --accent-line: #cfe3d8;
  --fill: #eef2ed;
  --fill-2: #f2f4f0;
  --tint: #eef2ed;
  --line: #e8eae5;
  --user-bubble: #e9ece5;
  --line-strong: #dfe3e0;
  --danger: #a94a42;
  --danger-soft: #fbeeec;
  --radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 44px; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .48; cursor: not-allowed; }
input, textarea, select { min-width: 0; }
[hidden] { display: none !important; }
svg { display: block; }
.icon { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; }
.icon-sm { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.app { width: 100%; max-width: 820px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; position: relative; }
.topbar { flex: none; min-height: 62px; padding: 8px 10px; display: flex; align-items: center; gap: 4px; }
.icon-button { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--ink); background: transparent; transition: background .15s; }
.icon-button:hover { background: #eef2ed; }
/* Workspace sits centred between the history button and the single new-chat entry. */
.workspace-button { flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 6px; border-radius: 12px; font-size: 15px; font-weight: 600; text-align: center; background: transparent; }
.workspace-button:hover { background: #eef2ed; }
.workspace-button > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.workspace-button .icon { color: var(--faint); }
#new { color: var(--accent); }

/* Chat content sits directly on the page background; no large white card. */
.conversation { flex: 1; min-height: 0; min-width: 0; margin: 0; padding: 4px 18px 20px; background: transparent; border-radius: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.messages { max-width: 760px; margin: 0 auto; padding: 8px 0 16px; }
.welcome { max-width: 760px; margin: 0 auto; padding: 18vh 12px 40px; text-align: center; }
.welcome-mark { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 18px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.welcome-mark .icon { width: 26px; height: 26px; }
.welcome h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.welcome p { margin: 0; color: var(--muted); font-size: 13px; }

.message { display: flex; gap: 10px; margin: 22px 0; min-width: 0; }
.message.user { justify-content: flex-end; }
.message.user .message-body { flex: 0 1 auto; max-width: 86%; padding: 10px 14px; background: var(--user-bubble); border-radius: 18px 18px 6px 18px; white-space: pre-wrap; word-break: break-word; }
.message.assistant .message-body { flex: 1; min-width: 0; font-size: 16px; line-height: 1.75; }
.message.error { padding: 12px 14px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.assistant-avatar { flex: none; width: 28px; height: 28px; margin-top: 3px; border-radius: 10px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.assistant-avatar .icon { width: 16px; height: 16px; }
.typing { color: var(--muted); font-size: 13px; }

.md { min-width: 0; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .65em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.3em 0 .5em; line-height: 1.35; font-weight: 600; }
.md h1 { font-size: 21px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 16.5px; }
.md h4 { font-size: 15px; }
.md ul, .md ol { margin: .6em 0; padding-left: 1.4em; }
.md li { margin: .28em 0; }
.md li > p { margin: .3em 0; }
.md a { color: var(--accent); text-underline-offset: 2px; }
.md blockquote { margin: .8em 0; padding: .1em 0 .1em 12px; border-left: 2px solid var(--accent-line); color: var(--muted); }
.md code { padding: 1px 5px; border-radius: 6px; background: #f1f1ee; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 13.5px; }
.md pre { max-width: 100%; margin: .8em 0; padding: 12px 14px; border-radius: 12px; background: #f6f6f3; overflow-x: auto; line-height: 1.6; }
.md pre code { padding: 0; background: none; font-size: 12.5px; white-space: pre; }
.md .table-wrap { max-width: 100%; margin: .9em 0; overflow-x: auto; }
.md table { border-collapse: collapse; min-width: 100%; font-size: 13.5px; }
.md th, .md td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { font-weight: 600; background: var(--fill-2); }
.md hr { margin: 1.2em 0; border: 0; border-top: 1px solid var(--line); }
.md img { max-width: 100%; height: auto; border-radius: 10px; }

.tool-group { max-width: 100%; margin: 14px 0; padding: 0; border-radius: 14px; background: #fafaf8; overflow: hidden; }
.tool-summary { min-height: 48px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.tool-summary::-webkit-details-marker { display: none; }
.tool-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.tool-icon .icon { width: 15px; height: 15px; }
.tool-label { font-size: 13.5px; font-weight: 600; }
.tool-count { color: var(--muted); font-size: 11.5px; }
.tool-state { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.tool-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #a7adb6; }
.tool-state.running { color: var(--accent); }
.tool-state.running::before { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.tool-state.failed { color: var(--danger); }
.tool-state.failed::before { background: var(--danger); }
.tool-state.completed::before { background: #5b8a68; }
.tool-chevron { flex: none; color: var(--faint); transition: transform .18s; }
.tool-chevron .icon { width: 15px; height: 15px; }
.tool-group[open] .tool-chevron { transform: rotate(90deg); }
.tool-body { padding: 0 12px 10px; }
.tool-item { padding: 10px 0; border-top: 1px solid #efefeb; }
.tool-item-head { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.tool-source { flex: none; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; line-height: 1.7; }
.tool-name { min-width: 0; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.tool-status { color: var(--muted); font-size: 11.5px; }
.tool-time { margin-left: auto; color: var(--faint); font-size: 11px; white-space: nowrap; }
.tool-detail { display: block; max-width: 100%; margin: 7px 0 0; padding: 8px 10px; border-radius: 9px; background: #f2f2ee; color: #4d525a; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 160px; overflow-y: auto; }
.tool-summary-text { margin: 8px 0 0; padding: 8px 10px; border-radius: 9px; background: var(--surface); color: #555a62; font-size: 12.5px; line-height: 1.6; overflow-wrap: anywhere; }
.step-list { margin: 6px 0 0; padding: 0; list-style: none; }
.step { margin: 3px 0; padding: 2px 0 2px 10px; border-left: 2px solid #dfe5ee; }
.step-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.step-name { font-size: 12.5px; }
.step-status { color: var(--faint); font-size: 10.5px; }
.step-detail { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; overflow-wrap: anywhere; }
.raw { margin-top: 8px; }
.raw summary { color: var(--faint); font-size: 11.5px; cursor: pointer; list-style: none; }
.raw summary::-webkit-details-marker { display: none; }
.raw summary::before { content: "› "; }
.raw pre { max-height: 240px; margin: 6px 0 0; padding: 9px 10px; border-radius: 9px; background: #f2f2ee; color: #4d525a; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; line-height: 1.55; white-space: pre; overflow: auto; }

.composer-area { flex: none; padding: 4px 12px calc(10px + env(safe-area-inset-bottom)); }
.activity { max-width: 760px; margin: 0 auto 6px; padding: 0 6px; display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 12.5px; }
.activity::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.4s ease-in-out infinite; }
.composer { max-width: 760px; margin: 0 auto; padding: 10px 12px 8px; border-radius: var(--radius); background: var(--fill); transition: box-shadow .15s; }
.composer:focus-within { box-shadow: 0 0 0 2px rgba(40, 102, 77, .16); }
#prompt { display: block; width: 100%; min-height: 27px; max-height: 140px; padding: 3px 2px; border: 0; background: transparent; color: var(--ink); font-size: 16px; line-height: 1.55; resize: none; outline: none; }
#prompt::placeholder { color: #8f949b; }
.composer-row { margin-top: 2px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-button { min-width: 0; min-height: 44px; max-width: 62%; padding: 0 6px; display: flex; align-items: center; gap: 3px; border-radius: 10px; color: #5f6670; font-size: 13px; background: transparent; }
.model-button:hover { background: #e8ece5; }
.model-button > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.send-button, .stop-button { width: 44px; height: 44px; min-height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; }
.send-button { background: var(--accent); color: #fff; }
.send-button:hover { background: var(--accent-strong); }
.stop-button { background: var(--surface); color: #4d525a; border: 1px solid #deded8; }
.stop-button .icon { width: 18px; height: 18px; }
.composer.is-stop .send-button, .composer:not(.is-stop) .stop-button { display: none; }

.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(32, 33, 36, .32); opacity: 0; transition: opacity .22s ease; }
.backdrop.open { opacity: 1; }
#sheet-backdrop { z-index: 70; }
.drawer { position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: 84vw; max-width: 340px; display: flex; flex-direction: column; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; box-shadow: 12px 0 40px rgba(32, 33, 36, .12); transform: translateX(-102%); transition: transform .26s cubic-bezier(.22, .8, .3, 1); padding-top: env(safe-area-inset-top); }
.drawer.open { transform: translateX(0); }
.drawer-head { flex: none; min-height: 60px; padding: 8px 12px 4px 20px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.scope-button { flex: none; margin: 2px 16px 0; padding: 0 4px; min-height: 44px; display: flex; align-items: center; gap: 6px; border-radius: 10px; color: var(--muted); font-size: 12.5px; text-align: left; }
.scope-button span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.scope-button:hover { color: var(--ink); background: #f6f6f2; }
.search-field { flex: none; min-height: 44px; margin: 6px 16px 10px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border-radius: 12px; background: #f4f4f1; color: var(--faint); }
.search-field input { flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 16px; outline: none; }
.search-field input::placeholder { color: #92979e; }
.session-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; }
.session-list-inner { display: flex; flex-direction: column; }
.history-group { margin: 10px 0; }
.history-group-title { margin: 8px 10px 4px; color: var(--faint); font-size: 11.5px; }
.history-item { width: 100%; min-height: 48px; padding: 3px 4px; display: flex; align-items: center; gap: 2px; border-radius: 12px; }
.history-item:hover { background: #f6f6f2; }
.history-item.selected { background: var(--accent-soft); }
.history-open { flex: 1; min-width: 0; min-height: 44px; padding: 7px 8px; display: flex; align-items: center; gap: 8px; border-radius: 10px; text-align: left; }
.history-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; }
.history-sub { flex: none; max-width: 42%; color: var(--faint); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.history-more { flex: none; width: 44px; color: var(--faint); border-radius: 10px; }
.history-more:hover, .history-more[aria-expanded="true"] { background: #e9e9e4; color: var(--ink); }
.history-more .icon { margin: 0 auto; }
.running-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.drawer-foot { flex: none; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); }
.drawer-action { width: 100%; padding: 0 12px; display: flex; align-items: center; gap: 10px; border-radius: 12px; background: #f6f6f2; font-size: 14px; text-align: left; }
.drawer-action:hover { background: #efefea; }
.drawer-action span { flex: 1; }
.drawer-action-end { color: var(--faint); }
.empty-state, .list-empty, .loading-state { padding: 28px 16px; color: var(--faint); font-size: 13px; text-align: center; }
.loading-state { display: flex; flex-direction: column; align-items: center; }
.spinner { width: 18px; height: 18px; margin: 0 auto 10px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: #ebede8; }
.tabs .tab { flex: 1; min-height: 44px; padding: 8px 4px; border-radius: 9px; color: var(--muted); font-size: 13px; }
.tabs .tab.selected { background: var(--surface); color: var(--ink); box-shadow: 0 1px 5px rgba(0, 0, 0, .03); }
#history-tabs { flex: none; margin: 0 16px 4px; }
.popover { position: fixed; z-index: 66; width: min(250px, calc(100vw - 24px)); padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 12px 36px rgba(32, 33, 36, .18); }
.popover-title { margin: 4px 10px 6px; color: var(--faint); font-size: 11.5px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-item { width: 100%; min-height: 46px; padding: 0 10px; display: flex; align-items: center; gap: 10px; border-radius: 10px; font-size: 14px; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: #f4f4f1; }
.menu-item + .menu-item { margin-top: 2px; }
.menu-item .icon { color: var(--faint); }
.menu-danger { color: var(--danger); }
.menu-danger .icon { color: var(--danger); }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; max-height: 90dvh; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -10px 40px rgba(32, 33, 36, .14); transform: translateY(102%); transition: transform .28s cubic-bezier(.22, .8, .3, 1), opacity .2s ease; padding-bottom: env(safe-area-inset-bottom); }
.sheet.open { transform: translateY(0); }
.sheet-tall { height: 90dvh; }
.sheet-head { position: sticky; top: 0; z-index: 2; flex: none; min-height: 56px; padding: 6px 10px 4px 12px; display: flex; align-items: center; gap: 6px; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.sheet-head h2 { flex: 1; min-width: 0; margin: 0 4px; font-size: 17px; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 2px 18px 18px; }
form.sheet-body { display: block; }
.sheet-foot { flex: none; padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid #f1f1ed; }
.sheet-label { margin: 16px 0 7px; color: var(--faint); font-size: 11.5px; letter-spacing: .02em; }
.sheet-label:first-child { margin-top: 4px; }
.sheet-note { margin: 16px 2px 4px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.help-text { margin: 6px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.error-text { margin: 8px 0; color: var(--danger); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.error-text:empty { display: none; }
.wide-button { width: 100%; min-height: 48px; padding: 0 12px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.wide-button:hover { background: #dcebe2; }
.primary-button { width: 100%; min-height: 48px; padding: 0 16px; border-radius: 14px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; }
.primary-button:hover:not(:disabled) { background: var(--accent-strong); }
.secondary-button { min-height: 44px; padding: 0 16px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 13.5px; font-weight: 500; }
.danger-button { min-height: 46px; padding: 0 16px; border-radius: 14px; background: var(--danger); color: #fff; font-size: 14.5px; font-weight: 600; }
.wide-secondary { width: 100%; min-height: 46px; margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; font-size: 13.5px; }
.wide-secondary:hover:not(:disabled) { background: var(--fill-2); }
.text-button { min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; gap: 5px; border-radius: 8px; color: var(--accent); font-size: 12.5px; }
.text-button:hover { background: var(--accent-soft); }
.text-button[aria-pressed="true"] { color: var(--ink); }
.path-text { color: var(--muted); font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }
.workspace-target { padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; border-radius: 12px; background: var(--fill-2); }
.workspace-target strong { font-size: 14px; font-weight: 500; }
.scope-note { margin: 6px 0 4px; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.scope-note .tag { flex: none; }
.section-label { margin: 20px 0 8px; color: var(--muted); font-size: 12px; }
.section-label:first-child { margin-top: 4px; }

.workspace-list { display: flex; flex-direction: column; gap: 2px; }
.workspace-row { display: flex; align-items: center; gap: 2px; border-radius: 12px; }
.workspace-row.selected { background: var(--accent-soft); }
.workspace-main { flex: 1; min-width: 0; min-height: 56px; padding: 7px 6px; display: flex; align-items: center; gap: 10px; border-radius: 12px; text-align: left; }
.workspace-check { flex: none; width: 22px; height: 22px; display: grid; place-items: center; border: 1.5px solid #d3d7dc; border-radius: 50%; color: transparent; }
.workspace-check.checked { border-color: var(--accent); background: var(--accent); color: #fff; }
.workspace-check .icon { width: 12px; height: 12px; }
.workspace-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.workspace-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; font-weight: 500; }
.workspace-path { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--faint); font-size: 11px; }

.folder-tools { flex: none; padding: 0 16px 6px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.breadcrumbs { display: flex; align-items: center; gap: 1px; max-width: 100%; padding: 2px 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.breadcrumbs::-webkit-scrollbar { display: none; }
.crumb { flex: none; min-height: 36px; max-width: 42vw; padding: 0 7px; border-radius: 8px; color: var(--accent); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover { background: var(--accent-soft); }
.crumb.current { color: var(--ink); font-weight: 600; }
.crumb-sep { flex: none; color: #b9bdc3; font-size: 11px; }
.roots { display: flex; gap: 7px; max-width: 100%; padding: 2px 0; overflow-x: auto; scrollbar-width: none; }
.roots::-webkit-scrollbar { display: none; }
.root-chip { flex: none; min-height: 36px; padding: 0 12px; border-radius: 10px; background: #f4f4f1; color: #4d525a; font-size: 12.5px; white-space: nowrap; }
.root-chip.active { background: var(--accent-soft); color: var(--accent); }
.folder-tools .search-field { margin: 2px 0 0; }
.folder-list { flex: 1; min-height: 80px; overflow-y: auto; padding: 2px 10px 8px; }
.folder-row { width: 100%; min-height: 52px; padding: 7px 10px; display: flex; align-items: center; gap: 11px; border-radius: 12px; text-align: left; }
.folder-row:hover { background: #f6f6f2; }
.folder-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #f1f5fa; color: var(--accent); }
.folder-icon .icon { width: 17px; height: 17px; }
.folder-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14.5px; }
.folder-chevron { flex: none; color: var(--faint); }
.folder-chevron .icon { width: 15px; height: 15px; }
.folder-foot { display: flex; flex-direction: column; gap: 9px; }
.folder-current { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.folder-current .sheet-label { margin: 0; }
.folder-foot .error-text { margin: 0; }

.option-list { max-height: 32dvh; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; }
.model-option { width: 100%; min-height: 56px; padding: 9px 11px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid transparent; border-radius: 12px; background: #fafaf8; text-align: left; }
.model-option:hover { background: #f4f4f1; }
.model-option.selected { border-color: var(--accent-line); background: var(--accent-soft); }
.model-radio { flex: none; width: 20px; height: 20px; margin-top: 2px; display: grid; place-items: center; border: 1.5px solid #cfd6df; border-radius: 50%; color: transparent; }
.model-option.selected .model-radio { border-color: var(--accent); background: var(--accent); color: #fff; }
.model-radio .icon { width: 11px; height: 11px; }
.model-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.model-name { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.model-desc { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.segmented { display: flex; flex-wrap: wrap; gap: 7px; }
.effort-option { min-height: 44px; padding: 0 13px; border: 1px solid transparent; border-radius: 10px; background: #f4f4f1; color: #4d525a; font-size: 12.5px; }
.effort-option.selected { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.switch-row { padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row > div { min-width: 0; }
.switch-row span { font-size: 14px; }
.switch-row .help-text { margin: 2px 0 0; }
.switch { position: relative; flex: none; width: 52px; height: 32px; min-height: 32px; padding: 0; border-radius: 999px; background: #d8d8d2; transition: background .18s; }
.switch::before { content: ""; position: absolute; inset: -6px; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch:disabled { opacity: .45; }
.switch-knob { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(32, 33, 36, .18); transition: transform .18s; }
.switch[aria-checked="true"] .switch-knob { transform: translateX(20px); }
.nav-row { width: 100%; min-height: 48px; margin-top: 14px; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 12px; background: var(--fill-2); border: 1px solid var(--line); font-size: 13.5px; text-align: left; }
.nav-row:hover { background: #f1f1ed; }
.nav-row > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-row .icon { color: var(--faint); }
.usage-text { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: var(--fill-2); color: var(--muted); font-size: 12px; line-height: 1.6; }
.field { display: block; margin: 14px 0 8px; color: #5d626a; font-size: 12.5px; }
.field input, .field textarea, .field select, .login-dialog input { display: block; width: 100%; min-height: 46px; margin-top: 7px; padding: 11px 12px; border: 1px solid transparent; border-radius: 12px; background: #f6f6f2; color: var(--ink); font-size: 16px; line-height: 1.5; outline: none; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field input:focus, .field textarea:focus, .field select:focus, .login-dialog input:focus { border-color: var(--accent-line); background-color: var(--surface); box-shadow: 0 0 0 2px rgba(40, 102, 77, .14); }
.field textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #9aa0a8; }
.field-help { display: block; margin-top: 5px; color: var(--faint); font-size: 11.5px; line-height: 1.5; }
/* Advanced options: collapsed by default, opened only on request. */
.run-settings { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.run-settings[open] { padding-top: 12px; }
.run-summary { min-height: 44px; display: flex; align-items: center; gap: 8px; border-radius: 10px; color: var(--ink); font-size: 13.5px; cursor: pointer; list-style: none; }
.run-summary::-webkit-details-marker { display: none; }
.run-summary:hover { background: var(--fill-2); }
.run-summary span { flex: 1; }
.run-summary .icon { color: var(--faint); }
.run-chevron { transition: transform .18s; }
.run-settings[open] .run-chevron { transform: rotate(90deg); }
.run-body { padding-bottom: 4px; }
.run-settings.is-locked { opacity: .7; }
.composer-channel { max-width: 760px; min-height: 34px; margin: 0 auto 4px; padding: 0 8px; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
.composer-channel:empty { display: none; }
#composer-channel-name { max-width: 60%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer-channel-sep { color: var(--faint); }
#composer-channel.billing-relay #composer-channel-billing { color: #8a6420; }
#composer-channel.billing-account #composer-channel-billing { color: var(--accent); }
.quota-alert { max-width: 760px; margin: 0 auto 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; line-height: 1.6; }
.quota-alert strong { font-size: 13.5px; font-weight: 600; }
.quota-alert p { margin: 0; color: #8c5c57; }
.quota-alert-actions { margin-top: 2px; display: flex; gap: 8px; }
.quota-alert-actions .secondary-button { background: var(--surface); color: var(--danger); border: 1px solid #efd6d2; }
.field input[readonly] { color: var(--muted); background: #f1f1ee; }
.connection-row { margin-top: 22px; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #f1f1ed; }
.connection-row span { font-size: 14px; }
.connection-row .help-text { margin: 2px 0 0; }
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #c4c8ce; }
.status-dot.connected { background: #5b8a68; }
.status-dot.reconnecting { background: #c99a4a; }
.status-dot.offline { background: var(--danger); }

.profile-row { padding: 8px 0 6px; display: flex; align-items: center; gap: 12px; }
.profile-avatar { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; }
.profile-avatar .icon { width: 22px; height: 22px; }
.row-main { flex: 1; min-width: 0; display: block; }
.row-main strong { display: block; font-size: 14px; font-weight: 500; }
.row-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.row-value { flex: none; max-width: 38%; color: var(--muted); font-size: 12px; text-align: right; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-value:empty { display: none; }
.group { margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.row { width: 100%; min-height: 58px; padding: 12px 14px; display: flex; align-items: center; gap: 11px; border-radius: 0; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
button.row:hover { background: var(--fill-2); }
.row.static { cursor: default; }
.row-chevron { color: var(--faint); }
.provider-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--tint); color: #4d525a; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px; background: var(--tint); color: var(--muted); font-size: 11px; white-space: nowrap; }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: #fbf3e4; color: #8a6420; }
.tag.bad { background: var(--danger-soft); color: var(--danger); }
.note-box { padding: 12px 13px; border-radius: 12px; background: var(--tint); color: var(--muted); font-size: 12px; line-height: 1.6; }
.note-box strong { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 500; }
.note-box p, .note-box ul { margin: 0; }
.note-box:empty { display: none; }

.provider { margin: 8px 0 4px; padding: 14px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.provider + .provider { margin-top: 10px; }
.provider-head { display: flex; align-items: center; gap: 9px; }
.provider-head strong { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.provider-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.provider-meta span { min-width: 0; overflow-wrap: anywhere; }
.provider-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.provider-footer { padding-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.provider-footer .text-button { min-height: 44px; margin: 0 -6px; }
.provider-list { display: flex; flex-direction: column; }
.selected-frame { border-color: var(--accent-line); background: #fbfcfe; }
.check-list { margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--ink); font-size: 12px; }
.check-list li .icon { width: 14px; height: 14px; color: #5b8a68; }
.check-list li.miss { color: var(--danger); }
.check-list li.miss .icon { color: var(--danger); }
.check-list li.pending { color: var(--muted); }
.check-list li.pending .icon { color: var(--faint); }
.device-login { padding-top: 12px; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); }
.device-login .section-label { margin: 0 0 2px; }
.device-login .help-text { margin: 0; }
.login-code-area { margin-top: 6px; padding: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; border-radius: 12px; background: var(--fill-2); border: 1px solid var(--line); }
.login-code-area .sheet-label { margin: 0; }
.login-code { padding: 2px 0; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 22px; font-weight: 600; letter-spacing: .12em; word-break: break-all; user-select: all; }
.login-code-area .help-text { margin: 0; }

.select-stack { display: flex; flex-direction: column; gap: 9px; }
.choice { width: 100%; min-height: 64px; padding: 12px 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; }
.choice:hover { background: var(--fill-2); }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice .row-main strong { font-size: 14px; font-weight: 500; }
.radio { flex: none; width: 18px; height: 18px; border: 1px solid #b9c0c8; border-radius: 50%; }
.choice.selected .radio { border: 5px solid var(--accent); }
#switch-explain { margin-top: 14px; }

.skills-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.skills-list:empty { display: none; }
.skill-group .section-label { margin: 14px 2px 8px; }
.skill-group:first-child .section-label { margin-top: 6px; }
.text-slot:empty { display: none; }
.skill-item { width: 100%; padding: 14px; display: flex; align-items: flex-start; gap: 12px; text-align: left; background: var(--surface); }
.skill-item + .skill-item { border-top: 1px solid var(--line); }
.skill-item:hover { background: var(--fill-2); }
.skill-item .row-main { min-width: 0; }
.skill-item strong { display: block; font-size: 14px; font-weight: 500; }
.skill-item .row-sub { margin-top: 2px; line-height: 1.6; }
.skill-icon { flex: none; width: 34px; height: 34px; margin-top: 2px; display: grid; place-items: center; border-radius: 10px; background: var(--tint); color: #4d525a; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.skill-chevron { flex: none; margin-top: 8px; color: var(--faint); }
.skill-heading { padding: 8px 0 0; display: flex; align-items: center; gap: 12px; }
.skill-heading .skill-icon { width: 44px; height: 44px; margin: 0; border-radius: 13px; }
.skill-heading h3 { margin: 0; font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.skill-heading .path-text { margin-top: 2px; font-family: ui-monospace, Consolas, monospace; }
.skill-description { margin: 12px 0 4px; color: var(--muted); font-size: 13px; line-height: 1.75; overflow-wrap: anywhere; }
#skill-tabs { margin: 14px 0; }
.skill-pane { min-width: 0; }
.skill-pane p { font-size: 13.5px; line-height: 1.8; overflow-wrap: anywhere; }
.skill-pane .note-box { margin-top: 10px; }
.skill-source { margin: 0; padding: 14px; min-height: 160px; max-height: 52dvh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: 12px/1.8 ui-monospace, Consolas, "Microsoft YaHei", monospace; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.tag.disabled { background: #f1f1ee; color: var(--faint); text-decoration: line-through; }
.alert { margin: 12px 0; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; line-height: 1.6; }
.alert strong { font-size: 13.5px; font-weight: 600; }
.empty-box { margin: 12px 0; padding: 18px 14px; border-radius: 12px; background: var(--fill-2); color: var(--muted); font-size: 13px; text-align: center; }

.login-dialog { width: min(90vw, 420px); padding: 22px; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 18px 60px rgba(32, 33, 36, .24); }
.login-dialog::backdrop { background: rgba(32, 33, 36, .34); }
.login-dialog form, .login-dialog .dialog-form { display: flex; flex-direction: column; }
.login-dialog h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.login-dialog .help-text { margin: 0 0 12px; }
.login-dialog .primary-button { margin-top: 8px; }
.login-dialog .field { margin-top: 8px; }
/* Workbench password login: labelled fields; the remember checkbox is NOT
 * affected by the full-width `.login-dialog input` rule. */
.login-auth #login-form { gap: 4px; }
.login-field { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.login-field input { margin-top: 4px; }
.login-auth #password-login-fields, .login-auth #token-login-fields { flex-direction: column; }
.login-auth #password-login-fields[hidden], .login-auth #token-login-fields[hidden] { display: none; }
.login-auth #token-login-fields { margin-top: 4px; }
.login-remember { min-height: 44px; margin-top: 10px; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); cursor: pointer; }
.login-auth .login-remember input[type="checkbox"] { display: inline-block; width: 20px; min-width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); accent-color: var(--accent); flex: none; box-shadow: none; }
.login-auth .login-remember input[type="checkbox"]:focus-visible { border-color: var(--accent-line); box-shadow: 0 0 0 2px rgba(40, 102, 77, .14); }
.workbench-login { flex-wrap: wrap; }
.workbench-login-main { min-width: 0; }
.workbench-login-main .help-text { margin: 2px 0 0; overflow-wrap: anywhere; }
.workbench-login #workbench-logout { min-width: 96px; padding: 0 14px; }
.dialog-text { margin: 6px 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.dialog-actions { margin-top: 14px; display: flex; gap: 8px; }
.dialog-actions > button { flex: 1; }
.history-dialog[open] { width: min(92vw, 440px); max-height: 86dvh; overflow-y: auto; padding: 20px; }
.history-dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.history-dialog .note-box { margin-top: 10px; }
#delete-confirm-button { flex: 1.2; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 100; max-width: calc(100vw - 40px); padding: 10px 14px; border-radius: 12px; background: #202124; color: #fff; font-size: 13px; box-shadow: 0 8px 26px rgba(32, 33, 36, .22); opacity: 0; transform: translate(-50%, 8px); transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .topbar { padding: 10px 20px; }
  .conversation { padding: 8px 28px 20px; }
  .composer-area { padding: 4px 18px 16px; }
  .sheet { left: 50%; right: auto; bottom: 24px; width: min(92vw, 560px); max-height: 84dvh; border-radius: var(--radius); opacity: 0; transform: translate(-50%, 26px); }
  .sheet.open { opacity: 1; transform: translate(-50%, 0); }
  .sheet-tall { height: 84dvh; }
  .sheet-head { border-radius: var(--radius) var(--radius) 0 0; }
}
@media (max-width: 359px) {
  .conversation { padding-left: 12px; padding-right: 12px; }
  .composer-area { padding-left: 8px; padding-right: 8px; }
  .sheet-body, .sheet-foot { padding-left: 14px; padding-right: 14px; }
  .history-title { font-size: 14px; }
  .history-sub { display: none; }
  .login-code { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
