:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-strong: #eef3f1;
  --ink: #1f2523;
  --muted: #69706d;
  --line: #dce4e1;
  --teal: #126e68;
  --coral: #bd4f4a;
  --gold: #a86f11;
  --focus: #234fbc;
  --shadow: 0 18px 55px rgba(43, 38, 28, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(18, 110, 104, 0.08), transparent 24rem),
    linear-gradient(315deg, rgba(189, 79, 74, 0.08), transparent 22rem),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.has-lightbox {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.workspace {
  min-height: calc(100vh - 32px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #132927;
  color: #f8f3e8;
  font-weight: 780;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.ghost-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) minmax(150px, 210px);
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 32px rgba(31, 37, 35, 0.06);
}

.search-field,
.select-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.search-control,
.select-control {
  position: relative;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 44px;
}

.select-control::after {
  position: absolute;
  top: 50%;
  right: 16px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  content: "";
  pointer-events: none;
  transform: translateY(-65%) rotate(45deg);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(35, 79, 188, 0.24);
  outline-offset: 2px;
}

.grid {
  column-count: 4;
  column-gap: 14px;
  padding: 16px 0 24px;
}

.prompt-card {
  display: block;
  break-inside: avoid;
  overflow: hidden;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.gallery-image-link {
  display: block;
  width: 100%;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.gallery-image {
  width: 100%;
  display: block;
  height: auto;
}

.load-status {
  display: flex;
  width: min(320px, 100%);
  min-height: 40px;
  align-items: center;
  justify-content: center;
  margin: 8px auto 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 650;
}

.load-status[hidden] {
  display: none;
}

.load-status[data-state="error"] {
  border: 1px solid rgba(189, 79, 74, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(189, 79, 74, 0.42);
  color: var(--coral);
  cursor: pointer;
}

.load-status[data-state="loading"]::before {
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(105, 112, 109, 0.22);
  border-top-color: var(--teal);
  border-radius: 999px;
  content: "";
  animation: load-spin 0.8s linear infinite;
}

@keyframes load-spin {
  to {
    transform: rotate(360deg);
  }
}

.load-sentinel {
  width: 100%;
  height: 1px;
}

pre {
  margin: 10px 0 0;
  border-radius: 8px;
  background: #1f2523;
  color: #f4efe4;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: auto;
  padding: 18px;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(18, 24, 23, 0.76);
  cursor: zoom-out;
}

.lightbox-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1280px, 100%);
  margin: auto 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #101817;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
}

.lightbox-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 12px;
  color: #f8f3e8;
}

.lightbox-close {
  min-height: 36px;
  flex: 0 0 auto;
  border: 1px solid rgba(248, 243, 232, 0.2);
  border-radius: 8px;
  background: rgba(248, 243, 232, 0.08);
  color: #f8f3e8;
  padding: 0 12px;
  cursor: pointer;
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
}

.detail-media,
.detail-info {
  min-height: 0;
}

.detail-media {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.lightbox-image-wrap {
  display: grid;
  min-height: 0;
  place-items: center;
  padding: 12px;
}

.lightbox-image-wrap img {
  max-width: 100%;
  max-height: calc(min(88vh, 900px) - 84px);
  display: block;
  object-fit: contain;
  border-radius: 4px;
}

.detail-output-strip,
.detail-input-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.detail-output-strip {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px 12px;
}

.detail-input-strip {
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.detail-info {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
  color: #f8f3e8;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-section h2 {
  color: rgba(248, 243, 232, 0.72);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.detail-section pre {
  margin: 0;
  background: rgba(248, 243, 232, 0.08);
  color: #f8f3e8;
}

.copy-button {
  min-height: 32px;
  border: 1px solid rgba(248, 243, 232, 0.22);
  border-radius: 8px;
  background: rgba(248, 243, 232, 0.1);
  color: #f8f3e8;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
}

.detail-section-light .copy-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.detail-image-button {
  position: relative;
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(248, 243, 232, 0.18);
  border-radius: 8px;
  background: rgba(248, 243, 232, 0.08);
  padding: 0;
  cursor: pointer;
}

.detail-image-button[data-active="true"] {
  border-color: #f8f3e8;
}

.detail-image-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.detail-image-button span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  border-radius: 6px;
  background: rgba(16, 24, 23, 0.82);
  color: white;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 760;
}

.source-lines {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.source-lines a {
  color: #f0bf64;
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
}

.empty-state {
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.detail-page {
  max-width: 1280px;
}

.detail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.example-detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.example-media {
  display: grid;
  gap: 14px;
}

.example-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 132px));
  gap: 12px;
}

.example-inputs .example-figure img {
  aspect-ratio: 1;
  object-fit: cover;
}

.example-figure {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.example-figure img {
  width: 100%;
  display: block;
  height: auto;
}

.example-figure figcaption {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 720;
}

.example-copy {
  display: grid;
  gap: 14px;
}

.detail-section-light {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 14px;
}

.detail-section-light h2 {
  color: var(--muted);
}

.detail-section-light pre {
  background: #1f2523;
  color: #f4efe4;
}

.detail-section-light .source-lines {
  color: var(--muted);
}

.detail-section-light .source-lines p {
  font-size: 13px;
}

.detail-section-light .source-lines span {
  color: var(--ink);
  font-weight: 720;
}

@media (max-width: 1180px) {
  .grid {
    column-count: 3;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .grid {
    column-count: 2;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-media {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .example-detail-layout {
    grid-template-columns: 1fr;
  }

  .example-copy {
    position: static;
  }
}

@media (max-width: 540px) {
  .shell {
    padding: 10px;
  }

  .grid {
    column-count: 1;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .ghost-button {
    flex: 1;
  }

  .lightbox {
    padding: 10px;
  }

  .lightbox-header {
    align-items: center;
  }

  .detail-info {
    padding: 12px;
  }

  .detail-nav {
    align-items: flex-start;
    flex-direction: column;
  }
}
