:root {
  --bg: #f7f2ea;
  --card: #ffffff;
  --ink: #2a1f1a;
  --muted: #7a6c63;
  --line: #e8ddd0;
  --brand: #7a1f2b;
  --brand-2: #a32e3d;
  --hdr1: #5e1520; --hdr2: #8a2433; --hdr3: #6a1b26;
  --gold: #c8962e;
  --green: #2f6b4f;
  --shadow: 0 1px 2px rgba(60, 30, 20, .06), 0 8px 24px rgba(60, 30, 20, .07);
  --radius: 18px;
  --on-brand: #fff;
  color-scheme: light;
}
/* Farben (Ansicht → Farbe) */
:root[data-accent="gruen"]    { --brand: #1f5a3f; --brand-2: #2b7553; --hdr1: #123826; --hdr2: #1f5a3f; --hdr3: #17442f; --bg: #f2f5f0; --line: #dbe3d6; }
:root[data-accent="blau"]     { --brand: #1f3a6b; --brand-2: #2c4f8f; --hdr1: #13254a; --hdr2: #1f3a6b; --hdr3: #182e57; --bg: #f1f4f9; --line: #d9e0ec; }
:root[data-accent="lila"]     { --brand: #5b2a86; --brand-2: #7438a8; --hdr1: #3b1a59; --hdr2: #5b2a86; --hdr3: #47206b; --bg: #f6f2f9; --line: #e3d9ec; }
:root[data-accent="schlicht"] { --brand: #2f2f2f; --brand-2: #4a4a4a; --hdr1: #1e1e1e; --hdr2: #3a3a3a; --hdr3: #2a2a2a; --bg: #f4f4f4; --line: #e0e0e0; --ink: #1f1f1f; --muted: #6b6b6b; }

/* Dunkel: automatisch (System) oder per Schalter */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120f; --card: #221b17; --ink: #f3ebe3; --muted: #b3a59a; --line: #3a2f29;
    --brand: #c9485a; --brand-2: #de6072; --gold: #e0b24f; --green: #5fb88b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --on-brand: #120d0b;
    color-scheme: dark;
  }
  :root:not([data-theme="light"])[data-accent="gruen"]    { --brand: #4fae80; --brand-2: #63c493; --bg: #101512; --card: #18201b; --line: #2a362e; }
  :root:not([data-theme="light"])[data-accent="blau"]     { --brand: #6b93d6; --brand-2: #85a8e3; --bg: #0f131a; --card: #171d27; --line: #29323f; }
  :root:not([data-theme="light"])[data-accent="lila"]     { --brand: #a77bd6; --brand-2: #bb94e3; --bg: #141018; --card: #1e1824; --line: #342a3d; }
  :root:not([data-theme="light"])[data-accent="schlicht"] { --brand: #d0d0d0; --brand-2: #e6e6e6; --bg: #121212; --card: #1c1c1c; --line: #2f2f2f; --ink: #eeeeee; --muted: #a3a3a3; }
}
:root[data-theme="dark"] {
  --bg: #17120f; --card: #221b17; --ink: #f3ebe3; --muted: #b3a59a; --line: #3a2f29;
  --brand: #c9485a; --brand-2: #de6072; --gold: #e0b24f; --green: #5fb88b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --on-brand: #120d0b;
  color-scheme: dark;
}
:root[data-theme="dark"][data-accent="gruen"]    { --brand: #4fae80; --brand-2: #63c493; --bg: #101512; --card: #18201b; --line: #2a362e; }
:root[data-theme="dark"][data-accent="blau"]     { --brand: #6b93d6; --brand-2: #85a8e3; --bg: #0f131a; --card: #171d27; --line: #29323f; }
:root[data-theme="dark"][data-accent="lila"]     { --brand: #a77bd6; --brand-2: #bb94e3; --bg: #141018; --card: #1e1824; --line: #342a3d; }
:root[data-theme="dark"][data-accent="schlicht"] { --brand: #d0d0d0; --brand-2: #e6e6e6; --bg: #121212; --card: #1c1c1c; --line: #2f2f2f; --ink: #eeeeee; --muted: #a3a3a3; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.previewbar { background: var(--gold); color: #2a1f1a; text-align: center; padding: 8px 16px; font-size: 14px; }
.previewbar a { color: inherit; font-weight: 600; }

.top {
  background: linear-gradient(135deg, var(--hdr1), var(--hdr2) 60%, var(--hdr3));
  color: #fff;
  padding: calc(22px + env(safe-area-inset-top)) 0 26px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.top::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.18) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  pointer-events: none;
}
.top .wrap { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; position: relative; z-index: 1; }
.title { display: flex; gap: 14px; align-items: center; }
.snow { font-size: 40px; line-height: 1; }
h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.sub { margin: 4px 0 0; opacity: .88; font-size: 14.5px; max-width: 560px; }
.top-actions { display: flex; gap: 8px; }

.btn {
  appearance: none; border: 1px solid transparent; border-radius: 999px;
  padding: 9px 16px; font: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; white-space: nowrap;
}
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.danger { background: transparent; color: #c0392b; border-color: rgba(192,57,43,.35); }
.btn.light.primary { background: #fff; color: var(--hdr2); }
.btn.light.primary:hover { background: #f3eee9; }
.btn.light.ghost { color: #fff; border-color: rgba(255,255,255,.45); }
.btn:disabled { opacity: .6; cursor: wait; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.sortbar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex: 1; min-width: 0; }
.viewbtn { flex: none; min-height: 34px; padding: 6px 12px; font-size: 13.5px; background: var(--card); }
.catnote { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); background: var(--card);
  border: 1px dashed var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 14px; }
.catnote .btn { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.center { text-align: center; padding: 30px 0; }
.group + .group { margin-top: 26px; }
.grp { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; font-size: 18px; }
.grp small { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.meta { font-size: 13px; color: var(--muted); }
.taken-note { font-size: 13px; color: var(--green); font-weight: 600; }

/* Kompakt */
.grid.compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.grid.compact .pic img { padding: 8px; }
.grid.compact .body { padding: 10px 11px 12px; gap: 4px; }
.grid.compact .body h2 { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.grid.compact .price { font-size: 16px; }
.grid.compact .actions .btn { flex: 1 1 100%; justify-content: center; font-size: 13px; min-height: 32px; padding: 5px 10px; }
.grid.compact .badge-fav { font-size: 12px; padding: 3px 7px; }
.grid.compact .badge-taken { font-size: 11px; padding: 3px 8px; left: 6px; right: 6px; text-align: center; }

/* Liste */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; grid-template-columns: 88px 1fr auto; gap: 14px; align-items: center; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 10px; box-shadow: var(--shadow); }
.rpic { width: 88px; height: 88px; border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.rpic img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.rpic .noimg { font-size: 36px; }
.rmain { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rmain h2 { margin: 0; font-size: 15.5px; line-height: 1.3; overflow-wrap: anywhere; }
.rside { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.rside .actions { padding: 0; justify-content: flex-end; flex-wrap: wrap; max-width: 260px; }
.rside .actions .btn { flex: none; min-height: 34px; font-size: 13px; padding: 6px 11px; }
.row.taken .rpic img, .row.taken h2 { opacity: .55; filter: grayscale(.7); }
.row.mine { border: 2px solid var(--green); }
.row.fav { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }

/* Tabelle */
.tblwrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .c-img { width: 56px; padding-right: 0; }
.tbl .c-img img { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 8px; display: block; }
.tbl .c-title b { font-weight: 600; overflow-wrap: anywhere; }
.tbl .c-title .note { font-size: 13px; color: var(--muted); }
.tbl .c-cat, .tbl .c-shop { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.tbl .c-shop a { color: var(--brand); text-decoration: none; }
.tbl .c-price { font-weight: 700; color: var(--brand); white-space: nowrap; text-align: right; }
.tbl th.c-price { text-align: right; }
.tbl .c-act .actions { padding: 0; flex-wrap: nowrap; justify-content: flex-end; }
.tbl .c-act .btn { min-height: 32px; font-size: 13px; padding: 5px 10px; flex: none !important; }
.tbl tr.taken td { opacity: .6; }
.tbl tr.mine td { background: color-mix(in srgb, var(--green) 10%, transparent); }
.tbl .mine-note { font-size: 13px; flex: none; white-space: nowrap; align-self: center; }

/* Ansicht-Dialog */
.seg-field { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.seg-field legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.swatches i { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); display: inline-block; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
dialog.sheet.small form { gap: 14px; }
dialog.sheet { overflow-y: auto; }
.sortbar::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line);
  transition: transform .15s ease;
}
.card.fav { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.pic { position: relative; aspect-ratio: 1 / 1; background: #fff; display: flex; align-items: center; justify-content: center; }
.pic img { width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.noimg { font-size: 64px; opacity: .55; }
:root[data-theme="dark"] .pic { background: #f4efe9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pic { background: #f4efe9; } }
.badge-fav, .badge-taken {
  position: absolute; left: 10px; top: 10px; font-size: 12.5px; font-weight: 600;
  background: rgba(255,255,255,.94); color: #7a1f2b; border-radius: 999px; padding: 4px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.badge-taken { left: auto; right: 10px; top: auto; bottom: 10px; background: var(--green); color: #fff; }
.card.taken .pic img, .card.taken .noimg { filter: grayscale(.85); opacity: .55; }
.card.taken h2, .card.taken .price { opacity: .6; }
.card.mine { border: 2px solid var(--green); }
.card.done { opacity: .75; }
.body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.body h2 { font-size: 16.5px; margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.price { font-size: 20px; font-weight: 700; color: var(--brand); }
.oldp { color: var(--muted); font-weight: 500; font-size: .78em; }
.pchg { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 7px; vertical-align: middle; white-space: nowrap; }
.pchg.down { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.pchg.up { background: rgba(192, 57, 43, .12); color: #c0392b; }
.tbl .c-price .pchg { display: block; width: fit-content; margin: 3px 0 0 auto; }
.note { margin: 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 8px; }
.actions .btn { font-size: 13.5px; min-height: 36px; padding: 7px 12px; }
.actions .btn.primary { flex: 1 1 100%; justify-content: center; }
.mine-note { color: var(--green); font-weight: 600; font-size: 14px; flex: 1 1 100%; }

.empty { text-align: center; padding: 50px 16px; color: var(--muted); }
.empty .big { font-size: 64px; }
.empty p { max-width: 420px; margin: 8px auto 18px; }

.donebox { margin-top: 28px; }
.donebox summary { cursor: pointer; color: var(--muted); font-weight: 600; margin-bottom: 14px; }

.foot { color: var(--muted); font-size: 13.5px; text-align: center; padding: 32px 16px 40px; }

/* Dialoge */
dialog.sheet {
  border: 0; padding: 0; border-radius: 22px; width: min(520px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  max-height: calc(100dvh - 24px);
}
dialog.sheet::backdrop { background: rgba(20, 10, 8, .5); backdrop-filter: blur(2px); }
dialog.sheet form { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
dialog.sheet header { display: flex; justify-content: space-between; align-items: center; }
dialog.sheet h3 { margin: 0; font-size: 19px; }
.x { border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
dialog label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
dialog label small { font-weight: 400; color: var(--muted); }
dialog input[type=text], dialog input[type=url], dialog textarea {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%;
}
dialog input:focus, dialog textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
.euro { position: relative; }
.euro span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.imgrow { display: flex; gap: 12px; align-items: center; }
.imgprev {
  width: 96px; height: 96px; border-radius: 14px; background: #fff; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; font-size: 38px;
}
.imgprev img { width: 100%; height: 100%; object-fit: contain; }
.imgbtns { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.filebtn { flex-direction: row !important; font-weight: 600 !important; }
.picks-wrap { display: flex; flex-direction: column; gap: 6px; }
.picks-head { font-weight: 600; font-size: 14px; }
.picks-head small { font-weight: 400; color: var(--muted); }
.picks { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.pick {
  flex: none; width: 76px; height: 76px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
  padding: 3px; cursor: pointer; scroll-snap-align: start; position: relative;
}
.pick img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; display: block; }
.pick.on { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); }
.pick .src { position: absolute; left: 3px; bottom: 3px; font-size: 9.5px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 1px 4px; }
.withbtn { display: flex; gap: 8px; }
.withbtn input { flex: 1; min-width: 0; }
.withbtn .btn { flex: none; }
.hint { font-size: 13.5px; color: var(--muted); background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.err { color: #fff; background: #b03a2e; border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.muted { color: var(--muted); margin: 0; font-size: 14.5px; }
dialog footer { display: flex; gap: 8px; align-items: center; padding-top: 4px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14.5px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50; max-width: calc(100vw - 32px);
}

@media (max-width: 560px) {
  .toolbar { gap: 8px; }
  .grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .grid.compact .body { padding: 7px 8px 9px; }
  .grid.compact .body h2 { font-size: 12.5px; }
  .grid.compact .price { font-size: 14px; }
  .grid.compact .actions { gap: 5px; padding-top: 4px; }
  .grid.compact .actions .btn { font-size: 12px; min-height: 30px; padding: 4px 6px; }
  .row { grid-template-columns: 64px 1fr; gap: 10px; padding: 8px; }
  .rpic { width: 64px; height: 64px; }
  .rside { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .rside .actions { max-width: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }
  .tbl thead { display: none; }
  .tbl tr { display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td { padding: 0; border: 0; }
  .tbl .c-img { grid-row: span 2; width: auto; }
  .tbl .c-title { grid-column: 2 / 3; }
  .tbl .c-price { grid-column: 3; grid-row: 1; }
  .tbl .c-cat, .tbl .c-shop { grid-column: 2 / 4; font-size: 12.5px; }
  .tbl .c-cat.none { display: none; }
  .tbl .c-act { grid-column: 1 / -1; margin-top: 6px; }
  .tbl .c-act .actions { justify-content: flex-start; flex-wrap: wrap; }
  h1 { font-size: 22px; }
  .snow { font-size: 32px; }
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1; justify-content: center; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .body { padding: 10px 11px 12px; }
  .body h2 { font-size: 14.5px; }
  .price { font-size: 17px; }
  .actions .btn { flex: 1 1 100%; justify-content: center; white-space: normal; text-align: center; }
  .badge-fav { font-size: 11px; padding: 3px 8px; }
  .badge-taken { font-size: 11px; padding: 3px 8px; left: 8px; right: 8px; text-align: center; }
  dialog.sheet { margin: auto auto 0; border-radius: 22px 22px 0 0; width: 100vw; max-width: 100vw; padding-bottom: env(safe-area-inset-bottom); }
}
