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

:root {
  --bg: #0b0d12;
  --bg2: #11141c;
  --bg3: #181c28;
  --bg4: #1f2333;
  --border: #262b3b;
  --border-strong: #353a52;
  --text: #e6e8f2;
  --text2: #8b90a8;
  --text3: #5a5f75;
  --accent: #6c8aff;
  --accent2: #4a6bff;
  --green: #3dd68c;
  --yellow: #ffca62;
  --orange: #ff8c5a;
  --red: #f06292;
  --arch-vector: #4a8bff;
  --arch-graph: #b48eff;
  --arch-kv: #ffca62;
  --arch-episodic: #4ad4c4;
  --arch-hybrid: #ff7eae;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* TOP BAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 100%);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent2), var(--arch-hybrid));
  color: white;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 18px;
  box-shadow: 0 0 24px rgba(108, 138, 255, 0.25);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* CONTAINER */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* STATS */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-num {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); margin-top: 2px; }

/* FILTER BAR */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-grow { flex: 1 1 220px; }
.filter-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  font-weight: 600;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }

select, input[type="text"], input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  min-width: 120px;
  transition: border-color 0.15s;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); }

.chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip-toggle.active {
  background: var(--bg4);
  border-color: var(--accent);
  color: var(--text);
}
.chip-toggle[data-arch="vector"].active { box-shadow: inset 0 0 0 1px var(--arch-vector); }
.chip-toggle[data-arch="graph"].active { box-shadow: inset 0 0 0 1px var(--arch-graph); }
.chip-toggle[data-arch="kv"].active { box-shadow: inset 0 0 0 1px var(--arch-kv); }
.chip-toggle[data-arch="episodic"].active { box-shadow: inset 0 0 0 1px var(--arch-episodic); }
.chip-toggle[data-arch="hybrid"].active { box-shadow: inset 0 0 0 1px var(--arch-hybrid); }

.arch-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(108, 138, 255, 0.1);
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
  text-transform: lowercase;
}
.arch-vector { background: rgba(74, 139, 255, 0.13); color: var(--arch-vector); }
.arch-graph { background: rgba(180, 142, 255, 0.13); color: var(--arch-graph); }
.arch-kv { background: rgba(255, 202, 98, 0.13); color: var(--arch-kv); }
.arch-episodic { background: rgba(74, 212, 196, 0.13); color: var(--arch-episodic); }
.arch-hybrid { background: rgba(255, 126, 174, 0.14); color: var(--arch-hybrid); }

/* GRID */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.grid thead th {
  background: var(--bg3);
  color: var(--text3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.col-num { text-align: right !important; font-family: var(--mono); }
.grid tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.grid tbody tr { cursor: pointer; transition: background 0.1s; }
.grid tbody tr:hover { background: var(--bg3); }
.grid tbody tr:last-child td { border-bottom: 0; }

.name-cell { display: flex; flex-direction: column; gap: 4px; }
.name-row { display: flex; align-items: center; gap: 10px; }
.name-text { font-weight: 600; }
.name-tagline { font-size: 12px; color: var(--text2); }
.num-cell { font-family: var(--mono); text-align: right; }
.dim { color: var(--text3); }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 7px;
  vertical-align: middle;
}
.badge-active { background: rgba(61, 214, 140, 0.13); color: var(--green); }
.badge-slow { background: rgba(255, 202, 98, 0.13); color: var(--yellow); }
.badge-stale { background: rgba(240, 98, 146, 0.13); color: var(--red); }
.badge-unknown { background: rgba(139, 144, 168, 0.13); color: var(--text2); }

.empty {
  text-align: center;
  color: var(--text2);
  padding: 40px 16px !important;
  font-size: 13px;
}

/* PILL / BUTTON */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 999px;
  font-family: var(--mono);
}
.pill-muted { color: var(--text3); }
.pill strong { color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg4); border-color: var(--border-strong); }
.btn-primary { background: linear-gradient(135deg, var(--accent2), var(--accent)); border-color: transparent; color: white; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-icon { background: transparent; border: 0; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.btn-icon:hover { color: var(--text); }

/* FOOTER */
.footer {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--text3);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

/* DETAIL PANEL */
.detail-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(480px, 92vw);
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 80;
  box-shadow: -20px 0 60px rgba(0,0,0,0.4);
}
.detail-panel.open { transform: translateX(0); }
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 70;
  backdrop-filter: blur(2px);
}
.detail-inner { padding: 22px 24px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.detail-name { font-size: 20px; font-weight: 700; }
.detail-tagline { color: var(--text2); margin-bottom: 18px; }
.detail-section { border-top: 1px solid var(--border); padding: 16px 0; }
.detail-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  margin-bottom: 8px;
  font-weight: 700;
}
.vitals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 18px;
}
.vital-row { display: flex; justify-content: space-between; }
.vital-label { color: var(--text3); font-size: 12px; }
.vital-value { font-family: var(--mono); font-size: 12.5px; color: var(--text); }

.sparkline { width: 100%; height: 60px; }

.link-row { display: flex; gap: 10px; flex-wrap: wrap; }
.link-row a {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.link-row a:hover { background: var(--bg4); text-decoration: none; }

/* QUIZ OVERLAY */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: grid; place-items: center;
  z-index: 90;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.55);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-sub { color: var(--text3); font-size: 11.5px; margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }
.modal-body { padding: 22px; min-height: 260px; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  gap: 12px;
}
.dots { display: flex; gap: 6px; flex: 1; justify-content: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bg4); }
.dot.active { background: var(--accent); }
.dot.done { background: var(--green); }

.question { font-size: 17px; font-weight: 600; margin-bottom: 14px; line-height: 1.4; }
.q-hint { color: var(--text2); font-size: 13px; margin-bottom: 18px; }
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt-list label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.12s;
}
.opt-list label:hover { background: var(--bg4); border-color: var(--border-strong); }
.opt-list input[type=radio] { accent-color: var(--accent); }
.opt-list label.selected { background: var(--bg4); border-color: var(--accent); }
.opt-text { flex: 1; font-size: 14px; }
.opt-sub { font-size: 12px; color: var(--text3); }

/* RECOMMENDATION RESULT */
.result-head { text-align: center; margin-bottom: 16px; }
.result-title { font-size: 18px; font-weight: 700; }
.result-sub { color: var(--text2); font-size: 13px; margin-top: 4px; }
.reco-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  transition: border-color 0.15s;
  text-decoration: none;
  color: inherit;
}
.reco-card:hover { border-color: var(--accent); text-decoration: none; }
.rank-1 { border-color: rgba(108, 138, 255, 0.4); }
.rank { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--accent); width: 36px; }
.reco-body { flex: 1; }
.reco-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.reco-reason { font-size: 12.5px; color: var(--text2); margin-bottom: 6px; line-height: 1.45; }
.reco-meta { font-family: var(--mono); font-size: 11px; color: var(--text3); }

.share-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.share-link {
  flex: 1 1 200px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .brand-sub { display: none; }
  .container { padding: 16px; }
  .grid { font-size: 12.5px; }
  .grid thead th, .grid tbody td { padding: 9px 10px; }
  .name-tagline { display: none; }
}
