/* Marketplace browse page — Neo-Scribe (obsidian + amber + Courier).
   Featured hero gets the full editorial treatment; the grid stays restrained
   so the most prestigious slot reads as the most prestigious. */

.marketplace-page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    font-family: 'Courier New', monospace;
    color: var(--text-light);
}

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

.marketplace-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 24px;
}

.marketplace-header-lockup { min-width: 0; }

.marketplace-strap {
    color: var(--text-dim);
    font-size: 12px;
    letter-spacing: 0.04em;
    margin: 6px 0 0;
}

.marketplace-search {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Inline copy of the search input. Lives in the discover row (next to the
   sort tabs), pushed to the right edge so the sticky bar carries SORT + search
   together. */
.marketplace-search-inline { margin-left: auto; }

/* Mobile copy of the search input. Lives between the carousel and the
   sort/filter toolbar so it's grouped with the other narrowing controls.
   The discover-row copy is hidden on mobile (the row itself is); this one is
   hidden on desktop. */
.marketplace-search-mobile { display: none; }

.marketplace-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-mute);
    pointer-events: none;
    transition: color 150ms ease;
}

.marketplace-search:focus-within .marketplace-search-icon {
    color: var(--accent);
}

.marketplace-search input {
    background: var(--surface-1);
    border: 1px solid var(--hairline);
    color: var(--text-light);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 9px 14px 9px 34px;
    width: 280px;
    border-radius: 0;
}

.marketplace-search input::placeholder {
    color: var(--text-mute);
    text-transform: none;
    letter-spacing: 0.02em;
}

.marketplace-search input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

/* ==================================================== FEATURED CAROUSEL
   One Quill of the Month winner per slide, rotating through the curated
   list. Each slide gets its full editorial moment: large cover with subtle
   Ken Burns, italic serif title, "Picked because →" curator note, author
   block, single CTA. Auto-advances every 7s, pauses on hover/focus, and
   stops entirely when the user interacts. The L-bracket frame still wraps
   the whole zone — the signature treatment lives only here. */

.featured-carousel {
    margin: 8px 0 40px;
}

.featured-carousel[hidden] { display: none; }

.featured-carousel-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 14px;
    row-gap: 4px;
    margin-bottom: 14px;
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.14em;
}

.featured-carousel-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    white-space: nowrap;
}

.featured-carousel-month { color: var(--accent); }
.featured-carousel-eyebrow-sep { color: var(--accent-deep); }
.featured-carousel-honor { color: var(--accent); font-weight: bold; letter-spacing: 0.18em; }

.featured-carousel-count {
    color: var(--accent-deep);
    font-size: 11px;
    letter-spacing: 0.18em;
    margin-left: 4px;
}

.featured-carousel-rule {
    height: 1px;
    background: linear-gradient(to right, var(--accent-deep) 0%, transparent 100%);
}

.featured-carousel-tagline {
    grid-column: 1 / -1;
    color: var(--text-mute);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: none;
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
}

/* L-bracket blueprint frame — signature treatment, reserved for this zone. */
.featured-carousel-frame {
    position: relative;
    background: linear-gradient(180deg, var(--bg-input) 0%, var(--bg) 100%);
    border: 1px solid var(--surface-3);
    overflow: hidden;
}

.bracket {
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: var(--accent);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
    z-index: 5;
}
.bracket--tl { top: -3px; left: -3px; border-top-width: 2px; border-left-width: 2px; }
.bracket--tr { top: -3px; right: -3px; border-top-width: 2px; border-right-width: 2px; }
.bracket--bl { bottom: -3px; left: -3px; border-bottom-width: 2px; border-left-width: 2px; }
.bracket--br { bottom: -3px; right: -3px; border-bottom-width: 2px; border-right-width: 2px; }

/* ------------------------------------------------------ viewport + track */

.carousel-viewport {
    overflow: hidden;
    position: relative;
}

.carousel-track {
    display: flex;
    width: 100%;
    will-change: transform;
    transition: transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* During initial mount we don't want a transition from translateX(0). */
.carousel-track.is-instant { transition: none; }

/* ----------------------------------------------------------------- slide */

.carousel-slide {
    flex: 0 0 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
    align-items: stretch;
}

.carousel-slide-cover {
    position: relative;
    display: block;
    aspect-ratio: 16 / 11;
    overflow: hidden;
    background: var(--bg-void);
    border-right: 1px solid var(--bg-tertiary);
}

.carousel-slide-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scale(1.02);
    transition: transform 600ms ease;
}

/* Subtle Ken Burns: only on the active slide so background slides don't
   compete. The animation slowly pushes scale + a small pan over 12s. */
.carousel-slide.is-active .carousel-slide-cover img {
    animation: kenburns 12000ms ease-out forwards;
}

@keyframes kenburns {
    0%   { transform: scale(1.02) translate(0, 0); }
    100% { transform: scale(1.12) translate(-2%, -1.5%); }
}

.carousel-slide-cover::after {
    /* gentle vignette + faint amber edge wash so titles never fight the photo */
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(120% 80% at 0% 0%, var(--accent-subtle), transparent 55%),
        linear-gradient(90deg, transparent 60%, var(--scrim) 100%),
        linear-gradient(180deg, transparent 55%, var(--scrim) 100%);
}

.carousel-slide-body {
    padding: 32px 36px 32px 38px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    min-width: 0;
    background:
        linear-gradient(180deg, var(--bg-void) 0%, var(--bg) 100%);
}

.carousel-slide-genre {
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.carousel-slide-title {
    margin: 0;
    color: var(--accent);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-style: italic;
    font-weight: normal;
    font-size: clamp(28px, 3vw, 40px);
    line-height: 1.05;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.carousel-slide-title a {
    color: inherit;
    text-decoration: none;
    transition: color 150ms ease;
}
.carousel-slide-title a:hover { color: var(--accent-bright); }

.carousel-slide-blurb {
    margin: 0;
    color: var(--text-light);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 15.5px;
    line-height: 1.55;
    max-width: 46ch;
}

.carousel-slide-blurb-prefix {
    color: var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin-right: 8px;
    vertical-align: 2px;
    display: inline-block;
}

.carousel-slide-author {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px dashed var(--hairline);
    border-bottom: 1px dashed var(--hairline);
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 0.06em;
}

.carousel-slide-mark {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brown-warm);
    color: var(--accent);
    border: 1px solid var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
}

.carousel-slide-author-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.carousel-slide-author-label {
    color: var(--text-mute);
    font-size: 10px;
    letter-spacing: 0.2em;
}

.carousel-slide-author-name {
    color: var(--text-light);
    font-size: 14px;
    letter-spacing: 0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.carousel-slide-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.carousel-slide-open,
.carousel-slide-host {
    background: var(--accent);
    color: var(--bg);
    border: 1px solid var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 12px;
    letter-spacing: 0.16em;
    padding: 10px 18px;
    text-decoration: none;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 150ms ease;
}
.carousel-slide-open:hover { background: var(--accent-bright); }
.carousel-slide-host {
    background: transparent;
    color: var(--accent);
}
.carousel-slide-host:hover {
    background: var(--accent-subtle);
}

/* ----------------------------------------------------------- arrows */

.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 44px;
    height: 44px;
    border: 1px solid var(--accent-half);
    background: var(--scrim);
    color: var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease, background 150ms ease, border-color 150ms ease;
    backdrop-filter: blur(2px);
}

.carousel-arrow--prev { left: 14px; }
.carousel-arrow--next { right: 14px; }

.featured-carousel:hover .carousel-arrow,
.featured-carousel:focus-within .carousel-arrow {
    opacity: 1;
}

.carousel-arrow:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.carousel-arrow:disabled { opacity: 0.2; cursor: default; }

@media (hover: none) {
    .carousel-arrow { opacity: 1; }
}

/* --------------------------------------------- countdown progress bar
   Thin amber bar pinned to the bottom of the carousel frame. Fills from
   0% to 100% over AUTO_ADVANCE_MS, then resets when the slide changes
   or the user hovers. CSS-only animation; JS just toggles `is-filling`
   and sets the transition-duration inline. */

.carousel-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 1px;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg,
        var(--accent-strong) 0%,
        var(--accent-half) 100%);
    pointer-events: none;
    z-index: 3;
}

.carousel-progress.is-filling {
    transform: scaleX(1);
    transition: transform var(--carousel-progress-duration, 5000ms) linear;
}

@media (prefers-reduced-motion: reduce) {
    .carousel-progress { display: none; }
}

/* ------------------------------------------------- dots + position */

.featured-carousel-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 4px 0;
}

.carousel-dots {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.carousel-dot {
    width: 22px;
    height: 6px;
    background: var(--hairline);
    border: 0;
    border-radius: 0;
    padding: 0;
    cursor: pointer;
    transition: background 150ms ease, width 200ms ease;
}

.carousel-dot:hover { background: var(--accent-deep); }

.carousel-dot.is-active {
    background: var(--accent);
    width: 36px;
}

.carousel-position {
    color: var(--accent-deep);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.2em;
}

/* -------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
    .carousel-track { transition: none !important; }
    .carousel-slide.is-active .carousel-slide-cover img {
        animation: none;
        transform: scale(1);
    }
}

/* ------------------------------------------------------- responsive */

@media (max-width: 880px) {
    .carousel-slide {
        grid-template-columns: 1fr;
    }
    .carousel-slide-cover {
        border-right: 0;
        border-bottom: 1px solid var(--bg-tertiary);
        aspect-ratio: 16 / 9;
    }
    .carousel-slide-cover::after {
        background:
            radial-gradient(120% 80% at 0% 0%, var(--accent-subtle), transparent 55%),
            linear-gradient(180deg, transparent 55%, var(--scrim) 100%);
    }
    .carousel-slide-body { padding: 22px 18px 22px; gap: 12px; }
    .carousel-slide-title { font-size: 26px; }
    .carousel-slide-blurb { font-size: 14.5px; }
    .featured-carousel-controls { padding-top: 12px; }
    .carousel-arrow { width: 38px; height: 38px; }
    .featured-carousel-meta { grid-template-columns: 1fr; }
    .featured-carousel-rule { display: none; }
}

/* Mobile carousel: hide arrows, restore thin-line dots (the global 44px
   touch-target rule in base.css inflates them otherwise), enable touch drag.
   Selectors match base.css's specificity (button:not()(:not())) so the source
   order wins. */
@media (max-width: 767px) {
    .carousel-arrow { display: none !important; }

    .carousel-dots button.carousel-dot {
        min-width: 0;
        min-height: 0;
        width: 20px;
        height: 4px;
    }
    .carousel-dots button.carousel-dot.is-active { width: 32px; }
    .carousel-dots { gap: 6px; }

    .carousel-viewport {
        touch-action: pan-y;
        cursor: grab;
    }
    .carousel-viewport.is-dragging {
        cursor: grabbing;
    }
    .carousel-viewport.is-dragging .carousel-track {
        transition: none;
    }
}

/* ============================================================ DISCOVER ROW
   SORT promoted above filters — it's the single most useful affordance on
   the page and now reads that way. */

.discover-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    padding: 14px 0;
    border-top: 1px solid var(--surface-3);
    border-bottom: 1px solid var(--surface-3);
    margin: 0 0 20px;
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--bg);
}

.discover-label {
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 0.2em;
}

.discover-sorts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.discover-sort {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 13px;
    letter-spacing: 0.12em;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 0;
    text-transform: uppercase;
    position: relative;
}

.discover-sort:hover { color: var(--accent); }
.discover-sort.active {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
    font-weight: bold;
}

.discover-sort.active::before {
    content: '▸ ';
    color: var(--bg);
    margin-right: 2px;
}

/* ============================================================== FILTERS
   Filter pills LOOK like buttons (border + + prefix when inactive, × when
   active). Card tags drop the border and become inline metadata. The two
   components are no longer confusable. */

.filter-chips {
    margin: 0 0 24px;
    padding: 4px 0 0;
}

.filter-axis {
    display: grid;
    grid-template-columns: 88px 1fr;
    align-items: start;
    gap: 16px;
    margin-bottom: 12px;
}

.filter-axis-label {
    color: var(--accent-deep);
    font-size: 11px;
    letter-spacing: 0.2em;
    padding-top: 6px;
}

.filter-axis-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.filter-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12px;
    padding: 4px 10px 4px 8px;
    cursor: pointer;
    border-radius: 0;
    text-transform: lowercase;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.chip::before {
    content: '+';
    color: var(--text-faint);
    font-weight: bold;
    line-height: 1;
}

.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip:hover::before { color: var(--accent); }

.chip.active {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
}
.chip.active::before {
    content: '×';
    color: var(--bg);
    font-weight: bold;
}

.filter-more {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 0.14em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 0;
    text-transform: uppercase;
}
.filter-more:hover { color: var(--accent); }
.filter-more[hidden] { display: none; }

/* Active-filters summary row — only shows when something is selected. */

.filter-active-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 88px 1fr auto;
    align-items: center;
    gap: 16px;
    margin-top: 6px;
    padding: 10px 0 0;
    border-top: 1px dashed var(--surface-3);
}
.filter-active-row[hidden] { display: none; }

.filter-active-label {
    color: var(--accent);
    font-size: 11px;
    letter-spacing: 0.2em;
}

.filter-active-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-active-pill {
    background: var(--accent-subtle);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-family: inherit;
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 0;
    text-transform: lowercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.filter-active-pill:hover { background: var(--accent-soft); }
.filter-active-pill::after {
    content: '×';
    color: var(--accent);
    font-weight: bold;
}

.filter-clear {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--text-dim);
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 0.14em;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 0;
    text-transform: uppercase;
}
.filter-clear:hover { color: var(--accent); border-color: var(--accent); }

/* ============================================================ GRID + EMPTY */

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 4px;
}

.market-grid .marketplace-card { height: 100%; }

.market-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 48px 0;
}

.market-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 40px 0 8px;
    font-family: 'Courier New', monospace;
}

.page-btn {
    background: transparent;
    border: 1px solid var(--hairline);
    color: var(--accent);
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    padding: 9px 18px;
    cursor: pointer;
    border-radius: 0;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.page-btn:not(:disabled):hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: bold;
}

.page-btn:disabled { color: var(--surface-5); border-color: var(--bg-tertiary); cursor: default; }

#market-page-label {
    color: var(--text-mute);
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    min-width: 88px;
    text-align: center;
}

#market-page-label .page-num { color: var(--accent); font-weight: bold; }

/* Mobile filters toolbar + bottom sheet. Default state hides the inline-only
   pieces (toolbar buttons, sheet header/footer, sort sheet, backdrop). The
   @media block below flips the desktop chip wall into a slide-up sheet, hides
   the desktop discover-row, and shows the unified [Sort: x] [Filters (n)]
   toolbar with an always-visible active-pills row. */

.filter-mobile-bar { display: none; }
.filter-active-mobile { display: none; }
.filter-sheet-header { display: none; }
.filter-sheet-footer { display: none; }
.filter-sheet-backdrop { display: none; }
.filter-sheet-backdrop[hidden] { display: none; }
.sort-sheet { display: none; }

@media (max-width: 768px), (pointer: coarse) {
    .marketplace-header { flex-direction: column; gap: 16px; align-items: stretch; }
    .marketplace-search-mobile {
        display: flex;
        width: 100%;
        margin: 0 0 12px;
    }
    .marketplace-search-mobile input { width: 100%; }
    .filter-axis { grid-template-columns: 1fr; gap: 6px; }
    .filter-axis-label { padding-top: 0; }
    .filter-active-row { grid-template-columns: 1fr; gap: 8px; }
    .discover-row { position: static; }

    /* Desktop discover-row (label + sort tabs) is replaced on mobile by the
       unified [Sort:][Filters] toolbar below. */
    .discover-row { display: none; }

    /* Unified toolbar: two equal buttons side-by-side. */
    .filter-mobile-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin: 0 0 12px;
    }
    .sort-open-btn,
    .filter-open-btn {
        background: transparent;
        border: 1px solid var(--hairline);
        color: var(--text-light);
        font-family: inherit;
        font-size: 12px;
        letter-spacing: 0.14em;
        padding: 10px 14px;
        cursor: pointer;
        border-radius: 0;
        text-transform: uppercase;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 44px;
        width: 100%;
    }
    .sort-open-btn:hover,
    .filter-open-btn:hover { color: var(--accent); border-color: var(--accent); }
    .sort-open-btn[aria-expanded="true"],
    .filter-open-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

    .sort-open-btn-prefix { color: var(--text-mute); }
    .sort-open-btn-value { color: inherit; font-weight: bold; }

    .filter-open-btn-count {
        background: var(--accent);
        color: var(--bg);
        font-weight: bold;
        font-size: 11px;
        letter-spacing: 0;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .filter-open-btn-count[hidden] { display: none; }

    /* Always-visible active-filters row below the toolbar. Horizontal scroll
       so many pills don't wrap the layout. */
    .filter-active-mobile {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0 0 14px;
    }
    .filter-active-mobile[hidden] { display: none; }
    .filter-active-mobile-pills {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        gap: 6px;
        padding: 2px 0;
    }
    .filter-active-mobile-pills::-webkit-scrollbar { display: none; }
    .filter-active-mobile-pills .filter-active-pill { flex-shrink: 0; }
    .filter-active-mobile-clear {
        flex-shrink: 0;
        background: transparent;
        border: 0;
        color: var(--text-dim);
        font-family: inherit;
        font-size: 11px;
        letter-spacing: 0.14em;
        padding: 4px 4px;
        cursor: pointer;
        text-transform: uppercase;
        text-decoration: underline;
        min-height: auto;
        min-width: auto;
    }
    .filter-active-mobile-clear:hover { color: var(--accent); }

    /* The in-sheet active-row becomes redundant on mobile since we mirror it
       above the sheet. Hide inside the sheet. */
    .filter-chips .filter-active-row { display: none; }

    /* Sort sheet: same slide-up pattern as filter sheet. */
    .sort-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 95;
        margin: 0;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom)) 16px;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--bg-secondary);
        border-top: 1px solid var(--accent);
        transform: translateY(100%);
        transition: transform 240ms cubic-bezier(.4,0,.2,1);
        visibility: hidden;
    }
    body[data-sort-sheet-open] .sort-sheet {
        transform: translateY(0);
        visibility: visible;
    }
    .sort-sheet .filter-sheet-header { padding: 12px 0 10px; }
    .sort-sheet-list {
        list-style: none;
        padding: 0;
        margin: 8px 0 0;
    }
    .sort-sheet-item {
        width: 100%;
        background: transparent;
        border: 0;
        color: var(--text-light);
        font-family: 'Courier New', monospace;
        font-size: 14px;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        text-align: left;
        padding: 14px 4px;
        cursor: pointer;
        border-bottom: 1px solid var(--surface-3);
        min-height: 48px;
        position: relative;
    }
    .sort-sheet-item:hover { color: var(--accent); }
    .sort-sheet-item.is-active { color: var(--accent); font-weight: bold; }
    .sort-sheet-item.is-active::after {
        content: '✓';
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--accent);
        font-size: 16px;
    }

    /* The chip wall becomes a slide-up bottom sheet. Default closed: translated
       offscreen with no pointer events. Body sets data-filter-sheet-open when
       the toggle button is pressed. */
    .filter-chips {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 95;
        margin: 0;
        padding: 0 16px calc(16px + env(safe-area-inset-bottom)) 16px;
        max-height: 82vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--bg-secondary);
        border-top: 1px solid var(--accent);
        transform: translateY(100%);
        transition: transform 240ms cubic-bezier(.4,0,.2,1);
        visibility: hidden;
    }
    body[data-filter-sheet-open] .filter-chips {
        transform: translateY(0);
        visibility: visible;
    }

    .filter-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        position: sticky;
        top: 0;
        background: var(--bg-secondary);
        padding: 12px 0 10px;
        margin: 0 0 8px;
        border-bottom: 1px solid var(--surface-3);
        z-index: 2;
    }
    .filter-sheet-title {
        color: var(--accent);
        font-family: 'Courier New', monospace;
        font-size: 13px;
        letter-spacing: 0.2em;
        font-weight: bold;
    }
    .filter-sheet-close {
        width: 44px;
        height: 44px;
        background: transparent;
        border: 0;
        color: var(--text-light);
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
    }
    .filter-sheet-close:hover { color: var(--accent); }

    .filter-sheet-footer {
        display: block;
        position: sticky;
        bottom: 0;
        background: var(--bg-secondary);
        padding: 12px 0 4px;
        margin-top: 12px;
        border-top: 1px solid var(--surface-3);
    }
    .filter-sheet-apply {
        width: 100%;
        background: var(--accent);
        color: var(--bg);
        border: 1px solid var(--accent);
        font-family: 'Courier New', monospace;
        font-size: 13px;
        letter-spacing: 0.18em;
        font-weight: bold;
        padding: 12px 16px;
        cursor: pointer;
        border-radius: 0;
        text-transform: uppercase;
        min-height: 48px;
    }
    .filter-sheet-apply:active { background: var(--accent-bright); }

    /* Inside the sheet, chips get a bit more breathing room for fingers. */
    .filter-chips .chip { padding: 8px 12px 8px 10px; font-size: 13px; }
    .filter-chips .filter-axis { margin-bottom: 16px; }
    .filter-chips .filter-axis-label {
        color: var(--accent);
        font-size: 11px;
        letter-spacing: 0.22em;
        margin-bottom: 4px;
    }

    .filter-sheet-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 94;
        background: var(--scrim);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .filter-sheet-backdrop[hidden] { display: none; }
}

@media (max-width: 640px) {
    .marketplace-page { padding: 24px 16px 48px; }
    .market-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* base.css forces every <button> to a 44px square under 768px, ballooning the
   removable active-filter pills and the filter-panel chips (dense, wrapping
   rows). Restore their designed size; the element+class+attribute selectors
   tie the global rule and win by load order (no !important). */
@media (max-width: 767px) {
    button.filter-active-pill[data-axis],
    button.chip[data-axis] {
        min-height: auto;
        min-width: auto;
    }
}
