:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-hover: #fbfbfd;
  --border: #e2e5ea;
  --text: #14171f;
  --text-muted: #5b6270;
  --accent: #4f5bd5;
  --accent-contrast: #ffffff;
  --chip-bg: #eef0f6;
  --chip-active-bg: #4f5bd5;
  --chip-active-text: #ffffff;
  --shadow: 0 1px 2px rgba(20, 23, 31, 0.06), 0 1px 12px rgba(20, 23, 31, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161c;
    --surface: #1c1f27;
    --surface-hover: #21242e;
    --border: #2c3039;
    --text: #eef0f4;
    --text-muted: #a2a8b6;
    --accent: #8b93f0;
    --accent-contrast: #12131a;
    --chip-bg: #262a34;
    --chip-active-bg: #8b93f0;
    --chip-active-text: #14161c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 16px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.header-title h1 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0;
  color: var(--text-muted);
  max-width: 46ch;
}

.header-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.btn-star {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 0.75rem;
}

#search {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

#search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.chip[aria-pressed="true"] {
  background: var(--chip-active-bg);
  color: var(--chip-active-text);
  border-color: var(--chip-active-bg);
}

.result-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card-thumb {
  aspect-ratio: 16 / 9;
  background: var(--chip-bg);
  cursor: zoom-in;
  display: block;
  overflow: hidden;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.card-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
}

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

.card-category {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

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

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

.card-actions a {
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-hover);
  color: var(--text);
}

.card-actions a.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.5rem;
}

.site-footer p { margin: 0.25rem 0; }

.lightbox[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 15, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 50;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #fff;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  font-size: 2rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
}
