:root {
  color-scheme: light;
  --sidebar: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --ink: #202123;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --accent: #2457d6;
  --accent-hover: #1949bd;
  --accent-soft: #edf3ff;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--surface); color: var(--ink); font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
.hidden { display: none !important; }
[data-icon] { align-items: center; display: inline-flex; justify-content: center; }
[data-icon] svg { height: 19px; width: 19px; }
.brand-mark { align-items: center; background: var(--accent); border-radius: 12px; color: white; display: inline-flex; font-family: Georgia, serif; font-size: 24px; font-weight: 700; height: 48px; justify-content: center; width: 48px; }
.brand-mark.small { border-radius: 8px; font-size: 16px; height: 30px; width: 30px; }
.icon-button { align-items: center; background: transparent; border: 0; border-radius: 8px; display: inline-flex; height: 36px; justify-content: center; padding: 0; width: 36px; }
.icon-button:hover { background: rgba(31, 41, 55, .07); }
.primary-button { background: var(--accent); border: 0; border-radius: 10px; color: white; font-weight: 650; min-height: 48px; padding: 0 20px; }
.primary-button:hover:not(:disabled) { background: var(--accent-hover); }
.inline-error { background: #fff1f0; border: 1px solid #ffd2ce; border-radius: 8px; color: var(--danger); font-size: 12px; line-height: 1.5; margin: 0; padding: 9px 11px; }

.login-page { align-items: center; background: #f7f8fa; display: flex; justify-content: center; min-height: 100%; padding: 24px; }
.login-card { background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 20px; max-width: 420px; padding: 42px; width: 100%; }
.login-card > .brand-mark { margin: 0 auto 4px; }
.login-copy { text-align: center; }
.login-copy h1 { font-size: 24px; letter-spacing: -.025em; margin: 0 0 8px; }
.login-copy p, .login-footnote { color: var(--muted); font-size: 13px; margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 8px; }
.login-card label span { font-size: 13px; font-weight: 650; }
.login-card input { background: white; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 15px; min-height: 46px; outline: none; padding: 0 13px; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 87, 214, .12); }
.login-footnote { text-align: center; }

.app-page { display: flex; height: 100%; overflow: hidden; }
.sidebar { background: var(--sidebar); display: flex; flex: 0 0 260px; flex-direction: column; height: 100%; padding: 14px 12px 12px; position: relative; z-index: 30; }
.sidebar-head { align-items: center; display: flex; height: 42px; justify-content: space-between; padding: 0 7px; }
.brand-lockup { align-items: center; display: flex; gap: 9px; }
.brand-lockup strong { font-size: 16px; letter-spacing: -.02em; }
.new-chat-button { align-items: center; background: white; border: 1px solid var(--line); border-radius: 10px; display: flex; font-size: 14px; font-weight: 600; gap: 10px; margin-top: 15px; min-height: 46px; padding: 0 13px; text-align: left; width: 100%; }
.new-chat-button:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px rgba(15, 23, 42, .04); }
.primary-nav { border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding-bottom: 12px; }
.primary-nav button { align-items: center; background: transparent; border: 0; border-radius: 8px; display: grid; font-size: 13px; gap: 10px; grid-template-columns: 20px 1fr auto; min-height: 40px; padding: 0 10px; text-align: left; }
.primary-nav button:hover, .primary-nav button.active { background: rgba(31, 41, 55, .07); }
.primary-nav small { color: var(--muted); font-size: 10px; }
.history-section { display: flex; flex: 1; flex-direction: column; min-height: 0; padding-top: 15px; }
.sidebar-label { color: var(--muted); font-size: 11px; padding: 0 10px 8px; }
.history-list { overflow: auto; }
.history-item { background: transparent; border: 0; border-radius: 8px; display: block; font-size: 13px; overflow: hidden; padding: 10px; text-align: left; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.history-item:hover, .history-item.active { background: rgba(31, 41, 55, .07); }
.history-empty { color: #9ca3af; font-size: 12px; line-height: 1.6; margin: 3px 10px; }
.sidebar-footer { align-items: center; border-top: 1px solid var(--line); display: grid; gap: 10px; grid-template-columns: 34px 1fr 36px; padding: 12px 4px 0; }
.user-avatar { align-items: center; background: #dbe6ff; border-radius: 50%; color: var(--accent); display: flex; font-size: 12px; font-weight: 700; height: 34px; justify-content: center; width: 34px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { color: var(--muted); font-size: 10px; margin-top: 2px; }

.main-panel { background: white; flex: 1; height: 100%; min-width: 0; }
.chat-view, .files-view, .model-view { display: flex; flex-direction: column; height: 100%; }
.chat-header { align-items: center; border-bottom: 1px solid rgba(229, 231, 235, .7); display: flex; flex: 0 0 58px; padding: 0 24px; }
.chat-header > div { align-items: center; display: flex; gap: 12px; }
.chat-header strong { font-size: 14px; }
.chat-header span { align-items: center; color: var(--muted); display: inline-flex; font-size: 11px; gap: 6px; }
.chat-header i { background: #22a06b; border-radius: 50%; height: 7px; width: 7px; }
.chat-header.is-busy i { animation: pulse 850ms ease-in-out infinite alternate; background: var(--accent); }
.messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 24px 20px 160px; }
.welcome { align-items: center; display: flex; flex-direction: column; justify-content: center; margin: auto; min-height: min(590px, calc(100vh - 210px)); text-align: center; }
.assistant-orb { align-items: center; background: var(--accent); border-radius: 14px; color: white; display: flex; font-family: Georgia, serif; font-size: 20px; font-weight: 700; height: 46px; justify-content: center; margin-bottom: 22px; width: 46px; }
.welcome h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 650; letter-spacing: -.035em; margin: 0; }
.welcome > p { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.suggestions { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 34px; max-width: 720px; width: 100%; }
.suggestions button { align-items: flex-start; background: white; border: 1px solid var(--line); border-radius: 12px; display: flex; font-size: 12px; gap: 9px; line-height: 1.55; min-height: 74px; padding: 14px; text-align: left; }
.suggestions button:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.suggestions [data-icon] { color: var(--accent); margin-top: 1px; }
.message { display: grid; gap: 15px; grid-template-columns: 30px minmax(0, 1fr); margin: 0 auto; max-width: 780px; padding: 18px 0; width: 100%; }
.message + .message { border-top: 1px solid #f0f1f3; }
.message-avatar { align-items: center; background: var(--accent); border-radius: 8px; color: white; display: flex; font-family: Georgia, serif; font-size: 12px; font-weight: 700; height: 30px; justify-content: center; width: 30px; }
.message.user .message-avatar { background: #e8ebef; color: #4b5563; font-family: inherit; }
.message-role { font-size: 12px; font-weight: 650; margin: 2px 0 7px; }
.message-text { font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
.message.user .message-text { white-space: pre-wrap; }
.message-text p { margin: 0 0 10px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text ol, .message-text ul { margin: 8px 0 12px; padding-left: 24px; }
.message-text li { margin: 5px 0; padding-left: 2px; }
.message-text h3, .message-text h4, .message-text h5 { line-height: 1.45; margin: 16px 0 7px; }
.message-text h3:first-child, .message-text h4:first-child, .message-text h5:first-child { margin-top: 0; }
.message-text blockquote { border-left: 3px solid var(--line-strong); color: var(--muted); margin: 10px 0; padding-left: 12px; }
.message-text code { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 5px; font-family: Consolas, monospace; font-size: .9em; padding: 1px 4px; }
.message.assistant.is-streaming .message-text::after { animation: blink 900ms steps(1) infinite; color: var(--accent); content: "▋"; margin-left: 2px; }
.message-error { color: var(--danger); }
.citations { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.citations-title { color: var(--muted); flex-basis: 100%; font-size: 11px; }
.citation { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; max-width: 100%; }
.citation summary { cursor: pointer; font-size: 11px; font-weight: 600; max-width: 260px; overflow: hidden; padding: 8px 10px; text-overflow: ellipsis; white-space: nowrap; }
.citation p { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.65; margin: 0; max-width: 580px; padding: 9px 10px; white-space: pre-wrap; }
.composer-wrap { background: linear-gradient(180deg, rgba(255,255,255,0), white 22%); bottom: 0; left: 260px; padding: 28px 20px 12px; position: fixed; right: 0; z-index: 10; }
.composer { background: white; border: 1px solid var(--line-strong); border-radius: 22px; box-shadow: 0 8px 26px rgba(15, 23, 42, .08); margin: 0 auto; max-width: 780px; padding: 8px; }
.composer:focus-within { border-color: #9bb2ea; box-shadow: 0 8px 30px rgba(36, 87, 214, .1); }
.composer-row { align-items: flex-end; display: grid; gap: 8px; grid-template-columns: 38px 1fr 38px; }
.composer textarea { background: transparent; border: 0; line-height: 1.55; max-height: 170px; min-height: 40px; outline: 0; padding: 9px 3px; resize: none; width: 100%; }
.attach-button, .send-button { align-items: center; border: 0; border-radius: 50%; display: flex; height: 38px; justify-content: center; width: 38px; }
.attach-button { background: transparent; color: #4b5563; }
.attach-button:hover { background: var(--surface-soft); }
.send-button { background: var(--ink); color: white; }
.send-button:hover:not(:disabled) { background: #000; }
.send-button.is-stop { background: var(--danger); }
.disclaimer { color: #8b939f; font-size: 10px; margin: 7px 0 0; text-align: center; }
.attachment-queue { display: flex; gap: 7px; overflow-x: auto; padding: 0 1px 7px; }
.file-chip { align-items: center; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 10px; display: grid; flex: 0 0 auto; gap: 7px; grid-template-columns: 28px minmax(0, 130px) auto; max-width: 220px; padding: 7px 8px; }
.file-chip-icon { align-items: center; background: var(--accent-soft); border-radius: 6px; color: var(--accent); display: flex; height: 28px; justify-content: center; width: 28px; }
.file-chip-icon svg { height: 15px; width: 15px; }
.file-chip-copy { display: flex; flex-direction: column; min-width: 0; }
.file-chip-copy strong { font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-copy span { color: var(--muted); font-size: 9px; margin-top: 2px; }
.chip-remove { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 2px; }
.composer .inline-error { margin-bottom: 7px; }

.files-header { align-items: flex-start; border-bottom: 1px solid var(--line); display: flex; flex: 0 0 96px; justify-content: space-between; padding: 22px clamp(24px, 5vw, 60px); }
.files-header h1 { font-size: 23px; letter-spacing: -.025em; margin: 0 0 7px; }
.files-header p { color: var(--muted); font-size: 11px; margin: 0; }
.quiet-button { align-items: center; background: white; border: 1px solid var(--line); border-radius: 8px; display: inline-flex; font-size: 11px; gap: 6px; min-height: 36px; padding: 0 12px; }
.quiet-button:hover { background: var(--surface-soft); }
.files-body { margin: 0 auto; max-width: 900px; overflow-y: auto; padding: 32px 24px 60px; width: 100%; }
.drop-zone { align-items: center; background: var(--surface-soft); border: 1px dashed #b5becb; border-radius: 14px; display: flex; flex-direction: column; justify-content: center; min-height: 190px; padding: 24px; width: 100%; }
.drop-zone:hover, .drop-zone.is-dragging { background: var(--accent-soft); border-color: var(--accent); }
.drop-graphic { align-items: center; background: white; border: 1px solid var(--line); border-radius: 10px; color: var(--accent); display: flex; height: 42px; justify-content: center; margin-bottom: 12px; width: 42px; }
.drop-zone strong { font-size: 15px; }
.drop-zone > span:not(.drop-graphic) { color: var(--muted); font-size: 11px; margin-top: 6px; }
.drop-zone small { color: #949ba5; font-size: 10px; margin-top: 12px; }
.files-body > .inline-error { margin-top: 12px; }
.library-queue { border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; padding: 6px 12px; }
.library-queue .queue-row { align-items: center; border-bottom: 1px solid var(--line); display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; padding: 10px 2px; }
.library-queue .queue-row:last-child { border-bottom: 0; }
.queue-copy { min-width: 0; }
.queue-copy strong { display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-copy span { color: var(--muted); font-size: 9px; }
.queue-status { color: var(--accent); font-size: 10px; }
.queue-status.error { color: var(--danger); }
.recent-uploads { margin-top: 36px; }
.section-title { align-items: flex-end; display: flex; justify-content: space-between; margin-bottom: 12px; }
.section-title h2 { font-size: 15px; margin: 0; }
.section-title span { color: var(--muted); font-size: 10px; }
.recent-list { border-top: 1px solid var(--line); }
.recent-item { align-items: center; border-bottom: 1px solid var(--line); display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) auto; min-height: 62px; padding: 10px 2px; }
.file-main { min-width: 0; }
.file-name { display: block; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); display: block; font-size: 9px; margin-top: 5px; }
.recent-actions { align-items: center; display: flex; gap: 10px; }
.recent-result { color: #17785a; font-size: 10px; }
.recent-result.pending { color: #9a6700; }
.delete-upload, .download-upload { background: transparent; border: 0; border-radius: 6px; color: var(--muted); font-size: 10px; padding: 6px 8px; }
.delete-upload:hover { background: #fff1f0; color: var(--danger); }
.download-upload:hover { background: var(--accent-soft); color: var(--accent); }
.empty-state { color: var(--muted); font-size: 11px; margin: 0; padding: 26px 2px; }
.media-section { margin-top: 38px; }
.media-gallery { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.media-card { border: 1px solid var(--line); border-radius: 13px; min-width: 0; overflow: hidden; }
.media-preview { align-items: center; background: #f0f2f5; display: flex; height: 145px; justify-content: center; overflow: hidden; position: relative; }
.media-preview img, .media-preview video { height: 100%; object-fit: cover; width: 100%; }
.media-placeholder { align-items: center; color: var(--muted); display: flex; flex-direction: column; font-size: 10px; gap: 8px; }
.media-placeholder [data-icon] svg { height: 28px; width: 28px; }
.preview-media { align-items: center; background: rgba(32, 33, 35, .82); border: 0; border-radius: 999px; color: white; display: inline-flex; font-size: 10px; gap: 5px; min-height: 32px; padding: 0 12px; }
.media-card-footer { align-items: center; display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) auto; padding: 11px; }
.media-card-copy { min-width: 0; }
.media-card-copy strong { display: block; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card-copy span { color: var(--muted); display: block; font-size: 9px; margin-top: 3px; }
.model-body { margin: 0 auto; max-width: 900px; overflow-y: auto; padding: 38px 24px 60px; width: 100%; }
.model-summary-card { align-items: center; background: linear-gradient(135deg, #f6f8ff, #fff); border: 1px solid #dfe6f5; border-radius: 16px; display: flex; gap: 18px; padding: 24px; }
.model-logo { align-items: center; background: var(--accent); border-radius: 13px; color: white; display: flex; flex: 0 0 auto; font-size: 13px; font-weight: 750; height: 52px; justify-content: center; width: 52px; }
.model-kicker { color: var(--muted); font-size: 10px; }
.model-summary-card h2 { font-size: 20px; letter-spacing: -.02em; margin: 4px 0 7px; }
.model-summary-card p { align-items: center; color: #17785a; display: flex; font-size: 11px; margin: 0; }
.model-summary-card p::before { background: #22a06b; border-radius: 50%; content: ""; height: 7px; margin-right: 7px; width: 7px; }
.model-summary-card p.unavailable { color: #9a6700; }
.model-summary-card p.unavailable::before { background: #d99b19; }
.balance-section { margin-top: 34px; }
.balance-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.balance-card { border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.balance-card > span { color: var(--muted); font-size: 10px; }
.balance-total { align-items: baseline; display: flex; gap: 6px; margin-top: 12px; }
.balance-total strong { font-size: 28px; letter-spacing: -.035em; }
.balance-total small { color: var(--muted); font-size: 11px; }
.balance-detail { border-top: 1px solid var(--line); color: var(--muted); display: flex; font-size: 9px; justify-content: space-between; margin-top: 15px; padding-top: 11px; }
.balance-note { color: var(--muted); font-size: 10px; line-height: 1.7; margin: 14px 0 0; }
.balance-section .inline-error { margin-top: 12px; }
.mobile-header, .mobile-only { display: none; }
@keyframes pulse { to { opacity: .35; } }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 760px) {
  .sidebar { box-shadow: 12px 0 40px rgba(15, 23, 42, .16); left: 0; position: fixed; transform: translateX(-105%); transition: transform 180ms ease; width: min(86vw, 300px); }
  .sidebar.open { transform: translateX(0); }
  .mobile-backdrop { background: rgba(15, 23, 42, .32); inset: 0; position: fixed; z-index: 20; }
  .mobile-only { display: inline-flex; }
  .mobile-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; flex: 0 0 54px; justify-content: space-between; padding: 0 10px; }
  .mobile-header strong { font-size: 14px; }
  .chat-header { display: none; }
  .messages { padding: 14px 16px 150px; }
  .welcome { min-height: calc(100vh - 220px); }
  .suggestions { display: flex; flex-direction: column; margin-top: 28px; max-width: 360px; }
  .suggestions button { min-height: 50px; }
  .message { gap: 11px; grid-template-columns: 28px minmax(0, 1fr); padding: 15px 0; }
  .message-avatar { height: 28px; width: 28px; }
  .composer-wrap { left: 0; padding: 25px 10px 8px; }
  .composer { border-radius: 19px; }
  .files-header { flex: 0 0 auto; padding: 20px 18px; }
  .files-body, .model-body { padding: 20px 16px 50px; }
  .section-title { align-items: flex-start; flex-direction: column; gap: 6px; }
  .recent-actions { align-items: flex-end; flex-direction: column; gap: 3px; }
}
@media (max-width: 420px) {
  .login-page { padding: 14px; }
  .login-card { border-radius: 15px; padding: 30px 22px; }
  .welcome h1 { font-size: 25px; }
  .welcome > p { max-width: 280px; }
  .file-chip { grid-template-columns: 25px minmax(0, 110px) auto; }
}
