:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --surface: #fbfaf6;
  --surface-deep: #eeebe1;
  --ink: #252a25;
  --muted: #676c64;
  --accent: #435b48;
  --accent-dark: #304437;
  --accent-pale: #e7ece5;
  --line: #cbc9bf;
  --line-soft: #dedbd1;
  --warm: #866f4d;
  --serif: Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--paper); scroll-behavior: smooth; }
body { min-height: 100vh; min-height: 100dvh; margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.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: 10px; left: 10px; transform: translateY(-150%); padding: 10px 14px; border-radius: 4px; background: var(--ink); color: white; font-size: 13px; }
.skip-link:focus { transform: translateY(0); }

.site-header { width: 100%; min-height: 82px; padding: 18px clamp(20px, 4vw, 52px); display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line-soft); }
.wordmark { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: block; flex: 0 0 auto; }
.brand-lockup { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-family: var(--serif); font-size: 23px; line-height: 1; letter-spacing: -.3px; }
.brand-subtitle { color: var(--muted); font-size: 9px; letter-spacing: .04em; }
.preview-badge { padding: 5px 9px; border: 1px solid #c0c6bc; border-radius: 999px; color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: clamp(12px, 2.5vw, 24px); }
.quiet-button { min-height: 34px; padding: 5px 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: #4d5d50; font-size: 11px; }
.quiet-button:hover { border-color: #899989; color: var(--accent-dark); }
.quiet-button:focus-visible, .icon-button:focus-visible, summary:focus-visible, .send-button:focus-visible, .primary-button:focus-visible, .auth-cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

main { width: min(100% - 40px, 790px); margin: 0 auto; }
.login-view { min-height: calc(100vh - 83px); display: grid; grid-template-columns: minmax(0, 1fr) 250px; align-content: center; gap: clamp(34px, 7vw, 68px); padding: 56px 0 84px; }
.login-card { padding: clamp(28px, 6vw, 54px); border: 1px solid var(--line); border-radius: 3px 3px 22px 3px; background: var(--surface); box-shadow: 0 20px 60px rgba(49, 55, 46, .05); }
.eyebrow { margin: 0 0 18px; color: #657362; font-size: 9px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; }
h1 { margin: 0; font-size: clamp(42px, 7vw, 64px); line-height: 1.03; letter-spacing: -.035em; text-wrap: balance; }
.login-card h1 { font-size: clamp(38px, 5.5vw, 52px); }
.lede { margin: 20px 0 30px; color: var(--muted); font-family: var(--serif); font-size: 17px; line-height: 1.65; }
label { display: block; margin: 18px 0 7px; color: #4e574e; font-size: 11px; }
input { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid #b9bdb5; border-radius: 6px; background: #fffefa; color: var(--ink); }
input:focus, textarea:focus { outline: 2px solid #7f9180; outline-offset: 2px; }
.primary-button { width: 100%; min-height: 46px; margin-top: 23px; padding: 12px 18px; border: 0; border-radius: 6px; background: var(--accent); color: white; }
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.primary-button:disabled { opacity: .55; }
.form-message { min-height: 20px; margin: 15px 0 0; color: #755f3f; font-size: 11px; line-height: 1.6; }

.about-panel { color: var(--muted); font-size: 11px; line-height: 1.7; }
.about-panel summary { width: fit-content; cursor: pointer; color: #4a594c; font-weight: 600; list-style: none; }
.about-panel summary::-webkit-details-marker { display: none; }
.about-panel summary::after { content: "+"; display: inline-block; margin-left: 8px; color: var(--warm); font-size: 15px; font-weight: 400; transition: transform .15s ease; }
.about-panel[open] summary::after { transform: rotate(45deg); }
.about-content { margin-top: 14px; padding: 16px 0 0 18px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.about-content p { margin: 0; }
.about-content p + p { margin-top: 12px; }
.login-about { align-self: center; }

.chat-view { padding: clamp(52px, 8vw, 78px) 0 70px; }
.welcome { text-align: center; padding: 8px 0 46px; }
.welcome .lede { max-width: 630px; margin-left: auto; margin-right: auto; }
.conversation { display: flex; flex-direction: column; gap: 30px; }
.message { max-width: 100%; }
.message-user { width: fit-content; max-width: 84%; align-self: flex-end; }
.message-label { margin: 0 0 8px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--serif); font-size: 17px; line-height: 1.78; }
.message-content p { margin: 0; }
.message-content p + p, .message-content p + ul, .message-content p + ol,
.message-content ul + p, .message-content ol + p, .message-content h3 + p { margin-top: 16px; }
.message-content h3 { margin: 22px 0 8px; font-family: var(--sans); font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.message-content h3:first-child { margin-top: 0; }
.message-content ul, .message-content ol { margin: 12px 0 0; padding-left: 24px; }
.message-content li { padding-left: 4px; }
.message-content li + li { margin-top: 7px; }
.message-content strong { font-weight: 700; }
.message-content em { font-style: italic; }
.message-content code { padding: 1px 4px; border-radius: 3px; background: var(--surface-deep); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84em; }
.message-user .message-content { padding: 13px 17px; border: 1px solid #d4dbd2; border-radius: 14px 14px 3px 14px; background: var(--accent-pale); font-family: var(--sans); font-size: 14px; line-height: 1.6; }
.message-note .message-content, .message-error .message-content { padding: 13px 16px; border: 1px solid #d9d2c3; border-radius: 6px; background: #eee9dd; color: #6d5d43; font-family: var(--sans); font-size: 12px; line-height: 1.6; }
.composer-section { position: sticky; z-index: 2; bottom: 0; margin-top: 40px; padding: 22px 0 4px; background: linear-gradient(to bottom, rgba(244, 241, 233, 0), var(--paper) 19px); }
.composer { padding: 16px 14px 10px 18px; border: 1px solid #babfb7; border-radius: 12px; background: var(--surface); box-shadow: 0 6px 22px rgba(44, 50, 42, .07); transition: border-color .18s ease, box-shadow .18s ease; }
.composer:focus-within { border-color: #829281; box-shadow: 0 0 0 3px rgba(105, 129, 108, .13), 0 10px 28px rgba(44, 50, 42, .08); }
textarea { display: block; width: 100%; min-height: 54px; max-height: 190px; resize: none; overflow-y: hidden; overscroll-behavior: contain; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font-size: 15px; line-height: 1.55; }
textarea::placeholder { color: #858981; }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 9px; }
.composer-hint { color: var(--muted); font-size: 10px; }
.pending-queue-note:not(:empty) { display: block; margin-top: 4px; }
.pending-dots { display: inline-flex; align-items: center; gap: 3px; margin-left: 5px; vertical-align: middle; }
.pending-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .25; animation: pending-pulse 1.2s ease-in-out infinite; }
.pending-dot:nth-child(2) { animation-delay: .16s; }
.pending-dot:nth-child(3) { animation-delay: .32s; }
.pending-elapsed { margin-left: 7px; color: #7b827b; font-variant-numeric: tabular-nums; }
@keyframes pending-pulse { 0%, 65%, 100% { opacity: .22; } 32% { opacity: .8; } }
.send-button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 7px; background: var(--accent); color: white; }
.send-button:hover:not(:disabled) { background: var(--accent-dark); }
.send-button:disabled { background: #d7dbd4; color: #929990; }
.send-button svg { width: 19px; height: 19px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.quota-hint { margin: 9px 7px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.quota-hint a { color: var(--accent); text-underline-offset: 2px; }
.action-notice { color: #596359; font-size: 12px; line-height: 1.55; }
.action-notice a { color: var(--accent-dark); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.action-notice strong { color: #3f4d42; font-weight: 650; }
.chat-action-notice { margin: 10px 7px 0; }
.action-message { min-height: 0; margin: 7px 7px 0; color: #755f3f; font-size: 11px; line-height: 1.5; }
.chat-about { margin: 11px 7px 0; }
.chat-about .about-content { max-width: 620px; }
.service-details { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 10px; }
.service-details dt { color: #465449; }
.service-details dd { margin: 0; }

.sources-drawer { width: min(100%, 470px); max-width: 100%; height: 100vh; height: 100dvh; max-height: 100%; margin: 0 0 0 auto; padding: 29px clamp(22px, 5vw, 34px) 44px; border: 0; border-left: 1px solid var(--line); background: var(--paper); color: var(--ink); overflow-y: auto; }
.sources-drawer::backdrop { background: rgba(36, 43, 37, .28); backdrop-filter: blur(3px); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.drawer-header .eyebrow { margin-bottom: 8px; }
.drawer-header h2 { margin: 0; font-size: 33px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; }
.icon-button:hover { background: var(--accent-pale); }
.drawer-intro { margin: 17px 0 26px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.source-card { margin-bottom: 14px; padding: 20px; border: 1px solid var(--line); border-radius: 3px 3px 13px 3px; background: var(--surface); }
.source-card h3 { margin: 0 0 8px; font-size: 21px; }
.source-meta, .source-attribution, .source-reference-note, .source-numbering { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.source-reference-note { margin-bottom: 7px; color: #465848; }
.source-numbering { margin-bottom: 11px; }
.source-text { margin: 17px 0 14px; padding-top: 13px; border-top: 1px solid var(--line-soft); font-family: var(--serif); font-size: 20px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.source-text[dir="rtl"] { font-size: 23px; line-height: 2; }
.source-editorial { margin: 0 0 13px; padding: 10px 12px; border-radius: 5px; background: var(--surface-deep); color: var(--muted); font-size: 10px; line-height: 1.65; }
.source-editorial p { margin: 0; }
.source-editorial p + p { margin-top: 5px; }
.source-link { display: inline-block; min-height: 28px; margin-top: 10px; color: var(--accent); font-size: 10px; text-decoration: none; border-bottom: 1px solid #a7b3a5; }
.source-notes p { margin: 13px 0; padding-left: 12px; border-left: 2px solid #b8c1b3; color: var(--muted); font-size: 10px; line-height: 1.7; }
.auth-dialog { width: min(calc(100% - 32px), 470px); max-width: 100%; padding: 29px clamp(23px, 5vw, 36px) 26px; border: 1px solid var(--line); border-radius: 4px 4px 18px 4px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgba(31, 38, 32, .18); }
.auth-dialog::backdrop { background: rgba(36, 43, 37, .32); backdrop-filter: blur(3px); }
.auth-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.auth-dialog-header .eyebrow { margin-bottom: 8px; }
.auth-dialog h2 { margin: 0; font-size: 31px; }
.auth-intro { margin: 18px 0 21px; color: var(--muted); font-family: var(--serif); font-size: 15px; line-height: 1.6; }
.auth-form .primary-button { margin-top: 20px; }
.code-instruction { margin: 0 0 17px; color: var(--muted); font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }
.auth-token { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 23px; font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.auth-code-help { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.auth-action-notice { margin: 14px 0 -8px; }
.auth-cancel { display: block; min-height: 40px; margin: 4px auto 0; padding: 8px 12px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.noscript-note { padding: 20px; text-align: center; color: var(--muted); }

@media (max-width: 700px) {
  .site-header { min-height: 72px; padding: 14px 18px; gap: 10px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-name { font-size: 20px; }
  .brand-subtitle { display: none; }
  .preview-badge { display: none; }
  .header-actions { gap: 11px; }
  .quiet-button { min-height: 44px; font-size: 10px; }
  main { width: calc(100% - 24px); }
  .login-view { min-height: calc(100vh - 73px); grid-template-columns: 1fr; gap: 26px; padding: 34px 0 54px; }
  .login-card { padding: 28px 23px 30px; }
  .login-about { margin: 0 8px; }
  .chat-view { padding: 30px 0 max(44px, env(safe-area-inset-bottom)); }
  .welcome { padding-bottom: 34px; }
  h1 { font-size: clamp(39px, 11.5vw, 50px); }
  .lede { font-size: 16px; }
  .conversation { gap: 26px; }
  .message { scroll-margin-block: 18px; }
  .message-content { font-size: 17px; line-height: 1.72; }
  .message-content ul, .message-content ol { padding-left: 22px; }
  .message-user { max-width: 96%; }
  .message-user .message-content { padding: 12px 14px; font-size: 15px; }
  .composer-section { position: static; margin: 30px 0 0; padding: 0; background: none; }
  .composer { padding: 14px 12px 10px 15px; border-radius: 17px; box-shadow: 0 8px 28px rgba(44, 50, 42, .09); }
  textarea { min-height: 96px; max-height: min(36dvh, 280px); padding: 2px 2px 6px; font-size: 17px; line-height: 1.45; touch-action: pan-y; }
  .composer-bottom { gap: 10px; padding-top: 7px; }
  .composer-hint { max-width: calc(100% - 58px); font-size: 11px; line-height: 1.45; }
  .send-button { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 12px; }
  .send-button svg { width: 21px; height: 21px; }
  .chat-action-notice, .quota-hint, .chat-about { margin-left: 4px; margin-right: 4px; }
  .chat-action-notice { font-size: 11px; line-height: 1.55; }
  .quota-hint { margin-top: 11px; font-size: 11px; }
  .chat-about { margin-top: 13px; }
  .chat-about summary { min-height: 38px; display: inline-flex; align-items: center; }
  .chat-about .about-content { max-width: none; margin-top: 7px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(251, 250, 246, .72); }
  .service-details { grid-template-columns: 1fr; }
  .service-details dd { margin-bottom: 5px; }
  .sources-drawer { padding-top: 24px; }
}

@media (max-width: 470px) {
  .brand-lockup { display: none; }
  .header-actions { width: calc(100% - 42px); justify-content: flex-end; }
  .quiet-button { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .pending-dot { animation: none !important; opacity: .55; }
}

.launch-footer { padding: 1.5rem 1rem 2rem; text-align: center; font-size: .8rem; color: #596359; }
.launch-footer a { color: inherit; text-underline-offset: .2em; }
