:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --ink: #e8eaed;
  --muted: #9aa4b2;
  --line: #2a323d;
  --gold: #e0b341;
  --gold-dim: #b8912f;
  --red: #e5534b;
  --green: #4ac07a;
  --blue: #5aa2e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a2230 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0.5px; }
.brand .badge {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(145deg, var(--gold), var(--gold-dim));
  color: #1a1204; box-shadow: 0 2px 10px rgba(224,179,65,0.25);
}
.brand small { display: block; font-weight: 500; color: var(--muted); letter-spacing: 2px; font-size: 10px; }
.nav a { color: var(--muted); margin-left: 18px; font-weight: 600; font-size: 14px; }
.nav a:hover, .nav a.active { color: var(--gold); text-decoration: none; }
.nav .user-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); vertical-align: middle;
}
.nav .user-link:hover { border-color: var(--gold-dim); text-decoration: none; }
.nav .user-link svg { width: 17px; height: 17px; }

.topbar-left { display: flex; align-items: center; gap: 12px; }
.hamburger {
  background: none; border: 1px solid var(--line); border-radius: 9px;
  color: var(--muted); width: 38px; height: 38px;
  display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
}
.hamburger:hover, .hamburger[aria-expanded="true"] { border-color: var(--gold-dim); color: var(--gold); }
.hamburger svg { width: 20px; height: 20px; }

h1 { font-family: Georgia, "Times New Roman", serif; font-size: 30px; margin: 0 0 6px; }
h2 { font-family: Georgia, serif; font-size: 20px; margin: 22px 0 10px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.hero {
  padding: 40px 0 10px;
}
.hero .kicker { color: var(--gold); font-weight: 700; letter-spacing: 3px; font-size: 12px; text-transform: uppercase; }
.hero h1 { font-size: 40px; max-width: 18ch; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--gold-dim); }
.card h3 { margin: 8px 0 6px; font-family: Georgia, serif; font-size: 19px; }
.card p { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

.tag {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.tag.murder { color: #f2a3a0; border-color: #5a2b2b; background: #2a1717; }
.tag.theft, .tag.heist, .tag.smuggling, .tag.burglary { color: #9fd0f5; border-color: #274a63; background: #14212c; }
.tag.fraud, .tag.bribery, .tag.espionage { color: #f2d59a; border-color: #5a4a20; background: #262010; }
.tag.mystery { color: #c9b3f5; border-color: #3d3363; background: #1c1830; }
.tag.household { color: #a7e6c8; border-color: #245536; background: #12261a; }
.tag.cyber, .tag.sabotage { color: #8fe6e0; border-color: #1f5a55; background: #0f2624; }
.tag.arson { color: #f3b28a; border-color: #63431f; background: #26180f; }
.tag.sports, .tag.school { color: #d7c9a0; border-color: #4a4020; background: #201d10; }
.tag.difficulty { color: var(--muted); }
.tag.solved { color: #a7e6c8; border-color: #2f7a4a; background: #12261a; }
.tag.inprogress { color: #9fd0f5; border-color: #274a63; background: #14212c; }

.chip {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700;
  cursor: pointer; text-transform: capitalize;
}
.chip:hover { border-color: var(--gold-dim); color: var(--ink); }
.chip.on { background: var(--gold); color: #1a1204; border-color: var(--gold); }

.layout { display: flex; gap: 26px; align-items: flex-start; }
.sidebar { width: 232px; flex-shrink: 0; position: sticky; top: 74px; display: none; }
.sidebar.open { display: block; }
.main { flex: 1; min-width: 0; }
.side-item, .side-cat {
  display: flex; justify-content: space-between; width: 100%; text-align: left;
  background: none; border: none; color: var(--muted); padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14px; text-transform: capitalize;
}
.side-item:hover, .side-cat:hover { background: var(--panel); color: var(--ink); }
.side-item.on, .side-cat.on { background: var(--gold); color: #1a1204; font-weight: 700; }
.side-item .n, .side-cat .n { opacity: 0.7; font-variant-numeric: tabular-nums; }
.side-group { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.side-head {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: none; border: none; color: var(--ink); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.8px; padding: 4px 10px 8px; cursor: pointer;
}
.side-head .caret { transition: transform 0.15s; color: var(--gold); }
.side-head.collapsed .caret { transform: rotate(-90deg); }
.side-list.collapsed { display: none; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
}

.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: linear-gradient(145deg, var(--gold), var(--gold-dim));
  color: #1a1204; border: none; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; font-size: 14px;
  min-height: 42px;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold-dim); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid #5a2b2b; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; margin-bottom: 16px;
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input, textarea, select {
  width: 100%; background: #0d1117; color: var(--ink);
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-dim); }
textarea { resize: vertical; }
.mono, textarea.sql { font-family: "SF Mono", "Consolas", "Courier New", monospace; font-size: 13px; }

.editor { background: #0a0d12; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.editor textarea { background: #0a0d12; border: none; min-height: 120px; }
.editor .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }

table.results { width: 100%; border-collapse: collapse; font-size: 13px; }
table.results th, table.results td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line);
  font-family: "SF Mono", "Consolas", monospace;
}
table.results th { color: var(--gold); border-bottom: 1px solid var(--gold-dim); position: sticky; top: 0; background: var(--panel); }
.results-wrap { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }

.note { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 10px 0; }
.note.ok { background: #12261a; border: 1px solid #245536; color: #b7e6c8; }
.note.err { background: #2a1414; border: 1px solid #5a2b2b; color: #f2b3af; }
.note.info { background: #141d2a; border: 1px solid #274155; color: #aecde8; }

.hint-list { list-style: none; padding: 0; margin: 0; }
.hint-list li { margin-bottom: 8px; }
.hint-list summary { cursor: pointer; color: var(--gold); font-weight: 600; }
.hint-body { color: var(--muted); padding: 6px 0 0 14px; font-size: 14px; }

.schema-table { margin-bottom: 10px; }
.schema-table .tname { color: var(--gold); font-weight: 700; font-family: monospace; }
.schema-table .cols { color: var(--muted); font-family: monospace; font-size: 12px; }

.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 0 30px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 14px; font-weight: 700; font-size: 14px; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) {
  .row-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
  .split { grid-template-columns: 1fr !important; }
}

.split { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
