:root {
  --bg: #0f1116;
  --panel: #151923;
  --panel-2: #11151d;
  --text: #e6e8ee;
  --muted: #8a93a6;
  --accent: #f6c453;
  --accent-text: #1b1400;
  --border: #2a3142;
  --vscode-blue: #007acc;
  --vscode-blue-2: #1f6feb;
  --vscode-ink: #0b0f16;
  --vscode-line: #1c2433;
}
* { box-sizing: border-box; }
html, body { height: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; color: var(--text); background: var(--bg); min-height: 100vh; min-height: 100svh; min-height: 100dvh; min-height: -webkit-fill-available; overflow: hidden; }
body.history-shell { min-height: 100vh; min-height: 100svh; min-height: 100dvh; height: auto; overflow-x: hidden; overflow-y: auto; }
.version-float { position: fixed; top: 6px; left: 6px; z-index: 10020; padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; background: color-mix(in srgb, var(--panel) 88%, transparent); color: var(--muted); font-size: 11px; line-height: 1.2; box-shadow: 0 4px 14px rgba(0,0,0,0.22); pointer-events: none; backdrop-filter: blur(8px); }
/* Scrollbar styling (WebKit + Firefox) */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--panel-2); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--panel-2); }
*::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 8px; border: 2px solid var(--panel-2); }
*::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--border) 70%, var(--text)); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--panel); padding: 32px; border-radius: 12px; width: 360px; border: 1px solid var(--border); }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 12px; margin-bottom: 16px; }
.login-error { color: #ff7a7a; font-size: 12px; margin-bottom: 10px; }
.login-card input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); margin-bottom: 12px; }
.login-card button { width: 100%; padding: 10px; border-radius: 8px; border: none; background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer; }
.input { background: var(--panel-2); border: 1px solid var(--vscode-line); color: var(--text); border-radius: 6px; padding: 6px 8px; font-size: 12px; }

.app { height: 100vh; height: 100svh; height: 100dvh; height: -webkit-fill-available; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--panel); gap: 12px; flex-wrap: wrap; }
.brand-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.brand-status-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { font-weight: 700; letter-spacing: 0.5px; white-space: nowrap; }
.status-group { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.status { font-size: 12px; color: var(--muted); }
.status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 999px; margin-right: 6px; background: var(--muted); vertical-align: 1px; }
.status.status-online { color: #9ee6af; }
.status.status-online::before { background: #36d66b; box-shadow: 0 0 0 3px rgba(54, 214, 107, 0.14); }
.status.status-warn { color: #ffd38a; }
.status.status-warn::before { background: #f6c453; box-shadow: 0 0 0 3px rgba(246, 196, 83, 0.14); }
.status.status-error { color: #ff9a9a; }
.status.status-error::before { background: #ff5f5f; box-shadow: 0 0 0 3px rgba(255, 95, 95, 0.14); }
.ghost { background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: 12px; }
.ghost { touch-action: manipulation; }
.tab-bar { display: flex; gap: 0; padding: 0; border-bottom: 0; background: transparent; overflow-x: auto; }
.tab-btn { background: transparent; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; font-size: 12px; position: relative; white-space: nowrap; -webkit-appearance: none; appearance: none; border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; overflow: hidden; }

.app-main { display: grid; grid-template-columns: 240px minmax(0, 1fr) 360px; gap: 12px; padding: 12px; flex: 1 1 0; min-height: 0; overflow: hidden; }
.side { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 14px; }
.side-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.side-title { font-size: 12px; color: var(--muted); }
.ghost.mini { padding: 4px 8px; font-size: 11px; }
.fav-list { display: flex; flex-wrap: wrap; gap: 6px; }
.fav-item { background: var(--panel-2); border: 1px solid var(--border); padding: 6px 8px; border-radius: 8px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.fav-item span { white-space: nowrap; }
.fav-actions { display: none; }
.fav-menu { position: fixed; z-index: 9999; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: none; min-width: 120px; left: -9999px; top: -9999px; visibility: hidden; }
.fav-menu[hidden] { display: none !important; }
.fav-menu.show { display: block; visibility: visible; }
.fav-menu button { -webkit-appearance: none; appearance: none; }
.fav-menu button { width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); padding: 6px 8px; cursor: pointer; font-size: 12px; border-radius: 6px; }
.fav-menu button:hover { background: var(--panel-2); }
.fav-item span { color: var(--text); }
.fav-item button { background: transparent; border: none; color: #ff7a7a; cursor: pointer; }
.fav-add { display: flex; gap: 6px; }
.fav-add input { flex: 1; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px; font-size: 12px; }
.fav-add button { background: var(--accent); border: none; border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }

.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 9998; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-card { position: relative; z-index: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; width: min(420px, 90vw); display: grid; gap: 12px; }
.modal-title { font-size: 14px; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ghost.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.online-list { display: grid; gap: 8px; max-height: 50vh; overflow: auto; }
.online-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: grid; gap: 4px; background: var(--panel-2); }
.online-line { font-size: 12px; color: var(--text); display: flex; gap: 6px; flex-wrap: wrap; }
.online-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.init-box { display: flex; flex-direction: column; gap: 8px; }
.init-select { width: 100%; background: var(--panel-2); border: 1px solid var(--vscode-line); color: var(--text); border-radius: 6px; padding: 8px 10px; font-size: 12px; }
.init-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.init-actions { display: flex; gap: 8px; justify-content: flex-end; }
.init-hint { font-size: 11px; color: var(--muted); }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
#terminalPanel { min-height: 0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--panel-2); overflow: hidden; flex: 0 0 auto; min-width: 0; }
.panel-actions { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.panel-title { font-size: 12px; color: var(--muted); }
.terminal-head-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.terminal-head-main .panel-title { flex: 0 0 auto; }
.panel-actions,
.terminal-head-main { flex-wrap: nowrap; }
.panel-actions .ghost,
.terminal-head-main .ghost { flex: 0 0 auto; white-space: nowrap; }
.server-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.server-tab { background: var(--panel); border: 1px solid var(--border); color: var(--muted); padding: 4px 10px; border-radius: 999px; cursor: pointer; font-size: 11px; }
.server-tab.active { color: var(--accent-text); background: var(--accent); border-color: transparent; }
.server-modal-list { display: grid; gap: 8px; max-height: 40vh; overflow: auto; }
.server-modal-item { display: flex; align-items: start; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.server-modal-meta { display: grid; gap: 3px; min-width: 0; }
.server-modal-meta strong { font-size: 12px; color: var(--text); }
.server-modal-meta span { font-size: 11px; color: var(--muted); word-break: break-all; }
.server-modal-actions-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.server-modal-form { display: grid; gap: 8px; }
.server-modal-badge { padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; color: var(--text); }
.server-modal-badge.muted { color: var(--muted); }
.server-distribute-box { display: grid; gap: 10px; }
.server-distribute-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.server-progress { display: grid; gap: 6px; }
.server-progress-bar { width: 100%; height: 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); overflow: hidden; }
.server-progress-bar span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.2s ease; }
.server-progress-text { font-size: 11px; color: var(--muted); text-align: right; }
.server-distribute-result { font-size: 11px; color: var(--muted); line-height: 1.6; word-break: break-word; }
.server-distribute-result.success { color: #9ee6af; }
.server-distribute-result.error { color: #ffb3b3; }
.server-distribute-result.warn { color: #ffd38a; }
.server-release-notes { margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.server-release-history { display: grid; gap: 8px; }
.server-release-history-item { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.server-release-history-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 6px; }
.server-release-history-version { font-size: 12px; color: var(--text); font-weight: 700; }
.server-release-history-meta { font-size: 11px; color: var(--muted); }
.server-release-history-notes { font-size: 12px; color: var(--text); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.resume-history-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.resume-history-actions .ghost { padding: 4px 8px; font-size: 11px; }
.history-shell { min-height: 100vh; background:
  radial-gradient(circle at top left, rgba(246, 196, 83, 0.14), transparent 28%),
  radial-gradient(circle at top right, rgba(47, 128, 255, 0.12), transparent 24%),
  linear-gradient(180deg, #0c1017 0%, #0f1116 100%);
  overflow-x: hidden;
  overflow-y: auto; }
.history-page { max-width: 1120px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.history-hero { display: grid; gap: 10px; padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(135deg, rgba(21, 25, 35, 0.96), rgba(17, 21, 29, 0.96)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.history-kicker { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.history-title { font-size: clamp(26px, 5vw, 40px); line-height: 1.05; font-weight: 800; color: var(--text); }
.history-subtitle { font-size: 13px; line-height: 1.7; color: var(--muted); max-width: 760px; }
.history-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.history-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.history-search { flex: 1; min-width: 220px; }
.history-search.input { padding: 10px 12px; border-radius: 12px; background: rgba(17, 21, 29, 0.96); }
.history-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.history-summary { display: grid; gap: 12px; position: sticky; top: 18px; }
.history-stat-card { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: rgba(21, 25, 35, 0.92); }
.history-stat-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.history-stat-value { font-size: 26px; font-weight: 800; color: var(--text); }
.history-list-page { display: grid; gap: 14px; }
.history-card { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: rgba(21, 25, 35, 0.94); box-shadow: 0 12px 34px rgba(0,0,0,0.18); }
.history-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.history-card-version { font-size: 22px; font-weight: 800; color: var(--text); }
.history-card-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.history-card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.history-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.history-chip { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); font-size: 11px; color: var(--muted); }
.history-card-notes { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.75; color: var(--text); }
.history-empty { padding: 30px; text-align: center; border: 1px dashed var(--border); border-radius: 18px; color: var(--muted); background: rgba(21, 25, 35, 0.8); }
.panel-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; overscroll-behavior: contain; }
.settings-page { display: grid; gap: 12px; max-width: 1180px; width: 100%; margin: 0 auto; align-content: start; }
.settings-section { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: color-mix(in srgb, var(--panel-2) 92%, #ffffff 3%); }
.settings-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.settings-collapsible { display: block; }
.settings-collapsible[open] { display: grid; }
.settings-section-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.settings-section-summary::-webkit-details-marker { display: none; }
.settings-section-summary::after { content: "展开"; flex: 0 0 auto; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; background: var(--panel); }
.settings-collapsible[open] .settings-section-summary::after { content: "收起"; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.settings-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.settings-title { font-size: 13px; color: var(--text); font-weight: 700; }
.settings-desc { font-size: 12px; color: var(--muted); }
.settings-row { display: flex; gap: 8px; align-items: center; }
.settings-hint { font-size: 11px; color: var(--muted); line-height: 1.55; }
.settings-control-grid,
.prompt-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.settings-field { display: grid; gap: 7px; min-width: 0; color: var(--muted); font-size: 11px; }
.settings-field .init-select,
.settings-field .input { width: 100%; min-width: 0; }
.settings-inline-control { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.settings-inline-control .init-select { flex: 1 1 120px; }
.settings-link-row { display: flex; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap; }
.release-notes-input { min-height: 110px; resize: vertical; line-height: 1.7; }
.version-pill { padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); white-space: nowrap; }
.prompt-settings-row { align-items: center; flex-wrap: wrap; }
.prompt-tone-block { min-width: 0; }
.prompt-tone-select { width: auto; min-width: 120px; padding: 6px 8px; }
.codex-account-box { display: grid; gap: 10px; }
.codex-account-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.codex-account-list { display: grid; gap: 8px; }
.codex-account-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.codex-account-item.active { outline: 2px solid var(--accent); }
.codex-account-meta { display: grid; gap: 3px; min-width: 0; }
.codex-account-meta strong { font-size: 12px; color: var(--text); }
.codex-account-meta span { font-size: 11px; color: var(--muted); word-break: break-all; }
.codex-account-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.codex-account-form .input { flex: 1 1 240px; }
.server-release-history.compact { max-height: 260px; overflow: auto; }
.theme-results { display: grid; gap: 6px; margin-top: 6px; }
.theme-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,0.02); }
.theme-item .meta { display: flex; flex-direction: column; gap: 2px; }
.theme-item .name { font-size: 12px; color: var(--text); }
.theme-item .desc { font-size: 11px; color: var(--muted); }
.keyword-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.keyword-chip { padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; color: var(--muted); cursor: pointer; background: rgba(255,255,255,0.02); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 8px; }
.theme-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; background: rgba(255,255,255,0.02); }
.theme-card.active { outline: 2px solid #2f80ff; }
.theme-card .title { font-size: 12px; color: var(--text); }
.theme-card .palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.theme-card .swatch { height: 12px; border-radius: 2px; background: var(--c); }
.theme-quick { position: relative; }
.theme-dropdown { position: absolute; right: 0; top: 36px; width: 280px; max-height: 320px; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; box-shadow: 0 12px 24px rgba(0,0,0,0.2); z-index: 20; }
.theme-dropdown-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.theme-dropdown-list { display: grid; gap: 6px; }
.theme-dropdown-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.theme-dropdown-item.active { outline: 2px solid #2f80ff; }
.theme-dropdown-item .label { font-size: 12px; color: var(--text); }
.theme-dropdown-item .palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.theme-dropdown-item .swatch { height: 10px; border-radius: 2px; background: var(--c); }
.upload-drop { border: 1px dashed var(--vscode-line); border-radius: 8px; padding: 16px; text-align: center; cursor: pointer; background: var(--panel); position: relative; }
.upload-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-list { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.upload-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); }
.upload-item button { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 2px 6px; border-radius: 6px; cursor: pointer; font-size: 11px; }
.terminal-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0; flex: 1 1 0; min-height: 0; overflow: hidden; }
.terminal-wrap { flex: 1 1 0; padding: 6px; background: var(--panel-2); min-height: 0; border-radius: 0 0 10px 10px; overflow: hidden; position: relative; display: flex; flex-direction: column; gap: 6px; }
.fav-collapsed .side { display: none !important; }
.fav-collapsed .app-main { grid-template-columns: 1fr; }
.perf-mini { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 8px; padding: 6px; width: 160px; backdrop-filter: blur(6px); }
.perf-mini[hidden] { display: none !important; }
.perf-title { font-size: 10px; color: var(--muted); margin-bottom: 4px; }
.perf-stats { font-size: 10px; color: var(--text); margin-top: 4px; text-align: center; }
.theme-side { width: 0; overflow: hidden; border-left: 1px solid var(--border); background: var(--panel-2); transition: width 0.2s ease; min-height: 0; display: flex; flex-direction: column; }
.theme-side[hidden] { display: none !important; }
.theme-side.open { width: 260px; }
.theme-side-header { display: flex; align-items: center; justify-content: space-between; padding: 8px; border-bottom: 1px solid var(--border); }
.theme-side-title { font-size: 12px; color: var(--muted); }
.theme-side-list { padding: 8px; display: grid; gap: 8px; flex: 1; min-height: 0; overflow: auto; }
.theme-side-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px; cursor: pointer; display: grid; gap: 6px; }
.theme-side-item.active { outline: 2px solid #2f80ff; }
.theme-side-item .title { font-size: 12px; color: var(--text); }
.theme-side-item .preview { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.theme-side-item .swatch { height: 10px; border-radius: 2px; background: var(--c); }
#terminal { flex: 1 1 0; height: 100%; min-height: 0; width: 100%; }
#terminal .xterm { height: 100% !important; padding: 0; }
#terminal .xterm-viewport { height: 100% !important; width: 100% !important; }
#terminal .xterm-screen { height: 100% !important; }
#terminal .xterm-scroll-area { min-height: 100% !important; }
.terminal-rendered-code-stream { flex: 1 1 0; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 10px; padding: 8px; }
.terminal-rendered-code-stream[hidden] { display: none !important; }
.terminal-wrap.rendered-transcript-active #terminal { display: none; }
.terminal-chat-block { border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--panel) 88%, #ffffff 2%); padding: 10px 12px; color: var(--text); font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.terminal-chat-heading { font-weight: 800; font-size: 14px; }
.terminal-chat-paragraph { white-space: pre-wrap; }
.terminal-chat-steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.terminal-chat-code-block { border: 1px solid var(--vscode-line); border-radius: 8px; overflow: hidden; background: #0b0f16; box-shadow: inset 3px 0 0 var(--accent); }
.terminal-chat-code-head { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px 7px 12px; background: color-mix(in srgb, var(--panel) 88%, #ffffff 2%); border-bottom: 1px solid rgba(255,255,255,0.06); }
.terminal-chat-code-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.terminal-chat-code-head button { flex: 0 0 auto; padding: 4px 9px; border: 1px solid transparent; border-radius: 6px; background: var(--accent); color: var(--accent-text); font: inherit; font-size: 11px; cursor: pointer; }
.terminal-chat-code-block pre { margin: 0; padding: 10px 12px; overflow: auto; max-height: 220px; color: var(--text); font: inherit; font-size: 12px; line-height: 1.55; white-space: pre; }
.terminal-chat-code-block code { font: inherit; }
.terminal-local-echo { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4; display: none; align-items: center; min-height: 30px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--text); font-size: 12px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; pointer-events: none; box-shadow: 0 8px 22px rgba(0,0,0,0.28); }
.terminal-repaint-kick .xterm-screen,
.terminal-repaint-kick .xterm-viewport,
.terminal-repaint-kick canvas { transform: translateZ(0); will-change: transform; }
.terminal-local-echo.pending { border-color: rgba(246,196,83,0.7); color: #ffd98a; }
.terminal-local-echo.error { border-color: rgba(248,81,73,0.7); color: #ffc1c1; }
.terminal-local-echo[hidden] { display: none !important; }
.input-bar { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 6px; background: var(--panel); flex: 0 0 auto; max-height: min(45vh, 360px); overflow: auto; }
.input-bar.collapsed { padding: 6px 10px; gap: 0; }
.input-bar.collapsed .input-toolbar,
.input-bar.collapsed .input-preview,
.input-bar.collapsed .auto-choice-bar,
.input-bar.collapsed .input-nav,
.input-bar.collapsed .mix-input,
.input-bar.collapsed .input-actions { display: none; }
.input-bar.collapsed::after { content: "输入已折叠，点击展开"; color: var(--muted); font-size: 12px; }
.input-toolbar { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; overflow-x: auto; }
.input-toolbar [hidden],
.toolbar-group[hidden] { display: none !important; }
.toolbar-group { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
.toolbar-group .init-select { min-width: 160px; padding: 6px 8px; }
.toolbar-group .ghost { padding: 4px 8px; font-size: 11px; }
.model-picker { position: relative; }
.model-dropdown { position: absolute; left: 0; top: 34px; width: 260px; max-height: 360px; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; box-shadow: 0 12px 24px rgba(0,0,0,0.2); z-index: 20; }
.model-section-title { font-size: 11px; color: var(--muted); margin: 4px 0; }
.model-list { display: grid; gap: 4px; margin-bottom: 6px; }
.model-item { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: space-between; }
.model-item.active { outline: 2px solid var(--accent); }
.model-more { width: 100%; background: transparent; border: 1px dashed var(--border); color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; font-size: 11px; margin-bottom: 6px; }
.toolbar-group .ghost { background: transparent; }
.input-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.input-preview.drag-over { outline: 1px dashed var(--vscode-blue); outline-offset: 3px; }
.auto-choice-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); min-height: 34px; }
.auto-choice-main { min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.auto-choice-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.auto-choice-value { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auto-choice-detail { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.input-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
.input-nav-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.input-nav-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.input-nav-lastline { font-size: 11px; color: var(--text); opacity: 0.82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.input-nav-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.input-nav-btn { min-width: 72px; background: transparent; }
.preview-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; font-size: 11px; color: var(--text); }
.preview-chip.sent { opacity: 0.72; border-style: dashed; }
.preview-img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.preview-chip .meta { color: var(--muted); font-size: 11px; }
.preview-chip button { background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.mix-input { width: 100%; min-height: 96px; resize: vertical; background: var(--panel-2); border: 1px solid var(--vscode-line); color: var(--text); caret-color: var(--text); border-radius: 6px; padding: 10px 12px; font: inherit; font-size: 13px; line-height: 1.45; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2); white-space: pre-wrap; word-break: break-word; user-select: text; position: relative; z-index: 1; box-sizing: border-box; }
.mix-input:focus { outline: none; border-color: var(--vscode-blue); box-shadow: 0 0 0 2px rgba(0,122,204,0.15); }
.mix-input.drag-over { border-color: var(--vscode-blue); background: color-mix(in srgb, var(--panel-2) 82%, var(--vscode-blue)); box-shadow: 0 0 0 2px rgba(0,122,204,0.22), inset 0 0 0 1px rgba(0,0,0,0.2); }
.mix-input::placeholder { color: var(--muted); opacity: 1; }
.send-receipt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); color: var(--muted); font-size: 11px; line-height: 1.5; }
.send-receipt[hidden] { display: none !important; }
.send-receipt-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.send-receipt-meta { flex: 0 0 auto; white-space: nowrap; color: var(--muted); }
.input-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.input-actions .ghost { background: var(--panel-2); }
.input-actions #sendBtn { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.input-guard-status { margin-right: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.input-guard-status.active { color: #f0b429; }
.input-guard-status.pending { color: #58a6ff; }

.users-frame { width: 100%; height: 70vh; border: 0; background: var(--panel-2); }
.toast { position: fixed; top: 16px; right: 16px; z-index: 9999; background: var(--panel-2); border: 1px solid var(--vscode-line); color: var(--text); padding: 8px 12px; border-radius: 6px; font-size: 12px; display: none; }
.toast.show { display: block; }
.toast.success { border-color: rgba(46,160,67,0.5); color: #b6f2c2; }
.toast.error { border-color: rgba(248,81,73,0.6); color: #ffc1c1; }
.terminal-fullscreen .app-header,
.terminal-fullscreen .side,
.terminal-fullscreen .app-main { grid-template-columns: 1fr; padding: 0; gap: 0; }
.terminal-fullscreen #terminalPanel { position: fixed; inset: 0; z-index: 9999; border-radius: 0; border: 0; }
.terminal-fullscreen #terminalPanel .panel-header { position: sticky; top: 0; z-index: 1; }
.terminal-fullscreen .terminal-wrap { border-radius: 0; }

.focus-mode-shell { position: fixed; inset: 0; z-index: 10020; padding: 16px; max-width: 100vw; overflow: hidden; font-size: 14px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: linear-gradient(180deg, rgba(8, 11, 16, 0.96), rgba(8, 11, 16, 0.99)); backdrop-filter: blur(12px); }
.focus-mode-panel { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 12px; border: 1px solid color-mix(in srgb, var(--border) 82%, #ffffff 8%); border-radius: 22px; padding: 18px; background: linear-gradient(180deg, rgba(17, 21, 29, 0.98), rgba(12, 15, 22, 0.98)); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45); }
.focus-mode-header { display: grid; gap: 8px; padding-bottom: 6px; }
.focus-mode-title-group { display: grid; gap: 4px; }
.focus-mode-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); }
.focus-mode-title { font-size: clamp(22px, 3vw, 28px); line-height: 1.05; font-weight: 800; color: var(--text); }
.focus-mode-subtitle { font-size: 13px; color: var(--muted); line-height: 1.6; }
.focus-mode-head-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.focus-mode-content { min-height: 0; display: block; }
.focus-mode-rendered,
.focus-mode-composer { border: 1px solid var(--border); border-radius: 18px; background: rgba(12, 16, 24, 0.9); }
.focus-mode-rendered { min-height: 0; height: 100%; overflow: hidden; }
.focus-mode-section-title { font-size: 13px; color: var(--text); font-weight: 700; }
.focus-mode-section-meta { display: inline-flex; align-items: center; min-height: 34px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); font-size: 11px; color: var(--muted); }
.focus-mode-stream { height: 100%; min-height: 0; overflow: auto; padding: 18px; display: grid; gap: 12px; }
.focus-mode-status { font-size: 13px; color: var(--text); line-height: 1.6; }
.focus-mode-status-hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.focus-mode-composer { padding: 14px; display: grid; gap: 10px; }
.focus-cmd-input { min-height: 112px; max-height: 26vh; font-size: 16px; overflow: auto; border: 1px solid var(--vscode-line); border-radius: 14px; background: rgba(17, 21, 29, 0.96); padding: 14px 16px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.focus-cmd-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(246, 196, 83, 0.14); }
.focus-cmd-input:empty:before { content: attr(data-placeholder); color: var(--muted); }
.focus-mode-composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; }
.focus-mode-composer-actions .ghost:first-child { background: var(--accent); border-color: transparent; color: var(--accent-text); }
.focus-mode-exit-btn { justify-self: flex-end; min-width: 0; }
.focus-block { border: 1px solid color-mix(in srgb, var(--border) 88%, #ffffff 8%); border-radius: 16px; padding: 14px; background: rgba(255,255,255,0.03); }
.focus-block-heading { padding: 0; background: transparent; border: 0; }
.focus-heading { font-size: 16px; font-weight: 800; color: var(--text); line-height: 1.4; padding: 2px 2px 4px; }
.focus-paragraph { font-size: 13px; line-height: 1.85; color: var(--text); }
.focus-block-head,
.focus-block-code summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.focus-block-title { font-size: 13px; font-weight: 700; color: var(--text); }
.focus-block-summary { font-size: 11px; color: var(--muted); }
.focus-block-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.focus-block-actions-inline { margin: 10px 0 0; }
.focus-step-list { margin: 12px 0 0; padding: 0; display: grid; gap: 10px; list-style: none; }
.focus-step-list li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.75; color: var(--text); }
.focus-step-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 64px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: 10px; white-space: nowrap; }
.focus-step-badge.done { color: #a8e5b2; border-color: rgba(75, 181, 67, 0.45); background: rgba(75, 181, 67, 0.12); }
.focus-step-badge.doing { color: #ffd38a; border-color: rgba(255, 196, 83, 0.45); background: rgba(255, 196, 83, 0.12); }
.focus-step-badge.pending { color: #9dd0ff; border-color: rgba(47, 128, 255, 0.45); background: rgba(47, 128, 255, 0.12); }
.focus-step-badge.error { color: #ffb3b3; border-color: rgba(248, 81, 73, 0.48); background: rgba(248, 81, 73, 0.12); }
.focus-step-text { flex: 1; min-width: 0; }
.focus-block-code summary { cursor: pointer; list-style: none; }
.focus-block-code summary::-webkit-details-marker { display: none; }
.focus-code { margin: 10px 0 0; padding: 14px; border-radius: 14px; background: #0b0f16; border: 1px solid rgba(255,255,255,0.06); overflow: auto; font-size: 12px; line-height: 1.7; color: #dfe6f3; }
.focus-code code { font-family: inherit; }
.focus-empty { padding: 28px; border: 1px dashed var(--border); border-radius: 14px; text-align: center; color: var(--muted); line-height: 1.8; }
body.focus-mode { overflow: hidden; }

.focus-mode-panel,
.focus-mode-header,
.focus-mode-title-group,
.focus-mode-head-meta,
.focus-mode-content,
.focus-mode-rendered,
.focus-mode-stream,
.focus-mode-composer,
.focus-mode-composer-actions,
.focus-block,
.focus-block-head,
.focus-block-code,
.focus-block-code summary,
.focus-code,
.focus-code code,
.focus-step-list li { min-width: 0; max-width: 100%; }
.focus-mode-panel { width: 100%; overflow: hidden; }
.focus-mode-head-meta > * { max-width: 100%; }
.focus-mode-section-meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus-block-head,
.focus-block-code summary { flex-wrap: wrap; }
.focus-block-actions,
.focus-block-actions-inline,
.focus-mode-composer-actions { max-width: 100%; }
.focus-mode-composer-actions .ghost,
.focus-block-actions .ghost { max-width: 100%; }
.focus-mode-composer-actions .ghost,
.focus-mode-exit-btn { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.focus-code { overflow-x: auto; overflow-y: hidden; }
.focus-code code { display: block; white-space: pre; }
.focus-mode-shell *,
.focus-mode-shell *::before,
.focus-mode-shell *::after { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.focus-mode-stream { align-content: start; }
@media (min-width: 1800px) {
  .app-main { grid-template-columns: 280px 1fr 420px; }
}
@media (max-width: 1200px) {
  .app-main { display: flex; flex-direction: column; }
  #terminalPanel { order: 1; flex: 1 1 0; min-height: 0; }
  #terminalPanel .terminal-body { flex: 1 1 0; min-height: 0; }
  .side { order: 2; flex: 0 0 auto; max-height: 24vh; overflow: auto; }
}
@media (max-width: 1200px) {
  .fav-collapsed .side { display: none !important; }
}
@media (max-width: 1024px) {
  .app-main { grid-template-columns: 1fr; }
  .side { max-height: 26vh; overflow: auto; }
  .toolbar-group { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .toolbar-group .init-select { min-width: 0; width: 100%; }
  .perf-mini { display: none; }
}
@media (max-width: 768px) {
  .app-header { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .brand-wrap { width: 100%; align-items: stretch; gap: 8px; }
  .brand-status-wrap { width: 100%; justify-content: space-between; align-items: center; gap: 10px; }
  .status-group { justify-content: flex-end; align-items: center; gap: 6px; flex-wrap: nowrap; }
  .status { font-size: 11px; white-space: nowrap; }
  .tab-bar { width: 100%; }
  .header-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .header-actions .ghost { min-height: 38px; display: inline-flex; align-items: center; }
  .app-main { padding: 8px; gap: 8px; flex: 1 1 0; min-height: 0; }
  .history-page { padding: 12px; }
  .history-grid { grid-template-columns: 1fr; }
  .history-summary { position: static; }
  .side { border-radius: 10px; padding: 10px; }
  .panel { border-radius: 10px; }
  .panel-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .panel-actions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; overflow-x: visible; }
  .panel-actions .ghost { width: 100%; min-height: 40px; justify-content: center; }
  .terminal-head-main { width: 100%; flex-wrap: wrap; align-items: center; gap: 6px; }
  .server-tab { flex: 0 0 auto; }
  .terminal-body { grid-template-columns: 1fr; }
  .theme-side { width: 100%; max-height: 0; border-left: 0; border-top: 1px solid var(--border); }
  .theme-side.open { width: 100%; max-height: 42vh; }
  .theme-side-list { max-height: 42vh; }
  .input-toolbar { flex-wrap: wrap; overflow-x: visible; }
  .toolbar-group { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .toolbar-group .ghost { flex: 1 1 auto; min-height: 38px; }
  .auto-choice-bar { align-items: stretch; flex-direction: column; gap: 4px; }
  .auto-choice-value,
  .auto-choice-detail { white-space: normal; text-align: left; }
  .input-nav { align-items: stretch; flex-direction: column; }
  .input-nav-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .input-nav-btn { min-height: 40px; }
  .mix-input { min-height: 88px; font-size: 16px; }
  .focus-mode-shell { padding: 10px; }
  .focus-mode-panel { padding: 12px; border-radius: 18px; }
  .focus-mode-header { gap: 10px; }
  .focus-mode-head-meta { width: 100%; display: grid; grid-template-columns: 1fr; }
  .focus-mode-composer-actions { width: 100%; display: flex; justify-content: flex-end; flex-wrap: nowrap; overflow-x: auto; }
  .focus-mode-rendered { min-height: 42vh; }
  .focus-cmd-input { min-height: 132px; font-size: 16px; }
  .focus-mode-exit-btn { justify-self: flex-end; width: auto; }
  .users-frame { height: 60vh; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-aspect-ratio: 3/4) {
  .app-main { grid-template-columns: 1fr; }
  .side { max-height: 30vh; overflow: auto; }
  #terminalPanel { flex: 1 1 auto; min-height: 0; }
  .terminal-body { flex: 1 1 0; min-height: 0; }
  .terminal-wrap { min-height: 0; }
}
