:root {
    --page-bg: #f5f8fa;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --surface-tint: #eef7f6;
    --sidebar-bg: #061b30;
    --sidebar-bg-2: #0a2742;
    --sidebar-line: rgba(255, 255, 255, 0.12);
    --text-primary: #13202b;
    --text-secondary: #3e5163;
    --text-muted: #6d7d8c;
    --text-faint: #96a3af;
    --text-on-dark: #eef7fb;
    --text-on-dark-muted: #a9bbc8;
    --border: #d8e2e8;
    --border-strong: #bac9d3;
    --accent: #11998e;
    --accent-hover: #0c7f77;
    --accent-soft: #dff4f1;
    --accent-blue: #2670c9;
    --accent-green: #0f9f6e;
    --accent-red: #d94a4a;
    --accent-orange: #f49b18;
    --shadow-sm: 0 1px 2px rgba(16, 31, 45, 0.06);
    --shadow-md: 0 10px 28px rgba(21, 46, 64, 0.08);
    --shadow-lg: 0 20px 60px rgba(8, 26, 44, 0.16);
    --shadow-input: 0 0 0 4px rgba(17, 153, 142, 0.14);
    --r-xs: 4px;
    --r-sm: 6px;
    --r-md: 8px;
    --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
    --sidebar-w: 296px;
    --content-w: 920px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    overflow: hidden;
    background: var(--page-bg);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 430;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

.app {
    display: flex;
    height: 100%;
    background: var(--page-bg);
}

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(6, 27, 48, 0.08), rgba(17, 153, 142, 0.08)),
        var(--page-bg);
}

.login-box {
    width: min(360px, calc(100vw - 40px));
    padding: 34px 28px 28px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-mark,
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), #38bfb5);
    color: #fff;
    font-weight: 750;
}

.login-box h2 {
    margin-top: 16px;
    font-size: 20px;
    font-weight: 720;
    letter-spacing: 0;
}

.login-box p {
    margin-top: 6px;
    margin-bottom: 22px;
    color: var(--text-muted);
    font-size: 14px;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-box input[type="password"],
.login-box input[type="text"] {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-soft);
    color: var(--text-primary);
    outline: none;
    padding: 0 13px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.login-box input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: var(--shadow-input);
}

.login-btn {
    min-height: 42px;
    border: 0;
    border-radius: var(--r-md);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 650;
    transition: background 0.16s ease, transform 0.16s ease;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.login-btn:active {
    transform: translateY(1px);
}

.login-error {
    min-height: 18px;
    margin-top: 12px;
    margin-bottom: 0 !important;
    color: var(--accent-red);
    font-size: 13px;
}

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #d4e0e8;
    background:
        linear-gradient(180deg, rgba(17, 153, 142, 0.2), rgba(17, 153, 142, 0) 220px),
        var(--sidebar-bg);
    color: var(--text-on-dark);
    transition: width 0.2s ease, flex-basis 0.2s ease;
}

.sidebar.collapsed {
    width: 0;
    flex-basis: 0;
    border-right: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.brand-copy {
    min-width: 0;
}

.brand-title {
    overflow: hidden;
    color: #fff;
    font-size: 15px;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-subtitle {
    margin-top: 4px;
    color: var(--text-on-dark-muted);
    font-size: 12px;
}

.sidebar-top {
    padding: 18px 14px 12px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--r-md);
    background: linear-gradient(135deg, var(--accent), #2bb7ae);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(17, 153, 142, 0.24);
    transition: transform 0.16s ease, filter 0.16s ease;
}

.new-chat-btn:hover {
    filter: brightness(1.04);
}

.new-chat-btn:active {
    transform: translateY(1px);
}

.sidebar-section-title {
    padding: 0 20px 8px;
    color: #7f98aa;
    font-size: 12px;
    font-weight: 700;
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 12px;
}

.sidebar-history::-webkit-scrollbar {
    width: 5px;
}

.sidebar-history::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
}

.history-item {
    position: relative;
    margin-bottom: 4px;
    padding: 11px 38px 11px 12px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    color: var(--text-on-dark-muted);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.history-item:hover,
.history-item.active {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.history-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.history-item-query {
    overflow: hidden;
    font-size: 13px;
    font-weight: 560;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-meta {
    overflow: hidden;
    margin-top: 4px;
    color: #8198aa;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-delete-btn {
    position: absolute;
    top: 9px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: #7e93a4;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    background: rgba(217, 74, 74, 0.16);
    color: #ffb1b1;
}

.sidebar-history-empty {
    margin: 10px;
    padding: 18px 12px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--r-md);
    color: #7f98aa;
    font-size: 12px;
    text-align: center;
}

.sidebar-bottom {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--sidebar-line);
    background: rgba(4, 16, 28, 0.26);
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-on-dark-muted);
    font-size: 12px;
}

.beian {
    font-size: 11px;
    line-height: 1.4;
}

.beian a {
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.beian a:hover {
    opacity: 1;
    text-decoration: underline;
}

.beian-login {
    position: absolute;
    right: 18px;
    bottom: 14px;
}

.beian-login a {
    color: var(--text-muted);
}

.beian-main {
    margin-left: 14px;
    flex: 0 0 auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--brand-deep, #071d33);
}

.beian-main a {
    color: #fff;
}

.status-indicator {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 0 4px rgba(217, 74, 74, 0.12);
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.status-indicator.connected {
    background: var(--accent-green);
    box-shadow: 0 0 0 4px rgba(15, 159, 110, 0.16);
}

.current-user {
    margin-left: auto;
    max-width: 120px;
    overflow: hidden;
    padding: 3px 9px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-on-dark);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: 6px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-on-dark-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.main {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
}

.topbar {
    min-height: 72px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.topbar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.topbar-toggle:hover {
    border-color: var(--border-strong);
    background: var(--surface-soft);
    color: var(--text-primary);
}

.topbar-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-title {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 760;
    line-height: 1.2;
}

.topbar-subtitle {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
}

.topbar-model {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
}

.conversation {
    flex: 1;
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(225, 242, 240, 0.62), rgba(245, 248, 250, 0) 260px),
        var(--page-bg);
}

.conversation::-webkit-scrollbar {
    width: 8px;
}

.conversation::-webkit-scrollbar-track {
    background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
    border: 2px solid var(--page-bg);
    border-radius: 999px;
    background: #bdcbd5;
}

.welcome {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 100%;
    padding: 64px 28px 120px;
}

.welcome-content {
    width: min(100%, 860px);
    text-align: left;
}

.welcome-mark {
    display: none;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    margin-bottom: 22px;
    border: 1px solid rgba(17, 153, 142, 0.22);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.welcome-content h1 {
    max-width: 620px;
    margin: 0;
    color: var(--text-primary);
    font-size: 30px;
    font-weight: 720;
    letter-spacing: 0;
    line-height: 1.28;
}

.welcome-sub {
    max-width: 640px;
    margin: 12px 0 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.7;
}

.messages {
    width: 100%;
    max-width: var(--content-w);
    margin: 0 auto;
    padding: 30px 24px 28px;
}

.msg-user {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.msg-user-bubble {
    max-width: min(76%, 660px);
    padding: 12px 15px;
    border: 1px solid #c6dfdb;
    border-radius: var(--r-md);
    background: #e7f6f3;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.65;
    word-break: break-word;
}

.msg-assistant {
    margin-bottom: 24px;
    padding: 22px 24px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.assistant-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.assistant-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: var(--r-md);
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 14px;
    font-weight: 760;
}

.assistant-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 720;
}

.assistant-prose {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.78;
}

.assistant-prose h1,
.assistant-prose h2,
.assistant-prose h3 {
    color: var(--text-primary);
    letter-spacing: 0;
}

.assistant-prose h1 {
    margin: 26px 0 12px;
    font-size: 24px;
    font-weight: 760;
}

.assistant-prose h2 {
    margin: 24px 0 10px;
    font-size: 19px;
    font-weight: 740;
}

.assistant-prose h3 {
    margin: 20px 0 8px;
    font-size: 16px;
    font-weight: 730;
}

.assistant-prose p {
    margin-bottom: 12px;
}

.assistant-prose p:last-child {
    margin-bottom: 0;
}

.assistant-prose a {
    color: var(--accent-hover);
    text-decoration: underline;
    text-decoration-color: rgba(17, 153, 142, 0.3);
    text-underline-offset: 3px;
}

.assistant-prose a:hover {
    text-decoration-color: currentColor;
}

.assistant-prose strong {
    font-weight: 720;
}

.assistant-prose code {
    padding: 2px 6px;
    border-radius: var(--r-xs);
    background: var(--surface-soft);
    color: #263d4f;
    font-family: var(--font-mono);
    font-size: 13px;
}

.assistant-prose pre {
    overflow-x: auto;
    margin: 14px 0;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: #f4f7f8;
    color: #273b4a;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
}

.assistant-prose pre code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.assistant-prose blockquote {
    margin: 14px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--surface-tint);
    color: var(--text-secondary);
}

.assistant-prose ul,
.assistant-prose ol {
    margin: 10px 0 12px 22px;
}

.assistant-prose li {
    margin-bottom: 5px;
}

.assistant-prose hr {
    margin: 20px 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.assistant-prose table {
    width: 100%;
    margin: 14px 0;
    border-collapse: collapse;
    font-size: 14px;
}

.assistant-prose th,
.assistant-prose td {
    padding: 9px 11px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.assistant-prose th {
    background: var(--surface-soft);
    font-weight: 720;
}

.assistant-prose td {
    background: var(--surface);
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--accent);
    animation: blink 1s step-end infinite;
}

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

.tool-block {
    overflow: hidden;
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-soft);
}

.tool-block:hover {
    border-color: var(--border-strong);
}

.tool-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    user-select: none;
}

.tool-block-header:hover {
    background: #eef4f6;
}

.tool-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border-radius: var(--r-sm);
    font-size: 13px;
}

.tool-icon.search,
.tool-icon.fetch,
.tool-icon.academic {
    background: #e6eff9;
    color: var(--accent-blue);
}

.tool-icon.read,
.tool-icon.cite,
.tool-icon.ask {
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.tool-icon.news,
.tool-icon.plan {
    background: #fff3db;
    color: #b76b00;
}

.tool-name {
    color: var(--text-primary);
    font-weight: 700;
}

.tool-query {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-spinner,
.activity-spinner {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 2px solid #d1dde4;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.tool-check {
    color: var(--accent-green);
    flex: 0 0 auto;
}

.tool-error-mark {
    color: var(--accent-red);
    flex: 0 0 auto;
}

.tool-chevron {
    color: var(--text-muted);
    flex: 0 0 auto;
    font-size: 10px;
    transition: transform 0.15s ease;
}

.tool-block.expanded .tool-chevron {
    transform: rotate(90deg);
}

.tool-block-body {
    display: none;
    max-height: 220px;
    overflow-y: auto;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: #edf3f5;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.tool-block.expanded .tool-block-body {
    display: block;
}

.status-inline,
.activity-line {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.status-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-orange);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.activity-text {
    line-height: 1.45;
}

.error-block {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 12px 0;
    padding: 12px 14px;
    border: 1px solid #f0c0c0;
    border-radius: var(--r-md);
    background: #fff2f2;
    color: var(--accent-red);
    font-size: 13px;
}

.sources-panel {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.sources-title {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 760;
}

.source-item {
    display: flex;
    gap: 10px;
    margin-bottom: 4px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    transition: background 0.12s ease;
}

.source-item:hover {
    background: var(--surface-soft);
}

.source-num {
    min-width: 24px;
    padding-top: 2px;
    color: var(--accent-hover);
    font-size: 12px;
    font-weight: 760;
}

.source-info {
    min-width: 0;
    flex: 1;
}

.source-info a {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.4;
    text-decoration: none;
}

.source-info a:hover {
    color: var(--accent-hover);
}

.source-snippet {
    display: -webkit-box;
    overflow: hidden;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.source-domain {
    margin-top: 3px;
    color: var(--text-faint);
    font-size: 11px;
}

/* Inline citation superscript [n] in prose */
.cite-ref {
    font-size: 11px;
    font-weight: 760;
    line-height: 0;
    margin: 0 1px;
    cursor: pointer;
}

.cite-ref a {
    display: inline-block;
    min-width: 14px;
    padding: 0 3px;
    border-radius: var(--r-sm);
    background: var(--surface-tint);
    color: var(--accent-hover);
    text-align: center;
    text-decoration: none;
}

.cite-ref a:hover {
    background: var(--accent);
    color: #fff;
}

/* Flash highlight when a source is targeted by clicking its [n] */
@keyframes sourceFlash {
    0%   { background: var(--surface-tint); }
    100% { background: transparent; }
}

.source-item.source-flash {
    animation: sourceFlash 1.4s ease-out;
}

.stats-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    margin-left: auto;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 620;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-soft);
    color: var(--text-primary);
}

.copy-btn.copied {
    border-color: rgba(15, 159, 110, 0.4);
    color: var(--accent-green);
}

.copy-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.copy-btn svg {
    flex: 0 0 auto;
}

.export-btn {
    margin-left: 0;
}

.plan-checklist {
    overflow: hidden;
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-soft);
}

.plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.plan-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 750;
}

.plan-progress {
    color: var(--text-muted);
    font-size: 12px;
}

.plan-progress-bar {
    height: 4px;
    background: #e2ebef;
}

.plan-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.35s ease;
}

.plan-tasks {
    margin: 0;
    padding: 7px 0;
    list-style: none;
}

.plan-task {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 14px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.plan-task:hover {
    background: #edf4f5;
}

.plan-task-icon {
    width: 16px;
    flex: 0 0 auto;
    padding-top: 1px;
    font-size: 12px;
    text-align: center;
}

.plan-task-pending .plan-task-icon {
    color: var(--text-muted);
}

.plan-task-in_progress .plan-task-icon {
    color: var(--accent-orange);
}

.plan-task-completed .plan-task-icon {
    color: var(--accent-green);
}

.plan-task-title {
    min-width: 0;
    flex: 1;
}

.plan-task-completed .plan-task-title {
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--border-strong);
}

.plan-task-findings {
    display: block;
    max-width: 460px;
    overflow: hidden;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-area {
    flex: 0 0 auto;
    padding: 0 28px 22px;
    background: var(--page-bg);
}

.input-form {
    max-width: var(--content-w);
    margin: 0 auto;
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 58px;
    padding: 10px 10px 10px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-box:focus-within {
    border-color: var(--accent);
    box-shadow: var(--shadow-md), var(--shadow-input);
}

#queryInput {
    flex: 1;
    max-height: 160px;
    min-height: 36px;
    padding: 7px 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.55;
}

#queryInput::placeholder {
    color: var(--text-faint);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border: 0;
    border-radius: var(--r-md);
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.send-btn:disabled {
    cursor: default;
    opacity: 0.35;
}

.input-hint {
    padding-top: 9px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.user-question-block {
    margin: 14px 0;
    padding: 16px;
    border: 1px solid #f1c982;
    border-radius: var(--r-md);
    background: #fff8eb;
}

.uq-question {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 720;
    line-height: 1.5;
}

.uq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uq-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #edd4a2;
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.uq-option:hover:not(:disabled),
.uq-option.selected {
    border-color: var(--accent-orange);
    background: #fff4de;
}

.uq-option:disabled:not(.selected) {
    cursor: default;
    opacity: 0.48;
}

.uq-option-label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 650;
}

.uq-option-desc {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.uq-other-input {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.uq-other-text {
    min-width: 0;
    flex: 1;
    min-height: 38px;
    padding: 0 11px;
    border: 1px solid #edd4a2;
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
}

.uq-other-text:focus {
    border-color: var(--accent-orange);
}

.uq-other-submit {
    min-height: 38px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--accent-orange);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.uq-other-submit:disabled,
.uq-other-text:disabled {
    cursor: default;
    opacity: 0.5;
}

.blocked-link {
    color: var(--text-muted);
}

@media (max-width: 980px) {
    :root {
        --sidebar-w: 276px;
    }

    .topbar {
        padding: 0 18px;
    }

    .welcome {
        padding: 42px 18px 110px;
    }

    .messages {
        padding-right: 18px;
        padding-left: 18px;
    }

    .input-area {
        padding-right: 18px;
        padding-left: 18px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 100;
        width: min(86vw, var(--sidebar-w));
        flex-basis: min(86vw, var(--sidebar-w));
        box-shadow: var(--shadow-lg);
    }

    .sidebar.collapsed {
        width: 0;
        flex-basis: 0;
        box-shadow: none;
    }

    .topbar {
        min-height: 64px;
    }

    .topbar-subtitle {
        display: none;
    }

    .welcome-content h1 {
        font-size: 25px;
    }

    .welcome-sub {
        font-size: 14px;
    }

    .msg-user-bubble {
        max-width: 88%;
    }

    .msg-assistant {
        padding: 18px;
    }

    .stats-bar {
        flex-wrap: wrap;
    }

    .copy-btn {
        margin-left: 0;
    }
}

@media (max-width: 520px) {
    .topbar {
        gap: 10px;
        padding: 0 12px;
    }

    .topbar-title {
        font-size: 15px;
    }

    .welcome {
        padding: 32px 14px 100px;
    }

    .welcome-mark {
        width: 54px;
        height: 54px;
    }

    .welcome-content h1 {
        font-size: 22px;
    }

    .messages {
        padding: 18px 12px 100px;
    }

    .input-area {
        padding: 0 10px 14px;
    }

    .input-box {
        min-height: 54px;
        padding-left: 12px;
    }
}
