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

:root {
  --bg: #1e1e1e;
  --surface: #272727;
  --surface-raised: #303030;
  --border: #3a3a3a;
  --border-light: #555;
  --text-primary: #e8e8e8;
  --text-muted: #888;
  --text-subtle: #555;
  --accent-blue: #3b82f6;
  --chip-ms-bg: #1e3a8a;
  --chip-ms-text: #93c5fd;
  --tag-problemese-border: #666;
  --tag-genre-border: #4ade80;
  --tag-genre-color: #4ade80;
  --link-color: #a78bfa;
  --link-hover: #c4b5fd;
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ── */

header {
  text-align: center;
  padding: 52px 24px 36px;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  color: var(--link-color);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.back-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.disclaimer {
  color: var(--text-subtle);
  font-size: 0.8rem;
  max-width: 520px;
  margin: 14px auto 0;
  line-height: 1.5;
}

/* ── Main layout ── */

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 72px;
}

/* ── Search row ── */

.search-row {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}

.search-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--border-light);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.filter-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 20px;
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.filter-toggle:hover {
  background: var(--surface-raised);
}

.filter-toggle.open {
  border-color: var(--border-light);
}

/* ── Filter panel ── */

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 14px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 28px;
}

.filter-field > label {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  margin-bottom: 7px;
}

.text-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus {
  border-color: var(--border-light);
}

.text-input::placeholder {
  color: var(--text-subtle);
}

.year-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-input {
  width: 88px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.year-input:focus {
  border-color: var(--border-light);
}

.year-input::-webkit-outer-spin-button,
.year-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.year-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 22px;
  color: var(--text-primary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

.reset-btn:hover {
  background: var(--surface-raised);
}

/* ── Multi-select dropdown ── */

.multi-select {
  position: relative;
}

.ms-field {
  min-height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: border-color 0.15s;
  user-select: none;
}

.ms-field:hover {
  border-color: var(--border-light);
}

.ms-field.open {
  border-color: var(--border-light);
}

.ms-chip {
  background: var(--chip-ms-bg);
  color: var(--chip-ms-text);
  border-radius: 4px;
  padding: 3px 6px 3px 9px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.ms-chip-remove {
  background: none;
  border: none;
  color: var(--chip-ms-text);
  opacity: 0.7;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  display: flex;
  align-items: center;
}

.ms-chip-remove:hover {
  opacity: 1;
}

.ms-placeholder {
  color: var(--text-subtle);
  font-size: 0.83rem;
  padding: 2px 0;
}

.ms-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.ms-search {
  width: 100%;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 0.83rem;
  outline: none;
}

.ms-search::placeholder {
  color: var(--text-subtle);
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: background 0.1s;
}

.ms-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ms-option input[type="checkbox"] {
  accent-color: var(--accent-blue);
  flex-shrink: 0;
}

/* ── Results header ── */

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0 12px;
  color: var(--text-muted);
  font-size: 0.88rem;
  min-height: 48px;
}

/* ── Results list ── */

.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: border-color 0.15s;
}

.result-card:hover {
  border-color: var(--border-light);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 0.76rem;
  border: 1px solid;
  line-height: 1.6;
}

.tag-problemese {
  border-color: var(--tag-problemese-border);
  color: var(--text-primary);
  background: transparent;
}

.tag-more {
  border-color: var(--text-subtle);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.footer-toggle {
  cursor: pointer;
  user-select: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-style: dashed;
}

.tag-genre {
  border-color: var(--tag-genre-border);
  color: var(--tag-genre-color);
  background: transparent;
}

.card-footer {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.card-footer a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card-footer a:hover {
  color: var(--link-hover);
}

/* ── Pagination ── */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 24px 0 0;
}

.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-width: 36px;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: var(--border-light);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.page-btn-active {
  background: var(--surface-raised);
  border-color: var(--border-light);
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 4px;
  font-size: 0.85rem;
  user-select: none;
}

/* ── Empty / loading states ── */

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 48px 0;
  font-size: 0.9rem;
}

/* ── Responsive ── */

@media (max-width: 600px) {
  h1 {
    font-size: 1.7rem;
  }

  .search-row {
    flex-direction: column;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    flex-direction: column;
    gap: 4px;
  }
}
