:root {
  color-scheme: dark;
  --ink: #d8f4ff;
  --muted: #7292a7;
  --panel: #0b1c2a;
  --panel-raised: #102739;
  --line: #294b5d;
  --cyan: #51e5ff;
  --green: #69f0ae;
  --amber: #ffc857;
  --red: #ff5f6d;
  --purple: #c18cff;
  --shadow: #02090f;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

/* Routine observability uses the same pixel-world palette and panel borders. */
.workspace-grid > *, .control-stack > * { min-width: 0; }
.routine-resident { min-width: 0; padding: 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.routine-resident-name { margin: 0 0 5px; color: var(--ink); font-size: .85rem; }
.routine-mode { margin: 0 0 10px; color: var(--cyan); font-size: .6rem; letter-spacing: .06em; }
.routine-caption { display: block; margin: 6px 0; color: #9ebdcd; font-size: .7rem; line-height: 1.6; }
.routine-current { display: grid; gap: 6px; padding: 10px; border-left: 3px solid var(--green); background: #07141e; }
.routine-current strong { font-size: .75rem; line-height: 1.6; }
.routine-progress { width: 100%; height: 6px; accent-color: var(--green); }
.routine-disclosure { margin-top: 10px; min-width: 0; }
.routine-disclosure summary { padding: 6px 0; color: var(--cyan); font-size: .72rem; line-height: 1.6; cursor: pointer; }
.routine-disclosure summary:hover { color: var(--ink); }
.routine-disclosure summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.routine-intentions { margin: 6px 0; padding-left: 24px; }
.routine-intention { margin-bottom: 14px; font-size: .72rem; line-height: 1.65; }
.routine-intention p { margin: 4px 0; color: #a9c3d1; }
.routine-status { font-size: .7rem; line-height: 1.6; }
.routine-status.is-success { color: var(--green); }
.routine-status.is-error { color: var(--red); }
.routine-status.is-pending { color: var(--amber); }
.routine-feedback { list-style: none; padding: 0; margin: 6px 0; }
.routine-feedback li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .7rem; }
.routine-feedback p { margin: 4px 0; line-height: 1.65; color: #a9c3d1; }
.routine-decision-list { max-height: 650px; overflow-y: auto; scrollbar-color: var(--line) transparent; }
.routine-decision { padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.routine-event-header { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: .72rem; }
.routine-event-time, .routine-kind { color: var(--muted); font-size: .65rem; }
.routine-action { color: var(--ink); font-size: .75rem; line-height: 1.7; }
.routine-sensor { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .65rem; line-height: 1.6; }
.routine-sensor span { color: #a9c3d1; }
.routine-reason { color: #a9c3d1; font-size: .7rem; line-height: 1.7; white-space: pre-wrap; }
.routine-json { max-height: 260px; padding: 9px; overflow: auto; margin: 5px 0; border: 1px solid var(--line); background: #07141e; color: #a9c3d1; font: inherit; font-size: .65rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(41, 75, 93, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(41, 75, 93, 0.08) 1px, transparent 1px),
    #06111b;
  background-size: 24px 24px;
  font-size: 16px;
}

button { font: inherit; }

body[data-setup="open"] { overflow: hidden; }
body[data-setup="open"] .app-shell { filter: blur(3px) brightness(.45); pointer-events: none; }

.setup-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 9, 15, .88);
  overflow: auto;
}
.setup-card {
  width: min(1240px, 100%);
  max-height: calc(100vh - 44px);
  padding: 22px;
  border: 2px solid var(--cyan);
  background: #081722;
  box-shadow: 10px 10px 0 #02090f;
  overflow: auto;
}
.setup-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.setup-heading h1 { margin: 4px 0 8px; font-size: 1.5rem; }
.setup-heading > div > p:last-child { max-width: 720px; color: #9ebdcd; font-size: .88rem; line-height: 1.55; }
.asset-count { flex: 0 0 auto; padding: 10px 12px; color: var(--green); border: 1px solid #2a765d; font-size: .75rem; text-align: center; }
.asset-count b { display: block; font-size: 1.35rem; }
.setup-agent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup-agent-card, .world-setup { min-width: 0; margin: 0; padding: 14px; border: 1px solid #31576a; background: #0b1f2d; }
.neighbour-setup-card { border-color: #694d82; }
.setup-agent-card legend, .world-setup legend { padding: 0 8px; color: var(--cyan); font-size: .82rem; font-weight: 800; letter-spacing: .04em; }
.neighbour-setup-card legend { color: var(--purple); }
.setup-agent-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 10px; background: #07141e; }
.setup-agent-summary > div:last-child { display: grid; gap: 4px; }
.setup-agent-summary strong { font-size: .9rem; }
.setup-agent-summary small { color: var(--muted); font-size: .75rem; }
.setup-avatar { width: 48px; height: 58px; flex: 0 0 48px; background-image: var(--avatar-image); background-repeat: no-repeat; background-position: 8px -72px; background-size: 1792px 1312px; image-rendering: pixelated; filter: drop-shadow(3px 4px 0 #02090f); }
.setup-agent-card label { display: grid; grid-template-columns: 1fr auto; gap: 5px; margin-top: 10px; color: #9ebdcd; font-size: .78rem; }
.setup-agent-card label > input:not([type="range"]), .setup-agent-card label > select { grid-column: 1 / -1; }
.setup-agent-card input, .setup-agent-card select, .world-setup input, .world-setup select { min-width: 0; min-height: 38px; padding: 7px 9px; color: var(--ink); border: 1px solid var(--line); background: #102739; accent-color: var(--cyan); font-family: inherit; font-size: .82rem; }
.setup-agent-card input:focus, .setup-agent-card select:focus, .world-setup input:focus, .world-setup select:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 6px rgba(81, 225, 255, .35); }
.setup-agent-card input[type="range"] { grid-column: 1 / -1; padding: 0; }
.setup-agent-card output { color: var(--ink); }
.setup-floor-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.setup-floor-card { min-width: 0; margin: 0; padding: 12px; border: 1px solid #31576a; background: #0b1f2d; }
.setup-floor-card legend { padding: 0 8px; color: var(--cyan); font-size: .82rem; font-weight: 800; letter-spacing: .04em; }
.setup-floor-card label { display: grid; gap: 6px; color: #9ebdcd; font-size: .76rem; }
.setup-floor-card select { min-height: 38px; padding: 7px 9px; color: var(--ink); border: 1px solid var(--line); background: #102739; font-family: inherit; }
.setup-floor-card select:focus { border-color: var(--cyan); outline: none; box-shadow: 0 0 6px rgba(81, 225, 255, .35); }
.setup-floor-card > small { display: block; margin-top: 8px; color: var(--muted); font-size: .68rem; }
.setup-map-preview { position: relative; width: 100%; margin-top: 9px; aspect-ratio: 38 / 29; overflow: hidden; border: 1px solid #294b5d; background: #10222f; }
.setup-map-preview .tile-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.setup-placeholder-actors { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.setup-person { position: absolute; bottom: 20%; width: 16px; height: 24px; background-image: var(--agent-3-sprite); background-repeat: no-repeat; background-position: 0 0; background-size: 896px 656px; image-rendering: pixelated; filter: drop-shadow(2px 2px 0 #02090f); }
.setup-person.setup-alex { left: 43%; }
.setup-person.setup-jordan { left: 53%; background-image: var(--agent-4-sprite); }
.world-setup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.world-setup legend { grid-column: 1 / -1; }
.world-setup label { position: relative; display: grid; gap: 5px; color: #9ebdcd; font-size: .76rem; }
.world-setup .weather-input { position: relative; display: block; }
.world-setup .weather-input > input { width: 100%; padding-right: 32px; }
.world-setup .weather-input > span { position: absolute; right: 9px; bottom: 10px; color: var(--muted); }
.world-setup label > small { min-height: 1.2em; color: var(--muted); font-size: .66rem; line-height: 1.2; }
.setup-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 14px; }
.setup-footer p { max-width: 650px; color: var(--muted); font-size: .78rem; line-height: 1.45; }
.setup-submit { min-width: 250px; }
.setup-footer-actions { display: flex; gap: 8px; }

.app-shell { max-width: 1500px; margin: 0 auto; padding: 20px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}
.header-actions { display: flex; align-items: center; gap: 9px; }
.setup-link { min-height: 42px; padding: 0 13px; color: var(--amber); border: 1px solid #70592d; background: #1f190f; cursor: pointer; }
.setup-link:hover, .setup-link:focus-visible { border-color: var(--amber); outline: none; }

.brand-lockup { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: #001118;
  background: var(--cyan);
  border: 3px solid #b9f6ff;
  box-shadow: 5px 5px 0 #153749;
  font-weight: 900;
  overflow: hidden;
}

.brand-mark img { width: 48px; height: auto; image-rendering: pixelated; transform: scale(1.45); }

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.15rem, 2vw, 1.55rem); letter-spacing: -0.03em; }
h2 { font-size: 1rem; }
h3 { margin-top: 3px; font-size: 1rem; }
.eyebrow { color: var(--cyan); font-size: 0.76rem; letter-spacing: 0.14em; }

.view-switch {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  background: #071520;
  box-shadow: 4px 4px 0 var(--shadow);
}

.switch-button {
  min-height: 42px;
  padding: 0 16px;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
}

.switch-button:hover, .switch-button:focus-visible { color: var(--ink); outline: 2px solid var(--cyan); outline-offset: -2px; }
.switch-button.active { color: #001118; background: var(--cyan); font-weight: 800; }

.status-ribbon {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid #624a28;
  background: #231c13;
  box-shadow: 4px 4px 0 var(--shadow);
}

.status-ribbon > span:not(.status-dot, .tick-chip, .seed-chip) { color: #d6b980; font-size: 0.88rem; }
.status-dot { width: 10px; height: 10px; background: var(--amber); box-shadow: 0 0 16px var(--amber); }
.tick-chip, .seed-chip { margin-left: auto; color: var(--muted); font-size: 0.78rem; }
.tick-chip { min-width: 132px; }
.seed-chip { margin-left: 0; }
.tick-chip b, .seed-chip b { color: var(--ink); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 14px; }
.simulation-card, .panel { border: 1px solid var(--line); background: rgba(11, 28, 42, 0.96); box-shadow: 6px 6px 0 var(--shadow); }
.simulation-card { padding: 18px; }
.simulation-mode-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.simulation-mode-button {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  color: var(--muted);
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(8, 24, 36, .94);
  cursor: pointer;
}
.simulation-mode-button span { color: var(--cyan); font-size: .62rem; letter-spacing: .12em; }
.simulation-mode-button strong { color: var(--text); font-size: .9rem; }
.simulation-mode-button small { line-height: 1.35; }
.simulation-mode-button:hover,
.simulation-mode-button:focus-visible { border-color: var(--cyan); outline: none; }
.simulation-mode-button.active {
  border-color: var(--green);
  background: rgba(22, 70, 65, .35);
  box-shadow: inset 4px 0 0 var(--green);
}
body[data-simulation-mode="simulation_step1"] .homebot-character,
body[data-simulation-mode="simulation_step1"] #homebot-ledger {
  display: none;
}
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-heading.compact { margin-bottom: 12px; }
.live-pill { padding: 7px 9px; border: 1px solid #216b52; color: var(--green); font-size: 0.75rem; }
.live-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; background: var(--green); box-shadow: 0 0 9px var(--green); }

.floor-switcher {
  display: grid;
  width: min(100%, 960px);
  margin: 0 auto 12px;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.floor-button {
  display: grid;
  min-height: 72px;
  padding: 11px 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #081722;
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
  text-align: left;
}
.floor-button span { color: var(--cyan); font-size: .68rem; letter-spacing: .12em; }
.floor-button strong { margin: 3px 0; color: var(--ink); font-size: .88rem; }
.floor-button small { color: var(--muted); font-size: .68rem; }
.floor-button:hover, .floor-button:focus-visible { border-color: var(--cyan); outline: none; transform: translateY(-1px); }
.floor-button.active { border-color: var(--cyan); background: #103044; box-shadow: inset 4px 0 0 var(--cyan), 3px 3px 0 var(--shadow); }
body[data-view="agent"] .floor-button[data-floor-target="upper"],
body[data-view="agent"] .floor-button[data-floor-target="lower"] { border-color: #5f4678; }

.tile-map {
  position: relative;
  display: grid;
  width: min(100%, 960px);
  margin-inline: auto;
  gap: 12px;
}

.plant-room {
  display: grid;
  grid-template-columns: auto 1fr minmax(210px, 38%);
  align-items: center;
  gap: 14px;
  min-height: 92px;
  padding: 14px 18px;
  border: 3px solid #37596a;
  background: #102434;
  box-shadow: inset 0 0 0 4px #091824;
}

.tile-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.1em; }
.plant-room strong { color: var(--red); }
.sprite { filter: saturate(0.85); font-size: 2rem; line-height: 1; image-rendering: pixelated; }
.pump-sprite {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 2px solid var(--line);
  background-color: #091824;
  background-image: url("/assets/teacher/office-devices.png");
  background-repeat: no-repeat;
  background-position: 72% 82%;
  background-size: 154px 509px;
  font-size: 1.7rem;
  image-rendering: pixelated;
}
.pump-sprite span { color: var(--cyan); text-shadow: 2px 2px 0 #06101a; }
.capacity-label { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 0.78rem; }
.capacity-label b { color: var(--red); }
.meter { height: 14px; padding: 2px; border: 2px solid #36566a; background: #07131e; overflow: hidden; }
.meter span { display: block; width: 100%; height: 100%; background: repeating-linear-gradient(90deg, var(--red) 0 10px, transparent 10px 13px); }

.floor-stage { min-height: 500px; }

.room { width: 100%; min-width: 0; border: 3px solid #37596a; background: #0a1824; box-shadow: inset 0 0 0 4px #06101a; }
.room-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 2px solid #37596a; background: #112838; }
.room-header span { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; }
.access-tag { padding: 5px 7px; border: 1px solid; }
.access-tag.allowed { color: var(--green); border-color: #2a765d; }
.access-tag.private { color: var(--purple); border-color: #6f4e91; }

.pixel-floor {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  aspect-ratio: 304 / 214;
  min-height: 384px;
  background-color: #10222f;
  background-image:
    linear-gradient(rgba(4, 17, 27, .20), rgba(4, 17, 27, .20)),
    url("/assets/teacher/home-floorplan.png");
  background-position: center;
  background-size: cover;
  overflow: hidden;
  image-rendering: pixelated;
}

.room-4b .pixel-floor { background-position: 62% center; }

.room-zone { z-index: 0; margin: 0; border: 0; background: transparent; pointer-events: none; }
.room-zone span { display: inline-block; margin: 7px; color: rgba(216, 244, 255, .52); font-size: .62rem; letter-spacing: .08em; }
.living-zone { grid-column: 1 / 4; grid-row: 1 / 5; }
.bedroom-zone { grid-column: 4 / 7; grid-row: 1 / 5; }
.service-zone { grid-column: 1 / 7; grid-row: 5 / 7; }
.collision-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.collision-layer.debugging {
  pointer-events: auto;
  cursor: crosshair;
}
.collision-body {
  position: absolute;
  display: block;
  pointer-events: none;
  border: 1px dashed rgba(255, 95, 109, .58);
  background: rgba(255, 95, 109, .10);
  box-shadow: inset 0 0 0 1px rgba(4, 17, 27, .45);
}
.wall-body {
  border-color: rgba(114, 146, 167, .55);
  background: rgba(114, 146, 167, .10);
}
.calibration-body {
  position: absolute;
  display: none;
  pointer-events: none;
  border: 2px solid var(--amber);
  background: rgba(255, 200, 87, .16);
  box-shadow: 0 0 0 1px rgba(4, 17, 27, .82);
}
.collision-calibrator {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 7;
  display: grid;
  gap: 6px;
  width: min(330px, calc(100% - 20px));
  padding: 10px;
  border: 1px solid var(--amber);
  background: rgba(4, 17, 27, .94);
  box-shadow: 4px 4px 0 var(--shadow);
}
.collision-calibrator strong { color: var(--amber); font-size: .72rem; }
.collision-calibrator output {
  color: var(--ink);
  font-size: .68rem;
  white-space: pre-wrap;
}
.collision-calibrator textarea {
  min-height: 74px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #07131e;
  font: 0.62rem/1.35 var(--mono);
}
.collision-calibrator button {
  justify-self: end;
  padding: 5px 8px;
  color: #06101a;
  border: 0;
  background: var(--amber);
  cursor: pointer;
  font-weight: 800;
}

.person {
  --sprite-facing-x: -96px;
  z-index: 2;
  grid-column: 2;
  grid-row: 3;
  align-self: center;
  justify-self: center;
  width: 32px;
  height: 56px;
  background-repeat: no-repeat;
  background-position: var(--sprite-facing-x) -8px;
  background-size: 1792px 1312px;
  filter: drop-shadow(3px 4px 0 rgba(3, 9, 14, .7));
  image-rendering: pixelated;
}
.person[data-direction="left"] { --sprite-facing-x: -64px; }
.person[data-direction="up"] { --sprite-facing-x: -32px; }
.person[data-direction="right"] { --sprite-facing-x: 0px; }
.person[data-direction="down"] { --sprite-facing-x: -96px; }
.person-3b {
  position: absolute;
  left: var(--agent-left, 76%);
  top: var(--agent-top, 42%);
  transform: translate(-50%, -50%);
  transition: left 900ms steps(9, end), top 900ms steps(9, end), filter 180ms ease;
  background-image: var(--agent-3-sprite, url("/assets/teacher/resident-3b.png"));
}
.person-4b {
  grid-column: 3;
  grid-row: 3;
  background-image: var(--agent-4-sprite, url("/assets/teacher/resident-4b.png"));
}
.homebot-character {
  position: relative;
  z-index: 3;
  grid-column: 2;
  grid-row: 4;
  align-self: end;
  justify-self: end;
  display: grid;
  justify-items: center;
  width: 32px;
  height: 48px;
  filter: drop-shadow(4px 5px 0 rgba(3, 9, 14, .72));
}
.map-actor {
  position: absolute;
  left: var(--actor-left);
  top: var(--actor-top);
  grid-column: auto;
  grid-row: auto;
  align-self: auto;
  justify-self: auto;
  transform: translate(-50%, -100%);
  transition: left 900ms steps(9, end), top 900ms steps(9, end), filter 180ms ease;
  will-change: left, top;
}
.floor-resident-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.floor-resident {
  position: absolute;
  left: var(--actor-left, var(--resident-left));
  top: var(--actor-top, var(--resident-top));
  width: calc(100% / 38);
  height: calc(200% / 29);
  background-image: var(--resident-sprite);
  background-repeat: no-repeat;
  background-position: var(--resident-frame-x, 86.9565%) 0;
  background-size: 2400% 100%;
  filter: drop-shadow(3px 4px 0 rgba(3, 9, 14, .72));
  image-rendering: pixelated;
  transform: translate(-50%, -100%);
  transform-origin: bottom center;
}
.floor-resident[data-direction="left"] { --resident-frame-x: 8.6957%; }
.floor-resident[data-direction="up"] { --resident-frame-x: 34.7826%; }
.floor-resident[data-direction="right"] { --resident-frame-x: 60.8696%; }
.floor-resident[data-direction="down"] { --resident-frame-x: 86.9565%; }
.floor-resident.map-actor {
  /* Positions are replayed one walkable tile at a time. Interpolating across
     multiple timer steps cuts corners and makes residents slide through walls. */
  transition: filter 180ms ease;
  will-change: left, top;
}
.floor-resident[data-presence="away"] { display: none; }
[data-map-actor="FA1"] { --actor-left: 25%; --actor-top: 32.8%; }
[data-map-actor="FA2"] { --actor-left: 64.5%; --actor-top: 25.9%; }
[data-map-actor="HB-3"] { --actor-left: 46.1%; --actor-top: 63.8%; }
[data-map-actor="HB-4"] { --actor-left: 46.1%; --actor-top: 63.8%; }
.homebot-character-4 { z-index: 3; }
.placeholder-agent { position: absolute; z-index: 4; top: 48%; transform: translate(-50%, -100%); }
.placeholder-agent.placeholder-alex { left: 44%; }
.placeholder-agent.placeholder-jordan { left: 55%; }
.homebot-sprite {
  width: 32px;
  height: 48px;
  image-rendering: pixelated;
}
.homebot-light {
  position: absolute;
  right: 2px;
  top: 14px;
  width: 7px;
  height: 7px;
  background: var(--cyan);
  box-shadow: 0 0 9px var(--cyan);
}
.homebot-light.alert { background: var(--red); box-shadow: 0 0 10px var(--red); }
.homebot-light.ok { background: var(--green); box-shadow: 0 0 10px var(--green); }
.homebot-bubble {
  position: absolute;
  left: 32px;
  bottom: 42px;
  width: max-content;
  max-width: 190px;
  min-height: 28px;
  padding: 7px 9px;
  color: #b9f6ff;
  border: 1px solid #397085;
  background: rgba(4, 17, 27, .94);
  box-shadow: 3px 3px 0 #06101a;
  font-size: .66rem;
  line-height: 1.35;
}
.homebot-bubble::before {
  content: "";
  position: absolute;
  left: 8px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid #397085;
  border-bottom: 1px solid #397085;
  background: rgba(4, 17, 27, .94);
  transform: rotate(45deg);
}
.homebot-bubble-4 { right: 32px; left: auto; }
.homebot-bubble-4::before { right: 8px; left: auto; }
.homebot-character.active .homebot-sprite { filter: brightness(1.18) saturate(1.1); }
.device-highlight {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
  box-shadow: 0 0 22px rgba(255, 200, 87, .44);
}

.device-readout { z-index: 4; grid-column: 1 / 7; grid-row: 6; align-self: end; display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 10px 10px; padding: 9px; border: 1px solid var(--line); background: rgba(4, 17, 27, .92); }
.readout-item { display: grid; place-items: center; align-content: center; gap: 3px; min-width: 0; padding: 3px 7px; text-align: center; }
.readout-item + .readout-item { border-left: 1px solid var(--line); }
.readout-item small { color: var(--muted); font-size: .68rem; }
.readout-item b { color: var(--ink); font-size: .78rem; }
.readout-item em { color: var(--muted); font-size: .62rem; font-style: normal; }
.sensor-readout b { color: var(--cyan); font-size: .92rem; }

.private-overlay { z-index: 5; grid-column: 1 / 7; grid-row: 1 / 7; align-self: stretch; display: grid; place-items: center; align-content: center; gap: 11px; margin: 12px; padding: 28px; border: 2px solid #735199; background: rgba(14, 10, 28, .95); text-align: center; }
.private-overlay span { font-size: 2.5rem; }
.private-overlay strong { color: var(--purple); }
.private-overlay small { color: #9f8ab4; font-size: .72rem; line-height: 1.5; }
.researcher-only { display: none; }
body[data-view="researcher"] .researcher-only { display: block; }
body[data-view="researcher"] #readout-4b { display: grid; }
body[data-view="researcher"] .private-overlay { display: none; }
body[data-view="agent"] .room-4b .pixel-floor { background: #120d1c; }
body[data-view="agent"] .room-4b .pixel-floor > :not(.private-overlay) { visibility: hidden; }
.researcher-only-block { display: none; }
body[data-view="researcher"] .researcher-only-block { display: block; }
.agent-only { display: block; }
body[data-view="researcher"] .agent-only { display: none; }

.complaint, .causal-tag { min-height: 46px; padding: 11px 14px; border-top: 2px solid #37596a; background: #0e2230; color: var(--muted); font-size: .78rem; }
.complaint.active { color: #ffd3d7; background: #34191e; }
.causal-tag { color: var(--amber); background: #2a2112; }
.agent-private-note { min-height: 46px; padding: 12px 14px; border-top: 2px solid #57416f; color: #b39acb; background: #1e1528; font-size: .76rem; }

.control-stack { display: grid; align-content: start; gap: 14px; }
.panel { padding: 16px; }
.panel-copy { margin: -2px 0 13px; color: var(--muted); font-size: .78rem; line-height: 1.55; }
.agent-state { padding: 5px 7px; color: var(--green); border: 1px solid #2a765d; font-size: .7rem; letter-spacing: .08em; }
.memory-chip { color: var(--muted); font-size: .72rem; }
.memory-chip b { color: var(--cyan); }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 45px; padding: 8px 10px; color: var(--ink); border: 1px solid var(--line); background: #102738; box-shadow: 3px 3px 0 #04101a; cursor: pointer; }
.action-button i {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  background-image: url("/assets/teacher/modern-ui.png");
  background-repeat: no-repeat;
  background-position: -383px -31px;
  image-rendering: pixelated;
}
.action-button:hover, .action-button:focus-visible { border-color: var(--cyan); outline: none; transform: translateY(-1px); }
.action-button.primary { color: #001118; border-color: var(--cyan); background: var(--cyan); font-weight: 800; }
.agent-roster { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 10px; }
.agent-roster.single-agent { grid-template-columns: 1fr; }
.agent-roster-empty { grid-column: 1 / -1; margin: 0; padding: 12px; color: var(--muted); border: 1px dashed var(--line); font-size: .72rem; text-align: center; }
.persona-card { display: flex; min-width: 0; align-items: center; gap: 9px; padding: 9px; border: 1px solid var(--line); background: #0a1e2c; }
.persona-card > div:last-child { display: grid; min-width: 0; gap: 3px; }
.persona-card strong { font-size: .74rem; overflow-wrap: anywhere; }
.persona-card small { color: var(--muted); font-size: .65rem; }
.persona-card em { color: var(--green); font-size: .6rem; font-style: normal; letter-spacing: .06em; }
.neighbour-agent { border-color: #5f4678; }
.neighbour-agent em { color: var(--purple); }
.persona-avatar { display: grid; place-items: center; width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid #315c70; background: #102b3a; overflow: hidden; }
.resident-agent-avatar-sprite {
  width: 24px;
  height: 48px;
  background-repeat: no-repeat;
  background-position: 86.9565% 0;
  background-size: 2400% 100%;
  image-rendering: pixelated;
}
.mini-agent { width: 32px; height: 48px; background-repeat: no-repeat; background-position: 0 -80px; background-size: 1792px 1312px; image-rendering: pixelated; }
.mini-alex { background-image: var(--agent-3-sprite, url("/assets/teacher/resident-3b.png")); }
.mini-jordan { background-image: var(--agent-4-sprite, url("/assets/teacher/resident-4b.png")); }
.selected-character { color: var(--cyan) !important; }
.persona-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0 0 12px; }
.persona-grid > div { min-width: 0; padding: 8px; border: 1px solid rgba(41, 75, 93, .75); background: #091925; }
.persona-grid dt { margin-bottom: 4px; color: var(--muted); font-size: .68rem; }
.persona-grid dd { margin: 0; color: var(--ink); font-size: .74rem; overflow-wrap: anywhere; }
.agent-now { display: grid; gap: 5px; padding: 10px; border-left: 3px solid var(--cyan); background: #0a2231; }
.agent-now span { color: var(--cyan); font-size: .66rem; letter-spacing: .09em; }
.agent-now strong { font-size: .76rem; line-height: 1.42; }
.agent-now small { color: var(--muted); font-size: .7rem; line-height: 1.45; }

body[data-running="true"] .mini-alex,
body[data-running="true"] .mini-jordan,
body[data-running="true"] .homebot-character.active { animation: agent-pulse 950ms steps(2, end) infinite; }

.persona-editor { margin-top: 10px; border: 1px solid #3a6074; background: #081923; }
.persona-editor summary { padding: 10px; color: var(--cyan); cursor: pointer; font-size: .74rem; }
.persona-editor > p { padding: 0 10px 8px; color: var(--muted); font-size: .66rem; line-height: 1.45; }
.persona-editor label { display: grid; gap: 5px; margin: 0 10px 9px; color: var(--muted); font-size: .68rem; }
.persona-editor output { justify-self: end; margin-top: -1.1rem; color: var(--ink); }
.persona-editor input, .persona-editor select { width: 100%; accent-color: var(--cyan); }
.persona-editor select { min-height: 34px; padding: 5px; color: var(--ink); border: 1px solid var(--line); background: #102739; }
.persona-editor .action-button { width: calc(100% - 20px); margin: 2px 10px 10px; }

.iot-panel { margin-top: 14px; padding: 15px; border: 1px solid var(--line); background: #081923; }
.iot-count { color: var(--muted); font-size: .72rem; }
.iot-count b { color: var(--cyan); }
.iot-device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.iot-device-card { min-width: 0; padding: 10px; border: 1px solid #294b5d; background: #0c2230; }
#mvp-tv-rooms small { display: block; white-space: normal; overflow-wrap: anywhere; line-height: 1.5; color: var(--muted); }
.noise-advance-row { margin-top: 12px; }
.noise-advance-row .action-button { width: 100%; }
.iot-device-card.private-device { border-color: #644879; background: #171020; }
.iot-device-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.iot-device-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; color: var(--cyan); border: 1px solid #315c70; background: #07151f; font-size: .9rem; }
.iot-device-card.private-device .iot-device-icon { color: var(--purple); border-color: #644879; }
.iot-device-meta { min-width: 0; flex: 1; }
.iot-device-meta strong { display: block; font-size: .72rem; line-height: 1.35; }
.iot-device-meta small { display: block; margin-top: 3px; color: var(--muted); font-size: .65rem; }
.iot-state { margin-top: 8px; padding: 6px; color: var(--green); background: #071720; font-size: .68rem; overflow-wrap: anywhere; }
.iot-device-card.private-device .iot-state { color: var(--purple); }
.iot-last { display: block; margin-top: 6px; color: #9ebdcd; font-size: .64rem; line-height: 1.4; }
.environment-history { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.environment-history-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.environment-history-title > div:first-child { display: grid; gap: 4px; }
.environment-history-tabs { display: inline-flex; flex: 0 0 auto; border: 1px solid #315c70; background: #07151f; }
.environment-history-tab { min-height: 28px; padding: 5px 10px; color: var(--muted); border: 0; border-right: 1px solid #315c70; background: transparent; cursor: pointer; font: inherit; font-size: .64rem; }
.environment-history-tab:last-child { border-right: 0; }
.environment-history-tab:hover { color: var(--ink); background: #102739; }
.environment-history-tab.active { color: #07151f; background: var(--cyan); }
.environment-history-tab:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.environment-history-table-wrap { max-height: 190px; overflow: auto; border: 1px solid #294b5d; background: #071720; }
.environment-history-table { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; font-size: .64rem; }
.environment-history-table th,
.environment-history-table td { padding: 6px 7px; border-bottom: 1px solid rgba(41, 75, 93, .55); text-align: left; white-space: nowrap; }
.environment-history-table th { position: sticky; top: 0; z-index: 2; color: var(--amber); background: #081923; box-shadow: 0 1px 0 rgba(41, 75, 93, .8); }
.environment-history-table td { color: #a9c7d5; }
.environment-history-table td:first-child,
.environment-history-table td:nth-child(2) { color: var(--cyan); }
.environment-history-table .empty-history-row td { min-height: 34px; color: var(--muted); text-align: center; white-space: normal; }
.device-interaction-ledger { display: grid; grid-template-columns: 210px 1fr; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.ledger-title { display: grid; align-content: start; gap: 4px; }
.ledger-title strong { color: var(--amber); font-size: .76rem; }
.ledger-title small { color: var(--muted); font-size: .66rem; line-height: 1.4; }
#iot-interaction-log { display: grid; gap: 5px; max-height: 130px; margin: 0; padding: 0; overflow: auto; list-style: none; }
#iot-interaction-log li { display: grid; grid-template-columns: 42px 96px 1fr; gap: 7px; padding: 6px 8px; color: #a9c7d5; background: #071720; font-size: .66rem; }
#iot-interaction-log li b { color: var(--cyan); }
#iot-interaction-log li em { color: var(--green); font-style: normal; }
#iot-interaction-log .empty-ledger { display: block; color: var(--muted); }

@keyframes agent-pulse {
  50% { filter: brightness(1.12) drop-shadow(0 5px 0 rgba(81, 229, 255, .32)); }
}

.text-button { color: var(--muted); border: 0; background: transparent; cursor: pointer; font-size: .75rem; }
.text-button:hover { color: var(--ink); }
.evidence-panel { min-height: 210px; }
.evidence-log { display: grid; gap: 9px; max-height: 215px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.evidence-log li { display: grid; grid-template-columns: 42px 1fr; gap: 8px; align-items: start; padding-bottom: 8px; border-bottom: 1px solid rgba(41, 75, 93, .55); }
.evidence-log li > span { padding: 3px 4px; color: var(--cyan); border: 1px solid #28566b; font-size: .66rem; text-align: center; }
.evidence-log p { color: #a7c4d3; font-size: .75rem; line-height: 1.48; }
.evidence-log .denied-entry > span { color: var(--red); border-color: #783b41; }
.evidence-log .success-entry > span { color: var(--green); border-color: #357057; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(420px, calc(100vw - 44px)); padding: 12px 14px; color: var(--ink); border: 1px solid var(--cyan); background: #092130; box-shadow: 5px 5px 0 var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

.asset-credit { margin: 16px 2px 0; color: #5f7f91; font-size: .72rem; line-height: 1.5; text-align: right; }

button:disabled { cursor: wait; opacity: .62; }

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .control-stack { grid-template-columns: 1fr 1fr; }
  .evidence-panel { grid-column: 1 / -1; }
  .iot-device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 740px) {
  .simulation-mode-switcher { grid-template-columns: 1fr; }
  .app-shell { padding: 12px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .header-actions { align-items: stretch; flex-direction: column; }
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; }
  .status-ribbon { flex-wrap: wrap; }
  .status-ribbon > span:not(.status-dot, .tick-chip, .seed-chip) { width: calc(100% - 28px); }
  .tick-chip { margin-left: 22px; }
  .workspace-grid, .control-stack, .floor-switcher { grid-template-columns: 1fr; }
  .evidence-panel { grid-column: auto; }
  .plant-room { grid-template-columns: auto 1fr; }
  .capacity-wrap { grid-column: 1 / -1; }
  .floor-stage { min-height: 430px; }
  .pixel-floor { min-height: 336px; }
  .homebot-bubble { max-width: 145px; font-size: .6rem; }
  .device-readout { grid-template-columns: repeat(2, 1fr); }
  .readout-item:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .readout-item:nth-child(4) { border-top: 1px solid var(--line); }
  .agent-roster { grid-template-columns: 1fr; }
  .setup-screen { padding: 0; }
  .setup-card { min-height: 100vh; max-height: none; border: 0; box-shadow: none; }
  .setup-heading, .setup-footer { align-items: stretch; flex-direction: column; }
  .setup-agent-grid, .setup-floor-grid, .world-setup, .iot-device-grid { grid-template-columns: 1fr; }
  .setup-submit { width: 100%; min-width: 0; }
  .setup-footer-actions { display: grid; }
  .device-interaction-ledger { grid-template-columns: 1fr; }
}

/* Interactive course-tile game world */
.app-shell { max-width: 1680px; }
.workspace-grid { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.simulation-card { padding: 14px; }
.map-heading { width: min(100%, 1120px); margin-inline: auto; }
.floor-switcher, .tile-map { width: min(100%, 1120px); }
.floor-switcher { margin-bottom: 8px; }
.floor-button { min-height: 58px; padding: 8px 12px; }
.floor-button strong { margin: 1px 0; }
.tile-world-legend {
  display: flex;
  width: min(100%, 1120px);
  margin: 0 auto 8px;
  padding: 6px 9px;
  gap: 14px;
  color: #7fa0b1;
  border: 1px solid #294b5d;
  background: #071520;
  font-size: .62rem;
  letter-spacing: .05em;
}
.tile-world-legend span { display: inline-flex; align-items: center; gap: 5px; }
.tile-world-legend span:last-child { margin-left: auto; color: var(--green); }
.tile-world-legend i { width: 9px; height: 9px; border: 1px solid; }
.legend-tile { border-color: var(--cyan) !important; background: #9a8f6c; }
.legend-walkable { border-color: var(--green) !important; background: rgba(105, 240, 174, .25); }
.legend-blocked { border-color: var(--red) !important; background: rgba(255, 95, 109, .25); }

.game-world-shell { gap: 8px; }
.plant-room {
  grid-template-columns: auto minmax(150px, 1fr) minmax(210px, 42%);
  min-height: 66px;
  padding: 8px 12px;
  border-width: 2px;
}
.pump-sprite { width: 42px; height: 42px; }
.floor-stage { min-height: 0; }
.room { border-color: #496775; background: #07131c; }
.room-header { padding: 8px 12px; }

.pixel-floor.tile-world {
  --tile-columns: 19;
  --tile-rows: 14;
  --tile-width: calc(100% / var(--tile-columns));
  --tile-height: calc(100% / var(--tile-rows));
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  aspect-ratio: 304 / 224;
  background-color: #10222f;
  background-image: none;
  isolation: isolate;
  overflow: hidden;
  cursor: crosshair;
}
.room-4b .pixel-floor.tile-world { background-position: initial; }
.tile-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}
.tile-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--cyan); }
.tile-grid-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(224, 248, 255, .09) 1px, transparent 1px),
    linear-gradient(rgba(224, 248, 255, .09) 1px, transparent 1px);
  background-size: var(--tile-width) 100%, 100% var(--tile-height);
  mix-blend-mode: screen;
}
.tile-world:not(.tiles-ready)::before {
  content: "LOADING COURSE TILESET";
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  color: var(--cyan);
  background: #07131c;
  font-size: .78rem;
  letter-spacing: .12em;
}
.tile-world.tile-error::before { content: "COURSE TILESET FAILED TO LOAD"; color: var(--red); }
.tile-cursor {
  position: absolute;
  z-index: 6;
  left: calc(var(--tile-column) * var(--tile-width));
  top: calc(var(--tile-row) * var(--tile-height));
  width: var(--tile-width);
  height: var(--tile-height);
  pointer-events: none;
  border: 2px solid var(--green);
  background: rgba(105, 240, 174, .18);
  box-shadow: 0 0 0 1px rgba(2, 9, 15, .78), 0 0 12px rgba(105, 240, 174, .5);
}
.tile-cursor[data-status="blocked"] { border-color: var(--red); background: rgba(255, 95, 109, .22); }
.tile-cursor[data-status="private"] { border-color: var(--purple); background: rgba(193, 140, 255, .2); }
.tile-inspector {
  position: absolute;
  left: 8px;
  bottom: 7px;
  z-index: 7;
  max-width: calc(100% - 16px);
  padding: 5px 7px;
  color: #d8f4ff;
  border: 1px solid rgba(81, 229, 255, .55);
  background: rgba(4, 17, 27, .9);
  box-shadow: 2px 2px 0 rgba(2, 9, 15, .72);
  font-size: clamp(.55rem, 1vw, .68rem);
  pointer-events: none;
}

.collision-layer { z-index: 2; }
.map-actor {
  z-index: 4;
  width: var(--tile-width);
  height: calc(var(--tile-height) + var(--tile-height));
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
}
.person.map-actor {
  transition: none;
  background-size: 5600% 2342.857%;
  background-position: var(--map-facing-x) .557%;
}
.person.map-actor[data-direction="left"] { --map-facing-x: 3.636%; }
.person.map-actor[data-direction="up"] { --map-facing-x: 1.818%; }
.person.map-actor[data-direction="right"] { --map-facing-x: 0%; }
.person.map-actor[data-direction="down"] { --map-facing-x: 5.455%; }
.homebot-character.map-actor { z-index: 5; }
.homebot-character.map-actor .homebot-sprite { width: 100%; height: 100%; object-fit: contain; }
.person.map-actor::before,
.homebot-character.map-actor::before {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  padding: 2px 4px;
  color: #e5f9ff;
  border: 1px solid rgba(81, 229, 255, .7);
  background: rgba(4, 17, 27, .9);
  box-shadow: 1px 1px 0 rgba(2, 9, 15, .8);
  font-size: .48rem;
  line-height: 1.1;
  white-space: nowrap;
  transform: translateX(-50%);
}
.person.map-actor::after,
.homebot-character.map-actor::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 22px;
  height: 9px;
  border: 1px solid rgba(105, 240, 174, .65);
  border-radius: 50%;
  background: rgba(4, 17, 27, .42);
  box-shadow: 0 0 7px rgba(105, 240, 174, .3);
  transform: translateX(-50%);
}
.homebot-character.map-actor::after { border-color: rgba(81, 229, 255, .75); box-shadow: 0 0 7px rgba(81, 229, 255, .35); }
.person-4b.interacting { filter: drop-shadow(0 0 8px var(--purple)); }
.person.map-actor.walking { animation: actor-walk 210ms steps(2, end) infinite; }

.tiled-iot-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.tiled-iot-object {
  position: absolute;
  min-width: 5px;
  min-height: 5px;
  border: 1px solid rgba(94, 204, 255, .92);
  border-radius: 2px;
  background: rgba(29, 144, 214, .3);
  box-shadow: inset 0 0 5px rgba(102, 218, 255, .2);
  pointer-events: auto;
  cursor: help;
}
.tiled-iot-object:hover,
.tiled-iot-object:focus-visible,
.tiled-iot-object.activity-highlight,
.tiled-iot-object.interaction-highlight {
  border-color: #b7edff;
  background: rgba(37, 157, 231, .43);
  outline: 1px solid rgba(183, 237, 255, .85);
  outline-offset: 1px;
}
.tiled-iot-name {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  z-index: 1;
  max-width: 120px;
  padding: 3px 6px;
  color: #d9f7ff;
  border: 1px solid rgba(94, 204, 255, .75);
  border-radius: 8px;
  background: rgba(4, 24, 37, .94);
  box-shadow: 0 3px 9px rgba(0, 0, 0, .3);
  font-size: .52rem;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 2px);
  transition: opacity 100ms ease, transform 100ms ease;
  pointer-events: none;
}
.tiled-iot-name::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  border: 4px solid transparent;
  border-top-color: rgba(94, 204, 255, .75);
  transform: translateX(-50%);
}
.tiled-iot-object:hover .tiled-iot-name,
.tiled-iot-object:focus-visible .tiled-iot-name,
.tiled-iot-object.activity-highlight .tiled-iot-name,
.tiled-iot-object.interaction-highlight .tiled-iot-name {
  opacity: 1;
  transform: translate(-50%, 0);
}
.device-highlight { outline-offset: 4px; }

.device-readout {
  position: relative;
  z-index: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0;
  padding: 8px;
  border: 0;
  border-top: 2px solid #37596a;
  background: #091923;
}
.device-readout.researcher-only { display: none; }
body[data-view="researcher"] .device-readout.researcher-only { display: grid; }
.private-overlay {
  position: absolute;
  inset: 12px;
  z-index: 10;
  margin: 0;
}
body[data-view="agent"] .room-4b .pixel-floor { background: #120d1c; }
body[data-view="agent"] .room-4b .pixel-floor > :not(.private-overlay) { visibility: hidden; }

.iot-panel { margin-top: 14px; }
.control-stack { gap: 10px; }
.panel { padding: 13px; }
.asset-credit { color: #6f91a2; }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 310px; }
}

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .control-stack { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 740px) {
  .control-stack { grid-template-columns: 1fr; }
  .plant-room { grid-template-columns: auto 1fr; }
  .capacity-wrap { grid-column: 1 / -1; }
  .pixel-floor.tile-world { min-height: 0; }
  .map-actor { transform: translate(-50%, -100%); }
  .homebot-bubble { display: none; }
  .tiled-iot-name { max-width: 92px; font-size: .46rem; }
  .tile-world-legend { flex-wrap: wrap; }
  .tile-world-legend span:last-child { width: 100%; margin-left: 0; }
  .environment-history-title { align-items: stretch; flex-direction: column; }
  .environment-history-tabs { align-self: start; }
}

@keyframes actor-walk {
  0%, 100% { filter: drop-shadow(3px 4px 0 rgba(3, 9, 14, .7)) brightness(1); }
  50% { filter: drop-shadow(2px 2px 0 rgba(3, 9, 14, .7)) brightness(1.16); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
.button-grid.researcher-only-block { display: none; }
body[data-view="researcher"] .button-grid.researcher-only-block { display: grid; }
/* A full-day read-only player replaces the shared-loop status ribbon. */
.day-replay { flex: 1; min-width: 260px; }
.replay-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.replay-toolbar button, .replay-toolbar select { background: #102d3b; color: #d6f5ff; border: 1px solid #326074; padding: 7px 10px; }
.replay-toolbar button:disabled { opacity: .45; }
#replay-status { font-size: 12px; color: #9cb9c7; }
#replay-seek { width: 100%; margin: 14px 0 0; accent-color: #54dfff; }
.replay-hours { display: flex; justify-content: space-between; font-size: 11px; color: #a9c7d3; border-top: 1px solid #326074; }
.replay-hours span::before { content: "│"; display: block; text-align: center; }
.json-file-picker { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.json-file-picker input[hidden] { display: none; }
#experiment-file-name, #experiment-import-feedback { overflow-wrap: anywhere; }
