:root {
    color-scheme: light;
    --chat-ink: #282a2e; --chat-muted: #80838a; --chat-line: #e7e8eb;
    --chat-canvas: #fff; --chat-sidebar: #f7f7f8; --chat-hover: #ededf0;
    --chat-accent: #2865ad; --chat-height: 100dvh;
    font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 14px; color: var(--chat-ink); background: var(--chat-canvas);
    -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
button, a { transition: background-color 160ms ease, color 160ms ease; }
:is(a, button, input, textarea, summary):focus-visible { outline: 2px solid var(--chat-accent); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 10px; left: 20px; padding: 10px 16px; background: var(--chat-ink); color: white; border-radius: 8px; z-index: 30; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.chat-app { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: var(--chat-height); min-height: 0; }
.chat-sidebar { display: flex; flex-direction: column; gap: 6px; min-height: 0; padding: max(22px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); background: var(--chat-sidebar); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 23px; }
.sidebar-brand { font-size: 21px; font-weight: 650; letter-spacing: -.06em; }
.brand-dot { color: var(--chat-accent); margin-left: 1px; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #64676f; }
.icon-button:hover { background: var(--chat-hover); color: var(--chat-ink); }
.icon-button:active { transform: translateY(1px); }
.sidebar-close { display: none; }
.new-chat-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 9px; background: transparent; font-weight: 500; text-align: left; }
.new-chat-button:hover { background: var(--chat-hover); }
.history-search { display: flex; gap: 12px; align-items: center; padding: 9px 12px; min-height: 44px; color: #777a82; }
.history-search svg { width: 18px; height: 18px; }
.history-search input { min-width: 0; width: 100%; padding: 0; border: 0; background: transparent; font-size: 13px; }
.history-search input::placeholder { color: #868992; opacity: 1; }
.history-section { flex: 1; overflow-y: auto; min-height: 0; margin-top: 25px; }
.history-section h2 { margin: 0 12px 12px; font-size: 11px; font-weight: 500; color: #989ba2; }
.history-list { margin: 0; padding: 0; list-style: none; }
.history-list li { display: flex; align-items: center; border-radius: 9px; margin: 2px 0; }
.history-list li.is-active, .history-list li:hover { background: var(--chat-hover); }
.history-select { min-width: 0; flex: 1; min-height: 40px; border: 0; background: transparent; padding: 10px 12px; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.history-delete { width: 30px; height: 32px; margin-right: 5px; opacity: 0; }
.history-delete svg { width: 15px; height: 15px; }
.history-list li:is(:hover, :focus-within) .history-delete { opacity: 1; }
.history-empty { margin: 0 12px; max-width: 180px; color: #999ca4; font-size: 12px; line-height: 1.8; }
.sidebar-footer { padding: 10px 8px 0; }
.site-shortcuts { display: flex; gap: 24px; padding: 0 4px 16px; font-size: 12px; color: #7a7d85; }
.site-shortcuts a:hover { color: var(--chat-ink); }
.sidebar-persona { display: flex; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--chat-line); }
.sidebar-persona img { image-rendering: pixelated; object-fit: contain; }
.sidebar-persona strong, .sidebar-persona span { display: block; }
.sidebar-persona strong { font-size: 13px; font-weight: 550; }
.sidebar-persona span { margin-top: 2px; color: #94979f; font-size: 10px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-canvas); }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; min-height: 68px; padding: env(safe-area-inset-top) 28px 0 18px; }
.chat-header-leading, .chat-header-actions { display: flex; align-items: center; gap: 12px; }
.chat-header-name { font-size: 18px; font-weight: 550; letter-spacing: -.035em; }
.service-mode { font-size: 11px; color: #a0a2a8; }
.home-link { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 9px; color: #777a82; font-size: 12px; }
.home-link svg { width: 16px; height: 16px; }
.home-link:hover { background: var(--chat-sidebar); color: var(--chat-ink); }
.chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.transcript-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 28px 32px 24px; scroll-behavior: smooth; }
.chat-log { width: min(100%, 720px); margin: 0 auto; }
.chat-welcome { text-align: center; padding: 0 20px; }
.chat-welcome h1 { margin: 0 0 14px; font-size: 30px; font-weight: 550; letter-spacing: -.04em; line-height: 1.4; text-wrap: balance; }
.chat-welcome p { margin: 0; color: #8b8e95; font-size: 14px; line-height: 1.8; }
.is-empty .chat-body { justify-content: center; padding-bottom: clamp(30px, 11dvh, 118px); overflow-y: auto; }
.is-empty .transcript-scroll { flex: 0 0 auto; padding-top: 0; padding-bottom: 30px; overflow: visible; }
.is-empty .chat-log { display: none; }
.composer-dock { flex: 0 0 auto; width: min(100%, 784px); padding: 12px 32px max(16px, env(safe-area-inset-bottom)); margin: 0 auto; background: var(--chat-canvas); }
.chat-composer { background: #f7f7f8; border: 1px solid #e5e6e9; border-radius: 24px; padding: 17px 16px 12px 20px; transition: border-color 160ms ease; }
.chat-composer:focus-within { border-color: #c7c9d0; }
.chat-composer textarea { display: block; width: 100%; min-height: 46px; max-height: min(180px, calc(var(--chat-height) * .28)); padding: 0 3px 4px 0; resize: none; border: 0; outline: 0; background: transparent; font-size: 16px; line-height: 1.6; overflow-y: auto; }
.chat-composer textarea:focus-visible { outline: 0; }
.chat-composer textarea::placeholder { color: #a1a4ac; opacity: 1; }
.composer-toolbar { display: flex; align-items: center; gap: 12px; margin-top: 8px; min-height: 36px; }
.composer-context { color: #989ba4; font-size: 11px; }
.keyboard-hint { margin-left: auto; color: #b2b4ba; font-size: 10px; }
.send-button { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #303137; color: #fff; }
.send-button:hover { background: #17181d; }
.send-button:disabled { background: #dddfe3; color: white; }
.send-button svg { width: 20px; height: 20px; stroke-width: 2; }
.stop-button span { width: 12px; height: 12px; background: #fff; border-radius: 2px; }
.starter-prompts { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.starter-prompts button { padding: 8px 14px; border: 1px solid #e6e7ea; border-radius: 20px; color: #787b83; background: transparent; font-size: 12px; line-height: 1.5; }
.starter-prompts button:hover { background: #f5f5f7; color: var(--chat-ink); }
.chat-privacy { margin: 12px 0 0; text-align: center; color: #7b7f88; font-size: 11px; line-height: 1.7; }
.chat-message { position: relative; margin: 0 0 30px; min-width: 0; font-size: 16px; line-height: 1.9; overflow-wrap: anywhere; }
.chat-message.user { display: flex; justify-content: flex-end; padding-left: 48px; margin-bottom: 32px; }
.user .message-copy { width: fit-content; max-width: 100%; padding: 11px 19px; border-radius: 22px; background: #f1f1f3; white-space: pre-wrap; }
.assistant .message-copy { white-space: pre-wrap; }
.message-label { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; font-size: 12px; font-weight: 550; }
.message-label img { width: 23px; height: 23px; image-rendering: pixelated; object-fit: contain; }
.message-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.message-actions .icon-button { width: 30px; height: 30px; color: #9a9da4; }
.message-actions svg { width: 16px; height: 16px; }
.message-actions .retry-button { min-height: 30px; border: 0; padding: 4px 8px; background: transparent; color: var(--chat-accent); font-size: 12px; border-radius: 6px; }
.message-actions .retry-button:hover { background: #f1f4f8; }
.chat-message.error .message-copy { color: #947147; }
.pending-copy { display: flex; align-items: center; gap: 10px; color: #999ca4; font-size: 14px; }
.thinking-dots { display: inline-flex; gap: 3px; }
.thinking-dots i { width: 4px; height: 4px; border-radius: 50%; background: #a3a6ae; animation: thinking 1.2s infinite ease; }
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
.answer-links { display: grid; gap: 8px; margin-top: 18px; }
.answer-link { display: block; padding: 12px 15px; border: 1px solid var(--chat-line); border-radius: 12px; font-size: 13px; line-height: 1.7; }
.answer-link:hover { background: #f9f9fa; border-color: #d6dae2; }
.answer-link strong { display: block; font-weight: 550; color: #455c79; }
.answer-link span { display: block; margin-top: 3px; font-size: 12px; color: #92959d; }
.answer-sources { margin-top: 15px; color: #989ba4; font-size: 12px; line-height: 1.8; }
.answer-sources summary { cursor: pointer; width: fit-content; }
.answer-sources a { display: block; margin: 7px 0; color: #5c7290; }
.answer-sources a:hover { text-decoration: underline; text-underline-offset: 3px; }
.message-copy .katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 4px 0; }
.chat-toast { position: fixed; z-index: 30; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 40px); padding: 11px 18px; background: #303137; color: white; border-radius: 10px; box-shadow: 0 6px 22px rgb(30 30 36 / 10%); font-size: 12px; }
.no-script { position: fixed; inset: auto 20px 20px; z-index: 30; padding: 20px; background: white; border: 1px solid var(--chat-line); text-align: center; }
.no-script a { color: var(--chat-accent); }
.sidebar-collapsed .chat-app { grid-template-columns: minmax(0, 1fr); }
.sidebar-collapsed .chat-sidebar { display: none; }
@keyframes thinking { 0%, 70%, 100% { opacity: .35; } 35% { opacity: 1; } }
@media (max-width: 820px) {
    .chat-app { grid-template-columns: minmax(0, 1fr); }
    .chat-sidebar { position: fixed; z-index: 20; inset: 0 auto auto 0; width: min(280px, calc(100% - 48px)); height: var(--chat-height); transform: translateX(-100%); visibility: hidden; transition: transform 200ms ease, visibility 200ms; box-shadow: 6px 0 24px rgb(30 30 36 / 5%); }
    .sidebar-open .chat-sidebar { transform: none; visibility: visible; }
    .sidebar-collapsed .chat-sidebar { display: flex; }
    .sidebar-backdrop { position: fixed; z-index: 15; inset: 0; width: 100%; height: 100%; border: 0; background: rgb(35 37 43 / 18%); }
    .sidebar-close { display: grid; }
    .sidebar-heading { padding-bottom: 16px; }
    .history-delete { opacity: 1; }
    .chat-header { min-height: calc(60px + env(safe-area-inset-top)); padding-inline: 12px; gap: 10px; }
    .chat-header-leading, .chat-header-actions { gap: 8px; }
    .chat-header-name { font-size: 17px; }
    .home-link { padding: 10px; }
    .home-link span { display: none; }
    .home-link svg { width: 18px; height: 18px; }
    .transcript-scroll { padding-inline: 22px; padding-top: 24px; }
    .composer-dock { padding-inline: 20px; }
    .chat-welcome h1 { font-size: 28px; }
    .keyboard-hint { display: none; }
    .composer-context { margin-right: auto; }
}
@media (max-width: 480px) {
    .service-mode { display: none; }
    .chat-header-leading, .chat-header-actions { gap: 5px; }
    .is-empty .chat-body { padding-bottom: 48px; }
    .chat-welcome h1 { font-size: 26px; }
    .chat-welcome p { font-size: 12px; }
    .composer-dock { padding-inline: 16px; }
    .chat-composer { padding: 15px 12px 10px 17px; border-radius: 22px; }
    .starter-prompts { gap: 7px; }
    .starter-prompts button { padding-inline: 12px; font-size: 11px; }
    .transcript-scroll { padding-inline: 20px; }
    .chat-message { font-size: 15px; line-height: 1.9; }
    .chat-message.user { padding-left: 28px; }
    .chat-privacy { font-size: 10px; padding-inline: 8px; }
}
@media (max-height: 550px) {
    .is-empty .chat-body { padding-bottom: 0; }
    .is-empty .transcript-scroll { padding-bottom: 12px; }
    .chat-welcome p { display: none; }
    .chat-welcome h1 { font-size: 23px; margin-bottom: 0; }
    .starter-prompts { display: none; }
    .chat-header { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
