:root {
    color-scheme: light;
    --bg: #f7f6f3;
    --surface: #ffffff;
    --input-bg: #ffffff;
    --border: #e2ddd3;
    --text: #2a2621;
    --muted: #7a7266;
    --accent: #a8763e;
    --accent-dark: #8a5f2f;
    --danger: #b5443a;
    --success: #3f7a4f;
    --warning-text: #a06a1a;
    --success-bg: #e7f3e9;
    --success-border: #c7e2cb;
    --danger-bg: #fbe9e7;
    --danger-border: #f0c9c4;
    --warning-bg: #fdf1de;
    --neutral-bg: #f1f1ef;
    --hero-gradient-start: #f1e4cf;
    --secondary-hover-bg: #f1efe9;
    --hatch: rgba(42, 38, 33, 0.045);
    --radius: 8px;
    --festive-rose: #d1626b;
    --festive-teal: #3f8f8a;
    --festive-gold: #e0a63e;
}

/* System-Präferenz wird automatisch übernommen, solange kein Toggle-Wert gespeichert ist */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #1c1815;
        --surface: #262019;
        --input-bg: #211c17;
        --border: #3a332b;
        --text: #f0ece4;
        --muted: #a89e8e;
        --accent: #c99a5b;
        --accent-dark: #dab077;
        --danger: #d9756a;
        --success: #6fbf7f;
        --warning-text: #e2a75a;
        --success-bg: rgba(111, 191, 127, 0.14);
        --success-border: rgba(111, 191, 127, 0.35);
        --danger-bg: rgba(217, 117, 106, 0.16);
        --danger-border: rgba(217, 117, 106, 0.35);
        --warning-bg: rgba(226, 167, 90, 0.16);
        --neutral-bg: rgba(255, 255, 255, 0.06);
        --hero-gradient-start: rgba(201, 154, 91, 0.16);
        --secondary-hover-bg: rgba(255, 255, 255, 0.06);
        --hatch: rgba(255, 255, 255, 0.05);
        --festive-rose: #c47178;
        --festive-teal: #4d9d97;
        --festive-gold: #cf9a54;
    }
}

/* Manuelle Auswahl per Toggle überschreibt die System-Präferenz in beide Richtungen */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1c1815;
    --surface: #262019;
    --input-bg: #211c17;
    --border: #3a332b;
    --text: #f0ece4;
    --muted: #a89e8e;
    --accent: #c99a5b;
    --accent-dark: #dab077;
    --danger: #d9756a;
    --success: #6fbf7f;
    --warning-text: #e2a75a;
    --success-bg: rgba(111, 191, 127, 0.14);
    --success-border: rgba(111, 191, 127, 0.35);
    --danger-bg: rgba(217, 117, 106, 0.16);
    --danger-border: rgba(217, 117, 106, 0.35);
    --warning-bg: rgba(226, 167, 90, 0.16);
    --neutral-bg: rgba(255, 255, 255, 0.06);
    --hero-gradient-start: rgba(201, 154, 91, 0.16);
    --secondary-hover-bg: rgba(255, 255, 255, 0.06);
    --hatch: rgba(255, 255, 255, 0.05);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background-color .15s ease, color .15s ease;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: background-color .15s ease, border-color .15s ease;
}
.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.brand-icon { width: 80px; height: 57px; flex-shrink: 0; }
.site-header nav { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.site-header nav a { color: var(--text); text-decoration: none; font-size: 0.87rem; }
.site-header nav > * { margin-left: 9px; padding-left: 9px; border-left: 1px solid var(--border); }
.site-header nav > *:first-child { margin-left: 0; padding-left: 0; border-left: none; }
.site-header nav > .btn-nav-primary { border-left: none; padding-left: 14px; }
.site-header nav a:hover { color: var(--accent-dark); }

/* Bei umgebrochenen Nav-Zeilen (schmale Bildschirme) sehen die Trennstriche
   vor dem jeweils ersten Element einer neuen Zeile abgerissen aus – daher
   auf kleinen Bildschirmen ganz auf sie verzichten, Abstand per gap statt
   margin/border. */
@media (max-width: 640px) {
    .site-header nav { gap: 8px 14px; }
    .site-header nav > * { margin-left: 0; padding-left: 0; border-left: none; }
}
.user-name { color: var(--muted); font-size: 0.9rem; }
.btn-nav-primary {
    background: var(--accent);
    color: #fff !important;
    padding: 7px 14px;
    border-radius: 6px;
}
.btn-nav-primary:hover { background: var(--accent-dark); color: #fff !important; }

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.theme-toggle:hover { background: var(--secondary-hover-bg); }

main.wrap { padding-top: 28px; padding-bottom: 60px; min-height: 60vh; }

h1 { font-size: 1.6rem; margin: 0 0 6px; }
h2 { font-size: 1.2rem; }
p.subtitle { color: var(--muted); margin-top: 0; }

.hero {
    position: relative;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    background:
        repeating-linear-gradient(45deg, var(--hatch) 0, var(--hatch) 1px, transparent 1px, transparent 10px),
        linear-gradient(135deg, var(--hero-gradient-start) 0%, var(--bg) 70%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    margin-bottom: 24px;
    overflow: hidden;
}
.hero-content { position: relative; z-index: 1; flex: 1 1 320px; }
.hero h1 { font-size: 1.8rem; }
.hero p.subtitle { margin-bottom: 0; max-width: calc(60ch + 50px); }

.hero-confetti { position: absolute; inset: 0; z-index: 0; opacity: 0.9; pointer-events: none; }
.hero-confetti-svg { width: 100%; height: 100%; display: block; }

.hero-balloon { position: absolute; width: 40px; z-index: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15)); pointer-events: none; }
.hero-balloon-1 { top: -14px; right: 132px; }
.hero-balloon-2 { top: 18px; right: 14px; width: 32px; }
@media (max-width: 640px) {
    .hero-balloon { display: none; }
    /* Fächer + Lupe rutschen bei umgebrochenem Layout in eine eigene Zeile
       unter den Text; ohne das stünden sie am linken statt zentriert. */
    .hero { justify-content: center; }
}

.hero-note-3 .banknote-serial { display: none; }
.hero-magnifier { position: absolute; width: 140px; left: 54px; top: 18px; z-index: 5; filter: drop-shadow(0 5px 8px rgba(0,0,0,0.3)); }
.hero-magnifier-usd { left: -1px; top: -5px; }
.hero-note-3 .banknote-serial-topleft { display: none; }

.hero-banknotes { position: relative; z-index: 1; width: 190px; height: 128px; flex: 0 0 auto; }
.hero-note { position: absolute; width: 170px; top: 0; left: 10px; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.22)); }
.hero-note .banknote { width: 100%; margin: 0; }
.hero-note-1 { transform: rotate(-11deg); z-index: 1; }
.hero-note-2 { transform: rotate(5deg) translate(16px, 10px); z-index: 2; }
.hero-note-3 { transform: rotate(-2deg) translate(2px, 24px); z-index: 3; }

.empty-state {
    position: relative;
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state::before {
    content: "";
    display: block;
    width: 54px;
    height: 14px;
    margin: 0 auto 14px;
    background:
        radial-gradient(circle, var(--festive-rose) 3px, transparent 4px) 0 2px/18px 18px no-repeat,
        radial-gradient(circle, var(--festive-gold) 3px, transparent 4px) 18px 0/18px 18px no-repeat,
        radial-gradient(circle, var(--festive-teal) 3px, transparent 4px) 36px 2px/18px 18px no-repeat;
    opacity: 0.7;
}

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; }
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    transition: background-color .15s ease, border-color .15s ease;
}

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 24px; }
.admin-stat { display: block; text-decoration: none; color: inherit; text-align: center; }
.admin-stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent-dark); }
.admin-stat-label { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.search-bar {
    background:
        repeating-linear-gradient(45deg, var(--hatch) 0, var(--hatch) 1px, transparent 1px, transparent 10px),
        var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}
.search-bar-heading { display: flex; align-items: center; gap: 8px; color: var(--accent-dark); font-weight: 700; font-size: 0.9rem; margin-bottom: 12px; }
.filter-icon { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.search-bar form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.search-bar .field { display: flex; flex-direction: column; gap: 4px; }
.search-bar label { font-size: 0.82rem; color: var(--muted); }

.banknote { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,0.18); }
.banknote-sm { max-width: 84px; }
.banknote-md { max-width: 100%; margin-bottom: 12px; }
.banknote-lg { max-width: 320px; margin-bottom: 16px; }
.banknote-photo { object-fit: cover; aspect-ratio: 16 / 9; background: var(--neutral-bg); }

.currency-hint { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.8rem; color: var(--muted); }
.currency-hint .status-badge { margin-left: 0; }

.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}
.listing-tile {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    color: var(--text);
    display: block;
    transition: background-color .15s ease, border-color .15s ease;
}
.listing-tile:hover { border-color: var(--accent); }
.listing-tile-featured { border-color: var(--warning-text); }
.listing-tile-featured-badge { position: absolute; top: 10px; left: 10px; z-index: 1; margin-left: 0; }
.listing-tile::after {
    content: "";
    position: absolute;
    top: -16px;
    right: -16px;
    width: 36px;
    height: 36px;
    background: var(--festive-rose);
    transform: rotate(45deg);
    opacity: 0;
    transition: opacity .15s ease;
}
.listing-tile:hover::after { opacity: 0.16; }
.listing-tile .serial { font-family: "SFMono-Regular", Consolas, monospace; font-size: 1.05rem; letter-spacing: 1px; }
.listing-tile .serial-date { font-family: inherit; letter-spacing: normal; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.listing-tile .denom { color: var(--muted); font-size: 0.85rem; }
.listing-tile .listed-on { color: var(--muted); font-size: 0.72rem; margin-top: 4px; opacity: 0.85; }

.results-toolbar { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle-btn { background: var(--surface); border: none; padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; border-radius: 0; }
.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--border); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }

.listing-grid.list-view { display: flex; flex-direction: column; gap: 10px; }
.listing-grid.list-view .listing-tile { display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.listing-grid.list-view .listing-tile .banknote { width: 70px; flex-shrink: 0; margin: 0; }
.listing-grid.list-view .listing-tile .serial { min-width: 90px; }
.listing-grid.list-view .listing-tile .denom { margin-left: auto; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; margin-left: 6px; }
.status-active { background: var(--success-bg); color: var(--success); }
.status-reserved { background: var(--warning-bg); color: var(--warning-text); }
.status-sold { background: var(--neutral-bg); color: var(--muted); }
.status-removed { background: var(--neutral-bg); color: var(--muted); }
.status-completed { background: var(--success-bg); color: var(--success); }
.status-featured { background: var(--warning-bg); color: var(--warning-text); }
.status-shipped { background: rgba(63, 143, 138, 0.16); color: var(--festive-teal); }
.status-buyer_paid { background: var(--warning-bg); color: var(--warning-text); }
.status-pending { background: var(--warning-bg); color: var(--warning-text); }
.status-cancelled { background: var(--danger-bg); color: var(--danger); }

.auth-banknote { max-width: 180px; margin: 0 0 20px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.18)); }
.auth-banknote .banknote { margin: 0; }
.gift-banknote { position: relative; display: block; }
.gift-banknote .banknote { display: block; width: 100%; }
.gift-banknote .ribbon-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }

form.stacked { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
form.stacked label { font-size: 0.95rem; font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
.field-hint { color: var(--muted); font-size: 0.78rem; line-height: 1.4; margin-top: 4px; }
.link-button { background: none; border: none; padding: 0; margin: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.link-button:hover { color: var(--accent-dark); }

.crop-modal { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--input-bg); }
.crop-image-wrap { height: 280px; }
.crop-image-wrap img { display: block; max-width: 100%; }
.crop-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.affiliate-list { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }
.affiliate-list a { color: var(--accent); text-decoration: none; }
.affiliate-list a:hover { text-decoration: underline; }

.confirm-bar { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.confirm-text { font-size: 0.82rem; color: var(--text); }

.message-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.message { background: var(--neutral-bg); border-radius: var(--radius); padding: 10px 12px; max-width: 80%; }
.message-own { background: var(--success-bg); align-self: flex-end; }
.message-meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.message-body { white-space: pre-wrap; }

.review-form { min-width: 180px; }
.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; font-size: 1.3rem; }
.star-rating input { position: absolute; opacity: 0; pointer-events: none; }
.star-rating label { cursor: pointer; color: var(--neutral-bg); }
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: #d9a441; }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-dark); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--secondary-hover-bg); }
.btn-danger { background: var(--danger); }

.seller-stats { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--muted); }
.seller-stats .status-badge { font-size: 0.82rem; padding: 4px 10px; }
a.status-badge { text-decoration: none; cursor: pointer; transition: box-shadow 0.15s; }
a.status-badge:hover { box-shadow: 0 0 0 1px var(--border); }
a.status-badge.status-badge-selected { box-shadow: 0 0 0 2px var(--accent); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th, table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; }

.site-footer { border-top: 1px solid var(--border); margin-top: 40px; color: var(--muted); font-size: 0.85rem; background: var(--surface); }
.site-footer .hint { color: var(--warning-text); }

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: 24px;
    padding: 32px 20px 24px;
}
.footer-col h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text); margin: 0 0 10px; }
.footer-col .brand { font-size: 1.05rem; margin-bottom: 8px; }
.footer-blurb { margin: 0; max-width: 32ch; }
.footer-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-dark); text-decoration: underline; }
.footer-toggles { display: flex; align-items: center; gap: 8px; }
.lang-toggle { text-decoration: none; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.footer-bottom p { margin: 0; }

.footer-hints { padding: 0 20px 20px; }
.footer-hints p { margin: 4px 0; }

.design-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.design-option h2 { font-size: 1.05rem; }

.detail-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
@media (max-width: 700px) { .detail-grid { grid-template-columns: 1fr; } }
.big-serial { font-family: "SFMono-Regular", Consolas, monospace; font-size: 2rem; letter-spacing: 3px; margin: 6px 0; }
