/*
 * PehriJo Studio — app shell chrome (website/app/)
 * Layered ON TOP of css/style.css tokens. Uses only design tokens —
 * no raw hex outside this file's token references (Phase 0 rule).
 */

/* ===== Layout frame ===== */
.app-body {
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--primary);
    color: var(--white);
    padding: var(--space-2) var(--space-4);
    border-radius: 0 0 var(--radius-md, 8px) 0;
    z-index: 200;
}

.skip-link:focus {
    left: 0;
}

/* ===== Workspace topbar =====
 * The app header IS the marketing navbar (see studio-chrome.js): .navbar,
 * .nav-container, .nav-brand, .brand-text, .nav-links, .nav-link, .nav-actions
 * and .mobile-menu-btn all come from style.css, so the two surfaces cannot
 * drift apart again. This replaced a private .studio-topbar / .studio-nav /
 * .studio-brand / .studio-nav-btn set that had no max-width (so it ran the
 * full browser width), a 44px logo against the landing page's 60px, a pill
 * treatment on nav items against the landing page's plain links, and no
 * mobile menu at all.
 *
 * Two deliberate differences from the marketing bar:
 *   - anchoring: the marketing navbar is `position: fixed` and the landing
 *     hero offsets itself with padding. The app shell scrolls its own content,
 *     so the bar stays in flow as `sticky` and needs no body offset.
 *   - container width: 1200px to match .studio-panel below it, so the brand
 *     lines up with the page content. The marketing .nav-container is 1400px,
 *     which would leave the header hanging 100px outside the content column.
 */
.app-navbar {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
}

.app-navbar .nav-container {
    max-width: 1200px;
}

/* The workspace bar carries an identity control that the marketing bar does not
 * (avatar/name, or "Guest" + Sign in), plus the looks chip. At 360px that pushed
 * the row 28px past the viewport and shoved the hamburger off-screen, because the
 * marketing bar's own small-screen rules only account for its own contents.
 *
 * Below 480px the identity collapses to the avatar (a signed-in user) or the
 * Sign in link (a guest). Both remain labelled: the avatar button is the account
 * menu trigger and the menu repeats the name, and "Sign in" is the visible link. */
@media (max-width: 480px) {
    .app-navbar .nav-container,
    .app-navbar .nav-actions {
        gap: 4px;
    }

    .app-navbar .studio-account-name,
    .app-navbar .studio-account-guest {
        display: none;
    }

    /* The looks chip label is the widest item in the row (136px for "1 free
       look"). Collapsing it to the icon keeps the balance one tap away in the
       profile and still announced, because looks-chip.js mirrors the label into
       the chip's accessible name. */
    .app-navbar .looks-chip-label {
        display: none;
    }
}



/* ===== Panels =====
 * Each Studio section is now its own page, so the panel is the page body
 * (`.studio-panel`). `.studio-view` is kept for the legacy hash-panel markup
 * that still exists on a few pages, where only the active panel is shown. */
.studio-panel,
.studio-view {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-8);
}

.studio-panel {
    display: block;
    animation: studio-view-in 220ms ease;
}

.studio-view {
    display: none;
}

.studio-view.is-active {
    display: block;
    animation: studio-view-in 220ms ease;
}

@keyframes studio-view-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .studio-view.is-active { animation: none; }
}

.studio-panel-head {
    text-align: center;
    margin-bottom: var(--space-6);
}

/* The hosted wizard keeps its own section spacing; neutralize the double pad */
.studio-panel .generator-section,
.studio-view .generator-section {
    padding: 0;
    background: transparent;
}

.studio-panel .section-container,
.studio-view .section-container {
    padding: 0;
}

/* ===== Gallery (Looks) ===== */
.gallery-container {
    min-height: 240px;
}

.gallery-empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 14px);
    background: var(--bg-secondary);
}

.gallery-empty svg {
    opacity: 0.5;
    margin-bottom: var(--space-3);
}

.gallery-empty h3 {
    color: var(--text-primary);
    margin: 0 0 var(--space-2);
}

.gallery-empty p {
    margin: 0 0 var(--space-4);
}

/* ===== Profile panel ===== */
.profile-panel-card {
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 14px);
    padding: var(--space-6);
}

.profile-panel-card .profile-info {
    text-align: center;
    margin-bottom: var(--space-5);
}

.profile-panel-card .profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--primary-light);
    margin-bottom: var(--space-3);
}

.profile-panel-card .profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.profile-panel-card .stat-item {
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border-radius: var(--radius-md, 10px);
    padding: var(--space-4);
    text-align: center;
}

.profile-panel-card .stat-number {
    display: block;
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.profile-panel-card .stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ===== Footer ===== */
.studio-footer {
    border-top: 1px solid var(--border-color);
    padding: var(--space-5);
    margin-top: auto;
}

.studio-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.studio-footer-inner a {
    color: var(--text-muted);
    text-decoration: none;
    padding: var(--space-2) 0;
}
@media (hover: hover) and (pointer: fine) {
.studio-footer-inner a:hover {
    color: var(--text-primary);
}
}


.studio-footer-inner nav {
    display: flex;
    gap: var(--space-4);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .studio-view {
        padding: var(--space-4) var(--space-3) var(--space-7);
    }
}

/* ===== Focus system (Phase 0 parity) =====
 * The workspace nav links and the signed-out control now come from the marketing
 * navbar (.nav-link / .btn-login), which already carry a global :focus-visible
 * ring, so nothing app-specific is needed here. */

/* ===== Account control (topbar identity) =====
 * Replaces the old static label + repurposed "Sign in" link pair with one
 * control: the user's name and a real menu, or a single Sign in link. */
.studio-account {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.studio-account-btn {
    appearance: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
    min-height: 44px;
    border-radius: 999px;
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .studio-account-btn:hover {
        background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    }
}

.studio-account-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-cta, var(--primary));
    color: var(--white);
    font-size: var(--text-xs);
    font-weight: 700;
}

.studio-account-name {
    color: var(--text-muted);
}

.studio-account-guest {
    padding: var(--space-2);
}

.studio-account-chevron {
    opacity: 0.7;
}

.looks-chip-icon {
    width: 14px;
    height: 14px;
}

/* ===== Page toolbar (count + primary action) ===== */
.studio-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.studio-count {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.studio-inline-link {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--primary-light);
    text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
    .studio-inline-link:hover {
        text-decoration: underline;
    }
}

/* ===== Gate: a signed-out page says so instead of rendering an empty shell ===== */
.studio-gate {
    max-width: 460px;
    margin: var(--space-7) auto;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 14px);
    padding: var(--space-7) var(--space-5);
}

.studio-gate svg {
    opacity: 0.55;
    margin-bottom: var(--space-3);
}

.studio-gate h2 {
    margin: 0 0 var(--space-2);
    color: var(--text-primary);
}

.studio-gate p {
    margin: 0 0 var(--space-5);
    color: var(--text-muted);
}

/* ===== Loading / error status block ===== */
.studio-status {
    text-align: center;
    padding: var(--space-6);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 14px);
    color: var(--text-muted);
}

.studio-status.is-error {
    border-color: var(--error, var(--danger));
    color: var(--text-primary);
}

.studio-status p {
    margin: 0 0 var(--space-3);
}

.studio-status-retry {
    appearance: none;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    min-height: 44px;
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md, 10px);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--text-primary);
    cursor: pointer;
}

.studio-loading {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-6);
}


/* ===== Profile page ===== */
.profile-account-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 14px);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
}

.profile-account-card .profile-avatar {
    margin-bottom: 0;
    font-size: var(--text-xl);
    font-weight: 700;
}

.profile-account-meta {
    flex: 1;
    min-width: 0;
}

.profile-account-meta h2 {
    margin: 0 0 var(--space-1);
    font-size: var(--text-xl);
    color: var(--text-primary);
}

.profile-account-meta p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.profile-member-since {
    margin-top: var(--space-1) !important;
    font-size: var(--text-xs) !important;
}

/* ===== Profile tabs (owner request 2026-11-18) =====
 * Same pill idiom as the plans tabs (.plan-tab): three destinations instead
 * of one long scroll, with the destructive controls isolated on their own
 * tab so a long receipt list can never push Delete My Data below the fold.
 * The row scrolls rather than wraps on narrow screens: switching tabs must
 * never feel like landing on a different page. */
.profile-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    overflow-x: auto;
    scrollbar-width: none;
}

.profile-tabs::-webkit-scrollbar {
    display: none;
}

.profile-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 14px);
    color: var(--text-muted);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast),
        background var(--transition-fast), box-shadow var(--transition-fast);
}

@media (hover: hover) and (pointer: fine) {
    .profile-tab:hover {
        background: var(--bg-secondary);
        color: var(--text-primary);
    }
}

/* Active tab: the plans-page treatment (soft pink/violet tint), so the two
 * surfaces read as the same product. */
.profile-tab.active {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.15), rgba(139, 92, 246, 0.15));
    border-color: rgba(244, 114, 182, 0.4);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(244, 114, 182, 0.15);
}

.profile-tab svg {
    flex-shrink: 0;
}

.profile-tab:focus-visible {
    outline: 2px solid var(--accent-light, var(--primary));
    outline-offset: 2px;
}

.profile-tabpanel {
    margin-bottom: var(--space-5);
}

/* Same defensive pin as .plan-tab[hidden]: author rules must never resurrect
 * a hidden panel. */
.profile-tabpanel[hidden] {
    display: none;
}

@media (max-width: 480px) {
    .profile-tab {
        min-height: 40px;
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-xs);
    }
}

.btn-buy-looks {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md, 10px);
    background: var(--gradient-cta, var(--primary));
    color: var(--white);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
}

/* ===== Profile page — one measure, one block rhythm =====
 * The panel is 1200px so the topbar and the page edge line up, but text set to
 * that width is hard to scan and made the plan card's meta line a 1200px
 * sentence. The account content is therefore capped to a reading measure.
 */
#profileContent {
    max-width: 880px;
    margin: 0 auto;
}

/* Every section is a "block": heading, optional one-line note, then content.
 * The shared head is what makes four sections read as one account story
 * instead of four unrelated cards. */
.profile-block {
    margin-bottom: var(--space-6);
}

.profile-block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-color);
}

.profile-block-head h3 {
    margin: 0;
    font-size: var(--text-md);
    color: var(--text-primary);
}

.profile-block-note {
    margin: 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.profile-block-note[hidden] {
    display: none;
}

/* ===== Plan card (profile) ===== */
.plan-card {
    /* Anchors the absolutely positioned badge to this card. */
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 14px);
    padding: var(--space-5);
}

.plan-card-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.plan-card-empty h4 {
    margin: 0 0 var(--space-1);
    color: var(--text-primary);
}

.plan-card-empty p {
    margin: 0;
    max-width: 52ch;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.plan-card-cta {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: var(--space-2) var(--space-5);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md, 10px);
    color: var(--primary-light);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
}

.plan-card-head h4 {
    margin: var(--space-2) 0 var(--space-1);
    font-size: var(--text-lg);
    color: var(--text-primary);
}

.plan-card-meta {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.plan-status-pill {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--primary-light);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.plan-progress {
    height: 8px;
    margin: var(--space-4) 0 var(--space-2);
    border-radius: 999px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.08));
    overflow: hidden;
}

.plan-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--gradient-cta, var(--primary));
    transition: width 300ms ease;
}

.plan-card-foot {
    margin: 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ===== Payments & invoices (profile) =====
 * A list of receipt rows, not a table: each row is one payment with one
 * action, and rows reflow to two lines on a phone instead of scrolling
 * sideways. Figures use tabular numerals so amounts line up between rows.
 */
.payments-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
}

.payment-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
}

.payment-row:first-child {
    border-top: 0;
}

.payment-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.payment-plan {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.payment-meta {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.payment-figures {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    text-align: right;
}

.payment-amount {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.payment-status {
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px var(--space-2);
    border-radius: 999px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    color: var(--text-muted);
    white-space: nowrap;
}

.payment-status.is-paid {
    color: var(--success);
}

.payment-status.is-pending {
    color: var(--warning);
}

.payment-status.is-failed {
    color: var(--error);
}

.payment-status.is-refunded {
    color: var(--text-primary);
}

/* The invoice control is a link, a button or a plain note in the same slot, so
 * the row keeps one stable right-hand column in every state. */
.payment-invoice {
    appearance: none;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    min-height: 36px;
    /* A shared min-width keeps the amount column from shifting a few pixels
       between "Invoice", "Get invoice" and "No invoice" in the same list. */
    min-width: 104px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-3);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius-md, 10px);
    background: transparent;
    color: var(--primary-light);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.payment-invoice.is-none {
    border-color: var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
    cursor: default;
}

.payment-invoice:disabled {
    opacity: 0.6;
    cursor: progress;
}

@media (hover: hover) and (pointer: fine) {
    .payment-invoice:not(.is-none):hover {
        background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    }
}

.payments-toggle {
    appearance: none;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    width: 100%;
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    border: 0;
    border-top: 1px solid var(--border-color);
    background: transparent;
    color: var(--primary-light);
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .payments-toggle:hover {
        background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    }
}

/* No purchase yet: one sentence and one way forward. */
.payments-empty {
    padding: var(--space-5);
    text-align: center;
}

.payments-empty h4 {
    margin: 0 0 var(--space-1);
    font-size: var(--text-md);
    color: var(--text-primary);
}

.payments-empty p {
    margin: 0 auto var(--space-4);
    max-width: 46ch;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ===== Session actions =====
 * Signing out is not destructive, so it does not wear the danger colour: red
 * stays reserved for Delete My Data directly above it. */
.profile-session-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-5);
}

.btn-signout {
    appearance: none;
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    min-height: 44px;
    padding: 0 var(--space-5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .btn-signout:hover {
        background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    }
}

/* ===== Looks balance tiles ===== */
.looks-balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
}

.balance-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
}

.balance-tile.is-total {
    background: var(--bg-secondary);
    border-color: var(--primary-light);
}

.balance-tile.is-expiring {
    border-color: var(--accent);
}

.balance-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
}

.balance-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.balance-note {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* ===== Activity tiles =====
 * The same tile idiom as the Looks balance above it. The page previously had
 * two treatments for the same kind of fact — gradient text inside a centred
 * flex bar here, cards in a grid there — which read as two different products.
 */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    background: none;
    border-radius: 0;
}

.profile-stats .stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-4);
    text-align: left;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
}

.profile-stats .stat-number {
    /* Undo the marketing page's gradient text: on the account page a number has
       to be read, not decorated, and it has to match the tiles beside it. */
    background: none;
    background-clip: initial;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: currentColor;
    font-size: var(--text-2xl);
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.profile-stats .stat-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== Plans page ===== */
.plan-card.is-current {
    border-color: var(--primary-light);
}

.plan-card-badge-current {
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.08));
    color: var(--primary-light);
}

.plans-secure {
    margin-top: var(--space-3);
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.limit-exceeded-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
}

.limit-exceeded-btn-primary {
    background: var(--gradient-cta, var(--primary));
    color: var(--white);
    text-decoration: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    /* The avatar alone is enough to identify the account on a phone. */
    .studio-account-name {
        display: none;
    }

    .profile-account-card {
        flex-direction: column;
        text-align: center;
    }

    .plan-card-empty {
        flex-direction: column;
        align-items: flex-start;
    }

    .looks-balance-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* A receipt row is three columns at most on a phone: the plan and its facts on
 * the first line, the amount and status on the second, and the invoice action
 * spanning the full width where a thumb can reach it. */
@media (max-width: 560px) {
    .payment-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--space-2) var(--space-3);
        padding: var(--space-3) var(--space-4);
    }

    .payment-figures {
        grid-column: 2;
        grid-row: 1;
    }

    .payment-main {
        grid-column: 1;
        grid-row: 1;
    }

    .payment-invoice {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        /* Inherited from the desktop rule, but a phone row wants the full
           width rather than a fixed floor. */
        min-width: 0;
        min-height: 44px;
    }

    .payment-invoice.is-none {
        justify-content: flex-start;
        border-color: transparent;
        padding: 0;
        min-height: 0;
    }

    .profile-session-actions {
        justify-content: stretch;
    }

    .btn-signout {
        width: 100%;
    }

    .profile-block-head {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
    }
}
/* ============================================================================
   Gallery page (/gallery) — gal-* components
   One tagged feed of uploads + Looks. Filter chips + sort run client-side;
   tiles lazy-load their owner-gated images via blob fetch. Colors come only
   from the style.css tokens (design-token rule).
   ============================================================================ */

/* Author display rules (flex/grid below) beat the UA stylesheet's [hidden]
   rule, so a hidden-attribute container with a display rule still rendered.
   Every component toggled via the hidden attribute is pinned here. */
.hist-filter-note[hidden],
.hist-toolbar[hidden],
.gal-toolbar[hidden],
.gal-grid[hidden],
.hist-grid[hidden] {
    display: none;
}

/* ============================================================================
   Gallery page (/gallery) — gal-* components
   One tagged feed of uploads + Looks. Filter chips + sort run client-side;
   tiles lazy-load their owner-gated images via blob fetch. Colors come only
   from the style.css tokens (design-token rule).
   ============================================================================ */

/* ===== Toolbar ===== */
.gal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto var(--space-4);
}

.gal-chips {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.gal-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast),
        background var(--transition-fast);
}

.gal-chip:hover {
    border-color: rgba(148, 163, 184, 0.35);
    color: var(--text-primary);
}

.gal-chip.is-active {
    border-color: rgba(244, 114, 182, 0.45);
    background: rgba(244, 114, 182, 0.1);
    color: var(--text-primary);
}

.gal-chip-count {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-muted);
}

.gal-chip.is-active .gal-chip-count {
    color: var(--accent-light);
}

.gal-sort {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.gal-sort select {
    min-height: 36px;
    padding: 4px var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
}

/* ===== Tile grid =====
    Square-ish media tiles so mixed aspect ratios crop consistently. */
.gal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
    max-width: 1080px;
    margin: 0 auto;
}

.gal-tile {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.gal-tile:hover {
    border-color: rgba(148, 163, 184, 0.35);
}

.gal-tile.is-highlighted {
    border-color: rgba(244, 114, 182, 0.6);
    box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.35), 0 8px 32px rgba(219, 39, 119, 0.2);
}

.gal-tile-media {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-tertiary);
}

.gal-tile-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}

.gal-badge {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(3, 7, 12, 0.65);
    backdrop-filter: blur(4px);
}

.gal-badge--photo {
    color: var(--primary-light);
}

.gal-badge--fabric {
    color: var(--accent-light);
}

.gal-badge--readymade {
    color: var(--purple-300, var(--primary-light));
}

.gal-badge--result {
    color: var(--emerald-text);
}

.gal-tile-download {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: rgba(3, 7, 12, 0.65);
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast), border-color var(--transition-fast);
}

.gal-tile:hover .gal-tile-download,
.gal-tile-download:focus-visible {
    opacity: 1;
}

.gal-tile-caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.gal-tile-date {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.gal-tile-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--accent-light);
    text-decoration: none;
}

.gal-tile-link:hover {
    color: var(--white);
}

.gal-tile-label {
    margin: 0;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.gal-usage {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--primary-light);
    text-decoration: none;
}

.gal-usage:hover {
    color: var(--white);
}

@media (max-width: 560px) {
    .gal-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--space-3);
    }

    .gal-tile-download {
        opacity: 1;
    }
}

/* ============================================================================
   History page (/history) — hist-* additions over the shared gallery cards
   ============================================================================ */

.hist-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto var(--space-4);
}

.hist-count {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-muted);
}
}

.hist-filter-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: var(--radius-md, 10px);
    background: rgba(99, 102, 241, 0.08);
}

.hist-filter-note p {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.hist-filter-clear {
    min-height: 36px;
    padding: 6px var(--space-3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
}

.hist-grid {
    max-width: 1080px;
    margin: 0 auto;
}

/* Thumbnails carry two actions: click to zoom, corner link to the Gallery.
   Sized by width + aspect-ratio, NOT flex — the card's column flex container
   has no definite height, so a flex-basis-0 thumb collapsed to 0×0 (found
   live 2026-11-18: blob URLs loaded but rendered nothing). */
.hist-thumb {
    position: relative;
    width: 100%;
    min-width: 0;
    border-radius: var(--radius-md, 10px);
    overflow: hidden;
    background: var(--bg-tertiary);
    aspect-ratio: 4 / 5;
}

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

.hist-thumb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: var(--text-xs);
}

.hist-thumb-gallery {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: rgba(3, 7, 12, 0.65);
    color: var(--text-primary);
    opacity: 0;
    transition: opacity var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.hist-thumb:hover .hist-thumb-gallery,
.hist-thumb-gallery:focus-visible {
    opacity: 1;
}

.hist-thumb-gallery:hover {
    border-color: rgba(244, 114, 182, 0.45);
    color: var(--accent-light);
}

.hist-highlight {
    border-color: rgba(244, 114, 182, 0.6) !important;
    box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.35), 0 12px 32px rgba(219, 39, 119, 0.18);
}

@media (max-width: 768px) {
    .hist-thumb {
        aspect-ratio: 3 / 4;
    }

    .hist-thumb-gallery {
        opacity: 1;
    }
}


/* ===== GSTIN (enterprise invoicing, 2026-11-18) ===== */
.gstin-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
}

.gstin-row[hidden] { display: none; }

.gstin-head {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.gstin-head label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.gstin-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.gstin-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.gstin-controls input {
    flex: 0 1 240px;
    min-height: 40px;
    padding: 0 var(--space-3);
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--text-sm);
    text-transform: uppercase;
}

.gstin-controls input:focus-visible {
    outline: 2px solid var(--accent-light, var(--primary));
    outline-offset: 2px;
}

.gstin-save {
    min-height: 40px;
    padding: 0 var(--space-4);
    border: 1px solid rgba(244, 114, 182, 0.4);
    border-radius: var(--radius-md, 10px);
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.15), rgba(139, 92, 246, 0.15));
    color: var(--text-primary);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}

.gstin-save:disabled { opacity: 0.6; cursor: wait; }

.gstin-saved {
    font-size: var(--text-sm);
    color: #6ee7b7;
}
