:root {
  --canvas: #f3f2ee;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --soft: #e8e7e1;
  --ink: #1d1d1b;
  --muted: #64655f;
  --line: rgba(29, 29, 27, 0.1);
  --accent: #ff5b2e;
  --accent-ink: #ffffff;
  --focus: #3e63dd;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 14px 34px -16px rgba(20, 20, 18, 0.32), 0 2px 6px -2px rgba(20, 20, 18, 0.12);
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #131412;
    --surface: rgba(36, 38, 34, 0.82);
    --surface-solid: #222420;
    --soft: #2c2e29;
    --ink: #f0f1ec;
    --muted: #a9aca2;
    --line: rgba(240, 241, 236, 0.12);
    --accent: #ff6a3d;
    --focus: #7c9bff;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 16px 40px -16px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(24px, 3.2vw, 34px); font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.js .nojs-only { display: none !important; }
html:not(.js) .js-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons and links */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border-radius: 999px; border: 0;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 0.2s var(--ease), background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { filter: brightness(1.05); }
.btn--quiet { background: var(--soft); color: var(--ink); }
.btn--quiet:hover { background: var(--line); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); cursor: pointer; }
.link:hover { text-decoration-color: currentColor; }

/* Top bar */
.bar {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 8px;
  width: min(1120px, calc(100vw - 24px)); padding: 7px 7px 7px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
}
.logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; letter-spacing: -0.02em; flex: none; margin-right: 4px; }
.filters { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; margin: 0; }
.select, .search { position: relative; display: flex; align-items: center; height: 40px; border-radius: 999px; background: var(--soft); }
.select select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-weight: 550; height: 100%; padding: 0 30px 0 14px; max-width: 210px; cursor: pointer; border-radius: 999px;
}
.select::after { content: ""; position: absolute; right: 13px; top: 17px; width: 6px; height: 6px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); pointer-events: none; opacity: 0.6; }
.search { flex: 1; min-width: 120px; padding-left: 12px; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 0 14px 0 8px; border-radius: 999px; outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--focus); }
.add { flex: none; }

/* Popovers built on <details> */
.pop { position: relative; }
.pop summary { list-style: none; }
.pop summary::-webkit-details-marker { display: none; }
.pop-trigger {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 13px; border-radius: 999px;
  background: var(--soft); cursor: pointer; font-weight: 550; user-select: none;
}
.pop-trigger.is-active { box-shadow: 0 0 0 2px var(--ink) inset; }
.pop[open] .pop-trigger { background: var(--line); }
.dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line) inset; }
.pop-panel {
  position: absolute; top: calc(100% + 10px); right: 0; width: 264px; padding: 16px;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; gap: 12px; animation: pop-in 0.22s var(--ease);
}
.pop-panel--wide { width: 300px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
.pop-title { margin: 0; font-weight: 650; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span:not(.sr-only) { display: block; aspect-ratio: 1; border-radius: 50%; box-shadow: 0 0 0 1px var(--line) inset; transition: transform 0.2s var(--ease); }
.swatch:hover span:not(.sr-only) { transform: scale(1.1); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; }
.custom-color { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }
.custom-color input { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.field { display: grid; gap: 6px; font-weight: 550; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field select, .field input {
  height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--canvas); color: var(--ink);
  font: inherit; padding: 0 12px; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--focus); outline-offset: 0; }

/* Pages */
.page { padding: 96px 24px 64px; max-width: 1180px; margin: 0 auto; }
.narrow { max-width: 640px; }
.lede { color: var(--muted); font-size: 17px; margin: 10px 0 24px; }
.panel { position: relative; background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: grid; gap: 14px; }

/* Intro */
.intro { position: relative; margin-bottom: 28px; max-width: 640px; }
.intro p { color: var(--muted); margin: 10px 0 0; }
.intro strong { color: var(--ink); }
.intro-close { display: none; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 22px 20px; }
.card { display: block; text-decoration: none; color: inherit; border-radius: var(--radius); }
.card-art {
  display: block; aspect-ratio: 1920 / 823; border-radius: var(--radius); overflow: hidden;
  background: var(--bg, var(--soft)); box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .card-art { transform: translateY(-3px); }
.card-meta { display: flex; align-items: center; gap: 10px; padding: 10px 4px 0; min-width: 0; }
.card-icon { width: 30px; height: 30px; border-radius: 8px; flex: none; background: var(--soft); box-shadow: 0 0 0 1px var(--line); }
.card-text { display: grid; min-width: 0; line-height: 1.25; }
.card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-dev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 40px; color: var(--muted); }

/* Canvas mode (JS): the grid becomes an endless, draggable plane */
.canvas { display: none; }
.canvas-mode body { overflow: hidden; overscroll-behavior: none; }
.canvas-mode .canvas {
  display: block; position: fixed; inset: 0; overflow: hidden; touch-action: none; cursor: grab; outline: none;
  user-select: none; -webkit-user-select: none;
}
.canvas-mode .canvas.is-dragging { cursor: grabbing; }
.canvas-mode .canvas.is-dragging .tile { pointer-events: none; }
.canvas-mode .home .grid, .canvas-mode .home .pager { display: none; }
.canvas-mode .home .page { padding: 0; }
.canvas-mode .intro {
  position: fixed; left: 16px; bottom: 16px; z-index: 15; width: min(420px, calc(100vw - 32px)); margin: 0;
  padding: 18px 44px 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.canvas-mode .intro h1 { font-size: 20px; }
.canvas-mode .intro p { font-size: 14px; }
.canvas-mode .intro.is-hidden { opacity: 0; transform: translateY(12px); pointer-events: none; }
.canvas-mode .intro-close {
  display: grid; place-items: center; position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); cursor: pointer;
}
.tile { position: absolute; top: 0; left: 0; will-change: transform; }
.tile .card-art img { opacity: 0; transition: opacity 0.4s; }
.tile .card-art img.is-loaded { opacity: 1; }
.tile:focus-visible { outline-offset: 4px; }

/* Detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 550; margin-bottom: 16px; }
.back:hover { color: var(--ink); }
.hero { margin: 0; aspect-ratio: 1920 / 823; border-radius: calc(var(--radius) + 6px); overflow: hidden; background: var(--bg); box-shadow: var(--shadow); }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; margin-top: 28px; align-items: start; }
.app-id { display: flex; gap: 16px; align-items: center; }
.app-icon { width: 64px; height: 64px; border-radius: 15px; box-shadow: 0 0 0 1px var(--line), var(--shadow); flex: none; }
.meta { margin: 6px 0 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 28px; }
.headline { margin: 0 0 28px; padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--surface-solid); border-radius: 0 12px 12px 0; }
.headline blockquote { margin: 0; font-size: 17px; font-weight: 550; }
.headline figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.palette ul { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink); font: inherit; cursor: copy;
}
.chip-swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px var(--line) inset; }
.chip-hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.chip-pct { font-size: 12px; color: var(--muted); }
.chip.is-copied .chip-hex::after { content: " copied"; color: var(--muted); font-family: inherit; }
.facts { background: var(--surface-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.facts dl { margin: 12px 0 0; display: grid; }
.facts dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 550; }
.facts dd a { text-decoration-color: var(--line); text-underline-offset: 3px; }
.related { margin-top: 56px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }

/* Submit */
.error { color: #d13415; margin: 0; font-weight: 550; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.submit-form .btn { justify-self: start; }
.busy-overlay {
  position: absolute; inset: 0; border-radius: inherit; display: none; place-items: center; align-content: center; gap: 12px;
  background: var(--surface); backdrop-filter: blur(4px); font-weight: 600;
}
.is-busy .busy-overlay { display: grid; }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; vertical-align: -4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.recent { margin-top: 40px; }
.list { list-style: none; padding: 0; margin: 12px 0 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list a { font-weight: 600; text-decoration: none; }
.status-line { display: flex; align-items: center; gap: 10px; margin: 0; }
.status p { margin: 0; }
.status .btn { justify-self: start; }
.narrow h1 { margin-bottom: 18px; }
.narrow .lede { margin-top: -6px; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; gap: 28px; }
  .pop-label { display: none; }
  .logo-text { display: none; }
}
@media (max-width: 640px) {
  .bar { top: 8px; width: calc(100vw - 16px); border-radius: 26px; flex-wrap: wrap; padding: 7px; gap: 6px; }
  .logo { margin: 0 0 0 6px; }
  .filters { order: 3; flex-basis: 100%; }
  .add { margin-left: auto; height: 36px; }
  .select select { max-width: 120px; }
  .search { min-width: 0; }
  .pop-panel { position: fixed; top: 112px; left: 8px; right: 8px; width: auto; }
  .page { padding: 132px 16px 48px; }
  .grid { gap: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
