/* All assets and styles are local; message text never becomes markup. */
:root {
  color-scheme: light;
  --paper: #fcfcfa;
  --canvas: #f7f8f5;
  --sidebar: #f0f2ed;
  --ink: #29372f;
  --muted: #657168;
  --line: #dfe5dc;
  --accent: #3d624c;
  --accent-hover: #2e4e3b;
  --soft-accent: #e5ece2;
  --warning: #805329;
  --warning-bg: #faf2e6;
  --danger: #98413a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font-size: 14px; line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button { border: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; }
button, a, select, input, textarea, summary { touch-action: manipulation; }
:focus-visible { outline: 3px solid #73937b; outline-offset: 4px; }
button { transition: background-color .15s ease, color .15s ease; }
button svg { flex: 0 0 auto; }
p, h1, h2, h3 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.noscript { margin: 20px; padding: 15px; background: var(--warning-bg); color: var(--warning); }
.eyebrow { font-size: 11px; letter-spacing: .2em; color: var(--muted); }
.primary-button, .secondary-button, .danger-button { padding: 12px 19px; border-radius: 10px; min-height: 46px; font-weight: 600; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover:not(:disabled), .send-button:hover:not(:disabled) { background: var(--accent-hover); }
.secondary-button { background: var(--sidebar); color: var(--ink); }
.secondary-button:hover { background: var(--soft-accent); }
.danger-button { background: var(--danger); color: #fff; }
.danger-button:hover { background: #7e332e; }
.text-button { min-height: 36px; padding: 6px 3px; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; }
.text-button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; color: var(--muted); background: transparent; border-radius: 10px; }
.icon-button:hover { background: var(--soft-accent); color: var(--ink); }
.login-view { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 52px 24px 26px; background: radial-gradient(ellipse at 20% 5%, #e9eee3 0, transparent 52%), radial-gradient(ellipse at 90% 90%, #eeeee5 0, transparent 45%), var(--canvas); }
.login-card { width: min(100%, 395px); margin: auto; }
.brand-mark { width: 52px; height: 50px; display: flex; gap: 6px; align-items: center; margin-bottom: 30px; }
.brand-mark span { display: block; width: 10px; height: 36px; background: var(--accent); border-radius: 9px; transform: rotate(25deg); }
.brand-mark span:nth-child(2) { height: 48px; opacity: .65; }
.brand-mark span:nth-child(3) { height: 25px; opacity: .3; }
.login-card h1 { font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif; font-weight: 500; font-size: clamp(32px, 5vw, 40px); line-height: 1.55; letter-spacing: .03em; margin-top: 13px; }
.login-intro { margin: 17px 0 30px; color: var(--muted); line-height: 1.9; }
.login-form { display: flex; flex-direction: column; gap: 11px; }
.login-form label { font-size: 13px; font-weight: 600; }
.login-form input { min-height: 49px; width: 100%; padding: 12px 15px; background: #ffffffb3; border: 1px solid #cfd8cc; border-radius: 10px; font-size: 16px; color: var(--ink); }
.login-form input::placeholder { color: #7a8279; font-size: 14px; }
.form-message { min-height: 23px; color: var(--warning); font-size: 13px; overflow-wrap: anywhere; }
.login-footnote { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 19px; color: var(--muted); font-size: 12px; line-height: 1.9; }
.login-footnote p + p { margin-top: 8px; }
.login-storage-note { margin: 12px 0; font-size: 12px; color: var(--warning); }
.login-signature { color: var(--muted); letter-spacing: .1em; font-size: 11px; margin-top: 40px; }
.login-signature span { padding: 0 9px; color: #a1afa1; }
.app-shell { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 274px minmax(0, 1fr); overflow: hidden; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 28px 17px 16px; display: flex; flex-direction: column; min-height: 0; }
.sidebar-brand { min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 9px; margin-bottom: 25px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 22px; font-weight: 600; letter-spacing: .09em; }
.brand-symbol { display: inline-block; width: 17px; height: 21px; border: 2px solid var(--accent); border-radius: 10px 2px 10px 2px; transform: rotate(10deg); }
.brand-caption { margin-left: 1px; align-self: end; padding-bottom: 5px; font-size: 10px; color: var(--muted); font-weight: 400; letter-spacing: .03em; }
.new-button { display: flex; align-items: center; justify-content: center; gap: 11px; width: 100%; border: 1px solid #cad6c5; border-radius: 10px; padding: 12px; background: #fafcf8; color: var(--accent); font-weight: 600; }
.new-button:hover { background: var(--soft-accent); }
.plus-icon { width: 15px; height: 15px; position: relative; }
.plus-icon::before, .plus-icon::after { position: absolute; content: ""; background: currentColor; border-radius: 1px; }
.plus-icon::before { width: 14px; height: 1.5px; top: 6.5px; left: 0; }
.plus-icon::after { width: 1.5px; height: 14px; left: 6.5px; top: 0; }
.sidebar-section-heading { display: flex; justify-content: space-between; align-items: center; padding: 30px 10px 11px; color: var(--muted); }
.sidebar-section-heading h2, .sidebar-section-heading span { font-size: 11px; font-weight: 500; }
.history-nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.history-list { padding: 0 3px 12px; margin: 0; list-style: none; }
.history-list li + li { margin-top: 5px; }
.history-item { display: block; text-align: left; width: 100%; padding: 11px 12px; border-radius: 9px; background: transparent; color: var(--ink); border: 1px solid transparent; }
.history-item:hover { background: #e8ede4; }
.history-item[aria-current="true"] { background: var(--paper); border-color: #e2e7dd; box-shadow: 0 2px 6px #29372f04; }
.history-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.history-meta { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); margin-top: 5px; }
.pending-dot { height: 6px; width: 6px; border-radius: 50%; background: var(--accent); animation: breathe 1.5s ease-in-out infinite; }
.sidebar-footer { margin-top: 14px; padding: 16px 9px 0; border-top: 1px solid var(--line); }
.local-note { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); }
.small-dot { width: 5px; height: 5px; border-radius: 50%; background: #7c9574; flex-shrink: 0; }
.sidebar-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header { min-height: 91px; flex-shrink: 0; padding: 18px 34px; display: flex; align-items: center; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); }
.conversation-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.heading-text { min-width: 0; }
.heading-text h1 { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heading-text p { color: var(--muted); font-size: 10px; margin-top: 4px; }
.model-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.model-control label { color: var(--muted); font-size: 11px; }
.model-control select { max-width: 225px; min-width: 125px; color: var(--ink); background: var(--canvas); border: 1px solid var(--line); border-radius: 8px; padding: 8px 27px 8px 11px; font-size: 12px; min-height: 37px; text-overflow: ellipsis; }
.notice-area { padding: 0 28px; }
.warning-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 13px; background: var(--warning-bg); color: var(--warning); border: 1px solid #eddfcb; border-radius: 8px; font-size: 12px; margin-top: 12px; }
.warning-banner p { overflow-wrap: anywhere; }
.warning-banner .text-button { flex-shrink: 0; color: var(--warning); }
.inline-notice { color: var(--warning); font-size: 12px; margin: 9px 0; overflow-wrap: anywhere; }
.chat-body { flex: 1; min-height: 0; position: relative; display: flex; }
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; scrollbar-width: thin; padding: 0 34px; }
.welcome { min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 38px 0; }
.welcome-illustration { position: relative; width: 78px; height: 69px; margin-bottom: 25px; }
.welcome-illustration span { position: absolute; width: 44px; height: 52px; border: 1px solid #b7c7ae; border-radius: 16px 4px 16px 4px; background: #eef2e9; transform: rotate(-18deg); left: 7px; top: 6px; }
.welcome-illustration span:nth-child(2) { left: 24px; top: 8px; transform: rotate(13deg); background: #f8faf5; }
.welcome-illustration span:nth-child(3) { width: 15px; height: 1px; border: 0; background: #7d9873; top: 31px; left: 39px; transform: rotate(13deg); }
.welcome h2 { font-family: "Songti SC", "Noto Serif CJK SC", "SimSun", serif; font-weight: 500; font-size: clamp(25px, 3vw, 32px); line-height: 1.6; margin: 10px 0 13px; letter-spacing: .04em; }
.welcome > p:not(.eyebrow) { color: var(--muted); line-height: 1.9; font-size: 13px; }
.welcome-note { font-size: 11px; color: var(--muted); margin-top: 28px; line-height: 1.9; }
.message-list { width: min(100%, 780px); margin: 0 auto; padding: 28px 0 37px; }
.message-list:empty { padding: 0; }
.message { padding: 0 0 30px; }
.message:last-child { padding-bottom: 0; }
.message-heading { display: flex; gap: 9px; align-items: center; margin-bottom: 12px; }
.message-heading h3 { font-size: 12px; font-weight: 600; }
.message-avatar { height: 25px; width: 25px; border-radius: 8px; background: var(--soft-accent); color: var(--accent); font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
.message-user .message-avatar { background: #edeee9; color: var(--muted); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.85; font-size: 15px; tab-size: 4; min-width: 0; }
.message-user .message-body { padding: 15px 19px; border: 1px solid #e6e9e0; border-radius: 2px 13px 13px 13px; background: #f2f4ee; }
.message-assistant .message-body { padding: 0 1px; }
.message-notice { margin-top: 10px; padding-left: 10px; border-left: 2px solid #c3cfc0; color: var(--muted); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-notice.is-warning { border-color: #c6a277; color: var(--warning); }
.jump-button { position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); padding: 8px 15px; color: var(--accent); box-shadow: 0 4px 18px #29372f0c; font-size: 12px; white-space: nowrap; }
.jump-button:hover { background: var(--soft-accent); }
.jump-button span { margin-left: 8px; }
.composer-area { width: min(100%, 848px); margin: 0 auto; padding: 0 34px max(16px, env(safe-area-inset-bottom)); flex-shrink: 0; }
.activity-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 29px; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.activity-line p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-line span { flex-shrink: 0; }
.composer { border: 1px solid #cdd8c8; border-radius: 14px; background: #fff; box-shadow: 0 3px 18px #29372f04; padding: 14px 14px 11px; transition: border-color .15s; }
.composer:focus-within { border-color: #8ba17f; box-shadow: 0 0 0 3px #73937b13; }
.composer textarea { display: block; width: 100%; min-height: 73px; max-height: 25dvh; resize: vertical; border: 0; padding: 0 3px; background: transparent; color: var(--ink); line-height: 1.7; font-size: 15px; }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: #7d897d; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.keyboard-hint { color: var(--muted); font-size: 10px; padding-left: 3px; }
.keyboard-hint span { padding: 0 5px; }
.send-button { display: flex; align-items: center; gap: 9px; border-radius: 8px; padding: 8px 13px; min-height: 38px; background: var(--accent); color: white; font-size: 12px; flex-shrink: 0; }
.send-button.is-stopping { background: #eef1e9; color: var(--ink); border: 1px solid var(--line); }
.send-button.is-stopping:hover { background: var(--soft-accent); }
.stop-icon { display: inline-block; width: 10px; height: 10px; background: currentColor; border-radius: 2px; }
.composer-error { font-size: 12px; color: var(--danger); margin-top: 8px; overflow-wrap: anywhere; }
.composer-help { margin-top: 10px; text-align: center; font-size: 10px; color: var(--muted); }
.context-details { color: var(--muted); font-size: 11px; margin-bottom: 4px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.context-details summary { cursor: pointer; color: var(--accent); }
.context-content { padding-top: 10px; max-height: 23dvh; overflow-y: auto; scrollbar-width: thin; }
.context-content p { line-height: 1.8; }
#summary-state { color: var(--warning); margin-top: 6px; }
.context-content pre { font: inherit; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid var(--line); padding-left: 12px; }
.confirm-dialog { color: var(--ink); background: var(--paper); border: 1px solid var(--line); padding: 28px; width: min(440px, calc(100% - 36px)); border-radius: 17px; box-shadow: 0 24px 90px #1c2b3026; }
.confirm-dialog::backdrop { background: #24302660; backdrop-filter: blur(3px); }
.confirm-dialog h2 { font-size: 19px; font-weight: 600; margin-bottom: 13px; }
.confirm-dialog p { font-size: 13px; line-height: 1.9; color: var(--muted); }
.confirm-dialog .dialog-warning { margin-top: 10px; color: var(--warning); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.attach-button { min-height: 38px; padding: 7px 11px; font-size: 12px; flex-shrink: 0; }
.attachment-list { list-style: none; margin: 9px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
#draft-attachments { max-height: 16dvh; overflow-y: auto; }
.attachment-item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); min-width: 0; }
.attachment-open { background: transparent; color: var(--accent); text-align: left; padding: 9px 11px; min-height: 40px; min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 12px; }
.attachment-open:hover { text-decoration: underline; }
.attachment-remove { padding: 8px 10px; min-height: 40px; flex-shrink: 0; background: transparent; color: var(--danger); font-size: 12px; }
.attachment-copy-note { margin-top: 8px; color: var(--warning); font-size: 11px; overflow-wrap: anywhere; }
.attachment-help { color: var(--muted); font-size: 10px; margin-top: 7px; }
.attachment-help summary { cursor: pointer; }
.attachment-help[open] { max-height: 20dvh; overflow-y: auto; }
.attachment-help p { margin-top: 7px; overflow-wrap: anywhere; }
.attachment-dialog { width: min(760px, calc(100% - 32px)); max-height: 90dvh; overflow-y: auto; }
.attachment-dialog h2 { overflow-wrap: anywhere; }
.attachment-dialog img { display: block; max-width: 100%; max-height: 60dvh; object-fit: contain; margin: 15px auto 0; }
.attachment-dialog pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.7 ui-monospace, monospace; max-height: 55dvh; overflow-y: auto; }
.mobile-only { display: none; }
@keyframes breathe { 50% { opacity: .35; } }
@media (min-width: 1500px) { .app-shell { grid-template-columns: 294px minmax(0, 1fr); } .chat-header { padding-left: 46px; padding-right: 46px; } }
@media (max-width: 950px) and (min-width: 761px) { .app-shell { grid-template-columns: 232px minmax(0, 1fr); } .chat-header { padding: 18px 22px; } .model-control select { max-width: 170px; min-width: 100px; } .model-control label { display: none; } .composer-area, .transcript { padding-left: 23px; padding-right: 23px; } }
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  .app-shell { display: flex; }
  .chat-main { flex: 1; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 20; padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility .2s; box-shadow: 12px 0 40px #24302615; }
  .sidebar.is-open { visibility: visible; transform: translateX(0); }
  .sidebar-brand { padding-right: 0; }
  .drawer-overlay { position: fixed; inset: 0; z-index: 19; background: #24302655; backdrop-filter: blur(2px); }
  .chat-header { min-height: 75px; padding: max(11px, env(safe-area-inset-top)) 14px 11px 8px; gap: 8px; }
  .conversation-heading { gap: 3px; flex: 1; }
  .heading-text h1 { font-size: 14px; }
  .heading-text p { font-size: 9px; }
  .model-control { flex-direction: column; align-items: flex-end; gap: 0; }
  .model-control label { display: none; }
  .model-control select { font-size: 12px; width: 140px; max-width: 35vw; min-width: 0; padding-left: 8px; padding-right: 20px; }
  .model-control .text-button { font-size: 10px; min-height: 27px; padding: 2px; }
  .notice-area { padding: 0 17px; }
  .warning-banner { align-items: flex-start; font-size: 11px; padding: 9px 10px; }
  .transcript { padding: 0 20px; }
  .message-list { padding: 24px 0 35px; }
  .message-body { font-size: 15px; }
  .message { padding-bottom: 25px; }
  .message-user .message-body { padding: 12px 15px; }
  .welcome { padding: 25px 0; }
  .welcome-illustration { margin-bottom: 19px; }
  .welcome-note { margin-top: 20px; }
  .composer-area { padding: 0 14px max(10px, env(safe-area-inset-bottom)); }
  .composer { padding: 12px 12px 10px; }
  .composer textarea { min-height: 59px; font-size: 16px; max-height: 23dvh; }
  .keyboard-hint { display: none; }
  .composer-help { font-size: 9px; margin-top: 8px; }
  .activity-line { font-size: 10px; }
  .context-details { font-size: 10px; }
}
@media (max-height: 650px) { .welcome-illustration, .welcome-note { display: none; } .welcome { padding: 22px 0; } .welcome h2 { font-size: 25px; } .composer textarea { min-height: 44px; } .login-view { padding-top: 28px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
