:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef0f4;
  --text: #111418;
  --muted: #586170;
  --border: #dde1e7;
  --accent: #1f5fd6;
  --accent-strong: #184bb0;
  --accent-text: #ffffff;
  --accent-soft: #e4ecfb;
  --ok: #17703c;
  --wait: #8a5a00;
  --media-bg: #e3e7ee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(17 20 24 / 6%), 0 6px 20px rgb(17 20 24 / 6%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f12;
    --surface: #15181d;
    --surface-alt: #111317;
    --text: #e7eaee;
    --muted: #9ba4b0;
    --border: #272c34;
    --accent: #7ba7ff;
    --accent-strong: #a3c1ff;
    --accent-text: #0b1220;
    --accent-soft: #1b2741;
    --ok: #5fd08d;
    --wait: #e4b456;
    --media-bg: #1d2128;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 20px rgb(0 0 0 / 30%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #15181d;
  --surface-alt: #111317;
  --text: #e7eaee;
  --muted: #9ba4b0;
  --border: #272c34;
  --accent: #7ba7ff;
  --accent-strong: #a3c1ff;
  --accent-text: #0b1220;
  --accent-soft: #1b2741;
  --ok: #5fd08d;
  --wait: #e4b456;
  --media-bg: #1d2128;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 20px rgb(0 0 0 / 30%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 1.5rem + 2vw, 2.75rem);
}

h2 {
  font-size: clamp(1.375rem, 1.15rem + 1vw, 1.75rem);
}

h3 {
  font-size: 1.0625rem;
}

p {
  margin: 0 0 12px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 16px;
  top: -56px;
  padding: 8px 16px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip:focus {
  top: 8px;
}

.wrap {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.wrap.narrow > * {
  max-width: 760px;
}

.wrap.narrow.center > * {
  margin-left: auto;
  margin-right: auto;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.meta {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  font-size: 1.0625rem;
}

.brand b {
  font-weight: 700;
}

.brand-mark {
  width: 26px;
  height: 26px;
  fill: var(--accent);
}

.main-nav {
  display: none;
  gap: 4px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.main-nav a:hover {
  background: var(--surface-alt);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  justify-content: space-between;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.seg a,
.seg button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}

.seg a + a,
.seg button + button {
  border-left: 1px solid var(--border);
}

.seg [aria-current="true"],
.seg [aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

@media (min-width: 768px) {
  .main-nav {
    display: flex;
  }

  .controls {
    width: auto;
  }
}

/* Buttons and links */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.text-link,
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-weight: 600;
}

.back {
  text-decoration: none;
  margin-bottom: 8px;
}

/* Sections and cards */
.section {
  padding: 40px 0;
}

.section.alt {
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.lead {
  font-size: 1.0625rem;
  color: var(--muted);
  max-width: 62ch;
}

.section-lead {
  color: var(--muted);
  max-width: 62ch;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.shot {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--media-bg);
}

/* Catalog */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0;
}

.filters button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.filters button[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.theme-grid,
.item-grid,
.product-grid,
.changelog,
.chips,
.swatches {
  list-style: none;
  margin: 0;
  padding: 0;
}

.theme-grid {
  display: grid;
  gap: 20px;
}

@media (min-width: 600px) {
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .theme-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.theme-card {
  overflow: hidden;
}

.theme-card a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.theme-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.theme-card-body {
  padding: 16px;
}

.theme-card h2 {
  font-size: 1.125rem;
  margin-bottom: 4px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.chips li {
  font-size: 0.8125rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.theme-card .meta {
  margin: 0;
}

.empty {
  margin-top: 24px;
}

/* Theme page */
.theme-head {
  padding-top: 24px;
}

.theme-head-grid {
  display: grid;
  gap: 24px;
  align-items: start;
}

@media (min-width: 900px) {
  .theme-head-grid {
    grid-template-columns: 1fr 1.1fr;
    gap: 48px;
  }
}

.theme-head-shot {
  margin: 0;
}

.theme-head-shot .shot,
.scene .shot {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  margin: 20px 0 8px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.swatches li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.swatches code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
}

.count {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 400;
  vertical-align: middle;
  margin-left: 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.item-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

@media (min-width: 900px) {
  .item-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.item {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.item-media {
  max-width: 160px;
}

@media (min-width: 480px) {
  .item {
    grid-template-columns: 140px 1fr;
    gap: 16px;
  }
}

.item-media .shot {
  border-radius: var(--radius-sm);
}

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--media-bg);
  color: var(--muted);
}

.tile-icon {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.item h3 {
  margin-bottom: 2px;
}

.item .for {
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.item-body > p:not(.status-badge):not(.for) {
  font-size: 0.9375rem;
}

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--muted);
}

.status-live,
.status-download {
  color: var(--ok);
}

.status-review {
  color: var(--wait);
}

.item-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 4px 0 8px;
}

.file-meta {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
}

details {
  font-size: 0.9375rem;
}

summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

details p {
  color: var(--muted);
  margin: 0;
}

.item.is-yours {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.scene-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

@media (min-width: 600px) {
  .scene-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .scene-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.scene {
  margin: 0;
}

.scene figcaption {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 6px;
}

.changelog {
  display: grid;
  gap: 16px;
  margin-bottom: 32px;
}

.changelog > li {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
}

.changelog h3 {
  font-family: var(--mono);
  font-size: 0.9375rem;
  margin-bottom: 4px;
}

.changelog ul {
  margin: 0;
  padding-left: 20px;
}

.support-title {
  font-size: 1.25rem;
}

/* Products */
.product-grid {
  display: grid;
  gap: 16px;
}

@media (min-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.product {
  padding: 20px;
}

.product p {
  margin-bottom: 4px;
}

/* Prose and 404 */
.prose h1 {
  margin-bottom: 24px;
}

.center {
  text-align: center;
}

.code-404 {
  font-family: var(--mono);
  font-size: 4rem;
  color: var(--accent);
  margin: 0;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 0 max(24px, env(safe-area-inset-bottom));
  font-size: 0.9375rem;
  color: var(--muted);
}

.footer-row {
  display: grid;
  gap: 8px;
}

.footer-row p {
  margin: 0;
}

.footer-row nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 16px;
}

.footer-row nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

@media (min-width: 900px) {
  .footer-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .theme-card,
  .filters button,
  .seg button {
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  }
}
