/* ========== 原有样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #f5f7fb;
    padding: 0;
    margin: 0;
    height: 100vh;    /* fallback */
    height: 100dvh;   /* modern: excludes browser chrome */
    display: flex;
    flex-direction: column;
}
.app {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}
.header {
    background: #ffffff;
    padding: 16px 16px 10px;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 10;
}
.header h2 {
    font-size: 1.4rem;
    font-weight: 600;
    background: linear-gradient(135deg, #1e3c72, #2b4c7c);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}
.header .sub {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}
.header-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}
.security-note {
    font-size: 0.65rem;
    color: #8e9aaf;
    white-space: nowrap;
}
.auth-bar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 999px;
    min-width: 0;
    max-width: 62%;
}
.auth-user {
    color: #495057;
    font-size: 0.68rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-user.logged-in {
    color: #0f7a3b;
    font-weight: 600;
}
.auth-entry-btn {
    background: #007aff;
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.68rem;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,122,255,0.2);
}
.auth-entry-btn.logged-in {
    background: #495057;
    box-shadow: none;
}


.version-badge, .model-badge, .voice-badge {
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.model-badge {
    font-family: monospace;
}
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
}
.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeInUp 0.2s ease-out;
}
.user-message {
    align-self: flex-end;
}
.ai-message {
    align-self: flex-start;
    width: 100%;
    max-width: 100%;
}
.bubble {
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}
.user-message .bubble {
    background: #007aff;
    color: white;
    border-bottom-right-radius: 4px;
}
.ai-message .bubble {
    background: #e9ecef;
    color: #1e2a3a;
    border-bottom-left-radius: 4px;
}
.message-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 4px;
    margin-left: 10px;
    margin-right: 10px;
    gap: 6px;
    font-size: 0.65rem;
    color: #8e9aaf;
}
.token-speed {
    font-family: monospace;
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 12px;
    font-size: 0.6rem;
}
.model-badge {
    max-width: min(58vw, 360px);
    overflow: hidden;
    color: #495057;
    font: 0.65rem ui-monospace, SFMono-Regular, Menlo, monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.model-badge.loaded { color: #137333; }
.model-badge.loading { color: #9a6700; }
.model-badge.unavailable { color: #b42318; }
.task-progress {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    margin: 7px 0 2px;
}
.task-progress-track {
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: #dfe5ec;
}
.task-progress-bar {
    width: 0;
    height: 100%;
    background: #0b78d0;
    transition: width 240ms ease;
}
.task-progress-value {
    min-width: 30px;
    color: #647181;
    font: 0.6rem ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: right;
}
.message-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    margin-left: auto;
}
.message-action,
.message-followup {
    border: 0;
    border-radius: 6px;
    padding: 2px 6px;
    background: transparent;
    color: #0a58ca;
    font-size: 0.65rem;
    font-weight: 600;
}
.message-action:hover,
.message-followup:hover { background: #e8f4fd; }
.message-action:active,
.message-followup:active { background: #d8ebfb; color: #084298; }
.message-action.retry { color: #b42318; }
.message-action.cancel { color: #b42318; }
.markdown-body {
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
    user-select: text;
    -webkit-user-select: text;
}
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body p { margin: 0 0 0.7em; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin: 1em 0 0.45em;
    color: #172033;
    line-height: 1.3;
}
.markdown-body h1 { font-size: 1.2rem; }
.markdown-body h2 { font-size: 1.08rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body h4 { font-size: 0.94rem; }
.markdown-body ul,
.markdown-body ol {
    margin: 0.45em 0 0.75em;
    padding-left: 1.45em;
}
.markdown-body li + li { margin-top: 0.24em; }
.markdown-body blockquote {
    margin: 0.7em 0;
    padding: 0.2em 0 0.2em 0.8em;
    border-left: 3px solid #8aa4bf;
    color: #4b5868;
}
.markdown-body code {
    padding: 0.12em 0.34em;
    border: 1px solid #d8dde4;
    border-radius: 4px;
    background: #f6f7f9;
    color: #9c2f2f;
    font: 0.86em ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.markdown-body pre {
    max-width: 100%;
    margin: 0.7em 0;
    padding: 10px 12px;
    overflow-x: auto;
    border-radius: 6px;
    background: #20242b;
    color: #f4f6f8;
    line-height: 1.5;
    user-select: text;
    -webkit-user-select: text;
}
.markdown-body pre code {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 0.78rem;
    white-space: pre;
}
.markdown-body table {
    display: block;
    max-width: 100%;
    margin: 0.7em 0;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.markdown-body th,
.markdown-body td {
    padding: 6px 8px;
    border: 1px solid #cfd5dc;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}
.markdown-body th { background: #f4f6f8; }
.markdown-body a { color: #075bb5; text-decoration: underline; }
.markdown-body hr {
    height: 1px;
    margin: 0.9em 0;
    border: 0;
    background: #cfd5dc;
}
.source-area:empty { display: none; }
.message-sources {
    margin-top: 9px;
    padding-top: 7px;
    border-top: 1px solid rgba(92, 107, 122, 0.22);
    font-size: 0.74rem;
}
.message-sources summary {
    width: fit-content;
    cursor: pointer;
    color: #425b76;
    font-weight: 650;
    user-select: none;
}
.source-links {
    display: grid;
    gap: 4px;
    margin-top: 6px;
}
.source-link {
    display: flex;
    min-width: 0;
    gap: 6px;
    color: #075bb5;
    text-decoration: none;
}
.source-link:hover { text-decoration: underline; }
.source-index { flex: 0 0 auto; color: #738295; }
.source-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reasoning {
    margin-bottom: 8px;
    background: #f1f3f5;
    border-radius: 12px;
    padding: 6px 10px;
    font-size: 0.8rem;
    border-left: 3px solid #6c757d;
}
.reasoning summary {
    cursor: pointer;
    color: #495057;
    font-weight: 500;
    outline: none;
    user-select: none;
}
.reasoning-content {
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed #dee2e6;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 0.75rem;
    color: #2c3e50;
}
.user-image {
    max-width: 180px;
    max-height: 140px;
    border-radius: 12px;
    margin-top: 6px;
    display: block;
}
.input-area {
    background: #ffffff;
    border-top: 1px solid #e9ecef;
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.mode-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.mode-tabs {
    display: inline-flex;
    padding: 3px;
    background: #eef2f7;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
}
.mode-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.model-tabs {
    display: inline-flex;
    padding: 3px;
    background: #f8fafc;
    border-radius: 999px;
    border: 1px solid #dbe3ee;
}
.mode-tab {
    min-width: 64px;
    justify-content: center;
    padding: 5px 12px;
    border-radius: 999px;
    background: transparent;
    color: #495057;
    font-size: 0.76rem;
}
.mode-tab.active {
    background: #007aff;
    color: white;
    box-shadow: 0 2px 7px rgba(0,122,255,0.22);
}
.model-tab.active {
    background: #26364a;
    color: white;
    box-shadow: 0 2px 7px rgba(38,54,74,0.18);
}
.web-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #495057;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}
.web-toggle input {
    width: 14px;
    height: 14px;
    accent-color: #007aff;
}
.web-toggle.active {
    border-color: #9ed4b0;
    background: #f0fff4;
    color: #0f7a3b;
}
.web-controls {
    display: flex;
    align-items: center;
    gap: 7px;
}
.research-depth-tabs {
    display: inline-flex;
    padding: 3px;
    background: #f2f6f3;
    border: 1px solid #dce8df;
    border-radius: 999px;
}
.research-depth-tabs[hidden] { display: none; }
.depth-tab {
    min-width: 54px;
    padding: 5px 10px;
    border-radius: 999px;
    background: transparent;
    color: #3d5a47;
    font-size: 0.74rem;
}
.depth-tab.active {
    color: #ffffff;
    background: #198754;
    box-shadow: 0 2px 7px rgba(25,135,84,0.2);
}
.depth-tab.deep.active { background: #26364a; }
textarea {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 24px;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    background: #f8f9fa;
    transition: all 0.2s;
    max-height: 100px;
}
textarea:focus {
    outline: none;
    border-color: #007aff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    align-items: center;
}
.composer-tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding-top: 2px;
    animation: fadeInUp 0.16s ease-out;
}
.composer-tools[hidden] { display: none; }
.composer-tools button {
    justify-content: center;
    white-space: nowrap;
}
.tools-toggle {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border: 1px solid #d8dee6;
    border-radius: 50%;
    background: #fff;
    color: #41536a;
    font-size: 1.15rem;
    line-height: 1;
}
.tools-toggle.expanded {
    border-color: #26364a;
    background: #26364a;
    color: #fff;
}
.speak-toggle {
    min-width: 76px;
    height: 34px;
    justify-content: center;
    border: 1px solid #d8dee6;
    background: #fff;
    color: #657184;
}
.speak-toggle.on {
    border-color: #198754;
    background: #198754;
    color: #fff;
}
.speak-toggle.off {
    border-color: #d8dee6;
    background: #fff;
    color: #657184;
}
.action-buttons .primary {
    min-width: 64px;
    height: 34px;
    justify-content: center;
}
button {
    border: none;
    background: #f1f3f5;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1e2a3a;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
button.primary {
    background: #007aff;
    color: white;
}
button.primary:active {
    background: #005fc1;
    transform: scale(0.97);
}
button.voice {
    background: #28a745;
    color: white;
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
}
button.voice.recording {
    background: #ffc107;
    color: #1e2a3a;
    animation: pulse 1s infinite;
}
button.voice:disabled {
    background: #a0a0a0;
    color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.7;
}
button.voice.transcribing,
button.voice.transcribing:disabled {
    background: #1769aa;
    color: #fff;
    opacity: 1;
}
button.danger {
    background: #dc3545;
    color: white;
}
button.secondary {
    background: #6c757d;
    color: white;
}
button.open{
    background: #d2660d;
    color: white;
}
button:active {
    transform: scale(0.97);
}
button:active:not(.recording) {
    background: #0066cc;
}
button:active.recording {
    transform: scale(0.97);
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}
.followup-context {
    display: none;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-left: 3px solid #0b75d1;
    border-radius: 6px;
    background: #eef6ff;
    color: #38516f;
    font-size: 0.76rem;
}
.followup-context.active { display: flex; }
.followup-context-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.followup-context button {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    padding: 0;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    color: #536278;
}
.followup-context button:hover { background: #dbeeff; }
.attachment-item {
    background: #e9ecef;
    border-radius: 16px;
    padding: 4px 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
}
.attachment-item img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
}
.attachment-item .remove {
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
    padding: 0 2px;
}
.status-bar {
    font-size: 0.7rem;
    padding: 5px 12px;
    background: #f1f3f5;
    color: #495057;
    text-align: center;
    border-top: 1px solid #e9ecef;
    font-family: monospace;
}
.voice-preview {
    background: #f1f3f5;
    border-radius: 20px;
    padding: 8px 14px;
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: #2c3e50;
    border-left: 3px solid #28a745;
    transition: all 0.1s;
    display: none;
}
.voice-preview.active {
    display: block;
}
.voice-preview-label {
    font-size: 0.7rem;
    color: #6c757d;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.voice-preview-text {
    word-break: break-word;
    white-space: pre-wrap;
}
.file-download-area {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.file-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #e8f4fd;
    border: 1px solid #b6d4fe;
    border-radius: 8px;
    color: #0a58ca;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.file-download-btn:hover {
    background: #d0e9ff;
}
.ai-message .bubble.tool-response {
    min-height: 60px;
}
.ai-message .bubble.error-response {
    border: 1px solid #f0c4c4;
    background: #fff6f6;
}
.error-panel {
    display: grid;
    gap: 6px;
    color: #3d2626;
    font-size: 0.82rem;
    line-height: 1.5;
}
.error-title {
    color: #a82020;
    font-weight: 700;
}
.error-detail {
    color: #5f3b3b;
    white-space: pre-wrap;
}
.error-meta {
    color: #8a5a5a;
    font-family: monospace;
    font-size: 0.72rem;
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal-content {
    background: white;
    border-radius: 20px;
    max-width: 320px;
    width: 85%;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
}
.modal-content p {
    margin: 12px 0;
    font-size: 0.9rem;
    color: #333;
}
.modal-checkbox {
    margin: 12px 0;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}
.modal-buttons {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    gap: 12px;
}
.modal-buttons button {
    flex: 1;
}
.auth-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    z-index: 999;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 18px;
}
.auth-card {
    width: min(390px, 100%);
    background: white;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.24);
}
.auth-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.auth-card h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #1e2a3a;
}
.auth-card .auth-hint {
    margin-top: 4px;
    font-size: 0.74rem;
    color: #6c757d;
    line-height: 1.35;
}
.auth-close-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    background: #f1f3f5;
    color: #495057;
    font-size: 1rem;
}
.auth-segment {
    display: flex;
    padding: 3px;
    background: #eef2f7;
    border-radius: 999px;
    margin-bottom: 14px;
}
.auth-segment button {
    flex: 1;
    justify-content: center;
    border-radius: 999px;
    padding: 7px 12px;
    background: transparent;
    color: #495057;
}
.auth-segment button.active {
    background: #007aff;
    color: white;
    box-shadow: 0 2px 7px rgba(0,122,255,0.22);
}
.auth-field {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 9px;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    font-size: 0.88rem;
    font-family: inherit;
    background: #fbfcfe;
}
.auth-field:focus {
    outline: none;
    border-color: #007aff;
    background: white;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}
.auth-code-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 9px;
}
.auth-code-row .auth-field {
    margin-bottom: 0;
}
.auth-send-code {
    border-radius: 10px;
    padding: 0 12px;
    background: #1e2a3a;
    color: white;
    font-size: 0.78rem;
    white-space: nowrap;
}
.auth-message {
    min-height: 18px;
    margin: 2px 0 10px;
    color: #dc3545;
    font-size: 0.76rem;
    line-height: 1.35;
    display: none;
}
.auth-message.success {
    color: #198754;
}
.auth-submit {
    width: 100%;
    justify-content: center;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.88rem;
}
.auth-switch-line {
    margin-top: 12px;
    text-align: center;
    font-size: 0.76rem;
    color: #6c757d;
}
.auth-switch-line button {
    padding: 0;
    background: transparent;
    color: #007aff;
    font-size: 0.76rem;
    border-radius: 0;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}
@media (max-width: 640px) {
    .message { max-width: 90%; }
    .bubble { padding: 8px 12px; font-size: 0.85rem; }
    .action-buttons { gap: 6px; }
    .composer-tools {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }
    .composer-tools[hidden] { display: none; }
    .composer-tools button {
        min-width: 0;
        padding-left: 7px;
        padding-right: 7px;
    }
    .tools-toggle { flex: 0 0 34px; }
    .speak-toggle { flex: 0 1 92px; }
    button { padding: 5px 12px; font-size: 0.75rem; }
    .header h2 { font-size: 1.2rem; }
    .header .sub { font-size: 0.65rem; }
    .version-badge, .voice-badge { font-size: 0.6rem; padding: 2px 6px; }
    .chat-area { padding: 10px 10px 6px; gap: 8px; }
    .message-meta { font-size: 0.6rem; }
    .message-action, .message-followup { font-size: 0.62rem; padding: 3px 5px; }
    .token-speed { font-size: 0.55rem; padding: 1px 4px; }
    .markdown-body pre { padding: 8px 9px; }
    .markdown-body pre code { font-size: 0.72rem; }
    .markdown-body table { font-size: 0.74rem; }
    .user-image { max-width: 140px; max-height: 110px; }
    .reasoning { font-size: 0.75rem; padding: 5px 8px; }
    .reasoning-content { font-size: 0.7rem; }
    .input-area { padding: 8px 10px 12px; }
    textarea { padding: 8px 12px; font-size: 0.85rem; }
    .header-meta-row { align-items: stretch; flex-direction: column; gap: 6px; }
    .security-note { white-space: normal; }
    .auth-bar { max-width: 100%; justify-content: space-between; }
    .mode-row { align-items: stretch; flex-direction: column; gap: 7px; }
    .mode-controls { width: 100%; flex-direction: column; align-items: stretch; }
    .mode-tabs, .model-tabs { width: 100%; }
    .mode-tab { flex: 1; }
    .web-controls { width: 100%; }
    .research-depth-tabs { flex: 1; }
    .depth-tab { flex: 1; }
    .web-toggle { flex: 1; justify-content: center; }
    .voice-preview { padding: 6px 10px; font-size: 0.8rem; }
    .attachment-item { font-size: 0.7rem; }
    .modal-content { width: 90%; padding: 16px; }
    .auth-card { padding: 16px; }
    .auth-code-row { grid-template-columns: 1fr; }
    .auth-send-code { height: 38px; justify-content: center; }
}

/* ========== 两栏布局 ========== */
.main-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}
.sidebar {
    width: 240px;
    min-width: 240px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar-header {
    padding: 12px 10px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-header-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6c757d;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.new-chat-btn {
    width: 100%;
    padding: 8px 12px;
    background: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s;
}
.new-chat-btn:hover {
    background: #005fc1;
}
.new-chat-btn:active {
    transform: scale(0.97);
}
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
}
.conv-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #1e2a3a;
    margin-bottom: 2px;
    transition: background 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    padding-right: 58px;
}
.conv-item:hover {
    background: #e9ecef;
}
.conv-item.active {
    background: #007aff;
    color: white;
    font-weight: 500;
}
.conv-item .conv-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item .conv-actions {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
}
.conv-item .conv-action {
    font-size: 0.7rem;
    color: inherit;
    opacity: 0;
    transition: opacity 0.12s;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    user-select: none;
}
.conv-item:hover .conv-action,
.conv-item .conv-pin.pinned {
    opacity: 0.6;
}
.conv-item:hover .conv-action:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}
.sidebar-footer {
    padding: 10px;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: #8e9aaf;
}
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ========== 齿轮设置面板 ========== */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 2000;
    display: none;
    justify-content: flex-end;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.settings-overlay.active {
    display: flex;
}
.settings-drawer {
    width: 340px;
    max-width: 92%;
    background: white;
    height: 100%;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.25s ease-out;
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.settings-header {
    padding: 18px 16px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}
.settings-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    color: #6c757d;
    transition: background 0.15s;
}
.settings-close:hover {
    background: #e9ecef;
}
.settings-body {
    padding: 20px 16px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.settings-avatar {
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #6c757d;
    margin: 0 auto 16px;
}
.settings-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f3f5;
}
.settings-section:last-of-type {
    border-bottom: none;
}
.settings-section label {
    font-size: 0.7rem;
    color: #8e9aaf;
    display: block;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.settings-section .value {
    font-size: 0.9rem;
    color: #1e2a3a;
    font-weight: 500;
}
.settings-section .value.guest {
    color: #adb5bd;
    font-style: italic;
}
.settings-logout {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}
.settings-logout:hover {
    background: #fecaca;
}

/* 游客模式下设置面板的注册按钮 */
.settings-login-prompt {
    text-align: center;
    padding: 20px 0;
}
.settings-login-prompt p {
    color: #6c757d;
    font-size: 0.85rem;
    margin-bottom: 12px;
}
.settings-file-tools,
.settings-task-tools {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.settings-file-tools input,
.settings-task-tools input {
    flex: 1;
    min-width: 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.82rem;
    outline: none;
}
.settings-file-tools button,
.settings-task-tools button {
    border: 1px solid #d0d7de;
    background: #fff;
    color: #1e2a3a;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    cursor: pointer;
}
.settings-task-selection {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 9px;
    border: 1px solid #b9daf7;
    border-radius: 8px;
    background: #eef7ff;
    color: #38516f;
    font-size: 0.76rem;
}
.settings-task-selection.active { display: flex; }
.settings-task-selection button {
    flex: 0 0 auto;
    border: none;
    border-radius: 7px;
    padding: 7px 10px;
    background: #0b75d1;
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
}
.settings-task-selection button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.settings-file-list,
.settings-task-list {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}
.settings-file-item,
.settings-task-item {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid #edf0f3;
    border-radius: 8px;
    padding: 9px;
    background: #fbfcfd;
}
.settings-task-item.failed {
    border-color: #fecaca;
    background: #fff8f8;
}
.settings-task-item.completed {
    border-color: #d7f3e3;
    background: #fbfffd;
}
.settings-file-name {
    color: #1e2a3a;
    font-size: 0.82rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.settings-task-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}
.settings-task-select {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    margin: 1px 0 0;
    accent-color: #0b75d1;
    cursor: pointer;
}
.settings-task-title {
    flex: 1 1 180px;
    min-width: 0;
    color: #1e2a3a;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.settings-task-badge {
    flex: 0 0 auto;
    max-width: 100%;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 0.68rem;
    line-height: 1.35;
    white-space: nowrap;
    background: #e8f4fd;
    color: #0a58ca;
}
.settings-task-badge.failed {
    background: #fee2e2;
    color: #dc2626;
}
.settings-task-badge.completed {
    background: #dcfce7;
    color: #166534;
}
.settings-file-meta {
    color: #8e9aaf;
    font-size: 0.7rem;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-task-meta {
    color: #8e9aaf;
    font-size: 0.7rem;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-file-actions,
.settings-task-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.settings-file-actions a,
.settings-file-actions button,
.settings-task-actions a,
.settings-task-actions button {
    border: none;
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: none;
    background: #e8f4fd;
    color: #0a58ca;
}
.settings-file-empty,
.settings-task-empty {
    color: #adb5bd;
    font-size: 0.8rem;
    padding: 12px 0;
}
.settings-session-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.settings-session-head button {
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
    color: #344054;
    padding: 5px 8px;
    font-size: 0.72rem;
    cursor: pointer;
}
.settings-session-list {
    display: grid;
    gap: 7px;
    margin-top: 9px;
}
.settings-session-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border: 1px solid #e6ebef;
    border-radius: 7px;
    padding: 9px;
    background: #fbfcfd;
}
.settings-session-name {
    color: #263442;
    font-size: 0.8rem;
    font-weight: 600;
}
.settings-session-meta {
    margin-top: 2px;
    color: #8492a3;
    font-size: 0.68rem;
    overflow-wrap: anywhere;
}
.settings-session-current {
    color: #157347;
    font-size: 0.7rem;
    font-weight: 600;
}
.settings-session-revoke {
    border: none;
    background: transparent;
    color: #c2413b;
    padding: 5px;
    font-size: 0.72rem;
    cursor: pointer;
}

/* ========== 齿轮按钮 ========== */
.gear-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.15s, transform 0.15s;
    color: #495057;
    line-height: 1;
}
.gear-btn:hover {
    background: #e9ecef;
}
.gear-btn:active {
    transform: scale(0.9);
}

/* ========== 侧栏切换按钮(移动端) ========== */
.menu-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
    color: #495057;
    line-height: 1;
    display: none;
}
.menu-btn:hover {
    background: #e9ecef;
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
    .app { max-width: 100%; }
    .input-area { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1001;
        width: 280px;
        box-shadow: 2px 0 20px rgba(0,0,0,0.15);
        transform: translateX(-100%);
        transition: transform 0.25s ease-out;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: rgba(0,0,0,0.3);
        display: none;
    }
    .sidebar-backdrop.open {
        display: block;
    }
    .menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ========== AoE visual system ========== */
:root {
    --aoe-ink: #17212b;
    --aoe-muted: #637083;
    --aoe-line: #d8e0e7;
    --aoe-canvas: #edf2f5;
    --aoe-surface: #ffffff;
    --aoe-navy: #172b3d;
    --aoe-blue: #1268d3;
    --aoe-blue-soft: #e8f1fb;
    --aoe-green: #16845b;
    --aoe-green-soft: #e7f4ef;
    --aoe-amber: #c57a12;
    --aoe-amber-soft: #fff2df;
    --aoe-red: #c63d35;
}
body {
    color: var(--aoe-ink);
    background: var(--aoe-canvas);
}
.app {
    max-width: 1280px;
    border-right: 1px solid var(--aoe-line);
    border-left: 1px solid var(--aoe-line);
    background: var(--aoe-surface);
    box-shadow: 0 0 34px rgba(33, 47, 61, .09);
}
.header {
    padding: 11px 17px 10px;
    border-bottom-color: var(--aoe-line);
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 4px 18px rgba(42, 56, 70, .045);
}
.header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.chat-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.chat-brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--aoe-navy);
    box-shadow: 0 7px 18px rgba(23, 43, 61, .17);
    font-size: .9rem;
    font-weight: 850;
}
.header h2 {
    margin: 0;
    color: var(--aoe-navy);
    background: none;
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 0;
}
.chat-brand-name {
    margin-top: 1px;
    color: #718095;
    font-size: .64rem;
    font-weight: 650;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.gear-btn,
.menu-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--aoe-line);
    border-radius: 7px;
    background: #f7f9fb;
    color: #34495d;
    font-size: 1rem;
}
.gear-btn:hover,
.menu-btn:hover { background: #edf2f6; }
.header .sub {
    gap: 6px;
    margin-top: 8px;
    padding-left: 44px;
}
.version-badge,
.model-badge,
.voice-badge {
    min-height: 22px;
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 2px 7px;
    font-size: .63rem;
    font-weight: 650;
}
.version-badge {
    border-color: #d8e4ef;
    background: #eef3f7;
    color: #52667a;
}
.model-badge {
    border-color: #cfe0f2;
    background: var(--aoe-blue-soft);
    color: #285a89;
}
.voice-badge {
    border-color: #f0d7ae;
    background: var(--aoe-amber-soft);
    color: #86520c;
}
.model-badge.loaded {
    border-color: #bfe3d4;
    background: var(--aoe-green-soft);
    color: #136f4d;
}
.model-badge.unavailable {
    border-color: #efcbc8;
    background: #fff0ef;
    color: #a8322c;
}
.header-meta-row {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #edf1f4;
}
.security-note { color: #748296; }
.auth-bar {
    max-width: 48%;
    border-color: #d5e0ea;
    border-radius: 7px;
    background: #f7f9fb;
}
.auth-entry-btn,
.auth-entry-btn.logged-in {
    border-radius: 6px;
    box-shadow: none;
}
.auth-entry-btn { background: var(--aoe-blue); }
.auth-entry-btn.logged-in { background: var(--aoe-navy); }
.main-body { background: #f2f5f7; }
.sidebar {
    width: 268px;
    min-width: 268px;
    border-right-color: var(--aoe-line);
    background: #f8fafb;
}
.sidebar-header {
    padding: 14px 12px 12px;
    border-bottom-color: var(--aoe-line);
}
.sidebar-header-title {
    color: #68778a;
    font-size: .69rem;
    letter-spacing: 0;
    text-transform: none;
}
.new-chat-btn {
    min-height: 36px;
    border-radius: 7px;
    background: var(--aoe-blue);
    box-shadow: 0 6px 16px rgba(18, 104, 211, .16);
}
.new-chat-btn:hover { background: #0e58b6; }
.sidebar-list { padding: 8px; }
.conv-item {
    min-height: 39px;
    display: flex;
    align-items: center;
    margin-bottom: 3px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #344355;
}
.conv-item:hover {
    border-color: #dde5ec;
    background: #eef2f5;
}
.conv-item.active {
    border-color: #b9d4ee;
    background: var(--aoe-blue-soft);
    color: #174f84;
    box-shadow: inset 3px 0 0 var(--aoe-blue);
}
.conv-item:hover .conv-action,
.conv-item .conv-pin.pinned { opacity: .72; }
.sidebar-footer {
    border-top-color: var(--aoe-line);
    background: #f3f6f8;
}
.chat-panel { background: #f2f5f7; }
.chat-area {
    gap: 15px;
    padding: 22px 28px 16px;
    background: #f2f5f7;
}
.message { max-width: min(76%, 760px); }
.ai-message {
    width: 100%;
    max-width: 920px;
}
.bubble {
    border-radius: 14px;
    padding: 11px 14px;
    font-size: .91rem;
    line-height: 1.62;
    box-shadow: none;
}
.user-message .bubble {
    border-bottom-right-radius: 5px;
    background: var(--aoe-blue);
    box-shadow: 0 7px 18px rgba(18, 104, 211, .14);
}
.ai-message .bubble {
    border: 1px solid #dce3e9;
    border-bottom-left-radius: 5px;
    background: #fff;
    color: var(--aoe-ink);
    box-shadow: 0 6px 18px rgba(39, 52, 65, .045);
}
.message-meta {
    margin-top: 5px;
    color: #778699;
}
.token-speed {
    border: 1px solid #dde4ea;
    border-radius: 5px;
    background: #eef2f5;
}
.message-action,
.message-followup {
    border-radius: 5px;
    color: #1b65aa;
}
.reasoning {
    border: 1px solid #dce4e9;
    border-left: 3px solid var(--aoe-green);
    border-radius: 7px;
    background: #f5f8f7;
}
.input-area {
    gap: 9px;
    padding: 12px 16px calc(13px + env(safe-area-inset-bottom, 0px));
    border-top-color: var(--aoe-line);
    background: #fff;
    box-shadow: 0 -8px 24px rgba(38, 51, 64, .045);
}
textarea {
    min-height: 44px;
    max-height: 120px;
    border-color: #d5dee6;
    border-radius: 9px;
    padding: 11px 13px;
    background: #f7f9fb;
    color: var(--aoe-ink);
}
textarea:focus {
    border-color: #6fa8df;
    box-shadow: 0 0 0 3px rgba(18, 104, 211, .1);
}
.mode-tabs,
.model-tabs,
.research-depth-tabs {
    border-color: #d8e0e7;
    border-radius: 7px;
    background: #f3f6f8;
}
.mode-tab,
.depth-tab {
    border-radius: 5px;
    color: #536276;
}
.mode-tab.active {
    background: var(--aoe-blue);
    box-shadow: none;
}
.model-tab.active,
.depth-tab.deep.active {
    background: var(--aoe-navy);
    box-shadow: none;
}
.depth-tab.active {
    background: var(--aoe-green);
    box-shadow: none;
}
.web-toggle {
    min-height: 34px;
    border-color: #d8e0e7;
    border-radius: 7px;
    background: #f8fafb;
}
.web-toggle.active {
    border-color: #a8d3c1;
    background: var(--aoe-green-soft);
    color: #136f4d;
}
.composer-tools {
    justify-content: flex-start;
    padding: 7px 0 1px;
    border-top: 1px solid #edf1f4;
}
.composer-tools button {
    min-height: 34px;
    border: 1px solid #d8e0e7;
    border-radius: 7px;
    background: #eef2f5;
    color: #3e4f61;
}
.composer-tools button.voice {
    border-color: #b8ddce;
    background: var(--aoe-green-soft);
    color: #146f4e;
}
.tools-toggle,
.speak-toggle,
.action-buttons .primary {
    height: 36px;
    border-radius: 7px;
}
.tools-toggle {
    width: 36px;
    border-color: #d5dee6;
    background: #f7f9fb;
}
.tools-toggle.expanded {
    border-color: var(--aoe-navy);
    background: var(--aoe-navy);
}
.speak-toggle {
    min-width: 82px;
    border-color: #d5dee6;
    background: #f7f9fb;
}
.speak-toggle.on {
    border-color: var(--aoe-green);
    background: var(--aoe-green);
}
.action-buttons .primary {
    min-width: 76px;
    background: var(--aoe-blue);
}
.status-bar {
    min-height: 27px;
    padding: 5px 14px;
    border-top: 0;
    background: var(--aoe-navy);
    color: #d7e0e7;
}
.followup-context {
    border-left-color: var(--aoe-blue);
    background: var(--aoe-blue-soft);
}
.voice-preview {
    border-color: #b8ddce;
    border-radius: 7px;
    background: #f1f8f5;
}
.attachment-item { border-radius: 7px; }
.modal-overlay,
.auth-modal,
.settings-overlay { background: rgba(18, 29, 40, .52); }
.modal-content,
.auth-card {
    border: 1px solid #d7e0e7;
    border-radius: 8px;
    box-shadow: 0 22px 60px rgba(17, 30, 42, .22);
}
.auth-card { padding: 20px; }
.auth-card h3 { color: var(--aoe-navy); }
.auth-close-btn {
    border: 1px solid #d8e0e7;
    border-radius: 7px;
    background: #f4f7f9;
}
.auth-segment {
    border: 1px solid #d8e0e7;
    border-radius: 7px;
    background: #f2f5f7;
}
.auth-segment button { border-radius: 5px; }
.auth-segment button.active {
    background: var(--aoe-blue);
    box-shadow: none;
}
.auth-field {
    border-color: #d5dee6;
    border-radius: 7px;
    background: #f8fafb;
}
.auth-send-code,
.auth-submit { border-radius: 7px; }
.auth-send-code { background: var(--aoe-navy); }
.auth-submit { background: var(--aoe-blue); }
.settings-drawer {
    width: 390px;
    border-left: 1px solid var(--aoe-line);
    box-shadow: -12px 0 40px rgba(17, 30, 42, .14);
}
.settings-header {
    min-height: 58px;
    border-bottom-color: var(--aoe-line);
    color: var(--aoe-navy);
}
.settings-avatar {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: var(--aoe-blue-soft);
    color: #245f98;
    font-weight: 800;
}
.settings-section { border-bottom-color: #e9eef2; }
.settings-section label {
    color: #768497;
    letter-spacing: 0;
    text-transform: none;
}
.settings-file-item,
.settings-task-item {
    border-color: #dce4ea;
    border-radius: 7px;
    background: #f8fafb;
}
.settings-file-actions a,
.settings-file-actions button,
.settings-task-actions a,
.settings-task-actions button { border-radius: 6px; }
.settings-logout { border-radius: 7px; }

@media (max-width: 768px) {
    .app { border: 0; }
    .header { padding: 9px 11px 8px; }
    .chat-brand-mark {
        width: 31px;
        height: 31px;
        flex-basis: 31px;
    }
    .header h2 { font-size: .96rem; }
    .header .sub { padding-left: 0; }
    .sidebar {
        width: min(300px, 86vw);
        box-shadow: 10px 0 30px rgba(17, 30, 42, .18);
    }
    .chat-area { padding: 13px 11px 10px; }
    .message { max-width: 92%; }
    .ai-message { max-width: 100%; }
    .bubble { font-size: .86rem; line-height: 1.58; }
    .input-area { padding: 9px 10px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .mode-row { flex-direction: column; align-items: stretch; }
    .mode-controls {
        width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    .mode-tabs,
    .model-tabs { flex: 1 1 0; width: auto; }
    .mode-tab { min-width: 0; flex: 1; padding: 5px 6px; }
    .web-controls { width: 100%; }
    .research-depth-tabs { flex: 1; }
    .web-toggle { flex: 1; justify-content: center; }
    .composer-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .settings-drawer { width: min(390px, 100%); max-width: 100%; }
}
@media (max-width: 420px) {
    .header-meta-row { align-items: stretch; flex-direction: column; gap: 6px; }
    .auth-bar { width: 100%; max-width: 100%; justify-content: space-between; }
    .model-badge { max-width: calc(100vw - 142px); }
    .gear-btn, .menu-btn { width: 32px; height: 32px; }
}
