/* Layout: a single column; the landscape is the hero, details beside it on wide
   screens, examples as a scroll-snap strip at the bottom. Cool paper and
   slate ink, a dusk-blue accent, amber only for the favorite star. */
:root {
  --bg: #eef1f2;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #5a6772;
  --line: #d5dce0;
  --accent: #2f4e7a;
  --accent-ink: #ffffff;
  --star: #d9971c;
  --scrim: rgba(12, 18, 24, 0.72);
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --body: "Figtree", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* bit map namespace colors */
  --ns-global: #9aa19c; --ns-global-extra: #ab9f91; --ns-sky: #8fb8d8; --ns-celestial: #e2a43c; --ns-mountains: #6f7f98;
  --ns-hills: #8fae6e; --ns-trees: #3f6b4a; --ns-vegetation: #c1b36a; --ns-fog: #b9a9c9;
  --cell-ink: #ffffff;
  --glow: 0.6;
  color-scheme: light;
}
/* Dark: follows the system unless the visitor picked a theme (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --panel: #16202a; --ink: #e5ecf1; --muted: #8fa0ad; --line: #26323d;
    --accent: #8db4e8; --accent-ink: #0f151c; --star: #f0b545; --scrim: rgba(4, 7, 10, 0.8);
    --ns-global: #59615c; --ns-global-extra: #6f665b; --ns-sky: #5f8fb4; --ns-celestial: #c98a22; --ns-mountains: #5a6a86;
    --ns-hills: #6d8f4f; --ns-trees: #4f8a5e; --ns-vegetation: #a39553; --ns-fog: #8f7fa3;
    --cell-ink: #f4f7f5;
    --glow: 0.45;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --panel: #16202a; --ink: #e5ecf1; --muted: #8fa0ad; --line: #26323d;
  --accent: #8db4e8; --accent-ink: #0f151c; --star: #f0b545; --scrim: rgba(4, 7, 10, 0.8);
  --ns-global: #59615c; --ns-global-extra: #6f665b; --ns-sky: #5f8fb4; --ns-celestial: #c98a22; --ns-mountains: #5a6a86;
  --ns-hills: #6d8f4f; --ns-trees: #4f8a5e; --ns-vegetation: #a39553; --ns-fog: #8f7fa3;
  --cell-ink: #f4f7f5;
  --glow: 0.45;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; }
[hidden] { display: none !important; }

/* a soft, blurred wash of the current landscape behind the page */
.glow { position: fixed; inset: 0; z-index: -1; overflow: hidden; opacity: var(--glow); pointer-events: none; }
.glow::before { content: ""; position: absolute; inset: -12%; background: var(--glow-img, none) center / cover no-repeat; filter: blur(56px) saturate(1.35); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; }
code { font-family: var(--mono); font-size: 0.86em; word-break: break-all; }

/* header */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 14px max(20px, env(safe-area-inset-left)); padding-top: calc(14px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.wordmark { font-family: var(--display); font-size: 22px; color: var(--ink); text-decoration: none; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: none; border: 0; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.site { margin-left: auto; color: var(--muted); text-decoration: none; font-weight: 500; }
.site:hover { color: var(--ink); }
.gh { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.gh:hover { color: var(--ink); }

main { max-width: 1160px; margin: 0 auto; padding-inline: 20px; padding-block: 40px 24px; }

/* hero and search */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 14px; max-width: 760px; margin-inline: auto; text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 52px); line-height: 1.08; letter-spacing: -0.01em; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; }
.search { display: flex; gap: 8px; margin-top: 10px; width: 100%; max-width: 640px; }
.field { position: relative; flex: 1; display: flex; min-width: 0; }
.search input { flex: 1; min-width: 0; padding: 14px 44px 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 15px var(--mono); }
.clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.clear:hover { color: var(--ink); background: var(--line); }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; padding: 12px 20px; border-radius: 10px; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.try { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; text-align: left; }
.chip b { font-weight: 600; font-size: 14px; }
.chip code { color: var(--muted); font-size: 11px; }
.chip:hover { border-color: var(--accent); }

/* result */
.result { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-top: 36px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.12); }
.frame { position: relative; margin: 0; overflow: hidden; background: var(--panel); aspect-ratio: 4 / 3; max-width: 100%; }
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--panel); }
.details { display: grid; align-content: start; gap: 18px; min-width: 0; padding: 22px; background: var(--panel); border-left: 1px solid var(--line); }
.ref { margin: 0; display: grid; gap: 12px; }
.ref dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ref dd { margin: 2px 0 0; min-width: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
#star[aria-pressed="true"] { color: var(--star); border-color: var(--star); }
#star[aria-pressed="true"] svg path { fill: var(--star); stroke: var(--star); }
.status { margin: 0; min-height: 1.5em; font-size: 14px; color: var(--muted); }

/* strips: favorites and examples */
.strip { margin-top: 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.strip h2 { font-size: 24px; }
.strip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nav { display: flex; gap: 8px; }
.round { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.round:hover { border-color: var(--accent); }
.thumbs, .carousel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 280px); gap: 14px; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 8px; scrollbar-width: thin; }
.dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.tile { scroll-snap-align: start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; padding: 0; text-align: left; display: grid; }
.tile:hover { border-color: var(--accent); }
.tile .thumb { aspect-ratio: 4 / 3; max-width: 100%; background: var(--line); display: block; width: 100%; object-fit: cover; }
.tile .cap { padding: 10px 12px; display: grid; gap: 2px; }
.tile .cap b { font-weight: 600; font-size: 14px; }
.tile .cap code { color: var(--muted); font-size: 11px; }

/* lightbox: an in-page div over a scrim */
.lightbox { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: grid; place-items: center; padding: 20px; }
.lb-panel { position: relative; width: min(1100px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.lb-panel img { display: block; width: 100%; aspect-ratio: 4 / 3; max-width: 100%; object-fit: cover; background: var(--line); }
.lb-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.lb-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; }
.lb-meta h3 { font-size: 22px; }
.lb-meta code { color: var(--muted); }
.lb-meta > div:first-child { min-width: 0; flex: 1 1 320px; }

.foot { max-width: 1160px; margin: 0 auto; padding: 24px 20px calc(32px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

/* bit map tab */
.bits-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; max-width: 920px; }
.bits-head { display: grid; gap: 10px; }
.bits-head h1 { font-size: clamp(28px, 4.5vw, 40px); }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.bit-stats { display: flex; flex-wrap: wrap; gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; display: grid; gap: 2px; min-width: 0; }
.stat b { font-family: var(--mono); font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.grid-scroll, .table-scroll { overflow-x: auto; }
.bits { display: grid; grid-template-columns: 34px repeat(16, minmax(20px, 1fr)); gap: 3px; min-width: 380px; }
.rowlabel, .collabel { font-family: var(--mono); font-size: 11px; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; padding-right: 4px; font-variant-numeric: tabular-nums; }
.collabel { justify-content: center; padding-right: 0; }
.cell { aspect-ratio: 1; max-width: 100%; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10px; color: var(--cell-ink); font-variant-numeric: tabular-nums; }
.cell:hover, .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.hint { font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 1.5em; }
.table-scroll { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ns { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.fields { color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .bar { gap: 12px; flex-wrap: wrap; }
  .gh span { display: none; }
  .result { grid-template-columns: minmax(0, 1fr); }
  .details { border-left: 0; border-top: 1px solid var(--line); }
  .search { flex-direction: column; }
  /* the example chips become one swipeable row instead of a tall stack */
  .try { width: 100%; }
  .chips { flex-wrap: nowrap; justify-content: flex-start; width: 100%; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }


/* discoverer credit */
.tile .cap .by { color: var(--muted); font-size: 12px; }
.lb-by { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* gallery suggestion: a small floating form, opened from the result card */
.suggest { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 16; width: min(360px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.suggest form { display: grid; gap: 8px; padding: 18px; }
.suggest h3 { font-size: 20px; }
.sg-note { margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.sg-preview { display: block; width: 100%; aspect-ratio: 4 / 3; max-width: 100%; object-fit: cover; border-radius: 10px; background: var(--line); }
.suggest label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 4px; }
.suggest input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 15px var(--body); min-width: 0; }
.suggest .actions { justify-content: flex-end; }
.suggest .primary { padding: 8px 18px; }

/* theme switch: system, light, dark */
.theme-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--muted); padding: 0; }
.theme-btn:hover { color: var(--ink); border-color: var(--accent); }
.theme-btn svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
