/* Layout: sticky slim header, split hero (copy + featured code card), filter bar, auto-fill card grid.
   Dark-first "HUD at night" palette: blue-slate ground, one amber tracer accent for codes and actions. */
:root {
  --bg: #0c1018;
  --surface: #131925;
  --surface-2: #1a2231;
  --line: #263044;
  --fg: #e9edf5;
  --muted: #8c97ab;
  --accent: #ffb547;
  --accent-ink: #1d1304;
  --accent-soft: rgba(255, 181, 71, 0.12);
  --meta: #ffb547;
  --tier-s: #7cc4ff;
  --tier-a: #8ee0b5;
  --tier-b: #b7bfcf;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.6);
  --overlay: rgba(5, 8, 13, 0.72);

  --font-display: "Chakra Petch", "Rajdhani", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1200px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f4f8;
    --surface: #ffffff;
    --surface-2: #eaeef4;
    --line: #d8dee8;
    --fg: #111725;
    --muted: #5a6476;
    --accent: #b86e00;
    --accent-ink: #ffffff;
    --accent-soft: rgba(184, 110, 0, 0.1);
    --meta: #b86e00;
    --tier-s: #1f6fb2;
    --tier-a: #1d8a55;
    --tier-b: #5a6476;
    --shadow: 0 18px 50px -24px rgba(17, 23, 37, 0.25);
    --overlay: rgba(17, 23, 37, 0.45);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --line: #d8dee8;
  --fg: #111725;
  --muted: #5a6476;
  --accent: #b86e00;
  --accent-ink: #ffffff;
  --accent-soft: rgba(184, 110, 0, 0.1);
  --meta: #b86e00;
  --tier-s: #1f6fb2;
  --tier-a: #1d8a55;
  --tier-b: #5a6476;
  --shadow: 0 18px 50px -24px rgba(17, 23, 37, 0.25);
  --overlay: rgba(17, 23, 37, 0.45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.no-scroll { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--bg);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 720px) {
  .wrap { padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); }
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── header ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
}
.brand-avatar { object-fit: cover; background: var(--surface-2); clip-path: none; border-radius: 8px; width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.topnav { display: flex; align-items: center; gap: 8px; }
.nav-btn, .nav-live {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: transparent;
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.nav-btn:hover, .nav-live:hover { background: var(--surface-2); }
.nav-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nav-btn[aria-pressed="true"] svg { fill: currentColor; }
.badge {
  min-width: 20px; padding: 0 6px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; text-align: center; font-variant-numeric: tabular-nums;
}
.nav-live.is-live { border-color: #e5484d; color: #ff6b70; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
@media (max-width: 480px) {
  .nav-btn > span:not(.badge), .nav-live:not(.is-live) span { display: none; }
}

.notice { background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.notice .wrap { padding-block: 8px; }
.notice code { font-family: var(--font-mono); color: var(--fg); font-size: 12px; }

/* ── hero ───────────────────────────────────────────────── */
.hero { padding-block: 48px 32px; }
.hero-grid { display: grid; gap: 32px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 56px; } }
.hero-copy { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.04;
  letter-spacing: -0.01em;
}
.lede { color: var(--muted); font-size: 17px; max-width: 46ch; }

.search {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
  height: 52px; padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search svg { color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search input::placeholder { color: var(--muted); }
.search kbd {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px;
}
@media (hover: none) { .search kbd { display: none; } }

.hero-stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 8px 0 0; }
.hero-stats div { display: flex; flex-direction: column-reverse; }
.hero-stats dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.hero-stats dd { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.featured {
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(140deg, var(--accent), var(--line) 45%) border-box;
  border: 1px solid transparent;
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.featured-top { display: flex; align-items: center; justify-content: space-between; }
.featured-name { font-family: var(--font-display); font-size: 36px; font-weight: 700; line-height: 1; }
.featured-meta { color: var(--muted); font-size: 14px; }
.featured-atts { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.featured-atts li { font-size: 14px; display: flex; flex-direction: column; min-width: 0; }
.featured-atts span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.featured .text-btn { align-self: flex-start; margin-top: 4px; }

/* ── shared bits ────────────────────────────────────────── */
.tier {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid currentColor;
  color: var(--tier-b);
}
.tier-meta { color: var(--accent-ink); background: var(--meta); border-color: var(--meta); }
.tier-s { color: var(--tier-s); }
.tier-a { color: var(--tier-a); }
.cat { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

.code-row {
  display: flex; align-items: stretch;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  overflow: hidden;
}
.code {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  padding: 10px 12px;
  font-family: var(--font-mono); font-weight: 500; font-size: 13px; letter-spacing: 0.02em;
  color: var(--fg);
  overflow-wrap: anywhere;
  line-height: 1.45;
  user-select: all;
}
.code-row.lg .code { font-size: 15px; padding: 14px 16px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600; font-size: 14px;
  transition: filter 0.15s;
}
.copy-btn:hover { filter: brightness(1.08); }
.copy-btn svg { width: 16px; height: 16px; }
.copy-btn.copied { background: var(--tier-a); }

.text-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 0; border: 0; background: none;
  color: var(--accent); font-weight: 600; font-size: 14px;
  text-decoration: none;
}
.text-btn svg { width: 16px; height: 16px; transition: transform 0.15s; }
.text-btn:hover svg { transform: translateX(2px); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 600; font-size: 14px; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.fav.is-on { color: var(--accent); }
.fav.is-on svg { fill: currentColor; }

/* ── controls ───────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; gap: 16px; padding-block: 16px; scroll-margin-top: 76px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative;
  padding: 10px 14px;
  border: 0; background: none;
  font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0.02em;
  color: var(--muted);
}
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent);
}
.filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.chip {
  height: 34px; padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  transition: all 0.15s;
}
.chip:hover { color: var(--fg); border-color: color-mix(in srgb, var(--fg) 30%, var(--line)); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.selects { display: flex; flex-wrap: wrap; gap: 8px; }
.select {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 4px 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}
.select span { color: var(--muted); }
.select select { border: 0; background: transparent; font-weight: 500; height: 100%; padding-right: 4px; outline: none; }
.select select option { background: var(--surface); color: var(--fg); }
.select:focus-within { border-color: var(--accent); }
.result-line { display: flex; align-items: center; gap: 16px; min-height: 24px; }
#count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* ── grid + cards ───────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  padding-bottom: 64px;
}
.card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  transition: border-color 0.15s, transform 0.15s;
  animation: rise 0.25s ease both;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
@keyframes rise { from { transform: translateY(4px); } to { transform: none; } }
.card-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px -4px 0; }
.card-tags { display: flex; align-items: center; gap: 10px; }
.card-title button {
  padding: 0; border: 0; background: none; text-align: left;
  font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.1;
}
.card-title button:hover { color: var(--accent); }
.card-meta { color: var(--muted); font-size: 14px; margin-top: -8px; }
.att-list { list-style: none; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.att-list li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; font-size: 14px; }
.att-list .slot { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 2px; }
.att-list .more .att { color: var(--muted); }
.card .code-row { margin-top: auto; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 64px 16px 96px;
  color: var(--muted);
}
.empty-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--fg); }
.empty .btn { margin-top: 12px; }

/* ── modal ──────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); animation: fade 0.18s ease; }
.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop 0.2s ease;
}
.modal-panel:focus { outline: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin: -8px -10px -4px 0; }
.modal-actions { display: flex; gap: 2px; }
.modal-title { font-family: var(--font-display); font-size: clamp(30px, 5vw, 40px); font-weight: 700; line-height: 1; }
.share { align-self: flex-start; }
.how-to { color: var(--muted); font-size: 14px; margin-top: -4px; }
.modal-body { display: grid; gap: 24px; padding-top: 8px; }
@media (min-width: 640px) { .modal-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.section-label { font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.att-list.full { border-top: 0; padding-top: 0; gap: 0; }
.att-list.full li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.att-list.full li:last-child { border-bottom: 0; }
.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.stats li { display: grid; grid-template-columns: 80px minmax(0, 1fr) 28px; align-items: center; gap: 12px; font-size: 13px; }
.stat-label { color: var(--muted); }
.stat-val { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.notes { padding: 16px; background: var(--surface-2); border-radius: var(--radius-sm); }
.notes .section-label { margin-bottom: 6px; }
.notes p { max-width: 65ch; }
.modal-panel > .btn { align-self: flex-start; }

@media (max-width: 560px) {
  .modal { align-items: end; padding: 0; }
  .modal-panel { width: 100%; max-height: 92%; border-radius: 16px 16px 0 0; padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
}

/* ── toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  transform: translate(-50%, 16px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: var(--fg); color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── footer ─────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; padding-block: 32px; }
.footer-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.footer-note { color: var(--muted); font-size: 14px; max-width: 52ch; margin-top: 4px; }
.socials { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.socials a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.socials a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
