:root {
  --bg0: #0c1412;
  --bg1: #12201c;
  --bg2: #1a2e28;
  --ink: #e8f2ee;
  --muted: #8aa399;
  --line: rgba(232, 242, 238, 0.12);
  --accent: #3ecf8e;
  --accent-dim: rgba(62, 207, 142, 0.16);
  --warn: #f0c674;
  --radius: 4px;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
  --max: 1200px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(62, 207, 142, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(56, 120, 100, 0.22), transparent 50%),
    linear-gradient(165deg, var(--bg0) 0%, var(--bg1) 48%, #0e1a16 100%);
  background-attachment: fixed;
  line-height: 1.55;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero,
.main,
.footer {
  position: relative;
  z-index: 1;
}

.hero {
  padding: clamp(3.5rem, 12vh, 6.5rem) 1.25rem 2.5rem;
}

.hero-inner {
  max-width: var(--max);
  margin: 0 auto;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
}

.hero h1 {
  margin: 0 0 0.65rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 1.75rem;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.search {
  display: flex;
  gap: 0.5rem;
  max-width: 32rem;
  animation: rise 0.7s ease 0.12s both;
}

.search input {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 16, 14, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search input::placeholder {
  color: #6b857a;
}

.search input:focus {
  border-color: var(--accent);
  background: rgba(8, 16, 14, 0.85);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search button {
  padding: 0.85rem 1.2rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #062016;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.search button:hover {
  filter: brightness(1.08);
}

.search button:active {
  transform: scale(0.97);
}

.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  animation: rise 0.65s ease 0.18s both;
}

.cat {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.2rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.cat span {
  font-size: 0.8em;
  opacity: 0.75;
}

.cat:hover {
  color: var(--ink);
}

.cat.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.result-meta {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.result-meta a {
  color: var(--accent);
}

.result-meta strong {
  color: var(--ink);
  font-weight: 600;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.item {
  display: flex;
  flex-direction: column;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 16, 14, 0.35);
  animation: rise 0.55s ease both;
  animation-delay: var(--delay, 0s);
  transition: border-color 0.2s, background 0.2s;
}

.item:hover {
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(8, 16, 14, 0.55);
}

.item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.45rem;
}

.item h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.provider {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.item-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}

.btn:active {
  transform: scale(0.97);
}

.btn.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: transparent;
}

.btn.ghost:hover {
  border-color: rgba(232, 242, 238, 0.28);
  background: rgba(255, 255, 255, 0.03);
}

.btn.primary {
  color: #062016;
  background: var(--accent);
  border-color: var(--accent);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.primary.is-copied {
  background: var(--warn);
  border-color: var(--warn);
  color: #1a1408;
}

.desc {
  margin: 0 0 0.75rem;
  color: #b7cbc2;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.code {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  overflow-x: auto;
  border-radius: var(--radius);
  background: rgba(4, 10, 8, 0.65);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1.45;
  color: #9fd9b8;
  max-height: 6.5rem;
  overflow-y: auto;
}

.code code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

.tags {
  list-style: none;
  margin: auto 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
}

.tags a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.15s;
}

.tags a:hover {
  color: var(--accent);
}

.tags a::before {
  content: "#";
  opacity: 0.55;
}

.empty {
  padding: 2.5rem 0;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.pager-pages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pager-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

a.pager-num:hover {
  color: var(--ink);
  border-color: var(--line);
}

.pager-num.is-current {
  color: #062016;
  background: var(--accent);
  border-color: var(--accent);
}

.btn.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}

.result-meta a {
  margin-left: 0.15rem;
}

.brand a {
  color: inherit;
  text-decoration: none;
}

.item-title {
  color: inherit;
  text-decoration: none;
}

.item-title:hover {
  color: var(--accent);
}

.hero-compact {
  padding: clamp(2rem, 6vh, 3.5rem) 1.25rem 1.5rem;
}

.crumb {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
}

.crumb a:hover {
  color: var(--accent);
}

.detail {
  max-width: 720px;
}

.detail-desc {
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.detail-h {
  margin: 1.5rem 0 0.65rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.detail-code {
  max-height: none;
}

.detail-link a {
  color: var(--accent);
  word-break: break-all;
  font-size: 0.9rem;
}

.related {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.related li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.related a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.related a:hover {
  color: var(--accent);
}

.related span {
  color: var(--muted);
  font-size: 0.85rem;
}

.footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer strong {
  color: var(--ink);
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 20;
  transform: translateX(-50%) translateY(120%);
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: #0c1412;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s;
  opacity: 0;
}

.toast.is-show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .item-top {
    flex-direction: column;
  }

  .item-actions {
    width: 100%;
  }

  .btn {
    flex: 1;
  }

  .search {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
