/* Shani's building blocks: design tokens and the components every page shares (buttons, cards, tabs, chips, page
   header, empty state, skeletons, feedback). Colours come from the theme (themes.css); everything here only mixes them.
   Loaded right after shani.css, so a page's own rules (later files) still adjust them. */

/* ---------- Tokens ---------- */

.shani {
    /* Spacing: a 4 px grid. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 48px;

    /* Corners: controls, tiles, cards, dialogs, pills. */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* Type scale. */
    --text-xs: 0.75rem;
    --text-sm: 0.85rem;
    --text-md: 0.95rem;
    --text-lg: 1.1rem;
    --text-xl: 1.4rem;
    --text-display: clamp(1.8rem, 3.6vw, 2.6rem);

    /* Controls. */
    --control-h: 40px;
    --control-h-sm: 32px;

    /* Elevation: the theme's --shadow is the card level; one below and one above. */
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 12%);
    --shadow-lg: 0 18px 50px rgb(0 0 0 / 30%);
    --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

    /* Motion (the "Reduce motion" setting flattens all of it, see pages.css). */
    --dur-fast: 120ms;
    --dur: 200ms;
    --dur-slow: 320ms;
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

    /* Feedback colours, readable on light and dark themes. */
    --danger: #d0473b;
    --success: #2f9e64;
    --warning: #c98a1b;

    /* Rarity of forged gear in Hoshimura (grey, green, blue, orange, gold; hidden: violet), mixed with the theme's ink
       so each stays readable on light and dark themes. Never shown by colour alone: a name and a shape go with it. */
    --rarity-common: color-mix(in oklab, #8b9099 65%, var(--ink));
    --rarity-uncommon: color-mix(in oklab, #3aa655 72%, var(--ink));
    --rarity-rare: color-mix(in oklab, #3b82f6 72%, var(--ink));
    --rarity-epic: color-mix(in oklab, #f07f1a 75%, var(--ink));
    --rarity-legendary: color-mix(in oklab, #d9a400 75%, var(--ink));
    --rarity-hidden: color-mix(in oklab, #a54ef5 75%, var(--ink));

    /* Each area has its own hue, mixed into the theme's accent for small touches (page icon, section marks). */
    --area-hue: var(--accent);
    --area: color-mix(in oklab, var(--accent) 35%, var(--area-hue));
}

.shani [data-area="media"] { --area-hue: #5b8def; }
.shani [data-area="games"] { --area-hue: #9b6cf0; }
.shani [data-area="kitchen"] { --area-hue: #e0793a; }
.shani [data-area="household"] { --area-hue: #2fae9b; }
.shani [data-area="stats"] { --area-hue: #e0b25c; }
.shani [data-area="calendar"] { --area-hue: #2fae9b; }
.shani [data-area="news"] { --area-hue: #d0607a; }
.shani [data-area="notes"] { --area-hue: #8f9bb3; }

/* ---------- Buttons ---------- */

.primary-button, .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--control-h);
    padding: 6px var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: filter var(--dur-fast), background-color var(--dur-fast), border-color var(--dur-fast),
        box-shadow var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}

.primary-button { border: 1px solid transparent; background: var(--accent); color: var(--bg); }
.primary-button:hover { filter: brightness(1.08); box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent); }

.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; }
.secondary-button:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--surface-2); }

.primary-button:active, .secondary-button:active, .icon-button:active, .chip--toggle:active, .tab:active {
    transform: scale(0.97);
}

.primary-button svg, .secondary-button svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.primary-button--small, .secondary-button--small { min-height: var(--control-h-sm); padding: 4px var(--space-3); font-size: var(--text-sm); }
.secondary-button--danger { color: var(--danger); }
.secondary-button--danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }

/* A text link that acts. */
.text-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    text-underline-offset: 3px;
    cursor: pointer;
}
.text-button:hover { text-decoration: underline; }
.text-button--danger { color: var(--danger); }

.icon-button {
    width: var(--control-h);
    height: var(--control-h);
    flex: none;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.icon-button:hover { background: var(--surface); border-color: var(--line); }
.icon-button.is-active { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.icon-button--small { width: var(--control-h-sm); height: var(--control-h-sm); border-radius: var(--radius-sm); }
.icon-button--small svg { width: 16px; height: 16px; }
.icon-button--danger:hover { color: var(--danger); }
.icon-button svg rect { fill: none; stroke: currentColor; stroke-width: 1.8; }

.icon-button svg, .add-button svg, .chevron {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

/* Any button that can't be pressed right now looks it (one rule for the whole app). */
.primary-button:disabled, .secondary-button:disabled, .text-button:disabled, .icon-button:disabled {
    opacity: 0.5;
    cursor: default;
    filter: none;
    box-shadow: none;
    transform: none;
}

/* Keyboard focus: a soft ring in the accent on everything you can press. */
:is(.primary-button, .secondary-button, .icon-button, .tab, .chip--toggle, .card--link):focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.add-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.add-button:hover { color: var(--ink); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* A working button: a small spinner in front of the text. */
.spin { animation: shani-spin 0.9s linear infinite; }

/* ---------- Cards ---------- */

.card {
    --wi-fill: var(--surface);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

/* A whole card you can press: lifts a little. */
.card--link { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: border-color var(--dur), transform var(--dur) var(--ease-out), box-shadow var(--dur); }
.card--link:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-2px); }

/* ---------- Page header ---------- */

.page__header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-4); }
.page__header > div:first-child { min-width: 0; }

.page__header h1, .anime-header__title h1, .shop__title h1 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--text-display);
    font-weight: 300;
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-shadow: var(--glow);
}

.page__header p, .anime-header__title p { margin: 6px 0 0; color: var(--ink-muted); line-height: 1.45; }

/* The area's icon in front of the title, in the area's colour. */
.page__icon {
    width: 1.15em;
    height: 1.15em;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 0.32em;
    background: color-mix(in srgb, var(--area) 16%, transparent);
    color: var(--area);
}
.page__icon .icon { width: 0.62em; height: 0.62em; }

.page__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.page__bar { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }

/* ---------- Section title (start page sections, blocks inside pages) ---------- */

.hub-section__title, .section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
    font-size: var(--text-lg);
    font-weight: 650;
    letter-spacing: -0.005em;
}
.hub-section__title > .icon, .section-title > .icon { width: 18px; height: 18px; flex: none; color: var(--area); }

/* ---------- Tabs ---------- */

/* Too many tabs for a narrow screen: they scroll sideways (without a scrollbar). Soft shadows at the edges say there's
   more (the background-attachment trick: the covers move with the content, the shadows stay with the box). */
.tabs {
    display: flex;
    gap: 2px;
    max-width: 100%;
    padding: 3px;
    overflow-x: auto;
    scrollbar-width: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    background:
        linear-gradient(to right, var(--surface) 40%, transparent) left / 28px 100% no-repeat local,
        linear-gradient(to left, var(--surface) 40%, transparent) right / 28px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 28%), transparent) left / 10px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 28%), transparent) right / 10px 100% no-repeat scroll,
        var(--surface);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--control-h-sm);
    padding: 0 var(--space-3);
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--ink-muted);
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.tab:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tab.is-active { background: var(--accent); color: var(--bg); }

.tab__count {
    margin-left: 2px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: rgb(128 128 128 / 20%);
    font-size: 0.72rem;
}

/* ---------- Chips and badges ---------- */

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--ink-muted);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.chip--toggle {
    min-height: 30px;
    padding: 4px 12px;
    border: 1px solid var(--line);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.chip--toggle:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.chip--toggle.is-active { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.badge {
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--ink-muted);
    font-size: var(--text-xs);
    font-weight: 600;
}

/* ---------- Messages in place: error, success, hint ---------- */

/* ---------- Small helpers every page uses ----------
   .muted       quiet text: a hint under something, "nothing here yet", counts
   .form-error  what went wrong (in red), under a form or a list
   .spinner     a small turning ring while something loads (beside "Loading …")
   The old page-named classes (shopping__muted, feed-add__error, jellyfin-link__spinner) still work; new code uses these. */
.muted, .shopping__muted { margin: 0; color: var(--ink-muted); font-size: 0.9rem; }
.form-error, .feed-add__error { margin: 0; color: var(--danger); font-size: var(--text-sm); }
.spinner, .jellyfin-link__spinner {
    display: inline-block;
    flex: none;
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: shani-spin 0.9s linear infinite;
}
.form-success { margin: 0; color: var(--success); font-size: var(--text-sm); }

/* A notice with an icon: info (default), warning, error. */
.notice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid color-mix(in srgb, var(--notice, var(--accent)) 40%, var(--line));
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--notice, var(--accent)) 8%, var(--surface));
    font-size: var(--text-md);
    line-height: 1.45;
}
.notice > .icon { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--notice, var(--accent)); }
.notice p { margin: 0; }
.notice--warning { --notice: var(--warning); }
.notice--error { --notice: var(--danger); }

/* ---------- Empty state ---------- */

.page__empty { padding: var(--space-7) var(--space-6); display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); }
.page__empty h2 { margin: 0; font-size: 1.15rem; }
.page__empty p { margin: 0; color: var(--ink-muted); line-height: 1.5; max-width: 560px; }
.page__empty .primary-button { text-decoration: none; }

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-7) var(--space-5);
    text-align: center;
}
.empty__icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    margin-bottom: var(--space-2);
    border-radius: 18px;
    background: color-mix(in srgb, var(--area) 14%, var(--surface-2));
    color: var(--area);
}
.empty__icon .icon { width: 26px; height: 26px; }
.empty h2, .empty h3 { margin: 0; font-size: var(--text-lg); }
.empty p { margin: 0; max-width: 440px; color: var(--ink-muted); line-height: 1.5; }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }
.empty--compact { padding: var(--space-5) var(--space-4); }
.empty--compact .empty__icon { width: 44px; height: 44px; border-radius: 14px; }
.empty--compact .empty__icon .icon { width: 20px; height: 20px; }

/* ---------- Skeletons (placeholders while something loads) ---------- */

.skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%) 0 0 / 200% 100%;
    animation: shani-shimmer 1.4s linear infinite;
}

.skeleton-lines { display: flex; flex-direction: column; gap: 10px; }
.skeleton-line { display: block; height: 0.85rem; border-radius: 6px; }
.skeleton-line:nth-child(3n + 2) { width: 88%; }
.skeleton-line:nth-child(3n) { width: 64%; }
.skeleton-line--title { width: 40%; height: 1.2rem; margin-bottom: 4px; }
.skeleton-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); border-radius: var(--radius-xl); border: 1px solid var(--line); background: var(--surface); }
.skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: var(--space-3); }

/* ---------- Confirm dialog ---------- */

.confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: var(--space-4);
    background: rgb(0 0 0 / 45%);
    animation: shani-fade var(--dur) ease;
}

.confirm-dialog {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-6);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
    animation: shani-rise var(--dur) var(--ease-out);
}
.confirm-dialog h2 { margin: 0; font-size: 1.15rem; }
.confirm-dialog p { margin: 0; color: var(--ink-muted); line-height: 1.5; }
.confirm-dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }
.confirm-dialog--danger .primary-button { background: var(--danger); color: #fff; }

/* ---------- Toasts: kinds ---------- */

.toast { --toast: var(--accent); border-color: color-mix(in srgb, var(--toast) 70%, var(--line)); }
.toast--ok { --toast: var(--success); }
.toast--error { --toast: var(--danger); }
.toast__kind { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: var(--radius-md); background: color-mix(in srgb, var(--toast) 16%, transparent); color: var(--toast); }
.toast__kind .icon { width: 18px; height: 18px; }

/* ---------- Motion ---------- */

@keyframes shani-spin { to { transform: rotate(360deg); } }
@keyframes shani-fade { from { opacity: 0; } }
@keyframes shani-rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes shani-shimmer { to { background-position: -200% 0; } }
@keyframes shani-enter { from { opacity: 0; transform: translateY(6px); } }

/* Pages fade in a little when you open them. */
/* "backwards", not "both": a transform kept after the animation would make the page the containing block of the
   popups inside it (they'd sit on the page instead of the screen). */
.content > .page, .content > .home { animation: shani-enter var(--dur-slow) var(--ease-out) backwards; }

@media (prefers-reduced-motion: reduce) {
    .spin, .skeleton, .content > .page, .content > .home, .confirm-backdrop, .confirm-dialog { animation: none; }
    .primary-button, .secondary-button, .icon-button, .tab, .chip--toggle, .card--link { transition: none; }
    .primary-button:active, .secondary-button:active, .icon-button:active, .chip--toggle:active, .tab:active, .card--link:hover { transform: none; }
}

/* Fields line up with the buttons beside them (same height); :where() keeps it overridable. */
:where(.shani) :where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"], [type="image"], [type="submit"], [type="button"], [type="reset"]), select) {
    min-height: var(--control-h);
}

/* ---------- Touch: small controls get a bigger area to tap ----------
   On a touch screen a control needs about 40 px to hit. These stay small to look at; an invisible frame around them
   takes the tap. (Only where they don't use ::after themselves.) */
@media (pointer: coarse) {
    :is(.text-button, .start-section__more, .pinboard__swatch, .whats-new__heart, .wrapped__dot, .mt-world__toggle) { position: relative; }
    :is(.text-button, .start-section__more, .pinboard__swatch, .whats-new__heart, .wrapped__dot, .mt-world__toggle)::after {
        content: "";
        position: absolute;
        inset: -10px -4px;
    }
}

/* ---------- Media pages (MediaShell, MediaToolbar) ----------
   Every media page is built the same way: the head with its tabs, the filter bar, the page. Extras go below. */

.media-head { margin-bottom: var(--space-4); }
.media-tabs .icon { width: 15px; height: 15px; }

.media-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin: 0 0 var(--space-5);
}
.media-toolbar__search { position: relative; flex: 1 1 280px; display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.media-toolbar__search > .icon { position: absolute; left: var(--space-3); width: 16px; height: 16px; color: var(--ink-muted); pointer-events: none; }
.media-toolbar__search input { flex: 1; min-width: 0; padding-inline-start: 36px; }
.media-toolbar__search input::-webkit-search-cancel-button { display: none; }
.media-toolbar__search .icon-button { position: absolute; right: var(--space-1); }
.media-toolbar__end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-left: auto; }
.media-toolbar__sort { position: relative; display: flex; align-items: center; }
.media-toolbar__sort > .icon { position: absolute; left: var(--space-3); width: 15px; height: 15px; color: var(--ink-muted); pointer-events: none; }
.media-toolbar__sort select { padding-inline-start: 34px; }
.media-toolbar__view { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.media-toolbar__view .icon-button.is-active { background: var(--surface-2); color: var(--ink); }
.media-toolbar__filters { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); }
.media-toolbar__filters .chips { margin: 0; }
.media-toolbar__filters .field { flex: 0 1 190px; margin: 0; }
.media-toolbar__filters .field > span { font-size: var(--text-xs); }
.media-toolbar__count { margin-left: auto; font-size: var(--text-sm); }

/* Small tiles: two more in a row. */
.media-page--dense :is(.poster-grid, .tile-grid--poster) { grid-template-columns: repeat(calc(var(--cols-poster, 2) + 2), minmax(0, 1fr)); }

/* A section of a tab (continue watching, for you, what the family reads). */
.media-section { margin: 0 0 var(--space-5); }
/* On a media page the page's own gap already spaces them. */
.media-page .media-toolbar { margin-bottom: 0; }
.media-section > h2 { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); font-size: var(--text-lg); }
.media-section > h2 .icon { width: 18px; height: 18px; color: var(--area); }

@media (max-width: 560px) {
    .media-toolbar__end { margin-left: 0; width: 100%; }
    .media-toolbar__sort { flex: 1; }
    .media-toolbar__sort select { width: 100%; }
    .media-toolbar__count { margin-left: 0; }
}


/* ---------- Media lists: filters beside the list (MediaBrowser) ---------- */

.media-browse__body { display: block; }
@media (min-width: 900px) {
    .media-browse.has-panel .media-browse__body { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
    .media-browse:not(.has-panel) .filter-panel { display: none; }
    .filter-panel { position: sticky; top: calc(var(--topbar-h, 64px) + var(--space-3)); max-height: calc(100vh - var(--topbar-h, 64px) - var(--space-6)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: var(--space-2); }
    .filter-panel__close, .filter-panel__done, .media-toolbar__filter--sheet, .media-sheet__backdrop { display: none; }
}
@media (max-width: 899px) {
    .media-toolbar__filter--column { display: none; }
    /* On a phone the filters come up as a sheet from below. */
    .filter-panel { display: none; }
    .media-browse.has-sheet .filter-panel {
        display: flex; position: fixed; inset: auto 0 0; z-index: 60; max-height: 82vh; overflow-y: auto; overscroll-behavior: contain;
        padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
        border-radius: var(--radius-xl) var(--radius-xl) 0 0; background: var(--surface); box-shadow: var(--shadow-lg);
    }
    .media-sheet__backdrop { position: fixed; inset: 0; z-index: 59; background: rgb(0 0 0 / 45%); }
    .filter-panel__done { position: sticky; bottom: 0; width: 100%; }
}
.filter-panel { flex-direction: column; gap: var(--space-2); }
@media (min-width: 900px) { .filter-panel { display: flex; } }
.filter-panel__head { display: flex; align-items: center; gap: var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.filter-panel__head strong { display: flex; align-items: center; gap: var(--space-2); margin-right: auto; }
.filter-panel__head .icon { width: 16px; height: 16px; color: var(--area); }
.filter-sets { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.filter-set { display: inline-flex; align-items: center; gap: 2px; }
.filter-sets__save { display: flex; flex-direction: column; gap: var(--space-2); }
.filter-sets__buttons { display: flex; gap: var(--space-2); align-items: center; }
.filter-facet { border-bottom: 1px solid var(--line); padding: var(--space-2) 0; }
.filter-facet > summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) 0; cursor: pointer; font-weight: 600; font-size: var(--text-sm); list-style: none; }
.filter-facet > summary::-webkit-details-marker { display: none; }
.filter-facet > summary::after { content: "+"; margin-left: auto; color: var(--ink-muted); }
.filter-facet[open] > summary::after { content: "–"; }
.filter-facet > summary .icon { width: 15px; height: 15px; color: var(--ink-muted); }
.filter-facet__find { margin: var(--space-2) 0; width: 100%; }
.filter-facet__values { margin: var(--space-2) 0; }
.filter-facet__range { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; }
.filter-facet__range input { width: 0; flex: 1; }
.filter-facet__all { margin-top: var(--space-1); }

/* A filter value: tap once to include it (accent), again to exclude it (red, struck through), again to clear. */
.facet-chip.is-in { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.facet-chip.is-out { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border-color: var(--danger); text-decoration: line-through; }
.facet-chip .icon { width: 12px; height: 12px; }
.facet-chip.is-in .chip__count { color: inherit; opacity: 0.75; }
.media-active { flex: 1 1 auto; }

/* Suggestions under the search. */
.media-suggest {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40; margin: 0; padding: var(--space-1); list-style: none;
    border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto;
}
.media-suggest li { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.media-suggest li.is-active { background: var(--surface-2); }
.media-suggest li .icon { width: 15px; height: 15px; flex: none; color: var(--ink-muted); }
.media-suggest__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-suggest small { color: var(--ink-muted); white-space: nowrap; }

/* The table view. */
.media-table__wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.media-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.media-table th, .media-table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.media-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); font-weight: 600; }
.media-table thead button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; }
.media-table thead button:focus-visible { outline: 2px solid var(--accent); }
.media-table tbody tr { cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 56px; }
.media-table tbody tr:hover, .media-table tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.media-table .is-number { text-align: right; font-variant-numeric: tabular-nums; }
.media-table__title { display: flex; align-items: center; gap: var(--space-3); font-weight: 600; white-space: normal; min-width: 220px; }
.media-table__title img { width: 32px; height: 46px; object-fit: cover; border-radius: 4px; flex: none; }
.media-table__columns { width: 1%; position: relative; }
.media-table__columns summary { list-style: none; cursor: pointer; }
.media-table__columns summary .icon { width: 16px; height: 16px; }
.media-table__picker { position: absolute; right: 0; top: 100%; z-index: 5; display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-lg); }
.is-refreshing { opacity: 0.55; transition: opacity var(--dur); }

/* Gaming news: the esports schedule above the stories. */
.newsfeed-esports { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.newsfeed-esports .text-button { align-self: flex-end; }
