:root {
  color-scheme: dark;
  --bg: #080a0d;
  --surface: #0d1014;
  --surface-2: #12161b;
  --line: #292e36;
  --line-soft: #1d2229;
  --text: #f2f4f7;
  --muted: #929ba8;
  --faint: #626b77;
  --accent: #3f83f8;
  --accent-soft: rgba(63, 131, 248, .12);
  --page: min(1510px, calc(100vw - 88px));
  --sans: Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; background: var(--bg); }
body { min-width: 320px; margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; }
button, select { color: inherit; }
.sr-only { 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 {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(44px, calc((100vw - 1510px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 13, .94);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; font: 750 13px/1 var(--mono); letter-spacing: .1em; }
.brand svg { width: 24px; height: 24px; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.site-header nav { align-self: stretch; display: flex; align-items: center; gap: 34px; }
.site-header nav a { height: 100%; display: grid; place-items: center; position: relative; color: var(--muted); font: 600 12px/1 var(--mono); text-decoration: none; }
.site-header nav a:hover, .site-header nav a.active { color: var(--text); }
.site-header nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }

main { width: var(--page); margin: 0 auto; }
.browse-intro { padding: 92px 0 62px; border-bottom: 1px solid var(--line-soft); }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 22px; color: var(--muted); font: 650 10px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.eyebrow > span { width: 17px; height: 1px; background: var(--accent); }
h1, h2, p { text-wrap: balance; }
.browse-intro h1 { max-width: 900px; margin: 0; font-size: clamp(42px, 5.1vw, 76px); line-height: .96; letter-spacing: -.055em; }
.lede { max-width: 650px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.6; }

.catalog { padding: 30px 0 110px; }
.catalog-tools { display: grid; grid-template-columns: minmax(230px, 360px) minmax(0, 1fr) auto; gap: 22px; align-items: center; }
.search-field { height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field svg { width: 17px; fill: none; stroke: var(--faint); stroke-width: 1.5; }
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: 12px/1 var(--mono); }
.search-field input::placeholder { color: var(--faint); }
.filter-row { min-width: 0; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row button { flex: 0 0 auto; height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font: 600 10px/1 var(--mono); cursor: pointer; }
.filter-row button:hover { color: var(--text); background: var(--surface); }
.filter-row button.active { border-color: var(--line); background: var(--surface-2); color: var(--text); }
.sort-field { height: 36px; display: flex; align-items: center; gap: 9px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--faint); font: 600 9px/1 var(--mono); text-transform: uppercase; letter-spacing: .09em; }
.sort-field select { border: 0; outline: 0; background: var(--bg); color: var(--text); font: 600 11px/1 var(--mono); cursor: pointer; }
.catalog-meta { min-height: 56px; display: flex; align-items: center; justify-content: space-between; color: var(--faint); font: 500 9px/1 var(--mono); letter-spacing: .05em; text-transform: uppercase; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 42px 18px; }
.lab-card { min-width: 0; }
.card-preview { aspect-ratio: 16 / 9; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); transition: transform .22s ease, border-color .22s ease; }
.lab-card:hover .card-preview { transform: translateY(-3px); border-color: #4a5564; }
.card-preview::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(63, 131, 248, .08), transparent 42%), repeating-linear-gradient(90deg, transparent 0 32px, rgba(255,255,255,.018) 32px 33px); }
.card-preview iframe { width: 100%; height: 100%; border: 0; position: relative; z-index: 1; background: #fff; pointer-events: none; }
.card-hit { position: absolute; inset: 0; z-index: 2; }
.card-index { position: absolute; top: 10px; left: 10px; z-index: 3; display: grid; place-items: center; min-width: 29px; height: 24px; padding: 0 7px; border: 1px solid rgba(255,255,255,.16); border-radius: 5px; background: rgba(8,10,13,.82); color: #fff; font: 600 9px/1 var(--mono); pointer-events: none; }
.card-body { display: block; padding-top: 14px; text-decoration: none; }
.card-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.card-title { margin: 0; overflow: hidden; font-size: 15px; line-height: 1.25; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.card-views { flex: 0 0 auto; color: var(--muted); font: 500 9px/1 var(--mono); }
.card-description { height: 36px; margin: 7px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.55; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.tag-row { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.tag { max-width: 150px; padding: 4px 7px; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 5px; background: var(--surface); color: var(--muted); font: 550 8px/1 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.card-kind { flex: 0 0 auto; color: var(--faint); font: 550 8px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.empty-state { grid-column: 1 / -1; min-height: 300px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 9px; color: var(--muted); font: 12px/1.6 var(--mono); text-align: center; }

.about-block { display: grid; grid-template-columns: .7fr 1.2fr 1fr; gap: 60px; padding: 92px 0 108px; border-top: 1px solid var(--line); }
.about-block h2 { margin: 0; font-size: clamp(25px, 2.5vw, 39px); line-height: 1.08; letter-spacing: -.04em; }
.about-block > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.site-footer { width: var(--page); min-height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--faint); font: 600 9px/1 var(--mono); letter-spacing: .08em; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

.detail-main { padding: 43px 0 100px; }
.back-link { display: inline-flex; gap: 9px; align-items: center; margin-bottom: 54px; color: var(--muted); font: 600 10px/1 var(--mono); text-decoration: none; }
.back-link:hover { color: var(--text); }
.back-link span { color: var(--accent); }
.detail-loading { min-height: 50vh; display: grid; place-items: center; color: var(--muted); font: 11px/1 var(--mono); }
.detail-head { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 80px; align-items: end; padding-bottom: 45px; border-bottom: 1px solid var(--line); }
.detail-copy h1 { max-width: 900px; margin: 0; font-size: clamp(43px, 5.4vw, 78px); line-height: .98; letter-spacing: -.055em; }
.detail-description { max-width: 760px; margin: 24px 0 21px; color: var(--muted); font-size: 16px; line-height: 1.6; }
.detail-aside { display: flex; flex-direction: column; gap: 22px; }
.detail-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 0; }
.detail-stats div { padding-top: 12px; border-top: 1px solid var(--line); }
.detail-stats dt { color: var(--faint); font: 600 8px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.detail-stats dd { margin: 8px 0 0; font: 650 12px/1.2 var(--mono); }
.primary-action { min-height: 43px; display: inline-flex; align-items: center; justify-content: space-between; gap: 22px; padding: 0 15px; border: 1px solid var(--accent); border-radius: 7px; background: var(--accent); color: #fff; font: 650 10px/1 var(--mono); text-decoration: none; }
.primary-action:hover { background: #2775ef; }
.primary-action span { font-size: 15px; }

.prompt-panel { margin: 28px 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.prompt-panel summary { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 18px; list-style: none; cursor: pointer; }
.prompt-panel summary::-webkit-details-marker { display: none; }
.prompt-panel summary > span:first-child { display: flex; flex-direction: column; gap: 5px; }
.prompt-panel summary b { font-size: 11px; }
.prompt-panel summary small { color: var(--muted); font: 8px/1 var(--mono); }
.summary-action { display: flex; align-items: center; gap: 12px; color: var(--muted); font: 600 9px/1 var(--mono); }
.summary-action i { color: var(--accent); font: normal 15px/1 var(--sans); }
.prompt-panel[open] .summary-action i { transform: rotate(45deg); }
.prompt-content { position: relative; padding: 0 18px 18px; border-top: 1px solid var(--line-soft); }
.prompt-content pre { max-height: 350px; margin: 0; padding: 20px 130px 0 0; overflow: auto; color: #c8ced7; font: 11px/1.7 var(--mono); white-space: pre-wrap; }
.prompt-content button { position: absolute; top: 17px; right: 18px; height: 31px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--muted); font: 600 8px/1 var(--mono); cursor: pointer; }
.prompt-content button:hover { border-color: var(--accent); color: var(--text); }
.preview-section { padding-top: 20px; }
.preview-bar { height: 49px; display: flex; align-items: center; justify-content: space-between; }
.preview-bar h2 { margin: 0; font-size: 13px; }
.preview-bar span { color: var(--faint); font: 600 8px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.detail-preview { aspect-ratio: 16 / 9; min-height: 480px; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.detail-preview iframe { width: 100%; height: 100%; position: relative; z-index: 1; border: 0; background: #fff; }
.preview-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); font: 9px/1 var(--mono); }
.detail-preview iframe:not([src]) { display: none; }
.missing-state { max-width: 760px; min-height: 58vh; padding-top: 60px; }
.missing-state h1 { margin: 0; font-size: clamp(39px, 5vw, 69px); line-height: 1; letter-spacing: -.05em; }
.missing-state > p:not(.eyebrow) { margin: 24px 0 32px; color: var(--muted); font-size: 15px; }

@media (max-width: 1050px) {
  :root { --page: calc(100vw - 52px); }
  .site-header { padding: 0 26px; }
  .catalog-tools { grid-template-columns: 1fr auto; }
  .filter-row { grid-row: 2; grid-column: 1 / -1; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about-block { grid-template-columns: 1fr 1.4fr; }
  .about-block > p:last-child { grid-column: 2; }
  .detail-head { grid-template-columns: minmax(0, 1fr) 250px; gap: 40px; }
}

@media (max-width: 680px) {
  :root { --page: calc(100vw - 28px); }
  .site-header { height: 60px; padding: 0 14px; }
  .site-header nav { gap: 18px; }
  .site-header nav a { font-size: 10px; }
  .brand { font-size: 11px; }
  .brand svg { width: 21px; }
  .browse-intro { padding: 63px 0 43px; }
  .browse-intro h1 { font-size: clamp(41px, 13vw, 58px); }
  .lede { margin-top: 21px; font-size: 14px; }
  .catalog { padding-top: 22px; }
  .catalog-tools { grid-template-columns: 1fr; gap: 12px; }
  .filter-row { grid-row: auto; grid-column: auto; margin-right: -14px; }
  .sort-field { width: max-content; padding: 0; border: 0; }
  .catalog-meta { min-height: 48px; }
  #gallery-view-status { display: none; }
  .gallery-grid { grid-template-columns: 1fr; gap: 35px; }
  .card-description { height: auto; min-height: 34px; }
  .about-block { display: block; padding: 65px 0 75px; }
  .about-block h2 { margin-bottom: 26px; }
  .site-footer { min-height: 72px; }
  .detail-main { padding-top: 27px; }
  .back-link { margin-bottom: 39px; }
  .detail-head { display: block; padding-bottom: 31px; }
  .detail-copy h1 { font-size: clamp(42px, 13vw, 62px); }
  .detail-description { font-size: 14px; }
  .detail-aside { margin-top: 31px; }
  .detail-stats { gap: 12px; }
  .prompt-panel { margin: 20px 0; }
  .prompt-content pre { padding-right: 0; padding-top: 62px; }
  .detail-preview { min-height: 0; border-radius: 7px; }
  .preview-bar span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
