@layer surfaces {

    /* ── Utility ─────────────────────────────────────── */
    .header-spacer { height: 4rem; flex-shrink: 0; }

    /* ── Page header ─────────────────────────────────── */
    .main-header {
        position: fixed;
        top: 0; left: 0; right: 0;
        z-index: 50;
        background: hsl(var(--surface) / 0.8);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-bottom: 1px solid hsl(var(--line) / 0.5);
        padding: 1rem 0;
        box-shadow: var(--shadow-sm);
        flex-shrink: 0;
    }
    .header-content {
        width: 100%;
        max-width: 1400px;
        margin: 0 auto;
        padding: 0 2rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 2rem;
        position: relative;
    }
    .header-logo {
        display: flex;
        align-items: center;
        text-decoration: none;
        transition: opacity var(--dur-base) var(--ease);
        flex-shrink: 0;
    }
    .header-logo:hover { opacity: 0.8; }
    .header-logo-img { height: 2.5rem; width: auto; display: block; object-fit: contain; }
    .header-nav {
        display: flex;
        align-items: center;
        gap: 2rem;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }
    .header-nav a {
        color: var(--text-muted);
        text-decoration: none;
        font-size: var(--text-base);
        font-weight: 500;
        transition: color var(--dur-fast) var(--ease);
    }
    .header-nav a:hover { color: var(--text); }
    .header-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

    /* ── Avatar ──────────────────────────────────────── */
    .avatar-wrap { position: relative; }
    .avatar-btn {
        width: 28px;
        height: 28px;
        border-radius: var(--radius-pill);
        background: var(--accent-weak);
        border: 1px solid var(--accent-line);
        color: hsl(var(--accent));
        font-size: var(--text-xs);
        font-weight: 700;
        cursor: pointer;
        font-family: inherit;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: opacity var(--dur-fast) var(--ease);
        flex-shrink: 0;
    }
    .avatar-btn:hover { opacity: 0.8; }
    .avatar-popover { min-width: 200px; z-index: 200; padding: 0.25rem 0; top: calc(100% + 6px); right: 0; }
    .avatar-popover__identity   { padding: 0.5rem 0.875rem; font-size: var(--text-sm); color: var(--text); font-weight: 500; border-bottom: 1px solid hsl(var(--line) / 0.4); }
    .avatar-popover__name       { font-weight: 600; }
    .avatar-popover__email      { color: var(--text-muted); font-size: var(--text-xs); }
    .avatar-popover__badge      { padding: 0.375rem 0.875rem; font-size: var(--text-sm); font-weight: 600; color: hsl(var(--accent)); border-bottom: 1px solid hsl(var(--line) / 0.4); }
    .avatar-popover__logout     { display: block; width: 100%; padding: 0.5rem 0.875rem; background: none; border: none; color: var(--text-muted); font-size: var(--text-base); font-weight: 500; text-align: left; cursor: pointer; font-family: inherit; transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
    .avatar-popover__logout:hover { color: var(--text); background: hsl(var(--surface-raised)); }

    /* ── Main layout ─────────────────────────────────── */
    .main-content-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 0; }
    .demo-section {
        position: relative;
        padding: 0.25rem 0 1.5rem;
        overflow: hidden;
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    .background-gradient {
        position: absolute;
        inset: 0;
        background: linear-gradient(to bottom, transparent, var(--accent-weak), transparent);
        pointer-events: none;
    }
    .background-blur {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 1000px;
        height: 600px;
        background: var(--accent-weak);
        border-radius: 50%;
        filter: blur(150px);
        pointer-events: none;
    }
    .container {
        max-width: 1440px;
        margin: 0 auto;
        padding: 0 1rem;
        position: relative;
        z-index: 1;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .demo-container { flex: 1; display: flex; flex-direction: column; min-height: 0; }

    /* ── Demo header bar ─────────────────────────────── */
    .demo-header-bar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        background: hsl(var(--surface-raised));
        border: 1px solid hsl(var(--line));
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        min-height: 3rem;
        flex-shrink: 0;
    }
    .demo-header-left { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
    .brand-logo-img { height: 36px; max-width: 120px; object-fit: contain; }
    .brand-btn {
        background: hsl(var(--surface-raised));
        color: var(--text);
        padding: 0.3rem 0.625rem;
        border-radius: var(--radius-lg);
        font-size: var(--text-base);
    }
    .brand-btn:hover { border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
    .brand-caret { font-size: var(--text-xs); }
    .brand-dropdown { position: relative; }
    .brand-dropdown-menu { top: calc(100% + 4px); left: 0; min-width: 140px; z-index: 100; }
    .brand-option {
        display: block;
        width: 100%;
        padding: 0.5rem 0.875rem;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: var(--text-base);
        font-weight: 500;
        text-align: left;
        cursor: pointer;
        font-family: inherit;
        transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
    }
    .brand-option:hover { background: hsl(var(--surface-raised)); color: var(--text); }
    .brand-option.active { color: hsl(var(--accent)); }
    .demo-panel-title {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        font-size: var(--text-base);
        font-weight: 600;
        color: var(--text);
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Canvas tabs ─────────────────────────────────── */
    .demo-header-right { display: flex; align-items: center; flex-shrink: 0; }
    .canvas-tabs { display: flex; align-items: center; gap: 0.4rem; }
    .canvas-tab {
        padding: 0.25rem 0.6rem;
        border-radius: var(--radius-sm);
        background: hsl(var(--surface-raised) / 0.3);
        color: var(--text-muted);
        font-size: var(--text-sm);
    }
    .canvas-tab:hover { background: hsl(var(--surface-raised)); color: var(--text); }
    .canvas-tab.active { background: var(--accent-weak); color: hsl(var(--accent)); border-color: var(--accent-line); }
    .tab-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 22px;
        height: 18px;
        padding: 0 6px;
        border-radius: var(--radius-pill);
        background: hsl(var(--surface-raised));
        border: 1px solid hsl(var(--line));
        font-size: var(--text-sm);
        font-weight: 700;
        color: var(--text-muted);
    }
    .canvas-tab.active .tab-count { background: transparent; border-color: var(--accent-line); color: hsl(var(--accent)); }
    .canvas-tab[data-disabled] { opacity: 0.35; pointer-events: none; cursor: default; }

    /* ── Brand logo initials fallback (O2-AC12) ──────── */
    .brand-initials-fallback { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: hsl(var(--surface-raised)); color: var(--text-muted); font-size: var(--text-xs); font-weight: 600; flex-shrink: 0; }

    /* ── 3-panel grid ────────────────────────────────── */
    .demo-panels {
        display: grid;
        grid-template-columns: 293px 1fr 1.2fr;
        flex: 1;
        min-height: 0;
        border: 1px solid hsl(var(--line));
        border-top: none;
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
        overflow: hidden;
        background: hsl(var(--surface));
    }
    .demo-panel { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
    .guide-panel { border-right: 1px solid hsl(var(--line)); }
    .chat-panel  { border-right: 1px solid hsl(var(--line)); }
    .panel-header-row {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
        border-bottom: 1px solid hsl(var(--line));
        background: hsl(var(--surface-raised) / 0.3);
        flex-shrink: 0;
    }
    .panel-header-title { font-size: var(--text-sm); font-weight: 600; color: var(--text); margin: 0; white-space: nowrap; line-height: 1; }
    .panel-scroll {
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    /* ── Guide panel ─────────────────────────────────── */
    .guide-content { padding: 0.75rem; gap: 0; align-items: stretch; }
    .faq-section { width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 0.5rem; }
    .faq-heading { margin: 0; }
    .faq-items { display: flex; flex-direction: column; gap: 0.5rem; }
    .guide-group { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: var(--space-3); }
    .guide-group:last-child { margin-bottom: 0; }
    .guide-group-hdr { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 0 var(--space-2); margin-top: var(--space-1); margin-bottom: 0.15rem; }
    .faq-item {
        background: hsl(var(--surface-raised) / 0.3);
        border: 1px solid hsl(var(--line));
        border-radius: var(--radius-md);
        color: var(--text);
        padding: 0.5rem 0.75rem;
        font-size: var(--text-sm);
        font-weight: 500;
        cursor: pointer;
        text-align: left;
        width: 100%;
        font-family: inherit;
        transition: border-color var(--dur-fast) var(--ease);
    }
    .faq-item:hover { background: hsl(var(--surface-raised)); border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
    .faq-item:active { transform: scale(0.98); }

    /* ── Chat panel ──────────────────────────────────── */
    .chat-messages { padding: 0.75rem; gap: 0.25rem; }
    .message { display: flex; flex-direction: column; width: 100%; gap: 0.25rem; margin-bottom: 0.375rem; animation: fadeIn var(--dur-slow) var(--ease); }
    @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
    .bot-message  { align-items: flex-start; }
    .user-message { align-items: flex-end; }
    .message-content { border-radius: var(--radius-md); padding: 0.375rem 0.625rem; font-size: var(--text-base); line-height: 1.4; width: 100%; box-sizing: border-box; }
    .bot-content  { background: hsl(var(--surface-raised) / 0.3); color: var(--text); }
    .user-content { background: hsl(var(--user-bubble)); color: hsl(var(--white)); }
    .message-text { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: inherit; line-height: inherit; }
    .typing-indicator .message-content { display: flex; align-items: center; gap: 4px; }
    .typing-indicator span { width: 6px; height: 6px; border-radius: var(--radius-pill); background: var(--text-muted); animation: typing-bounce 1.2s infinite; }
    .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
    .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
    @keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }
    .prompt-limit-banner { flex-shrink: 0; padding: 6px 12px; background: hsl(var(--surface)); border-top: 1px solid hsl(var(--line)); font-size: var(--text-sm); color: var(--text-muted); text-align: center; }
    .cap-cta { margin-left: var(--space-2); }
    .chat-input-area { flex-shrink: 0; padding: 0.5rem 0.75rem; border-top: 1px solid hsl(var(--line)); background: hsl(var(--surface)); display: flex; flex-direction: column; gap: 0.35rem; }
    .chat-textarea { width: 100%; resize: none; border: none; background: transparent; color: var(--text); font-size: var(--text-sm); font-family: inherit; line-height: 1.5; outline: none; padding: 0.25rem 0; box-sizing: border-box; }
    .chat-textarea::placeholder { color: var(--text-muted); font-size: var(--text-sm); }
    .chat-input-actions { display: flex; justify-content: flex-end; }
    .send-btn {
        display: inline-flex;
        align-items: center;
        padding: 0.3rem 0.75rem;
        background: hsl(var(--accent));
        color: hsl(var(--surface));
        border: none;
        border-radius: var(--radius-sm);
        font-size: var(--text-sm);
        font-weight: 600;
        cursor: pointer;
        font-family: inherit;
        transition: background var(--dur-fast) var(--ease);
    }
    .send-btn:hover:not(:disabled) { background: hsl(var(--accent-hover)); }
    .send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

    /* ── Canvas panel ────────────────────────────────── */
    .canvas-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
    .canvas-view { display: none; padding: 1rem; }
    .canvas-view.active { display: flex; flex-direction: column; gap: 0.75rem; flex: 1; min-height: 0; overflow-y: auto; }
    .geo-placeholder { margin: 0; }
    .geo-placeholder__hint { margin-top: 0.75rem; color: var(--text-muted); font-size: var(--text-xs); }

    /* ── GEO scoreboard ──────────────────────────────── */
    .geo-brand-highlight { border-left: 3px solid hsl(var(--accent)); }
    .geo-highlight-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
    .geo-demand-badge { font-size: var(--text-xs); padding: 2px 7px; border-radius: 99px; background: hsl(var(--accent) / 0.12); color: hsl(var(--accent)); font-weight: 600; text-transform: capitalize; }
    .geo-engine-rows { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.3rem; }
    .geo-engine-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 0.75rem; }
    .geo-engine-name { font-size: var(--text-sm); color: var(--text); font-weight: 500; text-transform: capitalize; }
    .geo-engine-frac { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
    .geo-engine-pct { font-size: var(--text-xs); color: hsl(var(--accent)); font-weight: 700; min-width: 2.5rem; text-align: right; }
    .geo-engine-pct--absent { color: var(--text-muted); }
    .geo-no-data-hint { font-size: var(--text-sm); color: var(--text-muted); font-style: italic; padding: 2px 0; }
    .geo-trend-line { font-size: var(--text-xs); color: var(--text-muted); padding-top: 0.35rem; border-top: 1px solid hsl(var(--line) / 0.3); margin-top: 0.2rem; }
    .geo-trend-up   { color: hsl(var(--success)); font-weight: 600; }
    .geo-trend-down { color: hsl(var(--danger)); font-weight: 600; }
    .geo-snapshot-label { font-size: var(--text-xs); color: var(--text-muted); font-style: italic; margin-top: 0.4rem; }
    .geo-gap-insight { font-size: var(--text-xs); color: var(--text); line-height: 1.55; margin-top: 0.15rem; }
    /* ── About the demo toggle ──────────────────────── */
    .about-demo-btn { font-size: var(--text-xs); color: var(--text-muted); background: none; border: 1px solid hsl(var(--line) / 0.5); border-radius: var(--radius-sm); padding: 2px 8px; cursor: pointer; margin-left: auto; white-space: nowrap; }
    .about-demo-btn:hover { color: var(--text); border-color: hsl(var(--line)); }
    @keyframes welcome-pulse { 0%,100% { background: transparent; } 40% { background: hsl(var(--accent) / 0.07); } }
    .welcome-pulse { animation: welcome-pulse 1.2s ease; border-radius: var(--radius); }
    /* ── GEO share-of-voice bars ─────────────────────── */
    .geo-sov-bars { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; }
    .geo-sov-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 0.5rem; }
    .geo-sov-name { font-size: var(--text-xs); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .geo-sov-bar-wrap { background: hsl(var(--surface-sunken)); border-radius: 3px; height: 7px; overflow: hidden; }
    .geo-sov-bar { height: 100%; background: hsl(var(--line) / 0.6); border-radius: 3px; }
    .geo-sov-bar--brand { background: hsl(var(--accent)); }
    .geo-sov-count { font-size: var(--text-xs); color: var(--text-muted); min-width: 1.5rem; text-align: right; }
    .geo-sov-row--brand .geo-sov-name { color: hsl(var(--accent)); font-weight: 600; }
    .geo-sov-row--brand .geo-sov-count { color: hsl(var(--accent)); font-weight: 600; }

    /* ── Agent action row ────────────────────────────── */
    .agent-action-row { display: flex; gap: var(--space-2); padding: 0 var(--space-4) var(--space-3); flex-wrap: wrap; }
    .agent-action-btn { font-size: var(--text-xs); padding: 4px 12px; border-radius: var(--radius-sm); border: 1px solid hsl(var(--line)); background: none; color: var(--text-muted); cursor: pointer; transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease); }
    .agent-action-btn:hover { background: hsl(var(--surface-raised)); color: var(--text); }
    .agent-action-btn--primary { background: hsl(var(--accent)); color: hsl(var(--surface)); border-color: hsl(var(--accent)); }
    .agent-action-btn--primary:hover { opacity: 0.9; }
    /* verify flag — content_analyzer caution badge */
    .agent-verify-flag { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: hsl(var(--amber)); background: hsl(var(--amber-bg)); border: 1px solid hsl(var(--amber-border)); border-radius: var(--radius-sm); padding: 1px 6px; vertical-align: middle; }
    /* SEO data note */
    .seo-caveat-card .section-body--muted { font-size: var(--text-xs); }

    /* ── NBA strip (above-the-prompt zone) ──────────── */
    .nba-strip {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.375rem 0.75rem;
        background: hsl(var(--accent) / 0.06);
        border-bottom: 1px solid hsl(var(--accent) / 0.15);
        flex-shrink: 0;
        font-size: var(--text-xs);
    }
    .nba-strip__text   { flex: 1; color: var(--text-muted); }
    .nba-strip__dismiss { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: var(--text-sm); font-family: inherit; padding: 0 0.25rem; }
    .nba-strip__dismiss:hover { color: var(--text); }

    /* ── Quota bar ───────────────────────────────────── */
    .quota-bar {
        flex-shrink: 0;
        padding: 4px 0.75rem;
        background: hsl(var(--surface));
        border-top: 1px solid hsl(var(--line));
        font-size: var(--text-xs);
        color: var(--text-muted);
        text-align: center;
        cursor: pointer;
    }
    .quota-bar:hover { color: var(--text); }
    .trial-popover { position: absolute; bottom: 100%; left: 0.75rem; right: 0.75rem; padding: 0.75rem; display: none; }
    .trial-popover.open { display: block; }
    .trial-popover__row { display: flex; justify-content: space-between; font-size: var(--text-xs); padding: 3px 0; color: var(--text-muted); }
    .trial-popover__label { color: var(--text-muted); }

    /* ── Pricing section ─────────────────────────────── */
    .pricing-section {
        padding: var(--space-6) var(--space-4);
        border-top: 1px solid hsl(var(--line));
        background: hsl(var(--surface));
    }
    .pricing-inner {
        max-width: 860px;
        margin: 0 auto;
        display: flex;
        flex-direction: column;
        gap: var(--space-5);
    }
    .pricing-header { text-align: center; }
    .pricing-title {
        font-family: var(--font-heading);
        font-size: var(--text-base);
        font-weight: 600;
        color: var(--text);
        margin-bottom: var(--space-2);
    }
    .pricing-subtitle {
        font-size: var(--text-sm);
        color: var(--text-muted);
    }
    .pricing-cards {
        display: flex;
        gap: var(--space-4);
        align-items: flex-start;
    }
    .pricing-card {
        flex: 1;
        background: hsl(var(--surface-raised) / 0.4);
        border: 1px solid hsl(var(--line));
        border-radius: var(--radius-lg);
        padding: var(--space-5);
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        position: relative;
    }
    .pricing-card--premium { border-color: hsl(var(--accent-line)); }
    .pricing-card__badge {
        display: inline-flex;
        align-items: center;
        align-self: flex-start;
        padding: 2px 8px;
        border-radius: var(--radius-pill);
        background: hsl(var(--accent) / 0.12);
        border: 1px solid hsl(var(--accent) / 0.25);
        font-size: var(--text-xs);
        font-weight: 600;
        color: hsl(var(--accent));
    }
    .pricing-card__name {
        font-family: var(--font-heading);
        font-size: var(--text-base);
        font-weight: 600;
        color: var(--text);
    }
    .pricing-card__price {
        font-size: var(--text-base);
        font-weight: 700;
        color: var(--text);
    }
    .pricing-card__price span { font-size: var(--text-sm); font-weight: 400; color: var(--text-muted); }
    .pricing-card__note {
        font-size: var(--text-xs);
        color: var(--text-muted);
        line-height: 1.5;
    }
    .pricing-card__features {
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        flex: 1;
    }
    .pricing-card__features li {
        font-size: var(--text-sm);
        color: var(--text-muted);
        padding-left: var(--space-4);
        position: relative;
    }
    .pricing-card__features li::before {
        content: '✓';
        position: absolute;
        left: 0;
        color: hsl(var(--success));
        font-weight: 700;
    }
    .pricing-provisional {
        font-size: var(--text-xs);
        color: var(--text-muted);
        text-align: center;
        opacity: 0.7;
    }

    /* ── Demo landing gate — blur behind auth gate ───────── */
    .demo-gate-active .main-content-wrapper {
        filter: blur(2px);
        pointer-events: none;
        opacity: 0.7;
    }
    .demo-gate-active #closeAuthModal { display: none; }

}
