@import url("https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/style.css");

:root {
  --paper: #f7f1e3;
  --ivory: #fffdf8;
  --ink: #171411;
  --consumer: #e8c968;
  --merchant: #9fb58e;
  --rider: #79afc2;
  --platform: #d77a50;
  --gov: #65758b;
  --risk: #c4544d;
  --micro-agent-scale: 1;
  font-family: "LXGW WenKai", "PingFang SC", "Hiragino Sans GB", serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
output { font: inherit; }

button { color: inherit; }

#app {
  position: relative;
  isolation: isolate;
  background: var(--paper);
}

html.is-embedded .brand-card { display: none; }
html.is-embedded .topbar { top: 12px; right: 12px; left: 12px; justify-content: flex-end; }
html.is-embedded .stage-switcher { box-shadow: 2px 2px 0 rgba(23, 20, 17, .12); }
html.is-embedded .view-controls { top: 72px; right: 12px; }
html.is-embedded .render-switcher { top: 12px; left: 12px; }
html.is-embedded .micro-plan-switcher { top: 77px; left: 12px; }
html.is-embedded .legend { bottom: 12px; left: 12px; }
html.is-embedded .simulation-status { top: auto; bottom: 12px; }
html.is-embedded .detail-panel,
html.is-embedded .agent-intent-panel { top: 108px; right: 12px; max-height: calc(100vh - 120px); }

@media (max-width: 720px) {
  html.is-embedded .stage-switcher { grid-template-columns: repeat(4, minmax(0, 1fr)); width: calc(100% - 24px); }
  html.is-embedded .stage-button { min-width: 0; padding-inline: 5px; }
  html.is-embedded .render-switcher { top: 74px; }
  html.is-embedded .micro-plan-switcher { top: 140px; }
  html.is-embedded .view-controls { top: auto; right: 8px; bottom: 8px; left: 8px; overflow-x: auto; }
  html.is-embedded .legend,
  html.is-embedded .simulation-status,
  html.is-embedded .scale-wrap { display: none; }
}

#reference-fallback {
  position: absolute;
  z-index: 0;
  inset: 50% auto auto 50%;
  width: 90.5%;
  height: 90.5%;
  object-fit: contain;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: opacity .2s;
  pointer-events: none;
  user-select: none;
}

#reference-fallback.is-hidden { opacity: 0; }

#scene,
#scene canvas,
#scene .label-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#scene canvas { cursor: grab; }
#scene canvas { z-index: 1; }
#scene .label-layer { z-index: 2; }
#scene canvas:active { cursor: grabbing; }

.topbar {
  position: absolute;
  z-index: 10;
  top: 18px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand-card,
.stage-switcher,
.view-controls,
.render-switcher,
.micro-plan-switcher,
.legend,
.detail-panel,
.agent-intent-panel,
.simulation-status,
.scale-wrap {
  pointer-events: auto;
  background: rgba(255, 253, 248, .94);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(23, 20, 17, .15);
}

.brand-card {
  min-width: 284px;
  padding: 13px 17px 14px;
  border-radius: 15px 19px 13px 18px / 18px 13px 19px 14px;
}

.brand-card .eyebrow {
  margin: 0 0 3px;
  color: var(--gov);
  font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .15em;
}

.brand-card h1 {
  margin: 0;
  font-size: clamp(27px, 3vw, 42px);
  line-height: 1;
}

.brand-card > p:last-child {
  margin: 7px 0 0;
  color: rgba(23, 20, 17, .68);
  font-size: 12px;
}

.stage-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px;
  border-radius: 17px 13px 19px 14px / 14px 18px 13px 19px;
}

.stage-button {
  min-width: 70px;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px 13px 10px 14px;
  background: transparent;
  cursor: pointer;
  transition: background .2s, color .2s, transform .2s;
}

.stage-button span {
  display: block;
  font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: .52;
}

.stage-button:hover { background: rgba(23, 20, 17, .07); }
.stage-button.is-active { color: var(--ivory); background: var(--ink); transform: translateY(-1px); }

.view-controls {
  position: absolute;
  z-index: 10;
  top: 116px;
  right: 18px;
  display: flex;
  gap: 5px;
  padding: 5px;
  border-radius: 12px 16px 11px 15px / 15px 11px 16px 12px;
}

.view-controls button,
.view-controls output {
  min-height: 34px;
  padding: 7px 10px;
  border: 1.5px solid rgba(23, 20, 17, .45);
  border-radius: 8px 10px 7px 11px;
  background: var(--ivory);
}

.view-controls button { cursor: pointer; }
.view-controls button:hover,
.view-controls button[aria-pressed="true"] { background: var(--ink); color: var(--ivory); }
.view-controls output { min-width: 55px; text-align: center; font-weight: 700; }

.render-switcher {
  position: absolute;
  z-index: 11;
  top: 132px;
  left: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 5px;
  border-radius: 14px 18px 12px 17px / 17px 12px 18px 13px;
}

.render-mode-button {
  min-width: 96px;
  padding: 7px 10px 8px;
  border: 1.5px solid rgba(23,20,17,.42);
  border-radius: 9px 12px 8px 11px;
  background: var(--ivory);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.render-mode-button span {
  display: block;
  margin-bottom: 2px;
  color: var(--gov);
  font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
}

.render-mode-button:hover { background: rgba(23,20,17,.07); }
.render-mode-button.is-active { color: var(--ivory); background: var(--ink); }
.render-mode-button.is-active span { color: var(--consumer); }

.micro-plan-switcher {
  position: absolute;
  z-index: 11;
  top: 198px;
  left: 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 5px;
  border-radius: 13px 17px 12px 16px / 16px 12px 18px 13px;
  transition: opacity .2s, transform .2s;
}

.micro-plan-switcher.is-hidden {
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
}

.micro-plan-button {
  min-width: 57px;
  padding: 6px 8px;
  border: 1.4px solid rgba(23,20,17,.4);
  border-radius: 8px 10px 7px 11px;
  background: var(--ivory);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.micro-plan-button span {
  margin-right: 4px;
  color: var(--gov);
  font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.micro-plan-button:hover { background: rgba(23,20,17,.07); }
.micro-plan-button.is-active { color: var(--ivory); background: var(--ink); }
.micro-plan-button.is-active span { color: var(--consumer); }

.legend {
  position: absolute;
  z-index: 10;
  left: 18px;
  bottom: 18px;
  width: 196px;
  padding: 12px 14px;
  border-radius: 14px 18px 12px 19px / 18px 12px 20px 14px;
}

.legend-title { margin: 0 0 8px; font-size: 12px; font-weight: 800; }
.legend ul { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 5px; font-size: 10px; }
.legend i { width: 11px; height: 11px; border: 1.4px solid var(--ink); border-radius: 50%; background: var(--swatch); }
.legend-tip { margin: 9px 0 0; padding-top: 8px; border-top: 1px dashed rgba(23,20,17,.25); color: rgba(23,20,17,.6); font-size: 9px; }

.detail-panel {
  position: absolute;
  z-index: 12;
  top: 164px;
  right: 18px;
  width: min(330px, calc(100vw - 36px));
  padding: 17px;
  border-radius: 18px 13px 20px 15px / 14px 20px 13px 18px;
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition: transform .28s ease, opacity .22s;
}

.detail-panel.is-visible { transform: none; opacity: 1; }
.close-button { position: absolute; top: 8px; right: 9px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; font-size: 24px; cursor: pointer; }
.detail-role { display: inline-block; margin: 0 0 8px; padding: 4px 8px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--role-color, var(--gov)); font-size: 10px; font-weight: 800; }
.detail-panel h2 { margin: 0 30px 5px 0; font-size: 24px; line-height: 1.15; }
.detail-occupants { margin: 0 0 12px; color: rgba(23,20,17,.62); font-size: 11px; }
.detail-metrics { display: grid; gap: 6px; margin: 0; }
.detail-metrics div { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed rgba(23,20,17,.22); }
.detail-metrics dt { color: rgba(23,20,17,.58); font-size: 11px; }
.detail-metrics dd { margin: 0; text-align: right; font-size: 11px; font-weight: 800; }
.dialogue-thread { margin-top: 12px; padding: 10px; border: 1.5px dotted var(--ink); border-radius: 10px 13px 9px 14px; background: var(--paper); }
.dialogue-thread > p { margin: 0 0 7px; color: var(--gov); font-size: 10px; font-weight: 800; }
.dialogue-thread ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.dialogue-thread li { padding: 7px 9px; border-radius: 9px 11px 8px 12px; background: var(--ivory); font-size: 11px; line-height: 1.45; }
.dialogue-thread li:nth-child(even) { margin-left: 20px; background: color-mix(in srgb, var(--role-color, var(--gov)) 30%, var(--ivory)); }

.agent-intent-panel {
  position: absolute;
  z-index: 24;
  top: 164px;
  right: 18px;
  width: min(372px, calc(100vw - 36px));
  max-height: calc(100vh - 184px);
  padding: 17px;
  overflow: auto;
  border: 2px solid var(--ink);
  border-radius: 18px 13px 20px 15px / 14px 20px 13px 18px;
  background: rgba(255,253,248,.97);
  box-shadow: 5px 5px 0 rgba(23,20,17,.2), 0 16px 42px rgba(23,20,17,.18);
  transform: translateX(calc(100% + 30px));
  opacity: 0;
  transition: transform .28s ease, opacity .22s;
}

.agent-intent-panel.is-visible { transform: none; opacity: 1; }
.agent-intent-role { display: inline-block; margin: 0 0 8px; padding: 4px 8px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--agent-color, var(--consumer)); font-size: 10px; font-weight: 900; }
.agent-intent-panel h2 { margin: 0 30px 2px 0; font-size: 26px; line-height: 1.12; }
.agent-intent-id { margin: 0 0 11px; color: rgba(23,20,17,.53); font: 700 9px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.agent-intent-profile { margin: 0 0 7px; color: rgba(23,20,17,.7); font-size: 10px; line-height: 1.5; }
.agent-intent-traits { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.agent-intent-traits span { padding: 3px 6px; border: 1px solid rgba(23,20,17,.32); border-radius: 999px; background: color-mix(in srgb, var(--agent-color) 22%, var(--ivory)); font-size: 8px; font-weight: 900; }
.agent-live-thought { position: relative; display: grid; gap: 3px; margin-bottom: 9px; padding: 9px 11px 10px; border: 1.5px solid var(--ink); border-radius: 13px 17px 12px 16px / 16px 12px 18px 13px; background: var(--ivory); }
.agent-live-thought::after { content: ""; position: absolute; left: 20px; bottom: -6px; width: 9px; height: 9px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); background: var(--ivory); transform: rotate(45deg); }
.agent-live-thought span { color: rgba(23,20,17,.5); font-size: 8px; }
.agent-live-thought q { font-size: 11px; font-weight: 800; line-height: 1.45; }
.agent-live-speech { display: grid; grid-template-columns: 58px 1fr; gap: 7px; align-items: start; margin: -2px 0 9px 8px; padding: 7px 9px; border-left: 2px solid var(--agent-color, var(--consumer)); background: color-mix(in srgb, var(--agent-color) 12%, var(--paper)); }
.agent-live-speech span { color: rgba(23,20,17,.5); font-size: 8px; }
.agent-live-speech q { font-size: 10px; font-weight: 800; line-height: 1.45; }
.agent-intent-now { display: grid; gap: 2px; padding: 10px 12px; border: 1.7px solid var(--ink); border-radius: 11px 15px 10px 14px; background: color-mix(in srgb, var(--agent-color) 30%, var(--ivory)); }
.agent-intent-now span { color: rgba(23,20,17,.55); font-size: 9px; }
.agent-intent-now strong { font-size: 14px; }
.agent-intent-fields { display: grid; gap: 0; margin: 10px 0 0; }
.agent-intent-fields div { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px dashed rgba(23,20,17,.22); }
.agent-intent-fields dt { color: rgba(23,20,17,.55); font-size: 10px; }
.agent-intent-fields dd { margin: 0; font-size: 11px; font-weight: 800; line-height: 1.45; }
.agent-cognition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.agent-cognition-grid section { min-width: 0; padding: 9px; border: 1.4px dotted var(--ink); border-radius: 10px 13px 9px 12px; background: var(--paper); }
.agent-cognition-grid p { margin: 0 0 6px; color: var(--gov); font-size: 9px; font-weight: 900; }
.agent-cognition-grid ol { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.agent-cognition-grid li { padding: 6px 7px; border-radius: 7px 9px 6px 8px; background: rgba(255,253,248,.9); font-size: 9px; line-height: 1.4; }
.agent-intent-injector { display: grid; gap: 6px; margin-top: 10px; padding: 9px; border: 1.5px solid var(--ink); border-radius: 10px 13px 9px 12px; background: color-mix(in srgb, var(--agent-color) 18%, var(--ivory)); }
.agent-intent-injector label { font-size: 9px; font-weight: 900; }
.agent-intent-injector textarea { width: 100%; resize: vertical; padding: 7px 8px; border: 1.2px solid rgba(23,20,17,.42); border-radius: 7px 9px 6px 8px; background: rgba(255,253,248,.94); color: var(--ink); font: 10px/1.45 "LXGW WenKai", "PingFang SC", sans-serif; }
.agent-intent-injector button { justify-self: end; padding: 6px 9px; border: 1.4px solid var(--ink); border-radius: 7px 9px 6px 8px; background: var(--ink); color: var(--ivory); cursor: pointer; font-size: 9px; font-weight: 900; }
.agent-intent-api { margin: 10px 0 0; padding-top: 8px; border-top: 1px dashed rgba(23,20,17,.22); color: rgba(23,20,17,.58); font-size: 8px; }
.agent-intent-api code { font-size: 8px; }

.agent-bubble {
  width: 230px;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px 16px 11px 17px / 16px 11px 17px 12px;
  background: rgba(255,253,248,.97);
  box-shadow: 3px 3px 0 rgba(23,20,17,.15);
  transform: translateY(-8px);
  pointer-events: none;
}

.agent-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: var(--ivory);
  transform: translateX(-50%) rotate(45deg);
}

.agent-bubble strong { display: block; margin-bottom: 4px; font-size: 11px; }
.agent-bubble span { display: block; font-size: 10px; line-height: 1.45; }

.reference-building-tag {
  display: flex;
  align-items: center;
  max-width: 190px;
  padding: 5px 8px 5px 5px;
  border: 1.6px solid var(--ink);
  border-radius: 999px;
  background: rgba(255,253,248,.96);
  box-shadow: 2px 2px 0 rgba(23,20,17,.16);
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-4px);
}

.reference-building-tag i {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  margin-right: 5px;
  border: 1.2px solid var(--ink);
  border-radius: 50%;
  background: var(--tag-color);
  color: var(--ink);
  font-style: normal;
  font-size: 9px;
  font-weight: 900;
}

.reference-building-tag span {
  overflow: hidden;
  max-width: 145px;
  text-overflow: ellipsis;
  font-size: 10px;
  font-weight: 800;
}

.handdrawn-agent {
  position: relative;
  width: 23px;
  height: 35px;
  pointer-events: auto;
  user-select: none;
  cursor: pointer;
  overflow: visible;
  contain: layout style;
}

.handdrawn-agent-hit-target {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -58%);
}
.handdrawn-agent-hit-target:focus-visible { outline: 2px solid var(--agent-color); outline-offset: 2px; }

.handdrawn-agent.handdrawn-rider {
  width: 42px;
  height: 35px;
}

.handdrawn-agent-shell {
  position: absolute;
  inset: 0;
  display: block;
  transform: translateY(-49%) scale(var(--micro-agent-scale));
  transform-origin: 50% 96%;
  opacity: 1;
  backface-visibility: hidden;
  transition: transform .24s;
  will-change: transform;
}

.handdrawn-agent[data-state="waiting"] .handdrawn-agent-shell,
.handdrawn-agent[data-state="review"] .handdrawn-agent-shell {
  transform: translateY(-50%) scale(calc(var(--micro-agent-scale) * .96));
}
.handdrawn-agent[data-spatial-state="staying_inside"] .handdrawn-agent-shell,
.handdrawn-agent[data-spatial-state="idle_in_place"] .handdrawn-agent-shell,
.handdrawn-agent[data-spatial-state="waiting_outside"] .handdrawn-agent-shell {
  transform: translateY(-50%) scale(calc(var(--micro-agent-scale) * .86));
}
.handdrawn-agent[data-spatial-state="entering"] .handdrawn-agent-shell,
.handdrawn-agent[data-spatial-state="leaving"] .handdrawn-agent-shell {
  transform: translateY(-50%) scale(calc(var(--micro-agent-scale) * .78));
}

.handdrawn-agent-figure {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background-image: var(--agent-sprite);
  background-repeat: no-repeat;
  background-position: var(--agent-frame-x, 0%) 50%;
  background-size: 400% 100%;
  transform: scaleX(var(--agent-facing, 1));
  transform-origin: 50% 96%;
  backface-visibility: hidden;
}

.handdrawn-agent-shadow {
  position: absolute;
  z-index: 1;
  left: 18%;
  right: 18%;
  bottom: 1px;
  height: 3px;
  border: .7px solid rgba(23,20,17,.34);
  border-radius: 50%;
  background: rgba(23,20,17,.16);
  transform: scaleX(.92);
}

.handdrawn-agent:hover .handdrawn-agent-shell,
.handdrawn-agent.is-selected .handdrawn-agent-shell {
  transform: translateY(-49%) scale(calc(var(--micro-agent-scale) * 1.04));
}

.handdrawn-agent.is-selected::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 0;
  height: 5px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: color-mix(in srgb, var(--agent-color) 50%, transparent);
}

.handdrawn-agent.is-moving .handdrawn-agent-shell { animation: handdrawn-stable-bob .72s ease-in-out infinite; }
.handdrawn-agent.is-moving .handdrawn-agent-shadow { animation: handdrawn-step .72s ease-in-out infinite; }
.agent-speech-chip {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: calc(100% + 7px);
  width: max-content;
  max-width: 156px;
  display: grid;
  gap: 3px;
  padding: 6px 8px 5px;
  border: 1.2px solid var(--ink);
  border-radius: 8px 11px 7px 10px;
  background: rgba(255,253,248,.97);
  box-shadow: 2px 2px 0 rgba(23,20,17,.14);
  color: var(--ink);
  font-size: 8px;
  font-weight: 780;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px) scale(.94);
  transform-origin: 50% 100%;
  transition: opacity .18s ease, transform .18s ease;
}
.agent-speech-chip.is-thought { border-style: dashed; background: rgba(239,243,255,.97); }
.agent-speech-copy { display: block; }
.agent-speech-chip small { display: block; color: color-mix(in srgb,var(--agent-color) 72%,var(--ink)); font-size: 6px; font-weight: 900; letter-spacing: .04em; }
.agent-speech-chip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 6px;
  height: 6px;
  border-right: 1.2px solid var(--ink);
  border-bottom: 1.2px solid var(--ink);
  background: var(--ivory);
  transform: translateX(-50%) rotate(45deg);
}
.agent-speech-chip.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
@keyframes handdrawn-step {
  50% { transform: scaleX(.78); }
}
@keyframes handdrawn-stable-bob {
  0%, 100% { transform: translateY(-49%) scale(var(--micro-agent-scale)); }
  50% { transform: translateY(-51%) scale(var(--micro-agent-scale)); }
}

.axis-label {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--ivory);
  font: 800 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.simulation-status {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 999px;
  transform: translateX(-50%);
  font-size: 10px;
}

.simulation-status i { width: 8px; height: 8px; border: 1px solid var(--ink); border-radius: 50%; background: var(--merchant); animation: live 1.5s ease-in-out infinite; }

.micro-simulation-panel {
  position: absolute;
  z-index: 10;
  right: 18px;
  bottom: 18px;
  width: 282px;
  padding: 12px 13px 10px;
  border: 2px solid var(--ink);
  border-radius: 15px 19px 13px 18px / 18px 13px 19px 14px;
  background: rgba(255,253,248,.94);
  box-shadow: 3px 3px 0 rgba(23,20,17,.15);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}

.micro-simulation-panel.is-hidden { opacity: 0; transform: translateY(8px); }
.micro-simulation-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.micro-simulation-heading span { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900; }
.micro-simulation-heading span i { width: 8px; height: 8px; border: 1px solid var(--ink); border-radius: 50%; background: var(--merchant); animation: live 1.1s ease-in-out infinite; }
.micro-simulation-heading b { color: rgba(23,20,17,.55); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.micro-simulation-panel dl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin: 0; }
.micro-simulation-panel dl div { min-width: 0; padding: 7px 5px 6px; border: 1.2px solid rgba(23,20,17,.23); border-radius: 7px 10px 7px 9px; background: rgba(247,241,227,.72); text-align: center; }
.micro-simulation-panel dt { overflow: hidden; color: rgba(23,20,17,.58); font-size: 8px; white-space: nowrap; }
.micro-simulation-panel dd { margin: 2px 0 0; font: 900 17px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.micro-simulation-panel > p { display: flex; align-items: center; margin: 8px 0 0; color: rgba(23,20,17,.57); font-size: 8px; }
.flow-line { display: inline-block; width: 19px; margin-right: 4px; border-top: 2px dashed var(--rider); }
.heat-chip { display: inline-block; width: 12px; height: 8px; margin-right: 4px; border: 1px solid var(--ink); border-radius: 3px; background: color-mix(in srgb, var(--platform) 45%, transparent); }
.micro-simulation-panel[data-stage="burst"] .micro-simulation-heading span i,
.micro-simulation-panel[data-stage="burst"] .heat-chip { background: var(--platform); }
.micro-simulation-panel[data-stage="risk"] .micro-simulation-heading span i,
.micro-simulation-panel[data-stage="risk"] .heat-chip { background: var(--risk); }
.micro-simulation-panel[data-stage="policy"] .micro-simulation-heading span i,
.micro-simulation-panel[data-stage="policy"] .heat-chip { background: var(--gov); }

.micro-building-status {
  display: none;
  align-items: center;
  gap: 4px;
  max-width: 130px;
  padding: 3px 5px 3px 4px;
  border: 1.3px solid var(--ink);
  border-radius: 999px;
  background: rgba(255,253,248,.94);
  box-shadow: 1px 2px 0 rgba(23,20,17,.15);
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-5px);
}

.micro-building-status i { width: 7px; height: 7px; flex: 0 0 auto; border: 1px solid var(--ink); border-radius: 50%; background: var(--building-color); animation: live 1.2s ease-in-out infinite; }
.micro-building-status span { overflow: hidden; max-width: 72px; text-overflow: ellipsis; font-size: 8px; font-weight: 800; }
.micro-building-status b { padding: 2px 4px; border-radius: 999px; background: rgba(23,20,17,.09); font-size: 7px; }
.micro-building-status[data-stage="burst"][data-pressure="high"] { color: var(--ivory); background: var(--platform); }
.micro-building-status[data-stage="risk"][data-pressure="high"] { color: var(--ivory); background: var(--risk); }
.micro-building-status[data-stage="policy"][data-pressure="high"] { color: var(--ivory); background: var(--gov); }
.micro-building-status[data-stage="burst"][data-pressure="high"] i,
.micro-building-status[data-stage="risk"][data-pressure="high"] i,
.micro-building-status[data-stage="policy"][data-pressure="high"] i { background: var(--consumer); }
.micro-building-status[data-stage="burst"][data-pressure="high"] b,
.micro-building-status[data-stage="risk"][data-pressure="high"] b,
.micro-building-status[data-stage="policy"][data-pressure="high"] b { background: rgba(255,255,255,.18); }

.micro-zone-label {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 118px;
  padding: 2px 5px 2px 3px;
  border: 1px solid rgba(23,20,17,.72);
  border-radius: 999px;
  background: rgba(255,253,248,.88);
  pointer-events: none;
  transform: translate(50%, -50%);
}

.micro-zone-label i {
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--zone-color);
  font: 900 7px/1 sans-serif;
}

.micro-zone-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 7px;
  font-weight: 900;
}

.scale-wrap {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 11px 7px;
  border-radius: 9px 12px 8px 13px;
}

.scale-bar { position: relative; width: 120px; height: 12px; border-bottom: 3px solid var(--ink); }
.scale-bar::before,
.scale-bar::after,
.scale-bar span { content: ""; position: absolute; bottom: -3px; width: 3px; height: 10px; background: var(--ink); }
.scale-bar::before { left: 0; }
.scale-bar::after { right: 0; }
.scale-bar span { left: 50%; transform: translateX(-50%); height: 7px; }
.scale-wrap output { min-width: 42px; font-size: 11px; font-weight: 800; }

.loading {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--paper);
  transition: opacity .45s, visibility .45s;
}

.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading span { width: 54px; height: 54px; border: 3px solid rgba(23,20,17,.18); border-top-color: var(--platform); border-radius: 50%; animation: spin 1s linear infinite; }
.loading p { margin: 14px 0 0; font-size: 13px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes live { 50% { transform: scale(.7); opacity: .55; } }

@media (max-width: 900px) {
  .topbar { align-items: stretch; }
  .brand-card { min-width: 0; }
  .brand-card > p:last-child { display: none; }
  .stage-switcher { align-self: flex-start; }
  .stage-button { min-width: 54px; padding-inline: 6px; }
  .simulation-status { top: auto; bottom: 70px; }
  .view-controls { top: 104px; max-width: calc(100vw - 36px); flex-wrap: wrap; justify-content: flex-end; }
  .render-switcher { top: 124px; }
  .micro-plan-switcher { top: 188px; }
  .micro-simulation-panel { right: 12px; bottom: 12px; }
}

@media (max-width: 640px) {
  .topbar { display: block; }
  .brand-card { width: max-content; max-width: calc(100vw - 36px); }
  .brand-card h1 { font-size: 28px; }
  .stage-switcher { position: absolute; top: 88px; left: 0; }
  .view-controls { top: auto; right: 12px; bottom: 12px; max-width: 210px; }
  .render-switcher { top: 132px; left: 12px; }
  .micro-plan-switcher { top: 198px; left: 12px; }
  .legend { display: none; }
  .scale-wrap { left: 12px; bottom: 12px; transform: none; }
  .simulation-status { left: 12px; bottom: 58px; transform: none; }
  .detail-panel { top: 150px; right: 12px; }
  .agent-intent-panel { top: 150px; right: 12px; max-height: calc(100vh - 168px); }
  .micro-simulation-panel { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
