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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1rem;
  color: #1a1a1a;
  background: #fafafa;
}

header {
  margin-bottom: 1.5rem;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.subtitle {
  color: #666;
  font-size: 0.875rem;
}

.search-bar {
  position: relative;
  margin-bottom: 0.75rem;
}

.search-bar input[type="search"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input[type="search"]:focus {
  border-color: #333;
}

.htmx-indicator {
  display: none;
  font-size: 0.75rem;
  color: #999;
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.filters {
  margin-bottom: 1rem;
}

.filters summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: #666;
  user-select: none;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.filter-row input {
  flex: 1;
  padding: 0.375rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
}

.toggle-row {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.toggle {
  cursor: pointer;
  user-select: none;
}

.toggle input {
  display: none;
}

.toggle span {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  color: #999;
  background: #fff;
  transition: all 0.15s;
}

.toggle span::after {
  content: " \2717";
  color: #c62828;
  font-weight: 700;
}

.toggle input:checked + span {
  background: #333;
  color: #fff;
  border-color: #333;
}

.toggle input:checked + span::after {
  content: " \2713";
  color: #6fcf6f;
  font-weight: 700;
}

.toggle span:hover {
  border-color: #999;
}

.filter-hint {
  font-size: 0.7rem;
  color: #999;
  margin-top: 0.5rem;
}

.ysws-filter {
  margin-top: 0.5rem;
}

.tag-search {
  display: flex;
  align-items: center;
  margin-bottom: 0.375rem;
  position: relative;
}

.tag-search-input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  font-size: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
  outline: none;
}

.tag-search-input:focus {
  border-color: #999;
}

.tag-search-clear {
  position: absolute;
  right: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #999;
  line-height: 1;
  padding: 0 0.15rem;
}

.tag-search-clear:hover {
  color: #333;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 12rem;
  overflow-y: auto;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0;
  font-size: 0.8rem;
}

.tag-btns {
  display: flex;
  gap: 0.125rem;
  flex-shrink: 0;
}

.tag-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0 0.2rem;
  line-height: 1;
  color: #bbb;
  transition: color 0.1s;
}

.tag-btn:hover { color: #666; }
.btn-plus.active { color: #2e7d32; }
.btn-minus.active { color: #c62828; }
.btn-q.active { color: #999; }

.tag-name {
  color: #555;
}

.tag-count {
  font-size: 0.65rem;
  color: #bbb;
  margin-left: 0.125rem;
}

.tag-row.included .tag-name { color: #2e7d32; }
.tag-row.excluded .tag-name { color: #c62828; text-decoration: line-through; }

.card {
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  background: #fff;
}

.card .desc {
  font-size: 0.875rem;
  line-height: 1.45;
  margin-bottom: 0.375rem;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: #666;
}

.tag {
  background: #eee;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-size: 0.7rem;
}

.hours {
  color: #999;
}

.score {
  font-size: 0.65rem;
  color: #bbb;
  font-family: monospace;
}

.links a {
  color: #0645ad;
  text-decoration: none;
}

.links a::after {
  content: "\2009↗";
  font-size: 0.75em;
}

.links a:hover {
  text-decoration: underline;
}

.search-stats {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 0.5rem;
}

.timing-detail {
  color: #bbb;
  font-size: 0.65rem;
}

.no-results,
.error {
  text-align: center;
  color: #999;
  padding: 2rem 0;
  font-size: 0.875rem;
}

@media (prefers-color-scheme: dark) {
  body {
    color: #e0e0e0;
    background: #1a1a1a;
  }

  .subtitle { color: #999; }

  .search-bar input[type="search"] {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
  }

  .search-bar input[type="search"]:focus {
    border-color: #888;
  }

  .filter-row input {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
  }

  .filters summary { color: #999; }

  .card {
    background: #242424;
    border-color: #333;
  }

  .card-meta { color: #999; }
  .tag { background: #333; color: #ccc; }
  .hours { color: #777; }
  .score { color: #555; }
  .links a { color: #6b9fcf; }
  .no-results, .error { color: #666; }

  .toggle span {
    background: #2a2a2a;
    border-color: #444;
    color: #666;
  }

  .toggle span:hover { border-color: #666; }

  .toggle input:checked + span {
    background: #e0e0e0;
    color: #1a1a1a;
    border-color: #e0e0e0;
  }

  .tag-btn { color: #555; }
  .tag-btn:hover { color: #999; }
  .btn-plus.active { color: #6fcf6f; }
  .btn-minus.active { color: #cf6f6f; }
  .btn-q.active { color: #777; }
  .tag-name { color: #999; }
  .tag-search-input {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
  }
  .tag-search-input:focus { border-color: #666; }
  .tag-search-clear { color: #666; }
  .tag-search-clear:hover { color: #ccc; }
  .tag-count { color: #555; }
  .tag-row.included .tag-name { color: #6fcf6f; }
  .tag-row.excluded .tag-name { color: #cf6f6f; }
}

.usn { user-select: none;}