/* Layout: sticky toolbar, then a dense picture wall; the pictures carry the colour, the chrome stays quiet. */
:root {
  --bg: #0f1115;
  --surface: #181b21;
  --line: #2a2e37;
  --fg: #eceef2;
  --muted: #9097a5;
  --accent: #f2b544;
  --on-accent: #1b1406;
  --font-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --font-body: "Onest", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --radius: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f8; --surface: #ffffff; --line: #dde0e7; --fg: #15171c; --muted: #5d6472;
    --accent: #b77905; --on-accent: #ffffff; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f5f8; --surface: #ffffff; --line: #dde0e7; --fg: #15171c; --muted: #5d6472;
  --accent: #b77905; --on-accent: #ffffff; color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--font-body);
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

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

/* toolbar */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.top-in { display: flex; align-items: center; gap: 16px; padding-block: 12px; flex-wrap: wrap; }
.brand {
  display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none;
  font: 700 18px/1 var(--font-display); letter-spacing: .02em;
}
.brand-mark {
  width: 22px; height: 14px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #e0603a 60%, #4a63d8);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25);
}
.search { flex: 1 1 260px; min-width: 0; }
.search input {
  width: 100%; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
}
.search input::placeholder { color: var(--muted); }

/* intro */
.intro { padding-block: 32px 8px; display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px 24px; }
.intro h1 {
  margin: 0; max-width: 24ch; text-wrap: balance;
  font: 500 clamp(22px, 3.2vw, 36px)/1.15 var(--font-display); letter-spacing: -.01em;
}
.stat { margin: 0; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }

/* filters */
.filters { display: grid; gap: 12px; padding-block: 16px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--fg); white-space: nowrap;
}
.chip small { color: var(--muted); margin-left: 6px; font-family: var(--font-mono); font-size: 11px; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .6; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); }
.toggle {
  display: inline-flex; gap: 8px; align-items: center; cursor: pointer;
  border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 8px 12px;
}
.toggle .mono { font-size: 12px; color: var(--muted); }
.toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.toggle[aria-pressed="true"] .mono { color: inherit; }
.sort { margin-left: auto; }
.sort select { height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 10px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 12px; padding-block: 8px; }
.card {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, opacity .3s; opacity: 0; }
.card img.ok { opacity: 1; }
.card:hover img { transform: scale(1.04); }
.card .tag {
  position: absolute; left: 8px; bottom: 8px; display: flex; gap: 6px; align-items: center;
  font: 500 11px/1 var(--font-mono); color: #fff; background: rgba(10,12,16,.62);
  backdrop-filter: blur(6px); padding: 6px 8px; border-radius: 6px;
}
.card .tag b { color: #f2b544; font-weight: 500; }
.empty { text-align: center; padding-block: 64px; color: var(--muted); }
.more-row { display: grid; justify-items: center; gap: 12px; padding-block: 24px 48px; }
.shown { margin: 0; color: var(--muted); font-size: 13px; font-family: var(--font-mono); }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); font-weight: 500;
}
.btn-main { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-ghost { background: transparent; }

.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.foot .wrap { padding-block: 24px; }

/* viewer */
dialog#viewer {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: #07080a; color: #eceef2;
  display: none; grid-template-columns: 1fr 320px; grid-template-rows: 100%;
}
dialog#viewer[open] { display: grid; }
dialog#viewer::backdrop { background: rgba(0,0,0,.8); }
.v-stage { position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; display: grid; place-items: center; padding: 24px; }
.v-stage img { max-width: 100%; max-height: 100%; min-height: 0; width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.v-nav {
  position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 64px; border: 0; border-radius: 8px;
  background: rgba(255,255,255,.08); color: #fff; font-size: 34px; cursor: pointer;
}
.v-nav:hover { background: rgba(255,255,255,.16); }
.v-prev { left: max(12px, env(safe-area-inset-left, 0px)); }
.v-next { right: 12px; }
.v-info {
  display: flex; flex-direction: column; gap: 16px; background: #12141a;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) 24px;
  overflow-y: auto;
}
.v-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.v-cat { margin: 0; font: 500 20px/1.2 var(--font-display); }
.v-close { border: 0; background: rgba(255,255,255,.08); color: #fff; width: 36px; height: 36px; border-radius: 8px; font-size: 22px; cursor: pointer; flex: none; }
.v-meta { margin: 0; display: grid; gap: 10px; }
.v-meta div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #262a33; padding-bottom: 10px; }
.v-meta dt { color: #9097a5; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.v-meta dd { margin: 0; font-size: 13px; }
.v-fit { margin: 0; font-size: 13px; color: #9097a5; }
.v-fit.yes { color: #7fd49a; }
.v-fit.no { color: #f0a068; }
.v-info .btn { background: rgba(255,255,255,.06); color: #eceef2; border-color: #2a2e37; }
.v-info .btn-main { background: #f2b544; color: #1b1406; border-color: #f2b544; }

@media (max-width: 760px) {
  dialog#viewer { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .v-stage { padding: 12px; }
  .v-info { padding: 16px max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); gap: 12px; }
  .v-meta { grid-template-columns: 1fr 1fr; }
  .v-meta div { flex-direction: column; gap: 2px; }
  .sort { margin-left: 0; }
  .search { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .card img { transition: none; }
  .card:hover img { transform: none; }
}
