/* ── SIDEBAR ── */
        .sidebar {
            width: 260px;
            background: var(--bg-1);
            display: flex;
            flex-direction: column;
            border-right: 1px solid var(--border);
            padding: 20px 14px;
            gap: 6px;
            flex-shrink: 0;
            min-height: 0;
            overflow: hidden;
            transition: width 0.18s ease, padding 0.18s ease;
        }

        .brand {
            display: grid;
            grid-template-columns: 32px minmax(0, 1fr) 32px;
            align-items: center;
            column-gap: 10px;
            padding: 0 8px 20px;
        }

        .sidebar-toggle-btn {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            border: 1px solid var(--border);
            background: var(--bg-2);
            color: var(--text-2);
            cursor: pointer;
            font-size: 15px;
            justify-self: end;
            transition: 0.18s ease;
        }

        .sidebar-toggle-btn:hover {
            border-color: var(--accent-mid);
            color: var(--accent);
        }

        .brand-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            background: var(--accent);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: var(--bg-0);
            font-size: 15px;
            box-shadow: var(--accent-glow);
        }

        .brand-name {
            font-weight: 700;
            font-size: 17px;
            letter-spacing: -0.3px;
            min-width: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: opacity 0.16s ease, width 0.16s ease;
        }

        .user-av {
            overflow: hidden;
            flex-shrink: 0;
        }

        .user-av img {
            width: 100%;
            height: 100%;
            display: block;
            object-fit: cover;
        }

        .new-chat-btn,
        #new-chat-btn {
            background: var(--accent-dim);
            border: 1px solid var(--accent-mid);
            color: var(--accent);
            padding: 10px 14px;
            border-radius: var(--radius);
            cursor: pointer;
            font-weight: 600;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: 0.2s;
        }

        .new-chat-btn:hover,
        #new-chat-btn:hover {
            background: var(--accent-mid);
            box-shadow: var(--accent-glow);
        }

        .sidebar-section {
            font-size: 10px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--text-3);
            padding: 20px 10px 6px;
        }

        .nav-item {
            display: grid;
            grid-template-columns: 20px minmax(0, 1fr);
            align-items: center;
            column-gap: 12px;
            min-height: 44px;
            padding: 9px 12px;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text-2);
            font-weight: 500;
            font-size: 14px;
            transition: 0.15s;
            border: 1px solid transparent;
            overflow: hidden;
        }

        .nav-item:hover {
            background: var(--bg-hover);
            color: var(--text);
        }

        .nav-item.active {
            background: var(--accent-dim);
            color: var(--accent);
            border-color: var(--accent-mid);
        }

        .sidebar.collapsed {
            width: 84px;
            padding: 20px 12px;
        }

        .sidebar.collapsed .brand {
            display: grid;
            grid-template-columns: 1fr;
            justify-items: center;
            align-items: center;
            row-gap: 12px;
            padding: 0 0 16px;
        }

        .sidebar.collapsed .sidebar-section,
        .sidebar.collapsed #new-chat-btn,
        .sidebar.collapsed #chat-history-list,
        .sidebar.collapsed .user-row {
            display: none !important;
        }

        .sidebar.collapsed .brand-name {
            width: 0;
            opacity: 0;
            pointer-events: none;
        }

        .sidebar.collapsed .sidebar-toggle-btn {
            justify-self: center;
            align-self: center;
            margin: 0;
        }

        .sidebar.collapsed .brand-icon {
            margin: 0;
        }

        .sidebar.collapsed .nav-item {
            grid-template-columns: 20px 0;
            column-gap: 0;
            justify-content: start;
            padding: 10px 12px;
        }

        .sidebar.collapsed .nav-item svg {
            width: 20px;
            height: 20px;
            margin: 0;
        }

        .nav-item svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
            stroke-width: 2;
            fill: none;
        }

        .sidebar.collapsed .nav-item-label {
            width: 0;
            opacity: 0;
            pointer-events: none;
        }

        .nav-item-label {
            min-width: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.2;
            transition: opacity 0.16s ease, width 0.16s ease;
        }

        .chat-history-list {
            display: flex;
            flex-direction: column;
            gap: 2px;
            overflow-y: auto;
            flex: 1 1 auto;
            min-height: 0;
            max-height: none;
            padding-right: 2px;
            overscroll-behavior: contain;
            scrollbar-gutter: stable;
        }

        .sidebar-history-panel {
            flex: 1 1 auto;
            min-height: 0;
        }

        .chat-history-item {
            padding: 7px 8px 7px 8px;
            font-size: 13px;
            color: var(--text-2);
            cursor: pointer;
            border-radius: 8px;
            transition: 0.14s ease;
            display: flex;
            align-items: center;
            gap: 8px;
            flex: 0 0 auto;
            border: 1px solid transparent;
            position: relative;
        }

        @supports (content-visibility: auto) {
            .chat-history-item {
                content-visibility: auto;
                contain: layout paint style;
                contain-intrinsic-size: 40px;
            }
        }

        .chat-history-item:hover {
            background: var(--bg-hover);
            color: var(--text);
        }

        .chat-history-item.active {
            background: var(--accent-dim);
            color: var(--accent);
            border-color: var(--accent);
        }

        .chat-history-item.is-pinned::before {
            content: '';
            position: absolute;
            left: 0;
            top: 10px;
            bottom: 10px;
            width: 2px;
            border-radius: 2px;
            background: var(--accent, #f43f5e);
        }

        .chat-history-title {
            flex: 1 1 auto;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .chat-kind-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            font-size: 12px;
            line-height: 1;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.08);
            flex: 0 0 auto;
        }

        .chat-kind-badge.kind-chat {
            background: rgba(99, 102, 241, 0.14);
            border-color: rgba(99, 102, 241, 0.32);
        }

        .chat-kind-badge.kind-image {
            background: rgba(244, 63, 94, 0.14);
            border-color: rgba(244, 63, 94, 0.32);
        }

        .chat-kind-badge.kind-video {
            background: rgba(139, 92, 246, 0.14);
            border-color: rgba(139, 92, 246, 0.32);
        }

        .chat-kind-badge.kind-mix {
            background: linear-gradient(135deg, rgba(244, 63, 94, 0.14), rgba(99, 102, 241, 0.14));
            border-color: rgba(244, 63, 94, 0.32);
        }

        .chat-history-actions {
            display: inline-flex;
            align-items: center;
            gap: 2px;
            flex: 0 0 auto;
            opacity: 0;
            transition: opacity 0.14s ease;
        }

        .chat-history-item:hover .chat-history-actions,
        .chat-history-item.active .chat-history-actions,
        .chat-history-item.is-pinned .chat-history-actions {
            opacity: 1;
        }

        .chat-history-action {
            width: 24px;
            height: 24px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            border: none;
            background: transparent;
            color: var(--text-3, #888);
            border-radius: 6px;
            cursor: pointer;
            font-size: 12px;
            line-height: 1;
            transition: 0.14s ease;
        }

        .chat-history-action:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--text, #fff);
        }

        .chat-history-pin.is-active {
            color: var(--accent, #f43f5e);
            opacity: 1;
        }

        .chat-history-delete:hover {
            color: #f87171;
            background: rgba(248, 113, 113, 0.12);
        }

        .chat-history-load-more {
            width: 100%;
            min-height: 36px;
            margin-top: 6px;
            border-radius: 10px;
            border: 1px solid var(--border);
            background: rgba(24, 24, 24, 0.94);
            color: var(--text-2);
            font: inherit;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.02em;
            cursor: pointer;
            transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
        }

        .chat-history-load-more:hover,
        .chat-history-load-more:focus-visible {
            border-color: var(--accent-mid);
            color: var(--text);
            background: rgba(255, 255, 255, 0.04);
        }

        .chat-history-load-more:disabled {
            cursor: wait;
            opacity: 0.72;
        }

        /* Legacy class kept for backward compatibility */
        .delete-chat {
            opacity: 0.4;
            font-size: 10px;
            cursor: pointer;
        }

        .delete-chat:hover {
            opacity: 1;
            color: var(--red);
        }

        .gallery-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 16px;
        }

        .image-queue-clear-btn {
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-3);
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 10px;
            cursor: pointer;
        }

        .image-queue-empty {
            font-size: 12px;
            color: var(--text-3);
            padding: 10px;
            text-align: center;
        }

        .image-queue-list {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .spacer {
            flex: 1;
        }

        .user-row {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px 10px;
            border-top: 1px solid var(--border);
            margin-top: auto;
            font-size: 13px;
            color: var(--text-2);
            cursor: pointer;
            border-radius: 8px;
            transition: 0.15s;
            flex-shrink: 0;
        }

        .user-row:hover {
            background: var(--bg-hover);
        }

        .user-av {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            background: var(--accent);
            color: var(--bg-0);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 12px;
        }
