:root {
  --bg: #eef2f5;
  --panel: #ffffff;
  --text: #17222d;
  --muted: #5a6876;
  --border: #d8e0e7;
  --code-bg: #eaf0f4;
  --accent: #0f8b8d;
  --accent-text: #ffffff;
  --ok: #1d8a4e;
  --ok-bg: #e5f5ec;
  --err: #c62f2f;
  --err-bg: #fdecec;
  --warn: #9a6400;
  --warn-bg: #fff4dc;
  --hint-bg: #fff8e1;
  --hint-border: #f0c14b;
  --screen-bg: #0d1820;
  --screen-text: #d6e6ef;
  --screen-muted: #8aa1b1;
  --screen-line: #22343f;
  --chart-line: #3fd0c9;
  --chart-guide: #f0c14b;
  --console-err: #ff8a8a;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --map-land: #e8ede2;
  --map-water: #a8d2ea;
  --map-park: #b6dea4;
  --map-tree: #7fbf6a;
  --map-hill: #e6d9b9;
  --map-road: #ffffff;
  --map-block: #d2d9df;
  --map-hall: #c9c1e6;
  --map-label: #6b7a88;
  --celebrate: #7a5af8;
  color-scheme: light;
}

/* Dark colours: on a dark device unless the player chose light, or whenever they chose dark (theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151b;
    --panel: #172029;
    --text: #e2ebf2;
    --muted: #93a4b3;
    --border: #2a3742;
    --code-bg: #22303b;
    --accent: #2fb5b2;
    --accent-text: #06201f;
    --ok: #5fd08f;
    --ok-bg: #15301f;
    --err: #ff7b7b;
    --err-bg: #3a1c1c;
    --warn: #f0c060;
    --warn-bg: #3a2f15;
    --hint-bg: #2e2814;
    --hint-border: #8a6d1f;
    --screen-bg: #091117;
    --map-land: #19232a;
    --map-water: #173a4f;
    --map-park: #1f3b27;
    --map-tree: #2c5a35;
    --map-hill: #302d20;
    --map-road: #34434f;
    --map-block: #27343e;
    --map-hall: #3a3456;
    --map-label: #8ea0af;
    --celebrate: #a58bff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151b;
  --panel: #172029;
  --text: #e2ebf2;
  --muted: #93a4b3;
  --border: #2a3742;
  --code-bg: #22303b;
  --accent: #2fb5b2;
  --accent-text: #06201f;
  --ok: #5fd08f;
  --ok-bg: #15301f;
  --err: #ff7b7b;
  --err-bg: #3a1c1c;
  --warn: #f0c060;
  --warn-bg: #3a2f15;
  --hint-bg: #2e2814;
  --hint-border: #8a6d1f;
  --screen-bg: #091117;
  --map-land: #19232a;
  --map-water: #173a4f;
  --map-park: #1f3b27;
  --map-tree: #2c5a35;
  --map-hill: #302d20;
  --map-road: #34434f;
  --map-block: #27343e;
  --map-hall: #3a3456;
  --map-label: #8ea0af;
  --celebrate: #a58bff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
code, kbd { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--code-bg); padding: 0.05em 0.35em; border-radius: 4px; }
/* Inline Python in briefings (pyhighlight.js), coloured like the editor: its light style, or One Dark. */
:root {
  --tok-kw: #770088; --tok-str: #aa1111; --tok-num: #116644; --tok-fn: #0451a5; --tok-prop: #0b6e75;
  --tok-self: #b35400; --tok-com: #8a6d00;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tok-kw: #c678dd; --tok-str: #98c379; --tok-num: #d19a66; --tok-fn: #61afef; --tok-prop: #e5c07b;
    --tok-self: #e06c75; --tok-com: #7d8799;
  }
}
:root[data-theme="dark"] {
  --tok-kw: #c678dd; --tok-str: #98c379; --tok-num: #d19a66; --tok-fn: #61afef; --tok-prop: #e5c07b;
  --tok-self: #e06c75; --tok-com: #7d8799;
}
code.py .tok-kw { color: var(--tok-kw); }
code.py .tok-str { color: var(--tok-str); }
code.py .tok-num { color: var(--tok-num); }
code.py .tok-fn { color: var(--tok-fn); }
code.py .tok-prop { color: var(--tok-prop); }
code.py .tok-self { color: var(--tok-self); }
code.py .tok-com { color: var(--tok-com); font-style: italic; }
/* Fonts like Cascadia Code draw <= as ≤ and != as ≠. Beginners need to see the characters they typed. */
code, kbd, pre, .editor .cm-scroller, .editor .cm-tooltip, .manual-entry h4, .manual-entry dt, .gauges dd, .clock,
.run-card td.num {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 0.01em; }
.topbar h1 .home { color: inherit; text-decoration: none; border-radius: 6px; }
.topbar h1 .home:hover { opacity: 0.85; }
.topbar h1 .home:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.topbar .sub { font-weight: 500; color: var(--muted); font-size: 15px; }
.status {
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--code-bg);
}
.status.ok { color: var(--ok); background: var(--ok-bg); }
.status.error { color: var(--err); background: var(--err-bg); }
.status.warn { color: var(--warn); background: var(--warn-bg); }
.status.running, .status.loading { color: var(--accent); }
.status.loading::before, .status.running::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.warning { margin: 0; padding: 8px 20px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 2fr) minmax(0, 3fr);
  gap: 16px;
  padding: 16px 20px;
  height: calc(100vh - 55px);
  min-height: 640px;
}
.panel, .workspace {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}
.briefing { padding: 18px 20px; overflow: auto; }

/* ---------- picker ---------- */
.picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.picker label, .speed {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  min-width: 0;
}
.picker label { flex: 1 1 140px; }
select {
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  width: 100%;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- briefing ---------- */
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.briefing h2 { margin: 2px 0 8px; font-size: 22px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tags:empty { display: none; }

/* The challenge's name and tags, with who the job is for beside them (underneath on a narrow panel). */
.challenge-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.challenge-name { flex: 1 1 200px; min-width: 0; }
.job-contact {
  flex: 0 1 auto; display: flex; align-items: center; gap: 8px;
  padding: 5px 6px; margin-top: 2px;
  border: 1px solid var(--border); border-radius: 999px;
}
.job-contact .avatar { width: 28px; height: 28px; font-size: 11px; }
.job-contact-who { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.25; }
.job-contact-who strong { white-space: nowrap; }
.job-contact-place { font-size: 12px; color: var(--muted); white-space: nowrap; }
.job-contact .btn { flex: 0 0 auto; border-radius: 999px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--code-bg); color: var(--muted); }
.tag.level { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.tag.draft { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
/* ---------- steps ---------- */
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.step-tab {
  font: inherit;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.step-tab .step-number { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.step-tab[aria-current="step"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.step-tab[aria-current="step"] .step-number { color: var(--accent); }
.step-tab:disabled { opacity: 0.55; cursor: not-allowed; }
.step-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.verdict-next { margin: 0 0 12px; }

/* Briefing sections: one idea each, with room to breathe. */
.sections { line-height: 1.6; }
.brief-section { margin-top: 22px; }
.brief-section:first-child { margin-top: 16px; }
.brief-section h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.sections p { margin: 0 0 10px; max-width: 62ch; }
.brief-list { margin: 0 0 10px; padding-left: 22px; max-width: 62ch; }
.brief-list li { margin: 3px 0; }
.brief-list li::marker { color: var(--accent); }
/* "Your plan": numbered steps in boxes, so each one reads as a separate thing to do. */
.brief-list.plan { list-style: none; padding-left: 0; counter-reset: plan; }
.brief-list.plan li {
  counter-increment: plan;
  position: relative;
  margin: 6px 0;
  padding: 6px 10px 6px 40px;
  border-radius: 8px;
  background: var(--code-bg);
}
.brief-list.plan li::before {
  content: counter(plan);
  position: absolute;
  left: 10px;
  top: 7px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 21px;
  text-align: center;
}

/* Briefing tabs: one part of the briefing at a time. The bar stays put while the panel scrolls. */
.brief-tabs {
  position: sticky;
  top: -18px; /* the panel's top padding */
  z-index: 2;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin: 12px -20px 0;
  padding: 8px 20px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brief-tabs [role="tab"] {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 6px 10px 5px;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.brief-tabs [role="tab"]:hover { color: var(--text); }
.brief-tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.brief-tabs [role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.brief-tabs [data-tab="results"].pass { color: var(--ok); }
.brief-tabs [data-tab="results"].fail { color: var(--err); }
.tab-panel { padding-top: 2px; }
.tab-panel[hidden] { display: none; }
.tab-panel > .verdict { margin-top: 14px; }

/* Fold-outs on the Plan tab: About this job (open on step 1, folded away after) and the Plan (open). */
.fold { margin-top: 14px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.fold[hidden] { display: none; }
.fold summary { cursor: pointer; font-weight: 600; }
.fold[open] summary { margin-bottom: 4px; }
.fold.about[open] summary { margin-bottom: -6px; } /* its sections bring their own headings */
.plan-box { border-color: var(--accent); }

/* Hints: each behind its own button, gentlest first. */
.hints-note { margin: 12px 0 8px; }
.hints { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hint-card { border: 1px solid var(--hint-border); background: var(--hint-bg); border-radius: 8px; padding: 8px 12px; }
.hint-card.locked { opacity: 0.55; }
.hint-title { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.hint-reveal { margin: 6px 0 2px; }
.hint-body p { margin: 6px 0 2px; }
.hint-body .code-block { margin: 6px 0 4px; }

.manual-note { margin: 12px 0 0; }

/* The 📚 Wiki tab: a page picker and a search box, then this step's components or the chosen page. */
.wiki-bar { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.wiki-bar select { flex: 1 1 180px; width: auto; }
.wiki-bar input {
  flex: 1 1 160px; min-width: 0; font: inherit; font-size: 14px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--panel); color: var(--text);
}
.wiki-bar input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.wiki-results { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.wiki-results[hidden] { display: none; }
.wiki-result {
  width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); color: var(--text);
}
.wiki-result:hover, .wiki-result:focus-visible { border-color: var(--accent); outline: none; }
.wiki-result .muted { font-size: 12px; color: var(--muted); white-space: nowrap; }
.wiki-article { margin-top: 12px; }
.wiki-article h3 { margin: 0 0 6px; }
.wiki-article .eyebrow { font-size: 11px; }

/* The mission: the step's job in a sentence, and the targets. */
.mission {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: 8px;
}
.mission-step { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.mission-title { margin: 2px 0 6px; font-size: 18px; }
.mission-goal { margin: 0 0 10px; font-size: 16px; line-height: 1.5; }
.targets h4 { margin: 0 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
/* Code samples in briefings: a read-only editor, so they look exactly like the IDE. */
.code-block { margin: 4px 0 10px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.code-block .cm-editor { font-size: 15px; }
.code-block .cm-scroller {
  font-family: var(--mono);
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.code-block .cm-editor.cm-focused { outline: none; }
/* Expected output: looks like the script log. */
.output-block { margin: 4px 0 10px; border-radius: 6px; overflow: hidden; background: var(--screen-bg); }
.output-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--screen-muted);
  padding: 4px 10px 0;
}
.output-block pre {
  margin: 0;
  padding: 4px 10px 8px;
  color: var(--screen-text);
  font-family: var(--mono);
  font-size: 14px;
  white-space: pre-wrap;
}
.targets { padding-top: 10px; border-top: 1px solid var(--border); }
.targets ul { margin: 4px 0 0; padding-left: 20px; }
.note { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

.manual-entry { margin-top: 10px; }
.manual-entry h4 { margin: 0; font-size: 15px; font-family: var(--mono); }
.manual-entry h4 .type { font-family: system-ui, sans-serif; font-weight: 400; color: var(--muted); font-size: 13px; }
.manual-entry > p { margin: 2px 0 4px; color: var(--muted); font-size: 14px; }
.manual-entry dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 14px; }
.manual-entry dt { font-family: var(--mono); font-size: 13.5px; }
.manual-entry dt.command::before { content: "⚙ "; color: var(--accent); }
.manual-entry dt.reading::before { content: "◉ "; color: var(--muted); }
.manual-entry dd { margin: 0; color: var(--muted); }
.manual-entry dt.attribute { padding-left: 2.2em; }
.manual-entry dd.returns { font-style: italic; }

.workspace { display: flex; flex-direction: column; overflow: hidden; }

/* ---------- toolbar & buttons ---------- */
.toolbar { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.speed { flex: 0 0 auto; }
/* Speed buttons: ▶ Test's, in the toolbar, and the city clock's, on the map. */
.speed-buttons { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.speed-btn {
  font: inherit; font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 5px 10px; border: 0; border-right: 1px solid var(--border);
  background: var(--panel); color: var(--muted); cursor: pointer;
}
.speed-btn:last-child { border-right: 0; }
.speed-btn:hover:not(:disabled) { color: var(--text); background: var(--code-bg); }
.speed-btn[aria-checked="true"] { background: var(--accent); color: var(--accent-text); }
.speed-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.speed-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.spacer { flex: 1; }
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.btn:hover:not(:disabled) { filter: brightness(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.ghost { background: transparent; }
.btn.small { padding: 2px 10px; font-size: 12px; }

/* ---------- editor ---------- */
.editor { flex: 5 1 0; min-height: 180px; overflow: hidden; }
.editor .cm-editor { height: 100%; font-size: 16px; }
.editor .cm-scroller { font-family: var(--mono); }
.editor .cm-editor.cm-focused { outline: none; }
/* The suggestion Enter will pick. The dark theme's own highlight is darker than the list and dims
   the text, so the chosen option looked less highlighted than the others. */
.editor .cm-editor .cm-tooltip-autocomplete > ul > li[aria-selected] {
  background: var(--accent);
  color: var(--accent-text);
}
.editor .cm-editor .cm-tooltip-autocomplete > ul > li[aria-selected] .cm-completionDetail { opacity: 0.8; }

/* ---------- monitor & log (the "screens") ---------- */
.lower {
  flex: 4 1 0;
  min-height: 260px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-top: 1px solid var(--border);
  background: var(--screen-bg);
  color: var(--screen-text);
}
.monitor, .log-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.monitor { border-right: 1px solid var(--screen-line); }
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 4px 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--screen-muted);
  border-bottom: 1px solid var(--screen-line);
}
.pane-head .btn { color: #b8c6d1; border-color: #34444f; }
.clock { font-family: var(--mono); text-transform: none; letter-spacing: 0; color: var(--screen-text); font-size: 13px; }
.monitor-body { flex: 1; overflow: auto; padding: 8px 14px 12px; }
.daybar { height: 4px; border-radius: 2px; background: var(--screen-line); margin-bottom: 8px; overflow: hidden; }
.daybar-fill { height: 100%; width: 0; background: var(--chart-line); }
.gauges { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin: 0 0 8px; }
.gauges div { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--screen-line); border-radius: 6px; padding: 4px 8px; }
.gauges dt { font-size: 11px; color: var(--screen-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.gauges dd { margin: 0; font-family: var(--mono); font-size: 15px; }
.chart-label { font-size: 11px; color: var(--screen-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.chart { display: block; width: 100%; height: 110px; }
.scores { font-size: 13px; color: var(--screen-muted); margin-top: 6px; }
.scores .met { color: #6fe0a0; }
.scores .missed { color: var(--console-err); }
.run-result { margin: 8px 0 0; padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.run-result.pass { background: rgba(95, 208, 143, 0.15); color: #7fe6aa; }
.run-result.fail { background: rgba(255, 120, 120, 0.12); color: #ffb0b0; }

.console {
  flex: 1;
  margin: 0;
  padding: 6px 14px 12px;
  overflow: auto;
  color: var(--screen-text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.console .stderr { color: var(--console-err); }
.console .info { color: var(--screen-muted); font-style: italic; }
.console .hint { color: #f3d27a; }
.console .error {
  display: block;
  margin: 6px 0;
  padding: 8px 12px;
  border-left: 4px solid var(--console-err);
  background: rgba(255, 120, 120, 0.1);
  color: #ffd2d2;
  border-radius: 4px;
}

/* ---------- Check results ---------- */
.verdict { margin-top: 20px; border-radius: 10px; padding: 14px 16px; border: 1px solid var(--border); }
.verdict.pass { background: var(--ok-bg); border-color: var(--ok); }
.verdict.fail { background: var(--err-bg); border-color: var(--err); }
.verdict-banner { font-size: 19px; font-weight: 700; margin: 0 0 10px; }
.verdict-message { margin: 0 0 10px; }
.runs { display: flex; flex-direction: column; gap: 10px; }
.run-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 10px 12px;
}
.run-card.pass { border-left-color: var(--ok); }
.run-card.fail { border-left-color: var(--err); }
.run-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.run-card.pass .run-status { color: var(--ok); }
.run-card.fail .run-status { color: var(--err); }
.run-card table { border-collapse: collapse; width: 100%; font-size: 14px; }
.run-card th, .run-card td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--border); }
.run-card th { font-size: 12px; color: var(--muted); font-weight: 600; }
.run-card td.num { font-family: var(--mono); white-space: nowrap; }
.run-card .run-about { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.run-card ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.run-card pre { margin: 8px 0 0; padding: 6px 8px; background: var(--code-bg); border-radius: 6px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .topbar { padding: 10px 16px; }
  .me-chip { margin-left: 0; }
  .layout { grid-template-columns: 1fr; height: auto; padding: 12px 16px; }
  .workspace { height: 120vh; min-height: 760px; }
  .briefing { overflow: visible; }
  .brief-tabs { top: 0; }
  .lower { grid-template-columns: 1fr; grid-template-rows: auto minmax(160px, 1fr); }
  .monitor { border-right: 0; border-bottom: 1px solid var(--screen-line); }
}

/* ---------- main navigation ---------- */
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 7px;
}
.mainnav a:hover { background: var(--code-bg); color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
.mainnav a:focus-visible, .me-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.me-chip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.me-chip[hidden] { display: none; }
.me-chip:hover { background: var(--code-bg); }
.me-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  font-size: 11px; font-weight: 700;
}
.me-name { font-weight: 600; }
.me-rank { color: var(--muted); }
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.badge[hidden] { display: none; }

/* ---------- step points ---------- */
.points-note { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--warn); }
.points-note.earned { color: var(--ok); }
.points-earned {
  display: inline-block;
  margin-left: 10px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 14px;
  vertical-align: 2px;
}

/* ---------- pages ---------- */
.page { padding: 20px; max-width: 1200px; margin: 0 auto; }
.page[hidden], .layout[hidden] { display: none; }
.page-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.page-card.narrow { max-width: 680px; margin: 0 auto; }
.page h2 { margin: 2px 0 10px; font-size: 22px; }
.section-title {
  margin: 20px 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.muted { color: var(--muted); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
a.btn { display: inline-block; text-decoration: none; }

.job-ad {
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.job-ad p { margin: 4px 0 0; }
.job-ad > p:first-child { margin-top: 0; }
.apply-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
.field input {
  font: inherit;
  font-weight: 400;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  max-width: 320px;
}
.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.job-ad strong { display: block; margin-top: 10px; }
.job-ad ul { margin: 4px 0 0; padding-left: 20px; }
.sending { margin: 0; color: var(--accent); font-weight: 600; }

.letter {
  border-left: 4px solid var(--celebrate);
  padding: 4px 16px;
  margin-bottom: 16px;
  background: color-mix(in srgb, var(--celebrate) 6%, transparent);
  border-radius: 0 8px 8px 0;
}
.letter .signature { font-style: italic; color: var(--muted); }
.checklist { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
}
.checklist li div { display: flex; flex-direction: column; }
.checklist li span { color: var(--muted); font-size: 14px; }
.checklist li.done { border-color: var(--ok); background: var(--ok-bg); }
.checklist li.done strong { color: var(--ok); }

/* ---------- ID card ---------- */
.id-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  max-width: 420px;
  margin-bottom: 16px;
}
.id-top {
  display: flex; justify-content: space-between;
  padding: 6px 14px;
  background: var(--accent); color: var(--accent-text);
  font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
}
.id-body { display: flex; gap: 14px; padding: 14px; align-items: center; }
#view-onboarding .id-card { margin-left: auto; margin-right: auto; }
.id-photo {
  flex: 0 0 72px; height: 86px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--code-bg); color: var(--accent);
  font-size: 26px; font-weight: 800;
}
.id-info { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 1px 12px; font-size: 14px; }
.id-info dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; align-self: center; }
.id-info dd { margin: 0; font-weight: 600; }

/* ---------- staff file ---------- */
.staff { display: grid; grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.rank-box h2 { margin-bottom: 4px; }
.rank-box p { margin: 6px 0 0; }
.reset-box p { margin: 6px 0 0; }
.reset-box .form-actions { margin-top: 12px; }
.reset-warning { color: var(--err); font-size: 13px; }
.progress { height: 10px; border-radius: 5px; background: var(--code-bg); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); border-radius: 5px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--muted); }
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ladder li {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  flex: 1 1 110px; padding: 8px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel); opacity: 0.6; font-size: 13px;
}
.ladder li.reached { opacity: 1; }
.ladder li.current { opacity: 1; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ladder-badge { font-size: 24px; }
.record { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 10px; overflow: hidden; font-size: 14px; }
.record th, .record td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.record th { font-size: 12px; color: var(--muted); }
.record td.num { font-family: var(--mono); white-space: nowrap; }
.record tr.complete td:first-child { color: var(--ok); font-weight: 600; }
.record .tag { margin-left: 6px; }

/* ---------- city map ---------- */
/* The map gets most of the screen: a wider page than the others, and as tall as the window allows. */
#view-map.page { max-width: 1800px; }
.map-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.map-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.city-map { display: block; width: 100%; height: auto; max-height: calc(100vh - 150px); border-radius: 8px; }
.m-land { fill: var(--map-land); }
.m-hill { fill: var(--map-hill); }
.m-contour { fill: none; stroke: var(--map-label); stroke-opacity: 0.25; stroke-width: 1.5; }
.m-sea { fill: var(--map-water); }
.m-river { fill: none; stroke: var(--map-water); stroke-width: 30; stroke-linecap: round; }
.m-park { fill: var(--map-park); }
.m-tree circle { fill: var(--map-tree); }
.m-path { fill: none; stroke: var(--map-road); stroke-width: 4; stroke-dasharray: 2 6; stroke-linecap: round; }
.m-blocks rect { fill: var(--map-block); }
.m-hall { fill: var(--map-hall); }
.m-roads path { fill: none; stroke: var(--map-road); stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.m-rail { fill: none; stroke: var(--map-label); stroke-width: 3; stroke-dasharray: 10 5; opacity: 0.6; }
.m-bridge { fill: var(--map-road); stroke: var(--map-label); stroke-width: 2; }
.m-label text {
  fill: var(--map-label); font: 700 13px system-ui, sans-serif; letter-spacing: 0.14em; text-anchor: middle;
}
/* The city's own time on the map: a night tint, and lit windows. */
.m-night { fill: #0a1433; opacity: 0; pointer-events: none; transition: opacity 0.9s linear; }
.m-lights { opacity: 0; pointer-events: none; transition: opacity 0.9s linear; }
.m-lights circle { fill: #ffd774; }
.map-clock-box { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.map-clock { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pin { cursor: pointer; }
.pin:focus { outline: none; }
.pin-ring { fill: var(--panel); stroke: var(--muted); stroke-width: 3; transition: stroke-width 0.15s; }
.pin.started .pin-ring { stroke: var(--accent); }
.pin.done .pin-ring { stroke: var(--ok); fill: var(--ok-bg); }
.pin.draft .pin-ring { stroke-dasharray: 5 4; }
.pin:hover .pin-ring, .pin:focus-visible .pin-ring, .pin.selected .pin-ring { stroke-width: 6; }
.pin.selected .pin-ring, .pin:focus-visible .pin-ring { stroke: var(--celebrate); }
.pin-icon { font-size: 22px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.pin-label {
  font: 700 13px system-ui, sans-serif; text-anchor: middle; fill: var(--text);
  paint-order: stroke; stroke: var(--map-land); stroke-width: 4; stroke-linejoin: round; pointer-events: none;
}
.pin-tick { font: 800 16px system-ui, sans-serif; fill: var(--ok); paint-order: stroke; stroke: var(--panel); stroke-width: 4; }
.pin-pulse { fill: none; stroke: var(--warn); stroke-width: 3; animation: pulse 1.8s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { from { opacity: 0.9; transform: scale(0.8); } to { opacity: 0; transform: scale(1.5); } }
@media (prefers-reduced-motion: reduce) { .pin-pulse { animation: none; opacity: 0.8; } }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 4px 0; font-size: 13px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--muted); background: var(--panel); }
.legend-item.started .legend-dot { border-color: var(--accent); }
.legend-item.done .legend-dot { border-color: var(--ok); background: var(--ok-bg); }
.legend-item.next .legend-dot { border-color: var(--warn); }
/* A fixed height, so the card doesn't jump about while hovering from pin to pin. */
.map-detail { height: 310px; display: flex; flex-direction: column; overflow: hidden; }
.map-detail h2 {
  font-size: 20px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.map-detail .client span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.map-detail .form-actions { margin-top: auto; }
.map-detail .tags { margin: 4px 0 10px; }
.tag.status-done { background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.tag.status-started { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
.client { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.map-detail .muted { font-size: 14px; margin: 6px 0 0; }
.facility-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.facility-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); font-size: 14px;
}
.facility-list li.done { border-color: var(--ok); }
.facility-list a { color: var(--text); text-decoration: none; font-weight: 600; }
.facility-list a:hover { color: var(--accent); }

/* ---------- avatars ---------- */
.avatar {
  flex: 0 0 auto;
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
}

/* ---------- CityChat ---------- */
/* Minimised, CityChat is a button floating in the bottom corner; opened, the panel takes its place. */
.im-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 15px; font-weight: 700;
  padding: 10px 16px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.im-launcher[hidden] { display: none; }
.im-launcher:hover { filter: brightness(1.05); }
.im-launcher:focus-visible { outline: 3px solid var(--celebrate); outline-offset: 2px; }
.im {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: min(460px, calc(100vw - 32px));
  height: min(540px, calc(100vh - 100px));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.im[hidden] { display: none; }
.im-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px 8px 14px; background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.im-head .btn { color: var(--accent-text); border-color: transparent; font-size: 16px; line-height: 1; }
.im-body { flex: 1; display: grid; grid-template-columns: 118px minmax(0, 1fr); min-height: 0; }
.im-contacts {
  list-style: none; margin: 0; padding: 6px 4px; overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg);
  display: flex; flex-direction: column; gap: 1px;
}
/* Support sits at the bottom of the list, apart from the team. */
.im-contacts li.pinned { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border); }
.im-contact {
  position: relative;
  width: 100%;
  display: flex; flex-direction: row; align-items: center; gap: 6px;
  padding: 4px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.im-contact .avatar { width: 24px; height: 24px; font-size: 10px; }
.im-contact:hover { background: var(--code-bg); }
.im-contact[aria-current="true"] { background: var(--panel); box-shadow: inset 0 0 0 1px var(--accent); }
.im-contact .badge { margin-left: auto; flex: 0 0 auto; }
.im-contact-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.im-thread-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 49px;
}
.im-thread-head div { display: flex; flex-direction: column; line-height: 1.2; }
.im-role { font-size: 12px; color: var(--muted); }
.im-messages { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.im-day { align-self: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 4px 0; }
.im-msg {
  max-width: 85%;
  padding: 7px 11px 4px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.im-msg.them { align-self: flex-start; background: var(--code-bg); border-bottom-left-radius: 4px; }
.im-msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.im-msg.me code { background: rgba(255, 255, 255, 0.2); }
.im-time { display: block; text-align: right; font-size: 10px; opacity: 0.6; margin-top: 1px; }
.im-link { font-weight: 700; color: var(--accent); }
.im-msg.typing { display: flex; gap: 4px; padding: 10px 12px; }
.im-msg.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite;
}
.im-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.im-msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.im-replies {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end;
  padding: 8px 12px; border-top: 1px solid var(--border); min-height: 44px; align-items: center;
}
/* Typing to Support. */
.im-compose { display: flex; gap: 6px; align-items: flex-end; width: 100%; }
.im-compose textarea {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 14px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text);
}
.im-compose textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.im-reply { border-color: var(--accent); color: var(--accent); border-radius: 999px; }
.im-note, .im-empty { font-size: 13px; color: var(--muted); margin: auto; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; bottom: 76px; right: 20px; z-index: 50; /* just above the CityChat button */
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; gap: 10px; align-items: flex-start;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font: inherit;
  font-size: 14px;
  text-align: left;
  animation: slide-in 0.25s ease-out;
}
button.toast { cursor: pointer; }
.toast.celebrate { border-left-color: var(--celebrate); background: color-mix(in srgb, var(--celebrate) 10%, var(--panel)); }
.toast-body { display: flex; flex-direction: column; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

@media (max-width: 900px) {
  .page { padding: 12px 16px; }
  .staff, .map-page { grid-template-columns: 1fr; }
  .me-rank { display: none; }
  .im { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: min(560px, calc(100vh - 80px)); }
  .toasts { right: 8px; left: 8px; align-items: stretch; }
  .toast { max-width: none; }
}
/* The status pill sits on the right when there is no staff chip (before the application). */
.me-chip[hidden] + .city-clock { margin-left: auto; }
/* The build: version, branch and commit, at the right of the top bar. */
.build-tag { font: 11px/1.4 var(--mono); color: var(--muted); white-space: nowrap; opacity: 0.8; }
.build-tag[hidden] { display: none; }
/* The city's own clock, in the top bar. */
.city-clock {
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums; cursor: default;
}

/* Light or dark, on the job application and staff details. */
.theme-choice { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.theme-choice legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.theme-option {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px;
}
.theme-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-option input { accent-color: var(--accent); margin: 0; }
