:root {
  --brand: #f47715;
  --brand-hover: #d9650c;
  --bg: #fafaf9;
  --surface: #ffffff;
  --sunken: #f4f4f2;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --muted: #57534e;
  --faint: #78716c;
  --info-bg: #e6f1fb;
  --info-text: #0c447c;
  --ok-bg: #eaf3de;
  --ok-text: #27500a;
  --radius: 8px;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #191817;
    --sunken: #201f1e;
    --border: #282726;
    --border-strong: #413f3e;
    --text: #e5e4e4;
    --muted: #a2a09e;
    --faint: #8a8785;
    --info-bg: #0c2c4a;
    --info-text: #b5d4f4;
    --ok-bg: #1f3310;
    --ok-text: #c0dd97;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 Geist, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; }
h1, h2, h3 { font-weight: 600; margin: 0; line-height: 1.3; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.loading { padding: 64px 0; text-align: center; }
main { flex: 1; }

/* Header and footer */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-row { display: flex; align-items: center; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; }
.brand-name { color: var(--muted); font-weight: 500; padding-left: 10px; border-left: 1px solid var(--border-strong); }
.top-nav { margin-left: auto; display: flex; align-items: center; gap: 20px; font-size: 14px; }
.top-nav a:not(.btn) { color: var(--muted); text-decoration: none; }
.top-nav a:not(.btn):hover { color: var(--text); }
.foot { border-top: 1px solid var(--border); margin-top: 64px; font-size: 13px; color: var(--faint); }
.foot-row { display: flex; justify-content: space-between; padding-top: 20px; padding-bottom: 20px; }
.foot a { color: var(--faint); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--sunken); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn svg, .icon { width: 16px; height: 16px; flex: none; }

/* Chips and badges */
.chip { text-decoration: none; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); font-size: 12px; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge-official { background: var(--info-bg); color: var(--info-text); }

/* Home */
.hero { padding: 48px 0 28px; }
.hero h1 { font-size: 32px; letter-spacing: -0.02em; }
.hero p { margin: 8px 0 24px; color: var(--muted); font-size: 16px; max-width: 620px; }
.search { position: relative; max-width: 620px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.search input {
  width: 100%; height: 46px; padding: 0 14px 0 42px; font: inherit; font-size: 15px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

.browse { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 32px; align-items: start; }
.filters { position: sticky; top: 84px; font-size: 14px; }
.filters h2 { font-size: 12px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px; }
.filters h2 + * { margin-bottom: 24px; }
.kind-list { list-style: none; padding: 0; margin: 0; }
.kind-list button {
  display: flex; width: 100%; justify-content: space-between; align-items: center;
  padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--muted);
  font: inherit; text-align: left; cursor: pointer;
}
.kind-list button:hover { background: var(--sunken); color: var(--text); }
.kind-list button[aria-pressed='true'] { background: var(--sunken); color: var(--text); font-weight: 500; }
.count { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-list button { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 12px; }
.tag-list button:hover { color: var(--text); }
.tag-list button[aria-pressed='true'] { background: var(--info-bg); color: var(--info-text); }

.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 14px; color: var(--muted); min-height: 32px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.thumb { aspect-ratio: 16 / 9; background: var(--sunken); display: flex; align-items: center; justify-content: center; color: var(--faint); overflow: hidden; border-bottom: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.thumb svg { width: 40px; height: 40px; stroke-width: 1.4; }
.thumb-dashboard { --tint: var(--brand); }
.thumb-alert { --tint: #dc2626; }
.thumb-workflow { --tint: #7c3aed; }
.thumb[class*='thumb-'] { background: color-mix(in srgb, var(--tint) 9%, var(--surface)); color: var(--tint); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { font-size: 15px; font-weight: 500; }
.card-body p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.card-foot .count { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.card-foot .count svg { width: 13px; height: 13px; }

.empty { text-align: center; padding: 64px 16px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--muted); }
.empty h2 { font-size: 17px; color: var(--text); margin-bottom: 6px; }

/* Item */
.back { display: inline-flex; align-items: center; gap: 6px; margin: 24px 0 20px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; column-gap: 40px; align-items: start;
  grid-template-areas: 'head panel' 'body panel';
}
.item-head { grid-area: head; }
.item-body { grid-area: body; }
.item .panel { grid-area: panel; }
.item h1 { font-size: 28px; letter-spacing: -0.01em; }
.byline { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; color: var(--muted); font-size: 14px; }
.byline .sep { color: var(--border-strong); }
.lead { font-size: 16px; color: var(--muted); margin: 0 0 24px; white-space: pre-wrap; }
.shot { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--sunken); margin-bottom: 32px; }
.shot img { display: block; width: 100%; }
.shots { display: flex; gap: 8px; margin: -20px 0 32px; }
.shot-pick { width: 120px; aspect-ratio: 16 / 10; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--sunken); cursor: pointer; }
.shot-pick.on { border-color: var(--brand); }
.shot-pick img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.note { background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 14px; margin: 0 0 24px; }
.section { margin-bottom: 32px; }
.section h2 { font-size: 17px; margin-bottom: 10px; }
.section > p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.setup { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 0 var(--radius) var(--radius) 0; padding: 4px 18px; font-size: 14px; }
.setup code { font-family: var(--mono); font-size: 13px; background: var(--sunken); padding: 1px 5px; border-radius: 4px; }
.setup pre { background: var(--sunken); padding: 12px; border-radius: 6px; overflow-x: auto; }
.setup pre code { padding: 0; }
.rows { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.rows li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 14px; }
.rows li + li { border-top: 1px solid var(--border); }
.rows li .chip { margin-left: auto; }
.rows .icon { color: var(--faint); }

.panel { position: sticky; top: 84px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.panel h2 { font-size: 15px; margin-bottom: 12px; }
.panel ol { margin: 0 0 16px; padding-left: 18px; color: var(--muted); font-size: 13px; }
.panel ol li + li { margin-top: 4px; }
.id-box { display: flex; align-items: center; gap: 8px; background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 4px 4px 12px; margin-bottom: 12px; }
.id-box code { font-family: var(--mono); font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .btn + .btn { margin-top: 8px; }
.panel-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

@media (max-width: 860px) {
  .browse, .item { grid-template-columns: minmax(0, 1fr); }
  .filters, .panel { position: static; }
  .kind-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .kind-list button { gap: 8px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
  .hero { padding-top: 32px; }
  .item { grid-template-areas: 'head' 'panel' 'body'; }
  .item .panel { margin-bottom: 32px; }
  .hero h1 { font-size: 26px; }
}

@media (max-width: 560px) {
  .top-nav .btn { display: none; }
}
