@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap');

:root {
  --page: #f4f9f4;
  --surface: #ffffff;
  --surface-soft: #edf6ee;
  --surface-warm: #f8fbf7;
  --ink: #18392a;
  --ink-strong: #0b2f20;
  --muted: #6e8375;
  --muted-light: #9aac9f;
  --line: #dce9de;
  --line-strong: #cbdccc;
  --green: #16805e;
  --green-dark: #07543f;
  --green-deep: #063d2f;
  --green-soft: #dcefe0;
  --mint: #b8ddbd;
  --gold: #b8914e;
  --danger: #b64f4f;
  --danger-soft: #fff1f0;
  --shadow: 0 18px 50px rgba(27, 75, 45, .10);
  --shadow-soft: 0 8px 24px rgba(27, 75, 45, .07);
  --sidebar-width: 292px;
  --content-width: 900px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: 'Noto Sans SC', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { border: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid rgba(22,128,94,.35); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Shared brand and buttons */
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 52px; height: 52px; flex: 0 0 auto; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-copy strong { color: var(--ink-strong); font-size: 17px; letter-spacing: -.02em; white-space: nowrap; }
.brand-copy small { color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border-radius: var(--radius-pill); font-weight: 700; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:hover { transform: translateY(-2px); }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(22,128,94,.18); }
.button-primary:hover { background: var(--green-dark); box-shadow: 0 12px 25px rgba(22,128,94,.25); }
.button-secondary { color: var(--green-dark); background: rgba(255,255,255,.88); border: 1px solid var(--line); }
.button-secondary:hover { background: #fff; border-color: var(--mint); }
.button-large { min-height: 52px; padding: 0 25px; font-size: 15px; }

/* Landing page */
.landing-page { background: var(--page); overflow-x: hidden; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 14px clamp(22px, 4vw, 64px); background: rgba(255,255,255,.87); border-bottom: 1px solid rgba(203,220,204,.8); backdrop-filter: blur(14px); position: relative; z-index: 2; }
.header-cta { min-height: 44px; padding: 0 23px; font-size: 14px; }
.hero { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 650px; padding: 122px 24px 110px; isolation: isolate; overflow: hidden; background: radial-gradient(ellipse at 50% 28%, rgba(199,231,204,.8) 0%, rgba(244,249,244,0) 56%), linear-gradient(180deg, #f9fcf9 0%, var(--page) 100%); }
.hero::before { content: ''; position: absolute; inset: 55px 12% auto; height: 520px; z-index: -1; border-radius: 50%; background: radial-gradient(ellipse, rgba(221,242,223,.65), transparent 69%); filter: blur(10px); }
.hero-orbit { position: absolute; z-index: -1; border: 1px solid rgba(90,159,103,.17); border-radius: 50%; transform: rotate(-16deg); }
.orbit-one { width: 720px; height: 235px; top: 240px; }
.orbit-two { width: 940px; height: 330px; top: 200px; border-color: rgba(90,159,103,.09); }
.eyebrow, .panel-tag { display: inline-flex; align-items: center; gap: 7px; color: var(--green); background: var(--green-soft); border: 1px solid rgba(95,167,107,.22); border-radius: var(--radius-pill); padding: 8px 15px; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.hero h1 { max-width: 840px; margin: 25px 0 22px; color: var(--ink-strong); font-size: clamp(42px, 6.4vw, 84px); line-height: 1.1; letter-spacing: -.07em; font-weight: 800; }
.hero h1 span { color: var(--green); }
.hero-lead { max-width: 720px; color: var(--muted); font-size: clamp(15px, 1.5vw, 18px); line-height: 1.9; }
.hero-actions { display: flex; gap: 12px; margin-top: 36px; }
.capability-panel { position: relative; display: grid; grid-template-columns: 1fr 1fr; max-width: 1080px; min-height: 270px; margin: -38px auto 0; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.capability-statement { padding: 38px 42px; color: #fff; background: var(--green-deep); }
.capability-statement h2 { margin: 23px 0 13px; font-size: clamp(23px, 2.4vw, 32px); line-height: 1.45; letter-spacing: -.05em; }
.capability-statement p { max-width: 400px; color: rgba(255,255,255,.68); font-size: 13px; line-height: 1.8; }
.capability-statement .panel-tag { color: #d9f4dd; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.18); }
.capability-list { padding: 38px 46px; background: rgba(255,255,255,.78); }
.panel-tag-light { color: var(--green); background: var(--green-soft); }
.capability-list ul { list-style: none; margin-top: 22px; }
.capability-list li { display: grid; grid-template-columns: minmax(130px, 1fr) 1.35fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.capability-list li:last-child { border-bottom: 0; }
.capability-list strong { color: var(--ink-strong); }
.capability-list li span { color: var(--muted); font-size: 13px; }
.panel-bridge { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 46px; height: 46px; color: var(--green); background: #fff; border: 1px solid var(--line); border-radius: 50%; transform: translate(-50%, -50%); font-size: 22px; box-shadow: var(--shadow-soft); }
.workflow-section { max-width: 1080px; margin: 100px auto 90px; padding: 0 25px; }
.section-heading { display: flex; align-items: flex-start; gap: 35px; }
.section-index, .section-kicker { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.section-kicker { margin-bottom: 10px; }
.section-heading h2 { max-width: 650px; color: var(--ink-strong); font-size: clamp(27px, 3vw, 42px); letter-spacing: -.055em; }
.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; list-style: none; margin: 46px 0 30px; }
.workflow-grid li { min-height: 210px; padding: 24px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: var(--radius-md); }
.step-number { display: block; margin-bottom: 40px; color: var(--green); font: 700 12px 'DM Sans', sans-serif; }
.workflow-grid h3 { margin-bottom: 9px; color: var(--ink-strong); font-size: 17px; }
.workflow-grid p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.text-link { display: inline-flex; align-items: center; gap: 8px; color: var(--green-dark); font-size: 14px; font-weight: 700; }
.text-link:hover { color: var(--green); }
.site-footer { display: flex; justify-content: space-between; gap: 15px; padding: 23px clamp(22px, 4vw, 64px); color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.filing-link { color: inherit; text-decoration: none; }
.filing-link:hover { color: var(--green-dark); text-decoration: underline; }
.filing-separator { margin: 0 .5em; }

/* Portal shell */
.portal-page { height: 100vh; overflow: hidden; background: var(--surface); }
.portal-shell { display: flex; height: 100vh; }
.portal-sidebar { position: relative; display: flex; flex: 0 0 var(--sidebar-width); flex-direction: column; padding: 26px 17px 18px; background: var(--surface-soft); border-right: 1px solid var(--line); z-index: 10; transition: flex-basis .2s ease; }
.portal-sidebar.is-collapsed { flex-basis: 0; width: 0; padding-left: 0; padding-right: 0; overflow: visible; }
.portal-sidebar.is-collapsed > *:not(.sidebar-resizer), .portal-sidebar.is-collapsed .sidebar-resizer { visibility: hidden; }
.sidebar-resizer { position: absolute; top: 0; right: -5px; bottom: 0; z-index: 2; width: 10px; cursor: col-resize; }
.sidebar-resizer::after { content: ''; position: absolute; top: 50%; left: 4px; width: 2px; height: 44px; background: var(--line-strong); border-radius: 2px; transform: translateY(-50%); opacity: .7; }
.sidebar-toggle { align-self: flex-end; margin: -17px 2px 8px; padding: 4px 7px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 6px; font-size: 10px; }
.sidebar-toggle:hover { color: var(--green-dark); background: #fff; }
.sidebar-expand { position: absolute; top: 16px; left: 10px; z-index: 11; display: none; }
.portal-sidebar.is-collapsed + .sidebar-scrim + .portal-main .sidebar-expand { display: grid; }
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; min-width: 0; margin: 0 8px 29px; }
.brand-compact { gap: 9px; }
.brand-compact .brand-logo { width: 44px; height: 44px; }
.brand-compact .brand-copy strong { font-size: 14px; }
.brand-compact .brand-copy small { font-size: 10px; }
.icon-button { display: grid; place-items: center; color: var(--muted); background: transparent; border-radius: 10px; }
.icon-button:hover { color: var(--green-dark); background: rgba(255,255,255,.7); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-close { display: none; width: 34px; height: 34px; font-size: 24px; }
.new-chat-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; color: #fff; background: var(--green); border-radius: 12px; box-shadow: 0 7px 16px rgba(22,128,94,.17); font-size: 14px; font-weight: 700; transition: background .2s, transform .2s; }
.new-chat-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.new-chat-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin: 37px 8px 12px; }
.history-heading h2 { color: var(--ink); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.history-heading span { display: grid; place-items: center; min-width: 21px; height: 21px; color: var(--green); background: rgba(255,255,255,.7); border-radius: 50%; font: 700 10px 'DM Sans', sans-serif; }
.history-nav { flex: 1; min-height: 0; overflow-y: auto; }
.conversation-list { list-style: none; display: grid; gap: 4px; }
.conversation-list li { display: flex; align-items: center; gap: 4px; }
.conversation-item { display: block; min-width: 0; flex: 1; padding: 12px 13px; color: var(--muted); background: transparent; border-radius: 10px; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; transition: color .2s, background .2s; }
.conversation-delete { flex: 0 0 auto; padding: 5px 4px; color: var(--muted-light); background: transparent; border: 0; font-size: 10px; opacity: 0; }
.conversation-list li:hover .conversation-delete, .conversation-delete:focus-visible { opacity: 1; }
.conversation-delete:hover { color: var(--danger); }
.conversation-item:hover { color: var(--ink); background: rgba(255,255,255,.62); }
.conversation-item.active { color: var(--green-dark); background: #fff; box-shadow: var(--shadow-soft); font-weight: 700; }
.history-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 30px 0; padding: 27px 12px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 13px; text-align: center; }
.history-empty svg { width: 23px; height: 23px; fill: none; stroke: var(--green); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.history-empty span { font-size: 12px; font-weight: 700; }
.history-empty small { color: var(--muted-light); font-size: 10px; line-height: 1.5; }
.sidebar-footnote { display: flex; align-items: center; gap: 8px; margin-top: 17px; padding: 12px 8px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; background: #d7a546; border-radius: 50%; box-shadow: 0 0 0 3px rgba(215,165,70,.12); }
.status-dot.is-online { background: #42a866; box-shadow: 0 0 0 3px rgba(66,168,102,.12); }
.status-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(182,79,79,.12); }
.sidebar-scrim { display: none; }
.portal-main { display: flex; flex: 1; min-width: 0; flex-direction: column; background: var(--surface); }
.portal-header { display: flex; align-items: center; justify-content: space-between; min-height: 82px; padding: 0 clamp(24px, 4.5vw, 70px); border-bottom: 1px solid var(--line); }
.portal-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.portal-overline { margin-bottom: 3px; color: var(--green); font: 700 10px 'DM Sans', sans-serif; letter-spacing: .13em; text-transform: uppercase; }
.portal-header h1 { max-width: 400px; overflow: hidden; color: var(--ink-strong); font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.portal-actions { display: flex; align-items: center; gap: 14px; }
.health-button, .home-button { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 10px; font-size: 11px; }
.health-button:hover { background: var(--surface-soft); border-color: var(--line); }
.home-button { color: var(--green-dark); border-color: var(--line); font-weight: 700; }
.home-button:hover { background: var(--surface-soft); border-color: var(--mint); }
.mobile-menu { display: none; width: 38px; height: 38px; }
.portal-workspace { position: relative; display: flex; flex: 1; min-height: 0; flex-direction: column; }
.welcome-state { width: min(100% - 48px, var(--content-width)); margin: auto auto 31px; padding-top: 35px; text-align: center; }
.welcome-logo { width: 72px; height: 72px; margin-bottom: 16px; filter: drop-shadow(0 8px 12px rgba(37,109,58,.12)); }
.welcome-kicker { margin-bottom: 10px; color: var(--green); font: 700 10px 'DM Sans', sans-serif; letter-spacing: .17em; }
.welcome-state h2 { color: var(--ink-strong); font-size: clamp(24px, 3vw, 34px); letter-spacing: -.06em; }
.welcome-intro { max-width: 660px; margin: 13px auto 0; color: var(--muted); font-size: 13px; line-height: 1.85; }
.welcome-capabilities { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 29px auto 24px; text-align: left; }
.welcome-capabilities article { display: flex; gap: 12px; min-height: 91px; padding: 16px; background: var(--surface-warm); border: 1px solid var(--line); border-radius: 13px; }
.welcome-capabilities article > span { color: var(--green); font: 700 11px 'DM Sans', sans-serif; }
.welcome-capabilities h3 { margin-bottom: 5px; color: var(--ink); font-size: 13px; }
.welcome-capabilities p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.prompt-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.prompt-suggestions button { padding: 8px 12px; color: var(--green-dark); background: var(--green-soft); border-radius: var(--radius-pill); font-size: 11px; transition: background .2s; }
.prompt-suggestions button:hover { background: var(--mint); }
.message-stream { flex: 1; width: min(100% - 48px, var(--content-width)); margin: 0 auto; padding: 36px 0 25px; overflow-y: auto; }
.message-stream[hidden], .welcome-state[hidden] { display: none; }
.chat-message { display: flex; gap: 13px; padding: 20px 0; border-bottom: 1px solid var(--line); }
/* 入场动画只在消息节点**首次**插入时播放。旧实现每次收到 delta 都重建整段消息 DOM，
   该动画随之对每条消息重放 —— 整段回答反复从透明淡入并上移 5px，这就是"文字刷新跳动"。 */
.chat-message.is-entering { animation: message-in .25s ease both; }
@keyframes message-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.message-avatar { display: grid; place-items: center; width: 31px; height: 31px; flex: 0 0 auto; color: var(--green-dark); background: var(--green-soft); border-radius: 10px; font: 700 11px 'DM Sans', sans-serif; }
.message-user .message-avatar { color: #fff; background: var(--green); }
.message-error .message-avatar { color: var(--danger); background: var(--danger-soft); }
.message-body { min-width: 0; flex: 1; }
.message-meta { margin: 2px 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.message-content { color: var(--ink); font-size: 14px; line-height: 1.85; overflow-wrap: anywhere; }
.message-error .message-content { color: var(--danger); }
.message-content p, .message-content ul, .message-content ol, .message-content blockquote, .message-content pre, .message-content table { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { padding-left: 22px; }
.message-content li { margin-bottom: 4px; }
.message-content h1, .message-content h2, .message-content h3 { margin: 18px 0 8px; color: var(--ink-strong); }
.message-content h2 { font-size: 18px; }
.message-content h3 { font-size: 16px; }
.message-content strong { color: var(--ink-strong); }
.message-content a { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.message-content blockquote { padding-left: 14px; color: var(--muted); border-left: 3px solid var(--mint); }
.message-content pre { padding: 14px; overflow-x: auto; color: #e7f3e8; background: var(--green-deep); border-radius: 10px; }
.message-content code { padding: 2px 5px; color: var(--green-dark); background: var(--green-soft); border-radius: 4px; font-family: 'DM Sans', monospace; font-size: .9em; }
.message-content pre code { padding: 0; color: inherit; background: transparent; }
.message-content table { width: 100%; border-collapse: collapse; font-size: 12px; }
.message-content th, .message-content td { padding: 8px; border: 1px solid var(--line); text-align: left; }
.message-content th { background: var(--surface-soft); }
.message-actions { margin-top: 8px; }
.message-actions[hidden] { display: none; }
.copy-message { padding: 4px 8px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 7px; font-size: 10px; }
.copy-message:hover { color: var(--green-dark); background: var(--surface-soft); }
.stream-cursor { display: inline-block; width: 6px; height: 17px; margin-left: 4px; vertical-align: -3px; background: var(--green); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.partial-label { color: var(--muted); font-size: 11px; }
/* 流式正文：已定稿的块直接作为 .message-content 的子节点（与整段渲染同构，间距一致），
   未定稿的尾部放在这里，每次只重绘这一个节点。 */
.stream-tail > :last-child { margin-bottom: 0; }
.composer-zone { width: min(100% - 48px, var(--content-width)); margin: auto auto 0; padding: 14px 0 21px; background: var(--surface); }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 11px 11px 11px 18px; background: #fff; border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 5px 18px rgba(31,81,48,.06); transition: border .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--green); box-shadow: 0 6px 22px rgba(22,128,94,.11); }
.composer textarea { width: 100%; max-height: 180px; min-height: 26px; padding: 4px 0; resize: none; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 13px; line-height: 1.6; }
.composer textarea::placeholder { color: var(--muted-light); }
.composer-actions { display: flex; align-items: center; gap: 6px; }
.attachment-button { display: grid; place-items: center; width: 36px; height: 36px; color: var(--muted-light); background: var(--surface-soft); border-radius: 10px; }
.attachment-button:disabled { cursor: not-allowed; opacity: .65; }
.attachment-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.send-button { height: 36px; padding: 0 16px; color: #fff; background: var(--green); border-radius: 10px; font-size: 12px; font-weight: 700; transition: background .2s; white-space: nowrap; flex-shrink: 0; }
.send-button:hover:not(:disabled) { background: var(--green-dark); }
.send-button:disabled { cursor: wait; opacity: .55; }
.stop-button { height: 36px; padding: 0 11px; color: var(--danger); background: var(--danger-soft); border-radius: 10px; font-size: 11px; font-weight: 700; }
.stop-button span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; vertical-align: 1px; background: currentColor; border-radius: 2px; }
.ai-disclaimer { margin-top: 9px; color: var(--muted-light); text-align: center; font-size: 10px; line-height: 1.5; }

@media (max-width: 800px) {
  .site-header { min-height: 72px; padding: 12px 20px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { display: none; }
  .header-cta { min-height: 39px; padding: 0 16px; font-size: 12px; }
  .hero { min-height: 590px; padding: 96px 22px 90px; }
  .hero h1 { font-size: clamp(38px, 11vw, 62px); }
  .hero-lead { font-size: 14px; }
  .capability-panel { grid-template-columns: 1fr; margin: -28px 18px 0; }
  .capability-statement, .capability-list { padding: 30px 27px; }
  .panel-bridge { top: 50%; left: auto; right: 23px; transform: translateY(-50%) rotate(90deg); }
  .capability-list li { grid-template-columns: 1fr; gap: 3px; }
  .workflow-section { margin-top: 70px; }
  .section-heading { gap: 18px; }
  .workflow-grid { grid-template-columns: 1fr; margin-top: 30px; }
  .workflow-grid li { min-height: auto; }
  .step-number { margin-bottom: 22px; }
  .site-footer { flex-direction: column; }
  .portal-sidebar { position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-width), calc(100vw - 45px)); transform: translateX(-102%); transition: transform .25s ease; box-shadow: var(--shadow); }
  .portal-sidebar.is-collapsed { flex-basis: auto; width: min(var(--sidebar-width), calc(100vw - 45px)); padding: 26px 17px 18px; transform: translateX(-102%); }
  .sidebar-resizer, .sidebar-toggle { display: none; }
  .portal-sidebar.is-open { transform: translateX(0); }
  .sidebar-close, .mobile-menu { display: grid; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 9; display: block; visibility: hidden; background: rgba(10,45,30,.22); opacity: 0; transition: visibility .25s, opacity .25s; }
  .sidebar-scrim.is-visible { visibility: visible; opacity: 1; }
  .portal-header { min-height: 70px; padding: 0 18px; }
  .portal-actions { gap: 4px; }
  .health-button { padding: 0 7px; }
  .health-button span:last-child { display: none; }
  .home-button { padding: 0 8px; font-size: 10px; }
  .welcome-state, .message-stream, .composer-zone { width: min(100% - 32px, var(--content-width)); }
  .welcome-state { padding-top: 25px; }
  .welcome-capabilities { grid-template-columns: 1fr; gap: 7px; margin-top: 22px; }
  .welcome-capabilities article { min-height: 0; padding: 12px; }
  .welcome-capabilities article > span { width: 25px; }
  .prompt-suggestions button { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .message-stream { padding-top: 17px; }
  .composer-zone { padding-bottom: 12px; }
}

@media (max-width: 480px) {
  .hero-actions { width: 100%; flex-direction: column; max-width: 280px; }
  .button-large { width: 100%; }
  .hero-orbit { display: none; }
  .portal-header h1 { max-width: 150px; font-size: 16px; }
  .portal-heading { gap: 8px; }
  .message-content { font-size: 13px; }
  .composer { padding-left: 13px; }
  .attachment-button { display: none; }
  .send-button { padding: 0 13px; }
}

/* ============================================================
   Auth & Admin (login / register / admin / portal 用户区)
   复用上方 :root 设计变量与 .site-header / .button 体系
   ============================================================ */

/* —— 登录 / 注册页 —— */
.auth-page { display: flex; flex-direction: column; min-height: 100vh; background: radial-gradient(ellipse at 50% 0%, rgba(199,231,204,.55) 0%, rgba(244,249,244,0) 52%), var(--page); }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 56px 20px; }
.auth-card { width: min(100%, 432px); padding: 38px 36px; background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-kicker { margin-bottom: 10px; color: var(--green); font: 700 10px 'DM Sans', sans-serif; letter-spacing: .17em; }
.auth-card h1 { color: var(--ink-strong); font-size: 26px; letter-spacing: -.04em; }
.auth-subtitle { margin: 9px 0 24px; color: var(--muted); font-size: 12.5px; line-height: 1.75; }
.auth-submit { width: 100%; min-height: 46px; margin-top: 6px; font-size: 14px; }
.auth-switch { margin-top: 19px; color: var(--muted); text-align: center; font-size: 12.5px; }
.auth-switch .text-link { margin-left: 4px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { display: flex; flex-direction: column; gap: 3px; color: var(--ink-strong); font-size: 13px; font-weight: 700; }
.field label small { color: var(--muted); font-weight: 500; font-size: 11px; line-height: 1.5; }
.field input { width: 100%; min-height: 44px; padding: 10px 14px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 14px; transition: border .2s, box-shadow .2s; }
.field input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px rgba(22,128,94,.14); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 科研邀请码：置顶且醒目 */
.field-invite { padding: 14px; background: var(--surface-warm); border: 1px dashed rgba(184,145,78,.55); border-radius: var(--radius-sm); }
.invite-tag { display: inline-flex; align-items: center; gap: 5px; margin-right: 7px; padding: 3px 9px; color: #7c5b21; background: #fdf6e7; border: 1px solid rgba(184,145,78,.4); border-radius: var(--radius-pill); font-size: 11px; font-weight: 800; letter-spacing: .04em; }

.form-alert { margin-bottom: 14px; padding: 10px 13px; color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(182,79,79,.28); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.65; }

.gate-card { text-align: center; }
.gate-card h1 { margin-bottom: 12px; }
.gate-card p:not(.auth-kicker) { color: var(--muted); font-size: 13px; line-height: 1.8; }
.gate-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.gate-actions .button { min-height: 44px; padding: 0 20px; font-size: 13px; }

.button-logout:hover { color: var(--danger); border-color: rgba(182,79,79,.45); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.admin-user-chip { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* —— 管理控制台 —— */
.admin-page { display: flex; flex-direction: column; min-height: 100vh; background: var(--page); }
.admin-main { flex: 1; width: min(100% - 40px, 1120px); margin: 0 auto; padding: 34px 0 60px; }
.admin-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.admin-heading h1 { color: var(--ink-strong); font-size: clamp(22px, 3vw, 30px); letter-spacing: -.04em; }
.admin-tabs { display: flex; gap: 5px; padding: 5px; background: rgba(255,255,255,.8); border: 1px solid var(--line); border-radius: var(--radius-pill); }
.admin-tabs button { padding: 8px 16px; color: var(--muted); background: transparent; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 700; transition: color .2s, background .2s; }
.admin-tabs button:hover { color: var(--green-dark); }
.admin-tabs button[aria-selected="true"] { color: #fff; background: var(--green); box-shadow: 0 5px 12px rgba(22,128,94,.18); }
.admin-panel { animation: message-in .25s ease both; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.admin-toolbar h2 { color: var(--ink-strong); font-size: 17px; letter-spacing: -.03em; }
.admin-card { padding: 22px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }
.admin-card h2 { margin-bottom: 6px; color: var(--ink-strong); font-size: 16px; letter-spacing: -.02em; }
.card-hint { margin-bottom: 16px; color: var(--muted-light); font-size: 11px; }
.invite-layout { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(300px, 4fr); gap: 16px; align-items: start; margin-top: 18px; }
.invite-form .invite-submit { width: 100%; min-height: 42px; }

.callout-warning { display: flex; gap: 8px; margin-bottom: 13px; padding: 10px 13px; color: #7c5b21; background: #fdf6e7; border: 1px solid rgba(184,145,78,.38); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.65; }
.code-block { max-height: 220px; overflow: auto; margin: 0 0 14px; padding: 14px; color: #e7f3e8; background: var(--green-deep); border-radius: var(--radius-sm); font-family: 'DM Sans', monospace; font-size: 12.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }
.invite-result-actions { display: flex; gap: 10px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }
.data-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 12.5px; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 11px 13px; color: var(--muted); background: var(--surface-soft); text-align: left; font-size: 11px; letter-spacing: .03em; white-space: nowrap; }
.data-table td { padding: 11px 13px; color: var(--ink); border-top: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
.data-table tbody tr:hover td { background: var(--surface-warm); }
.table-empty { padding: 26px; color: var(--muted-light); text-align: center; font-size: 12px; }
.cell-strong { color: var(--ink-strong); font-weight: 700; }
.cell-muted { color: var(--muted); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; color: var(--green-dark); background: #fff; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 700; white-space: nowrap; transition: background .2s, color .2s, border-color .2s; }
.btn:hover { border-color: var(--mint); background: var(--surface-soft); }
.btn-danger { color: var(--danger); border-color: rgba(182,79,79,.35); }
.btn-danger:hover { color: var(--danger); background: var(--danger-soft); border-color: rgba(182,79,79,.55); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.stat-card { padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }
.stat-card dt { color: var(--muted); font-size: 11px; }
.stat-card dd { margin-top: 6px; color: var(--ink-strong); font: 700 22px 'DM Sans', sans-serif; letter-spacing: -.02em; overflow-wrap: anywhere; }

.pager { display: flex; align-items: center; gap: 10px; }
.pager span { color: var(--muted); font-size: 12px; }
.pager .btn:disabled { cursor: not-allowed; opacity: .45; }

/* —— 弹窗与轻提示 —— */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10,45,30,.35); backdrop-filter: blur(3px); }
.modal-overlay[hidden] { display: none; }
.modal { width: min(100%, 420px); max-height: calc(100vh - 48px); overflow-y: auto; padding: 26px 26px 22px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal h3 { margin-bottom: 18px; color: var(--ink-strong); font-size: 17px; }
.modal-target { margin-left: 8px; color: var(--green); font-size: 12.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: 34px; z-index: 80; transform: translateX(-50%); max-width: min(90vw, 520px); padding: 11px 18px; color: #fff; background: var(--green-deep); border-radius: var(--radius-pill); box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.6; text-align: center; animation: message-in .25s ease both; }
.toast[hidden] { display: none; }
.toast-error { background: #7d3a3a; }

/* —— Portal 顶部用户区（由 portal-auth.js 注入）—— */
.user-chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 6px 3px 12px; background: var(--surface-warm); border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: 11px; }
.user-chip-name { max-width: 140px; overflow: hidden; color: var(--ink-strong); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-action { padding: 5px 9px; color: var(--muted); background: transparent; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; transition: color .2s, background .2s; }
.user-chip-action:hover { color: var(--green-dark); background: #fff; }
.user-chip-logout:hover { color: var(--danger); }

@media (max-width: 800px) {
  .auth-card { padding: 30px 22px; }
  .header-actions { gap: 6px; }
  .admin-user-chip { display: none; }
  .admin-heading { flex-direction: column; align-items: stretch; }
  .admin-tabs { justify-content: space-between; }
  .invite-layout { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}


/* ---------------------------------------------------------------------------
   检索档位切换（快速 / 深度思考）—— 2026-09-17
   与 DeepSeek 网页版的"快速 / 思考"同构：新对话可自由切换，
   会话一旦开始就锁定档位（Dify 的 conversation_id 绑在具体应用上）。
--------------------------------------------------------------------------- */
.composer-modes {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.mode-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: var(--surface-muted, rgba(127, 127, 127, 0.12));
  border: 1px solid var(--border-subtle, rgba(127, 127, 127, 0.22));
}

.mode-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted, #6b7280);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-option svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-option:hover:not(:disabled):not(.is-active) {
  color: var(--text-strong, #111827);
}

.mode-option.is-active {
  background: var(--surface-raised, #fff);
  color: var(--text-strong, #111827);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.mode-option:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mode-option[data-unavailable="1"] {
  text-decoration: line-through;
}

.mode-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  flex: 1 1 240px;
  min-width: 0;
}

/* 侧栏"生成中"标记：会话正在后台生成回答 */
.conversation-item .conversation-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.conversation-item .conversation-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.conversation-item .conversation-busy-label {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  color: var(--green-dark, #2f6f4f);
  background: rgba(47, 111, 79, 0.14);
}

.conversation-item .conversation-busy {
  display: inline-block;
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: bsf-busy-pulse 1.1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes bsf-busy-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .conversation-item .conversation-busy { animation: none; opacity: 0.8; }
}
