/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-tertiary: #1e2130;
    --bg-hover: #252836;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #2a2d37;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-on-accent: #ffffff;
    /* Top chrome removed; account lives in the sidebar footer. Keep 0 so
       legacy calc(100dvh - var(--navbar-height) - …) still resolve cleanly. */
    --navbar-height: 0px;
    --navbar-control-height: 36px;
    --navbar-control-radius: 8px;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 64px;
    /* Dashboard shell content contract (main column). Full-bleed pages
       (Idea Design) zero these via :has(.design-page). */
    --shell-content-pad-y: 24px;
    --shell-content-pad-x: 32px;
    --shell-content-pad-y-sm: 16px;
    --shell-content-pad-x-sm: 14px;
    /* Shared frame for the New Chat composer and its upgrade notice. */
    --design-home-content-width: min(760px, 100%);
    --design-home-content-gutter: 24px;
    --transition-speed: 200ms;
    /* Content UI system — restrained SaaS chrome (tables, forms, buttons). */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --control-height: 36px;
    --control-height-sm: 32px;
    --control-font: 0.875rem;
    --surface-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
    /* Shared Design + Build composer chrome (shell / pill / floating notices). */
    --composer-max-width: 780px;
    --composer-side-gutter: 36px;
    --composer-pill-radius: 22px;
    --composer-control-size: 32px;
    --composer-attach-size: 28px;
    --composer-min-height: 52px;
    --composer-notice-gap: 6px;
    --composer-shell-width: min(var(--composer-max-width), calc(100% - var(--composer-side-gutter)));
}

/* Floating notice stack above Design/Build composers — out of document flow so
   the bottom chrome height (and message list flex) does not shrink. */
.composer-notice-stack {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    z-index: 36;
    display: flex;
    flex-direction: column;
    gap: var(--composer-notice-gap);
    margin: 0 0 8px;
    pointer-events: none;
}

.composer-notice {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    border-left-width: 3px;
    font-size: 13px;
    line-height: 1.45;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.composer-notice__text {
    min-width: 0;
    flex: 1 1 auto;
}

.composer-notice__close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: -2px -4px -2px 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    opacity: 0.72;
    cursor: pointer;
}

.composer-notice__close:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 12%, transparent);
}

.composer-notice__close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    opacity: 1;
}

.composer-notice--error {
    border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
    border-left-color: var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, var(--bg-secondary));
    color: color-mix(in srgb, var(--danger) 72%, var(--text-primary));
}

.composer-notice--warning {
    border-color: color-mix(in srgb, var(--warning) 32%, var(--border));
    border-left-color: var(--warning);
    background: color-mix(in srgb, var(--warning) 12%, var(--bg-secondary));
    color: color-mix(in srgb, var(--warning) 55%, var(--text-primary));
}

.composer-notice--info {
    border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
    border-left-color: color-mix(in srgb, var(--accent) 70%, var(--border));
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary));
    color: var(--text-secondary);
}

[data-theme="light"] .composer-notice {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f4f4f5;
    --bg-tertiary: #e4e4e7;
    --bg-hover: #d4d4d8;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e4e4e7;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --surface-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
    --text-on-accent: #ffffff;
}

[data-theme="light"] .project-card,
[data-theme="light"] .stat-card,
[data-theme="light"] .channel-card,
[data-theme="light"] .wizard-step-content,
[data-theme="light"] .deliverable-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .dropup-menu {
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .chat-bubble.ai {
    background: var(--bg-secondary);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: var(--border);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Light-mode chip/badge/tag/state contrast.
   The status colours throughout the app are bright pastels tuned for a dark
   translucent chip; on the near-white light card the same text on a faint tint
   falls below WCAG. Override every tinted-background label to a deeper 700-level
   shade of the same hue (grouped by colour). Plain links / menu items / borders
   are intentionally excluded - those are a separate concern, not tinted chips.
 */
[data-theme="light"] .status-dev,
[data-theme="light"] .status-released,
[data-theme="light"] .issue-status.done,
[data-theme="light"] .role-badge-tag.owner,
[data-theme="light"] .plan-badge.growth,
[data-theme="light"] .docs-cat-tag.getting-started,
[data-theme="light"] .chat-badge.active,
[data-theme="light"] .btn-deploy.ready,
[data-theme="light"] .usage-range-chip.active,
[data-theme="light"] .plan-card-status.current {
    color: #1d4ed8; /* blue-700 */
}

[data-theme="light"] .issue-status.open,
[data-theme="light"] .role-badge-tag.member,
[data-theme="light"] .docs-cat-tag.team,
[data-theme="light"] .chat-badge.success,
[data-theme="light"] .project-status-bar.completed,
[data-theme="light"] .domain-state.ready,
[data-theme="light"] .invite-feedback.success,
[data-theme="light"] .credit-status.ok,
[data-theme="light"] .upgrade-plan-badge.active,
[data-theme="light"] .invoice-status.paid,
[data-theme="light"] .doc-stage.done,
[data-theme="light"] .settings-gh-status.connected,
[data-theme="light"] .playground-preview-pill.public {
    color: #15803d; /* green-700 */
}

[data-theme="light"] .status-analyzing,
[data-theme="light"] .docs-cat-tag.billing,
[data-theme="light"] .credit-status.low,
[data-theme="light"] .invoice-status.due,
[data-theme="light"] .spend-alert,
[data-theme="light"] .new-repo-banner,
[data-theme="light"] .new-repo-banner-link {
    color: #b45309; /* amber-700 */
}

/* Every non-terminal issue stage uses the same calm green treatment. */
[data-theme="light"] .issue-status.working,
[data-theme="light"] .issue-status.open,
[data-theme="light"] .issue-status.todo,
[data-theme="light"] .status-dev,
[data-theme="light"] .status-todo {
    color: #15803d; /* green-700 */
}

[data-theme="light"] .issue-status.queued {
    color: #475569; /* slate-700 */
}

[data-theme="light"] .new-repo-banner-link:hover {
    color: #92400e; /* amber-800 */
}

[data-theme="light"] .role-badge-tag.admin,
[data-theme="light"] .plan-badge.enterprise,
[data-theme="light"] .docs-cat-tag.projects {
    color: #7e22ce; /* purple-700 */
}

[data-theme="light"] .credit-status.critical {
    color: #c2410c; /* orange-700 */
}

[data-theme="light"] .domain-state.failed,
[data-theme="light"] .invite-feedback.error,
[data-theme="light"] .credit-status.empty,
[data-theme="light"] .issue-status.failed {
    color: #b91c1c; /* red-700 */
}

[data-theme="light"] .domain-state.pending {
    color: #854d0e; /* yellow-800 -> yellow-700 #a16207 was only 4.48:1, just under 4.5 */
}

[data-theme="light"] .docs-cat-tag.api {
    color: #be185d; /* pink-700 */
}

[data-theme="light"] .docs-cat-tag.integrations {
    color: #0e7490; /* cyan-700 */
}

[data-theme="light"] .status-todo {
    color: #52525b; /* zinc-600 */
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: 14px;
}

button {
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
}

small {
    font-size: 14px;
}

.pwa-install-banner {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(78px, calc(70px + env(safe-area-inset-bottom)));
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

.pwa-install-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pwa-install-copy strong {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.2;
}

.pwa-install-copy span {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.35;
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-primary {
    min-height: 34px;
    padding: 0 12px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}

.pwa-install-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: var(--text-muted);
}

.pwa-install-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .pwa-install-banner {
        display: flex;
    }
}

@media (display-mode: standalone) {
    .pwa-install-banner {
        display: none;
    }
}

/* --- App Shell --- */
/* Row chrome: full-height sidebar + content column (topbar is not full-bleed). */
.app {
    display: flex;
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* Soft handoff after AppShellSkeleton → real shell (same geometry). */
.app-shell-ready {
    animation: app-shell-ready-in 180ms ease-out;
}

@keyframes app-shell-ready-in {
    from {
        opacity: 0.78;
    }
    to {
        opacity: 1;
    }
}

/* Token present, profile still loading — dashboard-shaped, not a login card. */
.app-shell-skeleton {
    background: var(--bg-primary);
}

.app-shell-skeleton-sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-height: 0;
    padding: 16px 14px;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    box-sizing: border-box;
}

.app-shell-skeleton-brand {
    width: 120px;
    height: 22px;
    margin-bottom: 28px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--border) 70%, transparent);
}

.app-shell-skeleton-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
}

.app-shell-skeleton-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 16px;
}

.app-shell-skeleton-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--border) 70%, transparent);
}

.app-shell-skeleton-main {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: var(--shell-content-pad-y) var(--shell-content-pad-x);
}

.app-shell-skeleton-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(720px, 100%);
    margin: 48px auto 0;
}

.app-shell-skeleton-line {
    height: 12px;
    width: 72%;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--border) 55%, transparent) 0%,
        color-mix(in srgb, var(--bg-tertiary) 85%, transparent) 50%,
        color-mix(in srgb, var(--border) 55%, transparent) 100%
    );
    background-size: 200% 100%;
    animation: app-shell-skeleton-shimmer 1.2s ease-in-out infinite;
}

.app-shell-skeleton-line.short {
    width: 42%;
}

.app-shell-skeleton-line.wide {
    width: 88%;
    height: 16px;
}

.app-shell-skeleton-block {
    height: 120px;
    margin-top: 8px;
    border-radius: 12px;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--border) 45%, transparent) 0%,
        color-mix(in srgb, var(--bg-tertiary) 75%, transparent) 50%,
        color-mix(in srgb, var(--border) 45%, transparent) 100%
    );
    background-size: 200% 100%;
    animation: app-shell-skeleton-shimmer 1.2s ease-in-out infinite;
}

.app-shell-skeleton-status {
    margin: 20px 0 0;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

.app-shell-root-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 40dvh;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

@keyframes app-shell-skeleton-shimmer {
    0% {
        background-position: 100% 0;
    }
    100% {
        background-position: -100% 0;
    }
}

@media (max-width: 768px) {
    .app-shell-skeleton-sidebar {
        display: none;
    }
}

.app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Sticky workspace notices above the scrollable page body. */
.shell-banners {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.shell-banners:empty {
    display: none;
}

/* --- Main Content --- */
/* Default: padded scroll surface for list/settings/admin/billing pages. */
.main-content {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: var(--shell-content-pad-y) var(--shell-content-pad-x);
    background: var(--bg-primary);
}

/*
 * Full-bleed product surfaces (Idea Design). Zero shell padding so the
 * workbench owns the entire main column; page root fills height via flex.
 */
.main-content:has(> .design-page) {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.main-content:has(> .design-page) > .design-page {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

/* Template preview is a full-bleed product surface (not a padded settings page).
   Avoid stacking shell pad + .shared-design-main pad. */
.main-content:has(> .shared-design-page.template-design-preview) {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    /* Match template stage tint so shell + page read as one surface. */
    background: color-mix(in srgb, var(--accent) 4%, var(--bg-secondary));
}

.main-content:has(> .shared-design-page.template-design-preview) > .shared-design-page.template-design-preview {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

@media (max-width: 768px) {
    html,
    body,
    .app {
        min-height: 100dvh;
    }

    .app {
        height: 100dvh;
    }

    .app {
        flex-direction: column;
    }

    .navbar {
        padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
        gap: 8px;
    }

    .navbar-logo,
    .navbar-logo-mobile {
        display: flex;
    }

    .navbar-mode-switcher {
        display: none;
    }

    .navbar-mode-compact {
        display: inline-flex;
    }

    .navbar-cmd {
        width: var(--navbar-control-height);
        height: var(--navbar-control-height);
        padding: 0;
        justify-content: center;
    }

    .navbar-cmd-label,
    .navbar-cmd .navbar-cmd-kbd {
        display: none;
    }

    .navbar-avatar .role-badge,
    .navbar-avatar .user-menu-trigger-label,
    .navbar-avatar .account-role-badge {
        display: none;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: var(--shell-content-pad-y-sm) max(var(--shell-content-pad-x-sm), env(safe-area-inset-right)) calc(82px + env(safe-area-inset-bottom)) max(var(--shell-content-pad-x-sm), env(safe-area-inset-left));
    }

    .main-content:has(> .design-page) {
        padding: 0 0 calc(82px + env(safe-area-inset-bottom));
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 120;
        display: flex;
        min-height: calc(64px + env(safe-area-inset-bottom));
        padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }

    /* mobile notification sheet */
    .notif-backdrop {
        z-index: 180;
        background: rgba(0, 0, 0, 0.42);
    }

    .notif-dropdown {
        position: fixed;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: calc(74px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        max-height: min(72dvh, 560px);
        border-radius: 14px;
        z-index: 190;
    }

    .notif-header {
        padding: 13px 14px;
    }

    .notif-item {
        padding: 13px 14px;
    }

    .mobile-project-detail {
        height: calc(100dvh - var(--navbar-height) - 82px);
        min-height: 0;
        padding-bottom: 0;
    }

    .mobile-project-header {
        margin-bottom: 10px;
        padding-bottom: 12px;
    }

    .mobile-project-tabs {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 3px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 10px;
        flex-shrink: 0;
    }

    .mobile-project-tab {
        min-height: 36px;
        border-radius: 8px;
        color: var(--text-muted);
        font-size: 14px;
        font-weight: 700;
    }

    .mobile-project-tab.active {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }

    .mobile-project-body {
        display: flex;
        flex: 1;
        min-height: 0;
        flex-direction: column;
    }

    .mobile-project-body .right-panel {
        flex: 1;
        min-height: 0;
        min-width: 0;
    }

    /* Keep chat composer inside the panel above the bottom nav (panel height
       already accounts for nav; do not pin input over fixed chrome). */
    .mobile-project-body .project-chat-panel {
        display: flex;
        flex-direction: column;
        min-width: 0;
        min-height: 0;
    }

    .mobile-project-body .project-chat-panel .chat-composer-shell {
        margin-bottom: 10px;
        flex-shrink: 0;
    }

    .mobile-project-panel {
        flex: 1;
        min-height: 0;
        min-width: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .mobile-work-panel,
    .mobile-lite-work-panel,
    .mobile-info-panel {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-lite-work-panel {
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    .mobile-work-card {
        display: flex;
        flex-shrink: 0;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .mobile-deployment-action {
        width: 100%;
        justify-content: center;
    }

    .mobile-work-label {
        color: var(--text-muted);
        font-size: 14px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0;
    }

    .mobile-work-value {
        color: var(--text-primary);
        font-size: 14px;
        font-weight: 700;
        text-transform: capitalize;
    }

    .mobile-work-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-work-list.long {
        max-height: min(42dvh, 360px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-right: 2px;
    }

    .mobile-work-load-more {
        justify-content: center;
        width: 100%;
    }

    .mobile-work-row {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        color: var(--text-secondary);
        font-size: 14px;
        min-width: 0;
    }

    .mobile-work-row span:first-child {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-work-muted {
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .mobile-danger-zone {
        margin-top: 8px;
        border-color: rgba(239, 68, 68, 0.35);
    }
}

/* --- Content page frame (Team / Settings / Billing / Admin / …) ---
   Shell already pads .main-content; pages must not add a second 32px pad. */
.content-page {
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.content-page--narrow {
    max-width: 960px;
}

.content-page--default {
    max-width: 1100px;
}

.content-page--wide {
    max-width: 1280px;
}

.content-page--full {
    max-width: none;
}

/*
 * Content page header — Stripe/Linear-adjacent hierarchy:
 * clear title, restrained subtitle, generous quiet space, no ornament.
 */
.content-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px 32px;
    flex-wrap: wrap;
    margin: 0 0 32px;
    padding: 0 0 24px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
}

.content-page-header-text {
    flex: 1 1 16rem;
    min-width: min(100%, 16rem);
    /* Keep header copy within the same visual width as centered body columns */
    max-width: 40rem;
}

/* Settings / Billing: keep page header title block centered with body column */
.settings-page > .content-page-header,
.billing-page > .content-page-header {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    box-sizing: border-box;
}

.content-page-title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.5rem, 1.35rem + 0.6vw, 1.75rem);
    font-weight: 650;
    letter-spacing: -0.035em;
    line-height: 1.15;
    font-feature-settings: "ss01" on, "cv01" on;
}

.content-page-description {
    margin: 8px 0 0;
    max-width: 36rem;
    color: var(--text-secondary);
    font-size: 0.9375rem; /* 15px — common body meta size in US SaaS */
    font-weight: 400;
    letter-spacing: -0.005em;
    line-height: 1.55;
}

.content-page-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    justify-content: flex-end;
    padding-bottom: 2px; /* optical align with title baseline row */
}

[data-theme="light"] .content-page-header {
    border-bottom-color: color-mix(in srgb, var(--border) 92%, transparent);
}

[data-theme="light"] .content-page-description {
    color: #64748b; /* slate-500 — quieter than body secondary for captions */
}

/* Consistent vertical rhythm under the shared header. */
.content-page > .feedback-block {
    margin-top: 0;
}

/* Legacy alias: older admin markup still using .page-header. */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 32px;
    padding: 0 0 24px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
}

.page-header h1 {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.5rem, 1.35rem + 0.6vw, 1.75rem);
    font-weight: 650;
    letter-spacing: -0.035em;
    line-height: 1.15;
}

.page-header p {
    margin: 0;
    max-width: 36rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: -0.005em;
    line-height: 1.55;
}

[data-theme="light"] .page-header {
    border-bottom-color: color-mix(in srgb, var(--border) 92%, transparent);
}

[data-theme="light"] .page-header p {
    color: #64748b;
}

.page-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

/* --- Buttons (shared) — compact, quiet, high-end --- */
.btn-primary,
.btn-secondary,
.btn-ghost,
.btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    height: var(--control-height);
    padding: 0 14px;
    border-radius: var(--radius-md);
    font-size: var(--control-font);
    font-weight: 550;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
    transition:
        background 140ms ease,
        border-color 140ms ease,
        color 140ms ease,
        box-shadow 140ms ease,
        opacity 140ms ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent, #fff);
    border: 1px solid transparent;
    box-shadow: none;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary.btn-sm,
.btn-secondary.btn-sm,
.btn-ghost.btn-sm {
    height: var(--control-height-sm);
    padding: 0 12px;
    font-size: 0.8125rem;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: color-mix(in srgb, var(--border) 70%, var(--text-muted));
}

.btn-secondary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-success {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

/* Shared deployment action button. */
.btn-deploy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: background var(--transition-speed), color var(--transition-speed);
}

.btn-deploy:hover {
    background: rgba(113, 113, 122, 0.25);
}

.btn-deploy:disabled {
    cursor: not-allowed;
    opacity: 1;
}

.btn-deploy.ready {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.btn-deploy.ready:hover {
    background: rgba(59, 130, 246, 0.25);
}

.btn-deploy.released {
    cursor: default;
    opacity: 1;
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.deploy-pending-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--warning, #f59e0b);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.deploy-action-error {
    max-width: 260px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-ghost:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* --- Progress Bar --- */
.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    flex: 1;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Invite Modal --- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}


.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* Project app sharing uses the same modal shell as destructive confirmations,
   with a deliberate permission choice instead of a browser-native prompt. */
.project-share-modal {
    width: 480px;
}

.project-share-intro,
.project-share-error {
    margin: 0;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.project-share-error {
    color: var(--danger);
}

.project-share-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px;
    text-align: left;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}

.project-share-option:hover,
.project-share-option:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.project-share-option:disabled {
    cursor: wait;
    opacity: 0.72;
}

.project-share-option-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.project-share-option-copy strong {
    font-size: 14px;
}

.project-share-option-copy > span {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.45;
}

.project-share-switch {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    transition: background 0.18s ease;
}

.project-share-switch.on {
    background: var(--accent);
}

.project-share-switch-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.18s ease;
}

.project-share-switch.on .project-share-switch-knob {
    transform: translateX(18px);
}

.project-share-link-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.project-share-link-field label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.project-share-link-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.remix-error-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.remix-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.remix-title .design-thinking-dots {
    flex: 0 0 auto;
}

.remix-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Shell banner: upgrade / free-limit CTA (sits in .shell-banners, not over content). */
.subscription-upgrade-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    margin: 0;
    padding: 12px var(--shell-content-pad-x);
    background: color-mix(in srgb, var(--warning) 10%, var(--bg-secondary));
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
    border-radius: 0;
    box-sizing: border-box;
}

/* Workspace pause strip — theme-aware (was hard-coded amber in design.css). */
.workspace-pause-notice {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    width: 100%;
    margin: 0;
    padding: 10px var(--shell-content-pad-x);
    box-sizing: border-box;
    border-bottom: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
    background: color-mix(in srgb, var(--warning) 12%, var(--bg-secondary));
    color: var(--text-primary);
    font-size: 14px;
}

.workspace-pause-notice time {
    margin-left: auto;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.workspace-pause-notice a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.workspace-pause-notice a:hover {
    text-decoration: underline;
}

.subscription-upgrade-notice-copy,
.subscription-upgrade-notice-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.subscription-upgrade-notice-copy > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.subscription-upgrade-notice-copy strong {
    color: var(--text-primary);
    font-size: 14px;
}

.subscription-upgrade-notice-copy span:not(.subscription-upgrade-notice-icon) {
    color: var(--text-muted);
    font-size: 14px;
}

.subscription-upgrade-notice .btn-sm,
.subscription-upgrade-notice-close {
    font-size: 14px;
}

.subscription-upgrade-notice-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
    border-radius: 8px;
    font-weight: 800;
}

.subscription-upgrade-notice-close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.subscription-upgrade-notice-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.credited-free-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary));
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-radius: 10px;
}

.credited-free-notice > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.credited-free-notice strong {
    color: var(--text-primary);
    font-size: 14px;
}

.credited-free-notice span {
    color: var(--text-muted);
    font-size: 14px;
}

.design-workspace > .credited-free-notice {
    margin: 12px 16px 0;
}

@media (max-width: 700px) {
    .subscription-upgrade-notice {
        align-items: flex-start;
        flex-wrap: wrap;
        padding-left: max(var(--shell-content-pad-x-sm), env(safe-area-inset-left));
        padding-right: max(var(--shell-content-pad-x-sm), env(safe-area-inset-right));
    }

    .subscription-upgrade-notice-copy span:not(.subscription-upgrade-notice-icon) {
        display: none;
    }

    .workspace-pause-notice {
        padding-left: max(var(--shell-content-pad-x-sm), env(safe-area-inset-left));
        padding-right: max(var(--shell-content-pad-x-sm), env(safe-area-inset-right));
    }

    .workspace-pause-notice time {
        margin-left: 0;
        width: 100%;
    }

    .credited-free-notice {
        align-items: flex-start;
        flex-direction: column;
    }
    .credited-free-notice .btn-sm {
        align-self: flex-end;
    }
}

/* --- Form Controls --- */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 550;
    letter-spacing: -0.005em;
    color: var(--text-secondary);
}

.form-input,
.form-textarea,
.settings-input {
    box-sizing: border-box;
    width: 100%;
    max-width: 28rem;
    min-height: var(--control-height);
    padding: 0 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--control-font);
    letter-spacing: -0.005em;
    line-height: 1.4;
    outline: none;
    transition:
        border-color 140ms ease,
        box-shadow 140ms ease,
        background 140ms ease;
}

.form-textarea {
    min-height: 96px;
    padding: 10px 12px;
    resize: vertical;
}

.form-input:hover,
.form-textarea:hover,
.settings-input:hover {
    border-color: color-mix(in srgb, var(--border) 60%, var(--text-muted));
}

.form-input:focus,
.form-textarea:focus,
.settings-input:focus,
.form-input:focus-visible,
.form-textarea:focus-visible,
.settings-input:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
    box-shadow: var(--focus-ring);
    outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder,
.settings-input::placeholder {
    color: var(--text-muted);
}

.form-input:disabled,
.form-textarea:disabled,
.settings-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-textarea,
[data-theme="light"] .settings-input {
    background: #ffffff;
}

/* --- Data tables (content pages) ---
   Prefer these tokens for any list/table surface. Domain tables map onto them. */
.ui-table,
.team-table,
.admin-adjustment-table {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: none;
}

[data-theme="light"] .ui-table,
[data-theme="light"] .team-table,
[data-theme="light"] .admin-adjustment-table {
    background: #ffffff;
    box-shadow: var(--surface-shadow);
}

.ui-table-header,
.team-table-header,
.admin-adjustment-header {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    background: color-mix(in srgb, var(--bg-tertiary) 55%, var(--bg-secondary));
    border-bottom: 1px solid var(--border);
}

[data-theme="light"] .ui-table-header,
[data-theme="light"] .team-table-header,
[data-theme="light"] .admin-adjustment-header {
    background: #fafafa;
}

.ui-table-th,
.team-th {
    font-size: 0.6875rem; /* 11px */
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    line-height: 1.2;
}

.ui-table-row,
.team-row {
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 12px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
    transition: background 120ms ease;
}

.ui-table-row:last-child,
.team-row:last-child {
    border-bottom: none;
}

.ui-table-row:hover,
.team-row:hover {
    background: color-mix(in srgb, var(--bg-hover) 55%, transparent);
}

[data-theme="light"] .ui-table-row:hover,
[data-theme="light"] .team-row:hover {
    background: #fafafa;
}

/* Surface panels used on settings / billing content */
.ui-panel,
.settings-section.ui-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 20px 18px;
}

[data-theme="light"] .ui-panel,
[data-theme="light"] .settings-section.ui-panel {
    background: #ffffff;
    box-shadow: var(--surface-shadow);
}

