:root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --ink: #1c1b19;
    --muted: #6b675f;
    --line: #e6e1d8;
    --accent: #d94f2b;
    --accent-ink: #ffffff;
    --accent-soft: #fbe9e3;
    --ok: #2f7d4f;
    --ok-soft: #e4f3ea;
    --error: #b42318;
    --error-soft: #fdecea;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --logo-filter: none;
    color-scheme: light;
}

/* Dark theme: follows the system unless the visitor picked a theme (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #151412;
        --surface: #1e1d1a;
        --ink: #eeebe5;
        --muted: #a29d93;
        --line: #33312c;
        --accent: #f0714d;
        --accent-ink: #151412;
        --accent-soft: #3a221b;
        --ok: #6cc591;
        --ok-soft: #1c2f24;
        --error: #ff8a7a;
        --error-soft: #3a1f1c;
        --shadow: none;
        color-scheme: dark;
        --logo-filter: invert(1);
    }
}

:root[data-theme="dark"] {
    --bg: #151412;
    --surface: #1e1d1a;
    --ink: #eeebe5;
    --muted: #a29d93;
    --line: #33312c;
    --accent: #f0714d;
    --accent-ink: #151412;
    --accent-soft: #3a221b;
    --ok: #6cc591;
    --ok-soft: #1c2f24;
    --error: #ff8a7a;
    --error-soft: #3a1f1c;
    --shadow: none;
    color-scheme: dark;
    --logo-filter: invert(1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.55 var(--font);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
main { flex: 1; padding-block: 2rem 4rem; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 1rem; }
h2 { font-size: 1.25rem; }
code { font-family: var(--mono); font-size: .9em; }
img { max-width: 100%; }

.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .container { padding-inline: 24px; } }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: .5rem 1rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pre { white-space: pre-line; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .25rem; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.header-inner { display: flex; align-items: center; gap: 1rem 1.5rem; padding-block: .75rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; white-space: nowrap; }
.brand:hover { color: inherit; }
/* the old logo is white on black; inverted it becomes black on white for the dark theme */
.brand-logo { display: block; height: 52px; width: auto; filter: var(--logo-filter); }
.brand-suffix { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.theme-toggle { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}
.header-search { flex: 1 1 220px; max-width: 360px; }
.header-search input { width: 100%; }
.main-nav { display: flex; gap: .25rem 1rem; flex-wrap: wrap; }
.main-nav a { text-decoration: none; padding: .35rem 0; border-bottom: 2px solid transparent; font-weight: 500; }
.main-nav a[aria-current] { border-color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.lang-switch { display: flex; gap: .25rem; }
.lang-switch a { text-decoration: none; font-size: .8rem; font-weight: 600; padding: .2rem .45rem; border-radius: 6px; color: var(--muted); }
.lang-switch a[aria-current] { background: var(--ink); color: var(--bg); }
.cart-link { position: relative; display: inline-flex; padding: .3rem; text-decoration: none; }
.cart-count {
    position: absolute; top: -4px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px;
    border-radius: 10px; background: var(--accent); color: var(--accent-ink);
    font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}
.cart-count.is-empty { display: none; }
@media (max-width: 719px) {
    .header-search { order: 5; flex-basis: 100%; max-width: none; }
    .main-nav { order: 6; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .main-nav a { white-space: nowrap; }
}

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); font-size: .9rem; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding-block: 2rem; }
.footer-inner strong { color: var(--ink); }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; align-content: flex-start; max-width: 560px; }

/* Forms & buttons */
input[type=text], input[type=search], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=file], select, textarea {
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .85rem; line-height: 1.5; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
    border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
    border-radius: 999px; padding: .55rem 1.2rem;
}
.btn:hover { color: var(--bg); opacity: .88; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { color: var(--ink); background: var(--bg); }
.btn-small { padding: .3rem .8rem; font-size: .85rem; }
.btn-done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn-done:hover { color: var(--ok); }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-button:hover { color: var(--accent); }
.link-button.danger { color: var(--error); margin-top: 1rem; }

.form .field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.form .field label { font-weight: 500; font-size: .92rem; }
.form .field-checkbox { flex-direction: row; align-items: flex-start; gap: .6rem; }
.form .field-checkbox input { margin-top: .3rem; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.form .field-checkbox label { font-weight: 400; }
.form .has-error input, .form .has-error textarea { border-color: var(--error); }
.form-errors { list-style: none; margin: 0; padding: 0; color: var(--error); font-size: .875rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid input { width: 100%; }
@media (max-width: 599px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
fieldset.payment { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; margin: 0 0 1rem; background: var(--surface); }
fieldset.payment legend { font-weight: 600; padding-inline: .3rem; }
fieldset.payment p { margin: .25rem 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.card h2:first-child { margin-top: 0; }
.card input:not([type=checkbox]), .card textarea { width: 100%; }
.narrow { max-width: 560px; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; background: var(--ok-soft); color: var(--ok); font-weight: 500; }
.flash-error { background: var(--error-soft); color: var(--error); }
.notice { background: var(--accent-soft); padding: .6rem 1rem; border-radius: var(--radius); margin: 0; }

/* Home */
.hero { padding: 1.5rem 0 1rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); max-width: 18ch; margin-bottom: .75rem; }
.hero .prose { font-size: 1.1rem; max-width: 60ch; color: var(--muted); }
.hero-search { display: flex; gap: .5rem; max-width: 640px; margin: 1.5rem 0 .5rem; }
.hero-search input { flex: 1; font-size: 1.05rem; padding: .75rem 1rem; border-radius: 999px; }
.section { margin-top: 3rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.section-head h2 { margin: 0 0 .5rem; }
.category-grid { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.category-grid a { display: flex; flex-direction: column; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; height: 100%; transition: border-color .15s, transform .15s; }
.category-grid a:hover { border-color: var(--accent); transform: translateY(-1px); color: inherit; }
.category-name { font-weight: 650; }

/* Genres */
.jump-nav, .chip-nav, .letter-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.25rem; }
.jump-nav a, .chip-nav a { text-decoration: none; font-size: .875rem; padding: .3rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.chip-nav a[aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.letter-nav a { text-decoration: none; min-width: 2.1rem; text-align: center; padding: .3rem .45rem; border-radius: 6px; font-weight: 600; font-size: .9rem; }
.letter-nav a:hover { background: var(--accent-soft); }
.letter-nav a[aria-current] { background: var(--accent); color: var(--accent-ink); }
.genre-columns { columns: 280px; column-gap: 2rem; }
.genre-block { break-inside: avoid; margin-bottom: 1.75rem; scroll-margin-top: 140px; }
.genre-block h2 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--ink); padding-bottom: .3rem; margin: 0 0 .4rem; }
.genre-block ul { list-style: none; margin: 0; padding: 0; }
.genre-block li { display: flex; justify-content: space-between; gap: 1rem; padding: .22rem 0; border-bottom: 1px dashed var(--line); }
.genre-block li a { text-decoration: none; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .875rem; }
.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; }

/* Article list */
.article-list { list-style: none; margin: 0; padding: 0; }
.article { display: flex; justify-content: space-between; gap: 1rem 1.5rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.article-main { min-width: 0; }
.article-artist { font-weight: 700; }
.article-artist a { text-decoration: none; }
.article-interpret { font-weight: 500; }
.article-title { font-size: 1.02rem; }
.article-meta { display: flex; flex-wrap: wrap; gap: .25rem .8rem; font-size: .85rem; color: var(--muted); margin-top: .2rem; align-items: center; }
.article-meta a { text-decoration: none; }
.article-condition { font-family: var(--mono); font-size: .8rem; }
.article-label { overflow-wrap: anywhere; }
.article-extra { font-style: italic; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .1rem .45rem; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.tag-new { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); margin-left: .4rem; vertical-align: 2px; }
.article-buy { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex: none; text-align: right; }
.article-price { font-weight: 750; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 2rem 0; }
@media (max-width: 599px) {
    .article { flex-direction: column; }
    .article-buy { flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
}

.pagination { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin-top: 2rem; align-items: center; }
.pagination a, .pagination span, .pagination button { min-width: 2.2rem; text-align: center; padding: .35rem .6rem; border-radius: 6px; text-decoration: none; font: inherit; }
.pagination a, .pagination button { border: 1px solid var(--line); background: var(--surface); color: inherit; cursor: pointer; }
.pagination a:hover, .pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination span[aria-current] { font-weight: 700; }
.pagination .gap { border: 0; }

/* Search */
.search-controls { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.search-input { font-size: 1.15rem; padding: .8rem 1.1rem; border-radius: 999px; width: 100%; }
.search-filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: .4rem .9rem; font-size: .9rem; }
.segmented input:checked + span { background: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.check { display: inline-flex; gap: .4rem; align-items: center; cursor: pointer; }
.check input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; }
.search-status { min-height: 1.6rem; color: var(--muted); font-size: .9rem; }
.search-hint { max-width: 60ch; }
.is-loading { opacity: .5; transition: opacity .15s; }

/* Cart & checkout */
.cart-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cart-table th, .cart-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.cart-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.cart-table tr:last-child td { border-bottom: 0; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty { width: 4.5rem; text-align: right; }
@media (max-width: 599px) {
    .cart-table thead { display: none; }
    .cart-table tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line); padding: .5rem 0; }
    .cart-table td { border: 0; padding: .25rem 1rem; }
    .cart-table td:first-child { grid-column: 1 / -1; }
    .cart-table td.num::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
}
.cart-actions { display: flex; justify-content: flex-end; margin: .75rem 0 1.5rem; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1.5rem; margin: 0 0 0 auto; max-width: 340px; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-weight: 750; font-size: 1.15rem; color: var(--ink); border-top: 1px solid var(--line); padding-top: .4rem; }
.totals-note { text-align: right; max-width: 520px; margin-left: auto; }
.cart-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.checkout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 2rem; align-items: start; }
@media (max-width: 899px) { .checkout-grid { grid-template-columns: 1fr; } }
.summary-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; position: sticky; top: 90px; box-shadow: var(--shadow); }
.summary-card h2 { margin-top: 0; font-size: 1.1rem; }
.summary-card .totals { max-width: none; margin: 1rem 0; }
.summary-card .totals-note { text-align: left; }
.order-lines { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.order-lines li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: step; font-size: .875rem; flex-wrap: wrap; }
.steps li { counter-increment: step; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.steps li::before { content: counter(step); width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-weight: 600; font-size: .8rem; }
.steps li + li::after { order: -1; content: ""; width: 1.5rem; height: 1px; background: var(--line); }
.steps li[aria-current] { color: var(--ink); font-weight: 600; }
.steps li[aria-current]::before { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps li.done::before { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.review-block { border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1rem; }
.review-block h2 { font-size: 1rem; display: flex; gap: .75rem; align-items: baseline; }
.review-block address { font-style: normal; }
.done { text-align: center; padding: 3rem 0; max-width: 560px; margin: 0 auto; }

/* Content pages */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2rem; }
.prose h3 { font-size: 1.05rem; margin-top: 1.5rem; }
.prose h4 { font-size: 1rem; margin-top: 1.25rem; }
.prose dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; }
.prose dt { font-family: var(--mono); font-weight: 700; }
.prose dd { margin: 0; }
.page { margin-inline: auto; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
@media (max-width: 799px) { .two-col { grid-template-columns: 1fr; } }

/* Admin */
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }
.big-number { font-size: 2.6rem; font-weight: 800; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 0 0 1rem; }
.stats div { background: var(--bg); border-radius: 8px; padding: .5rem .75rem; }
.stats dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats dd { margin: 0; font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.warnings summary { cursor: pointer; font-weight: 600; }
.warnings ul { font-size: .8rem; max-height: 320px; overflow: auto; padding-left: 1.2rem; }
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table th, .admin-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
@media (max-width: 699px) {
    .admin-table thead { display: none; }
    .admin-table tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
    .admin-table td { display: block; border: 0; padding: .25rem .9rem; }
}
.badge { display: inline-block; font-size: .7rem; padding: .05rem .45rem; border-radius: 999px; background: var(--bg); color: var(--muted); margin-left: .4rem; white-space: nowrap; }
.badge-custom { background: var(--accent-soft); color: var(--accent); }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.5rem; align-items: start; }
@media (max-width: 899px) { .editor-grid { grid-template-columns: 1fr; } }
.editor-grid .form input[type=text] { width: 100%; }
.placeholder-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.placeholder-list code { background: var(--bg); padding: .1rem .35rem; border-radius: 4px; }
.login-card { max-width: 380px; margin: 3rem auto; }
.login-card input { width: 100%; }

.listing-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem 1.5rem; flex-wrap: wrap; }
.listing-head h1 { margin-bottom: .75rem; }
.print-link { font-size: .875rem; color: var(--muted); }
