:root {
  --ink: #2b2a33;
  --muted: #6d6a78;
  --card: rgba(255, 252, 245, 0.94);
  --line: #e7dfd0;
  --accent: #ff7a45;
  --red: #e5484d;
  --amber: #f0a020;
  --green: #3fa86b;
  --blue: #3d7be0;
  font-family: "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); background: #9fd8f5; }
#scene { position: fixed; inset: 0; }
button, select { font: inherit; }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08), 0 12px 28px rgba(30, 40, 60, 0.18);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

#topbar {
  position: fixed; top: 12px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--card); border: 2px solid var(--line); border-radius: 18px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 28px; }
.title { font-weight: 800; font-size: 18px; }
.subtitle { font-size: 12px; color: var(--muted); }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.controls label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
select { padding: 6px 8px; border-radius: 10px; border: 2px solid var(--line); background: white; min-width: 210px; }
button {
  padding: 8px 12px; border-radius: 12px; border: 2px solid var(--line); background: white; cursor: pointer;
  font-weight: 700; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}
button:active { transform: translateY(2px); box-shadow: none; }
button.primary { background: var(--accent); border-color: #e0612e; color: white; }

#fix-menu { position: fixed; top: 84px; right: 12px; width: 380px; max-height: 70vh; overflow: auto; padding: 14px; }
.card-title { font-weight: 800; margin-bottom: 8px; }
#fix-list label { display: flex; gap: 8px; padding: 5px 2px; font-size: 13px; align-items: flex-start; cursor: pointer; }
#fix-list .status { margin-left: auto; font-size: 11px; font-weight: 800; }
.row { display: flex; gap: 8px; margin-top: 10px; }

#panel { position: fixed; top: 84px; right: 12px; bottom: 12px; width: 380px; overflow: auto; padding: 16px 16px 20px; }
#panel-close { position: absolute; top: 10px; right: 10px; padding: 2px 8px; }
#panel h2 { margin: 0 0 2px; font-size: 20px; }
#panel h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
#panel .kind { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
#panel table { width: 100%; border-collapse: collapse; font-size: 13px; }
#panel td { padding: 4px 4px; border-bottom: 1px dashed var(--line); vertical-align: top; }
#panel td:first-child { color: var(--muted); width: 42%; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; color: white; }
.pill.gap, .pill.enabled, .pill.bad { background: var(--red); }
.pill.unknown, .pill.indeterminate { background: var(--amber); }
.pill.pass, .pill.blocked, .pill.good { background: var(--green); }
.finding { font-size: 13px; padding: 6px 8px; border-radius: 10px; background: #fff; border: 1px solid var(--line); margin-bottom: 6px; }
.finding b { font-size: 12px; }
.attack { font-size: 13px; padding: 8px; border-radius: 10px; background: #fff1ee; border: 1px solid #f7c8bd; margin-bottom: 6px; }
.attack.safe { background: #eef8f1; border-color: #bfe3cb; }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }

#caption {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(720px, calc(100% - 24px)); padding: 12px 16px; font-size: 14px;
}
#caption .stepno { font-weight: 800; color: var(--red); }
#caption .tech { font-weight: 800; }
#caption a { color: var(--blue); }

#legend { position: fixed; left: 12px; bottom: 12px; padding: 10px 12px; font-size: 12px; display: grid; gap: 3px; max-width: 260px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.red { background: var(--red); } .dot.amber { background: var(--amber); } .dot.green { background: var(--green); }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800;
  background: #9fd8f5; color: white; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); text-align: center; padding: 20px;
}

/* floating labels in the 3D scene */
.tag {
  font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 99px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.9); border: 2px solid var(--line); color: var(--ink); pointer-events: none;
  display: flex; align-items: center; gap: 4px;
}
.tag .dot { margin: 0; width: 8px; height: 8px; }
.tag.extra { opacity: 0.65; }
.room-label {
  font-size: 13px; font-weight: 900; color: white; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  letter-spacing: 0.04em; text-transform: uppercase; pointer-events: none; white-space: nowrap;
}
.attack-tag { background: var(--red); color: white; border-color: #b8322f; }

@media (max-width: 720px) {
  #panel, #fix-menu { left: 12px; right: 12px; width: auto; top: auto; max-height: 55vh; }
  #legend { display: none; }
  select { min-width: 150px; }
}

/* portfolio integration: link back to the case study, and loading/error actions */
.back-link {
  margin-left: 14px; padding: 6px 10px; border-radius: 99px; border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.85); color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: none;
  white-space: nowrap;
}
.back-link:hover { background: #fff; }
.back-link:focus-visible, #loading a:focus-visible, #loading button:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
#loading small { display: inline-block; max-width: 34rem; margin-top: 10px; font-size: 15px; font-weight: 600; line-height: 1.45; }
#loading a { color: white; }
#loading .load-actions { display: inline-flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
#loading .load-actions button { font: inherit; font-weight: 800; padding: 8px 14px; border-radius: 99px; border: 0; background: white; color: #1f6f9e; cursor: pointer; }
#loading .load-detail { display: inline-block; margin-top: 8px; font-size: 12px; opacity: 0.85; }
#noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: #9fd8f5; color: white; font: 700 18px system-ui, sans-serif; text-align: center; }
#noscript a { color: white; }
@media (max-width: 640px) { .back-link { margin-left: 8px; font-size: 12px; padding: 5px 8px; } }
