* {
    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: #65768f;
    --accent: #22c7f3;
    --accent-strong: #0ea5cf;
    --link-color: #7dd3fc;
    --user-bubble: #111827;
    --scrollbar-size: 8px;
    --scrollbar-track: #111827;
    --scrollbar-thumb: #334155;
    --scrollbar-thumb-hover: #475569;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
}

body.panel-open {
    overflow: hidden !important;
}

body.feature-unlock-open {
    overflow: hidden !important;
}

.guidelines-modal,
.info-panel,
.chat-scroll,
.query-input,
.message-body pre,
.retrieved-chunks-list {
    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,
.retrieved-chunks-list::-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,
.retrieved-chunks-list::-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,
.retrieved-chunks-list::-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,
.retrieved-chunks-list::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.guidelines-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

.guidelines-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 880px;
    max-height: min(80vh, 720px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.guidelines-modal h2 {
    color: #1e293b;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.guidelines-content {
    margin-bottom: 25px;
    line-height: 1.8;
    color: #334155;
}

.agreement-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 10px;
}

.agreement-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.agreement-checkbox label {
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
}

.proceed-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.proceed-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.proceed-btn:not(:disabled):hover {
    transform: translateY(-2px);
}

.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;
}

.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);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: auto;
}

.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;
}

.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;
}

.new-chat-control {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.new-chat-label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.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(420px, calc(100vw - 32px));
    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;
    padding-bottom: 40px;
}

.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: 20px;
    padding: 20px;
    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);
}

.chat-main {
    position: relative;
    height: 100vh;
    background: var(--bg);
}

.chat-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 82px 20px 210px;
}

.chat-content {
    width: min(760px, 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: 120px;
}

.app-shell.is-empty .composer-shell {
    position: absolute;
    left: 50%;
    top: calc(50% + 26px);
    bottom: auto;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    margin: 0;
    padding: 0;
}

.app-shell.is-empty .examples-block {
    position: absolute;
    left: 50%;
    top: calc(50% + 130px);
    bottom: auto;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    margin: 0;
}

.app-shell.is-empty .footer-note {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    margin: 0;
}

.hero-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: clamp(20px, 6vh, 64px);
    margin-bottom: 14px;
}

.hero-title {
    color: var(--text-primary);
    font-size: clamp(18px, 3.6vw, 22px);
    line-height: 1.05;
    font-weight: 600;
    margin-bottom: 10px;
}

.hero-description {
    max-width: 500px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.4;
}

.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);
}

.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;
}

.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,
.retrieved-card-link {
    color: var(--link-color);
    text-decoration: none;
}

.message-body a:hover,
.citation-link:hover,
.retrieved-card-link:hover {
    text-decoration: underline;
}

.citations-section {
    margin-top: 16px;
    padding-top: 10px;
}

.citations-divider {
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    margin: 0 0 14px;
}

.citations-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.92em;
}

.citations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation-item {
    font-size: 0.86em;
    color: var(--text-secondary);
    line-height: 1.5;
}

.inline-citation {
    color: var(--link-color);
    font-weight: 600;
    font-size: 0.82em;
}

.citation-meta {
    color: var(--text-muted);
    font-size: 0.84em;
}

.retrieved-disclosure {
    margin-top: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.62);
    overflow: hidden;
}

.retrieved-disclosure summary {
    cursor: pointer;
    list-style: none;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.retrieved-disclosure summary::-webkit-details-marker {
    display: none;
}

.retrieved-disclosure summary::after {
    content: "+";
    color: var(--text-secondary);
    font-size: 22px;
    line-height: 1;
}

.retrieved-disclosure[open] summary::after {
    content: "-";
}

.retrieved-disclosure-count {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.retrieved-chunks-list {
    max-height: 420px;
    overflow-y: auto;
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.retrieved-card {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 12px;
    padding: 11px;
    background: rgba(2, 6, 23, 0.75);
}

.retrieved-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.35;
}

.retrieved-meta,
.retrieved-relevance {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.retrieved-text {
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.4;
    white-space: pre-wrap;
}

.composer-shell {
    position: absolute;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    margin: 0;
    padding: 0;
    z-index: 20;
}

.composer-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.composer-surface {
    flex: 1;
    background: var(--panel-elevated);
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 22px;
    padding: 10px 14px 8px;
    box-shadow: 0 16px 36px rgba(2, 6, 23, 0.42);
}

.query-input {
    width: 100%;
    min-height: 30px;
    max-height: 60px;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.query-input::placeholder {
    color: var(--text-muted);
}

.composer-help {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
}

.submit-btn {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(34, 199, 243, 0.35);
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #022c3a;
    font-size: 16px;
    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:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.examples-block {
    position: absolute;
    left: 50%;
    bottom: 170px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 19;
}

.example-query {
    color: var(--text-muted);
    background: transparent;
    border: none;
    text-align: left;
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    padding: 1px 4px;
}

.example-query:hover {
    color: #8ba0bc;
}

.footer-note {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 28px));
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 0;
    z-index: 18;
}

.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; }
}

/* --- Database selector --- */
.db-selector {
    position: relative;
}

.db-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    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;
}

.db-selector-btn:hover {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.07);
}

.db-selector-btn[aria-expanded="true"] {
    border-color: var(--accent);
    background: rgba(34, 199, 243, 0.10);
}

.db-selector-chevron {
    color: var(--text-secondary);
    transition: transform 0.18s ease;
    flex-shrink: 0;
}

.db-selector-btn[aria-expanded="true"] .db-selector-chevron {
    transform: rotate(180deg);
}

.db-selector-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 320px;
    background: var(--panel-elevated);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 12px 36px rgba(2, 6, 23, 0.55);
    z-index: 28;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.db-selector-dropdown[hidden] {
    display: none;
}

.db-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.db-option:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.09);
}

.db-option.is-selected {
    background: rgba(34, 199, 243, 0.08);
}

.db-option.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.db-option:disabled {
    pointer-events: none;
}

.db-option-check {
    flex-shrink: 0;
    width: 16px;
    color: var(--accent);
    font-size: 13px;
    margin-top: 1px;
}

.db-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.db-option-name {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.db-option-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}

.db-option-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;
}

.db-option-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;
}

@media (max-width: 640px) {
    .db-selector-label { display: none; }
    .db-selector-btn { padding: 0 9px; gap: 4px; }
}

@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; }
    .chat-scroll { padding: 72px 16px 198px; }
    .composer-shell,
    .examples-block { width: calc(100% - 32px); }
    .submit-btn {
        width: 46px;
        height: 46px;
        border-radius: 14px;
        align-self: flex-end;
    }
    .message-body,
    .user-bubble { max-width: 100%; }
    .footer-note {
        width: calc(100% - 32px);
    }
    .app-shell.is-empty .composer-shell,
    .app-shell.is-empty .examples-block,
    .app-shell.is-empty .footer-note {
        width: calc(100% - 32px);
    }
    .app-shell.is-empty .composer-shell {
        top: calc(50% + 18px);
    }
    .app-shell.is-empty .examples-block {
        top: calc(50% + 130px);
    }
}

@media (max-width: 640px) {
    .hero-block { margin-top: 14px; }
    .hero-title { font-size: 18px; }
    .hero-description { font-size: 12px; }
    .topbar-actions { gap: 10px; }
    .new-chat-control { gap: 8px; }
    .new-chat-label { font-size: 12px; }
    .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 12px 7px;
    }
    .query-input {
        min-height: 46px;
        font-size: 13px;
    }
    .composer-shell {
        width: calc(100% - 20px);
        bottom: 30px;
    }
    .examples-block {
        width: calc(100% - 20px);
        bottom: 90px;
    }
    .footer-note {
        width: calc(100% - 20px);
        font-size: 11px;
        bottom: 8px;
    }
    .app-shell.is-empty .composer-shell,
    .app-shell.is-empty .examples-block,
    .app-shell.is-empty .footer-note {
        width: calc(100% - 20px);
    }
    .app-shell.is-empty .composer-shell {
        top: calc(50% + 10px);
    }
    .app-shell.is-empty .examples-block {
        top: calc(50% + 125px);
    }
}

/* ── Mobile Overlay ─────────────────────────────────────── */
.mobile-overlay {
    display: none;
}

.panel-support-note {
    margin: 0 20px 8px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

@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-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-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;
}
