/* ============================================================ *
   ANALYTICS

   The analytics site, i.e. the filters, the totals, the visitors per
   day & the top lists.
 * ============================================================ */

.analytics {
    width: 100%; /* as wide as the page, not its widest content (e.g. the filter bar) */
    max-width: var(--content-max-width);
    margin: 0 auto var(--section-margin-bottom);
}

.analytics-environment,
.analytics-empty {
    color: var(--color-content-2);
}

/* The visitors of the last minutes (see realtime.js), with a pulsing dot. */
.analytics-realtime {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin: -1rem 0 1.5rem;
    font-size: 0.8125rem;
    color: var(--color-content-2);
}

.analytics-realtime::before {
    width: 0.5rem;
    height: 0.5rem;
    content: '';
    background: var(--cd-sea-green-60);
    border-radius: 50%;
    animation: analytics-pulse 2s ease-in-out infinite;
}

@keyframes analytics-pulse {
    50% {
        opacity: 0.3;
    }
}

.analytics-realtime-count {
    color: var(--color-content-1);
}

.analytics-user {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    align-items: baseline;
}

/* The buttons, like the links of the navigation (see BUTTONS for their reset). */
.analytics-user button:where(:hover, :focus-visible) {
    color: var(--link-color-hover);
}

/* -------------------- HEADER -------------------- */

/* The header is opaque, since the filters stick right below it (see FILTERS). */
:root {
    --color-ui-navigation-opacity: 1;
}

/* -------------------- LINKS -------------------- */

/* The links of the analytics: plain text, orange on hover (see settings.css);
 * and the scale's gutter left of the chart (also the weekdays' of the hours). */
main {
    --link-text-decoration: none;
    --scale-width: 3.75rem;
}

/* The main content while it's swapped (see boost.js). */
main[aria-busy="true"] {
    opacity: 0.6;
    transition: opacity 0.2s 0.1s;
}

/* -------------------- ICONS -------------------- */

/* Inline icons, e.g. the heatmap links, the filter removals & the back links. */
main [data-icon]::before,
.analytics-user [data-icon]::before,
.analytics-dialog [data-icon]::before,
.analytics-suggestions [data-icon]::before {
    content: attr(data-icon);
    content: attr(data-icon) / "";
    display: inline-block;
    margin-right: 0.25em;
    font-family: 'Symbols Outlined', sans-serif;
    font-size: 1.25em;
    font-weight: normal;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    line-height: 1;
    letter-spacing: normal; /* letter-spacing disables the icon ligatures */
    text-transform: none;
    vertical-align: -0.2em;
    white-space: nowrap;
}

main [data-icon]:empty::before {
    margin-right: 0;
}

/* -------------------- BUTTONS & TOOLTIPS -------------------- */

/* The plain buttons, without the browser's styles (their rules add their own). */
:where(
    .analytics-user button,
    .analytics-filters-ribbon,
    .analytics-totals button,
    .analytics-card [role="tab"],
    .analytics-more,
    .analytics-sort
) {
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    background: none;
    border: 0;
}

/* The tooltips: a panel above everything, shown on hover (by their rules). */
.analytics-tip {
    position: absolute;
    z-index: 5;
    padding: 0.5rem 0.75rem;
    background: var(--color-ui-bg);
    border: 1px solid var(--color-ui-borders);
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 40%);
    visibility: hidden;
    pointer-events: none;
}

/* -------------------- FILTERS -------------------- */

/* The filters, sticking below the header, on the page's background (to the
 * edges of the window), with the ribbon below them, which collapses them. */
.analytics-filters {
    position: sticky;
    top: var(--analytics-header, 0);
    z-index: calc(var(--z-index-header) - 1);
    margin-bottom: calc(var(--section-gap) + 1.5rem);
    padding: 0.75rem 0;
    background: var(--color-ui-bg);
    border-bottom: 1px solid var(--color-ui-borders);
    box-shadow: 0 0 0 100vmax var(--color-ui-bg);
    clip-path: inset(-1px -100vmax -2rem);
}

.analytics-filter-bar {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.5rem 1.25rem;
}

.analytics-filter-bar[hidden] {
    display: none;
}

/* Collapsed, only the line with the ribbon is left. */
.analytics-filters[data-collapsed] {
    padding: 0;
}

.analytics-filters-ribbon {
    position: absolute;
    top: 100%;
    left: 50%;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    max-width: min(40rem, 100%);
    padding: 0.2rem 1rem 0.3rem;
    font-size: 0.75rem;
    color: var(--color-content-2);
    background: var(--color-ui-bg);
    border: 1px solid var(--color-ui-borders);
    border-top: 0;
    border-radius: 0 0 0.75rem 0.75rem;
    transform: translateX(-50%);
}

.analytics-filters-ribbon > :not(.analytics-filters-summary) {
    flex: none;
    white-space: nowrap;
}

.analytics-filters-ribbon:hover {
    color: var(--color-content-1);
}

/* The active filters, in the ribbon while collapsed. */
.analytics-filters-summary {
    display: none;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.analytics-filters[data-collapsed] .analytics-filters-summary {
    display: block;
}

.analytics-filters-toggle::before {
    transition: transform 0.2s;
}

.analytics-filters[data-collapsed] .analytics-filters-toggle::before {
    transform: rotate(180deg);
}

.analytics-filter-group {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    align-items: start;
}

.analytics-filter-group-title {
    padding-top: 0.35em;
    font-size: 0.75rem;
    color: var(--color-content-2);
}

.analytics-filter-reset {
    --link-text-decoration: none;

    align-self: center;
    margin-left: auto;
    font-size: 0.875rem;
}

.analytics-filter-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    min-width: 0;
}

@media (width < 600px) {
    .analytics-filter-bar {
        grid-template-columns: minmax(0, 1fr);
    }
}

.analytics-pills {
    display: inline-flex;
    align-items: stretch;
    max-width: 100%;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
    font-size: 0.75rem;
    border: 1px solid var(--color-ui-borders);
    border-radius: 999px;
}

.analytics-pills > * {
    display: flex;
    align-items: center;
    padding: 0.3em 0.8em;
    border-left: 1px solid var(--color-ui-borders);
}

.analytics-pills > :first-child {
    border-left: 0;
}

.analytics-pills > input[type="hidden"],
.analytics-pills > datalist,
.analytics-pills > template {
    display: none;
}

.analytics-pills-label {
    font-weight: var(--font-weight-bold);
    background: var(--color-ui-borders);
}

/* The text fields are all equally wide, whatever their label (& their value, once set). */
.analytics-pills-field {
    width: 22em;
}

.analytics-pills-field > a {
    display: block; /* not flex, which doesn't cut its text with an ellipsis */
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.analytics-pills a {
    --link-text-decoration: none;

    color: inherit;
    font-weight: var(--font-weight-base);
    white-space: nowrap;
}

.analytics-pills a:hover {
    color: var(--color-brand-dark);
}

.analytics-pills a.active {
    color: var(--color-ui-bg);
    background: var(--color-brand-dark);
}

.analytics-pills input {
    flex: 1;
    width: auto;
    min-width: 0;
    font: inherit;
    color: inherit;
    background: none;
    border-top: 0;
    border-right: 0;
    border-bottom: 0;
    outline: none; /* the pill shows the focus instead */
    text-overflow: ellipsis;
}

/* The custom period: two days, as wide as any date (so they don't resize). */
.analytics-pills-range input {
    flex: none;
    width: 8.5rem;
    font-variant-numeric: tabular-nums;
    color-scheme: dark;
}

.analytics-pills-range.active {
    border-color: var(--color-brand-dark);
}

.analytics-pills-field:focus-within {
    border-color: var(--color-brand-dark);
}

.analytics-pills .disabled {
    white-space: nowrap;
    color: var(--color-content-2);
    opacity: 0.4;
}

.analytics-pills input:disabled {
    opacity: 0.5;
}

/* -------------------- TOTALS -------------------- */

/* The totals, which switch the metric of the chart (see chart.js). */

/* The totals in equal columns (as many as fit), their labels wrapped if long. */
.analytics-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
    gap: 1.5rem 2rem;
    place-items: end stretch;
}

/* A total's cell, which sizes its value to the column (see .analytics-total-value). */
.analytics-total {
    container-type: inline-size;
}

.analytics-totals button {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    padding-bottom: 0.25rem;
    color: var(--color-content-2);
    text-align: left;
    border-bottom: 2px solid transparent;
}

.analytics-totals button:hover {
    color: inherit;
}

.analytics-totals button[aria-pressed="true"] {
    color: inherit;
    border-bottom-color: var(--color-brand-dark);
}

/* The info icon of a total, with its explanation on hover. */
.analytics-info {
    position: relative;
    display: inline-block;
}

.analytics-info::before {
    font-size: 1em;
    opacity: 0.6;
}

.analytics-info:hover::before {
    opacity: 1;
}

.analytics-info-tip {
    top: calc(100% + 0.5rem);
    left: 50%;
    width: 16rem;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-base);
    line-height: 1.5;
    color: var(--color-content-1);
    text-align: left;
    white-space: normal;
    transform: translateX(-50%);
}

.analytics-info:hover > .analytics-info-tip {
    visibility: visible;
}

/* Shrinks with the column, so the longest label ("Returning visitors") fits on one line. */
.analytics-total-label {
    font-size: clamp(0.75rem, 9cqi, 1rem);
    white-space: nowrap;
}

/* Shrinks with the column, so the longest value (e.g. "1m 43s") fits on one line. */
.analytics-total-value {
    font-size: clamp(1.5rem, 26cqi, 2.5rem);
    white-space: nowrap;
    font-weight: var(--font-weight-light);
}

/* The change since the previous period, green if better, red if worse; the
 * previous period's days & value on its info icon. */
.analytics-total-change {
    font-size: 0.75rem;
    color: var(--color-content-2);
}

.analytics-total-change[data-direction="up"]::before {
    content: '▲ ';
}

.analytics-total-change[data-direction="down"]::before {
    content: '▼ ';
}

.analytics-total-change[data-better="true"] {
    color: var(--cd-sea-green-60);
}

.analytics-total-change[data-better="false"] {
    color: var(--cd-red-50);
}

/* The previous period's tooltip, an info tooltip laid out like an hour's. */
.analytics-change-tip {
    width: max-content;
    white-space: nowrap;
}

.analytics-change-tip dl {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.15rem 1rem;
    margin: 0.35rem 0 0;
}

.analytics-change-tip dt {
    color: var(--color-content-2);
}

.analytics-change-tip dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

/* -------------------- HEADINGS -------------------- */

/* The column headings of the tables (in the cards). */
.analytics-table th {
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
}

/* -------------------- BARS -------------------- */

/* The bars behind the number cells of the tables, filled from the right by
 * their share (the --share of their cell). */
.analytics-table td[style]::before {
    position: absolute;
    z-index: -1;
    top: 50%;
    right: 0;
    left: 1rem; /* the gap to the previous column */
    height: 1.75em;
    content: '';
    background: linear-gradient(to left, var(--color-ui-borders) var(--share), transparent var(--share));
    transform: translateY(-50%);
}

/* -------------------- CARDS -------------------- */

/* The cards (with their tables & optionally tabs), in grids. */
.analytics-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
    margin: var(--section-gap) 0;
    gap: 1rem;
}

/* Consecutive card grids are as far apart as their cards. */
.analytics-cards:has(+ .analytics-cards) {
    margin-bottom: 0;
}

.analytics-cards + .analytics-cards {
    margin-top: 1rem;
}

/* A card spans two rows of its grid (its head & the shown tab), so the heads
 * in a row are equally high, with or without tabs, and so are their tables. */
.analytics-card {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    min-width: 0;
    padding: 1rem 1.25rem 1.25rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-ui-borders);
}

/* A card without its box, like the chart (the weekdays & hours). */
.analytics-card-plain {
    padding: 0;
    border: 0;
}

.analytics-card-head {
    display: grid;
    gap: 0.75rem;
    align-content: start;
}

.analytics-card h3 {
    margin: 0;
    font-size: 1rem;
}

/* The tabs below the title, on a line; the selected one marked on it. */
.analytics-card [role="tablist"] {
    display: flex;
    gap: 1rem;
    margin: 0;
    border-bottom: 1px solid var(--color-ui-borders);
}

.analytics-card [role="tab"] {
    margin-bottom: -1px;
    padding-bottom: 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-content-2);
    border-bottom: 2px solid transparent;
}

.analytics-card [role="tab"]:hover,
.analytics-card [role="tab"][aria-selected="true"] {
    color: var(--color-content-1);
}

.analytics-card [role="tab"][aria-selected="true"] {
    border-bottom-color: var(--color-brand-dark);
}

/* The body of a card is at least as high as a header, 10 rows & the "show all"
 * button, so the cards don't jump when their number of rows changes. */
.analytics-card.analytics-table > :not(.analytics-card-head) {
    min-height: 25.5rem;
}

/* A card shows the first 10 rows of its table, all if expanded (see cards.js). */
.analytics-card tbody tr:nth-child(n + 11) {
    display: none;
}

.analytics-card [data-expanded] tbody tr:nth-child(n) {
    display: table-row;
}

.analytics-more {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-content-2);
}

.analytics-more:hover {
    color: var(--color-brand-dark);
}

/* -------------------- DAYS -------------------- */

/* The chart with its scale (the labels left). */
.analytics-chart {
    position: relative;
    margin: var(--section-gap) 0;
    padding-left: var(--scale-width);
}

.analytics-days {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 8rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The scale of the shown metric: grid lines at 0, 50 & 100%, & the highest value. */
.analytics-scale {
    position: absolute;
    inset: 0 0 0 var(--scale-width);
    margin: 0;
    padding: 0;
    font-size: 0.75rem;
    color: var(--color-content-2);
    list-style: none;
    pointer-events: none;
}

.analytics-scale[hidden] {
    display: none;
}

.analytics-scale > li {
    position: absolute;
    right: 0;
    bottom: var(--at);
    left: 0;
    border-top: 1px solid var(--color-ui-borders);
}

.analytics-scale span {
    position: absolute;
    right: calc(100% + 0.5rem);
    white-space: nowrap;
    transform: translateY(-50%);
}

.analytics-scale > .analytics-highest {
    z-index: 1;
    border-top: 1px dashed var(--cd-sea-green-60);
}

.analytics-highest span {
    color: var(--cd-sea-green-60);
}

/* A column per day (the whole height, so small bars are easy to hover) with its bar. */

/* The bar height of the shown metric (its --share, see chart.js). */
.analytics-days li {
    position: relative;
    display: flex;
    flex: 1;
    align-items: flex-end;
    height: 100%;
    outline: none;
}

.analytics-days li::before {
    content: '';
    width: 100%;
    height: var(--share);
    min-height: 1px;
    background: var(--color-brand-gradient);
}

/* The best day of the shown metric. */
.analytics-days li.best::before {
    background: linear-gradient(135deg, var(--cd-sea-green-70), var(--cd-sea-green-50));
}

/* Today isn't over yet, so its bar is faded. */
.analytics-days li.today::before {
    opacity: 0.5;
}

.analytics-days li:hover::before,
.analytics-days li:focus-visible::before {
    filter: brightness(1.25);
}

/* The day's details, shown above its bar on hover (or focus). */
.analytics-day-tip {
    bottom: calc(var(--share) + 0.5rem); /* right above its bar */
    left: 50%;
    width: max-content; /* not as narrow as its day's column */
    min-width: 12rem;
    max-width: 32rem;
    font-size: 0.875rem;
    white-space: nowrap;
    transform: translateX(-50%);
}

.analytics-days li:nth-child(-n + 3) .analytics-day-tip {
    left: 0;
    transform: none;
}

.analytics-days li:nth-last-child(-n + 3) .analytics-day-tip {
    right: 0;
    left: auto;
    transform: none;
}

.analytics-days li:hover .analytics-day-tip,
.analytics-days li:focus-visible .analytics-day-tip {
    visibility: visible;
}

/* The metrics in two columns (of labels & values), the most viewed below them. */
.analytics-day-tip dl {
    display: grid;
    grid-template-columns: auto auto auto auto;
    gap: 0.15rem 1rem;
    margin: 0.35rem 0 0;
}

.analytics-day-tip dl > .analytics-day-top {
    grid-column: 1;
    margin-top: 0.35rem;
}

.analytics-day-tip dl > dd.analytics-day-top {
    grid-column: 2 / -1;
}

.analytics-day-tip dt {
    color: var(--color-content-2);
}

.analytics-day-tip dd {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

/* -------------------- HOURS -------------------- */

/* The visitors per weekday & hour: a cell per hour, as dark as its share of the
 * busiest hour; the hours equally wide, the weekdays in the chart's gutter. */
.analytics-hours {
    contain: inline-size; /* as wide as its card, whatever its table (see chart.js) */
}

.analytics-hours table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 0.75rem;
}

/* The weekdays' column, as wide as the chart's gutter (with the spacing around
 * it), so the hours line up with the chart's bars. */
.analytics-hours col:first-child {
    width: calc(var(--scale-width) - 4px);
}

.analytics-hours :is(th, td) {
    border: 0;
}

.analytics-hours th {
    padding: 0 0.5rem 0 0;
    font-weight: var(--font-weight-base);
    color: var(--color-content-2);
    text-align: right;
}

.analytics-hours :where(thead) th {
    padding: 0;
    text-align: left;
}

.analytics-hours td {
    position: relative;
    height: 1.5rem;
    padding: 0;
    min-width: 1rem;
    background: color-mix(in srgb, var(--color-brand-dark) var(--heat), var(--color-ui-borders));
}

/* An hour's tooltip, like a day's (see above): above its cell, its visitors. */
.analytics-hour-tip {
    bottom: calc(100% + 0.5rem);
    left: 50%;
    width: max-content;
    font-size: 0.875rem;
    white-space: nowrap;
    transform: translateX(-50%);
}

.analytics-hours td:nth-child(-n + 4) .analytics-hour-tip {
    left: 0;
    transform: none;
}

.analytics-hours td:nth-last-child(-n + 3) .analytics-hour-tip {
    right: 0;
    left: auto;
    transform: none;
}

.analytics-hours td:hover .analytics-hour-tip,
.analytics-hours td:focus-visible .analytics-hour-tip {
    visibility: visible;
}

.analytics-hour-tip dl {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.15rem 1rem;
    margin: 0.35rem 0 0;
}

.analytics-hour-tip dt {
    color: var(--color-content-2);
}

.analytics-hour-tip dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

/* -------------------- TABLES -------------------- */

.analytics-table {
    overflow-x: auto;
}

.analytics-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-small);
}

.analytics-table th,
.analytics-table td {
    padding: 0.4rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-ui-borders);
}

/* -------------------- HEATMAP -------------------- */

/* The window widths of the heatmap, below the filter bar. */
.analytics-heatmap-widths {
    margin-top: var(--section-gap);
}

.analytics-heatmap {
    overflow-x: auto;
    margin-top: var(--section-gap);
}

.analytics-heatmap iframe {
    display: block;
    max-width: none;
    height: 80vh;
    border: 1px solid var(--color-ui-borders);
    background: var(--color-ui-bg);
}

/* -------------------- VISITORS -------------------- */

/* A total without a chart to switch (e.g. of the visitors), like the buttons. */
.analytics-stat {
    display: flex;
    flex-direction: column;
    padding-bottom: 0.25rem;
}

/* Which visitors are shown (all, or those with actions). */
.analytics-visitors-shown {
    margin-top: var(--section-gap);
}

.analytics-visitors {
    margin-top: 1rem;
}

/* The list shows the first 25 visitors, all if expanded (see cards.js). */
.analytics-visitors :where(tbody tr:nth-child(n + 26)) {
    display: none;
}

.analytics-visitors[data-expanded] :where(tbody tr) {
    display: table-row;
}

.analytics-visitors td:first-child,
.analytics-profile-icons,
.analytics-ago {
    white-space: nowrap;
}

/* The source, broken between words only (e.g. "linkedin.com / tino-launch"). */
.analytics-source {
    min-width: 8rem;
}

.analytics-profile-icons > a:not(:first-child) {
    margin-left: 0.25em;
}

.analytics-returning {
    color: var(--color-content-2);
}

/* The last section a visitor reached on a page, in the text's colour. */
.analytics-section {
    font-size: var(--font-size-small);
}

.analytics-muted,
.analytics-meta {
    font-size: var(--font-size-small);
    color: var(--color-content-2);
}

/* The chips of the actions, clicks & sources. */
.analytics-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.analytics-chip {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    font-size: 0.75rem;
    color: var(--color-content-2);
    white-space: nowrap;
    border: 1px solid var(--color-ui-borders);
    border-radius: 1rem;
}

.analytics-chip + .analytics-chip {
    margin-left: 0.25rem;
}

.analytics-chips .analytics-chip {
    margin: 0;
}

.analytics-chip-action {
    color: var(--color-content-1);
    border-color: var(--color-brand-dark);
}

/* The links among the chips & profile icons (filters), without the link styles. */
a.analytics-chip,
.analytics-profile-icons a:any-link {
    --link-text-decoration: none;
}

a.analytics-chip:hover {
    color: var(--color-brand-dark);
}

/* A click as grouped pill: a cursor, then its target (a filter). */
.analytics-pills-click > *,
.analytics-pills-action > * {
    padding: 0.1rem 0.6rem;
}

/* An action as grouped pill: its name, then its properties (each a filter). */
.analytics-pills-action,
.analytics-pills-action > * {
    border-color: var(--color-brand-dark);
}

.analytics-pills-action > .analytics-pills-label {
    font-weight: var(--font-weight-bold);
    color: var(--color-ui-bg);
    background: var(--color-brand-dark);
}

/* Its name keeps its dark text on hover, on a lighter orange. */
.analytics-pills-action > .analytics-pills-label:hover {
    color: var(--color-ui-bg);
    background: var(--color-brand-light);
}

/* -------------------- VISITOR -------------------- */

/* The profile of a visitor: who they are, then what they did (a list each). */
.analytics-profile {
    display: grid;
    gap: 1.25rem;
    margin: var(--section-gap) 0;
}

/* Its values in equal columns, aligned between the lists. */
.analytics-profile dl {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 1.25rem 2rem;
    margin: 0;
}

.analytics-profile dt {
    font-size: 0.75rem;
    color: var(--color-content-2);
}

.analytics-profile dd {
    margin: 0.25rem 0 0;
    font-size: 1.125rem;
    white-space: nowrap;
}

/* A session as card, with its time, source & totals on top. */
.analytics-session {
    display: block;
    margin-top: 1rem;
}

.analytics-session-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
}

/* The pages of a session on a line, each with a dot on it. */
.analytics-timeline {
    margin: 1.25rem 0 0 0.375rem;
    padding: 0;
    list-style: none;
    border-left: 1px solid var(--color-ui-borders);
}

.analytics-step {
    position: relative;
    padding: 0 0 1.25rem 1.5rem;
}

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

.analytics-step::before {
    position: absolute;
    top: 0.45em;
    left: -0.3125rem;
    width: 0.5625rem;
    height: 0.5625rem;
    content: '';
    background: var(--color-ui-bg);
    border: 2px solid var(--color-brand-dark);
    border-radius: 50%;
}

.analytics-timeline-title {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    align-items: baseline;
}

.analytics-timeline-title time {
    font-size: var(--font-size-small);
    color: var(--color-content-2);
    font-variant-numeric: tabular-nums;
}

/* The reading time & scroll depth of a page as bars (filled by their share). */
.analytics-page-bars {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.375rem;
}

.analytics-bar {
    width: 6rem;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(to right, var(--color-ui-borders) var(--share), transparent var(--share));
    border: 1px solid var(--color-ui-borders);
}

.analytics-table .number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* A cell with long values without spaces (e.g. URLs), which may break anywhere. */
.analytics-table .analytics-wrap {
    overflow-wrap: anywhere;
}

/* The icon of a device (an empty icon, so the gap is the span's own). */
.analytics-device {
    margin-right: 0.4em;
}

/* The flag of a country (an emoji). */
.analytics-flag {
    margin-right: 0.4em;
    font-style: normal;
}

/* The icon of a browser or OS (see labels.BRAND_ICONS), in its brand's colours. */
.analytics-brand {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.4em;
    background: center / contain no-repeat;
    vertical-align: -0.125em;
}

.analytics-brand[data-brand="android"] { background-image: url("../icons/android.svg?v=49f44115"); }
.analytics-brand[data-brand="chrome"] { background-image: url("../icons/chrome.svg?v=98045c79"); }
.analytics-brand[data-brand="edge"] { background-image: url("../icons/edge.svg?v=3b6f52dc"); }
.analytics-brand[data-brand="firefox-browser"] { background-image: url("../icons/firefox-browser.svg?v=3f3742d1"); }
.analytics-brand[data-brand="internet-explorer"] { background-image: url("../icons/internet-explorer.svg?v=915749e7"); }
.analytics-brand[data-brand="linux"] { background-image: url("../icons/linux.svg?v=37b14e5b"); }
.analytics-brand[data-brand="opera"] { background-image: url("../icons/opera.svg?v=c44ee714"); }
.analytics-brand[data-brand="safari"] { background-image: url("../icons/safari.svg?v=80fd72ca"); }
.analytics-brand[data-brand="windows"] { background-image: url("../icons/windows.svg?v=0b7754f4"); }

/* The monochrome brand, in the text's colour. */
.analytics-brand[data-brand="apple"] {
    background: currentcolor;
    mask: url("../icons/apple.svg?v=ceb71de1") center / contain no-repeat;
}

/* The bar of a number cell (its share, see index.html). */
.analytics-table td[style] {
    position: relative;
    isolation: isolate;
}

/* The headers of a sortable table: a click sorts by the column (see sort.js). */
.analytics-sort {
    letter-spacing: inherit;
    text-align: inherit;
}

/* The arrow of the sorted column (pointing up when ascending), in front of the
 * label of number columns, so their labels stay aligned with the numbers. */
.analytics-sort-icon {
    margin-left: 0.25em;
    visibility: hidden;
}

.number .analytics-sort-icon {
    margin-left: 0;
}

th[aria-sort] .analytics-sort-icon {
    visibility: visible;
}

th[aria-sort="ascending"] .analytics-sort-icon::before {
    transform: rotate(180deg);
}

.analytics-sort:hover,
th[aria-sort] .analytics-sort {
    color: var(--color-brand-dark);
}

/* -------------------- SUGGESTIONS -------------------- */

/* The suggestions of a text field (see filter-bar.js), below its pill. */
.analytics-suggestions {
    position: fixed;
    z-index: 10;
    max-height: 18em;
    margin: 0.25rem 0 0;
    padding: 0.25rem;
    overflow-y: auto;
    font-size: 0.875rem;
    list-style: none;
    background: var(--color-ui-bg);
    border: 1px solid var(--color-ui-borders);
    border-radius: 0.75rem;
    box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 40%);
}

.analytics-suggestions li {
    padding: 0.35em 0.8em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-radius: 0.5rem;
    cursor: pointer;
}

.analytics-suggestions li:hover,
.analytics-suggestions li[aria-selected="true"] {
    color: var(--color-ui-bg);
    background: var(--color-brand-dark);
}

/* -------------------- LOGIN -------------------- */

/* The login page, like Glancelot's: the logo left of the welcome & the SSO button. */
.analytics-login {
    display: flex;
    flex-wrap: wrap;
    gap: var(--section-gap) calc(2 * var(--section-gap));
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.analytics-login-logo {
    width: 14rem;
    height: auto;
}

.analytics-login h1 {
    margin: 0.25em 0 0.4em;
}

/* Without the line below the headings (see common.css), like Glancelot's. */
.analytics-login h1::after {
    content: none;
}

.analytics-login-lede {
    max-width: 30em;
    margin-bottom: 2em;
}

main .analytics-login-button {
    display: inline-flex;
    align-items: center;
    padding: 0.6em 1.5em;
    font-weight: var(--font-weight-semibold);
    border: 2px solid currentcolor;
    border-radius: 2em;
}

main .analytics-login-button:hover,
main .analytics-login-button:focus-visible {
    color: var(--color-ui-bg);
    background: var(--color-brand-dark);
    border-color: var(--color-brand-dark);
}

/* The icon left of the text & the privacy policy below it (aligned with the text). */
.analytics-login-state {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25em 0.5em;
    align-items: baseline;
    max-width: none; /* the paragraphs' 37em would be narrow in the small font */
    margin-top: 2.5em;
    font-size: var(--font-size-small);
    color: var(--color-content-2);
}

.analytics-login-state a:any-link {
    grid-column: 2;
    justify-self: start;
    text-decoration: underline;
}

/* -------------------- DIALOGS -------------------- */

/* A dialog, e.g. how to connect an AI agent via MCP (see mcp-dialog.html). */
.analytics-dialog {
    width: min(48rem, calc(100% - 2rem));
    max-height: calc(100% - 4rem);
    padding: 1.5rem;
    color: var(--color-content-1);
    background: var(--color-ui-bg);
    border: 1px solid var(--color-ui-borders);
    border-radius: var(--border-radius);
}

.analytics-dialog::backdrop {
    background: rgb(0 0 0 / 60%);
}

.analytics-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.analytics-dialog h2 {
    margin: 0;
    font-size: 1.25rem;
}

.analytics-dialog h2::after {
    content: none;
}

.analytics-dialog h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: var(--font-size-small);
    text-transform: uppercase;
}

/* The texts in the small font, as wide as the dialog (not the paragraphs' 37em). */
.analytics-dialog p,
.analytics-dialog-notes,
.analytics-dialog-tools {
    max-width: none;
    font-size: var(--font-size-small);
}

.analytics-dialog-notes dt {
    font-weight: var(--font-weight-semibold);
}

.analytics-dialog-notes dd {
    margin: 0 0 0.75rem;
}

.analytics-dialog-notes ul {
    padding-left: 1.1rem;
}

/* A command or URL, with its copy button (in the brand's colour once copied). */
.analytics-code {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-ui-borders);
    border-radius: 0.25rem;
}

/* Without the code's own background, since the box has a border already. */
.analytics-code code {
    flex: 1;
    padding: 0;
    background: none;
    overflow-x: auto;
    font-size: var(--font-size-small);
    white-space: nowrap;
}

/* A tool: its name with a chevron (turned while it's collapsed), and its description. */
.analytics-dialog-tools summary {
    display: flex;
    flex-direction: row-reverse;
    gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
    list-style: none;
}

.analytics-dialog-tools summary::-webkit-details-marker {
    display: none;
}

.analytics-dialog-tools details:not([open]) summary::before {
    transform: rotate(-90deg);
}

.analytics-dialog-tools details p {
    margin: 0.25rem 0 0.75rem;
}

:where(.analytics-dialog button) {
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    background: none;
    border: 0;
}

.analytics-dialog button:hover,
.analytics-dialog button.is-copied {
    color: var(--color-brand-dark);
}

