* { box-sizing: border-box; }
:root { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #222; background: #fff; font-size: 16px; --source-width: 50vw; --topbar-height: 56px; }
body { margin: 0; }
button, input, textarea { font: inherit; }
a, button { color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { text-decoration: none; }
a:hover, button:hover { color: #666; }
:focus-visible { outline: 2px solid #999; outline-offset: 6px; }
.entry { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.company { font-size: 18px; font-weight: 400; letter-spacing: .01em; margin: 0; }
.auth { min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; }
.auth form { width: min(100%, 320px); }
.auth input { width: 100%; border: 0; border-bottom: 1px solid #ddd; border-radius: 0; background: transparent; padding: 14px 0; outline: none; }
.auth input:focus { border-color: #777; }
.auth button { display: block; margin: 24px 0 0 auto; }
.auth p { color: #888; font-size: 13px; line-height: 1.6; }
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 3; height: var(--topbar-height); display: flex; align-items: center; gap: 20px; padding: 0 24px; background: #fff; border-bottom: 1px solid #eee; font-size: 13px; color: #888; }
.topbar .brand { font-size: 14px; color: #333; }
.topnav { display: flex; gap: 18px; }
.topnav-link { color: #888; }
.topnav-link:hover { color: #444; }
.topnav-link.active { color: #222; }
.topbar .account { margin-left: auto; display: flex; align-items: center; gap: 8px; color: #aaa; }
.topbar .note { color: #c9c9c9; }
.topbar .logout-status { color: #999; }
.chat { max-width: 720px; margin: 0 auto; padding: 96px 24px 180px; }
.chat.empty { padding: 0 24px; margin-top: var(--topbar-height); min-height: calc(100svh - var(--topbar-height)); display: flex; align-items: center; }

.content-layout { display: flex; align-items: flex-start; margin-top: var(--topbar-height); }
.content-sidebar { position: sticky; top: var(--topbar-height); flex: none; width: var(--sidebar-width, 300px); height: calc(100svh - var(--topbar-height)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 24px 20px 60px; }
.content-sidebar::-webkit-scrollbar { display: none; }
.content-resizer { position: relative; flex: none; align-self: stretch; width: 9px; margin: 0 -4px; cursor: ew-resize; touch-action: none; }
.content-resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 4px; width: 1px; background: #eee; }
.content-resizer:hover::after, .content-resizer:focus-visible::after { background: #d0d0d0; }
.content-resizer:focus, .content-resizer:focus-visible { outline: none; }
body.content-resizing, body.content-resizing * { cursor: ew-resize; user-select: none; }
.doc-group + .doc-group { margin-top: 24px; }
.doc-group-title { margin: 0 0 6px; font-size: 12px; font-weight: 400; color: #aaa; }
.doc-list { display: flex; flex-direction: column; }
.doc-item { display: block; width: 100%; text-align: left; padding: 4px 0; line-height: 1.7; color: #777; }
.doc-item:hover { color: #222; }
.doc-item.active { color: #111; }
.doc-item-title { display: block; font-size: 13px; }
.content-sidebar .doc-item-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-date { color: #c0c0c0; }
.doc-item-meta { display: block; margin-top: 1px; font-size: 11px; color: #bbb; }
.doc-badge { margin-left: 6px; color: #bbb; font-size: 11px; }
.content-main { flex: 1; min-width: 0; padding: 40px 40px 140px; }
.overview-header h1 { margin: 0 0 8px; font-size: 24px; }
.overview-meta { margin: 0; color: #999; font-size: 13px; }
.overview-groups .doc-group { margin-top: 30px; }
.overview-groups .doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 28px; }
.overview-groups .doc-item { padding: 6px 0; }
.doc { max-width: 760px; }
.doc-header { margin-bottom: 26px; }
.doc-path { margin: 0 0 10px; font-size: 12px; color: #b8b8b8; overflow-wrap: anywhere; }
.doc-title { margin: 0 0 10px; font-size: 26px; line-height: 1.35; }
.doc-meta { margin: 0; font-size: 12px; color: #999; }
.doc-ask { display: inline-block; margin-top: 14px; font-size: 13px; color: #777; text-decoration: underline; text-underline-offset: 3px; }
.doc-note { margin: 0 0 22px; padding: 10px 12px; background: #f8f8f8; border-radius: 8px; color: #888; font-size: 13px; line-height: 1.7; }
.doc-back { display: none; margin-bottom: 14px; font-size: 13px; color: #777; }
.doc-body { font-size: 16px; }
.doc-link { text-decoration: underline; text-underline-offset: 3px; }
.doc-link-missing { color: #aaa; }
.content-status { color: #999; font-size: 14px; }

.composer { width: 100%; }
.composer textarea { display: block; width: 100%; min-height: 54px; max-height: 160px; resize: none; padding: 14px 0; border: 0; border-bottom: 1px solid #e1e1e1; border-radius: 0; outline: none; background: #fff; line-height: 1.6; overflow-y: auto; scrollbar-width: none; }
.composer textarea::-webkit-scrollbar, .source-content::-webkit-scrollbar { display: none; }
.composer textarea:focus { border-color: #aaa; }
.composer textarea::placeholder { color: #aaa; }
.suggestions { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 18px; }
.suggestions[hidden] { display: none; }
.suggestions button { padding: 0; color: #888; font-size: 13px; line-height: 1.8; }
.suggestions button:hover { color: #333; }
.suggestions button:not(:first-child)::before { content: '·'; margin-right: 14px; color: #ddd; }

.chat:not(.empty) .composer { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); max-width: 720px; padding: 20px 24px 36px; background: #fff; }
.turn { margin: 18px 0 52px; }
.question { color: #888; margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; margin: 0; }
.pending { color: #999; }
.sources { margin-top: 18px; font-size: 12px; color: #888; line-height: 1.8; }
.source-link { display: block; margin: 6px 0; text-align: left; line-height: inherit; }
.source-link[aria-expanded="true"] { color: #333; }
.citation { color: #888; font-size: .8em; vertical-align: baseline; }
.citation:hover { color: #222; text-decoration: underline; }
.markdown { white-space: normal; overflow-wrap: anywhere; line-height: 1.9; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown pre, .markdown table { margin: 0 0 1em; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 { margin: 1.5em 0 .65em; line-height: 1.5; font-weight: 600; }
.markdown h1 { font-size: 1.4em; }
.markdown h2 { font-size: 1.2em; }
.markdown h3, .markdown h4, .markdown h5, .markdown h6 { font-size: 1em; }
.markdown ul, .markdown ol { padding-left: 1.5em; }
.markdown li + li { margin-top: .25em; }
.markdown li > p { margin-bottom: .35em; }
.markdown blockquote { border-left: 2px solid #ddd; padding-left: 1em; color: #777; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: #f5f5f5; padding: .15em .3em; border-radius: 3px; }
.markdown pre { background: #f7f7f7; padding: 14px 16px; border-radius: 5px; overflow-x: auto; white-space: pre; line-height: 1.7; }
.markdown pre code { padding: 0; background: none; }
.markdown table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .9em; }
.markdown th, .markdown td { padding: 8px 12px; border: 1px solid #e7e7e7; text-align: left; }
.markdown th { background: #fafafa; font-weight: 600; }
.markdown hr { border: 0; border-top: 1px solid #eee; margin: 1.5em 0; }
.markdown a[href] { text-decoration: underline; text-underline-offset: 3px; }
.markdown input[type="checkbox"] { margin-right: .4em; }
.source-panel[hidden] { display: none; }
.source-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--source-width); z-index: 2; background: #fff; border-left: 1px solid #eaeaea; display: flex; flex-direction: column; padding: 28px 32px 0; }
.source-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.source-header h2 { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.6; overflow-wrap: anywhere; }
.source-close { flex-shrink: 0; color: #999; font-size: 24px; line-height: 1; min-width: 28px; min-height: 28px; }
.source-meta { font-size: 12px; color: #aaa; margin: 8px 0 28px; }
.source-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 36px; font-size: 14px; scrollbar-width: none; }
.source-resizer { position: absolute; top: 0; bottom: 0; left: -6px; width: 12px; cursor: ew-resize; touch-action: none; }
.source-resizer:hover, .source-resizer:focus-visible { background: #eee8; }
body.source-resizing, body.source-resizing * { cursor: ew-resize; user-select: none; }
body.source-open { padding-right: var(--source-width); }
body.source-open .chat:not(.empty) .composer { left: calc((100% - var(--source-width)) / 2); max-width: min(720px, calc(100% - var(--source-width))); }
.error { color: #888; font-size: 14px; line-height: 1.7; }
.retry { margin-top: 12px; font-size: 13px; color: #888; }
@media (max-width: 600px) { .chat { padding-top: 84px; } .chat:not(.empty) .composer { padding-bottom: max(24px, env(safe-area-inset-bottom)); } }
@media (max-width: 900px) {
  body.source-open { padding-right: 0; overflow: hidden; }
  body.source-open .chat:not(.empty) .composer { left: 50%; max-width: 720px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar .note { display: none; }
  .content-sidebar { display: none; }
  .content-resizer { display: none; }
  .content-main { padding: 24px 20px 100px; }
  .content.doc-open .doc-back { display: block; }
  .overview-groups .doc-list { grid-template-columns: 1fr; }
  .source-panel { width: 100%; padding: 24px 24px 0; border-left: 0; }
  .source-resizer { display: none; }
  .source-content { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

.answer.pending::after {
  content: '...';
  display: inline-block;
  width: max-content;
  animation: answering-dots 1.6s steps(1, end) infinite;
}
@keyframes answering-dots {
  0%, 100% { clip-path: inset(0 100% 0 0); }
  16%, 83% { clip-path: inset(0 66.66% 0 0); }
  33%, 66% { clip-path: inset(0 33.33% 0 0); }
  50% { clip-path: inset(0 0 0 0); }
}
@media (prefers-reduced-motion: reduce) {
  .answer.pending::after { animation: none; }
}
