/* ── Colour tokens ───────────────────────────────────────────── */
:root {
  --bg:                #ffffff;
  --surface:           #fafafa;
  --border:            #eeeeee;
  --border-card:       #dddddd;
  --text:              #222222;
  --text-dim:          #555555;
  --text-counts:       #444444;
  --header-bg:         #ffffff;
  --img-bg:            #f3f3f3;
  --card-owned-bg:     #e9ffe9;
  --card-owned-border: #77cc77;
  --sidebar-a:         #333333;
}

body.dark {
  --bg:                #1a1a1a;
  --surface:           #242424;
  --border:            #333333;
  --border-card:       #3a3a3a;
  --text:              #e0e0e0;
  --text-dim:          #999999;
  --text-counts:       #bbbbbb;
  --header-bg:         #1a1a1a;
  --img-bg:            #2a2a2a;
  --card-owned-bg:     #1a3320;
  --card-owned-border: #4a8a4a;
  --sidebar-a:         #cccccc;
}

/* ── Base layout ─────────────────────────────────────────────── */
body {
  font-family: system-ui, Arial, sans-serif;
  margin: 16px;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Sticky header with counts and filter buttons */
.sticky-header {
  position: sticky;
  top: 0;
  background: var(--header-bg);
  padding: 8px 0;
  z-index: 20;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.header-controls {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
}
.header-controls .counts {
  color: var(--text-counts);
  font-size: 14px;
}
.header-controls .filters button {
  padding: 6px 10px;
  font-size: 13px;
}
.header-controls .filters button.active {
  background: #77cc77;
  color: #fff;
  border-radius: 6px;
}

.header-controls .export button {
  background: #2b7be4;
  color: #fff;
  border-radius: 6px;
  padding: 6px 10px;
}

.header-controls .export button#copyBtn {
  background: #2b7be4;
  margin-left: 6px;
}

/* Dark mode toggle button */
#darkToggle {
  background: none;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
  line-height: 1;
  margin-top: 0;
}
#darkToggle:hover { border-color: var(--text-dim); }

/* ── Layout for sidebar + main content ───────────────────────── */
.layout {
  display: flex;
  gap: 16px;
}
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  border-right: 1px solid var(--border);
  padding: 12px;
  background: var(--surface);
}
.sidebar.collapsed {
  display: none;
}
.sidebar h3 { margin: 0 0 8px 0; font-size: 14px; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 3px 0; }
.sidebar a { color: var(--sidebar-a); text-decoration: none; font-size: 13px; display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.sidebar a:hover { text-decoration: underline; }
.sidebar a.current-set { font-weight: 700; }
.sidebar details { margin-bottom: 2px; }
.sidebar details summary {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 0;
  list-style: none;
  user-select: none;
}
.sidebar details summary::-webkit-details-marker { display: none; }
.sidebar details summary::before { content: '▶ '; font-size: 9px; }
.sidebar details[open] summary::before { content: '▼ '; }
.sidebar details ul { padding-left: 8px; margin: 2px 0 6px; }
.set-count { font-size: 11px; color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.main { flex: 1 1 auto; }

/* Make sure sticky header spans full width */
.sticky-header { padding-left: 12px; padding-right: 12px; }

#status {
  margin: 10px 0;
  color: var(--text-dim);
}

/* ── Grid layout ─────────────────────────────────────────────── */
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

@media (min-width: 1400px) {
  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ── Card styling ────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border-card);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg);
}

.card.owned {
  background: var(--card-owned-bg);
  border-color: var(--card-owned-border);
}

.card img {
  width: 80px;
  height: 110px;
  object-fit: contain;
  background: var(--img-bg);
}

.meta {
  flex: 1 1 auto;
  min-width: 0;
}

.name {
  font-weight: 700;
  margin-bottom: 6px;
}

.small {
  font-size: 12px;
  color: var(--text-dim);
}

button {
  padding: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
