:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --text: #1f2328;
  --muted: #6b6f76;
  --border: #e4dfd6;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-contrast: #ffffff;
  --ok: #15803d;
  --ok-bg: #e9f8ef;
  --warn: #92400e;
  --warn-bg: #fdf3e1;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141518;
    --surface: #1e2024;
    --surface-2: #25282d;
    --text: #e9e7e4;
    --muted: #9b9ea4;
    --border: #33363c;
    --accent: #fb923c;
    --accent-hover: #fdba74;
    --accent-contrast: #1b1206;
    --ok: #4ade80;
    --ok-bg: #12301e;
    --warn: #fbbf24;
    --warn-bg: #352812;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.1rem; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem max(16px, calc((100vw - 960px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; align-items: center; gap: 1rem; }
.topbar nav a { color: var(--text); text-decoration: none; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0 1rem;
}

.list-card { display: block; color: var(--text); text-decoration: none; margin: 0; transition: transform .12s, border-color .12s; }
.list-card:hover { color: var(--text); transform: translateY(-2px); border-color: var(--accent); }
.list-card p { margin: 0; }
.grid > p { grid-column: 1 / -1; margin: 0; }

.back { display: inline-block; margin-bottom: 1rem; text-decoration: none; }
.list-head { margin-bottom: 1.25rem; }
.list-head p { margin: 0; }

.occasion {
  display: inline-block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}

.hero { text-align: center; margin: 1rem 0 2rem; }
.hero .desc { max-width: 600px; margin: .75rem auto 0; white-space: pre-line; }
.countdown { color: var(--accent); font-weight: 600; margin: 0; }
.howto { text-align: center; margin: 0 0 1.5rem; }

/* ---------- Formulare ---------- */

label { display: block; font-weight: 600; font-size: .9rem; }
label input, label select, label textarea { margin-top: .3rem; font-weight: 400; }

input, select, textarea, button, .button {
  font: inherit;
  font-size: 1rem;
  border-radius: 10px;
}

input, select, textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: var(--surface);
}
textarea { resize: vertical; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .55rem 1rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}
button:hover, .button:hover { border-color: var(--accent); color: var(--text); }
button:disabled { opacity: .6; cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.small, .button.small { padding: .3rem .7rem; font-size: .875rem; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); }
button.link:hover { color: var(--accent); }

form { margin: 0; }
.stack { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: .5rem; }
.inline-form input { flex: 1; min-width: 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0; }
legend { font-weight: 700; padding: 0 .4rem; }

.offer-row { display: grid; gap: .5rem; padding: .75rem 0; border-bottom: 1px dashed var(--border); }
.offer-row:last-child { border-bottom: 0; }
.offer-url, .offer-details { display: flex; gap: .5rem; }
.offer-url input { flex: 1; min-width: 0; }
.offer-details { align-items: flex-end; }
.offer-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; font-size: .72rem; color: var(--muted); }
.offer-field.shop { flex: 2; }
.offer-field input { width: 100%; min-width: 0; margin-top: 0; }
.offer-status:empty { display: none; }
#add-offer { margin-top: .5rem; }

.image-field { display: flex; gap: 1rem; align-items: flex-end; }
.image-field label { flex: 1; }
#image-preview { width: 84px; height: 84px; object-fit: contain; background: #fff; border-radius: 10px; border: 1px solid var(--border); }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- Meldungen ---------- */

.flash { padding: .75rem 1rem; border-radius: 10px; background: var(--ok-bg); color: var(--ok); margin-bottom: 1rem; }
.flash.warn, .warn { background: var(--warn-bg); color: var(--warn); }
.offer-status.warn { background: none; }
.ok { color: var(--ok); }

/* ---------- Werkzeugleiste ---------- */

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin: 1rem 0; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tabs { display: flex; gap: .25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .25rem; }
.tabs a { padding: .35rem .9rem; border-radius: 999px; text-decoration: none; color: var(--muted); }
.tabs a.active { background: var(--accent); color: var(--accent-contrast); }

/* ---------- Wünsche ---------- */

.items { display: grid; gap: 1rem; }
.item { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 1.25rem; margin: 0; scroll-margin-top: 1rem; }
.item-body { min-width: 0; }
.item h3, .item .desc, .list-card h2 { overflow-wrap: anywhere; }
.item:target { border-color: var(--accent); }
.item h3 { margin: .25rem 0 .4rem; }
.item .desc { margin: 0 0 .75rem; color: var(--muted); white-space: pre-line; }
.item.is-reserved { opacity: .65; }
.item.is-reserved .thumb { filter: grayscale(1); }

.thumb {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.noimg::after { content: "🎁"; font-size: 3rem; opacity: .5; }

.item-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.prio, .tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.prio-1 { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.tag.reserved { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.tag.best { background: var(--ok-bg); border-color: transparent; color: var(--ok); }

.offers { list-style: none; padding: 0; margin: 0 0 .9rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.offers li { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-top: 1px solid var(--border); }
.offers li:first-child { border-top: 0; }
.offers a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offers .price { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.offers li { flex-wrap: wrap; }
.price-date { font-size: .72rem; font-weight: 400; color: var(--muted); }
.price-ship { font-size: .72rem; font-weight: 400; color: var(--muted); }
.tag.alt { background: var(--surface); }
.alternative { margin: .25rem 0 .75rem; }
.alt-or { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin: .5rem 0; }
.alt-or::before, .alt-or::after { content: ""; flex: 1; border-top: 1px dashed var(--border); }
.alt-body { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: .75rem; align-items: start; }
.alt-body .thumb { width: 72px; height: 72px; }
.alt-body .thumb.noimg::after { font-size: 1.5rem; }
.alt-body h4 { margin: 0 0 .4rem; font-size: 1rem; }
.add-alt { margin: 0 0 .75rem; }
.add-alt summary { cursor: pointer; color: var(--muted); }
.add-alt .inline-form { margin: .5rem 0 .25rem; }
.offers a.ship-rule, a.ship-rule { font-size: .72rem; font-weight: 400; color: var(--muted); text-decoration: none; white-space: normal; }
a.ship-rule:hover { text-decoration: underline; }
a.ship-rule.add { font-style: italic; }
.rules .rule-summary { margin-left: auto; font-size: .875rem; }
.tier-row { display: flex; gap: .5rem; margin-bottom: .5rem; }
.bundles summary { cursor: pointer; font-weight: 600; }
.bundle-table { width: 100%; border-collapse: collapse; margin-top: .75rem; font-size: .875rem; }
.bundle-table th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: .35rem .5rem; border-bottom: 1px solid var(--border); }
.bundle-table td { padding: .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.bundle-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price-ship.unknown { font-style: italic; }
.offer-note { flex-basis: 100%; font-size: .75rem; color: var(--muted); margin-top: -.15rem; }
.price-date.stale, .offer-note.stale { color: var(--warn); }
.offer-confirm { flex-basis: 100%; }
.offer-confirm button { font-size: .75rem; padding: .15rem .55rem; }

.reserve { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.reserve .inline-form { flex: 1 1 100%; max-width: 480px; }
.reserve .inline-form select { width: auto; }
.tag.qty { background: var(--warn-bg); border-color: transparent; color: var(--warn); }

.empty { text-align: center; padding: 2rem 0; }

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog p { margin: 0 0 1rem; }
.dialog .actions { justify-content: flex-end; }
.dialog button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }

details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 1rem; }

@media (max-width: 600px) {
  .offer-details { flex-wrap: wrap; }
  .offer-field { flex-basis: calc(50% - .25rem); }
  .offer-field.shop { flex-basis: 100%; }
  .offer-details button.confirm-offer { flex: 1; }
  .bundle-table thead { display: none; }
  .bundle-table tr { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .bundle-table td { padding: 0; border: 0; }
  .bundle-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .item { grid-template-columns: minmax(0, 1fr); }
  .thumb { width: 100%; height: 200px; }
  .inline-form { flex-direction: column; }
  .reserve .inline-form { max-width: none; width: 100%; }
}
