:root {
  --ink: #ffffff;
  --dim: #4a545f;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; }

html, body { height: 100%; }

body {
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--mono);
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0.3rem 2.5rem;
  padding: 0.9rem 1rem 0;
}

.channels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.4rem;
}

.channels button,
.channels a,
.pages a {
  background: none;
  border: none;
  color: var(--dim);
  font: 0.72rem var(--mono);
  letter-spacing: 0.1em;
  text-decoration: none;
  cursor: pointer;
  padding: 0.3rem 0;
}

.channels button:hover,
.channels a:hover,
.pages a:hover { color: #9aa4af; }

.channels button[aria-selected="true"],
.channels a[aria-current="page"],
.pages a[aria-current="page"] { color: var(--ink); }

button:focus-visible, a:focus-visible { outline: 1px solid var(--dim); outline-offset: 3px; }

.pages { display: flex; gap: 1.4rem; }

main {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  min-height: 0;
}

#stage {
  position: relative;
  height: min(92vh, 100vw - 1.2rem);
  width: min(92vh, 100vw - 1.2rem);
  max-width: 100%;
}

#stage .loop, #stage #still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#stage .loop { opacity: 0; }

#stage .loop.front { opacity: 1; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(44vh, 90vw), 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 96vh;
}

.grid figure { text-align: center; }

.grid a { display: block; text-decoration: none; }

.grid img { width: 100%; aspect-ratio: 1; cursor: zoom-in; }

.grid figcaption {
  color: var(--dim);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  margin-top: 0.4rem;
}

.viewer-main { padding: 0.6rem; }

.image-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
}

.image-viewer.is-zoomed { cursor: grab; }
.image-viewer.is-zoomed:active { cursor: grabbing; }

.image-viewer > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center;
  will-change: transform;
  pointer-events: none;
}

.image-viewer .tile-layer {
  position: absolute;
  transform-origin: center;
  will-change: transform;
  pointer-events: none;
}

.image-viewer .tile-layer img { position: absolute; }

.image-status {
  color: var(--dim);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.zoom-controls {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem;
  border: 1px solid #30363d;
  border-radius: 0.3rem;
  background: rgb(0 0 0 / 75%);
}

.zoom-controls button {
  min-width: 2rem;
  min-height: 2rem;
  border: 0;
  border-radius: 0.2rem;
  background: #161b22;
  color: var(--ink);
  font: 1rem var(--mono);
  cursor: pointer;
}

.zoom-controls button:hover { background: #252c34; }

#zoom-level {
  min-width: 3.5rem;
  color: #9aa4af;
  font-size: 0.65rem;
  text-align: center;
}
