* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  margin: 0;
  padding: 0 24px 48px;
}
header { padding: 24px 0 8px; border-bottom: 1px solid #1e293b; }
h1 { margin: 0; font-size: 20px; font-weight: 600; }
.subtitle { margin: 4px 0 0; color: #64748b; font-size: 12px; }
h2 { font-size: 13px; text-transform: uppercase; color: #94a3b8; letter-spacing: 0.06em; margin: 24px 0 10px; }
main { max-width: 1100px; margin: 0 auto; }

.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input {
  flex: 1; padding: 8px 10px; background: #1e293b; border: 1px solid #334155;
  color: #f1f5f9; border-radius: 4px; font-size: 13px;
}
.search-row button {
  padding: 8px 14px; background: #334155; color: #f1f5f9; border: 1px solid #475569;
  border-radius: 4px; cursor: pointer; font-size: 12px;
}
.search-row button:hover { background: #475569; }

#search-results {
  list-style: none; padding: 0; margin: 0 0 12px;
  max-height: 200px; overflow: auto;
  border: 1px solid #1e293b; border-radius: 4px;
}
#search-results:empty { border: none; }
#search-results li {
  padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #1e293b;
  display: grid; grid-template-columns: 1fr 2fr 150px; gap: 12px;
  font-size: 12px; align-items: center;
}
#search-results li:hover { background: #1e293b; }
#search-results li.empty { color: #64748b; cursor: default; }
#search-results .slug { color: #60a5fa; font-family: ui-monospace, monospace; }
#search-results .question { color: #cbd5e1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search-results .end { color: #64748b; font-family: ui-monospace, monospace; font-size: 11px; }

form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; align-items: end; }
form label { display: flex; flex-direction: column; font-size: 12px; color: #94a3b8; }
form label.wide { grid-column: 1 / -1; }
form label.checkbox { flex-direction: row; align-items: center; gap: 8px; color: #e2e8f0; font-size: 13px; }
form input[type="text"], form input[type="number"] {
  margin-top: 4px; padding: 8px 10px; background: #1e293b; border: 1px solid #334155;
  color: #f1f5f9; border-radius: 4px; font-size: 13px;
}
button[type="submit"] {
  grid-column: 1 / -1;
  padding: 10px 16px; background: #3b82f6; color: white; border: none;
  border-radius: 4px; font-weight: 600; cursor: pointer;
}
button[type="submit"]:hover { background: #2563eb; }
button[type="submit"]:disabled { background: #475569; cursor: not-allowed; }

#status { margin-top: 12px; font-size: 13px; color: #f59e0b; min-height: 18px; }

#summary, #advice {
  background: #1e293b; padding: 16px; border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px;
  white-space: pre-wrap; line-height: 1.5;
}

.legend { display: flex; gap: 8px; margin-bottom: 12px; }
.legend .layer { padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }

.layer.data    { background: #1e3a8a; color: #bfdbfe; }
.layer.feature { background: #064e3b; color: #a7f3d0; }
.layer.skill   { background: #78350f; color: #fed7aa; }
.layer.judge   { background: #581c87; color: #e9d5ff; }
.layer.policy  { background: #7f1d1d; color: #fecaca; }

#tree { font-size: 13px; }
.node { margin-left: 16px; border-left: 1px dashed #334155; padding-left: 12px; }
.node-row {
  display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer;
}
.node-row:hover { background: #1e293b; }
.toggle {
  display: inline-block; width: 12px; color: #64748b; font-family: monospace;
}
.node-label { color: #cbd5e1; }
.has-llm { color: #fbbf24; font-size: 11px; }

#metrics-card {
  display: flex; gap: 16px; align-items: center;
  background: #1e293b; padding: 16px; border-radius: 6px; margin-bottom: 12px;
}
.metric { display: flex; flex-direction: column; min-width: 80px; }
.metric-label { font-size: 10px; text-transform: uppercase; color: #94a3b8; letter-spacing: 0.05em; }
.metric-value { font-size: 20px; font-weight: 600; color: #f1f5f9; font-family: ui-monospace, monospace; }
#refresh-btn {
  margin-left: auto; padding: 8px 14px;
  background: #334155; color: #f1f5f9; border: 1px solid #475569;
  border-radius: 4px; cursor: pointer; font-size: 12px;
}
#refresh-btn:hover { background: #475569; }

#history {
  width: 100%; border-collapse: collapse; font-size: 12px;
  background: #1e293b; border-radius: 6px; overflow: hidden;
}
#history thead { background: #0f172a; }
#history th {
  text-align: left; padding: 8px 10px; color: #94a3b8;
  font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid #334155;
}
#history td { padding: 8px 10px; border-bottom: 1px solid #0f172a; color: #cbd5e1; }
#history tr:last-child td { border-bottom: none; }
#history .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
#history .slug-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#history .hit { color: #4ade80; }
#history .miss { color: #f87171; }
.resolve-btn {
  padding: 4px 10px; background: #065f46; color: #d1fae5;
  border: 1px solid #047857; border-radius: 3px; font-size: 11px; cursor: pointer;
}
.resolve-btn:hover { background: #047857; }
.resolve-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#modal[hidden] { display: none; }
#modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); }
.modal-body {
  position: relative; background: #0f172a; border: 1px solid #334155;
  border-radius: 8px; padding: 24px; max-width: 80vw; max-height: 80vh; overflow: auto;
}
#modal-close {
  position: absolute; top: 8px; right: 12px; background: none; border: none;
  color: #94a3b8; font-size: 24px; cursor: pointer;
}
#modal-content {
  background: #020617; padding: 12px; border-radius: 4px; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; max-width: 70vw;
}
