/* ============================================================
   Channel 9 Marketplace — design system
   Inspired by CB radio faceplates: dial glow, S-meters, LED
   channel readouts, brushed-metal panels.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    --bg:            #1c1b19;
    --panel:         #262420;
    --panel-raised:  #302d28;
    --line:          #3d3a34;
    --accent:        #ff6b1a;   /* squelch-orange LED glow */
    --accent-dim:    #b34d13;
    --amber:         #f2a93b;   /* analog dial glow */
    --green:         #4caf6d;   /* transmit / active */
    --red:           #e5533d;
    --text:          #f0ebe1;
    --text-muted:    #a69d8e;
    --text-faint:    #766c5e;

    --font-display: 'Oswald', sans-serif;
    --font-body:    'Inter', sans-serif;
    --font-mono:    'IBM Plex Mono', monospace;

    --radius: 7px;
    --radius-sm: 4px;

    color-scheme: dark;
}

/* Light theme — brushed-aluminum faceplate under daylight rather than
   dial-glow at night. Same accent hues, inverted surfaces. Opt-in via toggle. */
html[data-theme="light"] {
    --bg:            #f3efe4;
    --panel:         #fdfbf6;
    --panel-raised:  #ece5d5;
    --line:          #ddd2ba;
    --accent:        #e35d17;
    --accent-dim:    #c94f10;
    --amber:         #b06f16;
    --green:         #2f8f56;
    --red:           #c73f2b;
    --text:          #2a251d;
    --text-muted:    #6e6455;
    --text-faint:    #948a78;

    color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 900px 500px at 50% -10%, rgba(255,107,26,0.08), transparent 60%);
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.5em;
    color: var(--text);
}

h1 { font-size: 1.9rem; letter-spacing: 0.03em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

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

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------- Header / faceplate bar ---------------- */

.site-header {
    background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    flex-wrap: wrap;
}
@media (max-width: 700px) {
    .site-header__inner { padding: 12px 0; }
    .main-nav { width: 100%; justify-content: flex-start; }
}
@media (max-width: 480px) {
    .brand { font-size: 1.7rem; gap: 10px; }
    .smeter { height: 26px; }
    .smeter span { width: 6px; }
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }

/* Signature element: an S-meter (signal strength meter), the
   little bar-graph on every CB radio that shows signal strength.
   Used here as a pulsing brand mark / "on air" indicator. */
.smeter {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 36px;
}
.smeter span {
    width: 8px;
    background: var(--line);
    border-radius: 2px;
    animation: smeter-pulse 2.2s ease-in-out infinite;
}
.smeter span:nth-child(1) { height: 30%; animation-delay: 0s; }
.smeter span:nth-child(2) { height: 55%; animation-delay: 0.15s; }
.smeter span:nth-child(3) { height: 80%; animation-delay: 0.3s; }
.smeter span:nth-child(4) { height: 100%; animation-delay: 0.45s; }
.smeter span:nth-child(5) { height: 65%; animation-delay: 0.6s; }
@keyframes smeter-pulse {
    0%, 100% { background: var(--line); }
    50% { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
}
@media (prefers-reduced-motion: reduce) {
    .smeter span { animation: none; background: var(--accent-dim); }
}

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

/* Theme toggle — styled like a physical rocker switch on a radio faceplate. */
.theme-toggle {
    position: relative;
    width: 52px;
    height: 28px;
    padding: 0;
    margin-right: 4px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--panel-raised);
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: transform 0.2s ease;
}
html[data-theme="light"] .theme-toggle__thumb { transform: translateX(24px); }
.theme-toggle__thumb::before { content: '\263E'; } /* crescent moon (default/dark) */
html[data-theme="light"] .theme-toggle__thumb::before { content: '\2600'; } /* sun */

.nav-link {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}
.nav-link:hover { color: var(--text); background: var(--panel-raised); text-decoration: none; }
.nav-link.is-active { color: var(--accent); }

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--accent);
    color: #1c1b19;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 8px;
    margin-left: 4px;
}

.nav-link--admin { color: var(--amber); border: 1px solid var(--line); }
.nav-link--admin:hover { border-color: var(--amber); }
.nav-link--admin.is-active { color: var(--amber); background: var(--panel-raised); border-color: var(--amber); }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    background: var(--panel-raised);
    color: var(--text);
    transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--line); text-decoration: none; color: var(--text); }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    color: #201a12;
    border-color: var(--accent);
}
.btn-primary:hover { background: #ff7f38; color: #201a12; }

.btn-outline {
    background: transparent;
    border-color: var(--line);
    color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--accent); color: var(--text); background: transparent; }

.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #1c1b19; }

.btn-sm { padding: 7px 12px; font-size: 0.75rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------- Forms ---------------- */

label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=search], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    outline: none;
}
textarea { resize: vertical; min-height: 120px; }

.field { margin-bottom: 18px; }
.field-hint { font-size: 0.8rem; color: var(--text-faint); margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* Sell vs Wanted toggle on the post-listing form */
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-toggle__option {
    display: flex; align-items: center; justify-content: center;
    padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer; font-family: var(--font-display); font-weight: 600;
    font-size: 0.9rem; letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--text-muted); text-align: center;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.type-toggle__option input { position: absolute; opacity: 0; pointer-events: none; }
.type-toggle__option:has(input:checked) {
    border-color: var(--accent); color: var(--accent); background: rgba(255,107,26,0.08);
}

/* Password field with a show/hide eye toggle inside the input. */
.password-field { position: relative; }
.password-field input { padding-right: 42px; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--panel-raised); }
.password-toggle svg { width: 19px; height: 19px; }
.password-toggle .icon-eye-off { display: none; }
.password-field.is-visible .icon-eye { display: none; }
.password-field.is-visible .icon-eye-off { display: block; }

.form-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 560px;
}
.form-panel.wide { max-width: 760px; }

.error-box {
    background: rgba(229, 83, 61, 0.12);
    border: 1px solid var(--red);
    color: #ffb3a5;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 0.9rem;
}
.error-box ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------------- Flash messages ---------------- */

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 0.9rem;
    border: 1px solid var(--line);
}
.flash-success { border-color: var(--green); background: rgba(76,175,109,0.1); color: #b6e9c7; }
.flash-error   { border-color: var(--red); background: rgba(229,83,61,0.1); color: #ffb3a5; }
.flash-info    { border-color: var(--amber); background: rgba(242,169,59,0.1); color: #f5cf94; }

/* ---------------- Hero / search bar ---------------- */

.hero {
    padding: 40px 0 28px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,107,26,0.06), transparent);
}
.hero__eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--amber);
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}
.hero h1 { margin-bottom: 6px; }
.hero p.lead { color: var(--text-muted); max-width: 560px; }

.search-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-top: 22px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}
@media (max-width: 1000px) {
    .search-panel { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 640px) {
    .search-panel { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
    .search-panel { grid-template-columns: 1fr; }
}
.search-panel .field { margin-bottom: 0; }

/* ---------------- Listing grid / cards ---------------- */

.section { padding: 34px 0; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.result-count { color: var(--text-faint); font-size: 0.85rem; font-family: var(--font-mono); }

.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s ease, transform 0.1s ease;
}
.card:hover { border-color: var(--accent-dim); text-decoration: none; }

.card__media {
    aspect-ratio: 4 / 3;
    background: var(--panel-raised);
    position: relative;
    overflow: hidden;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; background: var(--panel-raised); display: block; }
.card__media .no-photo {
    display: flex; align-items: center; justify-content: center;
    height: 100%; color: var(--text-faint); font-family: var(--font-mono); font-size: 0.75rem;
}
.card__badge {
    position: absolute; top: 8px; left: 8px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    color: var(--amber);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    padding: 3px 8px;
    border-radius: 3px;
    letter-spacing: 0.04em;
    border: 1px solid var(--line);
}
.card__badge.sold { color: var(--red); }
.card__badge.featured {
    color: #201a12; background: var(--amber); border-color: var(--amber); font-weight: 600;
    left: auto; right: 8px;
}
.card--featured { border-color: var(--amber); }

/* Sponsored/featured cards in the main grid stand out with a thicker
   amber border and a modestly larger presentation (a bit more image
   height, padding, and text size) — noticeably bigger than a standard
   card without dominating the page. Deliberately does NOT span extra
   grid columns — that made it far too large. */
.card--sponsored {
    border: 2px solid var(--amber);
}
.card--sponsored .card__media { aspect-ratio: 5 / 4; }
.card--sponsored .card__body { padding: 16px; }
.card--sponsored .card__title { font-size: 0.9rem; }
.card--sponsored .card__price { font-size: 1.25rem; }
.card__badge.wanted {
    left: auto; right: 8px;
    background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600;
}

/* Status stamp — an ink-stamp style badge overlaid on listing photos.
   Not shown for Active listings (that's the normal/default state). */
.status-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 7px 22px;
    border: 4px double currentColor;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-faint);
    background: rgba(10, 9, 8, 0.85);
    z-index: 2;
    pointer-events: none;
}
.status-stamp.status-pending   { color: var(--amber); }
.status-stamp.status-on_hold   { color: var(--text-muted); }
.status-stamp.status-sold      { color: var(--accent); }
.status-stamp.status-suspended { color: var(--red); }
.status-stamp--lg {
    font-size: 1.7rem;
    padding: 12px 34px;
    border-width: 5px;
    letter-spacing: 0.2em;
}

.card--pending .card__media img,
.card--on_hold .card__media img,
.card--sold .card__media img { opacity: 0.55; }

.card__body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__price {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent);
}
.card__title {
    color: var(--text);
    font-weight: 600;
    font-size: 0.825rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-transform: uppercase;
}
.card__meta {
    font-size: 0.78rem;
    color: var(--text-faint);
    display: flex;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 6px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}
.empty-state h3 { color: var(--text); }

/* ---------------- Filter chips (admin status filters) ---------------- */

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.chip {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text-muted);
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--panel-raised); text-decoration: none; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #201a12; font-weight: 600; box-shadow: 0 2px 8px rgba(255,107,26,0.25); }

/* ---------------- Listing detail ---------------- */

.listing-detail {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 860px) { .listing-detail { grid-template-columns: 1fr; } }

/* Equal two-column layout used on admin overview/detail pages. A separate
   class (not an inline style) so the mobile media query below can actually
   override it — inline styles always beat media queries, which was
   silently breaking these pages on narrow screens. */
.two-col-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}
@media (max-width: 860px) { .two-col-equal { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto, which lets wide content (like our
   min-width:560px scrollable tables) force the whole grid wider than its
   container. min-width:0 lets the track actually shrink to fit, so the
   table-scroll wrapper's own overflow-x handles it instead. */
.listing-detail > *, .two-col-equal > * { min-width: 0; }

.gallery__main {
    aspect-ratio: 4/3;
    background: var(--panel-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}
.gallery__main img { width: 100%; height: 100%; object-fit: contain; background: var(--bg); }
.gallery__thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery__thumbs img {
    width: 64px; height: 64px; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--line);
    cursor: pointer;
}
.gallery__thumbs img.is-active { border-color: var(--accent); }

.detail-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    position: sticky;
    top: 84px;
}
.detail-price {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}
.detail-title { margin-bottom: 10px; }
.spec-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; }
.spec-table td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.spec-table td:first-child { color: var(--text-faint); width: 40%; }
.spec-table td:last-child { color: var(--text); text-align: right; }

.seller-box {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; background: var(--panel-raised); border-radius: var(--radius-sm);
    margin-bottom: 16px; font-size: 0.9rem;
}
.avatar-circle {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-dim); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; flex-shrink: 0;
}

.description-block { white-space: pre-wrap; line-height: 1.7; color: var(--text); }

/* ---------------- Badges / status ---------------- */

.badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    padding: 3px 9px;
    border-radius: 3px;
    letter-spacing: 0.03em;
    border: 1px solid var(--line);
    color: var(--text-muted);
}
.badge.active { color: var(--green); border-color: var(--green); }
.badge.pending { color: var(--amber); border-color: var(--amber); }
.badge.on_hold { color: var(--text-muted); border-color: var(--text-muted); }
.badge.sold { color: var(--accent-dim); border-color: var(--accent-dim); }
.badge.suspended { color: var(--red); border-color: var(--red); text-decoration: line-through; }
.badge.featured { color: #201a12; background: var(--amber); border-color: var(--amber); font-weight: 600; }
.badge.wanted { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---------------- Tables (my listings, messages) ---------------- */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}
.list-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.list-table th {
    text-align: left; font-family: var(--font-display); text-transform: uppercase;
    font-size: 0.72rem; letter-spacing: 0.05em; color: var(--text-faint);
    padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.list-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.list-table tr:hover td { background: var(--panel-raised); }
.list-table img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: var(--radius-sm); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Admin dashboard ---------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: block;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
a.stat-card:hover {
    border-color: var(--accent);
    background: var(--panel-raised);
    transform: translateY(-1px);
    text-decoration: none;
}
.stat-card .stat-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--accent);
    line-height: 1.1;
}
.stat-card .stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 4px;
}
.admin-section-nav { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

/* ---------------- User management cards (expand-to-edit) ---------------- */

.user-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 12px;
    border-left: 3px solid var(--line);
}
.user-card.is-self { border-left-color: var(--accent-dim); }
.user-card.is-suspended { border-left-color: var(--red); }
.user-card__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}
.user-card__name {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.user-card__meta {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-faint);
    margin-top: 4px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.user-card__meta a { color: var(--amber); }
.user-card__actions { display: flex; gap: 8px; flex-shrink: 0; }

.user-card details { margin-top: 10px; }
.user-card summary {
    cursor: pointer;
    color: var(--amber);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.user-card summary::-webkit-details-marker { display: none; }
.user-card summary::before { content: '▶'; font-size: 0.65rem; transition: transform 0.15s ease; }
.user-card details[open] summary::before { transform: rotate(90deg); }
.user-card__edit-body {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.tier-edit-toggle { margin-top: 4px; }
.tier-edit-toggle summary {
    cursor: pointer;
    color: var(--amber);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.tier-edit-toggle summary::-webkit-details-marker { display: none; }
.tier-edit-toggle summary::before { content: '▶'; font-size: 0.65rem; color: var(--amber); transition: transform 0.15s ease; }
.tier-edit-toggle[open] summary::before { transform: rotate(90deg); }
.user-card__checks { display: flex; gap: 24px; margin: 6px 0 18px; flex-wrap: wrap; }
.user-card__checks label {
    display: flex; align-items: center; gap: 8px;
    text-transform: none; font-family: var(--font-body); font-weight: 400;
    font-size: 0.9rem; color: var(--text); cursor: pointer;
}
.user-card__checks input[type=checkbox] { width: auto; }

/* ---------------- Star rating picker ---------------- */

.star-picker {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 4px;
    font-size: 1.8rem;
}
.star-picker input { position: absolute; opacity: 0; pointer-events: none; }
.star-picker label {
    color: var(--line);
    cursor: pointer;
    text-transform: none;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: normal;
    transition: color 0.1s ease;
}
.star-picker input:checked ~ label,
.star-picker label:hover,
.star-picker label:hover ~ label {
    color: var(--amber);
}

/* ---------------- Messages / inbox ---------------- */

.thread-list { display: flex; flex-direction: column; gap: 2px; }
.thread-item {
    display: flex; gap: 12px; padding: 14px; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius-sm); align-items: center;
}
.thread-item.unread { border-color: var(--accent-dim); }
.thread-item img.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.thread-item__body { flex: 1; min-width: 0; }
.thread-item__body .snippet { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.message-bubble { max-width: 75%; padding: 10px 14px; border-radius: 12px; margin-bottom: 10px; font-size: 0.92rem; }
.message-bubble.mine { background: var(--accent-dim); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.message-bubble.theirs { background: var(--panel-raised); border-bottom-left-radius: 3px; }
.message-time { font-size: 0.7rem; color: var(--text-faint); margin-top: 3px; }

/* ---------------- Pagination ---------------- */

.pagination { display: flex; gap: 6px; margin-top: 26px; justify-content: center; }
.pagination a, .pagination span {
    font-family: var(--font-mono);
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.pagination a:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.pagination .is-current { background: var(--accent); border-color: var(--accent); color: #201a12; }
.pagination__arrow { font-weight: 700; }
.pagination__arrow.is-disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------------- Confirm modal (replaces native browser confirm()) ---------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 8, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.15s ease;
}
.modal-overlay.is-open .modal { transform: translateY(0) scale(1); }

.modal h2 {
    margin-bottom: 10px;
    font-size: 1.05rem;
}
.modal p {
    color: var(--text-muted);
    margin-bottom: 22px;
    font-size: 0.92rem;
    line-height: 1.6;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
@media (prefers-reduced-motion: reduce) {
    .modal-overlay, .modal { transition: none; }
}

/* ---------------- Footer ---------------- */

.site-footer {
    margin-top: auto;
    border-top: 1px solid var(--line);
    padding: 24px 0;
    color: var(--text-faint);
    font-size: 0.82rem;
}
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.footer-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 6px;
    gap: 18px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}
.footer-links span { color: var(--text-faint); }
.admin-cog {
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 0.9rem;
    opacity: 0.45;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    margin-left: 4px;
    text-decoration: none;
    transition: opacity 0.15s ease;
}
.admin-cog:hover { opacity: 0.9; color: var(--text-muted); text-decoration: none; }
@media (max-width: 640px) {
    .site-footer .container { flex-direction: column; align-items: flex-start; gap: 14px; }
}

/* ---------------- Utility ---------------- */

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Long-form prose (About/Terms pages) — avoids doubling spacing that
   .stack's gap would otherwise add on top of paragraphs' own margins. */
.prose { display: flex; flex-direction: column; gap: 6px; }
.prose > p, .prose > ul { margin: 0; }
.prose > h2 { margin-top: 12px; margin-bottom: 0; }
.prose > h2:first-child { margin-top: 0; }

/* ============================================================
   Mobile refinements — a focused pass on top of the responsive
   rules already scattered through the components above.
   ============================================================ */

@media (max-width: 600px) {
    /* iOS Safari auto-zooms on focus if a field's font-size is under
       16px — this was the single biggest "feels wrong on mobile" bug. */
    input[type=text], input[type=email], input[type=password], input[type=number],
    input[type=tel], input[type=search], select, textarea {
        font-size: 16px;
    }

    .container { padding: 0 16px; }

    .form-panel, .form-panel.wide { padding: 20px; max-width: 100%; }

    /* A sticky price/action panel makes little sense once the layout
       has already stacked to a single column — let it sit in normal
       document flow instead of floating oddly with nothing beside it. */
    .detail-panel { position: static; top: auto; }

    .hero { padding: 26px 0 18px; }
    .section { padding: 22px 0; }

    h1 { font-size: 1.55rem; }
    h2 { font-size: 1.2rem; }
    .detail-price { font-size: 1.6rem; }
    .brand { line-height: 1.1; }

    .card__price { font-size: 1rem; }
    .listing-grid { gap: 12px; }

    .btn { padding: 10px 16px; }
    .btn-block, .form-panel .btn { width: 100%; }

    .seller-box { flex-wrap: wrap; }

    .message-bubble { max-width: 88%; }

    .user-card { padding: 14px; }
    .user-card__actions { width: 100%; }
    .user-card__actions form { flex: 1; }
    .user-card__actions .btn { width: 100%; }
}

@media (max-width: 380px) {
    .brand { font-size: 1.4rem; }
    .smeter { height: 22px; }
    .smeter span { width: 5px; }
}

/* ---------------- Homepage billboard announcements ---------------- */

.billboard {
    background: linear-gradient(90deg, rgba(255,107,26,0.16), rgba(242,169,59,0.10));
    border-bottom: 1px solid var(--accent-dim);
}
.billboard .container {
    padding-top: 10px;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.billboard__item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}
.billboard__emoji {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
}

/* ---------------- Registration terms scroll-box ---------------- */

.terms-scroll-box {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    background: var(--bg);
}
.terms-scroll-box .prose { font-size: 0.85rem; line-height: 1.65; }
.terms-scroll-box .prose h2 { font-size: 0.95rem; margin-top: 16px; }
.terms-scroll-box .prose h2:first-child { margin-top: 0; }
#termsCheckbox:disabled { cursor: not-allowed; opacity: 0.5; }
#termsCheckbox:disabled ~ span { color: var(--text-faint); }

/* ---------------- Emoji quick-pick row (announcements, maintenance) ---------------- */

.emoji-pick-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.emoji-pick-btn {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    line-height: 1;
    padding: 8px 11px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.emoji-pick-btn:hover { border-color: var(--accent); background: var(--panel-raised); }

/* Custom tooltip — native title="" attributes are slow to appear, can't
   be styled, and don't work at all on touch devices, so this shows
   immediately on hover/focus instead. */
.emoji-pick-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-raised);
    color: var(--text);
    border: 1px solid var(--line);
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.1s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 20;
}
.emoji-pick-btn:hover::after,
.emoji-pick-btn:focus-visible::after {
    opacity: 1;
    visibility: visible;
}
.emoji-picker {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--bg);
}
.emoji-picker__cat-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin: 12px 0 6px;
}
.emoji-picker__cat-label:first-child { margin-top: 0; }

/* ---------------- Homepage two-column layout ---------------- */

.homepage-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 28px;
    align-items: start;
}
.homepage-main, .homepage-sidebar { min-width: 0; }
.homepage-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 84px;
}
@media (max-width: 960px) {
    .homepage-layout { grid-template-columns: 1fr; }
    .homepage-sidebar { position: static; }
}

/* ---------------- Recently Added / Recently Sold vertical carousels ---------------- */

.vcarousel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}
.vcarousel__label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.vcarousel__viewport {
    height: 210px;
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-sm);
}
.vcarousel__track {
    display: flex;
    flex-direction: column;
}
.vcarousel__item {
    position: relative;
    flex-shrink: 0;
    height: 210px;
    display: flex;
    flex-direction: column;
    background: var(--panel-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-decoration: none;
    transition: border-color 0.15s ease;
}
.vcarousel__item:hover { border-color: var(--accent); text-decoration: none; }
.vcarousel__item img,
.vcarousel__noimg {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background: var(--panel);
    display: block;
}
.vcarousel__noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    background: var(--panel);
    opacity: 0.5;
}
.vcarousel__item.is-sold img,
.vcarousel__item.is-sold .vcarousel__noimg { opacity: 0.45; }
.vcarousel__sold-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(10,9,8,0.85);
    border: 2px double var(--accent);
    color: var(--accent);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    padding: 3px 8px;
}
.vcarousel__info { padding: 10px 12px; }
.vcarousel__price {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.95rem;
}
.vcarousel__title {
    font-size: 0.695rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
    text-transform: uppercase;
}


/* Listing titles display in uppercase like the rest of the site's retro
   CB look, regardless of the case the seller actually typed — the
   database always keeps their real typed text either way. */
.detail-title { text-transform: uppercase; font-size: 1.775rem; }

/* Brief highlight pulse drawing attention to the sponsor section when
   arriving there via the Edit Listing "feature" checkbox. */
.sponsor-highlight {
    animation: sponsor-pulse 2.2s ease;
    border-radius: var(--radius-sm);
}
@keyframes sponsor-pulse {
    0%, 100% { box-shadow: none; background: transparent; }
    15%, 60% { box-shadow: 0 0 0 3px var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
}

/* ---------------- Themed scrollbars ---------------- */
/* Applies to every scrollable area on the site (page body, horizontal
   table overflow, the admin dashboard's Recent Listings/Users tables,
   etc.) so scrollbars match the current theme instead of the browser's
   plain default gray, in both dark and light mode. */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--line) var(--panel);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: var(--panel);
}
*::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 6px;
    border: 2px solid var(--panel);
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dim);
}
*::-webkit-scrollbar-corner {
    background: var(--panel);
}

/* Username in the nav shows exactly as the person typed it at
   registration (e.g. "aPoLLo"), overriding the uppercase style shared
   by every other nav link. */
.nav-link--username {
    text-transform: none;
    font-size: 0.945rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
