:root {
  color-scheme: light dark;
  --page: #fafbfd;
  --sidebar: #f0f2f6;
  --surface: #fdfdfe;
  --surface-hover: #e7ebf2;
  --text: #242832;
  --muted: #626b7b;
  --line: #dce1e9;
  --accent: #315bd6;
  --accent-hover: #2548b7;
  --accent-soft: #edf1fc;
  --error-bg: #fff0ed;
  --error-text: #9a352b;
  --error-border: #eab4ac;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
  line-height: 1.5;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; font-weight: 500; white-space: nowrap; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .55; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, p { margin-top: 0; }
::selection { background: var(--accent-soft); color: var(--text); }
.primary { color: #fdfdff; background: var(--accent); border-radius: 14px; padding: 13px 20px; font-weight: 600; }
.primary:hover { background: var(--accent-hover); }
.quiet { color: var(--muted); background: transparent; border-radius: 9px; padding: 8px 10px; font-size: 12px; }
.quiet:hover { color: var(--text); background: var(--surface-hover); }

.session-check { min-height: 100dvh; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 44px 24px; }
.login-panel { width: min(100%, 370px); }
.login-product { font-size: 17px; font-weight: 600; margin-bottom: 28px; }
.login-panel h1 { font-size: 30px; line-height: 1.2; font-weight: 620; letter-spacing: -.9px; margin-bottom: 12px; }
.login-intro { font-size: 15px; color: var(--muted); line-height: 1.6; margin-bottom: 32px; }
.field { margin-bottom: 19px; }
label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
input, textarea { color: var(--text); border: 1px solid var(--line); background: var(--surface); border-radius: 12px; }
input { width: 100%; min-width: 0; padding: 14px 15px; font-size: 16px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.login-submit { width: 100%; margin-top: 5px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 20px 0 0; }

/* Desktop navigation stays visible. The mobile navigation uses layers 1 and 2. */
.app-shell { height: 100dvh; min-height: 500px; display: grid; grid-template-columns: 248px minmax(0, 1fr); overflow: hidden; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); padding: 26px 17px 18px; border-right: 1px solid var(--line); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; margin-bottom: 29px; min-height: 28px; }
.product-name { font-size: 18px; font-weight: 600; letter-spacing: -.3px; }
.menu-close { display: none; color: var(--muted); background: transparent; border-radius: 9px; padding: 5px 10px; font-size: 25px; line-height: 1; }
.new-chat { width: 100%; display: flex; gap: 12px; align-items: center; padding: 13px 15px; color: var(--text); border: 1px solid var(--line); background: var(--surface); border-radius: 12px; text-align: left; font-size: 13px; }
.new-chat>span { font-size: 21px; font-weight: 400; line-height: 1; color: var(--muted); }
.new-chat:hover { background: var(--surface-hover); }
.chat-history { flex: 1; min-height: 70px; overflow-y: auto; margin: 20px -4px 16px; padding: 0 4px; }
.history-heading { display: flex; justify-content: space-between; align-items: center; padding-left: 10px; color: var(--muted); font-size: 11px; }
.history-heading .quiet { font-size: 19px; }
.history-empty { color: var(--muted); font-size: 12px; padding: 12px 10px; }
.conversation-link { display: block; width: 100%; text-align: left; color: var(--text); background: transparent; border-radius: 9px; padding: 11px 10px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.conversation-link:hover, .conversation-link[aria-current] { background: var(--surface-hover); }
.delete-chat { flex-shrink: 0; margin-left: auto; }
.delete-chat:not([hidden]) + .access-badge { display: none; }
.sources { min-height: 0; overflow-y: auto; padding: 0 5px; }
.sources summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; list-style: none; color: var(--muted); font-size: 12px; padding: 12px 7px; border-radius: 8px; }
.sources summary:hover { background: var(--surface-hover); color: var(--text); }
.sources summary::-webkit-details-marker { display: none; }
.sources summary>span { font-size: 18px; line-height: 1; }
.sources[open] summary>span { transform: rotate(180deg); }
.sources-panel { padding: 8px 7px 16px; }
.source-row { margin-bottom: 14px; }
.source-name { font-size: 12px; font-weight: 600; }
.source-detail { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.source-summary, .source-note { font-size: 11px; color: var(--muted); line-height: 1.65; margin: 13px 0; }
.source-note { padding-top: 12px; border-top: 1px solid var(--line); }
.source-warning { color: var(--error-text); }
.sources .quiet { margin-left: -7px; font-size: 11px; }
.account { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding: 18px 7px 0; border-top: 1px solid var(--line); }
.account>div { min-width: 0; }
.account-label { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.session-user { display: block; font-size: 13px; max-width: 125px; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-header { display: flex; align-items: center; gap: 14px; min-height: 76px; flex-shrink: 0; padding: 18px 32px; }
.conversation-title { font-size: 14px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.access-badge { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.menu-open { display: none; }
.conversation-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 30px 24px; scroll-padding: 24px; }
.conversation { max-width: 760px; margin: 0 auto; }
.empty-state { padding: clamp(36px, 10vh, 96px) 0 30px; max-width: 640px; margin: 0 auto; }
.empty-state h1 { font-size: clamp(30px, 3.3vw, 38px); line-height: 1.2; letter-spacing: -1.2px; font-weight: 600; text-align: center; margin-bottom: 14px; }
.empty-state>p { color: var(--muted); font-size: 15px; line-height: 1.7; text-align: center; margin-bottom: 34px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suggestions button { display: flex; flex-direction: column; justify-content: center; gap: 6px; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 15px; padding: 17px 19px; text-align: left; white-space: normal; }
.suggestions strong { font-size: 13px; font-weight: 550; }
.suggestions button>span { font-size: 12px; color: var(--muted); line-height: 1.5; }
.suggestions button:hover { border-color: var(--accent); background: var(--accent-soft); }
.message { margin: 17px 0 36px; }
.message.user { max-width: 82%; width: fit-content; margin-left: auto; padding: 13px 20px; background: var(--surface-hover); border-radius: 22px; }
.message-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.message.user .message-label { display: none; }
.message-content { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.85; }
.message.user .message-content { line-height: 1.6; }
.message.assistant .message-content { white-space: normal; }
.message-content p { margin: 0 0 14px; }
.message-content h3, .message-content h4, .message-content h5, .message-content h6 { font-size: 16px; line-height: 1.5; font-weight: 600; margin: 23px 0 9px; }
.message-content ul, .message-content ol { margin: 10px 0 16px; padding-left: 25px; }
.message-content li { margin: 5px 0; padding-left: 3px; }
.message-content strong { font-weight: 650; }
.message-content code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .86em; padding: 2px 5px; border-radius: 5px; background: var(--surface-hover); }
.message-content pre { margin: 14px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--sidebar); overflow-x: auto; white-space: pre; overflow-wrap: normal; line-height: 1.65; }
.message-content pre code { background: transparent; padding: 0; border-radius: 0; }
.message-content>:first-child { margin-top: 0; }
.message-content>:last-child { margin-bottom: 0; }
.answer-sources { margin-top: 18px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.answer-sources summary { cursor: pointer; width: fit-content; padding: 4px 0; font-size: 12px; }
.answer-sources summary:hover { color: var(--text); }
.answer-sources[open] summary { margin-bottom: 9px; }
.message-meta { margin-top: 15px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.thinking { display: flex; align-items: center; gap: 11px; padding: 0 0 20px; color: var(--muted); font-size: 13px; }
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots i { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.composer-area { width: min(820px, 100%); margin: 0 auto; padding: 8px 30px 14px; flex-shrink: 0; }
.composer { padding: 16px 17px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 25px; box-shadow: 0 4px 20px rgb(38 48 72 / .04); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; resize: vertical; border-radius: 0; width: 100%; min-height: 59px; max-height: 180px; padding: 3px; background: transparent; font-size: 16px; line-height: 1.6; }
.composer textarea:focus-visible { outline: 0; }
.composer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding-top: 6px; }
.composer-bottom>span { font-size: 10px; line-height: 1.5; color: var(--muted); }
.send-button { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 37px; height: 37px; border-radius: 50%; padding: 0; }
.send-arrow { font-size: 23px; line-height: 1; font-weight: 400; }
.footnote { text-align: center; font-size: 10px; line-height: 1.5; color: var(--muted); margin: 10px 0 0; }
.error { padding: 12px 14px; border: 1px solid var(--error-border); border-radius: 12px; background: var(--error-bg); color: var(--error-text); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; margin: 10px 0 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (prefers-color-scheme: dark) {
  :root { --page: #202228; --sidebar: #191b20; --surface: #292c34; --surface-hover: #333741; --text: #eff1f5; --muted: #b0b7c6; --line: #3b414c; --accent: #7c9eff; --accent-hover: #96b0ff; --accent-soft: #2b385a; --error-bg: #3a2527; --error-text: #ffb4a7; --error-border: #714042; }
  .primary { background: #315bd6; }
  .primary:hover { background: #3b66e3; }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .chat-header { padding-left: 24px; padding-right: 24px; }
  .conversation-scroll { padding-left: 24px; padding-right: 24px; }
  .composer-area { padding-left: 24px; padding-right: 24px; }
  .suggestions button { padding: 15px; }
}
@media (max-width: 767px) {
  .app-shell { grid-template-columns: 1fr; min-height: 100dvh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(290px, calc(100vw - 48px)); height: 100dvh; z-index: 2; padding: 22px 17px 18px; visibility: hidden; transform: translateX(-100%); box-shadow: 18px 0 45px rgb(20 28 48 / .12); }
  .app-shell.sidebar-is-open .sidebar { visibility: visible; transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 1; background: rgb(20 28 48 / .3); padding: 0; }
  .menu-close { display: block; }
  .menu-open { display: block; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 12px; }
  .chat-header { min-height: 66px; padding: 12px 18px; gap: 12px; }
  .access-badge { display: none; }
  .conversation-title { font-size: 13px; }
  .conversation-scroll { padding: 0 20px 18px; }
  .empty-state { padding-top: 36px; }
  .empty-state h1 { font-size: 30px; letter-spacing: -.9px; }
  .empty-state>p { font-size: 14px; margin-bottom: 25px; }
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .suggestions button { padding: 14px 16px; gap: 4px; }
  .desktop-break { display: none; }
  .message { margin: 14px 0 27px; }
  .message.user { max-width: 92%; padding: 12px 17px; }
  .message-content { font-size: 14px; }
  .composer-area { padding: 6px 15px max(12px, env(safe-area-inset-bottom)); }
  .composer { padding: 13px 14px 10px; border-radius: 23px; }
  .composer textarea { min-height: 50px; }
  .composer-bottom>span { font-size: 9px; max-width: 230px; }
  .footnote { font-size: 9px; }
  .login-screen { padding: 32px 26px; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: transform .2s cubic-bezier(.2,.8,.2,1), background .2s, border-color .2s; }
  button:not(:disabled):active { transform: scale(.98); }
  .login-panel, .empty-state, .message { animation: appear .35s cubic-bezier(.16,1,.3,1) both; }
  .thinking-dots i { animation: thinking 1.25s ease-in-out infinite; }
  .thinking-dots i:nth-child(2) { animation-delay: .14s; }
  .thinking-dots i:nth-child(3) { animation-delay: .28s; }
  .session-check { animation: breathing 1.6s ease-in-out infinite; }
  .sidebar { transition: transform .24s cubic-bezier(.2,.8,.2,1), visibility .24s; }
  .sidebar-backdrop { animation: fade .2s ease-out; }
}
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes thinking { 0%, 70%, 100% { opacity: .4; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
@keyframes breathing { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
