/* Code dock (crates/web/src/code.rs): editor + serial monitor.
   Desktop: a strip under the board, across the stage column (collapsible to its bar).
   Phone: two sections at the end of the panel list. */
:root {
  --dock-h: 380px; --dock-bar: 44px;
  /* syntax colours (crates/web/js/code.js highlightStyle) */
  --cm-kw: #8a2bb0; --cm-type: #0b6e8a; --cm-str: #a33d14; --cm-num: #116644; --cm-comment: #7a7f87;
  --cm-macro: #9a5b00; --cm-fn: #2451b5; --cm-label: #b3245d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cm-kw: #d08cf0; --cm-type: #5fc4d8; --cm-str: #f0a37a; --cm-num: #8fd19e; --cm-comment: #8b9099;
    --cm-macro: #e6c06a; --cm-fn: #7fb0ff; --cm-label: #f08cb0;
  }
}
:root[data-theme="dark"] {
  --cm-kw: #d08cf0; --cm-type: #5fc4d8; --cm-str: #f0a37a; --cm-num: #8fd19e; --cm-comment: #8b9099;
  --cm-macro: #e6c06a; --cm-fn: #7fb0ff; --cm-label: #f08cb0;
}
.app { position: relative; }
.app:has(#code) .stage { padding-bottom: var(--dock-bar); }
.app:has(#code.open) .stage { padding-bottom: var(--dock-h); }
#code {
  position: absolute; left: var(--pal-w); right: 360px; bottom: 0; height: var(--dock-bar); overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  border-top: 1px solid var(--line); background: var(--panel);
}
#code.open { height: var(--dock-h); }
.code-pane, .serial-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0 12px 10px; }
.serial-pane { border-left: 1px solid var(--line); }
.code-bar { height: var(--dock-bar); flex: none; display: flex; align-items: center; gap: 6px; }
.code-bar h2 { margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-bar button { height: 30px; padding: 0 12px; flex: none; }
.code-tpl { position: relative; flex: none; display: flex; }
.code-tpl select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.code-tpl select:disabled { cursor: default; }
.code-tpl:has(select:focus-visible) button { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-bar button.primary { background: var(--btn-on); border-color: var(--btn-on); color: var(--accent-ink); font-weight: 600; width: 112px; padding: 0; }
/* Under the editor: one framed box for the status line and the compiler messages, its bottom edge
   level with the serial box. */
.code-msgs {
  min-height: 0; display: flex; flex-direction: column; padding: 4px 4px 4px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
}
.code-status { height: 18px; line-height: 18px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.code-status.bad { color: var(--err); }
.code-src { color: var(--ink); }
/* Compiler errors are not breakpoints: a square with a cross, not a red dot (the gutter of the source view). */
.cm-gutter-lint .cm-lint-marker-error {
  content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="2" y="2" width="16" height="16" rx="3" fill="%23d11"/><path d="M7 7l6 6M13 7l-6 6" stroke="white" stroke-width="2"/></svg>') !important;
}
.code-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 128px; gap: 6px; }
.code-editor { min-height: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--bg); }
.code-editor .cm-editor { height: 100%; }
.code-fallback {
  width: 100%; height: 100%; border: 0; resize: none; padding: 6px 8px; background: var(--bg); color: var(--ink);
  font: 12.5px/1.45 ui-monospace, Menlo, monospace; tab-size: 4; white-space: pre; outline: none;
}
.code-diags { flex: 1; min-height: 0; list-style: none; margin: 0 0 0 -4px; padding: 0; overflow-y: auto; font: 12px/1.3 ui-monospace, Menlo, monospace; }
.code-diags button.diag {
  width: 100%; min-height: 22px; display: flex; gap: 8px; align-items: baseline; text-align: left;
  background: transparent; border: 0; border-radius: 4px; padding: 2px 4px; font: inherit;
}
.code-diags button.diag:disabled { opacity: 1; cursor: default; }
.code-diags li.error .diag { color: var(--err); }
.code-diags li.warning .diag { color: var(--warn); }
.diag-at { flex: none; width: 48px; color: var(--muted); }
.diag-msg { min-width: 0; overflow-wrap: anywhere; }
.serial-out {
  flex: 1; min-height: 0; margin: 0; overflow-y: auto; padding: 4px 8px;
  font: 12px/1.35 ui-monospace, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  white-space: pre-wrap; word-break: break-all;
}
.serial-out:empty::before { content: "UART0 output of the running firmware"; color: var(--muted); word-break: normal; overflow-wrap: break-word; }
/* Desktop: the bar is too narrow for the file name after the title (it stays in the text for the phone). */
@media (min-width: 761px) and (min-height: 501px), (min-width: 761px) and (pointer: fine) { .code-bar h2 .h-sub { display: none; } }


/* No build service: the build-it-yourself note takes the place of the compiler messages. */
.code-guide { flex: 1; min-height: 0; overflow-y: auto; font-size: 12px; line-height: 1.4; }
.code-guide p { margin: 4px 0; }
.code-guide code { font-family: ui-monospace, Menlo, monospace; }
.code-guide button { height: 28px; padding: 0 12px; margin-right: 12px; }
.code-guide a { color: var(--accent); }
.code-diags.gone, .code-guide.gone { display: none; }
