/* ============================================================================
   Components. Named blocks the site is assembled from: section headings, page
   header, brand mark, page-head backdrop, the home red shadow, CTA, list
   rows, stats, skeletons.
   ========================================================================== */
@layer components {
    /* ---- Section heading ---------------------------------------------------- */
    .section-head { max-width: 640px; margin-bottom: var(--space-10); }
    .section-head h2 { margin: 0 0 var(--space-3); }
    .section-head p { color: var(--text-secondary); font-size: var(--text-lg); line-height: 1.55; max-width: 56ch; }

    .section-bar {
        display: flex; justify-content: space-between; align-items: flex-end;
        gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-10);
    }
    .section-bar .section-head { margin-bottom: 0; }

    /* ---- Brand mark (BrandMark.razor) ----------------------------------------
       The ghost and RedSkia.dev, "Red" in the brand red. Flat: no shadow on
       the mark. Pointed at, the ghost lifts a little — nothing more. -------- */
    .nav-brand { display: inline-flex; align-items: center; color: var(--text-primary); }
    .brand-mark { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text-primary); }
    .brand-ghost { display: grid; place-items: center; width: 26px; height: 26px; }
    .brand-ghost img { width: 24px; height: 24px; transition: transform 0.3s var(--ease); }
    [data-theme="light"] .brand-ghost img { filter: invert(1); }
    a:hover .brand-ghost img { transform: translateY(-2px) rotate(-4deg); }
    .brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1.1875rem; letter-spacing: -0.035em; line-height: 1; }
    .brand-red { color: var(--action-primary-bg); }
    .brand-tld { color: var(--text-primary); font-weight: 600; }
    .brand-mark--lg { gap: var(--space-4); }
    .brand-mark--lg .brand-ghost { width: 56px; height: 56px; }
    .brand-mark--lg .brand-ghost img { width: 52px; height: 52px; }
    .brand-mark--lg .brand-word { font-size: 2rem; }
    @media (prefers-reduced-motion: reduce) { a:hover .brand-ghost img { transform: none; } }

    /* ---- Page header (Masthead.razor) --------------------------------------
       The opening of every standalone page: quiet meta, one big title, a lead,
       actions on the right. ------------------------------------------------ */
    .masthead {
        position: relative;
        display: flex; align-items: flex-end; justify-content: space-between;
        gap: var(--space-6) var(--space-10); flex-wrap: wrap;
        padding: var(--space-12) 0 var(--space-8);
        margin-bottom: var(--space-10);
        border-bottom: 1px solid var(--border-subtle);
    }
    .masthead-text { flex: 1 1 520px; max-width: 760px; }
    .masthead-meta {
        display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4);
        margin-bottom: var(--space-4);
        font-size: var(--text-sm); color: var(--text-tertiary);
    }
    .masthead-meta > * { display: inline-flex; align-items: center; gap: var(--space-2); font-variant-numeric: tabular-nums; }
    .masthead-title {
        margin: 0;
        font-size: clamp(2.25rem, 4.5vw, var(--text-4xl));
        font-weight: 700; letter-spacing: -0.045em; line-height: 1.02;
        color: var(--text-primary);
    }
    .masthead-lead {
        margin-top: var(--space-4); max-width: 60ch;
        font-size: var(--text-lg); line-height: 1.55; color: var(--text-secondary);
    }
    .masthead-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
    @media (max-width: 640px) { .masthead { padding-top: var(--space-8); } }

    /* Inside the admin frame every page opens the same compact way as Overview (.admin-head):
       a working title, one quiet line, actions on the right, no rule. */
    .admin-content .masthead { padding: 0; margin-bottom: var(--space-6); border-bottom: 0; align-items: flex-end; gap: var(--space-4); }
    .admin-content .masthead-meta { margin-bottom: var(--space-1); font-size: var(--text-xs); }
    .admin-content .masthead-title { font-size: var(--text-2xl); letter-spacing: -0.03em; line-height: 1.15; }
    .admin-content .masthead-lead { margin-top: var(--space-1); font-size: var(--text-sm); color: var(--text-tertiary); }
    .admin-content .stat-tile { padding: var(--space-4); }
    .admin-content .stat-tile-value { font-size: var(--text-xl); }

    /* ---- Page-head backdrop ------------------------------------------------
       Behind every page head: a faint red haze from the top-left corner and
       a hairline to close the head off. ---------------------------------- */
    .hero-backdrop { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
    .hero-backdrop::before {
        content: ""; position: absolute; inset: 0;
        background: radial-gradient(70% 120% at 0% 0%, var(--hero-glow-b), transparent 65%);
    }
    .hero-backdrop::after {
        content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
        background: linear-gradient(90deg, var(--action-primary-line), var(--border-strong) 30%, var(--border-subtle) 80%, transparent);
    }

    /* ---- Red shadow (home hero only) ----------------------------------------
       The ghost's shadow, pooled under the hero: a deep red haze, a brighter
       core, and one lit edge where it meets the page. It settles in once on
       load; that is the only unprompted motion on the site. ---------------- */
    .redshadow { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
    .redshadow::before {
        content: ""; position: absolute; left: -10%; right: -10%; top: 0; bottom: 0;
        background:
            radial-gradient(34% 26% at 64% 100%, var(--redshadow-core), transparent 72%),
            radial-gradient(62% 50% at 60% 100%, var(--redshadow-glow), transparent 72%),
            radial-gradient(110% 85% at 50% 100%, var(--redshadow-haze), transparent 76%);
        transform-origin: 60% 100%;
        animation: redshadow-in 1.6s var(--ease) both;
    }
    .redshadow::after {
        content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
        background: linear-gradient(90deg, transparent 5%, var(--redshadow-line) 45%, var(--redshadow-line) 75%, transparent 95%);
        box-shadow: 0 0 24px 4px var(--redshadow-glow);
    }
    @keyframes redshadow-in { from { opacity: 0; transform: translateY(12%) scaleY(0.85); } to { opacity: 1; transform: none; } }

    /* ---- CTA panel: text left, actions right --------------------------------- */
    .cta-panel {
        position: relative; overflow: hidden; isolation: isolate;
        display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--space-3) var(--space-12);
        padding: var(--space-12) var(--space-10);
        background: var(--surface-1); border: 1px solid var(--border-default);
        border-radius: var(--radius-xl);
    }
    .cta-panel h2 { font-size: clamp(1.75rem, 3.5vw, var(--text-3xl)); letter-spacing: -0.04em; grid-column: 1; }
    .cta-panel p { color: var(--text-secondary); font-size: var(--text-lg); max-width: 48ch; grid-column: 1; }
    .cta-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; grid-column: 2; grid-row: 1 / span 2; align-self: end; }
    @media (max-width: 760px) {
        .cta-panel { grid-template-columns: minmax(0, 1fr); padding: var(--space-10) var(--space-6); }
        .cta-actions { grid-column: 1; grid-row: auto; }
    }

    /* ---- List row ----------------------------------------------------------- */
    .list-row {
        display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5);
        border: 1px solid var(--border-default); border-radius: var(--radius-lg);
        background: var(--surface-1);
        transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
    }
    a.list-row:hover, .list-row:hover { border-color: var(--border-strong); background: var(--surface-hover); }
    .list-row .price { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
    .list-row .arrow { color: var(--text-tertiary); transition: transform 0.15s var(--ease), color 0.15s; }
    .list-row:hover .arrow { color: var(--text-primary); transform: translateX(3px); }

    /* ---- Skeleton loader ---------------------------------------------------- */
    /* The fade-in is held back 200ms, so data that lands inside that window
       never paints a placeholder at all. */
    .skeleton {
        border-radius: var(--radius);
        background: linear-gradient(90deg, var(--skeleton-from) 25%, var(--skeleton-to) 50%, var(--skeleton-from) 75%);
        background-size: 200% 100%;
        animation: shimmer 1.4s linear 200ms infinite, skeleton-in 120ms ease-out 200ms both;
    }
    /* Sizes the Skeleton component picks from (no inline styles): heights in px, widths in 5% steps, spacing. */
    .sk-h-9 { height: 9px; } .sk-h-10 { height: 10px; } .sk-h-11 { height: 11px; } .sk-h-13 { height: 13px; }
    .sk-h-14 { height: 14px; } .sk-h-15 { height: 15px; } .sk-h-24 { height: 24px; } .sk-h-28 { height: 28px; }
    .sk-h-40 { height: 40px; } .sk-h-48 { height: 48px; } .sk-h-96 { height: 96px; } .sk-h-160 { height: 160px; }
    .sk-h-220 { height: 220px; } .sk-h-240 { height: 240px; }
    .sk-w-5 { width: 5%; } .sk-w-10 { width: 10%; } .sk-w-15 { width: 15%; } .sk-w-20 { width: 20%; }
    .sk-w-25 { width: 25%; } .sk-w-30 { width: 30%; } .sk-w-35 { width: 35%; } .sk-w-40 { width: 40%; }
    .sk-w-45 { width: 45%; } .sk-w-50 { width: 50%; } .sk-w-55 { width: 55%; } .sk-w-60 { width: 60%; }
    .sk-w-65 { width: 65%; } .sk-w-70 { width: 70%; } .sk-w-75 { width: 75%; } .sk-w-80 { width: 80%; }
    .sk-w-85 { width: 85%; } .sk-w-90 { width: 90%; } .sk-w-95 { width: 95%; } .sk-w-100 { width: 100%; }
    .sk-w-64px { width: 64px; }
    .sk-grow { flex: 1; }
    .sk-mt-1 { margin-top: 0.4rem; } .sk-mt-2 { margin-top: 0.6rem; } .sk-mt-3 { margin-top: 0.75rem; }
    @keyframes skeleton-in { from { opacity: 0; } to { opacity: 1; } }
    @keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

    /* ---- Entrance (hero only) ----------------------------------------------- */
    @keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
    .fade-up { animation: fade-up 0.6s var(--ease) both; }
    .fade-up-2 { animation: fade-up 0.6s var(--ease) 0.08s both; }
    .fade-up-3 { animation: fade-up 0.7s var(--ease) 0.16s both; }

    /* ---- Result pages (404, payment outcomes, auth callback) ----------------
       One centred, elevated card. The status badge above the title answers
       "did it work?" before a word is read. ---------------------------------- */
    .result-page { position: relative; overflow: hidden; padding: var(--space-20) 0; }
    .result-page > .container { position: relative; z-index: 1; }
    .result-card {
        max-width: 520px; margin: 0 auto;
        display: flex; flex-direction: column; align-items: center; gap: var(--space-4);
        padding: var(--space-12) var(--space-8); text-align: center;
        background: var(--surface-1); border: 1px solid var(--border-strong);
        border-radius: var(--radius-xl); box-shadow: var(--shadow-3);
    }
    .result-title { font-size: var(--text-2xl); letter-spacing: -0.035em; }
    .result-lead { max-width: 42ch; color: var(--text-secondary); line-height: 1.6; }
    .result-receipt {
        width: 100%; display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-2) 0 0;
        padding: var(--space-4); text-align: left;
        background: var(--surface-sunken); border: 1px solid var(--border-default); border-radius: var(--radius);
    }
    .result-receipt dt { font-size: var(--text-xs); color: var(--text-tertiary); }
    .result-receipt dd { margin: var(--space-1) 0 0; font-size: var(--text-sm); word-break: break-all; color: var(--text-primary); }
    .result-note { font-size: var(--text-xs); color: var(--text-tertiary); }
    .result-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center; margin-top: var(--space-4); }
    /* A block placeholder while the payment is confirmed spans the card (the card centres its children). */
    .result-card .skeleton { width: 100%; }

    /* Floating surface for the header and sticky panels. */
    .glass {
        background: var(--glass-bg);
        backdrop-filter: saturate(160%) blur(16px);
        -webkit-backdrop-filter: saturate(160%) blur(16px);
    }
}

/* The floating edit dock never covers the last lines of the page. */
@layer components {
    body:has(.admin-dock) { padding-bottom: 4.5rem; }
}

/* Charts and KPI tiles (Components/Ui: AreaChart, Sparkline, BarList, KpiTile). One series per
   chart in brand red; grid and axes recede; values wear text colours, never the series colour. */
@layer components {
    .chart { margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
    .chart-readout { display: flex; flex-direction: column; gap: 2px; }
    .chart-readout-label { font-size: var(--text-xs); color: var(--text-tertiary); }
    .chart-readout-value { font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text-primary); }
    .chart-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); height: 220px; }
    .chart-yaxis { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding: 2px 0; font-size: var(--text-2xs); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
    .chart-svg { width: 100%; height: 100%; overflow: visible; }
    .chart-grid { stroke: var(--border-subtle); stroke-width: 1; stroke-dasharray: 3 4; }
    .chart-base { stroke: var(--border-default); stroke-width: 1; }
    .chart-area { fill: var(--action-primary-soft); }
    .chart-line { fill: none; stroke: var(--action-primary-bg); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
    .chart-cross { stroke: var(--border-hover); stroke-width: 1; }
    .chart-dot { stroke: var(--action-primary-bg); stroke-width: 9; stroke-linecap: round; }
    .chart-hit { fill: transparent; cursor: crosshair; }
    .chart-xaxis { display: flex; justify-content: space-between; margin-left: var(--space-10); font-size: var(--text-2xs); color: var(--text-tertiary); }
    .chart-table summary { font-size: var(--text-xs); color: var(--text-tertiary); cursor: pointer; width: max-content; }
    .chart-table[open] summary { margin-bottom: var(--space-2); }
    .chart-table .table { max-height: 16rem; display: block; overflow-y: auto; }

    .spark { display: block; width: 100%; height: 32px; margin-top: auto; }
    .spark-area { fill: var(--action-primary-soft); opacity: 0.7; }
    .spark-line { fill: none; stroke: var(--action-primary-bg); stroke-width: 1.5; stroke-linejoin: round; }

    .barlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
    .barlist-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); height: 30px; padding: 0 var(--space-3); font-size: 0.8125rem; border-radius: var(--radius-sm); overflow: hidden; }
    .barlist-bar { position: absolute; inset: 0; width: 100%; height: 100%; }
    .barlist-bar rect { fill: var(--action-primary-soft); }
    .barlist-label { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
    .barlist-value { position: relative; flex: none; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
    .empty-note { margin: 0; font-size: var(--text-sm); color: var(--text-tertiary); }
    .empty-note.is-padded { padding: var(--space-6) var(--space-4); text-align: center; }

    .kpi {
        display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4);
        background: var(--surface-1); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
    }
    .kpi:has(.spark) { min-height: 150px; }
    .kpi-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
    .kpi-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }
    .kpi-value { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text-primary); }
    .kpi-foot { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: var(--text-xs); white-space: nowrap; }
    .kpi-delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; font-weight: 600; border-radius: var(--radius-full); color: var(--text-secondary); background: var(--surface-2); }
    .kpi-delta.is-up { color: var(--status-ok-fg); background: var(--status-ok-bg); }
    .kpi-delta.is-down { color: var(--status-error-fg); background: var(--status-error-bg); }
    .kpi-vs { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-tertiary); }

    /* Admin page scaffolding shared by Overview, Analytics and Customers. */
    .admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
    .admin-head h1 { font-size: var(--text-2xl); letter-spacing: -0.03em; margin: 0; }
    .admin-head p { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--text-tertiary); }
    .admin-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
    .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
    .admin-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: var(--space-4); }
    .admin-grid > .span-4 { grid-column: span 4; } .admin-grid > .span-6 { grid-column: span 6; } .admin-grid > .span-8 { grid-column: span 8; }
    @media (max-width: 1100px) { .admin-grid > :is(.span-4, .span-6, .span-8) { grid-column: span 12; } }
    .admin-card { display: flex; flex-direction: column; min-width: 0; background: var(--surface-1); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
    .admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); }
    .admin-card-head h2 { margin: 0; font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; }
    .admin-card-head a { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--text-tertiary); }
    .admin-card-head a:hover { color: var(--text-primary); }
    .admin-card-body { padding: var(--space-4); flex: 1; }
    .admin-card-body.is-flush { padding: 0; }
    .admin-grid.analytics-gap { margin-top: var(--space-4); }

    /* A key/value list with an icon per row ("Right now" on the overview). */
    .stat-rows { list-style: none; margin: 0; padding: 0; }
    .stat-rows li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4); font-size: 0.8125rem; }
    .stat-rows li + li { border-top: 1px solid var(--border-subtle); }
    .stat-rows span:not(.icon-tile) { flex: 1; color: var(--text-secondary); }
    .stat-rows strong { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
    .stat-rows a { color: inherit; display: contents; }
}

/* The public page frame (Components/Ui/PageHero + .page-body): every page but Home and Portfolio
   opens with the same band, title size and spacing, then a body with one rhythm. Masthead (account
   and legal pages) uses the same type so those read alike. */
@layer components {
    .page-hero { position: relative; overflow: hidden; padding: var(--space-12) 0 var(--space-8); border-bottom: 1px solid var(--border-subtle); }
    .page-hero-inner { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4) var(--space-8); flex-wrap: wrap; }
    .page-hero-text { max-width: 760px; }
    .page-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
    .page-hero h1 { margin: 0; font-size: clamp(2.25rem, 4.2vw, 3.25rem); letter-spacing: -0.04em; line-height: 1.04; }
    .page-hero-lead { margin: var(--space-3) 0 0; max-width: 60ch; font-size: var(--text-lg); line-height: 1.55; color: var(--text-secondary); }
    .page-hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
    .page-body { padding-top: var(--space-8); padding-bottom: var(--space-16); }
    @media (max-width: 640px) { .page-hero { padding: var(--space-8) 0 var(--space-6); } .page-hero-lead { font-size: var(--text-base); } }

    /* Masthead outside the admin frame: same type as .page-hero. */
    .masthead { padding: var(--space-10) 0 var(--space-6); margin-bottom: var(--space-8); }
    .masthead-title { font-size: clamp(2.25rem, 4.2vw, 3.25rem); letter-spacing: -0.04em; line-height: 1.04; }
    .masthead-lead { margin-top: var(--space-3); }

    /* A plain content card, the one surface used for side panels and forms on public pages. */
    .surface-card { background: var(--surface-1); border: 1px solid var(--border-default); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
    .surface-card-pad { padding: var(--space-6); }
    .surface-card-title { margin: 0 0 var(--space-4); font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; color: var(--text-primary); }
}

/* Drop zones ([data-dropzone], state set by the drag script in js/redskia.js). While files are dragged
   anywhere on the page every zone breathes to say "drop here"; the zone under the pointer lifts,
   glows red and its icon bounces. Reduced motion keeps the colour change and drops the movement. */
@layer components {
    [data-dropzone] { transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease), background-color 0.18s var(--ease); }
    .is-dragging-files [data-dropzone] {
        border-color: var(--action-primary-line) !important; border-style: dashed !important;
        animation: drop-breathe 1.4s ease-in-out infinite;
    }
    .is-dragging-files [data-dropzone].is-drop-target {
        animation: none; transform: scale(1.015);
        border-color: var(--action-primary-bg) !important; border-style: solid !important;
        background-color: var(--action-primary-soft) !important;
        box-shadow: 0 0 0 4px var(--action-primary-soft), 0 12px 32px -12px var(--redshadow-glow);
    }
    .is-dragging-files [data-dropzone].is-drop-target svg { animation: drop-bounce 0.7s var(--ease) infinite alternate; }
    @keyframes drop-breathe { 50% { box-shadow: 0 0 0 4px var(--action-primary-soft); } }
    @keyframes drop-bounce { from { transform: translateY(0); } to { transform: translateY(-4px); } }
    @media (prefers-reduced-motion: reduce) {
        .is-dragging-files [data-dropzone], .is-dragging-files [data-dropzone].is-drop-target svg { animation: none; }
        .is-dragging-files [data-dropzone].is-drop-target { transform: none; }
    }
}

/* Side navigation for content pages (forum categories, blog tags): icon, label, count; the current
   item carries the admin sidebar's look. <nav class="side-nav"><button class="side-nav-item" aria-pressed>. */
@layer components {
    .side-nav { display: flex; flex-direction: column; gap: 1px; }
    .side-nav-title { margin: 0 0 var(--space-2); padding: 0 var(--space-3); font-size: var(--text-2xs); font-weight: 600; color: var(--text-tertiary); }
    .side-nav-item {
        display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 34px; padding: 0 var(--space-3);
        font: inherit; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); text-align: left; text-decoration: none;
        background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer;
        transition: color 0.12s var(--ease), background-color 0.12s var(--ease);
    }
    .side-nav-item .icon { color: var(--text-tertiary); }
    .side-nav-item:hover { color: var(--text-primary); background: var(--overlay-firm); }
    .side-nav-item[aria-pressed="true"] { color: var(--text-primary); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-default); }
    .side-nav-item[aria-pressed="true"] .icon { color: var(--accent-text); }
    .side-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .side-nav-count { font-size: var(--text-2xs); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

    /* Content page with a sticky side column (forum, writing). */
    .content-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: var(--space-6); align-items: start; }
    /* Main column first, a narrow card column on the right (forms with a "how it works" note). */
    .content-layout.side-right { grid-template-columns: minmax(0, 1fr) 20rem; }
    /* Grid items default to min-width: auto (their content), which would stop them shrinking on small screens. */
    .content-layout > * { min-width: 0; }
    .content-side { position: sticky; top: calc(var(--header-h) + var(--space-4)); display: flex; flex-direction: column; gap: var(--space-4); }
    .content-main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
    @media (max-width: 860px) {
        .content-layout, .content-layout.side-right { grid-template-columns: 1fr; }
        .content-side { position: static; }
        .content-side .side-nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
        .content-side .side-nav-item { flex: none; width: auto; }
        .content-side .side-nav-title { display: none; }
    }
}

/* Account tables (orders, subscriptions, the client portal): an instrument panel reads its records as rows of a
   table, not a stack of cards, so columns line up and amounts and dates compare at a glance. A lighter head than
   the plain .data-table, collapsed borders. */
@layer components {
    .data-table.is-compact { width: 100%; border-collapse: collapse; }
    .data-table.is-compact th {
        padding: var(--space-2) var(--space-4); font-size: var(--text-xs); font-weight: 600; text-align: left;
        color: var(--text-tertiary); border-bottom: 1px solid var(--border-subtle);
    }
    .data-table.is-compact td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); font-size: var(--text-sm); vertical-align: middle; }
    .data-table.is-compact tbody tr:last-child td { border-bottom: 0; }
    .data-table.is-compact th.num, .data-table.is-compact td.num { text-align: right; }
}
