/* Shared spacing keeps chrome, dialogs, and controls on the same grid. */
:root {
  color-scheme: dark;
  --ground: #090a0b;
  --surface: #111315;
  --raised: #1b1d1f;
  --text: #f6f5f1;
  --muted: #b8babc;
  --border: #424549;
  --accent: #e4f4ab;
  --edge: 28px;
  --panel-space: 28px;
  --control-size: 44px;
  --radius: 4px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  font-family: "Paper Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--ground); color: var(--text); }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; border: 0; }
a { color: inherit; text-decoration: none; }
button:disabled { opacity: .45; cursor: wait; }
button:focus-visible, a:focus-visible, select:focus-visible, .wall:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.wall:focus-visible { outline-offset: -5px; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.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; }
.skip-link { position: fixed; z-index: 20; top: 12px; left: 12px; display: flex; align-items: center; min-height: var(--control-size); padding: 12px 16px; color: var(--ground); background: var(--accent); transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.wall { position: fixed; inset: 0; overflow: hidden; contain: strict; cursor: grab; touch-action: pinch-zoom; user-select: none; -webkit-user-select: none; outline: 0; }
.wall.is-dragging { cursor: grabbing; }
.world { position: absolute; top: 0; left: 0; transform: translate3d(0,0,0); will-change: transform; contain: strict; background-repeat: repeat; background-position: 0 0; }
/* Wall chrome */
.masthead {
  position: fixed; inset: 0 0 auto; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: var(--edge) var(--edge) 48px;
  padding-top: max(var(--edge), env(safe-area-inset-top));
  pointer-events: none;
  background: linear-gradient(#000b, #0004 65%, transparent);
}
.masthead > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-size); white-space: nowrap; }
.brand-logo { display: block; width: 138px; height: 44px; object-fit: contain; }
.brand-divider { align-self: center; height: 18px; width: 1px; background: #fff5; }
.brand-label { font-size: 12px; line-height: 1; font-weight: 400; letter-spacing: 0; color: #edeeed; }
.collection-button {
  min-height: var(--control-size); display: inline-flex; gap: var(--space-3); align-items: center; justify-content: center;
  padding: 0 var(--space-4); border: 1px solid #ffffff38; border-radius: var(--radius);
  background: #111315e8; font-size: 12px; line-height: 1; font-weight: 500; white-space: nowrap;
}
.collection-button:hover { background: #2a2d30; }
.collection-button .icon { width: 16px; height: 16px; }
.colophon {
  position: fixed; inset: auto 0 0; z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6);
  padding: 48px var(--edge) var(--edge);
  padding-bottom: max(var(--edge), env(safe-area-inset-bottom));
  background: linear-gradient(transparent, #0009 45%, #000d); pointer-events: none;
}
.colophon button { pointer-events: auto; }
.eyebrow { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; font-weight: 500; letter-spacing: .06em; }
.collection-heading { display: grid; gap: var(--space-2); min-width: 0; }
.collection-heading .eyebrow { display: flex; align-items: center; gap: var(--space-2); min-height: 18px; color: #d3d5d5; }
.footer-mark { display: block; width: 18px; height: 18px; flex: none; }
.collection-heading h1 { margin: 0; font-size: 24px; line-height: 1.1; letter-spacing: -.6px; font-weight: 450; }
.collection-meta { display: flex; align-items: baseline; gap: var(--space-2); margin: 0; font-size: 11px; line-height: 1.4; color: #d0d2d3; }
.collection-meta > span { white-space: nowrap; }
.meta-dot { color: #b2b4b6; }
.wall-tools { display: flex; align-items: center; gap: var(--space-2); }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--control-size); height: var(--control-size); padding: 0;
  border: 1px solid #ffffff38; border-radius: var(--radius); background: #111315e8;
  transition: background 140ms ease-out;
}
.icon-button:hover { background: #34373a; }
.icon-button .icon { width: 18px; height: 18px; }
.load-state { position: fixed; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: var(--space-6); background: var(--ground); font-size: 12px; color: var(--muted); }
.load-state[hidden] { display: none; }
.loading-mark { display: block; width: 44px; height: 44px; object-fit: contain; }
.load-state a { display: inline-flex; align-items: center; min-height: var(--control-size); text-decoration: underline; text-underline-offset: 4px; }

/* Collection sheet */
dialog { padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); box-shadow: none; }
dialog::backdrop { background: #050607bf; }
dialog[open] { animation: dialog-in 140ms ease-out; }
@keyframes dialog-in { from { opacity: 0; } to { opacity: 1; } }
.collection-dialog {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: 440px; max-width: 100%; height: 100%; max-height: 100%;
  border-top: 0; border-right: 0; border-bottom: 0; padding: var(--panel-space);
  padding-top: max(var(--panel-space), env(safe-area-inset-top));
  padding-bottom: max(var(--panel-space), env(safe-area-inset-bottom));
  overscroll-behavior: contain; scrollbar-gutter: stable;
}
.sheet-header { display: grid; grid-template-columns: 1fr var(--control-size); align-items: center; gap: var(--space-4); margin-bottom: var(--space-6); }
.sheet-header h2 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.6px; font-weight: 450; }
.sheet-header .icon-button, .viewer-top .icon-button { border-color: transparent; background: transparent; }
.sheet-header .icon-button:hover, .viewer-top .icon-button:hover { background: var(--raised); }
.pack-selector { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-block: 1px solid var(--border); font-size: 12px; }
.pack-selector label { color: var(--muted); }
.pack-selector select { min-height: var(--control-size); max-width: 240px; padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.sheet-intro { padding: var(--space-4) 0; }
.sheet-release { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.wallpaper-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.wallpaper-row {
  display: grid; grid-template-columns: 22px 40px minmax(0, 1fr) 16px; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 80px; padding: var(--space-3) 0;
  background: none; border-bottom: 1px solid #ffffff1a; text-align: left;
}
.wallpaper-row:hover { background: #ffffff09; }
.wallpaper-row img { display: block; width: 40px; height: 56px; object-fit: cover; background: var(--raised); }
.row-number { color: var(--muted); font-size: 10px; line-height: 1; font-variant-numeric: tabular-nums; }
.row-title { font-size: 13px; line-height: 1.4; font-weight: 400; letter-spacing: -.1px; }
.wallpaper-row > .icon { width: 16px; height: 16px; color: var(--muted); }

/* Wallpaper viewer */
.viewer { position: fixed; inset: 24px; margin: auto; width: 1120px; max-width: calc(100% - 48px); height: 800px; max-height: calc(100% - 48px); overflow: hidden; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer-top {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-4);
  min-height: 72px; padding: 0 var(--panel-space); flex: none; border-bottom: 1px solid #ffffff1a;
}
.viewer-brand { display: block; justify-self: start; width: 119px; height: 38px; object-fit: contain; }
.viewer-position { justify-self: center; font-size: 11px; line-height: 1; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.viewer-top .icon-button { justify-self: end; }
.viewer-content { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.4fr 1fr; }
.viewer-art { position: relative; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; background: var(--ground); padding: var(--panel-space); }
.viewer-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer-art img:not([src]) { visibility: hidden; }
.viewer-image-status { position: absolute; bottom: var(--panel-space); max-width: calc(100% - 48px); padding: var(--space-2) var(--space-3); background: #090a0be8; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.viewer-image-status:empty { display: none; }
.viewer-details { align-self: center; min-width: 0; padding: var(--panel-space); }
.viewer-details .eyebrow { margin-bottom: var(--space-4); font-size: 10px; line-height: 1.5; }
.viewer-details h2 { margin: 0 0 var(--space-3); font-size: 32px; line-height: 1.1; letter-spacing: -.9px; font-weight: 450; overflow-wrap: anywhere; }
.viewer-dimensions { margin: 0 0 var(--space-8); font-size: 11px; line-height: 1.6; color: var(--muted); }
.download-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-size); padding: 0 var(--space-4); border-radius: var(--radius); background: var(--text); color: var(--ground); font-size: 12px; line-height: 1.25; font-weight: 550; }
.download-button:hover { background: var(--accent); }
.download-button .icon { width: 16px; height: 16px; }
.original-link { display: flex; align-items: center; gap: var(--space-1); width: max-content; min-height: var(--control-size); margin-top: var(--space-2); font-size: 12px; line-height: 1.25; color: #d0d2d3; text-decoration: underline; text-underline-offset: 4px; }
.original-link .icon { width: 13px; height: 13px; }
.viewer-bottom { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: var(--space-4); min-height: 64px; padding: 0 var(--panel-space); border-top: 1px solid #ffffff1a; flex: none; }
.viewer-nav { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-size); padding: 0; background: transparent; font-size: 12px; line-height: 1; }
.viewer-nav:first-child { justify-self: start; }
.viewer-nav:last-child { justify-self: end; }
.viewer-nav .icon { width: 16px; height: 16px; }
.viewer-nav:hover { color: var(--accent); }
.noscript-message { position: fixed; z-index: 30; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-6); padding: var(--space-8); background: var(--ground); font-size: 14px; line-height: 1.5; text-align: center; }
.noscript-message a { display: inline-flex; align-items: center; min-height: var(--control-size); text-decoration: underline; text-underline-offset: 5px; }

@media (min-width: 1800px) {
  :root { --edge: 36px; }
}
@media (max-width: 700px) {
  :root { --edge: 20px; --panel-space: 20px; }
  .masthead { gap: var(--space-3); padding-bottom: 40px; }
  .brand { gap: var(--space-2); }
  .brand-divider { height: 16px; }
  .brand-label { font-size: 11px; }
  .collection-button { gap: var(--space-2); padding-inline: var(--space-3); font-size: 11px; }
  .collection-button .icon { width: 14px; height: 14px; }
  .colophon { gap: var(--space-4); padding-top: 40px; }
  .collection-heading h1 { font-size: 22px; letter-spacing: -.5px; }
  .collection-heading .eyebrow { font-size: 9px; }
  .collection-meta { flex-wrap: wrap; column-gap: 6px; row-gap: 2px; font-size: 10px; }
  .reset-button { display: none; }
  .collection-dialog { border-left: 0; }
  .sheet-header { margin-bottom: var(--space-4); }
  .viewer { inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; border: 0; }
  .viewer-top { min-height: calc(60px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  .viewer-brand { width: 100px; height: 32px; }
  .viewer-content { display: flex; flex-direction: column; overflow: auto; overscroll-behavior: contain; }
  .viewer-art { height: 52svh; min-height: 220px; flex: none; }
  .viewer-details { align-self: stretch; padding: var(--space-6) var(--panel-space); }
  .viewer-details h2 { font-size: 28px; letter-spacing: -.7px; }
  .viewer-details .eyebrow { margin-bottom: var(--space-3); }
  .viewer-dimensions { margin-bottom: var(--space-6); }
  .download-button { width: 100%; }
  .original-link { margin-inline: auto; }
  .viewer-bottom { min-height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
}
@media (max-width: 600px) {
  .brand-divider, .brand-label { display: none; }
}
@media (max-width: 380px) {
  .brand-logo { width: 128px; height: 41px; }
  .collection-heading h1 { font-size: 20px; }
}
@media (max-height: 600px) and (min-width: 701px) {
  .viewer-content { overflow-y: auto; }
  .viewer-art { min-height: 280px; }
  .viewer-details { align-self: start; padding-block: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
