/* ── 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: flex;
            align-items: center;
            gap: 12px;
            padding: 0 10px 20px;
        }

        .sidebar-toggle-btn {
            margin-left: auto;
            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;
            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;
        }

        .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 {
            padding: 9px 14px;
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 11px;
            color: var(--text-2);
            font-weight: 500;
            font-size: 14px;
            transition: 0.15s;
            border: 1px solid transparent;
        }

        .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 10px;
        }

        .sidebar.collapsed .brand {
            justify-content: center;
            gap: 0;
            padding: 0 0 12px;
        }

        .sidebar.collapsed .brand-name,
        .sidebar.collapsed .sidebar-section,
        .sidebar.collapsed #new-chat-btn,
        .sidebar.collapsed #chat-history-list,
        .sidebar.collapsed .user-row {
            display: none !important;
        }

        .sidebar.collapsed .sidebar-toggle-btn {
            margin-left: 0;
            margin-top: 8px;
        }

        .sidebar.collapsed .nav-item {
            justify-content: center;
            gap: 0;
            padding: 10px;
            font-size: 0;
        }

        .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;
        }

        .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;
        }

        .chat-history-item {
            padding: 7px 10px;
            font-size: 13px;
            color: var(--text-2);
            cursor: pointer;
            border-radius: 6px;
            transition: 0.15s;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex: 0 0 auto;
        }

        .chat-history-item:hover {
            background: var(--bg-hover);
            color: var(--text);
        }

        .chat-history-item.active {
            background: var(--accent-dim);
            color: var(--accent);
        }

        .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));
            grid-auto-rows: min-content;
            align-items: start;
            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;
        }

        /* ── MAIN ── */

        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
            overflow: hidden;
            min-width: 0;
        }

        .topbar {
            height: 56px;
            display: flex;
            align-items: center;
            padding: 0 24px;
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
            background: rgba(13, 13, 13, 0.7);
            backdrop-filter: blur(12px);
            flex-shrink: 0;
        }

        .topbar-title {
            font-weight: 600;
            font-size: 15px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .topbar-title .sep {
            color: var(--text-3);
            font-weight: 300;
        }

        .topbar-title .sub {
            color: var(--text-2);
            font-weight: 400;
        }

        .topbar-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .pill {
            padding: 5px 14px;
            border: 1px solid var(--border-bright);
            border-radius: 999px;
            font-size: 12px;
            cursor: pointer;
            color: var(--text-2);
            display: flex;
            align-items: center;
            gap: 6px;
            transition: 0.2s;
            background: var(--bg-2);
        }

        .pill:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .credits-chip {
            min-height: 38px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 5px 6px 5px 13px;
            border: 1px solid var(--accent-line);
            border-radius: 14px;
            font-size: 12px;
            font-weight: 800;
            color: var(--text-2);
            background:
                linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
                rgba(21, 19, 22, 0.94);
            box-shadow:
                inset 0 0 0 1px rgba(255, 255, 255, 0.025),
                0 10px 24px rgba(0, 0, 0, 0.18);
            white-space: nowrap;
        }

        .credits-chip-main {
            display: inline-flex;
            align-items: baseline;
            gap: 7px;
            min-width: 0;
        }

        .credits-chip-label {
            color: var(--text-3);
            font-size: 10px;
            font-weight: 900;
            letter-spacing: 0.08em;
            line-height: 1;
            text-transform: uppercase;
        }

        .credits-chip-value {
            color: var(--accent);
            font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
            font-size: 13px;
            font-weight: 900;
            letter-spacing: 0;
            line-height: 1;
        }

        .credits-chip-plan {
            min-height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 999px;
            padding: 0 10px;
            background: var(--credit-plan-bg, var(--accent-soft-18));
            border: 1px solid var(--credit-plan-line, var(--accent-line-strong));
            color: var(--credit-plan-text, var(--accent-text));
            font-size: 11px;
            font-weight: 900;
            letter-spacing: 0.01em;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
        }

        /* Plan tier variants — same accent stepped through alpha + lightness */
        .credits-chip--free {
            --credit-plan-bg: hsla(var(--accent-h), calc(var(--accent-s) - 40%), 45%, 0.16);
            --credit-plan-line: hsla(var(--accent-h), calc(var(--accent-s) - 30%), 55%, 0.42);
            --credit-plan-text: hsl(var(--accent-h), calc(var(--accent-s) - 30%), 78%);
        }

        .credits-chip--beginner {
            --credit-plan-bg: hsla(var(--accent-h), calc(var(--accent-s) - 10%), 50%, 0.18);
            --credit-plan-line: hsla(var(--accent-h), var(--accent-s), 60%, 0.48);
            --credit-plan-text: hsl(var(--accent-h), calc(var(--accent-s) + 5%), 82%);
        }

        .credits-chip--pro {
            --credit-plan-bg: var(--accent-soft-22);
            --credit-plan-line: var(--accent-line-strong);
            --credit-plan-text: var(--accent-text);
        }

        .credits-chip--proplus {
            --credit-plan-bg: hsla(var(--accent-h), var(--accent-s), calc(var(--accent-l) + 10%), 0.25);
            --credit-plan-line: hsla(var(--accent-h), var(--accent-s), calc(var(--accent-l) + 15%), 0.68);
            --credit-plan-text: hsl(var(--accent-h), calc(var(--accent-s) + 20%), 92%);
        }

        .credits-chip--low {
            border-color: rgba(242, 189, 95, 0.48);
            background:
                linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
                rgba(44, 32, 18, 0.78);
        }

        .credits-chip--low .credits-chip-value {
            color: #ffd06f;
        }

        .credits-chip--empty {
            border-color: rgba(255, 133, 133, 0.45);
            background:
                linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
                rgba(42, 20, 24, 0.78);
        }

        .credits-chip--empty .credits-chip-value {
            color: #ff9a9a;
        }

        /* ── OBSIDIAN VIEW PANELS ── */

        .obs-view {
            display: none;
            flex: 1;
            width: 100%;
            min-width: 0;
            min-height: 0;
            flex-direction: column;
            overflow: hidden;
        }

        .obs-view.active {
            display: flex !important;
        }

        .main > .obs-view:not(.active) {
            display: none !important;
        }
