:root {
  color-scheme: light;
  --canvas: #fff; --sidebar: #f5f5f7; --surface: #fff; --hover: #eeeef2;
  --ink: #232328; --muted: #686872; --line: #e3e3e8; --accent: #7041c9;
  --accent-hover: #6030b8; --accent-soft: #ece7f7; --on-accent: #fff;
  --scrim: #18182270; --danger: #ac2938; --z-floating: 10; --z-skip: 40;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 16px; font-synthesis: none;
}
:root[data-theme='dark'] {
  color-scheme: dark; --canvas: #202024; --sidebar: #19191d; --surface: #27272d;
  --hover: #34343c; --ink: #eeeef2; --muted: #b3b3bf; --line: #464650;
  --accent: #b895ff; --accent-hover: #c4a8ff; --accent-soft: #352b48;
  --on-accent: #20142e; --scrim: #08080c99; --danger: #ff9aa9;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, summary { cursor: pointer; }
button { background: none; border: 0; transition: background-color 180ms ease-out, color 180ms ease-out; }
button:hover:not(:disabled), a:hover, summary:hover { background-color: var(--hover); }
button:active:not(:disabled) { background-color: var(--accent-soft); }
button:disabled, select:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; } h1, h2, h3 { text-wrap: balance; } p { text-wrap: pretty; }
.chat-layout { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
#sidebarSlot { min-width: 0; min-height: 0; }
.chat-sidebar { height: 100%; display: flex; flex-direction: column; background: var(--sidebar); padding: 16px 12px 12px; overflow-y: auto; }
.brand-row { display: flex; justify-content: space-between; align-items: center; padding-left: 8px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.1875rem; font-weight: 680; min-height: 44px; border-radius: 8px; }
.brand-mark { background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; font-size: 1.1875rem; font-weight: 700; flex-shrink: 0; }
.icon-button { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 8px; color: var(--muted); }
.new-chat { display: flex; align-items: center; gap: 12px; min-height: 44px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); padding: 0 12px; font-size: .875rem; font-weight: 600; }
.history-search { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-top: 8px; padding: 0 12px; color: var(--muted); }
.history-search input { width: 100%; min-width: 0; height: 44px; padding: 0; border: 0; background: transparent; font-size: .875rem; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.sidebar-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 8px; font-size: .875rem; list-style: none; }
.sidebar-link::-webkit-details-marker { display: none; }
.sidebar-link > i:first-child { width: 18px; text-align: center; color: var(--muted); }
.sidebar-link .trailing { margin-left: auto; font-size: .75rem; color: var(--muted); }
.sidebar-link.current { font-weight: 600; background: var(--hover); }
.workspace-nav { padding: 16px 0; margin-top: 8px; border-bottom: 1px solid var(--line); }
.workspace-tool-links { max-height: 264px; overflow-y: auto; padding-left: 16px; }
.workspace-tool-links a { display: flex; align-items: center; min-height: 44px; border-radius: 8px; padding: 8px 12px; font-size: .8125rem; }
.history { flex: 1; min-height: 112px; overflow-y: auto; padding-top: 24px; }
.history h2 { padding: 0 12px 8px; color: var(--muted); font-size: .75rem; font-weight: 500; }
.history-loading, .chat-empty { padding: 12px; color: var(--muted); font-size: .8125rem; line-height: 1.8; }
.chat-empty .empty-icon { display: none; } .chat-empty h3 { font-size: .8125rem; font-weight: 500; }
.chat-history-item { display: flex; align-items: center; min-height: 44px; padding: 12px; border-radius: 8px; color: var(--ink); gap: 8px; }
.chat-history-item:hover { background: var(--hover) !important; }
.chat-history-item.active { color: var(--accent); background: var(--accent-soft) !important; }
.chat-history-item .item-icon { display: none; }
.chat-history-item .item-content { min-width: 0; display: block; width: 100%; }
.item-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .8125rem; }
.item-time { display: block; color: var(--muted); font-size: .6875rem; margin-top: 4px; }
.sidebar-bottom { padding-top: 12px; }
.account { display: flex; align-items: center; gap: 12px; padding: 12px; width: 100%; border-radius: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--line); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.account-text { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 4px; }
.account-text strong { font-size: .8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.account-text small { font-size: .6875rem; color: var(--muted); }
.account-actions { display: flex; justify-content: space-between; padding: 0 4px; }
.account-actions > * { min-height: 44px; display: flex; align-items: center; padding: 8px; border-radius: 8px; color: var(--muted); font-size: .75rem; }
.chat-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.chat-topbar { min-height: 72px; padding: 12px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0; }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-left { flex: 1; } .topbar-actions { flex-shrink: 0; }
.chat-topbar h1 { font-size: .9375rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.context-name { color: var(--muted); font-size: .75rem; padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
.open-sidebar { display: none; }
.chat-messages { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; padding: 16px 48px 24px; overscroll-behavior: contain; }
.chat-messages.is-welcome { padding-top: max(24px, min(7vh, 80px)); }
.chat-welcome { width: 100%; max-width: 800px; margin: 0 auto; text-align: center; }
.welcome-logo { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 32px; font-size: 1.75rem; font-weight: 650; }
.welcome-logo .brand-mark { width: 40px; height: 40px; font-size: 1.5rem; border-radius: 12px; }
.welcome-greet { font-size: 1.875rem; font-weight: 600; line-height: 1.5; letter-spacing: -.02em; }
.welcome-sub { color: var(--muted); font-size: .9375rem; line-height: 1.8; margin-top: 12px; }
.welcome-input-host { margin-top: 32px; text-align: left; }
.chat-input-area { width: calc(100% - 96px); max-width: 800px; flex-shrink: 0; margin: 0 auto; padding-top: 16px; }
.welcome-input-host .chat-input-area { width: 100%; padding-top: 0; }
.composer { padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
/* User-approved softer homepage corners; active conversation remains compact. */
.is-welcome .composer { border-radius: 28px; }
.composer:focus-within { border-color: var(--accent); }
.prompt-label { display: none; color: var(--muted); font-size: .75rem; padding: 4px 8px 0; }
.is-welcome .prompt-label { display: block; }
[data-chat-input] { display: block; resize: none; width: 100%; height: 56px; min-height: 52px; max-height: 120px; padding: 12px 8px; border: 0; background: transparent; outline: none; font-size: 1rem; line-height: 1.6; }
.is-welcome [data-chat-input] { min-height: 100px; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.input-tools, .composer-send { display: flex; align-items: center; gap: 8px; min-width: 0; }
.composer-send { margin-left: auto; }
.tool-btn { min-height: 44px; padding: 8px 12px; display: inline-flex; align-items: center; gap: 8px; border-radius: 8px; color: var(--muted); font-size: .8125rem; }
.tool-btn[aria-pressed='true'] { background: var(--accent-soft); color: var(--accent); }
.model-selector { display: block; min-width: 0; }
.model-selector select { max-width: 216px; width: 100%; min-height: 44px; padding: 8px; background: var(--surface); border: 0; border-radius: 8px; font-size: .8125rem; cursor: pointer; }
.btn-send { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; background: var(--accent); color: var(--on-accent); }
.btn-send:hover:not(:disabled) { background: var(--accent-hover); }
.composer-footnote { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 8px 0; color: var(--muted); font-size: .6875rem; line-height: 1.6; }
.chat-status { color: var(--muted); font-size: .8125rem; line-height: 1.6; overflow-wrap: anywhere; max-height: 72px; overflow: auto; padding: 4px 8px; }
.chat-status:empty { padding: 0; } .chat-status.error { color: var(--danger); }
[data-chat-context] { display: flex; flex-wrap: wrap; gap: 8px; max-height: 136px; overflow-y: auto; }
[data-chat-context]:not(:empty) { margin: 4px 0 12px; }
[data-chat-context] > span { max-width: 100%; min-width: 0; overflow-wrap: anywhere; border-radius: 8px !important; background: var(--accent-soft) !important; color: var(--accent) !important; padding: 0 0 0 12px !important; }
[data-chat-context] button { min-width: 44px; height: 44px; flex-shrink: 0; font-size: 1.125rem; }
.welcome-suggestions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 32px; padding-bottom: 32px; }
.suggestion-chip { display: flex; align-items: center; gap: 8px; padding: 8px 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; font-size: .8125rem; color: var(--muted); }
.page-footer { flex-shrink: 0; text-align: center; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); color: var(--muted); font-size: .6875rem; line-height: 1.6; order: 10; }
.message-row { display: flex; gap: 12px; width: 100%; max-width: 760px; margin: 0 auto 32px; min-width: 0; }
.message-row > div:last-child { min-width: 0; flex: 1; }
.message-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 28px; background: var(--accent); color: var(--on-accent); border-radius: 8px; font-size: .8125rem; margin-top: 4px; }
.message-row.user { justify-content: flex-end; } .message-row.user .message-avatar { display: none; }
.message-row.user > div:last-child { flex: 0 1 auto; max-width: 85%; }
.message-row.user .message-bubble { border-radius: 16px; padding: 16px 20px; background: var(--sidebar); font-size: .9375rem; white-space: pre-wrap; }
.message-row.user .message-meta { justify-content: flex-end; }
.message-bubble { line-height: 1.85; font-size: 1rem; overflow-wrap: anywhere; }
.message-bubble p { margin-bottom: 12px; }
.message-bubble h2, .message-bubble h3, .message-bubble h4 { font-size: 1.125rem; font-weight: 650; margin: 24px 0 12px; }
.message-bubble > :first-child { margin-top: 0; }
.message-bubble ul { padding-left: 24px; margin: 12px 0 20px; } .message-bubble li { padding: 4px 0; }
.message-bubble pre { max-width: 100%; overflow-x: auto; background: var(--sidebar); padding: 16px; border-radius: 8px; }
.message-bubble code { font-size: .875em; background: var(--sidebar); padding: 2px 4px; border-radius: 4px; }
.message-bubble table { display: block; overflow-x: auto; border-collapse: collapse; max-width: 100%; font-size: .875rem; margin: 16px 0; }
.message-bubble td, .message-bubble th { border: 1px solid var(--line); padding: 8px 12px; text-align: left; min-width: 100px; }
.message-bubble blockquote { margin: 16px 0; background: var(--sidebar); padding: 16px; border-radius: 8px; color: var(--muted); }
.message-bubble a { color: var(--accent); text-decoration: underline; }
.message-markdown-spacer { height: 8px; }
.message-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .6875rem; margin-top: 8px; }
.chat-scroll-bottom { position: absolute; z-index: var(--z-floating); bottom: var(--chat-composer-offset, 200px); left: 50%; transform: translateX(-50%); min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); color: var(--muted); display: flex; align-items: center; gap: 8px; font-size: .8125rem; }
.chat-dialog { margin: auto; width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto; border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: var(--surface); color: var(--ink); }
.chat-dialog h2 { font-size: 1.125rem; margin-bottom: 16px; }
.chat-dialog p { font-size: .875rem; line-height: 1.8; margin: 12px 0; }
.chat-dialog h3 { color: var(--ink) !important; }
.chat-dialog select { background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); padding: 8px; max-width: 100%; }
.chat-dialog .btn-primary, .chat-dialog .btn-ghost { min-height: 44px; padding: 8px 16px; border-radius: 8px; font-size: .875rem; }
.chat-dialog .btn-primary { background: var(--accent); color: var(--on-accent); }
.chat-dialog .btn-ghost { color: var(--ink); } .chat-dialog small { color: var(--muted); line-height: 1.7; }
dialog::backdrop { background: var(--scrim); }
.mobile-nav { padding: 0; margin: 0; width: min(300px, calc(100vw - 40px)); height: 100dvh; max-height: 100dvh; border: 0; color: var(--ink); }
.skip-link { position: fixed; left: 16px; top: 16px; transform: translateY(-200%); z-index: var(--z-skip); padding: 12px; background: var(--surface); border: 1px solid var(--accent); }
.skip-link:focus { transform: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.sidebar-collapsed .chat-layout { grid-template-columns: minmax(0, 1fr); }
body.sidebar-collapsed #sidebarSlot { display: none; } body.sidebar-collapsed .open-sidebar { display: inline-flex; }
@media (max-width: 1100px) { .context-name, .keyboard-hint { display: none; } .chat-topbar { padding-inline: 24px; } .chat-messages { padding-inline: 32px; } .welcome-greet { font-size: 1.625rem; } }
@media (max-width: 900px) { .chat-layout { grid-template-columns: minmax(0, 1fr); } #sidebarSlot { display: none; } .open-sidebar { display: inline-flex; } .chat-messages { padding-inline: 24px; } }
@media (max-width: 600px) {
  .chat-topbar { min-height: 64px; padding: 8px 12px; gap: 8px; } .topbar-left, .topbar-actions { gap: 4px; }
  .chat-messages { padding: 16px; } .chat-messages.is-welcome { padding-top: 24px; }
  .welcome-logo { font-size: 1.5rem; margin-bottom: 24px; } .welcome-greet { font-size: 1.5rem; max-width: 13em; margin-inline: auto; } .welcome-sub { font-size: .8125rem; max-width: 21em; margin-inline: auto; }
  .chat-input-area { width: calc(100% - 32px); padding-top: 8px; } .composer { padding: 12px; } .is-welcome .composer { border-radius: 24px; }
  .composer-toolbar { gap: 8px; } .input-tools { gap: 4px; } .tool-btn { padding-inline: 8px; font-size: .75rem; }
  .model-selector select { max-width: 200px; font-size: .8125rem; } .welcome-suggestions { gap: 8px; margin-top: 24px; }
  .suggestion-chip { justify-content: center; min-width: calc(50% - 4px); font-size: .75rem; padding-inline: 12px; }
  .message-row { gap: 8px; margin-bottom: 24px; } .message-row.ai { display: block; } .message-row.ai .message-avatar { margin-bottom: 12px; }
  .message-row.user > div:last-child { max-width: 94%; } .message-row.user .message-bubble { font-size: .875rem; padding: 12px 16px; }
  .page-footer { font-size: .625rem; padding-top: 8px; } .chat-dialog { padding: 16px; }
}
@media (max-height: 600px) { .chat-topbar { min-height: 52px; padding-block: 4px; } .chat-messages.is-welcome { padding-top: 16px; } .page-footer { padding-block: 4px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
