@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #ffffff;
  --surface: #f9f9f9;
  --surface-2: #f2f2f3;
  --sidebar: #f7f7f8;
  --text: #141416;
  --text-2: #5d5d66;
  --text-3: #8d8d98;
  --border: #e7e7ea;
  --border-2: #f0f0f2;
  --bubble: #f2f2f4;
  --accent: #c8a96a;
  --accent-ink: #16130c;
  --code-head: #17171c;
  --code-body: #0f0f14;
  --green: #12805c;
  --green-soft: #e7f6ef;
  --blue: #1d5bd7;
  --blue-soft: #eaf1ff;
  --red: #d9344c;
  --red-soft: #fdeef0;
  --amber: #a86400;
  --amber-soft: #fdf3e1;
  --shadow: 0 10px 30px -18px rgba(15, 18, 25, .25);
  --sidebar-w: 264px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, sans-serif;
}
body.dark {
  --bg: #212121;
  --surface: #2a2a2a;
  --surface-2: #303030;
  --sidebar: #171717;
  --text: #ececf0;
  --text-2: #b4b4bf;
  --text-3: #8a8a96;
  --border: #3a3a3a;
  --border-2: #333;
  --bubble: #303030;
  --code-head: #101014;
  --code-body: #0b0b0f;
  --shadow: 0 16px 40px -20px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.ico { flex: none; vertical-align: -2px; }
.eyebrow { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; font-size: 10px; font-weight: 800; flex: none; }
.logo-mark { display: inline-grid; place-items: center; border-radius: 30%; background: var(--text); color: var(--accent); flex: none; }
.logo-mark .ico { stroke-width: 2; }

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar-w); flex: none; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: width .2s; }
body.sidebar-collapsed .sidebar { width: 0; border-right: 0; overflow: hidden; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 14px 12px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand > div { display: flex; align-items: center; gap: 6px; }
.brand strong { font-family: var(--display); font-size: 15px; letter-spacing: -.03em; }
.brand span { font-size: 7.5px; font-weight: 800; letter-spacing: .12em; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); padding: 2px 4px; border-radius: 4px; }
.new-chat { display: flex; align-items: center; gap: 8px; margin: 0 12px 10px; height: 40px; padding: 0 12px; border: 1px solid var(--border); background: transparent; border-radius: 12px; font-size: 12px; font-weight: 600; }
.new-chat:hover { background: var(--surface-2); }
.new-chat em { margin-left: auto; font-style: normal; font-size: 9px; color: var(--text-3); border: 1px solid var(--border); padding: 2px 5px; border-radius: 4px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px 8px; }
.side-nav button { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 9px; border: 0; border-radius: 8px; background: none; font-size: 12px; font-weight: 500; color: var(--text-2); text-align: left; }
.side-nav button:hover { background: var(--surface-2); color: var(--text); }
.side-nav button.active { background: var(--surface-2); color: var(--text); font-weight: 700; }
.side-nav em { margin-left: auto; font-style: normal; font-size: 8.5px; font-weight: 700; color: var(--text-3); }
.chat-search { display: flex; align-items: center; gap: 7px; margin: 4px 12px 8px; padding: 0 9px; height: 32px; border-radius: 8px; border: 1px solid transparent; color: var(--text-3); }
.chat-search:hover { border-color: var(--border); }
.chat-search input { border: 0; background: transparent; outline: none; width: 100%; font-size: 11.5px; color: var(--text); }
.convo-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.convo-list::-webkit-scrollbar { width: 6px; }
.convo-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9px; }
.convo-group { margin-bottom: 12px; }
.convo-label { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); font-weight: 700; padding: 4px 8px 5px; }
.convo-item { display: flex; align-items: center; width: 100%; border: 0; background: none; border-radius: 7px; padding: 7px 8px; font-size: 11.5px; color: var(--text-2); text-align: left; gap: 6px; }
.convo-item:hover { background: var(--surface-2); color: var(--text); }
.convo-item.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.convo-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-more { border: 0; background: none; color: var(--text-3); padding: 2px; border-radius: 4px; opacity: 0; }
.convo-item:hover .convo-more, .convo-item.active .convo-more { opacity: 1; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px; }
.user-card { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 9px; }
.user-card:hover { background: var(--surface-2); }
.user-card > div { flex: 1; min-width: 0; }
.user-card strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card span { font-size: 9.5px; color: var(--text-3); }
.side-links { display: flex; gap: 4px; margin-top: 6px; }
.side-links button { display: flex; align-items: center; gap: 5px; flex: 1; border: 0; background: none; padding: 6px; border-radius: 6px; color: var(--text-3); font-size: 9.5px; }
.side-links button:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Main / header ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.chat-header { height: 54px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border-2); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); z-index: 10; }
.header-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.header-title strong { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-badge { font-size: 8.5px; font-weight: 700; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; }
.header-actions { margin-left: auto; display: flex; gap: 2px; }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 7px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mobile-menu { display: none; }
#mainView { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Chat ---------- */
.chat-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.message-list { width: min(760px, 100%); margin: 0 auto; padding: 28px 20px 30px; }
.msg { display: flex; flex-direction: column; margin-bottom: 26px; }
.msg.user { align-items: flex-end; }
.user-bubble { max-width: 82%; background: var(--bubble); border-radius: 18px 18px 4px 18px; padding: 11px 15px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.user-files { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.user-file { display: inline-flex; align-items: center; gap: 5px; background: color-mix(in srgb, var(--bg) 65%, transparent); border: 1px solid var(--border); border-radius: 7px; padding: 3px 7px; font-size: 9.5px; }
.user-file em { font-style: normal; color: var(--text-3); font-size: 8px; }
.msg-meta { font-size: 9.5px; color: var(--text-3); margin-top: 5px; }
.msg-meta.right { text-align: right; }
.msg.assistant { flex-direction: row; gap: 11px; align-items: flex-start; }
.assistant-avatar { flex: none; margin-top: 1px; }
.assistant-body { min-width: 0; flex: 1; }
.assistant-name { font-size: 10.5px; font-weight: 700; color: var(--text-2); margin-bottom: 7px; display: flex; align-items: center; gap: 7px; }
.assistant-name span { font-weight: 400; color: var(--text-3); font-size: 9px; }
.md { font-size: 13px; line-height: 1.72; color: var(--text); }
.md p { margin-bottom: 11px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 8px 0 12px; padding-left: 21px; }
.md li { margin-bottom: 5px; }
.md strong { font-weight: 700; }
.cite { display: inline-grid; place-items: center; min-width: 15px; height: 15px; padding: 0 3px; margin: 0 1px; border: 0; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font-size: 8px; font-weight: 800; vertical-align: 1px; }
.cite:hover { transform: translateY(-1px); }
.file-cite { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; padding: 1px 5px; font-size: 9.5px; font-weight: 600; color: var(--text-2); vertical-align: 1px; }
.file-cite:hover { border-color: var(--accent); color: var(--text); }

/* tool strip */
.tool-strip { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 7px 9px; margin-bottom: 11px; font-size: 10.5px; color: var(--text-2); text-align: left; }
.tool-strip:hover { background: var(--surface-2); }
.tool-icon { color: var(--blue); display: inline-flex; }
.tool-favs { display: flex; margin-left: 2px; }
.tool-fav { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 7px; font-weight: 800; border: 1.5px solid var(--surface); margin-left: -4px; }
.tool-count { margin-left: auto; font-size: 9.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 2px; }

/* file cards */
.file-card { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 11px; margin: 11px 0; }
.file-card:hover { border-color: color-mix(in srgb, var(--border) 50%, var(--text-3)); }
.file-tile { width: 38px; height: 38px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 8px; font-weight: 800; letter-spacing: .04em; flex: none; }
.file-tile.pdf { background: var(--red-soft); color: var(--red); }
.file-tile.docx, .file-tile.doc { background: var(--blue-soft); color: var(--blue); }
.file-tile.xlsx { background: var(--green-soft); color: var(--green); }
.file-tile.md, .file-tile.html { background: var(--surface-2); color: var(--text-2); }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-info strong { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info span { font-size: 9.5px; color: var(--text-3); }
.file-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 34px; padding: 0 13px; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; font-size: 11px; font-weight: 600; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.tiny { height: 27px; padding: 0 9px; font-size: 10px; border-radius: 6px; }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; }

/* artifact row */
.artifact-row { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 560px; padding: 7px 9px; margin: 4px 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-size: 11.5px; text-align: left; }
.artifact-row:hover { background: var(--surface); border-color: var(--border); }
.artifact-glyph { color: var(--blue); display: inline-flex; }
.artifact-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-badge { font-size: 7.5px; font-weight: 800; letter-spacing: .08em; color: var(--text-3); border: 1px solid var(--border); padding: 2px 4px; border-radius: 3px; }
.artifact-meta { margin-left: auto; font-size: 9px; color: var(--text-3); }
.artifact-chev { color: var(--text-3); display: inline-flex; }

/* code block */
.code-block { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 12px 0; background: var(--code-body); }
.code-head { height: 38px; display: flex; align-items: center; padding: 0 10px; background: var(--code-head); color: #a9a9b4; border-bottom: 1px solid #2a2a32; }
.code-lang { font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.code-actions { margin-left: auto; display: flex; gap: 2px; }
.code-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: #9a9aa6; font-size: 9.5px; padding: 5px 6px; border-radius: 5px; }
.code-btn:hover { color: #fff; background: rgba(255,255,255,.08); }
.code-btn.preview { color: #d8d8e2; border: 1px solid #34343f; }
.code-btn.preview.active { background: rgba(200,169,106,.15); border-color: rgba(200,169,106,.4); color: var(--accent); }
.code-body { margin: 0; padding: 15px; max-height: 330px; overflow: auto; font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 11px; line-height: 1.65; color: #d6d6e0; }
.html-preview { width: 100%; height: 420px; max-height: 62vh; border: 0; background: #fff; display: block; }

/* sources */
.sources-block { margin: 13px 0 5px; border-top: 1px solid var(--border-2); padding-top: 10px; }
.sources-head { display: flex; align-items: center; justify-content: space-between; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin-bottom: 8px; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 9.5px; font-weight: 700; }
.source-tabs { display: flex; gap: 5px; margin-bottom: 9px; flex-wrap: wrap; }
.source-tabs span { font-size: 9px; font-weight: 600; color: var(--text-3); padding: 3px 6px; border-radius: 5px; background: var(--surface); }
.source-tabs span.active { background: var(--surface-2); color: var(--text); }
.source-tabs em { font-style: normal; font-size: 8px; opacity: .7; }
.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.source-card { display: flex; flex-direction: column; gap: 4px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 9.5px; min-width: 0; }
.source-card:hover { background: var(--surface-2); }
.source-top { display: flex; align-items: center; gap: 5px; color: var(--text-3); font-size: 8.5px; }
.favicon { width: 15px; height: 15px; border-radius: 4px; display: inline-grid; place-items: center; color: #fff; font-size: 7.5px; font-weight: 800; flex: none; }
.source-card strong { font-size: 10.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-card p { font-size: 9px; line-height: 1.45; color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-card.image { padding: 0; overflow: hidden; background: none; }
.source-card.image img { width: 100%; height: 74px; object-fit: cover; display: block; }
.source-card.image span { padding: 6px 8px; font-size: 9px; color: var(--text-2); }
.source-files { display: flex; flex-direction: column; gap: 5px; }
.source-file { display: flex; align-items: center; gap: 8px; width: 100%; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 7px 8px; text-align: left; }
.source-file .file-tile { width: 30px; height: 30px; border-radius: 7px; font-size: 7px; }
.source-file > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.source-file strong { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-file small { font-size: 8.5px; color: var(--text-3); }
.source-file p { font-size: 9px; color: var(--text-3); margin-top: 2px; }

.followups { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.followup { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: transparent; border-radius: 20px; padding: 5px 9px; font-size: 10px; color: var(--text-2); }
.followup:hover { background: var(--surface); color: var(--text); }
.msg-actions { display: flex; gap: 8px; margin-top: 10px; opacity: .65; }
.msg-actions:hover { opacity: 1; }
.msg-action { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--text-3); font-size: 9.5px; padding: 2px 3px; }
.msg-action:hover { color: var(--text); }

/* typing */
.typing-card { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px 14px; max-width: 480px; }
.typing-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; margin-bottom: 8px; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing-stage { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--text-3); padding: 3px 0; }
.typing-stage.done { color: var(--green); }
.stage-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--border); }
.typing-dots { display: flex; gap: 3px; margin-top: 7px; }
.typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* landing */
.landing { width: min(760px, 100%); margin: auto; padding: 28px 20px 130px; text-align: center; }
.landing-mark { display: flex; justify-content: center; margin-bottom: 16px; }
.landing h1 { font-family: var(--display); font-size: clamp(27px, 3.4vw, 38px); letter-spacing: -.04em; font-weight: 600; }
.landing-sub { font-size: 11.5px; color: var(--text-3); margin: 8px auto 26px; max-width: 440px; line-height: 1.6; }
.prompt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; text-align: left; }
.prompt-card { position: relative; display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 13px; min-height: 104px; text-align: left; }
.prompt-card:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--border) 40%, var(--text-3)); }
.prompt-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--border); color: var(--accent); margin-bottom: 6px; }
.prompt-card strong { font-size: 11.5px; }
.prompt-card > span:not(.prompt-icon) { font-size: 9.5px; color: var(--text-3); }
.prompt-card em { position: absolute; right: 11px; bottom: 10px; color: var(--text-3); }

/* composer */
.composer-wrap { padding: 8px 20px 12px; background: linear-gradient(to top, var(--bg) 65%, transparent); }
.composer-wrap.center { padding: 0; background: none; width: min(700px, 100%); margin: 0 auto; }
.composer { position: relative; width: min(760px, 100%); margin: 0 auto; border: 1px solid var(--border); background: var(--bg); border-radius: 23px; box-shadow: var(--shadow); padding: 11px 11px 8px 14px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 6px; }
.composer-icon { grid-row: 1 / span 2; align-self: end; width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; border-radius: 7px; margin-bottom: 2px; }
.composer-icon:hover { background: var(--surface-2); }
.composer textarea { width: 100%; border: 0; outline: none; background: transparent; resize: none; font-size: 13px; line-height: 1.55; padding: 5px 0 3px; min-height: 28px; max-height: 180px; }
.composer textarea::placeholder { color: var(--text-3); }
.composer-tools { grid-column: 2; display: flex; align-items: center; gap: 5px; }
.model-select, .web-toggle { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: transparent; border-radius: 14px; height: 26px; padding: 0 8px; font-size: 9.5px; font-weight: 600; color: var(--text-2); }
.model-select:hover, .web-toggle:hover { background: var(--surface); }
.model-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.web-toggle.active { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, transparent); color: var(--blue); }
.send-btn { margin-left: auto; width: 31px; height: 31px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.composer-note { text-align: center; font-size: 8.5px; color: var(--text-3); margin-top: 7px; }
.composer-tray { width: min(760px, 100%); margin: 0 auto 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tray-file { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 5px 7px; font-size: 9.5px; }
.tray-file .file-tile { width: 26px; height: 26px; border-radius: 6px; font-size: 6.5px; }
.tray-file > span:nth-child(2) { display: flex; flex-direction: column; }
.tray-file strong { font-size: 9.5px; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-file small { font-size: 8px; color: var(--text-3); }
.attach-menu { display: none; position: absolute; left: 6px; bottom: 46px; width: 230px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; z-index: 15; }
.attach-menu.open { display: block; }
.attach-menu button { display: flex; align-items: center; gap: 7px; width: 100%; border: 0; background: none; padding: 8px 9px; border-radius: 6px; font-size: 10.5px; text-align: left; }
.attach-menu button:hover { background: var(--surface-2); }
body.dragging .composer { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--bg)); }

/* ---------- Files page ---------- */
.page-view { width: min(980px, 100%); margin: 0 auto; padding: 30px 24px 60px; overflow-y: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-head h1 { font-family: var(--display); font-size: 27px; letter-spacing: -.04em; margin: 3px 0; }
.page-head p { font-size: 11.5px; color: var(--text-3); max-width: 540px; line-height: 1.6; }
.file-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.file-stats div { border: 1px solid var(--border); border-radius: 10px; padding: 13px; background: var(--surface); display: flex; flex-direction: column; }
.file-stats strong { font-family: var(--display); font-size: 21px; }
.file-stats span { font-size: 9px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.file-table { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.file-row { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-bottom: 1px solid var(--border-2); }
.file-row:last-child { border-bottom: 0; }
.file-row:hover { background: var(--surface); }
.file-row-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-row-name strong { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row-name span { font-size: 9px; color: var(--text-3); }
.status-pill { font-size: 8.5px; font-weight: 700; padding: 3px 7px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); }
.status-pill.indexed { background: var(--green-soft); color: var(--green); }
.status-pill.processing { background: var(--amber-soft); color: var(--amber); }
.chunk-count { font-size: 9px; color: var(--text-3); min-width: 60px; text-align: right; }
.file-row-actions { display: flex; gap: 4px; }
.rag-note { display: flex; gap: 9px; align-items: flex-start; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px; margin-top: 16px; font-size: 10.5px; color: var(--text-2); line-height: 1.55; }
.rag-note .ico { color: var(--accent); margin-top: 2px; }

/* ---------- Canvas ---------- */
.canvas-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.canvas-head { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.canvas-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.canvas-title input { border: 0; background: transparent; font-family: var(--display); font-size: 13px; font-weight: 600; outline: none; width: 100%; }
.canvas-title span { font-size: 8.5px; color: var(--text-3); }
.canvas-actions { display: flex; gap: 5px; }
.canvas-body { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.canvas-page { flex: 1; overflow-y: auto; background: #f5f4f0; color: #1b1b1b; padding: 46px 60px; font-family: Georgia, "Times New Roman", serif; font-size: 13.5px; line-height: 1.8; margin: 24px; border-radius: 3px; box-shadow: 0 10px 40px -20px rgba(0,0,0,.4); max-width: 760px; margin-left: auto; margin-right: auto; outline: none; }
.canvas-page h1 { font-size: 25px; line-height: 1.2; margin-bottom: 6px; }
.canvas-page h2 { font-size: 15px; margin: 20px 0 6px; }
.canvas-page .doc-sub { color: #777; font-size: 11px; margin-bottom: 18px; }
.canvas-page ul { padding-left: 20px; }
.canvas-side { width: 250px; flex: none; border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; background: var(--surface); }
.canvas-side h3 { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin: 15px 0 7px; }
.canvas-side h3:first-child { margin-top: 0; }
.canvas-side > button { display: block; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--bg); border-radius: 7px; padding: 7px 8px; font-size: 10px; margin-bottom: 4px; }
.canvas-side > button:hover { background: var(--surface-2); }
.version-row { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 6px; font-size: 10px; }
.version-row.active { background: var(--bg); border: 1px solid var(--border); }
.version-row small { font-size: 8px; color: var(--text-3); }
.canvas-file { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.canvas-file .file-tile { width: 30px; height: 30px; font-size: 7px; }
.canvas-file div { display: flex; flex-direction: column; }
.canvas-file strong { font-size: 9.5px; }
.canvas-file small { font-size: 8px; color: var(--text-3); }

/* ---------- Modals ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 18, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; }
.sources-modal, .file-modal { width: min(720px, 100%); max-height: 86vh; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); }
.file-modal { width: min(980px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px 12px; }
.modal-head h2 { font-family: var(--display); font-size: 19px; letter-spacing: -.03em; }
.modal-head p { font-size: 9.5px; color: var(--text-3); margin-top: 2px; }
.modal-tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.modal-tabs button { border: 0; background: none; padding: 8px 8px 10px; font-size: 10.5px; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; }
.modal-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.modal-tabs em { font-style: normal; font-size: 8px; opacity: .65; }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.source-row { display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; }
.source-row:hover { background: var(--surface); }
.source-row strong { font-size: 11.5px; }
.source-row p { font-size: 10px; color: var(--text-3); line-height: 1.5; }
.source-file.row { padding: 10px; }
.source-file.row > span:nth-child(2) { gap: 2px; }
.source-file.row p { font-size: 9px; color: var(--text-3); }
.image-source { border: 0; background: none; padding: 0; border-radius: 9px; overflow: hidden; }
.image-source img { width: 100%; height: 120px; object-fit: cover; display: block; }
.image-source span { display: block; padding: 6px 8px; background: var(--surface); font-size: 9.5px; text-align: left; }
.file-modal-title { display: flex; align-items: center; gap: 10px; }
.file-modal-title .file-tile { width: 42px; height: 42px; }
.modal-head-actions { display: flex; gap: 4px; }
.file-modal-body { display: flex; flex: 1; min-height: 0; border-top: 1px solid var(--border); }
.pdf-pages { flex: 1; overflow: auto; background: var(--surface-2); padding: 14px; display: flex; gap: 10px; }
.pdf-page { background: #fff; color: #1a1a1a; width: 198px; flex: none; border-radius: 4px; box-shadow: 0 6px 20px -10px rgba(0,0,0,.3); padding: 12px; }
.pdf-page-head { display: flex; justify-content: space-between; font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #888; margin-bottom: 12px; }
.pdf-page-head em { font-style: normal; color: var(--green); font-size: 7.5px; }
.pdf-lines { display: flex; flex-direction: column; gap: 6px; }
.pdf-lines i { display: block; height: 4px; background: #e3e3e3; border-radius: 3px; }
.pdf-snippet { margin-top: 13px; font-size: 8.5px; line-height: 1.5; color: #555; border-top: 1px solid #eee; padding-top: 8px; }
.file-modal-side { width: 260px; flex: none; border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.file-modal-side h3 { font-size: 9px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin: 14px 0 7px; }
.file-modal-side h3:first-child { margin-top: 0; }
.file-modal-side p { font-size: 10px; color: var(--text-2); line-height: 1.55; }
.context-meter { display: flex; align-items: baseline; gap: 5px; }
.context-meter span { font-family: var(--display); font-size: 26px; font-weight: 600; }
.context-meter small { font-size: 8px; text-transform: uppercase; color: var(--text-3); }
.page-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.page-chips span { font-size: 9px; border: 1px solid var(--border); border-radius: 5px; padding: 2px 5px; color: var(--text-2); }
.image-modal { position: relative; max-width: 90vw; max-height: 88vh; }
.image-modal img { max-width: 90vw; max-height: 88vh; border-radius: 10px; display: block; }
.image-modal .icon-btn { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.55); color: #fff; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 7px; }
.toast { display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg); padding: 10px 13px; border-radius: 9px; font-size: 10.5px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transform: translateY(7px); transition: .2s; max-width: 330px; }
.toast.show { opacity: 1; transform: none; }
.toast.success .ico { color: #4ade80; }
.toast.danger .ico { color: #fca5a5; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 30px 0 60px -30px rgba(0,0,0,.5); }
  body.mobile-open .sidebar { transform: none; }
  body.mobile-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  .mobile-menu { display: inline-grid; }
  .message-list { padding: 18px 14px 26px; }
  .composer-wrap { padding: 6px 12px 10px; }
  .landing { padding-bottom: 120px; }
  .file-modal-body { flex-direction: column; }
  .file-modal-side { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  .pdf-pages { overflow-x: auto; }
  .canvas-side { display: none; }
  .canvas-page { margin: 14px; padding: 30px 24px; }
}
@media (max-width: 640px) {
  .prompt-grid { grid-template-columns: 1fr; }
  .source-grid { grid-template-columns: 1fr; }
  .file-stats { grid-template-columns: 1fr 1fr; }
  .header-actions .icon-btn:nth-child(2) { display: none; }
  .file-row { flex-wrap: wrap; }
  .chunk-count { display: none; }
  .user-bubble { max-width: 92%; }
  .html-preview { height: 300px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-view { padding: 20px 14px 44px; }
  .modal-layer { padding: 8px; }
  .sources-modal, .file-modal { max-height: 94vh; }
}
