:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #121315;
  --strong: #181a1d;
  --ink: #f7f8f8;
  --muted: #aeb4b8;
  --line: rgba(255, 255, 255, 0.14);
  --cyan: #23bdd6;
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.04), transparent 28rem), var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body:has(dialog[open]) { overflow: hidden; }
a { color: inherit; }
button, input, select { font: inherit; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.25rem;
  padding: .75rem clamp(1rem, 4vw, 4rem);
  background: rgba(7, 7, 7, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand-mark { display: inline-flex; align-items: center; gap: .8rem; min-width: 0; text-decoration: none; }
.brand-logo { display: block; width: auto; height: clamp(2.45rem, 4vw, 2.85rem); max-width: min(58vw, 20rem); }
.brand-section {
  padding-left: .8rem;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 740;
  letter-spacing: .08em;
  text-transform: uppercase;
}
nav, .footer-links { display: flex; align-items: center; gap: clamp(.8rem, 3vw, 2rem); color: var(--muted); font-size: .92rem; }
nav a, .site-footer a { text-decoration: none; }
nav a:hover, .site-footer a:hover, .text-link:hover { color: var(--ink); }

h1, h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 1rem; font-size: clamp(2.1rem, 5vw, 4.6rem); font-weight: 780; line-height: 1; }
h3 { margin-bottom: .5rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-weight: 720;
  cursor: pointer;
}
.button.secondary { background: rgba(255,255,255,.06); }

.catalog-section {
  padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 5vw, 5rem);
  border-bottom: 1px solid var(--line);
}
.catalog-count {
  align-self: center;
  justify-self: end;
  margin: 0;
  padding: 0 .5rem;
  color: var(--muted);
  white-space: nowrap;
}
.catalog-controls {
  position: sticky;
  top: 4.25rem;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) auto auto;
  gap: .75rem;
  margin: 0 0 1rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18,19,21,.92);
  backdrop-filter: blur(18px);
}
.search-field input, .select-field select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #24272b;
  color: var(--ink);
}
.search-field input { padding: 0 .9rem; }
.search-field input::placeholder { color: #858d92; }
.select-field { display: grid; grid-template-columns: auto minmax(7rem,1fr); align-items: center; gap: .6rem; padding-left: .75rem; color: var(--muted); font-size: .84rem; }
.select-field select { padding: 0 2rem 0 .7rem; }
.scale-switch { display: flex; gap: .25rem; padding: .25rem; border: 1px solid var(--line); border-radius: 6px; background: #202225; }
.scale-switch button {
  min-height: 2.2rem;
  padding: 0 .75rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.scale-switch button.is-active { background: var(--ink); color: #080808; }
.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 1rem; }
.title-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: border-color 150ms ease, transform 150ms ease;
}
.title-card:hover { border-color: rgba(255,255,255,.32); transform: translateY(-2px); }
.title-card button { display: grid; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.card-image { aspect-ratio: 1.84 / 1; overflow: hidden; border-bottom: 1px solid var(--line); background: #0b1017; }
.card-image img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 240ms ease; }
.title-card:hover .card-image img { transform: scale(1.015); }
.card-copy { padding: 1rem; }
.card-copy h3 { font-size: 1.03rem; line-height: 1.3; }
.card-meta { margin: 0; color: var(--muted); font-size: .84rem; }
.empty-state { padding: 5rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); text-align: center; background: var(--panel); }
.empty-state p { color: var(--muted); }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 6rem; padding: 1.5rem clamp(1rem,5vw,5rem); color: var(--muted); font-size: .92rem; }

.title-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(7,7,7,.98);
  color: var(--ink);
}
.title-dialog::backdrop { background: rgba(0,0,0,.86); }
.dialog-shell { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; min-height: 100%; }
.dialog-header, .dialog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem clamp(1rem,3vw,2.5rem); border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: clamp(1.35rem,3vw,2.4rem); }
.dialog-meta, .scale-note { margin: 0 0 .3rem; color: var(--muted); font-size: .84rem; }
.icon-button, .viewer-nav { border: 1px solid var(--line); background: rgba(18,19,21,.86); color: var(--ink); cursor: pointer; }
.icon-button { width: 2.75rem; height: 2.75rem; border-radius: 50%; font-size: 1.7rem; }
.dialog-actions { display: flex; align-items: center; gap: 1rem; }
.text-link { color: var(--muted); font-size: .88rem; }
.graph-stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: auto; padding: clamp(.75rem,2vw,1.5rem) clamp(3rem,6vw,6rem); background: #050505; }
.graph-stage img { display: block; width: auto; max-width: 100%; max-height: calc(100vh - 12rem); border: 1px solid var(--line); background: #0b1017; box-shadow: 0 1.5rem 5rem rgba(0,0,0,.5); }
.viewer-nav { position: fixed; top: 50%; z-index: 2; width: 2.8rem; height: 4.5rem; border-radius: var(--radius); font-size: 2rem; }
.viewer-nav-previous { left: .75rem; }
.viewer-nav-next { right: .75rem; }
.scale-note { padding: .75rem clamp(1rem,3vw,2.5rem); text-align: center; }

@media (max-width: 1100px) {
  .catalog-controls { grid-template-columns: 1fr 1fr; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 780px) {
  .site-header { align-items: flex-start; flex-direction: column; gap: .6rem; }
  nav { width: 100%; justify-content: space-between; }
  .brand-logo { max-width: 65vw; }
  .catalog-count { justify-self: start; }
  .catalog-controls { position: static; grid-template-columns: 1fr; }
  .select-field { grid-template-columns: 4rem 1fr; padding-left: 0; }
  .catalog-grid { grid-template-columns: 1fr; }
  .dialog-toolbar { align-items: stretch; flex-direction: column; }
  .dialog-actions { justify-content: space-between; }
  .graph-stage { padding-inline: .5rem; }
  .viewer-nav { top: auto; bottom: 1rem; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
