:root {
  --bg: #faf8f5;
  --card: #ffffff;
  --ink: #2b2622;
  --muted: #8a8178;
  --line: #ece6dd;
  --accent: #c0623f;
  --accent-dark: #a04e30;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(60, 45, 30, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.4px; }
.tagline { margin: 0; font-size: 12.5px; color: var(--muted); }

.tabs { display: flex; gap: 6px; background: #f0ebe3; padding: 4px; border-radius: 999px; }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.lang { display: flex; gap: 4px; }
.lang-btn {
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  padding: 5px 7px; border-radius: 9px; line-height: 0;
  opacity: .45; transition: opacity .15s, transform .15s;
}
.lang-btn:hover { transform: translateY(-1px); opacity: .8; }
.lang-btn.active { opacity: 1; border-color: var(--accent); }

/* ---------- Generator ---------- */
.generator {
  max-width: 1180px;
  margin: 22px auto 0;
  padding: 22px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.generator h2 { margin: 0 0 16px; font-size: 18px; }
.ctrl { margin-bottom: 16px; }
.ctrl > label {
  display: block; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); margin-bottom: 8px;
}
.ctrl-row { display: flex; gap: 28px; flex-wrap: wrap; }
.ctrl-row .ctrl { flex: 1; min-width: 200px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fbf9f6; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  transition: all .12s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fbf9f6; cursor: pointer;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  transition: all .12s;
}
.swatch:hover { border-color: var(--accent); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(192,98,63,.2); }
.swatch .dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.12);
}

.generate-btn {
  margin-top: 6px; width: 100%;
  border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  padding: 14px; border-radius: 12px;
  font-size: 15.5px; font-weight: 700;
  transition: background .15s;
}
.generate-btn:hover { background: var(--accent-dark); }
.generate-btn:disabled { opacity: .6; cursor: progress; }

/* ---------- Content / Masonry ---------- */
.content { max-width: 1180px; margin: 0 auto; padding: 26px 24px 40px; }
.section-title { font-size: 15px; color: var(--muted); margin: 0 0 16px; font-weight: 700; }

.masonry { column-count: 4; column-gap: 16px; }
@media (max-width: 1080px) { .masonry { column-count: 3; } }
@media (max-width: 760px)  { .masonry { column-count: 2; } .ctrl-row { gap: 16px; } }
@media (max-width: 430px)  { .masonry { column-count: 1; } }

.card {
  position: relative;
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #efe9e0;
  box-shadow: var(--shadow);
}
.card img {
  display: block; width: 100%; height: auto;
  opacity: 0; transition: opacity .4s;
}
.card.loaded img { opacity: 1; }

/* Lade-Skelett */
.card .skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #ece5db 30%, #f6f1ea 50%, #ece5db 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
.card.loaded .skeleton, .card.error .skeleton { display: none; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Fehlerzustand */
.card .err {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 16px; text-align: center;
  font-size: 13px; color: var(--muted); background: #f3ede4;
}
.card.error .err { display: flex; }
.card .err button {
  border: 1px solid var(--accent); color: var(--accent); background: #fff;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600;
}

/* Hover-Aktionen */
.card .actions {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0));
  opacity: 0; transition: opacity .15s;
}
.card:hover .actions, .card:focus-within .actions { opacity: 1; }
.card.loaded .actions { display: flex; }
.card:not(.loaded) .actions { display: none; }
.act {
  border: 0; cursor: pointer;
  background: rgba(255,255,255,.92); color: var(--ink);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 11px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.act:hover { background: #fff; }
.act.primary { background: var(--accent); color: #fff; }
.act.is-saved { background: #2e7d4f; color: #fff; }

/* ---------- Empty / Footer ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 15px; }
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px; border-top: 1px solid var(--line); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 30px; background: rgba(20, 15, 10, .85);
}
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: 0 12px 50px rgba(0,0,0,.5); }
.lightbox-close {
  position: absolute; top: 18px; right: 24px;
  border: 0; background: transparent; color: #fff;
  font-size: 40px; line-height: 1; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 60;
  box-shadow: var(--shadow);
}

[hidden] { display: none !important; }
