.chat-page-heading { margin-bottom:28px; }
.chat-page-heading h1 { font-size:30px; }
.chat-workspace { max-width: 1400px; margin: 0 auto; border-top:1px solid #e7e0ee; padding-top:22px; }
.chat-toolbar { display:flex; align-items:center; gap:12px; padding:0 0 16px; border-bottom:1px solid #ece6f2; }
.chat-toolbar .button { flex-shrink:0; width:36px; height:36px; padding:8px; border:0; background:transparent; color:#927ba3; border-radius:8px; }
.chat-toolbar .button:hover { background:#eee7f5; color:#775193; }
.chat-title-wrap { min-width:0; flex:1; }
.chat-title-wrap h2 { font-size:var(--text-body); font-weight:550; line-height:1.5; letter-spacing:-.03em; overflow-wrap:anywhere; }
#chat-archived[hidden] { display:none; }
#chat-archived { display:block; font-size:var(--text-ui); color:#937ea0; margin-top:4px; }
.chat-new-shortcut { margin-left:auto; }
.chat-layout { display:grid; grid-template-columns:270px minmax(0,1fr); gap:36px; padding-top:0; align-items:start; }
.chat-layout.history-collapsed { grid-template-columns:minmax(0,1fr); }
.chat-layout.history-collapsed #chat-history-slot { display:none; }
.chat-content { min-width:0; width:100%; max-width:860px; margin:0 auto; }
#chat-history-slot { position:sticky; top:24px; min-width:0; }
.conversation-history { background:transparent; border:0; border-right:1px solid #e7dfef; border-radius:0; padding:0 20px 24px 0; min-height:540px; max-height:calc(100dvh - 48px); overflow:auto; scrollbar-width:thin; scrollbar-color:#d8cce4 transparent; }
.history-heading { display:flex; align-items:center; justify-content:space-between; padding:0 2px 17px; }
.history-heading h2 { font-size:var(--text-body); font-weight:550; letter-spacing:0; color:#6b567c; }
.history-heading .icon-button { width:32px; height:32px; color:#a28eaf; }
.history-new.button { display:flex; justify-content:flex-start; width:100%; gap:10px; margin-bottom:12px; padding:12px 14px; font-size:var(--text-ui); font-weight:500; background:#fefcff; border:1px solid #e3d9ed; border-radius:10px; color:#75528e; box-shadow:0 2px 4px #50316b03; }
.history-new.button:hover { background:#f2eaf9; border-color:#cdb8df; }
.history-new .icon { width:18px; height:18px; color:#9b70be; }
.history-search { display:flex; align-items:center; gap:8px; padding:0 11px; background:#eee9f4; border:1px solid transparent; border-radius:9px; color:#a08aad; }
.history-search .icon { width:16px; flex-shrink:0; }
.history-search input { font:inherit; font-weight:400; font-size:var(--text-ui); padding:11px 0; min-width:0; width:100%; border:0; margin:0; background:transparent; color:#594365; }
.history-search:focus-within { outline:2px solid #b89bd1; outline-offset:2px; }
.history-search input:focus { outline:none; }
.history-filters { display:flex; gap:20px; margin:18px 2px 6px; border-bottom:1px solid #e8e1ef; }
.history-filters button { border:0; background:transparent; color:#8b749b; font:inherit; font-size:var(--text-ui); padding:0 1px 10px; border-radius:0; cursor:pointer; border-bottom:2px solid transparent; }
.history-filters button[aria-pressed=true] { background:transparent; color:#785296; border-bottom-color:#ab87c8; }
.history-search-note,.history-empty { font-size:var(--text-ui); color:#947fa3; padding:10px 5px; line-height:1.7; }
.history-group h3 { font-size:var(--text-caption); font-weight:600; color:#9b84ab; text-transform:uppercase; letter-spacing:.1em; padding:24px 10px 8px; }
.history-row { position:relative; display:flex; align-items:flex-start; border-radius:9px; margin:3px 0; }
.history-row:hover { background:#f0eaf6; }
.history-row.selected { background:#ebe2f4; box-shadow:inset 2px 0 #a37ac5; }
.history-row > a { flex:1; min-width:0; display:block; padding:12px 34px 12px 12px; border-radius:9px; }
.history-row > a > span { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; overflow-wrap:anywhere; color:#756181; font-size:var(--text-ui); line-height:1.55; }
.history-row.selected > a > span { color:#62427a; font-weight:550; }
.history-row time { display:block; color:#a18daf; font-size:var(--text-caption); margin-top:7px; }
.history-options { position:absolute; right:3px; top:7px; }
.history-options > summary { cursor:pointer; width:30px; height:34px; display:grid; place-items:center; list-style:none; font-size:22px; color:#8e72a3; border-radius:6px; }
.history-options > summary::-webkit-details-marker { display:none; }
.history-options > summary:hover { background:#d8c7e8; }
.history-actions { position:absolute; top:34px; right:0; width:170px; padding:5px; z-index:3; border:1px solid #ddd0e9; background:#fffdfd; border-radius:10px; box-shadow:0 8px 24px #492e661a; }
.history-actions button { display:block; width:100%; text-align:left; padding:11px; border:0; background:transparent; font:inherit; font-size:var(--text-ui); color:#715287; cursor:pointer; border-radius:6px; }
.history-actions button:hover { background:#f0e8f7; }
.history-actions button:disabled { opacity:.5; cursor:wait; }
.history-more { width:100%; padding:14px 4px; margin-top:10px; font-size:var(--text-ui); }
.history-error:empty { display:none; }
.history-error { font-size:var(--text-ui); padding:6px; }
.history-status { position:absolute; }
.history-drawer { position:fixed; inset:0 auto 0 0; margin:0; padding:0; width:min(340px,92vw); max-width:92vw; height:100dvh; max-height:100dvh; border:0; background:#f8f5fc; color:#594365; }
.history-drawer::backdrop,.conversation-rename::backdrop { background:#28163655; }
.history-drawer .conversation-history { border:0; border-radius:0; min-height:0; max-height:none; height:100%; padding:24px 20px; }
.conversation-rename { width:min(420px,calc(100vw - 32px)); padding:28px; border:1px solid #ddcde9; border-radius:16px; background:#fffcff; color:#58406a; }
.conversation-rename h2 { font-size:22px; margin:0 0 24px; }
.conversation-rename label { font-size:var(--text-ui); }
.conversation-rename input { width:100%; font-size:var(--text-body); }
.rename-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:22px; }
@media (max-width:1100px) {
 .chat-layout { grid-template-columns:minmax(0,1fr); }
 #chat-history-slot { display:none; }
}
.chat-empty { text-align: center; padding: 52px 22px 36px; }
.chat-empty[hidden], .chat-workspace [hidden] { display: none; }
.chat-empty .assistant-logo { margin: 0 auto 22px; }
.chat-empty h2 { font-size: clamp(25px,3vw,34px); margin: 0 0 12px; letter-spacing: -.04em; }
.chat-empty p { color: #867792; line-height: 1.7; }
.chat-starters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin: 30px auto 20px; }
.chat-starters button { padding: 20px; text-align: left; border: 1px solid #e5dcef; border-radius: 14px; background: #fffdfd; color: #705286; font: inherit; font-size:var(--text-body); line-height: 1.6; cursor: pointer; display:flex; align-items:center; gap:12px; justify-content:space-between; }
.chat-starters button:hover { background: #eee6f7; border-color: #bd9cd7; }
.chat-scope { font-size:var(--text-ui); }
.chat-turn { padding: 20px 0 8px; }
.chat-question { width: fit-content; max-width: 85%; margin-left: auto; padding: 14px 20px; background: #ede5f5; color: #4b365a; border-radius: 18px 18px 4px 18px; overflow-wrap: anywhere; }
.chat-question span { font-size:var(--text-ui); text-transform: uppercase; letter-spacing: .1em; color: #80618f; }
.chat-question p { white-space: pre-wrap; margin: 7px 0 0; line-height:1.7; }
.chat-reply { margin: 20px 0; padding: 25px 28px; background: #fffdfd; border: 1px solid #eae3f1; border-radius: 14px; min-width: 0; }
.chat-author { display: flex; gap: 10px; align-items: center; color: #77508e; font-size:var(--text-body); }
.chat-answer .answer-text { padding: 20px 0; font-size:var(--text-body); line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-copy { font-size:var(--text-ui); }
.chat-sources { margin-top: 22px; border-top: 1px solid #eee7f4; padding-top: 12px; }
.chat-sources > p { font-size:var(--text-ui); color: #8c779e; }
.chat-source { margin: 8px 0; border: 1px solid #e8dff1; border-radius: 9px; overflow: hidden; }
.chat-source summary { padding: 12px 14px; font-size:var(--text-ui); cursor: pointer; overflow-wrap: anywhere; }
.chat-source small { display: block; color: #9c88ad; padding-left: 14px; margin-top: 5px; }
.chat-source pre { padding: 16px; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size:var(--text-ui); max-height: 300px; overflow: auto; background: #f7f3fb; }
.chat-source a { display: block; padding: 12px 16px; color: #8158a1; }
.chat-activity { border-top: 1px solid #eee7f4; margin-top: 20px; padding-top: 14px; }
.chat-activity > summary { font-size:var(--text-ui); color: #8e70a5; cursor: pointer; }
.chat-activity-host { margin-top: 18px; min-width: 0; }
.chat-progress { display:flex; align-items:center; gap:12px; padding:20px 0 5px; font-size:var(--text-body); color:#8a6c9c; }
.chat-progress .spinner { width:16px; height:16px; flex-shrink:0; }
.chat-composer { background:#fffdfd; border:1px solid #d9c7e8; border-radius:16px; padding:18px; margin-top:24px; box-shadow:0 8px 30px #68478408; }
#assistant-form.chat-composer textarea { border:0; background:transparent; resize:vertical; width:100%; font:inherit; font-size:var(--text-body); line-height:1.6; min-height:84px; padding:8px; color:#483556; }
#assistant-form.chat-composer textarea:focus-visible { outline:2px solid #c3a7df; outline-offset:2px; border-radius:6px; }
.chat-composer .composer-footer { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:10px 0 0; border:0; background:transparent; border-radius:0; }
#chat-status { font-size:var(--text-ui); color:#917e9f; }
.chat-composer .button { flex-shrink:0; }
.chat-composer .error:empty, #chat-load-error:empty { display:none; }
.chat-footnote { text-align:center; font-size:var(--text-ui); color:#9784a3; margin:16px 0 30px; }
@media (max-width:700px) {
 .chat-toolbar { flex-wrap:wrap; gap:10px; }
 .chat-title-wrap { padding-top:0; }
 .chat-title-wrap h2 { font-size:var(--text-body); }
 .chat-toolbar .button { width:32px; height:32px; padding:6px; }
 .chat-starters { grid-template-columns:1fr; }
 .chat-empty { padding:30px 0 15px; }
 .chat-reply { padding:18px 14px; }
 .chat-question { max-width:94%; }
 .chat-composer { padding:12px; }
 .chat-composer .composer-footer { flex-wrap:wrap; }
 .chat-composer .button { margin-left:auto; }
}

@media (prefers-reduced-motion: reduce) { .chat-progress .spinner { animation: none; } }

@media (hover:hover) and (pointer:fine) {
 .history-options > summary { opacity:0; transition:opacity .15s ease; }
 .history-row:hover .history-options > summary,.history-row:focus-within .history-options > summary,.history-options[open] > summary { opacity:1; }
}
@media (prefers-reduced-motion:reduce) { .history-options > summary { transition:none; } }

.history-search input { font-size:var(--text-body); }
.chat-answer .answer-text, .chat-question p { font-size:var(--text-body); line-height:1.75; }
.chat-source small { font-size:var(--text-caption); }
.history-heading h2 { font-size:var(--text-body); }
.history-filters button, .history-actions button, .history-row > a > span { font-size:var(--text-ui); }
