:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --accent: #0f62fe;
  --accent-weak: #eaf1ff;
  --clean: #0f62fe;
  --playful: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
}

header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
header h1 { font-size: 18px; margin: 0 0 2px 0; }
header .sub { margin: 0; color: var(--muted); font-size: 12px; }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: var(--accent-weak); color: var(--accent); border-color: var(--accent); }
.count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  border-radius: 10px;
  background: var(--border);
  color: var(--text);
  font-weight: 600;
}
.tab.active .count { background: var(--accent); color: white; }

.header-actions { display: flex; gap: 8px; }
.btn {
  padding: 8px 14px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
}
.btn:hover { background: var(--bg); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-small { padding: 6px 10px; font-size: 12px; }

main {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  min-height: calc(100vh - 63px);
}

.sidebar {
  padding: 20px 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 63px;
  align-self: start;
  max-height: calc(100vh - 63px);
  overflow-y: auto;
}
.search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
}
.filter-group { margin-top: 22px; }
.filter-group h3 {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 10px 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.filter-item input { cursor: pointer; }
.filter-item.nested { padding-left: 20px; font-size: 12px; color: var(--muted); }
.filter-item .fcount { margin-left: auto; color: var(--muted); font-size: 11px; }
#clear-filters { margin-top: 20px; }

.grid-wrap { padding: 20px 24px 60px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: opacity 0.15s ease, filter 0.15s ease;
  position: relative;
}
.card.dismissed {
  opacity: 0.45;
  filter: grayscale(100%);
}
.card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.card-img-wrap {
  background: var(--bg);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card-name { font-size: 13px; font-weight: 600; line-height: 1.3; margin: 0; }
.card-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.card-price { font-weight: 600; color: var(--text); }

.card-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.opt input[type=checkbox] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}
.opt.playful input { accent-color: var(--playful); }
.opt .tag {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--clean);
}
.opt.playful .tag { background: var(--playful); }

.card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 6px 10px 10px;
}
.dismiss-btn, .restore-btn {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  color: var(--muted);
}
.dismiss-btn:hover { background: var(--danger); color: white; border-color: var(--danger); }
.restore-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Dismissed cards: the interactive controls still need to be usable */
.card.dismissed .card-options,
.card.dismissed .card-actions { filter: none; opacity: 1; }

/* Landing */
[hidden] { display: none !important; }
#landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}
.landing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  box-shadow: var(--shadow);
  max-width: 480px;
  width: 100%;
}
.landing-card h1 { margin: 0 0 8px; font-size: 22px; }
.landing-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; line-height: 1.5; }
.landing-actions { display: flex; flex-direction: column; gap: 16px; }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); padding: 10px 18px; }
.btn-primary:hover { background: #0b4fc9; }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
#landing details summary { cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
#landing details summary:hover { color: var(--text); }
#resume-form { display: flex; gap: 8px; margin-top: 10px; }
#resume-form input { flex: 1; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 13px; }
.landing-footer { margin-top: 16px; color: var(--danger); font-size: 13px; }

/* Session chip in header */
#session-id-display {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, Menlo, monospace;
}
.save-status { font-size: 12px; color: var(--muted); }
.save-status.pending { color: #ca8a04; }
.save-status.error { color: var(--danger); }

/* Responsive */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--border); }
  header { grid-template-columns: 1fr; gap: 10px; }
  .tabs { overflow-x: auto; }
}
