/* RoboCanvas browser application. One stylesheet, no framework.
 *
 * A technical workspace, not a page of cards:
 *   structure  an ink command bar; the workspace in the middle is the largest
 *              thing on screen; contents on the left, properties on the right,
 *              problems in a strip below. Each has one edge, no frame.
 *   type       13 px system sans for reading; uppercase 600 labels name each
 *              region; values, codes and numbers are monospace and tabular
 *   colour     flat grey tiers; one accent (the product's teal) for selection,
 *              focus and the primary action; status colours only in status tags
 *   shape      square: no rounded cards, pills, gradients or drop shadows
 *   size       the workspace adapts: three panes on desktop; a properties drawer
 *              on tablets; one pane at a time, with a pane bar, on phones
 *
 * Scripts read --line, --line-strong, --accent and --muted to draw, so those
 * names stay.
 */
:root {
  --bg: #e7e8e4;
  --panel: #f7f7f4;
  --panel-2: #eeeeea;
  --line: #dadad4;
  --line-strong: #b7b8b1;
  --text: #121314;
  --muted: #55595d;
  --faint: #6c7075;
  --accent: #0f6a6f;
  --accent-strong: #0a5155;
  --accent-soft: #d9ebea;
  --on-accent: #ffffff;
  --ok: #1d7347;
  --ok-soft: #dcefe3;
  --warn: #855600;
  --warn-soft: #f6ebd2;
  --err: #b0261b;
  --err-soft: #f8e1de;
  --info: #2c5c99;
  --info-soft: #e2eaf5;
  --unknown: #66558f;
  --unknown-soft: #ebe7f3;
  /* the command bar is ink in both themes */
  --ink: #0b0c0d;
  --on-ink: #f2f1ec;
  --on-ink-mute: rgba(242, 241, 236, 0.66);
  --on-ink-line: rgba(242, 241, 236, 0.17);
  --signal: #33bfb8;
  --signal-hover: #5fd6d0;
  --shadow: none;
  --radius: 2px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --canvas: #e7e8e4;   /* behind the 3D view and the graph */
  --bar: 48px;
  --strip: 34px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1011; --panel: #16181a; --panel-2: #1d2023; --line: #272a2e; --line-strong: #3b3f44;
    --text: #e9e9e5; --muted: #a4a8ac; --faint: #8b9095; --accent: #33bfb8; --accent-strong: #5fd6d0;
    --accent-soft: #11302f; --on-accent: #0b0c0d; --ok: #5fc48b; --ok-soft: #142a1e; --warn: #e2b452; --warn-soft: #30260c;
    --err: #f2867b; --err-soft: #361a17; --info: #8db4ec; --info-soft: #18263a; --unknown: #b6a6e0;
    --unknown-soft: #251f36; --on-ink-line: rgba(242, 241, 236, 0.14); --canvas: #1b1d20; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1011; --panel: #16181a; --panel-2: #1d2023; --line: #272a2e; --line-strong: #3b3f44;
  --text: #e9e9e5; --muted: #a4a8ac; --faint: #8b9095; --accent: #33bfb8; --accent-strong: #5fd6d0;
  --accent-soft: #11302f; --on-accent: #0b0c0d; --ok: #5fc48b; --ok-soft: #142a1e; --warn: #e2b452; --warn-soft: #30260c;
  --err: #f2867b; --err-soft: #361a17; --info: #8db4ec; --info-soft: #18263a; --unknown: #b6a6e0;
  --unknown-soft: #251f36; --on-ink-line: rgba(242, 241, 236, 0.14); --canvas: #1b1d20; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; letter-spacing: -0.01em; } h2 { font-size: 15px; } h3 { font-size: 13px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }

/* A region's name: uppercase, small, set in the text colour's quiet tone. */
.pane-head, .section-title, .pane-section h4, .card h3, .dock-head .dock-toggle, .drawer-head .label,
.modal-body h4, .slider-title {
  font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase;
}

/* buttons and fields */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel);
  cursor: pointer; white-space: nowrap; font-weight: 500; }
.btn:hover:not(:disabled) { border-color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.danger.solid { background: var(--err); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; }
.btn.small { height: 24px; padding: 0 7px; font-size: 12px; }
.icon-btn { width: 28px; padding: 0; justify-content: center; }
label.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
label.field > span { font-size: 11.5px; color: var(--muted); }
label.field > small { font-size: 11.5px; line-height: 1.4; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  height: 28px; padding: 0 7px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); min-width: 0; }
input[type="number"] { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
input[type="text"]:hover, input[type="number"]:hover, select:hover, textarea:hover { border-color: var(--muted); }
textarea { height: auto; padding: 6px 7px; resize: vertical; }
input[readonly] { background: var(--panel-2); color: var(--muted); }
input.invalid { border-color: var(--err); box-shadow: inset 2px 0 0 var(--err); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); }
.check { display: flex; gap: 6px; align-items: center; }
.vec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }

/* Status tags: one shape, squared and solid. The word says the state; the
   colour repeats it. */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 5px 1px; border-radius: 0;
  font: 650 10px/1.35 var(--mono); letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.badge.unknown { background: var(--unknown-soft); color: var(--unknown); }
.dot { width: 7px; height: 7px; background: var(--faint); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.dot.unknown { background: var(--unknown); }

/* the logo (web/js/brand.js): light on the ink bar; on pages, the rendition that contrasts */
.brand-logo { display: block; height: 38px; width: auto; }
.brand-logo-pair, .boot-logo { display: block; margin: 0; line-height: 0; }
.brand-logo-pair img, .boot-logo img { height: 160px; width: auto; }
.logo-for-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-for-light { display: none; }
  :root:not([data-theme="light"]) .logo-for-dark { display: block; }
}
:root[data-theme="dark"] .logo-for-light { display: none; }
:root[data-theme="dark"] .logo-for-dark { display: block; }

/* boot */
.boot { height: 100vh; display: grid; place-items: center; padding: 16px; }
.boot-card { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; width: min(520px, 100%);
  padding: 20px 0; border-top: 2px solid var(--text); }
.boot-card .brand-logo-pair img { height: 80px; }
.boot-status { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.boot-status.boot-failed { color: var(--err); font-family: var(--sans); font-size: 13px; max-width: 46ch; }
.boot-error { text-align: left; background: var(--err-soft); color: var(--text); border-left: 2px solid var(--err); padding: 10px 12px; }

/* --- command bar -------------------------------------------------------------- */
.topbar { height: var(--bar); display: flex; align-items: center; gap: 10px; padding: 0 8px 0 14px;
  background: var(--ink); color: var(--on-ink); color-scheme: dark; border-bottom: 1px solid #000; min-width: 0; }
.topbar :focus-visible { outline-color: var(--signal); }
.brand { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 0; background: none; padding: 4px 0;
  color: var(--on-ink); }
.topbar .sep { width: 1px; height: 20px; background: var(--on-ink-line); flex: none; }
.tb-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-tools { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0; }
.tb-tools .sep { margin: 0 6px; }
.project-title { font-weight: 600; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dirty-flag { color: #e2b452; font-size: 12px; white-space: nowrap; }
.topbar .btn { background: transparent; border-color: transparent; color: var(--on-ink-mute); }
.topbar .btn:hover:not(:disabled) { color: var(--on-ink); background: rgba(242, 241, 236, 0.08); border-color: transparent; }
.topbar .btn:not(.ghost):not(.primary) { border-color: var(--on-ink-line); color: var(--on-ink); }
.topbar .btn.primary { background: var(--signal); border-color: var(--signal); color: var(--ink); padding: 0 14px; }
.topbar .btn.primary:hover:not(:disabled) { background: var(--signal-hover); border-color: var(--signal-hover); color: var(--ink); }
.topbar .badge.neutral { color: var(--on-ink-mute); border-color: var(--on-ink-line); }
.companion-chip { display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 9px; min-width: 0;
  border: 1px solid var(--on-ink-line); border-radius: var(--radius); background: transparent; color: var(--on-ink);
  cursor: pointer; font: 500 11.5px/1 var(--mono); white-space: nowrap; }
.companion-chip:hover { border-color: var(--on-ink); }
.companion-chip .chip-label { overflow: hidden; text-overflow: ellipsis; }
.companion-chip .dot { background: var(--on-ink-mute); }
.companion-chip .dot.ok { background: #5fc48b; } .companion-chip .dot.warn { background: #e2b452; }
.companion-chip .dot.err { background: #f2867b; } .companion-chip .dot.unknown { background: #b6a6e0; }

/* --- projects (dashboard) ----------------------------------------------------- */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; padding-bottom: 18px;
  margin-bottom: 18px; border-bottom: 1px solid var(--text); flex-wrap: wrap; }
.hero h1 { font-size: 22px; }
.hero p { color: var(--muted); max-width: 640px; margin: 6px 0 0; }
.hero .row { flex-wrap: wrap; }
.section-title .count { font: 500 11px/1 var(--mono); letter-spacing: 0; color: var(--faint); }
.section-title { margin: 30px 0 0; padding-bottom: 8px; display: flex; align-items: center; gap: 8px; color: var(--muted);
  border-bottom: 1px solid var(--line-strong); }
/* Projects and samples are an index: one ruled row each, not a grid of cards. */
.cards { display: flex; flex-direction: column; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 0; padding: 12px 14px; }
.card h3 { margin-bottom: 4px; color: var(--muted); }
.project-card { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2.4fr) auto; gap: 4px 20px; align-items: baseline;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 12px 0; }
.project-card:hover { background: var(--panel); }
.project-card h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; text-transform: none; color: var(--text); margin: 0; }
.project-card .meta { color: var(--muted); font-size: 12.5px; grid-column: 2; }
.project-card .meta + .meta { font-size: 12px; }
.project-card .actions { display: flex; gap: 6px; flex-wrap: wrap; grid-column: 3; grid-row: 1 / span 2; justify-content: flex-end; }
.notice { border: 0; border-left: 2px solid var(--line-strong); background: var(--panel-2); padding: 8px 12px; }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.err { border-color: var(--err); background: var(--err-soft); }
.notice.info { border-color: var(--info); background: var(--info-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.page > .notice { margin-top: 10px; }
.empty { color: var(--muted); padding: 14px 0; border-bottom: 1px solid var(--line); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 34px 1fr; padding: 9px 0; border-bottom: 1px solid var(--line); margin: 0; }
.steps li::before { content: counter(step, decimal-leading-zero); font: 600 11px/1.8 var(--mono); color: var(--faint); }
.page-foot { margin-top: 28px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }

/* --- editor layout ------------------------------------------------------------ */
.editor { height: 100vh; height: 100dvh; display: grid; grid-template-rows: var(--bar) minmax(0, 1fr) auto; }
.editor-body { position: relative; display: grid; grid-template-columns: 252px minmax(0, 1fr) 304px; min-height: 0; }
.sidebar, .inspector { background: var(--panel); min-height: 0; overflow: auto; overscroll-behavior: contain; }
.sidebar { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }
.pane-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 6px 4px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); color: var(--muted); }
.pane-head .btn.ghost { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.pane-head .count { font-family: var(--mono); font-weight: 500; letter-spacing: 0; color: var(--faint); }
.pane-section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pane-section h4 { margin-bottom: 8px; color: var(--muted); }
.sidebar .pane-section.small.muted { padding: 6px 12px 4px; border-bottom: 0; font-size: 11px; }
/* The inspector names what is selected: kind tag, then the name, larger. */
.inspector .pane-head { min-height: 40px; padding: 6px 8px 6px 12px; color: var(--text); text-transform: none;
  letter-spacing: -0.005em; font-size: 14px; font-weight: 600; }
.drawer-head { display: none; }
.center { display: grid; grid-template-rows: 34px minmax(0, 1fr); min-width: 0; min-height: 0; }

/* Workspace switch: four flat labels; the current one is lit and underlined. */
.tabs { display: flex; gap: 0; padding: 0 6px; background: var(--panel); border-bottom: 1px solid var(--line); align-items: stretch; min-width: 0; }
.tab { position: relative; padding: 0 12px; border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 11.5px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.tablist { display: flex; align-items: stretch; min-width: 0; }
.tabs .pane-toggle { display: none; margin: auto 0 auto auto; }
.tab-body { min-height: 0; overflow: hidden; position: relative; }
.tab-body > * { height: 100%; }

/* tree: kind code, name; nesting drawn as a guide line */
.tree { list-style: none; margin: 0; padding: 4px 0 8px; }
.tree ul { list-style: none; margin: 0 0 0 16px; padding: 0; border-left: 1px solid var(--line); }
/* A joint and the link it moves share one indent, so an arm's chain stays readable. */
.tree ul.moved { margin-left: 0; border-left: 0; }
/* A long name wraps onto a second line rather than being cut (R-23): rows align on the first line. */
.tree-item { display: flex; align-items: baseline; gap: 8px; min-height: 26px; padding: 5px 10px 5px 12px; cursor: pointer; }
.tree ul .tree-item { padding-left: 8px; }
.tree-item:hover { background: var(--panel-2); }
.tree-item[aria-selected="true"] { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.tree-kind { flex: none; width: 30px; font: 600 9.5px/1 var(--mono); color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.tree-item[aria-selected="true"] .tree-kind { color: var(--accent-strong); }
.tree-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.tree-item .badge { margin-left: auto; }

/* inspector forms */
.form { display: flex; flex-direction: column; gap: 9px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.kv { display: grid; grid-template-columns: 1fr 1fr auto; gap: 4px; align-items: center; }
.readonly-list { margin: 0; padding: 0; list-style: none; font-size: 12px; }
.readonly-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0;
  border-bottom: 1px solid var(--line); }
.readonly-list li:last-child { border-bottom: 0; }
.readonly-list li span:first-child { color: var(--muted); flex: none; }
.readonly-list li span:last-child { color: var(--text); text-align: right; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* --- problems strip ----------------------------------------------------------- */
.dock { background: var(--panel); border-top: 1px solid var(--line-strong); display: grid; grid-template-rows: auto auto; min-height: 0; }
.dock.collapsed .dock-body { display: none; }
.dock-head { display: flex; align-items: center; gap: 8px; min-height: var(--strip); padding: 3px 8px 3px 6px; min-width: 0; }
.dock-head .row.grow { flex-wrap: wrap; row-gap: 4px; }
.dock-toggle { color: var(--text); }
.dock-toggle::before { content: ""; display: inline-block; width: 0; height: 0; margin-right: 7px; vertical-align: 1px;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; }
.dock.collapsed .dock-toggle::before { transform: rotate(-90deg); }
.dock-body { height: 200px; overflow: auto; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.readiness { display: flex; gap: 4px; flex-wrap: wrap; padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line); }
.diag { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: default; }
.diag > .badge { justify-self: start; align-self: start; margin-top: 1px; }
.diag.selectable { cursor: pointer; }
.diag.selectable:hover { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--line-strong); }
.diag > div { max-width: 120ch; }
.diag .code { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 2px; }
.diag .fix { color: var(--muted); font-size: 12px; }

/* --- viewport ----------------------------------------------------------------- */
.viewport { position: relative; background: var(--canvas); }
.viewport canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.viewport canvas:active { cursor: grabbing; }
/* Overlays sit on the workspace, square and flat, with one hairline edge. */
.overlay { position: absolute; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 0;
  padding: 8px 10px; font-size: 12px; }
.overlay.tl { top: 8px; left: 8px; max-width: min(360px, calc(100% - 16px)); }
.overlay.tr { top: 8px; right: 8px; width: 264px; max-height: calc(100% - 16px); overflow: auto; }
.overlay.tr .row strong { font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.overlay.bl { bottom: 8px; left: 8px; border-color: transparent; background: transparent; padding: 0; font-size: 11.5px; }
.overlay .badge { margin-right: 4px; }
/* The collision overlay switch; the swatch is the colour viewport.js draws with. */
.collision-toggle { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); cursor: pointer; }
.collision-swatch { width: 10px; height: 10px; border: 1.5px solid rgb(214, 40, 170); background: rgba(214, 40, 170, 0.12); }
.collision-warning { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.slider-row { display: grid; grid-template-columns: 1fr; gap: 2px; padding: 5px 0; border-top: 1px solid var(--line); }
.slider-row:first-of-type { margin-top: 6px; }
.slider-row input[type="range"] { width: 100%; margin: 2px 0 0; }

/* logic graph */
.graph { position: relative; background: var(--canvas); }
.graph svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
.graph-toolbar { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.graph-toolbar select { height: 24px; font-size: 12px; }
.g-node rect { fill: var(--panel); stroke: var(--line-strong); }
.g-node.node rect { stroke: var(--text); }
.g-node.selected rect, .g-node.selected path { stroke-width: 2.5; stroke: var(--accent); }
.g-node text { fill: var(--text); font-size: 12px; }
.g-node .sub { fill: var(--muted); font-size: 10px; }
.g-node.topic rect { fill: var(--info-soft); stroke: var(--info); }
.g-node.service rect { fill: var(--warn-soft); stroke: var(--warn); }
.g-node.action rect { fill: var(--unknown-soft); stroke: var(--unknown); }
.g-node.component rect { fill: var(--panel-2); stroke: var(--line-strong); stroke-dasharray: 4 3; }
.g-node { cursor: grab; }
.g-node:focus-visible { outline: none; }
.g-node:focus-visible rect { stroke: var(--accent); stroke-width: 2.5; }
.g-edge { fill: none; stroke: var(--faint); stroke-width: 1.5; }
.g-edge.client { stroke-dasharray: 5 4; }
.g-edge.component { stroke-dasharray: 2 3; }
.g-edge-label { fill: var(--muted); font-size: 10px; }

/* simulation and run */
.scroll-pane { overflow: auto; padding: 14px 16px 24px; }
/* In Simulate and Run on ROS 2, sections are ruled at the top, not boxed. */
.scroll-pane .card { border: 0; border-top: 1px solid var(--text); padding-inline: 0; background: transparent; }
.scroll-pane .card h3 { color: var(--text); }
.split { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.plot { width: 100%; height: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 0; display: block; }
.plot-frame { position: relative; border-top: 1px solid var(--text); padding-top: 12px; }
.plot-frame h3 { margin-bottom: 8px; font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; }
/* Until a preview has run, the plot says what it will show instead of standing empty. */
.plot-frame:not(.drawn)::after { content: "Run a preview to draw the path here."; position: absolute; left: 1px; right: 1px; bottom: 1px;
  height: 358px; display: grid; place-items: center; color: var(--faint); font-size: 12px; pointer-events: none; }
.log-view { background: #0b0c0d; color: #d9dcd8; font: 12px/1.45 var(--mono); height: 280px; overflow: auto; padding: 8px 10px;
  border-radius: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
pre.log-view { height: auto; max-height: 280px; margin: 0; }
pre.usage-view { max-height: 160px; }
.log-view .stderr { color: #ffb4a8; } .log-view .lifecycle { color: #8fd3db; } .log-view .warn { color: #f0c46b; }
.op-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.status-grid { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 0 12px; margin: 0; }
.status-grid dt, .status-grid dd { padding: 4px 0; border-bottom: 1px solid var(--line); }
.status-grid dt { color: var(--muted); } .status-grid dd { margin: 0; overflow-wrap: anywhere; }
table.simple { width: 100%; border-collapse: collapse; font-size: 12px; }
table.simple th, table.simple td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }

/* --- modal and toast ---------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 12, 13, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border-radius: 0;
  border: 1px solid var(--line-strong); border-top: 2px solid var(--text); }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal-head h2 { font-size: 15px; }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.modal-body h4 { color: var(--muted); margin-bottom: 4px; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
#toast-root { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--on-ink); padding: 9px 12px; border-radius: 0; border-left: 2px solid var(--signal); max-width: 420px; }
.toast.err { background: var(--err); color: #fff; border-left-color: #fff; }

/* spacing utilities (inline styles are blocked by the Content-Security-Policy) */
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.my-12 { margin: 12px 0; } .maxw-520 { max-width: 520px; }
.g-arrow { fill: var(--faint); }
.row .sep { width: 1px; height: 20px; background: var(--line); }

/* pane bar: phones only */
.pane-bar { display: none; }

/* --- tablet: contents and workspace; properties as a drawer ------------------- */
@media (max-width: 1180px) {
  .editor-body { grid-template-columns: 232px minmax(0, 1fr); overflow: hidden; }
  .inspector { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; width: min(340px, 86%);
    border-left: 1px solid var(--line-strong); visibility: hidden; transform: translateX(16px); opacity: 0;
    transition: transform 140ms ease-out, opacity 140ms ease-out, visibility 0s linear 140ms; }
  .editor[data-pane="properties"] .inspector { visibility: visible; transform: none; opacity: 1;
    transition: transform 140ms ease-out, opacity 140ms ease-out; }
  .drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 34px;
    padding: 3px 6px 3px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
  .drawer-head .label { color: var(--muted); flex: 1; }
  .inspector .pane-head { top: 34px; }
  .tabs .pane-toggle { display: inline-flex; }
  .tabs .pane-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
  .split { grid-template-columns: minmax(0, 1fr); }
}

/* --- phone: one pane at a time, chosen from the pane bar ---------------------- */
@media (max-width: 760px) {
  .editor { grid-template-rows: auto minmax(0, 1fr) auto; }
  .topbar { height: auto; flex-wrap: wrap; gap: 0 8px; padding: 0 6px 0 12px; }
  .topbar > .tb-tools > .spacer { display: none; }
  .tb-id { order: 1; flex: 1 1 0; min-height: var(--bar); }
  .topbar > .btn.primary, .topbar > .help { order: 2; }
  /* Full width, edge to edge (the basis makes up for the negative margins, so the row always
     starts on a line of its own). It wraps rather than scrolls: every tool stays in view (R-24). */
  .tb-tools { order: 3; flex: 1 0 calc(100% + 18px); flex-wrap: wrap; row-gap: 0; min-height: 38px; margin: 0 -6px 0 -12px;
    padding: 2px 6px 2px 8px; border-top: 1px solid var(--on-ink-line); }
  .project-title { max-width: none; }
  .editor-body { grid-template-columns: minmax(0, 1fr); }
  .editor-body > .sidebar, .editor-body > .center { display: none; }
  .editor[data-pane="contents"] .sidebar { display: block; border-right: 0; }
  .editor[data-pane="canvas"] .center { display: grid; }
  .inspector { position: static; width: auto; border-left: 0; display: none; visibility: visible; transform: none; opacity: 1; transition: none; }
  .editor[data-pane="properties"] .inspector { display: block; }
  .tabs .pane-toggle { display: none; }
  .tab { padding: 0 10px; flex: 1 1 auto; }
  .tabs { padding: 0; }
  .tablist { flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
  /* Problems takes the whole workspace when chosen, and is otherwise out of the way. */
  .dock { display: none; }
  .editor[data-pane="problems"] .editor-body { display: none; }
  .editor[data-pane="problems"] .dock { display: grid; grid-row: 2; grid-template-rows: auto minmax(0, 1fr); border-top: 0; }
  .editor[data-pane="problems"] .dock .dock-body { display: block; height: auto; }
  .dock-toggle { pointer-events: none; }
  .editor[data-pane="problems"] .dock-head { flex-wrap: wrap; padding: 6px 8px 8px; }
  .dock-head .row.grow { order: 3; flex: 1 0 100%; }
  .dock-head .row.grow + .btn { margin-left: auto; }
  .dock-toggle::before { display: none; }
  .readiness { border-left: 0; padding-left: 0; margin-left: 0; }
  .pane-bar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--ink); color: var(--on-ink);
    border-top: 1px solid #000; padding-bottom: env(safe-area-inset-bottom); }
  .pane-bar button { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; height: 48px;
    border: 0; background: transparent; color: var(--on-ink-mute); cursor: pointer;
    font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
  .pane-bar button[aria-pressed="true"] { color: var(--on-ink); box-shadow: inset 0 2px 0 var(--signal); }
  .pane-bar button:focus-visible { outline: 2px solid var(--signal); outline-offset: -3px; }
  .pane-count { font: 600 10px/1 var(--mono); padding: 2px 4px 1px; background: rgba(242, 241, 236, 0.12); color: var(--on-ink); }
  .pane-count.err { background: #f2867b; color: var(--ink); }
  .pane-count.warn { background: #e2b452; color: var(--ink); }
  .overlay.tl { font-size: 11.5px; padding: 6px 8px; }
  .overlay.tr { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 44%; }
  .viewport .overlay.bl, .graph .overlay.bl { display: none; }
  .graph-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .scroll-pane { padding: 12px; }
  .status-grid { grid-template-columns: minmax(0, 1fr); }
  .status-grid dt { border-bottom: 0; padding-bottom: 0; }
  .op-row { grid-template-columns: 70px minmax(0, 1fr) auto; }
  .diag { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .page { padding: 18px 14px 40px; }
  .project-card { grid-template-columns: minmax(0, 1fr); }
  .project-card .meta, .project-card .actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .project-card .actions { margin-top: 6px; }
  .topbar .companion-chip { max-width: 52vw; }
  /* On a phone the chip gives the state only; its tooltip and label keep the full sentence. */
  .companion-chip .chip-key { display: none; }
  .tb-tools > * { flex-shrink: 0; }
  .tb-tools > .companion-chip { flex-shrink: 1; }
}

/* The narrowest phones: four pane labels and a count in 320 px. */
@media (max-width: 360px) {
  .pane-bar button { min-width: 0; gap: 4px; padding: 0 2px; font-size: 10px; letter-spacing: .03em; }
}

/* Short windows: the page scrolls instead of squeezing the workspace to nothing. */
@media (min-width: 761px) and (max-height: 600px) {
  .editor { height: auto; min-height: 100vh; }
  .center { min-height: 440px; }
  .dock-body { height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:active:not(:disabled) { transform: none; }
}
