/* Q&A */
#panel-qa.active { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 40px); }
.qa-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; flex: 1; min-height: 0; }
.chat-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.chat-title { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sm { padding: 6px 12px !important; font-size: 12px !important; white-space: nowrap; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.chat-composer { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--bg-surface); }
.side-panel { display: flex; flex-direction: column; min-height: 0; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.side-tabs { display: flex; border-bottom: 1px solid var(--border); }
.side-tab { flex: 1; padding: 10px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--font); }
.side-tab:hover { color: var(--text-primary); }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.side-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; }
.hist-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 4px; }
.hist-item:hover { background: var(--bg-hover); }
.hist-item.active { background: var(--accent-dim); border-color: var(--accent); }
.hist-main { flex: 1; min-width: 0; }
.hist-title { font-size: 12.5px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-sub { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.hist-del { opacity: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; font-size: 14px; }
.hist-item:hover .hist-del, .hist-del:focus-visible { opacity: 1; }
.hist-del:hover { color: var(--red); background: var(--red-dim); }
.hist-empty { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }
.hist-group { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 10px 4px 6px; }
/* Empty-state welcome */
.qa-welcome { margin: auto; max-width: 560px; text-align: center; padding: 10px; }
.qa-welcome h3 { font-family: var(--font-serif); font-weight: 500; font-size: 22px; color: var(--text-primary); margin-bottom: 6px; }
.qa-welcome p { color: var(--text-secondary); font-size: 13.5px; line-height: 1.6; margin-bottom: 16px; }
.qa-welcome .qa-starters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
/* Status / error / actions */
.qa-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.qa-error { color: var(--red); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.qa-actions { display: flex; gap: 6px; margin-top: 6px; }
.qa-act { background: none; border: 1px solid transparent; color: var(--text-muted); font-size: 11px; padding: 3px 8px; border-radius: 5px; cursor: pointer; font-family: var(--font); }
.qa-act:hover { border-color: var(--border); color: var(--text-primary); background: var(--bg-elevated); }
@media (max-width: 1000px) { .qa-layout { grid-template-columns: 1fr; } .side-panel { display: none; } }
.msg { display: flex; gap: 10px; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.msg.user .msg-avatar { background: var(--accent); color: #fff; }
.msg.assistant .msg-avatar { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.msg-bubble { max-width: 82%; padding: 16px 20px; border-radius: 14px; font-size: 14.5px; line-height: 1.75; }
.msg.user .msg-bubble { background: var(--accent); color: #fff; border-radius: 14px 3px 14px 14px; }
.msg.assistant .msg-bubble { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); border-radius: 3px 14px 14px 14px; }
#panel-qa .msg.assistant .msg-bubble h2, #panel-qa .msg.assistant .msg-bubble h3 { font-weight: 500; margin: 16px 0 7px; color: var(--text-primary); letter-spacing: -0.01em; font-family: var(--font-serif); }
.msg.assistant .msg-bubble h2, .msg.assistant .msg-bubble h3 { font-weight: 600; margin: 16px 0 7px; color: var(--text-primary); letter-spacing: -0.01em; }
.msg.assistant .msg-bubble h2 { font-size: 16px; }
.msg.assistant .msg-bubble h3 { font-size: 14.5px; }
.msg.assistant .msg-bubble table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.msg.assistant .msg-bubble thead { background: var(--bg-elevated); }
.msg.assistant .msg-bubble td, .msg.assistant .msg-bubble th { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.msg.assistant .msg-bubble tr:last-child td { border-bottom: none; }
.msg.assistant .msg-bubble th { background: var(--bg-elevated); color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.msg.assistant .msg-bubble tbody tr:hover { background: var(--bg-hover); }
.msg.assistant .msg-bubble code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-base); padding: 2px 6px; border-radius: 4px; color: var(--teal); }
.msg.assistant .msg-bubble ul { margin: 6px 0 6px 20px; }
.msg.assistant .msg-bubble li { padding: 3px 0; line-height: 1.65; }
.msg.assistant .msg-bubble p { margin: 8px 0; }
.msg-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-row textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; line-height: 1.5; box-sizing: border-box; overflow-y: auto; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; color: var(--text-primary); font-size: 13px; font-family: var(--font); outline: none; }
.chat-input-row textarea:focus { border-color: var(--accent); }
.btn-send { background: var(--accent); color: #fff; border: none; border-radius: var(--radius); padding: 10px 18px; height: 40px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s; }
.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; }
.suggestions-panel { padding: 10px; }
.suggestions-panel h4 { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
.suggestion-chip { display: block; width: 100%; text-align: left; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text-secondary); font-size: 12px; cursor: pointer; margin-bottom: 6px; transition: all .12s; font-family: var(--font); }
.suggestion-chip:hover { background: var(--bg-active); color: var(--text-primary); border-color: var(--accent); }
.chip-category { font-size: 10px; color: var(--text-muted); display: block; margin-bottom: 2px; }
.mode-badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; }
.mode-badge.lookup { background: var(--green-dim); color: var(--green); }
.mode-badge.component { background: var(--accent-dim); color: var(--accent); }
.mode-badge.pattern { background: var(--purple-dim); color: var(--purple); }


.composer-hint { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; }
