/* CatTail Component Styles */

/* ========================================
   STAT CARDS (Analytics Bar)
   ======================================== */
.stat-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    min-width: 100px;
}

.stat-value {
    display: block;
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    line-height: var(--line-height-tight);
}

.stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   GAME CARDS
   ======================================== */
.game-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg) !important;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.game-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-card-hover);
}

.game-card__image {
    width: 100%;
    height: auto;
    display: block;
    mask-image: var(--bg-card-gradient);
    -webkit-mask-image: var(--bg-card-gradient);
}

/* Migrated from the retired static/style.css. The plain Bootstrap card keeps
   the 8px corner, and the artwork image built in views.js
   (`<img class="card-img">`) keeps its fade-out and rounded bottom corners. */
.card {
    border-radius: var(--radius-lg) !important;
}

.card-img {
    mask-image: linear-gradient(to top, rgba(7, 0, 91, 0.71), #001233ed);
    border-bottom-right-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-lg);
}

/* Card Custom Overlay */
.card-custom-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.card-custom-overlay>* {
    pointer-events: auto;
}

/* Top Badges (Category & Type) */
.top-badges {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--game-card-badge-gap);
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 20;
    overflow: hidden;
}

.category-container {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--game-card-badge-gap);
}

.right-badges-container {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--game-card-badge-gap);
}

/* Bottom Overlay (Title & Size) */
.bottom-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-overlay);
    padding: var(--game-card-overlay-padding);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 20;
}

.title-container {
    flex: 1;
    min-width: 0;
}

.game-title {
    font-size: var(--game-card-title-size);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.size-text {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    margin-left: var(--spacing-sm);
}

/* ========================================
   BADGES
   ======================================== */
.game-tag {
    font-size: 0.8rem;  /* Fixed — never scaled by sliders, matches .chip standard */
    padding: 4px 10px;
    margin-right: 2px;
    border-radius: 20px;
    font-weight: 500;
    line-height: 1.4;
}

/* Game Details modal: override badge sizing to match .chip standard (0.8rem, pill shape, 500 weight) */
#gameDetailsModal .game-tag {
    font-size: 0.8rem !important;
    padding: 4px 10px !important;
    border-radius: 20px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
}

.category-badge {
    background-color: var(--color-secondary);
    color: var(--text-primary);
}

.version-tag {
    cursor: pointer;
}

/* Update-history panel — the popover on a version chip.

   One scroll region, and only when the list would leave the screen. The
   global .popover-body cap (200px) fought the list's own max-height, which is
   what produced two vertical scrollbars, and the list's min-width (15rem)
   pushed past the popover's 276px width for the horizontal one on top. The
   rows are plain and the badge carries the meaning, so nothing here fills a
   colored block per row. */
.popover-update-history { --bs-popover-max-width: 24rem; }
.popover-update-history .popover-body { max-height: none; overflow: visible; }
.update-history { max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
.update-history-row {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 0.35rem 0;
}
.update-history-row + .update-history-row { border-top: 1px solid var(--border-color); }
.update-history-version { white-space: nowrap; font-variant-numeric: tabular-nums; }
.update-history-facts { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.update-history-facts .badge { font-size: 0.7rem; }
.update-history-installed { font-size: 0.8rem; }

/* Badge Size Scaling — removed: all .game-tag badges now use fixed 0.8rem (matches .chip standard) */

/* Allow badges to wrap on smallest cards */
.card-size-1 .category-container,
.card-size-1 .right-badges-container {
    flex-wrap: wrap;
}

/* Title Scaling */
.card-size-1 .game-title {
    font-size: 0.65rem;
}

.card-size-2 .game-title {
    font-size: 0.8rem;
}

.card-size-3 .game-title {
    font-size: 0.95rem;
}

.card-size-4 .game-title {
    font-size: 1.1rem;
}

.card-size-5 .game-title {
    font-size: 1.25rem;
}

/* Size Text Scaling */
.card-size-1 .size-text {
    font-size: 0.6rem;
}

.card-size-2 .size-text {
    font-size: 0.75rem;
}

.card-size-3 .size-text {
    font-size: 0.9rem;
}

.card-size-4 .size-text {
    font-size: 1.1rem;
}

.card-size-5 .size-text {
    font-size: 1.3rem;
}

/* ========================================
   ICON VIEW
   ======================================== */
.icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    /* Needed for absolute positioning of add-mode checkbox */
}

.icon-wrapper:hover {
    background: var(--bg-secondary);
    transform: scale(1.1);
}

/* Ensure add-mode checkboxes are always visible in icon view */
.icon-wrapper.add-mode-active .add-mode-checkbox-container {
    opacity: 1 !important;
    visibility: visible !important;
}

.game-icon {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

/* ========================================
   LIST VIEW
   ======================================== */
.list-header-row {
    display: grid;
    /* Two kinds of track, because the two kinds of column have two different
       real minimums.

       The six status columns hold content of a fixed size — a 20px checkbox, a
       thumbnail at the current list size, a chip whose font is deliberately not
       slider-scaled. Their minimum is their content's own, so it is written as
       `min-content` and derived rather than chosen. Each track keeps its former
       width as a cap and gives way only under pressure, which is what retires
       the permanent dead space a px track held (section 3b of
       docs/responsive-conventions.md). Note that a max below the minimum is
       ignored, so the cap is a cap and not a wall — a column never clips to
       honour it. The bar's labels are content too, so a track gives way only as
       far as its widest of the two ("UPDATE" is wider than the chip under it).

       Title and Category are the opposite: they hold unbounded text. A title in
       the default nowrap mode has no soft-wrap opportunity, so its min-content
       is the WHOLE string, which is a useless minimum — `min-content` there
       would demand the full title's width. They carry a chosen floor instead
       (--list-*-floor, raised under the mobile seam in views.css).

       `auto` is deliberately not used as a minimum here even where it would look
       equivalent: it resolves to the item's min-width, and every list cell sets
       min-width: 0, which is exactly how a bare fr collapsed to 0px before the
       floors existed. (fit-content() has the same problem — its minimum is an
       auto minimum. min-content does not read min-width.)

       In list mode the wrapper above owns this track set outright and the bar
       and the rows become subgrids of it (views.css "one grid owns the tracks").
       They have to: `min-content` is resolved per grid, from that grid's own
       items, and the bar's contents are not the rows' — its icon cell is empty
       and its UPDATE cell holds the word where the row holds an icon-only chip.
       Two grids sharing this string therefore come out at different widths under
       pressure, which is what T17c measures. One grid resolves once, over the bar
       and every row together. This declaration remains the one the bar uses
       outside list mode, where it is a grid of its own.

       T19 checks the bar and row cells come out the same width and T17c that
       their left edges stay aligned; T20 checks the six derived tracks give way
       to their content, and that nothing clips when they do. */
    grid-template-columns: var(--list-template);
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* Card and Icon reuse the List sort bar, but their game tiles keep their
   own grid layout below it. */
.grid-container > .list-header-row {
    grid-column: 1 / -1;
    width: 100%;
}

.list-col-sortable {
    cursor: pointer;
    user-select: none;
}

.list-col-sortable:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.list-row {
    display: grid;
    /* Same template as .list-header-row above, derived minimums included — see
       the note there for why the six status tracks are min-content and the two
       text tracks carry a floor, and why list mode hands the track set over to
       the wrapper instead. */
    grid-template-columns: var(--list-template);
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background var(--transition-fast);
    cursor: pointer;
}


.list-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.list-col {
    display: flex;
    align-items: center;
    overflow: hidden;
    min-width: 0;
}

.list-col-type,
.list-col-version,
.list-col-dlc {
    justify-content: center;
}

.list-icon {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.list-title {
    font-size: var(--font-size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-badge {
    font-size: 0.8rem;  /* Fixed — matches .game-tag/.chip standard, never scaled by sliders */
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* List-view tag/category chips are a quick-filter action: clicking one narrows
   the library to that tag. The active chip marks the soft (temporary)
   narrowing, which is cleared by clicking it again or leaving List view. */
.list-tag-chip-clickable {
    cursor: pointer;
    transition: filter 0.12s ease, background-color 0.12s ease;
}

.list-tag-chip-clickable:hover {
    filter: brightness(1.15);
}

/* Keyboard focus is an accessibility affordance (Tab only), never the
   active-filter marker — so it is a distinct outline, not a white ring. */
.list-tag-chip-clickable:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

/* A tag that is in the active filter is marked by stepping its color to the
   third gray of the #9aa3ac → #586068 progression (#161d24), never by a ring.
   !important + (0,2,0) beats both the chip's inline identity color
   (tag.color) and Bootstrap's !important text-bg-secondary. */
.list-tag-chip-clickable.list-tag-chip-active {
    background-color: #161d24 !important;
    filter: none;
}

.list-size-text {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
}

/* List View Size Scaling */
#gameGrid.list-view[data-list-size="1"] .list-size-text {
    font-size: 0.7rem;
}

#gameGrid.list-view[data-list-size="2"] .list-size-text {
    font-size: 0.75rem;
}

#gameGrid.list-view[data-list-size="3"] .list-size-text {
    font-size: 0.85rem;
}

#gameGrid.list-view[data-list-size="4"] .list-size-text {
    font-size: 0.9rem;
}

#gameGrid.list-view[data-list-size="5"] .list-size-text {
    font-size: 0.95rem;
}

#gameGrid.list-view[data-list-size="6"] .list-size-text {
    font-size: 1rem;
}

#gameGrid.list-view[data-list-size="1"] .list-icon {
    width: 28px;
    height: 28px;
}

#gameGrid.list-view[data-list-size="2"] .list-icon {
    width: 36px;
    height: 36px;
}

#gameGrid.list-view[data-list-size="3"] .list-icon {
    width: 48px;
    height: 48px;
}

#gameGrid.list-view[data-list-size="4"] .list-icon {
    width: 64px;
    height: 64px;
}

#gameGrid.list-view[data-list-size="5"] .list-icon {
    width: 80px;
    height: 80px;
}

#gameGrid.list-view[data-list-size="6"] .list-icon {
    width: 96px;
    height: 96px;
}

/* ========================================
   FILTERS DROPDOWN
   ======================================== */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.category-filters .form-check {
    margin-bottom: 2px;
}

.category-filters .form-check-label {
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.dropdown-menu {
    max-height: 80vh;
    overflow-y: auto;
}

/* Redesigned dropdown menu */
.filter-dropdown-menu {
    width: min(520px, calc(100vw - 1rem));
    max-width: calc(100vw - 1rem);
    padding: 0.5rem 0.75rem;
    max-height: 70vh;
}

/* Filter sections */
.filter-section {
    padding: 0.25rem 0.5rem;
}

.filter-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary, rgba(255,255,255,0.5));
    margin-bottom: 0.35rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Two-column grid for Game Info / Status */
.filter-columns-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

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

/* Each filter row: label + control */
.filter-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.filter-row-label {
    font-size: 0.7rem;
    color: var(--text-secondary, rgba(255,255,255,0.6));
    min-width: 40px;
    flex-shrink: 0;
    font-weight: 500;
}

/* Extra small button group sizing */
.btn-group-xs .btn-xs {
    font-size: 0.8125rem;
    padding: 0.15rem 0.4rem;
    line-height: 1.3;
}

.form-select-xs {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    height: auto;
}

.form-control-xs {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    height: auto;
}

/* Release-year bars under the Year select.

   One bar per selectable year; the bar itself carries --year-fill (a
   percentage of the track) and data-count, so the height and the number
   cannot drift from the markup a test asserts. */
.year-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    margin: 0.3rem 0 0.4rem;
    padding: 0 0.1rem;
}

.year-bar {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 0;
    background: none;
    border: 0;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary, rgba(255, 255, 255, 0.6));
}

.year-bar-count {
    font-size: 0.5625rem;
    opacity: 0.8;
}

.year-bar-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 26px;
}

.year-bar-fill {
    width: 100%;
    height: var(--year-fill, 0%);
    min-height: 2px;
    border-radius: 2px 2px 0 0;
    background: rgba(255, 255, 255, 0.18);
    transition: background 0.15s ease;
}

/* A year with nothing in it keeps its stub (the axis stays readable). */
.year-bar.is-empty .year-bar-fill {
    background: rgba(255, 255, 255, 0.07);
}

.year-bar:hover .year-bar-fill {
    background: rgba(13, 110, 253, 0.5);
}

.year-bar.active .year-bar-fill {
    background: var(--color-primary);
}

.year-bar.active {
    color: var(--color-primary);
    font-weight: 600;
}

.year-bar-label {
    font-size: 0.5625rem;
    opacity: 0.7;
}

/* Tag filter chips */
.filter-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    max-height: 120px;
    overflow-y: auto;
    padding: 0.15rem 0;
}

.filter-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    line-height: 1.3;
}

.filter-tag-chip:hover {
    background: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.3);
    color: var(--color-primary);
}

.filter-tag-chip.active {
    background: rgba(13, 110, 253, 0.15);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Tag origin dot indicator */
.tag-origin-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    margin-right: 0.15rem;
}

.tag-origin-user {
    background: #868e96;
}

.tag-origin-admin {
    background: #5c636a;
}

/* Tag origin dot inside filter tag chips */
.filter-tag-chip .tag-origin-dot {
    width: 4px;
    height: 4px;
    opacity: 0.7;
}

/* Active filter button styling */
.btn-check:active+.btn-outline-primary,
.btn-check:focus+.btn-outline-primary,
.btn-check:checked+.btn-outline-primary {
    background-color: var(--color-primary);
    color: var(--text-primary);
    outline: none;
    border-color: var(--color-primary);
}

/* Two-button segmented filter group: toggle icon (left) + dropdown trigger (right). */
.filter-btn-group > .btn {
    position: relative;
}

/* All-filters toggle inside the dialog header. */
#filterToggleBtn {
    border-radius: 0.375rem;
    padding-left: 10px;
    padding-right: 10px;
}

/* Remove focus outline/ring on click/active */
#filterToggleBtn:focus,
#filterToggleBtn:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Funnel trigger is the left segment of the search input group. */
#filterDropdownBtn {
    border-radius: 0.375rem 0 0 0.375rem;
    padding-left: 10px;
    padding-right: 10px;
}

#filterDropdownBtn::after {
    display: none !important;
}

/* Filter button rest state, like the unselected view buttons: dim until
   hovered or with its menu open. Deliberately CONSTANT — the dim must not
   track filter state; the filled/outline funnel glyph is the only
   active-filter signal on this button. */
#filterDropdownBtn {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

#filterDropdownBtn:hover,
#filterDropdownBtn[aria-expanded="true"] {
    opacity: 0.85;
}

/* Filter icon styling */
#filterToggleBtn i {
    transition: opacity 0.2s ease;
}

/* Prevent the border from doubling up inside the group */
.filter-btn-group > .btn + .btn {
    border-left: none;
}

.btn-group:focus-within,
.btn-group:active,
.btn-group:focus,
.filter-btn-group:focus-within,
.filter-btn-group:active,
.filter-btn-group:focus,
.dropdown-item:active,
.dropdown-item:focus {
    background: none;
    box-shadow: none;
}

/* Combined Library search control: input, clear, and pause/enable live together. */
.library-search-control {
    min-width: 0;
}

/* The template moves this wrapper into the input group so the controls are
   flush. It is deliberately not a Bootstrap `.col-auto`: column padding is
   for `.row` children and creates a gap when nested in an input group. */
.library-filter-control {
    flex: 0 0 auto;
    padding: 0;
    margin-right: -1px;
    position: relative;
    /* Must float above the grid's card overlays. `.game-card` is
       position:relative with z-index:auto, so it creates NO stacking context —
       its absolutely-positioned children (.card-custom-overlay /
       .bottom-overlay, z-index 10–50) compete in the SAME stacking context as
       this control. A z-index of 1 let a card's name/size overlay paint over
       the open filter menu. --z-sticky (1020) clears all page content while
       staying below fixed chrome and modals. */
    z-index: var(--z-sticky);
}

.library-search-input-group > .library-filter-control {
    padding-left: 0;
    padding-right: 0;
}

.filter-funnel-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.library-search-input-group > .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.filter-dialog-header {
    padding: 8px 12px 6px;
}

.library-search-input-group {
    width: 280px;
}

.library-search-input-group .search-clear-btn,
.library-search-input-group .search-toggle-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.library-search-input-group .search-clear-btn i {
    font-size: 0.75rem;
}

.library-search-input-group .search-toggle-btn i {
    font-size: 1.15rem;
}

/* Search toggle button */
.search-toggle-btn {
    min-width: 28px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* "Off" state for the search toggle. Deliberately NOT the Bootstrap
   `.disabled` class: that sets pointer-events: none and would make the
   toggle impossible to click back on. This is visual-only. */
.search-toggle-btn.search-toggle-off {
    opacity: 0.4;
}

.search-toggle-btn i {
    font-size: 0.8rem;
}

/* Search paused state for the toolbar input: faded, but still focusable
   and typable — typing into it is what resumes the search (see
   _onSearchInput). pointer-events must stay enabled; the old
   pointer-events:none made the pause a dead end only the toggle could
   undo. */
#textFilter.search-disabled,
#romsSearch.search-disabled {
    opacity: 0.35;
}

@media (max-width: 768px) {
    .library-search-input-group {
        width: min(100%, 280px);
    }
}

/* ========================================
   BUTTONS
   ======================================== */
.view-toggle-btn {
    min-width: 40px;
}

/* Active view button: #0d6efd background with white text/icon (same as Filters button).
   Override Bootstrap's .btn-primary.active which darkens the background to #0a58ca.
   Inactive view buttons: slightly faded to indicate they're not selected.
   The visual difference is a subtle opacity fade — no box/highlight border. */
.view-toggle-btn.active {
    background-color: var(--color-primary) !important;
    border-color: var(--color-primary) !important;
    color: var(--color-white) !important;
}

.view-toggle-btn:not(.active) {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.view-toggle-btn:not(.active):hover {
    opacity: 0.85;
}

/* ========================================
     NAVBAR ENHANCEMENTS
     ======================================== */
.navbar-brand img {
    vertical-align: middle;
    margin-bottom: 0;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Inline nav links inside brand - grouped with dynamic mode label */
.navbar-nav-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: 0.15rem;
}

/* Each word is always as wide as it will be when it is the active one: the
   semibold highlight is a real width change, and without this every word to
   its right jumped ~6px as the highlight moved. The ::after below is an
   invisible copy of the label, in the active weight, stacked under the
   visible text. data-label must match the link text; the header layout test
   checks every link. */
.nav-link-inline {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    white-space: nowrap;
    font-size: 20px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: color 0.15s ease-in-out;
}

.nav-link-inline:hover {
    color: #ffffff;
}

.nav-link-inline.active {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
}

/* The width reservation described above: same label, same font, no height. */
.nav-link-inline::after {
    content: attr(data-label);
    display: block;
    height: 0;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    font-weight: var(--font-weight-semibold);
}

.navbar .nav-link {
    font-size: 20px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.navbar .nav-link.active {
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary) !important;
}

/* Navbar navigation - new flex layout */
.navbar-spacer {
    flex: 1 1 auto;
    min-width: 0.5rem;
}

.navbar-right-section {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
}

/* Force navbar-nav items to display in a row, not column */
.navbar-right-section>.navbar-nav,
.navbar-right-section>.navbar-nav-left,
.navbar-right-section>.navbar-nav-right,
.navbar-right-section>.navbar-stats {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0;
    padding: 0;
}

/* Allow wrapping only on smaller screens */
@media (max-width: 991.98px) {
    .navbar-right-section {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .navbar-right-section>.navbar-nav,
    .navbar-right-section>.navbar-nav-left,
    .navbar-right-section>.navbar-nav-right {
        flex-wrap: wrap;
    }
}

/* Progressive stat scaling - keep text size, just reduce padding/min-width */
@media (max-width: 1200px) {
    .nav-stat-item {
        padding: 0 0.6rem;
        min-width: 62px;
    }
}

@media (max-width: 991.98px) {
    .nav-stat-item {
        padding: 0 0.45rem;
        min-width: 55px;
    }
}

@media (max-width: 767.98px) {
    .nav-stat-item {
        padding: 0 0.35rem;
        min-width: 48px;
    }
}

@media (max-width: 600px) {
    .nav-stat-item {
        padding: 0 0.25rem;
        min-width: 42px;
    }
}

@media (max-width: 480px) {
    .nav-stat-item {
        padding: 0 0.2rem;
        min-width: 38px;
    }
}

/* The title slot is as wide as the longest title ("CatTail Analytics"), so
   the nav words beside the brand keep one x-position on every page instead
   of sliding left whenever the title is shorter. Both titles share a single
   grid cell; the sizer is the invisible widest one and only sets the width. */
.navbar-title-slot {
    display: inline-grid;
    align-items: center;
    flex: 0 0 auto;
    min-width: 0;
}

.navbar-title-slot > .navbar-title {
    grid-area: 1 / 1;
}

.navbar-title-sizer {
    visibility: hidden;
    pointer-events: none;
}

/* Navbar Title Styling - fixed size, never changes */
.navbar-title {
    font-size: 20px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    color: #fff;
    margin-left: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}



/* ========================================
   FORM ELEMENTS
   ======================================== */
.form-control-code {
    font-family: var(--font-family-monospace);
    font-size: var(--font-size-sm);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* ========================================
   POPOVER & TOOLTIP
   ======================================== */
.popover-body {
    max-height: 200px;
    overflow-y: auto;
}

/* The update-history panel opts out of the cap above and manages its own
   height — see .popover-update-history, next to the row styles. */

/* Bootstrap's dark theme gives tooltips a WHITE box (--bs-tooltip-bg resolves
   to emphasis-color), which reads as a pale beige flash over this dark page.
   Pin them to a surface darker than the body instead, so a tooltip looks like
   the panel it floats over rather than a light patch. */
.tooltip {
    --bs-tooltip-bg: #12161a;
    --bs-tooltip-color: var(--color-light);
}

/* The stat tooltips carry more than one line (the format the library is
   mostly in, then a size per duplicate format). Bootstrap writes the title as
   textContent, so newlines arrive intact — pre-line is what keeps them instead
   of collapsing the stack into one run. */
.tooltip-nav-stat .tooltip-inner {
    white-space: pre-line;
    text-align: left;
}

/* One idea per line needs room per line: at Bootstrap's 200px default the
   format line wrapped mid-format, which is the thing the line breaks exist to
   avoid. Only the stat tooltips are widened. */
.tooltip-nav-stat {
    --bs-tooltip-max-width: 24rem;
}



/* ========================================
   ADD MODE CHECKBOXES
   ======================================== */

/* Card view: checkbox wrapper appended directly to card (outside overlay) */
.add-mode-checkbox-wrapper {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 50;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    cursor: pointer;
}

/* Icon view: checkbox container inside icon-wrapper */
.add-mode-checkbox-container {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 50;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    cursor: pointer;
}

/* Keep the checkbox itself visible but smaller within the larger container */
/* Use pointer-events: none so all clicks go to the wrapper/container */
.add-mode-checkbox-wrapper .add-mode-checkbox,
.add-mode-checkbox-container .add-mode-checkbox {
    width: 20px;
    height: 20px;
    margin: 0;
    pointer-events: none;
}

.add-mode-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #0d6efd;
    margin: 0;
    padding: 0;
}

/* Scale checkbox clickable area with card size (card view wrapper) */
.card-size-1 .add-mode-checkbox-wrapper {
    width: 36px;
    height: 36px;
}

.card-size-2 .add-mode-checkbox-wrapper {
    width: 40px;
    height: 40px;
}

.card-size-3 .add-mode-checkbox-wrapper {
    width: 48px;
    height: 48px;
}

.card-size-4 .add-mode-checkbox-wrapper {
    width: 56px;
    height: 56px;
}

.card-size-5 .add-mode-checkbox-wrapper {
    width: 64px;
    height: 64px;
}

.card-size-6 .add-mode-checkbox-wrapper {
    width: 72px;
    height: 72px;
}

/* Scale checkbox clickable area with card size (icon view container) */
.card-size-1 .add-mode-checkbox-container {
    width: 36px;
    height: 36px;
}

.card-size-2 .add-mode-checkbox-container {
    width: 40px;
    height: 40px;
}

.card-size-3 .add-mode-checkbox-container {
    width: 48px;
    height: 48px;
}

.card-size-4 .add-mode-checkbox-container {
    width: 56px;
    height: 56px;
}

.card-size-5 .add-mode-checkbox-container {
    width: 64px;
    height: 64px;
}

.card-size-6 .add-mode-checkbox-container {
    width: 72px;
    height: 72px;
}

/* Scale checkbox size with card size (for card/icon views) */
.card-size-1 .add-mode-checkbox {
    width: 16px;
    height: 16px;
}

.card-size-2 .add-mode-checkbox {
    width: 18px;
    height: 18px;
}

.card-size-3 .add-mode-checkbox {
    width: 20px;
    height: 20px;
}

.card-size-4 .add-mode-checkbox {
    width: 24px;
    height: 24px;
}

.card-size-5 .add-mode-checkbox {
    width: 28px;
    height: 28px;
}

.card-size-6 .add-mode-checkbox {
    width: 32px;
    height: 32px;
}

/* Scale checkbox size for list view (uses data-list-size instead of card-size) */
#gameGrid.list-view[data-list-size="1"] .add-mode-checkbox {
    width: 16px;
    height: 16px;
}

#gameGrid.list-view[data-list-size="2"] .add-mode-checkbox {
    width: 18px;
    height: 18px;
}

#gameGrid.list-view[data-list-size="3"] .add-mode-checkbox {
    width: 20px;
    height: 20px;
}

#gameGrid.list-view[data-list-size="4"] .add-mode-checkbox {
    width: 24px;
    height: 24px;
}

#gameGrid.list-view[data-list-size="5"] .add-mode-checkbox {
    width: 28px;
    height: 28px;
}

#gameGrid.list-view[data-list-size="6"] .add-mode-checkbox {
    width: 32px;
    height: 32px;
}

.add-mode-active {
    outline: none;
}

/* Related content indicator - yellow border */
.related-content-item {
    outline: 2px solid #ffc107 !important;
    outline-offset: 2px;
}

/* Icon view related content indicator */
.icon-wrapper.related-content-item {
    border: 2px solid #ffc107;
    outline: none;
}

/* List view checkbox column - hidden in normal mode, shown in Add Mode */
.list-col-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    min-width: 40px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

/* Show checkbox column in Add Mode with fade animation */
#gameGrid.add-mode-active .list-col-checkbox {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    animation: checkboxFadeIn 0.3s ease-in-out;
}

/* Always show checkbox column in staging area (independent of add-mode-active) */
#stagingListContainer .list-col-checkbox {
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Ensure staging checkboxes are visible and clickable */
#stagingListContainer .form-check-input {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer;
}

/* Fade-in animation for checkboxes */
@keyframes checkboxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Header checkbox styling */
.list-header-row .header-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #0d6efd;
    margin: 0;
    padding: 0;
}

/* Scale header checkbox with card size (for card/icon views) */
.card-size-1 .list-header-row .header-checkbox {
    width: 16px;
    height: 16px;
}

.card-size-2 .list-header-row .header-checkbox {
    width: 18px;
    height: 18px;
}

.card-size-3 .list-header-row .header-checkbox {
    width: 20px;
    height: 20px;
}

.card-size-4 .list-header-row .header-checkbox {
    width: 24px;
    height: 24px;
}

.card-size-5 .list-header-row .header-checkbox {
    width: 28px;
    height: 28px;
}

.card-size-6 .list-header-row .header-checkbox {
    width: 32px;
    height: 32px;
}

/* Header checkbox for list view - always stays at compact size regardless of
   slider. The bar is a sibling of #gameGrid inside #gridContainer
   (renderListHeader), so it is matched through the container; `list-scroll`
   marks the List view. */
#gridContainer.list-scroll .list-header-row .header-checkbox {
    width: 16px;
    height: 16px;
}

/* ========================================
   HIDE BADGES FEATURE
   ======================================== */
#gameGrid.hide-badges .top-badges {
    display: none !important;
}

/* The Hide toggle: the card tiles' bottom banner (title + size), which is the
   only place card view names the game. Card view is the only view that draws
   one, so the toggle is disabled everywhere else. */
#gameGrid.hide-card-overlay .bottom-overlay {
    display: none !important;
}

/* ========================================
   SELECTION COUNTER (Add Mode)
   ======================================== */
.selection-counter-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 2px var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    min-width: 120px;
}

.selection-counter-value {
    font-size: 2rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-success);
    line-height: 1;
    margin: 0;
    padding: 0;
}

.selection-counter-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--font-weight-semibold);
    line-height: 1;
}

/* ========================================
   NAVBAR STATS
   ======================================== */
.nav-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.75rem;
    min-width: 70px;
    flex-shrink: 0;
    /* Prevent stats from shrinking below min-width */
}

.nav-stat-value {
    /* Main and duplicate values share one grid cell. The grid's max-content
       sizing reserves space for whichever value is wider, so hover cannot
       resize the navbar or move the pointer target. */
    display: grid;
    grid-template-columns: max-content;
    grid-template-rows: 1em;
    align-items: center;
    justify-items: end;
    font-size: 1.15rem;
    font-weight: var(--font-weight-bold);
    color: var(--color-primary);
    cursor: default;
}

.nav-stat-main,
.nav-stat-duplicate {
    grid-column: 1;
    grid-row: 1;
    text-align: right;
    white-space: nowrap;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.nav-stat-duplicate {
    opacity: 0;
    color: rgb(255, 218, 106);
}

.nav-stat-item.show-duplicate .nav-stat-main {
    opacity: 0;
}

.nav-stat-item.show-duplicate .nav-stat-duplicate {
    opacity: 1;
}

.nav-stat-item.show-duplicate .nav-stat-value {
    color: rgb(255, 218, 106);
}

/* Label row holds the optional duplicate-reveal icon + label text */
.nav-stat-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Duplicate reveal: an in-theme yellow 'duplicate' icon fades in to the left
   of the stat label on hover, alongside the duplicate count shown above the
   label. Only rendered for stat items with duplicate data (has-dup class,
   added by AnalyticsModule.display() on the Library page). */
.dup-icon {
    font-size: 0.7rem;
    line-height: 1;
    color: rgb(255, 218, 106);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.nav-stat-item.has-dup:hover .dup-icon,
.nav-stat-item.has-dup.show-duplicate .dup-icon {
    opacity: 1;
    transform: translateX(0);
}

/* ========================================
   STAGING CHIP CONTAINERS
   ======================================== */
.staging-column-label {
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
    opacity: 0.8;
}

/* A chip row is the workspace's control height (36px) with its chips centred in
   it, not stretched by it: the same `.chip` is one size in the staged, popular
   and starred rows of the Tags tab (and in Create Group's staged row), and the
   rows line up with the control row above them. */
.staging-chip-container {
    align-items: center;
    min-height: 36px;
}

/* Section headings inside the Tools workspace. Every section — Working set,
   Create Group, Tags, Install, Maintain library — carries the same sentence-case h5
   heading (`.tools-section-heading`), so the workspace reads as one set of
   peers rather than two type hierarchies (tools_mode_ux_ui_audit.md IA-8).
   There is deliberately no second, uppercase section voice: the Commit pair
   carries no heading at all — it is woven into the counter/scope row it acts
   on, so it is not a section with a name to compete for. */
.tools-section-heading {
    margin: 0;
}

/* The Tools workspace's action tabs, on the workspace's first line — directly
   under the library toolbar's filter/search row — so the strip reads as the tab
   bar of the whole workspace rather than a divider halfway down it. It still
   switches only the ACTION surface (Create Group / Tags / Install / Maintain library): the
   counter/scope row below it is the scope all three read, and the Working set
   list follows the panes so the tab and the thing it opened stay together. The
   strip never wraps either of them. */
.tools-tabs {
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.tools-tabs .nav-link {
    color: var(--text-secondary);
}

.tools-tabs .nav-link.active {
    font-weight: var(--font-weight-semibold);
}

/* The fold chevron in a workspace card's heading. It folds that card's BODY, so
   the header — and the section name that says what the card is — stays put. The
   chevron is the whole affordance, so it is a real button carrying
   aria-expanded, and its direction is driven by that attribute rather than a
   class of its own: the drawing cannot disagree with the state it reports. */
.tools-fold-toggle {
    background: none;
    border: 0;
    padding: 0;
    vertical-align: middle;
    font-size: 0.85em;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.tools-fold-toggle:hover,
.tools-fold-toggle:focus-visible {
    color: var(--text-primary);
}

.tools-fold-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
}

.tools-fold-toggle[aria-expanded="false"] .tools-fold-chevron {
    transform: rotate(-90deg);
}

/* A foldable group inside a tab pane. The panes are one card-body of rows with no
   headings, so a fold has nothing to hang on there; a group supplies the name and
   the chevron, and folds its own body — the head, and the row of tag controls
   above it, stay put. The head is deliberately quieter than a card heading
   (.tools-section-heading): a group is one level below the pane it lives in. */
.tools-fold-group {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-xs);
}

/* Baseline-aligned so the name and the count beside it sit on one line even
   though they are different sizes; the chevron is a box, so it centres instead. */
.tools-fold-head {
    display: flex;
    align-items: baseline;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

/* The chips below are 0.875rem, so the group name is too: a group head is a
   label for the row it names, one level under the pane's own h5, and
   --text-secondary keeps it quieter than that heading rather than inventing a
   third weight of voice (IA-8). */
.tools-fold-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    line-height: var(--line-height-tight);
}

/* What the fold would hide, said on the head: a folded group that names its own
   contents is not a mystery box. One step down from the name (--font-size-xs),
   same colour: size carries the hierarchy, so the two never disagree in value. */
.tools-fold-meta {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-normal);
    color: var(--text-secondary);
    line-height: var(--line-height-tight);
}

/* The chevron sits inside the name, exactly as the Working set card's sits inside
   its h5, so the two folds are read the same way: "name ⌄ what is in it". */
.tools-fold-head .tools-fold-toggle {
    align-self: center;
}

/* Empty-working-set prompt inside the Working-set card (IA audit IA-10). */
.staging-empty-state {
    padding: var(--spacing-sm);
    text-align: center;
}

/* The Tools tab row: the strip on the left, the Commit pair on the right. The
   row stays one line; the commit slot takes the leftover width and its summary
   is the first thing to shrink, so the Review and Discard buttons are the last
   to give way. */
.tools-tabs-row {
    flex-wrap: wrap;
    min-width: 0;
}

/* The strip never gives way: the tabs are the row's reason to exist, so they
   keep their width and the Commit pair wraps to the next line when the row runs
   out. Shrinking the strip instead clipped tab labels — the last thing a user
   should lose. */
.tools-tabs-row > .tools-tabs {
    flex: 0 0 auto;
}

.tools-commit-slot {
    flex: 0 0 auto;
    margin-left: auto;
}

/* The one job surface every Tools pane uses: directly under the pane's action
   row, a 6px bar while a job with a known total runs, and the status line under
   it. Install's queue, Maintain's library jobs and a forwarder build all report
   here, so a job is in the same place on every tab instead of in the row, in a
   card, or in a muted line at the bottom of the pane. */
.tools-progress {
    margin-top: var(--spacing-sm);
}

.tools-progress .progress {
    height: 6px;
}

.tools-progress-text {
    display: block;
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* An idle surface takes no space: each pane keeps its line in the markup so a
   job has somewhere to report, and it collapses until there is something to
   say. */
.tools-progress-text:empty {
    display: none;
}

.commit-cluster {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    margin-left: auto;
}

.commit-cluster > div {
    flex: 0 0 auto;
}

/* The draft summary inside the Commit pair on the tab row. It is the flexible
   middle of that row: as the row narrows it truncates first, and the Review
   and Discard buttons at the end are the last things to give way. */
.commit-staged-summary {
    flex: 0 1 22ch;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ========================================
   BOXY STYLE - reusable staged chip style
   ======================================== */
.boxy-style {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    border: 2px solid;
    background: transparent;
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* ========================================
   CHIP SYSTEM (unified sizing & color modifiers)
   
   Base .chip uses .popular-tag-badge sizing as the default standard.
   Color modifiers set font color only.
   - Semi-transparent backgrounds: NO matching color border.
   - Fully transparent backgrounds: may carry a matching color border.
   ======================================== */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem !important;  /* Fixed — never scaled by sliders */
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* A chip whose action is already running: still reads as a chip, not a state. */
.chip:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Default gray — solid background (User chip standard) */
.chip-gray {
    background: #495057;
    color: var(--text-primary);
    border-color: #495057;
}

/* Add-tag — cyan text, semi-transparent bg, NO matching border */
.chip-add {
    color: var(--color-info);
    background: rgba(13, 202, 240, 0.12);
}
.chip-add:hover {
    color: var(--color-info-dark) !important;
    background: rgba(10, 155, 191, 0.2) !important;
}

/* Remove-tag — red text, semi-transparent bg, NO matching border */
.chip-remove {
    color: var(--color-danger);
    background: rgba(220, 53, 69, 0.12);
}
.chip-remove:hover {
    color: var(--color-danger-dark) !important;
    background: rgba(176, 42, 55, 0.25) !important;
}

/* Group — green text, semi-transparent bg, NO matching border */
.chip-group {
    color: var(--color-success);
    background: rgba(25, 135, 84, 0.12);
}
.chip-group:hover {
    color: var(--color-danger) !important;
    background: rgba(220, 53, 69, 0.15) !important;
}

/* Compress — yellow text, semi-transparent bg, NO matching border */
.chip-compress {
    color: var(--color-warning);
    background: rgba(255, 193, 7, 0.12);
}
.chip-compress:hover {
    color: var(--color-danger) !important;
    background: rgba(220, 53, 69, 0.15) !important;
}

/* Queue for Push — Admin gray (#5c636a) style, semi-transparent, matches .chip conventions */
.chip-queue {
    color: #adb5bd;
    background: rgba(92, 99, 106, 0.15);
    border: 1px solid rgba(92, 99, 106, 0.3);
}
.chip-queue:hover {
    color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.15) !important;
    border-color: rgba(220, 53, 69, 0.3) !important;
}

/* Clear staged — wireframe style: dashed border, transparent bg, no color shift on hover */
.chip-clear {
    color: var(--text-secondary);
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.35);
    font-weight: 400;
    opacity: 0.7;
    transition: all 0.2s ease;
}
.chip-clear:hover {
    color: var(--color-danger) !important;
    border-color: var(--color-danger) !important;
    background: rgba(220, 53, 69, 0.1) !important;
    opacity: 1;
    transform: translateY(-1px);
}

/* ========================================
   STAGING CHIPS (legacy — uses .chip sizing)
   ======================================== */
.staging-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
    background: transparent;
}

/* Staged pending tags in category columns — use chip color palette */
.staged-pending-tag {
    border: none !important;
    color: var(--color-info) !important;
    background: rgba(13, 202, 240, 0.12) !important;
    font-size: 0.8rem !important;  /* Fixed — matches .chip, never scaled */
    opacity: 1;
}

/* Tag removal pending badge in category columns */
.staged-pending-remove-tag {
    border: none !important;
    color: var(--color-danger) !important;
    background: rgba(220, 53, 69, 0.12) !important;
    font-size: 0.8rem !important;  /* Fixed — matches .chip, never scaled */
    opacity: 1;
}

/* ========================================
   DONE BUTTON STYLES
   ======================================== */
/* Done button uses Bootstrap's default .btn-primary styling (like Filters button)
   Only custom overrides are for the disabled (faded) state */
#doneBtn .btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Admin checkbox — no left margin (aligned with Wrap above) */

/* ========================================
   BUTTON HOVER EFFECTS
   ======================================== */
#createGroupBtn, #tagPlusBtn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#createGroupBtn:hover, #tagPlusBtn:hover {
    background-color: rgba(var(--bs-success-rgb), 0.2) !important;
    border-color: var(--bs-success) !important;
    color: var(--bs-success) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#createGroupBtn:active, #tagPlusBtn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ========================================
   BROKEN IMAGE FALLBACK
   ======================================== */
.img-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 100px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.15);
    font-size: 2rem;
}

.img-fallback.img-fallback-sm {
    min-height: 36px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
}

/* Card view: fallback fills the card area */
.game-card .img-fallback {
    aspect-ratio: 16 / 9;
}

/* Icon view: fallback is square */
.icon-wrapper .img-fallback {
    aspect-ratio: 1;
    width: 100%;
    min-height: 60px;
}

/* Group preview: small icon fallback */
.group-preview-icons .img-fallback {
    width: 48px;
    height: 48px;
    min-height: unset;
    font-size: 1.2rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
}

/* Game preview card: fallback fills the card-img-top space */
.game-preview-card .img-fallback {
    height: 120px;
    min-height: unset;
}

/* ========================================
   TAG BADGE ORIGIN STYLES
   ======================================== */
/* Migrated from the retired static/style.css. The grey fill used to live there
   alone — without it every tag badge in the app goes transparent, since the
   box-shadow here only draws the hairline edge. */
.tag-badge {
    display: inline-block;
    border-radius: 12px;
    font-weight: 500;
    color: #f8f9fa;
    line-height: 1;
    transition: all 0.2s ease;
}

.tag-badge-origin-admin {
    background-color: #5c636a;
    box-shadow: inset 0 0 0 1px #5c636a;
}

.tag-badge-origin-user {
    background-color: #868e96;
    box-shadow: inset 0 0 0 1px #868e96;
}

.tag-badge-origin-titledb {
    background-color: #495057;
    box-shadow: inset 0 0 0 1px #495057;
}

.tag-badge-favorite {
    font-weight: bold;
}

.nav-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-bg-warning {
    color: var(--text-primary) !important;
    background-color: RGBA(var(--bs-warning-rgb), var(--bs-bg-opacity, 1)) !important;
    font-weight: var(--font-weight-normal);
}

/* Partial state: present but not complete (outdated update or some DLC missing). */
.text-bg-partial {
    color: var(--text-primary) !important;
    background-color: var(--color-partial) !important;
    font-weight: var(--font-weight-normal);
}

/* Unknown state (§7 rev 2 orange #ed631d): asked, got no verdict from data we
   have. Drawn as a QUIET OUTLINE, not a filled alert: it is a gap in what is
   known, not an instruction and not a fault — a solid orange badge on every
   row whose catalog entry is thin reads as an emergency. The accent stays in
   the text/border, so the state is still findable in a scan. */
.text-bg-unknown {
    color: var(--color-unknown) !important;
    background-color: rgba(237, 99, 29, 0.12) !important;
    border: 1px solid rgba(237, 99, 29, 0.55);
    font-weight: var(--font-weight-normal);
}

/* Error state (§7 rev 2 vermillion #e44029): the data contradicts itself —
   stale claims, unparseable versions, missing files. No honest advice
   exists; fix the data (fresh report / rescan), not the chip. Outranks
   every advice color (heat ladder precedence: error first). */
.text-bg-error {
    color: var(--text-primary) !important;
    background-color: var(--color-error) !important;
    font-weight: var(--font-weight-normal);
}

.text-bg-info {
    color: var(--text-primary) !important;
    background-color: RGBA(var(--bs-info-rgb), var(--bs-bg-opacity, 1)) !important;
    font-weight: var(--font-weight-normal);
}

.btn-outline-info {
    --bs-btn-hover-color: var(--text-primary);
}

/* Flexbox utilities for card columns */
.col-1,
.col-2,
.col-3,
.col-4,
.col-6,
.col-12 {
    display: flex;
    flex-direction: column;
}

.col-1>.card,
.col-2>.card,
.col-3>.card,
.col-4>.card,
.col-6>.card,
.col-12>.card {
    flex: 1;
}

/* Heading spacing */
.h1,
.h2,
.h3,
.h4,
.h5,
.h6,
h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Settings divider */
.hr-settings {
    margin-top: var(--spacing-xl) !important;
}

/* ========================================
   POPULAR TAG BADGES
   ======================================== */
/* The chip container inside a row, not a section of its own: no padding,
   divider or margin of its own, so the row's spacing is the pane's 8px gap and
   nothing else. */
.popular-tag-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.popular-tag-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid #495057;
    background: #495057;
    font-size: 0.8rem !important;  /* Fixed — never scaled by sliders */
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Keyboard focus is an affordance of its own, never the starred/active state
   the chip is already drawing — so it is the same 2px ring the app's other
   focusable chips use (.list-tag-chip-clickable), and Tab is where it shows.
   These three used to cancel the outline outright, leaving no indication at
   all for a keyboard user moving through the Tags pane. */
.popular-tag-badge:focus-visible,
.popular-tag-badge .tag-star-toggle:focus-visible,
.popular-tag-label:focus-visible,
.popular-sort-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

.popular-tag-badge:hover {
    border-color: #0dcaf0;
    color: #0dcaf0;
    background: rgba(13, 202, 240, 0.15);
    transform: translateY(-1px);
}

/* ========================================
   POPULAR SORT TOGGLE
   ======================================== */
/* The toggle and the starred marker are the rows' only controls, so they take
   the workspace's control height (36px) rather than a 26px allowance of their
   own: one hit target size across the pane, and the chip rows line up with the
   control row above them. */
.popular-sort-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
    border: 1px solid transparent;
}

/* The toggle is red for + and blue for −. */
.popular-sort-toggle.sort-add {
    color: #dc3545;
}
.popular-sort-toggle.sort-add:hover {
    color: #ea868f;
    background: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.3);
}
.popular-sort-toggle.sort-add:focus {
    color: #dc3545;
}

.popular-sort-toggle.sort-remove {
    color: #0dcaf0;
}
.popular-sort-toggle.sort-remove:hover {
    color: #3dd5f3;
    background: rgba(13, 202, 240, 0.12);
    border-color: rgba(13, 202, 240, 0.3);
}
.popular-sort-toggle.sort-remove:focus {
    color: #0dcaf0;
}

/* The mode word beside the toggle takes the mode's own colour — blue Add, red
   Remove, the same pair the chips wear — in plain "Add" / "Remove" case. */
.popular-mode-label {
    font-size: 0.8rem;
    user-select: none;
}
.popular-mode-add .popular-mode-label {
    color: #0dcaf0;
}
.popular-mode-remove .popular-mode-label {
    color: #dc3545;
}

.popular-sort-toggle i {
    font-size: 1rem;
    line-height: 1;
}

/* Mode labels for add/remove chip styling */
.popular-mode-add .popular-tag-badge {
    background: rgba(13, 202, 240, 0.12);
    border-color: rgba(13, 202, 240, 0.25);
    color: #0dcaf0;
}
.popular-mode-add .popular-tag-badge:hover {
    background: rgba(13, 202, 240, 0.22);
    border-color: #0dcaf0;
    color: #3dd5f3;
    transform: translateY(-1px);
}

.popular-mode-remove .popular-tag-badge {
    background: rgba(220, 53, 69, 0.12);
    border-color: rgba(220, 53, 69, 0.25);
    color: #dc3545;
}
.popular-mode-remove .popular-tag-badge:hover {
    background: rgba(220, 53, 69, 0.22);
    border-color: #dc3545;
    color: #ea868f;
    transform: translateY(-1px);
}

/* Star toggle inside a popular tag chip.
   The star is its own click target (star/unstar); the label beside it keeps
   following the Add/Remove mode, so the two actions never collide. */
.popular-tag-badge .tag-star-toggle {
    margin-right: 0.35rem;
    font-size: 0.75rem;
    line-height: 1;
    opacity: 0.7;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.popular-tag-badge .tag-star-toggle:hover,
.popular-tag-badge .tag-star-toggle:focus {
    opacity: 1;
    transform: scale(1.15);
}

.popular-tag-badge .tag-star-toggle.is-starred {
    opacity: 1;
    color: #ffc107;
}

/* A chip in the Starred tags row reads as already pinned. */
.starred-tag-badge {
    border-color: rgba(255, 193, 7, 0.55);
    background: rgba(255, 193, 7, 0.14);
}

.starred-tags-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    color: #ffc107;
    border: 1px solid transparent;
}

/* Hidden history state */
.hidden-history {
    display: none !important;
}

/* Tag Chips in Input */
.tag-chip {
    display: inline-flex;
    align-items: center;
    background-color: rgba(13, 110, 253, 0.2);
    border: 1px solid rgba(13, 110, 253, 0.4);
    border-radius: 4px;
    padding: 0.125rem 0.5rem 0.125rem 0.375rem;
    margin: 0.125rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.tag-chip-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0 0 0.25rem;
    opacity: 0.7;
}

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

/* Tag Input Container */
#tagInput {
    min-width: 180px;
    width: 180px;
}

/* Tag+ / Tag- : the icon and its drawn operator sit on one centred line with
   a fixed breath between them, so the operator keeps the Add group mark's
   size (9px, 1.6px thick) instead of the smaller, lighter text glyph. */
.tag-op-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tag-op-icon {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
}

/* Create-group Button Styling */
/* The four-cell mark with its plus. 1em tall like the .bi glyphs beside it,
   but its own drawing is 25:14 — cells of 5 units, ~1.5 apart, then a
   3.5-unit breath before the plus — so it reads at the weight of a tag
   glyph instead of as four specks, and the two shapes do not touch. */
.group-tiles-icon {
    width: 1.8em;
    height: 1em;
    vertical-align: -0.125em;
}
#createGroupBtn {
    background-color: transparent !important;
    border: 1px solid #198754 !important;
    color: #198754 !important;
}

#createGroupBtn:hover {
    background-color: #157347 !important;
    border-color: #157347 !important;
    color: #fff !important;
}

/* Tag+ Button Styling */
#tagPlusBtn {
    background-color: transparent !important;
    border: 1px solid #0dcaf0 !important;
    color: #0dcaf0 !important;
}

#tagPlusBtn:hover {
    background-color: #0a9bbf !important;
    border-color: #0a9bbf !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#tagPlusBtn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Tag- Button Styling (remove tag) */
#tagMinusBtn {
    background-color: transparent !important;
    border: 1px solid #dc3545 !important;
    color: #dc3545 !important;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#tagMinusBtn:hover {
    background-color: #b02a37 !important;
    border-color: #b02a37 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#tagMinusBtn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ========================================
   COMPACT STACKED CHECKBOXES
   (Details/Hide and Wrap/Admin pairs)
   ======================================== */
/* Container aligns to top so first checkboxes in each column match horizontally */
#detailsHideContainer,
#wrapAdminContainer {
    align-self: flex-start;
}

.stacked-check-group {
    gap: 0;
}

.stacked-check-group .compact-check {
    min-height: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    padding-left: 22px !important;
    line-height: 1 !important;
}

.stacked-check-group .compact-check .form-check-input {
    float: left;
    width: 16px !important;
    height: 16px !important;
    margin-top: 0 !important;
    margin-left: -22px !important;
    font-size: 16px !important;
    accent-color: #0d6efd !important;
}

.stacked-check-group .compact-check .form-check-label {
    font-size: 0.8rem !important;
    line-height: 1.2 !important;
    vertical-align: middle !important;
    color: var(--text-secondary);
    display: inline !important;
    cursor: pointer !important;
}

/* A toolbar checkbox the active view/page has no wiring for (Details in List/
   Smart, Wrap in Smart, Hide outside Tools) is `disabled` from views.js;
   Bootstrap greys the input, and this dims its label to match so the pair
   reads as "no option here". The label's pointer cursor is overridden because
   there is nothing to click. */
.stacked-check-group .compact-check .form-check-input:disabled + .form-check-label {
    opacity: 0.45;
    cursor: not-allowed !important;
}

/* ====== Publisher Filter Chips ====== */
.publisher-filter-container {
    position: relative;
}

.publisher-filter-btn {
    position: relative;
    z-index: 1;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}

.publisher-filter-btn .bi-chevron-down {
    font-size: 0.7rem;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.publisher-filter-btn.btn-outline-primary .bi-chevron-down {
    opacity: 1;
}

.publisher-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 0;
}

.publisher-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.8125rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    color: rgba(255, 255, 255, 0.8);
}

.publisher-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.publisher-chip.publisher-chip-active {
    background: rgba(13, 110, 253, 0.25);
    border-color: #0d6efd;
    color: #6ea8fe;
}

/* ========================================
   DEVICE MANAGEMENT
   ======================================== */

/* Fixed layout, because every value in this table is a badge, a date or a
   button: under auto layout the longest one silently sets its column's width,
   which is exactly how a 32-character UID used to sprawl. The widths are
   declared instead — once, in the <colgroup> the template carries, the way the
   Library's List view declares its track set — so a column is as wide as the
   thing it shows and no wider, and the width list has one home instead of a
   rule per column here.

   Two rules keep that honest. The declared widths must add up to min-width:
   a column left without width gets zero, and its heading then renders one
   letter per line and its cell spills over its neighbour — the Transfer column
   did exactly that when it was added to the header but not to the width list.
   And every heading is nowrap, so a too-narrow column shows a cut-off word
   rather than that. */
/* A status badge is also a filter for its own state, so it has to read as the
   badge it still is: no button chrome, the badge colour kept, and a ring rather
   than a fill when the filter is on — filling it would change the colour that
   says which state it is. */
.device-status-filter {
    border: 0;
    cursor: pointer;
    font-weight: 600;
}

.device-status-filter:hover { opacity: .85; }

.device-status-filter:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.device-status-filter[aria-pressed="true"] {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .9);
}

#devicesTable {
    /* Auto, not fixed: fixed layout can only give a column the width it is told,
       so a column holding "Offline" in 152px keeps 81px of air, and a table
       narrower than the sum of those widths pans instead of tightening. Auto
       layout sizes each column from its own contents — the Library List view's
       arrangement, where six tracks are min-content and the text tracks take
       what is left — which is what lets the width rules below mean what they
       say. */
    table-layout: auto;
    /*       The pan threshold: the six management columns come to about 61rem with
       real data (Status, Installs, Not in CatTail, Credentials, Admin and
       Actions), and this adds a 10rem Console column on top. The widths are
       content-sized, so this is a floor rather than a fixed set: below it the
       table pans instead of squeezing a badge onto two lines — the old 73rem
       fixed set began panning at 1168px. */
    min-width: 71rem;
}

/* Content-sized: as wide as what they hold and no wider, which is what the gaps
   between the columns are meant to measure — one gutter each, not one gutter
   plus whatever a column was over-allocated. 1% is the idiom for it: a preferred
   width smaller than any content, so the content wins and nothing grows to fill
   the table. */
#devicesTable col.col-status,
#devicesTable col.col-installs,
#devicesTable col.col-gaps,
#devicesTable col.col-credentials,
#devicesTable col.col-admin,
#devicesTable col.col-actions { width: 1%; }

/* The console cell is the row's identity, so it carries the name in bold (the
   cap in constants.DEVICE_NAME_MAX_LENGTH) with its pencil, and the UID with its
   copy button on the line under it. 100% makes it the one column that absorbs
   the table's spare width: a wide window shows a longer CID rather than a wider
   gap, and the CID shortens with an ellipsis (see .device-uid) long before the
   column runs out of room. */
#devicesTable col.col-console { width: 100%; }

/* The densest cell in the table: the count, then what is behind and what is
   owned-but-not-installed, right-aligned as one numeric column the way SIZE is
   in List. It is the one management column that carries a floor, because three
   facts given only "as wide as my longest word" would wrap mid-phrase and make
   every row several lines tall. 13rem holds the longest of them on one line
   ("3 updates ready to install") with the gutter either side; the Console
   column absorbs the rest, and a wide window does not widen these numbers. */
#devicesTable col.col-installs { width: 1%; }
#devicesTable th.col-installs, #devicesTable td.col-installs { min-width: 13rem; }

/* One number and its heading. The floor is the wider of the two — "NOT IN
   CATTAIL" at the caps size, or "12 not in CatTail" at the count size — so the
   breakdown stays in the hover and never wraps the column. */
#devicesTable col.col-gaps { width: 1%; }
#devicesTable th.col-gaps, #devicesTable td.col-gaps { min-width: 9rem; }

/* One line of table is one line of text. Bootstrap's half-rem cell padding is
   for prose cells; these are a name, a state and a count, and the gap it left
   doubled the height of every row without adding anything to read. */
#devicesTable > tbody > tr > td { padding-top: 0.25rem; padding-bottom: 0.25rem; }

/* A content-sized column may not wrap: "Offline" and "Listening" on two lines,
   or a badge and the button that clears it, would make the column narrower and
   the row taller — the one trade these four columns must not make. */
#devicesTable th.col-status, #devicesTable td.col-status,
#devicesTable th.col-gaps, #devicesTable td.col-gaps,
#devicesTable th.col-credentials, #devicesTable td.col-credentials,
#devicesTable th.col-admin, #devicesTable td.col-admin,
#devicesTable th.col-actions, #devicesTable td.col-actions { white-space: nowrap; }

/* The five management columns share one gutter: the same inset on both sides of
   each, so the air between Status and Installs is the air between the numbers
   and the token beside them. The numbers are right-aligned, so their unused
   space sits on the LEFT of their column, where it reads as Status's — which is
   why the column has to be as wide as its contents and no wider, and why the
   gap on the credentials side comes from the padding rather than from slack.
   0.75rem a side is the list grid's gap between tracks, plus the room a table
   cell needs that a grid track does not (no cell background to separate them). */
#devicesTable th.col-status, #devicesTable td.col-status,
#devicesTable th.col-installs, #devicesTable td.col-installs,
#devicesTable th.col-gaps, #devicesTable td.col-gaps,
#devicesTable th.col-credentials, #devicesTable td.col-credentials,
#devicesTable th.col-admin, #devicesTable td.col-admin,
#devicesTable th.col-actions, #devicesTable td.col-actions {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Row controls are table-sized, not page-sized: the stock half-rem padding on a
   small button made a two-line cell taller than the text inside it. */
#devicesTable .btn-sm { padding: 0 0.45rem; font-size: 0.8125rem; line-height: 1.45; }

/* The console cell is two lines, each a flex row: the name with its pencil and
   the admin switch, then   the UID with its copy button and the one chip that pairs it. */
#devicesTable .device-identity {
    display: grid;
    gap: 0.15rem;
}

#devicesTable .device-identity-line {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

#devicesTable .device-identity-line .device-name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
}

#devicesTable .device-identity-sub { gap: 0.5rem; }
#devicesTable .device-identity-sub .device-uid-row { flex: 1 1 auto; min-width: 0; margin-left: 0; }

/* The Admin cell: the switch, then what that console's access amounts to — the
   pairing chip, or the owner-only note for a console an administrator may not
   manage. Two controls on one line, so the row stays one line high. */
/* The address line's three parts, measured against the name row above it: the
   name line is the column's full width, the CID stops at about two thirds of it,
   and the badges lane holds the rest. The lane is reserved whether or not there
   is a mark in it, so a console that starts reporting storage never moves the
   ID beside it, and a mark lands in the same place on every row. */
#devicesTable .device-identity-sub .device-uid-row { max-width: 100%; }
#devicesTable .device-identity-sub .device-uid { max-width: 66%; }

/* The badges lane: one line of marks about the console, each carrying its own
   hover, packed left so the first mark starts at the lane's own boundary and a
   second follows it rather than pushing the first along. */
#devicesTable .device-badges {
    display: inline-flex;
    flex: 0 0 3.5rem;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
}

/* The console's storage ring: the card reading of the NAND this boot runs,
   sat on the UID's line beside the copy button and sized to that glyph so it
   reads as one more fact about this console rather than a column of its own.
   The arc is the used fraction, like the navbar pill's meter, and the figures
   are in the hover. Absent entirely until the console has reported storage. */
#devicesTable .device-storage {
    display: inline-flex;
    flex: none;
    align-self: center;
    /* A centered 13px box sits above the UID's baseline and the clipboard glyph
       beside it; three pixels down puts its rim on that same optical line. */
    position: relative;
    top: 3px;
    width: 13px;
    height: 13px;
    color: var(--text-secondary);
    cursor: help;
}

#devicesTable .device-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

#devicesTable .device-ring-track,
#devicesTable .device-ring-fill {
    fill: none;
    stroke-width: 3;
}

#devicesTable .device-ring-track {
    stroke: rgba(127, 127, 127, 0.35);
}

#devicesTable .device-ring-fill {
    stroke: var(--color-success);
    stroke-linecap: round;
}

/* Same muted warm rungs as the navbar ring (components.css, the pill's ring). */
#devicesTable .device-ring.is-tight .device-ring-fill {
    stroke: var(--color-partial);
}

#devicesTable .device-ring.is-full .device-ring-fill {
    stroke: color-mix(in srgb, var(--color-error) 45%, var(--color-partial));
}

#devicesTable .device-admin {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#devicesTable .device-admin .form-check { margin: 0; min-height: 0; }
#devicesTable .device-pair,
#devicesTable .device-owner-only { white-space: nowrap; }

/* The pencil is the visible half of "click the name to rename": the name is a
   target too, but a target with no affordance is a secret, and it stays quiet
   until the row is hovered or the button is focused. */
#devicesTable .device-name-pencil {
    padding: 0 2px;
    border: 0;
    background: none;
    font-size: var(--font-size-xs);
    line-height: 1;
    color: var(--text-secondary);
    opacity: 0.45;
}

#devicesTable tr:hover .device-name-pencil,
#devicesTable .device-name-pencil:hover,
#devicesTable .device-name-pencil:focus-visible {
    opacity: 1;
    color: var(--text-primary);
}

/* The same field, in the row it edits: a label is ten characters, and a modal
   for ten characters is a dialog to read, fill and dismiss. */
#devicesTable .device-name-input {
    height: auto;
    padding: 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: var(--font-weight-semibold);
    line-height: 1.4;
}

/* The installs cell is three answers, one under the other: the games, what is
   behind on them, and the DLC. Each is its own line rather than a sentence that
   has to be parsed to find the facts in it. */
#devicesTable .install-count,
#devicesTable .install-line,
#devicesTable .install-gap,
#devicesTable .install-non-game {
    line-height: 1.3;
}

#devicesTable .install-line {
    display: block;
    font-size: 0.8125rem;
    /* A column of numbers, each line flush with the game count and the heading
       above it: a block line would otherwise start at the cell's left edge and
       read as a paragraph. */
    text-align: right;
}

/* The two rungs the Library paints, borrowed rather than invented — the same
   green and the same olive the readiness chips use, so a colour means one thing
   across the app. Green is "in the shop, installable now" (its dark-theme
   emphasis tone, which is the readable green on this table); olive is "a build
   the shop does not have", the rung an administrator has to go and acquire,
   which is why it gets a colour of its own instead of folding into green. Grey
   stays muted: a version the console never sent is not an instruction. */
#devicesTable .install-line-owned { color: var(--bs-success-text-emphasis, #75b798); }
#devicesTable .install-line-unowned { color: var(--color-partial); }

/* The secondary cells, folded into the console's own cell on a phone. Rendered
   there by renderDevices rather than moved by CSS, so the same content is built
   once and the folded copy cannot drift from the column it replaces. The
   credentials go in as two labelled facts rather than one, which is the only
   place a phone gets more detail than the desktop row. */
.device-mobile-facts {
    display: grid;
    gap: .35rem;
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--bs-border-color, rgba(0, 0, 0, .175));
}

.device-mobile-fact {
    display: grid;
    gap: .1rem;
}

.device-mobile-fact-label {
    font-size: .625rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--bs-secondary-color, #6c757d);
}

.device-mobile-fact-value { min-width: 0; }
.device-mobile-fact-value .form-check { margin: 0; min-height: 0; }

@media (max-width: 767.98px) {
    /* Three columns stay — what the console is, how it is, what it has — and
       the rest fold, so no row has to be panned sideways to be read. */
    #devicesTable { min-width: 0; }

    /* The desktop gutter is 1.5rem of padding per management column; a third of
       a phone's width is not the place to spend it, so the fold keeps the tight
       one and the columns get a readable count instead. */
    #devicesTable th.col-status, #devicesTable td.col-status,
    #devicesTable th.col-installs, #devicesTable td.col-installs {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* The Installs floor is a desktop rule: on a phone the three columns that
       stay divide a fixed percentage of the table, and 11.5rem is most of it.
       The fold already gives the count its own line, so it needs no floor. */
    #devicesTable th.col-installs, #devicesTable td.col-installs { min-width: 0; }

    #devicesTable col.col-console { width: 44%; }
    #devicesTable col.col-status { width: 34%; }
    #devicesTable col.col-installs { width: 22%; }

    #devicesTable .col-gaps,
    #devicesTable .col-credentials,
    #devicesTable .col-admin,
    #devicesTable .col-actions { display: none; }

    /* A two-word badge or a timestamp wraps rather than widening the column. */
    #devicesTable .badge { white-space: normal; }
    #devicesTable .install-count { font-size: .8125rem; }

    /* The ID keeps its ellipsis on a phone: a third of the width is not enough
       for a CID, and wrapping one onto three lines is worse than shortening it. */
    #devicesTable tbody .device-uid-row { max-width: 100%; }
    #devicesTable tbody .device-uid { max-width: 62%; }
    #devicesTable .device-badges { flex-basis: 2.75rem; }
}

/* The same header dress as List view's sort bar: a small, spaced, uppercase
   label in the secondary text colour. The words stay plain in the markup, so a
   screen reader announces "Last seen" and not "LAST SEEN". */
#devicesTable thead th {
    white-space: nowrap;
    /* A label row, not content: 0.3rem above and below instead of the table's
       half-rem cell rhythm, which leaves the sortable words a target of about
       two dozen pixels and the consoles themselves a few pixels higher up. */
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    font-size: 0.75rem;
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* A sortable heading is the List view's .list-col-sortable, applied to a real
   table cell: it reuses that class's arrow and sorted states, and takes its own
   hover/sorted colour and keyboard ring here — the th rule above is an id
   selector, so it outranks the class-level rules in views.css. */
#devicesTable thead th.list-col-sortable:hover,
#devicesTable thead th.list-col-sortable.sorted-asc,
#devicesTable thead th.list-col-sortable.sorted-desc {
    color: var(--color-primary);
}

#devicesTable thead th.list-col-sortable:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: -2px;
}

/* The game count is the handle on the install detail, drawn as a link-button
   like the modal's title buttons. It used to be a badge with the button chrome
   removed, which read as decoration next to the badges beside it that do
   nothing — an affordance that looked like the wrong thing. */
#devicesTable .install-count {
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--bs-link-color, #0d6efd);
    text-decoration: underline;
    text-underline-offset: 2px;
}

#devicesTable .install-count:hover {
    text-decoration-thickness: 2px;
}

#devicesTable .install-count .bi {
    font-size: 0.75rem;
}

/* "142 games" counts games only, so the console's other reported programs sit
   beside it as a quiet "+14 other" instead of inflating the number. */
#devicesTable .install-non-game {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* The install detail is a split view: the console's titles on the left, one
   title's library entry on the right. Reading a title must not mean leaving
   the console behind, which is what the old search link did. */
#deviceInstallsBody .install-split-table {
    flex: 1 1 auto;
    min-width: 0;
}

/* The column rule stays where the tabs change around it. Column widths used to
   come from the widest name in the visible rows, so the line between Title and
   the readiness column moved every time a tab swapped the list — the one thing
   a reader is tracking across the switch. A fixed layout with Title at 45%
   puts that rule at the same x on every tab, and what is left is split evenly
   between the readiness columns the tab shows. */
#deviceInstallsBody .install-table {
    table-layout: fixed;
    width: 100%;
}

#deviceInstallsBody .install-table th:first-child,
#deviceInstallsBody .install-table td:first-child {
    width: 45%;
    overflow-wrap: anywhere;
}

#deviceInstallsBody .install-pane {
    /* The pane now carries the record (art, facts, categories, description,
       tags), not a two-line peek, so it needs a readable column width. */
    flex: 0 0 24rem;
    padding-left: 1rem;
    border-left: 1px solid var(--bs-border-color, rgba(128, 128, 128, 0.35));
    font-size: 0.875rem;
}

#deviceInstallsBody .install-pane-name {
    overflow-wrap: anywhere;
}

/* The All tab's mini details: the cover opens the pane at its left, the facts
   fill the column beside it. A square cover centred at the pane's width leaves
   a third of the row blank; this is where the publisher, the categories and the
   readiness chips go instead. */
#deviceInstallsBody .install-pane-media {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

#deviceInstallsBody .install-pane-meta {
    flex: 1 1 auto;
    min-width: 0;
}

/* In the media row the art takes the left 45% at the same size in every pane,
   pinned to the left edge. Two things made this read wrong before: `contain`
   letterboxed a square icon inside a wider box, which centred it; and the
   update and DLC panes capped the height lower, so the same 45% box was filled
   only partly and kept a band of art background beside the icon. One art box
   for all four shapes fixes both — the row is exactly as tall as the art, and
   the facts start beside it. */
#deviceInstallsBody .install-pane-art {
    flex: 0 0 45%;
    width: 45%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#deviceInstallsBody .install-pane-media .install-pane-hero {
    width: 100%;
    max-height: none;
    margin-top: 0;
    object-position: left center;
}

/* The pane's one action sits under the art it acts on, at the art's width —
   the same column the cover fills, so the split view reads as two columns and
   the button is never a full pane's scroll away from its title. */
#deviceInstallsBody .install-pane-add {
    width: 100%;
    margin-top: 0;
}

/* The update pane's action rides the build's own row in the version history
   instead of the pane's foot: the list is the one place several of a title's
   releases are on screen at once, so a single button at the foot could only
   ever mean the newest. Small, because it is a row's control and not the
   pane's subject. */
#deviceInstallsBody .install-update-add {
    padding: 0.05rem 0.45rem;
    font-size: 0.7rem;
    line-height: 1.5;
    white-space: nowrap;
    margin-left: auto;
}

/* The pane's art at the pane's width. The second column is ~22rem of content
   (24rem less its padding), so the cover is the thing a reader opens a row for
   rather than a 2.5rem thumb beside the name. `contain`, because the cache
   holds 2:1 banners where a square icon is missing and cropping one to fill a
   square box cuts the edges off the very art the row points at; the box keeps
   its background whether or not art was cached, so two panes align. */
#deviceInstallsBody .install-pane-hero {
    display: block;
    width: 100%;
    max-height: 12rem;
    border-radius: 0.35rem;
    object-fit: contain;
    background: var(--bs-secondary-bg, rgba(128, 128, 128, 0.15));
    margin-top: 0.25rem;
}

/* A description can run long; the pane shows the opening lines so the table
   beside it keeps its height, and the Library's Details has the rest. */
#deviceInstallsBody .install-pane-desc {
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 0.25rem;
}

/* A missing DLC is a row about the DLC, not a line of its game's footnote: it
   can carry its own art and blurb when the catalog or the art cache knows the
   content id. The art is shown whole inside a fixed box rather than filling it,
   because most DLC art we cache is a 2:1 banner and a square crop cuts the
   title off it; the box is the same size whether or not art was found, so a
   list of mixed rows keeps one left edge. */
#deviceInstallsBody .install-dlc-item {
    /* A row the pane can open, not a link list: the button chrome is reset so
       it reads as the row it is, the same way .install-title does. */
    display: flex;
    width: 100%;
    text-align: left;
    color: inherit;
    background: none;
    border: 0;
    border-top: 1px solid var(--bs-border-color, rgba(128, 128, 128, 0.25));
}

#deviceInstallsBody .install-dlc-item:hover {
    background: var(--bs-tertiary-bg, rgba(128, 128, 128, 0.08));
}

#deviceInstallsBody .install-dlc-item:focus-visible {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: -2px;
}

#deviceInstallsBody .install-dlc-item:first-child {
    border-top: 0;
}

/* Wide rather than square: a 2:1 banner in a square box shrinks to half the
   box's height, so the row's art read as a sliver. At 9rem x 6rem a banner
   fills 9rem wide and a square icon still gets a full 6rem — at half this the
   row was twice as tall as its art, so the art filled only the top half of it. */
#deviceInstallsBody .install-dlc-art {
    width: 9rem;
    height: 6rem;
    border-radius: 0.35rem;
    flex: 0 0 auto;
    object-fit: contain;
    background: var(--bs-secondary-bg, rgba(128, 128, 128, 0.15));
}

#deviceInstallsBody .install-dlc-art-none {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-secondary-color, #6c757d);
}

#deviceInstallsBody .install-dlc-text {
    display: block;
    min-width: 0;
}

#deviceInstallsBody .install-dlc-name { font-weight: 500; }

/* The DLC tab's pane lists content under the art, so the list gets the gap
   the removed 2.5rem art block used to give it. */
#deviceInstallsBody .install-pane-dlc-list {
    margin-bottom: 0.5rem;
}

/* Inline history in the update pane. It gets no scrollbox of its own: the
   releases are part of the Console installs record, so a long history grows the
   pane and the modal scrolls as one document, exactly as the table beside it
   does. `.update-history` is capped for the chip popover, so the pane's copy has
   to opt back out — otherwise the list keeps a scrollbar inside the column. */
#deviceInstallsBody .install-pane-history,
#deviceInstallsBody .install-pane-history .update-history {
    max-height: none;
    overflow: visible;
}

/* A DLC blurb can run long; three lines name the content and leave the list
   scannable, and the Shop's detail has the rest. */
#deviceInstallsBody .install-dlc-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 0.15rem;
}

/* Narrow modals stack the pane under the table: a 24rem column beside a table
   that needs its width would squeeze both. */
@media (max-width: 767.98px) {
    #deviceInstallsBody .install-split {
        flex-direction: column;
    }

    #deviceInstallsBody .install-pane {
        flex: 0 0 auto;
        width: 100%;
        padding-left: 0;
        padding-top: 1rem;
        border-left: 0;
        border-top: 1px solid var(--bs-border-color, rgba(128, 128, 128, 0.35));
    }
}

/* A title is a button (it opens the pane), drawn as the link it replaced. */
#deviceInstallsBody .install-title {
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    color: var(--bs-link-color, #0d6efd);
    text-decoration: underline;
    text-underline-offset: 2px;
}

#deviceInstallsBody .install-title:hover {
    text-decoration-thickness: 2px;
}

/* A name longer than the column — a client that reports one, or a UID standing
   in for a name — truncates rather than widening anything. Name and UID share
   the top line: two labels stacked are two lines of height on every row, and
   the UID is an identifier to be read once, not a second title. */
#devicesTable .device-name {
    display: inline-block;
    max-width: 62%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* The name the console reports for itself, when it differs from ours: a
   subordinate label on the identifier's line, truncated like everything else
   in the cell rather than wrapping it open. */
/* A fifth of the cell at most: it is a secondary label on the UID's line, and
   the UID beside it must never be the thing that gives way. */
#devicesTable .device-reported-name {
    display: inline-block;
    /* A flex item's own min-content would otherwise outrank the cap and push the
       ID line out of the cell. */
    flex: 0 1 auto;
    min-width: 0;
    max-width: 20%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* The ID line stops where the name line's controls begin, so the name box above
   is always the wider of the two. A 32-character CID fits inside that edge; a
   longer one ends in an ellipsis, because past that point the row is not where
   anyone reads it from — the copy button beside it copies the whole value. */
#devicesTable .device-uid-row {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    max-width: calc(100% - 5rem);
    margin-left: 0.4rem;
    white-space: nowrap;
}

/* A step down from body text: the monospace face keeps the pairs apart, and the
   ID is a value to check, not the row's title. */
#devicesTable .device-uid {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 20rem;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem;
    white-space: nowrap;
}

/* A clipped ID says what it is: the dotted underline is the affordance for the
   tap that opens it, the same rule the pencil beside the name follows — a click
   target nobody can see is a secret. Only a cut value gets the class, so a CID
   that fits is plain text.

   It is judged from the row's own width, so the mark is re-applied whenever the
   table is re-rendered or the window resizes (see markClippedUids). */
#devicesTable .device-uid.is-clipped {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

/* Opened in place: the whole CID wraps inside the same edge the ellipsis ended
   at. A phone has no hover, so the hint that carries the value on a desktop is
   unreachable there — this is the read-it-on-screen path. */
#devicesTable .device-uid.is-revealed {
    max-width: 100%;
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    text-overflow: clip;
    cursor: pointer;
}

#devicesTable .copy-device-uid {
    display: inline-block;
    flex: none;
    padding: 0 2px;
    vertical-align: bottom;
    border: 0;
    background: none;
    font-size: var(--font-size-xs);
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

#devicesTable .copy-device-uid:hover,
#devicesTable .copy-device-uid:focus-visible {
    color: var(--text-primary);
}

#devicesTable .copy-device-uid.copied {
    color: var(--color-primary);
}

/* ── Tools ▸ Queue ────────────────────────────────────────────────────────
   The queue's rows are transfers, not library titles: a name, a state, a
   destination and — while bytes are moving — a bar that means something. The
   rows sit directly in the pane's card (no card inside a card), like the two
   forwarder lists. */
.queue-job-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 520px;
    overflow-y: auto;
}

.queue-job {
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.025);
}

.queue-job-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.queue-job-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.queue-job-dest {
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 45%;
    font-family: var(--font-monospace, monospace);
}

.queue-job-state {
    flex: none;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.1rem 0.4rem;
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* Colour follows the state's meaning, never colour alone: the label is always
   there, so the tint is an echo rather than the message. */
.queue-job-state.state-transferring,
.queue-job-state.state-verifying,
.queue-job-state.state-commit_granted,
.queue-job-state.state-install_requested {
    color: var(--color-primary);
}

.queue-job-state.state-completed {
    color: var(--color-success, #6ee7a8);
}

.queue-job-state.state-waiting_conflict,
.queue-job-state.state-failed,
.queue-job-state.state-delivery_failed {
    color: var(--color-warning, #ffb454);
}

.queue-job-progress {
    height: 6px;
    margin-top: 0.45rem;
    background: rgba(255, 255, 255, 0.08);
}

.queue-job-meta:empty {
    display: none;
}

.queue-job-meta {
    margin-top: 0.3rem;
}

.queue-job-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.queue-conflict {
    margin-top: 0.55rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.4rem;
    background: rgba(255, 180, 84, 0.08);
}

/* Source picker: one scrollable list of folders then files, with the chosen
   file lit. Buttons rather than rows so a tap is the whole target. */
.queue-source-list {
    display: flex;
    flex-direction: column;
    max-height: 420px;
    overflow-y: auto;
}

.queue-source-row {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: none;
    color: inherit;
    text-align: left;
}

.queue-source-row:hover,
.queue-source-row:focus-visible {
    background: rgba(255, 255, 255, 0.06);
}

.queue-source-row.is-picked {
    background: rgba(110, 168, 254, 0.16);
    outline: 1px solid var(--color-primary);
    outline-offset: -1px;
}

.queue-source-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-crumb {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-primary);
    font: inherit;
}

.queue-crumb:hover,
.queue-crumb:focus-visible {
    text-decoration: underline;
}

/* ── Queue status pill (navbar) ───────────────────────────────────────────
   A 6px bar under the label is the whole "how far" answer; the count and the
   percent are text beside it. It stays out of the stats group's rhythm by
   being a link with its own padding, not another stat. */
/* ========================================
   NAVBAR CONSOLE PILL
   ======================================== */
/* The header's two chips -- the console a push would target, and the transfers
   in flight -- are one size: one min-height, one padding, one corner and one
   type size, so the row reads as a row of chips rather than two boxes that
   nearly line up. Each keeps only what it adds on top of that outline. */
.nav-console-pill,
.nav-transfer-pill {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 1.6rem;
    padding: 0 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0.45rem;
    font-size: var(--font-size-xs);
    line-height: 1;
    white-space: nowrap;
}

/* The console the Push target points at: a dot for state, the console's name,
   and a ring for SD headroom. Symbolic at rest -- the figures, including the
   NAND this boot uses, are in the hover -- and hidden entirely when the shell
   has no console to name (non-admin, or an empty registry). */
.nav-console-pill {
    margin-right: 0.5rem;
    max-width: 15rem;
    background: none;
    color: var(--text-secondary);
}

.nav-console-pill:hover,
.nav-console-pill:focus-visible {
    color: var(--text-primary);
    border-color: var(--color-primary);
    outline: none;
}

.nav-console-dot {
    flex: 0 0 auto;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--color-secondary);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* online: a heartbeat inside the window, so it can take a push right now. */
.nav-console-pill.is-online .nav-console-dot {
    background: var(--color-success);
}

/* stale: known, but its last beat is older than the window -- hollow, so it
   never reads as live. */
.nav-console-pill.is-stale .nav-console-dot {
    background: transparent;
    border: 1px solid var(--color-secondary);
}

/* unclaimed: an anonymous registry entry CatTail cannot match to a console. */
.nav-console-pill.is-unclaimed .nav-console-dot {
    background: var(--color-unknown);
}

.nav-console-pill.is-offline .nav-console-dot {
    background: var(--color-secondary);
    opacity: 0.55;
}

/* Queued asset jobs: a count, not a list. It rides the console chip because
   the work is that console's, and its own click opens the queue where the
   jobs can be read and cancelled. Amber when one is waiting on a decision,
   which is the only state that needs a person. */
.nav-console-jobs {
    flex: 0 0 auto;
    min-width: 1.05rem;
    padding: 0 0.26rem;
    border-radius: 0.6rem;
    background: rgba(13, 110, 253, 0.35);
    color: var(--text-primary);
    font-size: 0.66rem;
    line-height: 1.3;
    text-align: center;
    cursor: pointer;
}

.nav-console-jobs.needs-decision {
    background: rgba(255, 193, 7, 0.92);
    color: #1a1a1a;
}

.nav-console-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 8.5rem;
}

/* SD headroom: a 15px ring, filled clockwise from the top by the USED
   fraction (a storage meter, not a free-space arc -- see ConsolePill.paintRing
   for why). The stroke colour carries headroom, so a nearly-full ring and a
   nearly-full card are the same picture. Hidden while no storage has ever been
   reported: an empty ring would claim plenty of room. */
.nav-console-ring {
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    transform: rotate(-90deg);
}

.nav-console-ring-track,
.nav-console-ring-fill {
    fill: none;
    stroke-width: 3;
}

.nav-console-ring-track {
    stroke: rgba(255, 255, 255, 0.22);
}

.nav-console-ring-fill {
    stroke: var(--color-success);
    stroke-linecap: round;
    transition: stroke-dasharray 0.4s ease, stroke 0.2s ease;
}

/* Warm rungs climb to olive and then a muted clay rather than the palette's
   full-strength orange and vermillion: a card filling up is a fact to plan
   around, not a failure the data is wrong about, and a 15px arc has no room to
   shout without becoming the loudest thing in the navbar. */
.nav-console-pill.sd-tight .nav-console-ring-fill {
    stroke: var(--color-partial);
}

.nav-console-pill.sd-full .nav-console-ring-fill {
    stroke: color-mix(in srgb, var(--color-error) 45%, var(--color-partial));
}

.nav-console-pill.no-storage .nav-console-ring {
    display: none;
}

/* Checking: one slow pulse on the dot while the probe runs, so a click has an
   answer that is not a guess. */
.nav-console-pill.is-checking .nav-console-dot {
    animation: nav-console-pulse 0.9s ease-in-out infinite;
}

@keyframes nav-console-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
    .nav-console-pill.is-checking .nav-console-dot { animation: none; }
    .nav-console-ring-fill { transition: none; }
    .nav-console-menu { transition: none; }
}

@media (max-width: 767.98px) {
    .nav-console-name { display: none; }
}

/* The pill, its pin control and the console menu. The pin is a ghost chevron
   beside the pill rather than a segment inside it: the pill is already a
   button (click = check now), and a button inside a button is invalid HTML. */
.nav-console-group {
    display: inline-flex;
    align-items: center;
    position: relative;
    margin-right: 0.5rem;
}

.nav-console-group .nav-console-pill {
    margin-right: 0;
}

.nav-console-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    width: 1.1rem;
    margin-left: 0.15rem;
    padding: 0;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 0.25rem;
    cursor: pointer;
}

.nav-console-pin:hover,
.nav-console-pin:focus-visible,
.nav-console-pin[aria-expanded="true"] {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.nav-console-caret {
    width: 12px;
    height: 12px;
}

/* Known consoles: a Quake-style drop-down rather than a dropdown bubble.

   The panel is fixed to the viewport — not absolute inside the pin — which is
   what fixes the paint order: the library's filter control sits at --z-sticky
   (1020) in the root stacking context, so a menu in a Bootstrap bubble
   (z-index 1000) drew UNDER the filter button. At --z-fixed the panel covers
   page chrome and still stays below modal backdrops.

   It is a hanging panel, not a full-width bar: its right edge is measured
   from the pin and it reaches leftwards only as far as its own width. That is
   deliberate asymmetry — the panel is anchored to the control that opened it,
   with nothing forcing it to both viewport edges or a centred position.

   Its width follows its content instead of being fixed: the panel is as wide
   as the longest row it shows, and no wider. Rows are single-line, so the
   intrinsic width IS the longest label. 28rem is the ceiling that label can
   reach (a ★ active marker, a display name at its 32-character cap, and an
   IPv4 address), which keeps a pathological label from stretching the panel
   across the screen.

   `top` and `right` are measured by ConsolePill.placeMenu(), so a navbar that
   has wrapped taller, or a pin that has moved, still drops the panel from the
   right place. */
.nav-console-menu {
    position: fixed;
    top: 0;  /* placeMenu() replaces this on open */
    right: 1rem;  /* placeMenu() replaces this too */
    left: auto;
    width: max-content;
    max-width: min(28rem, calc(100vw - 2rem));
    min-width: 0;
    max-height: 50vh;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent);
    backdrop-filter: blur(8px);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    font-family: var(--font-family-monospace);
    font-size: 0.8125rem;
    /* Bootstrap's .dropdown-menu is display:none; the panel has to exist to be
       able to slide, so it is painted but unreachable until .show. */
    display: block;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-0.5rem);
    pointer-events: none;
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    z-index: var(--z-fixed);
}

.nav-console-menu.show {
    display: block;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* One console per line, the way a console prints them: the row spans the panel
   so the click target matches what the eye reads as a line. */
.nav-console-menu .nav-console-option {
    padding: 0.5rem 0.75rem;
    border-radius: 0;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-console-menu .nav-console-option:hover,
.nav-console-menu .nav-console-option:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-console-menu .nav-console-option.active {
    background: transparent;
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

.nav-transfer-pill {
    position: relative;
    margin-right: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    overflow: hidden;
}

.nav-transfer-pill:hover,
.nav-transfer-pill:focus-visible {
    color: var(--text-primary);
    border-color: var(--color-primary);
    text-decoration: none;
}

.nav-transfer-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
}

.nav-transfer-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--color-primary);
    transition: width 0.4s ease;
}

.nav-transfer-percent {
    color: var(--color-primary);
    font-variant-numeric: tabular-nums;
}

/* The quiet toast rung (ConsolePill's `note` tone): the page's own surface and
   border with one thin olive edge, instead of a filled banner. Storage filling
   up is a fact to plan around, so it reads like the chrome it sits over rather
   than an alert that outshouts the reading it describes. */
.cattail-toast-note {
    background-color: var(--bs-body-bg);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-left: 2px solid var(--color-partial);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    box-shadow: var(--shadow-md);
}

/* Back to top: the long walls (Library, Retro) are thousands of rows tall, so
   the way back to the console strip is a control, not a scroll. Hidden until
   the page has actually scrolled and only drawn on the pages that need it. */
.back-to-top {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1040;
    display: none;
    width: 3rem;
    height: 3rem;
    font-size: 1.15rem;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bs-body-bg);
    color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.back-to-top.is-visible {
    display: flex;
}

.back-to-top:hover,
.back-to-top:focus-visible {
    background: var(--color-primary);
    color: #fff;
}
