:root {
  --ink: #1d293d;
  --muted: #4a5565;
  --line: #f0dcc7;
  --panel: #fffaf4;
  --bench: #fdf3e8;
  --grid: #ead1b8;
  --teal: #c2410c;          /* MGUG theme 2026-11-12: accent (white text 5.2:1) */
  --teal-dark: #b93d0b;
  --teal-tint: #ffedd5;
  --stop: #b83227;
  --ok: #1e9e5a;
  --warn: #c98a00;
  --code-bg: #282c34;
  --brand: #ff6900;         /* MGUG saffron: decoration only (2.9:1, not for text) */
  --brand-strong: #f54900;  /* large headings / numbers */
  --cream: #fff7ed;
  --peach: #ffead1;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  background: #fff4e8;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: var(--teal); stroke-width: 1.8; stroke-linecap: round; }
.brand-logo { height: 36px; width: 36px; display: block; }
.brand abbr { text-decoration: none; color: var(--teal-dark); font-weight: 600; }
.title {
  border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; min-width: 0; width: 240px;
  font-weight: 500; background: transparent;
}
.title:hover { border-color: var(--line); }
.title:focus { border-color: var(--teal); background: #fff; outline: none; }
.save-state { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px; border: 1px solid transparent;
  font-weight: 500; cursor: pointer; background: #fff; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; fill: currentColor; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.run { background: var(--teal); color: #fff; }
.btn.run:hover:not(:disabled) { background: var(--teal-dark); }
.btn.run.stop { background: var(--stop); }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { background: var(--panel); }
.btn.ghost[aria-pressed="true"] { background: var(--teal-tint); border-color: #fdba74; color: var(--teal-dark); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.danger { color: var(--stop); border-color: var(--line); }
.link { background: none; border: 0; padding: 0; color: var(--teal-dark); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }
.account { color: var(--teal-dark); text-decoration: none; font-weight: 500; padding: 6px 4px; white-space: nowrap; }

.menu { position: relative; }
.menu-list {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  min-width: 230px; padding: 6px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(30 42 50 / .14);
}
.menu-list.right { left: auto; right: 0; }
.menu-list button {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 5px; cursor: pointer;
}
.menu-list button:hover { background: var(--panel); }
.menu-list .menu-note { display: block; color: var(--muted); font-size: 12px; }

.banner { padding: 8px 16px; background: #fff7e0; border-bottom: 1px solid #f0dc9f; font-size: 13.5px; }
.banner .btn { margin-left: 10px; padding: 3px 10px; }

/* ---------- layout ---------- */
.app { flex: 1; min-height: 0; display: flex; }
.palette { width: 196px; flex: none; border-right: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; min-height: 0; }
.search { margin: 10px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; }
.part-list { overflow-y: auto; padding: 0 10px 16px; }
.part-cat { margin: 14px 2px 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.part-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.part-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff;
  cursor: grab; user-select: none; touch-action: none; text-align: center; font-size: 11.5px; line-height: 1.2;
}
.part-item:hover { border-color: #fdba74; background: var(--teal-tint); }
.part-thumb { width: 64px; height: 48px; position: relative; overflow: hidden; pointer-events: none; }
.part-thumb > * { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(var(--s, 0.5)); }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; opacity: .8; transform-origin: 0 0; }

.stage { flex: 1; min-width: 0; position: relative; }
.canvas {
  position: absolute; inset: 0; overflow: hidden;
  background-color: var(--bench);
  background-image: radial-gradient(var(--grid) 1.1px, transparent 1.3px);
  cursor: default; touch-action: none;
}
.canvas.panning { cursor: grabbing; }
.canvas.drawing { cursor: crosshair; }

.toolbar {
  position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 6px rgb(30 42 50 / .06);
}
.toolbar button { width: 32px; height: 30px; border: 0; background: none; border-radius: 5px; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.toolbar button:hover:not(:disabled) { background: var(--panel); }
.toolbar button:disabled { color: #c9b8a8; cursor: default; }
.toolbar svg { width: 18px; height: 18px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }

.inspector {
  position: absolute; top: 12px; right: 12px; width: 250px; padding: 12px 14px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgb(30 42 50 / .1);
}
.inspector h3 { margin: 0 0 2px; font-size: 14px; }
.inspector .kind { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.inspector label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.inspector input[type="text"], .inspector select, .inspector .res-row input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.inspector .res-row { display: flex; gap: 6px; }
.inspector .res-row select { width: 80px; flex: none; }
.inspector input[type="range"] { width: 100%; accent-color: var(--teal); }
.inspector .range-value { font-family: var(--mono); font-size: 12.5px; }
.inspector .actions { display: flex; gap: 6px; margin-top: 14px; }
.inspector .actions .btn { padding: 5px 10px; font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--teal); }
.inspector .note { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.45; }

.stage-status {
  position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; gap: 14px; align-items: center; pointer-events: none;
}
.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; background: rgb(255 255 255 / .92); border: 1px solid var(--line); border-radius: 20px; font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grid); }
.status[data-state="running"] .dot { background: var(--ok); box-shadow: 0 0 0 3px rgb(30 158 90 / .18); }
.status[data-state="busy"] .dot { background: var(--warn); }
.status[data-state="error"] .dot { background: var(--stop); }
.speed { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.warn-text { color: #8a4b00; background: #fff4dc; border: 1px solid #f0d49a; border-radius: 6px; padding: 4px 10px; font-size: 13px; }
.warn-text:empty { display: none; }
.empty-hint { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%); margin: 0; color: var(--muted); background: rgb(255 255 255 / .9); padding: 12px 16px; border-radius: 8px; border: 1px dashed var(--grid); }

/* ---------- circuit editor ---------- */
.cl-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.cl-parts { position: absolute; left: 0; top: 0; }
.cl-part { position: absolute; cursor: move; }
.cl-part > * { display: block; pointer-events: none; }
.canvas.simulating .cl-part { cursor: default; }
.canvas.simulating .cl-part > * { pointer-events: auto; }
.canvas.readonly .cl-part { cursor: default; }
.cl-part.selected { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 3px; }
.cl-part.warn::after {
  content: "!"; position: absolute; top: -10px; right: -10px; width: 18px; height: 18px; border-radius: 50%;
  background: #e8a000; color: #fff; font: 700 12px/18px var(--sans); text-align: center; pointer-events: none;
}
.cl-wires, .cl-overlay { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.cl-wire-outline { fill: none; stroke: rgb(0 0 0 / .35); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; }
.cl-wire-line { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.cl-wire-glow { fill: none; stroke: rgb(194 65 12 / .35); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; }
.cl-wire-hit { fill: none; stroke: transparent; stroke-width: 10; pointer-events: stroke; cursor: pointer; }
.cl-wire-end { pointer-events: none; }
.cl-pin { fill: transparent; stroke: transparent; pointer-events: all; cursor: crosshair; }
.canvas:not(.simulating):not(.readonly) .cl-part:hover ~ .x, .cl-pin:hover { fill: rgb(194 65 12 / .35); stroke: var(--teal); stroke-width: 1.2; }
.cl-pin.hl { fill: rgb(30 158 90 / .45); stroke: var(--ok); stroke-width: 1; }
.canvas.drawing .cl-pin { fill: rgb(194 65 12 / .12); }
.canvas.simulating .cl-pin, .canvas.readonly .cl-pin { pointer-events: none; }
.cl-handle { fill: #fff; stroke: var(--teal); stroke-width: 1.6; pointer-events: all; cursor: move; }
.cl-draft { fill: none; stroke: var(--teal); stroke-width: 2.6; stroke-dasharray: 5 4; stroke-linecap: round; }
.cl-tooltip {
  position: absolute; transform: translate(-50%, -100%); padding: 3px 8px; border-radius: 5px; white-space: nowrap;
  background: var(--ink); color: #fff; font-size: 12px; pointer-events: none; z-index: 5;
}

/* ---------- code panel ---------- */
.code-panel { width: 46%; min-width: 360px; max-width: 760px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #fff; min-height: 0; }
.code-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.code-head select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-weight: 500; }
.board-label { font-size: 13px; }
.build-info { margin-left: auto; font-size: 12.5px; font-family: var(--mono); }
.code-body { flex: 1; min-height: 0; display: flex; }
.blockly { flex: 1; min-width: 0; position: relative; }
.text-editor { flex: 1; min-width: 0; background: var(--code-bg); overflow: hidden; }
.code-body[data-mode="blocks"] .text-editor { display: none; }
.code-body[data-mode="text"] .blockly { display: none; }
.code-body[data-mode="blocks+text"] .text-editor { flex: 0 0 44%; }
.text-editor .cm-editor { height: 100%; font-size: 13px; }
.text-editor .cm-scroller { font-family: var(--mono); line-height: 1.55; }
.muted { color: var(--muted); font-weight: 400; }

.log { max-height: 30%; display: flex; flex-direction: column; border-top: 3px solid var(--stop); background: #1d2026; color: #e6e6e6; }
.log-head { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 13px; }
.log-head .link { color: #9ad7db; }
.log pre { margin: 0; padding: 0 12px 10px; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; }

.serial { display: flex; flex-direction: column; height: 34%; min-height: 160px; border-top: 1px solid var(--line); }
.serial-head { display: flex; align-items: center; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.serial-head .spacer { flex: 1; }
.serial-head .link { margin-left: 12px; }
.tab { border: 0; background: none; padding: 8px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); font-weight: 500; }
#serial-out { flex: 1; margin: 0; padding: 8px 12px; overflow: auto; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; }
#serial-out:empty::before { content: "Output from Serial.print() appears here while the simulation runs."; color: var(--muted); font-family: var(--sans); }
.plotter { flex: 1; width: 100%; min-height: 0; display: block; }
.serial-form[hidden], .netview[hidden] { display: none; }
.tab-count { display: inline-block; min-width: 16px; margin-left: 5px; padding: 0 5px; border-radius: 8px; background: var(--teal-tint); color: var(--teal-dark); font-size: 11px; font-weight: 600; }
.tab-count[hidden] { display: none; }
.netview { flex: 1; min-height: 0; overflow: auto; font-size: 12.5px; }
.net-empty { padding: 10px 12px; color: var(--muted); }
.net-empty p { margin: 4px 0 0; line-height: 1.45; max-width: 75ch; }
.net-empty[hidden] { display: none; }
.net-row { border-bottom: 1px solid #fdf0e3; }
.net-row > summary { list-style: none; display: flex; gap: 8px; align-items: center; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.net-row > summary::-webkit-details-marker { display: none; }
.net-row > summary:hover { background: var(--panel); }
.net-row[open] > summary { background: var(--panel); }
.net-row.leak > summary { box-shadow: inset 3px 0 0 var(--warn); }
.net-row.attacker > summary { box-shadow: inset 3px 0 0 var(--stop); background: #fdf3f2; }
.net-t { font-family: var(--mono); color: var(--muted); width: 58px; flex: none; font-size: 11.5px; }
.net-dir { font-weight: 700; width: 12px; flex: none; }
.net-dir.out { color: var(--teal-dark); }
.net-dir.in { color: #6b3fa0; }
.net-ends { font-family: var(--mono); font-size: 11.5px; color: #364153; flex: none; }
.net-proto { font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 3px; flex: none; }
.net-proto.http { background: #fff4dc; color: #8a5a00; }
.net-proto.tls { background: #e2f4ea; color: #17733f; }
.net-proto.tcp { background: #fdf0e3; color: var(--muted); }
.net-flag { font-size: 10.5px; font-weight: 600; color: #fff; background: var(--stop); padding: 0 5px; border-radius: 3px; flex: none; }
.net-sum { overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-family: var(--mono); font-size: 11.5px; }
.net-body { padding: 4px 12px 10px 90px; }
.net-body p { margin: 4px 0 8px; line-height: 1.45; max-width: 80ch; font-size: 12.5px; }
.net-bad { color: #8c2a20; background: #fbe9e7; border-radius: 5px; padding: 6px 9px; }
.net-good { color: #17733f; background: #e2f4ea; border-radius: 5px; padding: 6px 9px; }
.net-bad code { font-family: var(--mono); background: #fff; padding: 0 4px; border-radius: 3px; }
.net-raw { margin: 0; padding: 8px 10px; background: #1f2830; color: #d6e2e8; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; }
.net-raw.hex { color: #9fb4bf; white-space: pre; word-break: normal; }
.net-secret { background: #ffcf4a; color: #1e2a32; border-radius: 2px; padding: 0 2px; }
.net-acts { display: flex; gap: 8px; margin-top: 8px; }
.net-acts .btn { padding: 3px 10px; font-size: 12.5px; }
.net-edit { width: 100%; box-sizing: border-box; margin-top: 8px; font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.net-edit + .btn { margin-top: 6px; }
.net-proto.udp { background: #e7eefb; color: #2c5fb0; }
.net-bar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 6px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.net-bar .spacer { flex: 1; }
.net-bar .btn { padding: 3px 10px; font-size: 12.5px; }
.net-bar .btn[disabled] { opacity: .5; cursor: not-allowed; }
.net-rate { font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: pre; color: #364153; }
.net-views { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.net-view { border: 0; background: #fff; padding: 2px 9px; font: inherit; font-size: 12px; color: #364153; cursor: pointer; }
.net-view + .net-view { border-left: 1px solid var(--line); }
.net-view[aria-pressed="true"] { background: var(--teal-tint); color: var(--teal-dark); font-weight: 600; }
.net-gateway { background: #fff; color: var(--teal-dark); border: 1px solid var(--teal-dark); }
.net-gateway[aria-pressed="true"] { background: var(--teal-dark); color: #fff; }
.net-panel[hidden] { display: none; }
.net-pad { padding: 8px 12px; }
.net-h { margin: 10px 12px 4px; font-size: 12.5px; }
.net-pad .net-h { margin: 2px 0 6px; }
.net-none { color: var(--muted); padding: 2px 0; }
.net-cards { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px 0; }
.net-cards > .net-none { margin: 0; }
.net-card { flex: 1 1 240px; max-width: 360px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
.net-card-head { display: flex; align-items: center; gap: 6px; }
.net-card-type { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.net-dot { width: 8px; height: 8px; border-radius: 50%; background: #c4b19f; flex: none; }
.net-dot.on { background: #2e9e4f; }
.net-dot.wait { background: #e8a000; }
.net-state { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.net-card dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 0; }
.net-card dt { color: var(--muted); font-size: 11.5px; }
.net-card dd { margin: 0; font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
.net-values { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.net-value { font-family: var(--mono); font-weight: 600; background: var(--teal-tint); border-radius: 4px; padding: 1px 6px; }
.net-value small { font-weight: 400; color: var(--muted); margin-right: 5px; }
.net-events { list-style: none; margin: 0; padding: 0 12px 10px; }
.net-events li { display: flex; gap: 8px; padding: 2px 0; line-height: 1.4; }
.net-events li.bad { color: #8c2a20; }
.net-report-acts { margin: 0 0 8px; }
.net-report { white-space: pre; overflow-x: auto; word-break: normal; max-height: none; }
.net-help p { margin: 0 0 8px; line-height: 1.45; max-width: 80ch; }
.net-help code { font-family: var(--mono); font-size: 11.5px; background: var(--panel); padding: 0 3px; border-radius: 3px; }
@media (max-width: 760px) { .net-body { padding-left: 12px; } .net-ends { display: none; } }
.serial-form { display: flex; gap: 8px; padding: 7px 10px; border-top: 1px solid var(--line); }
.serial-form input { flex: 1; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; font-family: var(--mono); font-size: 12.5px; }

/* ---------- dialogs ---------- */
.dialog { border: 0; border-radius: 10px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(30 42 50 / .25); }
.dialog::backdrop { background: rgb(30 42 50 / .35); }
.dialog form, .dialog .body { padding: 18px 20px; }
.dialog h2 { margin: 0 0 10px; font-size: 17px; }
.dialog p { margin: 0 0 12px; line-height: 1.5; }
.dialog label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.dialog input, .dialog textarea, .dialog select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.dialog .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dialog .error { color: var(--stop); font-size: 13px; min-height: 1em; margin: 8px 0 0; }
.copy-row { display: flex; gap: 6px; }

@media (max-width: 1000px) {
  .palette { width: 150px; }
  .part-grid { grid-template-columns: 1fr; }
  .code-panel { position: absolute; right: 0; top: 52px; bottom: 0; width: 100%; max-width: none; min-width: 0; z-index: 20; }
  .title { width: 140px; }
  .save-state { display: none; }
}
@media (max-width: 640px) {
  .palette { display: none; }
  .brand span { display: none; }
  .brand-logo { height: 30px; }
  .brand span { display: inline; font-size: 14px; }
  .bar { gap: 8px; padding: 8px 10px; }
  .bar-actions { gap: 4px; }
  #save-btn, #starter-btn { display: none; }
  .inspector { width: calc(100% - 24px); top: auto; bottom: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.inspector .toggle-row { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13.5px; cursor: pointer; }
.inspector .toggle-row input { width: 16px; height: 16px; accent-color: var(--teal); }
#starter-menu { max-height: min(70vh, 640px); overflow-y: auto; width: 320px; }
.menu-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.menu-group:first-child { padding-top: 4px; }
.inspector .tap-btn { margin-top: 8px; width: 100%; }
.inspector select { width: 100%; }
.part-terminal { background:#111827; color:#d1fae5; font-size:12px; height:110px; overflow:auto; margin:4px 0 6px; padding:6px; border-radius:4px; white-space:pre-wrap; word-break:break-word; }
.site-footer { flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; height: 34px; padding: 0 12px; font-size: 13px; font-weight: 500; text-align: center; color: var(--ink); background: #fff; border-top: 2px solid var(--teal); }
.site-footer img { display: block; flex: none; }
.cookie-notice { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 60; box-sizing: border-box; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 100px); overflow: auto; display: flex; gap: 16px; align-items: flex-start; padding: 12px 16px; font-size: 13px; line-height: 1.45; color: var(--ink); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 8px; box-shadow: 0 4px 18px rgba(30, 42, 50, .22); }
.cookie-notice .cookie-body { flex: 1; min-width: 0; }
.cookie-notice p { margin: 0; }
.cookie-notice summary { margin-top: 4px; color: var(--teal-dark); cursor: pointer; }
.cookie-notice ul { margin: 6px 0 0; padding-left: 18px; }
.cookie-notice li { margin-bottom: 3px; }
.cookie-notice .btn { flex: none; min-width: 64px; justify-content: center; }
@media (max-width: 520px) { .cookie-notice { flex-direction: column; } .cookie-notice .btn { align-self: flex-end; } }
/* teacher review (2026-11-11) */
.review-form label { display: block; margin: 10px 0 4px; font-size: 13px; }
.review-form label.check { display: flex; gap: 8px; align-items: center; }
.review-form textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border: 1px solid #f0dcc7; border-radius: 6px; }
.review-form .error { color: #b83227; min-height: 1em; }
.review-form .small { font-size: 12px; margin: 0 0 0 26px; }
ul.notes { list-style: none; padding: 0; margin: 8px 0; max-height: 50vh; overflow: auto; }
ul.notes li { border-top: 1px solid #f1e2d3; padding: 8px 0; }
ul.notes p { margin: 4px 0 6px; white-space: pre-wrap; }
.review-form label.check input { width: auto; margin: 0; flex: none; }
.review-form label.check { justify-content: flex-start; text-align: left; }
ul.notes a.btn { text-decoration: none; color: inherit; display: inline-block; }

/* IoT Virtual Lab logo (2026-11-13): chip mark + name + "NIELIT GORAKHPUR" line */
.brand-name { font-family: 'Space Grotesk', var(--sans); font-weight: 600; font-size: 18px; line-height: 1.05; letter-spacing: -0.01em; color: #0e1b2c; display: flex; flex-direction: column; }
.brand-name small { font-family: 'Space Grotesk', var(--sans); font-size: 9.5px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; color: #4a5d75; margin-top: 3px; }
@media (max-width: 640px) { .brand-name { font-size: 15px; } .brand-name small { display: none; } }

/* ===== Mobile menu (2026-11-13, like the Avirat site): see js/site-nav.js ===== */
.navtoggle { display: none; align-items: center; justify-content: center; width: 42px; height: 42px; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; padding: 0; }
.navtoggle svg { width: 22px; height: 22px; }
.navtoggle:hover { background: var(--teal-tint); color: var(--teal-dark); }
.navtoggle:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
header.bar .drawer-only { display: none; }
body { overflow-x: clip; }
@media (max-width: 860px) {
  header.bar { flex-wrap: wrap; gap: 8px; position: relative; }
  header.bar .navtoggle { display: inline-flex; margin-left: auto; }
  header.bar:not(.editor-bar) > .home-nav,
  header.bar:not(.editor-bar) > .top-links,
  header.bar:not(.editor-bar) > .bar-actions,
  header.bar.editor-bar > .top-links { display: none; }
  header.bar.nav-open > .home-nav,
  header.bar.nav-open > .top-links,
  header.bar.nav-open:not(.editor-bar) > .bar-actions {
    display: flex; flex-direction: column; align-items: stretch; flex-basis: 100%; gap: 2px; margin: 0;
    padding: 6px 0 4px; border-top: 1px solid var(--line); order: 20; }
  header.bar.nav-open:not(.editor-bar) > .bar-actions { order: 21; padding-top: 8px; gap: 8px; }
  header.bar.nav-open > .home-nav > a, header.bar.nav-open > .top-links > a,
  header.bar.nav-open .nav-menu > summary {
    display: flex; align-items: center; min-height: 44px; padding: 10px 12px; border-radius: 8px; font-size: 15.5px;
    color: var(--ink); text-decoration: none; font-weight: 500; }
  header.bar.nav-open > .home-nav > a:hover, header.bar.nav-open > .top-links > a:hover,
  header.bar.nav-open > .top-links > a[aria-current="page"] { background: var(--teal-tint); color: var(--teal-dark); }
  header.bar.nav-open .nav-menu-list { position: static; width: auto; box-shadow: none; border: 0; margin: 0 0 4px 12px; padding: 0; background: transparent; }
  header.bar.nav-open:not(.editor-bar) > .bar-actions .btn { justify-content: center; min-height: 44px; }
  header.bar.nav-open:not(.editor-bar) > .bar-actions .who { padding: 2px 12px; }
  header.bar .drawer-only { display: none; }
  header.bar.nav-open > .drawer-only { display: flex; }
  header.bar.nav-open .drawer-account { color: var(--teal-dark) !important; font-weight: 600 !important; }
  /* lab editor: keep the working buttons; the account link and project name move out of the way */
  header.editor-bar { flex-wrap: wrap; }
  header.editor-bar .navtoggle { margin-left: 0; order: 5; }
  header.editor-bar > .bar-actions { order: 4; margin-left: auto; gap: 6px; }
}
@media (max-width: 640px) {
  header.editor-bar .brand-name, header.editor-bar #title, header.editor-bar #save-state, header.editor-bar #account { display: none; }
  header.editor-bar .bar-actions .btn { padding: 6px 9px; }
  header.editor-bar #code-btn { font-size: 0; gap: 0; }
  header.editor-bar #code-btn svg { width: 16px; height: 16px; }
  header.editor-bar #sim-btn span { display: none; }
}
header.bar { flex-shrink: 0; }   /* never squeeze the header on long pages (the open menu needs its height) */
@media (max-width: 640px) {
  header.editor-bar #starter-btn { display: inline-flex; }
  header.editor-bar .menu-list { max-width: calc(100vw - 16px); }
}
header.bar .drawer-save { display: none; }
@media (max-width: 640px) { header.bar.nav-open .drawer-save { display: flex; } }
/* lab editor and Admin Desk: menu button on desktop too, opening a small panel (2026-11-13) */
@media (min-width: 861px) {
  header.bar.has-drawer { position: relative; }
  header.bar.has-drawer .navtoggle { display: inline-flex; margin-left: 4px; }
  header.bar.has-drawer:not(.editor-bar) .navtoggle { order: 30; }
  header.bar.has-drawer.nav-open > .drawer-only {
    display: flex; flex-direction: column; position: absolute; right: 10px; top: calc(100% + 4px); width: 250px; z-index: 60;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgb(15 23 42 / .16); padding: 6px; gap: 2px; }
  header.bar.has-drawer.nav-open > .drawer-only > a { display: block; padding: 9px 12px; border-radius: 7px; color: var(--ink); text-decoration: none; font-weight: 500; }
  header.bar.has-drawer.nav-open > .drawer-only > a:hover, header.bar.has-drawer.nav-open > .drawer-only > a[aria-current="page"] { background: var(--teal-tint); color: var(--teal-dark); }
  header.bar.has-drawer.nav-open > .drawer-only > .drawer-account { border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 4px; padding-top: 10px; }
}
@media (min-width: 861px) { header.bar.has-drawer.nav-open > .drawer-only > .drawer-save { display: none; } }

/* Footer policy links (2026-11-13) */
.site-footer a { color: var(--teal-dark, #9a3412); font-weight: 600; }
@media (max-width: 520px) { .site-footer { font-size: 11.5px; gap: 6px; } }

/* Menu icons (2026-11-13): added by js/site-nav.js */
.nav-ico { display: inline-flex; flex: none; width: 17px; height: 17px; color: var(--teal-dark, #9a3412); }
.nav-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.home-nav > a.has-ico, .top-links > a.has-ico, .nav-menu > summary.has-ico, .bar-actions > a.btn.has-ico { display: inline-flex; align-items: center; gap: 6px; }
.nav-menu-list a.has-ico { display: grid; grid-template-columns: 18px 1fr; column-gap: 10px; align-items: start; }
.nav-menu-list a.has-ico .nav-ico { grid-row: 1 / span 2; margin-top: 2px; }
.nav-menu-list a[aria-current="page"] { background: var(--teal-tint); }
#info-menu .nav-menu-list { left: auto; right: 0; }
@media (min-width: 861px) {
  header.bar.has-drawer.nav-open > .drawer-only > a.has-ico:not(.drawer-save) { display: flex; align-items: center; gap: 10px; }
}
@media (max-width: 860px) {
  header.bar.nav-open > .home-nav > a.has-ico, header.bar.nav-open > .top-links > a.has-ico, header.bar.nav-open .nav-menu > summary.has-ico { gap: 10px; }
  header.bar.nav-open .nav-ico { width: 19px; height: 19px; }
  header.bar.nav-open:not(.editor-bar) > .bar-actions > a.btn.has-ico { gap: 8px; }
}
/* medium screens: the header row is full, so keep icons only in dropdowns and buttons */
@media (min-width: 861px) and (max-width: 1359px) {
  header.bar > .home-nav > a > .nav-ico, header.bar > .home-nav .nav-menu > summary > .nav-ico { display: none; }
}
@media (min-width: 861px) and (max-width: 1359px) {
  header.bar:not(.editor-bar) > .bar-actions > a.btn > .nav-ico { display: none; }
}
@media (min-width: 861px) and (max-width: 1060px) {
  header.bar > .home-nav > a, header.bar > .home-nav .nav-menu > summary { padding-left: 6px; padding-right: 6px; }
  header.bar > .home-nav { gap: 0; }
}
@media (min-width: 861px) and (max-width: 1359px) {
  /* Policies menu shows as a shield icon only */
  header.bar > .home-nav #info-menu > summary > .nav-ico { display: inline-flex; }
  header.bar > .home-nav #info-menu > summary > .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  header.bar > .home-nav #info-menu > summary { gap: 3px; }
}

/* ---------- Accessibility bar (GIGW), 2026-11-13: js/a11y.js + js/prefs.js ---------- */
.skip-link { position: absolute; left: 8px; top: -80px; z-index: 1000; background: #0e1b2c; color: #fff; padding: 9px 14px; border-radius: 6px; font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 8px; outline: 3px solid #fdba74; }
.gov-strip { flex: none; background: #0e1b2c; color: #e7e9ee; font-size: 12.5px; line-height: 1.3; }
.gov-in { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 3px 16px; min-height: 34px; }
.gov-org { color: #d6dbe3; }
.gov-dot { opacity: .6; margin: 0 2px; }
.a11y-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.a11y-link { display: inline-flex; align-items: center; gap: 5px; color: #e7e9ee; text-decoration: none; padding: 4px 6px; border-radius: 4px; }
.a11y-link:hover { text-decoration: underline; color: #fff; }
.a11y-tools svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.a11y-size { display: inline-flex; border: 1px solid rgba(255, 255, 255, .4); border-radius: 5px; overflow: hidden; }
.a11y-btn { font: inherit; font-weight: 600; background: transparent; color: #fff; border: 0; padding: 3px 9px; min-height: 26px; cursor: pointer; }
.a11y-size .a11y-btn + .a11y-btn { border-left: 1px solid rgba(255, 255, 255, .4); }
.a11y-size .a11y-btn[aria-pressed="true"], .a11y-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .16); }
.a11y-btn:disabled { opacity: .4; cursor: default; }
.a11y-theme { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255, 255, 255, .4); border-radius: 5px; }
.gov-strip a:focus-visible, .gov-strip button:focus-visible { outline: 2px solid #fdba74; outline-offset: 1px; }
@media (max-width: 760px) {
  .gov-org { display: none; }
  .gov-in { padding: 3px 10px; gap: 6px; }
  .a11y-tools { margin: 0 auto; gap: 6px; }
  .gov-strip .a11y-link span, .gov-strip .a11y-theme span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gov-strip .a11y-link, .gov-strip .a11y-theme { padding: 4px 7px; min-height: 28px; }
}
/* the same controls inside the menu on the lab editor and Admin Desk */
.drawer-a11y { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 10px 4px; }
.drawer-a11y-title { margin: 0 0 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.drawer-a11y .a11y-tools { margin: 0; }
.drawer-a11y .a11y-size, .drawer-a11y .a11y-theme { border-color: var(--line); }
.drawer-a11y .a11y-size .a11y-btn + .a11y-btn { border-left-color: var(--line); }
.drawer-a11y .a11y-btn { color: var(--ink); }
.drawer-a11y .a11y-size .a11y-btn[aria-pressed="true"], .drawer-a11y .a11y-btn:hover:not(:disabled) { background: var(--teal-tint); }
.drawer-a11y-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13px; }
.drawer-a11y-links a { color: var(--teal-dark); }
.last-updated { font-weight: 400; }
/* text size in the lab editor (html[data-ts], set by js/prefs.js): panels grow, the canvas keeps its own zoom */
html[data-ts] .palette, html[data-ts] .serial, html[data-ts] .code-head, html[data-ts] .log, html[data-ts] .inspector { zoom: var(--ts); }
html[data-ts] .text-editor .cm-editor { font-size: calc(13px * var(--ts)); }
