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

:root {
  --bg: #0f0f13;
  --surface: #1a1a22;
  --surface2: #22222e;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --text-muted: #7a7a96;
  --accent: #7c6af7;
  --accent-hover: #9585ff;
  --danger: #e05252;
  --star-on: #f5c842;
  --star-off: #3a3a50;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 0.75rem; }

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.count-badge {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.header-right { display: flex; align-items: center; gap: 1rem; }

.job-status {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 500;
}
.job-status.idle    { background: var(--surface2); color: var(--text-muted); }
.job-status.running { background: #2a2a10; color: #e6c84a; }
.job-status.done    { background: #0e2a1a; color: #4ecb71; }
.job-status.error   { background: #2a0e0e; color: var(--danger); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.875rem 2rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-row {
  display: contents;
}

.filter-group { display: flex; align-items: center; gap: 0.4rem; }
.filter-group--dropdowns { gap: 0.3rem; }

.search-input {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font);
  outline: none;
  width: 200px;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.filter-group--sort { margin-left: auto; }

.sort-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.score-dropdown-menu {
  min-width: 200px;
  padding: 0.75rem 1rem;
}

.score-slider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.score-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  border: 1px solid var(--border);
  outline: none;
  cursor: pointer;
  transition: background 0.15s;
}
.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  border: none;
}
.score-slider:hover::-webkit-slider-thumb,
.score-slider:focus::-webkit-slider-thumb {
  background: var(--accent);
  transform: scale(1.2);
}

.score-range-val {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 2.5rem;
  font-variant-numeric: tabular-nums;
}
.score-range-val--active { color: var(--accent); font-weight: 600; }

.filter-btn {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Clear filters button ── */
.btn-clear-filters {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-clear-filters:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ── Back link ── */
.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

/* ── Settings page ── */
.settings-body {
  max-width: 600px;
  margin: 2rem auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.settings-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.sources-list { display: flex; flex-direction: column; gap: 0.75rem; }

.source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  transition: border-color 0.15s;
}
.source-card:hover { border-color: #3e3e5a; }
.source-card-left { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.source-card-top { display: flex; align-items: center; gap: 0.65rem; }
.source-name {
  font-weight: 700;
  font-size: 1.15rem;
  text-transform: capitalize;
}

.btn-update-all {
  width: 100%;
  padding: 0.75rem;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn-update-all:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.btn-update-all:disabled { opacity: 0.4; cursor: not-allowed; }
.source-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.source-last-run {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.run-label {
  font-weight: 600;
  color: #6e6e90;
  margin-right: 0.2rem;
}
.source-never { font-style: italic; color: #4a4a66; }
.source-run-stats { display: flex; gap: 0.5rem; }
.stat-chip {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}
.stat-new { background: #0e2a1a; color: #4ecb71; }
.stat-updated { background: #1a1a2e; color: #9d94ff; }
.source-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.1rem; }
.source-update-btn { white-space: nowrap; flex-shrink: 0; }

.log-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.log-row {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.log-row:last-child { border-bottom: none; }
.log-source { font-weight: 600; color: var(--text); min-width: 130px; }
.log-detail { color: var(--text-muted); }
.log-row--error .log-source { color: var(--danger); }

/* ── Category dropdown ── */
.cat-dropdown { position: relative; }

.cat-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cat-dropdown-btn:hover,
.cat-dropdown-btn.open { border-color: var(--accent); color: var(--text); }
.cat-dropdown-btn.has-filter {
  border-color: var(--accent);
  background: rgba(124, 106, 247, 0.15);
  color: var(--accent);
}
.cat-dropdown-btn.open .cat-dropdown-arrow { transform: rotate(180deg); }
.cat-dropdown-arrow { font-size: 0.65rem; transition: transform 0.15s; }

.cat-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem;
  z-index: 200;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.cat-dropdown-menu.open { display: block; }

.cat-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  user-select: none;
}
.cat-dropdown-item:hover { background: var(--surface2); color: var(--text); }
.cat-dropdown-item input[type=checkbox] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.cat-dropdown-item:has(input:checked) { color: var(--text); }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}
.toggle-label input { cursor: pointer; accent-color: var(--accent); }

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem 2rem;
}

.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 4rem;
  font-size: 0.95rem;
}

/* ── Activity card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }


.card-img-link {
  display: block;
  line-height: 0;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--surface2);
  display: block;
}
.card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}

.category-badges {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: calc(100% - 2.5rem);
}
.category-badge {
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.category-badge--more {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
}

.delete-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.6);
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  backdrop-filter: blur(4px);
  transition: color 0.15s, background 0.15s;
}
.delete-btn:hover { color: var(--danger); background: rgba(0,0,0,0.85); }

.bookmark-btn {
  position: absolute;
  top: 0.5rem;
  right: 2.25rem;
  background: rgba(0,0,0,0.6);
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  backdrop-filter: blur(4px);
  transition: background 0.15s, transform 0.1s;
  filter: grayscale(1) opacity(0.5);
}
.bookmark-btn:hover { filter: none; background: rgba(0,0,0,0.85); transform: scale(1.1); }
.bookmark-btn--active { filter: none; color: var(--text); }

/* ── Bookmark popover ── */
.bookmark-popover {
  position: fixed;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  min-width: 200px;
  max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.bookmark-popover-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem 0.4rem;
}
.bookmark-popover-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-muted);
  transition: background 0.1s, color 0.1s;
  user-select: none;
}
.bookmark-popover-item:hover { background: var(--surface2); color: var(--text); }
.bookmark-popover-item input[type=checkbox] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.bookmark-popover-item:has(input:checked) { color: var(--text); }
.bookmark-popover-divider {
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}
.bookmark-popover-new input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.84rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.bookmark-popover-new input:focus { border-color: var(--accent); }
.bookmark-popover-new input::placeholder { color: var(--text-muted); }

/* ── Lists dropdown ── */
.lists-dropdown-item {
  display: flex;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: background 0.1s;
}
.lists-dropdown-item:hover { background: var(--surface2); }
.lists-dropdown-item label { font-size: 0.82rem; color: var(--text-muted); }
.lists-dropdown-item:has(input:checked) label { color: var(--text); }
.lists-dropdown-item input[type=checkbox] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.list-count-chip {
  font-size: 0.68rem;
  background: var(--surface2);
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: auto;
}
.list-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}
.lists-dropdown-item:hover .list-delete-btn { opacity: 1; }
.list-delete-btn:hover { color: var(--danger); }

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

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
}
.card-meta a { color: inherit; text-decoration: underline dotted; }
.card-meta a:hover { color: var(--accent); }
.map-link { font-size: 0.72rem; color: var(--text-muted); text-decoration: none; opacity: 0.7; }
.map-link:hover { opacity: 1; color: var(--accent); }

.neighborhood-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #1a2a1a;
  color: #6ecf8a;
  border: 1px solid #2a4a2a;
  white-space: nowrap;
}

.card-date {
  font-size: 0.8rem;
  color: #9d94ff;
  font-weight: 500;
}

.card-price {
  font-size: 0.8rem;
  color: #4ecb71;
  font-weight: 500;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  margin-top: 0.6rem;
}
.card-footer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
}
.source-favicon {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  object-fit: contain;
}
.source-favicon-chip {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  object-fit: contain;
  opacity: 0.85;
}

.stars {
  display: flex;
  gap: 0.15rem;
}
.star {
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--star-off);
  transition: color 0.1s, transform 0.1s;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}
.star:hover, .star.on { color: var(--star-on); }
.star:hover { transform: scale(1.2); }

.source-link {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s;
  white-space: nowrap;
}
.source-link:hover { border-color: var(--accent); color: var(--accent); }

/* ── Weekday chips ── */
.weekday-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.1rem;
}
.weekday-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: #1e1e30;
  color: #a09ae0;
  border: 1px solid #2e2e50;
  text-transform: capitalize;
}
.chip-all {
  background: #1e1e30;
  color: #a09ae0;
  border-color: #2e2e50;
}

/* ── Week/month tags ── */
.time-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}
.tag-week  { background: #1e2a3a; color: #6bbfff; }
.tag-month { background: #1e2a28; color: #4ecb71; }

/* Sign-out. Deliberately quiet: it sits next to the primary action in the header and
   should never be the thing your eye lands on first. */
.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.logout-link:hover { color: var(--text); background: var(--surface2); }
