/* ==========================================================================
   Chat page redesign — additive, loads AFTER chat.css + chat-compare.css.
   Light theme follows the approved mockup; dark keeps the same components.
   All colors via --dch-* tokens on .app-container.
   ========================================================================== */

/* ---- Tokens: DARK default (chat.css heritage), LIGHT overrides below ---- */
.app-container {
    --dch-sidebar-w: 268px;
    --dch-content-w: 1200px;
    --dch-composer-w: 1200px;
    --dch-radius: 16px;
    --dch-accent: #8B6FF0;
    --dch-accent-strong: #7C5FE3;
    --dch-fab-grad: linear-gradient(135deg, #7C5FE3 0%, #6D4FE0 100%);
    --dch-page: #0F0E11;
    --dch-sidebar: #141218;
    --dch-surface: #1A1720;
    --dch-hover: rgba(139, 111, 240, 0.10);
    --dch-border: #2A2732;
    --dch-text: #E4E2E9;
    --dch-muted: #8A8794;
    --dch-active-bg: rgba(139, 111, 240, 0.12);
    --dch-user-bubble: rgba(124, 95, 227, 0.16);
    --dch-system-bubble: #0d162c66;

    --dch-pill-a-bg: rgba(124, 95, 227, 0.14);
    --dch-pill-a-fg: #B9A5FF;
    --dch-pill-b-bg: rgba(59, 130, 246, 0.14);
    --dch-pill-b-fg: #7EB3F7;
    --dch-search-bg: #1A1720;
    --dch-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.30);
    --dch-shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.45);
}

[data-bs-theme="light"] .app-container {
    --dch-accent: #6D4FE0;
    --dch-system-bubble: #0d162c08;
    --dch-accent-strong: #6D4FE0;
    --dch-page: #FFFFFF;
    --dch-sidebar: #FFFFFF;
    --dch-surface: #FFFFFF;
    --dch-hover: rgba(109, 79, 224, 0.06);
    --dch-border: #ECEEF4;
    --dch-text: #1F2430;
    --dch-muted: #8A92A3;
    --dch-active-bg: #F3F0FF;
    --dch-user-bubble: #F3F0FF;
    --dch-pill-a-bg: #F1EDFF;
    --dch-pill-a-fg: #6D4FE0;
    --dch-pill-b-bg: #EAF2FF;
    --dch-pill-b-fg: #2F6FED;
    --dch-search-bg: #F5F6F8;
    --dch-shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
    --dch-shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.14);
}

/* ============================ Shell ============================ */

.app-container {
    background: transparent;
}

.app-container .sidebar {
    width: var(--dch-sidebar-w);
    background: var(--dch-sidebar);
    border-right: 1px solid var(--dch-border);
    padding: 14px 12px;
    padding-top: 86px;
    /* below the fixed navbar pill */
    z-index: 900;
    color: var(--dch-text);
}

.app-container .main-chat {
    background: transparent;
    color: var(--dch-text);
}

.app-container .chat-messages,
.app-container .empty-state {
    background: transparent;
}

[data-bs-theme="light"] .app-container .main-chat {
    background: transparent;
}

/* ============================ Sidebar drawer ============================ */
/* chat.css keeps a 100px icon rail when closed — hide it fully instead. */
.app-container .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0.22s ease;
}

.app-container .sidebar.open {
    transform: translateX(0);
    visibility: visible;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1240;
    background: rgba(15, 14, 17, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-float-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--dch-border);
    border-radius: 10px;
    background: var(--dch-surface);
    color: var(--dch-text);
    cursor: pointer;
    box-shadow: var(--dch-shadow-card);
    transition: background 0.15s ease;
}

.sidebar-float-toggle:hover {
    background: var(--dch-hover);
}

@media (max-width: 991.98px) {
    .sidebar-float-toggle {
        top: 78px;
        left: 10px;
    }
}

/* ============================ Sidebar content ============================ */

.sidebar-new-chat {
    padding: 0 0 12px;
}

.new-chat-pill {
    width: 100%;
    height: 44px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: none;
    border-radius: 12px;
    background: var(--dch-active-bg);
    color: var(--dch-accent);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.new-chat-pill:hover {
    filter: brightness(1.05);
}

.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    margin-bottom: 12px;
    padding: 0 10px 0 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--dch-search-bg);
    color: var(--dch-muted);
}

.sidebar-search:focus-within {
    border-color: var(--dch-accent);
}

.chat-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--dch-text);
    font-size: 13.5px;
}

.chat-search-input::placeholder {
    color: var(--dch-muted);
}

.search-kbd {
    flex: none;
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--dch-border);
    border-radius: 5px;
    color: var(--dch-muted);
}

/* History list */
.chat-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
}

.chat-group {
    margin-bottom: 6px;
}

.chat-group-label {
    padding: 10px 8px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dch-muted);
}

.chat-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 2px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.app-container .chat-history-item:hover {
    background: var(--dch-hover);
}

.app-container .chat-history-item.active {
    background: var(--dch-active-bg);
}

.chat-avatar-mini {
    flex: none;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--dch-muted);
    border-radius: 8px;
    background: transparent;
}

.chat-history-item.active .chat-avatar-mini {
    color: var(--dch-accent);
}

.chat-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* chat.css constrains .text-content to 140px (its collapse trick);
   neutralize inside the flex row */
.app-container .sidebar .text-content {
    width: auto;
    margin-left: 0;
    overflow: hidden;
}

.chat-item-title {
    display: block;
    font-size: 13.5px;
    color: var(--dch-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-time {
    font-size: 11px;
    color: var(--dch-muted);
}

.chat-empty {
    padding: 14px 10px;
    font-size: 13px;
    color: var(--dch-muted);
}

/* Compare badge */
.app-container .compare-history-badge {
    margin-left: auto;
    flex: none;
    font-size: 9.5px;
    padding: 2px 6px;
    color: var(--dch-accent);
    background: var(--dch-hover);
    border: none;
    border-radius: 6px;
    letter-spacing: 0.03em;
}

/* Sync note + user footer */
.sidebar-sync {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 8px;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--dch-muted);
}

.sidebar-sync i {
    margin-top: 2px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 8px 4px;
    border-top: 1px solid var(--dch-border);
}

.sidebar-user-avatar {
    flex: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--dch-fab-grad);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-name {
    display: block;
    font-size: 12.5px;
    color: var(--dch-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Collapsed sidebar: icons only */
.sidebar:not(.open) .sidebar-new-chat,
.sidebar:not(.open) .sidebar-search,
.sidebar:not(.open) .sidebar-sync,
.sidebar:not(.open) .sidebar-user,
.sidebar:not(.open) .chat-group-label,
.sidebar:not(.open) .chat-item-body,
.sidebar:not(.open) .chat-avatar-mini,
.sidebar:not(.open) .compare-history-badge {
    display: none;
}

.sidebar:not(.open) .chat-history-item {
    justify-content: center;
    padding: 8px 4px;
}

/* ============================ Conversation header card ============================ */

.chat-header-card {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(var(--dch-content-w), calc(100% - 40px));
    max-width: var(--dch-content-w);
    margin: 84px auto 0;
    padding: 12px 16px;
    background: var(--dch-surface);
    border: 1px solid var(--dch-border);
    border-radius: var(--dch-radius);
    box-shadow: var(--dch-shadow-card);
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.chat-header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--dch-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-sub {
    flex: none;
    font-size: 12px;
    color: var(--dch-muted);
}

.chat-header-actions {
    flex: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
    transition: 150ms ease;
}

.header-icon-btn:hover {
    color: var(--dch-accent);
    background: var(--dch-hover);
}

/* ============================ Messages ============================ */

.app-container .chat-messages {
    display: flex;
    flex-direction: column;
    width: min(var(--dch-content-w), calc(100% - 40px));
    max-width: var(--dch-content-w);
    margin-left: auto;
    margin-right: auto;
}

/* Empty state: centered */
.app-container .empty-state {
    margin: auto 0;
    text-align: center;
}

.empty-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.empty-chip {
    padding: 8px 14px;
    border: 1px solid var(--dch-border);
    border-radius: 18px;
    background: var(--dch-surface);
    color: var(--dch-text);
    font-size: 13px;
    cursor: pointer;
    transition: 150ms ease;
}

.empty-chip:hover {
    border-color: var(--dch-accent);
    color: var(--dch-accent);
    background: var(--dch-hover);
}

/* User bubble: right, violet tint */
.app-container .message.user {
    align-self: stretch;
    justify-content: flex-end;
}

.app-container .message.user .message-content {
    width: fit-content;
    max-width: min(78%, 760px);
    margin-left: auto;
    background: var(--dch-user-bubble);
    border-radius: 16px;
    padding: 10px 14px;
    color: var(--dch-text);
}

.app-container .message.user .message-actions {
    right: 0;
}

.msg-time {
    margin-top: 4px;
    font-size: 11px;
    color: var(--dch-muted);
    text-align: right;
}

/* Assistant: no bubble, plain markdown with model row */
.app-container .message.system {
    flex-direction: column;
    align-items: stretch;
}

.app-container .message.system .message-content {
    background: #0d162c66;
    max-width: 860px;
    padding: 1em;
}

.answer-model-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dch-muted);
}

/* Provider icon colors */
.prov-openai {
    color: #8B6FF0;
}

.prov-google {
    color: #8B6FF0;
}

.prov-anthropic {
    color: #E07A3F;
}

.prov-deepseek {
    color: #4F8FE0;
}

.prov-qwen {
    color: #6D5FE0;
}

.prov-meta {
    color: #4F8FE0;
}

.prov-mistral {
    color: #E0A23F;
}

.prov-glm {
    color: #38B2AC;
}

.prov-moonshot {
    color: #8A92A3;
}

.prov-xai {
    color: var(--dch-text);
}

.prov-other {
    color: var(--dch-muted);
}

/* ============================ Compare cards ============================ */

.app-container .compare-pairs,
.app-container .compare-branches,
.app-container .compare-question,
.app-container .compare-pending {
    max-width: var(--dch-content-w);
}

.app-container .compare-question .message-content {
    max-width: 68%;
    margin-left: auto;
    background: var(--dch-user-bubble);
    border-radius: 16px;
    padding: 10px 14px;
}

.app-container .compare-branch {
    background: var(--dch-surface);
    border: 1px solid var(--dch-border);
    border-radius: var(--dch-radius);
    box-shadow: var(--dch-shadow-card);
}

.compare-branch-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--dch-border);
}

.compare-branch-icon {
    font-size: 14px;
}

.compare-branch-model {
    font-weight: 700;
    font-size: 14px;
    margin-right: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.branch-badge {
    flex: none;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

.branch-badge.b1 {
    color: var(--dch-pill-a-fg);
    background: var(--dch-pill-a-bg);
}

.branch-badge.b2 {
    color: var(--dch-pill-b-fg);
    background: var(--dch-pill-b-bg);
}

.branch-icon-btn {
    margin-left: auto;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
    transition: 150ms ease;
}

.branch-icon-btn:hover {
    color: var(--dch-accent);
    background: var(--dch-hover);
}

/* Markdown inside compare branches */
.app-container .compare-branch-body h1,
.app-container .compare-branch-body h2,
.app-container .compare-branch-body h3,
.app-container .compare-branch-body h4 {
    margin: 14px 0 8px;
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.35;
}

.app-container .compare-branch-body h1:first-child,
.app-container .compare-branch-body h2:first-child,
.app-container .compare-branch-body h3:first-child,
.app-container .compare-branch-body p:first-child,
.app-container .compare-branch-body ul:first-child,
.app-container .compare-branch-body ol:first-child {
    margin-top: 0;
}

.app-container .compare-branch-body p {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.6;
}

.app-container .compare-branch-body ul,
.app-container .compare-branch-body ol {
    margin: 0 0 10px;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.6;
}

.app-container .compare-branch-body li {
    margin-bottom: 5px;
}

.app-container .compare-branch-body li:last-child {
    margin-bottom: 0;
}

.app-container .compare-branch-body code {
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--dch-hover);
    font-size: 13px;
}

.app-container .compare-branch-body pre {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--dch-page);
    border: 1px solid var(--dch-border);
    overflow-x: auto;
}

.app-container .compare-branch-body pre code {
    padding: 0;
    background: transparent;
}

.app-container .compare-branch-body table {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 13.5px;
}

.app-container .compare-branch-body th,
.app-container .compare-branch-body td {
    padding: 6px 8px;
    border: 1px solid var(--dch-border);
    text-align: left;
}

/* Branch footer */
.compare-branch-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: auto;
    padding: 10px 16px;
    border-top: 1px solid var(--dch-border);
}

.compare-gen {
    font-size: 12px;
    color: var(--dch-muted);
    margin-right: auto;
}

.compare-metric {
    font-size: 12px;
    color: var(--dch-muted);
    white-space: nowrap;
}

.compare-regen-btn {
    height: 28px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
    transition: 150ms ease;
}

.compare-regen-btn:hover:not(:disabled) {
    color: var(--dch-accent);
    background: var(--dch-hover);
}

.compare-regen-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.compare-continue-btn {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid var(--dch-border);
    background: transparent;
    color: var(--dch-text);
    cursor: pointer;
    white-space: nowrap;
    transition: 150ms ease;
}

.compare-continue-btn:hover {
    border-color: var(--dch-accent);
    color: var(--dch-accent);
}

/* faster / cheaper badges keep their colors from chat-compare.css */

@media (max-width: 900px) {
    .app-container .compare-branches {
        grid-template-columns: 1fr;
    }
}

/* ============================ Composer ============================ */

.app-container .chat-footer {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: transparent;
    border: none;
    padding-bottom: 0;
}

.app-container .chat-input-container {
    position: relative;
    width: min(var(--dch-composer-w), calc(100% - 40px)) !important;
    max-width: var(--dch-composer-w);
    margin: 0 auto 12px;
    padding: 12px 14px;
    border: 1px solid var(--dch-border);
    border-radius: 18px;
    background: var(--dch-surface);
    box-shadow: var(--dch-shadow-card);
}

.app-container .editor-wrapper {
    margin: 0 0 8px;
}

.app-container .editor {
    min-height: 24px;
    max-height: 160px;
    padding: 10px 12px;
    border: none;
    overflow-y: auto;
    color: var(--dch-text);
    font-size: 14.5px;
    line-height: 1.5;
}

.app-container .editor:empty::before {
    content: attr(placeholder);
    color: var(--dch-muted);
    pointer-events: none;
}

.app-container .editor p {
    margin: 0;
    min-height: 1.5em;
}

/* Composer bottom row */
.composer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.composer-spacer {
    flex: 1;
}

.composer-swap {
    flex: none;
    font-size: 13px;
    color: var(--dch-muted);
}

.app-container .round-btn,
.app-container .compare-toggle {
    flex: none;
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--dch-border);
    border-radius: 50%;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
    transition: 160ms ease;
}

.app-container .round-btn:hover,
.app-container .compare-toggle:hover {
    color: var(--dch-accent);
    border-color: var(--dch-accent);
    background: var(--dch-hover);
}

.app-container .compare-toggle.active {
    background: var(--dch-active-bg);
    border-color: var(--dch-accent);
    color: var(--dch-accent);
}

/* Model pills (A / B / aspect) */
.model-pill-btn {
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: none;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    max-width: 260px;
    transition: filter 0.15s ease;
}

.model-pill-btn:hover {
    filter: brightness(0.97);
}

.model-pill-btn .model-pill-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-pill-btn .fa-chevron-down {
    font-size: 10px;
    opacity: 0.7;
}

.pill-a .model-pill-btn {
    background: var(--dch-pill-a-bg);
    color: var(--dch-pill-a-fg);
}

.pill-b .model-pill-btn {
    background: var(--dch-pill-b-bg);
    color: var(--dch-pill-b-fg);
}

.pill-aspect .model-pill-btn {
    background: var(--dch-search-bg);
    color: var(--dch-text);
    border: 1px solid var(--dch-border);
    border-radius: 18px;
}

/* FAB send */
.app-container .chat-send-btn {
    flex: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--dch-fab-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(109, 79, 224, 0.35);
    transition: filter 0.15s ease;
}

.app-container .chat-send-btn:hover {
    background: var(--dch-fab-grad);
    filter: brightness(1.1);
}

.app-container .chat-send-btn:disabled {
    background: var(--dch-hover);
    color: var(--dch-muted);
    box-shadow: none;
    cursor: not-allowed;
}

/* Notices inside the composer card */
.composer-notice {
    margin: 8px 12px 0;
    font-size: 12px;
    color: var(--dch-muted);
}

/* Guest limit CTA */
.guest-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
    padding: 14px 16px;
    border: 1px dashed var(--dch-border);
    border-radius: 14px;
}

.guest-cta-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--dch-text);
}

.guest-cta-btn {
    flex: none;
    height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--dch-fab-grad);
    color: #fff !important;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: filter 0.15s ease;
}

.guest-cta-btn:hover {
    filter: brightness(1.1);
    color: #fff;
}

/* ============================ Model picker popover ============================ */

.model-picker {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 14px;
    left: 14px;
    z-index: 1300;
    max-width: 460px;
    margin-left: auto;
    display: flex;
    flex-direction: column;
    background: var(--dch-surface);
    border: 1px solid var(--dch-border);
    border-radius: 14px;
    box-shadow: var(--dch-shadow-pop);
    overflow: hidden;
}

.picker-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--dch-border);
    color: var(--dch-muted);
}

.picker-search {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--dch-text);
    font-size: 14px;
}

.picker-close {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
}

.picker-close:hover {
    background: var(--dch-hover);
    color: var(--dch-text);
}

.picker-segments {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--dch-border);
}

.picker-seg {
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--dch-border);
    border-radius: 15px;
    background: transparent;
    color: var(--dch-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: 150ms ease;
}

.picker-seg.active {
    background: var(--dch-active-bg);
    border-color: var(--dch-accent);
    color: var(--dch-accent);
}

.picker-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
}

.picker-group-label {
    padding: 10px 10px 4px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dch-muted);
}

.picker-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--dch-text);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
}

.picker-item:hover {
    background: var(--dch-hover);
}

.picker-item.active {
    background: var(--dch-active-bg);
}

.picker-item-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-check {
    color: var(--dch-accent);
    font-size: 12px;
}

.picker-empty {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--dch-muted);
}

/* ============================ Page scope ============================ */
/* Chat is a viewport-filling surface; the marketing footer and legacy floating
   controls must not participate in its layout. */
html:has(.app-container),
body:has(.app-container),
body:has(.app-container)>section#app {
    height: 100%;
}

body:has(.app-container) {
    overflow: hidden;
}

body:has(.app-container)>section#app {
    height: 100dvh;
}

body:has(.app-container) .app-container {
    height: 100%;
    min-height: 0;
}

body:has(.app-container) .main-chat,
body:has(.app-container) .chat-messages {
    min-width: 0;
    min-height: 0;
}

body:has(.app-container) .site-footer {
    display: none;
}

body:has(.app-container) .scroll-to-top {
    display: none;
}

/* Old chat.css burger on mobile — superseded by .sidebar-float-toggle */
.app-container .mobile-menu-toggle {
    display: none !important;
}

/* Empty state uses the available upper half of the screen. Once a message
   exists, the composer becomes intrinsic so the conversation can use the
   remaining height instead of being forced into a 50/50 split. */
.app-container .chat-messages {
    margin-top: 75px;
}

.app-container .chat-messages.with-conversation {
    margin-top: 102px;
}

.app-container.has-messages .chat-footer {
    flex: 0 0 auto;
}

@media (max-width: 767.98px) {

    .chat-header-card,
    .app-container .chat-messages,
    .app-container .chat-input-container {
        width: calc(100% - 20px) !important;
    }

    .app-container .chat-header-card {
        margin-top: 78px;
    }

    .app-container .chat-messages {
        margin-top: 68px;
    }

    .app-container .chat-messages.with-conversation {
        margin-top: 78px;
    }

    .guest-cta {
        align-items: stretch;
        flex-direction: column;
    }
}

/* Collapse chevron: absolute in the column's top-right corner */
.sidebar-collapse-btn {
    position: absolute;
    top: 16px;
    right: 8px;
    z-index: 5;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--dch-muted);
    cursor: pointer;
    transition: 150ms ease;
}

.sidebar-collapse-btn:hover {
    color: var(--dch-accent);
    background: var(--dch-hover);
}

/* ============================ Desktop sidebar ============================ */
/* ≥992px: the sidebar is a permanent column (no overlay, no dimming);
   the drawer + backdrop + float toggle are mobile/tablet-only. */
@media (min-width: 992px) {
    .app-container .sidebar {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        transform: none;
        visibility: visible;
    }

    /* chat.css collapses content when .open is absent — never collapse on
       desktop, otherwise a dead empty rail remains in the flex row */
    .app-container .sidebar.closed {
        width: var(--dch-sidebar-w);
    }

    /* chat.css hides .text-content/.chat-block when closed; restore them */
    .app-container .sidebar:not(.open) .text-content {
        display: block;
    }

    .app-container .sidebar:not(.open) .chat-block {
        display: flex;
    }

    .app-container .sidebar:not(.open) .sidebar-new-chat {
        display: block;
    }

    .app-container .sidebar:not(.open) .sidebar-search {
        display: flex;
    }

    .app-container .sidebar:not(.open) .sidebar-sync {
        display: flex;
    }

    .app-container .sidebar:not(.open) .sidebar-user {
        display: flex;
    }

    .app-container .sidebar:not(.open) .chat-group-label {
        display: block;
    }

    .app-container .sidebar:not(.open) .chat-item-body {
        display: flex;
    }

    .app-container .sidebar:not(.open) .chat-avatar-mini {
        display: inline-flex;
    }

    .app-container .sidebar:not(.open) .compare-history-badge {
        display: inline-block;
    }

    .app-container .sidebar:not(.open) .chat-history-item {
        justify-content: flex-start;
        padding: 8px 10px;
    }

    /* The drawer is an overlay at every viewport size. It must not become a
       flex item, otherwise opening it shifts the conversation to the right. */
    .app-container .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        visibility: hidden;
        z-index: 1250;
    }

    .app-container .sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-backdrop {
        display: block;
    }

    .sidebar-float-toggle {
        display: inline-flex;
        z-index: 1260;
    }
}

/* ---- Light theme explicit surfaces ---- */
[data-bs-theme="light"] .app-container .chat-input-container,
[data-bs-theme="light"] .app-container .compare-branch,
[data-bs-theme="light"] .chat-header-card,
[data-bs-theme="light"] .model-picker,
[data-bs-theme="light"] .sidebar-float-toggle {
    background: var(--dch-surface);
}