:root {
  color-scheme: light;
  --paper: #efeee6;
  --ink: #151918;
  --gold: #ad9471;
  --muted: #6d746c;
  --line: #d6d8ce;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--paper); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a, textarea, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input, textarea { border-radius: 0; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }
.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; }
.skip-link { position: fixed; z-index: 20; top: 8px; left: 16px; padding: 12px 18px; background: var(--paper); border: 1px solid var(--gold); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar { display: flex; flex-direction: column; min-height: 0; padding: 29px 18px 20px; color: var(--paper); background: var(--ink); }
.sidebar-brand { display: flex; align-items: center; gap: 13px; align-self: flex-start; margin: 0 12px 38px; font-size: 13px; font-weight: 600; letter-spacing: .18em; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 38px; border: 1px solid #6b6656; color: #d7c5a7; font-family: Georgia, "Times New Roman", serif; font-size: 27px; font-weight: 400; letter-spacing: -.06em; }
.brand-caption { display: block; margin-top: 5px; color: #92988f; font-size: 8px; font-weight: 400; letter-spacing: .29em; }
.new-conversation { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 46px; padding: 10px 13px; border: 1px solid #42473f; border-radius: 8px; background: transparent; font-size: 13px; text-align: start; transition: background .15s, border-color .15s; }
.new-conversation:hover { border-color: #777968; background: #232825; }
.new-conversation svg { width: 19px; height: 19px; }
.conversation-nav { min-height: 0; margin-top: 35px; flex: 1; }
.sidebar-label { margin: 0 13px 13px; color: #92998f; font-size: 11px; }
.current-conversation { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 43px; padding: 10px 13px; border: 0; border-radius: 7px; background: #292f2a; text-align: start; font-size: 12px; }
.current-conversation svg { width: 17px; height: 17px; color: #b8bfb2; }
.current-conversation span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-conversation:hover { background: #343b34; }
.sidebar-footer { padding: 19px 4px 0; border-top: 1px solid #353b34; }
.sidebar-footer > p { margin: 0 8px 15px; color: #92998f; font-size: 10px; line-height: 1.7; }
.login-button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; text-align: start; font-size: 12px; }
.login-button:hover { background: #292f2a; }
.login-icon { display: grid; place-items: center; width: 32px; height: 32px; color: #cfbc9c; border: 1px solid #4c5147; border-radius: 50%; }
.login-icon svg { width: 17px; height: 17px; }
.login-arrow { margin-inline-start: auto; color: #aeb5a9; font-size: 17px; }
.sidebar-backdrop { position: fixed; z-index: 4; inset: 0; width: 100%; height: 100%; border: 0; background: rgb(8 13 10 / 45%); }

.dialogue-main { display: grid; grid-template-rows: 75px minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; padding: 0 35px; }
.topbar-left { display: flex; align-items: center; min-width: 0; gap: 14px; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; min-width: 0; }
.topbar .language-picker { flex-shrink: 0; }
.topbar .language-picker select { width: 142px; max-width: 100%; min-width: 0; font-size: 11px; }
.page-label { margin: 0; color: #586153; font-size: 10px; font-weight: 500; letter-spacing: .15em; white-space: nowrap; }
.page-label span { margin: 0 9px; color: #a5aa9e; }
.home-link { display: flex; align-items: center; gap: 13px; flex-shrink: 0; color: #5c6558; font-size: 11px; }
.home-link [aria-hidden] { font-size: 16px; }
.home-link:hover { color: var(--ink); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 6px; background: transparent; }
.icon-button:hover { background: #e3e5db; }
.menu-toggle { display: none; }
.message-scroll { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #c4c8ba transparent; }
.message-scroll:focus-visible { outline-offset: -4px; }
.welcome { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 32px 24px 65px; text-align: center; }
.welcome-inner { width: 100%; max-width: 620px; }
.welcome-mark { position: relative; display: inline-block; margin-bottom: 24px; padding-right: 6px; font-family: Georgia, "Times New Roman", serif; font-size: 58px; line-height: .9; letter-spacing: -.12em; }
.welcome-mark > span { position: absolute; width: 7px; height: 7px; top: 3px; right: -8px; background: var(--gold); }
.welcome-eyebrow { margin: 0 0 14px; color: #838778; font-size: 9px; letter-spacing: .25em; }
.welcome h1 { margin: 0; font-size: clamp(29px, 3.2vw, 42px); font-weight: 450; line-height: 1.5; letter-spacing: .025em; }
.welcome-description { margin: 15px 0 34px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.suggestions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; max-width: 580px; margin: 0 auto; }
.suggestions button { display: flex; align-items: center; gap: 20px; min-height: 41px; max-width: 100%; padding: 9px 15px 9px 17px; border: 1px solid #d2d5c9; border-radius: 22px; background: transparent; color: #535e4e; font-size: 11px; text-align: start; overflow-wrap: anywhere; transition: background .15s, border-color .15s; }
.suggestions button:hover { border-color: #b8bfad; background: #e4e7dc; }
.suggestions button [aria-hidden] { color: #8a927f; font-size: 13px; flex-shrink: 0; }

.messages { width: min(100% - 64px, 760px); margin: 0 auto; padding: 25px 0 40px; }
.message { display: flex; gap: 15px; align-items: flex-start; margin: 0 0 32px; }
.message--user { flex-direction: column; align-items: flex-end; gap: 7px; }
.message--assistant { margin-bottom: 39px; }
.message-avatar { display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0; border: 1px solid #c4c7b9; border-radius: 50%; font-family: Georgia, "Times New Roman", serif; font-size: 19px; }
.message-content { min-width: 0; max-width: 100%; padding-top: 2px; }
.message--user .message-content { max-width: 86%; padding: 13px 19px; border-radius: 22px 22px 5px 22px; background: #e1e5d9; }
.message-role { margin: 0 0 8px; color: #646f5d; font-size: 10px; font-weight: 600; letter-spacing: .05em; }
.message-text { margin: 0; color: #313a2c; font-size: 14px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.message--user .message-text { color: #20291d; line-height: 1.85; }
.message-tools { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 10px; max-width: 100%; }
.copy-message { min-width: 40px; min-height: 32px; padding: 3px 7px; border: 0; border-radius: 4px; color: #687260; background: transparent; font-size: 10px; }
.copy-message:hover { background: #e0e4d7; }
.copy-feedback { margin: 0; color: #687260; font-size: 10px; line-height: 1.6; }
.composer-region { min-width: 0; padding: 15px 32px 15px; }
.composer-shell { width: 100%; max-width: 780px; margin: 0 auto; }
.composer { padding: 17px 14px 11px 20px; border: 1px solid #cfd4c6; border-radius: 23px; background: #f7f7f0; box-shadow: 0 5px 26px rgb(21 25 24 / 3%); }
.composer:focus-within { border-color: #a5b198; }
.composer textarea { display: block; width: 100%; min-height: 27px; max-height: 160px; margin: 0; padding: 0 6px 0 0; border: 0; background: transparent; color: #222c1d; font-size: 14px; line-height: 1.8; resize: none; overflow-y: auto; outline: none; scrollbar-width: thin; }
.composer textarea:focus-visible { outline: none; }
.composer textarea::placeholder { color: #929987; opacity: 1; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.keyboard-hint { color: #89917f; font-size: 9px; line-height: 1.5; }
.keyboard-hint span { margin: 0 5px; }
.send-button { display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0; padding: 0; border: 0; border-radius: 50%; color: var(--paper); background: var(--ink); transition: background .15s, color .15s; }
.send-button svg { width: 20px; height: 20px; stroke-width: 1.8; }
.send-button:hover:not(:disabled) { background: #3b4535; }
.send-button:disabled { color: #f7f7f0; background: #c9cfbf; }
.preview-status { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 12px 0 0; color: #7b8472; font-size: 10px; line-height: 1.5; letter-spacing: .015em; }
.preview-status > .status-dot { width: 4px; height: 4px; flex-shrink: 0; border-radius: 50%; background: #ac9674; }
.no-script { margin: 12px 0 0; color: #6a735f; font-size: 12px; line-height: 1.7; text-align: center; }

.login-dialog { position: fixed; width: min(420px, calc(100% - 32px)); max-height: calc(100% - 32px); margin: auto; padding: 35px 32px 25px; overflow-y: auto; border: 1px solid #d0d5c5; border-radius: 18px; color: var(--ink); background: var(--paper); box-shadow: 0 20px 100px rgb(0 0 0 / 16%); }
.login-dialog::backdrop { background: rgb(8 13 10 / 47%); }
.dialog-close { position: absolute; top: 13px; inset-inline-end: 13px; color: #7c8572; }
.dialog-close svg { width: 19px; height: 19px; }
.dialog-brand { display: block; margin-bottom: 25px; font-family: Georgia, "Times New Roman", serif; font-size: 41px; line-height: 1; letter-spacing: -.08em; }
.dialog-eyebrow { margin: 0 0 12px; color: #7d8772; font-size: 9px; letter-spacing: .15em; }
.login-dialog h2 { margin: 0 0 29px; font-size: 27px; font-weight: 450; }
.login-form label { display: block; margin-bottom: 9px; color: #5f6b55; font-size: 11px; }
.login-form input { width: 100%; min-height: 48px; padding: 11px 13px; border: 1px solid #c9d0bf; border-radius: 6px; color: #222c1d; background: #f7f7f0; font-size: 14px; }
.login-form input::placeholder { color: #939b88; }
.login-submit { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 47px; margin-top: 13px; padding: 12px 15px; border: 0; border-radius: 6px; color: var(--paper); background: var(--ink); font-size: 12px; text-align: start; }
.login-submit:hover { background: #35402f; }
.login-submit [aria-hidden] { font-size: 16px; }
.login-result { margin: 0 0 18px; padding: 17px 18px; border: 1px solid #cfd6c2; border-radius: 6px; color: #505e43; background: #e5e9dc; font-size: 13px; line-height: 1.9; }
.continue-button { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; min-height: 44px; margin-top: 14px; padding: 10px 0; border: 0; border-radius: 6px; background: transparent; color: #5a674f; font-size: 11px; }
.continue-button:hover { background: #e2e6d9; }
.login-note { margin: 13px 0 0; color: #818b75; font-size: 10px; line-height: 1.7; text-align: center; }

[dir="rtl"] .message--user .message-content { border-radius: 22px 22px 22px 5px; }
[dir="rtl"] .composer { padding-inline: 20px 14px; }
[dir="rtl"] .composer textarea { padding-inline: 0 6px; }
[dir="rtl"] .continue-button [aria-hidden] { transform: scaleX(-1); }

@media (min-width: 1500px) {
  .app-shell { grid-template-columns: 266px minmax(0, 1fr); }
  .sidebar { padding-right: 22px; padding-left: 22px; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; width: min(280px, calc(100% - 48px)); visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility .2s; }
  .sidebar-open .sidebar { visibility: visible; transform: translateX(0); }
  .dialogue-main { grid-template-rows: 65px minmax(0, 1fr) auto; }
  .topbar { gap: 8px; padding: 0 14px 0 12px; }
  .topbar-left { gap: 8px; }
  .menu-toggle { display: grid; }
  .page-label { font-size: 9px; letter-spacing: .09em; }
  .page-label span { margin: 0 5px; }
  .topbar-actions { gap: 7px; }
  .topbar .language-picker select { width: 115px; font-size: 10px; }
  .home-link { gap: 7px; font-size: 10px; }
  .home-link [data-i18n="chat.home"] { display: none; }
  .home-link { justify-content: center; width: 22px; min-height: 36px; }
  .welcome { padding: 25px 20px 45px; }
  .welcome-mark { margin-bottom: 22px; font-size: 51px; }
  .welcome-description { margin: 13px 0 28px; font-size: 12px; }
  .suggestions { max-width: 370px; gap: 8px; }
  .suggestions button { gap: 15px; min-height: 40px; padding: 9px 13px; font-size: 10px; }
  .messages { width: calc(100% - 36px); padding-top: 22px; }
  .message { gap: 11px; }
  .message-text { font-size: 13px; }
  .message--user .message-content { max-width: 90%; padding: 11px 16px; }
  .message-avatar { width: 27px; height: 27px; font-size: 17px; }
  .composer-region { padding: 11px 14px max(12px, env(safe-area-inset-bottom)); }
  .composer { padding: 15px 12px 10px 16px; border-radius: 21px; }
  .composer textarea { font-size: 16px; }
  .keyboard-hint { font-size: 8px; }
  .keyboard-hint span { margin: 0 3px; }
  .preview-status { margin-top: 10px; font-size: 9px; }
  [dir="rtl"] .sidebar { inset: 0 0 0 auto; transform: translateX(100%); }
  [dir="rtl"] .sidebar-open .sidebar { transform: translateX(0); }
  [dir="rtl"] .composer { padding-inline: 16px 12px; }
}

@media (max-width: 359px) {
  .topbar { padding-right: 14px; padding-left: 9px; }
  .topbar-left { gap: 3px; }
  .page-label { font-size: 8px; letter-spacing: .06em; }
  .page-label span { margin: 0 3px; }
  .home-link { gap: 5px; font-size: 9px; }
  .topbar-actions { gap: 4px; }
  .topbar .language-picker select { width: 102px; }
  .welcome { padding-right: 16px; padding-left: 16px; }
  .welcome h1 { font-size: 27px; }
  .suggestions { max-width: 280px; gap: 7px; }
  .suggestions button { gap: 10px; padding-right: 11px; padding-left: 11px; }
  .keyboard-hint { max-width: 190px; }
  .login-dialog { padding-right: 23px; padding-left: 23px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Day and night palettes share the same layout and preserve conversation state. */
html[data-theme="light"] {
  color-scheme: light;
  --paper: #efeee6;
  --ink: #202824;
  --gold: #7a6240;
  --muted: #626c5c;
  --line: #d1d4c8;
}
html[data-theme="light"] .sidebar { color: #202824; background: #e2e5db; border-inline-end: 1px solid #d0d5c7; }
html[data-theme="light"] .brand-mark { color: #7a6240; border-color: #a99b82; }
html[data-theme="light"] .brand-caption,
html[data-theme="light"] .sidebar-label,
html[data-theme="light"] .sidebar-footer > p { color: #606b59; }
html[data-theme="light"] .new-conversation { border-color: #bfc7b5; }
html[data-theme="light"] .new-conversation:hover,
html[data-theme="light"] .current-conversation:hover,
html[data-theme="light"] .login-button:hover { background: #d1d8c9; border-color: #9ca88f; }
html[data-theme="light"] .current-conversation { background: #d6ddce; }
html[data-theme="light"] .current-conversation svg { color: #5f6c54; }
html[data-theme="light"] .sidebar-footer { border-color: #c0c8b6; }
html[data-theme="light"] .login-icon { color: #7a6240; border-color: #acb59f; }
html[data-theme="light"] .login-arrow { color: #637257; }
html[data-theme="light"] .welcome-eyebrow,
html[data-theme="light"] .keyboard-hint,
html[data-theme="light"] .preview-status,
html[data-theme="light"] .dialog-close,
html[data-theme="light"] .dialog-eyebrow,
html[data-theme="light"] .login-note { color: #626c5c; }
html[data-theme="light"] .composer textarea::placeholder,
html[data-theme="light"] .login-form input::placeholder { color: #6d7762; }

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151918;
  --ink: #efeee6;
  --gold: #c1aa87;
  --muted: #b7beb3;
  --line: #394038;
}
html[data-theme="dark"] .sidebar { color: #efeee6; background: #101412; border-inline-end: 1px solid #303830; }
html[data-theme="dark"] .brand-mark { color: #d7c5a7; border-color: #77745f; }
html[data-theme="dark"] .brand-caption,
html[data-theme="dark"] .sidebar-label,
html[data-theme="dark"] .sidebar-footer > p { color: #b7beb3; }
html[data-theme="dark"] .new-conversation { border-color: #454f42; }
html[data-theme="dark"] .new-conversation:hover,
html[data-theme="dark"] .current-conversation:hover,
html[data-theme="dark"] .login-button:hover { background: #293329; border-color: #75816a; }
html[data-theme="dark"] .current-conversation { background: #222b23; }
html[data-theme="dark"] .current-conversation svg { color: #b7beb3; }
html[data-theme="dark"] .sidebar-footer { border-color: #394038; }
html[data-theme="dark"] .login-icon { color: #d7c5a7; border-color: #59644f; }
html[data-theme="dark"] .login-arrow { color: #b7beb3; }
html[data-theme="dark"] .page-label,
html[data-theme="dark"] .home-link,
html[data-theme="dark"] .welcome-eyebrow,
html[data-theme="dark"] .keyboard-hint,
html[data-theme="dark"] .preview-status,
html[data-theme="dark"] .no-script,
html[data-theme="dark"] .dialog-close,
html[data-theme="dark"] .dialog-eyebrow,
html[data-theme="dark"] .login-form label,
html[data-theme="dark"] .login-note { color: #b7beb3; }
html[data-theme="dark"] .page-label span { color: #9da794; }
html[data-theme="dark"] .home-link:hover { color: #efeee6; }
html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .copy-message:hover,
html[data-theme="dark"] .continue-button:hover { background: #2c372d; }
html[data-theme="dark"] .message-scroll { scrollbar-color: #5c6853 transparent; }
html[data-theme="dark"] .suggestions button { color: #d6ddcf; border-color: #4b5744; }
html[data-theme="dark"] .suggestions button:hover { border-color: #819171; background: #273227; }
html[data-theme="dark"] .suggestions button [aria-hidden] { color: #b7beb3; }
html[data-theme="dark"] .message-avatar { border-color: #69745c; }
html[data-theme="dark"] .message--user .message-content { background: #2a362c; }
html[data-theme="dark"] .message-role,
html[data-theme="dark"] .copy-message,
html[data-theme="dark"] .copy-feedback,
html[data-theme="dark"] .continue-button { color: #b7beb3; }
html[data-theme="dark"] .message-text,
html[data-theme="dark"] .message--user .message-text { color: #efeee6; }
html[data-theme="dark"] .composer { border-color: #4a5542; background: #202820; box-shadow: 0 5px 26px #0002; }
html[data-theme="dark"] .composer:focus-within { border-color: #a9b596; }
html[data-theme="dark"] .composer textarea,
html[data-theme="dark"] .login-form input { color: #efeee6; }
html[data-theme="dark"] .composer textarea::placeholder,
html[data-theme="dark"] .login-form input::placeholder { color: #a8b19e; }
html[data-theme="dark"] .send-button:hover:not(:disabled),
html[data-theme="dark"] .login-submit:hover { color: #151918; background: #d3d8c8; }
html[data-theme="dark"] .send-button:disabled { color: #a6afa0; background: #414b3c; }
html[data-theme="dark"] .login-dialog { border-color: #535f49; box-shadow: 0 20px 100px #0008; }
html[data-theme="dark"] .login-dialog::backdrop { background: #060b08b3; }
html[data-theme="dark"] .login-form input { border-color: #5b6850; background: #202820; }
html[data-theme="dark"] .login-result { color: #d6ddcf; border-color: #59684b; background: #263222; }
.page-label .page-label-section { margin: 0; }
@media (max-width: 480px) {
  .page-label > span { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar .language-picker select { width: 105px; }
}
@media (max-width: 359px) {
  .topbar { padding-inline: 10px; }
  .topbar-left { gap: 2px; }
  .page-label { font-size: 8px; letter-spacing: .06em; }
  .topbar-actions { gap: 5px; }
  .topbar .language-picker select { width: 102px; }
}

.reading-link{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:13px 12px;margin:0 0 15px;border-top:1px solid var(--line);font-size:11px;line-height:1.6;color:inherit;overflow-wrap:anywhere}
.reading-link:hover{color:var(--gold)}
.article-context{display:flex;align-items:center;gap:16px;margin:0 4px 12px;padding:10px 13px;border:1px solid var(--line);border-inline-start:2px solid var(--gold);background:color-mix(in srgb,var(--gold) 6%,transparent)}
.article-context>div{min-width:0;flex:1}
.article-context p{font-size:9px;color:var(--muted);margin:0 0 5px}
.article-context a{display:block;font-size:12px;line-height:1.6;color:var(--ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.article-context a:hover{color:var(--gold)}
.article-context button{flex:0 0 30px;width:30px;height:30px;padding:0;border:0;background:none;color:var(--muted);font-size:20px}
@media(max-width:760px){.article-context{margin-inline:0;margin-bottom:9px;padding:8px 10px;gap:8px}.article-context a{font-size:11px}.article-context p{font-size:8px;margin-bottom:4px}}
