:root {
    /* Monochrome light theme — white / black / gray with black borders */
    --bg-primary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f4f4f5;
    --bg-sidebar: #fafafa;
    --border-color: #000000;
    --text-main: #0a0a0a;
    --text-muted: #555555;
    /* Orange accent (the one pop of color on the monochrome base) */
    --accent: #ea580c;         /* fills: buttons, avatars, send */
    --accent-hover: #c2410c;   /* darker for hover / pressed */
    --accent-ink: #c2410c;     /* orange used as text/links on white (>=4.5:1) */
    --accent-soft: #fdece0;    /* faint orange tint for subtle fills */
    --accent-blue: #ea580c;    /* legacy var name → mapped to orange (focus rings, brand) */
    --accent-purple: #ea580c;
    --accent-green: #ea580c;
    --accent-red: #0a0a0a;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-main: 0 1px 3px rgba(0, 0, 0, 0.10);
    --shadow-glow: none;

    /* Chat surface system (monochrome) */
    --chat-bg: #ffffff;
    --chat-surface: #ffffff;
    --assistant-bubble: #f4f4f5;
    --assistant-border: #000000;
    --user-bubble: #0a0a0a;
    --composer-bg: #ffffff;
    --text-strong: #0a0a0a;

    /* Motion */
    --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
    --dur-fast: 0.14s;
    --dur-med: 0.28s;

    /* z-index scale */
    --z-sticky: 20;
    --z-dropdown: 40;
    --z-toast: 60;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

code, textarea.code-font {
    font-family: 'Consolas', 'Monaco', monospace;
}

/* LAYOUT */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 310px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    font-size: 32px;
}

.brand-text h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-blue);
}

.brand-text span {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* FORM CONTROLS */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 10px 12px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

.form-control:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Native <option> popups default to the OS theme (light bg/dark text), which
   bleeds through as washed-out/overlapping against this dark UI. Chromium and
   Firefox honor color/background-color on <option>, unlike the rest of the
   native dropdown chrome, so this is the portable fix without a custom widget. */
.form-control option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .btn-icon {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.input-with-icon .btn-icon:hover {
    color: var(--accent-blue);
}

/* BUTTONS */
.btn {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #0284c7;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #0369a1;
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background-color: #334155;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-block {
    width: 100%;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
}

/* HERO HEADER */
.hero-header {
    background: linear-gradient(135deg, #1e2640 0%, #0f172a 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    box-shadow: var(--shadow-main);
}

.hero-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 24px;
    color: var(--accent-blue);
    margin-bottom: 6px;
}

.hero-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* TABS */
.tabs-header {
    display: flex;
    gap: 8px;
    background-color: var(--bg-sidebar);
    padding: 6px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: var(--bg-card);
}

.tab-btn.active {
    background-color: #0284c7;
    color: #ffffff;
    font-weight: 600;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* CARDS */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-main);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card h2, .card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 600;
}

.subtitle {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}

/* GRIDS */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.col-span-2 { grid-column: span 2; }
.margin-top { margin-top: 16px; }
.margin-bottom { margin-bottom: 16px; }

/* CHECKBOXES */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
}

.checkbox-group label {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* TABLES */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.custom-table th, .custom-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table th {
    background-color: #111827;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

.custom-table tr:hover {
    background-color: var(--bg-card-hover);
}

/* BADGES */
.badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.badge-get { background-color: #1e3a8a; color: #60a5fa; }
.badge-post { background-color: #064e3b; color: #34d399; }
.status-indicator { margin-top: 8px; font-size: 12px; }

/* FLOATING CHATBOT */
.chatbot-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
}

.chatbot-trigger-btn {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: 1px solid var(--accent-blue);
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s ease;
}

.chatbot-trigger-btn:hover {
    transform: translateY(-2px);
}

.chat-window {
    width: 550px;
    height: 650px;
    background-color: #1e293b;
    border: 1px solid var(--accent-blue);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
}

.chat-header {
    background-color: #0f172a;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.chat-header-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.chat-messages {
    flex: 1;
    min-width: 0;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 95%;
    min-width: 0;
}

.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.message-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 100%;
    overflow-x: auto; /* wide tables/code scroll inside the bubble instead of stretching the whole chat column */
}

.message.user .message-content {
    background-color: #0284c7;
    color: #ffffff;
    border-bottom-right-radius: 2px;
}

.message.assistant .message-content {
    background-color: #334155;
    color: #e2e8f0;
    border-bottom-left-radius: 2px;
}

/* .chat-controls-container, .quick-action-pills, .chat-input-area, .input-wrapper are
   siblings of .chat-messages inside the same .chatgpt-main column flex container, so
   they need the same min-width:0 fix or their own content (long pill labels, the
   persona dropdowns) can force the whole chat column wider than the viewport. */
.chat-controls-container,
.chat-input-area,
.input-wrapper {
    min-width: 0;
}

.quick-action-pills {
    min-width: 0;
    flex-shrink: 1;
}

.chat-input-area {
    padding: 16px 24px 14px;
    background-color: #ffffff;
    border-top: 1px solid #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ── MARKDOWN TABLE STYLES (for chatbot responses) ─────────────────── */
.chat-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 8px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.message-content table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 0.78rem;
    background: #fff;
    border: 1px solid #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: table;
    table-layout: auto;
    box-shadow: none;
}

.message-content table thead tr {
    background: #f4f4f5;
    border-bottom: 2px solid var(--accent);
}

.message-content table th {
    padding: 7px 12px;
    text-align: left;
    color: #0a0a0a;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.message-content table td {
    padding: 6px 12px;
    border-bottom: 1px solid #e4e4e7;
    color: #0a0a0a;
    vertical-align: middle;
}

.message-content table tbody tr:hover {
    background: #f4f4f5;
    transition: background 0.15s ease;
}

.message-content table tbody tr:last-child td {
    border-bottom: none;
}

.message-content table tbody tr:nth-child(even) {
    background: #fafafa;
}

/* code blocks inside chat */
.message-content pre {
    background: #0e1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    overflow-x: auto;
    font-size: 0.82rem;
    margin: 8px 0;
}

.message-content code {
    background: #1a2d4d;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.85em;
    color: var(--accent-blue);
}

.message-content ul, .message-content ol {
    padding-left: 1.4em;
    margin: 6px 0;
}

.message-content li {
    margin: 3px 0;
}

.message-content strong {
    color: var(--accent-blue);
    font-weight: 700;
}

.message-content h3, .message-content h4 {
    color: var(--accent-blue);
    margin: 10px 0 5px;
}

/* ── CHATGPT STYLE FULL PAGE LAYOUT ─────────────────────────── */
.chatgpt-layout {
    display: flex;
    width: 100%;
    height: 100%;
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chatgpt-sidebar {
    width: 260px;
    background-color: #0b0f19;
    border-right: 1px solid var(--border-color);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.history-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 10px;
    padding-left: 5px;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background-color: #1e293b;
}

.history-item.active {
    background-color: #334155;
    font-weight: 600;
}

.chatgpt-main {
    flex: 1;
    min-width: 0; /* flex items default to min-width:auto, letting a wide table below force this column past the viewport */
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
}

.chatgpt-main .message.user {
    max-width: 80%;
}

.chatgpt-main .message.assistant {
    max-width: 90%;
}

/* Quick Action Pills */
.btn-pill {
    background: #1e293b;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-pill:hover {
    background: var(--accent-blue);
    color: #000;
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.quick-action-pills::-webkit-scrollbar {
    height: 4px;
}

.quick-action-pills::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   REFINED CHAT EXPERIENCE (overrides the base chat rules above)
   ══════════════════════════════════════════════════════════════════ */

/* --- Shell --- */
.chatgpt-layout {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    background: var(--chat-surface);
}

.chatgpt-sidebar {
    width: 268px;
    background: #0a0e17;
    padding: 16px 14px;
    gap: 4px;
}

.chatgpt-main {
    background:
        radial-gradient(1200px 400px at 50% -10%, rgba(56, 189, 248, 0.06), transparent 70%),
        var(--chat-bg);
}

/* --- Topbar --- */
.chat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 22, 38, 0.7);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.chat-topbar-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-topbar-text { display: flex; flex-direction: column; min-width: 0; }
.chat-topbar-title { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 15px; color: var(--text-strong); }
.chat-topbar-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bot avatar / status chip */
.chat-bot-avatar {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #04121f;
    background: linear-gradient(135deg, var(--accent-blue), #7dd3fc);
    box-shadow: 0 0 0 1px rgba(56,189,248,0.35), 0 4px 12px rgba(56,189,248,0.25);
    font-size: 15px;
}

.chat-status-chip {
    flex-shrink: 0;
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 12px; font-weight: 600; color: var(--text-muted);
    padding: 5px 11px; border-radius: 999px;
    background: #10192b; border: 1px solid var(--border-color);
}
.chat-status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 0 rgba(52,211,153,0.6);
    animation: pulse-dot 2.4s var(--ease-out-quint) infinite;
}
@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); }
    70% { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
    100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* --- Messages area --- */
.chat-messages {
    flex: 1;
    padding: 26px 22px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: #223049; border-radius: 8px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #2d3f5e; }

/* --- Message rows --- */
.chat-messages .message {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 11px;
    max-width: 100%;
    animation: msg-in var(--dur-med) var(--ease-out-quint) both;
}
.chat-messages .message.user { flex-direction: row-reverse; }

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 13px;
    margin-top: 2px;
}
.message.assistant .msg-avatar {
    color: #04121f;
    background: linear-gradient(135deg, var(--accent-blue), #7dd3fc);
}
.message.user .msg-avatar {
    color: #dbeafe;
    background: #1e293b;
    border: 1px solid var(--border-color);
}

/* --- Bubbles --- */
.chatgpt-main .message.assistant,
.chatgpt-main .message.user { max-width: 100%; }

.chat-messages .message-content {
    padding: 12px 15px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    max-width: min(78ch, 82%);
    overflow-x: auto;
}
.chat-messages .message-content:has(table),
.chat-messages .message-content:has(.chat-table-wrapper) {
    max-width: min(100ch, 92%);
}
.chat-messages .message.assistant .message-content {
    background: var(--assistant-bubble);
    border: 1px solid var(--assistant-border);
    color: var(--text-strong);
    border-top-left-radius: 4px;
}
.chat-messages .message.user .message-content {
    background: linear-gradient(135deg, var(--user-bubble), #1d4ed8);
    color: #fff;
    border: 1px solid #3b82f6;
    border-top-right-radius: 4px;
}

/* --- Welcome / empty state --- */
.chat-welcome {
    margin: auto;
    max-width: 460px;
    text-align: center;
    padding: 30px 20px;
    animation: msg-in 0.4s var(--ease-out-quint) both;
}
.chat-welcome-avatar {
    display: inline-grid; place-items: center;
    width: 56px; height: 56px; border-radius: 18px;
    font-size: 24px; color: #04121f;
    background: linear-gradient(135deg, var(--accent-blue), #7dd3fc);
    box-shadow: 0 8px 30px rgba(56,189,248,0.35);
    margin-bottom: 16px;
}
.chat-welcome h3 {
    font-family: 'Outfit', sans-serif; font-size: 20px;
    color: var(--text-strong); margin-bottom: 8px; text-wrap: balance;
}
.chat-welcome p { color: var(--text-muted); font-size: 13.5px; line-height: 1.6; text-wrap: pretty; }
.chat-welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chat-chip {
    background: #131c2e; border: 1px solid var(--border-color);
    color: var(--text-main); padding: 8px 14px; border-radius: 999px;
    font-size: 12.5px; font-weight: 500; cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out-quint), border-color var(--dur-fast), background var(--dur-fast);
}
.chat-chip:hover { border-color: var(--accent-blue); background: #16233a; transform: translateY(-1px); }

/* --- Typing indicator --- */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 3px 2px; }
.typing-dots span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-blue); opacity: 0.5;
    animation: typing 1.2s var(--ease-out-quint) infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Copy button on assistant messages --- */
.msg-copy {
    align-self: flex-start; margin-top: 3px;
    background: none; border: none; color: var(--text-muted);
    font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
    opacity: 0; transition: opacity var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}
.message:hover .msg-copy { opacity: 1; }
.msg-copy:hover { color: var(--accent-blue); background: #16233a; }

/* --- Controls (persona + pills) --- */
.chat-controls-container {
    padding: 12px 22px 6px;
    background: rgba(11, 15, 23, 0.6);
    border-top: 1px solid var(--border-color);
}
.persona-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.persona-field { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 5px; }
.persona-field-wide { flex: 2; min-width: 300px; }
.persona-field label {
    font-size: 10.5px; color: var(--text-muted); text-transform: uppercase;
    font-weight: 700; letter-spacing: 0.06em; display: flex; align-items: center; gap: 6px;
}
.persona-field .form-control { font-size: 13px; padding: 8px 11px; }

/* Horizontal pill rail with fade edges */
.quick-action-scroll { position: relative; }
.quick-action-scroll::before,
.quick-action-scroll::after {
    content: ""; position: absolute; top: 0; bottom: 8px; width: 28px; pointer-events: none; z-index: 1;
}
.quick-action-scroll::before { left: 0; background: linear-gradient(90deg, var(--chat-bg), transparent); }
.quick-action-scroll::after { right: 0; background: linear-gradient(270deg, var(--chat-bg), transparent); }
.quick-action-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }

.btn-pill {
    background: #101a2c; border: 1px solid var(--border-color); color: var(--text-main);
    padding: 7px 14px; border-radius: 999px; font-size: 12px; font-weight: 500;
    cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
    transition: transform var(--dur-fast) var(--ease-out-quint), border-color var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
}
.btn-pill i { color: var(--accent-blue); transition: color var(--dur-fast); }
.btn-pill:hover { background: #16233a; border-color: var(--accent-blue); transform: translateY(-1px); }
.btn-pill:active { transform: translateY(0); }

/* --- Composer --- */
.chat-input-area {
    padding: 14px 22px 16px;
    background: rgba(11, 15, 23, 0.85);
    border-top: 1px solid var(--border-color);
}
.composer {
    display: flex; align-items: center; gap: 8px;
    max-width: 900px; margin: 0 auto;
    background: var(--composer-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px 6px 6px 8px;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.composer:focus-within { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.composer-input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text-strong); font-size: 14px; padding: 10px 8px;
}
.composer-input::placeholder { color: #64748b; }

.composer-send {
    flex-shrink: 0;
    width: 38px; height: 38px; border-radius: 12px;
    border: none; cursor: pointer;
    display: grid; place-items: center;
    color: #04121f; font-size: 15px;
    background: linear-gradient(135deg, var(--accent-blue), #7dd3fc);
    transition: transform var(--dur-fast) var(--ease-out-quint), opacity var(--dur-fast), filter var(--dur-fast);
}
.composer-send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.composer-send:active { transform: translateY(0) scale(0.95); }
.composer-send:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); transform: none; }

.composer-hint {
    max-width: 900px; margin: 8px auto 0;
    font-size: 11px; color: #64748b; text-align: center;
}

/* --- History list refinement --- */
.chatgpt-sidebar .btn-primary { border-radius: 12px; }
.history-item { border-radius: 10px; padding: 10px 12px; }
.history-item:hover { background: #16233a; }
.history-item.active { background: #1c2b45; box-shadow: inset 0 0 0 1px var(--assistant-border); }
.history-title { margin-top: 6px; }

/* --- Accessibility: focus-visible rings --- */
.btn-pill:focus-visible, .chat-chip:focus-visible, .composer-send:focus-visible,
.history-item:focus-visible, .msg-copy:focus-visible {
    outline: 2px solid var(--accent-blue); outline-offset: 2px;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .chat-messages .message,
    .chat-welcome { animation: none; }
    .chat-status-dot,
    .typing-dots span { animation: none; }
    .chat-messages { scroll-behavior: auto; }
    .btn-pill, .chat-chip, .composer-send, .chat-chip:hover, .btn-pill:hover { transition: none; transform: none; }
}

/* --- Responsive: collapse chat history sidebar on narrow screens --- */
@media (max-width: 820px) {
    .chatgpt-sidebar { display: none; }
    .chat-messages .message-content { max-width: 88%; }
    .chat-topbar-sub { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   MONOCHROME THEME OVERRIDES — white / black / gray, black borders
   Re-colors the hardcoded values that don't flow through :root tokens.
   ══════════════════════════════════════════════════════════════════ */

/* Inputs & focus */
.form-control:focus { border-color: #000; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15); }
.form-control option { background: #fff; color: #0a0a0a; }

/* Buttons */
.btn-primary { background: #0a0a0a; color: #fff; border: 1px solid #000; }
.btn-primary:hover { background: #333; box-shadow: none; }
.btn-secondary { background: #fff; color: #0a0a0a; border: 1px solid #000; }
.btn-secondary:hover { background: #f4f4f5; }

/* Tabs */
.tabs-header { background: #fff; border: 1px solid #000; }
.tab-btn:hover { background: #f4f4f5; color: #000; }
.tab-btn.active { background: #0a0a0a; color: #fff; }

/* Cards & hero */
.card { border: 1px solid #000; box-shadow: var(--shadow-main); }
.hero-header { background: #fff; border: 1px solid #000; box-shadow: var(--shadow-main); }
.hero-header h1 { color: #0a0a0a; }

/* Tables (dashboard) */
.table-responsive { border: 1px solid #000; }
.custom-table th { background: #f4f4f5; color: #0a0a0a; }
.custom-table th, .custom-table td { border-bottom: 1px solid #000; }
.custom-table tr:hover { background: #f4f4f5; }

/* Badges → monochrome (outline vs solid to keep GET/POST distinct) */
.badge-get { background: #fff; color: #0a0a0a; border: 1px solid #000; }
.badge-post { background: #0a0a0a; color: #fff; border: 1px solid #000; }

/* Chat shell */
.chatgpt-layout { background: #fff; border: 1px solid #000; }
.chatgpt-sidebar { background: #fafafa; border-right: 1px solid #000; }
.chatgpt-main { background: #fff; }

/* Topbar */
.chat-topbar { background: #fff; border-bottom: 1px solid #000; backdrop-filter: none; }
.chat-topbar-title { color: #0a0a0a; }

/* Avatars → solid black / white */
.chat-bot-avatar,
.message.assistant .msg-avatar {
    background: #0a0a0a; color: #fff; box-shadow: none; border: 1px solid #000;
}
.message.user .msg-avatar { background: #fff; color: #0a0a0a; border: 1px solid #000; }

/* Status chip + dot */
.chat-status-chip { background: #fff; border: 1px solid #000; color: #0a0a0a; }
.chat-status-dot { background: #0a0a0a; }
@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(0,0,0,0.4); }
    70% { box-shadow: 0 0 0 6px rgba(0,0,0,0); }
    100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}

/* Bubbles */
.chat-messages .message.assistant .message-content {
    background: #f4f4f5; border: 1px solid #000; color: #0a0a0a;
}
.chat-messages .message.user .message-content {
    background: #0a0a0a; color: #fff; border: 1px solid #000;
}

/* Scrollbars */
.chat-messages::-webkit-scrollbar-thumb { background: #c8c8c8; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #a3a3a3; }

/* Copy button */
.msg-copy:hover { color: #000; background: #f4f4f5; }

/* Welcome state */
.chat-welcome-avatar { background: #0a0a0a; color: #fff; box-shadow: none; border: 1px solid #000; }
.chat-welcome h3 { color: #0a0a0a; }
.chat-chip { background: #fff; border: 1px solid #000; color: #0a0a0a; }
.chat-chip:hover { background: #0a0a0a; color: #fff; border-color: #000; }

/* Typing dots */
.typing-dots span { background: #0a0a0a; }

/* Controls */
.chat-controls-container { background: #fafafa; border-top: 1px solid #000; }
.persona-field label { color: #555; }

/* Pills */
.btn-pill { background: #fff; border: 1px solid #000; color: #0a0a0a; }
.btn-pill i { color: #0a0a0a; }
.btn-pill:hover { background: #0a0a0a; color: #fff; border-color: #000; }
.btn-pill:hover i { color: #fff; }
.quick-action-pills::-webkit-scrollbar-thumb { background: #c8c8c8; }

/* Composer */
.chat-input-area { background: #fff; border-top: 1px solid #000; }
.composer { background: #fff; border: 1px solid #000; }
.composer:focus-within { border-color: #000; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12); }
.composer-input { color: #0a0a0a; }
.composer-input::placeholder { color: #888; }
.composer-send { background: #0a0a0a; color: #fff; border: 1px solid #000; }
.composer-send:hover { background: #333; filter: none; }
.composer-hint { color: #888; }

/* History list */
.history-item { color: #0a0a0a; }
.history-item:hover { background: #f4f4f5; }
.history-item.active { background: #ececec; box-shadow: inset 0 0 0 1px #000; }

/* Markdown tables inside chat answers */
.message-content table { background: #fff; border: 1px solid #000; box-shadow: none; display: table; width: 100%; table-layout: auto; }
.message-content table thead tr { background: #f4f4f5; border-bottom: 2px solid var(--accent); }
.message-content table th { color: #0a0a0a; }
.message-content table td { border-bottom: 1px solid #e4e4e7; color: #0a0a0a; }
.message-content table tbody tr:hover { background: #f4f4f5; }
.message-content code { background: #f4f4f5; color: #0a0a0a; border: 1px solid #000; }
.message-content pre { background: #f4f4f5; border: 1px solid #000; }
.message-content strong { color: #0a0a0a; }
.message-content h3, .message-content h4 { color: #0a0a0a; }
.message-content a { color: #0a0a0a; text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════════
   ORANGE ACCENT — one pop of colour on the monochrome base (~10%)
   Applied to brand marks, primary actions, focus, and hover only.
   ══════════════════════════════════════════════════════════════════ */

/* Brand marks */
.brand-text h2 { color: var(--accent-ink); }
.chat-bot-avatar,
.message.assistant .msg-avatar,
.chat-welcome-avatar {
    background: var(--accent); color: #fff; border: 1px solid var(--accent-hover);
}

/* Primary actions */
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent-hover); }
.btn-primary:hover { background: var(--accent-hover); }
.composer-send { background: var(--accent); color: #fff; border: 1px solid var(--accent-hover); }
.composer-send:hover { background: var(--accent-hover); }

/* Live status dot */
.chat-status-dot { background: var(--accent); }
@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(234, 88, 12, 0); }
    100% { box-shadow: 0 0 0 0 rgba(234, 88, 12, 0); }
}

/* Focus states */
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.18); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.18); }

/* Hover fills (interaction only) */
.btn-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent-hover); }
.btn-pill:hover i { color: #fff; }
.chat-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent-hover); }
.msg-copy:hover { color: var(--accent-ink); background: var(--accent-soft); }

/* Small accents */
.typing-dots span { background: var(--accent); }
.message-content a { color: var(--accent-ink); }
.message-content table thead tr { border-bottom: 2px solid var(--accent); }
.tab-btn.active { box-shadow: inset 0 -3px 0 var(--accent); }
.history-item.active { box-shadow: inset 3px 0 0 var(--accent), inset 0 0 0 1px #000; }
.badge-post { background: var(--accent); border-color: var(--accent-hover); }

/* ══════════════════════════════════════════════════════════════════
   COMPACT DENSITY — tighter spacing so more detail fits on screen
   ══════════════════════════════════════════════════════════════════ */

/* Global chrome trim */
.main-content { padding: 20px; gap: 16px; }
.hero-header { padding: 16px 22px; }
.hero-header h1 { font-size: 21px; margin-bottom: 3px; }
.hero-header p { font-size: 13px; }
.card { padding: 18px; }

/* Chat topbar */
.chat-topbar { padding: 9px 18px; }
.chat-bot-avatar { width: 30px; height: 30px; font-size: 14px; }
.chat-topbar-title { font-size: 14px; }
.chat-topbar-sub { font-size: 11.5px; }

/* Messages: less gap + padding, denser bubbles */
.chat-messages { padding: 14px 18px 6px; gap: 11px; }
.chat-messages .message { gap: 9px; }
.chat-messages .message-content {
    padding: 9px 13px; font-size: 13px; line-height: 1.45; border-radius: 11px;
}
.msg-avatar { width: 26px; height: 26px; font-size: 11px; margin-top: 1px; }

/* Denser markdown tables inside answers (the biggest space hog) */
.message-content table { font-size: 0.76rem; margin: 4px 0; width: 100%; display: table; table-layout: auto; }
.message-content table th { padding: 6px 12px; font-size: 0.72rem; }
.message-content table td { padding: 5px 12px; }
.message-content p { margin: 4px 0; }
.message-content ul, .message-content ol { margin: 4px 0; padding-left: 1.25em; }
.message-content li { margin: 1px 0; }
.message-content h3, .message-content h4 { margin: 7px 0 3px; }
.message-content pre { padding: 8px 11px; margin: 6px 0; }

/* Controls: compact persona row + pills */
.chat-controls-container { padding: 8px 18px 4px; }
.persona-row { margin-bottom: 8px; gap: 8px; }
.persona-field { gap: 3px; }
.persona-field label { font-size: 10px; }
.persona-field .form-control { padding: 6px 9px; font-size: 12.5px; }
.quick-action-pills { gap: 6px; padding-bottom: 6px; }
.btn-pill { padding: 5px 11px; font-size: 11.5px; gap: 6px; }

/* Composer + hint */
.chat-input-area { padding: 10px 18px 12px; }
.composer { padding: 4px 4px 4px 8px; border-radius: 13px; }
.composer-input { padding: 8px 6px; font-size: 13.5px; }
.composer-send { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
.composer-hint { margin-top: 5px; font-size: 10.5px; }

/* History list density & modern layout */
.chatgpt-sidebar {
    width: 290px;
    padding: 14px 12px;
    background: #fafafa;
    border-right: 1px solid #000;
}
.chatgpt-sidebar .btn-primary { margin-bottom: 12px !important; }

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-bottom: 24px;
    scrollbar-width: thin;
    scrollbar-color: #d4d4d8 transparent;
}

.chat-history-list::-webkit-scrollbar {
    width: 5px;
}
.chat-history-list::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history-list::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border-radius: 4px;
}
.chat-history-list::-webkit-scrollbar-thumb:hover {
    background: #a1a1aa;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #18181b;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.history-item:hover {
    background: #f4f4f5;
    border-color: #e4e4e7;
}

.history-item.active {
    background: #ffffff;
    border-color: #000000;
    box-shadow: inset 3px 0 0 var(--accent), 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.history-icon {
    flex-shrink: 0;
    font-size: 13px;
    color: #71717a;
    transition: color 0.15s ease;
}

.history-item:hover .history-icon,
.history-item.active .history-icon {
    color: var(--accent);
}

.history-item-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* Delete button appears on hover / active, avoiding the 'wall of trash cans' */
.history-del-btn {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #a1a1aa;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    transform: scale(0.9);
}

.history-item:hover .history-del-btn,
.history-item.active .history-del-btn {
    opacity: 0.7;
    pointer-events: auto;
    transform: scale(1);
}

.history-del-btn:hover {
    opacity: 1 !important;
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.1) !important;
}

/* Welcome state tighter */
.chat-welcome { padding: 22px 20px; }
.chat-welcome-avatar { width: 48px; height: 48px; font-size: 20px; margin-bottom: 12px; }
.chat-welcome h3 { font-size: 18px; }
.chat-welcome p { font-size: 13px; }

/* ══════════════════════════════════════════════════════════════════
   REFINED SEARCH / COMPOSER (persona dropdowns removed)
   ══════════════════════════════════════════════════════════════════ */
.chat-input-area { padding: 12px 18px 14px; }
.composer {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 6px 16px;
    border: 1.5px solid #000;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}
.composer:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.16), 0 2px 8px rgba(0, 0, 0, 0.08);
}
.composer-icon {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 15px;
    transition: color var(--dur-fast);
}
.composer:focus-within .composer-icon { color: var(--accent); }
.composer-input,
.chat-input-area .composer-input {
    flex: 1;
    font-size: 14.5px;
    padding: 10px 4px;
    color: #0a0a0a;
    background: transparent;
    border: none;
    outline: none;
    caret-color: var(--accent);
    line-height: 1.5;
}
.composer-input::placeholder { color: #9ca3af; font-size: 14px; }
.composer-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 15px;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.composer-send:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(234, 88, 12, 0.3);
}
.composer-send:active { transform: translateY(0) scale(0.96); }
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.composer-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #71717a;
    text-align: center;
    letter-spacing: 0.01em;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE WEB DESIGN — fluid layout for tablet & phone
   Appended last so these overrides win by cascade order. Desktop is
   unchanged; rules apply only at/below each breakpoint.
   ══════════════════════════════════════════════════════════════════ */

/* Tablet (≤1024px): stack handled above; make the tab bar swipeable and
   give the chat a usable height once the layout is vertical. */
@media (max-width: 1024px) {
    .tabs-header {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .tab-btn { flex: 0 0 auto; white-space: nowrap; }
    .chatgpt-layout { height: auto; min-height: 76vh; }
    .chatgpt-sidebar { width: 220px; }
    .main-content { max-width: 100%; }
}

/* Large phone / small tablet (≤768px): single-column chat, hide the
   recent-chats rail, compact the hero and topbar. */
@media (max-width: 768px) {
    body { -webkit-text-size-adjust: 100%; }
    .main-content { padding: 12px; }
    .hero-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    .chatgpt-sidebar { display: none; }          /* recent chats hidden on phones */
    .chatgpt-layout { min-height: 80vh; border-radius: var(--radius-md); }
    .chat-messages .message-content { max-width: 90%; }
    .chat-topbar-sub { display: none; }
    /* Quick-action pills & welcome chips scroll horizontally instead of wrapping tall. */
    .quick-action-pills,
    .chat-controls-container {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .quick-action-pills > * { flex: 0 0 auto; }
}
/* Phone (≤480px): tighten spacing/typography and ensure comfortable touch targets. */
@media (max-width: 480px) {
    .main-content { padding: 10px; }
    .hero-header { padding: 14px 16px; }
    .hero-header h1 { font-size: 18px; }
    .hero-header p { font-size: 12px; }
    .tab-btn { padding: 8px 12px; font-size: 13px; }
    .chatgpt-layout { min-height: 82vh; }
    .chat-topbar { padding: 10px 14px; }
    .chat-messages { padding: 12px 12px 4px; }
    .chat-messages .message-content { max-width: 94%; font-size: 14px; }
    .chat-bot-avatar { width: 30px; height: 30px; font-size: 13px; }
    .message-content table { font-size: 0.74rem; }
    /* Full-width form controls + larger tap targets in the config sidebar. */
    .sidebar .form-control,
    .sidebar .btn-primary,
    .sidebar .btn-secondary { width: 100%; }
    .composer-send { width: 42px; height: 42px; }   /* >=42px touch target */
    .composer-input { font-size: 16px; }             /* >=16px avoids iOS zoom-on-focus */
}

/* ══════════════════════════════════════════════════════════════════
   FLUID RESPONSIVE OVERHAUL — every element fits its viewport.
   No overlaps, no cut-offs, no horizontal page scroll at any size.
   ══════════════════════════════════════════════════════════════════ */

/* Base: never let the page itself scroll sideways; media never overflows. */
html { overscroll-behavior: none; }
body { overscroll-behavior-y: auto; }
img, video, canvas, svg, iframe { max-width: 100%; }
button, .tab-btn, .btn-pill, .chat-chip, .composer-send {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Skip link (guidelines: hierarchical headings + skip link). */
.skip-link {
    position: absolute; left: 12px; top: -48px; z-index: 100;
    background: #0a0a0a; color: #fff; padding: 8px 14px;
    border-radius: 8px; font-size: 13px; text-decoration: none;
    transition: top 0.14s ease;
}
.skip-link:focus-visible { top: 12px; outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fluid type + spacing so headings/cards scale instead of clipping. */
.hero-header h1 { font-size: clamp(18px, 2.4vw + 12px, 24px); text-wrap: balance; }
.hero-header p, .card p, .subtitle { overflow-wrap: anywhere; }
.main-content { width: 100%; min-width: 0; margin: 0 auto; }
.card, .hero-header, .tabs-header, .chatgpt-layout { min-width: 0; }
.card-header { flex-wrap: wrap; gap: 12px; }
.card-header > div { min-width: 0; flex: 1 1 200px; }

/* Missing layout class used by Project/Users headers (prevents overlap). */
.inline-inputs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; min-width: 0; }
.inline-inputs .form-control { flex: 1 1 180px; min-width: 0; }
.inline-input { min-width: 0; }
.result-area { min-width: 0; overflow-wrap: anywhere; }

/* Grids collapse gracefully at every step (no 3-col squeeze on tablets). */
@media (max-width: 1200px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: span 1; }
}

/* Tabs: swipeable rail that never wraps tall or pushes content. */
.tabs-header {
    position: sticky; top: 0; z-index: var(--z-sticky);
    scrollbar-width: thin;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.tabs-header::-webkit-scrollbar { height: 4px; }
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Tables: container scrolls with momentum; cells never force page scroll. */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
}
.custom-table { min-width: 560px; }
.custom-table th, .custom-table td {
    overflow-wrap: anywhere; word-break: break-word;
}
.custom-table code { overflow-wrap: anywhere; word-break: break-all; }

/* Chat tab height uses dynamic viewport so mobile browser chrome never cuts it. */
#tabAIChat.tab-content.active { display: flex; flex-direction: column; }
#tabAIChat {
    height: calc(100vh - 180px);
    height: calc(100dvh - 180px);
    min-height: 480px;
}
.chatgpt-layout { flex: 1; min-height: 0; }
.chat-messages {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.chat-controls-container { overflow-x: hidden; }
.quick-action-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}
.message-content {
    min-width: 0;
    overflow-wrap: anywhere; word-break: break-word;
}
.message-content pre { max-width: 100%; }
.message-content pre code { word-break: break-all; white-space: pre-wrap; }
.message-content table { max-width: 100%; }
.message-content img { height: auto; }

/* Safe-area aware chrome (notches / home bars never cover controls). */
.sidebar {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    padding-left: calc(20px + env(safe-area-inset-left));
    padding-right: calc(20px + env(safe-area-inset-right));
}
.chat-input-area {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    padding-left: calc(18px + env(safe-area-inset-left));
    padding-right: calc(18px + env(safe-area-inset-right));
}
.chat-topbar {
    padding-left: calc(22px + env(safe-area-inset-left));
    padding-right: calc(22px + env(safe-area-inset-right));
}

/* Compositor-friendly transitions (guidelines: never `transition: all`). */
.btn, .tab-btn, .btn-pill, .chat-chip, .chatbot-trigger-btn, .form-control {
    transition-property: background-color, border-color, color, box-shadow, transform, opacity, filter;
}
.form-control { transition-duration: 0.2s; transition-timing-function: ease; }

/* Coarse pointers: 16px inputs (no iOS zoom) + 44px targets everywhere. */
@media (pointer: coarse) {
    .form-control, .composer-input, textarea.form-control { font-size: 16px; }
    .tab-btn { min-height: 44px; }
    .btn-pill, .chat-chip { min-height: 36px; }
    .composer-send { width: 44px; height: 44px; }
    .history-del-btn { opacity: 0.7; pointer-events: auto; }
}

/* Small tablets: keep chat rail but narrower; chat height adapts. */
@media (max-width: 1024px) {
    #tabAIChat { height: calc(100dvh - 120px); min-height: 70dvh; }
}

/* Phones: single column, full-width controls, compact tables. */
@media (max-width: 768px) {
    #tabAIChat { height: calc(100dvh - 60px); min-height: 78dvh; }
    .inline-inputs { flex-direction: column; align-items: stretch; }
    .inline-inputs .btn { width: 100%; }
    .card-header .btn { width: 100%; }
    .custom-table { min-width: 520px; font-size: 12.5px; }
    .custom-table th, .custom-table td { padding: 10px 12px; }
    .checkbox-group { gap: 10px; }
    .form-control { padding: 11px 12px; }
}

/* Small phones: prevent any fixed-width element from exceeding 390px. */
@media (max-width: 480px) {
    #tabAIChat { min-height: 80dvh; }
    .chat-welcome-chips { max-width: 100%; }
    .chat-chip { max-width: 100%; white-space: normal; text-align: center; }
    .btn-pill { max-width: 78vw; overflow: hidden; text-overflow: ellipsis; }
    .composer { max-width: 100%; }
    .custom-table { min-width: 480px; }
}

/* Landscape phones / short viewports: hero collapses so chat stays usable. */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-header { display: none; }
    .main-content { gap: 12px; padding: 12px; }
    #tabAIChat { height: calc(100dvh - 40px); min-height: 88dvh; }
    .chat-welcome { padding: 12px; }
    .chat-welcome-avatar { width: 36px; height: 36px; font-size: 16px; margin-bottom: 8px; }
}

/* ══════════════════════════════════════════════════════════════════
   DIRECT QUERY MODE — toggle beside the composer + SQL provenance
   ══════════════════════════════════════════════════════════════════ */
.composer-mode-btn {
    flex-shrink: 0;
    width: 32px; height: 32px; border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #fff; color: #0a0a0a;
    font-size: 13px; cursor: pointer;
    display: grid; place-items: center;
    transition: background-color var(--dur-fast) var(--ease-out-quint),
                color var(--dur-fast), border-color var(--dur-fast);
}
.composer-mode-btn:hover { background: var(--accent-soft); }
.composer-mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer-mode-btn[aria-pressed="true"] {
    background: var(--accent); color: #fff; border-color: var(--accent-hover);
}
/* The pressed state must be obvious even without colour: ring + filled icon. */
.composer-mode-btn[aria-pressed="true"]::after {
    content: ""; position: absolute; inset: -4px;
    border: 1px solid var(--accent); border-radius: 13px; pointer-events: none;
}
.composer-mode-btn { position: relative; }

.msg-sql-steps {
    margin-top: 8px; padding-top: 6px;
    border-top: 1px dashed #c8c8c8;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px; color: var(--text-muted);
    overflow-wrap: anywhere;
}
.history-mode-badge { flex-shrink: 0; font-size: 11px; color: var(--accent); }

@media (pointer: coarse) {
    .composer-mode-btn { width: 40px; height: 40px; }
}
@media (max-width: 480px) {
    .composer { gap: 6px; padding-left: 6px; }
    .composer-mode-btn { width: 36px; height: 36px; border-radius: 9px; }
}

/* Large desktops: cap line length, center the app. */
@media (min-width: 1600px) {
    .main-content { max-width: 1500px; }
}


