:root {
  --cream: #f6efe6;
  --sand: #ece0cf;
  --taupe: #b8a394;
  --taupe-dk: #7a6a5c;
  --ink: #4a3f36;
  --blush: #e2b8b0;
  --accent: #c48a7d;
  --card-bg: #fbf6ee;
  --shadow: 0 8px 28px rgba(122, 106, 92, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Fira Code', monospace;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% -10%, #f3e3d3 0%, transparent 60%),
    radial-gradient(1000px 500px at 90% 0%, # efe6da 0%, transparent 55%),
    linear-gradient(160deg, #f7f0e7 0%, #efe4d5 55%, #e9dcc9 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.app-shell { max-width: 1180px; margin: 0 auto; padding: 0 16px 60px; }

/* ---- Header ---- */
.site-header {
  padding: 40px 4px 20px;
  border-bottom: 1px solid rgba(122,106,92,0.18);
}
.header-inner {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: flex-end; justify-content: space-between;
}
.site-title {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1;
  margin: 0;
  color: var(--taupe-dk);
  letter-spacing: -0.02em;
}
.site-sub {
  margin: 8px 0 0; font-size: 0.82rem; color: var(--taupe);
  letter-spacing: 0.02em;
}
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sfw-badge {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.14em;
  background: var(--blush); color: #6a3f38;
  padding: 6px 12px; border-radius: 999px; font-weight: 500;
}
.fav-toggle {
  border: 1px solid var(--taupe); background: transparent; color: var(--taupe-dk);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font-family: inherit;
  font-size: 0.8rem; transition: all .2s ease;
}
.fav-toggle:hover { background: var(--sand); }
.fav-toggle-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.clarify {
  margin: 18px 0 0; font-family: 'Fraunces', serif; font-style: italic;
  font-weight: 300; font-size: 1.05rem; color: var(--taupe-dk);
}

/* ---- Filter bar ---- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 22px 4px;
}
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 999px; cursor: pointer;
  font-family: inherit; font-size: 0.8rem; transition: all .18s ease;
}
.pill-idle { background: transparent; border: 1px solid var(--taupe); color: var(--taupe-dk); }
.pill-idle:hover { background: rgba(184,163,148,0.14); }
.pill-active { background: var(--taupe-dk); border: 1px solid var(--taupe-dk); color: var(--cream); box-shadow: var(--shadow); }
.pill-swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }

/* ---- Generate panel ---- */
.gen-wrap {
  background: var(--card-bg);
  border: 1px solid rgba(122,106,92,0.16);
  border-radius: 18px;
  overflow: hidden;
  margin: 0 4px 26px;
  box-shadow: var(--shadow);
}
.gen-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: transparent; border: none; cursor: pointer;
  font-family: 'Fraunces', serif; font-size: 1.1rem; color: var(--taupe-dk); font-weight: 500;
}
.chev { font-size: 0.7rem; color: var(--taupe); }
.gen-body { padding: 4px 20px 20px; }
.gen-input {
  width: 100%; resize: vertical; border-radius: 12px;
  border: 1px solid rgba(122,106,92,0.24); background: #fffdf9;
  padding: 12px; font-family: inherit; font-size: 0.85rem; color: var(--ink);
}
.gen-input:focus { outline: 2px solid var(--blush); border-color: transparent; }
.gen-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.gen-select {
  border: 1px solid rgba(122,106,92,0.24); background: #fffdf9; color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 0.8rem;
}
.gen-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 22px; cursor: pointer; font-family: inherit; font-weight: 500;
  transition: transform .12s ease, background .2s;
}
.gen-btn:hover:not(:disabled) { background: #b0776a; transform: translateY(-1px); }
.gen-btn:disabled { opacity: 0.6; cursor: wait; }
.surprise-btn {
  background: transparent; border: 1px dashed var(--taupe); color: var(--taupe-dk);
  border-radius: 10px; padding: 10px 18px; cursor: pointer; font-family: inherit;
}
.surprise-btn:hover:not(:disabled) { background: var(--sand); }
.gen-note { margin: 12px 0 0; font-size: 0.7rem; color: var(--taupe); }

/* ---- Grid ---- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, 1fr);
  padding: 0 4px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; border-radius: 16px; overflow: hidden;
  background: var(--card-bg); box-shadow: var(--shadow); margin: 0;
  animation: rise .6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.card-imgwrap { position: relative; aspect-ratio: 1/1; cursor: pointer; overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease, opacity .5s ease; }
.card-img-hidden { opacity: 0; }
.card-img-in { opacity: 1; }
.card:hover .card-img { transform: scale(1.06); }
.shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, #ede2d2 30%, #f7efe3 50%, #ede2d2 70%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.tone-badge {
  font-family: 'Fira Code', monospace; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.1em; background: rgba(246,239,230,0.9); color: var(--taupe-dk);
  padding: 4px 9px; border-radius: 999px; position: absolute; bottom: 10px; left: 10px;
  backdrop-filter: blur(2px);
}
.fav-btn {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  border-radius: 50%; border: none; cursor: pointer; font-size: 1.1rem; line-height: 1;
  background: rgba(246,239,230,0.85); backdrop-filter: blur(2px); transition: transform .15s ease;
}
.fav-btn:hover { transform: scale(1.12); }
.fav-off { color: var(--taupe-dk); }
.fav-on { color: var(--accent); }

/* ---- Empty ---- */
.empty { text-align: center; padding: 70px 20px; color: var(--taupe-dk); }
.empty-icon { font-size: 3rem; }
.empty-title { font-family: 'Fraunces', serif; font-size: 1.4rem; margin: 10px 0 4px; }
.empty-sub { font-size: 0.8rem; color: var(--taupe); margin: 0; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(74,63,54,0.78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lb-stage {
  max-width: 820px; width: 100%; background: var(--card-bg);
  border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.4);
}
.lb-img { width: 100%; max-height: 68vh; object-fit: contain; display: block; background: #e9ddcd; }
.lb-meta { padding: 16px 20px; position: relative; }
.lb-meta .tone-badge { position: static; display: inline-block; }
.lb-fav {
  position: static; width: auto; height: auto; border-radius: 999px;
  padding: 6px 16px; font-size: 0.78rem; margin-left: 10px; font-family: 'Fira Code', monospace;
}
.lb-prompt { margin: 12px 0 0; font-size: 0.8rem; color: var(--taupe); line-height: 1.5; }
.lb-close {
  position: absolute; top: 18px; right: 22px; z-index: 2;
  background: rgba(246,239,230,0.9); border: none; width: 42px; height: 42px;
  border-radius: 50%; font-size: 1.6rem; cursor: pointer; color: var(--taupe-dk); line-height: 1;
}
.lb-nav {
  background: rgba(246,239,230,0.8); border: none; width: 50px; height: 50px;
  border-radius: 50%; font-size: 2rem; cursor: pointer; color: var(--taupe-dk);
  flex-shrink: 0; margin: 0 8px; line-height: 1; transition: background .2s;
}
.lb-nav:hover { background: var(--cream); }
@media (max-width: 640px) {
  .lb-nav { position: absolute; top: 45%; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
}

/* ---- Footer ---- */
.site-footer {
  margin-top: 50px; padding-top: 24px; text-align: center;
  border-top: 1px solid rgba(122,106,92,0.18);
  font-size: 0.78rem; color: var(--taupe);
}
.remix-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.remix-link:hover { text-decoration: underline; }