:root {
  --paper: #f6f2e8;
  --ink: #15130f;
  --muted: #6d665b;
  --line: #d8cfbe;
  --panel: #fffaf0;
  --panel-strong: #ebe0ce;
  --accent: #e44b2d;
  --accent-dark: #a72614;
  --olive: #54623a;
  --blue: #254a66;
  --shadow: 0 18px 48px rgba(31, 25, 16, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21, 19, 15, 0.04) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(180deg, rgba(21, 19, 15, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--paper);
  font-family: Georgia, "Times New Roman", "Noto Serif SC", serif;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: rgba(246, 242, 232, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--accent);
  font-family: "Courier New", monospace;
  font-weight: 700;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 19px;
}

.brand small,
.kicker,
.card-meta,
.select-label span,
.stats-strip span,
.dialog-copy > p {
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  gap: 8px;
}

.topnav a {
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.topnav a:hover {
  border-bottom-color: var(--accent);
}

.icon-button,
.primary-button,
.secondary-button,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button {
  width: 44px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.chip:hover {
  transform: translateY(-2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
}

.primary-button,
.secondary-button {
  padding: 0 16px;
  font-family: "Courier New", monospace;
  font-size: 14px;
  font-weight: 700;
}

.primary-button {
  color: var(--paper);
  background: var(--accent);
}

.secondary-button {
  color: var(--ink);
  background: var(--panel);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(340px, 1.05fr);
  gap: clamp(26px, 4vw, 70px);
  align-items: end;
  padding: clamp(36px, 7vw, 92px) clamp(18px, 4vw, 54px) 28px;
  min-height: calc(100vh - 76px);
}

.hero-copy {
  max-width: 780px;
  padding-bottom: clamp(10px, 4vw, 64px);
}

.kicker {
  margin: 0 0 18px;
  color: var(--accent-dark);
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 22px;
  font-size: clamp(42px, 6vw, 86px);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero-text {
  max-width: 620px;
  margin-bottom: 30px;
  color: #3a342c;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.72;
}

.hero-actions,
.dialog-actions,
.load-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-board {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  grid-auto-rows: minmax(160px, 22vw);
  gap: 12px;
  align-items: stretch;
}

.hero-tile {
  position: relative;
  overflow: hidden;
  min-height: 180px;
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

.hero-tile.tall {
  grid-row: span 2;
}

.hero-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.05);
}

.hero-tile span {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 7px 9px;
  color: var(--paper);
  background: rgba(21, 19, 15, 0.82);
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.control-band {
  display: grid;
  gap: 18px;
  margin: 0 clamp(18px, 4vw, 54px);
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 14px;
  background: #fffdfa;
  border: 1px solid var(--line);
}

.search-box svg {
  width: 19px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel-strong);
  font-family: "Courier New", monospace;
  font-size: 13px;
}

.chip.active {
  color: var(--paper);
  background: var(--blue);
}

.select-label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.select-label select {
  height: 40px;
  padding: 0 36px 0 10px;
  color: var(--ink);
  background: #fffdfa;
  border: 1px solid var(--ink);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 18px clamp(18px, 4vw, 54px) 0;
  background: var(--ink);
  border: 1px solid var(--ink);
}

.stats-strip div {
  padding: 18px;
  background: var(--paper);
}

.stats-strip strong,
.stats-strip span {
  display: block;
}

.stats-strip strong {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
}

.debug-line {
  margin: 10px clamp(18px, 4vw, 54px) 0;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 54px) 8px;
}

.prompt-card {
  display: grid;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.prompt-card:hover {
  transform: translateY(-4px);
  box-shadow: 8px 8px 0 var(--ink);
}

.card-image {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--panel-strong);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}

.prompt-card:hover .card-image img {
  transform: scale(1.04);
}

.tag,
.featured {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
}

.featured {
  position: absolute;
  top: 10px;
  left: 10px;
  color: var(--paper);
  background: var(--accent);
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.12;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-prompt {
  display: -webkit-box;
  min-height: 58px;
  margin: 0;
  overflow: hidden;
  color: #3a342c;
  font-size: 14px;
  line-height: 1.45;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 8px;
}

.load-row {
  justify-content: center;
  padding: 20px clamp(18px, 4vw, 54px) 62px;
}

.faq {
  display: grid;
  gap: 24px;
  padding: 62px clamp(18px, 4vw, 54px) 86px;
  background: #e8ddcb;
  border-top: 1px solid var(--ink);
}

.faq h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 58px);
}

.faq-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--ink);
  border: 1px solid var(--ink);
}

.faq article {
  padding: 22px;
  background: var(--paper);
}

.faq h3 {
  margin-bottom: 10px;
  font-size: 22px;
}

.faq p {
  margin: 0;
  color: #3a342c;
  line-height: 1.65;
}

.prompt-dialog {
  width: min(1080px, calc(100vw - 28px));
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--ink);
  box-shadow: 12px 12px 0 var(--ink);
}

.prompt-dialog::backdrop {
  background: rgba(21, 19, 15, 0.55);
  backdrop-filter: blur(4px);
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}

.dialog-body {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(320px, 1.05fr);
  min-height: 560px;
}

.dialog-media {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--panel-strong);
}

.dialog-media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--panel-strong);
  cursor: zoom-in;
}

.dialog-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  background: var(--panel);
  border-top: 1px solid var(--ink);
}

.dialog-thumbs button {
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 2px solid transparent;
  cursor: pointer;
}

.dialog-thumbs button.active {
  border-color: var(--accent);
}

.dialog-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-copy {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(22px, 4vw, 38px);
}

.dialog-copy h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 56px);
  line-height: 1;
}

.tag {
  width: fit-content;
  color: var(--paper);
  background: var(--olive);
}

.prompt-box {
  max-height: 230px;
  overflow: auto;
  padding: 14px;
  color: #27221c;
  background: #fffdfa;
  border: 1px solid var(--line);
}

.prompt-box pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
}

.image-dialog {
  width: min(96vw, 1500px);
  height: min(94vh, 1000px);
  padding: 0;
  background: #11100e;
  border: 1px solid var(--paper);
  box-shadow: 12px 12px 0 var(--ink);
}

.image-dialog::backdrop {
  background: rgba(10, 9, 8, 0.82);
  backdrop-filter: blur(5px);
}

.image-dialog > img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #11100e;
}

.dialog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-tags span {
  padding: 6px 8px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 12px 16px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--paper);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--ink);
  color: var(--muted);
  font-family: "Courier New", monospace;
}

@media (max-width: 1080px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topnav {
    display: none;
  }

  .hero,
  .dialog-body {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-copy {
    padding-bottom: 0;
  }

  .hero-board {
    grid-auto-rows: 220px;
  }

  .gallery-grid,
  .faq-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dialog-media > img {
    max-height: 48vh;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 68px;
  }

  .brand small {
    display: none;
  }

  .hero-board,
  .gallery-grid,
  .faq-list,
  .stats-strip {
    grid-template-columns: 1fr;
  }

  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .select-label {
    justify-content: space-between;
  }

  .select-label select {
    flex: 1;
  }

  .card-actions {
    grid-template-columns: 1fr 44px;
  }
}
