:root {
  --bg: #f2f3f5;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e2e5e9;
  --accent: #1565c0;
  --pass: #2e7d32;
  --fail: #c62828;
  --advisory_risk: #f9a825;
  --info: #1565c0;
  --n_a: #9e9e9e;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
#project-name { font-weight: 600; font-size: 1.05rem; }
.controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ctl { color: var(--muted); font-size: 0.85rem; display: inline-flex; gap: 0.35rem; align-items: center; }
select { font: inherit; padding: 0.2rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.modes button { border: 1px solid var(--line); background: #fff; padding: 0.3rem 0.7rem; cursor: pointer; }
.modes button:first-child { border-radius: 6px 0 0 6px; }
.modes button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.modes button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

#banner {
  padding: 0.5rem 1rem;
  background: #fff8e1;
  color: #7a5c00;
  border-bottom: 1px solid #f0e2b0;
  font-size: 0.85rem;
}

main { flex: 1; display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; }
#view { display: block; width: 100%; height: 100%; }

.legend {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  display: flex;
  gap: 0.9rem;
  font-size: 0.78rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.side {
  width: 360px;
  max-width: 42vw;
  border-left: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.8rem; }
.panel h2 { margin: 0 0 0.1rem; font-size: 1.1rem; }
.panel h3 { margin: 0.9rem 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.id { color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.75rem; margin: 0 0 0.5rem; }
.muted { color: var(--muted); }

.chip { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; color: #fff; font-size: 0.75rem; margin-right: 0.3rem; }
.chip.pass { background: var(--pass); } .chip.fail { background: var(--fail); }
.chip.advisory_risk { background: var(--advisory_risk); color: #3a2c00; }
.chip.info { background: var(--info); } .chip.n_a, .chip.muted { background: var(--n_a); }

table.crit { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
table.crit th, table.crit td { text-align: left; padding: 0.25rem 0.35rem; border-bottom: 1px solid var(--line); }
table.crit th { color: var(--muted); font-weight: 600; }
td.good { color: var(--pass); font-weight: 600; }
td.bad { color: var(--fail); font-weight: 600; }

ul.facts { list-style: none; padding: 0; margin: 0.3rem 0; font-size: 0.82rem; }
ul.facts li { padding: 0.1rem 0; }
.explain { background: #eef4ff; border: 1px solid #d3e0fb; border-radius: 8px; padding: 0.5rem 0.6rem; margin-top: 0.6rem; }
.explain h3 { margin: 0 0 0.2rem; color: var(--accent); }
.explain p { margin: 0; }

.card { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem; margin-bottom: 0.5rem; }
.card-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.card .note { color: var(--muted); font-size: 0.78rem; margin: 0.3rem 0; }
.tag { font-size: 0.68rem; padding: 0.05rem 0.4rem; border-radius: 999px; }
.tag.rec { background: #e3f2fd; color: #0d47a1; }
.tag.warn { background: #fff3e0; color: #a15c00; }
button.add { border: 1px solid var(--accent); background: #fff; color: var(--accent); border-radius: 6px; padding: 0.2rem 0.6rem; cursor: pointer; font: inherit; }
button.add[disabled] { border-color: var(--line); color: var(--muted); cursor: default; }

.room { display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left; border: 0; background: none; padding: 0.35rem 0.3rem; cursor: pointer; border-radius: 6px; font: inherit; }
.room:hover { background: #f0f3f8; }
.room.active { background: #e3f2fd; }
.room .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--n_a); flex: none; }
.room .dot.pass { background: var(--pass); } .room .dot.fail { background: var(--fail); }
.room .dot.advisory_risk { background: var(--advisory_risk); } .room .dot.info { background: var(--info); }
.room-name { flex: 1; } .room-status { color: var(--muted); font-size: 0.75rem; }

.tray-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; border-bottom: 1px dashed var(--line); font-size: 0.82rem; }
.tray-target { font-family: ui-monospace, monospace; font-size: 0.72rem; color: var(--muted); flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-strat { flex: 1; }
button.x { border: 0; background: none; color: var(--fail); cursor: pointer; font-size: 1rem; line-height: 1; }
.field { display: block; margin-top: 0.5rem; font-size: 0.78rem; color: var(--muted); }
.field input, .field textarea { width: 100%; font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; margin-top: 0.15rem; }
.tray-actions { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.tray-actions button { border-radius: 6px; padding: 0.35rem 0.7rem; cursor: pointer; font: inherit; border: 1px solid var(--line); background: #fff; }
.tray-actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.tray-actions .primary[disabled] { background: var(--n_a); border-color: var(--n_a); cursor: default; }

.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: #263238; color: #fff; padding: 0.5rem 0.9rem; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity 0.2s; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.error { background: #b71c1c; } .toast.success { background: #1b5e20; } .toast.warn { background: #8d6e00; }

@media (max-width: 720px) {
  main { flex-direction: column; }
  .side { width: 100%; max-width: none; border-left: 0; border-top: 1px solid var(--line); }
  .stage { min-height: 46vh; }
}
