/* SolarBench play desk - game mode. Pixel-friendly warm daylight theme. */

:root {
  --bg: #f2ead8;
  --bg2: #e9dfc8;
  --ink: #21301f;
  --panel: #fbf6ea;
  --line: #cdbf9f;
  --deep: #1b2a4a;
  --sky: #bde3f0;
  --green: #3f9d63;
  --forest: #2c5f3f;
  --amber: #f2a33c;
  --red: #d64545;
  --steel: #56636f;
  --card: #ffffff;
  --shadow: 0 2px 0 rgba(33, 48, 31, 0.18);
  --px-font: "Press Start 2P", "IBM Plex Mono", monospace;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    linear-gradient(180deg, #f6efdf 0%, var(--bg) 40%, var(--bg2) 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  min-height: 100vh;
}
svg { display: block; }
.px { image-rendering: pixelated; shape-rendering: crispEdges; }
button { font-family: inherit; }
code { font-family: var(--mono); font-size: 0.86em; }

/* ---------------------------------------------------------------- HUD */

.hud {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--deep);
  color: #f4efe6;
  border-bottom: 4px solid #101c35;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 40;
}
.hud .brand {
  font-family: var(--px-font);
  font-size: 13px;
  letter-spacing: 0.5px;
  color: #ffd23f;
  text-shadow: 2px 2px 0 #00000055;
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.hud .brand:hover { color: #ffe27a; }
.day-strip { display: flex; gap: 4px; }
.day-chip {
  font-family: var(--px-font);
  font-size: 8px;
  padding: 5px 6px;
  background: #10203e;
  color: #7d90b4;
  border: 1px solid #2c4472;
  border-radius: 4px;
}
.day-chip.on { background: var(--amber); color: #22303f; border-color: #b06f1a; }
.day-chip.past { color: #45597e; text-decoration: line-through; }
.sunbox { display: flex; align-items: center; gap: 8px; }
.sunbox .clock {
  font-family: var(--px-font);
  font-size: 11px;
  color: #ffffff;
}
.hud .meters { display: flex; gap: 10px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.meter {
  font-family: var(--mono);
  font-size: 12px;
  background: #10203e;
  border: 1px solid #2c4472;
  padding: 4px 9px;
  border-radius: 5px;
  color: #bde3f0;
  white-space: nowrap;
}
.meter b { color: #ffd23f; font-weight: 600; }
.hud .btn { margin: 0; }

.btn {
  border: 2px solid #1d2b1b;
  background: var(--green);
  color: #fff;
  padding: 7px 13px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 0 #1d2b1b;
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; box-shadow: none; }
.btn.warn { background: var(--amber); color: #22303f; }
.btn.danger { background: var(--red); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 3px 8px; font-size: 11.5px; border-width: 1.5px; }

.ticker {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 6px 16px;
  background: #fff8e6;
  border-bottom: 1px solid var(--line);
  color: #6b5b2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker b { color: #22303f; }

/* ---------------------------------------------------------------- layout */

.wrap {
  display: grid;
  grid-template-columns: minmax(560px, 1.25fr) minmax(360px, 0.85fr);
  gap: 14px;
  padding: 14px 16px 130px;  /* bottom clearance for Watts the mascot */
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 1080px) { .wrap { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px 6px;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--px-font);
  font-size: 11px;
  color: var(--forest);
  letter-spacing: 0.5px;
}
.panel-head .sub { font-size: 12px; color: var(--steel); }
.panel-head .spacer { flex: 1; }

/* ---------------------------------------------------------------- map */

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
  padding: 10px 14px 14px;
}
.site-tile {
  position: relative;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  padding: 0 0 6px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.06s ease;
  overflow: hidden;
}
.site-tile:hover { transform: translateY(-2px); border-color: var(--forest); }
.site-tile:focus-visible { outline: 3px solid var(--amber); }
.site-tile svg { width: 100%; height: auto; border-bottom: 2px solid var(--line); }
.site-tile .nameplate {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 0;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
}
.site-tile .cap { color: var(--steel); font-weight: 400; font-size: 11px; margin-left: auto; }
.badges {
  position: absolute;
  top: 5px;
  left: 5px;
  display: flex;
  gap: 4px;
}
.badge {
  font-family: var(--px-font);
  font-size: 8px;
  padding: 3px 5px;
  border-radius: 4px;
  color: #fff;
  border: 1px solid #00000033;
}
.badge.crit { background: var(--red); }
.badge.warn { background: var(--amber); color: #3a2a05; }
.badge.info { background: var(--steel); }
.badge.truck { background: var(--forest); }
.badge.drone { background: #4c6fb1; }

/* ---------------------------------------------------------------- office dock */

.dock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px 14px;
}
.dock-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.dock-btn:hover { border-color: var(--forest); }
.dock-btn:active { transform: translateY(2px); box-shadow: none; }
.dock-btn .pip {
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  border-radius: 8px;
  padding: 1px 6px;
}

/* ---------------------------------------------------------------- site view */

.site-view { padding: 0 14px 16px; }
.site-view .scene-frame {
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}
.site-view .scene-frame svg { width: 100%; height: auto; }
.hotspot { cursor: pointer; }
.hotspot:hover .hotspot-ring { opacity: 1; }
.hotspot-ring { opacity: 0; transition: opacity 0.1s; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
}
.action-btn:hover { border-color: var(--forest); }
.action-btn:active { transform: translateY(2px); box-shadow: none; }
.action-btn .a-label { font-weight: 600; font-size: 12.5px; font-family: var(--mono); }
.action-btn.pricey .a-label::after { content: " $"; color: var(--amber); }

.backlink {
  background: none;
  border: none;
  color: var(--forest);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: block;
  padding: 12px 14px 6px;
}

/* ---------------------------------------------------------------- feed */

.feed-panel { position: sticky; top: 64px; max-height: calc(100vh - 84px); display: flex; flex-direction: column; }
.feed-tabs { display: flex; gap: 6px; padding: 10px 14px 0; }
.feed-tab {
  font-family: var(--px-font);
  font-size: 9px;
  border: 2px solid var(--line);
  border-bottom: none;
  background: var(--bg2);
  border-radius: 7px 7px 0 0;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--steel);
  display: flex;
  gap: 6px;
  align-items: center;
}
.feed-tab.on { background: var(--card); color: var(--forest); }
.feed-tab .pip { background: var(--red); color: #fff; border-radius: 8px; padding: 1px 6px; font-family: var(--mono); font-size: 10px; }
.feed-body {
  flex: 1;
  overflow-y: auto;
  margin: 0 14px 14px;
  border: 2px solid var(--line);
  border-radius: 0 8px 8px 8px;
  background: var(--card);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feed-empty { color: var(--steel); font-size: 13px; padding: 14px; text-align: center; }

.card {
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fffdf7;
  font-size: 13px;
}
.card .card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12.5px;
}
.card .card-head .when { margin-left: auto; color: var(--steel); font-weight: 400; font-size: 11px; white-space: nowrap; }
.card .card-body { margin-top: 6px; overflow-wrap: anywhere; }
.card.err { border-color: var(--red); background: #fdf1f1; }
.card .raw-toggle {
  background: none;
  border: none;
  color: var(--steel);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  padding: 4px 0 0;
}
.card pre.raw {
  margin: 6px 0 0;
  font-size: 10.5px;
  max-height: 220px;
  overflow: auto;
  background: #f4f0e4;
  padding: 6px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
/* in-world documents (read_doc): rendered markdown, sans body, real tables */
.doc-body { max-height: 320px; overflow: auto; font-family: var(--sans); font-size: 13px; line-height: 1.5; }
.doc-body .doc-h { font-weight: 700; color: var(--forest); margin: 8px 0 3px; }
.doc-body .doc-h1 { font-size: 14.5px; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.doc-body .doc-h2 { font-size: 13.5px; }
.doc-body .doc-h3, .doc-body .doc-h4 { font-size: 13px; }
.doc-body .doc-p { margin: 4px 0; }
.doc-body .doc-ul { margin: 4px 0; padding-left: 18px; }
.doc-body .doc-ul li { margin: 2px 0; }
.doc-table { border-collapse: collapse; margin: 6px 0; width: 100%; font-size: 12px; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 4px 7px; text-align: left; vertical-align: top; }
.doc-table th { background: #f4f0e4; font-family: var(--mono); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-family: var(--mono); font-size: 12px; }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; font-weight: 600; }

.alarm-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 0;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
}
.alarm-row:first-child { border-top: none; }
.sev {
  font-family: var(--px-font);
  font-size: 7px;
  padding: 3px 4px;
  border-radius: 3px;
  color: #fff;
}
.sev.CRITICAL { background: var(--red); }
.sev.WARNING { background: var(--amber); color: #3a2a05; }
.sev.INFO { background: var(--steel); }
.alarm-row .where { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.alarm-row .msg { color: #333; }
.alarm-row .btn { margin-left: auto; }
.alarm-row.ackd { opacity: 0.45; text-decoration: line-through; }

.inv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 12.5px;
}
.inv-row:first-child { border-top: none; }
.dot { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.dot.ok { background: var(--green); }
.dot.zero { background: var(--red); }
.dot.mute { background: var(--steel); }
.inv-row .kw { margin-left: auto; font-weight: 600; }

.sparkline { margin-top: 4px; }
.spark-meta { font-family: var(--mono); font-size: 11px; color: var(--steel); margin-top: 2px; }

.msg-card { border-left: 4px solid var(--amber); }
.msg-card .from { font-weight: 700; }

/* ---------------------------------------------------------------- dialog */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 20px;
}
.dialog {
  width: min(560px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: 3px solid var(--deep);
  border-radius: 10px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25);
  padding: 16px 18px;
}
.dialog h3 {
  margin: 0 0 4px;
  font-family: var(--px-font);
  font-size: 12px;
  color: var(--forest);
  display: flex;
  gap: 8px;
  align-items: center;
}
.dialog .tool-tag { font-family: var(--mono); font-size: 11px; color: var(--steel); margin-bottom: 8px; }
.dialog .desc { font-size: 13px; color: #4c4633; margin: 0 0 12px; }
.dialog .field { margin-bottom: 12px; }
.dialog .field > span {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--steel);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dialog input[type="text"], .dialog input[type="email"], .dialog input[type="number"], .dialog textarea, .dialog select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 9px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
}
.dialog textarea { min-height: 74px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.chip.on { background: var(--forest); border-color: var(--forest); color: #fff; }
.chip small {
  display: block;
  font-family: var(--sans, inherit);
  font-size: 10px;
  font-weight: 500;
  opacity: 0.75;
  margin-top: 1px;
}
.chip.inv-dead { border-color: var(--red); }
.chip.inv-dead.on { background: var(--red); border-color: var(--red); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.choice-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  cursor: pointer;
  text-align: left;
}
.choice-card.on { border-color: var(--forest); background: #eef7ef; }
.choice-card b { display: block; font-family: var(--mono); font-size: 13px; }
.choice-card small { color: var(--steel); font-size: 11.5px; line-height: 1.3; display: block; margin-top: 3px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.dialog .req-note { color: var(--red); font-size: 12px; margin-right: auto; align-self: center; }

/* ---------------------------------------------------------------- drawers (scratchpad, grade) */

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(620px, 96vw);
  background: var(--panel);
  border-left: 3px solid var(--deep);
  z-index: 80;
  padding: 16px 18px;
  overflow-y: auto;
}
.drawer h3 { font-family: var(--px-font); font-size: 12px; color: var(--forest); margin: 0 0 10px; }
.drawer textarea {
  width: 100%;
  min-height: 46vh;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 13px;
  background: #fffef4;
}

/* Progressive report (spec §7): per-site notes box, quick-log chip, and the
   editable Report draft drawer. Intentionally light. */
.quicklog { margin-top: 8px; }
.quicklog-chip { opacity: 0.9; }
.site-notes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.site-notes-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 5px;
}
.site-note {
  width: 100%;
  min-height: 52px;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 13px;
  background: #fffef4;
  color: var(--ink);
  box-sizing: border-box;
}
.finding-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.finding-row:last-child { border-bottom: none; }
.finding-main { flex: 1; min-width: 0; }
.finding-site {
  display: block;
  font-family: var(--px-font);
  font-size: 10px;
  color: var(--forest);
  margin-bottom: 4px;
}
.finding-edit {
  width: 100%;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  background: #fffef4;
  color: var(--ink);
  box-sizing: border-box;
}
.finding-del { flex: none; }

.grade-hero {
  text-align: center;
  padding: 14px 0 6px;
}
.grade-hero .score {
  font-family: var(--px-font);
  font-size: 34px;
  color: var(--forest);
}
.grade-hero .score.bad { color: var(--red); }
.grade-hero .lbl { font-family: var(--mono); color: var(--steel); font-size: 12px; margin-top: 8px; }
.crit-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
}
.crit-row .w { font-family: var(--mono); color: var(--steel); white-space: nowrap; }
.pass { color: var(--green); font-weight: 700; }
.fail { color: var(--red); font-weight: 700; }
.gate-flag {
  font-family: var(--px-font);
  font-size: 8px;
  background: var(--red);
  color: #fff;
  padding: 3px 5px;
  border-radius: 3px;
  margin-left: 6px;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--deep);
  color: #ffd23f;
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 8px;
  z-index: 120;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}

/* ---------------------------------------------------------------- intro screen + tour */

.intro-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #101c35 0%, #1b2a4a 55%, #223a63 100%);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
}
.intro-card {
  width: min(760px, 96vw);
  text-align: center;
  color: #f4efe6;
}
.intro-title {
  font-family: var(--px-font);
  font-size: clamp(22px, 5vw, 40px);
  color: #ffd23f;
  text-shadow: 3px 3px 0 #00000066;
  letter-spacing: 2px;
  margin: 10px 0 2px;
}
.intro-sub {
  font-family: var(--px-font);
  font-size: clamp(9px, 1.8vw, 13px);
  color: #bde3f0;
  margin-bottom: 14px;
}
.intro-scene {
  border: 3px solid #0c1526;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 0 #00000055;
  background: #bde3f0;
}
.intro-scene svg { width: 100%; height: auto; display: block; }
.intro-truck { animation: introDrive 14s linear infinite; }
@keyframes introDrive {
  0%   { transform: translateX(-40px) scaleX(1); }
  49%  { transform: translateX(360px) scaleX(1); }
  50%  { transform: translateX(360px) scaleX(-1); }
  99%  { transform: translateX(-40px) scaleX(-1); }
  100% { transform: translateX(-40px) scaleX(1); }
}
.intro-cloud { animation: introCloud 26s linear infinite; }
.intro-cloud.c2 { animation-duration: 38s; animation-delay: -14s; }
@keyframes introCloud {
  from { transform: translateX(-70px); }
  to   { transform: translateX(360px); }
}
.intro-brief {
  text-align: left;
  background: #fbf6ea;
  color: #21301f;
  border: 3px solid #0c1526;
  border-radius: 10px;
  padding: 14px 18px;
  margin: 14px 0;
  font-size: 14.5px;
  line-height: 1.5;
  box-shadow: 0 6px 0 #00000055;
}
.intro-brief b { color: var(--forest); }
.intro-brief ul { margin: 8px 0 0; padding-left: 20px; }
.intro-brief li { margin: 3px 0; }
.intro-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.intro-actions .btn { font-family: var(--px-font); font-size: 11px; padding: 12px 18px; }
.intro-actions .intro-btn { min-width: 220px; }
.intro-sheep { animation: introGraze 3.4s ease-in-out infinite; transform-origin: 8px 12px; }
@keyframes introGraze {
  0%, 48%, 100% { transform: translateY(0) rotate(0deg); }
  60%, 72%      { transform: translateY(1px) rotate(7deg); }
  66%           { transform: translateY(1px) rotate(5deg); }
}

.tour-tip {
  position: fixed;
  z-index: 210;
  width: min(340px, 90vw);
  background: var(--deep);
  color: #f4efe6;
  border: 3px solid #ffd23f;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 6px 0 #00000066;
}
.tour-tip h4 {
  margin: 0 0 6px;
  font-family: var(--px-font);
  font-size: 10px;
  color: #ffd23f;
}
.tour-tip p { margin: 0 0 10px; font-size: 13px; line-height: 1.45; }
.tour-tip .tour-nav { display: flex; align-items: center; gap: 8px; }
.tour-tip .tour-count { font-family: var(--mono); font-size: 11px; color: #7d90b4; margin-right: auto; }
.tour-spot {
  outline: 3px dashed #ffd23f !important;
  outline-offset: 3px;
  border-radius: 6px;
  position: relative;
  z-index: 205;
}

/* ---------------------------------------------------------------- ask-ops helper bot */

.opsbot-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--deep);
  color: #ffd23f;
  border: 3px solid #ffd23f;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--px-font);
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 4px 0 #00000066;
}
.opsbot-fab:active { transform: translateY(2px); box-shadow: none; }

.opsbot {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 160;
  width: min(380px, 94vw);
  height: min(520px, 78vh);
  background: var(--panel);
  border: 3px solid var(--deep);
  border-radius: 12px;
  box-shadow: 0 8px 0 #00000055;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.opsbot-head {
  background: var(--deep);
  color: #f4efe6;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.opsbot-head .t { font-family: var(--px-font); font-size: 10px; color: #ffd23f; }
.opsbot-head .sub { font-size: 11px; color: #bde3f0; display: block; margin-top: 3px; font-family: var(--mono); }
.opsbot-head .x {
  margin-left: auto;
  background: none;
  border: none;
  color: #bde3f0;
  font-size: 18px;
  cursor: pointer;
  font-family: var(--mono);
}
.opsbot-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: repeating-linear-gradient(0deg, #faf5e9, #faf5e9 26px, #f5efe0 26px, #f5efe0 27px);
}
.opsbot-bubble {
  max-width: 86%;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.45;
  background: #fff;
}
.opsbot-bubble.user {
  align-self: flex-end;
  background: var(--forest);
  border-color: #1d3f2b;
  color: #fff;
  font-family: var(--mono);
  font-size: 12.5px;
}
.opsbot-bubble.bot b { color: var(--forest); }
.opsbot-bubble.bot code { background: #f0ead8; padding: 0 4px; border-radius: 4px; }
.opsbot-chips {
  padding: 10px 12px;
  border-top: 2px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 158px;
  overflow-y: auto;
}
.opsbot-chips .chip { font-size: 11.5px; padding: 4px 10px; }
.opsbot-chips .chip-group {
  width: 100%;
  font-family: var(--px-font);
  font-size: 8px;
  color: var(--steel);
  margin: 4px 0 0;
}

/* ---------------------------------------------------------------- Watts the mascot */

.opsbot-mascot {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 150;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.25));
}
.mascot-bubble {
  background: #fff;
  border: 2.5px solid var(--deep);
  border-radius: 10px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
  position: relative;
  margin-bottom: 8px;
  animation: bubbleFloat 3.2s ease-in-out infinite;
  white-space: normal;
  max-width: 200px;
  align-self: flex-end;
}
.mascot-bubble b { color: var(--forest); }
.mascot-bubble::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--deep);
}
@keyframes bubbleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.mascot-sheep { animation: sheepBob 2.4s ease-in-out infinite; }
@keyframes sheepBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.opsbot-mascot:hover .mascot-sheep { animation-duration: 0.7s; }
.mascot-name {
  font-family: var(--px-font);
  font-size: 8px;
  color: var(--deep);
  background: #ffd23f;
  border: 2px solid var(--deep);
  border-radius: 5px;
  padding: 2px 6px;
}
.opsbot-head-sheep { background: #f4efe6; border-radius: 6px; padding: 2px; display: inline-flex; }
@media (max-width: 700px) { .mascot-bubble { white-space: normal; max-width: 150px; } }

.intro-question {
  font-family: var(--sans);
  font-size: clamp(15px, 2.6vw, 20px);
  font-weight: 600;
  color: #f4efe6;
  margin: 8px 0 4px;
}

/* ---------------------------------------------------------------- grouped site actions */
.act-group { margin-top: 12px; }
.act-group-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.act-group-title {
  font-family: var(--px-font); font-size: 9px; color: var(--forest); letter-spacing: 0.3px;
}
.act-group-hint { font-size: 11.5px; color: var(--steel); }

/* ---------------------------------------------------------------- diegetic scene regions */
.hotspot { cursor: pointer; }
.hotspot-glow { transition: opacity 0.12s ease; }
.hotspot:hover .hotspot-glow { opacity: 0.22; }

.region-pop {
  position: fixed;
  z-index: 170;
  background: var(--panel);
  border: 3px solid var(--deep);
  border-radius: 10px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.3);
  padding: 8px;
  width: min(280px, 88vw);
}
.region-pop-title {
  font-family: var(--px-font); font-size: 9px; color: var(--forest);
  padding: 4px 6px 8px;
}
.region-pop-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 2px solid var(--line); background: var(--card); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 6px; cursor: pointer; text-align: left;
}
.region-pop-btn:last-child { margin-bottom: 0; }
.region-pop-btn:hover { border-color: var(--forest); }
.region-pop-btn b { display: block; font-family: var(--mono); font-size: 13px; color: var(--ink); }
.region-pop-btn.pricey b::after { content: " 💸"; }

.action-grid[hidden] { display: none; }
.chips[hidden] { display: none; }   /* the window widget's custom-chips disclosure */

/* ---------------------------------------------------------------- play-desk UX spec (end-flow, filters, alarm literacy, shelf, notes) */
.linklike {
  background: none; border: none; color: #9fb4d8; font-family: var(--mono);
  font-size: 11px; text-decoration: underline; cursor: pointer; padding: 2px 4px;
}
.linklike:hover { color: #ffd23f; }

.sunbox #btn-continue {
  margin-left: 8px; background: var(--forest); font-size: 12.5px; padding: 5px 10px;
}

.farm-filters {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 0 14px 10px;
}
.farm-filters .spark-meta { margin-left: auto; }

.sev-legend { display: inline-flex; gap: 4px; vertical-align: middle; }
.sev-legend .sev { cursor: help; }
.alarm-legend { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }

.alarm-row { cursor: pointer; }
.alarm-row:hover { background: #f5f0e2; }

.site-alarm-strip {
  margin: 0 14px 10px; border: 2px solid var(--line); border-radius: 8px;
  background: var(--card); padding: 8px 10px;
}
.site-alarm-strip .strip-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; margin-bottom: 4px;
}
.site-alarm-strip .strip-head .btn { margin-left: auto; }

.doc-row { cursor: pointer; }
.doc-row:hover { background: #f5f0e2; }

.alarm-full {
  font-family: var(--mono); font-size: 13px; background: #f0ead8;
  border-radius: 6px; padding: 8px 10px; margin: 0 0 10px; overflow-wrap: anywhere;
}
.dialog h3 .sev { font-size: 10px; vertical-align: middle; }

.sku-cards { max-height: 240px; overflow: auto; }

/* Desk handbook (doc shelf) - layperson cards, not a file dump */

.handoff-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: #2c4472;
  color: #f4f1ea;
  font-family: var(--mono);
  font-size: 13px;
  border-bottom: 3px solid var(--amber);
}
.handoff-banner .btn {
  background: var(--amber);
  color: #3a2a05;
  border: none;
  white-space: nowrap;
}
.dialog-wide { width: min(720px, 94vw); max-width: 720px; }
.doc-shelf { max-height: 58vh; overflow: auto; margin: 8px 0 4px; text-align: left; }
.doc-group { margin: 0 0 18px; }
.doc-group-title {
  font-family: var(--px-font); font-size: 11px; color: var(--forest);
  margin: 0 0 4px; letter-spacing: 0.3px;
}
.doc-group-blurb { margin: 0 0 10px; color: var(--steel); font-size: 13px; line-height: 1.4; }
.doc-card-grid { display: grid; gap: 8px; }
.doc-card {
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto;
  gap: 2px 12px; align-items: center;
  width: 100%; text-align: left;
  background: var(--card); border: 2px solid var(--line); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink);
  box-shadow: var(--shadow);
}
.doc-card:hover { border-color: var(--forest); }
.doc-card-title { font-weight: 600; font-size: 14.5px; grid-column: 1; }
.doc-card-blurb { font-size: 12.5px; color: var(--steel); line-height: 1.35; grid-column: 1; }
.doc-card-cta {
  grid-column: 2; grid-row: 1 / span 2;
  font-family: var(--mono); font-size: 12px; color: var(--forest); font-weight: 600;
}
.doc-open-head { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.doc-open-blurb { color: var(--steel); font-size: 13.5px; line-height: 1.45; }

/* Name-gate dialogs must sit above the intro screen (z 200). */
#player-overlay, #player-gate { z-index: 220; }

/* ---------------------------------------------------------------- Watts vs dialogs
   Watts must never cover working UI (the screenshot bug: sheep + bubble over
   the grade drawer's Close/Restart). Two layers of defense:
   1) hide the mascot (and the open Q&A panel) whenever any dialog, drawer,
      popover, or full-screen view is on the page; */
body:has(.overlay, .drawer, .intro-screen, .score-screen, .lb-screen, .region-pop) .opsbot-mascot,
body:has(.overlay, .drawer, .intro-screen, .score-screen, .lb-screen, .region-pop) .opsbot-fab,
body:has(.overlay, .drawer, .intro-screen, .score-screen, .lb-screen) .opsbot {
  display: none;
}
/* 2) fallback for browsers without :has() - Watts sits BELOW drawers (z 80)
   and overlays (z 90) instead of on top of them. */
.opsbot-mascot { z-index: 70; }

/* ---------------------------------------------------------------- terminal score page + leaderboard (SPA screens) */

.score-screen, .lb-screen {
  position: fixed;
  inset: 0;
  z-index: 195;   /* above the desk, below the intro (200) */
  background: linear-gradient(180deg, #101c35 0%, #1b2a4a 55%, #223a63 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 18px 44px;
  overflow-y: auto;
}
.score-card, .lb-card { width: min(700px, 96vw); color: #f4efe6; text-align: center; }
.score-kicker {
  font-family: var(--sans);
  font-size: clamp(14px, 2.2vw, 17px);
  font-weight: 500;
  color: #bde3f0;
  letter-spacing: 0.02em;
  line-height: 1.35;
}
.score-big {
  font-family: var(--px-font);
  font-size: clamp(40px, 9vw, 68px);
  color: #ffd23f;
  text-shadow: 4px 4px 0 #00000066;
  margin: 16px 0 10px;
}
.score-big.bad { color: #ff8a75; }
.score-sub { font-family: var(--mono); font-size: 12.5px; color: #bde3f0; margin: 4px 0; }
.score-sub b { color: #ffd23f; }
.score-body {
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  border: 3px solid #0c1526;
  border-radius: 10px;
  box-shadow: 0 6px 0 #00000055;
  padding: 12px 16px;
  margin: 16px 0;
}
.score-body h4 { font-family: var(--px-font); font-size: 10px; color: var(--forest); margin: 10px 0 4px; }
.score-ctas { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.score-ctas .btn.warn { font-family: var(--px-font); font-size: 11px; padding: 12px 18px; }
.score-ctas .btn.ghost { color: #f4efe6; }
.score-ctas .linklike { font-size: 12.5px; }

/* Benchmark funnel (Change B): the shift is a warm-up; point at the real one. */
.score-funnel {
  background: #0c1526;
  border: 3px solid var(--forest);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0 0 16px;
  text-align: center;
}
.score-funnel-title { font-family: var(--px-font); font-size: 12px; color: #ffd23f; margin-bottom: 8px; }
.score-funnel-body { font-size: 13.5px; line-height: 1.5; color: #f4efe6; margin-bottom: 12px; }
.score-funnel-btn {
  display: inline-block;
  font-family: var(--px-font);
  font-size: 11px;
  padding: 12px 18px;
  text-decoration: none;
}
.lb-funnel { font-size: 12.5px; color: #f4efe6; text-align: center; margin-top: 12px; }
.lb-funnel a { color: #ffd23f; font-weight: 700; text-decoration: none; }
.lb-funnel a:hover { text-decoration: underline; }

.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  border: 2px solid #ffffff77;
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btnSpin 0.8s linear infinite;
}
@keyframes btnSpin { to { transform: rotate(360deg); } }

.lb-head { display: flex; align-items: center; gap: 8px; justify-content: center; }
.lb-head h3 {
  font-family: var(--px-font);
  font-size: 15px;
  color: #ffd23f;
  text-shadow: 2px 2px 0 #00000066;
  margin: 0;
  margin-right: auto;
}
.lb-head .btn.ghost { color: #f4efe6; }
.lb-toggle { justify-content: center; margin: 12px 0; }
.lb-rows {
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  border: 3px solid #0c1526;
  border-radius: 10px;
  box-shadow: 0 6px 0 #00000055;
  padding: 8px 12px;
}
.lb-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 6px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 13px;
}
.lb-row:first-child { border-top: none; }
.lb-row .rank { width: 36px; flex: none; color: var(--steel); font-weight: 600; }
.lb-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb-row .dt { color: var(--steel); font-size: 11px; white-space: nowrap; }
.lb-row .pct { font-weight: 700; white-space: nowrap; }
.lb-row.me { background: #fff4d6; outline: 2px solid var(--amber); border-radius: 6px; }
.lb-row.me, .lb-row.me + .lb-row { border-top-color: transparent; }
.lb-row.ai { background: #e9f0fb; outline: 2px dashed #4c6fb1; border-radius: 6px; }
.lb-row.ai, .lb-row.ai + .lb-row { border-top-color: transparent; }
.lb-row.ai .pct { color: #2c4472; }

/* ---------------------------------------------------------------- multi-series sparkline legend */
.spark-legend { display: flex; gap: 12px; margin-top: 4px; }
.spark-swatch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--steel);
}
.spark-swatch i { width: 14px; height: 3px; display: inline-block; border-radius: 2px; }

/* ---------------------------------------------------------------- dispatch priority (timing framing) */
.choice-card.rec { border-color: var(--forest); box-shadow: 0 0 0 2px #3f9d6340; }
.rec-tag {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--forest);
  margin-top: 2px;
}
.emerg-link {
  color: var(--red);
  font-size: 12px;
  margin-top: 8px;
  display: inline-block;
}
.emerg-link:hover { color: var(--red); filter: brightness(0.8); }
.emerg-link.on-emerg {
  color: #fff;
  background: var(--red);
  text-decoration: none;
  border-radius: 6px;
  padding: 4px 8px;
}
.emerg-rule { display: block; margin-top: 2px; }
