/*
 * Sharestream — shared stylesheet
 * Theme: Midnight cyberpunk — near-black neutral surfaces, one restrained accent
 * (hot pink) used sparingly. Surfaces are ~90% desaturated near-black; colour is
 * reserved for accents, never big fills.
 *
 * Structure, top to bottom:
 *   tokens -> base -> layout -> top bar -> typography -> components ->
 *   page modules -> motion -> responsive
 *
 * This file is the single source of truth for the shared UI. One block near the
 * end is the vendored Cactus Comments base sheet; it is marked with a banner and
 * kept close to upstream so it stays diffable against a future upgrade.
 */

/* --- Design tokens ---
 * The only place in this file where a raw colour, size, radius, shadow or
 * duration is written. Everything below resolves to these.
 */
:root {
    /* Render native widgets (form controls, scrollbars) in dark mode so a
       system light theme can't paint them white. */
    color-scheme: dark;

    /* --- surfaces --- */
    /* Near-black with a faint cool/purple cast, kept very close to the body bg
       so the container reads as the same depth as the top bar (no lighter
       rectangle floating above the page). --surface-2 lifts only a few steps
       for cards/inputs. */
    --bg:              #06050a;
    --bg-grad-from:    #040305;
    --bg-grad-to:      #08060d;
    --surface:         #110710;
    --surface-2:       #190b17;
    /* Translucent surface for the sticky bars: matches the container's depth
       while still letting a scrolling page show through. */
    --surface-scrim:   rgba(10, 7, 16, 0.82);
    /* Overlay fills. Two are the everyday card-pill and modal-backdrop weights;
       the light one lets a full-page scrim still show the page behind it, and
       the transparent one is the fade-out end state of that same scrim. */
    --overlay-scrim:       rgba(7, 6, 11, 0.7);
    --overlay-scrim-light: rgba(7, 6, 11, 0.55);
    --overlay-scrim-none:  rgba(7, 6, 11, 0);

    /* --- borders --- */
    --border:        rgba(255, 255, 255, 0.07);
    --border-accent: rgba(255, 42, 109, 0.24);

    /* --- text --- */
    --text:      #f2eef6;   /* solid near-white for headings + key text */
    --text-dim:  #b9b2c4;   /* body copy: a NEUTRAL grey, not a pink fill */
    --text-mute: #8a7d99;   /* labels, subtitles, tertiary */

    /* --- accent: one hue, tints and shades only --- */
    --accent:             #ff2a6d;
    --accent-soft:        #ff6ea4;
    --accent-tint:        rgba(255, 42, 109, 0.12);
    --accent-tint-mid:    rgba(255, 42, 109, 0.16);
    --accent-tint-strong: rgba(255, 42, 109, 0.2);
    --accent-glow:        rgba(255, 42, 109, 0.35);

    /* --- studio: the one sanctioned second hue ---
       A studio is a category, and the catalogue has always marked it with a
       warm amber — it is the chip a viewer scans a tag list for. It is used on
       exactly one chip variant and its suggestion prefix, never on a surface
       and never as a second accent family, so the "one hue" rule for ACTIONS
       still holds while the entity types stay distinguishable. */
    --studio:          #d0a078;
    --studio-soft:     #e0b894;
    --studio-tint:     rgba(184, 122, 70, 0.13);
    --studio-tint-mid: rgba(184, 122, 70, 0.22);
    --studio-line:     rgba(184, 122, 70, 0.3);

    /* --- elevation ---
       Three levels, no more: a resting surface, a floating one, and the hover
       lift. There is no fourth and fifth step to keep in sync, and nothing
       here is a literal at a call site. `--inset` is a hairline highlight, not
       a level; `--ring` and `--glow` are a focus ring and a CTA glow. */
    --elev-1:    0 8px 32px rgba(0, 0, 0, 0.3);
    --elev-2:    0 8px 24px rgba(0, 0, 0, 0.5);
    --elev-lift: 0 12px 40px rgba(0, 0, 0, 0.4);
    /* Accent glow under a primary CTA, at rest and on hover. */
    --glow:       0 4px 20px var(--accent-glow);
    --glow-hover: 0 6px 26px var(--accent-glow);
    --inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    /* The focus ring, shared by every control that has one. Solid rather than a
       12% tint: a tint measured 1.09:1 against the page, and WCAG 2.2 wants 3:1
       for a focus indicator. */
    --ring: 0 0 0 2px var(--accent);

    /* --- radii --- */
    --r-sm: 6px;
    --r-md: 12px;
    --r-pill: 999px;

    /* --- spacing scale --- */
    --sp-1: 6px;
    --sp-2: 12px;
    --sp-3: 20px;
    --sp-4: 32px;
    --sp-5: 48px;

    /* --- type ramp ---
       Six steps, and every font-size in this sheet resolves to one of them.
       Sizes that must track their own element's type (chips inheriting from a
       bar, code inside prose) stay in `em` on purpose. */
    --fs-xs:   0.78rem;
    --fs-sm:   0.85rem;
    --fs-base: 0.9rem;
    --fs-md:   1rem;
    --fs-lg:   1.25rem;
    --fs-2xl:  1.75rem;
    --lh-tight:   1.3;
    --lh-base:    1.6;
    --lh-relaxed: 1.7;
    --tracking-caps: 0.05em;
    --tracking-wide: 1px;

    /* --- controls ---
       The single source of truth for control box height. Tap targets are made
       by padding the visual box out to 44px at the call site (see the top bar
       hamburger), so there is no separate --tap step to keep in sync. */
    --control-h: 38px;
    --icon-sm: 16px;

    /* --- z-index ladder --- */
    --z-below:      -1;
    --z-raised:     1;
    --z-content:    2;
    --z-scrollbar:  10;
    --z-inline-menu: 30;
    --z-sticky:     50;
    --z-dropdown:   55;
    --z-popover:    60;
    --z-overlay:    1000;
    --z-top:        10000;

    /* --- motion ---
       Three durations and three recipes. A component names a recipe rather than
       writing its own property list, so "the same interaction" always takes the
       same time and eases the same way. */
    --dur-fast: 0.15s;
    --dur-base: 0.2s;
    --dur-slow: 0.3s;

    /* Colour/weight changes on a control: buttons, links, pills, menu rows. */
    --motion-ui: background-color var(--dur-base) ease, border-color var(--dur-base) ease,
                 color var(--dur-base) ease;
    /* A surface moving or lifting: cards, panels, modals. */
    --motion-surface: transform var(--dur-slow) ease, box-shadow var(--dur-slow) ease,
                      border-color var(--dur-slow) ease;
    /* Something appearing or dissolving: previews, scrims, fade-ins. */
    --motion-reveal: opacity var(--dur-slow) ease, transform var(--dur-slow) ease;

    /* --- select chevron ---
       appearance:none removes the native arrow, which stays chrome-light on a
       dark field. One shared glyph for every site-styled <select>. */
    --select-chevron: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ff6ec7' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

    /* --- Cactus (vendor) bridge ---
       The vendored block near the end of this file references these custom
       properties, but the upstream stylesheet that defines them is not linked,
       so every declaration using them was silently invalid. Map each onto the
       site token it should always have been. */
    --cactus-border-width: 1px;
    --cactus-border-color: var(--border);
    --cactus-border-radius: var(--r-sm);
    --cactus-error-color: var(--accent);
    --cactus-button-color: var(--accent-tint);
    --cactus-button-color--strong: var(--accent-tint-mid);
    --cactus-button-color--stronger: var(--accent-tint-strong);
    --cactus-button-text-color: var(--text);
    --cactus-text-color: var(--text);
    --cactus-text-color--soft: var(--text-mute);

    /* --- font role defaults ---
       Overridden by /fonts.css, which is built from config.yaml. The
       var(--font-role, var(--font-role-default)) indirection used throughout
       below is what makes operator font selection work: never bake a resolved
       family in here. */
    --font-base-default: 'Helvetica Neue', 'Inter', 'Helvetica', 'Arial', sans-serif;
    --font-title-default: 'Chakra Petch', 'Roboto Mono', monospace;
    --font-button-default: 'Chakra Petch', 'Roboto Mono', monospace;
    --font-disclaimer-default: 'Inter', 'Roboto Mono', monospace;
    --font-mono-default: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* --- Base --- */
body {
    /* Helvetica-Light look: real Helvetica Neue on macOS, Inter Light
       (a Helvetica-like neo-grotesque with true light weights) everywhere
       else. Overridden by --font-base from /fonts.css when configured. */
    font-family: var(--font-base, var(--font-base-default));
    font-size: var(--fs-md);
    font-weight: 400;
    letter-spacing: 0;
    margin:0;
    padding:0;
    background-color: var(--bg);
    background-image: linear-gradient(135deg, var(--bg-grad-from) 0%, var(--bg-grad-to) 100%);
    color: var(--text-dim);
    line-height: var(--lh-base);
    min-height: 100vh;
}

/* --- Layout ---
 * The container's padding IS the page's alignment axis: every child — the top
 * bar, page headings, the card grid — starts at this edge, so nothing can drift
 * out of line. Children must therefore NOT re-cap themselves with their own
 * max-width/margin:auto, which is what used to push the grid further right than
 * the headings on a wide window.
 *
 * `--edge` is the cushion where the page actually breathes: 30px, and it is
 * both the horizontal and the vertical inset while the window still constrains
 * the layout. Past --content-max the horizontal gutter alone grows (to keep the
 * cards from sprawling); the TOP cushion stays put at --edge, because inflating
 * it on wide screens just shoves the whole page down for no reason.
 */
.container {
    --content-max: 1560px;
    --edge: 30px;
    --gutter: max(var(--edge), calc((100% - var(--content-max)) / 2));
    margin:0 auto;
    /* The top bar supplies --sp-2 of its own padding above the logo, so the top
       padding only needs the remainder: the logo sits exactly --edge in from
       both the top and the left edge. */
    padding: calc(var(--edge) - var(--sp-2)) var(--gutter) 30px;
    background: var(--surface);
    border-radius: var(--r-md);
    box-shadow: var(--elev-1), var(--inset);
    min-height: calc(100vh - 60px);
    border: 1px solid var(--border);
}

/* --- Utilities --- */

/* The one way to hide something.
 *
 * Toggled as a CLASS from the script (`classList.add/remove`), never as an
 * inline `style.display`: this rule carries `!important`, so an inline
 * `display` is the one thing it would beat. Every element that uses this class
 * is toggled by class on both sides, which is what keeps the contract true — a
 * script that sets `el.style.display = 'block'` on one of these would leave it
 * invisible with no error to show for it.
 *
 * `!important` is deliberate: it has to beat component rules like
 * `#admin-content { display: flex }` and `.filedrop-tab-content { display: flex }`
 * without every one of them needing a `[hidden]`-style companion rule. */
.is-hidden {
    display: none !important;
}

/* A grid-form child that should sit under both label/field columns: a submit
   button, or a group of toggles. */
.grid-form-actions {
    grid-column: 1 / -1;
}

/* A .grid-form-actions group whose children stack vertically from the left, so
   a run of toggles reads as a list rather than a row. */
.grid-form-actions--stacked {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap:var(--sp-1);
    margin-top:5px;
}

/* The admin login card: the site's framed surface, held to a readable measure
   and centred in the viewport by its shell. */
.admin-login-card {
    max-width: 400px;
    width: 90%;
    overflow: visible;
}

/* A toggle row nested under another toggle in an admin form. */
.checkbox-wrapper--indented {
    margin-left:var(--sp-2);
}

/* --- Top bar (sticky) ---
 * A real, persistent header bar: logo left-aligned and size-capped, the global
 * search taking the slack, then operator buttons, then an overflow menu.
 * Sticky so it stays visible while scrolling.
 *
 * Grid columns are `logo | search | actions | menu`. Gaps are applied as
 * MARGINS rather than `gap` because an auto-sized grid track is zero-width when
 * its only child is display:none — a `gap` between the search and the actions
 * would then leave a stray 12px notch. Margins also let the search hand all of
 * its slack to the neighbouring cells (`justify-self: end`), so the strip sits
 * flush against the far right instead of inside a padded track.
 *
 * The columns NEVER wrap, which is what makes "two rows on mobile, never three"
 * structural rather than a hope: at narrow widths `.topbar-actions` is
 * display:none and the grid areas below put the menu on the logo's row.
 */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "logo search actions menu";
    align-items: center;
    padding:var(--sp-2) 0;
    background: var(--surface-scrim);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-logo {
    grid-area: logo;
    display: inline-flex;
    align-items: center;
    min-width: 0;
    /* The logo is deliberately TALLER than the bar's content box: it is the one
       hero element, and a 52px mark in a 63px bar reads better than a 36px mark
       with 13px of dead space above and below it. Rather than letting the image
       dictate the row height and then clawing it back with negative margins on
       the <img> (which is what this used to do, and which silently breaks the
       moment the logo asset changes), the LINK is pinned to the row height and
       the image is allowed to overflow it. */
    height: 32px;
}

.topbar-search {
    grid-area: search;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    margin-left:var(--sp-3);
}

/* Operator buttons, inline in the bar to the right of the search. Filled by
   topbar-menu.js, which moves as many menu items in here as fit. `min-width: 0`
   + `overflow: hidden` mean a partially-placed item clips instead of wrapping
   the bar (the JS measures before inserting, so clipping is only a last-resort
   guard). Invisible until the JS has composed, so a wide-screen visitor never
   sees buttons pop into place. */
.topbar-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--dur-fast) ease;
}

.topbar-actions.is-ready {
    opacity: 1;
}

.topbar-action {
    flex: 0 0 auto;
    margin-left:var(--sp-1);
}

/* Hamburger. Native <details> so open/close, focus order and keyboard support
   work with no JS; the script only adds Escape / outside-click closing and the
   inline-overflow composition. */
.topbar-menu {
    grid-area: menu;
    position: relative;
    margin-left:var(--sp-1);
}

.topbar-menu[hidden] {
    display: none;
}

.topbar-menu > summary {
    /* Same box as the mobile logo cap, so the row looks deliberate. border-box
       keeps the 1px border INSIDE the 32px so the total is 32px; otherwise the
       row is 34px tall and the 32px logo centers 1px lower than its left inset,
       making the vertical cushion visibly larger than the horizontal one. */
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding:0;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-mute);
    cursor: pointer;
    /* Hide the default disclosure triangle. */
    list-style: none;
    transition: var(--motion-ui);
}

.topbar-menu > summary::-webkit-details-marker {
    display: none;
}

.topbar-menu > summary::marker {
    content: "";
}

.topbar-menu > summary:hover {
    color: var(--accent);
    border-color: var(--border-accent);
}

.topbar-menu[open] > summary {
    color: var(--accent);
    border-color: var(--border-accent);
    background: var(--accent-tint);
}

.topbar-menu > summary:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Tap target: the visual box stays 32px so it sits tidily against the logo, but
   the hit area is padded out to ~44px on touch screens. */
.topbar-menu > summary::after {
    content: "";
    position: absolute;
    inset: -6px;
}

.topbar-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    max-width: min(320px, 80vw);
    padding: var(--sp-1);
    background: var(--surface-2);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    box-shadow: var(--elev-2);
    /* Above the bar (--z-sticky) and its logo, below the search's suggestion
       dropdown (--z-popover). */
    z-index: var(--z-dropdown);
}

.topbar-menu-section + .topbar-menu-section-sep {
    margin-top: var(--sp-1);
    padding-top: var(--sp-1);
    border-top: 1px solid var(--border);
}

.topbar-menu-label {
    padding:4px 10px;
    color: var(--text-mute);
    font-size: var(--fs-xs);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

/* Caps mean "this is a micro-label": th, form + field labels, the menu label,
   the separator, and the Cactus panel titles. Nothing else — a section heading
   written in caps shouts in the same voice as a form label, which is what made
   the page read as undocumented rather than as restrained. */

.topbar-menu-link {
    display: block;
    padding:8px 10px;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: var(--fs-base);
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}

.topbar-menu-link:hover {
    background: var(--accent-tint);
    color: var(--accent-soft);
}

/* Menu rows reuse the footer pill's colour language without the pill shape.
   "Primary" is the accent, not a second hue — the mint green that used to live
   here was the only green on the site and fought the hot pink.
   topbar-menu.js reads data-style to build the topbar-action-{style} class when
   it lifts a button into the inline strip, so this hook is also what keeps an
   operator's configured buttons styled after they move. */
.topbar-menu-action[data-style="primary"] {
    color: var(--accent-soft);
}

.topbar-menu-action[data-style="primary"]:hover {
    color: var(--accent);
    background: var(--accent-tint);
}

.global-search {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-1);
    width: 100%;
    /* Absorb most of the slack between the logo and the buttons, but never
       shrink below a usable width — past ~220px the inline buttons migrate into
       the menu instead (topbar-menu.js reads this same floor). */
    max-width: 520px;
    min-width: 220px;
}

.global-search-bar {
    flex: 1 1 auto;
    max-width: 100%;
    min-width: 0;
}

.global-search-bar .faceted-tag-suggestions {
    z-index: var(--z-popover);
}

/* Logo: height-capped (never width:100%, which balloons). The accent glow is
   the single restrained hero moment. `img.logo` is what the top bar and the
   admin header put on their <img>; admin.css narrows the height to its own
   header. */
.topbar-logo img,
img.logo {
    width: auto;
    height: 52px;
    max-height: 56px;
    display: block;
    filter: drop-shadow(0 0 8px var(--accent-glow));
    transition: var(--motion-reveal), filter var(--dur-slow) ease;
}

a:hover .logo,
.topbar-logo:hover img {
    transform: translateY(-1px);
    filter: drop-shadow(0 0 12px var(--accent-glow));
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: var(--font-title, var(--font-title-default));
    font-weight: 600;
    margin-top:var(--sp-3);
    margin-bottom:var(--sp-3);
    letter-spacing: 0;
    text-align: center;
    color: var(--text);
}

h1 {
    font-size: var(--fs-2xl);
}

/* Headings are solid near-white (no gradient text). emoji-fix.js still wraps
 * emoji in <span class="emoji">; this rule keeps any future gradient-clip on
 * headings rendering emoji normally. */
.emoji {
    color: initial;
}

/* Page-level heading (gallery name, tag directory). Left aligned and
 * deliberately understated — the catalog is the hero, not its label. */
.page-heading {
    text-align: left;
    font-size: var(--fs-2xl);
    font-weight: 600;
    letter-spacing: 0;
    margin:0 0 var(--sp-1) 0;
}

/* Parenthetical item count beside a page title: same line and family, but
 * clearly subordinate so it doesn't compete with the name. */
.gallery-count {
    color: var(--text-mute);
    font-weight: 400;
    white-space: nowrap;
}

/* No caps: an h2 is a section heading, not a micro-label. The uppercase voice
   is reserved for th / form labels / field labels / the menu label. */
h2 {
    font-size: var(--fs-lg);
}

h3 {
    font-size: var(--fs-md);
}

/* --- Disclaimer ---
 * This used to render at opacity 0.2, which measures 1.65:1 — below AAA, below
 * AA, and effectively unreadable. A disclaimer that cannot be read is a legal
 * notice pretending to be a legal notice. It is now body-copy-adjacent at
 * --text-mute (~5:1) and no longer justified or condensed. */
.disclaimer {
    font-family: var(--font-disclaimer, var(--font-disclaimer-default));
    font-weight: 400;
    margin:96px auto var(--sp-2);
    color: var(--text-mute);
    font-size: var(--fs-xs);
    max-width: 1000px;
    line-height: var(--lh-base);
}

/* --- Forms --- */
.grid-form {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap:var(--sp-3);
    margin:0 auto 30px;
    max-width: 600px;
}

.grid-form label {
    text-align: right;
    padding-top:10px;
    color: var(--text-mute);
    font-size: var(--fs-base);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

.grid-form input,
.grid-form select,
.grid-form button {
    width: 100%;
    padding: var(--sp-2);
    margin:0;
    border: 1px solid var(--border-accent);
    background: var(--bg);
    color: var(--text-dim);
    border-radius: var(--r-sm);
    font-size: var(--fs-base);
    transition: var(--motion-surface);
    backdrop-filter: blur(5px);
}

.grid-form input:focus,
.grid-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
    background: var(--surface-2);
}

.grid-form select {
    appearance: none;
    cursor: pointer;
}

.grid-form input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.grid-form input[type="number"]::-webkit-inner-spin-button,
.grid-form input[type="number"]::-webkit-outer-spin-button {
    appearance: none;
    margin:0;
    display: none;
}

.input-group {
    display: flex;
    gap:10px;
    grid-column: 2;
}

.input-group input {
    flex: 1;
    width: auto;
}

.input-group button {
    width: auto;
    background: var(--surface-2);
    color: var(--accent-soft);
    border: 1px solid var(--border-accent);
}

/* --- Buttons: ghost / secondary ---
   Rectangle with the standard radius, never a pill. Primary and danger are
   single-property variants so a page can opt in without a second rule set. */
button {
    font-family: var(--font-button, var(--font-button-default));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-1);
    background: var(--surface-2);
    color: var(--text-mute);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding:8px 16px;
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: var(--tracking-caps);
    cursor: pointer;
    transition: var(--motion-ui);
    box-shadow: none;
    transform: none;
    position: relative;
    overflow: visible;
}

button::before {
    content: none;
}

button:hover {
    background: var(--accent-tint);
    color: var(--accent);
    border-color: var(--border-accent);
    transform: none;
    box-shadow: none;
}

button:active {
    background: var(--surface);
    transform: translateY(1px); /* subtle press instead of a lift */
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Danger variant (for delete / logout).
   A treatment, not a hue: the old --danger #ff4d6d measured 1.13:1 against the
   accent #ff2a6d, so it read as the same colour while claiming to be a second
   one. Destructive controls are told apart by SHAPE — a transparent fill and an
   accent border — which is a cue a viewer can actually see. */
button.danger {
    color: var(--accent-soft);
    border-color: var(--border-accent);
    background: transparent;
}

button.danger:hover {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: none;
}

/* Secondary/outline variant (for refresh, cancel, copy, edit). */
button.secondary {
    background: transparent;
    color: var(--text-mute);
    border-color: var(--border);
}

button.secondary:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border-accent);
}

/* Primary variant: only for the main CTA on a page. */
button.primary {
    background: var(--accent);
    color: var(--text);
    border-color: transparent;
}

button.primary:hover {
    background: var(--accent-soft);
    box-shadow: none;
}

/* --- Messages --- */
.error-message {
    color: var(--accent-soft);
    font-size: var(--fs-sm);
    margin:10px auto 0;
    max-width: 600px;
}

.success-message {
    color: var(--accent-soft);
    font-size: var(--fs-sm);
    margin:10px auto 0;
    max-width: 600px;
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top:var(--sp-3);
    margin-bottom:30px;
}

th, td {
    padding: var(--sp-2) 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-base);
}

th {
    background: var(--surface);
    color: var(--text-dim);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    position: sticky;
    top: 0;
    z-index: var(--z-scrollbar);
    border-bottom: 1px solid var(--border-accent);
}

td {
    color: var(--text-dim);
}

tr {
    transition: background-color var(--dur-base) ease;
}

tr:hover {
    background: var(--accent-tint);
}

td a {
    color: var(--accent-soft);
    text-decoration: none;
    transition: color var(--dur-base) ease;
}

td a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* --- Gallery: grid and cards --- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap:30px;
    /* Only a small lead-in above the cards: the toolbar already ends with its
       own margin, and the two together should not exceed the gap above it. */
    padding:var(--sp-2) 0 30px;
}

.video-card {
    background: var(--surface-2);
    border-radius: var(--r-md);
    box-shadow: var(--elev-1);
    overflow: hidden;
    transition: var(--motion-surface);
    border: 1px solid var(--border);
    position: relative;
}

.video-card.tag-collection {
    border-color: var(--border-accent);
}

/* One restrained sheen sweep on hover. */
.video-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(45deg, transparent 30%, var(--accent-tint) 50%, transparent 70%);
    opacity: 0;
    transition: opacity var(--dur-slow) ease;
    pointer-events: none;
    z-index: var(--z-raised);
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--elev-lift);
    border-color: var(--border-accent);
}

.video-card:hover::before {
    opacity: 0.6;
    animation: sheen var(--dur-slow) ease-out;
}

@keyframes sheen {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

/* --- Thumbnail wrapper (positioning context for the card overlays) --- */
.video-card .thumb {
    position: relative;
    display: block;
    line-height: 0;
}

.video-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.video-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--bg);
    display: block;
    transition: opacity var(--dur-slow) ease;
}

.video-card .title {
    padding:4px  var(--sp-1);
    text-align: center;
    font-size: var(--fs-md);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

/* Animated WebP preview overlay shown on hover (and always-on for tag cards). */
.video-card img.preview-webp {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--dur-slow) ease;
    z-index: var(--z-raised);
    pointer-events: none;
}

.video-card img.preview-webp.is-visible {
    opacity: 1;
}

/* --- Card overlays: play count, runtime, collection size ---
 * The same little scrim pill; only the anchor corner, the icon and the number
 * weight differ. */
.hit-counter,
.duration-badge,
.video-count-overlay {
    position: absolute;
    background: var(--overlay-scrim);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: var(--r-sm);
    padding:4px 10px;
    display: flex;
    align-items: center;
    gap:4px;
    font-size: var(--fs-xs);
    color: var(--text);
    z-index: var(--z-content);
}

.hit-counter {
    top: 10px;
    right: 10px;
    border: 1px solid var(--border-accent);
}

.hit-counter span {
    font-weight: 400;
}

.duration-badge {
    bottom: 10px;
    right: 10px;
    border: 1px solid var(--border);
    line-height: 1;
}

.duration-badge span {
    font-weight: 600;
}

.video-count-overlay {
    top: 6px;
    right: 6px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-accent);
}

.video-count-overlay span {
    font-weight: 600;
}

.hit-counter .eye-icon,
.duration-badge .clock-icon,
.video-count-overlay .video-icon {
    width: var(--icon-sm);
    height: var(--icon-sm);
    color: var(--accent-soft);
}

/* --- Section separator --- */
.section-separator {
    display: flex;
    align-items: center;
    /* Only the bottom margin is used: it is the "space above the sort row" that
       the row's own spacing below is measured against. */
    margin:0 0 var(--sp-2);
    gap:var(--sp-3);
}

.separator-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

.separator-text {
    font-family: var(--font-title, var(--font-title-default));
    color: var(--text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-size: var(--fs-lg);
    background: var(--surface-2);
    padding:10px var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

/* The comments header's logo is taller than the old text pill, so let the
   separator grow to fit; align-items: center keeps the lines dead-center. */
.comments-separator {
    height: auto;
    align-items: center;
}

.comments-brand-logo {
    display: block;
    width: 6em;
    height: 6em;
    object-fit: contain;
    margin:0 1rem;            /* breathing room between the logo and lines */
}

.comments-brand-logo-link:hover .comments-brand-logo {
    transform: scale(1.03);   /* subtle affordance since there's no box anymore */
}

/* --- Gallery section --- */
.tag-gallery {
    margin-bottom:var(--sp-3);
}

/* The sort row above already provides the separation; a margin here would stack
   on it and reopen the gap we just tightened. */
.videos-gallery {
    margin-top:0;
}

/* --- Masonry gallery mode (opt-in per tag share) ---
 * Cards keep their native aspect ratio (no crop) and pack into balanced
 * columns. gallery-masonry.js distributes the cards across N flex columns,
 * always appending the next card to the shortest column — so the top row fills
 * left-to-right and no card overflows past the column (which a CSS multi-column
 * layout would, bleeding its shadow over the pagination). Each card carries a
 * --card-aspect var (width/height) so its thumbnail reserves the right height
 * before the image loads, keeping the packing stable and avoiding reflow. */
.gallery-masonry {
    display: flex;
    align-items: flex-start;
    gap:30px;
    padding:var(--sp-2) 0 30px;
}

.gallery-masonry .masonry-col {
    display: flex;
    flex-direction: column;
    gap:30px;
    flex: 1 1 0;
    min-width: 0;
}

.gallery-masonry .video-card .thumb {
    /* Reserve the native aspect ratio; fall back to 16:9 if unknown. */
    aspect-ratio: var(--card-aspect, 1.7778);
}

.gallery-masonry .video-card img {
    width: 100%;
    height: 100%;
    /* Show the whole frame, not a center-crop — the point of masonry mode. */
    object-fit: contain;
}

.gallery-masonry .video-card img.preview-webp {
    position: absolute;
    top: 0;
    left: 0;
    object-fit: contain;
}

#loading {
    text-align: center;
    padding:var(--sp-3);
    color: var(--text-mute);
    font-size: var(--fs-sm);
    display: none;
}

/* --- Video player: stage and box ---
 * The stage holds the player and the metadata side by side. When there is not
 * enough horizontal room the metadata wraps to a full-width row below the player
 * (handled entirely by flex-wrap). The Video.js chrome — control bar, controls,
 * progress — lives in video-player.css, which the player page and the embed
 * both load; nothing about the player skin belongs here. */
.video-stage {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap:30px;
    /* Constrain the stage to 80% of the viewport width. This reserves the ~10%
       breathing room on each side and makes the "is there room for metadata
       beside the player?" decision match it: a player sized to the full 80vw
       fills the row on its own, so the metadata wraps below; a narrow (portrait)
       player leaves room beside it. */
    max-width: 80vw;
    margin: var(--sp-3) auto;
    padding-bottom: var(--sp-3);
}

.video-container {
    flex: 0 0 auto;
    /* JS sets explicit width/height to fit the video into the viewport at its
       native aspect ratio. These provide a sensible landscape fallback until
       metadata loads (and if the sizing script is ever unavailable) so the
       player can never collapse to zero size. */
    width: min(80vw, 1280px);
    aspect-ratio: 16 / 9;
    max-width: 80vw;
    position: relative;
    /* A single, restrained glow behind the player. A blurred ellipse has no hard
       rectangular gradient boundary, and the player remains the only element
       that clips its media. */
    isolation: isolate;
}

.video-container::before {
    content: '';
    position: absolute;
    inset: -24px;
    z-index: var(--z-below);
    pointer-events: none;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.12;
    filter: blur(48px);
}

/* --- Scrollbars --- */
::-webkit-scrollbar {
    width: 0px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-2);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-accent);
}

/* --- Motion --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive: shell and cards --- */
@media (max-width: 768px) {
    .container {
        --edge: 20px;
        --gutter: var(--edge);
        padding:calc(var(--edge) - var(--sp-2)) var(--gutter)  var(--sp-3);
    }

    .grid-form {
        grid-template-columns: 1fr;
        gap:10px;
        max-width: 100%;
    }

    .grid-form label {
        text-align: left;
        padding-top:0;
    }

    .input-group {
        grid-column: 1;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap:var(--sp-3);
    }

    .video-card img {
        height: 180px;
    }

    th, td {
        padding:10px;
    }
}

@media (max-width: 480px) {
    .container {
        --edge: 15px;
        --gutter: var(--edge);
        padding:calc(var(--edge) - var(--sp-2)) var(--gutter) 15px;
    }

    /* Headings shrink on phones, they do not grow: the base h1 is --fs-2xl and
       this block used to push it a size bigger, which is backwards on the one
       screen size that has the least room. */
    h1 {
        font-size: var(--fs-lg);
    }

    h2 {
        font-size: var(--fs-lg);
    }

    button {
        padding: var(--sp-1)  var(--sp-2);
        font-size: var(--fs-xs);
    }

    .grid-form input,
    .grid-form select,
    .grid-form button {
        padding:8px;
        font-size: var(--fs-xs);
    }

    .gallery {
        gap:var(--sp-2);
    }

    .video-card img {
        height: 140px;
    }

    th, td {
        padding:8px;
    }
}

/* --- Gallery pagination --- */
.pagination {
    text-align: center;
    margin:30px 0;
    padding:var(--sp-3);
}

.pagination a,
.pagination span {
    display: inline-block;
    padding:5px 10px;
    margin:0 3px;
    color: var(--text);
    font-size: var(--fs-md);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    transition: var(--motion-ui);
}

.pagination a:hover {
    background: var(--accent-tint);
    border-color: var(--border-accent);
    color: var(--accent-soft);
}

.pagination .current {
    border-color: var(--accent);
    font-size: var(--fs-md);
    color: var(--text);
}

/* --- Social links (gallery and video pages) --- */
.social-links {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    margin:40px 0 var(--sp-3) 0;
    padding:var(--sp-3) 0;
    gap:24px;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin:0 10px;
    opacity: 0.4;
    transition: var(--motion-reveal);
}

.social-links a:hover {
    opacity: 1;
    transform: scale(1.12);
}

.social-links img {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    display: inline-block;
    background: none;
    box-shadow: none;
    /* Recolour black SVGs to the accent using a filter chain: brightness(0)
       flattens to black, then the sepia/saturate/hue-rotate ladder lands on the
       hot pink. It is a filter, not a colour, so it stays literal. */
    filter: brightness(0) saturate(100%) invert(56%) sepia(89%) saturate(1715%) hue-rotate(295deg) brightness(102%) contrast(101%);
}

.social-links a:hover img {
    filter: brightness(0) saturate(100%) invert(47%) sepia(97%) saturate(5159%) hue-rotate(313deg) brightness(103%) contrast(101%);
}

/* --- Not found / expired page --- */
.not-found {
    max-width: 600px;
    margin:50px auto;
    text-align: center;
    padding:var(--sp-5) var(--sp-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--elev-1);
}

.not-found-title {
    font-family: var(--font-title, var(--font-title-default));
    font-size: var(--fs-2xl);
    margin:0 0 var(--sp-2);
    color: var(--text);
}

.not-found-text {
    color: var(--text-dim);
    line-height: var(--lh-relaxed);
    margin:0 0 28px;
}

.not-found-home {
    font-family: var(--font-button, var(--font-button-default));
    display: inline-block;
    padding: var(--sp-2) 28px;
    border-radius: var(--r-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    background: var(--accent);
    box-shadow: var(--glow);
    transition: var(--motion-surface);
}

.not-found-home:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-hover);
}

/* --- Site footer --- */
.site-footer {
    text-align: center;
    margin:40px 0 10px 0;
    padding:var(--sp-3) 0 0;
    border-top: 1px solid var(--border);
}

.footer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap:var(--sp-2);
    margin-bottom:var(--sp-2);
}

/* Pill buttons. The footer renders these from config (footer.action_links); the
   top bar renders the SAME anchors inline from topbar.action_links
   (topbar-menu.js lifts them out of the menu). One rule set for both, so the two
   surfaces can't drift apart in look.

   The `action-link-{style}` class is also on each anchor, and an operator's
   localized/styles.css may style it. These rules are the built-in defaults; they
   must keep their exact names, values and specificity so an operator override
   wins where it should and the default renders identically where it doesn't. */
:is(.footer-action, .topbar-action) {
    font-family: var(--font-button, var(--font-button-default));
    display: inline-block;
    text-decoration: none;
    font-size: var(--fs-base);
    transition: var(--motion-ui);
    padding:8px 16px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    white-space: nowrap;
}

:is(.footer-action-secondary, .topbar-action-secondary) {
    color: var(--text-mute);
}

:is(.footer-action-secondary, .topbar-action-secondary):hover {
    color: var(--accent);
    background: var(--accent-tint);
    border-color: var(--border-accent);
}

:is(.footer-action-primary, .topbar-action-primary) {
    color: var(--accent-soft);
    border-color: var(--border-accent);
}

:is(.footer-action-primary, .topbar-action-primary):hover {
    color: var(--accent);
    background: var(--accent-tint);
    border-color: var(--accent);
}

.footer-inline-links {
    font-size: var(--fs-sm);
    line-height: var(--lh-base);
    color: var(--text-dim);
}

.footer-inline-links a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color var(--dur-base) ease;
}

.footer-inline-links a:hover {
    color: var(--accent-soft);
}

.footer-inline-sep {
    color: var(--text-mute);
    margin:0 0.4em;
    user-select: none;
}

/* --- Gallery toolbar: in-gallery search + sort (curated Galleries only) ---
 * One flex row, so the search bar and the select share a Y axis and a height.
 * This is the layout for a shared gallery, which HAS a search field; the title
 * and description sit above it as a full-width block and never compete with the
 * select for width. --control-h is the single source of truth for both controls'
 * box height. */
.gallery-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap:var(--sp-2);
    min-height: var(--control-h);
}

/* As a flex item the select has a content-sized box, so the auto margin (not
   `justify-content`) is what pushes it to the far right of the row. */
.gallery-toolbar .sort-container {
    margin-left:auto;
}

/* --- Gallery intro: tag page header, sort beside the last text line ---
 * An ordinary /tag/{tag} page has no in-gallery search, so a separate sort row
 * would waste a whole band of vertical space. Instead the select shares a row
 * with the LAST text line of the header: the description when one exists,
 * otherwise the title (see .gallery-intro-no-desc below). `align-items: start`
 * puts the select's top edge on that line's first baseline. `minmax(0, 1fr)`
 * lets long words wrap instead of pushing the grid wider than the page. */
.gallery-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    column-gap:var(--sp-4);
    row-gap:var(--sp-1);
    margin-bottom:var(--sp-2);
}

/* With a description below it, the title is its own full-width line. */
.gallery-intro .page-heading {
    grid-column: 1 / -1;
    margin-bottom:0;
}

.gallery-intro .sort-container {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
}

/* Inside the intro the row gap and the block's own margin handle the rhythm. */
.gallery-intro .tag-description {
    margin-bottom:0;
}

/* No description: the title IS the last text line, so it gives up the full-width
 * span and the select moves up beside it. Without this the select would be
 * forced into an empty second row and float below the title. */
.gallery-intro-no-desc .page-heading {
    grid-column: 1;
}

.gallery-intro-no-desc .sort-container {
    grid-row: 1;
}

/* Standalone on the home page it is its own right-aligned row; inside a
   .gallery-intro it becomes the right-hand grid cell. */
.sort-container {
    /* No bottom margin of its own: the card grid's lead-in supplies the gap
       below, matching the separator's margin above the row. */
    margin:0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap:10px;
}

.sort-container label {
    color: var(--text-mute);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    font-size: var(--fs-sm);
}

.sort-container select {
    box-sizing: border-box;
    height: var(--control-h);
    /* Vertical padding lives in `height`, so the label centers exactly like the
       search bar's contents do. */
    padding:0 38px 0 14px;
    border: 1px solid var(--border-accent);
    background-color: var(--surface-2);
    /* Dimmed: the chosen mode is a quiet state indicator, not the loudest text on
       the page. Options in the open list keep full contrast. */
    color: var(--text-dim);
    border-radius: var(--r-sm);
    font-size: var(--fs-base);
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: var(--motion-ui), box-shadow var(--dur-base) ease;
}

.sort-container select:hover {
    border-color: var(--accent);
    color: var(--text);
}

.sort-container select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.sort-container option {
    background-color: var(--surface-2);
    color: var(--text);
}

/* --- Faceted search bar (gallery-scoped) --- */
.faceted-search {
    /* basis 0 (not a pixel basis) so the flex line never wraps just because the
       search's *preferred* width plus the sort control exceeds the row;
       min-width still keeps it usable. */
    flex: 1 1 0;
    max-width: 560px;
    min-width: 150px;
    display: flex;
    align-items: center;
    gap: var(--sp-1);
}

.faceted-search-bar {
    display: flex;
    align-items: center;
    gap:8px;
    width: 100%;
    /* Border-box + min-height: the empty bar is exactly as tall as the sort
       select beside it, but it can still grow to fit wrapped entity chips. */
    box-sizing: border-box;
    min-height: var(--control-h);
    position: relative;
    padding:0 var(--sp-2);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    transition: var(--motion-surface);
}

.faceted-search-bar:focus-within {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.faceted-search-icon {
    flex: 0 0 auto;
    color: var(--text-mute);
    pointer-events: none;
}

.faceted-tag-box {
    display: flex;
    flex-wrap: wrap;
    gap:5px;
    align-items: center;
    flex: 1 1 auto;
    min-height: 28px;
    cursor: text;
}

/* The visual focus cue lives on the parent bar via :focus-within. */
.faceted-tag-box.focused {
    outline: none;
}

.faceted-tag-box:has(.faceted-tag-chip) #faceted-query-input::placeholder,
.faceted-tag-box:has(.faceted-tag-chip) .faceted-query-input::placeholder {
    color: transparent;
}

.faceted-tag-chip {
    display: inline-flex;
    align-items: center;
    gap:5px;
    background: var(--accent-tint);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-pill);
    padding:2px  var(--sp-1) 2px 9px;
    font-size: var(--fs-xs);
    white-space: nowrap;
    /* A long entity name must clip inside the bar rather than push the input off
       the line. */
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.faceted-tag-chip .faceted-tag-x {
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    opacity: 0.8;
    border: none;
    background: none;
    color: inherit;
    padding:0 2px;
    font-size: var(--fs-base);
}

.faceted-tag-chip .faceted-tag-x:hover {
    opacity: 1;
}

/* --- Alias parenthetical in the suggestion dropdown --- */
.faceted-alias {
    opacity: 0.7;
    font-size: 0.92em;
}

/* --- Entity type variants for chips ---
 * Three entity types need to be tellable apart at a glance. The old trio went
 * orange / cyan / magenta, three unrelated hues in what is a one-accent theme;
 * the middle one was the only one that earned its place, so now it is two
 * steps of the accent (a filled chip, an outline-only chip) plus the studio
 * amber, which the metadata tag list uses too. The type is also spelled out in
 * the suggestion dropdown ("Performer: ", "Studio: ", "Tag: "), so colour is
 * a secondary cue here, not the only one. */
.faceted-chip-performer {
    background: var(--accent-tint);
    border-color: var(--border-accent);
}

.faceted-chip-studio {
    background: var(--studio-tint);
    border-color: var(--studio-line);
    color: var(--studio);
}

.faceted-chip-tag {
    background: transparent;
    border-color: var(--border);
}

/* --- Entity prefix colours in the suggestion dropdown ---
 * Same three cues as the chips: the prefix is the only coloured part of the
 * row, and it repeats the chip's colour so a suggestion reads as the thing it
 * will become when chosen. */
.faceted-suggestion-performer .faceted-suggestion-prefix {
    color: var(--accent);
}

.faceted-suggestion-studio .faceted-suggestion-prefix {
    color: var(--studio);
}

.faceted-suggestion-tag .faceted-suggestion-prefix {
    color: var(--text-mute);
}

#faceted-query-input,
.faceted-query-input {
    flex: 1 1 auto;
    min-width: 90px;
    border: none;
    background: none;
    background-color: transparent;
    padding:4px 2px;
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-base);
    /* Kill the UA "searchfield" chrome (white pill) on input[type=search]. */
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
}

#faceted-query-input:focus,
.faceted-query-input:focus {
    outline: none;
}

#faceted-query-input::placeholder,
.faceted-query-input::placeholder {
    color: var(--text-mute);
}

.faceted-query-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.faceted-tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: var(--z-sticky);
    margin-top:4px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    box-shadow: var(--elev-2);
    display: none;
}

.faceted-tag-suggestions.open {
    display: block;
}

.faceted-tag-suggestion {
    padding:8px var(--sp-2);
    font-size: var(--fs-sm);
    cursor: pointer;
    color: var(--text-dim);
    transition: background-color var(--dur-fast) ease;
}

.faceted-tag-suggestion.active,
.faceted-tag-suggestion:hover {
    background: var(--accent-tint);
}

.faceted-tag-suggestions .empty {
    padding:8px var(--sp-2);
    font-size: var(--fs-xs);
    opacity: 0.6;
}

.faceted-clear-btn {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--text-mute);
    cursor: pointer;
    padding: var(--sp-1);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--dur-base) ease;
}

.faceted-clear-btn:hover {
    color: var(--accent);
}

.faceted-search-empty {
    padding:var(--sp-3);
    color: var(--text-mute);
    text-align: center;
    font-size: var(--fs-base);
    grid-column: 1 / -1;
}

/* --- Content warning overlay --- */
body.cw-locked {
    overflow: hidden;
}

.cw-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-top);
    display: flex;
    align-items: center;
    justify-content: center;
    padding:24px;
    background: var(--overlay-scrim-light);
    backdrop-filter: blur(24px) saturate(130%);
    -webkit-backdrop-filter: blur(24px) saturate(130%);
    opacity: 1;
    /* The one component that is an effect rather than a property change: it
       dissolves a blurred scrim, so backdrop-filter has to be in the list. It
       keeps a hand-written transition at --dur-slow on purpose. */
    transition: opacity var(--dur-slow) ease,
                backdrop-filter var(--dur-slow) ease,
                -webkit-backdrop-filter var(--dur-slow) ease,
                background var(--dur-slow) ease;
}

.cw-overlay.cw-dismissed {
    opacity: 0;
    background: var(--overlay-scrim-none);
    backdrop-filter: blur(0) saturate(100%);
    -webkit-backdrop-filter: blur(0) saturate(100%);
    pointer-events: none;
}

.cw-card {
    max-width: 520px;
    width: 100%;
    text-align: center;
    padding:var(--sp-4) var(--sp-4);
    background: var(--surface);
    border-radius: var(--r-md);
    border: 1px solid var(--border-accent);
    box-shadow: var(--elev-2);
    transition: var(--motion-reveal);
}

.cw-overlay.cw-dismissed .cw-card {
    transform: translateY(12px);
    opacity: 0;
}

.cw-title {
    font-family: var(--font-title, var(--font-title-default));
    font-size: var(--fs-2xl);
    margin:0 0 var(--sp-2) 0;
    color: var(--text);
}

.cw-message {
    color: var(--text-dim);
    line-height: var(--lh-relaxed);
    margin:0 0 28px 0;
    font-size: var(--fs-lg);
}

.cw-enter {
    padding: var(--sp-2) 44px;
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text);
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    background: var(--accent);
    box-shadow: var(--glow);
    transition: var(--motion-surface);
}

.cw-enter:hover {
    transform: translateY(-2px);
    box-shadow: var(--glow-hover);
}

/* --- Tags directory page ---
 * The directory box lines up with the page heading above it: no
 * max-width/margin:auto, because the container's gutter already caps the
 * measure and centring it is what pulled it out of line on wide windows. */
.tags-shell {
    margin:0 0 var(--sp-3) 0;
}

.tag-directory-count {
    opacity: 0.72;
    margin-left:0.35em;
    font-size: 0.92em;
}
@media (max-width: 768px) {
    /* Keep everything on ONE single row: [Logo] [Search (stretches)] [Menu] */
    .topbar {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "logo search menu";
        row-gap:0;
        column-gap:var(--sp-2);
        align-items: center;
    }

    .topbar-logo {
        flex-shrink: 0;
    }

    .topbar-logo img {
        height: 48px;
        width: auto;
        max-width: 100px; /* bounds a narrow logo */
        object-fit: contain;
    }

    .topbar-search {
        grid-area: search;
        margin-left:var(--sp-1);
        min-width: 0;
        width: 100%;
        justify-content: stretch;
    }

    .global-search {
        width: 100%;
        max-width: 100%;
        min-width: 0; /* lets the search shrink flexibly without forcing row breaks */
    }

    .topbar-actions {
        display: none; /* actions tuck cleanly into the hamburger menu */
    }

    .topbar-menu {
        grid-area: menu;
        margin-left:var(--sp-1);
        justify-self: end;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .faceted-search-bar {
        max-width: 100%;
    }
    /* Phones: the intro's two columns collapse, so the select would otherwise sit
       beside a very narrow prose column. Stack it under the description as a
       right-aligned row, and drop the now-obvious "Sort by:" label. */
    .gallery-intro {
        grid-template-columns: minmax(0, 1fr);
        row-gap:var(--sp-2);
    }
    .gallery-intro .sort-container {
        grid-column: 1;
        grid-row: auto;
        justify-self: end;
    }
    .sort-container label {
        display: none;
    }
    .sort-container select {
        padding:0 30px 0 10px;
        background-position: right 9px center;
    }
    .faceted-search {
        min-width: 120px;
    }
    #faceted-query-input,
    .faceted-query-input {
        min-width: 60px;
    }
}

/* ==========================================================================
   Video-player metadata and details pane

   The one place in this file where box values are NOT on the --sp scale,
   because they are coordinated with code outside the stylesheet:

     * `.details-grid`'s two column minimums plus its gap sum to the
       `@container` threshold, so the grid stacks at exactly the width where the
       divider disappears. Change all three or none of them; the guard
       `test_details_grid_minimums_sum_to_the_query` enforces the equation.
     * `.metadata-columns` / `.metadata-col` gap and `.video-metadata`
       min-width are mirrored as constants in metadata-masonry.js.

   Keep this section's literals and the reason above will keep making sense.
   ========================================================================== */

/* --- Video Player Metadata --- */
.video-metadata {
    flex: 1 1 320px;
    min-width: 240px;
    padding:30px;
    background: var(--surface);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--elev-1);
}

.video-title {
    font-family: var(--font-title, var(--font-title-default));
    font-size: var(--fs-lg);
    font-weight: 600;
    line-height: var(--lh-tight);
    margin-top:0px;
    margin-bottom:var(--sp-3);
    text-align: center;
    /* Wrap onto multiple lines instead of shrinking to stay on one line. */
    white-space: normal;
    letter-spacing: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Description stays a direct child of .metadata-grid (above the masonry
   columns), so as a block it already spans the full width; the shared
   .metadata-section rules provide its padding / background / border. */

.video-description h3 {
    margin-bottom:var(--sp-1);
    font-size: var(--fs-md);
}

.video-description .markdown-body {
    margin:0;
}

/* Related Videos: one horizontal strip of natural-aspect-ratio thumbnails.
   Every image is 180px tall and keeps its own width; the viewport, not the
   image, clips the strip. Edge fades shade partially occluded cards while the
   card nearest the center gets a restrained gloss and elevation highlight. */
.related-videos-viewport {
    --related-left-fade: 0;
    --related-right-fade: 0;
    position: relative;
    height: 180px;
    overflow: hidden;
}

.related-videos-viewport::before,
.related-videos-viewport::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 48px;
    z-index: var(--z-content);
    pointer-events: none;
}

.related-videos-viewport::before {
    left: 0;
    background: linear-gradient(to right, var(--surface-2), transparent);
    opacity: var(--related-left-fade);
}

.related-videos-viewport::after {
    right: 0;
    background: linear-gradient(to left, var(--surface-2), transparent);
    opacity: var(--related-right-fade);
}

.related-videos-scroll {
    height: 180px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-tint-strong) transparent;
    scroll-behavior: auto;
}

.related-videos-grid {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    width: max-content;
    min-width: 100%;
    padding: 0 var(--sp-1);
}

.related-videos-grid .video-card {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    border-radius: var(--r-sm);
    transition: var(--motion-surface);
}

.related-videos-grid .video-card:hover {
    transform: none;
}

.related-videos-grid .video-card.is-center {
    border-color: var(--border-accent);
    box-shadow: var(--elev-lift), var(--inset);
}

.related-videos-grid .video-card.is-center::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 25%, var(--accent-tint) 50%, transparent 75%);
    pointer-events: none;
    z-index: var(--z-raised);
}

.related-videos-grid .video-card .thumb {
    display: block;
    height: 180px;
    width: max-content;
    min-width: 0;
}

.related-videos-grid .video-card img {
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    height: 180px;
    object-fit: contain;
}

.related-videos-grid .video-card img.preview-webp {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.related-videos-grid .video-card .title {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--sp-1);
    font-size: var(--fs-sm);
    background: var(--overlay-scrim);
    color: var(--text);
}

.related-videos-grid .duration-badge {
    top: var(--sp-1);
    right: var(--sp-1);
    bottom: auto;
    padding: 2px var(--sp-1);
}

.related-videos-grid .duration-badge .clock-icon {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .related-videos-grid .video-card {
        transition: none;
    }
}

/* Shared Markdown typography (video descriptions + static pages).
 *
 * It lives in this section only because the original slice was drawn around the
 * metadata pane, which swallowed it. The rules are not player-specific — the
 * static Markdown pages and every video description use them — and they share no
 * box values with the coordination list above, so they are safe to edit freely. */
.markdown-body {
    line-height: var(--lh-relaxed);
/*    color: var(--text-dim); */
    overflow-wrap: break-word;
    word-break: break-word;
}

.markdown-body > :first-child {
    margin-top:0;
}

.markdown-body > :last-child {
    margin-bottom:0;
}

/* Tag / collection gallery description (rendered Markdown from Stash).
 * Left aligned so it reads as a caption to the gallery rather than a banner. */
.tag-description {
    /* No max-width of its own: inside .gallery-intro the text column already
       bounds the measure (and leaves room for the sort control beside it), so a
       one-sentence tagline stays on ONE line instead of wrapping against a
       fixed character count. */
    margin:0 0 var(--sp-3);
    text-align: left;
/*    font-size: 1rem; */
/*    line-height: 1.6; */
    color: var(--text);
}

.tag-description :is(ul, ol, table, pre, blockquote) {
    text-align: left;
}

/* Cap heading sizes so a `# Big Title` inside a tag description doesn't fight
 * the page's own <h1>{{ tag_name }}</h1>. */
.tag-description :is(h1, h2, h3, h4) {
    font-size: var(--fs-md);
    margin:0.5em 0;
    text-align: left;
}

/* First/last paragraph flush against the box edges so the overall vertical
   rhythm matches what the inline-styled version had. */
.tag-description p:first-child { margin-top:0; }
.tag-description p:last-child  { margin-bottom:0; }

/* Embedded images never exceed the bounds of their container, and scale down
   proportionally on narrow viewports. height:auto preserves aspect ratio when a
   width attribute is present on the <img>. */
.markdown-body img {
    max-width: 100%;
    height: auto;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote,
.markdown-body table {
    margin:0 0 1em;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    margin:1.25em 0 0.5em;
    color: var(--text);
    font-weight: 600;
    line-height: var(--lh-tight);
}

/* Three distinct steps against a --fs-md body. h3 lands on the body size and is
   separated by weight and colour instead, which is how every other third-level
   heading on the site reads. */
.markdown-body h1 { font-size: var(--fs-2xl); }
.markdown-body h2 { font-size: var(--fs-lg); }
.markdown-body h3 { font-size: var(--fs-md); }

.markdown-body a {
    color: var(--accent-soft);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.markdown-body a:hover {
    color: var(--accent);
}

.markdown-body strong {
    color: var(--text);
    font-weight: 600;
}

.markdown-body del {
    text-decoration: line-through;
    opacity: 0.85;
}

.markdown-body code {
    font-family: var(--font-mono, var(--font-mono-default));
    /* em, not a ramp step: inline code must track the prose size around it. */
    font-size: 0.9em;
    background: var(--accent-tint);
    padding:0.15em 0.35em;
    border-radius: var(--r-sm);
}

.markdown-body pre {
    background: var(--overlay-scrim);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding:var(--sp-2) 14px;
    overflow-x: auto;
}

.markdown-body pre code {
    background: none;
    padding:0;
}

.markdown-body blockquote {
    border-left: 3px solid var(--border-accent);
    margin-left:0;
    padding:0.25em 0 0.25em 1em;
    color: var(--text-mute);
}

.markdown-body ul,
.markdown-body ol {
    padding-left:1.4em;
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin:1.5em 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border);
    padding:8px 10px;
    text-align: left;
}

.markdown-body th {
    background: var(--accent-tint);
    color: var(--text);
}

.markdown-page {
    max-width: 800px;
    margin:var(--sp-3) auto var(--sp-4);
    padding:var(--sp-3) 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.markdown-page-title {
    margin:0 0 var(--sp-3);
    font-size: var(--fs-2xl);
    font-weight: 400;
    color: var(--text);
}

/* True masonry layout. metadata-masonry.js distributes the .metadata-section
   boxes into .metadata-col columns, dropping each box into the currently
   shortest column so a short box (e.g. Details) rises to fill the vertical gap
   a taller neighbour (e.g. Tags) would otherwise leave under it. A plain CSS
   grid keeps rows aligned (leaving the gap), and CSS multi-column is
   column-major (it can't lift a later box into an earlier column), so neither
   gives this. Before/without JS the boxes just stack vertically, which is fine.

   The `>` selector supplies the inter-box gap ONLY while the boxes are direct
   children of .metadata-grid (the no-JS stack, and the full-width Description
   which the script leaves in place above the columns). Once the script moves a
   box into a .metadata-col it's no longer a direct child, so the column's own
   `gap` spaces it instead. */
.metadata-grid > .metadata-section {
    margin-bottom: var(--sp-3);
}

.metadata-columns {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
}

.metadata-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.metadata-section {
    background: var(--surface-2);
    padding: var(--sp-2)  var(--sp-3)  var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

/* A section heading, not a form label: no caps. The uppercase voice belongs to
   micro-labels only, and this is the most visible misuse of it on the site. */
.metadata-section h3 {
    margin:0 0 8px;
    color: var(--text-mute);
    font-size: var(--fs-md);
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
}

.metadata-list {
    display: flex;
    flex-direction: column;
    gap:10px;
}

.details-section {
    /* The Details box is sized by the masonry column, not the viewport, so the
       inner two-column grid must respond to the BOX's width. A viewport media
       query fires far too late: at ~490px the box still had two ~200px columns
       and "RESOLUTION: 1440x1080" overflowed. */
    container-type: inline-size;
}

.details-grid {
    display: grid;
    /* Each column is sized to its OWN widest field, not to a shared minimum.
       Measured intrinsic widths (label + 8px gap + value, unwrapped):
         left  — Views 84, Rating 105, Date 102, Uploaded 170  -> 170px
         right — Length 94, Resolution 182, Links 115          -> 182px
       Equal `1fr` columns forced both to 182px, so the left column's slack was
       unusable and the layout collapsed while there was still room.

       Per-column minimums let the pair fit at 102 + 12 + 114 = 228px, which is
       also the @container threshold below — that equality is the whole point.
       Above it, the `1fr` maxima share the surplus evenly.

       NOTE: the minimums sit 68px below each column's measured intrinsic width
       (170 and 182), so the columns are deliberately allowed to be narrower
       than their content. That is intentional — it keeps two columns at widths
       where the values would otherwise wrap. If a value starts wrapping, raise
       these two numbers *and* the @container threshold to match. */
    grid-template-columns: minmax(102px, 1fr) minmax(114px, 1fr);
    column-gap:var(--sp-2);
}

.details-left,
.details-right {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 0;
}

.details-right {
    border-left: 1px solid var(--border);
    padding-left:var(--sp-2);
}

/* The two-column minimums above need 102 + 12 + 114 = 228px of content. This
   query uses that SAME 228px figure and the exclusive `<` range, so the grid
   collapses and the divider disappears at exactly the same width. The earlier
   bug was two thresholds one pixel apart (collapse at 372, divider removed at
   371), which left a 1px window where the grid had already stacked but the
   divider still drew — the stray vertical line beside the last few rows.

   In the stacked layout the divider is removed entirely rather than rotated
   into a horizontal rule, which read as a stray bar under the last left-hand
   field. */
@container (width < 228px) {
    .details-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .details-right {
        border-left: 0;
        padding-left:0;
    }
}

.details-field {
    display: flex;
    align-items: baseline;
    gap:8px;
    min-width: 0;
}

.details-label {
    flex: 0 0 auto;
    color: var(--text-mute);
    font-size: var(--fs-xs);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    white-space: nowrap;
}

/* This used to read `font: var(--font-mono-default)`, an invalid `font`
   shorthand (no size, no family fallback), so the whole declaration was
   dropped and every value lost both the mono face and its size. */
.details-value {
    flex: 1 1 auto;
    font-family: var(--font-mono, var(--font-mono-default));
    font-size: var(--fs-sm);
    min-width: 0;
    text-align: right;
}

/* Links wrap across the full width of the right column, so a wrapped chip can
   sit under the label instead of being confined to the value column. */
.details-links-field {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: baseline;
    gap:3px 8px;
}

.details-links-field .details-label {
    margin-right:auto;
}

.details-links {
    display: contents;
}

.metadata-item {
    display: flex;
    flex-direction: column;
    gap:5px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}

/* A tag list is a list of links, not the loudest text on the page. At body
   size in --text it out-shouted the video title it sits under, so the chips
   drop a ramp step and a tone: --fs-xs in --text-dim, lifting to full --text
   only on hover.

   Type is told apart by fill and colour, matching the faceted-search chips
   beside the search bar: performer is the accent base, studio is the amber the
   catalogue has always used for studios, tag is outline-only.
   .tag-item-performer therefore has no rule of its own — it IS the base. */
.tag-item {
    padding:4px 8px;
    border-radius: var(--r-sm);
    background: var(--accent-tint);
    color: var(--text-dim);
    font-size: var(--fs-xs);
    text-decoration: none;
    border: 1px solid var(--border-accent);
    transition: var(--motion-ui);
}

.tag-item:hover {
    background: var(--accent-tint-mid);
    border-color: var(--accent);
    color: var(--text);
}

.tag-item-studio {
    background: var(--studio-tint);
    border-color: var(--studio-line);
    color: var(--studio);
}

/* Same specificity as .tag-item:hover, one step later in the file, so the
   studio keeps its own fill and border instead of inheriting the accent's.
   The colour is restated because `.tag-item:hover` sets it too: without that
   line the amber chip would turn near-white on hover and stop reading as a
   studio, which is the whole reason the variant exists. */
.tag-item-studio:hover {
    background: var(--studio-tint-mid);
    border-color: var(--studio);
    color: var(--studio-soft);
}

.tag-item-tag {
    background: transparent;
    border-color: var(--border);
    color: var(--text-mute);
}

.tag-item-tag:hover {
    background: transparent;
    border-color: var(--border-accent);
    color: var(--text-dim);
}

.detail-link {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-mute);
    font-size: var(--fs-xs);
    line-height: 1.35;
    text-decoration: none;
    transition: var(--motion-ui);
}

.detail-link:hover {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.external-link {
    color: var(--accent-soft);
    text-decoration: none;
    word-break: break-all;
    transition: var(--motion-ui);
    padding:5px 0;
}

.external-link:hover {
    color: var(--accent);
}

/* Responsive adjustments for metadata. The title used to grow to 1.5rem here,
   which was backwards: it now holds one ramp step at every width. */
@media (max-width: 768px) {
    .video-metadata {
        padding:var(--sp-3);
    }

    /* metadata-masonry.js derives the column count from the available width, so
       it collapses to a single column on narrow screens on its own. */
}

/* ==========================================================================
   End video-player metadata and details pane
   ========================================================================== */

/* ==========================================================================
   Cactus Comments — layout and site overrides

   The vendor sheet (below) is unmodified. These rules are the site's own skin
   on top of it: they read the --cactus-* bridge defined in the token block, so
   the comment widget follows the theme without any of its rules being edited.
   `!important` is retained wherever it overrides a vendor declaration of equal
   specificity from that later sheet.
   ========================================================================== */

/* Comments span the full width as a row below the metadata grid: the feed on
   the left at two thirds, the editor on the right at one third. */
.comments-shell {
    max-width: 80vw;
    margin: var(--sp-3) auto 0;
    width: 100%;
    box-sizing: border-box;
    padding-top:24px;
}

/* Elm's root node: lay its two children side by side. */
.comments-shell .cactus-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap:var(--sp-3) !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* The two panes are the same card; only their proportions differ. */
.comments-shell .cactus-comments-container,
.comments-shell .cactus-editor {
    min-width: 0 !important;
    max-width: 100%;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface-2);
    padding:var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.comments-shell .cactus-comments-container {
    order: 1;
    flex: 2 1 66.666%;
    gap:var(--sp-1) !important;
}

.comments-shell .cactus-editor {
    order: 2;
    flex: 1 1 33.333%;
    gap:10px !important;
}

/* Section labels. Both panes used to repeat the same six declarations; the
   `content` is left unwritten because the markup supplies the visible heading. */
.comments-shell .cactus-comments-container::before,
.comments-shell .cactus-editor::before {
    display: block;
    font-family: var(--font-title, var(--font-title-default));
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: var(--tracking-caps);
    color: var(--text);
    text-align: center;
    margin-bottom:5px;
}

/* Stack vertically on narrow screens; the feed still comes first. */
@media (max-width: 768px) {
    .comments-shell .cactus-container {
        flex-direction: column !important;
    }

    .comments-shell .cactus-comments-container,
    .comments-shell .cactus-editor {
        flex: 1 1 100%;
    }
}

/* Login is a modal, not a pane: take it out of the flex flow entirely so the
   row/order rules above never reach it. The vendor base sheet that normally
   supplies this is not linked. */
.cactus-login-form-wrapper {
    position: fixed !important;
    inset: 0 !important;
    z-index: var(--z-top) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding:24px;
    background: var(--overlay-scrim);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    order: initial !important;
    flex: initial !important;
    width: auto !important;
}

.cactus-login-form {
    position: relative;
    display: flex;
    flex-direction: column;
    gap:var(--sp-3);
    width: 100%;
    max-width: 340px;
    box-sizing: border-box;
    padding: var(--sp-4) 28px;
    background: var(--surface) !important;
    border: 1px solid var(--border-accent) !important;
    border-radius: var(--r-md) !important;
    box-shadow: var(--elev-2) !important;
    color: var(--text-dim);
}

.cactus-login-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding:4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-sm) !important;
    color: var(--text-mute) !important;
    cursor: pointer;
}

.cactus-login-close:hover {
    color: var(--accent) !important;
    border-color: var(--border-accent) !important;
}

.cactus-login-close-icon {
    width: 14px !important;
    height: 14px !important;
}

.cactus-login-title {
    margin:0;
    font-size: var(--fs-lg);
    text-align: center;
    color: var(--text) !important;
    font-family: var(--font-title, var(--font-title-default));
}

.cactus-login-client,
.cactus-login-credentials {
    display: flex;
    flex-direction: column;
    gap:10px;
}

.cactus-login-client-title,
.cactus-login-credentials-title {
    margin:0;
    font-size: var(--fs-sm);
    color: var(--text-mute) !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

.cactus-login-field {
    display: flex;
    flex-direction: column;
    gap:4px;
}

.cactus-login-label {
    font-size: var(--fs-xs);
    color: var(--text-mute);
}

.cactus-login-error {
    font-size: var(--fs-xs);
    color: var(--cactus-error-color, var(--accent-soft));
    margin:0;
}

/* The Matrix link is an <a>, not a <button>, but it must read as one. */
.cactus-matrixdotto-button {
    font-family: var(--font-button, var(--font-button-default));
    text-decoration: none;
    text-align: center;
}

/* --- Shrink to fit: kill the vendor's own min-widths ---
 * Several Cactus nodes carry an intrinsic min-width sized for its default
 * centred column, which overflows the feed pane. Every one of them is told to
 * shrink and to break long words instead. */
.cactus-editor-textarea,
.cactus-editor-below,
.cactus-editor-name,
.cactus-editor-name > span,
.cactus-editor-name > span > input,
.cactus-comment,
.cactus-comment-content,
.cactus-message-text {
    box-sizing: border-box !important;
    max-width: 100% !important;
    min-width: 0 !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

.cactus-editor-name > span {
    min-inline-size: 0 !important;
    max-inline-size: 100% !important;
    width: 100% !important;
}

.cactus-editor-below {
    display: flex !important;
    flex-direction: column !important;
    gap:var(--sp-1) !important;
}

.cactus-editor-buttons {
    display: flex !important;
    gap:var(--sp-1) !important;
    justify-content: flex-end !important;
}

/* --- Inputs --- */
.cactus-editor-textarea {
    width: 100% !important;
    min-height: 100px !important;
    background: var(--bg) !important;
    border: 1px solid var(--border-accent) !important;
    border-radius: var(--r-sm) !important;
    color: var(--text) !important;
    padding:8px 10px !important;
    font-family: inherit !important;
    /* Body size, not --fs-sm: this is the one field a visitor types a whole
       comment into, and it read a step smaller than the prose it produces. */
    font-size: var(--fs-base) !important;
    resize: vertical;
}

.cactus-editor-textarea:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: var(--ring) !important;
    background: var(--surface) !important;
}

.cactus-editor-textarea::placeholder {
    color: var(--text-mute) !important;
    font-size: var(--fs-xs) !important;
    line-height: 1.4 !important;
    text-align: left !important;
}

/* The name field is a bare <input> inside .cactus-editor-name > span. A form
   control does NOT inherit the page's font the way text does: this rule used
   to set every property of the field EXCEPT font-family, and a browser only
   gives an <input> the page's typeface when one is inherited into it or
   declared on it. So the width, fill, border and radius were the site's while
   the type was the UA's default control font (Arial, ~13.3px) — the one
   typeface on the site that appears nowhere else.

   The selector also mirrors upstream's `.cactus-editor-name>span>input` so the
   two rules have equal weight and the result does not depend on which of them
   carries !important. Every property a text field needs is declared here
   rather than relied on to inherit. */
.cactus-editor-name > span > input,
.cactus-login-field > input {
    width: 100% !important;
    background: var(--bg) !important;
    border: 1px solid var(--border-accent) !important;
    border-radius: var(--r-sm) !important;
    color: var(--text) !important;
    padding: var(--sp-1) 10px !important;
    font-family: inherit !important;
    font-size: var(--fs-base) !important;
    box-sizing: border-box !important;
}

.cactus-editor-name > span > input::placeholder,
.cactus-login-field > input::placeholder {
    color: var(--text-mute) !important;
    font-family: inherit !important;
    font-size: var(--fs-base) !important;
    opacity: 1 !important; /* Firefox dims placeholders on its own */
}

.cactus-editor-name > span > input:focus,
.cactus-login-field > input:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: var(--ring) !important;
}

/* --- Buttons ---
 * These mirror the footer's secondary pill. The vendor sheet styles buttons
 * with its own gradient and lift, so each declaration here is forced. */
.cactus-button {
    font-family: var(--font-button, var(--font-button-default)) !important;
    display: inline-block !important;
    background: var(--surface-2) !important;
    color: var(--text-mute) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-sm) !important;
    padding:8px 16px !important;
    font-size: var(--fs-xs) !important;
    font-weight: 500 !important;
    letter-spacing: var(--tracking-caps) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: var(--motion-ui) !important;
}

.cactus-button::before {
    content: none !important;
}

.cactus-button:hover:not([disabled]) {
    transform: none !important;
    filter: none !important;
    box-shadow: none !important;
    color: var(--accent) !important;
    background: var(--accent-tint) !important;
    border-color: var(--border-accent) !important;
}

.cactus-button:active:not([disabled]) {
    transform: none !important;
}

/* Send is the one primary action in the editor. */
.cactus-send-button {
    color: var(--accent-soft) !important;
    border-color: var(--border-accent) !important;
}

.cactus-send-button:hover:not([disabled]) {
    color: var(--accent) !important;
    background: var(--accent-tint) !important;
    border-color: var(--accent) !important;
}

.cactus-send-button:focus-visible {
    outline: none !important;
    box-shadow: var(--ring) !important;
}

.cactus-send-button[disabled] {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

/* --- Comment feed items --- */
.cactus-comment {
    display: flex;
    gap:10px;
    padding-top:9px;
    padding-bottom:var(--sp-2);
    border-bottom: 1px solid var(--border) !important;
}

.cactus-comment:last-child {
    border-bottom: none !important;
    padding-bottom:0;
}

.cactus-comment-displayname {
    color: var(--accent-soft) !important;
    font-weight: 600 !important;
    font-size: var(--fs-sm) !important;
    text-decoration: none !important;
}

.cactus-comment-displayname:hover {
    color: var(--accent) !important;
    text-decoration: underline !important;
}

.cactus-comment-time {
    color: var(--text-mute) !important;
    font-size: var(--fs-xs) !important;
    margin-left: var(--sp-1);
}

.cactus-message-text {
    color: var(--text-dim) !important;
    font-size: var(--fs-sm) !important;
    line-height: 1.4 !important;
    margin-top:2px;
}

/* The Matrix-only affordance: nearly invisible until you look for it. */
.cactus-matrixdotto-only {
    opacity: 0.4;
    transition: opacity var(--dur-base) ease;
}

.cactus-matrixdotto-only:hover {
    opacity: 0.9;
}

/* --- Avatar --- */
.cactus-comment-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap:4px;
    flex-shrink: 0; /* Prevent squishing in flex layouts */
}

.cactus-comment-avatar > * {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin:0;
}

/* The JS writes background-image on this node once it has fetched the blob. */
.cactus-comment-avatar > [data-mxc-url] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    /* Hide any text content while loading */
    color: transparent;
    font-size: 0;
}

.cactus-comment-avatar-placeholder {
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-mute);
    font-size: var(--fs-xs);
    line-height: 1;
}

.cactus-comment-avatar-placeholder::before {
    content: "?";
}

/* Reply: a small ghost square, not the vendor's pink oval. */
.cactus-comment-reply-button {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    color: var(--text-mute) !important;
    width: 24px;
    height: 24px;
    padding:0;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin:0;
    flex-shrink: 0;
}

.cactus-comment-reply-button:hover {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border-accent) !important;
}

.cactus-comment-reply-button svg {
    width: 12px;
    height: 12px;
    display: block;
}

.cactus-message-text a {
    color: var(--accent-soft);
    text-decoration: none;
    word-break: break-all;
    transition: color var(--dur-base) ease;
    padding:5px 0;
}

.cactus-message-text a:hover {
    color: var(--accent);
}

/* ==========================================================================
   Vendored Cactus Comments base sheet.

   Upstream CSS, kept as close to verbatim as is useful so a future upgrade can
   be diffed against the source. It still reads ONLY the --cactus-* bridge
   tokens, never the site vocabulary; `test_cactus_bridge_tokens_are_complete`
   pins that.

   Deliberate divergences from upstream, all local defects rather than design:

     * a dead `.join-conversation` rule (plus its :hover) that had been
       appended to the end of the sheet was removed;
     * `.cactus-comment-reply-link .cactus-reply-blockquote` and its inner
       p/span/em reset shipped TWICE, verbatim. Collapsed to one;
     * `.cactus-editor-replying-to` used a nested `p { }` rule (CSS Nesting);
       rewritten as a plain child selector so it works everywhere;
     * `.cactus-comment-highlighted` carried the block's only `!important` and
       a 0.75s transition; both are gone.

   Two-space indentation is upstream's and is preserved.
   ========================================================================== */
/*
 * ***** ERROR *****
 */
/* error message */
.cactus-error {
  padding:0.5em;
  padding-inline-end: 1.5em;
  border: var(--cactus-border-width) solid var(--cactus-error-color);
  border-radius: var(--cactus-border-radius);
  /* for absolutely positioned close button */
  position: relative;
}

/* close button */
.cactus-error-close {
  position: absolute;
  right: 0.2em;
  top: 0em;
  color: var(--cactus-button-color);
  /* todo: remove after using all: unset */
  background-color: transparent;
  border: none;
}

.cactus-error-close:hover:not([disabled]) {
  color: var(--cactus-button-color--strong);
  cursor: pointer;
}

.cactus-error-close:active:not([disabled]) {
  color: var(--cactus-button-color--stronger);
  cursor: pointer;
}

.cactus-error-close-icon {
  inline-size: 20px;
  block-size: 20px;
}

/* error message */
.cactus-error-text {
  color: var(--cactus-error-color);
  font-weight: bold;
  /* todo: remove after using all: unset */
  margin:0;
}

.cactus-comment-reply-link {
  color: var(--cactus-text-color--soft); /* Use a softer text color */
  cursor: pointer;
  text-decoration: none; /* Remove underline if it appears by default on divs with onClick */
  display: inline-block; 
  font-size: .9em;
  padding:.1em;
  margin-left:0.5em; /* Space from time/displayname */
}

.cactus-comment-reply-link .cactus-reply-blockquote {
  display: inline-block; /* To keep it in line with other header elements */
  border-left: 3px solid var(--cactus-button-color--strong); /* Using a theme color, adjust as needed. Screenshot implies purple. */
  padding-left:0.5em;
  margin:0.1em 0; /* Small vertical margin */
  font-size: 0.9em; /* Slightly smaller than normal text */
  color: var(--cactus-text-color--soft); /* Softer color for quoted text */
  background-color: transparent; /* Ensure no unexpected background */
  cursor: pointer; /* Inherit cursor from parent link */
}

.cactus-comment-reply-link .cactus-reply-blockquote p,
.cactus-comment-reply-link .cactus-reply-blockquote span,
.cactus-comment-reply-link .cactus-reply-blockquote em {
    margin:0; /* Reset margins for inner elements */
    padding:0; /* Reset paddings for inner elements */
    font-style: normal; /* Override em if displayedLinkText was wrapped in it */
}


.cactus-comment-reply-link:hover .cactus-reply-blockquote {
  border-left-color: var(--cactus-button-color--stronger); /* Darken border on hover */
  color: var(--cactus-text-color);
}

/*
 * ***** EDITOR REPLYING TO *****
 */
.cactus-editor-replying-to {
  display: flex;
  align-items: center;
  background-color: var(--cactus-button-color);
  border-radius: var(--cactus-border-radius) var(--cactus-border-radius) 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  width: fit-content;
  max-width: 100%;
}

/* Upstream wrote this as a nested `p { }` inside the rule above, which is CSS
   Nesting and unsupported in older browsers. Same result as a child selector. */
.cactus-editor-replying-to p {
  margin-bottom:auto;
  margin-top:auto;
}

.cactus-editor-cancel-reply {
  background-color: transparent;
  border: none;
  color: var(--cactus-text-color--soft);
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width:30px;
  padding:5px;
}

.cactus-editor-cancel-reply:hover {
  background-color: var(--cactus-button-color);
  color: var(--cactus-button-text-color);
}

.cactus-editor-cancel-reply svg {
  width: 1em;
  height: 1em;
  display: block;
}

.cactus-message-emote {
  padding-top:0.5em;
  color: var(--cactus-text-color--soft);
}

.cactus-message-image {
  max-width: 100%;
  height: auto;
}

.cactus-message-file {
  line-height: 3em;
  margin-left:1em;
}

.cactus-message-video,
.cactus-message-audio {
  max-width: 100%;
}


/*
 * ***** LOADING SPINNER *****
 */
 .spinner {
  align-self: center;
  width: 2em;
  height: 2em;
  display: flex;
  gap:0.3em;
}

.spinner > div {
  flex: 1;
  background-color: var(--cactus-border-color);
  animation: sk-stretchdelay 2.4s infinite ease-in-out;
}

.spinner .rect2 {
  animation-delay: -2.2s;
}

.spinner .rect3 {
  animation-delay: -2.0s;
}

.spinner .rect4 {
  animation-delay: -1.8s;
}

@keyframes sk-stretchdelay {
  0%, 40%, 100% { 
    transform: scaleY(0.4);
  }  20% { 
    transform: scaleY(1.0);
  }
}

/* Highlight for a comment that was just scrolled to */
.cactus-comment-highlighted {
  background-color: var(--cactus-button-color);
}

/* contains the view-more button */
.cactus-view-more {
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   End vendored Cactus Comments base sheet
   ========================================================================== */

/* ==========================================================================
   File Drop page (static/filedrop.html)

   The uploader. Its markup lives in static/filedrop.html; layout and component
   styling live here, on the shared tokens, so the page follows the theme like
   every other page. The page sits inside the framed .container with the shared
   top bar above and the shared footer below, exactly like the static Markdown
   pages — so nothing here touches html/body, the container, or overflow.
   ========================================================================== */

/* The card mirrors .markdown-page: a framed surface, centred, one step in from
   the container edge. */
.filedrop-page {
    max-width: 720px;
    margin: var(--sp-3) auto 40px;
    padding:24px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.filedrop-page-title {
    margin:0 0 var(--sp-3);
    font-size: var(--fs-2xl);
    font-weight: 400;
    color: var(--text);
}

.filedrop-intro {
    color: var(--text-dim);
    margin:0 0 var(--sp-2);
}

/* Password pane: same card, narrower content column. */
.filedrop-locked {
    max-width: 400px;
}

.filedrop-form {
    display: flex;
    flex-direction: column;
    gap:var(--sp-2);
}

.filedrop-form label {
    color: var(--text-mute);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    margin:0;
}

.filedrop-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding:10px  var(--sp-2);
    background: var(--bg);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-base);
    transition: var(--motion-surface);
}

.filedrop-form input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.filedrop-form button[type="submit"] {
    width: 100%;
    padding:10px 16px;
    background: var(--accent);
    border-color: transparent;
    color: var(--text);
}

.filedrop-form button[type="submit"]:hover {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--text);
}

/* --- Drop target --- */
.dropzone {
    border: 2px dashed var(--border-accent);
    border-radius: var(--r-md);
    padding:28px 24px; /* ~25% shorter than before to leave room below */
    text-align: center;
    cursor: pointer;
    transition: var(--motion-ui);
    background: var(--surface-2);
}

.dropzone.dragover {
    background: var(--accent-tint);
    border-color: var(--accent);
}

.dropzone p {
    margin: var(--sp-1) 0;
    color: var(--text-dim);
}

.dropzone .hint {
    font-size: var(--fs-sm);
    color: var(--text-mute);
}

#file-input {
    display: none;
}

/* --- Upload queue --- */
.upload-list {
    list-style: none;
    padding:0;
    margin: var(--sp-3) 0 0;
}

.upload-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: var(--sp-2) 16px;
    margin-bottom:10px;
}

.upload-item .name {
    font-weight: 600;
    word-break: break-all;
    font-size: var(--fs-sm);
    color: var(--text-dim);
}

/* Preview thumbnail shown ASAP — for uploads it's grabbed from the local video
   file before/while it uploads; for scrapes it's the source image. Both are the
   same frame at two different height caps. */
.preview-thumb,
.scrape-preview-thumb {
    display: none;
    width: 100%;
    object-fit: contain;
    border-radius: var(--r-sm);
    background: var(--bg);
    border: 1px solid var(--border);
}

.preview-thumb {
    max-height: 220px;
    margin:10px 0 4px;
}

.scrape-preview-thumb {
    max-height: 260px;
    margin:4px 0;
}

.preview-thumb.ready,
.scrape-preview-thumb.ready {
    display: block;
}

.upload-item .status {
    font-size: var(--fs-sm);
    color: var(--text-mute);
    margin-top:var(--sp-1);
}

.upload-item .status.done {
    color: var(--accent-soft);
}

.upload-item .status.error,
.save-note.error,
.scrape-status.error {
    color: var(--accent-soft);
}

.progress-track {
    height: 6px;
    background: var(--surface-scrim);
    border-radius: var(--r-sm);
    margin-top:var(--sp-1);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    transition: width var(--dur-base);
}

.upload-item label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin:var(--sp-1) 0 3px;
}

.upload-item input[type="text"],
.upload-item textarea {
    width: 100%;
    box-sizing: border-box;
    padding:8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: var(--fs-base);
}

.upload-item textarea {
    resize: vertical;
    min-height: 48px;
}

.upload-item input:focus,
.upload-item textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.detail-row {
    margin-top:var(--sp-2);
    display: flex;
    gap:10px;
    align-items: center;
    flex-wrap: wrap;
}

.detail-row button {
    padding:8px 16px;
    white-space: nowrap;
}

.detail-row button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.detail-row button.completed {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent);
}

.save-note {
    font-size: var(--fs-xs);
    color: var(--text-mute);
}

.save-note.saved {
    color: var(--accent-soft);
}

.result-link {
    display: block;
    margin-top:var(--sp-1);
    font-size: var(--fs-base);
}

.result-link a {
    color: var(--accent-soft);
    font-weight: 600;
    text-decoration: none;
}

.result-link a:hover {
    text-decoration: underline;
    color: var(--accent);
}

.result-link .pwd-note {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin-top:3px;
    word-break: break-all;
}

.detail-row a.view-button {
    display: inline-block;
    padding:8px 16px;
    background: var(--accent-tint);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    color: var(--accent-soft);
    font-weight: 600;
    text-decoration: none;
}

.detail-row a.view-button:hover {
    background: var(--accent-glow);
    color: var(--text);
}

.upload-result {
    margin-top:var(--sp-2);
}

/* --- Generated share password --- */
.pwd-row {
    display: flex;
    align-items: center;
    gap:10px;
    flex-wrap: wrap;
}

.pwd-display {
    font-family: var(--font-mono, var(--font-mono-default));
    font-size: var(--fs-2xl);
    color: var(--text);
    letter-spacing: var(--tracking-caps);
    word-break: break-all;
}

.copy-pwd-btn {
    padding: var(--sp-1)  var(--sp-2);
    font-size: var(--fs-sm);
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-mute);
}

.copy-pwd-btn:hover {
    background: var(--accent-tint);
    border-color: var(--border-accent);
    color: var(--accent);
}

.copy-pwd-btn.copied {
    background: var(--accent-tint);
    border-color: var(--accent);
    color: var(--accent-soft);
}

/* --- Tag picker: a chip-styled text box with an autocomplete dropdown ---
 * Deliberately the same recipe as the gallery's .faceted-tag-box, so a chip
 * looks like a chip everywhere on the site. */
.tag-picker {
    position: relative;
}

.tag-box {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    align-items: center;
    min-height: var(--control-h);
    padding: var(--sp-1) 8px;
    box-sizing: border-box;
    background: var(--bg);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    cursor: text;
}

.tag-box.focused {
    border-color: var(--accent);
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    background: var(--accent-tint);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-pill);
    padding:3px  var(--sp-1) 3px 10px;
    font-size: var(--fs-xs);
}

.tag-chip .x {
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    opacity: 0.8;
    border: none;
    background: none;
    color: inherit;
    padding:0 2px;
}

.tag-chip .x:hover {
    opacity: 1;
}

.tag-input {
    flex: 1;
    min-width: 80px;
    border: none !important;
    background: none !important;
    padding:4px 2px !important;
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-base);
}

.tag-input:focus {
    outline: none;
}

.tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: var(--z-inline-menu);
    margin-top:4px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-2);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    box-shadow: var(--elev-2);
    display: none;
}

.tag-suggestions.open {
    display: block;
}

.tag-suggestion {
    padding:8px  var(--sp-2);
    font-size: var(--fs-base);
    cursor: pointer;
    color: var(--text-dim);
}

.tag-suggestion.active,
.tag-suggestion:hover {
    background: var(--accent-tint);
}

.tag-suggestions .empty {
    padding:8px  var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--text-mute);
}

/* --- Tabs: Upload / Scrape, two halves dividing the box top evenly --- */
.filedrop-tabs {
    display: flex;
    margin-bottom: var(--sp-3);
    border-bottom: 1px solid var(--border);
}

/* Reset the global ghost-button styling: a tab is text with an underline, not a
   boxed control. */
.filedrop-tab {
    flex: 1;
    text-align: center;
    padding: var(--sp-2) 0;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--text-mute);
    font-family: inherit;
    font-size: var(--fs-md);
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom:-1px;
    opacity: 0.55;
    transition: var(--motion-ui), opacity var(--dur-base) ease;
}

.filedrop-tab:hover {
    opacity: 0.85;
    color: var(--text);
    background: none;
    border-color: transparent;
    border-bottom-color: transparent;
}

.filedrop-tab.active {
    opacity: 1;
    color: var(--accent-soft);
    border-bottom-color: var(--accent-soft);
}

/* --- Scrape tab --- */
.scrape-url-bar {
    display: flex;
    gap:10px;
    align-items: center;
}

.scrape-url-bar input[type="url"] {
    flex: 1;
    padding:10px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: var(--fs-base);
}

.scrape-url-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

.scrape-url-bar button {
    padding:10px  var(--sp-3);
    white-space: nowrap;
}

.scrape-status {
    font-size: var(--fs-sm);
    margin-top:var(--sp-1);
    min-height: 20px;
    color: var(--text-mute);
}

.scrape-status.ok {
    color: var(--accent-soft);
}

/* Fade-in for the phase-2 edit fields. */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.scrape-edit.fade-in {
    animation: fadeInUp var(--dur-slow) ease-out both;
}

.scrape-edit {
    margin-top:var(--sp-2);
}

.scrape-edit label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin:10px 0 3px;
}

/* The scrape form's fields are the same field as the upload form's, so they
   share one rule rather than two copies. */
.scrape-edit input[type="text"],
.scrape-edit textarea {
    width: 100%;
    box-sizing: border-box;
    padding:8px 10px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: var(--fs-base);
}

.scrape-edit input:focus,
.scrape-edit textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.scrape-edit textarea {
    resize: vertical;
    min-height: 56px;
}

.scrape-download-area {
    margin-top:var(--sp-2);
}

.scrape-download-area button {
    padding:10px  var(--sp-3);
}

.scrape-download-area button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.scrape-progress {
    margin-top:var(--sp-2);
}

/* .progress-track is already sized above; only the timing differs here. */
.scrape-progress .progress-bar {
    transition: width var(--dur-slow);
}

.scrape-progress-text {
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin-top: var(--sp-1);
}

/* ==========================================================================
   Report form (static/report-form.html) — content report / DMCA

   Public form page. Inputs speak the same language as the admin login and the
   gallery search: a --bg field with a --border-accent hairline that turns
   --accent on focus. The card mirrors .filedrop-page / .markdown-page, and the
   single CTA is the accent fill — no second hue anywhere.
   ========================================================================== */

.report-page,
#message-container {
    max-width: 600px;
    margin-left:auto;
    margin-right:auto;
}

.report-page {
    margin: var(--sp-3) auto 40px;
    padding:24px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}

.report-page-title {
    margin:0 0 var(--sp-3);
    font-size: var(--fs-2xl);
    font-weight: 400;
    color: var(--text);
}

.report-page .form-group {
    margin-bottom:var(--sp-3);
}

.report-page .form-group label {
    display: block;
    margin-bottom:var(--sp-1);
    color: var(--text-mute);
    font-size: var(--fs-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
}

.report-page input,
.report-page select,
.report-page textarea {
    width: 100%;
    box-sizing: border-box;
    padding:10px  var(--sp-2);
    background: var(--bg);
    border: 1px solid var(--border-accent);
    border-radius: var(--r-sm);
    color: var(--text);
    font-family: inherit;
    font-size: var(--fs-base);
    transition: var(--motion-surface);
}

.report-page input::placeholder,
.report-page textarea::placeholder {
    color: var(--text-mute);
}

.report-page input:focus,
.report-page select:focus,
.report-page textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
    background: var(--surface-2);
}

/* Site-style select. appearance:none removes the native arrow, which would
   otherwise stay chrome-light on the dark field; the chevron is the shared
   token, so it cannot drift from the sort control's. */
.report-page select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right:38px;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.report-page select option {
    background-color: var(--surface-2);
    color: var(--text);
}

.report-page textarea {
    min-height: 120px;
    resize: vertical;
}

.report-page .required {
    color: var(--accent-soft);
}

.report-page .help-text {
    font-size: var(--fs-xs);
    color: var(--text-mute);
    margin-top: var(--sp-1);
}

/* Submit: the one primary CTA on the page (accent fill, like button.primary). */
.report-page .submit-button {
    background: var(--accent);
    color: var(--text);
    border: 1px solid transparent;
    padding: var(--sp-2) 30px;
    font-size: var(--fs-sm);
}

.report-page .submit-button:hover,
.report-page .submit-button:active {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--text);
}

.report-page .submit-button:disabled {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-mute);
    cursor: not-allowed;
}

/* Inline result banners. Scoped to the container the page's script writes into,
   so they don't collide with the site-wide .success-message / .error-message
   text rules. */
#message-container .success-message,
#message-container .error-message {
    padding: var(--sp-2) 16px;
    margin-bottom:var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid;
    text-align: center;
    font-size: var(--fs-base);
}

#message-container .success-message {
    background: var(--accent-tint);
    border-color: var(--border-accent);
    color: var(--accent-soft);
}

#message-container .error-message {
    background: var(--accent-tint);
    border-color: var(--border-accent);
    color: var(--accent-soft);
}

.report-page .loading {
    display: none;
    text-align: center;
    margin:var(--sp-3) 0;
}

.report-page .loading.active {
    display: block;
}

.report-page .loading p {
    color: var(--text-mute);
}

/* ==========================================================================
   Chips and the input share ONE line

   NOTE: this block lives at the END of the file on purpose. The
   @media (max-width: 480px) block above re-declares min-width on
   #faceted-query-input, and an ID selector in a later rule wins regardless of
   :has() specificity — so these overrides have to come after every media query
   or they are silently undone on phones.

   .faceted-tag-box is a wrapping flex row, and the input carries a min-width
   (90px, 60px on phones) so that an EMPTY bar has a usable typing area. The
   moment a chip is committed, chip + that floor no longer fit on one line, so
   the input wraps to a second line: the chip is stranded at the top of the bar
   and the placeholder sits underneath it, roughly doubling the bar's height.

   With a chip present the floor has done its job and becomes the problem, so
   the input drops to a caret-sized sliver and stays on the chip's line. The BAR
   itself does not change width — .faceted-search-bar and .global-search are
   both width:100%, and this only redistributes space inside them.

   The placeholder goes too: it is a prompt to type something, and a committed
   chip means the user already has. (Typed text hides its own placeholder
   natively; the rule above covers the chips-with-empty-input case.)

   The #id is repeated deliberately — the base rule sets min-width on
   #faceted-query-input, and an ID outranks any number of classes, so a
   class-only :has() rule would silently lose. */
.faceted-tag-box:has(.faceted-tag-chip) #faceted-query-input,
.faceted-tag-box:has(.faceted-tag-chip) .faceted-query-input {
    flex: 1 1 0;
    /* border-box so the 2px side padding is INSIDE the floor; otherwise the
       input's real footprint is min-width + 4px and the line breaks anyway. */
    box-sizing: border-box;
    /* px, not ch: ch resolves against each element's OWN font-size, and the
       chip (0.78rem) and input (0.9rem) differ — so a ch-based reservation on
       one never matches the floor on the other. */
    min-width: 16px;
}

/* A chip must be allowed to give ground too, and it has to give it BEFORE the
   line breaks. .faceted-tag-box is flex-wrap: wrap, and line breaking uses each
   item's hypothetical (unshrunk) width — so a long entity name claims the whole
   line, the input's sliver no longer fits beside it, and the input is pushed to
   a second line no matter how small its min-width is. Capping the chip's
   hypothetical width at "the line, minus room for the caret" keeps both on one
   line; the name then truncates via the overflow/ellipsis on the base rule. */
.faceted-tag-box:has(.faceted-tag-chip) .faceted-tag-chip {
    flex: 0 1 auto;
    min-width: 0;
    /* border-box, or the chip's own padding (9px + 6px) and border are added
       ON TOP of the cap and it fills the line again. */
    box-sizing: border-box;
    /* Leave room for the input's 16px floor, the 5px flex gap, and 1px slack. */
    max-width: calc(100% - 22px);
}
