* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

:root {
    --bg: #020617;
    --panel: #020617;
    --panel-elevated: #0f172a;
    --assistant-surface: #071122;
    --panel-line: #334155;
    --text-primary: #d8edf6;
    --text-secondary: #94a3b8;
    --text-muted: #7889a2;
    --accent: #22c7f3;
    --accent-strong: #0ea5cf;
    --link-color: #7dd3fc;
    --user-bubble: #111827;
    --scrollbar-size: 8px;
    --scrollbar-track: #111827;
    --scrollbar-thumb: #334155;
    --scrollbar-thumb-hover: #475569;

    /* Layout spacing. Overridden at runtime from config.yaml `ui_layout`
       (applyUiLayout in rag_ui.js); keep these defaults in sync with
       UiLayoutMainConfig / UiLayoutPanelConfig in config/runtime_config.py. */
    --layout-main-chat-max-width: 760px;
    --layout-main-content-max-width: 720px;
    --layout-main-chat-top-padding: 82px;
    --layout-main-chat-bottom-padding: 210px;
    --layout-main-hero-title-gap: 48px;
    --layout-main-hero-bottom-margin: 14px;
    --layout-main-composer-bottom: 90px;
    --layout-main-composer-bottom-with-history: 20px;
    --layout-main-examples-gap: 6px;
    --layout-main-footer-bottom: 10px;
    --layout-main-footer-bottom-empty: 32px;
    --layout-panel-width: 735px;
    --layout-panel-section-margin: 20px;
    --layout-panel-section-padding: 20px;
    --layout-panel-usage-padding: 16px;
    --layout-panel-bottom-spacing: 24px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

body.panel-open {
    overflow: hidden !important;
}

body.feature-unlock-open {
    overflow: hidden !important;
}

body.tha-browser-open {
    overflow: hidden !important;
}

body.feedback-modal-open {
    overflow: hidden !important;
}

body.dev-mode-open {
    overflow: hidden !important;
}

body.dev-settings-open {
    overflow: hidden !important;
}

.guidelines-modal,
.info-panel,
.chat-scroll,
.query-input,
.message-body pre,
.tha-browser-list,
.tha-browser-detail,
.feedback-textarea,
.tooltip-bubble--citation-expanded {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.guidelines-modal::-webkit-scrollbar,
.info-panel::-webkit-scrollbar,
.chat-scroll::-webkit-scrollbar,
.query-input::-webkit-scrollbar,
.message-body pre::-webkit-scrollbar,
.tha-browser-list::-webkit-scrollbar,
.tha-browser-detail::-webkit-scrollbar,
.feedback-textarea::-webkit-scrollbar,
.tooltip-bubble--citation-expanded::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

.guidelines-modal::-webkit-scrollbar-track,
.info-panel::-webkit-scrollbar-track,
.chat-scroll::-webkit-scrollbar-track,
.query-input::-webkit-scrollbar-track,
.message-body pre::-webkit-scrollbar-track,
.tha-browser-list::-webkit-scrollbar-track,
.tha-browser-detail::-webkit-scrollbar-track,
.feedback-textarea::-webkit-scrollbar-track,
.tooltip-bubble--citation-expanded::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

.guidelines-modal::-webkit-scrollbar-thumb,
.info-panel::-webkit-scrollbar-thumb,
.chat-scroll::-webkit-scrollbar-thumb,
.query-input::-webkit-scrollbar-thumb,
.message-body pre::-webkit-scrollbar-thumb,
.tha-browser-list::-webkit-scrollbar-thumb,
.tha-browser-detail::-webkit-scrollbar-thumb,
.feedback-textarea::-webkit-scrollbar-thumb,
.tooltip-bubble--citation-expanded::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.guidelines-modal::-webkit-scrollbar-thumb:hover,
.info-panel::-webkit-scrollbar-thumb:hover,
.chat-scroll::-webkit-scrollbar-thumb:hover,
.query-input::-webkit-scrollbar-thumb:hover,
.message-body pre::-webkit-scrollbar-thumb:hover,
.tha-browser-list::-webkit-scrollbar-thumb:hover,
.tha-browser-detail::-webkit-scrollbar-thumb:hover,
.feedback-textarea::-webkit-scrollbar-thumb:hover,
.tooltip-bubble--citation-expanded::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.guidelines-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.guidelines-modal {
    width: min(1144px, calc(100vw - 48px));
    background: var(--panel);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    padding: 24px;
    max-height: min(90vh, 760px);
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.guidelines-modal h2 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1.25rem;
    line-height: 1.35;
}

.guidelines-modal h3 {
    color: var(--text-primary);
    margin: 0 0 8px;
    font-size: 1rem;
    line-height: 1.35;
}

.guidelines-content {
    margin-bottom: 14px;
    line-height: 1.48;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.guidelines-content p {
    margin: 0 0 9px;
}

.guidelines-content ol {
    margin: 0 0 10px;
    padding-left: 1.75rem;
    list-style-position: outside;
}

.guidelines-content li {
    margin-bottom: 7px;
    padding-left: 0.15rem;
}

.guidelines-content li::marker {
    color: var(--text-primary);
    font-weight: 600;
}

.guidelines-content strong {
    color: var(--text-primary);
}

.user-guide-link {
    color: var(--link-color);
    text-decoration: underline;
}

.guidelines-section-break {
    height: 6px;
}

.proceed-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.proceed-btn:hover {
    transform: translateY(-2px);
}

@media (max-height: 760px) {
    .guidelines-modal {
        padding: 20px;
    }
    .guidelines-content {
        font-size: 0.84rem;
        line-height: 1.42;
    }
}

.app-shell {
    position: relative;
    min-height: 100vh;
    height: 100vh;
    background: var(--bg);
    overflow: hidden;
}

.app-topbar {
    position: absolute;
    top: 16px;
    left: 20px;
    right: 20px;
    height: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: none;
    background: transparent;
    z-index: 25;
    pointer-events: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    pointer-events: auto;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.brand-logo {
    height: 34px;
    width: auto;
    opacity: 0.92;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.brand-kicker {
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.brand-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.current-db-indicator {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.app-shell.db-indicator-hidden .current-db-indicator {
    opacity: 0;
    pointer-events: none;
}

.current-db-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.browse-database-btn {
    padding: 3px 8px;
    border: 1px solid rgba(34, 199, 243, 0.4);
    border-radius: 6px;
    background: rgba(34, 199, 243, 0.1);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.browse-database-btn:hover,
.browse-database-btn:focus-visible {
    border-color: var(--accent);
    color: var(--text-primary);
}

.current-db-prefix {
    font-size: 15px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.current-db-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 320px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
}

.topbar-action-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.icon-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(34, 199, 243, 0.08);
}

.icon-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.icon-button.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(34, 199, 243, 0.12);
}

#newChatButton {
    font-size: 30px;
    line-height: 1;
    font-weight: 500;
}

.hamburger-lines,
.hamburger-lines::before,
.hamburger-lines::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    content: "";
}

.hamburger-lines {
    position: relative;
}

.hamburger-lines::before {
    position: absolute;
    top: -6px;
    left: 0;
}

.hamburger-lines::after {
    position: absolute;
    top: 6px;
    left: 0;
}

.topbar-action-label {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    color: var(--text-secondary);
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 1.2;
    text-transform: uppercase;
    transition: opacity 0.16s ease;
    white-space: nowrap;
}

.topbar-action-control:hover .topbar-action-label,
.topbar-action-control:focus-within .topbar-action-label {
    opacity: 1;
}

/* The Help link sits alone in the bottom-right corner, so its label opens upward. */
.help-action-control {
    position: absolute;
    right: 20px;
    bottom: 20px;
    z-index: 19;
}

.help-action-control .icon-button {
    font-size: 20px;
    font-weight: 600;
    text-decoration: none;
}

.help-action-control .topbar-action-label {
    top: auto;
    bottom: calc(100% + 8px);
    /* One word per line: "User" over "Guide". */
    width: min-content;
    white-space: normal;
}

.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.68);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 30;
}

.panel-open .panel-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.info-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--layout-panel-width), calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    overflow-y: auto;
    z-index: 40;
}

/* Wraps everything above the usage footer so section margins keep collapsing
   (they wouldn't as direct children of the flex .info-panel). */
.info-panel-content {
    flex: 1 0 auto;
}

.panel-open .info-panel {
    transform: translateX(0);
}

.info-panel-header {
    padding: 24px 24px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.info-panel-title {
    display: flex;
    gap: 14px;
    align-items: center;
}

.info-panel-title img {
    height: 44px;
    width: auto;
}

.info-panel-copy h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.info-panel-copy p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.panel-section {
    margin: var(--layout-panel-section-margin);
    padding: var(--layout-panel-section-padding);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.52;
}

.panel-section h2 {
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 14px;
}

.panel-section p {
    margin-bottom: 9px;
}

.panel-section ol {
    padding-left: 18px;
    margin: 9px 0;
}

.panel-section li {
    margin: 5px 0;
}

.panel-section strong {
    color: var(--text-primary);
}

.changelog-date {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 6px;
}

.chat-main {
    position: relative;
    height: 100vh;
    background: var(--bg);
}

.chat-scroll {
    height: 100%;
    overflow-y: auto;
    padding: var(--layout-main-chat-top-padding) 20px var(--layout-main-chat-bottom-padding);
}

.chat-content {
    width: min(var(--layout-main-chat-max-width), 100%);
    margin: 0 auto;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-bottom: 20px;
}

.app-shell.is-empty .chat-content {
    justify-content: center;
    padding-bottom: 0;
}

/* Docked above the footer note. --empty-composer-bottom is measured by
   syncEmptyComposerLayout (rag_ui.js) so the gap under the text box equals the
   gap under the footer note; the fallback assumes a one-line note. */
.app-shell.is-empty .composer-shell {
    position: absolute;
    left: 50%;
    bottom: var(--empty-composer-bottom, calc(2 * var(--layout-main-footer-bottom-empty) - 6px));
    transform: translateX(-50%);
    width: min(var(--layout-main-content-max-width), calc(100% - 28px));
    margin: 0;
    padding: 0;
}

.app-shell.is-empty .footer-note {
    position: absolute;
    left: 50%;
    bottom: var(--layout-main-footer-bottom-empty);
    transform: translateX(-50%);
    width: min(var(--layout-main-content-max-width), calc(100% - 28px));
    margin: 0;
}

.hero-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: clamp(8px, 3vh, 32px);
    margin-bottom: var(--layout-main-hero-bottom-margin);
}

.app-title-block {
    margin-bottom: var(--layout-main-hero-title-gap);
}

.app-title {
    color: var(--text-primary);
    font-size: clamp(48px, 7.2vw, 44px);
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.app-acronym {
    max-width: 560px;
    color: rgba(217, 242, 252, 0.8);
    font-size: 11px;
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 6px;
}

.topbar-action-control[hidden] {
    display: none !important;
}

.message-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0 8px;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant,
.message-row.status {
    justify-content: flex-start;
}

.user-bubble {
    max-width: min(72%, 560px);
    background: var(--user-bubble);
    border: 1px solid rgba(148, 163, 184, 0.34);
    border-radius: 16px;
    padding: 11px 14px;
    color: #e5f4fb;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.24);
}

.assistant-card {
    width: min(100%, 740px);
}

/* User rows stack the bubble above its copy action, both right-aligned. */
.message-row.user {
    flex-direction: column;
    align-items: flex-end;
}

.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.message-row.user .message-actions {
    justify-content: flex-end;
}

.copy-message-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 7px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.7;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.copy-message-btn:hover,
.copy-message-btn:focus-visible {
    opacity: 1;
    border-color: rgba(148, 163, 184, 0.45);
    color: var(--text-primary);
    background: rgba(34, 199, 243, 0.08);
}

.copy-message-btn.is-copied {
    opacity: 1;
    color: var(--accent);
}

.generate-summary-btn {
    min-height: 32px;
    margin-top: 12px;
    padding: 6px 10px;
    border: 1px solid rgba(34, 199, 243, 0.45);
    border-radius: 7px;
    background: rgba(34, 199, 243, 0.1);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.pending-turn-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.pending-turn-actions button {
    min-height: 28px;
    padding: 4px 9px;
    border: 1px solid var(--panel-line);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    cursor: pointer;
}

.assistant-card.error .message-body {
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.message-body {
    background: var(--assistant-surface);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 18px;
    padding: 16px 18px;
    font-size: 13px;
    line-height: 1.52;
    color: var(--text-primary);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.18);
}

.status-text {
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.4;
    padding: 4px 2px;
}

.status-text.loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.tool-transparency .status-text {
    font-size: 12px;
    font-style: italic;
    opacity: 0.75;
    padding: 2px 2px;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
    margin-top: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.message-body h1 { font-size: 1.32em; }
.message-body h2 { font-size: 1.18em; }
.message-body h3 { font-size: 1.08em; }
.message-body p { margin: 8px 0; }

.message-body ul,
.message-body ol {
    margin: 8px 0;
    padding-left: 18px;
}

.message-body li {
    margin: 4px 0;
}

.message-body blockquote {
    margin: 10px 0;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.95);
    border-left: 3px solid rgba(125, 211, 252, 0.8);
    border-radius: 10px;
    color: #cbd5e1;
}

.message-body code {
    background: rgba(15, 23, 42, 0.92);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #dbeafe;
}

.message-body pre {
    background: rgba(15, 23, 42, 0.96);
    color: #e2e8f0;
    padding: 12px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-body pre code {
    background: none;
    padding: 0;
}

.message-body strong {
    color: #f8fafc;
}

.message-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.message-body th,
.message-body td {
    border: 1px solid rgba(148, 163, 184, 0.24);
    padding: 7px 10px;
    text-align: left;
}

.message-body th {
    background: rgba(15, 23, 42, 0.95);
    font-weight: 600;
}

.message-body a,
.citation-link {
    color: var(--link-color);
    text-decoration: none;
}

.message-body a:hover,
.citation-link:hover {
    text-decoration: underline;
}

.download-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(8px);
    max-width: min(90vw, 420px);
    padding: 10px 16px;
    border-radius: 8px;
    background: var(--panel-elevated);
    border: 1px solid var(--panel-line);
    color: #fca5a5;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.download-toast.is-success {
    color: #86efac;
}

.download-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* SETP launch outcome: sits above the guidelines overlay (1000) and other modals (<=1200). */
.setp-splash-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1300;
}

.setp-splash {
    position: relative;
    width: clamp(300px, 33vw, 640px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px 32px 28px;
    background: var(--panel);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.setp-splash-body {
    display: flex;
    align-items: stretch;
    gap: 16px;
}

.setp-splash-logo-col {
    display: flex;
    flex: 0 0 auto;
    width: 35%;
}

/* Fills its column's width, capped to the title+subtitle column's height so it never overflows either axis. */
.setp-splash-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.92;
}

.setp-splash-text-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    text-align: left;
}

.setp-splash h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    line-height: 1.35;
}

.setp-splash p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.setp-splash-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.setp-splash-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
}

.setp-splash-close:hover {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.12);
}

.setp-splash-close:focus-visible {
    outline: 2px solid var(--text-primary);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .setp-splash {
        width: calc(100vw - 32px);
    }

    .setp-splash-body {
        flex-direction: column;
        text-align: center;
    }

    .setp-splash-logo-col {
        width: 100%;
    }

    .setp-splash-logo {
        height: auto;
        width: 100%;
    }

    .setp-splash-text-col {
        text-align: center;
    }
}

.citations-section {
    margin-top: 8px;
    padding-top: 0;
}

.citations-group + .citations-group {
    margin-top: 12px;
}

.citations-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.92em;
}

.citations-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.citations-toggle-all {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.92em;
    font-weight: 400;
    text-decoration: underline;
}

.citations-toggle-all:hover {
    color: var(--accent);
}

.citations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation-item {
    font-size: 0.86em;
    color: var(--text-secondary);
    line-height: 1.5;
    /* Inherited by the row's title and its excerpts: extracted PDF text carries runs
       with no break opportunity (URLs, DOIs, numeric tables, and words run together
       where extraction dropped the spaces). Without this they paint straight past the
       answer bubble and give the whole page a horizontal scrollbar. */
    overflow-wrap: anywhere;
}

.inline-citation {
    color: var(--link-color);
    font-weight: 600;
    font-size: 0.82em;
}

.citation-ref {
    cursor: pointer;
    appearance: none;
    background: transparent;
    border: 0;
    border-bottom: 1px dotted currentColor;
    color: inherit;
    font: inherit;
    padding: 0 1px;
    position: relative;
}

/* Enlarges the click target beyond the small superscript digit. */
.citation-ref::after {
    content: "";
    position: absolute;
    inset: -6px -2px;
}

.citation-ref:hover,
.citation-ref.is-active {
    color: var(--accent);
}

.citation-ref.is-pinned {
    color: var(--accent-strong);
    background: rgba(34, 199, 243, 0.16);
    border-bottom-style: solid;
    border-radius: 3px;
}

.citation-meta {
    color: var(--text-muted);
    font-size: 0.84em;
}

.citation-source-title {
    color: var(--text-primary);
    font-weight: 600;
}

.citation-source-heading {
    display: block;
}

.citation-source-details {
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
}

.citation-download-icon {
    display: inline-flex;
    vertical-align: -0.125em;
    margin-left: 4px;
    transition: color 0.15s ease;
}

.citation-download-icon svg {
    width: 1em;
    height: 1em;
}

.citation-download-icon:hover {
    color: var(--accent);
}

.tooltip-citation-actions {
    display: flex;
    gap: 12px;
}

.tooltip-citation-actions a {
    color: var(--link-color);
    font-weight: 600;
}

.tooltip-citation-actions {
    margin-top: 6px;
}

.other-sources-disclosure > .other-sources-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0;
}

.other-sources-disclosure > .other-sources-summary::-webkit-details-marker {
    display: none;
}

.other-sources-disclosure:not([open]) > .other-sources-summary {
    margin-bottom: 0;
}

.citation-summary {
    cursor: pointer;
    list-style: none;
}

.citation-summary .citation-source-details {
    margin-top: 1px;
}

.citation-sections-label {
    color: var(--text-muted);
    font-size: 0.92em;
    transition: color 0.15s ease;
}

.citation-source-details + .citation-sections-label {
    margin-left: 6px;
}

.citation-summary::-webkit-details-marker {
    display: none;
}

.citation-caret {
    display: inline-block;
    position: relative;
    width: 14px;
    height: 14px;
    margin-left: 5px;
    vertical-align: middle;
    color: var(--text-secondary);
    transition: transform 150ms ease, color 0.15s ease;
}

/* A square with two borders, rotated into a chevron. The extra -85% lifts the
   "V" so its ink -- not its bounding box -- sits on the caret's centre line. */
.citation-caret::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    border-bottom-right-radius: 1px;
    transform: translate(-50%, -85%) rotate(45deg);
}

summary:hover > .citation-sections-label,
summary:hover > .citation-caret {
    color: var(--accent);
}

details[open] > summary .citation-caret {
    transform: rotate(180deg);
}

.citation-sections {
    margin: 7px 0 5px 2px;
    padding-left: 10px;
    border-left: 1px solid rgba(148, 163, 184, 0.22);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.citation-excerpt {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.citation-excerpt-page {
    font-weight: 600;
}

.composer-shell {
    position: absolute;
    left: 50%;
    bottom: var(--layout-main-composer-bottom);
    transform: translateX(-50%);
    width: min(var(--layout-main-content-max-width), calc(100% - 28px));
    margin: 0;
    padding: 0;
    z-index: 20;
}

.conversation-context {
    margin: 0 10px 7px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.conversation-context[hidden] {
    display: none;
}

.composer-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.composer-surface {
    position: relative;
    flex: 1;
    background: var(--panel-elevated);
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 22px;
    padding: 10px 56px 8px 14px;
    box-shadow: 0 16px 36px rgba(2, 6, 23, 0.42);
}

.query-input {
    /* Resting height; rag_ui.js autosizeQueryInput() grows it with the text up to 1.5x. */
    --query-input-base: 44.64px;
    width: 100%;
    height: var(--query-input-base);
    max-height: calc(var(--query-input-base) * 1.5);
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.app-shell.has-history .query-input {
    --query-input-base: 33px;
}

.query-input::placeholder {
    color: var(--text-muted);
}

.composer-footer {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.composer-help {
    color: var(--text-muted);
    font-size: 12px;
}

.query-character-count {
    min-height: 16px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: right;
    margin-top: 3px;
}

/* Docked empty screen: an empty counter must not use up the gap above the footer note. */
.app-shell.is-empty .query-character-count:empty {
    min-height: 0;
    margin-top: 0;
}

.query-character-count.is-over-limit {
    color: #fca5a5;
}

.composer-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.settings-popup-wrap {
    position: absolute;
    right: 8px;
    bottom: 8px;
    flex-shrink: 0;
}

.settings-popup-btn {
    width: 38px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.42);
    color: var(--text-secondary);
    font: inherit;
    font-size: 16px;
    font-weight: 400;
    line-height: 1;
    padding: 2px 10px 4px;
    text-align: center;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.settings-popup-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.12);
}

.settings-popup-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.settings-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #0d1a2b;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 248px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
    z-index: 500;
}

.settings-popup[hidden] {
    display: none;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-section[hidden] {
    display: none;
}

.settings-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.settings-section.is-inactive .settings-section-label {
    opacity: 0.55;
}

.settings-section.is-inactive .settings-option-group {
    opacity: 0.55;
}

.settings-option-group {
    display: grid;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.42);
    width: 100%;
}

.settings-option-group--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-option-group--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-option-btn {
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    min-height: 32px;
    padding: 5px 7px;
    white-space: nowrap;
    width: 100%;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.settings-option-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: rgba(148, 163, 184, 0.12);
}

.settings-option-btn.is-active {
    color: #022c3a;
    background: var(--accent);
}

.settings-option-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.settings-option-btn.is-unavailable {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.08);
    cursor: not-allowed;
    opacity: 0.65;
}

/* ── Info-icon tooltips ─────────────────────────────────── */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    margin-left: 5px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    font-style: italic;
    line-height: 1;
    cursor: help;
    flex-shrink: 0;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.info-icon:hover,
.info-icon.is-active {
    color: var(--accent);
    border-color: var(--accent);
}

.info-icon:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.tooltip-bubble {
    position: fixed;
    z-index: 2000;
    max-width: 260px;
    padding: 8px 10px;
    background: #0d1a2b;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-line;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.tooltip-bubble[hidden] {
    display: none;
}

.tooltip-bubble--coachmark {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 280px;
}

/* Width is set inline to 70% of the text box (showTooltip in rag_ui.js). */
.tooltip-bubble--examples {
    box-sizing: border-box;
    max-width: none;
    white-space: normal;
}

.tooltip-example + .tooltip-example {
    margin-top: 0.7em;
}

.tooltip-bubble--citation-expanded {
    max-width: 380px;
    max-height: 260px;
    overflow-y: auto;
}

.tooltip-citation-title {
    font-weight: 700;
    color: var(--text-primary);
}

.tooltip-citation-meta {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.tooltip-citation-divider {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    margin: 6px 0;
}

.tooltip-citation-excerpt {
    margin-top: 8px;
    overflow-wrap: anywhere;
}

.tooltip-bubble-next-btn {
    align-self: flex-end;
    border: 1px solid rgba(34, 199, 243, 0.35);
    border-radius: 6px;
    background: var(--accent);
    color: #022c3a;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
}

.submit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid rgba(34, 199, 243, 0.35);
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #022c3a;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.submit-btn.is-stop {
    border-color: rgba(248, 113, 113, 0.45);
    background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
    color: #fff1f2;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.backend-status-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    min-height: 1.1em;
    margin-top: 5.2px;
    width: 100%;
}

.backend-status-msg:empty {
    min-height: 0;
    margin-top: 0;
}

.usage-panel {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: var(--layout-panel-usage-padding);
    background: var(--panel);
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    z-index: 1;
    color: var(--text-muted);
    font-size: 12px;
}

.usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

#usagePercentText {
    color: var(--text-secondary);
    font-weight: 600;
}

.usage-track {
    height: 5px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
}

.usage-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--accent);
    transition: width 0.2s ease, background 0.2s ease;
}

.usage-fill.is-blocked {
    background: #f87171;
}

.usage-token-text {
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.usage-technical-details {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.usage-technical-details summary {
    cursor: pointer;
}

.usage-budget-notice {
    margin-top: 6px;
    color: #fbbf24;
    overflow-wrap: anywhere;
}

.examples-hint {
    margin-top: var(--layout-main-examples-gap);
    padding-left: 4px;
}

.examples-hint[hidden] {
    display: none;
}

.examples-trigger {
    background: transparent;
    border: none;
    border-bottom: 1px dotted rgba(148, 163, 184, 0.5);
    padding: 0;
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
    cursor: help;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.examples-trigger:hover,
.examples-trigger.is-pinned,
.examples-trigger:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}

.examples-trigger:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.footer-note {
    position: absolute;
    left: 50%;
    bottom: var(--layout-main-footer-bottom);
    transform: translateX(-50%);
    width: min(var(--layout-main-content-max-width), calc(100% - 28px));
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 0;
    z-index: 18;
}

.app-shell.has-history .footer-note {
    display: none;
}

.app-shell.has-history .composer-shell {
    bottom: var(--layout-main-composer-bottom-with-history);
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(148, 163, 184, 0.28);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.95s linear infinite;
    flex-shrink: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Config preset selector --- */
.preset-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    pointer-events: auto;
}

.preset-selector[hidden] {
    display: none;
}

.preset-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
    line-height: 1.2;
}

.preset-btn:hover {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.07);
}

.preset-btn.is-active {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.12);
    color: var(--accent);
}

.preset-btn-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.preset-btn-params {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 400;
}

.preset-btn.is-active .preset-btn-params {
    color: var(--accent);
    opacity: 0.75;
}

@media (max-width: 900px) {
    .preset-btn-params { display: none; }
    .preset-btn { padding: 4px 8px; }
}

@media (max-width: 640px) {
    .preset-selector { display: none; }
    .composer-footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
    .usage-header,
    .usage-token-text {
        white-space: normal;
    }
}

/* --- Change database button --- */
.change-db-btn {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.38);
    background: var(--panel-elevated);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.18s ease, background-color 0.18s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.change-db-btn:hover {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.07);
}

/* --- Database modal --- */
.database-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1100;
}

.database-modal[hidden] {
    display: none;
}

.database-modal-panel {
    width: min(680px, calc(100vw - 32px));
    padding: 24px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: #020617;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.database-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.database-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.database-card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
}

.database-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    width: 150px;
    height: 112px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--panel-elevated);
    color: var(--text-primary);
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.database-card:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.09);
    border-color: var(--accent);
}

.database-card.is-selected {
    background: rgba(34, 199, 243, 0.08);
    border-color: var(--accent);
}

.database-card.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.database-card:disabled {
    pointer-events: none;
}

.database-card[hidden] {
    display: none;
}

.database-card-check {
    position: absolute;
    top: 10px;
    right: 12px;
    color: var(--accent);
    font-size: 13px;
}

.database-card-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-align: center;
}

.database-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
    text-align: center;
}

.database-card-badge {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 6px;
    padding: 1px 5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.database-card-badge[hidden] {
    display: none;
}

.feature-unlock-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1100;
}

.feature-unlock-modal[hidden] {
    display: none;
}

.feature-unlock-panel {
    width: min(360px, calc(100vw - 32px));
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(2, 6, 23, 0.96);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.feature-unlock-panel h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.feature-unlock-copy {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.feature-unlock-form {
    margin-top: 14px;
}

.feature-unlock-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    padding: 12px 14px;
    outline: none;
}

.feature-unlock-input:focus {
    border-color: var(--accent);
}

.feature-unlock-message {
    min-height: 18px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 12px;
}

.feature-unlock-message.is-error {
    color: #fca5a5;
}

.feature-unlock-message.is-success {
    color: #86efac;
}

/* ── Feedback Modal ──────────────────────────────────────── */
.feedback-modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1100;
}

.feedback-modal[hidden] {
    display: none;
}

.feedback-panel {
    width: min(420px, calc(100vw - 32px));
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(2, 6, 23, 0.97);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.feedback-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.feedback-panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.feedback-copy {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.feedback-rating {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.feedback-thumb {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.feedback-thumb:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(34, 199, 243, 0.08);
}

.feedback-thumb.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(34, 199, 243, 0.12);
}

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feedback-label {
    font-size: 12px;
    color: var(--text-muted);
}

.feedback-textarea {
    width: 100%;
    min-height: 110px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    background: var(--panel-elevated);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    padding: 12px 14px;
    outline: none;
    resize: vertical;
    line-height: 1.5;
    box-sizing: border-box;
}

.feedback-textarea:focus {
    border-color: var(--accent);
}

.feedback-history-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.feedback-history-checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.feedback-message {
    min-height: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.feedback-message.is-error {
    color: #fca5a5;
}

.feedback-message.is-success {
    color: #86efac;
}

.feedback-submit-btn {
    align-self: flex-end;
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid rgba(34, 199, 243, 0.35);
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #022c3a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

.feedback-submit-btn:hover:not(:disabled) {
    filter: brightness(1.05);
}

.feedback-submit-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Export modal reuses the .feedback-modal / .feedback-panel shell. */
.export-form .feedback-history-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.export-note {
    margin: -4px 0 0 22px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}

.export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.export-cancel-btn {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid var(--panel-line);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
}

.export-cancel-btn:hover {
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.6);
}

.tha-browser-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(0, 0, 0, 0.68);
}

.tha-browser-overlay[hidden] {
    display: none;
}

.tha-browser-window {
    width: min(1180px, calc(100vw - 56px));
    height: min(780px, calc(100vh - 56px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.tha-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--panel-elevated);
}

.tha-browser-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
    color: var(--text-primary);
}

.tha-browser-header p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.tha-browser-status {
    min-height: 0;
    padding: 0 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.tha-browser-status:not(:empty) {
    padding-top: 12px;
}

.tha-browser-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(210px, 24%) 1fr;
}

.tha-browser-list-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--bg);
}

.tha-browser-search-wrap {
    padding: 12px 12px 8px 12px;
}

.tha-browser-search-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.22);
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.2;
    padding: 9px 10px;
}

.tha-browser-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(34, 199, 243, 0.16);
}

.tha-browser-list {
    overflow-y: auto;
    padding: 4px 12px 12px 12px;
}

.tha-browser-list-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    padding: 10px 11px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.tha-browser-list-item:hover,
.tha-browser-list-item.is-selected {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.1);
}

.tha-browser-list-title {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.tha-browser-list-file {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: none;
}

.tha-browser-detail {
    min-width: 0;
    overflow-y: auto;
    padding: 16px 18px;
    background: var(--panel);
}

.tha-browser-detail .tha-card {
    width: 100%;
}

.tha-highlight {
    background: rgba(251, 191, 36, 0.38);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.doc-browser-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(0, 0, 0, 0.68);
}

.doc-browser-overlay[hidden] {
    display: none;
}

.doc-browser-window {
    width: min(1180px, calc(100vw - 56px));
    height: min(780px, calc(100vh - 56px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.doc-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--panel-elevated);
}

.doc-browser-header h2 {
    margin: 0 0 4px;
    font-size: 18px;
    color: var(--text-primary);
}

.doc-browser-header p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.doc-browser-status {
    min-height: 0;
    padding: 0 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.doc-browser-status:not(:empty) {
    padding-top: 12px;
}

.doc-browser-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(210px, 24%) 1fr;
}

.doc-browser-list-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--bg);
}

.doc-browser-search-wrap {
    padding: 12px 12px 8px 12px;
}

.doc-browser-search-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.22);
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1.2;
    padding: 9px 10px;
}

.doc-browser-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(34, 199, 243, 0.16);
}

.doc-browser-list {
    overflow-y: auto;
    padding: 4px 12px 12px 12px;
}

.doc-browser-list-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    padding: 10px 11px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.doc-browser-list-item:hover,
.doc-browser-list-item.is-selected {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.1);
}

.doc-browser-list-title {
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}

.doc-browser-detail {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel);
}

.doc-browser-detail-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--panel-line);
    color: var(--text-secondary);
    font-size: 13px;
}

.doc-browser-detail-actions a {
    color: var(--link-color);
    font-weight: 600;
}

.doc-browser-iframe {
    width: 100%;
    flex: 1;
    height: 100%;
    border: 0;
}

.doc-browser-placeholder-text {
    margin: 16px 18px;
    color: var(--text-muted);
    font-size: 13px;
}

@media (max-width: 640px) {
    .change-db-btn { padding: 0 9px; font-size: 12px; }
    .current-db-label { max-width: 90px; }
    .database-modal-panel { padding: 18px; }
    .database-card { width: 100%; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 900px) {
    .app-topbar {
        top: 14px;
        left: 16px;
        right: 16px;
    }
    .topbar-left { gap: 10px; }
    .brand-copy { display: none; }
    .current-db-label { max-width: 140px; }
    .chat-scroll { padding: 72px 16px 198px; }
    .composer-shell { width: calc(100% - 32px); }
    .submit-btn {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }
    .message-body,
    .user-bubble { max-width: 100%; }
    .footer-note {
        width: calc(100% - 32px);
    }
    .app-shell.is-empty .composer-shell,
    .app-shell.is-empty .footer-note {
        width: calc(100% - 32px);
    }
}

@media (max-width: 640px) {
    .hero-block { margin-top: 14px; }
    .app-title-block { margin-bottom: 12px; }
    .app-title { font-size: 32px; }
    .app-acronym { font-size: 10px; }
    .topbar-actions { gap: 10px; }
    .info-panel { width: calc(100vw - 20px); }
    .panel-section,
    .info-panel-header { margin: 14px; }
    .chat-scroll {
        padding: 68px 12px 188px;
    }
    .composer-surface {
        border-radius: 20px;
        padding: 9px 48px 7px 12px;
    }
    .query-input {
        min-height: 46px;
        font-size: 13px;
    }
    .app-shell.has-history .query-input {
        min-height: 23px;
    }
    .composer-shell {
        width: calc(100% - 20px);
        bottom: 86px;
    }
    .footer-note {
        width: calc(100% - 20px);
        font-size: 11px;
        bottom: 8px;
    }
    .app-shell.has-history .composer-shell {
        bottom: 74px;
    }
    .app-shell.is-empty .composer-shell,
    .app-shell.is-empty .footer-note {
        width: calc(100% - 20px);
    }
}

/* ── Dev Mode Diagnostics ───────────────────────────────── */
.dev-mode-toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1150;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    cursor: pointer;
}

.dev-mode-toggle:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.dev-mode-toggle[hidden] {
    display: none;
}

.dev-mode-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 6, 23, 0.78);
}

.dev-mode-overlay[hidden] {
    display: none;
}

.dev-mode-window {
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.dev-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    background: var(--panel-elevated);
}

.dev-mode-header h2 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.dev-mode-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dev-mode-refresh-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.dev-mode-refresh-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.dev-mode-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.dev-mode-content::-webkit-scrollbar {
    width: var(--scrollbar-size);
}

.dev-mode-content::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

.dev-mode-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.dev-mode-section {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.72);
}

.dev-mode-section h3 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.dev-mode-kv {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    font-size: 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.dev-mode-kv:last-child {
    border-bottom: none;
}

.dev-mode-key {
    color: var(--text-muted);
}

.dev-mode-value {
    color: var(--text-primary);
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    text-align: right;
    word-break: break-all;
}

.dev-mode-log-note {
    margin: 0 0 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.dev-mode-log {
    max-height: 320px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: var(--bg);
    padding: 8px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.dev-mode-log::-webkit-scrollbar {
    width: var(--scrollbar-size);
}

.dev-mode-log::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 999px;
}

.dev-mode-log::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.dev-mode-log-line {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

.dev-mode-status-message {
    margin: 0;
    padding: 12px 0;
    font-size: 13px;
    color: var(--text-muted);
}

.dev-mode-error {
    color: #fca5a5;
}

/* ── Dev Settings (manual retrieval/LLM overrides) ─────── */
.dev-settings-context {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.72);
    color: var(--text-secondary);
    font-size: 12px;
}

.dev-settings-master-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.dev-settings-master-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.dev-settings-hint {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.dev-settings-field {
    margin-bottom: 10px;
}

.dev-settings-field:last-child {
    margin-bottom: 0;
}

.dev-settings-field-label {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
}

.dev-settings-input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
}

.dev-settings-input:focus {
    border-color: var(--accent);
}

.dev-settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.dev-settings-message {
    min-height: 16px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 12px;
}

.dev-settings-message.is-error {
    color: #fca5a5;
}

.dev-settings-message.is-success {
    color: #86efac;
}

/* ── Mobile Overlay ─────────────────────────────────────── */
.mobile-overlay {
    display: none;
}

.panel-support-note {
    margin: 0 var(--layout-panel-section-margin) 8px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.panel-unlock-btn {
    display: block;
    width: calc(100% - 2 * var(--layout-panel-section-margin));
    margin: 4px var(--layout-panel-section-margin) var(--layout-panel-bottom-spacing);
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.panel-unlock-btn:hover {
    color: var(--text-secondary);
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.5);
}

.history-control-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.history-control-actions button {
    min-height: 32px;
    padding: 6px 10px;
    border: 1px solid var(--panel-line);
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.history-control-actions button:hover {
    color: var(--accent);
    border-color: var(--accent);
}

@media (max-width: 640px) {
    .mobile-overlay {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        inset: 0;
        background: var(--bg);
        z-index: 9999;
        padding: 32px;
        text-align: center;
        color: var(--text-primary);
        font-size: 15px;
        line-height: 1.6;
    }
    .app-shell {
        display: none;
    }
}

/* ── THA Cards ─────────────────────────────────────────── */
.tha-results-summary {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.tha-tier-heading {
    color: var(--text-primary);
    font-weight: 600;
}

.tha-card + .tha-tier-heading {
    margin-top: 1.25rem;
}

.tha-top-summary {
    margin-bottom: 0.65rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 6px;
    background: rgba(148, 163, 184, 0.08);
    color: var(--text-primary);
    font-size: 0.86rem;
    line-height: 1.45;
}

.tha-cards-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.tha-card {
    border: 1px solid var(--text-muted);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.tha-card:hover {
    border-color: var(--accent);
}

.tha-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    background: var(--panel-elevated);
}

.tha-card-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 0.75rem;
}

.tha-variant-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.35rem;
    margin-right: 0.45rem;
    flex-shrink: 0;
}

.tha-variant-nav-btn {
    border: 1px solid var(--text-muted);
    background: var(--assistant-surface);
    color: var(--text-primary);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.tha-variant-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.tha-variant-index {
    font-size: 0.75rem;
    color: var(--text-secondary);
    min-width: 2.4rem;
    text-align: center;
}

.tha-card-arrow {
    font-size: 1.25rem;
    line-height: 1;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.tha-card.is-expanded .tha-card-arrow {
    transform: rotate(180deg);
}

.tha-card-body {
    display: none;
    padding: 0.75rem 1rem;
    background: var(--assistant-surface);
    border-top: 1px solid var(--text-muted);
}

.tha-card.is-expanded .tha-card-body {
    display: block;
}

.tha-placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    margin: 0 0 0.75rem 0;
    font-size: 0.85rem;
}

.tha-card-source {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.tha-card-source a {
    color: var(--link-color);
    text-decoration: underline;
}

.tha-card-why {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--panel-elevated);
    border-left: 3px solid var(--accent);
    font-size: 0.85rem;
    color: var(--text-primary);
    border-radius: 0 4px 4px 0;
}

.tha-why-label {
    font-weight: 700;
    color: var(--accent);
}

.tha-no-results {
    color: var(--text-muted);
    font-style: italic;
}

.tha-risk-badge {
    flex-shrink: 0;
    margin-right: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
}

.tha-risk-high {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.tha-field {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.tha-field-label {
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.35rem;
}

.tha-pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.85rem;
    margin: 0.35rem 0 0;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border-radius: 4px;
    color: var(--text-primary);
    line-height: 1.5;
}

.tha-field-secondary {
    opacity: 0.75;
}

.message-body .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    margin: 0.75em 0;
}
