:root {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d21;
  --text-muted: #626873;
  --accent: #3b6ef6;
  --accent-soft: rgba(59, 110, 246, 0.1);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0e1116;
  --bg-elev: #171b22;
  --border: #262c36;
  --text: #e8eaed;
  --text-muted: #9aa2ad;
  --accent: #6b93ff;
  --accent-soft: rgba(107, 147, 255, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1116;
    --bg-elev: #171b22;
    --border: #262c36;
    --text: #e8eaed;
    --text-muted: #9aa2ad;
    --accent: #6b93ff;
    --accent-soft: rgba(107, 147, 255, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 22px;
  padding-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-size: 34px;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle-icon::before {
  content: '🌙';
  font-size: 18px;
}

:root[data-theme='dark'] .theme-toggle-icon::before {
  content: '☀️';
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle-icon::before {
    content: '☀️';
  }
}

/* Toolbar */
main {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 48px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  opacity: 0.6;
  font-size: 0.95rem;
}

.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 0;
}

.count {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  font-size: 26px;
  line-height: 1;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.tag {
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 500;
}

.card-date {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px;
}

code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}
