:root {
  --paper: #f7f5ef;
  --paper-2: #efede4;
  --card: #fffefa;
  --ink: #14201d;
  --ink-2: #3d4a46;
  --muted: #6d7975;
  --line: #dcd9ce;
  --line-2: #e8e5dc;
  --accent: #0f766e;
  --accent-ink: #0b5f59;
  --accent-soft: #d9efeb;
  --amber: #b45309;
  --amber-soft: #fef0d8;
  --shadow: 0 1px 2px rgb(20 32 29 / 4%), 0 10px 30px -18px rgb(20 32 29 / 22%);
  --shadow-hover: 0 2px 4px rgb(20 32 29 / 6%), 0 18px 44px -18px rgb(20 32 29 / 28%);
  --radius: 18px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

html[data-theme="dark"] {
  --paper: #0b1210;
  --paper-2: #101a17;
  --card: #121d1a;
  --ink: #e9efec;
  --ink-2: #b4c0bb;
  --muted: #85938d;
  --line: #26332f;
  --line-2: #1d2925;
  --accent: #5eead4;
  --accent-ink: #99f6e4;
  --accent-soft: #11332e;
  --amber: #fbbf24;
  --amber-soft: #33270d;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 14px 40px -20px rgb(0 0 0 / 70%);
  --shadow-hover: 0 2px 6px rgb(0 0 0 / 35%), 0 22px 50px -20px rgb(0 0 0 / 80%);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --paper: #0b1210;
    --paper-2: #101a17;
    --card: #121d1a;
    --ink: #e9efec;
    --ink-2: #b4c0bb;
    --muted: #85938d;
    --line: #26332f;
    --line-2: #1d2925;
    --accent: #5eead4;
    --accent-ink: #99f6e4;
    --accent-soft: #11332e;
    --amber: #fbbf24;
    --amber-soft: #33270d;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 14px 40px -20px rgb(0 0 0 / 70%);
    --shadow-hover: 0 2px 6px rgb(0 0 0 / 35%), 0 22px 50px -20px rgb(0 0 0 / 80%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 82% -12%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 65%),
    radial-gradient(700px 420px at 0% 0%, color-mix(in srgb, var(--amber) 6%, transparent), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

.skip {
  position: fixed; left: 1rem; top: -4rem; z-index: 50;
  padding: .6rem 1rem; border-radius: 10px;
  background: var(--ink); color: var(--paper); text-decoration: none;
}
.skip:focus { top: 1rem; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 3rem);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
}

.brand {
  display: inline-flex; align-items: center; gap: .65rem;
  font-weight: 700; letter-spacing: -.02em; font-size: 1.03rem;
  text-decoration: none;
}
.brand-mark { color: var(--accent); display: inline-flex; }
.brand:hover { color: var(--ink); }

.topnav { display: flex; align-items: center; gap: .5rem; }
.topnav a {
  font-size: .86rem; color: var(--ink-2); text-decoration: none;
  padding: .45rem .7rem; border-radius: 9px;
  border: 1px solid transparent;
}
.topnav a:hover { color: var(--accent-ink); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover { color: var(--accent-ink); border-color: var(--accent); }
.icon-btn .sun { display: none; }
.icon-btn .moon { display: block; }
html[data-theme="dark"] .icon-btn .sun { display: block; }
html[data-theme="dark"] .icon-btn .moon { display: none; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .icon-btn .sun { display: block; }
  html[data-theme="auto"] .icon-btn .moon { display: none; }
}

main { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding-bottom: 2rem; }

.hero { padding: clamp(2.6rem, 7vw, 5.2rem) 0 2.1rem; max-width: 830px; }

.eyebrow {
  display: inline-flex; align-items: center; gap: .5rem;
  margin: 0 0 .9rem;
  font-family: var(--mono); font-size: .73rem; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted);
}
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.35rem, 6.6vw, 4.55rem);
  line-height: 1.02;
  letter-spacing: -.045em;
  font-weight: 760;
}
h1 .accent { color: var(--accent-ink); }
html[data-theme="dark"] h1 .accent { color: var(--accent); }

.lede {
  margin: 0;
  max-width: 60ch;
  color: var(--ink-2);
  font-size: clamp(1rem, 1.5vw, 1.13rem);
}
.lede strong { color: var(--ink); }

.stats {
  display: flex; flex-wrap: wrap; gap: 0;
  margin: 2.2rem 0 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 70%, transparent);
  overflow: hidden;
}
.stats > div {
  flex: 1 1 130px;
  padding: .85rem 1.1rem;
  border-right: 1px solid var(--line);
}
.stats > div:last-child { border-right: 0; }
.stats dt {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.stats dd {
  margin: .18rem 0 0; font-weight: 650; font-size: 1.16rem;
  letter-spacing: -.02em; display: flex; align-items: center; gap: .45rem;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #16a34a; box-shadow: 0 0 0 3px rgb(22 163 74 / 16%);
}

.controls {
  display: flex; gap: .75rem; align-items: center;
  margin: 2.4rem 0 1rem;
}
.search-wrap {
  position: relative; flex: 1 1 auto;
  display: flex; align-items: center;
}
.search-wrap svg { position: absolute; left: .95rem; color: var(--muted); pointer-events: none; }
.search-wrap input {
  width: 100%;
  padding: .85rem 3rem .85rem 2.7rem;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap kbd {
  position: absolute; right: .75rem;
  font-family: var(--mono); font-size: .7rem; color: var(--muted);
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: .1rem .4rem; background: var(--paper-2);
}

.sort {
  display: flex; align-items: center; gap: .5rem;
  font-size: .82rem; color: var(--muted); white-space: nowrap;
}
.sort select {
  font: inherit; font-size: .86rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: .72rem 2rem .72rem .8rem;
  cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.sort select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .7rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .42rem .78rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit; font-size: .82rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.chip .n {
  font-family: var(--mono); font-size: .7rem; opacity: .7;
}

.result-line { margin: 0 0 1rem; color: var(--muted); font-size: .82rem; min-height: 1.2em; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: .95rem;
}

.repo-card {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 256px;
  padding: 1.15rem 1.2rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  animation: rise .4s ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.repo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .75rem; }
.cat {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  padding: .17rem .48rem; border-radius: 999px;
}
html[data-theme="dark"] .cat { color: var(--accent); }
.vis {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--mono); font-size: .64rem; color: var(--muted);
}
.vis .dot { width: 6px; height: 6px; box-shadow: none; }

.repo-card h2 {
  margin: 0 0 .35rem;
  font-size: 1.17rem; letter-spacing: -.025em; line-height: 1.25;
  font-weight: 680;
}
.repo-card h2 a { text-decoration: none; }
.repo-card h2 a:hover { color: var(--accent-ink); text-decoration: underline; }
html[data-theme="dark"] .repo-card h2 a:hover { color: var(--accent); }

.card-desc {
  margin: 0 0 .9rem;
  color: var(--ink-2);
  font-size: .88rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .8rem;
  margin-top: auto;
  padding-top: .6rem;
  border-top: 1px solid var(--line-2);
  font-family: var(--mono); font-size: .7rem; color: var(--muted);
}
.card-meta span { display: inline-flex; align-items: center; gap: .32rem; }
.card-meta svg { opacity: .75; }

.commit {
  display: flex; align-items: baseline; gap: .5rem;
  margin-top: .55rem;
  padding: .48rem .6rem;
  background: var(--paper-2);
  border-radius: 9px;
  font-size: .76rem;
  min-width: 0;
}
.commit code {
  font-family: var(--mono); font-size: .7rem; color: var(--accent-ink);
  flex: none;
}
html[data-theme="dark"] .commit code { color: var(--accent); }
.commit span {
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-actions {
  display: flex; gap: .45rem; margin-top: .8rem;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem .72rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font: inherit; font-size: .78rem; font-weight: 560;
  cursor: pointer; text-decoration: none;
  transition: background .14s, border-color .14s, color .14s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.copy { margin-left: auto; }
.btn.copy.copied { border-color: #16a34a; color: #15803d; background: rgb(22 163 74 / 10%); }

.empty {
  text-align: center; padding: 4rem 1rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty-mark { font-size: 2.4rem; margin: 0 0 .3rem; color: var(--muted); }
.empty h2 { margin: 0 0 .3rem; font-size: 1.2rem; }
.empty p { margin: 0 0 1rem; color: var(--muted); }

.howto {
  display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 2rem; align-items: center;
  margin: 4rem 0 2rem;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  background: color-mix(in srgb, var(--card) 75%, transparent);
}
.howto h2 { margin: 0 0 .5rem; font-size: clamp(1.4rem, 3vw, 1.9rem); letter-spacing: -.03em; }
.howto p:not(.eyebrow) { margin: 0; color: var(--ink-2); max-width: 42ch; }

.terminal { border-radius: 13px; overflow: hidden; border: 1px solid var(--line); background: #0c1512; box-shadow: var(--shadow); }
.term-head { display: flex; align-items: center; gap: .38rem; padding: .55rem .8rem; border-bottom: 1px solid #1e2b26; }
.term-head span { width: 9px; height: 9px; border-radius: 50%; background: #2b3a34; }
.term-head span:first-child { background: #f87171; }
.term-head span:nth-child(2) { background: #fbbf24; }
.term-head span:nth-child(3) { background: #4ade80; }
.term-head em { margin-left: auto; font-family: var(--mono); font-style: normal; font-size: .66rem; color: #6f837b; }
.terminal pre { margin: 0; padding: .95rem 1rem; overflow-x: auto; }
.terminal code { font-family: var(--mono); font-size: .76rem; line-height: 1.75; color: #cfe3db; white-space: pre; }
.terminal .c { color: #66807a; }

footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.4rem 0 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .8rem;
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; justify-content: space-between;
}
footer p { margin: 0; }
footer .muted { color: color-mix(in srgb, var(--muted) 80%, transparent); }

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 1.2rem);
  padding: .6rem 1rem; border-radius: 10px;
  background: var(--ink); color: var(--paper);
  font-size: .82rem; box-shadow: var(--shadow-hover);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 40;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topnav a { display: none; }
  .controls { flex-direction: column; align-items: stretch; }
  .sort { justify-content: flex-end; }
  .howto { grid-template-columns: 1fr; gap: 1.2rem; }
  .grid { grid-template-columns: 1fr; }
  .stats > div { flex-basis: 50%; }
  .stats > div:nth-child(2) { border-right: 0; }
  .stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .repo-card { animation: none; transition: none; }
  .repo-card:hover { transform: none; }
}
