/* CatTail View-Specific Styles */

/* ========================================
   GRID CONTAINER
   ======================================== */
.grid-container {
    padding: var(--spacing-lg);
}

/* ========================================
   HORIZONTAL SCROLL FOR DATA LIST ROWS
   ======================================== */
/* A list row is a six-track grid (40+100+80+80+50+80) plus gaps and padding, so
   it needs roughly 560px and cannot fit a phone. The chosen treatment is to
   scroll it, keeping every column (docs/responsive-conventions.md, "the list at
   narrow width"): nothing is hidden, and the columns that fall past the right
   edge ARE the signal that there is more — NN/g's mobile-table guidance is that
   a cut-off element conveys this better than any decorative cue, provided the
   scroll is not a surprise. The thin, always-coloured scrollbar is the second,
   explicit signal for pointer users, who do not get the cut-off as strongly.

   #gridContainer is the scroller, not #gameGrid. In list mode it is also the
   grid the bar and the rows are laid out on — see "one grid owns the tracks"
   immediately below for why, and what the wrapper carries. The class is set
   per view (views.js render) because Card and Icon share that bar but must not
   scroll sideways. overscroll-behavior-x stops a sideways swipe at the end of
   the list from becoming a browser back/forward gesture. */
#gridContainer.list-scroll,
#stagingListContainer {
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    overscroll-behavior-x: contain;
}

/* ---------------------------------------------------------------
   ONE GRID OWNS THE TRACKS (list mode)
   ---------------------------------------------------------------
   The bar and the rows are two grid containers sharing one template string, and
   a template is not a track set: `min-content` is resolved per grid, from that
   grid's own items. The bar's icon cell is empty and its UPDATE cell holds the
   word, where the row holds a thumbnail and an icon-only chip — so under
   pressure the bar's tracks collapsed to label widths and the rows' to chip
   widths, measured 155px apart, labels naming nothing. Fixed px on both sides
   was the only reason they had ever agreed.

   So in list mode the WRAPPER is the grid, and the bar and every row are
   subgrids of it (the `subgrid` rules further down, after the sizing rules so
   they also beat them). The tracks are then resolved once, from the bar and all
   the rows together, and the columns agree by construction instead of by two
   declarations staying in step. It is also what makes the derived minimums in
   components.css usable at all, and what retires the bar/row inset drift the
   old --list-inset-x plumbing existed to paper over.

   Two things to know before editing here:
   - The wrapper owns the gutters and the horizontal inset, because padding on a
     subgrid item offsets its tracks from the parent's lines. What the wrapper
     carries totals what the two surfaces had: .grid-container's own padding plus
     --list-inset-x for the Library, --list-inset-x alone for Tools. The rows'
     dividers and the bar's wash are therefore inset by that extra amount — the
     one visible cost of the arrangement, and the reason it is stated here.
   - #gameGrid stops being a box of its own (display: contents), so its children
     become the wrapper's grid items. Descendant selectors still reach them:
     display: contents changes the box tree, not the DOM. */
#gridContainer.list-scroll,
#stagingListContainer {
    display: grid;
    grid-template-columns: var(--list-template);
    column-gap: var(--spacing-sm);
    /* The rows stay butted together, the way the old flex column had them. */
    row-gap: 0;
}

#gridContainer.list-scroll {
    padding-left: calc(var(--spacing-lg) + var(--list-inset-x, 0.8rem));
    padding-right: calc(var(--spacing-lg) + var(--list-inset-x, 0.8rem));
}

#stagingListContainer {
    padding-left: var(--list-inset-x, 0.8rem);
    padding-right: var(--list-inset-x, 0.8rem);
}

/* The working set list is capped vertically (inline max-height), so it scrolls
   on both axes. Keep the two scrollbars from fighting: no scroll chaining into
   the page when the vertical cap is reached. */
#stagingListContainer {
    overscroll-behavior: contain;
}

/* The mobile seam.
   767.98px is THE mobile boundary — the same number as MOBILE_MAX_PX in
   app.js (Viewport), which is what publishes <html data-viewport>. This block
   exists so the boundary has one home in CSS as well as one in JS, and so the
   different MOBILE treatment has an obvious place to land instead of being
   sprinkled into the older 768px/576px/480px blocks. A browser check asserts
   both literals still match (T17b).

   What is deliberately NOT here yet: dropping or re-stacking columns. Mobile
   keeps the same scroll-the-row treatment as desktop for now, and the plan for
   replacing it — including giving up columns in a priority order that always
   keeps the sorted one — is written down in docs/responsive-conventions.md.
   Do not add hide-a-column rules here before reading that: the order and the
   sort-column exception are the whole point of it. */
@media (max-width: 767.98px) {
    /* On touch there is no pointer hover to reveal anything, so a row that
       scrolls must also be tappable without the scroll stealing the tap:
       pan-x and pan-y together keep both axes draggable instead of locking the
       gesture to one. */
    #gridContainer.list-scroll,
    #stagingListContainer {
        touch-action: pan-x pan-y;
    }

    /* Name the two flexible list tracks instead of letting them divide whatever
       room is left. On this side of the seam that room is negative: the six
       fixed tracks plus the gaps need ~510px before Title and Category get
       anything, so from here down they were resolving to 0px and each cell's own
       overflow: hidden was clipping the row's name away — at ~576px and below a
       list row had no title at all, and even at 767.98px it had 101px of one.

       Floors rather than widths: the tracks still grow by their fr ratio once
       the row is wide enough, and where it is not, the row scrolls — which is
       the treatment already chosen for this side of the seam (section 2 of
       docs/responsive-conventions.md). Nothing is hidden; the columns falling
       past the right edge ARE the cue that there is more. Raising these is what
       makes that treatment readable rather than merely present. */
    :root {
        --list-title-floor: 11rem;
        --list-category-floor: 6rem;
    }
}

/* ========================================
   CARD VIEW - CSS Grid Layout
   ======================================== */
#gameGrid.card-grid {
    display: grid;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

/* Grid columns based on card size */
#gameGrid.card-grid[data-card-size="1"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-1), 1fr));
}

#gameGrid.card-grid[data-card-size="2"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-2), 1fr));
}

#gameGrid.card-grid[data-card-size="3"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-3), 1fr));
}

#gameGrid.card-grid[data-card-size="4"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-4), 1fr));
}

#gameGrid.card-grid[data-card-size="5"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-5), 1fr));
}

#gameGrid.card-grid[data-card-size="6"] {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}

#gameGrid.card-grid .game-col {
    display: flex;
    flex-direction: column;
}

#gameGrid.card-grid .game-card {
    height: 100%;
}

/* ========================================
   ICON VIEW - Grid Layout
   ======================================== */
#gameGrid.icon-grid {
    display: grid;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
}

#gameGrid.icon-grid[data-card-size="1"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-1), 1fr));
}

#gameGrid.icon-grid[data-card-size="2"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-2), 1fr));
}

#gameGrid.icon-grid[data-card-size="3"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-3), 1fr));
}

#gameGrid.icon-grid[data-card-size="4"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-4), 1fr));
}

#gameGrid.icon-grid[data-card-size="5"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-track-5), 1fr));
}

#gameGrid.icon-grid[data-card-size="6"] {
    grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}

/* ========================================
   SMART VIEW - flattened Smart groups
   ======================================== */
/* Sections are grid CARDS laid out by the Category Card Size slider — several smart
   groups share a row whenever their columns fit (like the Groups page's card
   grid). The 5 slider positions map to the SMART-ONLY track ladder
   (--smart-card-track-1..5 = 7/5/3/2/1 columns; see variables.css) so changing
   the slider never touches card/icon view columns, which keep the shared
   --card-track-* ladder. Member icon tiles flow inside each section and wrap;
   the Preview Rows slider clips the tile grid's height. */
#gameGrid.smart-view {
    display: grid;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    align-items: start;
}

#gameGrid.smart-view[data-card-size="1"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--smart-card-track-1), 1fr));
}

#gameGrid.smart-view[data-card-size="2"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--smart-card-track-2), 1fr));
}

#gameGrid.smart-view[data-card-size="3"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--smart-card-track-3), 1fr));
}

#gameGrid.smart-view[data-card-size="4"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--smart-card-track-4), 1fr));
}

#gameGrid.smart-view[data-card-size="5"] {
    grid-template-columns: repeat(auto-fill, minmax(var(--smart-card-track-5), 1fr));
}

/* A section card is header + its tile grid, stacked. Tiles are fixed-size
   (Image Size slider); each Preview Row fills with as many icons as the
   card's width allows (flex-wrap). */
.smart-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 0.6rem;
}

/* Member tile grid: wraps naturally inside its card. */
.smart-section-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    overflow: hidden;
    /* Rows stay LEFT-ALIGNED; the leftover card width is split evenly into
       the side padding by views.js (syncSmartTileCentering), which also
       gives the header the same insets. The 3px vertical padding is ring
       headroom (outline draws OUTSIDE the tile box). */
    padding-top: 3px;
    padding-bottom: 3px;
    padding-left: 3px;
    padding-right: 3px;
}

/* Member tiles: square icons sized by the Image Size slider (views.js sets
   --smart-tile-size from the same fixed px ladder List view uses). Tiles
   are fixed-size; each row fills with as many as the card's width allows
   (flex-wrap). */
.smart-member-tile {
    position: relative;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Linked selection state (Add Mode): a game can appear in several sections
   and in the section modal — syncSmartTileSelection() toggles .is-selected
   on EVERY instance of the title, so the blue ring stays consistent
   wherever the game shows. */
.smart-member-tile.is-selected .smart-member-icon,
.smart-section-game-card.is-selected img {
    outline: 2px solid rgba(13, 110, 253, 0.75);
    outline-offset: 1px;
}

/* Toolbar sliders: captions stacked above their slider (shared by the
   Library's Card Size / List Size / Smart sliders and the Groups page's
   Size / Columns / Rows trio) — same compact vertical-pair rhythm as
   Details/Hide and Wrap/Admin. */
.slider-stack {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.slider-stack .slider-caption {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.1;
    white-space: nowrap;
    margin-bottom: 0.1rem;
}

.slider-stack .form-range {
    margin-top: 0;
    margin-bottom: 0;
}

.smart-member-icon,
.smart-member-placeholder {
    display: block;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.smart-member-placeholder {
    background: rgba(255, 255, 255, 0.08);
}

#gameGrid.smart-view[data-card-size="1"] .smart-member-icon,
#gameGrid.smart-view[data-card-size="1"] .smart-member-placeholder,
#gameGrid.smart-view[data-card-size="2"] .smart-member-icon,
#gameGrid.smart-view[data-card-size="2"] .smart-member-placeholder,
#gameGrid.smart-view[data-card-size="3"] .smart-member-icon,
#gameGrid.smart-view[data-card-size="3"] .smart-member-placeholder,
#gameGrid.smart-view[data-card-size="4"] .smart-member-icon,
#gameGrid.smart-view[data-card-size="4"] .smart-member-placeholder,
#gameGrid.smart-view[data-card-size="5"] .smart-member-icon,
#gameGrid.smart-view[data-card-size="5"] .smart-member-placeholder { width: var(--smart-tile-size, 48px); height: var(--smart-tile-size, 48px); }

/* Add Mode checkbox reuses the card-view wrapper (absolute, top-right);
   tiles are small, so keep the hit area to the tile bounds. */
.smart-member-tile .add-mode-checkbox-wrapper {
    top: 0;
    right: 0;
    width: 50%;
    height: 50%;
}

.smart-member-tile:hover {
    filter: brightness(1.15);
}

/* Per-section select checkbox (Add Mode): leads the header, sized to the
   compact header row. Click/change stop propagation, so it never opens
   the section modal. */
.smart-section-checkbox-wrap {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.smart-section-select-checkbox {
    margin: 0;
    cursor: pointer;
}

/* Section header: compact enough to fit several cards per row, same
   blue-tinted look as the Groups page's smart-group cards
   (rgba(13,110,253,0.2) header tint + 0.3 border). Clicking it opens the
   section games modal (Groups-page parity), so it keeps an interactive
   affordance + focus ring. */
.smart-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 0.45rem 0.7rem;
    background-color: rgba(13, 110, 253, 0.2);
    border: 1px solid rgba(13, 110, 253, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.smart-section-header:hover,
.smart-section-header:focus-visible {
    background-color: rgba(13, 110, 253, 0.3);
    border-color: rgba(13, 110, 253, 0.5);
    outline: none;
}

/* The name is the priority header element: its wrapper absorbs ALL
   shrinking first (flex: 1 + min-width: 0 → ellipsis), while the count
   badge keeps its full width (flex-shrink: 0). So on narrow cards the
   name truncates LAST, never the badge. */
.smart-section-title-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: baseline;
    gap: var(--spacing-sm);
    min-width: 0;
}

.smart-section-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.smart-section-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    flex-shrink: 0;
    margin-left: auto;
}

.smart-section-count-badge {
    border: 1px solid rgba(0, 0, 0, 0.4);
}

/* Header-priority pass (views.js syncSmartHeaderPriority): while the section
   name truncates, the count badge steps aside so the name — the priority
   header element — gets its space back; the badge returns when it fits. */
.smart-section-count-badge.is-hidden-by-priority {
    display: none;
}

/* Header scale follows IMAGE Size (like List Size zooms whole list rows):
   the header must match the tiles under it, not the card width — Category
   Card Size lays out columns only. Seven steps anchored so Image Size 3 is
   the classic base look (position 7 = 112px tiles is the SMART-only bigger
   cap); horizontal padding is overwritten inline by
   syncSmartTileCentering to mirror the tile grid's balanced insets. */
#gameGrid.smart-view[data-image-size="1"] .smart-section-header { padding-top: 0.28rem; padding-bottom: 0.28rem; gap: 0.35rem; }
#gameGrid.smart-view[data-image-size="1"] .smart-section-title { font-size: 0.72rem; }
#gameGrid.smart-view[data-image-size="1"] .smart-section-count-badge { font-size: 0.6rem; padding: 0.15em 0.45em; }
#gameGrid.smart-view[data-image-size="1"] .smart-section-select-checkbox { width: 0.85rem; height: 0.85rem; }

#gameGrid.smart-view[data-image-size="2"] .smart-section-header { padding-top: 0.35rem; padding-bottom: 0.35rem; }
#gameGrid.smart-view[data-image-size="2"] .smart-section-title { font-size: 0.8rem; }
#gameGrid.smart-view[data-image-size="2"] .smart-section-count-badge { font-size: 0.65rem; }

#gameGrid.smart-view[data-image-size="4"] .smart-section-header { padding-top: 0.5rem; padding-bottom: 0.5rem; }
#gameGrid.smart-view[data-image-size="4"] .smart-section-title { font-size: 0.98rem; }

#gameGrid.smart-view[data-image-size="5"] .smart-section-header { padding-top: 0.55rem; padding-bottom: 0.55rem; }
#gameGrid.smart-view[data-image-size="5"] .smart-section-title { font-size: 1.05rem; }
#gameGrid.smart-view[data-image-size="5"] .smart-section-count-badge { font-size: 0.78rem; }

#gameGrid.smart-view[data-image-size="6"] .smart-section-header { padding-top: 0.62rem; padding-bottom: 0.62rem; }
#gameGrid.smart-view[data-image-size="6"] .smart-section-title { font-size: 1.12rem; }
#gameGrid.smart-view[data-image-size="6"] .smart-section-count-badge { font-size: 0.84rem; }

#gameGrid.smart-view[data-image-size="7"] .smart-section-header { padding-top: 0.68rem; padding-bottom: 0.68rem; }
#gameGrid.smart-view[data-image-size="7"] .smart-section-title { font-size: 1.18rem; }
#gameGrid.smart-view[data-image-size="7"] .smart-section-count-badge { font-size: 0.9rem; }

/* ===== Smart section games modal (header click) =====
   Same blue-tinted header treatment as the Groups page's smart-group
   preview modal (group-modal-smart). */
.modal-content.smart-section-modal-content .modal-header {
    background-color: rgba(13, 110, 253, 0.2);
    border-bottom: 3px solid rgba(13, 110, 253, 1);
}

/* Member cards show the artwork WHOLE. The library serves square icons
   (512x512 in the media cache), so the card is a 1:1 box with `contain`:
   the full icon fits, and the two non-square cached files letterbox instead
   of losing their edges. */
#smartSectionModalGrid .game-preview-card {
    position: relative;
}

#smartSectionModalGrid .game-preview-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

/* Broken images keep the identical box so rows stay aligned. */
#smartSectionModalGrid .game-preview-card .img-fallback {
    height: auto;
    aspect-ratio: 1 / 1;
}

/* The title rides ON the art in a dark scrim at the bottom, the treatment
   card view's .bottom-overlay gives its tiles — instead of a caption strip
   underneath. Pinned rather than flowed, so it costs the card no height. */
#smartSectionModalGrid .game-preview-card .card-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--game-card-overlay-padding);
    background: var(--bg-overlay);
    border-bottom-left-radius: var(--bs-card-border-radius, var(--radius-sm));
    border-bottom-right-radius: var(--bs-card-border-radius, var(--radius-sm));
    z-index: 20;
}

/* The name sits in the scrim and long names truncate, so `text-truncate`
   forces `overflow: hidden` — which clips at the title's OWN line box. A
   heading's tight default line-height makes that box shorter than the font
   itself, so it shaves the tails off g / y / p / q / j. Loosening it here (and
   only here) keeps the long-name ellipsis and gives the descenders back
   their room. */
#smartSectionModalGrid .game-preview-card .card-title {
    line-height: 1.35;
}

#smartSectionModalGrid .game-preview-card:hover {
    transform: scale(1.02);
    transition: transform 0.2s ease;
}

/* Smart view state banners (fetch failure / no matching sections). They live
   OUTSIDE #gameGrid as siblings (like #allLoadedMessage) so grid clears never
   destroy them — shown/hidden in place by views.js. */
.smart-state-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1.25rem 1rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.smart-state-banner.smart-error {
    background-color: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    color: var(--text-primary);
}

.smart-state-banner.smart-empty {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-secondary);
}

/* ========================================
   LIST VIEW - File Browser Style
   ======================================== */
#gameGrid.list-view {
    /* Not a box: in list mode the rows are items of #gridContainer's grid, so
       this element is transparent to layout. See "one grid owns the tracks". */
    display: contents;
}

/* List view scaling based on slider */
#gameGrid.list-view .list-header-row {
    font-size: 0.75rem;
}

/* List size text scaling for size 6 */
#gameGrid.list-view[data-list-size="6"] .list-size-text {
    font-size: 1rem;
}


/* Icon column in list view */
.list-col-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* List view icon styling - use contain to show full image without cropping */
.list-icon {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Category column in list view */
.list-col-category {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}

/* Category wrap mode - allows badges to wrap to fill space before clipping */
#gameGrid.category-wrap .list-col-category,
#stagingListContainer.category-wrap .list-col-category,
#gameGrid.category-wrap .category-container {
    flex-wrap: wrap;
    overflow: visible;
}

/* Wrap mode also un-truncates the game name. The toggle is one control for
   "let this row be as tall as its content needs": it governs the category
   badges AND the Title column, so a long name wraps onto a second line
   instead of being clipped to an ellipsis. `overflow-wrap: anywhere` keeps a
   single unbroken token (a 40-character homebrew title) inside the column. */
#gameGrid.category-wrap .list-col-title,
#stagingListContainer.category-wrap .list-col-title {
    overflow: visible;
    align-items: flex-start;
}

#gameGrid.category-wrap .list-col-title .list-title,
#stagingListContainer.category-wrap .list-col-title .list-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {

    .list-header-row,
    .list-row {
        padding: var(--spacing-sm);
    }

    .list-title {
        font-size: var(--font-size-sm);
    }

    /* Adjust card grid for mobile */
    #gameGrid.card-grid[data-card-size="1"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 5), 1fr));
    }

    #gameGrid.card-grid[data-card-size="2"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 4), 1fr));
    }

    #gameGrid.card-grid[data-card-size="3"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 3), 1fr));
    }

    #gameGrid.card-grid[data-card-size="4"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 2), 1fr));
    }
}

@media (max-width: 576px) {

    /* Further adjustments for very small screens */
    #gameGrid.card-grid[data-card-size="1"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 3), 1fr));
    }

    #gameGrid.card-grid[data-card-size="2"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 3), 1fr));
    }

    #gameGrid.card-grid[data-card-size="3"] {
        grid-template-columns: repeat(auto-fill, minmax(calc(100% / 2), 1fr));
    }
}

/* ========================================
   ANALYTICS BAR RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .stat-card {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-width: 80px;
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    .stat-label {
        font-size: 0.65rem;
    }
}

/* ========================================
   FILTER CONTROLS RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    #textFilter {
        max-width: 100%;
    }

    .btn-group.dropdown-center {
        width: 100%;
        margin-bottom: var(--spacing-sm);
    }

    .dropdown-menu {
        width: 100%;
    }
}

/* ========================================
   CARD SIZE SLIDER CONTAINER
   ======================================== */
#cardSizeSliderContainer,
#listSizeSliderContainer {
    min-width: 100px;
}

/* Category Card Size's caption is the longest toolbar label; keep its
   slider from being squeezed. */
#smartCardSizeSliderContainer {
    min-width: 130px;
}

#smartImageSizeSliderContainer {
    min-width: 100px;
}

.form-range {
    width: 100px;
}

@media (max-width: 768px) {
    .form-range {
        width: 80px;
    }
}

/* ========================================
   SHARED LIST SIZING (Library + Staging)
   ======================================== */

/* One horizontal inset per list size, read by the rows AND the sort bar that
   labels them. The bar used to keep a fixed compact inset (0.5rem, and 0.5rem
   again from the 768px media query) while the rows took theirs from the size
   slider (0.3-1.2rem), so every label sat off the column it named: 11.2px at the
   desktop default, 4.8px below 768px. The size reaches the bar because it is
   published on the wrapper the two share — #gridContainer for the Library,
   #stagingListContainer for Tools — since the bar is a SIBLING of the rows, not
   a child of their sizing container. */
#gridContainer[data-list-size="1"],
#stagingListContainer[data-list-size="1"] { --list-inset-x: 0.3rem; }

#gridContainer[data-list-size="2"],
#stagingListContainer[data-list-size="2"] { --list-inset-x: 0.6rem; }

#gridContainer[data-list-size="3"],
#stagingListContainer[data-list-size="3"] { --list-inset-x: 0.8rem; }

#gridContainer[data-list-size="4"],
#stagingListContainer[data-list-size="4"] { --list-inset-x: 1rem; }

#gridContainer[data-list-size="5"],
#stagingListContainer[data-list-size="5"] { --list-inset-x: 1.1rem; }

#gridContainer[data-list-size="6"],
#stagingListContainer[data-list-size="6"] { --list-inset-x: 1.2rem; }

/* Unified list-row sizing. Only the vertical padding lives here; the horizontal
   inset comes from --list-inset-x above so it cannot drift from the bar's. */
.list-sizing-container[data-list-size="1"] .list-row {
    padding: 0.05rem var(--list-inset-x, 0.3rem);
    font-size: 0.7rem;
}

/* At the smallest size the row's vertical padding collapses to ~1px, so when
   Wrap lets the category chips stack they nearly touch the row's bottom rule.
   Wrapped rows at this size get a 5px breath above and below the chips, one
   side against the chip and the other against the cell's horizontal divider. */
.list-sizing-container[data-list-size="1"].category-wrap .list-row {
    padding-top: 5px;
    padding-bottom: 5px;
}

.list-sizing-container[data-list-size="2"] .list-row {
    padding: 0.15rem var(--list-inset-x, 0.6rem);
    font-size: 0.75rem;
}

.list-sizing-container[data-list-size="3"] .list-row {
    padding: 0.2rem var(--list-inset-x, 0.8rem);
    font-size: 0.85rem;
}

.list-sizing-container[data-list-size="4"] .list-row {
    padding: 0.25rem var(--list-inset-x, 1rem);
    font-size: 0.9rem;
}

.list-sizing-container[data-list-size="5"] .list-row {
    padding: 0.3rem var(--list-inset-x, 1.1rem);
    font-size: 0.95rem;
}

.list-sizing-container[data-list-size="6"] .list-row {
    padding: 0.35rem var(--list-inset-x, 1.2rem);
    font-size: 1rem;
}

/* Unified list-header-row sizing - the bar stays compact vertically regardless
   of the slider, but its horizontal inset must equal the rows' or the labels sit
   off the columns (see --list-inset-x above). The id-scoped selectors are what
   reach the Library bar, which is outside .list-sizing-container, and they also
   outweigh the 768px media query that used to shrink the bar alone. */
.list-sizing-container .list-header-row,
#gridContainer[data-list-size] .list-header-row,
#stagingListContainer[data-list-size] .list-header-row {
    padding: 0.3rem var(--list-inset-x, 0.8rem);
}

/* The wrapper above owns the tracks in list mode, so the bar and the rows join
   its grid instead of sizing tracks of their own, and carry no horizontal
   padding: padding on a subgrid item offsets its tracks from the parent's lines
   and would put the labels back off their columns. The bar keeps the inset it
   has outside list mode, where it is a grid of its own. These rules sit after
   the sizing rules on purpose — `#gridContainer[data-list-size]
   .list-header-row` above is the same specificity as the first of them. */
#gridContainer.list-scroll > .list-header-row,
#stagingListContainer.list-sizing-container[data-list-size] > .list-header-row,
#gridContainer.list-scroll .list-row,
#stagingListContainer .list-row {
    grid-column: 1 / -1;
    grid-template-columns: subgrid;
    padding-left: 0;
    padding-right: 0;
}

/* A list row is the only thing that may be a grid item of its own width here;
   anything else the grid happens to hold (an empty state, a message) takes the
   whole row rather than one column. */
#gameGrid.list-view > :not(.list-row) {
    grid-column: 1 / -1;
}

/* Unified list icon sizing */
.list-sizing-container[data-list-size="1"] .list-icon {
    width: 28px;
    height: 28px;
}

.list-sizing-container[data-list-size="2"] .list-icon {
    width: 36px;
    height: 36px;
}

.list-sizing-container[data-list-size="3"] .list-icon {
    width: 48px;
    height: 48px;
}

.list-sizing-container[data-list-size="4"] .list-icon {
    width: 64px;
    height: 64px;
}

.list-sizing-container[data-list-size="5"] .list-icon {
    width: 80px;
    height: 80px;
}

.list-sizing-container[data-list-size="6"] .list-icon {
    width: 96px;
    height: 96px;
}

/* Unified checkbox sizing */
.list-sizing-container[data-list-size="1"] .header-checkbox,
.list-sizing-container[data-list-size="1"] .staging-checkbox,
.list-sizing-container[data-list-size="1"] .add-mode-checkbox {
    width: 16px;
    height: 16px;
}

.list-sizing-container[data-list-size="2"] .header-checkbox,
.list-sizing-container[data-list-size="2"] .staging-checkbox,
.list-sizing-container[data-list-size="2"] .add-mode-checkbox {
    width: 18px;
    height: 18px;
}

.list-sizing-container[data-list-size="3"] .header-checkbox,
.list-sizing-container[data-list-size="3"] .staging-checkbox,
.list-sizing-container[data-list-size="3"] .add-mode-checkbox {
    width: 20px;
    height: 20px;
}

.list-sizing-container[data-list-size="4"] .header-checkbox,
.list-sizing-container[data-list-size="4"] .staging-checkbox,
.list-sizing-container[data-list-size="4"] .add-mode-checkbox {
    width: 24px;
    height: 24px;
}

.list-sizing-container[data-list-size="5"] .header-checkbox,
.list-sizing-container[data-list-size="5"] .staging-checkbox,
.list-sizing-container[data-list-size="5"] .add-mode-checkbox {
    width: 28px;
    height: 28px;
}

.list-sizing-container[data-list-size="6"] .header-checkbox,
.list-sizing-container[data-list-size="6"] .staging-checkbox,
.list-sizing-container[data-list-size="6"] .add-mode-checkbox {
    width: 32px;
    height: 32px;
}

/* ========================================
   STAGING AREA LIST STYLES
   ======================================== */

/* The staging list container is a grid, declared with the Library's wrapper in
   "one grid owns the tracks" near the top of this file — the flex column that
   used to be declared here is what the bar and the rows are subgrids of now, and
   a flex container would put each of them in a column of their own. */

/* Staging list header and rows - inherits grid layout from base .list-header-row/.list-row */
/* Only border-bottom differs from base (slightly brighter border for staging context) */
#stagingListContainer .list-header-row,
#stagingListContainer .list-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#stagingListContainer .list-row {
    transition: background-color 0.15s ease;
}

#stagingListContainer .list-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Staging list column widths */
#stagingListContainer .list-col-checkbox {
    width: 40px;
    text-align: center;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Always show checkboxes in staging area (not dependent on add-mode-active) */
#stagingListContainer .form-check-input {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Staging header checkbox specific styling - sizing handled by shared .list-sizing-container */
#stagingListContainer .list-header-row .header-checkbox {
    margin: 0 auto;
    cursor: pointer;
}

/* Staging row checkbox styling - sizing handled by shared .list-sizing-container */
#stagingListContainer .staging-row .staging-checkbox {
    margin: 0 auto;
    cursor: pointer;
}

/* The icon and Type columns hold no width here on purpose, and neither did the
   Library's. A width on the cell is a width on the track's minimum (the cell is
   the track's item), so `50px` here made the Tools icon track demand 50px at
   every size while the Library's demanded whatever `.list-icon` was set to --
   28px at size 1, 96px at size 6. The two surfaces could not agree about what
   the column needs, because one of them was not asking. The same held for
   `60px` on Type against the Library's chip-derived track.

   The pins were also invisible to the cap: the icon track is capped at 100px,
   so from size 4 up (64 / 80 / 96px) every Tools thumbnail was squeezed back
   to 50px inside a track that was wide enough for it, while the Library's grew
   - the slider's top three rungs grew nothing in that column on the working set.

   Removed rather than renumbered. The Library's requirement moves with the
   slider, so any constant is right at one rung at best and wrong at the rest.
   Both columns are now sized by the shared `.list-icon` rungs and the shared
   `minmax(min-content, ...)` tracks, which is what "agreeing" means here; T21
   measures it and tests/test_list_grid_tracks.py keeps the pins from coming
   back. */
#stagingListContainer .list-col-icon img {
    border-radius: 4px;
}

#stagingListContainer .list-col-title {
    flex: 2;
    min-width: 0;
}

#stagingListContainer .list-col-size {
    width: 80px;
}

/* Selection counter styles */
.selection-counter-container {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(40, 167, 69, 0.2);
    padding: 0.375rem 0.625rem;
    border-radius: 4px;
    height: 38px;
    box-sizing: border-box;
}

.selection-counter-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: #28a745;
}

.selection-counter-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   CARD/ICON SELECT-ALL BAR (Add Mode)
   ======================================== */
.card-icon-select-all-bar {
    display: flex;
    align-items: center;
    padding: 0.4rem 1rem;
    margin-bottom: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    grid-column: 1 / -1;
}

.card-icon-select-all-bar .form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 0;
    margin-bottom: 0;
    padding-left: 0;
}

.card-icon-select-all-bar .form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;
    float: none;
    position: static;
    cursor: pointer;
    accent-color: #0d6efd;
}

.card-icon-select-all-bar .form-check-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline;
}

.card-icon-select-all-bar .select-all-count {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 0.35rem;
}

/* ========================================
   LIST VIEW ADD-MODE SELECT-ALL (header checkbox)
   ======================================== */
/* The List sort bar is a SIBLING of #gameGrid inside #gridContainer (see
   ViewsModule.renderListHeader), so the in-grid rule in components.css
   (`#gameGrid.add-mode-active .list-col-checkbox`) cannot reach its checkbox
   column. #gridContainer carries the same add-mode state
   (GroupsModule.setAddMode) and `list-scroll` marks the List view, so this
   reveals only the List header select-all. Card/Icon keep their own
   .card-icon-select-all-bar above, and the staging list is always visible. */
#gridContainer.list-scroll.add-mode-active > .list-header-row .list-col-checkbox {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    animation: checkboxFadeIn 0.3s ease-in-out;
}

/* ========================================
   LIST HEADER SELECTION COUNT
   ======================================== */
.list-header-select-count {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 0.5rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.list-compression-icon {
    margin-left: 0.25rem;
    font-size: 0.75rem;
    opacity: 0.7;
    color: var(--color-success);
}

/* ========================================
   COMPRESSION LEVEL ESTIMATION BAR (Modals)
   ======================================== */
#compressionLevelBar {
    background: rgba(255, 255, 255, 0.02);
}

#compressionLevelBar .form-range {
    width: 100%;
    height: 6px;
    cursor: pointer;
}

#compressionLevelBar .form-range::-webkit-slider-thumb {
    background: #0d6efd;
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(13, 110, 253, 0.4);
}

#compressionLevelBar .form-range::-moz-range-thumb {
    background: #0d6efd;
    border: 2px solid rgba(255, 255, 255, 0.3);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
}

/* ========================================
   ADVANCED SETTINGS COLLAPSIBLE (Modals)
   ======================================== */
.settings-collapse-section {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.015);
}

.settings-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.settings-collapse-header:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.03);
}

.settings-collapse-header .collapse-arrow {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.settings-collapse-header[aria-expanded="true"] .collapse-arrow {
    transform: rotate(180deg);
}

.settings-collapse-body {
    padding: 0.35rem 1rem 0.6rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 28px;
}

.settings-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.6);
    min-width: 90px;
    flex-shrink: 0;
}

.settings-control {
    width: auto;
    min-width: 80px;
    max-width: 120px;
}

.settings-control .form-check-input {
    margin: 0;
    cursor: pointer;
}

.settings-control .form-check {
    padding-left: 0;
    min-height: 0;
}

.settings-hint {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.3);
    margin-left: auto;
    white-space: nowrap;
}

/* "changed this session" — a value that differs from its Settings parent and
   will roll back to it in a new session. Amber so it reads as temporary.  */
.override-badge {
    margin-left: 0.4rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: rgba(255, 193, 7, 0.14);
    color: #ffc107;
    font-size: 0.6rem;
}

.override-notice {
    font-size: 0.65rem;
    color: #ffc107;
    margin-bottom: 0.35rem;
    white-space: normal;
}

#compressionEta,
#decompressionEta {
    font-weight: 400;
}

/* ========================================
   SORTABLE LIST HEADERS
   ======================================== */

.list-col-sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease;
}

.list-col-sortable:hover {
    color: var(--color-primary);
}

.list-col-sortable .sort-label {
    display: inline;
}

.list-col-sortable .sort-arrow {
    display: inline;
    font-size: 0.65rem;
    margin-left: 2px;
    opacity: 0.6;
}

.list-col-sortable.sorted-asc .sort-arrow,
.list-col-sortable.sorted-desc .sort-arrow {
    opacity: 1;
    color: var(--color-primary);
}

.list-col-sortable.sorted-asc,
.list-col-sortable.sorted-desc {
    color: var(--color-primary);
}

/* ========================================
   TOOLS WORKSPACE - ONE BUTTON SIZE
   ======================================== */
/* Every action tab's buttons are btn-sm and share this taller padding, so the
   four panes and the commit pair read as one control set: the same 36px target
   everywhere instead of the mix of 31px and 38px buttons the tabs used to
   carry. The height is padding, not btn-sm alone, because btn-sm's 31px reads
   as a footnote row beside the panes' inputs. */
#stagingArea .tools-pane .btn,
#stagingArea .tools-commit-slot .btn,
#stagingArea .tools-pane .form-control,
#stagingArea .tools-pane .form-select {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

/* A select carried btn-sm's 31px while the inputs around it carried this
   rule's 36px, so a row like the RetroArch pane's had two baselines in it. */
#stagingArea .tools-pane .form-select {
    font-size: 0.875rem;
}

/* ========================================
   RETROARCH CORE PICKER
   ======================================== */
/* One box that names the chosen core and takes the search. The list is placed
   absolutely so opening it never reflows the row it hangs from, and it scrolls
   inside a capped height instead of pushing the page down: a card carries ~140
   cores in ~54 system groups. */
.ra-combo {
    position: relative;
}

/* The closed box is one line of text: a pair wider than the box is cut with an
   ellipsis, and syncCoreBox puts the whole string on the title so a future
   core name widens the tooltip rather than the row. */
.ra-combo input {
    text-overflow: ellipsis;
}

/* The core manager puts the same list inside a modal body: there is no box
   to hang under, so it flows in place and scrolls there. */
.ra-combo--modal .ra-combo-list {
    position: static;
    margin-top: 0.35rem;
    max-height: 50vh;
    box-shadow: none;
}

.ra-combo-list {
    position: absolute;
    z-index: 1055;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    padding: 0.25rem 0;
    background: #212529;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.25rem;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}

.ra-combo-list[hidden] {
    display: none;
}

.ra-combo-group {
    padding: 0.35rem 0.5rem 0.1rem;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

/* The one group where the choice of core changes which files count. */
.ra-combo-group-note {
    padding: 0 0.5rem 0.35rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.72rem;
    line-height: 1.35;
}

/* A console whose core cannot boot without a file says so where the core is
   chosen, not after a black screen. A left rule marks it as a condition on the
   rows under it; the pane's one accent is the core, so this is white at a lower
   opacity rather than a warning colour. */
.ra-combo-group-bios {
    margin: 0 0.5rem 0.45rem;
    padding-left: 0.55rem;
    border-left: 2px solid rgba(255, 255, 255, 0.28);
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.72rem;
    line-height: 1.4;
}

.ra-combo-group-bios strong {
    color: #e9ecef;
    font-weight: 600;
}

/* The line names a file; the button is a way to answer it without leaving the
   list for a file manager. Quiet on purpose: it sits inside a note, not beside
   the console's name. */
.ra-combo-group-bios-add {
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    background: transparent;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.7rem;
    line-height: 1.6;
}

.ra-combo-group-bios-add:hover,
.ra-combo-group-bios-add:focus-visible {
    border-color: rgba(255, 255, 255, 0.45);
    color: #e9ecef;
}

/* Firmware only some of the library reads is a hint, not a warning: the rule is
   dotted so the eye does not read it as something broken. */
.ra-combo-group-bios--hint {
    border-left-style: dotted;
}

/* The firmware folder is the one drop point the pane adds: a scan of what a
   user already put in system/, and either the move that fixes it or the card
   path when the mount is read-only. The panel is quiet — it is a condition on
   the list, not a second console header. */
.ra-firmware {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.02);
}

.ra-firmware-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ra-firmware-title {
    color: #e9ecef;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.ra-firmware-head code {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.72rem;
}

.ra-firmware-report {
    margin-top: 0.4rem;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.72rem;
    line-height: 1.45;
}

.ra-firmware-report ul {
    margin: 0.3rem 0 0;
    padding-left: 1rem;
}

.ra-firmware-report li {
    margin: 0.15rem 0;
}

.ra-firmware-report code {
    color: #e9ecef;
}

.ra-firmware-console {
    display: inline-block;
    margin-right: 0.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.66rem;
    letter-spacing: 0.02em;
}

.ra-firmware-region {
    display: inline-block;
    margin-right: 0.25rem;
    padding: 0 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.64rem;
    letter-spacing: 0.02em;
}

.ra-firmware-digest {
    margin-left: 0.2rem;
    font-size: 0.66rem;
    letter-spacing: 0.02em;
}

.ra-firmware-digest.is-verified {
    color: #8fd19e;
}

.ra-firmware-digest.is-mismatch {
    color: #ff9a9a;
}

.ra-firmware-roms {
    margin-top: 0.45rem;
}

.ra-firmware-roms .ra-combo-group-bios-add {
    margin-left: 0.2rem;
}

.ra-firmware-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.ra-firmware-actions .ra-combo-group-bios-add {
    margin-left: 0;
}

/* Replacing a file the card already has asks in the row it is about, so the
   question sits beside the name instead of in a browser dialog. Amber for the
   question, quiet for the way out. */
.ra-firmware-confirm {
    margin-left: 0.35rem;
    color: #f0c36d;
    font-size: 0.72rem;
}

.ra-firmware-confirm .ra-combo-group-bios-add {
    border-color: rgba(240, 195, 109, 0.55);
    color: #f0c36d;
}

.ra-firmware-confirm-no {
    margin-left: 0.35rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    text-decoration: underline;
}

.ra-firmware-confirm-no:hover,
.ra-firmware-confirm-no:focus-visible {
    color: #e9ecef;
}

/* The manager's consoles are what the eye hunts for, so their names carry
   more weight than the box's compact headings: full-strength where the rest
   is muted, ruled off from the cores below. The hierarchy is weight and
   spacing, not a second accent colour — the pane has one thing to point at
   (the console's core) and a heading is not it. The gap above a heading is
   the break between one console's cores and the next console, so it is
   wider than the rows' own spacing. They are not pinned either: a console
   mostly shows one core, so a heading that follows the scroll would outstay
   the list under it. The gap above is now four times the one under the
   heading, so a console reads as owning the cores beneath it rather than
   all of them reading as one list. */
.ra-combo--modal .ra-combo-group {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    position: relative;
    padding: 1.25rem 0.5rem 0.28rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: #212529;
    color: #e9ecef;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.3;
}

/* The heading's controls sit together at its right end: the tick that decides
   the first screen, and the minus that takes a console off it. */
.ra-combo-group-tools {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

/* The tick that decides the first screen, on the console it decides about.
   Down the headings it reads as a column of boxes with one quiet word beside
   them, so the word stays small: it labels the column, it is not a second
   title. */
.ra-combo-group-tick {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: none;
    white-space: nowrap;
    cursor: pointer;
}

.ra-combo-group-tick:hover,
.ra-combo-group-tick:has(input:checked) {
    color: rgba(255, 255, 255, 0.82);
}

.ra-combo-group-tick input {
    margin: 0;
}

/* The one control the In Use tab can carry besides the drag: take this console
   off the first screen. A minus, not a cross — the arrow is the direction the
   list can be edited, and it sits in the tick's place on that tab. */
.ra-combo--modal .ra-combo-group-remove {
    flex: 0 0 auto;
    margin: 0;
    padding: 0 0.3rem;
    border: 0;
    background: none;
    color: rgba(255, 255, 255, 0.4);
    font: inherit;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.ra-combo--modal .ra-combo-group-remove:hover,
.ra-combo--modal .ra-combo-group-remove:focus-visible {
    color: #fff;
    outline: none;
}

/* The seam inside All consoles: above it the consoles in use, in the order the
   console box reads; below it the rest of the catalogue in its own order. The
   word names the half under the rule, which is the half that needs saying —
   the headings above are already ticked. */
.ra-combo--modal .ra-combo-split {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.6rem 0.5rem 0.1rem;
    color: rgba(255, 255, 255, 0.38);
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ra-combo--modal .ra-combo-split::before,
.ra-combo--modal .ra-combo-split::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: rgba(255, 255, 255, 0.16);
}

/* The In Use tab is its own order, so its headings are its handles: a grab
   cursor on the console you are already reading, and a dimmed heading while it
   is held. Nothing else in the catalogue drags, because no other tab keeps an
   order. */
.ra-combo--modal .ra-combo-group[draggable="true"] {
    cursor: grab;
}

.ra-combo--modal .ra-combo-group[draggable="true"]:active {
    cursor: grabbing;
}

.ra-combo--modal .ra-combo-group.ra-combo-group--drag {
    opacity: 0.45;
}

/* Where the held console lands: a line across the seam between two headings,
   ruled the width of the heading so it reads as the seam it is — above a
   console when it would go before it, under the last one when it is being sent
   to the end of the tab. */
.ra-combo--modal .ra-combo-group.ra-combo-group--drop-before::before,
.ra-combo--modal .ra-combo-group.ra-combo-group--drop-after::after {
    content: '';
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    height: 0.125rem;
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.85);
}

.ra-combo--modal .ra-combo-group.ra-combo-group--drop-before::before {
    top: -0.1rem;
}

.ra-combo--modal .ra-combo-group.ra-combo-group--drop-after::after {
    bottom: -0.1rem;
}

/* The list's own top is already spaced by the tab bar above it. */
.ra-combo--modal .ra-combo-list > .ra-combo-group:first-child {
    padding-top: 0.3rem;
}

/* The catalogue navigates by grouping, not by typing: one row of tabs names
   what is inside the manager, and More cores widens every one of them. The strip
   wraps rather than scrolls — a bar inside a tab row is worse than a second
   line, and overflow on a nav-tabs also earns a sliver of vertical scrollbar
   from the tab's own bottom border. */
.ra-core-bar {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    margin-bottom: 0.4rem;
}

.ra-core-tabs {
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
}

/* Bootstrap draws these: the strip is the Tools bar's nav-tabs, scaled to sit
   in the manager. The active tab is the only white thing in a muted row, which
   is enough to say which shelf you are reading without a second colour. */
.ra-core-tab {
    display: block;
    padding: 0.32rem 0.6rem;
    border-radius: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
    cursor: pointer;
}

.ra-core-tab:hover {
    color: #fff;
}

.ra-core-tab.active,
.ra-core-tab.active:hover {
    background: transparent;
    border-color: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.85);
    color: #fff;
}

.ra-core-tab-count {
    margin-left: 0.25rem;
    color: rgba(255, 255, 255, 0.4);
}

.ra-core-tab.active .ra-core-tab-count {
    color: rgba(255, 255, 255, 0.65);
}

/* The one switch beside the tabs: quiet until someone wants the lot. A plain
   checkbox, because it is not a tab and does not navigate — it never shrinks
   either, so the strip scrolls past it instead of pushing it down. */
.ra-core-legacy {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    line-height: 1;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
    cursor: pointer;
}

.ra-core-legacy:hover,
.ra-core-legacy:has(input:checked) {
    color: #fff;
}

/* The browser's own checkbox margin makes the bar taller than the tabs it
   sits beside, which is the last way this row can grow a scrollbar. */
.ra-core-legacy input {
    margin: 0;
}

/* A manager row is a name, its quiet description, then the chip that puts the
   build on this install. The row still picks a core; the chip is its own
   control, so it sits at the end and never stretches. */
.ra-combo--modal .ra-combo-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.22rem 0.5rem;
}

.ra-combo-row-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.ra-combo-row-name {
    color: #e9ecef;
}

.ra-combo-row-desc {
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.72rem;
}

/* Core rows carry the shell's chips. The one thing a .chip cannot know from
   its own class is that the core name is the column that gives way: chips
   keep their size. */
.ra-combo-row .chip {
    margin-left: 0.35rem;
}

/* Two rows under one Download are one install: the rule down their left says
   the button above is about both, while each row's quiet line says which set
   it reads. The rule spans the pair because the rows are adjacent. */
.ra-combo-row--set-pair {
    border-left: 2px solid rgba(255, 255, 255, 0.16);
}

.ra-combo-row {
    padding: 0.3rem 0.5rem;
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

/* An open row is two columns: the console the eye hunts for, then the core
   that builds it, quieter. No rule between them — the weight difference is
   the separation, so a scan down the list reads the consoles alone. */
.ra-combo-row--pair {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    align-items: baseline;
    column-gap: 0.75rem;
}

.ra-combo-row-console,
.ra-combo-row-core {
    overflow: hidden;
    text-overflow: ellipsis;
}

.ra-combo-row-core {
    font-size: 0.78rem;
    opacity: 0.62;
}

/* The row the list is on keeps its core at full weight — the dimming sets the
   pair apart, not the choice from the rest of the list. */
.ra-combo-row--chosen .ra-combo-row-core,
.ra-combo-row--active .ra-combo-row-core,
.ra-combo-row:hover .ra-combo-row-core {
    opacity: 1;
}

/* One mark sits at the row's right edge, outside the console/core pair, so a
   mark never pushes a core name out of view. It is the row's only icon
   column: the glyph's ring says the core is on the card, the glyph inside
   says the BIOS answer. Sized to the row's capital letters and dimmed until
   the row is hovered or chosen. Greys only — the shape says which state it
   is, not a colour. */
.ra-combo-row--pair {
    position: relative;
    padding-right: 1.7rem;
}

.ra-combo-row-mark {
    position: absolute;
    top: 50%;
    right: calc((1.7rem - 0.7rem) / 2);
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 0.7rem;
    line-height: 1.2;
    opacity: 0.5;
}

/* A dash is the quietest of the three: firmware the console plays without. */
.ra-combo-row-mark.is-optional {
    color: #6c757d;
}

/* The one file that stops a boot reads brightest. */
.ra-combo-row-mark.is-missing {
    color: #e9ecef;
    opacity: 0.85;
}

.ra-combo-row--chosen .ra-combo-row-mark,
.ra-combo-row--active .ra-combo-row-mark,
.ra-combo-row:hover .ra-combo-row-mark {
    opacity: 1;
}

.ra-combo-row-note {
    margin-left: 0.4rem;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}

.ra-combo-row:hover,
.ra-combo-row--active {
    background: rgba(13, 110, 253, 0.35);
}

.ra-combo-row--chosen {
    color: #6ea8fe;
    font-weight: 600;
}

.ra-combo-empty {
    padding: 0.4rem 0.5rem;
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.6);
}

/* ========================================
   TITLE ID BOX
   ======================================== */
/* The ID box is a search field so browsers stop offering saved logins in it;
   their own clear "×" would sit in the same corner as the refresh button's
   job, so the decorations are removed. */
#raTitleIdInput::-webkit-search-cancel-button,
#raTitleIdInput::-webkit-search-decoration,
#raTitleIdInput::-webkit-search-results-button,
#raTitleIdInput::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

/* The ID's verdict: one symbol inside the input group, right of the refresh, so
   it belongs to the box it describes rather than to a line under the whole row.
   Its words ride the tooltip and a screen-reader-only copy. */
.ra-titleid-status {
    background: transparent;
    border-left: 0;
    padding: 0 0.4rem 0 0.35rem;
    font-size: 0.95rem;
    line-height: 1;
}

.ra-titleid-status[hidden] {
    display: none !important;
}

/* The RetroArch pane's two ROM-folder boxes are an either/or: the one you
   drove stays lit, the other dims once one holds a path. It stays a working
   input — focus brings it straight back — so the dimming says "the pair is
   already answered", never "this box is off". */
.ra-root-dim {
    opacity: 0.45;
    transition: opacity 0.15s ease;
}

.ra-root-dim:focus-within {
    opacity: 1;
}

/* The name and tag fields are the same height as the buttons beside them: a
   Bootstrap .form-control is 38px against the buttons' 36px, which made each
   tab's control row a different height (70px, 67px, 75px across the panes). */
#stagingArea .tools-pane .form-control {
    font-size: 0.875rem;
}

/* ========================================
   GAME DETAILS - EDIT MODE
   ======================================== */

/* Pencil edit button in modal header */
#gameDetailsEditBtn {
    cursor: pointer;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.2s ease;
}

#gameDetailsEditBtn:hover {
    color: #0d6efd;
}

#gameDetailsEditBtn.active {
    color: #0d6efd;
}

/* Padding on the modal title */
#gameDetailsModalLabel {
    padding-right: 12px;
}

/* Tag edit mode - red scale for user tags */
.tag-badge-origin-user.tag-edit-mode {
    color: #dc3545 !important;
    background-color: #58151c !important;
    border: 1px solid #dc3545;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.tag-badge-origin-user.tag-edit-mode:hover {
    background-color: #7a1f2b !important;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
}

/* Tag edit mode - blue scale for admin tags */
.tag-badge-origin-admin.tag-edit-mode {
    color: #0d6efd !important;
    background-color: #0a1e3d !important;
    border: 1px solid #0d6efd;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.tag-badge-origin-admin.tag-edit-mode:hover {
    background-color: #12294d !important;
    box-shadow: 0 0 8px rgba(13, 110, 253, 0.5);
}

/* Fade-out animation for tag removal */
.tag-removing {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ========================================
   RETROARCH PANE - BULK LIST + FOLDER PICKER
   ======================================== */
/* Rows, not a multi-select: each ROM carries editable box art. */
.ra-selection-header {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ra-rom-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.375rem;
}

.ra-rom-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0;
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    cursor: pointer;
}

.ra-rom-row:last-child {
    border-bottom: 0;
}

.ra-rom-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* The placeholder icon sits under the art: a thumbnail the host does not have
   removes itself (onerror) and leaves this, instead of a broken-image glyph. */
.ra-rom-art {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    max-height: none;
    border: 0;
    padding: 0;
    border-radius: 0.25rem;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.35);
    overflow: hidden;
    cursor: pointer;
}

.ra-rom-art:focus-visible {
    outline: 2px solid #6ea8fe;
    outline-offset: 2px;
}

.ra-rom-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ra-rom-main {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.ra-rom-name {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ra-rom-sub {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The row the control row holds — the same blue the core list gives its chosen
   core, so a ticked row and the open one can never be read as the same thing. */
.ra-rom-row.is-current {
    background: rgba(13, 110, 253, 0.18);
}

/* Build state rides the row's right edge, out of the name's way. */
.ra-rom-badge {
    flex: 0 0 auto;
    min-width: 1rem;
    text-align: center;
}

/* The card's own answer sits beside the name: it is about the file, not the
   row's state, so it never borrows the build badge's edge. */
.ra-rom-oncard {
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.6rem;
    font-size: 0.65rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.65);
    vertical-align: middle;
}

/* A missing core rides the first game it would stop, not a line above the
   list: the warning names the core and keeps its words in the tooltip, so a
   long title still fits on one line. */
.ra-rom-warning {
    margin-left: 0.4rem;
    color: var(--bs-warning);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* ROM working-set rows use List view's shared size and icon selectors. */
.ra-working-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ra-working-row .list-icon {
    flex: 0 0 auto;
    max-height: none;
    object-fit: contain;
}

/* Folder picker: a folder is a button, so the whole row is the target. */
.ra-folder-list {
    display: flex;
    flex-direction: column;
    max-height: 45vh;
    overflow-y: auto;
}

.ra-folder-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: none;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    color: inherit;
    font-size: 0.875rem;
    text-align: left;
}

.ra-folder-row:hover,
.ra-folder-row:focus-visible {
    background: rgba(255, 255, 255, 0.08);
}

/* A row is the folder button plus, when the operator mapped it, the way back. */
.ra-folder-line {
    display: flex;
    align-items: center;
}

.ra-folder-line .ra-folder-row {
    flex: 1;
    min-width: 0;
}

/* What a folder feeds, on the row itself: a placed folder says its console
   without being opened, and the tooltip says whether the name, the files, or
   a saved link is what placed it. */
.ra-folder-system {
    flex: 0 0 auto;
    padding: 0 0.4rem 0 0.2rem;
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    white-space: nowrap;
}

.ra-folder-unmap {
    padding: 0 0.6rem;
    background: none;
    border: 0;
    color: var(--bs-secondary-color);
    font-size: 1rem;
    line-height: 1;
}

.ra-folder-unmap:hover,
.ra-folder-unmap:focus-visible {
    color: var(--bs-body-color);
}

/* The picker's only question: the folders neither a name nor the files inside
   them could place. Each row is the name as a way in, what its files look
   like, and the console it holds — a placed folder is never asked about. */
.ra-folder-conflicts {
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.5rem 0.5rem;
    border: 1px solid rgba(255, 193, 7, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(255, 193, 7, 0.06);
}

.ra-folder-conflicts-head {
    margin-bottom: 0.25rem;
    color: var(--bs-warning);
    font-size: 0.8rem;
}

.ra-folder-conflict {
    gap: 0.5rem;
}

.ra-folder-conflict .ra-folder-row {
    flex: 1 1 12rem;
    min-width: 0;
    border-bottom: 0;
}

.ra-folder-guess {
    flex: 0 1 10rem;
    overflow: hidden;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A link that contradicts the folder: the reasons beside the row, with "Link
   anyway" and "Cancel" the same weight so neither is the easy path. */
.ra-folder-warning {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.35rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 193, 7, 0.1);
    font-size: 0.78rem;
}

.ra-folder-warning-text {
    flex: 1 1 14rem;
    color: var(--bs-body-color);
}

.ra-folder-conflict .ra-folder-map {
    flex: 0 0 9rem;
    max-width: 9rem;
}

/* ========================================
   ROMS PAGE - one section per configured folder
   ======================================== */
/* The system strip: one tab per folder, in Tools ▸ RetroArch's console order.
   It wraps instead of scrolling, because a hidden tab would be a system the
   page never names; the counts ride the label so the strip also says how much
   is behind each one before it is opened. */
.roms-system-bar {
    margin-bottom: 0.75rem;
}

.roms-system-tabs {
    flex-wrap: wrap;
}

.roms-system-tab {
    padding: 0.35rem 0.65rem;
    border-radius: 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}

.roms-system-tab:hover {
    color: var(--text-primary);
}

.roms-system-tab.active,
.roms-system-tab.active:hover {
    background: transparent;
    border-color: transparent;
    border-bottom-color: var(--text-primary);
    color: var(--text-primary);
}

.roms-system-tab-count {
    margin-left: 0.3rem;
    color: rgba(255, 255, 255, 0.4);
}

.roms-system-tab.active .roms-system-tab-count {
    color: var(--text-secondary);
}

/* The page is a stack of systems, not one list: a folder is the unit a person
   thinks in ("my NES games"), and the art tail is per folder because the set
   behind it is. Tiles are square boxes so a mixed set of box fronts, screens
   and icons still lines up. */
.roms-system {
    margin-bottom: var(--spacing-lg);
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
}

.roms-system-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}

.roms-system-name {
    font-size: 0.95rem;
    font-weight: var(--font-weight-semibold);
}

.roms-system-sub {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.roms-system-path {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.roms-system-note {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* A genre in a row's metadata is the Genre filter's short path: it reads as
   part of the line until it is aimed at, then it lights up. */
.roms-genre-link {
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-decoration: none;
}

.roms-genre-link:hover,
.roms-genre-link:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
}

/* A console read from more than one folder: the console keeps the long form
   it always had, and each extra folder is its own tab with its name, count
   and card path. One row, because they describe the same console. */
/* A console read by more than one core (arcade's FBNeo and MAME): the set
   sub-tabs sit above the sections they scope, so the wall's own tab keeps
   naming the console and the line under it names the shelf. */
.roms-set-tabs {
    margin: 0 0 0.85rem;
}

/* Putting the player's spot back: the spot is reachable only as the shelves
   page in, and the page grows one fetch at a time, so the wall stays out of
   sight until it has landed. `visibility` keeps the rows laid out, so scrolling
   to the spot works while nothing is shown. */
html.roms-restoring #romsSystems {
    visibility: hidden;
}

.roms-folder-tabs {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
    flex-wrap: wrap;
    min-width: 0;
}

.roms-folder-tab {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    align-items: flex-start;
    gap: 0.1rem;
    min-width: 0;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 0.4rem;
    background: transparent;
    color: inherit;
    text-align: left;
}

.roms-folder-tab:hover {
    background: var(--bg-secondary);
}

.roms-folder-tab:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.roms-folder-tab.active {
    border-color: var(--color-primary);
    background: var(--bg-secondary);
}

.roms-folder-head {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    min-width: 0;
}

.roms-folder-tab .roms-system-sub {
    margin-left: 0;
}

.roms-folder-path {
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* Renaming a folder happens in its own tab, so the field reads as text
   with a cursor until it is focused. */
.roms-folder-tab [data-rom-folder-name] {
    border-bottom: 1px dotted transparent;
    outline: none;
    cursor: text;
}

.roms-folder-tab [data-rom-folder-name]:hover,
.roms-folder-tab [data-rom-folder-name]:focus {
    border-bottom-color: var(--text-secondary);
}

/* The bottom of a section that still has pages: a quiet line rather than a
   button, because reaching it is what asks for the next page. */
.roms-sentinel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.roms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.6rem;
}

.roms-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    padding: 0.35rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
}

.roms-tile-art {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    overflow: hidden;
}

.roms-tile-art img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.roms-tile-art:hover,
.roms-tile-art:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* The body is a button (it opens the details panel) and has to read as text. */
.roms-tile-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 0.15rem;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    width: 100%;
}

.roms-open {
    cursor: pointer;
}

.roms-open:hover .roms-tile-name,
.roms-open:hover > span:first-child,
.roms-open:focus-visible > span:first-child {
    text-decoration: underline;
}

.roms-tile-name {
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roms-tile-sub {
    /* Beside the body button rather than inside it, so it takes the padding the
       name had when they shared a box. */
    padding: 0 0.15rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Build state and the missing-art mark share one corner: both are a fact
   about the tile, and only one is ever true at a time. */
.roms-tile-mark {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    font-size: 0.75rem;
}

.rom-art-candidate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 7rem;
    margin: 0.25rem;
    padding: 0.4rem;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.rom-art-candidate:hover,
.rom-art-candidate:focus-visible {
    border-color: var(--color-primary, #0d6efd);
    color: var(--text-primary);
}

.rom-art-candidate img {
    object-fit: contain;
}

.rom-art-candidate span {
    text-align: center;
    overflow-wrap: anywhere;
}

/* The Library's other two view modes, on the same wall. Icon keeps the art as
   the subject and drops the second line; list turns each system into a table,
   because the catalog fields are what a row is for. */
.roms-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr));
    gap: 0.5rem;
}

.roms-icon {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.25rem;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
}

.roms-icon-art {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    overflow: hidden;
}

.roms-icon-art img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.roms-icon-art:hover,
.roms-icon-art:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.roms-icon-name {
    padding: 0 0.1rem;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
    width: 100%;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The catalog's line under an icon's name, the same fact the card carries. */
.roms-icon-sub {
    padding: 0 0.1rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roms-icon-mark {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    font-size: 0.7rem;
}

.roms-list {
    display: flex;
    flex-direction: column;
}

.roms-list-head,
.roms-list-row {
    display: grid;
    grid-template-columns: 2.5rem minmax(10rem, 2fr) 4rem minmax(6rem, 1fr) 5rem 2.25rem;
    gap: 0.5rem;
    align-items: center;
}

.roms-list-head {
    padding: 0.25rem 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* A column head is a sort control: plain text until it is aimed at. */
.roms-list-sort {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    white-space: nowrap;
}

.roms-list-sort i {
    font-size: 0.6rem;
    opacity: 0.5;
}

.roms-list-sort:hover,
.roms-list-sort:focus-visible,
.roms-list-sort.active {
    color: var(--text-primary);
}

.roms-list-sort.active i {
    opacity: 1;
}

.roms-list-row {
    padding: 0.3rem 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.roms-list-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.roms-list-art {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    overflow: hidden;
}

.roms-list-art img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.roms-list-art:hover,
.roms-list-art:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.roms-list-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    text-align: left;
}

.roms-list-name > span:first-child {
    font-size: 0.8125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roms-list-sub,
.roms-list-cell {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* An arcade set's path is its zip, not a game, so the row drops it and the
   DAT's title wraps into the line it would have taken. */
.roms-tile-name.roms-title-wrap,
.roms-list-name > span.roms-title-wrap {
    display: -webkit-box;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.roms-list-mark {
    justify-self: end;
    font-size: 0.8125rem;
}

.roms-filter-select {
    min-width: 11rem;
}

/* The details panel's cover: contained, never cropped, on the app's own tile
   background so a portrait box and a square icon both sit still. */
.roms-details-art {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.roms-details-art img {
    max-width: 100%;
    max-height: 20rem;
    object-fit: contain;
}

/* An NSP name plus its title ID is one long token; let it wrap in the panel. */
.roms-details-forwarder {
    word-break: break-word;
}

/* Below this width the catalog columns are the first thing to go: the title
   and its art are what a list is for, and the fields are still in the card and
   the picker's own metadata. */
@media (max-width: 900px) {
    .roms-list-head,
    .roms-list-row {
        grid-template-columns: 2.5rem minmax(8rem, 1fr) 4rem 2.25rem;
    }

    .roms-list-col-genre,
    .roms-list-col-players {
        display: none;
    }
}

/* ── The A–Z rail ──
   27 dots in a column one console icon wide, flush to the page's right edge
   and to the last card, so the index floats on the wall without a gutter of
   its own: `#` for the titles no letter can place, then A–Z. They are faint at
   rest — an index, not another row of controls — and vertical-centre. The
   letter is invisible until its dot is aimed at; the dot that is on keeps its
   letter, because the scoped wall has no heading of its own to say where you
   are. --dot is the 20px circle the rail is drawn at; a window too short for
   27 of them shrinks the dots rather than clipping the alphabet, and one too
   short for both the header and the jump-to-top button keeps shrinking until
   the column fits between them. */
/* The rail is a column exactly one icon tile wide, flush to the window edge,
   and the page reserves exactly that: one tile, no gutter left over. */
#romsPage {
    --rail-width: 40px;
    padding-right: calc(var(--rail-width) - 0.75rem);
}

.roms-letter-index {
    /* The console icons are the rail's widest tile, so they set its width; the
       dots follow the height budget. Both shrink on a short window instead of
       overflowing, and neither grows past the size the art reads well at. */
    --icon: clamp(16px, calc((100vh - 260px) / 19), var(--rail-width, 40px));
    --dot: clamp(10px, calc((100vh - 270px) / 28.5), 20px);
    --gap: 2px;
    position: fixed;
    /* That padding plus the container's 0.75rem is one tile, so the column is
       the tile's own width: it lands flush on the cards and on the window, not
       in a gutter sized by a guess. */
    width: var(--rail-width, 40px);
    right: 0;
    /* Centre between the header and the jump-to-top button, not on the
       viewport: on a short window the old 50% line pressed the console's icon
       into the header and the last dots onto the button. The header is as tall
       as its links wrap, so roms.js reads its foot into --rail-top; the 5.5rem
       below clears the 3rem button sitting 1.25rem off the bottom. */
    top: var(--rail-top, 5.5rem);
    bottom: 5.5rem;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;
    gap: var(--gap);
    overflow-y: auto;
    scrollbar-width: none;
}

.roms-letter-index [data-letter] {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--dot);
    height: var(--dot);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(122, 162, 247, 0.18);
    color: transparent;
    font: 600 calc(var(--dot) * 0.55)/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.roms-letter-index [data-letter]:hover,
.roms-letter-index [data-letter]:focus-visible {
    background: rgba(122, 162, 247, 0.8);
    color: #0b1020;
    transform: scale(1.12);
}

.roms-letter-index [data-letter]:focus-visible {
    outline: 2px solid #7aa2f7;
    outline-offset: 1px;
}

/* The clicked letter stays legible: it is the marker of what the wall shows. */
.roms-letter-index [data-letter].is-active {
    background: rgba(122, 162, 247, 0.9);
    color: #0b1020;
}

/* With no letter on, the dot the wall starts at is a hint, not a choice: a
   ring rather than the filled marker a click leaves behind. */
.roms-letter-index [data-letter].is-start {
    box-shadow: inset 0 0 0 1.5px rgba(122, 162, 247, 0.85);
}

/* A letter the painted wall does not hold yet is a dot, not a dead control. */
.roms-letter-index [data-letter]:disabled {
    opacity: 0.35;
    cursor: default;
}

.roms-letter-index [data-letter]:disabled:hover {
    background: rgba(122, 162, 247, 0.18);
    color: transparent;
    transform: none;
}


/* Under All the rail is the shelf itself: one icon per console, in the tab
   strip's order, so the index is the strip read beside the rows instead of
   above them. The tiles are the widest thing in the rail and the column is
   centred on them in both modes, so the letters stay in the same lane when a
   console is opened. A shelf reads as a stack, so its tiles sit a little
   further apart than the letter dots. */
.roms-letter-index[data-rail-mode="consoles"] {
    gap: 3px;
}

.roms-letter-index::-webkit-scrollbar {
    display: none;
}

.roms-letter-index .roms-rail-console {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--icon);
    height: var(--icon);
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.12s ease, transform 0.12s ease;
}

.roms-letter-index .roms-rail-console:hover,
.roms-letter-index .roms-rail-console:focus-visible {
    background: rgba(122, 162, 247, 0.25);
    transform: scale(1.12);
}

.roms-letter-index .roms-rail-console:focus-visible {
    outline: 2px solid #7aa2f7;
    outline-offset: 1px;
}

.roms-letter-index .roms-rail-console img,
.roms-letter-index .roms-rail-pin img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.roms-letter-index .roms-rail-initial {
    color: rgba(226, 232, 240, 0.75);
    font: 600 calc(var(--icon) * 0.38)/1 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* The console whose alphabet this is, pinned above `#`: the tabs say it too,
   but the rail is where the letters are read. */
.roms-letter-index .roms-rail-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--icon);
    height: var(--icon);
    opacity: 0.9;
}

/* A phone has no right gutter to spend, so the rail docks above the bottom
   edge as a strip: the letters stay one tap away and the rows keep their
   width. The jump-to-top button steps up over it. */
@media (max-width: 767.98px) {
    .roms-letter-index {
        --icon: 26px;
        --dot: 20px;
        width: auto;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        max-height: none;
        flex-direction: row;
        justify-content: flex-start;
        gap: 4px;
        padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
        overflow-x: auto;
        overflow-y: hidden;
        border-top: 1px solid var(--border-color);
        background: var(--bs-body-bg);
    }

    /* A strip wider than the phone scrolls; it does not squeeze the dots. */
    .roms-letter-index > * {
        flex: 0 0 auto;
    }

    #romsPage {
        padding-right: 1rem;
        padding-bottom: 4rem;
    }

    .back-to-top {
        bottom: calc(3.5rem + env(safe-area-inset-bottom, 0px));
    }
}

/* A finger has no hover to reveal a dot's letter, so on a touch screen the
   strip says its letters outright. */
@media (max-width: 767.98px) and (hover: none) {
    .roms-letter-index [data-letter] {
        background: rgba(122, 162, 247, 0.14);
        color: rgba(226, 232, 240, 0.8);
        font-size: calc(var(--dot) * 0.6);
    }
}

/* The wall's play-together chips: one per game somebody is sharing. They sit
   on the search row, right of the switches, so "who is playing" is one click
   from the library it is playing from. */
#romsPlayers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 34rem;
}

#romsPlayers[hidden] { display: none; }

.roms-player-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 22rem;
    padding: 4px 10px 4px 8px;
    border: 1px solid var(--border-color, #343a46);
    border-radius: 999px;
    background: rgba(122, 162, 247, 0.12);
    color: var(--bs-body-color, #e2e8f0);
    font-size: 0.8rem;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
}

.roms-player-chip:hover,
.roms-player-chip:focus-visible {
    border-color: var(--bs-primary, #7aa2f7);
    background: rgba(122, 162, 247, 0.2);
    color: inherit;
    text-decoration: none;
}

.roms-player-chip-name { font-weight: 600; }

.roms-player-chip-game {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.roms-player-chip-dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ece6a;
    box-shadow: 0 0 0 3px rgba(158, 206, 106, 0.18);
}
