/*
 * HiFi Corner — stylesheet. Plain CSS, no build step.
 *
 * Direction: an independent specialist shop and a listening magazine rather
 * than an app. Warm paper, black ink, one oxblood accent. Structure comes from
 * typography and thin rules; photographs carry the colour.
 *
 * Fonts are self-hosted (SIL OFL, see /assets/fonts): Newsreader for editorial
 * headings, IBM Plex Sans for everything you read to make a decision.
 */

/* Each font comes in two parts: basic Latin, and Latin Extended (Lithuanian ą č ę ė į š ų ū ž,
   other European letters). The browser downloads the second only when a page uses those letters. */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/newsreader-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/newsreader-normal-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 500; font-display: swap; src: url("../fonts/newsreader-italic.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 500; font-display: swap; src: url("../fonts/newsreader-italic-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/ibm-plex-sans-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/ibm-plex-sans-normal-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-italic.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-italic-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
    --paper: #f5f2eb;
    --paper-raised: #fbfaf6;
    --mat: #e8e3d8;            /* behind photographs */
    --ink: #1b1a18;
    --ink-soft: #3c3934;
    --muted: #6b665e;
    --rule: #d6cfc1;
    --rule-soft: #e4ded2;
    --accent: #7a2633;         /* oxblood */
    --accent-dark: #5c1b26;
    --accent-tint: #f2e6e3;
    --positive: #46542a;       /* muted olive */
    --positive-tint: #e9ecdc;
    --caution: #7f5512;
    --caution-tint: #f4ead3;
    --negative: #9b2c22;
    --negative-tint: #f6e3df;
    /* Lines and text that used to be fixed colours */
    --on-accent: #fff;         /* text on accent / danger fills */
    --line-positive: #c3c9a8;
    --line-caution: #dcc79c;
    --line-negative: #e0b5ad;
    --line-accent: #d8b5b5;
    --input-line: #bdb4a4;
    --placeholder: #958e84;
    --dropzone-line: #a79e8f;
    --sidebar: #1b1a18;        /* admin navigation: dark in both themes */
    --shadow: var(--shadow);
    /* Item condition scale: dot, label background, label text */
    --cond-new: #2f7a4b;       --cond-new-tint: #e2efe5;       --cond-new-ink: #1d4a2e;
    --cond-mint: #4a8a3c;      --cond-mint-tint: #e6f0df;      --cond-mint-ink: #2b5223;
    --cond-excellent: #6f8a25; --cond-excellent-tint: #edf0d9; --cond-excellent-ink: #3f4f12;
    --cond-very-good: #a08a14; --cond-very-good-tint: #f3eed4; --cond-very-good-ink: #5a4c08;
    --cond-good: #c07a12;      --cond-good-tint: #f6e9d2;      --cond-good-ink: #6b420a;
    --cond-fair: #c25a1e;      --cond-fair-tint: #f7e2d6;      --cond-fair-ink: #73330f;
    --cond-parts: #a8322a;     --cond-parts-tint: #f6dedb;     --cond-parts-ink: #7a2019;

    --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
    --sans: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
    --radius: 2px;
    --max: 1280px;
    --gutter: clamp(1rem, 3vw, 2rem);
    --ease: cubic-bezier(.2, .6, .2, 1);
    color-scheme: light;
}

/* ------------------------------------------------------------------ Dark theme
   The same variables with dark values. Applied when the visitor picks "Dark"
   (data-theme="dark" on <html>, set by the server from the theme cookie), or
   when they keep "Automatic" and their device is set to dark. The two blocks
   below must stay identical. */
:root[data-theme="dark"] {
    --paper: #171513; --paper-raised: #1f1c19; --mat: #2a2622;
    --ink: #ece6da; --ink-soft: #cdc5b7; --muted: #9c948a;
    --rule: #3b3631; --rule-soft: #2c2824;
    --accent: #d98893; --accent-dark: #ecaab2; --accent-tint: #3a2327;
    --positive: #b3c283; --positive-tint: #262b1c;
    --caution: #e0b366; --caution-tint: #33291a;
    --negative: #ec9386; --negative-tint: #3b211d;
    --cond-new: #5fb57f;       --cond-new-tint: #1c2c22;       --cond-new-ink: #a9dcb9;
    --cond-mint: #79b56a;      --cond-mint-tint: #1f2c1c;      --cond-mint-ink: #b6dcaa;
    --cond-excellent: #a2bb52; --cond-excellent-tint: #272c18; --cond-excellent-ink: #cfdc9c;
    --cond-very-good: #cdb43f; --cond-very-good-tint: #2f2a14; --cond-very-good-ink: #e6d78f;
    --cond-good: #e0a04a;      --cond-good-tint: #33261a;      --cond-good-ink: #f0c98f;
    --cond-fair: #e5855a;      --cond-fair-tint: #35221a;      --cond-fair-ink: #f2b496;
    --cond-parts: #e2736a;     --cond-parts-tint: #372019;     --cond-parts-ink: #f2aaa4;
    --on-accent: #171513;
    --line-positive: #4c5636; --line-caution: #5f4b26; --line-negative: #6a3a33; --line-accent: #66363d;
    --input-line: #4a443d; --placeholder: #857d72; --dropzone-line: #5a534b;
    --sidebar: #0f0e0c;
    --shadow: rgba(0, 0, 0, .6);
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #171513; --paper-raised: #1f1c19; --mat: #2a2622;
        --ink: #ece6da; --ink-soft: #cdc5b7; --muted: #9c948a;
        --rule: #3b3631; --rule-soft: #2c2824;
        --accent: #d98893; --accent-dark: #ecaab2; --accent-tint: #3a2327;
        --positive: #b3c283; --positive-tint: #262b1c;
        --caution: #e0b366; --caution-tint: #33291a;
        --negative: #ec9386; --negative-tint: #3b211d;
        --cond-new: #5fb57f;       --cond-new-tint: #1c2c22;       --cond-new-ink: #a9dcb9;
        --cond-mint: #79b56a;      --cond-mint-tint: #1f2c1c;      --cond-mint-ink: #b6dcaa;
        --cond-excellent: #a2bb52; --cond-excellent-tint: #272c18; --cond-excellent-ink: #cfdc9c;
        --cond-very-good: #cdb43f; --cond-very-good-tint: #2f2a14; --cond-very-good-ink: #e6d78f;
        --cond-good: #e0a04a;      --cond-good-tint: #33261a;      --cond-good-ink: #f0c98f;
        --cond-fair: #e5855a;      --cond-fair-tint: #35221a;      --cond-fair-ink: #f2b496;
        --cond-parts: #e2736a;     --cond-parts-tint: #372019;     --cond-parts-ink: #f2aaa4;
        --on-accent: #171513;
        --line-positive: #4c5636; --line-caution: #5f4b26; --line-negative: #6a3a33; --line-accent: #66363d;
        --input-line: #4a443d; --placeholder: #857d72; --dropzone-line: #5a534b;
        --sidebar: #0f0e0c;
        --shadow: rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}
/* Category drawings are light line art: invert them (hue kept) on dark pages. */
:root[data-theme="dark"] img[src^="/assets/images/categories/"] { filter: invert(.9) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) img[src^="/assets/images/categories/"] { filter: invert(.9) hue-rotate(180deg); }
}

/* ------------------------------------------------------------------ Base */

*, *::before, *::after { box-sizing: border-box; }
/* clip, not hidden: hidden would make <body> a scroll container and stop sticky
   elements (header, filters, summaries) from sticking. --header-h is set by app.js. */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; scroll-padding-top: calc(var(--header-h, 0px) + 1rem); }
body {
    margin: 0;
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-dark); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.005em; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); }
h2 { font-size: clamp(1.45rem, 2.2vw, 1.8rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 1.75rem 0; }
small, .small { font-size: .875rem; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; color: var(--paper); }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.container-fluid { max-width: none; }
.page { padding-top: 2.25rem; padding-bottom: 4rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* Small uppercase labels: brand names, section kickers, panel titles. */
.eyebrow, .panel-title {
    font-family: var(--sans);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 .5rem;
}
.lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 38rem; }
.arrow-link { font-weight: 500; text-decoration: none; white-space: nowrap; }
.arrow-link::after { content: " →"; }
.arrow-link:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ Masthead */

.site-header { background: var(--paper); border-bottom: 1px solid var(--ink); position: sticky; top: 0; z-index: 50; transition: box-shadow .2s var(--ease); }
/* Scrolled down: a soft shadow separates the header from the page under it, and
   a bar on its bottom edge fills from left to right, reaching the end at the
   bottom of the page (--scroll-progress, 0–1, set by app.js). */
.site-header.is-scrolled { box-shadow: 0 10px 22px -16px var(--shadow); }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); transform: scaleX(var(--scroll-progress, 0)); transform-origin: left center; pointer-events: none; }
@media (forced-colors: active) { .site-header::after { background: CanvasText; } }
.masthead { display: flex; align-items: center; gap: 1.5rem; padding-top: 1.1rem; padding-bottom: 1rem; }
.masthead .wordmark { margin-right: auto; }
/* Offers, Messages, Saved: icon and label; icon only on narrower screens (the label stays for screen readers). */
.header-actions { display: flex; align-items: center; gap: 1.25rem; }
.header-action { position: relative; display: inline-flex; align-items: center; gap: .4rem; color: var(--ink-soft); text-decoration: none; font-size: .9rem; white-space: nowrap; padding: .3rem 0; }
.header-action:hover { color: var(--accent); }
.header-action.active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.header-action .icon { width: 20px; height: 20px; flex: none; }
.header-action .badge-count { margin-left: 0; }
.header-sell { white-space: nowrap; }
.header-sell .sell-short { display: none; }
@media (max-width: 1180px) {
    .header-actions { gap: 1rem; }
    .header-action-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
    .header-action { padding: .35rem; }
    .header-action .badge-count { position: absolute; top: -.35rem; right: -.55rem; }
}
.wordmark { font-family: var(--serif); font-size: 1.7rem; font-weight: 500; letter-spacing: -.01em; color: var(--ink); text-decoration: none; line-height: 1; white-space: nowrap; }
.wordmark em { font-style: italic; font-weight: 400; color: var(--accent); }
.wordmark:hover { color: var(--ink); }
.account-links { display: flex; align-items: center; gap: 1.1rem; font-size: .9rem; white-space: nowrap; }
.account-links a, .account-links button.link { color: var(--ink-soft); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; padding: 0; }
.account-links a:hover, .account-links button.link:hover { color: var(--accent); }

.section-nav { border-top: 1px solid var(--rule); }

/* Search under the sticky header, the full width of the page (not on /listings). */
.search-band { background: var(--mat); border-bottom: 1px solid var(--rule); padding: .9rem 0; }
.search-band-form { display: flex; border: 1px solid var(--ink); background: var(--paper-raised); }
.search-band-form:focus-within { box-shadow: 0 0 0 1px var(--ink); }
.search-band-form input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 1rem; padding: .7rem .9rem; color: var(--ink); }
.search-band-form input::placeholder { color: var(--muted); }
.search-band-form input:focus { outline: none; }
.search-band-form button { border: 0; border-left: 1px solid var(--ink); background: var(--ink); color: var(--paper); font: inherit; font-weight: 500; padding: 0 1.4rem; cursor: pointer; }
.search-band-form button:hover, .search-band-form button:focus-visible { background: var(--accent); color: var(--on-accent); }
@media (max-width: 560px) { .search-band { padding: .6rem 0; } .search-band-form input { padding: .6rem .7rem; } .search-band-form button { padding: 0 1rem; } }
.section-nav .container { display: flex; align-items: center; gap: 1.75rem; min-height: 2.9rem; }
.main-nav { display: flex; align-items: center; gap: 1.75rem; flex: 1; }
.main-nav a, .user-nav a { color: var(--ink); text-decoration: none; font-size: .92rem; font-weight: 500; padding: .7rem 0; border-bottom: 2px solid transparent; margin-bottom: -1px; position: relative; }
.main-nav a:hover, .user-nav a:hover { color: var(--accent); }
.main-nav a.active, .user-nav a.active { border-bottom-color: var(--ink); }
.main-nav .nav-sell { color: var(--accent); }
.main-nav .push { margin-left: auto; }
.user-nav { display: flex; gap: 1.5rem; }
.badge-count { display: inline-block; min-width: 1.2rem; padding: 0 .3rem; margin-left: .3rem; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .7rem; line-height: 1.2rem; text-align: center; font-weight: 600; vertical-align: 1px; }

.user-menu { position: relative; }
.user-menu > button { display: inline-flex; align-items: center; gap: .5rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: var(--ink-soft); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 600; flex: none; letter-spacing: .02em; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 112px; height: 112px; font-size: 2rem; font-family: var(--serif); }
.dropdown { position: absolute; right: 0; top: calc(100% + .6rem); background: var(--paper-raised); color: var(--ink); border: 1px solid var(--ink); min-width: 220px; padding: .35rem 0; display: none; z-index: 60; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: .5rem 1rem; color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; font-size: .92rem; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--mat); color: var(--ink); }
.dropdown .divider { height: 1px; background: var(--rule); margin: .35rem 0; }
.nav-toggle { display: none; background: none; border: 0; color: var(--ink); padding: 0; font: inherit; cursor: pointer; border-radius: 50%; }
.nav-toggle-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav-toggle[aria-expanded="true"] .avatar { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
/* Phones: "Sign in" as a button (the desktop account links are hidden there). */
.header-signin { display: none; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); padding: .35rem .8rem; font-size: .85rem; font-weight: 600; text-decoration: none; border-radius: var(--radius); white-space: nowrap; }
.header-signin:hover, .header-signin:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Phones, signed in: the avatar opens this account menu under the header. */
.account-panel { display: none; border-top: 1px solid var(--rule); }
.account-panel .container { display: flex; flex-direction: column; padding-bottom: .5rem; }
.account-panel a, .account-panel button { display: block; text-align: left; padding: .75rem 0; border: 0; border-bottom: 1px solid var(--rule-soft); background: none; font: inherit; font-size: .92rem; color: var(--ink-soft); text-decoration: none; cursor: pointer; width: 100%; }
.account-panel a:hover, .account-panel button:hover { color: var(--accent); }

@media (max-width: 900px) {
    .masthead { flex-wrap: wrap; gap: .9rem 1rem; }
    .wordmark { font-size: 1.45rem; }
    .nav-toggle { display: inline-flex; align-items: center; }
    .header-signin { display: inline-block; }
    /* Signed in: language and name move into the account menu. Signed out: the language link stays. */
    .account-links { display: none; }
    .account-links.is-guest { display: flex; }
    .account-links.is-guest > a:not(.lang-link) { display: none; }
    /* Browse, Categories, Brands stay in a row; on a very narrow screen it scrolls sideways. */
    .section-nav .container { gap: 1rem; min-height: 0; }
    .main-nav { gap: 1.25rem; overflow-x: auto; scrollbar-width: none; }
    .main-nav a { padding: .6rem 0; font-size: .9rem; white-space: nowrap; }
    .account-panel.open { display: block; max-height: calc(100dvh - var(--masthead-h, 7rem)); overflow-y: auto; overscroll-behavior: contain; }
}
/* Phones: one header row: icons, "Sell", and the avatar (signed in) or Sign in and language. */
@media (max-width: 560px) {
    .masthead { flex-wrap: nowrap; gap: .5rem; }
    .masthead .wordmark { font-size: 1.3rem; }
    .header-actions { gap: .15rem; }
    .header-action { padding: .3rem; }
    .masthead .header-sell, .masthead .header-signin { padding: .3rem .6rem; font-size: .82rem; }
    .header-sell .sell-long { display: none; }
    .header-sell .sell-short { display: inline; }
}

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

.site-footer { border-top: 1px solid var(--ink); margin-top: 3rem; padding: 2.75rem 0 2.25rem; font-size: .9rem; color: var(--ink-soft); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); gap: 2rem; }
.footer-grid h4 { font-family: var(--sans); font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: .75rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.footer-grid a { color: var(--ink); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-note { max-width: 30rem; }
.footer-note .wordmark { font-size: 1.35rem; display: inline-block; margin-bottom: .75rem; }
.footer-small { margin-top: 2.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .82rem; }
.footer-bottom { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 2rem; margin-top: 2.25rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.footer-bottom .footer-small { margin: 0; padding: 0; border: 0; max-width: 46rem; }
.language-switch, .theme-switch { display: flex; gap: 1rem; font-size: .82rem; }
.language-switch a, .theme-switch a { color: var(--ink); }
.language-switch a:hover, .theme-switch a:hover { color: var(--accent); }
.language-switch [aria-current], .theme-switch [aria-current] { color: var(--muted); }
.account-links .lang-link { font-family: var(--sans); font-size: .74rem; font-weight: 600; letter-spacing: .08em; color: var(--ink); text-decoration: none; border: 1px solid var(--rule); border-radius: var(--radius); padding: .2rem .45rem; line-height: 1; }
.account-links .lang-link:hover { border-color: var(--ink); color: var(--accent); }
.push-settings { display: grid; gap: .45rem; }
.push-browser { display: grid; gap: .6rem; padding: .85rem 1rem; margin-bottom: .35rem; background: var(--paper); border: 1px solid var(--rule-soft); border-radius: var(--radius); }
.push-browser .row { gap: .5rem; flex-wrap: wrap; }
.push-browser .row:empty, .push-browser .row:not(:has(button:not([hidden]))) { display: none; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-note { grid-column: 1 / -1; } }

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

.flashes { margin: 1.25rem 0 0; display: grid; gap: .5rem; }
.flash { padding: .75rem 1rem; border-left: 3px solid var(--ink); background: var(--paper-raised); display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; font-size: .95rem; }
.flash-success { border-left-color: var(--positive); background: var(--positive-tint); }
.flash-error { border-left-color: var(--negative); background: var(--negative-tint); }
.flash-info { border-left-color: var(--ink-soft); }
.flash-warning { border-left-color: var(--caution); background: var(--caution-tint); }

.notice { padding: .85rem 1rem; background: var(--paper-raised); border: 1px solid var(--rule); border-left: 3px solid var(--ink-soft); font-size: .95rem; }
.notice-warn { border-left-color: var(--caution); background: var(--caution-tint); border-color: #e3d3ad; }
.notice-info { border-left-color: var(--ink-soft); }

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

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    padding: .62rem 1.15rem; border-radius: var(--radius); border: 1px solid var(--ink);
    background: transparent; color: var(--ink); font: inherit; font-size: .95rem; font-weight: 500;
    text-decoration: none; cursor: pointer; line-height: 1.2;
    transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--on-accent); }
.btn-accent { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-accent:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-danger { border-color: var(--negative); color: var(--negative); }
.btn-danger:hover { background: var(--negative); color: var(--on-accent); }
.btn-ghost { border-color: transparent; color: var(--accent); padding-left: .4rem; padding-right: .4rem; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.btn-ghost:hover { background: transparent; color: var(--accent-dark); }
.btn-sm { padding: .38rem .75rem; font-size: .85rem; }
.btn-lg { padding: .82rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
/* Google's own sign-in button colours (white, dark text), the same in light and dark mode. */
.btn-google { background: #fff; color: #1f1f1f; border-color: #747775; font-weight: 500; padding: .75rem 1.25rem; }
.btn-google:hover, .btn-google:focus-visible { background: #f2f2f2; color: #1f1f1f; border-color: #747775; }
.btn-google svg { width: 20px; height: 20px; }
.text-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.text-button:hover { color: var(--accent-dark); }
form.inline { display: inline; }

/* ------------------------------------------------------------------ Panels
 * Used across account and admin pages. A ruled box, not a floating card. */

.card { background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); }
.card-body { padding: 1.25rem 1.4rem; }
.card-header { padding: .9rem 1.4rem; border-bottom: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1.2rem; }

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

.form-grid { display: grid; gap: 1.15rem; }
.field label, .label { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .92rem; }
.field .hint, .hint { font-size: .84rem; color: var(--muted); margin-top: .3rem; }
.input, select.input, textarea.input {
    width: 100%; font: inherit; font-size: .97rem; color: var(--ink); background: var(--paper-raised);
    border: 1px solid var(--input-line); border-radius: var(--radius); padding: .58rem .7rem;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
select.input { padding-right: 2rem; }
textarea.input { min-height: 140px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); outline: none; }
.input::placeholder { color: var(--placeholder); }
.input-money, .input-unit { position: relative; }
.input-money span { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.input-money .input { padding-left: 2.8rem; font-variant-numeric: tabular-nums; }
.input-unit span { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.input-unit .input { padding-right: 2.6rem; font-variant-numeric: tabular-nums; }
.field-error { color: var(--negative); font-size: .86rem; margin: .3rem 0 0; }
.has-error .input { border-color: var(--negative); }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; font-size: .94rem; }
.check input { margin-top: .25rem; width: 1rem; height: 1rem; accent-color: var(--accent); flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.inline-input { display: inline-block; width: auto; min-width: 9rem; padding: .36rem .6rem; font-size: .88rem; }
.input.inline-input, select.input.inline-input { width: auto; }
.textarea-sm { min-height: 84px !important; }

/* ------------------------------------------------------------------ Labels
 * Status shown as small set type, not coloured pills. */

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .45rem; border: 1px solid var(--rule); border-radius: var(--radius); font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); background: transparent; white-space: nowrap; }
.badge-active, .badge-accepted, .badge-resolved, .badge-sent { color: var(--positive); border-color: var(--line-positive); }
.badge-reserved, .badge-countered, .badge-pending, .badge-open, .badge-sending { color: var(--caution); border-color: var(--line-caution); }
.badge-sold { color: var(--ink); border-color: var(--ink); }
.badge-removed, .badge-declined, .badge-suspended, .badge-failed, .badge-cancelled { color: var(--negative); border-color: var(--line-negative); }
.badge-pending_verification, .badge-expired, .badge-withdrawn, .badge-dismissed { color: var(--muted); }
.badge-drop { color: var(--accent); border-color: var(--line-accent); }

.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .6rem; border: 1px solid var(--ink); border-radius: var(--radius); background: transparent; color: var(--ink); font-size: .84rem; text-decoration: none; }
a.chip:hover { background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------------ Photographs */

.photo { display: block; position: relative; background: var(--mat); overflow: hidden; aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; transition: transform .5s var(--ease), opacity .3s var(--ease); }
.photo.fit-cover img { object-fit: cover; }
.photo.fit-contain img { object-fit: contain; padding: 6%; }
a.photo:hover img, a:hover > .photo img { transform: scale(1.025); }
.photo .no-image, .no-image { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; font-style: italic; font-family: var(--serif); }

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

.listing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2.25rem 1.5rem; }
/* Phones: two cards a row (one would fill the whole screen). */
@media (max-width: 560px) { .listing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem .85rem; } }
.listing-card { display: flex; flex-direction: column; position: relative; min-width: 0; }
.listing-card .cover { margin-bottom: .85rem; }
/* Every card's picture fills the same 4:3 frame (photo or drawing, any shape), so all cards look alike. */
.listing-card .cover img, .listing-card .cover.fit-contain img, .listing-card .cover.fit-illustration img { object-fit: cover; padding: 0; }
.listing-card .body { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.listing-card .maker { font-size: .72rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.listing-card .state { color: var(--caution); }
.listing-card .state-sold { color: var(--ink); }
.listing-card h3 { font-family: var(--sans); font-size: 1rem; font-weight: 500; line-height: 1.35; margin: 0; }
.listing-card h3 a { color: var(--ink); text-decoration: none; }
.listing-card h3 a::after { content: ""; position: absolute; inset: 0; }
.listing-card:hover h3 a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }
.listing-card .price-line { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; margin-top: .2rem; }
.listing-card .price { font-size: 1.12rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.listing-card .was { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.listing-card .was s { text-decoration-thickness: 1px; }
.listing-card .reduced { color: var(--accent); font-size: .8rem; font-weight: 500; }
.listing-card .condition { font-size: .88rem; }
.cond { --c: var(--muted); --c-tint: var(--rule-soft); --c-ink: var(--ink-soft);
    display: inline-flex; align-items: center; gap: .4em; padding: .05em .55em .05em .45em; border-radius: 999px;
    background: var(--c-tint); color: var(--c-ink); font-family: var(--sans); font-size: .82em; font-weight: 600; line-height: 1.55; white-space: nowrap; vertical-align: baseline; }
.cond::before { content: ""; width: .55em; height: .55em; border-radius: 50%; background: var(--c); flex: none; }
.cond-new { --c: var(--cond-new); --c-tint: var(--cond-new-tint); --c-ink: var(--cond-new-ink); }
.cond-mint { --c: var(--cond-mint); --c-tint: var(--cond-mint-tint); --c-ink: var(--cond-mint-ink); }
.cond-excellent { --c: var(--cond-excellent); --c-tint: var(--cond-excellent-tint); --c-ink: var(--cond-excellent-ink); }
.cond-very-good { --c: var(--cond-very-good); --c-tint: var(--cond-very-good-tint); --c-ink: var(--cond-very-good-ink); }
.cond-good { --c: var(--cond-good); --c-tint: var(--cond-good-tint); --c-ink: var(--cond-good-ink); }
.cond-fair { --c: var(--cond-fair); --c-tint: var(--cond-fair-tint); --c-ink: var(--cond-fair-ink); }
.cond-for-parts { --c: var(--cond-parts); --c-tint: var(--cond-parts-tint); --c-ink: var(--cond-parts-ink); }
.facts dd .cond + .note { margin-top: .3rem; }
@media (forced-colors: active) { .cond { border: 1px solid CanvasText; } .cond::before { background: CanvasText; } }
.listing-card .spec-line { font-size: .84rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listing-card .meta { display: flex; justify-content: space-between; gap: .5rem; margin-top: auto; padding-top: .45rem; border-top: 1px solid var(--rule-soft); color: var(--muted); font-size: .82rem; }
/* margin-top: auto keeps the location line at the bottom, level across a row of cards. */
.listing-card .body > :nth-last-child(2) { margin-bottom: .45rem; }
.listing-card .meta .new { color: var(--accent); }
.listing-card .flags { display: none; }

/* ------------------------------------------------------------------ Section heads */

.section { padding: 3.25rem 0 0; }
.section-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .5rem 2rem; margin-bottom: 1.6rem; padding-bottom: .8rem; border-bottom: 1px solid var(--ink); }
.section-head h2 { margin: 0; }
.section-head p { grid-column: 1; margin: 0; color: var(--muted); max-width: 40rem; font-size: .95rem; }
.section-head > a { grid-column: 2; grid-row: 1; align-self: end; }

/* ------------------------------------------------------------------ Categories */

.category-index { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2rem 1.5rem; }
.category-entry { min-width: 0; }
.category-entry > a { text-decoration: none; color: var(--ink); display: block; }
.category-entry .photo { aspect-ratio: 3 / 2; margin-bottom: .7rem; }
.category-entry .photo.empty-photo { display: flex; align-items: flex-end; padding: 1rem; background: var(--mat); }
.category-entry .photo.empty-photo span { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .9rem; }
.category-entry h3 { margin: 0; font-size: 1.25rem; }
.category-entry > a:hover h3 { color: var(--accent); }
.category-entry .count { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.category-entry ul { list-style: none; padding: 0; margin: .55rem 0 0; font-size: .88rem; display: flex; flex-wrap: wrap; gap: .15rem .9rem; }
.category-entry ul a { color: var(--ink-soft); }
.category-entry ul a:hover { color: var(--accent); }
@media (max-width: 1000px) { .category-index { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 680px) { .category-index { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1rem; } }

/* Kept for older templates */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.category-tile { border-top: 1px solid var(--ink); padding: .75rem 0; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.category-tile strong { font-family: var(--serif); font-size: 1.1rem; font-weight: 500; }
.category-tile span { color: var(--muted); font-size: .85rem; }


/* Key facts list: label / value rows separated by hairlines. */
.facts { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); font-size: .92rem; }
.facts dt, .facts dd { padding: .5rem 0; border-top: 1px solid var(--rule-soft); margin: 0; }
.facts dt { color: var(--muted); padding-right: 1.5rem; }
.facts dd { font-variant-numeric: tabular-nums; }
.facts dd .note { display: block; color: var(--muted); font-size: .84rem; }

/* ------------------------------------------------------------------ Home: price reductions ledger */

.ledger { width: 100%; border-collapse: collapse; font-size: .94rem; }
.ledger td, .ledger th { padding: .8rem .75rem .8rem 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.ledger th { font-size: .72rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--ink); padding-top: 0; }
.ledger .item { display: flex; gap: 1rem; align-items: center; min-width: 0; }
.ledger .item .photo { width: 5.5rem; flex: none; aspect-ratio: 4 / 3; }
.ledger .item a { color: var(--ink); text-decoration: none; font-weight: 500; }
.ledger .item a:hover { text-decoration: underline; color: var(--accent); }
.ledger .item small { display: block; color: var(--muted); }
.ledger .money { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.ledger .was { color: var(--muted); }
.ledger .now { font-weight: 600; }
.ledger .diff { color: var(--accent); }
.ledger .when { color: var(--muted); white-space: nowrap; text-align: right; font-size: .86rem; }
@media (max-width: 760px) {
    .ledger thead { display: none; }
    .ledger tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1px solid var(--rule); padding: .75rem 0; gap: .2rem 1rem; }
    .ledger td { border: 0; padding: 0; }
    .ledger td.cell-item { grid-column: 1 / -1; margin-bottom: .35rem; }
    .ledger .money, .ledger .when { text-align: left; }
}

/* ------------------------------------------------------------------ Home: how it works */

.principles { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: clamp(1.5rem, 4vw, 3.5rem); border-top: 1px solid var(--ink); padding-top: 1.75rem; }
.principles h2 { font-weight: 400; font-size: clamp(1.7rem, 2.8vw, 2.3rem); line-height: 1.1; }
.principles dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 2.5rem; }
.principles dt { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; margin-bottom: .35rem; }
.principles dd { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.principles .closing { grid-column: 2; margin: 0; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
@media (max-width: 860px) { .principles { grid-template-columns: minmax(0, 1fr); } .principles .closing { grid-column: 1; } }
@media (max-width: 600px) { .principles dl { grid-template-columns: minmax(0, 1fr); } }

/* Old hero classes (no longer used on the home page) */
.hero, .hero-points { display: none; }
.hero-search { display: flex; }

/* ------------------------------------------------------------------ Browse */

.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .5rem 2rem; padding-bottom: 1rem; margin-bottom: 1.75rem; border-bottom: 1px solid var(--ink); }
.page-head h1 { margin: 0; }
.page-head p { margin: .35rem 0 0; color: var(--muted); }
/* Phones: the heading and the link beside it stack, so the text keeps the full width. */
@media (max-width: 560px) {
    .page-head, .section-head { grid-template-columns: minmax(0, 1fr); }
    .page-head > *, .section-head > *, .page-head > a, .section-head > a { grid-column: 1; grid-row: auto; justify-self: start; }
}
.browse { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.browse > * { min-width: 0; }
.filters { position: sticky; top: calc(var(--header-h, 0px) + 1.25rem); }
.filters form { display: grid; gap: 1.05rem; }
.filters .field label, .filters .label { font-size: .74rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.filters .input { font-size: .92rem; padding: .48rem .6rem; }
.filters-toggle { display: none; }
@media (max-width: 900px) {
    .browse { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
    .filters { position: static; display: none; padding: 1rem; border: 1px solid var(--rule); background: var(--paper-raised); }
    .filters.open { display: block; }
    .filters-toggle { display: inline-flex; }
}
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.results-bar .row { gap: .5rem; }
.spec-filters { border-top: 1px solid var(--rule); padding-top: .9rem; }
.spec-filters summary { cursor: pointer; font-weight: 600; font-size: .74rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink); margin-bottom: .9rem; list-style-position: outside; }
.spec-filters .field { margin-bottom: 1rem; }
.spec-filters .check { margin: .3rem 0; font-size: .9rem; }
.range-pair { gap: .5rem; }

.pagination { display: flex; gap: .25rem; justify-content: center; margin-top: 3rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.pagination a, .pagination span { min-width: 2.3rem; padding: .4rem .65rem; text-align: center; text-decoration: none; color: var(--ink); border-bottom: 1px solid transparent; }
.pagination a:hover { border-bottom-color: var(--ink); }
.pagination .current { border-bottom: 2px solid var(--accent); font-weight: 600; }

.empty { padding: 2.5rem 0; color: var(--ink-soft); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); max-width: 40rem; }
.empty h3 { color: var(--ink); font-size: 1.4rem; font-weight: 400; }
.empty p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ Brands index */

.brand-letters { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-bottom: 2rem; font-weight: 500; }
.brand-letters a { text-decoration: none; }
.brand-index { columns: 4 14rem; column-gap: 2.5rem; }
.brand-group { break-inside: avoid; margin-bottom: 1.75rem; }
.brand-group h2 { font-size: 1.6rem; border-bottom: 1px solid var(--ink); padding-bottom: .2rem; margin-bottom: .5rem; }
.brand-group ul { list-style: none; margin: 0; padding: 0; }
.brand-group li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px solid var(--rule-soft); font-size: .95rem; }
.brand-group li a { color: var(--ink); text-decoration: none; }
.brand-group li a:hover { color: var(--accent); text-decoration: underline; }
.brand-group li .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.brand-group li.none { color: var(--muted); }

/* ------------------------------------------------------------------ Listing page */

.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1.5rem; display: flex; gap: .45rem; flex-wrap: wrap; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--ink); }
.breadcrumbs span { overflow-wrap: anywhere; color: var(--ink-soft); }

.product { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(1.5rem, 4vw, 3.25rem); align-items: start; }
.product > * { min-width: 0; }
@media (max-width: 960px) { .product { grid-template-columns: minmax(0, 1fr); } }

.gallery { position: relative; }
.gallery-main { position: relative; background: var(--mat); aspect-ratio: 4 / 3; touch-action: pan-y pinch-zoom; /* sideways swipes switch photos (app.js) */ }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-main .no-image { font-size: 1rem; }
.gallery-nav { position: absolute; inset: auto 0 0 auto; display: flex; align-items: center; gap: 0; background: var(--paper); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); font-size: .85rem; font-variant-numeric: tabular-nums; }
.gallery-nav button { background: none; border: 0; padding: .55rem .9rem; font: inherit; cursor: pointer; color: var(--ink); }
.gallery-nav button:hover { background: var(--ink); color: var(--paper); }
.gallery-nav span { padding: 0 .4rem; color: var(--muted); }
.gallery-thumbs { display: flex; gap: .5rem; margin-top: .6rem; overflow-x: auto; padding-bottom: .25rem; }
.gallery-thumbs button { border: 0; outline-offset: 2px; padding: 0; cursor: pointer; flex: none; width: 88px; height: 66px; background: var(--mat); opacity: .62; transition: opacity .15s var(--ease); border-bottom: 2px solid transparent; }
.gallery-thumbs button:hover { opacity: 1; }
.gallery-thumbs button.active { opacity: 1; border-bottom-color: var(--accent); }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* Photo viewer: [data-zoom-open] opens the lightbox below. */
.gallery-main [data-gallery-main] { cursor: pointer; }
.gallery-enlarge { position: absolute; top: .6rem; right: .6rem; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); padding: .35rem .65rem; font: inherit; font-size: .82rem; cursor: pointer; opacity: .9; }
.gallery-enlarge:hover, .gallery-enlarge:focus-visible { opacity: 1; background: var(--ink); color: var(--paper); }
/* Lightbox: the page dims, the photo sits in the middle at its own proportions
   (never cropped, never enlarged past its real size); arrows on the sides. */
.lightbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: #f5f2eb; overflow: hidden; }
.lightbox[open] { display: grid; place-items: center; }
.lightbox::backdrop { background: rgba(13, 12, 11, .78); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: .6rem; touch-action: pan-y; /* sideways swipes switch photos (app.js) */ }
.lightbox-figure img { display: block; width: auto; height: auto; max-width: min(calc(100vw - 9rem), 1600px); max-height: calc(100dvh - 6rem); object-fit: contain; background: var(--mat); box-shadow: 0 18px 60px rgba(0, 0, 0, .45); user-select: none; -webkit-user-drag: none; transition: opacity .15s var(--ease); }
.lightbox-figure img.is-loading { opacity: .25; }
.lightbox[open] .lightbox-figure { animation: lightbox-in .18s var(--ease); }
@keyframes lightbox-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .lightbox[open] .lightbox-figure { animation: none; } }
.lightbox-count { font-size: .85rem; font-variant-numeric: tabular-nums; opacity: .8; }
.lightbox-button { position: absolute; display: grid; place-items: center; width: 3rem; height: 3rem; padding: 0; border: 1px solid rgba(245, 242, 235, .25); border-radius: 50%; background: rgba(13, 12, 11, .55); color: inherit; font: inherit; font-size: 1.15rem; line-height: 1; cursor: pointer; transition: background .15s var(--ease); }
.lightbox-button:hover { background: rgba(245, 242, 235, .18); }
.lightbox-button:focus-visible { outline: 2px solid #f5f2eb; outline-offset: 2px; }
.lightbox-close { top: 1rem; right: 1rem; }
.lightbox-prev, .lightbox-next { top: 50%; transform: translateY(-50%); font-size: 2rem; padding-bottom: .2rem; }
.lightbox-prev { left: 1.25rem; }
.lightbox-next { right: 1.25rem; }
/* Phones: the photo uses the full width; swipe instead of arrows. */
@media (max-width: 560px), (pointer: coarse) {
    .lightbox-figure img { max-width: 100vw; max-height: calc(100dvh - 8rem); }
    .lightbox-prev, .lightbox-next { display: none; }
    .lightbox-close { top: .6rem; right: .6rem; }
}
/* Touch screens swipe between photos (app.js), so the arrow buttons go; the count stays. */
@media (pointer: coarse) {
    .gallery-nav button { display: none; }
    .gallery-nav span { padding: .45rem .75rem; }
}

.summary { position: sticky; top: calc(var(--header-h, 0px) + 1.25rem); }
@media (max-width: 960px) { .summary { position: static; } }
.summary .maker { margin-bottom: .55rem; }
.detail-title { font-size: var(--title-size, clamp(1.8rem, 3vw, 2.45rem)); font-weight: 400; line-height: 1.1; margin: 0 0 1rem; overflow-wrap: anywhere; }
.price-block { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin: 0 0 .35rem; }
.price-big { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.price-note { color: var(--muted); font-size: .9rem; margin-bottom: 1.35rem; }
.price-note a { color: var(--accent); }
.summary .facts { margin-bottom: 1.5rem; }
.summary .facts dt:last-of-type, .summary .facts dd:last-of-type { border-bottom: 1px solid var(--rule-soft); }
.action-block { padding: 1.25rem 0; border-top: 1px solid var(--ink); }
.action-block + .action-block { border-top-color: var(--rule); }
.action-block h2 { font-family: var(--sans); font-size: .95rem; font-weight: 600; margin: 0 0 .75rem; }
/* Listing title with the share button beside it. */
.title-row { --title-size: clamp(1.8rem, 3vw, 2.45rem); position: relative; display: flex; align-items: flex-start; gap: .75rem; }
/* The button is centred on the title's first line (line height 1.1 × the title size). */
.title-row .icon-button { margin-top: calc((var(--title-size) * 1.1 - 2.5rem) / 2); }
.title-row .detail-title { flex: 1; min-width: 0; }
/* Star ratings: thin outline stars, filled in the ink colour up to the average. */
.rating { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--ink-soft); line-height: 1; }
.rating-stars { display: block; flex: none; }
.rating-stars path { stroke-width: 1; stroke-linejoin: round; }
.rating-empty path { fill: none; stroke: var(--muted); }
.rating-full path { fill: var(--ink); stroke: var(--ink); }
.rating-value { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.rating-count { color: var(--muted); }
.profile-head .rating, .seller-block .rating { margin: .15rem 0 .45rem; }
.star-input { display: inline-flex; flex-direction: row-reverse; gap: .15rem; }
.star-input button { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.star-input svg { width: 26px; height: 26px; }
.star-input path { fill: none; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; transition: fill .12s var(--ease); }
.star-input button.is-on { color: var(--ink); }
.star-input button.is-on path { fill: currentColor; }
/* Hover or focus previews: that star and the ones before it (they come later in the DOM, row-reverse). */
.star-input:hover button, .star-input:focus-within button { color: var(--muted); }
.star-input:hover button path, .star-input:focus-within button path { fill: none; }
.star-input button:hover, .star-input button:hover ~ button, .star-input button:focus-visible, .star-input button:focus-visible ~ button { color: var(--ink); }
.star-input button:hover path, .star-input button:hover ~ button path, .star-input button:focus-visible path, .star-input button:focus-visible ~ button path { fill: currentColor; }
.star-input button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.rate-card h3 { margin: 0 0 .25rem; }
.icon-button { flex: none; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; margin-top: .2rem; padding: 0; border: 1px solid var(--rule); border-radius: 50%; background: none; color: var(--ink); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.icon-button:hover, .icon-button:focus-visible { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.icon-button .icon { width: 18px; height: 18px; }
.share-status { position: absolute; right: 0; top: 3.1rem; z-index: 2; padding: .25rem .6rem; border-radius: var(--radius); background: var(--ink); color: var(--paper); font-size: .8rem; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s var(--ease); }
.share-status.is-shown { opacity: 1; }
.secondary-actions { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; font-size: .92rem; padding: 1rem 0 0; border-top: 1px solid var(--rule); }
.secondary-actions details { width: 100%; }
.privacy-note { font-size: .86rem; color: var(--muted); margin: 1rem 0 0; }

details.inline-disclosure summary { cursor: pointer; color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; display: inline; list-style: none; }
details.inline-disclosure summary::-webkit-details-marker { display: none; }
details.inline-disclosure[open] summary { color: var(--ink); text-decoration: none; font-weight: 500; }
details.inline-disclosure > div { margin-top: .75rem; }
details.disclosure summary { cursor: pointer; font-weight: 500; color: var(--accent); list-style: none; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before { content: "+ "; }
details.disclosure[open] summary::before { content: "− "; }
details.disclosure > div { margin-top: .75rem; }

.product-body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(1.5rem, 4vw, 3.25rem); margin-top: 3.25rem; }
.product-body > * { min-width: 0; }
@media (max-width: 960px) { .product-body { grid-template-columns: minmax(0, 1fr); margin-top: 2.25rem; } }
.product-section { border-top: 1px solid var(--ink); padding-top: 1rem; }
.product-section > h2 { font-size: 1.45rem; margin-bottom: 1rem; }
.description { font-family: var(--serif); font-size: 1.14rem; line-height: 1.62; color: var(--ink); max-width: 40rem; overflow-wrap: anywhere; }
.description p { margin-bottom: .9em; }
.description .credit { font-family: var(--sans); font-size: .82rem; color: var(--muted); }

.specs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin: 0; font-size: .93rem; }
.specs dt, .specs dd { margin: 0; padding: .55rem 0; border-bottom: 1px solid var(--rule-soft); }
.specs dt { color: var(--muted); padding-right: 1rem; }
.specs dd { font-variant-numeric: tabular-nums; font-weight: 500; }
.specs-group { margin-top: 1.5rem; }
.specs-group:first-child { margin-top: 0; }

.history { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2rem; align-items: start; }
@media (max-width: 860px) { .history { grid-template-columns: minmax(0, 1fr); } }
.history-summary { font-family: var(--serif); font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 1.25rem; max-width: 44rem; }
.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { max-width: 100%; }
.history-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.history-table td, .history-table th { padding: .5rem .5rem .5rem 0; border-bottom: 1px solid var(--rule-soft); text-align: left; }
.history-table th { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; border-bottom-color: var(--ink); }
.history-table .down { color: var(--accent); }
.history-table .up { color: var(--ink); }

.seller-block { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.seller-block h3 { margin: 0 0 .2rem; font-size: 1.25rem; }
.seller-block h3 a { color: var(--ink); text-decoration: none; }
.seller-block h3 a:hover { color: var(--accent); text-decoration: underline; }
.seller-block .bio { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-soft); margin: .6rem 0 0; }
.seller-card { display: flex; gap: .85rem; align-items: center; }

/* Old detail classes kept for compatibility */
.detail { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 2rem; align-items: start; }
.detail > * { min-width: 0; }
/* No sidebar (e.g. a new listing, before photos can be added): use the full width. */
.detail-single { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 960px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.side-stack { display: grid; gap: 1rem; position: sticky; top: calc(var(--header-h, 0px) + 1.25rem); }
@media (max-width: 960px) { .side-stack { position: static; } }

/* ------------------------------------------------------------------ Seller profile */

.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.75rem; align-items: center; padding-bottom: 1.75rem; border-bottom: 1px solid var(--ink); margin-bottom: 2.25rem; }
.profile-head h1 { margin: 0 0 .3rem; }
.profile-head .bio { font-family: var(--serif); font-size: 1.15rem; color: var(--ink-soft); max-width: 42rem; margin: .8rem 0 0; }
@media (max-width: 560px) { .profile-head { grid-template-columns: minmax(0, 1fr); } }
.sold-list { list-style: none; margin: 0; padding: 0; }
.sold-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule-soft); font-size: .94rem; }
.sold-list li span { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ Tables */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.table th, table.table td { padding: .7rem .8rem .7rem 0; border-bottom: 1px solid var(--rule-soft); text-align: left; vertical-align: middle; }
.card table.table th:first-child, .card table.table td:first-child { padding-left: 1.4rem; }
table.table th { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); border-bottom-color: var(--rule); }
table.table tr:last-child td { border-bottom: 0; }
.thumb-sm { width: 64px; height: 48px; object-fit: cover; background: var(--mat); }

/* ------------------------------------------------------------------ Tabs */

.tabs { display: flex; gap: 1.75rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs a { padding: .6rem 0; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-color: var(--ink); }

/* ------------------------------------------------------------------ Offers */

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: .9rem; padding: .7rem 0; border-bottom: 1px solid var(--rule-soft); }
.timeline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rule); margin-top: .45rem; }
.timeline .dot.offer, .timeline .dot.counter { background: var(--ink); }
.timeline .dot.accept { background: var(--positive); }
.timeline .dot.decline, .timeline .dot.cancel, .timeline .dot.withdraw, .timeline .dot.expire { background: var(--negative); }
.amount-now { font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.contact-box { background: var(--positive-tint); border: 1px solid var(--line-positive); border-left: 3px solid var(--positive); padding: 1.1rem 1.25rem; }
.contact-box dl { margin: 0; }
.package-fields { border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0; }
.package-fields legend { padding: 0 .35rem; margin-left: -.35rem; }
.package-fields.has-error { border-color: var(--negative); }
.package-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.package-grid .field { margin: 0; }
@media (max-width: 560px) { .package-grid { grid-template-columns: 1fr 1fr; } }
.shipping { margin-top: 2rem; scroll-margin-top: 1.5rem; }
.shipping-table td, .shipping-table th { font-size: .9rem; }
.shipping-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.shipping-table tbody tr:first-child td { font-weight: 600; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.field-pair-hint { grid-column: 1 / -1; margin-top: .35rem; }
@media (max-width: 560px) { .field-pair { grid-template-columns: 1fr; } }

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

.conversation-list { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.conversation-item { display: flex; gap: .9rem; align-items: center; padding: .85rem .25rem; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.conversation-item:hover { background: var(--paper-raised); color: var(--ink); }
.conversation-item.unread { box-shadow: inset 3px 0 0 var(--accent); padding-left: .9rem; }
.conversation-item.unread strong { font-weight: 600; }
.conversation-item .preview { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; gap: .7rem; padding: 1.25rem; max-height: 62vh; overflow-y: auto; background: var(--paper); }
.bubble { max-width: 75%; padding: .65rem .9rem; background: var(--paper-raised); border: 1px solid var(--rule); overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bubble .time { display: block; font-size: .72rem; opacity: .7; margin-top: .25rem; }
.thread-more { align-self: center; font-size: .85rem; }

/* ------------------------------------------------------------------ Seller form & images */

.image-manager { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.image-tile { border: 1px solid var(--rule); background: var(--paper-raised); }
.image-tile img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; background: var(--mat); }
.image-tile .actions { display: flex; gap: .25rem; padding: .4rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
/* Rearranging: the first tile is the main photo; arrows only where a move is possible. */
.image-tile:not(:first-child) .main-badge, .image-tile:first-child .make-main,
.image-tile:first-child .move-earlier, .image-tile:last-child .move-later { display: none; }
.image-tile .move-buttons { display: inline-flex; margin-left: auto; }
.image-tile .move-buttons .btn { padding-inline: .45rem; }
/* "Main photo" / "Make main" on the first line, arrows and delete on the second,
   so tiles line up and long translations still fit. */
.image-manager[data-reorder] .image-tile .main-badge,
.image-manager[data-reorder] .image-tile .make-main { margin-right: 100%; flex-shrink: 0; white-space: nowrap; } /* forces the line break, keeps natural width */
.image-manager[data-reorder] .image-tile .make-main .btn { padding-inline: .3rem; }
.image-manager[data-reorder] .image-tile .move-buttons { margin-left: 0; }
.image-manager[data-reorder] .image-tile .move-buttons + form { margin-left: auto; }
.image-manager[data-reorder] .image-tile { cursor: grab; }
.image-manager[data-reorder] .image-tile { transition: transform .18s var(--ease); -webkit-touch-callout: none; }
.image-manager[data-reorder] .image-tile img { -webkit-user-drag: none; user-select: none; }
.image-manager.is-sorting, .image-manager.is-sorting * { cursor: grabbing; user-select: none; }
/* Where the dragged photo will land: the photo itself, greyed out and faded. */
.image-tile.is-placeholder { filter: grayscale(1); opacity: .45; outline: 2px dashed var(--accent); outline-offset: -2px; }
.image-tile.is-placeholder .actions { visibility: hidden; }
/* The copy that follows the pointer. */
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 80; margin: 0; pointer-events: none; box-shadow: 0 14px 30px -10px var(--shadow); will-change: transform; }
.drag-ghost.is-settling { transition: transform .15s var(--ease); }
.dropzone { border: 1px dashed var(--dropzone-line); padding: 1.25rem; text-align: center; background: var(--paper); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-tint); }
.previews { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; justify-content: center; }
.previews img { width: 90px; height: 68px; object-fit: cover; }
.spec-fieldset { border-top: 1px solid var(--ink); padding: .9rem 0 0; margin: .5rem 0 0; }
.spec-fieldset legend { font-family: var(--serif); font-size: 1.3rem; font-weight: 500; padding: 0 .6rem 0 0; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: .9rem 1.1rem; }
.spec-grid .field { margin: 0; }

/* ------------------------------------------------------------------ Sign in */

.draft-card .card-body { gap: 1rem; flex-wrap: wrap; }
.draft-card .badge { margin-right: .4rem; }
.draft-notice { gap: 1rem; align-items: center; }
.auth-or { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--muted); font-size: .85rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.input-code { font-size: 1.5rem; letter-spacing: .25em; font-variant-numeric: tabular-nums; max-width: 12rem; }

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

.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.admin-shell > * { min-width: 0; }
.admin-nav { background: var(--sidebar); padding: 1.25rem .75rem; }
.admin-nav a { display: block; color: #d8d2c7; text-decoration: none; padding: .5rem .75rem; margin-bottom: .1rem; font-size: .93rem; border-left: 2px solid transparent; }
.admin-nav a:hover, .admin-nav a.active { color: #fff; border-left-color: var(--accent); }
.admin-main { padding: 1.75rem 2rem 3rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; margin-bottom: 1.75rem; border-top: 1px solid var(--ink); }
.stat { padding: 1rem 1.1rem 1rem 0; border-bottom: 1px solid var(--rule); }
.stat .value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 400; }

/* Admin dashboard: range switch, headline figures, chart cards (charts drawn by app.js). */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.dash-head h1 { margin: 0; }
.dash-period { margin: .4rem 0 1.25rem; }
.range-switch { display: inline-flex; border: 1px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.range-switch a { padding: .4rem .85rem; font-size: .85rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.range-switch a + a { border-left: 1px solid var(--ink); }
.range-switch a:hover { background: var(--mat); }
.range-switch a[aria-current] { background: var(--ink); color: var(--paper); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.kpi { background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: .9rem 1rem; color: var(--ink); text-decoration: none; display: block; }
a.kpi:hover { border-color: var(--ink); }
.kpi-label { font-size: .8rem; color: var(--muted); letter-spacing: .02em; }
.kpi-value { font-size: 1.75rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; margin: .15rem 0; overflow-wrap: anywhere; }
.kpi-delta { font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.kpi-attention { border-color: var(--caution); background: var(--caution-tint); }
.disk-meter { width: 100%; height: .5rem; margin: .35rem 0 .2rem; }
.dash-section { font-size: 1.15rem; margin: 2rem 0 .9rem; padding-top: .9rem; border-top: 1px solid var(--ink); }
.dash-grid { gap: 1rem; }
.chart-card { padding: 1rem 1.1rem .75rem; display: flex; flex-direction: column; }
.chart-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.chart-card-head h3 { margin: 0; font-size: .95rem; font-weight: 600; }
.chart-figure { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 170px; }
.chart-box.tall { height: 290px; }
.chart-empty { margin: 1.5rem 0; }
.chart-note { margin: .4rem 0 0; }
.chart-table { margin-top: .5rem; font-size: .82rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table summary:hover { color: var(--ink); }
.table-compact th, .table-compact td { padding: .45rem .6rem; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .dash-grid.grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .dash-grid.grid-3, .dash-grid.grid-2 { grid-template-columns: minmax(0, 1fr); } .admin-main { padding: 1.25rem 1rem 2rem; } }
@media (max-width: 860px) {
    .admin-shell { grid-template-columns: minmax(0, 1fr); }
    .admin-nav { display: flex; overflow-x: auto; gap: .25rem; padding: .5rem; }
    .admin-nav a { white-space: nowrap; margin: 0; border-left: 0; border-bottom: 2px solid transparent; }
    .admin-nav a:hover, .admin-nav a.active { border-bottom-color: var(--accent); }
    .admin-main { padding: 1.25rem 1rem 2.5rem; }
}

/* ------------------------------------------------------------------ Error page */

.error-page { padding: 2.5rem 0 3rem; max-width: 40rem; }
.error-page .code { font-family: var(--serif); font-size: 5rem; font-weight: 400; font-style: italic; color: var(--accent); line-height: 1; margin-bottom: .5rem; }
pre.debug { text-align: left; background: var(--sidebar); color: #f5f2eb; padding: 1rem; overflow: auto; font-size: .8rem; max-height: 50vh; }

/* ------------------------------------------------------------------ Utilities (CSP forbids inline styles) */

.ml-auto { margin-left: auto; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.nav-always { display: flex !important; flex-basis: auto !important; flex-direction: row !important; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }
.w-auto { width: auto; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
    .site-header, .site-footer, .summary .action-block, .secondary-actions { display: none; }
    .filters, .summary, .side-stack { position: static; }
}

/* Ruled sections that follow other content on the listing page. */
.product-section.section { margin-top: 3.25rem; padding-top: 1rem; }

/* Spam honeypot (see honeypot_field()): off-screen, not display:none, so bots still see it. */
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Picture puzzle for new accounts past their daily allowance (see puzzle_field()). */
.puzzle { border-left: 3px solid var(--caution); background: var(--caution-tint); padding: .85rem 1rem; }
.puzzle .hint { margin: 0 0 .65rem; }
.puzzle-row { display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; }
/* Drawn at 240×80 and shown smaller, so it stays sharp on high-density screens. */
/* The picture is as tall as a text box (the answer box next to it is one). */
.puzzle-row img { width: 132px; height: 44px; object-fit: contain; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); }
/* The answer box sits right of the picture, as tall as it. */
.puzzle-row .puzzle-input { flex: 0 0 8rem; width: 8rem; height: 44px; font-variant-numeric: tabular-nums; }

/* Category illustrations (public/assets/images/categories/*.svg). */
.category-entry .illustration { display: block; aspect-ratio: 3 / 2; margin-bottom: .7rem; background: var(--mat); overflow: hidden; }
.category-entry .illustration img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.category-entry > a:hover .illustration img { transform: scale(1.03); }

/* Listings without photos show their category's drawing, labelled as such. */
.photo.fit-illustration img { object-fit: contain; }
.photo-note { position: absolute; left: .5rem; bottom: .5rem; padding: .1rem .45rem; background: var(--paper); color: var(--muted); font-size: .74rem; font-style: italic; font-family: var(--serif); pointer-events: none; }
.gallery-main .gallery-illustration { width: 100%; height: 100%; object-fit: contain; }
.gallery-main .photo-note { font-size: .85rem; left: .75rem; bottom: .75rem; }

/* Installable app (PWA): footer install button and the offline page. */
.install-app { background: none; border: 0; padding: 0; font: inherit; font-size: .86rem; color: var(--accent); text-decoration: underline; cursor: pointer; }
.offline { min-height: 100dvh; display: grid; place-content: center; justify-items: center; text-align: center; gap: .25rem; padding-block: 2rem; max-width: 34rem; }
.offline img { border-radius: 22%; margin-bottom: .75rem; }
.offline h1 { font-family: var(--serif); font-weight: 500; margin: 0 0 .25rem; }
.offline p { color: var(--ink-soft); }
/* Running as an installed app: keep clear of notches and the home indicator. */
@media (display-mode: standalone) {
    .site-header { padding-top: env(safe-area-inset-top); }
    .site-footer { padding-bottom: calc(env(safe-area-inset-bottom) + 1rem); }
}


/* Admin → Translations */
.translation-progress { min-width: 11rem; }
.translation-tools { justify-content: space-between; }
/* Parts of the site (Admin → Translations): one button each, with how many texts match. */
.translation-parts { display: flex; flex-wrap: wrap; gap: .4rem; border-top: 1px solid var(--rule); }
.translation-parts a { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink-soft); font-size: .85rem; text-decoration: none; white-space: nowrap; }
.translation-parts a span { color: var(--muted); font-variant-numeric: tabular-nums; }
.translation-parts a:hover { border-color: var(--ink); color: var(--ink); }
.translation-parts a.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.translation-parts a.active span { color: inherit; opacity: .75; }
.translation-table td { vertical-align: top; }
.translation-table td:first-child { width: 45%; }
.translation-source { overflow-wrap: anywhere; }
.translation-where { display: block; margin-top: .3rem; overflow-wrap: anywhere; }
.translation-form { display: block; margin-bottom: .4rem; }
.translation-form .muted { display: block; font-size: .78rem; }
.translation-status { display: block; margin-top: .3rem; min-height: 1.2em; }
.translation-status.is-saved { color: var(--positive); }
.translation-status.is-error { color: var(--negative); }
.translation-save { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; padding: .75rem 0; background: var(--paper); border-top: 1px solid var(--rule); margin-top: 1rem; }
@media (max-width: 760px) {
    .translation-table thead { display: none; }
    .translation-table tr, .translation-table td { display: block; width: auto; }
    .translation-table td:first-child { width: auto; border-bottom: 0; padding-bottom: .2rem; }
}

/* Admin → Security: authenticator app and backup codes */
.totp-card { max-width: 34rem; }
.totp-steps { padding-left: 1.2rem; display: grid; gap: 1.25rem; }
.totp-qr-box { width: 13rem; max-width: 100%; margin: .75rem 0; padding: .5rem; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); }
.totp-qr-box svg { display: block; width: 100%; height: auto; }
.totp-secret { font-size: 1rem; letter-spacing: .06em; word-spacing: .2em; overflow-wrap: anywhere; user-select: all; }
.backup-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .4rem 1.5rem; padding-left: 1.6rem; font-size: 1.05rem; }
.backup-codes code { letter-spacing: .06em; user-select: all; }
.backup-codes-card { border-color: var(--caution); }
