:root {
  color-scheme: light;
  --ink: #171b22;
  --muted: #69707d;
  --paper: #f5f3ee;
  --surface: #fffefa;
  --line: #d8d5ce;
  --red: #e44d32;
  --green: #176a55;
  --blue: #2567a7;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(rgba(23, 27, 34, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(23, 27, 34, 0.035) 1px, transparent 1px), var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "DM Sans", "Avenir Next", sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.gallery-header {
  position: relative;
  z-index: 10;
  display: flex;
  height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  padding: 0 48px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
.gallery-brand { flex-shrink: 0; }
.gallery-brand img { display: block; width: 132px; height: auto; }
.gallery-header nav { display: flex; align-items: center; gap: 10px; }
.gallery-header nav a { display: inline-flex; align-items: center; gap: 7px; border-radius: 5px; color: #626975; padding: 10px 14px; font-size: 13px; font-weight: 600; letter-spacing: 0; text-decoration: none; }
.gallery-header nav a:hover, .gallery-header nav a[aria-current="page"] { background: #e8e5de; color: var(--ink); }
.gallery-header nav .github-link { color: var(--ink); border-left: 1px solid var(--line); border-radius: 0; margin-left: 12px; padding-left: 23px; }
.gallery-header nav svg { width: 15px; height: 15px; flex-shrink: 0; }
.gallery-header .menu-toggle { display: none; width: 40px; height: 40px; flex-shrink: 0; border-radius: 5px; }
.gallery-header .menu-toggle svg { width: 18px; height: 18px; }
.gallery-header .menu-toggle:hover { background: #e8e5de; }
.gallery-header a:focus-visible, .gallery-header button:focus-visible { outline: 2px solid var(--blue); outline-offset: 5px; }
.gallery-header a, .gallery-header button { touch-action: manipulation; }

main { width: min(1500px, 100%); margin: 0 auto; padding: 0 clamp(20px, 4vw, 64px) 70px; }
.gallery-intro { display: flex; min-height: 210px; align-items: end; justify-content: space-between; gap: 30px; border-bottom: 1px solid var(--ink); padding: 56px 0 26px; }
.eyebrow { margin: 0 0 8px; color: var(--red); font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: clamp(48px, 7vw, 92px); font-weight: 500; line-height: 0.86; }

.gallery-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 0; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 5px; }
.filter-tabs button { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; padding: 0 12px; font-size: 12px; font-weight: 700; }
.filter-tabs button.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.gallery-search { position: relative; display: flex; width: min(310px, 100%); align-items: center; }
.gallery-search svg { position: absolute; left: 11px; width: 15px; color: var(--muted); pointer-events: none; }
.gallery-search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 6px; outline: 0; background: var(--surface); padding: 0 12px 0 35px; }
.gallery-search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 103, 167, 0.12); }

.taxonomy-filters { display: grid; gap: 9px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--ink); margin-bottom: 22px; padding: 14px 0; }
.taxonomy-filter-row { display: grid; grid-template-columns: 155px minmax(0, 1fr); align-items: start; gap: 14px; }
.taxonomy-filter-row > span { padding-top: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.taxonomy-options { display: flex; flex-wrap: wrap; gap: 5px; }
.taxonomy-options button { min-height: 29px; border: 1px solid #cbc8c0; border-radius: 999px; background: transparent; color: #525966; cursor: pointer; padding: 0 10px; font-size: 11px; font-weight: 600; }
.taxonomy-options button:hover { border-color: #8d8a83; color: var(--ink); }
.taxonomy-options button.active { border-color: var(--blue); background: #e7f0f8; color: #174d7c; }
.filter-result { display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: var(--green); font-size: 11px; font-weight: 700; }
.clear-filters { border: 0; background: transparent; color: var(--blue); cursor: pointer; padding: 2px 0; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 18px; }
.case-card { min-width: 0; border-top: 1px solid var(--line); padding-top: 9px; }
.case-open { display: block; width: 100%; border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0; text-align: left; }
.video-preview { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #252830; }
.video-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-preview::after { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.52)); content: ""; pointer-events: none; }
.play-control { position: absolute; z-index: 1; top: 50%; left: 50%; display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; background: rgba(255, 254, 250, 0.92); color: var(--ink); opacity: 0; transform: translate(-50%, -45%); transition: opacity 160ms ease, transform 160ms ease; }
.play-control svg { width: 19px; fill: currentColor; }
.case-open:hover .play-control, .case-open:focus-visible .play-control { opacity: 1; transform: translate(-50%, -50%); }
.case-index { position: absolute; z-index: 1; right: 10px; bottom: 8px; color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.case-copy { padding: 13px 2px 0; }
.case-kind { margin: 0 0 5px; color: var(--red); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.case-copy h2 { min-height: 48px; margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 23px; font-weight: 600; line-height: 1.05; }
.case-focus { margin: 8px 0; color: var(--muted); font-size: 13px; }
.case-tags { display: flex; min-height: 23px; flex-wrap: wrap; gap: 4px; margin: 10px 0; }
.taxonomy-tag { display: inline-flex; min-height: 21px; align-items: center; border-radius: 999px; padding: 2px 7px; font-size: 9px; font-weight: 700; line-height: 1.2; }
.taxonomy-tag-substrate { border: 1px solid #bbd0e3; background: #eaf2f8; color: #24577f; }
.taxonomy-tag-realization { border: 1px solid #c7d9cd; background: #edf5ef; color: #28614d; }
.case-stats { color: var(--green); font-size: 11px; font-weight: 700; }

.case-dialog { width: min(1800px, 98vw); height: min(1125px, 98vh, calc(98vw / 1.6)); max-height: 98vh; border: 0; border-radius: 8px; background: var(--surface); padding: 0; box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28); }
.case-dialog::backdrop { background: rgba(20, 23, 28, 0.72); backdrop-filter: blur(5px); }
.dialog-shell { display: flex; height: 100%; min-height: 0; flex-direction: column; }
.dialog-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 18px 20px; }
.dialog-header h2 { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 30px; line-height: 1; }
.dialog-content { display: grid; min-height: 0; flex: 1 1 auto; grid-template-columns: minmax(0, 1.8fr) minmax(430px, 0.9fr); overflow: hidden; }
.video-stage { display: grid; min-width: 0; min-height: 0; place-items: center; background: #15171c; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; }
.case-evidence { min-height: 0; overflow: auto; border-left: 1px solid var(--line); }
.case-evidence section { padding: 20px; }
.case-evidence section + section { border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-heading h3 { margin: 0; font-size: 13px; text-transform: uppercase; }
.case-about { background: #f3f0e9; }
.case-about .section-heading { margin-bottom: 10px; }
.case-about p { margin: 0; color: #474e59; font-family: "Newsreader", Georgia, serif; font-size: 18px; line-height: 1.42; }
.layer-file-groups { display: grid; gap: 8px; }
.layer-file-group { border: 1px solid #dedbd4; border-radius: 6px; background: #fbfaf6; }
.layer-file-group-primary { border-color: #b7cde0; background: #f4f8fb; }
.layer-file-heading { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #e4e1da; padding: 8px 10px; }
.layer-file-heading strong { display: grid; width: 25px; height: 20px; place-items: center; border-radius: 4px; background: #272b33; color: #fff; font-size: 9px; }
.layer-file-group-primary .layer-file-heading strong { background: var(--blue); }
.layer-file-heading span { color: #555d69; font-size: 11px; font-weight: 700; }
.layer-file-list { display: grid; }
.layer-file-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; border-top: 1px solid #ebe8e1; padding: 8px 10px; }
.layer-file-list > div:first-child { border-top: 0; }
.layer-skill-name { min-width: 0; overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.layer-file-list code { grid-column: 1 / -1; color: #687180; font: 9px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.layer-file-count { grid-column: 2; grid-row: 1; color: var(--green); font-size: 9px; font-weight: 700; white-space: nowrap; }
.layer-file-empty { display: block; color: #8a9099; padding: 8px 10px; font-size: 10px; font-style: italic; }
.model-chip { border: 1px solid #bad3cc; border-radius: 999px; background: #e8f3ef; color: var(--green); padding: 4px 8px; font-size: 10px; font-weight: 700; }
.feature-list { display: grid; }
.feature-list > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; border-top: 1px solid #e8e5df; padding: 9px 0; font-size: 12px; }
.feature-list span { color: var(--muted); }
.feature-list strong { font-weight: 600; overflow-wrap: anywhere; }
.history-section pre { max-height: 280px; overflow: auto; margin: 0; border: 1px solid #d8dbe0; border-radius: 6px; background: #20232a; color: #dbe6dd; padding: 13px; font: 10px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; padding: 0; }
.icon-button:hover { background: #ebe8e1; }
.icon-button svg { width: 17px; height: 17px; }
.gallery-empty, .load-error { border-top: 1px solid var(--line); color: var(--muted); padding: 50px 0; text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1100px) {
  .gallery-header { padding-inline: 32px; }
}
@media (max-width: 760px) {
  .gallery-header { height: 66px; padding-inline: 22px; }
  .gallery-brand img { width: 114px; }
  .gallery-header .menu-toggle { display: grid; }
  .gallery-header nav { display: none; position: absolute; left: 0; right: 0; top: 65px; padding: 16px 22px; border-bottom: 1px solid var(--line); background: var(--paper); }
  .gallery-header nav.is-open { display: flex; flex-direction: column; align-items: stretch; gap: 5px; }
  .gallery-header nav a { min-height: 44px; justify-content: space-between; }
  .gallery-header nav .github-link { padding-left: 14px; margin-left: 0; border-left: 0; justify-content: flex-start; }
}
@media (max-width: 980px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-content { grid-template-columns: 1fr; overflow: auto; }
  .video-stage { min-height: auto; aspect-ratio: 16 / 9; }
  .case-evidence { overflow: visible; border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 620px) {
  .gallery-intro { min-height: 170px; align-items: start; flex-direction: column; justify-content: end; gap: 14px; padding-top: 35px; }
  h1 { font-size: 54px; }
  .gallery-toolbar { align-items: stretch; flex-direction: column; }
  .gallery-search { width: 100%; }
  .taxonomy-filter-row { grid-template-columns: 1fr; gap: 5px; }
  .taxonomy-filter-row > span { padding-top: 0; }
  .filter-result { justify-content: space-between; }
  .gallery-grid { grid-template-columns: 1fr; }
  .case-copy h2 { min-height: 0; }
  .case-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; border-radius: 0; }
  .dialog-shell { max-height: 100dvh; }
  .dialog-header h2 { font-size: 24px; }
  .feature-list > div { grid-template-columns: 105px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .play-control { transition: none; }
}