:root {
    color-scheme: light;
    --bg-primary: #eef2f6;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e6ebf1;
    --border: #c7d0da;
    --text-primary: #1f2933;
    --text-secondary: #4b5968;
    --text-muted: #6f7d8c;
    --accent-blue: #276fb8;
    --accent-green: #2e8b57;
    --accent-yellow: #9a6700;
    --accent-red: #c53f4c;
    --accent-purple: #745bb5;
    --accent: var(--accent-blue);
    --terminal-font-size: 11px;
    --session-font-size: 14px;
    --composer-font-size: 14px;
    --popover-shadow: rgba(31, 41, 51, 0.18);
    --stat-card-bg: rgba(255, 255, 255, 0.92);
    --terminal-bg: #ffffff;
    --terminal-border: #b8c3d0;
    --terminal-text: #1f2933;
    --terminal-bold: #111827;
    --terminal-caret: #8a5a00;
    --terminal-selection-bg: rgba(39, 111, 184, 0.25);
    --terminal-selection-text: #102a43;
    --terminal-scrollbar: #8795a3;
    --terminal-scrollbar-track: #e6ebf1;
    --terminal-link: #005fb8;
    --ansi-fg-30: #1f2328;
    --ansi-fg-31: #b42318;
    --ansi-fg-32: #087f5b;
    --ansi-fg-33: #8a5a00;
    --ansi-fg-34: #005fb8;
    --ansi-fg-35: #8a2c8f;
    --ansi-fg-36: #007c91;
    --ansi-fg-37: #5b6572;
    --ansi-fg-90: #6b7280;
    --ansi-fg-91: #d13438;
    --ansi-fg-92: #107c10;
    --ansi-fg-93: #9a6700;
    --ansi-fg-94: #0067c0;
    --ansi-fg-95: #b4009e;
    --ansi-fg-96: #038387;
    --ansi-fg-97: #111827;
    --ansi-bg-40: #1f2328;
    --ansi-bg-41: #b42318;
    --ansi-bg-42: #087f5b;
    --ansi-bg-43: #c18c00;
    --ansi-bg-44: #005fb8;
    --ansi-bg-45: #8a2c8f;
    --ansi-bg-46: #007c91;
    --ansi-bg-47: #e5e7eb;
    --ansi-bg-100: #6b7280;
    --ansi-bg-101: #d13438;
    --ansi-bg-102: #107c10;
    --ansi-bg-103: #f2c94c;
    --ansi-bg-104: #0067c0;
    --ansi-bg-105: #b4009e;
    --ansi-bg-106: #038387;
    --ansi-bg-107: #ffffff;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #171a1f;
    --bg-secondary: #20242a;
    --bg-tertiary: #252a31;
    --border: #343b45;
    --text-primary: #e5e9ef;
    --text-secondary: #aab2bd;
    --text-muted: #7f8996;
    --accent-blue: #3385d6;
    --accent-green: #63c174;
    --accent-yellow: #d9a441;
    --accent-red: #e05a65;
    --accent-purple: #8f7bd8;
    --popover-shadow: rgba(0, 0, 0, 0.36);
    --stat-card-bg: rgba(37, 42, 49, 0.9);
    --terminal-bg: #0c0f14;
    --terminal-border: #263142;
    --terminal-text: #d8dee9;
    --terminal-bold: #ffffff;
    --terminal-caret: #f5f543;
    --terminal-selection-bg: rgba(59, 142, 234, 0.55);
    --terminal-selection-text: #ffffff;
    --terminal-scrollbar: #586b82;
    --terminal-scrollbar-track: #20242a;
    --terminal-link: #3b8eea;
    --ansi-fg-30: #000000;
    --ansi-fg-31: #cd3131;
    --ansi-fg-32: #0dbc79;
    --ansi-fg-33: #e5e510;
    --ansi-fg-34: #2472c8;
    --ansi-fg-35: #bc3fbc;
    --ansi-fg-36: #11a8cd;
    --ansi-fg-37: #e5e5e5;
    --ansi-fg-90: #666666;
    --ansi-fg-91: #f14c4c;
    --ansi-fg-92: #23d18b;
    --ansi-fg-93: #f5f543;
    --ansi-fg-94: #3b8eea;
    --ansi-fg-95: #d670d6;
    --ansi-fg-96: #29b8db;
    --ansi-fg-97: #ffffff;
    --ansi-bg-40: #000000;
    --ansi-bg-41: #cd3131;
    --ansi-bg-42: #0dbc79;
    --ansi-bg-43: #949800;
    --ansi-bg-44: #2472c8;
    --ansi-bg-45: #bc3fbc;
    --ansi-bg-46: #11a8cd;
    --ansi-bg-47: #e5e5e5;
    --ansi-bg-100: #666666;
    --ansi-bg-101: #f14c4c;
    --ansi-bg-102: #23d18b;
    --ansi-bg-103: #f5f543;
    --ansi-bg-104: #3b8eea;
    --ansi-bg-105: #d670d6;
    --ansi-bg-106: #29b8db;
    --ansi-bg-107: #ffffff;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

body,
.header,
.card,
.input-panel,
.session-prompt-panel,
.nav-popover-card {
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.terminal {
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.header {
    background: var(--bg-secondary);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.codex-default-account-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
}
#codexDefaultAccountControls[hidden] { display: none; }
.codex-default-account-controls select {
    min-height: 34px;
    max-width: 110px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.codex-default-account-controls #codexAccountStatus { max-width: 190px; }
.codex-account-login-compact { display: none; }

@media (max-width: 760px) {
    .codex-default-account-controls { gap: 4px; }
    .codex-default-account-controls label,
    .codex-default-account-controls #codexAccountStatus { display: none; }
    .codex-default-account-controls select { min-height: 30px; max-width: 78px; padding: 3px 5px; font-size: 10px; }
    .codex-default-account-controls .quick-btn { min-height: 30px; padding: 4px 6px; font-size: 10px; }
}

@media (max-width: 700px) {
    .codex-account-login-full { display: none; }
    .codex-account-login-compact { display: inline; }
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s infinite;
}

.status-dot.warning { background: var(--accent-yellow); }
.status-dot.error { background: var(--accent-red); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.refresh-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.refresh-btn:active {
    background: var(--border);
}

.refresh-btn.loading {
    opacity: 0.7;
}

.refresh-btn.pulse {
    animation: refresh-pulse 0.6s ease-in-out;
}

@keyframes refresh-pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.92); }
    100% { opacity: 1; transform: scale(1); }
}

#refreshText {
    display: none;
}

.refresh-btn {
    width: 32px;
    height: 32px;
    justify-content: center;
    padding: 0;
}

.container {
    padding: 12px;
    max-width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--accent-blue);
}

.stat-value.green { color: var(--accent-green); }
.stat-value.yellow { color: var(--accent-yellow); }
.stat-value.red { color: var(--accent-red); }

.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.card-header:active {
    background: var(--bg-tertiary);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.terminal-lines-select {
    margin-left: auto;
    margin-right: 10px;
    height: 28px;
    max-width: 112px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
}

.terminal-lines-select:focus {
    border-color: var(--accent);
}

.terminal-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    height: 28px;
    margin-left: 8px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.terminal-copy-btn svg {
    display: none;
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.terminal-copy-btn:hover,
.terminal-copy-btn:focus-visible {
    border-color: var(--accent);
    color: var(--text-primary);
}

.card-chevron {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.card.collapsed .card-chevron {
    transform: rotate(-90deg);
}

.card.collapsed .card-content {
    display: none;
}

.card-content {
    padding: 0 16px 16px;
}

.terminal {
    background: var(--terminal-bg);
    border: 1px solid var(--terminal-border);
    border-radius: 8px;
    padding: 12px;
    font-family: 'Cascadia Mono', 'Consolas', 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: var(--terminal-font-size);
    line-height: 1.4;
    overflow-x: auto;
    white-space: normal;
    max-height: 600px;
    overflow-y: scroll;
    overflow-anchor: none;
    color: var(--terminal-text);
    caret-color: var(--terminal-caret);
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.terminal * {
    user-select: text;
    -webkit-user-select: text;
}

/* OpenCode's alternate-screen TUI is reduced to the conversation itself: the
   prompt widget, tab bar and right sidebar are dropped in the frontend, so the
   model / effort / usage they used to carry live in this one-line status strip
   above the composer. */
.opencode-status {
    grid-area: usage;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 4px 16px 7px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-muted);
}

.opencode-status[hidden] {
    display: none;
}

.opencode-status b {
    color: var(--text-primary);
    font-weight: 600;
}

.opencode-status-sep {
    margin: 0 4px;
    opacity: 0.6;
}

.opencode-status-usage {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.opencode-status-actions {
    display: flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
}

.opencode-status-speed {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.terminal-virtual-line {
    display: block;
    min-height: 1.4em;
    white-space: pre;
    word-break: normal;
}

/* Keep East-Asian glyphs on the terminal's two-cell grid so columns of tables
   captured from the TUI still line up in the browser. */
.terminal-wide {
    display: inline-block;
    width: 2ch;
    text-align: center;
}

.terminal .terminal-virtual-spacer {
    display: block;
    width: 1px;
    min-height: 0;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

@media (max-width: 480px) {
    .terminal-copy-btn {
        width: 32px;
        padding: 0;
    }

    .terminal-copy-btn svg {
        display: block;
    }

    .terminal-copy-btn span {
        display: none;
    }
}

.terminal::selection,
.terminal *::selection {
    background: var(--terminal-selection-bg);
    color: var(--terminal-selection-text);
}

/* Chromium ignores ::-webkit-scrollbar entirely as soon as a non-auto
   `scrollbar-color` is set on the same element, so these rules are the only
   ones that style this scrollbar. Do not add `scrollbar-color` back to
   `.terminal` — it silently reverts the bar to the platform default, which is
   near-invisible against the dark terminal background. */
.terminal::-webkit-scrollbar {
    width: 10px;
    height: 6px;
}

.terminal::-webkit-scrollbar-track {
    background: var(--terminal-scrollbar-track);
    border-radius: 5px;
}

.terminal::-webkit-scrollbar-thumb {
    background: var(--terminal-scrollbar);
    border-radius: 3px;
}

.ansi-bold {
    color: var(--terminal-bold);
    font-weight: 700;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: var(--session-font-size);
}

.file-browser {
    min-height: 220px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.file-browser.drop-active {
    outline: 2px dashed var(--accent-blue);
    outline-offset: -3px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent-blue) 8%, transparent);
}

.file-browser-header,
.file-browser-path-row,
.file-browser-toolbar,
.file-browser-entry-main,
.file-browser-row {
    display: flex;
    align-items: center;
}

.file-browser-header {
    justify-content: space-between;
    min-height: 24px;
}

.file-browser-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.file-browser-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
}

.file-browser-count {
    color: var(--text-muted);
    font-size: 10px;
}

.file-browser-collapse-btn {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
}

.file-browser-collapse-btn:hover,
.file-browser-collapse-btn:active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.file-browser-collapse-btn svg {
    transition: transform 0.18s ease;
}

body.file-browser-collapsed .file-browser-collapse-btn svg {
    transform: rotate(180deg);
}

.file-browser-path-row {
    gap: 5px;
}

.file-browser-path {
    flex: 1;
    min-width: 0;
    height: 30px;
    padding: 4px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 11px;
    outline: none;
}

.file-browser-path:focus {
    border-color: var(--accent-blue);
}

.file-browser-icon-btn,
.file-browser-go-btn,
.file-browser-tool-btn,
.file-browser-download,
.file-browser-delete,
.file-browser-favorite {
    min-height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 11px;
}

.file-browser-icon-btn {
    width: 30px;
    padding: 0;
    font-size: 16px;
}

.file-browser-go-btn,
.file-browser-tool-btn {
    padding: 4px 8px;
}

.file-browser-tool-btn.primary {
    margin-left: auto;
    border-color: var(--accent-blue);
    background: var(--accent-blue);
    color: #fff;
}

.file-browser-icon-btn:hover,
.file-browser-go-btn:hover,
.file-browser-tool-btn:hover,
.file-browser-download:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.file-browser-favorite:hover,
.file-browser-favorite.active {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
}

.file-browser-delete:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.file-browser-tool-btn.primary:hover {
    color: #fff;
    filter: brightness(1.08);
}

.file-browser-icon-btn:disabled,
.file-browser-tool-btn:disabled,
.file-browser-delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.file-browser-toolbar {
    gap: 5px;
}

.file-browser-status {
    padding: 5px 7px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 10px;
}

.file-browser-status.error {
    color: var(--accent-red);
}

.file-browser-list {
    min-height: 150px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.file-browser-row {
    min-width: 0;
    border-bottom: 1px solid var(--border);
}

.file-browser-row:last-child {
    border-bottom: 0;
}

.file-browser-entry-main {
    flex: 1;
    min-width: 0;
    gap: 7px;
    padding: 7px 8px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.file-browser-entry-main:hover {
    background: var(--bg-tertiary);
}

.file-browser-entry-icon {
    flex: 0 0 auto;
    position: relative;
    display: inline-block;
    width: 22px;
    height: 20px;
    --file-icon-accent: #607d9d;
}

.file-browser-entry-icon:not(.file-icon-folder)::before {
    content: '';
    position: absolute;
    inset: 1px 3px 0;
    border: 1px solid #91a3b8;
    border-radius: 2px;
    background: linear-gradient(135deg, #ffffff 0 72%, #dce7f3 72% 100%);
    box-shadow: 0 1px 1px rgba(32, 52, 75, 0.16);
}

.file-browser-entry-icon:not(.file-icon-folder)::after {
    content: attr(data-file-label);
    position: absolute;
    right: 1px;
    bottom: 2px;
    min-width: 18px;
    height: 7px;
    padding: 0 1px;
    border-radius: 1px;
    background: var(--file-icon-accent);
    color: #fff;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 5px;
    font-weight: 700;
    line-height: 7px;
    letter-spacing: -0.15px;
    text-align: center;
}

.file-icon-folder::before {
    content: '';
    position: absolute;
    left: 1px;
    right: 0;
    top: 6px;
    bottom: 1px;
    z-index: 1;
    border: 1px solid #d59619;
    border-radius: 2px;
    background: linear-gradient(180deg, #ffd95c, #efb52a);
    box-shadow: 0 1px 1px rgba(91, 64, 13, 0.18);
}

.file-icon-folder::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 3px;
    width: 10px;
    height: 6px;
    border: 1px solid #d59619;
    border-bottom: 0;
    border-radius: 2px 2px 0 0;
    background: #f6c94c;
}

.file-icon-text { --file-icon-accent: #4a86d4; }
.file-icon-document { --file-icon-accent: #2867b2; }
.file-icon-spreadsheet { --file-icon-accent: #18864b; }
.file-icon-pdf { --file-icon-accent: #d13b32; }
.file-icon-image { --file-icon-accent: #8a55b5; }
.file-icon-audio { --file-icon-accent: #9b59b6; }
.file-icon-video { --file-icon-accent: #7655b7; }
.file-icon-archive { --file-icon-accent: #b57922; }
.file-icon-code { --file-icon-accent: #7355a5; }
.file-icon-web { --file-icon-accent: #2086bd; }
.file-icon-config { --file-icon-accent: #6d7885; }
.file-icon-executable { --file-icon-accent: #536b80; }
.file-icon-unknown { --file-icon-accent: #9099a4; }

.file-browser-resizer {
    display: none;
}

body.file-browser-collapsed .file-browser {
    min-height: 38px;
    margin-top: 4px;
    padding-top: 0;
    gap: 0;
}

body.file-browser-collapsed .file-browser-header {
    min-height: 38px;
}

body.file-browser-collapsed .file-browser > :not(.file-browser-header) {
    display: none;
}

.file-browser-entry-text {
    min-width: 0;
    flex: 1;
}

.file-browser-entry-name {
    display: block;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-browser-entry-meta {
    display: block;
    overflow: hidden;
    margin-top: 1px;
    color: var(--text-muted);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-browser-download {
    flex: 0 0 auto;
    min-height: 26px;
    margin-right: 6px;
    padding: 3px 7px;
    line-height: 18px;
    text-decoration: none;
}

.file-browser-delete {
    flex: 0 0 auto;
    min-height: 26px;
    width: 28px;
    margin-right: 6px;
    padding: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.file-browser-delete svg {
    display: block;
}

.file-browser-favorite {
    flex: 0 0 auto;
    min-height: 26px;
    width: 28px;
    margin-right: 2px;
    padding: 1px 3px 3px;
    color: var(--text-muted);
    font-size: 17px;
    line-height: 18px;
}

.file-browser-empty {
    padding: 18px 10px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

.session-item {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 7px 10px;        /* 手机端更紧凑，减少卡片行数占用 */
    display: flex;
    flex-direction: column;   /* 名字在上、操作在下，竖向堆叠 */
    align-items: stretch;     /* 占满整宽 */
    gap: 5px;                 /* 名字行与操作行间距，收紧 */
    cursor: pointer;
    font-size: inherit;
}

.session-item:active {
    background: var(--border);
}

.session-title-row {
    min-width: 0;
    width: 100%;
}

.session-name {
    font-weight: 500;
    font-size: inherit;
    display: flex;
    align-items: center;
    flex-wrap: wrap;          /* 名字/徽章过长时换行 */
    gap: 6px;
    min-width: 0;             /* 允许在 flex 中收缩换行 */
}

/* 手机端隐藏会话类型徽章（Claude/Codex/GLM）：已在对应模式页内，逐卡再标属冗余且占行 */
.session-name .card-badge {
    display: none;
}

.session-actions {
    display: flex;
    font-size: inherit;
    align-items: center;
    flex-wrap: wrap;          /* 按钮+时间换行，不再被卡片右缘裁掉 */
    gap: 5px;                 /* 收紧，争取按钮+时间挤进更少行数 */
}

.copy-session-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 3px 7px;        /* 手机端按钮更紧凑，争取按钮+时间一行 */
    font-size: 0.78em;
    cursor: pointer;
}

.copy-session-btn:active {
    background: var(--border);
}

.copy-session-btn.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.copy-session-btn.pin-btn {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    padding: 3px 6px;
}
.copy-session-btn.pin-btn.pinned {
    color: var(--accent-yellow);
    border-color: var(--accent-yellow);
}

.session-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.session-toolbar .quick-btn {
    flex: 1;
    min-width: 90px;
}

.programming-tool-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.programming-tool-select {
    flex: 1;
    min-width: 90px;
    max-width: 180px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
}

.session-prompt-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 100vw);
    padding: 14px;
    display: none;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.32);
    z-index: 260;
}

.session-prompt-panel.open {
    display: flex;
}

.session-prompt-header,
.session-prompt-template-header,
.session-prompt-actions-row,
.session-prompt-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.session-prompt-header {
    justify-content: space-between;
    flex-shrink: 0;
}

.session-prompt-header-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.session-prompt-title {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 15px;
}

.session-prompt-session,
.session-prompt-status,
.session-prompt-label {
    color: var(--text-muted);
    font-size: 11px;
}

.session-prompt-status.error {
    color: var(--accent-red);
}

.session-prompt-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.session-prompt-template-header {
    justify-content: space-between;
    margin-top: 4px;
}

.session-prompt-textarea,
.prompt-optimize-template,
.prompt-plan-template {
    width: 100%;
    min-height: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--composer-font-size);
    line-height: 1.5;
    resize: vertical;
    outline: none;
}

.session-prompt-textarea:focus {
    border-color: var(--border);
    box-shadow: none;
}

.prompt-optimize-template:focus,
.prompt-plan-template:focus,
.prompt-template-scope:focus {
    border-color: var(--accent);
}

.session-prompt-textarea {
    flex: 1 1 auto;
    min-height: 180px;
    height: auto;
}

.prompt-optimize-template,
.prompt-plan-template {
    min-height: 120px;
    max-height: 220px;
}

.session-prompt-plan-template-panel {
    display: none;
    flex-direction: column;
    gap: 8px;
}

body.prompt-plan-template-open .session-prompt-plan-template-panel {
    display: flex;
}

.prompt-template-scope {
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    outline: none;
}

.session-prompt-actions-row {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.session-meta {
    font-size: 0.78em;
    color: var(--text-muted);
}

.session-hook-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(110, 118, 129, 0.16);
}

.session-hook-dot.idle {
    background: var(--text-muted);
    opacity: 1;
}

.session-hook-dot.running {
    background: var(--accent-yellow);
    box-shadow: 0 0 0 2px rgba(210, 153, 34, 0.18);
}

.session-hook-dot.completed {
    background: var(--accent-green);
    box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.18);
}

.session-hook-dot.waiting_input {
    background: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(163, 113, 247, 0.18);
}

.session-hook-dot.uncertain {
    background: var(--accent-yellow);
    box-shadow: 0 0 0 2px rgba(210, 153, 34, 0.18);
}

.session-hook-dot.ended {
    background: var(--text-muted);
    box-shadow: 0 0 0 2px rgba(110, 118, 129, 0.16);
}

.session-group {
    margin-bottom: 8px;
}

.session-group.has-prompt-plan > .session-item {
    border-left: 3px solid var(--accent-purple);
    background: rgba(163, 113, 247, 0.08);
}

.session-group.prompt-plan-pending > .session-item {
    border-left-color: var(--accent-yellow);
    background: rgba(210, 153, 34, 0.1);
}

.session-group.active > .session-item {
    border-left: 3px solid var(--accent-green);
}

.session-plan-badge {
    border: 1px solid rgba(163, 113, 247, 0.5);
    color: var(--accent-purple);
    border-radius: 999px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
}

.session-plan-badge.pending {
    border-color: rgba(210, 153, 34, 0.6);
    color: var(--accent-yellow);
}

.session-history-section {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.session-history-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    color: var(--text-muted);
    font-size: 0.86em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
}

.session-history-toggle:active {
    color: var(--text-secondary);
}

.session-history-delete-all {
    margin-left: auto;
    padding: 2px 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

.session-history-delete-all:hover {
    opacity: 1;
    color: var(--danger, #e55353);
    border-color: var(--danger, #e55353);
}

.session-history-chevron {
    font-size: 10px;
    transition: transform 0.15s;
}

.session-history-count {
    color: var(--text-muted);
    font-weight: 400;
}

.session-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.session-history-list.collapsed {
    display: none;
}

.windows-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    margin-left: 12px;
}

.window-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.window-item:hover {
    background: var(--bg-tertiary);
}

.window-item.active {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.window-item.current {
    border-color: var(--accent-green);
}

.window-index {
    color: var(--accent-purple);
    font-weight: 600;
    font-family: monospace;
}

.window-name {
    color: var(--text-secondary);
}

.window-active-badge {
    color: var(--accent-green);
    font-weight: bold;
}

.window-group {
    margin-bottom: 4px;
}

.window-group.active > .window-item {
    border-color: var(--accent-blue);
    background: rgba(88, 166, 255, 0.1);
}

.pane-count {
    color: var(--text-muted);
    font-size: 10px;
    margin-left: 4px;
}

.panes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    margin-left: 16px;
}

.pane-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.72em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pane-item:hover {
    background: var(--bg-tertiary);
}

.pane-item.active {
    border-color: var(--accent-yellow);
    background: rgba(210, 153, 34, 0.1);
}

.pane-item.current {
    border-color: var(--accent-green);
}

.pane-index {
    color: var(--accent-yellow);
    font-weight: 600;
    font-family: monospace;
}

.pane-cmd {
    color: var(--text-muted);
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pane-active-badge {
    color: var(--accent-green);
    font-weight: bold;
}

.commit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.commit-item {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 12px;
}

.commit-hash {
    font-family: 'SF Mono', monospace;
    color: var(--accent-purple);
    font-size: 11px;
    flex-shrink: 0;
}

.commit-msg {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.git-changes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.git-file {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
}

.git-file.modified { border-left: 2px solid var(--accent-yellow); }
.git-file.added { border-left: 2px solid var(--accent-green); }
.git-file.deleted { border-left: 2px solid var(--accent-red); }

.process-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-summary-item {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-size: 11px;
    text-align: left;
    cursor: pointer;
}

.session-summary-item:hover,
.session-summary-item:active,
.session-summary-item.active {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
}

.session-summary-main,
.session-summary-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-summary-main {
    justify-content: space-between;
}

.session-summary-name {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-summary-meta,
.session-summary-activity {
    margin-top: 4px;
    color: var(--text-muted);
}

.session-summary-activity {
    display: block;
}

.session-summary-state {
    color: var(--accent-green);
}

.dispatch-details {
    margin: 6px 0 8px 22px;
    color: var(--text-muted);
    font-size: 11px;
}

.dispatch-details summary {
    cursor: pointer;
    user-select: none;
}

.dispatch-grid {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 4px 8px;
    margin-top: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
}

.dispatch-key {
    color: var(--text-muted);
}

.dispatch-value {
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.branch-badge {
    background: var(--accent-purple);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 11px;
}

.footer .time {
    color: var(--text-secondary);
}

.pull-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 200;
}

.pull-indicator.visible {
    opacity: 1;
}

/* Input Panel Styles */
.input-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 12px;
    position: relative;
}

.input-panel-resizer {
    display: none;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.input-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.target-badge, .mode-switch a {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.mode-switch {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mode-switch a.active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.target-badge {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 210px;
}

.send-status {
    flex: 1 0 100%;
    order: 99;
    min-width: 0;
    color: var(--text-muted);
    font-size: 12px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 18px;
}

.send-status.sending {
    color: var(--accent-yellow);
}

.send-status.success {
    color: var(--accent-green);
}

.send-status.error {
    color: var(--accent-red);
}

.quick-actions.send-status-visible {
    flex-wrap: wrap;
}

.plan-mode-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.image-attachments,
.file-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.image-attachments[hidden],
.file-attachments[hidden] {
    display: none;
}

.image-attachment {
    position: relative;
    width: 92px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
}

.image-attachment.uploading {
    opacity: 0.72;
}

.image-attachment.error {
    border-color: var(--accent-red);
}

.image-attachment img,
.image-attachment-placeholder {
    width: 100%;
    height: 64px;
    border-radius: 7px;
    object-fit: cover;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.image-attachment-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    line-height: 18px;
    padding: 0;
}

.image-attachment-meta {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-attachment {
    position: relative;
    width: 180px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
}

.file-attachment.uploading {
    opacity: 0.72;
}

.file-attachment.error {
    border-color: var(--accent-red);
}

.file-attachment-placeholder {
    width: 100%;
    height: 64px;
    border-radius: 7px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.file-attachment-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    line-height: 18px;
    padding: 0;
}

.file-attachment-meta {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 10px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-panel.drag-over,
.session-prompt-panel.drag-over {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.18);
}

.session-prompt-image-attachments {
    flex-shrink: 0;
    margin: 0 0 10px;
    max-height: 132px;
    overflow-y: auto;
}

.input-area {
    width: 100%;
    min-height: 60px;
    max-height: 150px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--composer-font-size);
    padding: 10px;
    resize: vertical;
    margin-bottom: 10px;
}

.input-area:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.input-area.sending {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-yellow) 22%, transparent);
}

.input-area::placeholder {
    color: var(--text-muted);
}

.quick-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    align-items: center;
}

.quick-command-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.quick-command-config-btn {
    flex: 0 0 auto;
}

.universal-prompt-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 6px 8px;
}

.universal-prompt-settings-btn svg {
    transition: transform 0.15s ease;
}

.universal-prompt-settings-btn[aria-expanded="true"] svg {
    transform: rotate(28deg);
}

.quick-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.quick-btn:active {
    background: var(--border);
    transform: scale(0.98);
}

.quick-btn.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.quick-btn.primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.composer-popover-trigger[aria-expanded="true"] {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.composer-settings {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}

.composer-setting {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}

.composer-setting select {
    max-width: 144px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font: inherit;
    padding: 4px 6px;
}

.composer-setting select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.composer-setting select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.model-settings-apply {
    min-width: 46px;
    padding: 4px 10px;
}

.model-settings-apply:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.composer-popover {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(100% + 8px);
    z-index: 260;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
    max-height: min(360px, 55dvh);
    overflow: auto;
}

.composer-popover[hidden] {
    display: none;
}

.session-prompt-prompts-popover {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    flex-shrink: 0;
    max-height: 160px;
}

.composer-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

.composer-section-meta,
.composer-empty {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0;
}

.composer-link-btn {
    background: transparent;
    border: 0;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
}

.input-history,
.custom-prompt-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.history-chip,
.custom-prompt-fill,
.custom-prompt-icon {
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
}

.history-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.history-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-images {
    color: var(--accent-blue);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-prompt-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.custom-prompt-fill {
    color: var(--text-primary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-prompt-icon {
    padding: 3px 6px;
    border-radius: 6px;
}

.custom-prompt-icon.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.custom-prompt-editor {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.custom-prompt-editor[hidden] {
    display: none;
}

.custom-prompt-title,
.custom-prompt-text {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    padding: 8px;
}

.custom-prompt-title:focus,
.custom-prompt-text:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.custom-prompt-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.quick-command-list {
    display: grid;
    gap: 5px;
}

.quick-command-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 5px;
    align-items: center;
}

.quick-command-row .quick-command-send {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.quick-command-row .quick-command-meta {
    color: var(--text-muted);
    font-size: 10px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-command-row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.quick-command-row-actions .custom-prompt-icon:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.quick-command-editor {
    margin-top: 8px;
    display: grid;
    grid-template-columns: minmax(120px, 0.7fr) minmax(160px, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.quick-command-editor[hidden] {
    display: none;
}

.quick-command-label,
.quick-command-text,
.quick-command-kind {
    width: 100%;
    min-width: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    padding: 8px;
}

.quick-command-label:focus,
.quick-command-text:focus,
.quick-command-kind:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.quick-command-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.universal-prompt-popover {
    max-height: min(520px, 65dvh);
}

.universal-prompt-heading {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

.universal-prompt-selection {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 10px;
}

.universal-prompt-selection select {
    min-width: 0;
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font: inherit;
    padding: 6px 8px;
}

.universal-prompt-selection select:focus,
.universal-prompt-selection select:focus-visible {
    outline: none;
    border-color: var(--accent-blue);
}

.universal-prompt-selection select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.universal-prompt-list {
    display: grid;
    gap: 6px;
}

.universal-prompt-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
}

.universal-prompt-row.active {
    border-color: var(--accent-blue);
    box-shadow: inset 3px 0 0 var(--accent-blue);
}

.universal-prompt-row-content {
    min-width: 0;
}

.universal-prompt-row-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}

.universal-prompt-selected {
    flex: 0 0 auto;
    color: var(--accent-blue);
    font-size: 10px;
    font-weight: 500;
}

.universal-prompt-row-preview {
    margin-top: 2px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.universal-prompt-row-actions,
.universal-prompt-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

.universal-prompt-row-actions .custom-prompt-icon:disabled {
    cursor: default;
    opacity: 0.4;
}

.universal-prompt-editor {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.universal-prompt-editor[hidden] {
    display: none;
}

.universal-prompt-title,
.universal-prompt-text {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 12px;
    padding: 8px;
}

.universal-prompt-text {
    min-height: 96px;
    line-height: 1.5;
    resize: vertical;
}

.universal-prompt-title:focus,
.universal-prompt-text:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.universal-prompt-help {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.opencode-run-state {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--accent-yellow);
    border-radius: 5px;
    color: var(--accent-yellow);
    font-size: 11px;
    line-height: 1.6;
    font-weight: 500;
    white-space: nowrap;
}

.opencode-run-state[hidden] {
    display: none;
}

.opencode-control-btn {
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.6;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.opencode-control-btn:hover:not(:disabled) {
    background: var(--border);
}

.opencode-control-btn.danger {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.opencode-control-btn[hidden] {
    display: none;
}

.opencode-control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-btn {
    flex: 1;
    background: var(--accent-green);
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.send-btn:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn.sending {
    background: var(--accent-yellow);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 300;
}

.toast.error {
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.toast.visible {
    opacity: 1;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 20px;
    background: color-mix(in srgb, var(--bg-primary) 88%, #000 12%);
    backdrop-filter: blur(4px);
}

.auth-overlay[hidden] {
    display: none;
}

.auth-dialog {
    width: min(360px, calc(100vw - 40px));
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-secondary);
    box-shadow: 0 18px 50px var(--popover-shadow);
}

.auth-dialog-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent-blue) 14%, transparent);
    color: var(--accent-blue);
}

.auth-dialog-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
}

.auth-dialog-help {
    margin: -5px 0 3px;
    color: var(--text-muted);
    font-size: 12px;
}

.auth-field {
    display: grid;
    gap: 5px;
    color: var(--text-secondary);
    font-size: 12px;
}

.auth-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.auth-remember {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
}

.auth-remember input {
    accent-color: var(--accent-blue);
}

.auth-error {
    margin: 0;
    color: var(--accent-red);
    font-size: 12px;
    line-height: 1.4;
}

.auth-submit {
    min-height: 36px;
    margin-top: 2px;
    border: 1px solid var(--accent-blue);
    border-radius: 8px;
    background: var(--accent-blue);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.auth-submit:hover {
    filter: brightness(1.08);
}

.auth-submit:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .header {
        padding: 8px;
    }

    .header h1 {
        min-width: 0;
        gap: 0;
    }

    .mode-switch {
        gap: 4px;
    }

    .mode-switch a {
        padding: 3px 5px;
        font-size: 11px;
    }

    .claw-brand-mark,
    .claw-brand-name,
    .header h1 > .status-dot {
        display: none;
    }
}

@media (max-width: 360px) {
    .mode-switch a {
        font-size: 10px;
        padding-inline: 4px;
    }
}


.desktop-only {
    display: none;
}

.mobile-only {
    display: inline-flex;
}

.nav-menu-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 8px;
}

.nav-menu-btn.active,
.nav-menu-btn:active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.nav-menu-btn.dirty {
    border-color: var(--accent-yellow);
    color: var(--accent-yellow);
}

.nav-menu-meta {
    color: var(--text-muted);
    font-family: 'SF Mono', 'Menlo', monospace;
}

.display-settings-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.04em;
    cursor: pointer;
}

.display-settings-btn:hover,
.display-settings-btn.active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.display-settings-panel {
    position: fixed;
    top: 56px;
    right: 12px;
    width: min(320px, calc(100vw - 24px));
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 18px 60px var(--popover-shadow);
    z-index: 320;
}

.display-settings-panel[hidden] {
    display: none;
}

.display-settings-header,
.display-font-row,
.display-font-controls {
    display: flex;
    align-items: center;
}

.display-settings-header {
    justify-content: space-between;
    margin-bottom: 12px;
}

.display-settings-title {
    font-size: 14px;
    font-weight: 700;
}

.display-settings-close {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.display-settings-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.display-settings-section + .display-settings-section {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.display-settings-label {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.display-theme-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.display-theme-option {
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.display-theme-option:hover,
.display-theme-option.active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.display-theme-option.active {
    background: color-mix(in srgb, var(--accent-blue) 14%, var(--bg-tertiary));
}

.display-font-list {
    display: grid;
    gap: 8px;
}

.display-font-row {
    justify-content: space-between;
    gap: 12px;
}

.display-font-name {
    color: var(--text-secondary);
    font-size: 12px;
}

.display-font-controls {
    gap: 5px;
}

.display-font-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.display-font-btn:hover {
    border-color: var(--accent-blue);
}

.display-font-value {
    min-width: 42px;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 11px;
    text-align: center;
}

.display-settings-reset {
    width: 100%;
    margin-top: 12px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.display-settings-reset:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}

.sidebar-collapse-btn:hover,
.sidebar-collapse-btn:active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.sidebar-collapse-btn svg {
    transition: transform 0.18s ease;
}

.sidebar-resizer {
    display: none;
}

@media (min-width: 960px) {
    :root {
        --nav-height: 56px;
        --sidebar-width: 320px;
        --sidebar-collapsed-width: 48px;
        --composer-max-width: 920px;
        --popover-width: 440px;
        --prompt-width: 720px;
        --terminal-width: 520px;
        --terminal-collapsed-width: 48px;
    }

    body {
        height: 100dvh;
        overflow: hidden;
    }

    /* Keep the shell's top margin inside the viewport. Otherwise it collapses
       through body and leaves a nav-height document scroll range. */
    body:not(.schedule-mode):not(.common-settings-mode) {
        display: flow-root;
    }

    .desktop-only {
        display: inline-flex;
    }

    .mobile-only {
        display: none;
    }

    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--nav-height);
        padding: 8px 16px;
        z-index: 200;
    }

    .header h1 {
        min-width: var(--sidebar-width);
        font-size: 16px;
    }

    .header-actions {
        gap: 10px;
    }

    .container.app-shell {
        height: calc(100dvh - var(--nav-height));
        margin-top: var(--nav-height);
        padding: 0;
        max-width: none;
        display: grid;
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "sessions terminal"
            "sessions usage"
            "sessions input";
        min-height: 0;
        background: var(--bg-secondary);
        transition: grid-template-columns 0.18s ease;
    }

    body.sidebar-collapsed .container.app-shell {
        grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
    }

    body.session-prompt-open .container.app-shell {
        grid-template-columns: var(--sidebar-width) minmax(360px, 1fr) var(--terminal-width);
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas:
            "sessions prompt terminal"
            "sessions prompt usage";
    }

    body.sidebar-collapsed.session-prompt-open .container.app-shell {
        grid-template-columns: var(--sidebar-collapsed-width) minmax(360px, 1fr) var(--terminal-width);
    }

    body.session-prompt-open.terminal-collapsed .container.app-shell {
        grid-template-columns: var(--sidebar-width) minmax(360px, 1fr);
        grid-template-areas:
            "sessions prompt"
            "sessions prompt";
    }

    body.sidebar-collapsed.session-prompt-open.terminal-collapsed .container.app-shell {
        grid-template-columns: var(--sidebar-collapsed-width) minmax(360px, 1fr);
    }

    .session-prompt-panel {
        position: static;
        grid-area: prompt;
        width: auto;
        height: auto;
        min-height: 0;
        box-shadow: none;
        z-index: auto;
        border-left: 0;
        border-right: 1px solid var(--border);
        padding: 14px 16px;
        overflow: hidden;
    }

    body.session-prompt-open #inputPanel {
        display: none;
    }

    body.session-prompt-open .session-prompt-textarea {
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        resize: none;
        font-size: 14px;
    }

    body.prompt-template-collapsed #promptOptimizeTemplatePanel {
        display: none;
    }

    body.prompt-template-open #promptOptimizeTemplatePanel {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        max-height: 220px;
        gap: 8px;
    }

    .stats-grid {
        position: fixed;
        top: 8px;
        left: calc(var(--sidebar-width) + 24px);
        right: 390px;
        z-index: 210;
        display: flex;
        justify-content: center;
        gap: 8px;
        margin: 0;
        pointer-events: none;
    }

    .stat-card {
        display: flex;
        align-items: baseline;
        gap: 6px;
        min-width: 92px;
        padding: 6px 10px;
        border-radius: 999px;
        background: var(--stat-card-bg);
        backdrop-filter: blur(10px);
        pointer-events: auto;
    }

    .stat-value {
        font-size: 14px;
    }

    .stat-label {
        margin: 0;
        font-size: 10px;
    }

    .toast {
        bottom: 112px;
    }

    #sessionsCard {
        grid-area: sessions;
        margin: 0;
        border-top: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 0;
        background: var(--bg-primary);
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #sessionsCard .card-header {
        cursor: default;
        padding: 14px 14px 10px;
    }

    #sessionsCard .card-chevron {
        display: none;
    }

    #sessionsCard .card-content {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        padding: 0 10px 12px;
    }

    #sessionsCard.collapsed .card-content {
        display: flex;
    }

    #sessionList {
        flex: 1 1 auto;
        min-height: 84px;
        max-height: none;
        overflow-y: auto;
        padding-right: 4px;
    }

    .file-browser {
        flex: 0 0 var(--file-browser-height, 58%);
        min-height: 140px;
        margin-top: 0;
        padding-top: 8px;
    }

    .file-browser-resizer {
        position: relative;
        display: block;
        flex: 0 0 10px;
        height: 10px;
        margin: 2px 0 0;
        cursor: row-resize;
        touch-action: none;
    }

    .file-browser-resizer::after {
        content: '';
        position: absolute;
        top: 4px;
        left: 8px;
        right: 8px;
        height: 1px;
        background: var(--border);
        transition: height 0.15s, background 0.15s;
    }

    .file-browser-resizer:hover::after,
    .file-browser-resizer:focus-visible::after,
    body.file-browser-resizing .file-browser-resizer::after {
        height: 2px;
        background: var(--accent-blue);
    }

    body.file-browser-resizing {
        cursor: row-resize;
        user-select: none;
    }

    body.file-browser-collapsed #sessionList {
        flex: 1 1 auto;
    }

    body.file-browser-collapsed .file-browser-resizer {
        display: none;
    }

    body.file-browser-collapsed .file-browser {
        flex: 0 0 38px;
        min-height: 38px;
        margin-top: 4px;
        padding-top: 0;
        gap: 0;
    }

    body.file-browser-collapsed .file-browser-header {
        flex: 1;
        min-height: 38px;
    }

    body.file-browser-collapsed .file-browser > :not(.file-browser-header) {
        display: none;
    }

    .file-browser-list {
        flex: 1;
        min-height: 0;
        max-height: none;
    }

    .session-toolbar {
        flex-shrink: 0;
    }

    .session-toolbar .quick-btn {
        min-width: 0;
        padding: 6px 8px;
    }

    .session-item {
        align-items: stretch;
        flex-direction: column;
        gap: 7px;
        padding: 10px;
    }

    .session-title-row {
        min-width: 0;
        width: 100%;
    }

    .session-name {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex-wrap: nowrap;
    }

    /* 桌面端恢复会话类型徽章（手机端隐藏，桌面侧栏保留） */
    .session-name .card-badge {
        display: inline-block;
    }

    .session-actions {
        flex-shrink: 0;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .copy-session-btn {
        padding: 3px 6px;
        font-size: 0.72em;
    }

    #terminalCard {
        grid-area: terminal;
        margin: 0;
        border: 0;
        border-radius: 0;
        background: var(--bg-secondary);
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #terminalCard .card-header {
        flex-shrink: 0;
        cursor: default;
        padding: 12px 18px;
    }

    #terminalCard .terminal-lines-select {
        margin-right: 0;
    }

    body.session-prompt-open.terminal-collapsed #terminalCard {
        display: none;
    }

    body.session-prompt-open #terminalDockToggleBtn svg {
        transform: rotate(180deg);
    }

    body.session-prompt-open.terminal-collapsed #terminalDockToggleBtn svg {
        transform: none;
    }

    #terminalCard .card-chevron {
        display: none;
    }

    #terminalCard.collapsed .card-content {
        display: flex;
    }

    #terminalCard .card-content {
        flex: 1;
        min-height: 0;
        display: flex;
        padding: 0 16px 12px;
        overflow: hidden;
    }

    .terminal {
        flex: 1;
        min-height: 0;
        max-height: none;
        width: 100%;
        font-size: var(--terminal-font-size);
    }

    #terminalCard .terminal {
        background: var(--terminal-bg);
    }

    #inputPanel {
        grid-area: input;
        width: calc(100% - 32px);
        height: var(--input-panel-height, auto);
        min-height: 104px;
        justify-self: stretch;
        margin: 0 16px 8px;
        padding: 8px;
        border-radius: 16px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
        display: flex;
        flex-direction: column;
    }

    .input-panel-resizer {
        position: absolute;
        top: -10px;
        left: 0;
        right: 0;
        z-index: 5;
        display: block;
        height: 12px;
        cursor: row-resize;
        touch-action: none;
    }

    .input-panel-resizer::after {
        content: '';
        position: absolute;
        top: 5px;
        left: 8px;
        right: 8px;
        height: 1px;
        background: var(--border);
        transition: height 0.15s, background 0.15s;
    }

    .input-panel-resizer:hover::after,
    .input-panel-resizer:focus-visible::after,
    body.input-panel-resizing .input-panel-resizer::after {
        height: 2px;
        background: var(--accent-blue);
    }

    body.input-panel-resizing {
        cursor: row-resize;
        user-select: none;
    }

    #inputPanel .input-header {
        display: none;
    }

    .input-area {
        flex: 1 1 auto;
        height: auto;
        min-height: 42px;
        max-height: none;
        padding: 9px 10px;
        margin-bottom: 6px;
        resize: none;
    }

    .quick-actions {
        flex: 0 0 auto;
        gap: 4px;
        margin-bottom: 6px;
        flex-wrap: nowrap;
    }

    .quick-command-buttons {
        gap: 4px;
        flex: 1 1 auto;
        min-width: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .quick-command-buttons .quick-btn {
        flex: 0 0 auto;
    }

    .quick-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    .composer-settings {
        width: auto;
        margin-left: auto;
        gap: 4px;
        flex-shrink: 0;
    }

    .composer-setting {
        flex: 0 0 auto;
    }

    .composer-setting select {
        flex: 0 0 auto;
        width: 132px;
        max-width: 132px;
        min-width: 0;
    }

    #reasoningSelect {
        width: 104px;
        max-width: 104px;
    }

    .composer-popover {
        left: 8px;
        right: 8px;
        bottom: calc(100% + 6px);
        max-height: min(320px, 50dvh);
    }

    .composer-section-header {
        margin-bottom: 4px;
        font-size: 10px;
    }

    .input-history {
        max-height: 52px;
        overflow-y: auto;
        gap: 4px;
    }

    .custom-prompt-list {
        gap: 4px;
    }

    .history-chip,
    .custom-prompt-fill,
    .custom-prompt-icon {
        padding: 3px 7px;
        font-size: 10px;
    }

    .custom-prompt-editor {
        grid-template-columns: minmax(140px, 0.35fr) minmax(220px, 1fr) auto;
        align-items: start;
        gap: 6px;
    }

    .custom-prompt-text {
        max-height: 72px;
        resize: vertical;
    }

    .custom-prompt-actions {
        flex-direction: column;
    }

    .quick-command-editor {
        grid-template-columns: 1fr;
    }

    .quick-command-actions {
        flex-direction: column;
    }

    .input-actions {
        display: none;
    }

    .nav-popover-card {
        position: fixed;
        top: calc(var(--nav-height) + 8px);
        right: 16px;
        width: min(var(--popover-width), calc(100vw - 32px));
        max-height: calc(100dvh - var(--nav-height) - 24px);
        overflow: auto;
        z-index: 240;
        margin: 0;
        display: none;
        box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
    }

    .nav-popover-card.dropdown-open {
        display: block;
    }

    .nav-popover-card.dropdown-open .card-content,
    .nav-popover-card.collapsed.dropdown-open .card-content {
        display: block;
    }

    .nav-popover-card .card-header {
        cursor: default;
    }

    .nav-popover-card .card-chevron {
        display: none;
    }

    .sidebar-resizer,
    .prompt-terminal-resizer {
        display: block;
        position: fixed;
        top: var(--nav-height);
        bottom: 0;
        width: 6px;
        z-index: 220;
        cursor: col-resize;
    }

    .sidebar-resizer {
        left: calc(var(--sidebar-width) - 3px);
    }

    .prompt-terminal-resizer {
        display: none;
        left: calc(var(--sidebar-width) + var(--prompt-width) - 3px);
    }

    body.session-prompt-open:not(.terminal-collapsed) .prompt-terminal-resizer {
        display: block;
    }

    body.sidebar-collapsed.session-prompt-open:not(.terminal-collapsed) .prompt-terminal-resizer {
        left: calc(var(--sidebar-collapsed-width) + var(--prompt-width) - 3px);
    }

    .sidebar-resizer::after,
    .prompt-terminal-resizer::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 2px;
        width: 1px;
        background: transparent;
        transition: background 0.15s;
    }

    .sidebar-resizer:hover::after,
    .prompt-terminal-resizer:hover::after,
    body.sidebar-resizing .sidebar-resizer::after,
    body.prompt-terminal-resizing .prompt-terminal-resizer::after {
        background: var(--accent-blue);
    }

    body.sidebar-resizing,
    body.prompt-terminal-resizing {
        cursor: col-resize;
        user-select: none;
    }

    body.sidebar-collapsed .stats-grid {
        left: calc(var(--sidebar-collapsed-width) + 24px);
    }

    body.session-prompt-open .stats-grid {
        left: calc(var(--sidebar-width) + 24px);
        right: 24px;
    }

    body.sidebar-collapsed.session-prompt-open .stats-grid {
        left: calc(var(--sidebar-collapsed-width) + 160px);
    }

    body.sidebar-collapsed #sessionsCard .card-header {
        justify-content: center;
        padding: 12px 6px;
    }

    body.sidebar-collapsed #sessionsCard .card-title,
    body.sidebar-collapsed #sessionsCard .card-content,
    body.sidebar-collapsed .sidebar-resizer {
        display: none;
    }

    body.sidebar-collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }

    .pull-indicator,
    .footer {
        display: none;
    }
}

[hidden] {
    display: none !important;
}

body.schedule-mode {
    min-height: 100dvh;
    height: auto;
    overflow: auto;
}

body[data-page="accounts"] {
    min-height: 100dvh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
}

body.schedule-mode #gitMenuBtn,
body.schedule-mode #processMenuBtn {
    display: none !important;
}

.scheduled-tasks-page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.scheduled-tasks-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.scheduled-tasks-kicker {
    margin: 0 0 4px;
    color: var(--accent-purple);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.scheduled-tasks-hero h2 {
    margin: 0;
    font-size: clamp(25px, 3vw, 36px);
    line-height: 1.2;
}

.scheduled-tasks-intro {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--text-secondary);
}

.scheduled-tasks-updated {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    color: var(--text-muted);
    font-size: 11px;
}

.scheduled-tasks-updated time {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.scheduled-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 0.7fr) minmax(280px, 1.6fr);
    gap: 12px;
    margin-bottom: 16px;
}

.scheduled-summary-card {
    min-height: 104px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-secondary);
    box-shadow: 0 8px 28px var(--popover-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.scheduled-summary-label {
    color: var(--text-muted);
    font-size: 12px;
}

.scheduled-summary-card strong {
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1.2;
}

.scheduled-summary-card-wide strong {
    font-size: 16px;
}

.scheduled-tasks-panel {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    box-shadow: 0 12px 36px var(--popover-shadow);
}

.scheduled-tasks-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.scheduled-tasks-panel-header h3 {
    margin: 0;
    font-size: 16px;
}

.scheduled-tasks-panel-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.scheduled-source-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.scheduled-source-pill,
.scheduled-task-source,
.scheduled-task-status {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.scheduled-source-pill {
    appearance: none;
    gap: 5px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.scheduled-source-pill:hover,
.scheduled-source-pill:focus-visible {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.scheduled-source-pill.active {
    border-color: color-mix(in srgb, var(--accent-purple) 70%, var(--border));
    color: var(--accent-purple);
    background: color-mix(in srgb, var(--accent-purple) 14%, var(--bg-tertiary));
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-purple) 10%, transparent);
}

.scheduled-source-pill i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
}

.scheduled-source-pill.error i {
    background: var(--accent-red);
}

.scheduled-task-list {
    padding: 10px;
}

.scheduled-task-card {
    padding: 16px;
    border: 1px solid transparent;
    border-bottom-color: var(--border);
}

.scheduled-task-card:last-child {
    border-bottom-color: transparent;
}

.scheduled-task-card:hover {
    border-color: var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.scheduled-task-heading,
.scheduled-task-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.scheduled-task-heading > div {
    min-width: 0;
}

.scheduled-task-title-row {
    justify-content: flex-start;
    align-items: center;
}

.scheduled-task-title-row h4 {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 15px;
}

.scheduled-task-description {
    margin: 5px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.scheduled-task-source {
    flex: 0 0 auto;
    padding: 4px 8px;
    color: var(--accent-purple);
    background: color-mix(in srgb, var(--accent-purple) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent-purple) 30%, var(--border));
}

.scheduled-task-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scheduled-run-now {
    appearance: none;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--accent-blue) 45%, var(--border));
    border-radius: 8px;
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 10%, transparent);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
}

.scheduled-run-now:hover,
.scheduled-run-now:focus-visible {
    background: color-mix(in srgb, var(--accent-blue) 18%, transparent);
}

.scheduled-run-now:disabled {
    cursor: wait;
    opacity: 0.58;
}

.scheduled-delete {
    appearance: none;
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--accent-red) 45%, var(--border));
    border-radius: 8px;
    color: var(--accent-red);
    background: color-mix(in srgb, var(--accent-red) 8%, transparent);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
}

.scheduled-delete:hover,
.scheduled-delete:focus-visible {
    background: color-mix(in srgb, var(--accent-red) 16%, transparent);
}

.scheduled-delete:disabled {
    cursor: wait;
    opacity: 0.58;
}

.scheduled-task-status {
    flex: 0 0 auto;
    padding: 2px 7px;
}

.scheduled-task-status.enabled,
.scheduled-task-status.queued {
    color: var(--accent-green);
    background: color-mix(in srgb, var(--accent-green) 12%, transparent);
}

.scheduled-task-status.running {
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
}

.scheduled-task-status.disabled {
    color: var(--text-muted);
    background: var(--bg-tertiary);
}

.scheduled-task-status.deployment-failed {
    color: var(--accent-red);
    background: color-mix(in srgb, var(--accent-red) 13%, transparent);
}

.scheduled-task-status.abnormal-exit {
    color: var(--accent-yellow);
    background: color-mix(in srgb, var(--accent-yellow) 14%, transparent);
}

.scheduled-task-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.scheduled-task-detail {
    min-width: 0;
    padding-left: 12px;
    border-left: 2px solid var(--border);
}

.scheduled-task-detail-next {
    border-left-color: var(--accent-blue);
}

.scheduled-task-detail > span,
.scheduled-task-detail > strong,
.scheduled-task-detail > small {
    display: block;
}

.scheduled-task-detail > span {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.scheduled-task-detail > strong {
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}

.scheduled-task-detail > small {
    margin-top: 2px;
    color: var(--accent-blue);
    font-size: 11px;
}

.scheduled-empty-state {
    padding: 54px 20px;
    color: var(--text-muted);
    text-align: center;
}

.scheduled-empty-state.error {
    color: var(--accent-red);
}

/* 账号与额度页，以及 Batch 页顶部的只读批次总览。 */
.accounts-page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
    padding-top: 36px;
}

.accounts-hero,
.accounts-panel-heading,
.batch-overview-header,
.batch-log-viewer-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
}

.accounts-hero { margin-bottom: 22px; }
.accounts-kicker,
.batch-overview-kicker {
    margin: 0 0 4px;
    color: var(--accent-purple);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.accounts-hero h2,
.batch-overview-header h2 { margin: 0; font-size: clamp(25px, 3vw, 36px); line-height: 1.2; }
.accounts-intro,
.accounts-panel-heading p,
.batch-overview-header p { margin: 7px 0 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; }
.accounts-timezone,
.quota-refresh-note { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.accounts-panel {
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-secondary);
}
.accounts-panel-heading { align-items: center; margin-bottom: 16px; }
.accounts-panel-heading h3 { margin: 0; font-size: 18px; }
.accounts-panel-heading p { max-width: 720px; }
.member-form {
    display: grid;
    grid-template-columns: minmax(140px, 0.8fr) minmax(200px, 1.5fr) minmax(160px, 0.9fr) auto;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
}
.account-field { display: flex; min-width: 0; flex-direction: column; gap: 6px; color: var(--text-muted); font-size: 12px; }
.account-field input,
.account-field select,
.quota-threshold-form input {
    min-width: 0;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
}
.member-form-actions { display: flex; gap: 8px; }
.member-list { display: grid; gap: 8px; margin-top: 14px; }
.member-row {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(150px, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-primary);
}
.member-row-main,
.member-row-expiry { display: grid; gap: 4px; min-width: 0; }
.member-row-main strong { color: var(--text-primary); font-size: 14px; }
.member-row-main span,
.member-row-expiry time { overflow-wrap: anywhere; color: var(--text-muted); font-size: 12px; }
.member-state-label { color: var(--accent-green); font-size: 12px; font-weight: 600; }
.member-state-expiring .member-state-label,
.member-state-today .member-state-label { color: var(--accent-orange, #d29922); }
.member-state-expired .member-state-label,
.member-state-invalid .member-state-label { color: var(--accent-red); }
 .codex-session-account { white-space: nowrap; }
.codex-session-switch { margin-left: auto; white-space: nowrap; }
.accounts-empty { padding: 24px 12px; color: var(--text-muted); text-align: center; font-size: 13px; }
.accounts-message { margin-bottom: 14px; padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent-green) 12%, var(--bg-secondary)); color: var(--text-primary); font-size: 13px; }
.accounts-message.error { background: color-mix(in srgb, var(--accent-red) 12%, var(--bg-secondary)); color: var(--accent-red); }
/* 卡片按内容高度自适应排入两列，短卡片会补到长卡片下方的空档，不留整列空白。 */
.quota-grid { display: block; columns: 2; column-gap: 12px; }
.quota-card { min-width: 0; margin: 0 0 12px; padding: 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg-primary); break-inside: avoid; }
.quota-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quota-card-heading h4 { margin: 0; font-size: 15px; }
.quota-status { padding: 3px 8px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.quota-state-ok .quota-status { color: var(--accent-green); }
.quota-state-failed .quota-status { color: var(--accent-red); }
.quota-account-note,
.quota-purpose { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; }
.quota-balance-row { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 10px; color: var(--text-muted); font-size: 12px; }
.quota-balance-row strong { color: var(--text-primary); font-size: 21px; font-variant-numeric: tabular-nums; }
.quota-low-balance { color: var(--accent-red); font-weight: 700; }
.quota-details { display: grid; gap: 7px; margin: 0; }
.quota-details div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; font-size: 11px; }
.quota-details dt { color: var(--text-muted); }
.quota-details dd { margin: 0; overflow-wrap: anywhere; color: var(--text-primary); }
.quota-threshold-form { display: flex; align-items: end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.quota-threshold-form label { display: grid; flex: 1; gap: 5px; color: var(--text-muted); font-size: 11px; }
.quota-threshold-form input { width: 100%; min-height: 34px; }
.quota-threshold-form button { min-height: 34px; }
.quota-query-error { margin: 10px 0 0; color: var(--accent-red); font-size: 12px; }
.quota-key-manager { display: grid; gap: 8px; margin-top: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-secondary); }
.quota-key-heading,
.quota-key-current { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.quota-key-heading { justify-content: space-between; color: var(--text-muted); font-size: 11px; }
.quota-key-heading strong { color: var(--text-primary); font-size: 12px; }
.quota-key-value { flex: 1 1 150px; min-width: 0; padding: 7px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-primary); color: var(--text-primary); font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; white-space: normal; }
.quota-key-save-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.quota-key-save-form .account-field { min-width: 0; }
.quota-key-save-form .account-field input { width: 100%; }
.quota-key-save-form button { min-height: 38px; }
.quota-key-feedback { margin: 0; color: var(--text-muted); font-size: 11px; overflow-wrap: anywhere; }
.quota-key-feedback:empty { display: none; }
.quota-key-feedback.error { color: var(--accent-red); }
.quota-key-pager { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 7px; color: var(--text-muted); font-size: 11px; }
.quota-key-pager span { flex: 1 1 auto; text-align: center; }

.batch-overview-panel[hidden],
.batch-log-viewer[hidden] { display: none; }
.batch-overview-panel {
    position: fixed;
    top: var(--nav-height, 56px);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 150;
    margin: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 0;
    background: var(--bg-secondary);
    overflow: auto;
}
.batch-overview-header { align-items: center; margin-bottom: 14px; }
.batch-overview-header h2 { font-size: 22px; }
.batch-overview-header p { font-size: 12px; }
.batch-overview-status { margin: 8px 0; color: var(--text-muted); font-size: 12px; }
.batch-overview-status.error { color: var(--accent-red); }
.batch-overview-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.batch-overview-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.batch-overview-table th,
.batch-overview-table td { min-width: 100px; padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.batch-overview-table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.batch-overview-table td:first-child { min-width: 190px; }
.batch-overview-table td:nth-child(5) { min-width: 160px; }
.batch-overview-table td:last-child { min-width: 130px; }
.batch-overview-table small { display: block; margin-top: 4px; overflow-wrap: anywhere; color: var(--text-muted); font-size: 10px; }
.batch-status-text { color: var(--accent-blue); }
.batch-failure-reason { color: var(--accent-red); overflow-wrap: anywhere; }
.batch-muted { color: var(--text-muted); }
.batch-overview-actions { display: grid; justify-items: start; gap: 5px; }
.batch-session-link,
.batch-log-link { padding: 0; border: 0; background: none; color: var(--accent-blue); font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer; }
.site-status-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.site-status-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.site-status-header h3 { margin: 0; font-size: 16px; }
.site-status-header p { margin: 5px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.site-status-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.site-status-controls input,
.site-status-controls select { min-height: 32px; max-width: 220px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-primary); color: var(--text-primary); font: inherit; font-size: 11px; }
.site-status-controls input:focus,
.site-status-controls select:focus { outline: none; border-color: var(--accent-blue); }
.site-status-message { margin: 8px 0; color: var(--text-muted); font-size: 11px; }
.site-status-message.error { color: var(--accent-red); }
.site-status-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.site-status-table { width: 100%; min-width: 1120px; border-collapse: collapse; font-size: 11px; text-align: left; }
.site-status-table th,
.site-status-table td { min-width: 105px; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.site-status-table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.site-status-table td:first-child { min-width: 190px; }
.site-status-table td:nth-child(4) { min-width: 170px; }
.site-status-table td a { color: var(--accent-blue); font-weight: 600; text-decoration: none; }
.site-status-table td a:hover { text-decoration: underline; }
.site-status-table small { display: block; margin-top: 4px; overflow-wrap: anywhere; color: var(--text-muted); font-size: 10px; }
.site-status-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--text-muted) 12%, transparent); color: var(--text-muted); font-size: 10px; line-height: 1.5; white-space: nowrap; }
.site-status-badge.done,
.site-status-badge.deployed { background: color-mix(in srgb, var(--accent-green) 14%, transparent); color: var(--accent-green); }
.site-status-badge.running { background: color-mix(in srgb, var(--accent-blue) 14%, transparent); color: var(--accent-blue); }
.site-status-badge.pending { background: color-mix(in srgb, var(--accent-yellow) 14%, transparent); color: var(--accent-yellow); }
.site-status-badge.failed { background: color-mix(in srgb, var(--accent-red) 14%, transparent); color: var(--accent-red); }
.site-status-badge.retired { background: color-mix(in srgb, var(--accent-red) 12%, transparent); color: var(--accent-red); }
.batch-log-viewer { margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-primary); }
.batch-log-viewer-header { align-items: center; }
.batch-log-viewer-header h3 { margin: 0; font-size: 14px; }
.batch-log-viewer pre { max-height: 420px; margin: 10px 0 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-primary); font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 760px) {
    .accounts-page { width: calc(100% - 20px); margin-top: 18px; padding-top: 36px; }
    .accounts-hero,
    .accounts-panel-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
    .accounts-timezone,
    .quota-refresh-note { white-space: normal; }
    .accounts-panel { padding: 14px; }
    .member-form { grid-template-columns: 1fr 1fr; }
    .member-form .account-field-wide { grid-column: 1 / -1; }
    .member-form-actions { grid-column: 1 / -1; }
    .member-row { grid-template-columns: minmax(0, 1fr) auto; }
    .member-row-expiry { grid-column: 1; }
    .member-edit-btn { grid-column: 2; grid-row: 1 / span 2; }
    .quota-grid { columns: 1; }
    .quota-key-save-form { grid-template-columns: minmax(0, 1fr) auto; }
    .batch-overview-panel { padding: 12px; }
    .batch-overview-header { align-items: flex-start; }
    .batch-overview-table { min-width: 800px; }
    .site-status-header { align-items: flex-start; flex-direction: column; }
    .site-status-controls { width: 100%; }
    .site-status-controls input { flex: 1 1 160px; max-width: none; }
}

/* 常用变量页。复用定时任务页的版式节奏（hero + 面板 + 卡片），只是内容是表单。 */
.common-settings-page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.common-settings-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.common-settings-kicker {
    margin: 0 0 4px;
    color: var(--accent-purple);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.common-settings-hero h2 {
    margin: 0;
    font-size: clamp(25px, 3vw, 36px);
    line-height: 1.2;
}

.common-settings-intro {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--text-secondary);
}

.common-settings-updated {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    color: var(--text-muted);
    font-size: 11px;
}

.common-settings-updated time {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.common-settings-status {
    margin-bottom: 14px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
}

.common-settings-status.error {
    border-color: color-mix(in srgb, var(--accent-red) 45%, var(--border));
    color: var(--accent-red);
}

.common-settings-panel {
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--bg-secondary);
    box-shadow: 0 12px 36px var(--popover-shadow);
}

.common-settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.common-settings-panel-header h3 {
    margin: 0;
    font-size: 16px;
}

.common-settings-panel-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.common-settings-reload {
    appearance: none;
    flex: 0 0 auto;
    min-height: 30px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
}

.common-settings-reload:hover,
.common-settings-reload:focus-visible {
    border-color: var(--accent-purple);
    color: var(--text-primary);
}

.common-settings-platform {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.common-settings-platform:last-child {
    border-bottom: none;
}

.common-settings-platform-name {
    display: block;
    margin-bottom: 10px;
    color: var(--accent-purple);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.common-settings-account-list {
    display: grid;
    gap: 8px;
}

.common-settings-account {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
    cursor: pointer;
}

.common-settings-account:hover {
    border-color: color-mix(in srgb, var(--accent-purple) 45%, var(--border));
}

/* 不可采集的账号行：说明它为什么点不动，而不是看起来能勾。 */
.common-settings-account.disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

.common-settings-account.disabled:hover {
    border-color: var(--border);
}

.common-settings-account-check {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--accent-purple);
    cursor: pointer;
}

.common-settings-account-body {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.common-settings-account-name {
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.common-settings-account-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: var(--text-muted);
    font-size: 11px;
}

/* 部署区右上角的模板 profile 徽标：文案由当前勾选推导，不是已保存值。 */
.common-settings-profile {
    flex: 0 0 auto;
    display: grid;
    justify-items: end;
    gap: 4px;
    max-width: 340px;
    text-align: right;
}

.common-settings-profile-badge {
    padding: 3px 10px;
    border-radius: 999px;
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 14%, transparent);
    font-size: 12px;
    font-weight: 700;
}

.common-settings-profile-badge.blocked {
    color: var(--accent-yellow);
    background: color-mix(in srgb, var(--accent-yellow) 14%, transparent);
}

.common-settings-profile-note {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.common-settings-deploy-list {
    display: grid;
    gap: 12px;
    padding: 16px 20px;
}

/* 每个平台一张卡：启用开关 + 仅本平台的账号下拉 + 不可用原因。 */
.common-settings-deploy {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-tertiary);
}

.common-settings-deploy.enabled {
    border-color: color-mix(in srgb, var(--accent-blue) 45%, var(--border));
}

.common-settings-deploy-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.common-settings-deploy-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.common-settings-deploy-check {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.common-settings-deploy-check:disabled {
    cursor: not-allowed;
}

.common-settings-deploy-check:disabled + .common-settings-deploy-name {
    opacity: 0.72;
}

.common-settings-deploy-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.common-settings-deploy-state {
    padding: 2px 9px;
    border-radius: 999px;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    font-size: 11px;
    font-weight: 700;
}

.common-settings-deploy-state.on {
    color: var(--accent-blue);
    background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
}

.common-settings-deploy-owner {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 11px;
}

.common-settings-deploy-body {
    display: grid;
    gap: 7px;
    margin-top: 12px;
}

/* 卡片内的账号下拉沿用 .common-settings-select 的外观，只是不必那么宽。 */
.common-settings-deploy-account {
    max-width: 100%;
}

@media (max-width: 760px) {
    .common-settings-profile {
        justify-items: start;
        max-width: none;
        text-align: left;
    }
}

.common-settings-field {
    display: grid;
    gap: 7px;
    padding: 16px 20px;
}

.common-settings-field-label {
    color: var(--text-muted);
    font-size: 12px;
}

.common-settings-select,
.common-settings-input {
    width: 100%;
    max-width: 460px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
}

.common-settings-select:focus,
.common-settings-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.common-settings-select:disabled,
.common-settings-input:disabled {
    cursor: default;
    opacity: 0.65;
}

.common-settings-field-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin: 0;
    color: var(--text-muted);
    font-size: 11px;
}

.common-settings-batch-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    padding: 0 20px 18px;
}

.common-settings-batch-grid .common-settings-field {
    padding: 0;
}

.common-settings-browser-pool {
    display: grid;
    gap: 9px;
    padding: 16px 20px 8px;
}

.common-settings-browser-instance {
    display: grid;
    grid-template-columns: minmax(90px, 160px) minmax(120px, 1fr) auto;
    align-items: end;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.common-settings-browser-instance .common-settings-field {
    padding: 0;
}

.common-settings-browser-enabled {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    color: var(--text-secondary);
    font-size: 12px;
}

.common-settings-browser-pool-interval {
    max-width: 460px;
}

@media (max-width: 600px) {
    .common-settings-browser-instance {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .common-settings-browser-enabled {
        grid-column: 1 / -1;
    }
}

.common-settings-field-warning {
    color: var(--accent-yellow);
}

.common-settings-llm-enabled {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 30px;
    color: var(--text-secondary);
    font-size: 12px;
}

.common-settings-llm-enabled input {
    margin: 0;
    accent-color: var(--accent-purple);
}

.common-settings-policy {
    display: grid;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.common-settings-policy > label {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-tertiary);
    cursor: pointer;
}

.common-settings-policy > label.disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

.common-settings-policy input {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin: 2px 0 0;
    accent-color: var(--accent-purple);
}

.common-settings-policy-body {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.common-settings-policy-name {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.common-settings-policy-detail {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.common-settings-policy-blocked {
    color: var(--accent-yellow);
    font-size: 11px;
}

.common-settings-verification {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 14px 20px;
    color: var(--text-muted);
    font-size: 12px;
}

.common-settings-verification-state {
    padding: 3px 9px;
    border-radius: 999px;
    color: var(--accent-yellow);
    background: color-mix(in srgb, var(--accent-yellow) 14%, transparent);
    font-size: 11px;
    font-weight: 700;
}

.common-settings-verification.verified .common-settings-verification-state {
    color: var(--accent-green);
    background: color-mix(in srgb, var(--accent-green) 14%, transparent);
}

.common-settings-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}

/* 研究分析模型自己的保存行：独立 revision、独立按钮，不参与上方常用变量的保存。 */
.common-settings-research-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

.common-settings-revision-tag {
    color: var(--text-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.common-settings-save-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.common-settings-save {
    appearance: none;
    min-height: 36px;
    padding: 8px 22px;
    border: 1px solid var(--accent-blue);
    border-radius: 8px;
    background: var(--accent-blue);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
}

.common-settings-save:hover:not(:disabled) {
    filter: brightness(1.08);
}

.common-settings-save:disabled {
    cursor: default;
    opacity: 0.55;
}

.common-settings-empty {
    padding: 26px 20px;
    color: var(--text-muted);
    text-align: center;
}

.common-settings-empty.error {
    color: var(--accent-red);
}

body.common-settings-mode {
    min-height: 100dvh;
    height: auto;
    overflow: auto;
}

@media (max-width: 600px) {
    .common-settings-batch-grid {
        grid-template-columns: 1fr;
        padding: 0 16px 16px;
    }
}

body.common-settings-mode #gitMenuBtn,
body.common-settings-mode #processMenuBtn {
    display: none !important;
}

@media (min-width: 960px) {
    body.schedule-mode .header h1,
    body.common-settings-mode .header h1 {
        min-width: 0;
    }

    .scheduled-tasks-page {
        margin-top: calc(var(--nav-height) + 28px);
    }

    .common-settings-page {
        margin-top: calc(var(--nav-height) + 28px);
    }
}

@media (max-width: 760px) {
    .scheduled-tasks-page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .common-settings-page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .common-settings-hero,
    .common-settings-panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .common-settings-updated {
        align-items: flex-start;
    }

    .common-settings-actions {
        justify-content: stretch;
    }

    .common-settings-save {
        flex: 1 1 auto;
    }

    .scheduled-tasks-hero,
    .scheduled-tasks-panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .scheduled-tasks-updated {
        align-items: flex-start;
    }

    .scheduled-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scheduled-summary-card-wide {
        grid-column: 1 / -1;
    }

    .scheduled-source-status {
        justify-content: flex-start;
    }

    .scheduled-task-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 460px) {
    .scheduled-tasks-page {
        width: min(100% - 12px, 1180px);
    }

    .scheduled-tasks-hero {
        padding-inline: 6px;
    }

    .scheduled-summary-grid {
        gap: 8px;
    }

    .scheduled-summary-card {
        min-height: 90px;
        padding: 14px;
    }

    .scheduled-task-heading {
        flex-direction: column;
    }

    .scheduled-task-actions {
        width: 100%;
        justify-content: space-between;
    }

    .scheduled-task-details {
        grid-template-columns: 1fr;
    }

    .common-settings-page {
        width: min(100% - 12px, 1180px);
    }

    .common-settings-hero {
        padding-inline: 6px;
    }

    .common-settings-panel-header,
    .common-settings-platform,
    .common-settings-deploy-list,
    .common-settings-field,
    .common-settings-policy,
    .common-settings-verification {
        padding-inline: 14px;
    }

    .common-settings-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 8px;
    }

    .common-settings-save-hint {
        text-align: center;
    }
}
.codebuddy-usage-panel {
    grid-area: usage;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 4px 16px 7px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.codebuddy-usage-panel b { color: var(--text-primary); font-weight: 600; }

@media (min-width: 960px) {
    body.session-prompt-open.terminal-collapsed #codebuddyUsagePanel { display: none; }
}
.accounts-account-link { margin: 14px 0 0; }

/* CodeBuddy / OpenCode default-model cards side by side */
.common-settings-model-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
    align-items: start;
}
@media (max-width: 960px) {
    .common-settings-model-pair { grid-template-columns: minmax(0, 1fr); }
}

/* Separated groups inside the Batch executor settings card. */
.common-settings-config-section {
    padding: 0 20px 18px;
}

.common-settings-config-section + .common-settings-config-section {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.common-settings-config-section .common-settings-batch-grid {
    padding: 0;
}

.common-settings-config-section .common-settings-field {
    padding: 0;
}

.common-settings-single-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.common-settings-group-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--accent-purple);
}

.common-settings-config-section .common-settings-field-warning {
    grid-column: 1 / -1;
    margin: 0;
}

@media (max-width: 760px) {
    .common-settings-config-section {
        padding-inline: 16px;
    }
}

@media (max-width: 600px) {
    .common-settings-config-section .common-settings-batch-grid,
    .common-settings-single-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
