/* NanoVM Editor — header · main(left tabs | editor) · footer. Light theme.
   Bootstrap handles components; the app-shell archetype, the shared toolbar
   (.nv-header / .nv-brand / .nv-header-actions and its widgets) and the
   .nv-panel surface live in application.css. This file owns the editor grid, the file tabs, the chat
   stream/input, the debug panel and the compiler modal. Sibling files in this
   editor/ folder: codemirror.css (CodeMirror theme) and briora-agent.css (briora agent
   bubbles + markdown). Theme tokens (--nv-*) live in application.css. */

/* ============================================================================
   App shell (grid: header / main / footer)
   ========================================================================= */
.nv-app {
  /* Width of the left column — set by the workspace controller (divider),
     shared by the header's left zone and the column below. */
  --nv-left-w: 380px;
  display: grid;
  grid-template-rows: var(--nv-header-h) 1fr var(--nv-footer-h);
  height: 100vh;
  background: var(--nv-bg);
  color: var(--nv-text);
}

/* ── Header — editor-only bits. The header widgets (.nv-project, .nv-connect,
   the device-action clusters, .nv-menu-toggle, .nv-cluster-menu) are shared
   shell chrome in application.css. ── */

/* Editor page: the header's left zone is exactly as wide as the left column
   below it, so the tab buttons end flush with the column's right edge. The
   brand logo lines up with the chat header's content (18px). */
.nv-app .nv-header {
  padding-left: 0;
  gap: 0;
}

.nv-header-left {
  flex: 0 0 var(--nv-left-w);
  box-sizing: border-box;
  min-width: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-left: 18px;
}

/* The action row keeps its natural width — when it no longer fits, the
   header overflows measurably and the workspace controller goes compact
   (instead of the clusters being clipped silently). */
.nv-app .nv-header-actions,
.nv-app .nv-header-actions > * {
  flex-shrink: 0;
}

.nv-app .nv-header-actions {
  padding-left: 0.75rem;
}

/* A template in the editor (.nv-solo): only the program and the board. The
   left column, its tabs and the divider are gone; the header's left zone
   shrinks to the logo. */
.nv-solo .nv-left,
.nv-solo .nv-left-tabs,
.nv-solo .nv-divider {
  display: none;
}
.nv-solo .nv-header-left {
  flex-basis: auto;
}

/* Left-column tabs (project | chat | docs): button typography, square; the
   open tab is boxed by a hairline. */
.nv-left-tabs {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 15px;
}

.nv-left-tab {
  box-sizing: border-box;
  min-width: 82px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 0;
  background: var(--nv-bg);
  color: var(--nv-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.nv-left-tab:hover {
  color: var(--nv-text);
}

.nv-left-tab[aria-selected="true"] {
  color: var(--nv-text);
  border-color: var(--nv-border);
}

/* The editor is a tab of its own on small screens only (media query below). */
.nv-left-tab--editor {
  display: none;
}

/* Unread posts in the chat stream while another tab is open. */
.nv-left-tab-badge {
  box-sizing: border-box;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--br-turquoise);
  color: var(--br-on-turquoise);
  font-size: 10px;
  letter-spacing: 0;
  line-height: 16px;
  text-align: center;
}

.nv-left-tab-badge[hidden] {
  display: none;
}

/* Too narrow for the whole button row (data-compact, workspace controller):
   Debug leaves the header; the overflow menu mirrors it
   (.nv-compact-only) while the run cluster is showing. */
.nv-header[data-compact] #btn-debug {
  display: none;
}

.nv-app.nv-cli-hidden .nv-header[data-compact] #btn-run {
  border-top-right-radius: var(--bs-btn-border-radius);
  border-bottom-right-radius: var(--bs-btn-border-radius);
}

.nv-compact-only {
  display: none;
}

.nv-header[data-compact] .nv-device-actions[data-device-panel="run"] ~ .dropdown .nv-compact-only:not([hidden]) {
  display: block;
}

/* A button row where some members are button_to forms: the forms dissolve
   (display: contents) and the buttons join up like a Bootstrap btn-group. */
.nv-form-group {
  display: inline-flex;
}

.nv-form-group form {
  display: contents;
}

.nv-form-group > * + * .btn,
.nv-form-group > * + *.btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -1px;
}

.nv-form-group > *:not(:last-child) .btn,
.nv-form-group > *:not(:last-child).btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* ── Main (left tabs | divider | editor). The left column shows one of three
     panels (data-left-tab on .nv-main, workspace controller); the editor
     takes the rest and is always on screen. ─────────────────────────────── */
.nv-main {
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* Shared height of the top bars (chat header, tree toolbar, docs search)
     so their bottom borders align. */
  --nv-bar-h: 38px;
}

.nv-left {
  position: relative;
  flex: 0 0 var(--nv-left-w);
  box-sizing: border-box;
  min-width: 0;
  border-right: 1px dashed var(--br-faint);
  background: var(--nv-bg);
}

/* The panels stack in the same box and only switch visibility — a hidden
   chat keeps its scroll position and keeps receiving the stream. */
.nv-left-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  visibility: hidden;
}

.nv-main[data-left-tab="project"] .nv-left-panel[data-tab="project"],
.nv-main[data-left-tab="chat"] .nv-left-panel[data-tab="chat"],
.nv-main[data-left-tab="docs"] .nv-left-panel[data-tab="docs"] {
  visibility: visible;
}

.nv-project-view,
.nv-chat,
.nv-docs-view {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--nv-bg);
}

/* Divider: a 9px grab strip straddling the dashed column rule. */
.nv-divider {
  position: relative;
  z-index: 7; /* above CodeMirror's gutters and scrollbars */
  flex: none;
  align-self: stretch;
  width: 9px;
  margin: 0 -4px 0 -5px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.nv-divider:hover,
.nv-divider:focus-visible,
.nv-app.is-resizing .nv-divider {
  background: color-mix(in srgb, var(--nv-accent) 35%, transparent);
  outline: none;
}

.nv-app.is-resizing {
  cursor: col-resize;
  user-select: none;
}

/* Keep the drag from selecting or hovering editor content. */
.nv-app.is-resizing .nv-detail {
  pointer-events: none;
}

.nv-detail {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* What the editor area shows (data-view, editor-app): the active source
   ("code"), a read-only toolchain header ("lib") or the summary card of a
   resource / device file ("card"). The stand-ins replace the editor and its
   version chrome; the debug panel stays. */
.nv-code-view {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.nv-viewer-bar,
.nv-viewer,
.nv-card {
  display: none;
}

.nv-code-view[data-view="lib"] .nv-viewer-bar {
  display: flex;
}

.nv-code-view[data-view="lib"] .nv-viewer {
  display: block;
}

.nv-code-view[data-view="card"] .nv-card {
  display: flex;
}

.nv-code-view:not([data-view="code"]) .nv-editor,
.nv-code-view:not([data-view="code"]) .nv-version-bar,
.nv-code-view:not([data-view="code"]) .nv-diff-bar {
  display: none;
}

.nv-viewer-bar {
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--nv-muted);
  background: var(--nv-panel);
  border-bottom: 1px solid var(--nv-border-soft);
}

.nv-viewer-name {
  margin-left: auto;
  font-family: var(--nv-mono);
}

.nv-card {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  font-size: 13px;
}

.nv-card-title {
  margin: 0;
  font-family: var(--nv-mono);
  font-size: 16px;
  font-weight: 500;
}

.nv-card-image {
  max-width: min(100%, 320px);
  max-height: 240px;
  border: 1px dashed var(--nv-border);
  border-radius: 6px;
  background: var(--br-paper);
  image-rendering: pixelated;
}

.nv-card-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 0;
}

.nv-card-facts dt {
  color: var(--nv-muted);
  font-weight: 400;
}

.nv-card-facts dd {
  margin: 0;
}

.nv-card-text {
  align-self: stretch;
  max-height: 40vh;
}

.nv-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Parts that do not apply to the open entry — beats .btn's display. */
.nv-card-image[hidden],
.nv-card-text[hidden],
.nv-card-facts > [hidden],
.nv-card-actions > [hidden] {
  display: none;
}

.nv-docs-head {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--nv-bar-h);
  flex-shrink: 0;
  padding: 0 6px;
  border-bottom: 1px solid var(--nv-border);
}

.nv-docs-search {
  flex: 1;
  min-width: 0;
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--nv-text);
  background: var(--nv-panel);
  border: 1px solid var(--nv-border);
  border-radius: 6px;
  outline: none;
}

.nv-docs-search:focus {
  border-color: var(--nv-accent);
}

/* ONE scroll pane: the tree (or, while searching, the results). The picked
   article is relocated inline below its tree entry by the docs controller. */
.nv-docs-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* The inlined article — an inset card, reading as the unfolded content of
   its tree entry. */
turbo-frame#doc-article {
  display: block;
}

.nv-docs-pane .nv-docs-article {
  margin: 4px 6px 12px 22px;
  border: 1px solid var(--nv-border);
  border-radius: 8px;
  background: var(--nv-panel);
}

/* — Article — */
.nv-docs-article {
  padding: 10px 14px 14px;
  font-size: 13px;
}

.nv-docs-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}

.nv-docs-fallback {
  font-size: 11px;
  color: var(--nv-muted);
  font-style: italic;
}

.nv-docs-prose {
  overflow-wrap: break-word;
}

.nv-docs-prose img {
  max-width: 100%;
}

/* Wide GFM tables (interface function lists) scroll inside the column
   instead of overflowing it. */
.nv-docs-prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.nv-docs-example {
  margin-top: 12px;
}

.nv-docs-interfaces {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--nv-muted);
}

.nv-docs-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.nv-docs-run-status {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--nv-muted);
}

.nv-docs-code {
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.5;
  background: var(--nv-panel);
  border: 1px solid var(--nv-border);
  border-radius: 6px;
  overflow-x: auto;
}

.nv-docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--nv-border);
  font-size: 12px;
}

.nv-docs-pager-link {
  color: var(--nv-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.nv-docs-pager-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-docs-pager-link:hover {
  color: var(--nv-accent);
}

.nv-docs-pager-next {
  text-align: right;
}

/* — TOC — */
.nv-docs-tree {
  padding: 8px 6px;
  font-size: 13px;
}

.nv-docs-chapter {
  margin-bottom: 2px;
}

.nv-docs-chapter .nv-docs-chapter {
  margin-left: 12px;
}

.nv-docs-chapter-title {
  padding: 4px 8px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  list-style-position: inside;
}

.nv-docs-chapter-title:hover {
  background: var(--nv-border-soft);
}

.nv-docs-tree-link {
  display: block;
  padding: 3px 8px 3px 24px;
  color: var(--nv-muted);
  text-decoration: none;
  border-radius: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-docs-tree-link:hover {
  color: var(--nv-text);
  background: var(--nv-border-soft);
}

.nv-docs-tree-link.is-active {
  color: var(--nv-accent);
  font-weight: 600;
}

/* — Search results — */
.nv-docs-results {
  font-size: 12px;
}

.nv-docs-empty {
  padding: 12px 14px;
  color: var(--nv-muted);
}

.nv-docs-result {
  display: block;
  padding: 8px 14px;
  color: var(--nv-text);
  text-decoration: none;
  border-bottom: 1px solid var(--nv-border-soft);
}

.nv-docs-result:hover {
  background: var(--nv-border-soft);
}

.nv-docs-result-title {
  display: block;
  font-weight: 600;
}

.nv-docs-result-path {
  display: block;
  font-size: 10px;
  color: var(--nv-muted);
}

.nv-docs-result-excerpt {
  display: block;
  margin-top: 2px;
  color: var(--nv-muted);
}

.nv-docs-result-excerpt mark {
  padding: 0 1px;
  border-radius: 2px;
}

/* ============================================================================
   Project tree (Projekt tab): toolbar + folders Code / Ressourcen / Gerät
   ========================================================================= */
.nv-tree-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  height: var(--nv-bar-h);
  padding: 0 8px;
  border-bottom: 1px solid var(--nv-border);
}

/* Square icon-only button; the label lives in title + aria-label. */
.nv-icon-btn {
  width: 31px;
  height: 31px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  letter-spacing: 0;
  flex-shrink: 0;
}

.nv-tree-errors,
.nv-tree-hint {
  flex-shrink: 0;
  padding: 6px 12px 0;
  font-size: 12px;
  color: var(--nv-muted);
}

.nv-tree-errors {
  color: var(--bs-danger);
}

.nv-tree-errors:empty,
.nv-tree-hint:empty {
  display: none;
}

.nv-tree {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
  font-size: 13px;
  scrollbar-width: thin;
}

.nv-tree.drag-over {
  outline: 2px dashed var(--nv-accent);
  outline-offset: -2px;
}

/* Indent per level: folder rows sit one step left of the files beside them. */
.nv-tree-children {
  --nv-tree-folder-pad: 30px;
  --nv-tree-pad: 50px;
}

.nv-tree-children .nv-tree-children {
  --nv-tree-folder-pad: 50px;
  --nv-tree-pad: 70px;
}

.nv-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px 0 var(--nv-tree-pad, 10px);
}

/* A library the program does not use — beats the row's display. */
.nv-tree-row[hidden] {
  display: none;
}

.nv-tree-row:hover {
  background: var(--nv-border-soft);
}

/* The entry showing on the right. */
.nv-tree-row.is-active {
  background: var(--br-tint);
  box-shadow: inset 2px 0 0 var(--nv-accent);
}

.nv-tree-row.is-active .nv-tree-name {
  font-weight: 500;
}

.nv-tree-folder-row {
  padding-left: var(--nv-tree-folder-pad, 10px);
  cursor: pointer;
  list-style: none; /* no default disclosure marker */
  user-select: none;
}

.nv-tree-folder-row::-webkit-details-marker {
  display: none;
}

/* The folder the toolbar acts on (new file / upload go here): the only bold
   folder, on a quiet wash. */
.nv-tree-folder.is-target > .nv-tree-folder-row {
  background: var(--nv-panel);
  font-weight: 700;
}

.nv-tree-caret {
  flex: none;
  font-size: 10px;
  color: var(--nv-muted);
}

.nv-tree-folder[open] > .nv-tree-folder-row .nv-tree-caret {
  transform: rotate(90deg);
}

.nv-tree-icon {
  flex: none;
  font-size: 14px;
  color: var(--nv-muted);
}

.nv-tree-icon.main-file {
  color: var(--nv-file-main);
}

.nv-tree-icon.header-file {
  color: var(--nv-file-header);
}

.nv-tree-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The clickable part of a row: icon + name, as wide as the row allows. */
.nv-tree-open {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nv-tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--nv-mono);
  font-size: 12.5px;
}

/* Source differs from what the connected board runs. */
.nv-tree-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nv-muted);
}

.nv-tree-dot[hidden] {
  display: none;
}

.nv-tree-status {
  flex: none;
  font-size: 14px;
  color: var(--nv-muted);
}

.nv-tree-status.status-synced,
.nv-tree-status.status-in_project {
  color: var(--bs-success);
}

.nv-tree-status.status-missing,
.nv-tree-status.status-changed {
  color: var(--bs-warning);
}

.nv-tree-status.status-device_only {
  color: var(--nv-accent);
}

.nv-tree-status.status-main {
  color: var(--nv-file-main);
}

.nv-tree-meta {
  flex: none;
  font-size: 11px;
  color: var(--nv-muted);
}

/* Rename / delete: on hover or keyboard focus, like the old tab actions. */
.nv-tree-actions {
  display: none;
  flex: none;
  gap: 2px;
}

.nv-tree-row:hover .nv-tree-actions,
.nv-tree-row:focus-within .nv-tree-actions {
  display: inline-flex;
}

.nv-tree-action-form {
  display: contents;
}

.nv-tree-action {
  padding: 0 3px;
  border: 0;
  background: transparent;
  color: var(--nv-muted);
  line-height: 1;
  font-size: 12px;
}

.nv-tree-action:hover {
  color: var(--nv-text);
}

.nv-tree-action--danger:hover {
  color: var(--bs-danger);
}

.nv-tree-info {
  padding: 4px 12px 4px var(--nv-tree-pad, 10px);
  font-size: 12px;
  color: var(--nv-muted);
}

.nv-tree-info:empty {
  display: none;
}

/* ── Project panel under the tree: title, description, picture ──────────── */
/* The title on a line of its own; under it two columns: the project on its
   board with the button that takes a new picture, and the description, which
   takes the rest of the width and the whole height. Square like the tree
   above it. Title and description are fields that look like text until they
   are pointed at or hold the focus; in a template they are text. */
.nv-project-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 254px;
  padding: 8px;
  border-top: 1px solid var(--nv-border);
  background: var(--nv-bg);
  font-size: 13px;
}

.nv-project-panel-title,
.nv-project-panel-description {
  display: block;
  margin: 0;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--nv-text);
  font: inherit;
}

.nv-project-panel-title {
  flex-shrink: 0;
  width: 100%;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nv-project-panel-body {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 0;
}

.nv-project-panel-description {
  flex: 1 1 0;
  min-width: 0;
  font-size: 12px;
  color: var(--nv-muted);
  line-height: 1.4;
}

textarea.nv-project-panel-description {
  resize: none;
  scrollbar-width: thin;
}

input.nv-project-panel-title:hover,
textarea.nv-project-panel-description:hover {
  border-color: var(--nv-border);
}

input.nv-project-panel-title:focus,
textarea.nv-project-panel-description:focus {
  outline: none;
  border-color: var(--nv-accent);
  color: var(--nv-text);
}

.nv-project-panel-title::placeholder,
.nv-project-panel-description::placeholder {
  color: var(--nv-muted);
  opacity: 0.8;
}

/* The left column takes half of the panel and the picture fills it; the
   button under it is exactly as wide as the picture's frame. Without a
   board there is no such column. */
.nv-project-panel-picture {
  flex: 0 0 calc(50% - 5px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

/* A hairline around the whole picture: the box of the drawing, not only
   the device's display. The display field keeps its place — it is measured
   inside the line. */
.nv-project-panel-picture .br-device {
  box-sizing: border-box;
  border: 1px solid var(--nv-border);
}

.nv-project-panel-snapshot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding-inline: 0;
  overflow: hidden;
}

.nv-project-panel-snapshot.is-busy .bi {
  animation: nv-project-panel-turn 1s linear infinite;
}

.nv-project-panel-hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--nv-muted);
}

@keyframes nv-project-panel-turn {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .nv-project-panel-snapshot.is-busy .bi { animation: none; }
}

.nv-detail.drag-over {
  outline: 2px dashed var(--nv-accent);
  outline-offset: -2px;
}

/* ── Column title: pictogram + bold uppercase name (chat header). ────────── */
.nv-col-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-text);
}

.nv-col-title .bi {
  font-size: 14px;
  color: var(--nv-muted);
}

/* ── List chrome shared with the share-links modal (snapshots/_modal). ───── */
.nv-files-delete {
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--nv-muted);
  line-height: 1;
  font-size: 12px;
}

.nv-files-delete:hover {
  color: var(--bs-danger);
}

.nv-files-empty {
  padding: var(--nv-gap);
  color: var(--nv-muted);
  font-size: 13px;
  text-align: center;
}

/* The editor (and the read-only library viewer in its place): 20pt of extra
   air on the left and on top. */
.nv-editor,
.nv-viewer {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: calc(var(--nv-gap) + 20pt) var(--nv-gap) var(--nv-gap) calc(var(--nv-gap) + 20pt);
}

/* The editor's gutter is 28px wider than the bare marker column (room for
   the current-line and diff bars, codemirror.css) — taken out of the left
   padding so the code starts where it did. */
.nv-editor {
  padding-left: calc(var(--nv-gap) + 20pt - 28px);
}

/* ============================================================================
   Version indicator bar (bottom of the editor column, right-aligned)
   ========================================================================= */
.nv-version-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
  padding: 2px 8px;
  background: var(--nv-panel);
  border-top: 1px solid var(--nv-border-soft);
}

/* Inline version-diff summary strip (between editor and version bar). */
.nv-diff-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px 8px;
  font-size: 12px;
  color: var(--nv-muted);
  background: var(--nv-panel);
  border-top: 1px solid var(--nv-border-soft);
}
.nv-diff-bar[hidden] {
  display: none;
}
.nv-diff-bar .btn-close {
  margin-left: auto;
  font-size: 10px;
}

.nv-version-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--nv-border-soft);
  background: var(--nv-bg);
  color: var(--nv-muted);
  border-radius: 10px;
  padding: 1px 9px;
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
}

.nv-version-chip:hover {
  color: var(--nv-text);
  border-color: var(--nv-border);
}

.nv-version-writer {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.nv-version-chip.writer-llm .nv-version-writer {
  color: var(--nv-writer-llm);
}

.nv-version-chip.writer-user .nv-version-writer {
  color: var(--nv-writer-user);
}

.nv-version-num {
  color: var(--nv-muted);
}

/* Version history table + writer tags */
.nv-version-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}

.nv-version-table th,
.nv-version-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--nv-border-soft);
  text-align: left;
  vertical-align: middle;
}

.nv-version-table th {
  color: var(--nv-muted);
  font-weight: 600;
}

.nv-version-row.is-current {
  background: rgba(var(--bs-primary-rgb), 0.06);
}

/* Instruction column: keep long chat prompts from widening the table (full
   text stays available via the cell's title tooltip). */
.nv-version-instruction {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nv-writer-tag {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  font-size: 11px;
}

.nv-writer-tag.writer-llm {
  color: var(--nv-writer-llm);
}

.nv-writer-tag.writer-user {
  color: var(--nv-writer-user);
}

.nv-version-badge-del {
  color: var(--bs-danger);
  font-size: 12px;
}

.nv-version-actions button {
  margin-left: 3px;
}

.nv-version-view {
  margin: 0;
  padding: 10px;
  background: var(--br-tint);
  color: var(--nv-text);
  border: 1px solid var(--nv-border-soft);
  border-radius: 4px;
  font-family: var(--nv-mono);
  font-size: 13px;
  white-space: pre;
  overflow: auto;
  max-height: 60vh;
}

/* ============================================================================
   Footer (status bar)
   ========================================================================= */
/* The screen's single Pflaume surface (same fill in both themes). */
.nv-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  background: var(--br-plum);
  border-top: 0;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--nv-mono);
  font-size: 11px;
}

.status-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
}

/* Left-edge footer info: compiler utilization + last one-line board status. */
.nv-footer-stats,
.nv-footer-device-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.75);
}

.nv-footer-stats.d-none {
  display: none;
}

/* CLI hidden (default, toggled from the "…" menu; the popup itself is
   shared chrome, application.css): the multi-line console lines in the chat
   stream disappear; agent bubbles and status updates stay. Lines keep being
   appended while hidden, so showing the CLI reveals the full history.
   EXCEPTIONS: program output (print() and VM runtime messages) is what the
   user's program says, and the outdated-firmware warning is an actionable
   alert — both always stay visible in the chat. */
.nv-app.nv-cli-hidden .nv-line:not(.nv-line--program):not(.nv-firmware-warning) {
  display: none;
}

/* With the CLI popup gone, the debug button is the group's visual end —
   give it back the outer corner rounding Bootstrap strips off inner
   group members. */
.nv-app.nv-cli-hidden #btn-debug {
  border-top-right-radius: var(--bs-btn-border-radius);
  border-bottom-right-radius: var(--bs-btn-border-radius);
}

/* The persisted [STATUS] board connect/disconnect info lines in the chat are
   CLI chrome too — the footer carries that information while hidden. */
.nv-app.nv-cli-hidden .briora-agent-status-update {
  display: none;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.status-item:hover {
  background-color: rgba(255, 255, 255, 0.12);
}

.status-item.status-errors {
  color: var(--br-raspberry);
}

.status-item.status-warnings {
  color: #e8c268;
}

.device-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
}

.device-info .platform {
  color: var(--br-turquoise);
  font-weight: 500;
}

.device-info .memory {
  font-size: 0.8rem;
}

.status-separator {
  color: var(--nv-muted);
  font-size: 0.8rem;
}

/* Compile status indicator dot */
.compile-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transition: background-color 0.3s ease;
}

.compile-status-dot.status-empty,
.compile-status-dot.status-dirty {
  background-color: var(--bs-gray-500);
}

.compile-status-dot.status-compiling {
  background-color: var(--bs-warning);
  animation: pulse 1s ease-in-out infinite;
}

.compile-status-dot.status-error {
  background-color: var(--bs-danger);
}

.compile-status-dot.status-ready {
  background-color: var(--br-turquoise);
}

.compile-status-dot.status-running {
  background-color: var(--nv-accent);
  animation: pulse 1s ease-in-out infinite;
}

.compile-status-dot.status-debugging {
  background-color: var(--bs-info);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ============================================================================
   Scrollbars (global chrome)
   ========================================================================= */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--nv-panel);
}
::-webkit-scrollbar-thumb {
  background: var(--nv-border);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--nv-muted);
}

/* ============================================================================
   Chat column: header · stream · status/notice · input
   ========================================================================= */
.chat-header {
  flex-shrink: 0;
  height: var(--nv-bar-h);
  /* left-aligned with the input-mode tabs below (.nv-input-modes, 18px) */
  padding-left: 18px;
  padding-right: 6px;
  font-size: 14px;
  background-color: var(--nv-bg);
  border-bottom: 1px solid var(--nv-border);
}

.chat-scroll {
  min-height: 0;
  padding: var(--nv-gap) var(--nv-gap) var(--nv-gap) var(--nv-chat-gutter);
}

/* Model dropdown in the chat toolbar — compact, content-width. */
.nv-model-select {
  width: auto;
  font-size: 11px;
  padding-top: 2px;
  padding-bottom: 2px;
}

/* Unified output stream: every post is a rounded box with a distinct colour.
   Text-only posts cap at 60% of the chat width; assistant/program posts (which
   may carry code or data dumps) get a little more room. User-initiated posts
   (your text, CLI commands) align right; system/assistant posts align left. */
.nv-line {
  font-family: var(--nv-mono);
  line-height: 1.4;
  white-space: pre-wrap;
}

.nv-line--program {
  background-color: var(--nv-program-bg);
  color: var(--nv-program-fg);
  max-width: 80%;
  border-color: var(--nv-program-border);
}
.nv-line--cli {
  background-color: var(--nv-cli-bg);
  color: var(--nv-cli-fg);
  border-color: var(--nv-cli-border);
}
.nv-line--error {
  background-color: var(--nv-error-bg);
  color: var(--nv-error-fg);
  border-color: var(--nv-error-border);
}
.nv-line--warning {
  background-color: var(--nv-warning-bg);
  color: var(--nv-warning-fg);
  border-color: var(--nv-warning-border);
}
.nv-line--success {
  background-color: var(--nv-success-bg);
  color: var(--nv-success-fg);
  border-color: var(--nv-success-border);
}
.nv-line--info {
  background-color: var(--nv-info-bg);
  color: var(--nv-info-fg);
  border-color: var(--nv-info-border);
}

/* Outdated-firmware warning: a compact red alert card in the chat stream —
   title, message, update button. Overrides the nv-line mono/pre-wrap chrome:
   this is an alert, not console output. */
.nv-firmware-warning {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  white-space: normal;
  font-family: var(--bs-body-font-family);
}

.nv-firmware-warning-title {
  font-weight: 600;
}

.nv-firmware-warning-btn {
  margin-top: 0.35rem;
  border: none;
  border-radius: 0.375rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--nv-error-fg);
  color: var(--nv-error-bg);
}

.nv-firmware-warning-btn:hover {
  filter: brightness(1.12);
}

/* Firmware modal: one bordered card per board block. */
.nv-firmware-board {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

/* Input area = floating mode tabs + composer card. */
.nv-input-area {
  flex-shrink: 0;
}

/* Composer card — the screen's primary input: floating, flat, loud.
   3px Blaugrau outline + 10px radius (Pflaume on focus); constant height
   across the three modes, sized for a 3-row chat textarea. */
.nv-input {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 16px 16px;
  padding: 10px 12px;
  min-height: 96px;
  background-color: var(--nv-bg);
  border: 3px solid var(--br-bluegray);
  border-radius: 10px;
}

.nv-input:focus-within {
  border-color: var(--br-plum);
}

/* Mode tabs — tracked uppercase micro-labels with a Türkis underline.
   Also hosts the model dropdown, pushed to the row's right edge. */
.nv-input-modes {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  margin: 10px 18px 6px;
}

.nv-mode-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--br-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0 0 5px;
  cursor: pointer;
  white-space: nowrap;
}

.nv-mode-tab:hover {
  color: var(--nv-text);
}

.nv-mode-tab.active {
  color: var(--nv-text);
  border-bottom-color: var(--br-turquoise);
}

.nv-input-panel {
  min-height: 0;
}

/* Auto-growing chat composer (textarea grows to ~6 lines, then scrolls) */
.nv-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

/* The card itself is the field: the textarea inside is borderless. */
.nv-chat-input {
  resize: none;
  line-height: 1.4;
  overflow-y: hidden;
  border: 0;
  background: transparent;
  color: var(--nv-text);
}

.nv-chat-input:focus {
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--nv-text);
}

.nv-chat-input::placeholder {
  color: var(--nv-muted);
}

.nv-composer .btn {
  flex-shrink: 0;
}

/* ============================================================================
   Debug symbols panel (call stack + variables)
   ========================================================================= */
.debug-panel {
  flex-shrink: 0;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  background-color: var(--nv-bg);
  /* docked under the editor */
  border-top: 1px solid var(--nv-border);
}

.debug-panel-header {
  background-color: var(--nv-panel);
  font-size: 14px;
  flex-shrink: 0;
  color: var(--nv-text);
}

.debug-panel-content {
  overflow-y: auto;
  flex: 1;
  background-color: var(--nv-bg);
}

.debug-panel-content.collapsed {
  max-height: 0;
  overflow: hidden;
}

.debug-section {
  padding: 6px 10px;
  border-bottom: 1px solid var(--nv-border-soft);
}

.debug-section:last-child {
  border-bottom: none;
}

.debug-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--nv-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.debug-section-content {
  font-family: var(--nv-mono);
  font-size: 12px;
}

.debug-frame {
  padding: 3px 6px;
  margin: 1px 0;
  border-radius: 3px;
}
.debug-frame-current {
  background-color: var(--nv-user-bg);
}
.debug-frame-name {
  color: var(--nv-syntax-def);
}
.debug-frame-line {
  color: var(--nv-muted);
  font-size: 11px;
}
.debug-var {
  display: flex;
  align-items: baseline;
  padding: 2px 0;
  gap: 4px;
  flex-wrap: wrap;
}
.debug-var-section {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--nv-muted);
  margin-top: 8px;
  margin-bottom: 2px;
  padding-left: 2px;
}
.debug-var-section:first-child {
  margin-top: 0;
}
.debug-var-name {
  color: var(--nv-syntax-type);
}
.debug-var-type {
  color: var(--nv-muted);
  font-size: 11px;
}
.debug-var-eq {
  color: var(--nv-muted);
}
.debug-var-value {
  color: var(--nv-error-fg);
}

/* ============================================================================
   Compiler output (modal)
   ========================================================================= */
.compiler-output-content {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.compiler-output-content .error-line {
  color: var(--nv-error-fg);
  cursor: pointer;
}
.compiler-output-content .error-line:hover {
  text-decoration: underline;
}
.compiler-output-content .warning-line {
  color: var(--nv-warning-fg);
  cursor: pointer;
}
.compiler-output-content .warning-line:hover {
  text-decoration: underline;
}

/* ============================================================================
   Small screens: one area at a time — the editor becomes a fourth tab
   ========================================================================= */
@media (max-width: 768px) {
  .nv-header-left {
    flex: 1 1 auto;
    gap: 0.5rem;
    padding-left: 10px;
  }

  .nv-app .nv-brand-mark {
    display: none;
  }

  .nv-left-tabs {
    padding: 0 6px;
  }

  .nv-left-tab {
    min-width: 0;
  }

  .nv-left-tab--editor {
    display: inline-flex;
  }

  .nv-left {
    flex: 1 1 100%;
    border-right: 0;
  }

  .nv-divider,
  .nv-detail {
    display: none;
  }

  .nv-main[data-left-tab="editor"] .nv-left {
    display: none;
  }

  .nv-main[data-left-tab="editor"] .nv-detail {
    display: flex;
  }
}
