:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f7f7;
  --line: #e5e5e5;
  --text: #202020;
  --muted: #707070;
  --green: #202020;
  --green-deep: #090909;
  --green-soft: #eeeeee;
  --rose: #c27884;
  --shadow: 0 24px 70px rgba(56,56,56,0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; min-height: 0; background: var(--bg); color: var(--text); }
body { overflow: hidden; }
button, textarea { font: inherit; }
button { color: inherit; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; background: var(--surface); }
.history-panel { min-width: 0; display: flex; flex-direction: column; padding: 22px 16px 16px; border-right: 1px solid var(--line); background: #f9f9f9; }
.history-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 8px 18px; }
.eyebrow { display: block; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.history-head h1 { margin: 5px 0 0; font-family: inherit; font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
.new-chat { width: 100%; height: 43px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--green); border-radius: 12px; background: var(--green); color: white; font-size: 14px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px rgba(89,89,89,.16); }
.new-chat:hover { background: var(--green-deep); }
.new-chat svg, .icon-button svg, .conversation-button svg, .send-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.history-label { margin: 25px 9px 9px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; }
.conversation-row { position: relative; display: flex; align-items: center; margin-bottom: 3px; border-radius: 10px; }
.conversation-row:hover, .conversation-row.is-active { background: var(--green-soft); }

.conversation-button { width: 100%; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 11px 34px 11px 11px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.conversation-button svg { flex: 0 0 auto; width: 16px; color: var(--muted); }
.conversation-button span { overflow: hidden; color: #4d4d4d; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-delete { position: absolute; right: 7px; width: 25px; height: 25px; border: 0; border-radius: 7px; background: transparent; color: transparent; cursor: pointer; }
.conversation-row:hover .conversation-delete { color: var(--muted); }
.conversation-delete:hover { background: rgba(149,149,149,.15); color: #a34859 !important; }
.history-foot { display: flex; align-items: center; gap: 7px; padding: 14px 8px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.45; }
.storage-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #929292; box-shadow: 0 0 0 4px rgba(126,126,126,.12); }

.chat-panel { min-width: 0; min-height: 0; overflow: hidden; position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--surface); }
.chat-header { height: 73px; display: flex; align-items: center; gap: 13px; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.chat-title-wrap { min-width: 0; display: flex; align-items: center; gap: 12px; }
.agent-mark { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; color: var(--green); }
.agent-mark svg { width: 29px; height: 29px; fill: currentColor; stroke: none; }
.welcome-orbit svg.sparkle-logo { fill: currentColor; stroke: none; }
.chat-header h2 { margin: 0; overflow: hidden; font-family: inherit; font-size: 18px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chat-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.model-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid #dcdcdc; border-radius: 999px; background: #f9f9f9; color: var(--green-deep); font-size: 12px; font-weight: 750; }
.model-badge span { width: 7px; height: 7px; border-radius: 50%; background: #8e8e8e; box-shadow: 0 0 0 4px rgba(122,122,122,.12); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.icon-button:hover { background: var(--green-soft); }
.history-toggle, .mobile-close { display: none; }

.messages { min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 32px max(24px, calc((100% - 880px) / 2)); scrollbar-gutter: stable; overflow-anchor: none; }
.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 0 60px; text-align: center; }
.welcome-orbit { position: relative; width: 82px; height: 82px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 50%; background: linear-gradient(145deg, #f6f6f6, #fff); box-shadow: var(--shadow); color: var(--green); }
.welcome-orbit svg { width: 35px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.orbit { position: absolute; border: 1px solid rgba(89,89,89,.18); border-radius: 50%; }
.orbit-one { inset: -7px; border-style: dashed; }
.orbit-two { inset: 7px; }
.welcome h2 { margin: 14px 0 16px; font-family: inherit; font-size: clamp(28px, 4vw, 42px); font-weight: 500; line-height: 1.25; letter-spacing: -.035em; }
.welcome > p { max-width: 680px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.source-cloud { max-width: 700px; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin: 22px 0 28px; }
.source-cloud span { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.75); color: #646464; font-size: 10px; font-weight: 700; }
.suggestions { width: min(760px, 100%); display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 28px; }
.suggestions button { min-height: 80px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.78); color: #4d4d4d; font-size: 12px; line-height: 1.6; text-align: left; cursor: pointer; box-shadow: 0 8px 25px rgba(59,59,59,.04); }
.suggestions button:hover { transform: translateY(-2px); border-color: #cacaca; box-shadow: 0 14px 28px rgba(59,59,59,.08); }

.message { display: flex; gap: 12px; margin: 0 0 25px; animation: messageIn .18s ease-out; }
@keyframes messageIn { from { opacity: 0; transform: translateY(6px); } }
.message.user { justify-content: flex-end; }
.message-avatar { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 900; }
.message-body { min-width: 0; max-width: min(760px, 87%); }
.message.user .message-body { padding: 11px 15px; border-radius: 16px 16px 4px 16px; background: var(--green); color: white; box-shadow: 0 8px 22px rgba(89,89,89,.14); }
.message.assistant .message-body { padding-top: 4px; }
.message-text { font-size: 14px; line-height: 1.72; overflow-wrap: anywhere; }
.message-text a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.message-text strong { color: var(--green-deep); }
.message.user .message-text strong, .message.user .message-text a { color: white; }
.message-meta { margin-top: 8px; color: var(--muted); font-size: 10px; }
.research-trace { margin-top: 14px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.research-trace summary { cursor: pointer; color: #5c5c5c; font-size: 11px; font-weight: 750; }
.trace-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.trace-chip { padding: 5px 7px; border-radius: 8px; background: white; color: var(--muted); font-size: 10px; }
.trace-chip.failed { color: #a34859; background: #fff1f3; }
.source-cards { display: grid; gap: 7px; margin-top: 10px; }
.source-card { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; gap: 9px; align-items: start; padding: 9px; border: 1px solid var(--line); border-radius: 10px; background: white; color: inherit; text-decoration: none; }
.source-card:hover { border-color: #c9c9c9; }
.source-number { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: var(--green-soft); color: var(--green-deep); font-size: 10px; font-weight: 800; }
.source-card strong { display: block; overflow: hidden; font-size: 11px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.source-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.source-arrow { color: var(--green); font-size: 15px; }
.typing { display: flex; align-items: center; gap: 5px; padding: 9px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: #9a9a9a; animation: typing 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .14s; }.typing span:nth-child(3) { animation-delay: .28s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.error-message { margin: 12px 0; padding: 11px 13px; border: 1px solid #efccd2; border-radius: 10px; background: #fff2f4; color: #9d4151; font-size: 12px; }

.composer-wrap { padding: 12px max(24px, calc((100% - 860px) / 2)) 14px; background: linear-gradient(transparent, var(--surface) 25%); }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 9px 9px 9px 15px; border: 1px solid #d7d7d7; border-radius: 17px; background: white; box-shadow: 0 14px 38px rgba(55,55,55,.11); }
.composer:focus-within { border-color: #9a9a9a; box-shadow: 0 15px 40px rgba(55,55,55,.14), 0 0 0 3px rgba(115,115,115,.09); }
.composer textarea { flex: 1; min-height: 28px; max-height: 150px; resize: none; padding: 5px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; line-height: 1.45; }
.composer textarea::placeholder { color: #9d9d9d; }
.send-button { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 12px; background: var(--green); color: white; cursor: pointer; }
.send-button:hover { background: var(--green-deep); }
.send-button:disabled { cursor: not-allowed; opacity: .45; }
.composer-note { margin: 7px 0 0; color: #9d9d9d; font-size: 9px; text-align: center; }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .history-panel { position: fixed; inset: 0 auto 0 0; z-index: 20; width: min(320px, 88vw); transform: translateX(-105%); box-shadow: 20px 0 50px rgba(41,41,41,.2); transition: transform .2s ease; }
  .history-panel.is-open { transform: translateX(0); }
  .history-scrim { position: fixed; inset: 0; z-index: 19; display: block; background: rgba(28,28,28,.28); }
  .history-toggle, .mobile-close { display: grid; }
  .chat-header { height: 66px; padding: 0 13px; }
  .chat-header p { display: none; }
  .messages { padding: 20px 15px; }
  .composer-wrap { padding: 10px 12px 11px; }
  .suggestions { grid-template-columns: 1fr; }
  .welcome { justify-content: flex-start; padding-top: 35px; }
  .source-cloud { margin-bottom: 20px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #171717; --surface: #212121; --surface-soft: #292929; --line: #3a3a3a; --text: #ececec; --muted: #a3a3a3; --green: #ececec; --green-deep: #ffffff; --green-soft: #333333; --shadow: 0 24px 70px rgba(0,0,0,.3); }
  :root:not([data-theme="light"]) .history-panel, :root:not([data-theme="light"]) .chat-header { background: rgba(25,25,25,.94); }
  :root:not([data-theme="light"]) .composer, :root:not([data-theme="light"]) .source-card, :root:not([data-theme="light"]) .trace-chip { background: #262626; }
  :root:not([data-theme="light"]) .model-badge { background: #2b2b2b; border-color: #444444; }
  :root:not([data-theme="light"]) .conversation-button span { color: var(--text); }
}

:root[data-theme="dark"] { --bg: #171717; --surface: #212121; --surface-soft: #292929; --line: #3a3a3a; --text: #ececec; --muted: #a3a3a3; --green: #ececec; --green-deep: #ffffff; --green-soft: #333333; --shadow: 0 24px 70px rgba(0,0,0,.3); }
:root[data-theme="dark"] .history-panel, :root[data-theme="dark"] .chat-header { background: rgba(25,25,25,.94); }
:root[data-theme="dark"] .composer, :root[data-theme="dark"] .source-card, :root[data-theme="dark"] .trace-chip { background: #262626; }
:root[data-theme="dark"] .model-badge { background: #2b2b2b; border-color: #444444; }
:root[data-theme="dark"] .conversation-button span { color: var(--text); }

[hidden] { display: none !important; }
button, select, input { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--green); 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; }
.history-panel { min-height: 0; }
.chat-title-wrap > div:last-child { min-width: 0; }
.message.assistant .message-body { max-width: 100%; width: 100%; }
.message-text { font-size: 15px; line-height: 1.85; }
.message-text > :first-child { margin-top: 0; }
.message-text > :last-child { margin-bottom: 0; }
.message-text p { margin: 0 0 1em; }
.message-text h1, .message-text h2, .message-text h3 { margin: 1.5em 0 .65em; line-height: 1.4; font-size: 1.15em; color: var(--text); }
.message-text h1 { font-size: 1.4em; }
.message-text h4, .message-text h5, .message-text h6 { font-size: 1em; }
.message-text ul, .message-text ol { padding-left: 1.5em; margin: .7em 0 1.2em; }
.message-text li { padding-left: .15em; margin: .45em 0; }
.message-text li p { margin: .35em 0; }
.message-text blockquote { margin: 1em 0; padding: .4em 1em; border-left: 3px solid var(--green); background: var(--surface-soft); color: var(--muted); }
.message-text pre { padding: 16px; border-radius: 10px; overflow-x: auto; background: var(--surface-soft); border: 1px solid var(--line); font-size: 13px; line-height: 1.6; }
.message-text code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--surface-soft); padding: .15em .3em; border-radius: 4px; }
.message-text pre code { padding: 0; }
.message-text hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.table-scroll { overflow-x: auto; max-width: 100%; margin: 1em 0; border: 1px solid var(--line); border-radius: 10px; }
.message-text table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 13px; }
.message-text th, .message-text td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.message-text th { background: var(--surface-soft); font-weight: 700; }
.message-text tr:last-child td { border-bottom: 0; }
.citation { display: inline; vertical-align: baseline; padding: 2px 6px; margin: 0 2px; border: 1px solid var(--line); border-radius: 5px; color: var(--green-deep); background: var(--green-soft); font-size: 10px; font-weight: 650; line-height: 1.5; white-space: normal; }
.citation:hover { border-color: var(--green); }
.citation-missing { color: var(--muted); font-size: 11px; }
.composer-wrap { position: relative; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: var(--surface); }
.search-toolbar { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; font-size: 12px; }
.mode-select select, .paper-sort { color: var(--text); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.text-button { color: var(--muted); background: transparent; border: 0; padding: 6px 2px; font-size: 12px; }
.text-button:hover { color: var(--green); }
.toolbar-hint { margin-left: auto; font-size: 10px; color: var(--muted); }
.search-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border: 1px solid var(--line); background: var(--surface-soft); padding: 12px; border-radius: 10px; margin-bottom: 10px; font-size: 11px; }
.search-filters label { display: flex; gap: 6px; align-items: center; }
.search-filters input[type=number] { width: 72px; min-width: 0; color: var(--text); background: var(--surface); padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.search-filters small { flex-basis: 100%; color: var(--muted); line-height: 1.5; }
.check-label input { accent-color: var(--green); }
.stop-button { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--green-soft); color: var(--green); }
.jump-latest { position: absolute; top: -46px; left: 50%; transform: translateX(-50%); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; box-shadow: 0 3px 16px #0001; font-size: 12px; z-index: 5; white-space: nowrap; }
.research-progress { display: flex; gap: 9px; align-items: center; color: var(--muted); padding: 6px 0 18px; font-size: 12px; }
.progress-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.streaming .message-text { min-height: 6px; }
.generation-tail { display: grid; gap: 10px; width: min(540px, 92%); margin: 16px 0 22px; }
.generation-tail span { height: 9px; border-radius: 999px; background: linear-gradient(100deg, var(--surface-soft) 20%, var(--green-soft) 44%, var(--surface-soft) 68%); background-size: 240% 100%; animation: generationShimmer 1.9s ease-in-out infinite; }
.generation-tail span:nth-child(1) { width: 94%; }
.generation-tail span:nth-child(2) { width: 78%; animation-delay: .12s; }
.generation-tail span:nth-child(3) { width: 48%; animation-delay: .24s; }
@keyframes generationShimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
.answer-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
.answer-context { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 15px; font-size: 10px; color: var(--muted); }
.answer-context span { border: 1px solid var(--line); padding: 3px 7px; border-radius: 5px; }
.papers-panel { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.papers-panel > summary { font-size: 13px; font-weight: 750; cursor: pointer; }
.paper-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; }
.paper-sort { font-size: 11px; }
.paper-list { display: grid; gap: 10px; }
.paper-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--surface); }
.paper-topline { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; margin-bottom: 7px; }
.paper-tag { background: var(--green-soft); color: var(--green-deep); padding: 2px 6px; border-radius: 4px; }
.paper-title { font-size: 14px; font-weight: 650; line-height: 1.5; text-align: left; border: 0; background: transparent; padding: 0; color: var(--text); }
.paper-title:hover { color: var(--green); }
.paper-authors { color: var(--muted); font-size: 11px; margin: 6px 0; line-height: 1.6; }
.paper-abstract { color: var(--muted); font-size: 12px; line-height: 1.75; margin: 8px 0; }
.paper-abstract.preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.paper-actions { display: flex; gap: 16px; align-items: center; margin-top: 10px; }
.paper-actions a { font-size: 11px; color: var(--green); text-decoration: none; }
.follow-ups { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 17px; }
.follow-ups button { text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--green-deep); background: var(--surface-soft); font-size: 11px; }
.citation-preview { position: fixed; z-index: 50; width: min(380px, calc(100vw - 24px)); max-height: min(390px, 65dvh); overflow-y: auto; border: 1px solid var(--line); border-radius: 13px; padding: 19px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); pointer-events: auto; }
.citation-preview strong { display: block; font-size: 13px; line-height: 1.5; }
.citation-preview .paper-abstract { margin-bottom: 0; }
.citation-preview:not(.is-expanded) { width: auto; padding: 4px; border-radius: 8px; max-height: none; }
.citation-more { border: 0; background: var(--surface); color: var(--green-deep); border-radius: 6px; padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.citation-more:hover { background: var(--green-soft); }
.preview-heading { display: flex; align-items: flex-start; gap: 8px; }
.preview-heading .paper-topline { flex: 1; }
.preview-close { background: transparent; border: 0; color: var(--muted); font-size: 20px; padding: 0 2px; line-height: 1; }
.paper-dialog { position: fixed; width: min(700px, calc(100vw - 24px)); max-height: 85dvh; overflow-y: auto; padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.paper-dialog::backdrop { background: #17171766; backdrop-filter: blur(3px); }
.dialog-close { position: absolute; right: 10px; top: 8px; font-size: 25px; }
.paper-dialog h2 { font-family: Georgia, serif; font-size: 23px; line-height: 1.45; margin: 16px 0; }
.paper-dialog h3 { font-size: 13px; margin: 26px 0 8px; }
.paper-dialog .paper-abstract { color: var(--text); font-size: 14px; }
.paper-doi { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 10px; font-size: 12px; }
.stream-note { margin-top: 12px; font-size: 11px; color: var(--muted); }
.error-message button { margin-left: 12px; }
@media (min-width: 761px) and (max-width: 1000px) { .app-shell { grid-template-columns: 210px minmax(0, 1fr); } .toolbar-hint { display: none; } }
@media (max-width: 600px) {
  .messages { padding: 20px 14px; }
  .message { gap: 8px; }
  .message-avatar { display: none; }
  .message-text { font-size: 14px; }
  .composer textarea { font-size: 16px; }
  .composer-wrap { padding-left: 14px; padding-right: 14px; }
  .toolbar-hint { display: none; }
  .chat-header { padding: 0 12px; height: 64px; }
  .model-badge { display: none; }
  .paper-dialog { padding: 25px 20px; }
  .paper-card { padding: 13px; }
  .welcome { padding-top: 16px; padding-bottom: 24px; }
  .welcome h2 { font-size: 28px; }
  .conversation-delete { color: var(--muted); }
}
@media (max-height: 600px) { .welcome-orbit { display: none; } .welcome { justify-content: flex-start; } .composer-note { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }


/* File composer: keep controls separate from the writing area. */
.composer { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px; }
.composer-main { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.composer textarea { min-width: 0; padding: 6px 4px; }
.composer-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.attach-button, .pdf-mode-button { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 7px; padding: 6px 8px; background: transparent; color: var(--muted); font-size: 12px; line-height: 1.4; }
.attach-button svg, .pdf-mode-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.attach-button:hover, .pdf-mode-button:hover { background: var(--green-soft); color: var(--green-deep); }
.pdf-mode-button[aria-pressed=true] { color: var(--green-deep); background: var(--green-soft); }
.model-tier { display: flex; align-items: center; gap: 3px; padding: 3px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 9px; }
.model-tier button { padding: 4px 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; }
.model-tier button[aria-pressed=true] { background: var(--surface); color: var(--green-deep); box-shadow: 0 1px 4px #0001; }
button:disabled { cursor: not-allowed; }
.attach-button:disabled, .pdf-mode-button:disabled, .model-tier button:disabled { opacity: .5; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 120px; overflow-y: auto; }
.attachment-chip { display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--text); font-size: 11px; text-align: left; }
.attachment-chip > span { min-width: 0; }
.attachment-chip strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; font-weight: 550; }
.attachment-chip small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.attachment-chip button { flex: 0 0 auto; width: 24px; height: 24px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 17px; }
.attachment-chip button:hover { background: var(--green-soft); }
.attachment-hint { margin: 0 4px 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.message-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.message-attachments span { max-width: 100%; overflow-wrap: anywhere; padding: 5px 8px; border: 1px solid #ffffff50; border-radius: 6px; font-size: 11px; }
.attachment-chip .attachment-image { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.message-image { display: flex; flex-direction: column; gap: 7px; }
.message-image .attachment-image { display: block; max-width: min(340px,100%); max-height: 260px; object-fit: contain; border-radius: 6px; }
.attachment-image[hidden] { display: none; }
@media (max-width: 760px) {
  .composer { padding: 10px; }
  .attachment-chip strong { max-width: 190px; }
  .search-toolbar { gap: 14px; }
}


/* Neutral workspace surfaces and accessible monochrome controls. */
.history-panel {background:var(--surface-soft)}
.welcome-orbit {background:var(--surface-soft);box-shadow:0 4px 20px rgba(0,0,0,.04)}
.suggestions button {box-shadow:none}
.message.user .message-body {box-shadow:none}
.chat-header {background:var(--surface)}
.composer {box-shadow:0 4px 24px rgba(0,0,0,.045)}
html[data-theme="dark"] .send-button {color:#171717}
html[data-theme="dark"] .message.user .message-text :is(a,strong) {color:inherit}
@media(prefers-color-scheme:dark) {
 html:not([data-theme="light"]) .send-button {color:#171717}
 html:not([data-theme="light"]) .message.user .message-text :is(a,strong) {color:inherit}
}

/* Quiet history action and soft blue user messages. */
:root {
 --research-action-bg:#ededed;--research-action-hover:#e2e2e2;--research-action-text:#303030;
 --user-message-bg:#e8f3ff;--user-message-text:#18344f;
}
.new-chat {
 background:var(--research-action-bg);color:var(--research-action-text);
 border-color:transparent;box-shadow:none;font-weight:600;
 transition:background-color .16s ease;
}
.new-chat:hover {background:var(--research-action-hover)}
.new-chat:focus-visible {outline:2px solid #909090;outline-offset:3px}
.message.user .message-body {background:var(--user-message-bg);color:var(--user-message-text);box-shadow:none}
.message.user .message-text :is(a,strong,code) {color:inherit}
:root[data-theme="dark"] {
 --research-action-bg:#303030;--research-action-hover:#3b3b3b;--research-action-text:#ececec;
 --user-message-bg:#253d53;--user-message-text:#e7f2ff;
}
@media(prefers-color-scheme:dark) {
 :root:not([data-theme="light"]) {
  --research-action-bg:#303030;--research-action-hover:#3b3b3b;--research-action-text:#ececec;
  --user-message-bg:#253d53;--user-message-text:#e7f2ff;
 }
}
