:root {
  --bg: #f8f3ec;
  --bg-deep: #f1e8dc;
  --card: #fffdf9;
  --ink: #2a2420;
  --muted: #7b6f65;
  --line: #e8ddcf;
  --accent: #c8553d;
  --accent-ink: #ffffff;
  --accent-soft: #f7e2d9;
  --done: #5f8a6b;
  --done-soft: #e3eee5;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 8px 24px -12px rgba(60, 40, 20, 0.18);
  --radius: 18px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a1714;
    --bg-deep: #14110f;
    --card: #24201c;
    --ink: #f3ece4;
    --muted: #a99c90;
    --line: #3a332c;
    --accent: #ec7a5c;
    --accent-ink: #1a1714;
    --accent-soft: #3d2a23;
    --done: #8fbf9b;
    --done-soft: #26342a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -200px, var(--bg-deep), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a { color: inherit; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 80px;
}

/* ---------- Kopfbereich ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.brand svg { width: 18px; height: 18px; color: var(--accent); }

.hero { margin: 28px 0 32px; }
.hero h1 {
  font: 600 clamp(32px, 7vw, 48px)/1.08 var(--serif);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-variation-settings: 'SOFT' 100;
}
.hero p { margin: 0; color: var(--muted); font-size: 17px; max-width: 56ch; white-space: pre-line; }

.progress {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}
.progress-bar {
  flex: 1;
  max-width: 220px;
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  background: var(--done);
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* ---------- Karten ---------- */

.items { display: grid; gap: 14px; }

.item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity 0.25s ease, transform 0.25s ease;
  position: relative;
}

.thumb {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.thumb.empty { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.thumb.empty svg { width: 34px; height: 34px; }

.item-body { min-width: 0; display: flex; flex-direction: column; }
.item h3 {
  font: 600 19px/1.25 var(--serif);
  margin: 2px 0 4px;
  overflow-wrap: anywhere;
}
.item .desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.item .actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.item.bought { opacity: 0.62; }
.item.bought h3 { text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: var(--muted); }

.stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--done-soft);
  color: var(--done);
  font-size: 13px;
  font-weight: 600;
}
.stamp svg { width: 14px; height: 14px; }

/* ---------- Buttons & Formulare ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 500 14px/1 var(--sans);
  padding: 10px 15px;
  border-radius: 99px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); padding-inline: 10px; }
.btn.ghost:hover { color: var(--ink); background: var(--bg-deep); }
.btn.danger:hover { color: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn.small { padding: 7px 11px; font-size: 13px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }

input, textarea, select {
  width: 100%;
  font: 16px/1.4 var(--sans);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.row { display: flex; gap: 8px; }
.row > input { flex: 1; min-width: 0; }

.buy-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.buy-form input { flex: 1 1 160px; padding: 8px 12px; font-size: 15px; }

/* ---------- Panels (Admin) ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 22px;
}
.panel h2 { font: 600 20px/1.2 var(--serif); margin: 0 0 14px; }

.section-title {
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 34px 0 14px;
}

.list-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.list-card:hover { border-color: var(--muted); transform: translateY(-1px); }
.list-card .meta { flex: 1; min-width: 0; }
.list-card h3 { font: 600 19px/1.25 var(--serif); margin: 0 0 3px; overflow-wrap: anywhere; }
.list-card small { color: var(--muted); font-size: 14px; }
.list-card .chev { color: var(--muted); width: 18px; height: 18px; flex: none; }

.share {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  margin: 18px 0 0;
  flex-wrap: wrap;
}
.share code {
  flex: 1 1 200px;
  font: 14px/1.3 ui-monospace, 'Cascadia Code', Consolas, monospace;
  overflow-wrap: anywhere;
}

.preview-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: start;
  margin: 4px 0 16px;
}
.preview-card .thumb { width: 72px; height: 72px; }

select { appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }

label.item { cursor: pointer; grid-template-columns: 96px 1fr auto; }
.item .pick { width: 22px; height: 22px; accent-color: var(--accent); margin: 4px 0 0; cursor: pointer; }
.item.skipped { opacity: 0.45; }
.bookmarklet { cursor: grab; }

/* ---------- Kopfzeile mit Zahnrad-Menü ---------- */

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 38px; }

.menu { position: relative; }
.menu-btn {
  appearance: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.3s;
}
.menu-btn svg { width: 19px; height: 19px; }
.menu-btn:hover, .menu-btn[aria-expanded='true'] { background: var(--card); border-color: var(--line); color: var(--ink); }
.menu-btn[aria-expanded='true'] svg { transform: rotate(45deg); transition: transform 0.3s; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow), 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  z-index: 5;
  animation: pop 0.14s ease-out;
}
.menu-pop[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font: 500 14px/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-deep); outline: none; }

.list-card .list-desc {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--done-soft);
  color: var(--done);
  font-size: 12px;
  font-weight: 600;
  flex: none;
}
.badge svg { width: 13px; height: 13px; }

/* ---------- Schalter „Öffentlich“ ---------- */

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
}
.switch-row input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.switch-row strong { display: block; font-size: 15px; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; }
.switch {
  flex: none;
  width: 42px; height: 24px;
  border-radius: 99px;
  background: var(--line);
  position: relative;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}
.switch-row input:checked + .switch { background: var(--done); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { box-shadow: 0 0 0 3px var(--accent-soft); }

.toolbar { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

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

.center-box { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.center-box .panel { text-align: left; margin-top: 24px; }

.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.error { color: var(--accent); font-size: 14px; margin: 8px 0 0; min-height: 1em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 99px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { margin-top: 48px; text-align: center; color: var(--muted); font-size: 13px; }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .wrap { padding-top: 28px; }
  .item { grid-template-columns: 72px 1fr; gap: 14px; padding: 14px; }
  label.item { grid-template-columns: 72px 1fr auto; }
  .thumb { width: 72px; height: 72px; }
  .item h3 { font-size: 17px; }
}
