:root {
  --bg: #0e0d0b;
  --bg-elev: #161410;
  --card: #1c1915;
  --card-hover: #221e19;
  --ink: #f4eee4;
  --muted: #9c9286;
  --dim: #6f675e;
  --line: #2c2822;
  --gold: #e2b56b;
  --gold-soft: rgba(226, 181, 107, 0.16);
  --copper: #c25b2c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-ui: "Instrument Sans", "Noto Sans SC", system-ui, sans-serif;
  --font-display: "Fraunces", "Noto Serif SC", Georgia, serif;
  --font-prompt: "Source Serif 4", "Noto Serif SC", "Songti SC", serif;
  --pad: clamp(16px, 3vw, 40px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #2a2118 0%, var(--bg) 52%);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.6;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--gold);
  color: #1a140c;
  padding: 8px 12px;
  z-index: 20;
}
.skip:focus { top: 12px; }

.masthead {
  padding: 48px var(--pad) 28px;
  border-bottom: 1px solid var(--line);
}
.masthead__inner { max-width: 1120px; margin: 0 auto; }
.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gold);
}
h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: clamp(56px, 11vw, 120px);
  line-height: 0.9;
  margin: 0 0 18px;
  letter-spacing: -0.03em;
}
.lede {
  max-width: 42rem;
  margin: 0 0 16px;
  color: #d7cfc3;
  font-size: clamp(15px, 1.8vw, 18px);
}
.meta { margin: 0; color: var(--muted); font-size: 13px; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 8;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: 14px 0 10px;
}
.toolbar__inner,
.filters,
.gallery,
.site-foot,
.status {
  width: min(1120px, calc(100% - 2 * var(--pad)));
  margin-left: auto;
  margin-right: auto;
}
.toolbar__inner {
  display: flex;
  gap: 12px;
  align-items: center;
}
.search { flex: 1; }
.search input,
.sort select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  outline: none;
}
.search input:focus,
.sort select:focus,
.icon-btn:focus-visible,
.chip:focus-visible,
.card:focus-visible,
.btn:focus-visible {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.sort select { width: auto; padding-right: 28px; }

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: thin;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.chip[aria-pressed="true"] {
  background: var(--gold);
  color: #1a140c;
  border-color: var(--gold);
  font-weight: 600;
}
.chip .n { color: inherit; opacity: 0.7; margin-left: 4px; }

.gallery-wrap { padding: 28px var(--pad) 80px; }
.gallery-wrap .status,
.gallery-wrap .gallery { width: min(1120px, 100%); }
.status { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  text-align: left;
  padding: 0;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  background: var(--card-hover);
  border-color: #433c33;
}
.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(180deg, rgba(14,13,11,0.05), rgba(14,13,11,0.55)),
    repeating-linear-gradient(135deg, #1a1713 0 8px, #141210 8px 16px);
  overflow: hidden;
}
.frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame.is-fallback img { display: none; }
.frame__fallback {
  display: none;
  position: absolute;
  inset: 0;
  padding: 18px 16px;
  font-family: var(--font-prompt);
  font-size: 13px;
  line-height: 1.45;
  color: #d8cbb8;
}
.frame.is-fallback .frame__fallback { display: block; }
.frame__tag {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1;
  background: rgba(14, 13, 11, 0.78);
  border: 1px solid rgba(226, 181, 107, 0.35);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
}
.card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card__prompt {
  font-family: var(--font-prompt);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.card__actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--line);
  background: #13110e;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 11px;
  cursor: pointer;
  font-size: 12px;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn--gold { background: var(--gold); color: #1a140c; border-color: var(--gold); font-weight: 600; }
.btn--gold:hover { color: #1a140c; filter: brightness(1.05); }

.empty {
  grid-column: 1 / -1;
  padding: 64px 16px;
  text-align: center;
  color: var(--muted);
}

.site-foot {
  padding: 0 var(--pad) 48px;
  color: var(--dim);
  font-size: 12px;
}
.site-foot p { margin: 0 0 8px; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 4, 0.62);
  z-index: 20;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(640px, 100%);
  height: 100%;
  background: #141210;
  border-left: 1px solid var(--line);
  z-index: 21;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.drawer__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.drawer__body { overflow: auto; padding: 24px 24px 48px; }
.drawer .frame { border-radius: 14px; margin-bottom: 20px; }
.drawer h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 8px;
}
.drawer .byline { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.prompt-full {
  font-family: var(--font-prompt);
  font-size: 17px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 0 0 22px;
}
.drawer .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
}
.caption { color: var(--muted); font-size: 13px; margin: 16px 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--gold);
  color: #1a140c;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  z-index: 30;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .masthead { padding-top: 32px; }
  h1 { font-size: 64px; }
  .toolbar__inner { flex-direction: column; align-items: stretch; }
  .sort { width: 100%; }
  .sort select { flex: 1; width: 100%; }
  .gallery { grid-template-columns: 1fr; gap: 14px; }
  .drawer { width: 100%; }
  .card__prompt { -webkit-line-clamp: 6; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
  .card:hover { transform: none; }
}
