:root {
  --bg: #030608; --txt: #c8d2d8; --dim: #6b7a85;
  --acc: #6cf2ff; --line: #17242c; --warn: #c9a227; --err: #e0614a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
#top {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  letter-spacing: .18em; font-size: 11px;
}
#top .brand { color: var(--acc); text-decoration: none; }
#top .sep, #top .page { color: var(--dim); }
#app { display: grid; grid-template-columns: 380px 1fr; height: calc(100vh - 45px); }
#setup { padding: 16px; overflow-y: auto; border-right: 1px solid var(--line); }
.panel { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 10px; font-size: 11px; letter-spacing: .18em; color: var(--acc); }
.panel label { display: block; margin-bottom: 8px; color: var(--dim); letter-spacing: .1em; }
select, input[type=password] {
  background: #071016; color: var(--txt); border: 1px solid var(--line);
  border-radius: 5px; padding: 6px 8px; font: inherit; width: 100%;
}
select { width: auto; min-width: 140px; }
button {
  background: none; border: 1px solid var(--acc); color: var(--acc);
  border-radius: 6px; padding: 9px 18px; font: inherit;
  letter-spacing: .16em; cursor: pointer;
}
button:disabled { border-color: var(--line); color: var(--dim); cursor: not-allowed; }
button.minor { border-color: var(--line); color: var(--dim); padding: 5px 10px; margin-top: 8px; }
.note { color: var(--dim); font-size: 11px; margin: 10px 0 0; }
.dim { color: var(--dim); }
#log { margin-top: 14px; }
#log div { padding: 3px 0; border-bottom: 1px solid var(--line); }
#log .ok { color: var(--acc); }
#log .warn { color: var(--warn); }
#log .err { color: var(--err); }
#flags { margin-top: 10px; }
.flag {
  color: var(--warn); border-left: 2px solid var(--warn);
  padding: 3px 0 3px 8px; margin-bottom: 4px; font-size: 11px;
}
#stage { position: relative; overflow: hidden; }
#gl { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------ bottom toolbar
   The APS-style pill from the main viewer (css/style.css), carried over
   so the two 3D surfaces of the site read as one product. */
#toolbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 12; display: flex;
}
#toolbar[hidden] { display: none; }
.tbg {
  display: flex; align-items: center; gap: 2px; padding: 4px 6px; position: relative;
  background: rgba(9, 16, 21, 0.72); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px; backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.tbsep {
  width: 1px; height: 24px; margin: 0 7px; flex: none;
  background: linear-gradient(180deg, transparent, #24363f, transparent);
}
.tbw { position: relative; display: flex; }
.tbb {
  width: 40px; height: 40px; border: none; border-radius: 7px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: #cfdde4; background: transparent; position: relative; cursor: pointer;
}
.tbb:hover { background: rgba(255, 255, 255, .08); color: var(--acc); }
.tbb.on { color: var(--acc); background: rgba(255, 255, 255, .06); box-shadow: inset 0 -2px 0 var(--acc); }
.tbb svg { width: 20px; height: 20px; display: block; }
.tbb .fo {
  position: absolute; top: 4px; right: 4px; width: 0; height: 0;
  border-top: 4px solid currentColor; border-left: 4px solid transparent; opacity: .35;
}
.tbf {
  position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%);
  display: none; flex-direction: column; gap: 2px; padding: 5px; min-width: 176px;
  background: rgba(9, 16, 21, 0.86); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px; backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.tbf.open { display: flex; }
.tbf button {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px;
  border: none; border-radius: 7px; font-size: 10px; letter-spacing: .16em;
  color: var(--txt); background: transparent; text-align: left; white-space: nowrap;
}
.tbf button:hover { background: rgba(255, 255, 255, .08); color: var(--acc); }
.tbf button.on { color: var(--acc); }
.tbf button.on::after { content: '●'; margin-left: auto; font-size: 7px; padding-left: 12px; }
.tbf .fh { padding: 6px 11px 3px; font-size: 8px; letter-spacing: .24em; color: var(--dim); }

.mlabel {
  position: fixed; z-index: 11; transform: translate(-50%, -130%);
  padding: 3px 8px; font-size: 10px; letter-spacing: .08em; border-radius: 4px;
  background: rgba(4, 8, 11, .85); border: 1px solid var(--acc); color: var(--acc);
  pointer-events: none; white-space: nowrap;
}
#toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%);
  z-index: 13; padding: 7px 14px; border-radius: 6px; font-size: 10px;
  letter-spacing: .16em; color: var(--acc); pointer-events: none;
  background: rgba(4, 8, 11, .9); border: 1px solid var(--acc);
  opacity: 0; transition: opacity .18s;
}
#toast.on { opacity: 1; }

/* Selection card. Sits top-right of the stage, clear of the bottom toolbar,
   and scrolls internally so a long evidence list never pushes it off screen. */
#card {
  position: absolute; top: 12px; right: 12px; z-index: 12; width: 292px;
  max-height: calc(100% - 100px); display: flex; flex-direction: column;
  background: rgba(4, 8, 11, .92); border: 1px solid var(--line);
  border-radius: 8px; backdrop-filter: blur(3px);
}
#card[hidden] { display: none; }
#card header {
  display: flex; align-items: flex-start; gap: 8px; padding: 11px 12px;
  border-bottom: 1px solid var(--line);
}
#card header > div { min-width: 0; flex: 1; }
#card-title {
  color: var(--acc); font-size: 11px; letter-spacing: .12em; line-height: 1.4;
  overflow-wrap: anywhere;
}
#card-sub { color: var(--dim); font-size: 10px; letter-spacing: .14em; margin-top: 3px; }
#card-close {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  padding: 0 2px; font-size: 13px; line-height: 1;
}
#card-close:hover { color: var(--acc); }
#card-props { overflow-y: auto; padding: 4px 12px 10px; }
#card .pr {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 11px;
}
#card .pr span { color: var(--dim); letter-spacing: .1em; white-space: nowrap; }
#card .pr b { font-weight: 400; text-align: right; overflow-wrap: anywhere; }
#card .phead {
  color: var(--acc); font-size: 10px; letter-spacing: .18em;
  margin: 12px 0 4px; padding-top: 8px; border-top: 1px solid var(--line);
}
#card .flagrow { color: var(--warn); font-size: 11px; padding: 6px 0; line-height: 1.5; }
#card footer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
#card footer button { flex: 1; padding: 6px 0; font-size: 10px; }
#card footer button.on { background: rgba(108, 242, 255, .14); }

/* Unhide is a STATE INDICATOR, as in the engine viewer: it exists exactly when
   something is hidden or isolated, which is the only way to know that it is. */
#unhide {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%);
  z-index: 13; padding: 6px 13px; border-radius: 6px; font-size: 10px;
  letter-spacing: .16em; cursor: pointer; white-space: nowrap;
  background: rgba(4, 8, 11, .9);
  border: 1px solid rgba(210, 130, 95, .55); color: #d99a7c;
}
#unhide:hover { border-color: #d08a6a; color: #f0b295; }
#unhide[hidden] { display: none; }

@media (max-width: 860px) {
  #card { width: auto; left: 12px; max-height: 46%; }

  #app { grid-template-columns: 1fr; height: auto; }
  #stage { height: 60vh; }
  #toolbar { max-width: 96vw; overflow-x: auto; scrollbar-width: none; }
  #toolbar::-webkit-scrollbar { display: none; }
  .tbb { width: 36px; height: 36px; }
  .tbb svg { width: 19px; height: 19px; }
}
