@font-face {
  font-family: "Manrope";
  src: url("../../../open-runtime/3ae11c49db0455a3cc33e37d380f20fdb8c7f8b41dc07625c177e3d87a9d6ae6/Manrope.ttf") format("truetype");
  font-display: swap;
}
:root {
  --bg: #f5f8fb;
  --panel: #ffffff;
  --ink: #253e50;
  --ink-soft: #627789;
  --line: #e0e8ee;
  --green: #70b39a;
  --yellow: #d2b263;
  --coral: #d29380;
  --blue: #6b97c4;
  --purple: #a39aca;
  --accent: #416b83;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", "Segoe UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* desktop: 3D scene on the left, controls + current explanation beside it,
   so animation and explanation stay visible together */
#layout { display: flex; height: 100vh; }
#stage-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#scene-labels { position:absolute; inset:0; pointer-events:none; overflow:hidden; }
#label-leaders { position:absolute; inset:0; width:100%; height:100%; }
#label-leaders path { fill:none; stroke:#9aabb7; stroke-width:.7; opacity:.65; }
.scene-label { position:absolute; left:0; top:0; font-size:12px; line-height:1.3; font-weight:600; white-space:nowrap; color:var(--label-ink); background:rgba(250,252,254,.9); border:1px solid rgba(221,231,237,.7); padding:4px 7px; border-radius:4px; box-shadow:0 2px 5px rgba(29,54,73,.025); }
.scene-label[hidden] { display:none; }
.scene-heading { position:absolute; top:24px; left:28px; display:flex; align-items:center; gap:14px; font-size:14px; color:var(--ink-soft); pointer-events:none; }
.scene-symbol { font-weight:800; font-size:27px; color:var(--ink); letter-spacing:-1.2px; }
.scene-symbol sup { font-size:14px; vertical-align:super; }
.scene-footer { position:absolute; bottom:20px; left:28px; right:28px; display:flex; justify-content:space-between; gap:10px; font-size:11px; color:var(--ink-soft); pointer-events:none; }
.flow-track { position:absolute; bottom:0; left:0; right:0; height:3px; background:#e6edf2; }
#flow-progress { height:100%; background:var(--green); transform:scaleX(0); transform-origin:left; }
#canvas-holder { width: 100%; height: 100%; overflow: hidden; }
#c { display: block; width: 100%; height: 100%; touch-action: none; }
#loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--ink-soft);
  font-size: 15px; letter-spacing: .05em;
  transition: opacity .4s; pointer-events: none;
}
#loading.hidden { opacity: 0; visibility: hidden; }

#panel {
  width: 350px;
  flex: 0 0 350px;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 24px 40px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}
header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; padding-bottom:5px; }
h1 { font-size: 23px; font-weight: 750; letter-spacing: -.8px; margin: 0; }
.sub { font-size: 13px; color: var(--ink-soft); margin: 0; flex: 1 1 auto; }
.lang-row { display: flex; gap: 4px; padding:3px; border:1px solid var(--line); border-radius:7px; }
.lang-row button { border:0; padding:5px 11px; font-size:12px; }
h2 {
  font-size: 12px; font-weight: 600; text-transform: none;
  letter-spacing: .08em; color: var(--ink-soft);
  border-bottom: 1px solid var(--line); padding-bottom: 4px;
}
section { margin-top: 22px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
button, select {
  font: inherit; font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
button:hover { border-color: var(--accent); }
button:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
#m-full[aria-pressed="true"] { background:#e5f3ed; border-color:#a8ccbc; color:#29694f; }
#m-reindex[aria-pressed="true"] { background:#fbf4df; border-color:#e3cf8f; color:#77601e; }
#m-reuse[aria-pressed="true"] { background:#f8ebe6; border-color:#ddbab0; color:#925c4c; }
.btn-row:has(#m-full) { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.btn-row:has(#m-full) button { padding:9px 5px; font-size:13px; }
.mode-note { font-size: 13px; color: var(--ink-soft); margin: 10px 0 0; line-height: 1.55; }

.stage-list {
  list-style: none; margin: 12px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.stage-list button {
  display: block; width: 100%; text-align: left;
  font-size: 12px; padding: 8px 10px; border-color:transparent; background:transparent;
}
.stage-list button[aria-current="true"] {
  border-color:#ccdedf; color:#315f66; background:#edf6f4; font-weight: 650;
}
#explanation, #provenance, .impl, .node-explain {
  font-size: 14px; line-height: 1.65; margin: 10px 0 0;
}
#provenance { font-size: 12.5px; color: var(--ink-soft); }
.node-explain { color: var(--ink-soft); border-left: 3px solid var(--line); padding-left: 10px; }
select { margin-top: 8px; max-width:100%; font-size:13px; }

.legend { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sw { width: 16px; height: 16px; border-radius: 4px; flex: none; border: 1px solid rgba(0,0,0,.08); }
.sw-green { background: var(--green); }
.sw-yellow { background: var(--yellow); }
.sw-coral { background: var(--coral); }
.sw-blue { background: var(--blue); }
.sw-purple { background: var(--purple); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* mobile: independent canvas on top, panel in normal document flow below */
@media (max-width: 860px) {
  #layout { display: block; height: auto; }
  #stage-wrap { position: relative; }
  #canvas-holder { width: 100vw; height: 54vh; min-height: 390px; }
  .scene-heading { top:14px; left:16px; font-size:12px; gap:10px; }
  .scene-symbol { font-size:22px; }
  .scene-label { font-size:10px; padding:3px 5px; }
  .scene-footer { bottom:12px; left:16px; right:16px; font-size:10px; }
  .scene-footer span:last-child { display:none; }
  #panel {
    width: auto; flex: none; height: auto; overflow: visible;
    border-left: none; border-top: 1px solid var(--line);
    max-width: none; margin: 0; padding: 14px 16px 40px;
  }
  h1 { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  button { transition: none; }
  #loading { transition: none; }
}
