:root {
  color-scheme: dark;
  --bg: #0c0e10;
  --panel: #14171b;
  --panel-2: #191d22;
  --line: #262c33;
  --text: #d8dee5;
  --title: #f2f5f7;
  --muted: #7d8894;
  --accent: #7ef29a;
  --on-accent: #08110b;
  --accent-soft: rgba(126, 242, 154, 0.08);
  --deny-soft: rgba(248, 113, 113, 0.1);
  --allow: #4ade80;
  --ask: #fbbf24;
  --deny: #f87171;
  --scanline: rgba(255, 255, 255, 0.015);
  --glow:
    radial-gradient(1200px 500px at 70% -10%, rgba(126, 242, 154, 0.06), transparent 60%),
    radial-gradient(800px 400px at 10% 0%, rgba(251, 191, 36, 0.04), transparent 60%);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --display: "Bricolage Grotesque", var(--mono);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #eceff2;
  --line: #d6dce2;
  --text: #22303c;
  --title: #101a24;
  --muted: #5d6b78;
  --accent: #0a7a46;
  --on-accent: #ffffff;
  --accent-soft: rgba(10, 122, 70, 0.08);
  --deny-soft: rgba(220, 38, 38, 0.08);
  --allow: #15803d;
  --ask: #b45309;
  --deny: #dc2626;
  --scanline: rgba(0, 0, 0, 0.02);
  --glow:
    radial-gradient(1200px 500px at 70% -10%, rgba(12, 143, 82, 0.05), transparent 60%),
    radial-gradient(800px 400px at 10% 0%, rgba(180, 83, 9, 0.04), transparent 60%);
}

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

html { scrollbar-gutter: stable both-edges; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  background-image: var(--glow);
}

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(0deg, var(--scanline) 0 1px, transparent 1px 3px);
}

code { color: var(--accent); }
em { font-style: normal; color: var(--ask); }
a { color: var(--accent); }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); position: relative; }
.header-actions {
  position: absolute; top: 20px; right: 24px; z-index: 2;
  display: flex; gap: 8px;
}
.header-actions .btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.gh-icon { flex-shrink: 0; }
.site-footer .stats { margin-bottom: 8px; color: var(--accent); }
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 56px 24px 36px;
  text-align: center;
}
.kicker {
  color: var(--accent); letter-spacing: 0.35em; font-size: 11px;
  margin-bottom: 14px;
}
h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--title);
  animation: rise 0.5s ease both;
}
.tagline {
  margin: 16px auto 0; color: var(--muted); max-width: 60ch;
  text-wrap: balance; /* even out the two centred lines instead of a lopsided wrap */
  animation: rise 0.5s 0.08s ease both;
}
.legend {
  margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap;
  justify-content: center; animation: rise 0.5s 0.16s ease both;
}
.chip {
  font-size: 11px; padding: 4px 10px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted);
}
.chip::before { content: "●"; margin-right: 6px; }
.chip-allow::before { color: var(--allow); }
.chip-visits { color: var(--accent); border-color: var(--accent); }
.chip-visits::before { color: var(--accent); }
.chip-ask::before { color: var(--ask); }
.chip-deny::before { color: var(--deny); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- layout ---------- */
.layout {
  max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px;
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2);
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: 12px; letter-spacing: 0.2em; color: var(--muted); font-weight: 600;
}

/* ---------- tagbar (search + selected tags) ---------- */
.tagbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  max-width: 720px; margin: 28px auto 0; padding: 14px 18px; cursor: text;
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--accent); border-radius: 12px;
  box-shadow: 0 0 24px var(--accent-soft);
  transition: box-shadow 0.15s;
  animation: rise 0.5s 0.24s ease both;
}
.tagbar:focus-within { box-shadow: 0 0 0 3px var(--accent-soft), 0 0 32px var(--accent-soft); }
.selected-tags {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  max-width: 720px; margin: 12px auto 0;
  animation: rise 0.5s 0.3s ease both;
}
.selected-tags:empty { display: none; }

/* ---------- autocomplete dropdown ---------- */
.suggest {
  position: absolute; top: calc(100% + 8px); left: -2px; right: -2px; z-index: 10;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  max-height: 320px; overflow-y: auto; text-align: left;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}
.suggest-item {
  display: block;
  padding: 10px 16px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item .s-top { display: flex; align-items: baseline; gap: 10px; }
.suggest-item .s-desc {
  display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest-item .hit {
  font-style: normal; color: var(--accent);
  background: var(--accent-soft); border-radius: 2px;
}
.suggest-item .s-name { font-weight: 600; }
.suggest-item .s-cat { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; }
.suggest-item .s-counts { margin-left: auto; font-size: 11px; white-space: nowrap; }
.suggest-item .s-counts .a { color: var(--allow); }
.suggest-item .s-counts .q { color: var(--ask); }
.suggest-item .s-counts .d { color: var(--deny); }
.suggest-item.active { background: var(--accent-soft); }
.suggest-item.active .s-name { color: var(--accent); }
.suggest-item.active .s-name::after { content: " ↵"; color: var(--accent); }
#search {
  flex: 1 1 160px; min-width: 140px;
  background: transparent; border: none; outline: none;
  color: var(--text); font-family: var(--mono); font-size: 14px;
  padding: 4px 2px;
}
.tag {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 3px 10px;
}
.tag .x { color: var(--muted); font-size: 13px; }
.tag:hover { background: var(--deny-soft); border-color: var(--deny); color: var(--deny); }
.tag:hover .x { color: var(--deny); }
.tag-more {
  font-family: var(--mono); font-size: 12px; color: var(--muted); cursor: pointer;
  background: transparent; border: 1px dashed var(--line); border-radius: 999px;
  padding: 3px 10px;
}
.tag-more:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- modules ---------- */
.module-list { padding: 12px; max-height: 70vh; overflow-y: auto; }
.loading { color: var(--muted); padding: 12px; }

.category { margin-bottom: 14px; }
.category-head { display: flex; align-items: center; justify-content: space-between; }
.category-toggle {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em;
  background: transparent; border: 1px dashed var(--line); border-radius: 4px;
  color: var(--muted); cursor: pointer; padding: 2px 8px;
}
.category-toggle:hover { border-color: var(--accent); color: var(--accent); }
.category-name {
  font-size: 14px; font-weight: 600; letter-spacing: 0.25em; color: var(--text);
  padding: 8px 4px; text-transform: uppercase; cursor: pointer;
  background: none; border: none; font-family: var(--mono);
}
.category-name::before { content: "▾ "; color: var(--accent); }
.category-name:hover { color: var(--text); }
.cat-count { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0.05em; margin-left: 4px; }
.cat-count.has-sel { color: var(--accent); }
.category.collapsed .category-name::before { content: "▸ "; }
.category.collapsed .module { display: none; }

.module {
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font-family: var(--mono);
  padding: 10px 12px; margin-bottom: 8px;
  display: block; transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.module:hover { border-color: var(--muted); transform: translateX(2px); }
.module.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.module-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.module-name { font-weight: 600; font-size: 14px; }
.module.selected .module-name::before { content: "[x] "; color: var(--accent); }
.module-name::before { content: "[ ] "; color: var(--muted); }
.module-counts { font-size: 11px; white-space: nowrap; }
.module-counts .a { color: var(--allow); }
.module-counts .q { color: var(--ask); }
.module-counts .d { color: var(--deny); }
.module-desc { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- output ---------- */
.output-panel { position: sticky; top: 16px; }
.actions { display: flex; gap: 8px; }
.actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.actions .btn .i { width: 12px; height: 12px; flex-shrink: 0; }
/* action buttons drop to their own line under the panel heading */
.panel-head .actions { flex-basis: 100%; }
/* freeze copy/link width: an invisible zero-height copy of the longest label reserves its exact width */
#copy .lbl, #copy-link .lbl { display: inline-flex; flex-direction: column; align-items: center; }
#copy .lbl::after, #copy-link .lbl::after { content: "COPIED ✓"; height: 0; overflow: hidden; visibility: hidden; }
/* success feedback: accent colour while the "COPIED ✓" flash is showing */
.btn.copied { border-color: var(--accent); color: var(--accent); }
.btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em;
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-ghost { border-style: dashed; color: var(--muted); }

.counts { display: flex; gap: 14px; padding: 10px 16px 0; font-size: 12px; color: var(--muted); }
.counts .a { color: var(--allow); }
.counts .q { color: var(--ask); }
.counts .d { color: var(--deny); }

.output {
  margin: 12px 16px; padding: 14px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line);
  overflow: auto; max-height: 56vh;
  font-size: 12.5px; line-height: 1.6;
}
.output .k-allow { color: var(--allow); font-weight: 600; }
.output .k-ask { color: var(--ask); font-weight: 600; }
.output .k-deny { color: var(--deny); font-weight: 600; }

.hint { padding: 0 16px 16px; color: var(--muted); font-size: 12px; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 24px; text-align: center; color: var(--muted); font-size: 12px;
}
