:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1f1f1f;
  --text-muted: #6b6b6b;
  --border: #e6e3de;
  --accent: #3b5bdb;
  --accent-soft: #eef1fd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --surface: #1d1e23;
    --text: #ececec;
    --text-muted: #9a9a9f;
    --border: #2b2c33;
    --accent: #8ab4ff;
    --accent-soft: #232a3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.page-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 2.5rem 1.5rem 1.75rem;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.selector-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.selector-wrap label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

#experiment-select {
  appearance: none;
  min-width: 320px;
  max-width: min(80vw, 560px);
  padding: 0.7rem 2.4rem 0.7rem 1rem;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%236b6b6b"><path d="M4 6l4 4 4-4"/></svg>') no-repeat right 0.9rem center / 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

#experiment-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 3rem;
}

.placeholder {
  text-align: center;
  color: var(--text-muted);
  margin-top: 3rem;
}

.original-prompt {
  text-align: center;
  color: var(--text-muted);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.25;
  font-style: italic;
  margin: 0 auto 2.25rem;
  max-width: 900px;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- LLM × image-model grid ---------- */

.grid-scroll {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.matrix {
  display: grid;
  /* Columns share the width, capped so a few columns don't turn into giant images. */
  grid-template-columns: minmax(120px, 190px) repeat(var(--cols), minmax(150px, 420px));
  justify-content: center;
  gap: 0.9rem;
  align-items: start;
}

.corner {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.2rem;
  height: 100%;
  padding-bottom: 0.4rem;
}

.axis {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* "LLM →" / "Image model ↓" titles in the grid's top-left corner */
.corner .axis {
  font-size: 1.05rem;
  font-weight: 700;
}

.grid-head {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* The dropdown: a plain header that unfolds into the prompt, no box or chrome. */
.head-static,
.prompt-toggle summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  border-radius: 8px;
  padding: 0.25rem 0.1rem;
}

.head-static {
  cursor: default;
}

.prompt-toggle summary::-webkit-details-marker {
  display: none;
}

.prompt-toggle summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.llm-name {
  font-size: 1.2rem;
  font-weight: 650;
  word-break: break-word;
}

.provider {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
}

.toggle-hint {
  flex-basis: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.prompt-toggle summary:hover .toggle-hint,
.prompt-toggle[open] .toggle-hint {
  color: var(--accent);
}

.chevron {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.prompt-toggle[open] .chevron {
  transform: rotate(180deg);
}

.llm-prompt {
  margin: 0.35rem 0 0.25rem;
  padding-left: 0.65rem;
  border-left: 2px solid var(--accent-soft);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
  animation: prompt-in 0.2s ease;
}

@keyframes prompt-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

.row-label {
  align-self: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  word-break: break-word;
  text-align: right;
  padding-right: 0.25rem;
}

.grid-cell {
  margin: 0;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.grid-cell:not(.empty) {
  cursor: zoom-in;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.grid-cell:not(.empty):hover,
.grid-cell:not(.empty):focus-visible {
  transform: scale(1.03);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 14px 32px rgba(0, 0, 0, 0.12);
}

.grid-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.grid-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--accent-soft);
}

.grid-cell.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-style: dashed;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
}

/* Column on/off chips */
.col-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 0 1.75rem;
}

.col-toggles .axis {
  margin-right: 0.35rem;
}

.col-chip,
.col-show-all {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.col-chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-muted) 50%, transparent);
}

.col-chip.on {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.col-chip:hover {
  border-color: var(--accent);
}

.col-show-all {
  border: none;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.col-chip:focus-visible,
.col-show-all:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Floating enlarged preview shown on hover */
.hover-preview {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08), 0 24px 60px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.hover-preview.visible {
  opacity: 1;
  transform: none;
}

.hover-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--accent-soft);
}

.hover-preview p {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Full-screen view on click */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lightbox.visible {
  opacity: 1;
}

.lightbox figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  max-height: 100%;
}

.lightbox img {
  max-width: min(92vw, 1200px);
  max-height: calc(100vh - 7rem);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.lightbox figcaption {
  color: #e6e6e6;
  font-size: 0.9rem;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  background: rgba(255, 255, 255, 0.24);
  outline: none;
}

body.no-scroll {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .matrix {
    grid-template-columns: 80px repeat(var(--cols), minmax(140px, 1fr));
    justify-content: start;
    gap: 0.6rem;
  }
  .row-label { font-size: 0.85rem; }
}

.page-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}
