/* ==========================================================================
   Fiddlekube Studio - design tokens & components
   Reuses the Fiddlekube website palette (dark default, Outfit, teal accent).
   Component classes are a contract shared by all Studio pages - see
   studio/README.md. Prefer these over page-specific CSS.

   Shared pieces (use these, do not re-invent them):
     .scroll-area              opt-in inner scroller: thin themed scrollbar, stable gutter; the wheel is contained
                               only while it overflows (studio.js sets .is-overflowing; also .textarea, .compose-preview)
     .inline-notice            one-sentence status next to an item (--warning / --danger / --info / --success)
     .badge                    the one state pill (min-height --pill-h); .badge--sm for dense rows
     .notice                   block-level message with an action
     .kv                       label/value rows (<dl class="kv"><dt>Link</dt><dd>...</dd></dl>); label column left, value wraps
     .back-link                single "Back to ..." link ABOVE the page header (36px tall, muted, text aligned to the edge)
     .avatar                   the one account-identity image/initial: --avatar-md (40px) by default,
                               .avatar--sm (--avatar-sm, 28px) for dense lists, .avatar--lg (56px) for profile heads
     .platform-card            selectable card; put the account .avatar (or the platform icon) first in .platform-card__head
     html.is-scroll-locked     set by Studio.lockScroll(owner); also applied automatically while a
                               <dialog class="modal|drawer"> is open or the mobile nav is open
     Page header actions: .page-actions holds ONE primary action (btn--primary). Any other navigation
                          action is btn--secondary (e.g. "Queue times", "Calendar", "History"). Do not put
                          btn--ghost in .page-actions: a ghost button's padding indents its label from the
                          heading edge, so the label no longer lines up with the heading.
                          "Back to ..." is a .back-link above the header, not a button in .page-actions.
     Touch targets: below 640px every .btn--sm, .select--sm, .compose-inline-btn, .net-summary__link,
                          .compose-preview__tab and .toast__close is 44px tall (--control-h); above that they keep
                          the dense desktop size. Small icon buttons (.queue-slot__remove, .compose-pv__nav) keep
                          their size and get a 44px hit area through a ::before, so do not give them a min-height.
     Tokens: --control-h (44px, buttons/inputs), --control-h-sm (36px), --chip-h (32px), --pill-h (24px),
             --pill-h-sm (20px, .badge--sm), --avatar-md (40px), --avatar-sm (28px),
             --btn-pad-x (horizontal button padding; 0 for .btn--icon, 0.8rem for .btn--sm)
     .section-head             section header: <h2> left, ONE action right (centred on the title), optional
                               .section-head__sub = one muted line under the title (max ~70 characters)
     .stat-tile                headline number: .stat-tile__label, __value (tabular-nums), __trend (change vs previous
                               period, always icon + text, .is-up/.is-down), __spark (sparkline slot, 2px line)
     .empty-row                compact "not enough data" row (icon + one sentence + action), max ~72px; the big
                               .empty illustration is only for a whole empty page/tab
     .chart-card               card for one chart: full-width svg (max-height 280px), __legend and __caption
                               inside the card under the chart; .chart-tooltip is the hover layer
     .seg                      segmented control: one row, never wraps, --control-h tall
     .progress                 thin bar (+ __bar); add .progress--seq for the sequential chart colour
     Chart tokens (dataviz, validated, see the block under :root): --chart-p-facebook|instagram|linkedin|youtube|tiktok
             (platforms in this fixed order, not brand colours), --chart-better / --chart-weaker / --chart-neutral
             (diverging, neutral = the "your usual" 1.0x line), --chart-seq-1..5 (one hue, low to high),
             --chart-hatch (texture for "too few posts", use .chart-hatch), --chart-grid / --chart-axis / --chart-label.
             Colour never carries meaning alone: pair it with an icon, a label or the hatch texture.
   Scroll rules: the page (document) is the one primary scroller. Inner scrollers are listed in the
   "Scrolling" section below and never chain wheel/trackpad scroll into the page.
   ========================================================================== */

:root {
    /* Brand (same as website/static/website/css/style.css) */
    --bg-color: #050505;
    --card-bg: #0a0a0a;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --accent: #4fd1c5;
    --accent-glow: rgba(79, 209, 197, 0.2);
    --border-color: #27272a;
    --font-heading: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* Studio surfaces */
    --surface-1: #0a0a0a;          /* cards */
    --surface-2: #111113;          /* inputs, nested */
    --surface-3: #18181b;          /* hover, chips */
    --border-strong: #3f3f46;
    --text-subtle: #8b8b94;        /* 5.6:1 on --bg */
    --accent-strong: #5eead4;
    --accent-contrast: #032320;    /* text on accent */
    --focus-ring: 0 0 0 2px var(--bg-color), 0 0 0 4px var(--accent);

    /* Status tones (text colour / soft background); always paired with icon + label */
    --tone-neutral: #d4d4d8;  --tone-neutral-bg: rgba(212, 212, 216, 0.10);
    --tone-muted: #a1a1aa;    --tone-muted-bg: rgba(161, 161, 170, 0.10);
    --tone-info: #7cb6ff;     --tone-info-bg: rgba(96, 165, 250, 0.14);
    --tone-progress: #c4b5fd; --tone-progress-bg: rgba(167, 139, 250, 0.16);
    --tone-success: #4ade80;  --tone-success-bg: rgba(74, 222, 128, 0.13);
    --tone-warning: #fbbf24;  --tone-warning-bg: rgba(251, 191, 36, 0.14);
    --tone-danger: #f87171;   --tone-danger-bg: rgba(248, 113, 113, 0.14);
    --danger-solid: #dc2626;  /* button bg, white text 4.8:1 */

    /* Platforms */
    --platform-facebook: #1877f2;
    --platform-instagram: #e1306c;
    --platform-linkedin: #0a66c2;
    --platform-youtube: #ff0000;
    --platform-tiktok: #25f4ee;

    /* Chart tokens (dataviz palette.md steps, validated against the dark surface #0a0a0a = --surface-1).
       node validate_palette.js --mode dark --surface #0a0a0a
         platforms "#3987e5,#d95926,#199e70,#c98500,#d55181": ALL CHECKS PASS. L band 0.48-0.67, chroma >= 0.1,
           CVD worst adjacent 8.4 (6-8 band: platform icon + direct label are the secondary encoding),
           normal-vision worst adjacent 19.3, contrast vs surface >= 3:1 for all 5.
         diverging "#1f9aa8,#9b3fc0" --pairs all: ALL CHECKS PASS. CVD 12.1 (deutan), normal 26.5, contrast >= 3:1.
       Light, --surface #ffffff:
         platforms "#2a78d6,#eb6834,#1baf7a,#eda100,#e87ba4": ALL CHECKS PASS (CVD 9.1, normal 19.6);
           WARN contrast < 3:1 for aqua 2.82, yellow 2.17, magenta 2.69. Relief rule: every platform mark has the
           platform icon, a direct label and a "Show as table" fallback.
         diverging "#1f9aa8,#9b3fc0" --pairs all: ALL CHECKS PASS. CVD 12.1 (deutan), normal 26.5, contrast >= 3:1.
         (teal and violet are used by no platform; better/weaker also carries an icon, a label or a signed ratio.)
       Sequential ramp = palette steps (dark 600..200, light 100..700): lightness is monotonic. The light low steps are under 3:1 on the card, so
       cells that use them need an edge (see .heat__cell). */
    --chart-p-facebook: #3987e5;
    --chart-p-instagram: #d95926;
    --chart-p-linkedin: #199e70;
    --chart-p-youtube: #c98500;
    --chart-p-tiktok: #d55181;
    --chart-better: #1f9aa8;
    --chart-weaker: #9b3fc0;
    --chart-neutral: #898781;
    --chart-seq-1: #184f95; --chart-seq-2: #256abf; --chart-seq-3: #3987e5; --chart-seq-4: #6da7ec; --chart-seq-5: #9ec5f4;
    --chart-hatch: #52525b;
    --chart-grid: #1f1f22;
    --chart-axis: #3f3f46;
    --chart-label: #a1a1aa;

    /* Scale */
    --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
    --space-5: 1.5rem;  --space-6: 2rem;   --space-7: 3rem;
    --radius-sm: 6px; --radius: 10px; --radius-lg: 16px; --radius-pill: 999px;
    --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.25rem; --text-xl: 1.75rem;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --transition-fast: 0.15s ease;
    --sidebar-width: 240px;
    --topbar-height: 56px;

    /* Control scale: one height per control family */
    --control-h: 44px; --control-h-sm: 36px; --chip-h: 32px; --pill-h: 24px; --pill-h-sm: 20px;

    /* Identity sizes: one avatar unit per density (compose, accounts, destination all use these) */
    --avatar-md: 40px; --avatar-sm: 28px;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-color: #ffffff;
        --card-bg: #f4f4f5;
        --text-main: #18181b;
        --text-muted: #52525b;
        /* Darker than the website's #0d9488 so links/buttons meet WCAG AA (5.5:1). */
        --accent: #0f766e;
        --accent-glow: rgba(13, 148, 136, 0.12);
        --border-color: #e4e4e7;

        --surface-1: #ffffff;
        --surface-2: #fafafa;
        --surface-3: #f4f4f5;
        --border-strong: #a1a1aa;
        --text-subtle: #5f5f68;
        --accent-strong: #115e59;
        --accent-contrast: #ffffff;

        --tone-neutral: #3f3f46;  --tone-neutral-bg: rgba(63, 63, 70, 0.08);
        --tone-muted: #52525b;    --tone-muted-bg: rgba(82, 82, 91, 0.08);
        --tone-info: #1d4ed8;     --tone-info-bg: rgba(29, 78, 216, 0.08);
        --tone-progress: #6d28d9; --tone-progress-bg: rgba(109, 40, 217, 0.08);
        --tone-success: #15803d;  --tone-success-bg: rgba(21, 128, 61, 0.09);
        --tone-warning: #a16207;  --tone-warning-bg: rgba(161, 98, 7, 0.10);
        --tone-danger: #b91c1c;   --tone-danger-bg: rgba(185, 28, 28, 0.08);
        --danger-solid: #b91c1c;
        --platform-tiktok: #000000;
        --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);

        --chart-p-facebook: #2a78d6;
        --chart-p-instagram: #eb6834;
        --chart-p-linkedin: #1baf7a;
        --chart-p-youtube: #eda100;
        --chart-p-tiktok: #e87ba4;
        --chart-better: #1f9aa8;
        --chart-weaker: #9b3fc0;
        --chart-neutral: #898781;
        --chart-seq-1: #cde2fb; --chart-seq-2: #86b6ef; --chart-seq-3: #3987e5; --chart-seq-4: #1c5cab; --chart-seq-5: #0d366b;
        --chart-hatch: #a1a1aa;
        --chart-grid: #e4e4e7;
        --chart-axis: #a1a1aa;
        --chart-label: #52525b;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; } /* gutter reserved: no layout jump when a lock hides the scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
body {
    margin: 0;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.55;
}
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
img, video, svg { max-width: 100%; }
img, video { display: block; }
code { font-size: 0.9em; background: var(--surface-3); padding: 0.1em 0.35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border-color); margin: var(--space-5) 0; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }

/* Focus: the ring is a box-shadow that follows each component's own radius (no radius override here). */
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
a:not([class]):focus-visible, .compose-inline-btn:focus-visible { border-radius: var(--radius-sm); }
@media (forced-colors: active) { :focus-visible { outline: 2px solid Highlight; outline-offset: 2px; } }

/* ---------- Scrolling & scroll lock ----------
   Rules:
   - Wheel/trackpad scroll stays in the container under the pointer. Every intentional inner
     scroller is listed here so it never chains into the page (overscroll-behavior: contain).
   - Scroll lock: Studio.lockScroll(owner) / Studio.unlockScroll(owner) (studio.js), or open
     <dialog class="modal|drawer"> / mobile nav, lock html. scrollbar-gutter keeps the width. */
.sidebar, .drawer, .modal, .compose-blocker__list, .table-wrap, .tabs,
.cal-root .fc-scroller, .cal-root .fc-popover-body {
    overscroll-behavior: contain;
}
/* Boxes that may or may not overflow (.scroll-area, .textarea, .compose-preview) contain the wheel only
   while studio.js (watchOverflow) marks them .is-overflowing. A short box passes the wheel to the page. */
.scroll-area, .textarea, .compose-preview { overscroll-behavior: auto; }
.scroll-area.is-overflowing, .textarea.is-overflowing, .compose-preview.is-overflowing { overscroll-behavior: contain; }
.scroll-area, .sidebar, .drawer, .modal, .compose-preview, .compose-blocker__list, .table-wrap, .tabs, .textarea,
.cal-root .fc-scroller, .cal-root .fc-popover-body {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
/* Gutter only where content really comes and goes (.scroll-area, compose preview, blocker list).
   Dialogs use both-edges so their content stays centred. The sidebar reserves nothing. */
.scroll-area, .compose-preview, .compose-blocker__list { overflow-y: auto; scrollbar-gutter: stable; }
.drawer, .modal { overflow-y: auto; scrollbar-gutter: stable both-edges; }
/* Horizontal-only scrollers: a sideways swipe at the end must not trigger browser Back or chain
   sideways; vertical wheel still scrolls the page when the box does not scroll vertically. */
.table-wrap, .tabs { overscroll-behavior: auto; overscroll-behavior-x: contain; }
/* Thin scrollbar for engines without scrollbar-width (Safari). Chromium 121+ and Firefox read the
   standard properties above, and ignore these pseudo-elements once scrollbar-width is supported. */
@supports not (scrollbar-width: thin) {
    .scroll-area::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .drawer::-webkit-scrollbar, .modal::-webkit-scrollbar,
    .compose-preview::-webkit-scrollbar, .compose-blocker__list::-webkit-scrollbar, .table-wrap::-webkit-scrollbar,
    .tabs::-webkit-scrollbar, .textarea::-webkit-scrollbar { width: 10px; height: 10px; }
    .scroll-area::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .drawer::-webkit-scrollbar-thumb,
    .modal::-webkit-scrollbar-thumb, .compose-preview::-webkit-scrollbar-thumb, .compose-blocker__list::-webkit-scrollbar-thumb,
    .table-wrap::-webkit-scrollbar-thumb, .tabs::-webkit-scrollbar-thumb, .textarea::-webkit-scrollbar-thumb {
        background: var(--border-strong); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: padding-box;
    }
}
/* Page lock: the page behind an open dialog does not scroll. The mobile menu locks via
   Studio.setScrollLock('nav', ...) in base.html, so it is media-aware and resets on widen. */
html.is-scroll-locked,
html:has(dialog.modal[open], dialog.drawer[open]) { overflow: hidden; }

.skip-link {
    position: absolute; left: var(--space-4); top: -100px; z-index: 1000;
    background: var(--accent); color: var(--accent-contrast); padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--space-4); }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon { flex-shrink: 0; vertical-align: middle; }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.cluster--between { justify-content: space-between; }
.grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.split { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); align-items: start; }
/* minmax(0, 1fr) on every single-column track: a wide table or code block must scroll inside its
   own box, never widen the track and create a horizontal page scrollbar at 375px. */
@media (max-width: 1024px) { .split { grid-template-columns: minmax(0, 1fr); } }
/* Key/value rows: label column on the left, value wraps. Used for "Link", "Scheduled", "Platform", etc. */
.kv { display: grid; grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr); gap: var(--space-2) var(--space-4); margin: 0; font-size: var(--text-sm); }
.kv > dt { color: var(--text-muted); font-weight: 600; }
.kv > dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 0; } .kv > dd { margin-bottom: var(--space-3); } }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: var(--space-4); } .mb-4 { margin-bottom: var(--space-4); }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.back-link {
    display: inline-flex; align-items: center; gap: var(--space-1); align-self: flex-start;
    min-height: var(--control-h-sm); padding: 0 var(--space-2); margin-left: calc(var(--space-2) * -1);
    color: var(--text-muted); font-size: var(--text-sm); font-weight: 500; text-decoration: none; border-radius: var(--radius-sm);
}
.back-link:hover { color: var(--text-main); }
.topbar { display: none; }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-main); text-decoration: none; font-weight: 500; }
.brand img { border-radius: 6px; }
.brand:hover { color: var(--text-main); }

.sidebar {
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column; gap: var(--space-5);
    padding: var(--space-5) var(--space-4);
    border-right: 1px solid var(--border-color);
    background: var(--bg-color);
}
.sidebar__brand { padding: 0 var(--space-2); font-size: 1.05rem; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav__link {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 0.6rem var(--space-3); border-radius: var(--radius);
    color: var(--text-muted); text-decoration: none; font-weight: 500;
    min-height: 44px;
}
.nav__link:hover { background: var(--surface-3); color: var(--text-main); }
.nav__link.is-active { background: var(--accent-glow); color: var(--text-main); }
.nav__link.is-active .icon { color: var(--accent); }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.sidebar__user { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-2); min-width: 0; }
.sidebar__username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
.sidebar-backdrop { display: none; }

.main { padding: var(--space-6) clamp(var(--space-4), 3vw, var(--space-7)); min-width: 0; outline: none; }
.page-header {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: var(--space-4); margin-bottom: var(--space-6);
}
.page-header__text { min-width: 0; }
.page-title { font-size: var(--text-xl); font-weight: 700; }
.page-subtitle { color: var(--text-muted); margin-top: var(--space-1); }
.page-subtitle:empty { display: none; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.page-actions:empty { display: none; }

@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .topbar {
        position: sticky; top: 0; z-index: 50; height: var(--topbar-height);
        display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3);
        background: var(--bg-color); border-bottom: 1px solid var(--border-color);
    }
    .topbar .brand { margin-right: auto; }
    .sidebar {
        position: fixed; z-index: 70; top: 0; left: 0; bottom: 0; width: min(85vw, 300px);
        transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow);
        visibility: hidden;
    }
    .sidebar.is-open { transform: none; visibility: visible; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); }
    .main { padding: var(--space-5) var(--space-4); }
    .page-header { align-items: flex-start; flex-direction: column; margin-bottom: var(--space-5); }
    .page-actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } * { animation-duration: 0.01ms !important; } }

/* ---------- Buttons ---------- */
.btn {
    --btn-bg: var(--surface-3); --btn-fg: var(--text-main); --btn-border: var(--border-color); --btn-pad-x: 1.1rem;
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--control-h); padding: 0.55rem var(--btn-pad-x); border-radius: var(--radius);
    border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
    font: inherit; font-weight: 600; font-size: var(--text-sm); line-height: 1.2;
    text-decoration: none; cursor: pointer; white-space: nowrap; user-select: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}
.btn:hover { color: var(--btn-fg); filter: brightness(1.08); }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--accent-contrast); --btn-border: var(--accent); }
.btn--secondary { --btn-bg: transparent; --btn-fg: var(--text-main); --btn-border: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-3); filter: none; }
.btn--danger { --btn-bg: var(--danger-solid); --btn-fg: #ffffff; --btn-border: var(--danger-solid); }
.btn--danger-ghost { --btn-bg: transparent; --btn-fg: var(--tone-danger); --btn-border: transparent; }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--text-muted); --btn-border: transparent; }
.btn--ghost:hover, .btn--danger-ghost:hover { background: var(--surface-3); filter: none; }
.btn--ghost:hover { color: var(--text-main); }
.btn--sm { --btn-pad-x: 0.8rem; min-height: var(--control-h-sm); padding: 0.35rem var(--btn-pad-x); font-size: var(--text-xs); }
.btn--lg { min-height: 52px; padding: 0.8rem 1.6rem; font-size: var(--text-md); }
.btn--block { width: 100%; }
.btn--icon { --btn-pad-x: 0; padding: 0; width: var(--control-h); }
.btn--icon.btn--sm { width: var(--control-h-sm); }
/* Touch targets: the dense controls grow to 44px on phones (desktop keeps the 36px density). */
@media (max-width: 640px) {
    .btn--sm, .select.select--sm { min-height: var(--control-h); }
    .btn--icon.btn--sm { width: var(--control-h); }
    .compose-inline-btn { min-height: var(--control-h); display: inline-flex; align-items: center; }
    /* Pills grow to 44px tall. Selectors are two classes deep so they beat the page sheets (loaded after this one). */
    .net-summary .net-summary__link { min-height: var(--control-h); }
    .compose-preview__tabs > .compose-preview__tab { min-height: var(--control-h); }
    /* Small icon buttons keep their visual size; the tappable area grows by 10px on every side (44px for a 24px button). */
    .queue-slot__remove { position: relative; }
    .queue-slot__remove::before, .compose-pv__nav::before { content: ''; position: absolute; inset: -10px; }
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.btn-group { display: inline-flex; flex-wrap: wrap; gap: var(--space-2); }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block; width: 1em; height: 1em; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
    vertical-align: -0.125em;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface-1); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: var(--space-5);
}
.card--flush { padding: 0; overflow: hidden; }
.card--interactive:hover { border-color: var(--border-strong); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.card__title { font-size: var(--text-lg); }
.card__footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-color); }
.section-title { font-size: var(--text-lg); margin-bottom: var(--space-3); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field__label { font-weight: 600; font-size: var(--text-sm); color: var(--text-main); }
.field__label .optional { font-weight: 400; color: var(--text-subtle); }
.field__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.field__hint { font-size: var(--text-xs); color: var(--text-subtle); }
.field__error {
    display: flex; align-items: flex-start; gap: var(--space-1);
    font-size: var(--text-sm); color: var(--tone-danger); font-weight: 500;
}
.field__error .icon { margin-top: 0.2em; }
.input, .select, .textarea {
    width: 100%; min-height: var(--control-h); padding: 0.6rem 0.8rem;
    background: var(--surface-2); color: var(--text-main);
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    font: inherit; font-size: var(--text-md); /* >=16px: no iOS zoom */
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.select {
    appearance: none; padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.7rem center;
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea,
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--tone-danger); }
.input-group { display: flex; align-items: stretch; }
.input-group > .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; }

.char-counter { font-size: var(--text-xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; white-space: nowrap; }
.char-counter.is-near { color: var(--tone-warning); }
.char-counter.is-over { color: var(--tone-danger); font-weight: 600; }

.checkbox, .radio { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; min-height: 44px; }
.checkbox input, .radio input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

/* Toggle switch: <label class="toggle"><input type="checkbox" role="switch"><span class="toggle__track"></span><span>Label</span></label> */
.toggle { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; min-height: 44px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track {
    position: relative; width: 42px; height: 24px; border-radius: var(--radius-pill);
    background: var(--border-strong); transition: background var(--transition-fast); flex-shrink: 0;
}
.toggle__track::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; transition: transform var(--transition-fast);
}
.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle__track { box-shadow: var(--focus-ring); }
.toggle input:disabled + .toggle__track { opacity: 0.5; }

/* Segmented control: <div class="segmented" role="radiogroup"><label><input type="radio" name=x><span>Now</span></label>...</div> */
.segmented {
    display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 3px;
    background: var(--surface-2); border: 1px solid var(--border-color); border-radius: var(--radius);
}
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
    display: inline-flex; align-items: center; gap: var(--space-1);
    /* 36px + 3px frame padding + 1px border on each side = 44px, the same as inputs */
    min-height: var(--control-h-sm); padding: 0.4rem 0.9rem; border-radius: calc(var(--radius) - 3px);
    font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); cursor: pointer;
}
.segmented input:checked + span { background: var(--surface-3); color: var(--text-main); box-shadow: inset 0 0 0 1px var(--border-strong); }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); }
.segmented input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* Progressive disclosure: <details class="disclosure"><summary>Advanced options</summary>...</details> */
.disclosure { border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--surface-1); }
.disclosure > summary {
    list-style: none; cursor: pointer; padding: var(--space-3) var(--space-4); min-height: 44px;
    display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: var(--text-sm);
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
    content: ''; width: 8px; height: 8px; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg); transition: transform var(--transition-fast); margin-left: var(--space-2);
}
.disclosure[open] > summary::after { transform: rotate(-135deg); }
.disclosure__body { padding: 0 var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------- Chips & badges ---------- */
.chip {
    display: inline-flex; align-items: center; gap: var(--space-1);
    min-height: var(--chip-h); padding: 0.25rem 0.7rem; border-radius: var(--radius-pill);
    background: var(--surface-3); border: 1px solid var(--border-color); color: var(--text-main);
    font-size: var(--text-sm); font-weight: 500; text-decoration: none; cursor: default;
}
button.chip, a.chip, label.chip { cursor: pointer; font: inherit; font-size: var(--text-sm); }
.chip:hover { border-color: var(--border-strong); color: var(--text-main); }
.chip.is-selected, .chip[aria-pressed="true"], input:checked + .chip { border-color: var(--accent); background: var(--accent-glow); }
.chip__remove { display: inline-flex; background: none; border: 0; padding: 0; color: var(--text-muted); cursor: pointer; }

/* One state pill for every item status (Accounts, Compose, History). Icon + label, never colour alone. */
.badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    min-height: var(--pill-h); padding: 0 0.6rem; border-radius: var(--radius-pill);
    font-size: var(--text-xs); font-weight: 600; line-height: 1.4; white-space: nowrap;
    color: var(--tone-neutral); background: var(--tone-neutral-bg);
}
.badge--sm { min-height: var(--pill-h-sm); padding: 0 0.45rem; }
.badge--neutral { color: var(--tone-neutral); background: var(--tone-neutral-bg); }
.badge--muted { color: var(--tone-muted); background: var(--tone-muted-bg); }
.badge--info { color: var(--tone-info); background: var(--tone-info-bg); }
.badge--progress { color: var(--tone-progress); background: var(--tone-progress-bg); }
.badge--progress .icon--loader { animation: spin 1s linear infinite; }
.badge--success { color: var(--tone-success); background: var(--tone-success-bg); }
.badge--warning { color: var(--tone-warning); background: var(--tone-warning-bg); }
.badge--danger { color: var(--tone-danger); background: var(--tone-danger-bg); }

/* Inline notice / banner: <div class="notice notice--warning" role="status">{% icon "alert" %}<div>...</div></div> */
.notice {
    display: flex; gap: var(--space-3); align-items: flex-start;
    padding: var(--space-3) var(--space-4); border-radius: var(--radius);
    border: 1px solid var(--border-color); background: var(--surface-2); font-size: var(--text-sm);
}
.notice > .icon { margin-top: 0.15em; }
.notice--info { border-color: var(--tone-info); background: var(--tone-info-bg); }
.notice--info > .icon { color: var(--tone-info); }
.notice--success { border-color: var(--tone-success); background: var(--tone-success-bg); }
.notice--success > .icon { color: var(--tone-success); }
.notice--warning { border-color: var(--tone-warning); background: var(--tone-warning-bg); }
.notice--warning > .icon { color: var(--tone-warning); }
.notice--danger { border-color: var(--tone-danger); background: var(--tone-danger-bg); }
.notice--danger > .icon { color: var(--tone-danger); }

/* Inline status line: one sentence that explains an item's state, placed beside or under it.
   Use .badge for the state itself (one per item), .inline-notice for the explanation, .notice for a block with an action.
   <p class="inline-notice inline-notice--warning">{% icon "alert" 14 %}<span>Reconnect to keep publishing.</span></p> */
.inline-notice {
    display: flex; align-items: flex-start; gap: var(--space-2);
    font-size: var(--text-xs); line-height: 1.45; color: var(--text-muted);
    min-width: 0; overflow-wrap: anywhere;
}
.inline-notice > .icon { flex-shrink: 0; margin-top: 0.15em; }
.inline-notice--warning { color: var(--tone-warning); }
.inline-notice--danger { color: var(--tone-danger); }
.inline-notice--info { color: var(--tone-info); }
.inline-notice--success { color: var(--tone-success); }

/* ---------- Platform visuals ---------- */
.platform-icon { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-main); }
.platform-icon svg { flex-shrink: 0; }
.platform-icon--facebook svg { color: var(--platform-facebook); }
.platform-icon--instagram svg { color: var(--platform-instagram); }
.platform-icon--linkedin svg { color: var(--platform-linkedin); }
.platform-icon--youtube svg { color: var(--platform-youtube); }
.platform-icon--tiktok svg { color: var(--platform-tiktok); }

/* Selectable platform/account card (compose, accounts). Same structure for every card:
     <label class="platform-card [is-selected] [is-disabled]"> (or <div> for non-selectable cards)
       <span class="platform-card__head">
         <span class="avatar">{avatar img or {% platform_icon %}}</span>      (the one --avatar-md identity unit)
         <span> name / "Platform · handle" sub-line </span>
       </span>
       <p class="inline-notice inline-notice--warning">...one status line...</p>   (optional)
       <div class="cluster">...actions...</div>                                   (optional)
   Cards in one grid row share a height (grid stretch); content stays top-aligned. */
.platform-card {
    position: relative; display: flex; flex-direction: column; gap: var(--space-2); height: 100%;
    padding: var(--space-4); border-radius: var(--radius-lg);
    border: 1px solid var(--border-color); background: var(--surface-1); cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.platform-card:hover { border-color: var(--border-strong); }
.platform-card.is-selected, .platform-card:has(input:checked) { border-color: var(--accent); background: var(--accent-glow); }
.platform-card:has(input:focus-visible) { box-shadow: var(--focus-ring); }
/* Disabled: no opacity on the card, so the reason, badge and fix text keep AA contrast.
   Signal it with a dashed border, not-allowed cursor and dimmed visuals (avatar/icons) only. */
.platform-card.is-disabled { cursor: not-allowed; background: var(--surface-2); border-style: dashed; }
.platform-card.is-disabled:hover { border-color: var(--border-color); }
.platform-card.is-disabled .platform-card__head .avatar,
.platform-card.is-disabled .platform-card__head img,
.platform-card.is-disabled .platform-card__head svg { opacity: 0.55; filter: grayscale(1); }
.platform-card.is-disabled .platform-card__head { color: var(--text-muted); }
.platform-card__head { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.platform-card__head > span:last-child { min-width: 0; display: flex; flex-direction: column; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: var(--avatar-md); height: var(--avatar-md); border-radius: 50%; overflow: hidden;
    background: var(--surface-3); color: var(--text-main); font-weight: 600; object-fit: cover;
}
.avatar--sm { width: var(--avatar-sm); height: var(--avatar-sm); font-size: var(--text-xs); }
.avatar--lg { width: 56px; height: 56px; }

/* ---------- Tabs ---------- */
/* <div class="tabs" role="tablist"><button class="tab" role="tab" aria-selected="true">Month</button>... */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-color); overflow-x: auto; }
.tab {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: var(--space-3) var(--space-4); min-height: 44px; white-space: nowrap;
    color: var(--text-muted); font: inherit; font-weight: 600; font-size: var(--text-sm); cursor: pointer; text-decoration: none;
}
.tab:hover { color: var(--text-main); }
.tab[aria-selected="true"], .tab.is-active { color: var(--text-main); border-bottom-color: var(--accent); }
.tab-panel { padding-top: var(--space-4); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table th { font-weight: 600; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
    /* Stacked rows: add data-label="Status" on each <td> */
    .table--stack thead { display: none; }
    .table--stack tr { display: block; padding: var(--space-3) 0; border-bottom: 1px solid var(--border-color); }
    .table--stack td { display: flex; justify-content: space-between; gap: var(--space-3); border: 0; padding: var(--space-1) var(--space-4); }
    .table--stack td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-weight: 600; }
}

/* ---------- Toasts ---------- */
.toast-region {
    position: fixed; z-index: 200; right: var(--space-4); bottom: var(--space-4);
    display: flex; flex-direction: column; gap: var(--space-2); width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
    border-radius: var(--radius); border: 1px solid var(--border-strong); border-left-width: 4px;
    background: var(--surface-1); color: var(--text-main); box-shadow: var(--shadow);
    animation: toast-in 0.2s ease-out;
}
.toast > .icon { margin-top: 0.15em; }
.toast__text { flex: 1; font-size: var(--text-sm); }
.toast__close { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 2px; min-width: 28px; min-height: 28px; border-radius: var(--radius-sm); }
.toast__close:hover { color: var(--text-main); }
.toast--success { border-left-color: var(--tone-success); } .toast--success > .icon { color: var(--tone-success); }
.toast--info, .toast--debug { border-left-color: var(--tone-info); } .toast--info > .icon { color: var(--tone-info); }
.toast--warning { border-left-color: var(--tone-warning); } .toast--warning > .icon { color: var(--tone-warning); }
.toast--danger { border-left-color: var(--tone-danger); } .toast--danger > .icon { color: var(--tone-danger); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 640px) {
    .toast-region { left: var(--space-4); right: var(--space-4); width: auto; }
    .toast__close { min-width: var(--control-h); min-height: var(--control-h); } /* after the base rule above, so it wins */
}

/* ---------- Modal (<dialog class="modal">) & drawer (<dialog class="drawer">) ---------- */
.modal, .drawer {
    border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-main);
    padding: 0; box-shadow: var(--shadow);
}
/* max-width overrides the UA dialog default (calc(100% - 6px - 2em)) so the modal uses the full gutter. */
.modal {
    border-radius: var(--radius-lg); width: min(480px, calc(100vw - 2rem)); max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); overflow-y: auto;
}
.modal--wide { width: min(760px, calc(100vw - 2rem)); }
.modal::backdrop, .drawer::backdrop { background: rgba(0, 0, 0, 0.6); }
.modal__dialog { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.modal__title { font-size: var(--text-lg); }
.modal__body { color: var(--text-muted); }
.modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
.drawer {
    margin: 0 0 0 auto; inset-block: 0; height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh;
    width: min(480px, 100vw); max-width: 100vw;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg); overflow-y: auto;
}
.drawer__body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.drawer__body { padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); } /* keep actions clear of the home indicator */
@media (max-width: 640px) {
    .modal__actions { flex-direction: column-reverse; }
    .modal__actions .btn { width: 100%; }
    .drawer { width: 100vw; max-width: 100vw; border-radius: 0; }
}

/* ---------- Empty states & skeletons ---------- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3);
    padding: var(--space-7) var(--space-4); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.empty-state--compact { padding: var(--space-5) var(--space-4); }
.empty-state__icon {
    display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px;
    border-radius: 50%; background: var(--accent-glow); color: var(--accent);
}
.empty-state__title { font-size: var(--text-lg); }
.empty-state__message { color: var(--text-muted); max-width: 46ch; }
.empty-state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }

.skeleton {
    display: block; border-radius: var(--radius-sm); min-height: 1em;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton--text { height: 0.9em; margin: 0.3em 0; }
.skeleton--block { height: 120px; border-radius: var(--radius); }
.skeleton--circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Media & upload ---------- */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
    padding: var(--space-6) var(--space-4); text-align: center; cursor: pointer;
    border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2);
    color: var(--text-muted); transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--accent); background: var(--accent-glow); color: var(--text-main); }
.dropzone:focus-within { box-shadow: var(--focus-ring); }
.progress { width: 100%; height: 6px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.media-grid { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.media-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--surface-3); border: 1px solid var(--border-color); }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }

/* Preview frame for "what will be posted" */
.preview { border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--surface-1); overflow: hidden; }
.preview__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-color); }
.preview__body { padding: var(--space-4); white-space: pre-wrap; word-break: break-word; font-size: var(--text-sm); }
.preview__media { background: #000; }
.preview__media img, .preview__media video { width: 100%; max-height: 480px; object-fit: contain; }

/* ---------- Shared patterns: section head, stat tile, empty row, chart card, segmented control ---------- */
.section-head {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
    column-gap: var(--space-4); row-gap: 2px; margin: 0 0 var(--space-4);
}
.section-head > :is(h2, h3) { font-size: var(--text-lg); min-width: 0; grid-column: 1; }
.section-head > :is(.btn, .badge, .section-head__action) { grid-column: 2; grid-row: 1; justify-self: end; }
.section-head__sub { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--text-sm); max-width: 70ch; }

.stat-tile {
    display: flex; flex-direction: column; gap: var(--space-1); min-width: 0;
    padding: var(--space-4); background: var(--surface-1);
    border: 1px solid var(--border-color); border-radius: var(--radius);
}
.stat-tile__label { color: var(--text-muted); font-size: var(--text-sm); }
.stat-tile__value { font-family: var(--font-heading); font-size: var(--text-xl); line-height: 1.1; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile__value.is-na { color: var(--text-subtle); }
.stat-tile__trend { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.stat-tile__trend.is-up { color: var(--tone-success); }
.stat-tile__trend.is-down { color: var(--tone-danger); }
.stat-tile__spark { display: block; width: 100%; height: 28px; margin-top: var(--space-1); max-width: 100%; color: var(--text-muted); }
.stat-tile__spark path { fill: none; stroke: currentColor; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }

.empty-row {
    display: flex; align-items: center; gap: var(--space-3); min-height: 48px; max-height: 72px;
    padding: var(--space-2) var(--space-4); overflow: hidden;
    background: var(--surface-2); border: 1px solid var(--border-color); border-radius: var(--radius);
    color: var(--text-muted); font-size: var(--text-sm);
}
.empty-row > svg { flex: none; width: 20px; height: 20px; }
.empty-row > :is(.btn, a):last-child { margin-left: auto; flex: none; }

.chart-card { padding: var(--space-4); background: var(--surface-1); border: 1px solid var(--border-color); border-radius: var(--radius); min-width: 0; }
.chart-card > svg { display: block; width: 100%; height: auto; max-height: 280px; overflow: visible; }
.chart-card__legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: var(--space-3) 0 0; padding: 0; list-style: none; font-size: var(--text-xs); color: var(--text-muted); }
.chart-card__legend li { display: inline-flex; align-items: center; gap: var(--space-1); }
.chart-card__caption { margin-top: var(--space-2); font-size: var(--text-xs); color: var(--text-muted); }
.chart-card svg text { font-family: var(--font-body); fill: var(--chart-label); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart-ref { stroke: var(--chart-neutral); stroke-width: 1; stroke-dasharray: 4 3; }
.chart-hatch { background-image: repeating-linear-gradient(45deg, var(--chart-hatch) 0 2px, transparent 2px 6px); }
.chart-tooltip {
    position: absolute; z-index: 5; pointer-events: none; max-width: 240px;
    padding: var(--space-2) var(--space-3); background: var(--surface-3); color: var(--text-main);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
    font-size: var(--text-xs); line-height: 1.4; font-variant-numeric: tabular-nums;
}
.chart-tooltip[hidden] { display: none; }

.seg {
    display: inline-flex; flex-wrap: nowrap; align-items: stretch; flex: none; max-width: 100%;
    height: var(--control-h); padding: 2px; gap: 2px;
    background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.seg__opt {
    display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
    padding: 0 var(--space-3); border: 0; border-radius: calc(var(--radius) - 3px);
    background: transparent; color: var(--text-muted); font: inherit; font-size: var(--text-sm); cursor: pointer; text-decoration: none;
}
.seg__opt:hover { background: var(--surface-3); color: var(--text-main); }
.seg__opt:focus-visible { box-shadow: var(--focus-ring); }
.seg__opt:is([aria-pressed="true"], [aria-current="true"], [aria-current="page"], .is-active) { background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.progress--seq .progress__bar { background: var(--chart-seq-3); }

/* ---------- Auth (login) ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth__card { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--space-4); }
.auth__brand { display: flex; align-items: center; gap: var(--space-2); font-size: 1.1rem; }
.auth__brand img { border-radius: 8px; }
.auth__title { font-size: var(--text-xl); }
.auth__footer { font-size: var(--text-xs); }
