/* ============================================
   Adplex — Main Application Styles
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Honor the HTML `hidden` attribute even when a more-specific rule sets
 * `display`. We rely on `hidden` to suppress the Designs / Templates
 * sidebar buttons during the legacy-data migration; without this rule
 * the .nav-item { display: flex } below wins and the buttons reappear. */
[hidden] { display: none !important; }

/* =============================================================================
 * Icon size bumps (UX polish)
 *
 * The codebase has hundreds of inline <svg width="N" height="N"> tags scattered
 * across templates and createElement() calls. Editing each one would be a
 * massive diff. Instead, scope a CSS rule to each known container that
 * OVERRIDES the inline width/height attributes.
 *
 * `svg[width][height]` selector + `!important` is needed because inline
 * width/height attributes have higher priority than non-!important CSS.
 *
 * Bumps applied:
 *   - Sidebar nav             20 → 22  (sturdier hit target, easier scanning)
 *   - Editor toolbar          18 → 20  (improves contrast in busy bar)
 *   - Editor left icon-bar    20 → 22  (parity with sidebar)
 *   - Insert panel buttons    18 → 20
 *   - Right-click menus       14 → 16  (much easier to scan)
 *   - Context menu items      ~      → 16
 *   - Floating toolbar        14 → 16
 *   - Adapt menu              ~      → 16
 *
 * If any spot looks off, scope the override more tightly OR override
 * specific subselectors back to their original size.
 * ============================================================================= */
.sidebar .nav-item svg[width] { width: 26px !important; height: 26px !important; }
.toolbar-btn svg[width]       { width: 20px !important; height: 20px !important; }
.icon-bar-btn svg[width]      { width: 22px !important; height: 22px !important; }
.insert-btn svg[width]        { width: 20px !important; height: 20px !important; }
.element-card svg[width]      { width: 22px !important; height: 22px !important; }
.context-menu-item svg[width],
.canvas-context-menu svg[width],
.adapt-menu svg[width],
.adapt-menu-item svg[width]   { width: 16px !important; height: 16px !important; }
.ft-btn svg[width]            { width: 16px !important; height: 16px !important; }

:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f2;
    --bg-surface: #e8e8ec;
    --bg-hover: #ededf0;
    --bg-active: #e0e0e6;

    --text-primary: #1a1a2e;
    --text-secondary: #5f6368;
    --text-muted: #646B78;   /* was #9aa0a6 (2.6:1 on white, fails WCAG AA) — audit 2026-11-08; #6B7280 → #646B78 2026-11-25 (4.39:1 on #F3F4F6 panels → ≥4.5 on every light surface) */

    --accent: #5B53E8;
    --accent-hover: #4f46e5;
    --accent-subtle: rgba(99, 102, 241, 0.1);
    --accent-secondary: #e8502f;
    --accent-secondary-hover: #d14527;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;

    --border: #e0e0e6;
    --border-subtle: #eaeaef;

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Consolidation tokens (UX consistency pass) — one focus ring, one modal
       backdrop, one card recipe, referenced by feature CSS so the look is
       constant across pages. */
    --focus-ring: 0 0 0 3px var(--accent-subtle);
    --overlay-bg: rgba(15, 23, 42, 0.55);
    --card-radius: 14px;
    --card-border: 1px solid var(--border);
    --card-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    --card-shadow-hover: 0 8px 26px rgba(16, 24, 40, 0.10);

    --transition: 150ms ease;
    /* Global UI font — change this one variable to re-skin the whole app. */
    --font: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --sidebar-width: 80px;
    --icon-bar-width: 54px;
    --left-panel-width: 300px;
    --right-panel-width: 300px;
    --toolbar-height: 52px;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* FORM-CONTROL BASELINE (audit 2026-11-08). Browsers do NOT inherit the page font into buttons/inputs/selects: every
   control without its own font rule rendered in Arial 13.33px (≈190 places). Element selectors = lowest specificity,
   so every class rule still wins; this only replaces the browser default. Checkboxes/radios take the brand accent. */
button, input, select, textarea { font-family: inherit; font-size: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent, #5B53E8); }
/* A bare <select>/<input>/<textarea> with no class of its own gets the design-system field look (DESIGN_SYSTEM.md
   inputs) instead of the grey 2px inset browser box. */
select:not([class]), textarea:not([class]),
input:not([class]):is([type="text"], [type="search"], [type="number"], [type="email"], [type="url"], [type="tel"], [type="password"], :not([type])) {
    border: 1px solid #E2E4EA; border-radius: 8px; background: #fff; color: var(--text-primary);
    padding: 6px 10px; min-height: 32px; box-sizing: border-box; outline: none;
}
select:not([class]):focus, textarea:not([class]):focus,
input:not([class]):is([type="text"], [type="search"], [type="number"], [type="email"], [type="url"], [type="tel"], [type="password"], :not([type])):focus {
    border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 3px rgba(91, 83, 232, 0.12);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* --- Scrollbar Styling --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* --- Focus Visible --- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
button:focus-visible, select:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* --- App Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
}

.app-layout.editor-mode .sidebar { display: none; }

/* --- Sidebar (Icon-only Vertical Bar) --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
    transition: width 0.16s ease;
}

.sidebar.hidden { display: none; }

/* Expanded sidebar — toggled by #sidebar-toggle, persisted per-device in a
   cookie. Wider rail; each item on ONE ROW (icon + label side by side). The
   default (collapsed) rail keeps the compact icon-over-label stack. */
.sidebar.is-expanded { width: 212px; align-items: stretch; }
/* Keep --sidebar-width in sync with the expanded rail so the fixed-position
   views (library / studio / composer use
   `inset: 0 0 0 var(--sidebar-width)`) shift right instead of being overlapped.
   Flex pages already reflow; these fixed layouts only know the variable. */
.app-layout:has(.sidebar.is-expanded) { --sidebar-width: 212px; }
/* AI Studio + the catalog template editor pin the rail collapsed (app.js
   _applyForcedSidebarState) and hide the expand toggle so it can't be widened
   there — those views need the horizontal space. */
.sidebar.sidebar--force-collapsed .sidebar-toggle { display: none; }
.sidebar.is-expanded .sidebar-logo { justify-content: flex-start; padding-left: 20px; }
.sidebar.is-expanded .sidebar-toggle { align-self: flex-end; margin-right: 12px; }
.sidebar.is-expanded .sidebar-nav { padding: 0 10px; align-items: stretch; }
.sidebar.is-expanded .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    height: auto;
    gap: 13px;
    padding: 9px 12px;
}
.sidebar.is-expanded .nav-item svg[width] { width: 20px !important; height: 20px !important; flex: 0 0 auto; }
.sidebar.is-expanded .nav-item .nav-label { font-size: 13px; line-height: 1.15; }
.sidebar.is-expanded .nav-group-label { width: 100%; text-align: left; font-size: 10px; padding: 7px 12px 3px; }
.sidebar.is-expanded .nav-warn-badge { top: 50%; right: 12px; transform: translateY(-50%); }
.sidebar.is-expanded .sidebar-bottom { align-items: stretch; }

/* Menu bigger/smaller toggle (top of the sidebar). */
.sidebar-toggle {
    margin-top: 10px;
    width: 36px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: none; color: var(--text-secondary);
    cursor: pointer; border-radius: 8px; flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-toggle svg { width: 19px; height: 19px; }

/* Collapsed rail: app.js _placeSidebarToggle() relocates the collapse/expand
   button into the bottom cluster, directly above Settings (easier to reach than
   the header in the compact rail). Render it as a full-width ghost row that sits
   apart from the account items below it with a hairline separator. */
.sidebar-bottom > .sidebar-toggle {
    margin-top: 0;
    width: 44px; height: 40px;
    padding-bottom: 6px; margin-bottom: 2px;
    border-bottom: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.sidebar-logo {
    padding: 16px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.sidebar-logo svg {
    color: var(--accent);
    width: 32px;
    height: 32px;
}

/* (A `.sidebar-logo span { display: none; }` rule from the first sidebar design lived here. It hid
   the brand block AND the bell's alert dot — both are spans — so neither ever showed. Removed 2026-10-31.) */

/* ── Project switcher (top of sidebar) ──────────────────────────────────── */
/* The button is a picker: [logo] PROJECT / name ⌃⌄. The list opens right under it (to the right of
   it when the sidebar is collapsed to icons). Redesigned 2026-10-31: the old centred name box did
   not read as clickable, its list opened detached beside it, and the type was too small. */
.project-switcher {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding: 4px 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 6px;
}
.project-switcher-btn {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    width: 100%; box-sizing: border-box;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 10px;
    background: var(--bg-primary, #fff);
    padding: 8px 8px 8px 8px;
    cursor: pointer; text-align: left;
    font-family: inherit;
    color: var(--text-primary, #111827);
    transition: border-color .12s, box-shadow .12s, background .12s;
}
.project-switcher-btn:hover { border-color: var(--accent, #5B53E8); background: #fafaff; }
.project-switcher.is-open .project-switcher-btn { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 3px rgba(91, 83, 232, 0.14); }
.psw-btn__avatar { width: 36px !important; height: 36px !important; border-radius: 9px !important; font-size: 16px !important; }
.psw-btn__all { background: linear-gradient(135deg, #5B53E8, #a855f7) !important; color: #fff !important; }
.psw-btn__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.psw-btn__kicker {
    font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-tertiary, #9ca3af); line-height: 1.2;
}
.psw-btn__name {
    font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--text-primary, #111827);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-switcher-caret { flex: 0 0 auto; display: inline-flex; color: #646B78; }
.project-switcher-btn:hover .project-switcher-caret,
.project-switcher.is-open .project-switcher-caret { color: var(--accent, #5B53E8); }

/* ── The list: search on top, scrolling projects, actions pinned at the bottom ── */
.project-switcher-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    left: 10px;
    top: calc(100% - 6px);           /* right under the button */
    width: 348px;
    max-height: min(640px, calc(100vh - 140px));
    background: #fff;
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.20);
    z-index: 200;
    overflow: hidden;
    font-family: var(--font-sans, 'IBM Plex Sans', system-ui, sans-serif);
}
/* Collapsed rail: the button is a 48px tile, so the list opens beside it. */
.sidebar:not(.is-expanded) .project-switcher-menu { left: calc(100% + 6px); top: 4px; max-height: min(640px, calc(100vh - 24px)); }
.project-switcher.is-open .project-switcher-menu { display: flex; }
/* The switcher menu is position:absolute INSIDE the sidebar, so it can only
   stack as high as the sidebar's own stacking context (z-index:10). Page roots
   like .studio-layout are position:fixed at z-index:100+, which would bury the
   menu. While the menu is OPEN, lift the whole sidebar above page content +
   page-level modals so the popup is visible on every page. Scoped via :has()
   so normal stacking (z-index:10) is unchanged when the menu is closed. */
.sidebar:has(.project-switcher.is-open) { z-index: 10050; }

.psw-search {
    position: relative; flex: 0 0 auto;
    display: flex; align-items: center;
    padding: 10px 10px 9px;
    border-bottom: 1px solid var(--border-subtle, #eef0f3);
}
.psw-search__ico { position: absolute; left: 23px; top: 50%; transform: translateY(-50%); margin-top: 1px; color: #646B78; display: inline-flex; pointer-events: none; }
.psw-search__ico svg { width: 17px; height: 17px; }
.psw-search__input {
    width: 100%; height: 42px; box-sizing: border-box;
    border: 1px solid var(--border-subtle, #e5e7eb); border-radius: 9px;
    padding: 0 34px 0 38px;
    font: inherit; font-size: 15px; color: var(--text-primary, #111827);
    background: var(--bg-secondary, #f8f9fb);
    outline: none;
    transition: border-color .12s, box-shadow .12s, background .12s;
}
.psw-search__input::placeholder { color: #9ca3af; }
.psw-search__input:focus { border-color: var(--accent, #5B53E8); background: #fff; box-shadow: 0 0 0 3px rgba(91, 83, 232, 0.14); }
.psw-search__clear {
    position: absolute; right: 18px; top: 50%; transform: translateY(-50%); margin-top: 1px;
    width: 24px; height: 24px; border: none; border-radius: 6px;
    background: transparent; color: #646B78; font-size: 19px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.psw-search__clear:hover { background: var(--bg-secondary, #f3f4f6); color: var(--text-primary, #111827); }
.psw-search__clear[hidden] { display: none; }

.psw-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.psw-foot { flex: 0 0 auto; padding: 6px; border-top: 1px solid var(--border-subtle, #eef0f3); background: #fcfcfd; }
.psw-foot:empty { display: none; }

.project-switcher-item {
    display: flex; align-items: center; gap: 11px; width: 100%;
    border: none; background: transparent; cursor: pointer;
    padding: 8px 10px; border-radius: 9px; font-size: 14.5px; font-weight: 500;
    color: var(--text-primary, #111827); text-align: left;
    font-family: inherit;
}
.project-switcher-item[hidden] { display: none; }
.project-switcher-item:hover,
.project-switcher-item.is-hl { background: var(--bg-secondary, #f3f4f6); }
.project-switcher-item.is-active { background: #eef2ff; color: #4338ca; font-weight: 600; }
.project-switcher-item.is-active.is-hl { background: #e0e7ff; }
.project-switcher-item.is-hl { box-shadow: inset 0 0 0 1px rgba(91, 83, 232, 0.28); }
.project-switcher-item-label { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.psw-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.3; }
.psw-name mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }
.psw-avatar {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 0;
    box-sizing: border-box;
}
/* The project's logo (display logo, else brand-kit logo) — a white tile so dark and transparent
   marks both read; contain, never crop a wordmark. */
.psw-avatar.has-logo {
    background: #fff;
    border: 1px solid var(--border-subtle, #e5e7eb); padding: 3px; overflow: hidden;
}
.psw-avatar.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.psw-icon {
    flex: 0 0 auto; width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-secondary, #f3f4f6); color: var(--text-secondary, #4b5563);
}
.psw-check { flex: 0 0 auto; margin-left: auto; color: var(--accent, #5B53E8); display: inline-flex; }
.psw-check svg { width: 17px; height: 17px; }
.project-switcher-count + .psw-check { margin-left: 4px; }
.psw-tag {
    flex: 0 0 auto; font-size: 11.5px; font-weight: 600; color: #b91c1c;
    background: #fee2e2; border-radius: 5px; padding: 1px 7px;
}
.project-switcher-item-sub {
    display: block; font-size: 12.5px; font-weight: 400; color: #646B78;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; line-height: 1.3;
}
.project-switcher-item.is-active .project-switcher-item-sub { color: #6d6af0; }
.project-switcher-pending .psw-name { color: #b91c1c; }
.project-switcher-heading {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #646B78;
    padding: 12px 10px 5px;
}
.project-switcher-heading[hidden] { display: none; }
.psw-heading__n { font-weight: 600; letter-spacing: 0; color: #646B78; }
/* "All projects" — a view, not a project: an icon row at the top of the list. */
.project-switcher-all .psw-icon { background: linear-gradient(135deg, #5B53E8, #a855f7); color: #fff; }
.project-switcher-all.is-active { background: #eef2ff; }
.project-switcher-new { color: #4f46e5; font-weight: 600; }
.project-switcher-new .psw-icon { background: #eef2ff; color: #4f46e5; }
.project-switcher-invite { color: var(--text-primary, #111827); font-weight: 500; }
.psw-empty { padding: 18px 12px 14px; text-align: center; }
.psw-empty[hidden] { display: none; }
.psw-empty__txt { font-size: 14px; color: var(--text-secondary, #6b7280); margin-bottom: 10px; word-break: break-word; }
.psw-empty__create {
    border: 1px dashed #c7d2fe; background: #f5f3ff; color: #4f46e5;
    border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.psw-empty__create:hover { border-color: var(--accent, #5B53E8); }
@media (max-width: 600px) {
    .project-switcher-menu { width: min(320px, calc(100vw - 80px)); }
}

/* New-project modal */
.cb-project-modal .modal-header { align-items: flex-start; }
.cb-project-sub { font-size: 12.5px; color: #6b7280; margin-top: 4px; line-height: 1.45; max-width: 380px; }
.cb-project-field { margin-bottom: 14px; display: flex; flex-direction: column; }
.cb-project-field .auth-label { margin-bottom: 5px; }
.cb-project-locale-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cb-project-locale-row .cb-project-field { margin-bottom: 0; }
.cb-project-select { appearance: auto; -webkit-appearance: auto; background: #fff; cursor: pointer; }
.cb-project-invalid { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.12) !important; }
.cb-project-fielderr { margin-top: 7px; font-size: 12px; color: #dc2626; }
@media (max-width: 480px) { .cb-project-locale-row { grid-template-columns: 1fr; } }

/* Project-type picker — prominent selectable cards (replaces a plain select) */
.cb-ptype { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cb-ptype__card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 11px 11px; border: 1.5px solid #e5e7eb; border-radius: 12px; background: #fff; cursor: pointer; text-align: left; transition: border-color .12s, background .12s, box-shadow .12s; }
.cb-ptype__card:hover { border-color: #c7cbd6; background: #fcfcfd; }
.cb-ptype__card.is-on { border-color: #5B53E8; background: #f5f5ff; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.cb-ptype__ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #f3f4f6; color: #6b7280; flex: 0 0 auto; }
.cb-ptype__ico svg { width: 17px; height: 17px; }
.cb-ptype__card.is-on .cb-ptype__ico { background: #5B53E8; color: #fff; }
.cb-ptype__title { font-size: 13px; font-weight: 700; color: #1f2433; }
.cb-ptype__desc { font-size: 11px; line-height: 1.35; color: #646B78; }
.cb-ptype__check { position: absolute; top: 9px; right: 9px; width: 16px; height: 16px; border-radius: 50%; background: #5B53E8; color: #fff; display: none; align-items: center; justify-content: center; }
.cb-ptype__check svg { width: 11px; height: 11px; }
.cb-ptype__card.is-on .cb-ptype__check { display: flex; }
@media (max-width: 480px) { .cb-ptype { grid-template-columns: 1fr; } }

/* ============================================================
   New Project modal — state-of-the-art redesign (scoped to
   .cb-project-create so the shared .cb-manage-modal is untouched)
   ============================================================ */
.cb-project-create { border-radius: 18px; }
.cb-project-create .modal-header {
    align-items: flex-start;
    gap: 14px;
    padding: 22px 22px 18px;
    background: linear-gradient(180deg, #f6f7ff 0%, #ffffff 100%);
    border-bottom: 1px solid #eef0f6;
    position: relative;
}
.cb-project-headicon {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #5B53E8 0%, #8b5cf6 55%, #a855f7 100%);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.38);
}
.cb-project-headtext { flex: 1 1 auto; min-width: 0; padding-right: 36px; }   /* clears the floating .cb-close (header pad 22 + 36 ≥ 56) */
.cb-project-create .modal-header h2 {
    margin: 1px 0 5px;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: #0f172a;
}
.cb-project-create .cb-project-sub { margin: 0; max-width: none; }

.cb-project-create .modal-body { padding: 20px 22px 6px; }
.cb-project-create .auth-label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    letter-spacing: 0.005em;
    margin-bottom: 7px;
}
.cb-project-create .auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    font-size: 14px;
    color: #0f172a;
    background: #fff;
    border: 1px solid #e2e5ee;
    border-radius: 11px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.cb-project-create .auth-input::placeholder { color: #9ca3af; }
.cb-project-create .auth-input:focus {
    outline: none;
    border-color: #5B53E8;
    box-shadow: var(--focus-ring);
}

/* Name field with a leading icon inside the input */
.cb-project-field-name { margin-bottom: 20px; }
.cb-project-input-icon { position: relative; }
.cb-project-input-ico {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    color: #646B78;
    pointer-events: none;
}
.cb-project-input-icon .auth-input { padding-left: 38px; }
.cb-project-input-icon:focus-within .cb-project-input-ico { color: #5B53E8; }

/* "Locale defaults · optional" divider label */
.cb-project-grouplabel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 12px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #646B78;
}
.cb-project-grouplabel::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #eef0f6;
}

.cb-project-create .cb-project-locale-row { gap: 11px; }
.cb-project-create .cb-project-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 13px;
}

.cb-project-create .modal-footer {
    padding: 15px 22px 20px;
    border-top: 1px solid #f1f2f7;
}
.cb-project-create .modal-footer .btn { border-radius: 10px; padding: 10px 16px; font-weight: 600; }
.cb-project-create-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, #5B53E8 0%, #7c3aed 100%);
    border: 0;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.32);
}
.cb-project-create-btn:hover { filter: brightness(1.04); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4); }
.cb-project-create-btn svg { margin-left: -2px; }

/* Project switcher — collaborator count badge */
.project-switcher-count { margin-left: auto; flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #eef2ff; color: #4f46e5; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.project-switcher-leave { color: #b91c1c; font-weight: 600; }

/* Project tag — shown on entity cards in the "All projects" bulk view so you
   can see which project a platform / rule / client / brand kit belongs to. */
.cb-proj-tag { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: #eef2ff; color: #4f46e5; line-height: 1.4; white-space: nowrap; vertical-align: middle; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.cb-proj-tag-shared { background: #ecfeff; color: #0e7490; }
.cb-proj-tag-none { background: #f3f4f6; color: #646B78; }
.rules-list__projtag { margin-top: 4px; }
.meta-conn-name-wrap .cb-proj-tag { margin-top: 3px; align-self: flex-start; }
.vlib-editor-list-item .cb-proj-tag { margin-top: 3px; }

/* "Move to project" attach control (brand-kit + connection cards) */

/* Settings page — LEFT vertical tab rail + RIGHT content pane
   (API Keys · Platforms · Inspiration · Brand Kits) */
/* Standing rule (CLAUDE.md / #96): every centered non-full-width page uses the 1320px
   content column — Settings included (was an ad-hoc 1060 straggler). The body cap widens
   to 900 so the rail + content fill the wider column instead of hugging the left edge. */
.account-page.settings-page { max-width: 1320px; }
.settings-layout {
    display: flex;
    gap: 36px;
    align-items: flex-start;
    margin-top: 20px;
}
.settings-rail {
    flex: 0 0 196px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: sticky;
    top: 24px;
}
.settings-body {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 900px;
}
/* Shopify-style settings nav: neutral gray pills, dark text on a light-gray
   selected state (no colored highlight), medium weight, calm spacing. */
.settings-tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.settings-tab-ico {
    display: inline-flex;
    flex-shrink: 0;
    color: currentColor;
    opacity: 0.7;
}
.settings-tab-ico svg { width: 17px; height: 17px; }
.settings-tab-btn:hover { color: #1a1a1a; background: #f6f6f7; }
.settings-tab-btn.active { color: #1a1a1a; background: #f1f1f1; font-weight: 600; }
.settings-tab-btn.active .settings-tab-ico { opacity: 1; }
/* Stack the rail above content on narrow screens so it doesn't crowd the column */
@media (max-width: 720px) {
    /* stretch, not flex-start: a flex-start column let the rail grow to its full row width (635px on a 390px phone)
       and the content past the screen edge (audit 2026-11-08). */
    .settings-layout { flex-direction: column; gap: 16px; align-items: stretch; }
    .settings-rail { flex: none; flex-direction: row; position: static; overflow-x: auto; min-width: 0; max-width: 100%; }
    .settings-body { max-width: 100%; min-width: 0; }
}
/* Shared tab header row: intro text left, primary action right. */
.settings-tab-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.settings-tab-head .btn { flex-shrink: 0; }

/* Inspiration tab — card-style rows to match the API-Keys cards + brand cards */
.settings-insp-list { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.settings-insp-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e1e3e5;
    border-radius: 10px;
}
.settings-insp-label { flex: 0 0 150px; }
.settings-insp-url { flex: 1; min-width: 0; }
.settings-insp-row .auth-input { padding: 8px 11px; border-radius: 8px; }
.settings-insp-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }

/* Brand Kits tab — project group heading as a clean section label */
.settings-bk-group { margin: 0 0 26px; }
.settings-bk-group > .account-key-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #9ca3af);
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle, #eef0f3);
}

/* Manage-project sections — Shopify-style cards (used in the Settings Project /
   Collaborators tabs and the manage-project modal). Discrete white cards with a
   soft 1px border + faint shadow, matching .account-key-block. */
/* The 70vh internal scroll is a MODAL constraint only (a dialog must not exceed the
   viewport). When these same sections render INLINE in the Settings Project / Collaborators
   tabs the host is .settings-tab-content.cb-manage-body (NO .modal-body), so it must NOT get
   a nested scroller — the content flows full-height and the main content column scrolls the
   whole page (user 2026-07-04: "scroll the entire window, not internally"). Scoping to
   .modal-body keeps the modal capped while freeing the inline Settings pane. */
.modal-body.cb-manage-body { max-height: 70vh; overflow-y: auto; }
.cb-manage-sec {
    background: #fff;
    border: 1px solid #e1e3e5;
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.cb-manage-sec:last-child { margin-bottom: 0; }
.cb-manage-sec-title { font-size: 14px; font-weight: 600; color: #1a1a1a; margin-bottom: 6px; letter-spacing: -0.005em; }
.cb-manage-hint { font-size: 12px; color: #6b7280; line-height: 1.45; margin-bottom: 10px; }
.cb-manage-label { font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 6px; }

/* Settings → Project → Product variants (variant grouping, schema v119). */
.cb-vg-status { font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; background: #F4F5F8; color: #374151; }
.cb-vg-status.is-on { background: #EEEDFC; color: #3F37C9; }
.cb-vg-status.is-off { background: #F4F5F8; color: #374151; }
.cb-vg-status.is-err { background: #FEF3F2; color: #B42318; }
.cb-vg-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.cb-vg-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid #E6E8EE; border-radius: 10px; cursor: pointer; background: #fff; }
.cb-vg-opt:hover { border-color: #C9C6F4; }
.cb-vg-opt.is-checked { border-color: var(--accent, #5B53E8); background: #F7F6FE; }
.cb-vg-opt input { margin: 2px 0 0; accent-color: var(--accent, #5B53E8); flex: none; }
.cb-vg-opt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cb-vg-opt-label { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.cb-vg-opt-hint { font-size: 12px; color: #6b7280; line-height: 1.4; }
.cb-vg-switch { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid #E6E8EE; border-radius: 10px; cursor: pointer; background: #fff; margin-bottom: 8px; }
.cb-vg-switch.is-checked { border-color: var(--accent, #5B53E8); background: #F7F6FE; }
.cb-vg-switch input { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; margin: 0; border-radius: 11px; background: #D0D4DC; position: relative; cursor: pointer; transition: background .15s; }
.cb-vg-switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.cb-vg-switch input:checked { background: var(--accent, #5B53E8); }
.cb-vg-switch input:checked::after { transform: translateX(16px); }
.cb-vg-switch input:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 2px; }
.cb-vg-auto { background: none; border: 0; padding: 0; margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--accent, #5B53E8); cursor: pointer; }
.cb-vg-auto:hover { text-decoration: underline; }
.cb-vg-err { color: #B42318; }
.cb-vg-detail { font-size: 12px; color: #4B5263; line-height: 1.5; display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; overflow-wrap: anywhere; }

/* ── Collaborators: people with access + invite ───────────────────────────────
   One component for owner, admin and member alike (see _renderCollaborators). The row is
   avatar | name+sub | badge | actions, so the eye lands on WHO first and the state second.
   Accent is the global indigo token. */
.cb-collab-sec { margin-bottom: 22px; }
.cb-collab-sec:last-child { margin-bottom: 0; }
.cb-collab-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cb-collab-title { font-size: 14px; font-weight: 650; color: #1a1a1a; letter-spacing: -0.005em; margin: 0; }
.cb-collab-count {
    font-size: 11px; font-weight: 700; line-height: 1;
    padding: 3px 7px; border-radius: 20px;
    background: var(--accent-subtle, rgba(99,102,241,.1)); color: var(--accent-hover, #4f46e5);
}
.cb-collab-hint { font-size: 12px; color: #6b7280; line-height: 1.5; margin: 0 0 12px; }

.cb-collab-list { display: flex; flex-direction: column; gap: 6px; }
.cb-collab-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 11px; border: 1px solid #eef0f3; border-radius: 10px; background: #fff;
    transition: border-color .14s, box-shadow .14s;
}
.cb-collab-row:hover { border-color: #e2e5ea; box-shadow: 0 1px 3px rgba(16,24,40,.05); }
.cb-collab-row.is-pending { background: #fffdf7; border-color: #f3e8cf; }

/* Deterministic hue per person (set inline) so the same face keeps the same swatch. */
.cb-collab-av {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 700; color: #fff; user-select: none;
    background: hsl(var(--av-h, 232) 58% 52%);
}
.cb-collab-av.is-pending {
    background: #fff; color: #b08b3e; border: 1px dashed #dcc79a; font-weight: 800;
}

.cb-collab-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cb-collab-email {
    font-size: 13.5px; color: #1f2937; font-weight: 550;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cb-collab-sub { font-size: 11.5px; color: #646B78; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cb-collab-badge {
    flex: 0 0 auto; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 6px; background: #f3f4f6; color: #4b5563;
}
.cb-collab-badge.is-owner   { background: var(--accent-subtle, rgba(99,102,241,.1)); color: var(--accent-hover, #4f46e5); }
.cb-collab-badge.is-pending { background: #fef3c7; color: #92400e; }

/* Actions stay VISIBLE rather than hover-only — a control you cannot find is not a control,
   and hover does not exist on touch. They just sit quiet until you approach them. */
.cb-collab-act {
    flex: 0 0 auto; cursor: pointer;
    background: none; border: 1px solid #e5e7eb; color: #6b7280;
    font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 7px;
    transition: color .14s, border-color .14s, background .14s;
}
.cb-collab-act:hover { color: #374151; border-color: #d1d5db; background: #f9fafb; }
.cb-collab-act.is-danger:hover { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.cb-collab-act:disabled { opacity: .55; cursor: default; }
.cb-collab-act:focus-visible { outline: 2px solid var(--accent, #5B53E8); outline-offset: 1px; }

.cb-collab-empty, .cb-collab-skel { font-size: 12.5px; color: #646B78; padding: 10px 2px; }
.cb-collab-error { font-size: 12.5px; color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 12px; }
.cb-collab-note {
    font-size: 12.5px; color: #6b7280;
    background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 10px 12px;
}

/* Invite: input + button read as ONE control, and the whole group takes the focus ring so the
   button never looks detached from the field it submits. */
.cb-collab-form { display: flex; flex-direction: column; gap: 6px; }
.cb-collab-field {
    display: flex; align-items: stretch; gap: 0;
    border: 1px solid #e2e5ea; border-radius: 10px; background: #fff; overflow: hidden;
    transition: border-color .14s, box-shadow .14s;
}
.cb-collab-field:focus-within { border-color: var(--accent, #5B53E8); box-shadow: 0 0 0 3px var(--accent-subtle, rgba(99,102,241,.1)); }
.cb-collab-field.is-err { border-color: #fca5a5; }
.cb-collab-field.is-err:focus-within { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.cb-collab-input {
    flex: 1 1 auto; min-width: 0;
    border: 0 !important; background: transparent !important; box-shadow: none !important;
    padding: 10px 12px; font-size: 13.5px; border-radius: 0;
}
.cb-collab-input:focus { outline: none; box-shadow: none !important; }
.cb-collab-send { flex: 0 0 auto; border-radius: 0; white-space: nowrap; padding-left: 16px; padding-right: 16px; }
.cb-collab-send:disabled { opacity: .5; cursor: default; }
.cb-collab-msg { font-size: 11.5px; color: #6b7280; min-height: 15px; line-height: 1.3; }
.cb-collab-msg.is-err { color: #b91c1c; }

.cb-collab-linkrow { margin-top: 10px; }
.cb-collab-link {
    display: inline-flex; align-items: baseline; gap: 7px; cursor: pointer;
    background: none; border: 0; padding: 4px 0;
    color: var(--accent-hover, #4f46e5); font-size: 12.5px; font-weight: 600;
}
.cb-collab-link:hover { text-decoration: underline; }
.cb-collab-link:disabled { opacity: .6; cursor: default; text-decoration: none; }
.cb-collab-link-note { color: #646B78; font-weight: 500; font-size: 11.5px; text-decoration: none; }

@media (max-width: 560px) {
    /* The badge is the first thing to go: the row still reads without it, and the actions must
       not wrap under the avatar on a phone. */
    .cb-collab-badge { display: none; }
    .cb-collab-field { flex-wrap: wrap; }
    .cb-collab-send { width: 100%; border-radius: 0 0 9px 9px; }
}
.cb-project-invite-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cb-project-invite-row .bx-in { flex: 1 1 220px; min-width: 0; }
.cb-manage-inline { display: flex; gap: 8px; align-items: stretch; }
.cb-manage-inline .auth-input { flex: 1; }
.cb-manage-inline .btn { white-space: nowrap; }
.cb-manage-linkrow { margin-top: 8px; }
.cb-manage-linkbtn { background: none; border: 0; color: #4f46e5; font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 0; }
.cb-manage-linkbtn:hover { text-decoration: underline; }
.cb-manage-roster { display: flex; flex-direction: column; gap: 6px; }
.cb-manage-person { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid #eef0f3; border-radius: 8px; background: #fff; }
.cb-manage-person-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #1f2937; }
.cb-manage-badge { flex: 0 0 auto; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #f3f4f6; color: #4b5563; text-transform: uppercase; letter-spacing: .03em; }
.cb-manage-badge-owner { background: #eef2ff; color: #4f46e5; }
.cb-manage-badge-pending { background: #fef3c7; color: #92400e; }
.cb-manage-pending .cb-manage-person-email { color: #6b7280; }
.cb-manage-x { flex: 0 0 auto; background: none; border: 1px solid #fecaca; color: #b91c1c; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px; cursor: pointer; }
.cb-manage-x:hover { background: #fef2f2; }
.cb-manage-x:disabled { opacity: .5; cursor: default; }
.cb-manage-loading, .cb-manage-empty { font-size: 12.5px; color: #646B78; padding: 8px 2px; }
.cb-manage-danger { border-top: 1px solid #fde8e8; }
.cb-manage-delbtn { background: #fff; border: 1px solid #fecaca; color: #b91c1c; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.cb-manage-delbtn:hover { background: #fef2f2; }
.cb-manage-delbtn.armed { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.cb-manage-delbtn:disabled { opacity: .6; cursor: default; }
/* Admin Fast Delete — deliberately heavier than the 72h soft delete above it,
   because it is immediate and irreversible. Sits below its own hint line. */
.cb-manage-fastdel { margin-top: 8px; border-color: #b91c1c; background: #fef2f2; }
.cb-manage-fastdel:hover { background: #fee2e2; }
.cb-manage-fastdel:disabled { opacity: .6; cursor: default; }

/* Admin → Projects tab: every project on the platform, one row each. */
.admin-proj-list { margin-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.admin-proj-row {
    /* fixed last column: an `auto` one sized to the Delete button in rows but to nothing in the
       header, so every header label sat left of its column. */
    display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) 110px 76px;
    gap: 10px; align-items: center; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0); background: #fff; font-size: 13px;
}
.admin-proj-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-proj-head {
    border: 0; background: transparent; padding-bottom: 2px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted, #64748b); font-weight: 600;
}
.admin-proj-name { font-weight: 600; }
.admin-proj-owner { color: var(--text-muted, #64748b); }
.admin-proj-status { color: var(--text-muted, #64748b); }
.admin-proj-row.is-pending { background: #fffbeb; border-color: #fde68a; }
.admin-proj-row.is-pending .admin-proj-status { color: #b45309; font-weight: 600; }
.admin-proj-del { padding: 6px 12px; font-size: 12px; justify-self: end; }
@media (max-width: 640px) {
    /* Stack on narrow screens — a 4-column grid would force the page sideways. */
    .admin-proj-row { grid-template-columns: 1fr auto; row-gap: 2px; }
    .admin-proj-head { display: none; }
    .admin-proj-owner, .admin-proj-status { grid-column: 1; font-size: 12px; }
    .admin-proj-del { grid-row: 1 / span 3; grid-column: 2; align-self: center; }
}

/* Fast Delete confirmation — the destructive dialog. Closes on X/Escape only. */
.cb-fastdel-modal .modal-body { padding-top: 4px; }
.cb-fastdel-name { font-weight: 600; font-size: 15px; margin-bottom: 8px; word-break: break-word; }
.cb-fastdel-warn { color: #b91c1c; font-weight: 600; font-size: 13px; margin: 0 0 10px; }
.cb-fastdel-list { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: var(--text-muted, #64748b); }
.cb-fastdel-list li { margin: 3px 0; }
.cb-fastdel-keep { font-size: 12px; color: var(--text-muted, #64748b); margin: 0; }
.cb-fastdel-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
.cb-fastdel-go { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.cb-fastdel-go:hover { background: #7f1d1d; border-color: #7f1d1d; }
.cb-fastdel-go:disabled { opacity: .7; cursor: default; }
/* Pending-deletion (72h cooldown) + restore */
.cb-manage-pending { color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 9px 11px; margin-bottom: 10px; }
.cb-manage-restorebtn { background: #ecfdf5; border: 1px solid #a7f3d0; color: #047857; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 8px; cursor: pointer; }
.cb-manage-restorebtn:hover { background: #d1fae5; }
.cb-manage-restorebtn:disabled { opacity: .6; cursor: default; }

/* Project logo drop zone (Settings → Project) */
.cb-logo-drop {
    display: flex; align-items: center; gap: 14px;
    border: 1.5px dashed var(--border-subtle, #d8dbe2); border-radius: 10px;
    padding: 12px 14px; background: var(--bg-secondary, #f9fafb);
    transition: border-color .12s, background .12s; outline: none;
}
.cb-logo-drop.is-drag { border-color: var(--accent, #5B53E8); background: #eef2ff; }
.cb-logo-drop.is-busy { opacity: .6; pointer-events: none; }
.cb-logo-preview {
    width: 84px; height: 64px; flex: 0 0 auto; border-radius: 8px;
    background: #fff; border: 1px solid var(--border-subtle, #e6e6ec);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cb-logo-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cb-logo-empty { font-size: 11px; color: #646B78; text-align: center; padding: 0 6px; line-height: 1.3; }
.cb-logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cb-logo-remove { color: #b91c1c; border-color: #fecaca; }
.cb-logo-remove:hover { background: #fef2f2; }

/* Square logo cropper (project display logo) — drag image, zoom slider/wheel */
.cb-crop-modal { width: 360px; max-width: calc(100vw - 32px); }
.cb-crop-vp {
    width: 280px; height: 280px; margin: 0 auto;
    position: relative; overflow: hidden;
    border: 1px solid var(--border-subtle, #e5e7eb); border-radius: 10px;
    background: conic-gradient(#f3f4f6 0 25%, #fff 0 50%, #f3f4f6 0 75%, #fff 0) 0 0 / 20px 20px;
    cursor: grab; touch-action: none;
}
.cb-crop-vp.is-drag { cursor: grabbing; }
.cb-crop-vp img {
    position: absolute; left: 0; top: 0;
    transform-origin: 0 0;
    max-width: none; max-height: none;
    user-select: none; pointer-events: none;
}
.cb-crop-zoom { width: 280px; display: block; margin: 12px auto 0; }
.cb-crop-hint { font-size: 12px; color: var(--text-secondary, #6b7280); text-align: center; margin-top: 10px; }
.cb-crop-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    flex: 1;
    /* Hidden until app.js resolves project-scoped visibility (Brand/Products
       are gated). Without this the nav paints ALL items, then JS hides the
       gated ones — a visible flash. We reveal via .nav-ready after the first
       _updateProjectScopedNav() pass. */
    opacity: 0;
    transition: opacity 0.12s ease;
}
.sidebar-nav.nav-ready { opacity: 1; }

.sidebar-bottom {
    padding: 8px;
    border-top: 1px solid var(--border-subtle);
    width: 100%;
    /* Column layout so Settings + Account + Sign-out (when present) stack
       vertically like the top nav, instead of crowding horizontally. */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 64px;
    height: 64px;
    padding: 6px 4px;
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    font: inherit;
    font-size: 10.5px;
    text-align: center;
    transition: background var(--transition), color var(--transition), transform 0.05s;
    position: relative;
}
.nav-item:active { transform: scale(0.96); }

.nav-item .nav-label {
    font-size: 10.5px;
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: 0.1px;
}

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

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

/* Warn (attention) nav treatment — yellow text + corner count badge. Applied
   by app.js to the Notifications bell when there are unread alerts; the item
   stays plain gray otherwise. */
.nav-item--warn { color: #B26A00; }
.nav-item--warn:hover { background: #FFF6E0; color: #8A5200; }
.nav-warn-badge {
    position: absolute; top: 7px; right: 9px;
    min-width: 15px; height: 15px; padding: 0 3px; box-sizing: border-box;
    border-radius: 8px; background: #F5B50A; color: #3A2B00;
    font-size: 10px; font-weight: 800; line-height: 15px; text-align: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

/* ==================== Notifications page ==================== */
/* Alerts inbox reached from the bell under the logo. Renders into
   .main-content (normal flow), so it carries its own padding + max-width. */
.notif-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 32px 28px 64px;
}
.notif-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 20px;
}
.notif-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}
.notif-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
/* Empty ("all caught up") state */
.notif-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 72px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}
.notif-empty__icon {
    width: 76px; height: 76px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    margin-bottom: 18px;
}
.notif-empty__title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}
.notif-empty__sub {
    margin: 0;
    max-width: 360px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}
/* Notification list */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
}
.notif-item.is-unread {
    border-color: #F2D58A;
    background: #FFFDF5;
}
.notif-item__dot {
    flex: 0 0 auto;
    width: 8px; height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: transparent;
}
.notif-item.is-unread .notif-item__dot { background: #F5B50A; }
.notif-item__body { min-width: 0; flex: 1; }
.notif-item__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.notif-item__text {
    margin-top: 3px;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-secondary);
}
.notif-item__time {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* Selected + keyboard-focused nav items share the SAME clean look — the
   tinted rounded pill, not the global square outline. The inset accent ring
   follows the 12px radius so keyboard focus stays visible without clashing. */
.nav-item:focus { outline: none; }
.nav-item:focus-visible {
    outline: none;
    background: var(--accent-subtle);
    color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--accent);
}

/* --- Sidebar nav groups --- */
/* A labelled cluster of related items (e.g. "Image" over Image Studio +
   Image Library). Pure visual grouping — the items stay directly visible
   and clickable; this is NOT a collapsible submenu. The subtle tinted,
   rounded container + small uppercase header bind the items together on
   the narrow 80px rail. */
.nav-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    /* Grayish grouping container (restored per user pref) — the tinted box +
       hairline border make it obvious that Studio + Library (and the Video
       item) are a cluster. The earlier "buggy hover" was the item pill on top
       of this surface; fixed below by giving grouped items a CRISP white
       hover and the standard accent active pill, which read cleanly against
       the tint. Symmetric padding keeps the 64px item pills centered. */
    padding: 5px 0 6px;
    margin: 4px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
}
/* `.nav-group` sets display:flex, which overrides the UA [hidden] rule — so a
   conditionally-shown group (e.g. #nav-group-products, gated on ≥1 product) needs
   this to actually hide when the `hidden` attribute is set. */
.nav-group[hidden] { display: none; }
/* Subtle hairline delimiting nav sections/groups (between Create, the media
   groups + Brand/Sources, and the builder tools). */
.nav-sep {
    width: 32px;
    height: 1px;
    margin: 7px auto;
    background: var(--border-subtle, #e5e7eb);
    border-radius: 1px;
    flex-shrink: 0;
}
/* Grouped items: crisp hover/active so the highlight reads cleanly over the
   group's tinted surface (no muddy bg-on-bg). */
.nav-group .nav-item:hover {
    background: var(--bg-secondary, #fff);
    color: var(--text-primary);
}
.nav-group .nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}
.nav-group-label {
    width: 64px;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 1px 0 3px;
    user-select: none;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* =========================================================================
   SIDEBAR REDESIGN  (from "Sidebar Redesign.dc.html")
   Grouped menu (labels + hairlines, no gray boxes), header brand + bell +
   collapse, workspace switcher below, active left-accent-bar, primary Create.
   Appended last so these win over the earlier sidebar rules.
   ========================================================================= */

/* Expanded rail width per the design (was 212px). */
.sidebar.is-expanded { width: 244px; }
.app-layout:has(.sidebar.is-expanded) { --sidebar-width: 244px; }

/* ---- Header row: brand · (bell + collapse) ---- */
.sidebar-logo {
    padding: 12px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    width: 100%;
}
.sidebar.is-expanded .sidebar-logo {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 12px 12px 8px 14px;
    justify-content: flex-start;
}
.sidebar-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.sidebar.is-expanded .sidebar-brand { flex: 1; }
/* Brand (2026-10-31): the adplex.ai wordmark when the sidebar is open, the "a" mark alone when it is
   collapsed. Transparent PNGs in assets/brand/ — the wordmark already contains the mark. */
.sidebar-logo-mark { width: 32px; height: auto; display: block; flex: 0 0 auto; }
.sidebar-logo-full { height: 24px; width: auto; max-width: 100%; display: none; }
.sidebar.is-expanded .sidebar-logo-mark { display: none; }
.sidebar.is-expanded .sidebar-logo-full { display: block; }

/* Bell + collapse: compact ghost icon buttons (override the .nav-item box). */
.sidebar-bell, .sidebar-logo .sidebar-toggle {
    width: 30px; min-width: 30px; height: 30px;
    margin: 0; padding: 0;
    flex: 0 0 auto;
    border-radius: 8px;
    flex-direction: row;
}
.sidebar.is-expanded .sidebar-bell, .sidebar.is-expanded .sidebar-logo .sidebar-toggle {
    width: 30px; min-width: 30px; align-self: center; margin: 0;
}
.sidebar .sidebar-bell svg[width],
.sidebar .sidebar-logo .sidebar-toggle svg[width] { width: 18px !important; height: 18px !important; }
.sidebar-bell .nav-label { display: none; }
.sidebar-bell.active::before { display: none !important; }   /* no accent bar on the header bell */
/* Unread → a small red dot on the bell (design language), not a number badge. */
.sidebar-bell .nav-warn-badge {
    top: 4px; right: 5px; transform: none;
    min-width: 8px; width: 8px; height: 8px; padding: 0;
    border-radius: 50%; background: #E5484D;
    border: 1.5px solid var(--bg-secondary, #fff);
    color: transparent; font-size: 0; box-shadow: none;
}
.sidebar.is-expanded .sidebar-bell .nav-warn-badge { top: 4px; right: 5px; transform: none; }
/* HIDDEN (user, 2026-10-31): the alerts bell is off the sidebar header. The notifications page
   (#notifications) and its data still exist — remove this rule to bring the bell back. */
.sidebar .sidebar-bell { display: none !important; }

/* ---- Groups: drop the gray box → labels + hairline dividers ---- */
.sidebar .nav-group {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    gap: 3px;
}
.sidebar-nav { gap: 3px; }
.sidebar:not(.is-expanded) .nav-sep { width: 28px; margin: 8px auto; }
.sidebar.is-expanded .nav-sep { width: auto; margin: 9px 10px; }
.nav-group-label { color: var(--text-muted); }
/* Collapsed rail: dividers instead of labels (per the design's collapsed variant). */
.sidebar:not(.is-expanded) .nav-group-label { display: none; }
/* Collapsed rail = ICON-ONLY (matches the design's compact column). Hide each
   item's text label and shrink the item to a square icon button, so the rail
   shows just icons instead of an icon-over-caption stack. Applies to the nav
   items AND the bottom account items (Settings / Sign out / Admin). */
.sidebar:not(.is-expanded) .nav-label { display: none; }
.sidebar:not(.is-expanded) .nav-item { width: 44px; height: 44px; gap: 0; padding: 0; }
/* Collapsed rail: the switcher is a logo / initial tile — name, caption and chevrons hidden;
   its list opens beside the rail (see .project-switcher-menu). */
.sidebar:not(.is-expanded) .project-switcher { padding: 4px 0 10px; display: flex; justify-content: center; }
.sidebar:not(.is-expanded) .project-switcher-btn { width: 50px; height: 50px; padding: 6px; justify-content: center; gap: 0; }
.sidebar:not(.is-expanded) .psw-btn__text,
.sidebar:not(.is-expanded) .project-switcher-caret { display: none; }

/* ---- Active item: 3px left accent bar + tint (design) ---- */
.sidebar .nav-item { position: relative; }
.sidebar .nav-item.active::before {
    content: "";
    position: absolute;
    left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 62%;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.sidebar:not(.is-expanded) .nav-item.active::before { top: 7px; bottom: 7px; height: auto; transform: none; }
.sidebar .nav-group .nav-item.active { background: var(--accent-subtle); color: var(--accent); }

/* ---- Create: primary indigo action ---- */
.nav-item-create { color: var(--accent); }
.nav-item-create .nav-label { font-weight: 700; }
.nav-item-create:hover { background: var(--accent-subtle); color: var(--accent); }
/* Collapsed → a filled indigo square button, matching the design's collapsed Create. */
.sidebar:not(.is-expanded) .nav-item-create {
    background: var(--accent); color: #fff;
    width: 44px; height: 44px; border-radius: 12px; align-self: center;
}
.sidebar:not(.is-expanded) .nav-item-create .nav-label { display: none; }
.sidebar:not(.is-expanded) .nav-item-create:hover { background: var(--accent); filter: brightness(0.94); color: #fff; }
.sidebar:not(.is-expanded) .nav-item-create.active::before { display: none; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); border-color: var(--border); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    border: none;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Secondary — neutral filled variant (was used in JS but never defined, so it
   silently fell back to the bare .btn look). Canonical home here. */
.btn-secondary { background: var(--bg-secondary, #f3f4f6); border-color: transparent; color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
/* Extra-small button — canonical home (was duplicated + divergent in editor.css
   and auth.css). A pure size modifier of .btn so xs buttons stay visually
   consistent everywhere; always used as `btn btn-xs`. */
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; line-height: 1.4; }
.btn-ghost { background: none; border-color: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-subtle); }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* Edit-with-AI primary action — deliberately distinct from .btn-primary
 * (indigo) and .btn-danger (alarm red). The deep crimson + soft glow makes
 * it pop in the right-panel image section without screaming "delete".
 *
 * Color: Tailwind red-700 (#b91c1c). Sits between bright-alarm (red-500)
 * and oxblood (red-900). Hover deepens further to red-800. Picked over
 * the brighter --danger so an EVERYDAY action doesn't look destructive. */
.btn-edit-ai {
    background: #b91c1c;
    color: #fff;
    border: 1px solid #a01919;
    font-weight: 600;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    box-shadow: 0 1px 2px rgba(185, 28, 28, 0.15);
}
.btn-edit-ai:hover {
    background: #991b1b;       /* red-800 */
    border-color: #7f1717;
    box-shadow: 0 4px 10px rgba(185, 28, 28, 0.25);
    transform: translateY(-1px);
}
.btn-edit-ai:active {
    background: #7f1717;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(185, 28, 28, 0.20);
}
.btn-edit-ai:disabled {
    background: #c98a8a;
    border-color: #c98a8a;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.btn-full { width: 100%; margin-bottom: 6px; }

.btn-group {
    display: flex;
    gap: 2px;
}

/* --- Inputs --- */
.input {
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

.input:focus { border-color: var(--accent); }

input[type="color"] {
    -webkit-appearance: none;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 28px;
    padding: 2px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

select.prop-input {
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font: inherit;
    font-size: 12px;
    outline: none;
    width: 100%;
}

/* --- Spinner --- */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Modal --- */
/* Popups scroll the OVERLAY (the whole window), never an inner region. align-items:flex-start +
   the modal's margin:auto keeps short dialogs centered while tall ones anchor to top and scroll. */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    max-width: 100%;
    margin: auto;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 { font-size: 16px; font-weight: 600; }

/* --- Popup close button (THE X) — DESIGN_SYSTEM.md "Popup close button" ---
   The ONLY close-button style for modals, dialogs, drawers, popovers and lightboxes. Build it with
   cbCloseButton() / cbCloseHtml() from js/utils/close-button.js — never a one-off "×" glyph or a
   per-popup close class. 20px 2px-stroke icon in a 40×40 hit area (44×44 on touch), 10px radius.
   Doubled class (.cb-close.cb-close) so a stray older per-popup rule can never shrink it. */
.cb-close.cb-close {
    --cb-close-size: 40px;
    flex: 0 0 auto;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--cb-close-size);
    height: var(--cb-close-size);
    min-width: var(--cb-close-size);
    padding: 0;
    /* Sits in a header flex row: pushed to the right edge, and the negative margins keep a 40px
       target from making the header taller or pushing the icon off the header's padding line. */
    margin: -8px -8px -8px auto;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #4B5563;
    font: inherit;
    line-height: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.cb-close.cb-close svg { width: 20px; height: 20px; display: block; flex: 0 0 auto; pointer-events: none; }
.cb-close.cb-close:hover { background: #F1F2F5; color: #111827; }
.cb-close.cb-close:active { background: #E5E7EB; color: #111827; }
.cb-close.cb-close:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.cb-close.cb-close:disabled { opacity: .45; cursor: default; background: transparent; }
@media (pointer: coarse) { .cb-close.cb-close { --cb-close-size: 44px; } }

/* Floating — absolutely positioned in the popup's top-right corner (the popup box must be
   position: relative). Give the popup's header/title `padding-right: 56px` so they never meet. */
.cb-close.cb-close--float { position: absolute; top: 12px; right: 12px; margin: 0; z-index: 5; }

/* Over an image, video or dark scrim (lightboxes, zoom viewers, dark editor chrome). */
.cb-close.cb-close--on-dark { color: #fff; background: rgba(15, 18, 26, 0.55); }
.cb-close.cb-close--on-dark:hover,
.cb-close.cb-close--on-dark:active { color: #fff; background: rgba(15, 18, 26, 0.8); }

.modal-body { flex: 1; }   /* no inner scroll — the overlay scrolls the whole popup */

.modal-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-subtle);
}

.modal-footer .input { max-width: 200px; }

.modal-footer .size-count {
    color: var(--text-secondary);
    font-size: 12px;
    flex: 1;
}

/* --- Context Menu --- */
.context-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 1001;
    min-width: 140px;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.context-menu-item:hover { background: var(--bg-hover); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger:hover { background: rgba(239, 68, 68, 0.1); }

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg { opacity: 0.4; }


/* --- Badge --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.4;
}

.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-secondary); }

/* --- Tooltip --- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    background: var(--text-primary);
    color: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    white-space: nowrap;
    /* Above fixed page roots (.studio-layout etc. at z-index:100) so a
       collapsed-rail tooltip rendered at left:100% isn't buried. The z-index
       only matters once the host's stacking context clears those roots — see
       the .sidebar:has() lift below. */
    z-index: 10060;
    pointer-events: none;
}
/* Collapsed sidebar tooltips render to the RIGHT (left:100%), over the fixed
   page root (AI Studio / Library / Composer are position:fixed at z-index:100,
   the sidebar is only z-index:10 — so its tooltip children paint UNDER them).
   While hovering any tooltip-bearing element in the rail, lift the whole
   sidebar above those roots, exactly like the project-switcher popup does.
   Scoped via :has() so the rail's normal z-index:10 is restored on mouse-out. */
.sidebar:has([data-tooltip]:hover) { z-index: 10050; }
/* EXPANDED sidebar shows full labels — the rail tooltip is redundant there and its
   ::after properties collide with the Meta submenu's tree-tick pseudo-element.
   :not(.nav-child) keeps the submenu tick (automation.css) untouched — the tick
   rules neutralize the tooltip leaks themselves. */
.sidebar.is-expanded .nav-item[data-tooltip]:not(.nav-child):hover::after { content: none; }

/* --- Global toast stack ---
 *
 * Anchored top-right, newest on top. Each toast is .app-toast and
 * comes in four kinds (.app-toast--{error,success,warning,info}). Toasts
 * stack vertically with a small gap so multiple errors are individually
 * readable. Clicking dismisses (text-selection inside the toast is
 * preserved — the click handler bails when window.getSelection has text).
 */
.toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;          /* let clicks fall through gaps */
    max-width: calc(100vw - 48px);
}
.app-toast {
    pointer-events: auto;          /* but the toasts themselves ARE clickable */
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    min-width: 280px;
    max-width: 420px;
    animation: appToastIn 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.app-toast--out { animation: appToastOut 0.22s ease-in forwards; }
.app-toast__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.app-toast__body { flex: 1; min-width: 0; }
.app-toast__title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.app-toast__text {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.45;
    word-break: break-word;
}
.app-toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    align-self: flex-start;
}
.app-toast__close:hover { color: var(--text-primary); }

/* Kind variants — color the left border + icon background. Body stays
 * neutral to keep long error text readable without "alarm fatigue". */
.app-toast--error {
    border-left-color: var(--danger);
    background: #fff5f5;
}
.app-toast--error .app-toast__icon {
    background: rgba(239, 68, 68, 0.14);
    color: var(--danger);
}
.app-toast--success {
    border-left-color: var(--success);
}
.app-toast--success .app-toast__icon {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}
.app-toast--warning {
    border-left-color: var(--warning);
    background: #fffbeb;
}
.app-toast--warning .app-toast__icon {
    background: rgba(245, 158, 11, 0.16);
    color: var(--warning);
}
.app-toast--info {
    border-left-color: var(--accent);
}
.app-toast--info .app-toast__icon {
    background: var(--accent-subtle);
    color: var(--accent);
}
@keyframes appToastIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes appToastOut {
    from { transform: translateX(0);    opacity: 1; }
    to   { transform: translateX(20px); opacity: 0; }
}

/* --- Welcome toast (post-register / post-login confirmation) ---
 *
 * Slides in from the bottom-right after auth. Click anywhere to dismiss
 * early; auto-dismisses after 6s. Visually distinct from error toasts so
 * users immediately recognize "things worked". */
.welcome-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid #c7e5d4;
    border-left: 3px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    cursor: pointer;
    min-width: 280px;
    max-width: 360px;
    animation: welcomeToastIn 0.32s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.welcome-toast--out { animation: welcomeToastOut 0.22s ease-in forwards; }
.welcome-toast__icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
}
.welcome-toast__body { flex: 1; min-width: 0; }
.welcome-toast__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}
.welcome-toast__sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
}
.welcome-toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.welcome-toast__close:hover { color: var(--text-primary); }
@keyframes welcomeToastIn {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes welcomeToastOut {
    from { transform: translateY(0);    opacity: 1; }
    to   { transform: translateY(20px); opacity: 0; }
}

/* --- Drop-only Create modal -------------------------------------------- */
/* Replaces the old categorized modal as the default + button experience.
 * Single full-width drop zone, click to upload, drag/drop supported.    */

.create-modal-drop-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    background: var(--bg-tertiary);
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
    user-select: none;
}
.drop-zone:hover,
.drop-zone--active {
    border-color: var(--accent);
    background: var(--accent-subtle);
}
.drop-zone--active {
    /* Subtle scale-up pulse — confirms the drop target is "live" while
     * the user is still holding the file over it. */
    transform: scale(1.01);
}
.drop-zone--busy {
    cursor: progress;
    opacity: 0.85;
    border-style: solid;
    border-color: var(--accent);
    background: var(--accent-subtle);
}
.drop-zone--error {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.06);
}
.drop-zone__icon {
    color: var(--accent);
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}
.drop-zone--error .drop-zone__icon { color: var(--danger); }

.drop-zone__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.drop-zone__sub {
    font-size: 13px;
    color: var(--text-secondary);
}
.drop-zone__link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.drop-zone__formats {
    margin-top: 16px;
    font-size: 11.5px;
    color: var(--text-muted);
}
.drop-zone-blank-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    align-self: center;
    padding: 4px 8px;
}
.drop-zone-blank-link:hover { color: var(--accent); }

/* "or" divider between the drop zone and the two alternative-start buttons */
.drop-zone-alts-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 2px 12px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.drop-zone-alts-divider::before,
.drop-zone-alts-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle, #e6e6ec);
}

/* Two equal-weight alternative-start buttons: blank canvas / generate */
.drop-zone-alts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
@media (max-width: 560px) { .drop-zone-alts { grid-template-columns: 1fr; } }
.drop-zone-alt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--bg-subtle, #f8f8fb);
    border: 1px solid var(--border-subtle, #e6e6ec);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, color 0.12s, transform 0.12s;
}
.drop-zone-alt svg { color: var(--text-muted); transition: color 0.12s; }
.drop-zone-alt span { text-align: center; line-height: 1.3; }
.drop-zone-alt:hover {
    border-color: var(--accent, #5B53E8);
    background: var(--accent-subtle, rgba(99, 102, 241, 0.06));
    color: var(--accent, #5B53E8);
    transform: translateY(-1px);
}
.drop-zone-alt:hover svg { color: var(--accent, #5B53E8); }

/* ==================== Admin impersonation banner ==================== */
/* Fixed bottom-center pill shown while an admin is "switched into" another
   account (app.js _renderImpersonationBanner). Floats above everything. */
.imp-banner {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    z-index: 99999; display: flex; align-items: center; gap: 12px;
    background: #1f2430; color: #fff; padding: 10px 16px;
    border-radius: 999px; box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
    font-size: 13px; max-width: min(92vw, 720px);
}
.imp-banner-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.imp-banner-msg b { font-weight: 600; }
.imp-banner button {
    flex: 0 0 auto; background: #fff; color: #1f2430; border: 0;
    border-radius: 999px; padding: 6px 13px; font-size: 12.5px;
    font-weight: 600; cursor: pointer;
}
.imp-banner button:hover { background: #e8e8ee; }
.imp-banner button:disabled { opacity: .6; cursor: default; }

/* ==================================================================
   Shared page chrome (js/utils/ui.js) — one source of truth for the
   empty / error / needs-project states + page header every page reused.
   ================================================================== */
.cb-state { max-width: 520px; margin: 0 auto; }
.cb-state svg { color: var(--text-muted); opacity: .5; margin-bottom: 4px; }
.cb-state-title { font-size: 19px; font-weight: 700; color: var(--text-primary); margin: 0; }
.cb-state-body  { font-size: 14px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
.cb-state-action { margin-top: 8px; }
.cb-state-error svg { color: var(--danger); opacity: .55; }

/* Shared page header: title + subtitle (left) · actions (right). */
.cb-page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin: 0 0 20px;
}
.cb-page-head-left { min-width: 0; }
.cb-page-title { font-size: 24px; font-weight: 800; color: var(--text-primary); margin: 0; letter-spacing: -.01em; }
.cb-page-subtitle { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }
.cb-page-head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }


/* ── Resize wizard ─────────────────────────────────────────────────────────
   One image → every ticked ad size → a ZIP foldered by channel. Entirely
   local (crop + downscale on canvas), so there is no upload state to show and
   no spend to warn about — the UI is just choose, tick, download.

   Uses the app's own tokens throughout. An earlier pass invented --bg-subtle,
   which does not exist, so every rule using it silently fell back to a
   hard-coded light grey and stopped tracking the palette. */
.rw-modal { width: 720px; max-width: 94vw; }

/* .modal-body carries no padding by design — each modal supplies its own
   (see .create-modal-drop-body). Without this the whole wizard sat flush
   against the popup edge. */
.rw-body {
    padding: 20px 24px 24px;
    max-height: 62vh;
    overflow-y: auto;
}

.rw-head { display: flex; flex-direction: column; gap: 6px; }
.rw-steps { display: flex; gap: 14px; }
.rw-step {
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.rw-step.is-active { color: var(--accent); font-weight: 600; }
.rw-step.is-done::after { content: ' ✓'; }

.rw-sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.55; }
.rw-note {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 18px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm, 6px);
}

/* chosen file */
.rw-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.rw-file-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rw-file-dims { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rw-file .btn { margin-left: auto; flex-shrink: 0; }

/* options strip — reads as one settings row rather than loose controls */
.rw-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    margin-bottom: 14px;
}
.rw-opt { display: flex; align-items: center; gap: 9px; }
.rw-opt-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.rw-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); overflow: hidden; }
.rw-seg-btn {
    border: 0;
    background: transparent;
    padding: 6px 13px;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background .12s, color .12s;
}
.rw-seg-btn:hover:not(.is-on) { background: var(--bg-hover); color: var(--text-primary); }
.rw-seg-btn + .rw-seg-btn { border-left: 1px solid var(--border); }
.rw-seg-btn.is-on { background: var(--accent); color: #fff; font-weight: 600; }
.rw-color {
    width: 36px; height: 28px; padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background: none; cursor: pointer;
}

/* channel groups */
.rw-channels { display: flex; flex-direction: column; gap: 18px; }
.rw-channel-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 9px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--border-subtle);
}
.rw-channel-name { font-weight: 600; font-size: 13px; }
.rw-channel-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.rw-check { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; margin: 0; flex-shrink: 0; }

/* Preset columns — Google Display / Meta core / Other recents, side by side, each scrolling
   on its own so a 16-size list never pushes the footer off screen. */
.rw-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(228px, 100%), 1fr)); gap: 18px; }
.rw-set { min-width: 0; }
.rw-set-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; padding-bottom: 7px; border-bottom: 1px solid var(--border-subtle); }
.rw-set-head h4 { font-size: 13px; font-weight: 600; margin: 0; flex: 1; min-width: 0; }
.rw-set-list { display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; padding-right: 2px; }
.rw-sub-label { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 2px 0 1px; }
.rw-sub-divider { height: 1px; background: var(--border-subtle); margin: 7px 0 3px; }
.rw-size {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 12px;
    transition: border-color .12s, background .12s;
}
.rw-size:hover { border-color: var(--accent); }
.rw-size.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.rw-size-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rw-size-dim { font-weight: 600; font-variant-numeric: tabular-nums; }
.rw-size-label { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Upscale marker — the size is bigger than the source, so it will lose detail. Flagged, not blocked. */
.rw-up { margin-left: auto; color: #c9803a; font-weight: 700; cursor: help; flex-shrink: 0; }

/* progress + results */
.rw-bar { height: 5px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; margin-bottom: 9px; }
.rw-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .18s ease; }
.rw-progress { font-size: 12px; color: var(--text-secondary); margin-bottom: 18px; font-variant-numeric: tabular-nums; }
.rw-out { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.rw-out-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.rw-out-cell img {
    max-width: 100%;
    max-height: 76px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    /* Chequerboard so a transparent PNG reads as transparent, not as white. */
    background: repeating-conic-gradient(var(--bg-tertiary) 0% 25%, var(--bg-secondary, #fff) 0% 50%) 50% / 12px 12px;
}
.rw-out-cell span { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
    .rw-body { padding: 16px; }
    .rw-sets { grid-template-columns: 1fr; }
    .rw-set-list { max-height: 220px; }
    .rw-opts { gap: 10px 14px; }
    .rw-steps { gap: 10px; }
}

/* Batch credit refusal — sits in the footer next to the button that was refused, so the reason
   and the control it applies to are read together. */
.rw-gate {
    flex: 1;
    font-size: 12px;
    line-height: 1.45;
    color: #9a3412;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: var(--radius-sm, 6px);
    padding: 7px 10px;
}

/* ── Broken ad-platform link (expired / revoked Meta or Google sign-in) ───────────────────
   app.js _applyConnHealth: a warning under the project switcher for the current project,
   a badge on the switcher button, and ⚠ beside every affected project in the list. */
.project-switcher-btn { position: relative; }
.project-switcher-btn.has-conn-warning { border-color: #F5B54A; }
.project-switcher-btn.has-conn-warning::after {
    content: '!'; position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%;
    background: #E0890B; color: #fff; font-size: 11px; font-weight: 800; line-height: 16px; text-align: center;
    box-shadow: 0 0 0 2px var(--bg-primary, #fff);
}
.project-switcher-warn { flex: 0 0 auto; margin-left: 6px; color: #D97706; font-size: 13px; line-height: 1; }
.project-switcher-item:has(.project-switcher-warn) .project-switcher-count { margin-left: 6px; }
.project-switcher-item .project-switcher-warn + .project-switcher-count { margin-left: 6px; }
.project-switcher-item:has(.project-switcher-warn) .project-switcher-item-label { flex: 0 1 auto; }
.project-conn-alert {
    display: flex; align-items: flex-start; gap: 8px; margin: 0 8px 8px; padding: 8px 9px;
    border: 1px solid #F7D9A6; border-radius: 10px; background: #FFF8EB; color: #7A4B06; font-size: 11.5px; line-height: 1.35;
    width: calc(100% - 16px); box-sizing: border-box;
}
.project-conn-alert__ico { flex: 0 0 auto; font-size: 14px; line-height: 1.1; color: #D97706; }
.project-conn-alert__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-conn-alert__txt strong { font-weight: 700; color: #6B3F03; }
.project-conn-alert__btn {
    align-self: center; flex: 0 0 auto; border: 1px solid #E8B864; background: #fff; color: #8A5300; border-radius: 7px;
    padding: 4px 8px; font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
}
.project-conn-alert__btn:hover { background: #FFF1D6; }
/* Collapsed rail: just the ⚠, still clickable through the button. */
.sidebar:not(.is-expanded) .project-conn-alert { flex-direction: column; align-items: center; padding: 6px 4px; margin: 0 6px 8px; width: calc(100% - 12px); }
.sidebar:not(.is-expanded) .project-conn-alert__txt { display: none; }
.sidebar:not(.is-expanded) .project-conn-alert__btn { padding: 3px 5px; font-size: 10px; }

/* ── Custom size form (js/utils/custom-size.js) — Resize wizard, editor Generate sizes, sizes picker ── */
.cs-form { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.cs-label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #646B78; }
.cs-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-in { height: 34px; border: 1px solid #E2E4EA; border-radius: 9px; padding: 0 10px; font: inherit; font-size: 13px; color: #1F2430; background: #fff; box-sizing: border-box; }
.cs-in:focus { outline: none; border-color: #5B53E8; box-shadow: 0 0 0 3px rgba(91, 83, 232, .12); }
.cs-num { width: 92px; font-variant-numeric: tabular-nums; }
.cs-name { flex: 1 1 140px; min-width: 120px; }
.cs-x, .cs-px { font-size: 13px; color: #646B78; }
.cs-btn { height: 34px; white-space: nowrap; }
.cs-msg { font-size: 11.5px; color: #6B7280; }
.cs-msg.is-err { color: #B91C1C; }
.cs-form--compact .cs-num { width: 76px; }
.cs-form--compact .cs-name { flex-basis: 100%; }
.cs-form--compact .cs-btn { flex: 1 1 auto; }
.rw-custom { margin: 6px 0 14px; padding: 12px 14px; border: 1px dashed #DCDEE5; border-radius: 12px; background: #FBFBFC; }
.rw-custom .cs-form { margin: 0; }
.rw-custom-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rw-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: #3F38C9; background: #EEEDFC; border-radius: 999px; padding: 4px 6px 4px 11px; }
.rw-chip-x { border: none; background: transparent; color: #5B53E8; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 999px; }
.rw-chip-x:hover { background: #E0DCFB; }
.gen-sizes-dup { margin-top: 18px; padding-top: 14px; border-top: 1px solid #ECEDF1; }
.studio-display-modal > .cs-form { margin: 10px 0 0; }

/* Full-screen "Setting up your project…" while a new project is saved and the app switches into it. */
.cb-busy-overlay { position: fixed; inset: 0; z-index: 9000; display: flex; align-items: center; justify-content: center; gap: 12px;
    background: rgba(245, 246, 248, .82); font: 600 15px/1.4 'IBM Plex Sans', system-ui, sans-serif; color: #14171F; }
.cb-busy-overlay__spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid #E0DCFB; border-top-color: #5B53E8; animation: cb-busy-spin .8s linear infinite; }
@keyframes cb-busy-spin { to { transform: rotate(360deg); } }

/* Free-trial badge (app.js _renderTrialBadge): bottom-right, out of the way of every page's own controls. */
.cb-trial-pill { position: fixed; right: 16px; bottom: 16px; z-index: 40; padding: 8px 14px; border-radius: 999px;
    background: #EEEDFC; border: 1px solid #D6D2F7; color: #3F38C9; font: 600 12.5px/1.2 'IBM Plex Sans', system-ui, sans-serif;
    text-decoration: none; box-shadow: 0 4px 14px rgba(20, 23, 31, .08); }
.cb-trial-pill:hover { background: #E0DCFB; color: #3F38C9; text-decoration: none; }
.cb-trial-pill.is-soon { background: #FFF4E5; border-color: #FEDF89; color: #8A4B00; }
.cb-trial-pill.is-ended { background: #FEF3F2; border-color: #FECDCA; color: #B42318; }

/* Store platforms (js/shared/store-platforms.js) — the numbered how-to + the letter-tile mark,
   shared by Sources and onboarding. */
.sp-guide { margin: 4px 0 2px; padding: 12px 14px; border-radius: 10px; background: #F7F7FB; border: 1px solid #ECEDF1; color: #2A3343; font-size: 12.5px; line-height: 1.55; text-align: left; }
.sp-guide__h { font-weight: 700; color: #14171F; margin-bottom: 6px; font-size: 12.5px; }
.sp-guide ol { margin: 0; padding-left: 18px; }
.sp-guide li { margin: 3px 0; }
.sp-guide__docs { display: inline-block; margin-top: 6px; color: #5B53E8; font-weight: 600; text-decoration: none; }
.sp-guide__docs:hover { text-decoration: underline; }
.sp-mark { display: inline-flex; align-items: center; justify-content: center; border-radius: 22%; color: #fff; font-weight: 700; font-family: 'IBM Plex Sans', system-ui, sans-serif; line-height: 1; flex: 0 0 auto; }

/* Signup-credit notice + confirmation outcome (js/auth/signup-notice.js) */
.cb-signup-notice {
    position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1200;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: min(760px, calc(100vw - 32px));
    padding: 10px 14px; border-radius: 10px; background: #fff; color: #1f2330;
    border: 1px solid #d9d7fb; box-shadow: 0 6px 24px rgba(20, 18, 60, .12); font-size: 13px; line-height: 1.4;
}
.cb-signup-notice__text { flex: 1 1 260px; }
/* While the setup wizard (or any dialog) is open the bar would sit ON its footer buttons (Previous / Skip for now):
   it waits underneath and is there again when the wizard closes. */
body:has(.aih-wz-overlay) .cb-signup-notice, body:has(.modal-overlay) .cb-signup-notice { display: none; }
.cb-signup-notice__out { flex-basis: 100%; color: #5b5f6e; font-size: 12px; }
.cb-signup-notice__out:empty { display: none; }
.cb-signup-notice__close { background: none; border: 0; font-size: 18px; line-height: 1; color: #646B78; cursor: pointer; padding: 2px 4px; }
.cb-signup-notice__close:hover { color: #1f2330; }
.cb-signup-toast {
    position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 1300;
    padding: 10px 16px; border-radius: 10px; background: #1f2330; color: #fff; font-size: 13px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px);
}

/* ── In-app confirm dialog (js/utils/confirm-dialog.js → cbConfirm / cbAlert) — replaces native confirm() ── */
.cb-confirm-bg { position: fixed; inset: 0; z-index: 10050; background: rgba(15,18,26,0.55); display: flex; align-items: center; justify-content: center; padding: 20px; animation: cb-confirm-fade .12s ease; }
.cb-confirm { width: 420px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 30px 80px rgba(16,24,40,0.4); font-family: inherit; }
.cb-confirm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 14px 4px 22px; }
.cb-confirm-head h2 { margin: 9px 0 0; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: #14171F; line-height: 1.35; overflow-wrap: anywhere; }
.cb-confirm-body { margin: 0; padding: 4px 22px 4px; font-size: 13.5px; line-height: 1.55; color: #4B5563; white-space: pre-line; overflow-wrap: anywhere; }
.cb-confirm-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 22px 20px; flex-wrap: wrap; }
.cb-confirm-cancel, .cb-confirm-ok { font: inherit; font-size: 13px; font-weight: 600; border-radius: 9px; padding: 9px 16px; cursor: pointer; min-height: 38px; }
.cb-confirm-cancel { color: #374151; background: #fff; border: 1px solid #E2E4EA; }
.cb-confirm-cancel:hover { background: #F7F7F9; }
.cb-confirm-ok { color: #fff; background: #5B53E8; border: 1px solid #5B53E8; }
.cb-confirm-ok:hover { background: #4A43D6; border-color: #4A43D6; }
.cb-confirm-ok--danger { background: #DC2626; border-color: #DC2626; }
.cb-confirm-ok--danger:hover { background: #B91C1C; border-color: #B91C1C; }
.cb-confirm-cancel:focus-visible, .cb-confirm-ok:focus-visible { outline: 2px solid #5B53E8; outline-offset: 2px; }
@keyframes cb-confirm-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Admin → White-label domains (v139, js/account/whitelabel-admin.js) ── */
.wl-admin { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.wl-admin__note { margin: 0; font-size: 12.5px; color: #8A4B00; background: #FFFBF2; border: 1px solid #F2E3C2; border-radius: 9px; padding: 9px 11px; }
.wl-admin__err { color: #B42318; }
.wl-admin__add { align-self: flex-start; }
.wl-card { border: 1px solid #E6E8EE; border-radius: 12px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 12px; }
.wl-card.is-off { opacity: .65; }
.wl-card__row { display: grid; grid-template-columns: 1.1fr 1fr 1.2fr auto; gap: 8px; align-items: center; }
.wl-card__domain { font-weight: 600; }
.wl-card__on { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.wl-card__secs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.wl-sec { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid #ECEEF2; border-radius: 9px; cursor: pointer; }
.wl-sec:has(input:checked) { border-color: #5B53E8; background: rgba(91, 83, 232, 0.05); }
.wl-sec input { margin-top: 3px; }
.wl-sec__t { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.wl-sec__t span { color: #6B7280; font-size: 11.5px; }
.wl-card__foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.wl-card__when { margin-right: auto; font-size: 12px; color: #646B78; }
/* v143: free AI feed optimizations per month */
.wl-card__free { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid #ECEEF2; border-radius: 9px; }
.wl-card__freelab { display: flex; flex-direction: column; gap: 2px; flex: 1 1 280px; font-size: 12.5px; }
.wl-card__freelab span { color: #6B7280; font-size: 11.5px; }
.wl-card__freein { width: 140px; flex: 0 0 auto; }
.wl-card__freeuse { flex: 1 1 100%; font-size: 12px; color: #5B6473; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .wl-card__row { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) {
    .wl-card { background: #16181D; border-color: #2E323B; }
    .wl-sec { border-color: #2E323B; }
}
/* White-label sidebar brand (js/utils/whitelabel.js) — the domain's name instead of the adplex.ai marks */
.sidebar-brand .wl-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; color: var(--text-primary, #14171F); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.sidebar-brand .wl-logo { max-height: 26px; width: auto; max-width: 150px; }
.sidebar-brand .wl-mark { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; object-fit: contain; }
.sidebar-brand span.wl-mark { display: inline-flex; align-items: center; justify-content: center; background: #5B53E8; color: #fff; font-weight: 700; font-size: 15px; }
.sidebar:not(.is-expanded) .sidebar-brand .wl-name, .sidebar:not(.is-expanded) .sidebar-brand .wl-logo { display: none; }
.sidebar.is-expanded .sidebar-brand .wl-mark { display: none; }

/* Admin → White-label: a domain's own Stripe account (v145) */
.wl-stripe { margin-top: 14px; padding: 14px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; background: var(--surface-2, #fafafb); display: flex; flex-direction: column; gap: 10px; }
.wl-stripe__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.wl-stripe__head strong { font-size: 14px; }
.wl-stripe__state { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3, #eef0f3); color: var(--text-2, #5b6472); }
.wl-stripe__state.is-on { background: rgba(22, 163, 74, .12); color: #15803d; }
.wl-stripe__link { align-self: flex-start; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #FEF3C7; color: #92400E; }
.wl-stripe__link.is-on { background: rgba(22, 163, 74, .12); color: #15803d; }
.wl-stripe__note { margin: 0; font-size: 12.5px; color: var(--text-2, #5b6472); }
.wl-stripe__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wl-stripe__f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; min-width: 0; }
.wl-stripe__f > span { font-weight: 600; }
.wl-stripe__f em, .wl-stripe__hook em { font-style: normal; font-size: 11.5px; color: var(--text-3, #7b8494); overflow-wrap: anywhere; }
.wl-stripe__hook { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: center; font-size: 12.5px; }
.wl-stripe__hook > span, .wl-stripe__hook > em { grid-column: 1 / -1; }
.wl-stripe__plans { display: flex; flex-wrap: wrap; gap: 6px; }
.wl-stripe__plan { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border, #e5e7eb); background: var(--surface, #fff); }
.wl-stripe__plan.is-ok { border-color: rgba(22, 163, 74, .35); color: #15803d; }
.wl-stripe__plan.is-missing { border-color: rgba(217, 119, 6, .4); color: #b45309; }
.wl-stripe__acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
@media (max-width: 900px) { .wl-stripe__grid { grid-template-columns: 1fr; } }
