/*
 * FFXIV Census design system.
 *
 * Tokens are defined once in :root and reused everywhere. Concept: the
 * aetheryte network. A blue night base, flat surfaces separated by tone,
 * and the two crystal colours (Aether, Crystal) reserved for data and focus.
 * Principles: no emoji, no inline styles, no ALL-CAPS labels, no glow, blur
 * or gradient decoration, no decorative motion. See docs/ui.md section 5.
 */

@font-face {
    font-family: "Manrope";
    src: url("fonts/manrope-latin-var.woff2") format("woff2");
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Figures face: Saira, variable in weight (400-800) and width (75-100%). */
@font-face {
    font-family: "Saira";
    src: url("fonts/saira-latin-var.woff2") format("woff2");
    font-weight: 400 800;
    font-stretch: 75% 100%;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    color-scheme: dark;

    /* Colour: surfaces */
    --color-night: #0D1220;    /* page background */
    --color-surface: #151C2E;  /* panels and tiles */
    --color-raised: #1D2640;   /* hover, selected rows, open menus, band track */
    --color-line: #28324D;     /* hairline separators and table rules only */
    --color-rim: #2F3B5C;      /* the lit top edge of panels and tiles, as on the game's windows */

    /* Colour: accents (data and focus only) */
    --color-aether: #5FD4F4;   /* links, primary series, focus ring, active nav */
    --color-crystal: #9D8CFF;  /* comparison series, brand facet; never text links */

    /* Colour: text */
    --color-ink: #E8ECF5;
    --color-ink-muted: #98A2BC;

    /* Colour: status (AA on Night, Surface and Raised) */
    --color-active: #4CC38A;
    --color-warning: #E8B04A;
    --color-negative: #EF7A72;

    /* Colour: job roles (meaning preserved, tuned to the palette; AA on Surface) */
    --color-role-tank: #5B8DEF;
    --color-role-healer: #4CC38A;
    --color-role-melee: #EF7A72;
    --color-role-phys-ranged: #F0975A;
    --color-role-magic-ranged: #B58CFF;
    --color-role-crafter: #3CC4B4;
    --color-role-gatherer: #E8C14A;

    /*
     * Colour: semantic mark palettes, taken from the game for meaning. Marks
     * only (bars, banners, rules, swatches); labels stay in ink and the name
     * is always printed beside the mark. Validated with the dataviz palette
     * validator (dark mode, all pairs) on Surface and Raised: every check
     * passes, every colour >= 3:1 on both.
     *   Roles: CVD worst dE 9.1 (deutan), normal-vision worst dE 23.6.
     *     DPS L 0.575 < tank L 0.60 < healer L 0.665, so the three also
     *     differ in lightness.
     *   Grand Companies: CVD worst dE 10.4 (deutan), normal-vision worst
     *     dE 18.7. Immortal Flames is a pale steel: the in-game black
     *     disappears on Night. "No company" is drawn as an outline, not a hue.
     */
    --color-mark-tank: #427FD8;
    --color-mark-healer: #03AF73;
    --color-mark-dps: #D2393A;
    --color-gc-maelstrom: #D1364C;
    --color-gc-twin-adder: #C38616;
    --color-gc-immortal-flames: #6896D1;

    /*
     * Colour: the level band ramp, an ordinal one-hue ramp in the Aether
     * hue (OKLCH h 220): the higher the band, the brighter and more
     * saturated, like an attuned aetheryte. Step 1 is A Realm Reborn, step 7
     * the level cap (see levelStep in levels.go). Validated with the dataviz
     * validator (--ordinal, dark): lightness monotone, adjacent dL >= 0.06,
     * single hue (7 deg spread), step 1 at 2.42:1 on Surface and 2.13:1 on
     * Raised. Marks only; every band is named beside its mark.
     */
    --color-level-1: #325F6D;
    --color-level-2: #3A7486;
    --color-level-3: #41899F;
    --color-level-4: #499FB8;
    --color-level-5: #51B5D3;
    --color-level-6: #59CCEE;
    --color-level-7: #61E4FF;

    /*
     * Colour: categorical chart palette. Eight slots in a fixed order, never
     * cycled; slot 1 is the Aether hue and slot 2 the Crystal hue, stepped
     * down to the top of the dark-mode chart band (OKLCH L 0.48-0.67; the
     * brand Aether and Crystal are lighter than the band allows). No gold or
     * amber slot: the spec drops gold entirely. Validated with the dataviz
     * palette validator on Night and Surface: adjacent CVD dE >= 8.2,
     * normal-vision dE >= 17.0, every slot >= 3:1 on Surface; slots 1-4 also
     * pass all-pairs (regions use them). Races and regions take the slot of
     * their position in the census taxonomy (domain/census/taxonomy.go).
     * Single-series charts use Aether, comparisons Crystal.
     */
    --color-chart-1: #00A4C5;  /* Aether hue */
    --color-chart-2: #917EF4;  /* Crystal hue */
    --color-chart-3: #D24C49;  /* red */
    --color-chart-4: #B334AD;  /* magenta */
    --color-chart-5: #4194F9;  /* blue */
    --color-chart-6: #27AF57;  /* green */
    --color-chart-7: #DD61A2;  /* pink */
    --color-chart-8: #DD7303;  /* orange */
    --color-chart-other: #7C869E;  /* neutral for unmapped categories */

    /*
     * Type: Manrope for text and labels; Saira, semi-condensed, for figures,
     * rank numerals, page titles and the wordmark (the HUD-like numeric voice
     * of the game's own interface). Contrast comes from weight, size and width.
     */
    --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-figures: "Saira", "Manrope", ui-sans-serif, system-ui, sans-serif;
    --width-semi-condensed: 87.5%;
    --width-condensed: 80%;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --weight-body: 400;
    --weight-medium: 500;
    --weight-heading: 600;
    --weight-display: 800;

    /* Type scale: modular ratio 1.25 on a 16px body */
    --step--2: 0.64rem;   /* 10.24px */
    --step--1: 0.8rem;    /* 12.8px  */
    --step-0: 1rem;       /* 16px    */
    --step-1: 1.25rem;    /* 20px    */
    --step-2: 1.563rem;   /* 25px    */
    --step-3: 1.953rem;   /* 31.25px */
    --step-4: 2.441rem;   /* 39px    */
    --step-5: 3.052rem;   /* 48.8px  */
    --step-6: 3.815rem;   /* 61px    */
    --leading-body: 1.55;
    --leading-tight: 1.15;
    --tracking-display: -0.02em;
    --measure: 70ch;

    /* Space: 4px base */
    --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;
    --space-8: 4rem;

    /* Shape: pages square, panels 12px, controls 8px, chips fully rounded */
    --radius-panel: 12px;
    --radius-control: 8px;
    --radius-pill: 9999px;

    /* Depth: only open menus and tooltips cast a shadow. Panels and tiles
       get a 1px lit top edge instead (an inset line, not a shadow). */
    --shadow-overlay: 0 8px 24px rgba(4, 7, 15, 0.6);
    --rim: inset 0 1px 0 var(--color-rim);

    /* Focus */
    --focus-ring: 2px solid var(--color-aether);
    --focus-offset: 2px;

    /* Layout */
    --content-max: 1280px;
    --gutter: var(--space-4);
    --header-height: 3.5rem;

    /* Motion: functional only, removed under reduced motion */
    --duration-fast: 120ms;
    --duration-base: 200ms;
    /* One entrance per page, on full page loads only (see [data-entrance]). */
    --duration-entrance: 360ms;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /*
     * Legacy aliases, referenced only by the inline styles of the disabled
     * character and free company templates. Gold is gone from the palette, so
     * the gold aliases resolve to neutral ink. Remove them when those
     * templates are restyled.
     */
    --bg-card: var(--color-surface);
    --border-color: var(--color-line);
    --text: var(--color-ink);
    --text-dim: var(--color-ink-muted);
    --gold: var(--color-ink);
    --gold-light: var(--color-ink);
    --cyan: var(--color-aether);
}

/* ---------- Base ---------- */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--step-0);
    font-weight: var(--weight-body);
    line-height: var(--leading-body);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    background-color: var(--color-night);
    color: var(--color-ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
    line-height: var(--leading-tight);
    font-weight: var(--weight-heading);
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--color-aether);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--duration-fast) ease;
}

a:hover {
    color: var(--color-ink);
}

/* A visible focus ring on every interactive element. */
:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
    border-radius: 2px;
}

main:focus {
    outline: none;
}

select,
input,
button,
textarea {
    font: inherit;
    color: inherit;
}

select,
input[type="text"],
input[type="search"] {
    background: var(--color-surface);
    color: var(--color-ink);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-control);
    padding: var(--space-2) var(--space-3);
    min-height: 2.5rem;
}

.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;
}

/* ---------- Shell: skip link ---------- */

.skip-link {
    position: absolute;
    left: var(--gutter);
    top: var(--space-2);
    z-index: 200;
    padding: var(--space-2) var(--space-4);
    background: var(--color-aether);
    color: var(--color-night);
    font-weight: var(--weight-heading);
    border-radius: var(--radius-control);
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: none;
    color: var(--color-night);
    outline-color: var(--color-ink);
}

/* ---------- Shell: header, brand, primary nav ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-night);
    border-bottom: 1px solid var(--color-line);
}

.site-header-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gutter);
    min-height: var(--header-height);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 var(--space-4);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-ink);
    text-decoration: none;
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-1);
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: var(--space-3) 0 var(--space-2);
}

.brand:hover {
    color: var(--color-ink);
}

.brand-mark {
    width: 20px;
    height: 28px;
    flex-shrink: 0;
}

.brand-facet-aether { fill: var(--color-aether); }
.brand-facet-crystal { fill: var(--color-crystal); }
.brand-facet-crown { fill: var(--color-ink); opacity: 0.85; }

/*
 * Primary nav: one bar on every width. On phones it takes its own row under
 * the brand and scrolls sideways (census.js scrolls the current item into
 * view); faded edges hint that there is more to scroll. Focus rings sit
 * inside the bar so the scroller never clips them.
 */
.primary-nav {
    flex-basis: 100%;
    min-width: 0;
    margin: 0 calc(-1 * var(--gutter));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--gutter), #000 calc(100% - var(--space-7)), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 var(--gutter), #000 calc(100% - var(--space-7)), transparent 100%);
}

.primary-nav::-webkit-scrollbar {
    display: none;
}

.primary-nav-list {
    list-style: none;
    display: flex;
    gap: var(--space-1);
    width: max-content;
    padding: 0 var(--space-7) 0 var(--gutter);
}

.primary-nav a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 var(--space-3);
    color: var(--color-ink-muted);
    font-weight: var(--weight-medium);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--duration-fast) ease;
}

.primary-nav a:hover {
    color: var(--color-ink);
}

.primary-nav a:focus-visible {
    outline-offset: -4px;
    border-radius: var(--radius-control);
}

/* The current page: ink text over a lit aether rule, like a selected tab. */
.primary-nav a[aria-current="page"] {
    color: var(--color-ink);
    font-weight: var(--weight-heading);
}

.primary-nav a[aria-current="page"]::after {
    content: "";
    position: absolute;
    left: var(--space-3);
    right: var(--space-3);
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--color-aether);
}

@media (min-width: 900px) {
    .site-header-inner {
        flex-wrap: nowrap;
    }

    .primary-nav {
        flex-basis: auto;
        margin: 0;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .primary-nav-list {
        padding: 0;
    }

    .primary-nav a {
        min-height: var(--header-height);
    }
}

/* ---------- Shell: main and footer ---------- */

.page-container {
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
    padding: var(--space-6) var(--gutter) var(--space-7);
    flex: 1;
}

@media (min-width: 768px) {
    :root {
        --gutter: var(--space-5);
    }
}

.site-footer {
    border-top: 1px solid var(--color-line);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}

.site-footer-inner {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--space-5) var(--gutter);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
}

.footer-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
}

.footer-links a {
    display: inline-block;
    padding: var(--space-1) 0;
}

/* ---------- Components: notice ---------- */

.notice {
    margin-bottom: var(--space-5);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-ink);
    border-left: 3px solid var(--color-aether);
}

.notice-stale {
    border-left-color: var(--color-warning);
}

/* A notice with a leading icon (the layout's stale notice). */
.notice:has(> .notice-icon) {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.notice-icon {
    flex-shrink: 0;
    margin-top: 0.15em;
    color: var(--color-aether);
}

.notice-stale .notice-icon { color: var(--color-warning); }

.notice-title {
    font-weight: var(--weight-heading);
    color: var(--color-ink);
}

/* ---------- Components: empty state ---------- */

.empty-state {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius-control);
    background: var(--color-night);
}

.empty-state-text { max-width: var(--measure); }

@media (max-width: 479px) {
    .notice { font-size: var(--step--1); }
}

.empty-state-mark {
    flex-shrink: 0;
    margin-top: 0.1em;
    fill: none;
    stroke: var(--color-ink-muted);
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.empty-state-mark path { stroke: var(--color-aether); }

.empty-state-title {
    font-weight: var(--weight-heading);
    color: var(--color-ink);
}

.empty-state-hint {
    color: var(--color-ink-muted);
    font-size: var(--step--1);
    margin-top: var(--space-1);
}

.empty-state-action {
    margin-top: var(--space-2);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
}

/* ---------- Components: state page (404 / 503) ---------- */

.state-page {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 40rem;
    padding: var(--space-7) 0 var(--space-6);
}

.state-mark {
    margin-bottom: var(--space-5);
}

.state-mark-orbit {
    fill: none;
    stroke: var(--color-line);
    stroke-width: 1.5;
}

.state-mark-orbit-inner { stroke-dasharray: 3 5; }
.state-mark-node { fill: var(--color-line); }
.state-mark-pending .state-mark-node { fill: var(--color-aether); }
.state-mark-facet-aether { fill: var(--color-aether); }
.state-mark-facet-crystal { fill: var(--color-crystal); }
.state-mark-facet-crown { fill: var(--color-ink); opacity: 0.85; }

/* Not found: the crystal is unlit, drawn only as an outline. */
.state-mark-missing .state-mark-facet-aether,
.state-mark-missing .state-mark-facet-crystal,
.state-mark-missing .state-mark-facet-crown {
    fill: var(--color-surface);
    stroke: var(--color-ink-muted);
    stroke-width: 1.5;
    stroke-linejoin: round;
    opacity: 1;
}

.state-code {
    color: var(--color-ink-muted);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    font-variant-numeric: tabular-nums;
    margin-bottom: var(--space-2);
}

.state-title {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-5);
    font-weight: 700;
    letter-spacing: -0.005em;
    line-height: var(--leading-tight);
    color: var(--color-ink);
}

.state-lead {
    margin-top: var(--space-4);
    color: var(--color-ink-muted);
    font-size: var(--step-1);
    max-width: var(--measure);
}

.state-actions {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.state-actions .btn {
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-5);
    font-size: var(--step-0);
}

@media (max-width: 479px) {
    .state-page { padding-top: var(--space-5); }
    .state-title { font-size: var(--step-4); }
    .state-lead { font-size: var(--step-0); }
}

/* ---------- Components: page header ---------- */

.page-header {
    margin-bottom: var(--space-6);
}

.page-title {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-5);
    font-weight: 700;
    letter-spacing: -0.005em;
    line-height: var(--leading-tight);
    color: var(--color-ink);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

.page-desc {
    color: var(--color-ink-muted);
    font-size: var(--step-0);
    margin-top: var(--space-2);
    max-width: var(--measure);
}

@media (max-width: 767px) {
    .page-title {
        font-size: var(--step-4);
    }
}

/* ---------- Components: stat tile ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

/* Three tiles: the headline tile spans the row over a pair on phones, then
   one row of three. Four tiles: 2 x 2 on phones and tablets, one row on
   desktop. Neither stacks into one tall column. */
.stat-grid-trio > .stat-card:first-child { grid-column: 1 / -1; }

@media (min-width: 600px) {
    .stat-grid { gap: var(--space-4); }
    .stat-grid-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat-grid-trio > .stat-card:first-child { grid-column: auto; }
}

@media (min-width: 1024px) {
    .stat-grid-quad { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Two tiles share a 360px row: tighten the tile so a seven-figure value
   still fits on one line. */
@media (max-width: 599px) {
    .stat-grid .stat-card { padding: var(--space-4); }
    .stat-grid .stat-value { font-size: clamp(var(--step-2), 8vw, var(--step-4)); }
    .stat-grid-trio > .stat-card:first-child .stat-value { font-size: var(--step-4); }
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-panel);
    box-shadow: var(--rim);
    padding: var(--space-5);
}

.stat-label {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    color: var(--color-ink-muted);
    margin-bottom: var(--space-2);
}

.stat-value {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-4);
    font-weight: 600;
    line-height: 1.05;
    color: var(--color-ink);
}

.stat-subtext {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    margin-top: var(--space-2);
}

/* ---------- Components: panel ---------- */

.panel {
    background: var(--color-surface);
    border-radius: var(--radius-panel);
    box-shadow: var(--rim);
    margin-bottom: var(--space-6);
    overflow: hidden;
    /* clip, not hidden: no scroll container, so table headers can stick to the viewport */
    overflow: clip;
}

.panel-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-line);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.panel-title {
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    color: var(--color-ink);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.panel-body {
    padding: var(--space-5);
}

@media (max-width: 767px) {
    .panel-header { padding: var(--space-4); }
    .panel-body { padding: var(--space-4); }
}

/* ---------- Components: charts ---------- */

.chart-container {
    position: relative;
    width: 100%;
    height: clamp(240px, 50vw, 340px);
}

/* ---------- Components: data table ---------- */

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: var(--step--1);
    font-variant-numeric: tabular-nums;
}

.data-table th {
    background: var(--color-surface);
    color: var(--color-ink-muted);
    font-weight: var(--weight-heading);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-line);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-line);
    color: var(--color-ink);
    vertical-align: middle;
}

.data-table tbody tr:hover,
.data-table tbody tr:focus-within {
    background-color: var(--color-raised);
}

.data-table tr.clickable {
    cursor: pointer;
}

/*
 * Scrolling data table. The table sits in a focusable, named region
 * (role="region" tabindex="0") that scrolls sideways on its own, so the page
 * never does. The first column (the row header: world, race, region) sticks
 * to the left edge while the rest scrolls under it. On wide screens, where
 * the table fits, the region stops being a scroll container and the column
 * headers stick below the site header instead.
 */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    container-type: inline-size;
}

.table-scroll:focus-visible {
    outline-offset: -2px;
}

.table-scroll > .data-table > thead > tr > th:first-child,
.table-scroll > .data-table > tbody > tr > th[scope="row"] {
    position: sticky;
    left: 0;
    z-index: 1;
}

.data-table > tbody > tr > th[scope="row"] {
    background: var(--color-surface);
}

.data-table > tbody > tr:hover > th[scope="row"],
.data-table > tbody > tr:focus-within > th[scope="row"] {
    background: var(--color-raised);
}

.data-table > tbody > tr > th[scope="row"] a {
    font-weight: var(--weight-heading);
    text-underline-offset: 0.2em;
}

.data-table abbr[title] {
    text-decoration: none;
}

/* Rank number before a world name in the rankings. */
.row-rank {
    display: inline-block;
    min-width: 2.5ch;
    margin-right: var(--space-3);
    color: var(--color-ink-muted);
    font-family: var(--font-figures);
    font-stretch: var(--width-condensed);
    font-size: var(--step-0);
    font-weight: 600;
    text-align: right;
}

/* Swatch tying a table row to its chart colour (.chart-slot-N). */
.swatch {
    display: inline-block;
    width: 0.625rem;
    height: 0.625rem;
    margin-right: var(--space-2);
    border-radius: 2px;
    background: var(--slot-color, var(--color-chart-other));
    vertical-align: baseline;
}

.share-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
}

.share-cell > span {
    min-width: 3.25rem;
}

.share-cell > .share-meter {
    width: clamp(4rem, 12vw, 10rem);
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .data-table th,
    .data-table td {
        padding: var(--space-3);
    }

    /* A hairline marks the edge the other columns scroll under. */
    .table-scroll > .data-table > thead > tr > th:first-child,
    .table-scroll > .data-table > tbody > tr > th[scope="row"] {
        box-shadow: inset -1px 0 0 var(--color-line);
    }
}

@media (min-width: 1024px) {
    .table-scroll {
        overflow-x: visible;
    }

    .table-scroll > .data-table > thead > tr > th {
        position: sticky;
        top: var(--header-height);
        z-index: 2;
    }

    .table-scroll > .data-table > thead > tr > th:first-child {
        z-index: 3;
    }
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted, .text-dim { color: var(--color-ink-muted); }
.font-mono { font-family: var(--font-mono); }

/* ---------- Components: badge ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-pill);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    background: var(--color-raised);
    color: var(--color-ink);
}

.badge-active { color: var(--color-active); }
.badge-inactive { color: var(--color-negative); }
.badge-region { color: var(--color-aether); }
.badge-gold { color: var(--color-ink); }

/* ---------- Components: buttons (controls) ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.5rem;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-control);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.btn-primary {
    background: var(--color-aether);
    color: var(--color-night);
}

.btn-primary:hover {
    background: var(--color-ink);
    color: var(--color-night);
}

.btn-outline {
    background: transparent;
    border-color: var(--color-line);
    color: var(--color-ink);
}

.btn-outline:hover {
    background: var(--color-raised);
    color: var(--color-ink);
}

/* ---------- Components: progress bar ---------- */

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--color-raised);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-aether);
    border-radius: var(--radius-pill);
}


/* ---------- Components: progression steps (MSQ funnel) ---------- */

/*
 * One step per expansion, joined by a vertical connector: the aetheryte
 * node motif again. Each step's meter is its share of all characters, so
 * the bars step down from A Realm Reborn to Dawntrail.
 */
.progression {
    list-style: none;
}

.progression-step {
    position: relative;
    padding: 0 0 var(--space-6) var(--space-6);
}

.progression-step:last-child {
    padding-bottom: 0;
}

/* The node. */
.progression-step::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.3rem;
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid var(--color-aether);
    border-radius: var(--radius-pill);
    background: var(--color-surface);
}

/* The connector down to the next node. */
.progression-step:not(:last-child)::after {
    content: "";
    position: absolute;
    left: calc(0.4375rem - 1px);
    top: 1.35rem;
    bottom: 0.15rem;
    width: 2px;
    background: var(--color-line);
    background: color-mix(in srgb, var(--color-aether) 30%, var(--color-surface));
}

.progression-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-1) var(--space-4);
}

.progression-name {
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    color: var(--color-ink);
}

.progression-meta {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.progression-meta cite {
    font-style: normal;
    color: var(--color-ink);
}

.progression-meter {
    margin: var(--space-3) 0 var(--space-4);
}

.progression-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
    max-width: 40rem;
}

.progression-figure dt {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    color: var(--color-ink-muted);
}

.progression-figure dd {
    margin-top: var(--space-1);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-3);
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--color-ink);
}

.progression-figure dd.progression-muted {
    font-family: var(--font-sans);
    font-stretch: normal;
    font-size: var(--step-0);
    font-weight: var(--weight-heading);
    letter-spacing: normal;
    color: var(--color-ink-muted);
}

@media (max-width: 599px) {
    .progression-step { padding-left: var(--space-5); }
    .progression-figures {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-3);
    }
    /* Retention's label names the previous expansion: give it the full row. */
    .progression-figure:last-child { grid-column: 1 / -1; }
    .progression-figure dd { font-size: var(--step-1); }
}

/* ---------- Components: node breadcrumb ---------- */

/*
 * Region > datacenter > world as small connected nodes. Each crumb is a
 * flex row of connector line (::before, not on the first), node (::after)
 * and label; the current world's node is filled.
 */
.node-breadcrumb {
    margin-bottom: var(--space-3);
}

.node-breadcrumb-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: var(--space-2);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
}

.node-crumb {
    display: inline-flex;
    align-items: center;
}

.node-crumb > * {
    order: 2;
}

.node-crumb + .node-crumb::before {
    content: "";
    order: 0;
    width: 1.25rem;
    height: 2px;
    margin: 0 var(--space-2);
    background: var(--color-line);
}

.node-crumb::after {
    content: "";
    order: 1;
    flex-shrink: 0;
    width: 0.625rem;
    height: 0.625rem;
    margin-right: var(--space-2);
    border: 2px solid var(--color-aether);
    border-radius: var(--radius-pill);
}

.node-crumb a {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
}

.node-crumb-current {
    color: var(--color-ink);
}

.node-crumb-current::after {
    background: var(--color-aether);
}

/* ---------- Components: long-form text ---------- */

.prose {
    max-width: var(--measure);
}

.prose-toc {
    margin-bottom: var(--space-6);
    font-size: var(--step--1);
}

.prose-toc ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
}

.prose-toc a {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    font-weight: var(--weight-heading);
}

.prose-section {
    padding-top: var(--space-6);
    margin-top: var(--space-6);
    border-top: 1px solid var(--color-line);
}

.prose-section h2 {
    font-size: var(--step-2);
    margin-bottom: var(--space-4);
    scroll-margin-top: calc(var(--header-height) + var(--space-4));
}

.prose-section > * + * {
    margin-top: var(--space-4);
}

.prose-section > h2 + * {
    margin-top: 0;
}

.prose-aside {
    font-size: 0.9375rem;
    color: var(--color-ink-muted);
}

.prose-note {
    margin-bottom: 0;
    padding: var(--space-4) var(--space-5);
}

.prose-note p + p {
    margin-top: var(--space-2);
}

.prose-note p:not(.notice-title) {
    color: var(--color-ink-muted);
    font-size: 0.9375rem;
}

.prose-definition {
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border-radius: var(--radius-panel);
}

.prose-definition dt {
    font-weight: var(--weight-heading);
}

.prose-definition dd {
    margin-top: var(--space-1);
    font-size: 0.9375rem;
    color: var(--color-ink-muted);
}

.prose .table-scroll {
    background: var(--color-surface);
    border-radius: var(--radius-panel);
}

.prose .data-table cite {
    font-style: normal;
}

/* ---------- Chart slots ---------- */

/* Sets --slot-color for SVG marks and HTML swatches. */
.chart-slot-0 { --slot-color: var(--color-chart-other); }
.chart-slot-1 { --slot-color: var(--color-chart-1); }
.chart-slot-2 { --slot-color: var(--color-chart-2); }
.chart-slot-3 { --slot-color: var(--color-chart-3); }
.chart-slot-4 { --slot-color: var(--color-chart-4); }
.chart-slot-5 { --slot-color: var(--color-chart-5); }
.chart-slot-6 { --slot-color: var(--color-chart-6); }
.chart-slot-7 { --slot-color: var(--color-chart-7); }
.chart-slot-8 { --slot-color: var(--color-chart-8); }

/* ---------- Components: realm tally (the dashboard headline) ---------- */

.realm-tally {
    margin-bottom: var(--space-7);
}

.realm-tally-heading {
    font-size: var(--step-1);
    font-weight: var(--weight-heading);
    color: var(--color-ink-muted);
    line-height: var(--leading-tight);
}

.realm-tally-figure {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: clamp(4rem, 19vw, 10rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 0.9;
    color: var(--color-aether);
    /* Proportional figures read tighter at display size. */
    font-variant-numeric: proportional-nums;
    margin: var(--space-2) 0 var(--space-4);
}

.realm-tally-lede {
    color: var(--color-ink-muted);
    max-width: var(--measure);
    margin-bottom: var(--space-5);
}

.realm-band-wrap {
    position: relative;
}

.realm-band {
    display: block;
    border-radius: var(--radius-control);
    overflow: hidden;
}

.realm-band-track {
    fill: var(--color-raised);
}

.realm-segment-fill {
    fill: var(--slot-color);
    /* 2px gap in the page colour between neighbouring segments. */
    stroke: var(--color-night);
    stroke-width: 2px;
    transition: opacity var(--duration-fast) ease;
}

.realm-segment-label {
    fill: var(--color-night);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: 1.25rem;
    font-weight: 700;
    pointer-events: none;
}

.realm-segment {
    text-decoration: none;
}

.realm-segment:focus {
    outline: none;
}

.realm-band:hover .realm-segment-fill,
.realm-band:focus-within .realm-segment-fill {
    opacity: 0.55;
}

.realm-band .realm-segment:hover .realm-segment-fill,
.realm-band .realm-segment:focus-visible .realm-segment-fill {
    opacity: 1;
}

.realm-segment:focus-visible .realm-segment-fill {
    stroke: var(--color-ink);
    stroke-width: 4px;
}

.realm-key {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-6);
    margin-top: var(--space-4);
}

.realm-key-item {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: var(--space-2);
    align-items: baseline;
    padding-left: var(--space-4);
    position: relative;
}

.realm-key-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--slot-color);
}

.realm-key-name {
    font-weight: var(--weight-heading);
    color: var(--color-ink);
}

.realm-key-share {
    color: var(--color-ink);
}

.realm-key-count {
    grid-column: 1 / -1;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

/* ---------- Components: trend ---------- */

.trend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-1);
}

.trend-icon {
    fill: currentColor;
    flex-shrink: 0;
}

.trend-value {
    font-weight: var(--weight-heading);
}

.trend-up .trend-icon,
.trend-up .trend-value { color: var(--color-active); }
.trend-down .trend-icon,
.trend-down .trend-value { color: var(--color-negative); }

/* ---------- Layout: dashboard ---------- */

.dashboard-grid,
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.dashboard-grid > .panel,
.panel-grid > .panel {
    margin-bottom: 0;
}

/* Page chart grids pair panels: two columns from 720px, never three. */
@media (min-width: 720px) {
    .panel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.panel-meta {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.panel-body-flush {
    padding: 0;
}

.panel-body-flush > .empty-state {
    margin: var(--space-5);
}

/* ---------- Components: chart text alternatives ---------- */

.chart-container-bars {
    height: 320px;
}

/* Bar charts with many categories (clans, race by gender). */
.chart-container-tall {
    height: 26rem;
}

.chart-data .table-scroll {
    max-height: 22rem;
    overflow: auto;
}

.chart-data .table-scroll > .data-table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.chart-summary {
    margin-top: var(--space-4);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    max-width: var(--measure);
}

.chart-data {
    margin-top: var(--space-3);
    font-size: var(--step--1);
}

.chart-data summary {
    display: inline-flex;
    align-items: center;
    min-height: 2rem;
    color: var(--color-aether);
    font-weight: var(--weight-heading);
    cursor: pointer;
}

.chart-data[open] summary {
    margin-bottom: var(--space-3);
}

.chart-data .table-responsive {
    max-height: 22rem;
    overflow-y: auto;
}

/* ---------- Components: progress list (expansion completion) ---------- */

.progress-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.progress-name {
    font-weight: var(--weight-heading);
}

.progress-value {
    font-weight: var(--weight-heading);
    white-space: nowrap;
}

.progress-count {
    margin-left: var(--space-2);
    font-weight: var(--weight-body);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.progress-meter {
    display: block;
    width: 100%;
    height: 8px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-raised);
    -webkit-appearance: none;
    appearance: none;
}

.progress-meter::-webkit-meter-bar {
    background: var(--color-raised);
    border: 0;
    border-radius: var(--radius-pill);
    height: 8px;
}

.progress-meter::-webkit-meter-optimum-value {
    background: var(--color-aether);
    border-radius: var(--radius-pill);
}

.progress-meter::-moz-meter-bar {
    background: var(--color-aether);
    border-radius: var(--radius-pill);
}

/* ---------- Components: region drill-down ---------- */

.btn-small {
    min-height: 2rem;
    padding: var(--space-1) var(--space-3);
}

.data-table th[scope="row"] {
    font-weight: var(--weight-heading);
    color: var(--color-ink);
    border-bottom: 1px solid var(--color-line);
    background: transparent;
}

.drilldown-row > td {
    padding: 0;
    background: var(--color-night);
}

.data-table > tbody > tr.drilldown-row:hover {
    background: transparent;
}

/*
 * The drill-down spans the region table's full row but is sized to the
 * visible scroll area (100cqi of the enclosing .table-scroll) and sticks to
 * its left edge, so on a phone it never hides off-screen when the region
 * table is scrolled sideways. Its own table scrolls inside it.
 */
.drilldown-body {
    position: sticky;
    left: 0;
    width: 100cqi;
    max-width: 100%;
    padding: var(--space-2) 0 var(--space-4);
}

.drilldown-body:empty {
    padding: 0;
}

.drilldown-body .data-table th,
.drilldown-body .data-table > tbody > tr > th[scope="row"] {
    background: var(--color-night);
}

.drilldown-body .data-table > tbody > tr:hover > th[scope="row"],
.drilldown-body .data-table > tbody > tr:focus-within > th[scope="row"] {
    background: var(--color-raised);
}

/* Datacenter group heading inside a drill-down: a small aetheryte node
   before the name echoes region -> datacenter -> world. */
.data-table .group-row > th {
    padding-top: var(--space-4);
    padding-bottom: var(--space-2);
    background: transparent;
    color: var(--color-ink-muted);
    font-weight: var(--weight-heading);
}

.data-table > tbody > tr.group-row:hover {
    background: transparent;
}

.group-name {
    position: sticky;
    left: var(--space-3);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.group-name::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border: 2px solid var(--color-aether);
    border-radius: var(--radius-pill);
}

.drilldown-body > .empty-state {
    margin: var(--space-2) var(--space-4);
}

/* Region name plus its drill-down trigger, stacked in the first column so
   the trigger stays reachable when the table scrolls sideways. */
.row-heading {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
}

.drilldown-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 2rem;
    margin-left: calc(-1 * var(--space-2));
    padding: 0 var(--space-2);
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--color-ink-muted);
    font-size: var(--step--1);
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.drilldown-toggle:hover {
    color: var(--color-ink);
    background: var(--color-raised);
}

.drilldown-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform var(--duration-fast) ease;
}

.drilldown-toggle[aria-expanded="true"] .drilldown-icon {
    transform: rotate(180deg);
}

/* ---------- Components: filter bar and chips ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-4) var(--space-5);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius-panel);
    box-shadow: var(--rim);
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.filter-label {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    color: var(--color-ink-muted);
}

.filter-select {
    -webkit-appearance: none;
    appearance: none;
    min-width: 12rem;
    max-width: 100%;
    padding-right: var(--space-7);
    background-color: var(--color-night);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2398A2BC' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 12px 12px;
    cursor: pointer;
}

.filter-select:hover {
    border-color: var(--color-ink-muted);
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0 var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    font-size: var(--step--1);
    font-weight: var(--weight-medium);
    text-decoration: none;
    white-space: nowrap;
}

.filter-pill:hover {
    color: var(--color-ink);
    background: var(--color-raised);
}

.filter-pill[aria-current="true"] {
    border-color: var(--color-aether);
    background: var(--color-aether);
    color: var(--color-night);
    font-weight: var(--weight-heading);
}

.filter-applied {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-5);
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2rem;
    padding: 0 var(--space-2) 0 var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--color-raised);
    color: var(--color-ink);
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    text-decoration: none;
}

.filter-chip:hover {
    color: var(--color-ink);
    background: var(--color-line);
}

.filter-chip-name {
    color: var(--color-ink-muted);
    font-weight: var(--weight-body);
}

.filter-chip-icon {
    width: 1.25rem;
    height: 1.25rem;
    padding: 0.25rem;
    border-radius: var(--radius-pill);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.filter-chip:hover .filter-chip-icon {
    background: var(--color-night);
}

.filter-clear {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
}

@media (max-width: 767px) {
    .filter-bar {
        padding: var(--space-4);
    }

    .filter-field,
    .filter-select {
        width: 100%;
    }

    .filter-select {
        min-width: 0;
    }
}

/* ---------- Components: switch (segmented link pair) ---------- */

/*
 * A set of links choosing one view of a region. Reads as one control: a
 * recessed track with the current option lifted onto it and marked by a lit
 * aether rule, distinct from the filter pills (which narrow the data rather
 * than change the view).
 */
.switch {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius-control);
    background: var(--color-night);
    box-shadow: inset 0 0 0 1px var(--color-line);
    font-size: var(--step--1);
}

.switch-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0 var(--space-3);
    border-radius: calc(var(--radius-control) - 3px);
    color: var(--color-ink-muted);
    font-weight: var(--weight-medium);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.switch-option:hover {
    color: var(--color-ink);
    background: var(--color-surface);
}

.switch-option[aria-current="true"] {
    color: var(--color-ink);
    background: var(--color-raised);
    font-weight: var(--weight-heading);
    box-shadow: inset 0 -2px 0 var(--color-aether);
}

@media (max-width: 599px) {
    .switch-option { min-height: 2.75rem; }
}

/* A heading that takes focus after a switch: no ring on programmatic focus
   (keyboard users still see :focus-visible on the switch itself). */
[data-switch-heading]:focus {
    outline: none;
}

/* ---------- Components: freshness line ---------- */

.freshness {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}

.freshness-icon {
    flex-shrink: 0;
    width: 0.875rem;
    height: 0.875rem;
    fill: none;
    stroke: var(--color-aether);
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.freshness time {
    color: var(--color-ink);
    font-weight: var(--weight-medium);
}

/* ---------- Components: arrives with the next refresh ---------- */

/*
 * A section whose data the stored snapshot predates. The crystal is lit but
 * its orbit is dashed: the node exists and is on its way into the network.
 */
.next-refresh {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    border-radius: var(--radius-panel);
    border: 1px dashed var(--color-line);
}

.next-refresh-mark {
    flex-shrink: 0;
}

.next-refresh-orbit {
    fill: none;
    stroke: var(--color-ink-muted);
    stroke-width: 1.5;
    stroke-dasharray: 3 5;
}

.next-refresh-node { fill: var(--color-aether); }
.next-refresh-facet-aether { fill: var(--color-aether); }
.next-refresh-facet-crystal { fill: var(--color-crystal); }

.next-refresh-text { max-width: var(--measure); }

.next-refresh-title {
    color: var(--color-ink);
    font-weight: var(--weight-heading);
    font-size: var(--step-1);
    line-height: var(--leading-tight);
}

.next-refresh-hint {
    margin-top: var(--space-2);
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}

@media (max-width: 479px) {
    .next-refresh {
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-4);
    }
}

/* ---------- Grand Companies: the standards ---------- */

/*
 * Each company's mark colour reaches its swatches, meters, band segments and
 * standard through --slot-color. "No Grand Company" has no hue: it is drawn
 * as an outline (see .gc-none and .standard-none).
 */
.gc-maelstrom { --slot-color: var(--color-gc-maelstrom); }
.gc-twin-adder { --slot-color: var(--color-gc-twin-adder); }
.gc-immortal-flames { --slot-color: var(--color-gc-immortal-flames); }
.gc-none { --slot-color: transparent; }

.gc-swatch.gc-none {
    box-shadow: inset 0 0 0 1px var(--color-ink-muted);
}

/* The signature element: three hanging standards and an empty outline one,
 * each filled from the swallowtail up to its company's share. */
.standards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
    max-width: 52rem;
    margin: 0 auto;
    padding: var(--space-2) 0 0;
    list-style: none;
}

.standard {
    --slot-color: var(--color-ink-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    text-align: center;
}

.standard-maelstrom { --slot-color: var(--color-gc-maelstrom); }
.standard-twin-adder { --slot-color: var(--color-gc-twin-adder); }
.standard-immortal-flames { --slot-color: var(--color-gc-immortal-flames); }

.standard-flag {
    position: relative;
    width: 100%;
    max-width: 9.5rem;
    padding: 0 6%;
}

/* The crossbar the standard hangs from, wider than the cloth. */
.standard-flag::before {
    content: "";
    display: block;
    height: 5px;
    margin: 0 -6% 3px;
    border-radius: var(--radius-pill);
    background: var(--color-ink-muted);
}

.standard-banner {
    display: block;
    width: 100%;
    height: clamp(11rem, 36vw, 21rem);
    overflow: visible;
}

/* The unfilled cloth carries a faint tint of its company, so an empty
 * standard still reads as that company's banner. */
.standard-cloth {
    fill: color-mix(in oklab, var(--slot-color) 12%, var(--color-surface));
}

.standard-fill {
    fill: var(--slot-color);
}

.standard-edge {
    fill: none;
    stroke: var(--slot-color);
    stroke-width: 1.5;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.standard-none .standard-cloth {
    fill: none;
}

.standard-none .standard-fill {
    fill: none;
    stroke: var(--color-ink-muted);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.standard-none .standard-edge {
    stroke: var(--color-line);
    stroke-dasharray: 5 4;
}

.standard-share {
    position: absolute;
    top: var(--space-4);
    left: 0;
    right: 0;
    margin: 0;
    font-family: var(--font-figures);
    font-stretch: var(--width-condensed);
    font-size: var(--step-1);
    font-weight: 700;
    line-height: 1;
    color: var(--color-ink);
}

.standard-name {
    margin: var(--space-3) 0 0;
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    line-height: var(--leading-tight);
    color: var(--color-ink);
    overflow-wrap: anywhere;
}

.standard-count {
    margin: var(--space-1) 0 0;
    font-size: var(--step--2);
    color: var(--color-ink-muted);
}

@media (min-width: 600px) {
    .standards { gap: var(--space-5); }
    .standard-share {
        top: var(--space-5);
        font-stretch: var(--width-semi-condensed);
        font-size: var(--step-3);
    }
    .standard-name { font-size: var(--step-0); }
    .standard-count { font-size: var(--step--1); }
}

@media (min-width: 1024px) {
    .standards { gap: var(--space-7); }
    .standard-share { font-size: var(--step-4); }
}

/* Who still plays: one meter per company in its own colour. */
.gc-active-list {
    display: grid;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.gc-active-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.gc-active-name {
    font-weight: var(--weight-heading);
}

.gc-active-value {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-1);
    font-weight: 600;
    line-height: 1;
}

.gc-active-note {
    margin: var(--space-1) 0 0;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.gc-meter::-webkit-meter-optimum-value {
    background: var(--slot-color);
}

.gc-meter::-moz-meter-bar {
    background: var(--slot-color);
}

.gc-none .gc-meter::-webkit-meter-optimum-value {
    background: var(--color-ink-muted);
}

.gc-none .gc-meter::-moz-meter-bar {
    background: var(--color-ink-muted);
}

/* World detail: the compact Grand Company band. */
.gc-band {
    display: block;
    width: 100%;
    height: 14px;
    border-radius: var(--radius-pill);
    background: var(--color-raised);
}

.gc-band-segment {
    fill: var(--slot-color);
    stroke: var(--color-surface);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.gc-band-key {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--step--1);
}

.gc-band-share {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 600;
    color: var(--color-ink);
}

/* ---------- Jobs: the Armoury ---------- */

/*
 * The signature element: every job as a tile, grouped by role the way the
 * game's Armoury and Character window group them. Role headings carry the
 * role colour as a thin rule, never a fill. The tile fill is one sequential
 * hue (Aether into Surface), stepped by how common the job is relative to the
 * most common job of the measure; a job nobody has stays unlit, like a job
 * not yet unlocked in game. The hairline along each tile's foot is its share
 * of characters, read like the experience bar under a job's level.
 */
.jobs-status,
.levels-status {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--space-5);
    margin: calc(-1 * var(--space-3)) 0 var(--space-5);
}

.coverage-line {
    margin-top: var(--space-3);
    color: var(--color-ink);
    font-size: var(--step--1);
    padding-left: var(--space-3);
    box-shadow: inset 2px 0 0 var(--color-warning);
}

.armoury-lede {
    max-width: var(--measure);
    margin-bottom: var(--space-5);
    color: var(--color-ink);
}

.armoury {
    --armoury-tile: 8.25rem;
    display: grid;
    gap: var(--space-6);
}

.armoury-discipline {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5) var(--space-6);
}

.armoury-discipline-name {
    flex: 0 0 100%;
    font-size: var(--step--1);
    font-weight: var(--weight-medium);
    color: var(--color-ink-muted);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--color-line);
}

.armoury-role {
    --role-rule: var(--color-line);
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.armoury-role-tank { --role-rule: var(--color-mark-tank); }
.armoury-role-healer { --role-rule: var(--color-mark-healer); }
.armoury-role-dps { --role-rule: var(--color-mark-dps); }

/* The role name, then its colour drawn out as a thin rule to the row's end. */
.armoury-role-name {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    font-size: var(--step-0);
    font-weight: var(--weight-heading);
    color: var(--color-ink);
}

.armoury-role-name::after {
    content: "";
    flex: 1 1 auto;
    min-width: var(--space-6);
    height: 2px;
    border-radius: 1px;
    background: var(--role-rule);
}

.armoury-tiles {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.armoury-tile {
    --tile-fill: var(--color-surface);
    flex: 0 0 var(--armoury-tile);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 7.5rem;
    padding: var(--space-3) var(--space-3) var(--space-4);
    border-radius: var(--radius-control);
    background: var(--tile-fill);
    box-shadow: var(--rim), inset 0 0 0 1px var(--color-line);
}

.armoury-level-1 { --tile-fill: color-mix(in oklab, var(--color-chart-1) 9%, var(--color-surface)); }
.armoury-level-2 { --tile-fill: color-mix(in oklab, var(--color-chart-1) 18%, var(--color-surface)); }
.armoury-level-3 { --tile-fill: color-mix(in oklab, var(--color-chart-1) 29%, var(--color-surface)); }
.armoury-level-4 { --tile-fill: color-mix(in oklab, var(--color-chart-1) 41%, var(--color-surface)); }
.armoury-level-5 { --tile-fill: color-mix(in oklab, var(--color-chart-1) 54%, var(--color-surface)); }

.armoury-level-1, .armoury-level-2, .armoury-level-3, .armoury-level-4, .armoury-level-5 {
    box-shadow: var(--rim);
}

/* Unlit: the job is in the Armoury but nobody here has it. */
.armoury-level-0 {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--color-line);
}

.armoury-abbr {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 700;
    font-size: var(--step-4);
    line-height: 1;
    letter-spacing: 0.01em;
    color: var(--color-ink);
}

.armoury-name {
    margin-top: var(--space-1);
    font-size: var(--step--1);
    line-height: var(--leading-tight);
    color: var(--color-ink-muted);
}

.armoury-figures {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: auto;
    padding-top: var(--space-3);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-variant-numeric: tabular-nums;
}

.armoury-count {
    font-size: var(--step-1);
    font-weight: 600;
    color: var(--color-ink);
}

.armoury-share {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

/* On the brighter steps muted ink loses contrast: everything reads in Ink. */
.armoury-level-3 .armoury-name, .armoury-level-3 .armoury-share,
.armoury-level-4 .armoury-name, .armoury-level-4 .armoury-share,
.armoury-level-5 .armoury-name, .armoury-level-5 .armoury-share {
    color: var(--color-ink);
}

.armoury-level-0 .armoury-abbr,
.armoury-level-0 .armoury-count {
    color: var(--color-ink-muted);
}

.armoury-gauge {
    position: absolute;
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-2);
    width: calc(100% - 2 * var(--space-3));
    height: 2px;
    background: color-mix(in oklab, var(--color-night) 55%, transparent);
    border-radius: 1px;
}

.armoury-gauge-fill {
    fill: var(--color-ink);
}

/* The most common job wears the census crystal in its corner. */
.armoury-lead::after {
    content: "";
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 0.625rem;
    height: 0.875rem;
    background: var(--color-ink);
    clip-path: polygon(50% 0, 100% 45%, 50% 100%, 0 45%);
}

.table-note {
    color: var(--color-ink-muted);
    font-size: var(--step--1);
}

@media (max-width: 767px) {
    .armoury { --armoury-tile: auto; }

    .armoury-role { flex: 1 1 100%; }

    .armoury-tiles {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr));
    }

    .armoury-tile { min-height: 6.5rem; padding: var(--space-2) var(--space-2) var(--space-4); }

    .armoury-abbr { font-size: var(--step-3); }

    .armoury-figures { flex-direction: column; align-items: flex-start; gap: 0; padding-top: var(--space-2); }

    .armoury-count { font-size: var(--step-0); }

    .armoury-lead::after { top: var(--space-2); right: var(--space-2); }

    .armoury-gauge { left: var(--space-2); right: var(--space-2); width: calc(100% - 2 * var(--space-2)); }
}

/* Phones: two compact tiles a row, read like the job list of the game's
   Character window: the abbreviation and the count on one line, the name and
   the share beneath. */
@media (max-width: 599px) {
    .armoury-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .armoury-tile {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas: "abbr figures" "name name";
        align-items: center;
        column-gap: var(--space-2);
        min-height: 0;
        padding: var(--space-2) var(--space-3) var(--space-4);
    }

    .armoury-abbr { grid-area: abbr; font-size: var(--step-2); }
    .armoury-name { grid-area: name; margin-top: var(--space-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .armoury-figures { grid-area: figures; align-items: flex-end; padding-top: 0; margin-top: 0; line-height: 1.2; }
    .armoury-lead::after { display: none; }
}

/* The Armoury's entrance: role groups fade in one after another (under
   400 ms in all), on full page loads only. */
[data-entrance="roles"] {
    animation: none;
}

[data-entrance="roles"] .armoury-role {
    animation: census-fade 200ms var(--ease-out) both;
}

[data-entrance="roles"] .armoury-role:nth-of-type(2) { animation-delay: 30ms; }
[data-entrance="roles"] .armoury-role:nth-of-type(3) { animation-delay: 60ms; }
[data-entrance="roles"] .armoury-role:nth-of-type(4) { animation-delay: 90ms; }
[data-entrance="roles"] .armoury-role:nth-of-type(5) { animation-delay: 120ms; }
[data-entrance="roles"] .armoury-discipline-crafting .armoury-role:nth-of-type(1) { animation-delay: 150ms; }
[data-entrance="roles"] .armoury-discipline-crafting .armoury-role:nth-of-type(2) { animation-delay: 180ms; }

.census-settled [data-entrance="roles"] .armoury-role {
    animation: none;
}

/* ---------- Jobs: party balance ---------- */

.balance-headline {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-5);
}

.balance-headline-place {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.balance-headline-ratio {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 600;
    font-size: var(--step-3);
    line-height: var(--leading-tight);
    color: var(--color-ink);
}

.role-tank { --slot-color: var(--color-mark-tank); }
.role-healer { --slot-color: var(--color-mark-healer); }
.role-dps { --slot-color: var(--color-mark-dps); }

.balance-key {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-5);
    margin-bottom: var(--space-4);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.balance-key li {
    display: inline-flex;
    align-items: center;
}

.balance-key-guide {
    display: inline-block;
    width: 2px;
    height: 0.875rem;
    margin-right: var(--space-2);
    background: var(--color-ink);
}

.balance-list {
    list-style: none;
    display: grid;
    gap: var(--space-1);
}

.balance-row {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-3);
    margin: 0 calc(-1 * var(--space-3));
    border-radius: var(--radius-control);
}

.balance-current {
    background: var(--color-raised);
}

.balance-name {
    font-weight: var(--weight-medium);
    color: var(--color-ink);
    white-space: nowrap;
}

.balance-region {
    margin-left: var(--space-1);
    font-size: var(--step--1);
    font-weight: var(--weight-body);
    color: var(--color-ink-muted);
    text-decoration: none;
}

.balance-bar {
    display: block;
    width: 100%;
    height: 0.875rem;
    overflow: visible;
}

.balance-segment {
    fill: var(--slot-color);
    stroke: var(--color-surface);
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.balance-current .balance-segment {
    stroke: var(--color-raised);
}

.balance-guide {
    stroke: var(--color-ink);
    stroke-width: 2px;
}

.balance-shares {
    display: grid;
    grid-template-columns: repeat(3, 3.25rem);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-variant-numeric: tabular-nums;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    text-align: right;
}

.balance-current .balance-shares {
    color: var(--color-ink);
}

@media (max-width: 599px) {
    .balance-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--space-2) var(--space-3);
    }

    .balance-bar {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}

/* ---------- Levels ---------- */

.level-step-1 { --slot-color: var(--color-level-1); }
.level-step-2 { --slot-color: var(--color-level-2); }
.level-step-3 { --slot-color: var(--color-level-3); }
.level-step-4 { --slot-color: var(--color-level-4); }
.level-step-5 { --slot-color: var(--color-level-5); }
.level-step-6 { --slot-color: var(--color-level-6); }
.level-step-7 { --slot-color: var(--color-level-7); }

.levels-lede {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2) var(--space-4);
    max-width: var(--measure);
    margin-bottom: var(--space-6);
}

.levels-lede-figure {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: var(--weight-display);
    font-size: var(--step-6);
    line-height: 1;
    letter-spacing: var(--tracking-display);
    color: var(--color-ink);
}

.levels-lede-text {
    flex: 1 1 18rem;
    font-size: var(--step-1);
    line-height: var(--leading-tight);
    color: var(--color-ink);
}

.levels-lede-aside {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--step-0);
    color: var(--color-ink-muted);
}

/* The band chart: one row per band, the expansions climbing down the page
   and the bar brightening as the levels rise. */
.level-bands {
    list-style: none;
    display: grid;
    gap: var(--space-1);
    margin-bottom: var(--space-4);
}

.level-band-row {
    display: grid;
    grid-template-columns: 9.5rem 3.5rem minmax(0, 1fr) 9rem;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-3);
    margin: 0 calc(-1 * var(--space-3));
    border-radius: var(--radius-control);
    transition: background-color var(--duration-fast) ease;
}

.level-band-row:hover,
.level-band-row:focus-visible {
    background: var(--color-raised);
}

.level-band-name {
    font-weight: var(--weight-medium);
    color: var(--color-ink);
}

.level-band-range {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    text-align: right;
}

.level-band-bar {
    display: block;
    width: 100%;
    height: 1.25rem;
}

.level-band-track {
    fill: var(--color-raised);
}

.level-band-row:hover .level-band-track,
.level-band-row:focus-visible .level-band-track {
    fill: var(--color-line);
}

.level-band-fill {
    fill: var(--slot-color);
}

.level-band-figures {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: var(--space-3);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-variant-numeric: tabular-nums;
}

.level-band-count {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.level-band-share {
    min-width: 3.5rem;
    font-size: var(--step-1);
    font-weight: 600;
    color: var(--color-ink);
    text-align: right;
}

@media (max-width: 599px) {
    .level-band-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--space-1) var(--space-3);
    }

    .level-band-range {
        text-align: left;
        grid-row: 2;
    }

    .level-band-bar {
        grid-column: 1 / -1;
        grid-row: 3;
        height: 0.875rem;
    }

    .level-band-figures {
        grid-column: 2;
        grid-row: 1 / span 2;
        flex-direction: column;
        align-items: flex-end;
        gap: 0;
    }
}

/* Stacked rows (per datacenter and per world) reuse the party balance
   layout; the right column is the share at the level cap. */
.level-row-name a {
    color: var(--color-ink);
    text-decoration-color: var(--color-line);
}

.level-row-name a:hover {
    color: var(--color-aether);
}

.level-segment {
    fill: var(--slot-color);
    stroke: var(--color-surface);
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.level-row-current .level-segment {
    stroke: var(--color-raised);
}

.level-row-cap {
    min-width: 3.5rem;
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-variant-numeric: tabular-nums;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    text-align: right;
}

.level-row-current .level-row-cap {
    color: var(--color-ink);
}

.level-world-prompt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
}

.level-world-prompt-text {
    color: var(--color-ink-muted);
}

.level-world-regions {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.level-world-region {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 var(--space-4);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-pill);
    color: var(--color-ink);
    text-decoration: none;
}

.level-world-region:hover {
    background: var(--color-raised);
    color: var(--color-ink);
}

/* World detail: the compact level band. */
.level-strip-lede {
    max-width: var(--measure);
    margin-bottom: var(--space-4);
    color: var(--color-ink);
}

.level-strip-figure {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 700;
    font-size: var(--step-2);
}

.level-strip {
    display: block;
    width: 100%;
    height: 14px;
    border-radius: var(--radius-pill);
    background: var(--color-raised);
}

.level-strip-key {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--step--1);
}

.level-strip-share {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 600;
    color: var(--color-ink);
}

/* ---------- World detail: most levelled jobs ---------- */

.top-jobs {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--space-2);
}

.top-job {
    display: flex;
    flex-direction: column;
    padding: var(--space-3);
    border-radius: var(--radius-control);
    background: var(--color-raised);
    box-shadow: var(--rim);
}

.top-job-abbr {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-weight: 700;
    font-size: var(--step-3);
    line-height: 1;
    color: var(--color-ink);
}

.top-job-name {
    margin-top: var(--space-1);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.top-job-figures {
    margin-top: var(--space-3);
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--color-ink);
}

.top-job-share {
    margin-left: var(--space-1);
    font-weight: var(--weight-body);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

/* ---------- Private Achievements: the veil ---------- */

/*
 * One wide band split into public (the Aether chart hue), private (Crystal
 * threads hatched at 45 degrees over the track: a veil drawn across the
 * data) and not yet checked (an empty dashed outline: the census's backlog,
 * not a choice, drawn like "No Grand Company"). The segments are SVG rects
 * sized in percentages, so the hatching keeps its true pitch at any width.
 * Every segment is named with its share in the key, so colour is never the
 * only cue.
 */
.veil {
    display: block;
    width: 100%;
    height: 4.5rem;
    border-radius: var(--radius-control);
    overflow: hidden;
}

.veil-track {
    fill: var(--color-raised);
}

.veil-segment {
    stroke: var(--color-surface);
    stroke-width: 2px;
}

.veil-public {
    fill: var(--color-chart-1);
}

.veil-hatch-ground {
    fill: var(--color-raised);
}

.veil-hatch-thread {
    fill: var(--color-chart-2);
}

.veil-unchecked {
    fill: var(--color-surface);
    stroke: var(--color-ink-muted);
    stroke-dasharray: 5 4;
}

.veil-key {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4) var(--space-5);
    margin: var(--space-5) 0 0;
    padding: 0;
    list-style: none;
}

.veil-key-item {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: var(--space-2);
}

.veil-swatch {
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 2px;
}

.veil-swatch-public {
    background: var(--color-chart-1);
}

.veil-swatch-private {
    background: repeating-linear-gradient(45deg, var(--color-chart-2) 0 3px, var(--color-raised) 3px 6px);
}

.veil-swatch-unchecked {
    border: 1px dashed var(--color-ink-muted);
}

.veil-key-name {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    color: var(--color-ink-muted);
}

.veil-key-share {
    grid-column: 1 / -1;
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-5);
    font-weight: 700;
    line-height: 1;
    letter-spacing: var(--tracking-display);
    color: var(--color-ink);
}

.veil-key-count {
    grid-column: 1 / -1;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.veil-panel .freshness {
    margin-top: var(--space-3);
}

.veil-notes {
    display: grid;
    gap: var(--space-5);
}

@media (min-width: 720px) {
    .veil-notes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: var(--space-6);
    }
}

.veil-note-title {
    font-size: var(--step-0);
    margin-bottom: var(--space-2);
}

.veil-note p {
    color: var(--color-ink-muted);
    max-width: var(--measure);
}

.veil-more {
    margin-top: var(--space-5);
    font-weight: var(--weight-heading);
}

.privacy-worlds {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: privacy-world;
}

.privacy-world {
    counter-increment: privacy-world;
    display: grid;
    grid-template-columns: 1.75rem 1fr auto;
    align-items: baseline;
    column-gap: var(--space-2);
    row-gap: var(--space-1);
    padding: var(--space-3) 0;
    border-top: 1px solid var(--color-line);
}

.privacy-world:first-child {
    border-top: 0;
    padding-top: 0;
}

.privacy-world::before {
    content: counter(privacy-world);
    grid-row: 1 / span 3;
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-2);
    font-weight: 700;
    line-height: 1;
    color: var(--color-ink-muted);
}

.privacy-world-name {
    font-weight: var(--weight-heading);
}

.privacy-world-dc {
    margin-left: var(--space-1);
    font-size: var(--step--1);
    font-weight: var(--weight-body);
    color: var(--color-ink-muted);
}

.privacy-world-share {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-1);
    font-weight: 700;
}

.privacy-world-bar {
    grid-column: 2 / -1;
    display: block;
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.privacy-world-track {
    fill: var(--color-raised);
}

.privacy-world-count {
    grid-column: 2 / -1;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.veil-footnote {
    margin: calc(-1 * var(--space-4)) 0 var(--space-6);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    max-width: var(--measure);
}

/* The privacy note on Expansions, and the activity note on the dashboard's
   active-players tile. */
.privacy-note,
.activity-note {
    margin-top: var(--space-2);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
    max-width: var(--measure);
}

@media (max-width: 599px) {
    .veil {
        height: 3rem;
    }

    .veil-key {
        column-gap: var(--space-3);
    }

    .veil-key-share {
        font-size: var(--step-3);
    }
}

/* ---------- Rankings: board tabs, controls and the ladder ---------- */

/* "Worlds and datacenters | Free Companies": the Rankings boards, as plain links. */
.board-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-5);
    margin-bottom: var(--space-3);
}

.board-tab {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--color-ink-muted);
    font-weight: var(--weight-medium);
    text-decoration: none;
    box-shadow: inset 0 -2px 0 transparent;
    transition: color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.board-tab:hover {
    color: var(--color-ink);
}

.board-tab[aria-current="page"] {
    color: var(--color-ink);
    font-weight: var(--weight-heading);
    box-shadow: inset 0 -2px 0 var(--color-aether);
}

/* The command strip: every choice of the board, above a hairline. */
/* The board's controls: one row per choice, labels in a fixed first column
   and every switch starting on the same line in the second. */
.rankings-controls {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: var(--space-5);
    row-gap: var(--space-3);
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-line);
}

.rankings-control {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: center;
    min-width: 0;
}

.rankings-control-label {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.rankings-control .switch-scroller {
    justify-self: start;
}

/* A switch wider than the screen scrolls sideways instead of overflowing. */
.switch-scroller {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.switch-scroller::-webkit-scrollbar {
    display: none;
}

.rankings-head {
    padding: var(--space-5) var(--space-5) 0;
}

.rankings-title {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-4);
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--color-ink);
}

.rankings-scope {
    margin-top: var(--space-1);
    font-weight: var(--weight-medium);
    color: var(--color-aether);
}

/* The Free Company board's one place-level figure: how many belong to any company. */
.rankings-membership {
    margin-top: var(--space-2);
    color: var(--color-ink);
    font-variant-numeric: tabular-nums;
}

/* The world page's share of characters in a Free Company, beside the top five. */
.fc-share {
    /* Sits beside the panel title; the link keeps the far edge. */
    margin: 0 auto 0 0;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.fc-share-value {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-1);
    font-weight: 600;
    color: var(--color-ink);
    font-variant-numeric: tabular-nums;
}

.rankings-explain {
    margin-top: var(--space-2);
    max-width: var(--measure);
    color: var(--color-ink-muted);
}

.rankings-body {
    padding: var(--space-5);
}

.rankings-footnote {
    margin-top: var(--space-4);
    max-width: var(--measure);
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

/*
 * The ladder: a real sequence, so the rank numerals carry it. They sit in a
 * left gutter, oversized and condensed; the leader is set apart by size alone.
 * Each rung ends in a hairline bar measured against the leader, which doubles
 * as the rule between rungs.
 */
.ladder-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.ladder-rung {
    display: grid;
    grid-template-columns: 4.25rem minmax(0, 1fr) auto;
    grid-template-areas:
        "rank name value"
        "rank note detail"
        "rank bar bar";
    align-items: baseline;
    column-gap: var(--space-3);
    padding: var(--space-3) 0 0;
}

.ladder-rank {
    grid-area: rank;
    align-self: start;
    font-family: var(--font-figures);
    font-stretch: var(--width-condensed);
    font-size: var(--step-4);
    font-weight: 600;
    line-height: 0.9;
    text-align: right;
    color: var(--color-ink-muted);
    font-variant-numeric: tabular-nums;
}

.ladder-name {
    grid-area: name;
    min-width: 0;
    font-weight: var(--weight-heading);
    overflow-wrap: break-word;
    hyphens: auto;
}

.ladder-name a {
    color: var(--color-ink);
    text-decoration: none;
}

.ladder-name a:hover {
    color: var(--color-aether);
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.ladder-note {
    grid-area: note;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.ladder-note a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--color-line);
    text-underline-offset: 0.2em;
}

.ladder-note a:hover {
    color: var(--color-aether);
    text-decoration-color: currentColor;
}

/*
 * A rung with an outbound link (a Free Company's Lodestone page) keeps the
 * link beside the note, so the official profile sits next to the world.
 */
.ladder-rung-linked {
    grid-template-columns: 4.25rem auto minmax(0, 1fr) auto;
    grid-template-areas:
        "rank name name value"
        "rank note external detail"
        "rank bar bar bar";
}

.ladder-external {
    grid-area: external;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.2em;
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    color: var(--color-aether);
    text-decoration: none;
}

.ladder-external:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.ladder-external-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ladder-value {
    grid-area: value;
    text-align: right;
    white-space: nowrap;
}

.ladder-figure {
    font-family: var(--font-figures);
    font-stretch: var(--width-semi-condensed);
    font-size: var(--step-2);
    font-weight: 700;
    line-height: 1;
}

.ladder-unit {
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.ladder-detail {
    grid-area: detail;
    text-align: right;
    font-size: var(--step--1);
    color: var(--color-ink-muted);
}

.ladder-bar {
    grid-area: bar;
    display: block;
    margin-top: var(--space-3);
}

.ladder-track {
    fill: var(--color-line);
}

.ladder-fill {
    fill: var(--color-aether);
}

/* Grand Company boards draw their bars in the company's colour. */
.ladder-tone-maelstrom .ladder-fill { fill: var(--color-gc-maelstrom); }
.ladder-tone-twin-adder .ladder-fill { fill: var(--color-gc-twin-adder); }
.ladder-tone-immortal-flames .ladder-fill { fill: var(--color-gc-immortal-flames); }

.ladder-leader {
    padding-top: 0;
}

.ladder-leader .ladder-rank {
    font-size: var(--step-6);
    font-weight: 700;
    color: var(--color-ink);
}

.ladder-leader .ladder-name {
    font-size: var(--step-2);
}

.ladder-leader .ladder-figure {
    font-size: var(--step-5);
}

.ladder-leader .ladder-bar {
    margin-top: var(--space-4);
}

.ladder-more {
    margin-top: var(--space-4);
}

.ladder-more-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    padding: 0 var(--space-4);
    border-radius: var(--radius-control);
    box-shadow: inset 0 0 0 1px var(--color-line);
    color: var(--color-aether);
    font-weight: var(--weight-heading);
    cursor: pointer;
    list-style: none;
}

.ladder-more-toggle::-webkit-details-marker {
    display: none;
}

.ladder-more-toggle::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform var(--duration-fast) ease;
}

.ladder-more[open] > .ladder-more-toggle::after {
    transform: translateY(2px) rotate(-135deg);
}

.ladder-more-toggle:hover {
    background: var(--color-raised);
}

.ladder-more[open] > .ladder-more-toggle {
    margin-bottom: var(--space-1);
}

.ladder .chart-data {
    margin-top: var(--space-5);
}

@media (max-width: 767px) {
    .rankings-controls { padding: var(--space-4); }
    .rankings-head { padding: var(--space-4) var(--space-4) 0; }
    .rankings-body { padding: var(--space-4); }
    .rankings-title { font-size: var(--step-3); }
}

@media (max-width: 599px) {
    /* Phones: each label sits over its switch, all flush left. */
    .rankings-controls {
        grid-template-columns: minmax(0, 1fr);
    }

    .rankings-control {
        row-gap: var(--space-1);
    }

    /* The detail line moves under the note so the figure keeps its room. */
    .ladder-rung {
        grid-template-columns: 2.75rem minmax(0, 1fr) auto;
        grid-template-areas:
            "rank name value"
            "rank note note"
            "rank detail detail"
            "rank bar bar";
        column-gap: var(--space-2);
    }

    .ladder-rung-linked {
        grid-template-columns: 2.75rem auto minmax(0, 1fr) auto;
        grid-template-areas:
            "rank name name value"
            "rank note external external"
            "rank detail detail detail"
            "rank bar bar bar";
    }

    .ladder-detail { text-align: left; }

    .ladder-rank { font-size: var(--step-3); }
    .ladder-figure { font-size: var(--step-1); }
    .ladder-leader .ladder-rank { font-size: var(--step-5); }
    .ladder-leader .ladder-name { font-size: var(--step-1); }
    .ladder-leader .ladder-figure { font-size: var(--step-4); }
}

/* ---------- Motion: the one entrance per page ---------- */

/*
 * Mark the page's signature element with data-entrance. It unfurls from the
 * left once, on a full page load. census.js adds .census-settled to the root
 * after the first 400 ms, so anything HTMX swaps in later appears still.
 * Variants: data-entrance="rise" grows up from the baseline (banners) and
 * data-entrance="fade" fades in (tile grids).
 */
@keyframes census-unfurl {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes census-rise {
    from { clip-path: inset(100% 0 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes census-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

[data-entrance] {
    animation: census-unfurl var(--duration-entrance) var(--ease-out) both;
}

[data-entrance="rise"] {
    animation-name: census-rise;
}

[data-entrance="fade"] {
    animation-name: census-fade;
}

.census-settled [data-entrance] {
    animation: none;
}

/* ---------- Character profile (routes disabled; kept rendering) ---------- */

.profile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
    background: var(--color-surface);
    border-radius: var(--radius-panel);
    padding: var(--space-5);
}

.profile-name {
    font-size: var(--step-4);
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-display);
    color: var(--color-ink);
    line-height: var(--leading-tight);
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
    color: var(--color-ink-muted);
}

.profile-actions {
    display: flex;
    gap: var(--space-3);
}

.job-category-group { margin-bottom: var(--space-5); }

.job-category-title {
    font-size: var(--step-0);
    font-weight: var(--weight-heading);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.role-tank { color: var(--color-role-tank); }
.role-healer { color: var(--color-role-healer); }
.role-melee { color: var(--color-role-melee); }
.role-phys-ranged { color: var(--color-role-phys-ranged); }
.role-magic-ranged { color: var(--color-role-magic-ranged); }
.role-crafter { color: var(--color-role-crafter); }
.role-gatherer { color: var(--color-role-gatherer); }
.role-other { color: var(--color-ink-muted); }

.jobs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--space-3);
}

.job-card {
    background: var(--color-night);
    border-radius: var(--radius-control);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.job-card.max-level { background: var(--color-raised); }

.job-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.job-name {
    font-size: var(--step--1);
    font-weight: var(--weight-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-level {
    font-size: var(--step-1);
    font-weight: var(--weight-display);
}

.job-card.max-level .job-level { color: var(--color-aether); }

.timeline {
    position: relative;
    padding-left: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--color-line);
}

.timeline-item { position: relative; }

.timeline-dot {
    position: absolute;
    left: calc(-1 * var(--space-6));
    top: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-night);
    border: 2px solid var(--color-aether);
}

.timeline-content {
    background: var(--color-night);
    border-radius: var(--radius-control);
    padding: var(--space-3) var(--space-4);
}

.timeline-title { font-weight: var(--weight-heading); }
.timeline-date { font-size: var(--step--1); color: var(--color-ink-muted); margin-top: var(--space-1); }

.search-input { width: 100%; }

/* ---------- Hover tips ---------- */

/* The one tooltip census.js shows for every data-tip mark, matching the
   Chart.js tooltips: a muted title with the colour key, then the figures. */
.census-tip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: min(20rem, calc(100vw - 16px));
    padding: 10px;
    background: var(--color-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-control);
    box-shadow: var(--shadow-overlay);
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--duration-fast) ease;
}

.census-tip[hidden] {
    display: none;
}

.census-tip-shown {
    opacity: 1;
}

.census-tip-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-ink-muted);
    font-weight: var(--weight-medium);
}

.census-tip-value {
    color: var(--color-ink);
    font-weight: var(--weight-heading);
    font-variant-numeric: tabular-nums;
}

:where(.census-tip-swatch) {
    background: var(--slot-color, var(--color-chart-other));
}

.census-tip-swatch {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin: 0;
    border-radius: 50%;
}

/* Marks that take focus for their tip: a ring that suits each shape. */
.balance-segment:focus-visible,
.level-segment:focus-visible,
.veil-segment:focus-visible,
.gc-band-segment:focus-visible {
    outline: none;
    stroke: var(--color-ink);
    stroke-width: 2px;
    stroke-dasharray: none;
    vector-effect: non-scaling-stroke;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    [data-entrance],
    [data-entrance] .armoury-role {
        animation: none;
    }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* The column a ranking is ordered by reads in Ink. */
.data-table th[aria-sort] {
    color: var(--color-ink);
}
