/* Application styles: sidebar shell, bordered cards without shadows.
   Fonts are served from our own host only (AGENTS.md §2.6). */

@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 200 800;
  font-display: swap; src: url("/fonts/manrope-variable.woff2") format("woff2");
}

:root {
  /* Studio palette (light): anthracite text and chrome, signature green for actions,
     pink for focus. The green is too light for text on white, so it is only a fill
     with black text; links use the dark step of the same green. */
  --app-text: #313a49;
  --app-heading: #1e232d;
  --app-muted: #575757;
  --app-accent: #14801e;
  --app-accent-hover: #16651d;
  --app-accent-soft: #f0fdf0;
  --app-focus: #de2053;
  /* Primary action: green fill, black text */
  --app-action: #61e26b;
  --app-action-hover: #bbf7bf;
  --app-action-border: #16a321;
  --app-action-text: #000;
  /* Current menu item */
  --app-nav-current: #1e232d;
  --app-nav-current-text: #fff;
  --app-nav-current-icon: #61e26b;
  /* Surfaces: page background, cards, fill inside cards */
  --app-bg: #f5f5f5;
  --app-paper: #fff;
  --app-surface: #fafafa;
  --app-border: #e6e6e6;
  /* Input border: 3:1 contrast against white */
  --app-input-border: #767676;
  --app-danger: #c33f3f;
  --app-danger-soft: #fff1f3;
  --app-danger-border: #fdced6;
  --app-success: #16651d;
  --app-success-soft: #dcfcde;
  --app-success-border: #bbf7bf;
  --app-warning: #7a4d00;
  --app-warning-soft: #fdf0d9;
  --app-neutral: #434343;
  --app-neutral-soft: #f0f0f0;
  --app-scrim: rgb(30 35 45 / 45%);
  --app-radius: 6px;
  --app-sidebar: 260px;

  color-scheme: light;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--app-text);
}

body.app {
  margin: 0;
  background: var(--app-bg);
}

.app h1,
.app h2,
.app h3 {
  color: var(--app-heading);
  font-weight: 600;
  line-height: 1.25;
}

.app h1 {
  font-size: 1.5rem;
}

.app h2 {
  font-size: 1.125rem;
}

.app a {
  color: var(--app-accent);
  text-underline-offset: 0.2em;
}

.app a:hover {
  color: var(--app-accent-hover);
}

.app :focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: 2px;
}

.app code {
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

/* Icon sprite: the hidden attribute has no effect on <svg> */
.app-icons {
  display: none;
}

.app-icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Shell: menu on the left (a <dialog> drawer on narrow screens), content on the right. */
.app-sidebar {
  display: none;
}

.app-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 14px 24px;
}

.app-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-brand {
  display: block;
  margin: 0 0 0 12px;
  color: var(--app-heading) !important;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
}

.app-brand::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--app-action);
  vertical-align: 0.05em;
}

.app-nav-group {
  margin: 20px 12px 6px;
  color: var(--app-muted);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-nav ul {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--app-radius);
  color: var(--app-text);
  text-decoration: none;
}

.app-nav a:focus-visible {
  outline-offset: -2px;
}

.app-nav li a:hover {
  background: var(--app-surface);
  color: var(--app-heading);
}

.app-nav li a[aria-current="page"] {
  background: var(--app-nav-current);
  color: var(--app-nav-current-text);
}

.app-nav li a[aria-current="page"] .app-icon {
  color: var(--app-nav-current-icon);
}

.app-drawer {
  box-sizing: border-box;
  width: min(280px, 85vw);
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid var(--app-border);
  background: var(--app-paper);
  color: var(--app-text);
}

.app-drawer::backdrop {
  background: var(--app-scrim);
}

.app-drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.app-drawer[open] {
  display: flex;
  flex-direction: column;
}

.app-drawer .app-nav-header {
  padding-right: 32px;
  min-height: 28px;
}

.app-mobile-menu {
  padding: 12px 16px 0;
}

.app-account {
  flex: none;
  display: grid;
  gap: 10px;
  padding: 16px 26px 20px;
  border-top: 1px solid var(--app-border);
}

.app-account-name {
  display: grid;
  color: var(--app-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.app-account-name strong {
  color: var(--app-heading);
  font-weight: 600;
}

.app-account form {
  margin: 0;
}

@media (min-width: 1024px) {
  body.app:not(.app-guest) {
    padding-left: var(--app-sidebar);
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: var(--app-sidebar);
    border-right: 1px solid var(--app-border);
    background: var(--app-paper);
  }

  .app-mobile-menu {
    display: none;
  }

  .app-sidebar-collapsed {
    --app-sidebar: 72px;
  }

  .app-sidebar-collapsed .app-sidebar .app-nav-header {
    justify-content: center;
  }

  .app-sidebar-collapsed .app-sidebar-toggle .app-icon {
    transform: rotate(180deg);
  }

  .app-sidebar-collapsed .app-sidebar :is(.app-brand, .app-nav-group) {
    display: none;
  }

  /* Labels stay available to screen readers; title gives a mouse tooltip. */
  .app-sidebar-collapsed .app-sidebar :is(.app-nav li a span, .app-account-name, .app-account button span) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app-sidebar-collapsed .app-sidebar .app-nav ul {
    margin-top: 16px;
  }

  .app-sidebar-collapsed .app-sidebar .app-nav li a {
    justify-content: center;
    padding: 10px;
  }

  .app-sidebar-collapsed .app-sidebar .app-account {
    padding-inline: 14px;
  }

  .app-sidebar-collapsed .app-sidebar .app-account button {
    width: 100%;
    padding-inline: 6px;
  }
}

.app-main {
  overflow-wrap: anywhere;
  max-width: 1400px;
  margin: 0;
  padding: 24px 16px 64px;
}

@media (min-width: 1024px) {
  .app-main {
    padding: 24px 24px 64px;
  }
}

/* Screens that use the whole width, e.g. nodes next to the PDF */
.app-main.app-main-wide {
  max-width: none;
}

/* Sign-in and two-factor: one centered card without the menu */
.app-guest .app-main {
  box-sizing: border-box;
  width: calc(100% - 32px);
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 24px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
}

.app-guest .app-brand {
  margin: 0 0 20px;
}

.app-guest h1,
.app-guest h2 {
  margin-top: 0;
}

.app-guest input[type="submit"] {
  width: 100%;
}

.app-guest form.button_to {
  margin-top: 16px;
}

/* Page heading in one row: the way back and the title on the left, a short line about the page
   after them, actions in the right corner. Wraps on a narrow screen. */
.app-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  margin-bottom: 16px;
}

.app-heading h1 {
  order: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.25rem;
}

.app-heading p {
  order: 2;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app-heading > :is(.app-heading-actions, .app-button, form) {
  order: 3;
  margin-left: auto;
}

.app-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* The way back sits before the title, set apart by a thin line. */
.app-back {
  display: inline-block;
  font-size: 0.875rem;
}

.app-heading > .app-back {
  order: 0;
  padding-right: 16px;
  border-right: 1px solid var(--app-border);
}

/* Buttons: default has a border, primary uses the accent, danger is red.
   A link styled as an action gets the app-button class. */
.app button,
.app input[type="submit"],
.app .app-button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--app-input-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
  color: var(--app-heading);
  font: inherit;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.app button:hover,
.app .app-button:hover {
  background: var(--app-surface);
  color: var(--app-heading);
}

.app input[type="submit"],
.app .app-button-primary {
  border-color: var(--app-action-border);
  background: var(--app-action);
  color: var(--app-action-text);
  font-weight: 600;
}

.app input[type="submit"]:hover,
.app .app-button-primary:hover {
  border-color: var(--app-action-border);
  background: var(--app-action-hover);
  color: var(--app-action-text);
}

.app button:disabled,
.app input[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app button.app-button-danger {
  border-color: var(--app-danger);
  color: var(--app-danger);
}

.app button.app-button-danger:hover {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

/* Text-like button (sign out on the guest card, "use another account") */
.app button.app-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--app-accent);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.app button.app-link:hover {
  background: none;
  color: var(--app-accent-hover);
}

.app .app-icon-button {
  min-width: 36px;
  padding: 6px;
  border-color: transparent;
}

/* Compact buttons inside tables */
.app .app-row-actions :is(button, .app-button) {
  min-height: 30px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* Status badges */
.app-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--app-neutral-soft);
  color: var(--app-neutral);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

/* An icon inside a badge keeps the height of its text. */
.app-badge .app-icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.app-badge-success {
  background: var(--app-success-soft);
  color: var(--app-success);
}

.app-badge-warning {
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

.app-badge-danger {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.app-flash {
  margin: 0 0 20px;
  padding: 10px 16px;
  border: 1px solid var(--app-success-border);
  border-radius: var(--app-radius);
  background: var(--app-success-soft);
  color: var(--app-success);
}

.app-token-issued {
  border-color: var(--app-success-border);
  background: var(--app-success-soft);
}

.app-token {
  display: block;
  padding: 8px 12px;
  overflow-wrap: anywhere;
  user-select: all;
  background: var(--app-surface);
  border: 1px solid var(--app-success-border);
  border-radius: var(--app-radius);
  font-size: 1rem;
}

.app-flash-alert {
  border-color: var(--app-danger-border);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.app-muted {
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app-empty-state {
  margin-block: 0 24px;
  padding: 24px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
}

.app-empty-state p {
  margin: 0 0 12px;
}

.app-empty-state > :last-child {
  margin-bottom: 0;
}

/* Turbo frames that wrap a card: a block, scrolled to with a little room above */
turbo-frame {
  display: block;
  scroll-margin-top: 16px;
}

/* Cards: form sections, tables, read-only details */
.app-card,
.app-table {
  box-sizing: border-box;
  margin: 0 0 24px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
}

.app-card {
  padding: 20px 24px;
}

.app-card > :is(h2, .app-heading):first-child {
  margin-top: 0;
}

.app-card > :last-child {
  margin-bottom: 0;
}

.app-card .app-heading {
  margin-bottom: 16px;
}

.app-card .app-table,
.app-card .app-empty-state {
  margin-bottom: 0;
}

.app-card .app-table + .app-inline-form {
  margin-top: 16px;
}

@media (max-width: 720px) {
  .app-card {
    padding: 16px;
  }
}

.app-section-title {
  margin: 32px 0 12px;
}

.app-table {
  width: 100%;
  border-spacing: 0;
  border-collapse: separate;
  overflow: hidden;
}

.app-table th,
.app-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-border);
  text-align: left;
  vertical-align: middle;
  /* Words wrap whole; file names and hashes opt into breaking anywhere (app-break) */
  overflow-wrap: normal;
}

.app-table th {
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-table :is(.app-break, code) {
  overflow-wrap: anywhere;
}

.app-table .app-nowrap,
.app-table .app-nowrap code {
  white-space: nowrap;
}

.app-table tbody tr:last-child td {
  border-bottom: 0;
}

.app-table tbody tr:hover {
  background: var(--app-surface);
}

/* A small table inside a cell, e.g. the rows of a table metric */
.app-table .app-table-compact {
  width: auto;
  margin: 0;
  border: 0;
  background: none;
}

.app-table .app-table-compact :is(th, td) {
  padding: 4px 16px 4px 0;
}

.app-table .app-table-compact th {
  background: none;
}

.app-table .app-table-compact tbody tr:hover {
  background: none;
}

@media (max-width: 720px) {
  .app-table .app-table-compact tr {
    padding: 4px 0;
  }
}

.app-list-title {
  color: var(--app-heading) !important;
  font-weight: 600;
  text-decoration: none;
}

.app-list-title:hover {
  color: var(--app-accent) !important;
  text-decoration: underline;
}

.app-list-detail {
  display: block;
  margin-top: 2px;
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-row-actions > div {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.app-row-actions form {
  margin: 0;
}

/* Narrow screens: each row becomes a card; columns flow inline with
   their header taken from data-label. */
@media (max-width: 720px) {
  .app-table,
  .app-table tbody {
    display: block;
  }

  .app-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--app-border);
  }

  .app-table tbody tr:last-child {
    border-bottom: 0;
  }

  .app-table td {
    display: block;
    padding: 0;
    border: 0;
  }

  .app-table .app-list-main {
    flex: 1 1 100%;
    min-width: 0;
  }

  .app-table td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--app-muted);
  }

  .app-table .app-row-actions {
    margin-left: auto;
  }
}

/* Read-only record details */
.app-details {
  display: grid;
  grid-template-columns: minmax(140px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0;
}

.app-details dt {
  color: var(--app-muted);
  font-weight: 500;
}

.app-details dd {
  margin: 0;
}

@media (max-width: 720px) {
  .app-details {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .app-details dd + dt {
    margin-top: 10px;
  }
}

.app-recipe-outdated {
  margin-top: 4px;
  color: var(--app-warning);
}

/* Review of a dataset version */
.app-pre-line {
  white-space: pre-line;
}

.app-review-form {
  margin-top: 20px;
}

/* A failed value without a decision blocks approval */
.app-table tbody tr.app-row-attention {
  background: var(--app-danger-soft);
}

.app-record-check > div {
  margin-top: 4px;
}

.app-record-acceptance {
  margin: 8px 0 0;
  font-size: 0.875rem;
}

.app-record-acceptance summary {
  color: var(--app-accent);
  cursor: pointer;
}

.app-record-acceptance form {
  display: grid;
  gap: 6px;
  min-width: 14rem;
  margin-top: 8px;
}

.app-record-acceptance form .app-button {
  justify-self: start;
}

.app-record-acceptance .button_to {
  display: inline;
}

/* Filters above a table */
.app-filters {
  margin-bottom: 16px;
}

/* Raw changes of an audit entry that has a summary */
.app .app-audit-changes {
  margin: 4px 0 0;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app-audit-changes summary {
  cursor: pointer;
}

/* Logs of background tasks: technical messages only, never client values. */
.app-log {
  margin: 0;
  padding: 12px 16px;
  overflow-x: auto;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Forms */
.app-form {
  max-width: 560px;
}

.app-field {
  margin-bottom: 16px;
}

.app-form fieldset {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
}

.app-form legend {
  margin-bottom: 12px;
  color: var(--app-heading);
  font-weight: 600;
}

.app-field label {
  display: block;
  margin-bottom: 4px;
  color: var(--app-heading);
  font-size: 0.875rem;
  font-weight: 500;
}

.app-field-hint {
  margin: 6px 0 0;
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app :is(input[type="text"], input[type="email"], input[type="password"], input[type="number"],
  input[type="url"], input[type="search"], input[type="date"], input[type="tel"], textarea, select) {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--app-input-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
  color: var(--app-text);
  font: inherit;
}

.app :is(input, textarea, select):focus-visible {
  border-color: var(--app-accent);
}

.app textarea {
  resize: vertical;
}

.app input[type="file"] {
  max-width: 100%;
  font: inherit;
}

/* Inline form: control and button in one row */
.app-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.app .app-inline-form :is(select, input[type="text"], input[type="search"]) {
  flex: 0 1 24rem;
  width: auto;
}

.app-errors {
  margin: 0 0 20px;
  padding: 12px 16px;
  border: 1px solid var(--app-danger-border);
  border-radius: var(--app-radius);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.app-errors ul {
  margin: 0;
  padding-left: 20px;
}

.field_with_errors {
  display: contents;
}

.field_with_errors :is(input, textarea, select) {
  border-color: var(--app-danger) !important;
}

.app .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Two-factor setup */
.qr img {
  display: block;
  width: 200px;
  height: 200px;
  margin: 16px 0;
}

.secret {
  display: block;
  margin: 8px 0 16px;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.app details {
  margin-bottom: 16px;
}

/* Path from the root of a recognised document to the current node */
.app-node-path {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0 0 16px 0;
  overflow-wrap: anywhere;
}

.app-node-path [aria-current] {
  color: var(--app-heading);
  font-weight: 600;
}

/* Screens that fill the window: the content under the heading takes at least the rest of the
   window and may grow taller, then the page scrolls (nodes next to the PDF). */
.app-main.app-main-fill {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 16px;
}

.app-main-fill > :is(.app-heading, .app-flash, [role="alert"], [role="status"]) {
  flex: none;
}

/* Nodes next to the PDF: the tree on the left at a readable width, on the right the node's card
   over the whole page of the PDF. The right column sets the height (at least the rest of the
   window); the tree takes the same height and scrolls inside. On a narrow screen they stack. */
.app-node-viewer {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 16px;
}

.app-node-tree-panel,
.app-node-side {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

.app-node-side > .app-card {
  margin: 0;
}

.app-node-tree-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* A long tree does not make the row taller: the panel takes the height of the right column. */
  contain: size;
}

.app-node-tree-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-inline: -8px;
  padding-inline: 8px;
}

.app-node-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* The node's card scrolls inside its frame. The border sits on the frame, so the card never looks
   cut off; the scrollbar stays visible (macOS hides overlay scrollbars) and a shadow at the bottom
   shows there is more below. */
.app-node-details {
  display: block;
  flex: none;
  max-height: 40vh;
  overflow: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background:
    linear-gradient(var(--app-paper) 30%, transparent) center top / 100% 32px no-repeat local,
    linear-gradient(transparent, var(--app-paper) 70%) center bottom / 100% 32px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgb(0 0 0 / 0.2), transparent) center top / 100% 14px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgb(0 0 0 / 0.2), transparent) center bottom / 100% 14px no-repeat scroll,
    var(--app-paper);
  scrollbar-gutter: stable;
}

.app-node-details::-webkit-scrollbar {
  width: 10px;
}

.app-node-details::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 5px;
  background: var(--app-border) padding-box;
}

.app-node-details::-webkit-scrollbar-thumb:hover {
  background-color: var(--app-muted);
}

.app-node-details > .app-card {
  margin: 0;
  border: 0;
  background: none;
}

.app-node-title {
  margin: 0 0 12px;
}

.app-node-path {
  font-size: 0.875rem;
}

.app-pdf-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
}

/* The tree: a row per node, parts indented under it. */
.app-tree-list {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;
}

.app-tree.app-tree-list {
  padding-left: 0;
}

.app-tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 6px 0 0;
  border-radius: var(--app-radius);
  white-space: nowrap;
}

.app-tree-row:hover {
  background: var(--app-surface);
}

.app-tree-item[aria-current] > .app-tree-row {
  background: var(--app-accent-soft);
  box-shadow: inset 3px 0 0 var(--app-accent);
}

.app-tree-item[aria-current] > .app-tree-row .app-tree-link {
  color: var(--app-heading);
  font-weight: 600;
  text-decoration: none;
}

.app .app-tree-toggle {
  flex: none;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: none;
}

.app-tree-toggle .app-icon {
  transition: transform 0.12s;
}

.app-tree-toggle[aria-expanded="true"] .app-icon {
  transform: rotate(90deg);
}

.app-tree-spacer {
  flex: none;
  width: 24px;
}

/* A tree reads as a menu: no underline, the whole row reacts to the pointer. */
.app-tree-link,
.app-node-search-list a {
  text-decoration: none;
}

.app-tree-link:hover,
.app-node-search-list a:hover {
  text-decoration: underline;
}

.app-tree-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-tree-meta {
  flex: none;
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-tree-more {
  margin: 4px 0 8px 30px;
}

.app-node-search-frame {
  display: block;
  flex: none;
  max-height: 40%;
  overflow: auto;
}

.app-node-search {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--app-border);
}

.app-tree-group {
  color: var(--app-heading);
  font-weight: 600;
}

.app-node-search p {
  margin: 0 0 8px;
}

.app-node-search-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.app-pdf-toolbar-gap {
  flex: 1;
}

/* The height of the whole page at 100%, set by the pdf-viewer controller. */
.app-pdf-stage {
  flex: none;
  min-height: 120px;
  overflow: auto;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
}

.app-pdf-page {
  position: relative;
  width: max-content;
  margin-inline: auto;
}

.app-pdf-page canvas {
  display: block;
  background: #fff;
}

.app-pdf-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

/* Boxes: the node's own in green, the nodes it is made of in anthracite, a number that did
   not read back from the PDF in red, the units of a page review in blue. */
.app-pdf-box {
  fill: rgb(49 58 73 / 6%);
  stroke: var(--app-text);
  stroke-width: 1;
  stroke-dasharray: 3 2;
  cursor: pointer;
}

.app-pdf-box-own {
  fill: rgb(97 226 107 / 22%);
  stroke: var(--app-accent);
  stroke-width: 2;
  stroke-dasharray: none;
}

.app-pdf-box-unit {
  fill: rgb(47 111 223 / 16%);
  stroke: #2f6fdf;
  stroke-width: 2;
  stroke-dasharray: none;
}

.app-pdf-legend-unit {
  color: #1f56b8;
  font-weight: 600;
}

/* Context nodes of a page review: label, kind and count, then the units they give. */
.app-page-review-list {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.app-page-review-list .app-list-detail {
  display: block;
}

.app-pdf-box-failed {
  fill: rgb(195 63 63 / 14%);
  stroke: var(--app-danger);
  stroke-width: 2;
  stroke-dasharray: none;
}

.app-pdf-box:hover {
  stroke: var(--app-focus);
}

.app-node-steps {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 16px 0;
}

.app-node-image img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  margin-bottom: 4px;
  border: 1px solid var(--app-border);
  background: repeating-conic-gradient(var(--app-neutral-soft) 0 25%, var(--app-paper) 0 50%) 0 0 / 16px 16px;
}

.app-hit-list {
  margin: 0;
  padding-left: 20px;
}

@media (max-width: 1100px) {
  .app-main.app-main-fill {
    display: block;
    padding-bottom: 64px;
  }

  .app-node-viewer {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-node-tree-panel {
    contain: none;
  }

  .app-node-tree-scroll {
    max-height: 50vh;
  }

  .app-node-details {
    max-height: none;
  }
}

/* Report: the tree of schematics and the fields of a schematic with their values */
.app-report-tree details {
  margin: 0;
}

.app-report-tree details > summary {
  cursor: pointer;
  list-style: none;
}

.app-report-tree details > summary::-webkit-details-marker {
  display: none;
}

.app-tree-chevron {
  display: inline-flex;
  flex: none;
  justify-content: center;
  width: 24px;
}

.app-tree-chevron .app-icon {
  transition: transform 0.12s;
}

.app-report-tree details[open] > summary .app-tree-chevron .app-icon {
  transform: rotate(90deg);
}

.app-report-tree .app-tree-meta {
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-component-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.app-fields-table td:first-child {
  width: 32%;
}

.app-slots {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0 0 4px;
}

.app-slots dt {
  color: var(--app-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.app-slots dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.app-binding {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  max-width: 100%;
  padding: 1px 8px;
  border: 1px solid var(--app-success-border);
  border-radius: 999px;
  background: var(--app-success-soft);
  font-size: 0.875rem;
}

.app-binding-inactive {
  border-color: var(--app-border);
  background: var(--app-neutral-soft);
}

.app-binding-broken {
  border-color: var(--app-danger-border);
  background: var(--app-danger-soft);
}

.app-binding-link {
  text-decoration: none;
}

.app-binding-link:hover {
  text-decoration: underline;
}

.app-binding-dataset {
  font-weight: 600;
}

.app-binding-note {
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-hand-value {
  display: block;
  white-space: pre-line;
}

.app-chips,
.app-marks {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.app-chips li,
.app-marks li {
  margin: 0 0 4px;
}

.app-mark-message {
  display: block;
  color: var(--app-muted);
  font-size: 0.8125rem;
}

@media (max-width: 720px) {
  .app-fields-table td:first-child {
    width: auto;
  }
}

.app-fields-table td {
  vertical-align: top;
}

.app-binding-text {
  color: var(--app-text);
}

.app-card.app-card-danger {
  border-color: var(--app-danger-border);
}

.app-card.app-card-warning {
  border-color: var(--app-warning);
}

/* Filter links above a list and a pager below it */
.app-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 16px;
}

.app-tabs a {
  padding: 4px 10px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  text-decoration: none;
}

.app-tabs a[aria-current] {
  border-color: var(--app-nav-current);
  background: var(--app-nav-current);
  color: var(--app-nav-current-text);
}

.app-pager {
  margin: 16px 0 0;
}

.app-usage-table td:first-child {
  width: 30%;
}

.app-usage-table td {
  vertical-align: top;
}

/* Correction of a recognised value: on the node card and in a row of "Used in the report". */
.app-correction {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--app-border);
}

.app-correction-title {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  font-size: 1rem;
}

.app-correction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.app-correction-actions .app-inline-form {
  margin: 0;
}

.app-correction-form,
.app-correction-history {
  margin-top: 12px;
}

.app-correction-row > summary,
.app-correction-back > summary,
.app-correction-scale > summary,
.app-correction-form > summary,
.app-correction-history > summary {
  cursor: pointer;
  color: var(--app-accent);
  font-weight: 500;
}

.app-correction-fields {
  margin-top: 12px;
}

.app-choice {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-right: 16px;
}

.app-correction-row {
  margin-top: 6px;
}

.app-correction-row .app-correction {
  margin-top: 8px;
  padding-top: 8px;
}

.app-correction-scale {
  margin-bottom: 16px;
}

.app-correction-scale > summary {
  margin-bottom: 8px;
}

.app-correction-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 16px;
}

.app-correction-back {
  margin-top: 8px;
}

.app .app-correction-switches [hidden] {
  display: none;
}

.app .app-correction-switches button {
  text-align: left;
}

/* The form of a schematic (stage 13): a card per component, a field under its description, the
   slots of a field one under the other. Focus changes the colour of a border only, never its
   width, so nothing in the form moves. */
.app-value-form-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 0 0 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg);
}

.app-value-form-bar > input[type="submit"] {
  margin-left: auto;
}

.app .app-language-switch {
  margin: 0;
}

.app .app-language-switch button {
  min-height: 32px;
  padding: 4px 10px;
  border-color: var(--app-border);
}

.app .app-language-switch button[aria-pressed="true"] {
  border-color: var(--app-nav-current);
  background: var(--app-nav-current);
  color: var(--app-nav-current-text);
}

.app-value-form-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.app-value-form[data-languages="en"] [data-slot-language="ar"],
.app-value-form[data-languages="ar"] [data-slot-language="en"] {
  display: none;
}

.app-value-field {
  padding: 14px 0;
  border-top: 1px solid var(--app-border);
}

.app-value-fields > .app-value-field:first-child {
  border-top: 0;
  padding-top: 0;
}

.app-value-field-refused {
  margin: 0 -12px;
  padding-right: 12px;
  padding-left: 12px;
  border-radius: var(--app-radius);
  background: var(--app-danger-soft);
}

.app-value-field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0 0 8px;
}

.app-value-field-description {
  color: var(--app-heading);
  font-weight: 600;
}

.app-value-field-name {
  color: var(--app-muted);
  font-size: 0.8125rem;
}

.app-value-slots {
  display: grid;
  gap: 8px;
}

.app-value-slot {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 12px;
}

.app-value-slot > :not(.app-value-slot-title) {
  grid-column: 2;
}

.app-value-slot > :is(.app-binding, .app-hand-value) {
  justify-self: start;
}

.app-value-slot-title {
  color: var(--app-muted);
  font-size: 0.875rem;
}

.app .app-value-slot :is(input[type="text"], select).app-value-short,
.app .app-value-slot select.app-value-short {
  max-width: 24rem;
}

/* A `file` slot: the picture, its size and how it was made, Upload / Replace and Remove. */
.app-file-tile {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.app-file-tile [hidden] {
  display: none;
}

.app-file-tile-picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 10rem;
  min-height: 6rem;
  padding: 4px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-surface);
  overflow-wrap: anywhere;
}

.app-file-tile-picture > img {
  display: block;
  max-width: 100%;
  max-height: 10rem;
  object-fit: contain;
}

.app-file-tile-about {
  display: grid;
  gap: 6px;
  flex: 1 1 14rem;
  justify-items: start;
}

.app-file-tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-file-tile-actions > label {
  cursor: pointer;
}

.app-file-tile-actions > label:focus-within {
  outline: 2px solid var(--app-focus);
  outline-offset: 2px;
}

.app-file-tile-error {
  color: var(--app-danger);
}

.app-value-date,
.app-value-link {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app .app-value-date > * {
  width: auto;
  flex: 0 1 11rem;
}

.app .app-value-date > .app-value-year {
  flex-basis: 6rem;
}

.app .app-value-link > input {
  flex: 1 1 20rem;
}

.app .app-value-link > select {
  width: auto;
  flex: 0 1 14rem;
}

.app-value-option {
  min-width: 0;
  margin: 8px 0 0;
  padding: 0;
  border: 0;
}

.app-value-option[hidden] {
  display: none;
}

.app-value-array-items,
.app-value-fixed,
.app-value-items {
  display: grid;
  gap: 8px;
  margin: 0 0 8px;
  padding-left: 1.75rem;
}

.app-value-items {
  margin-top: 8px;
}

.app-value-array-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.app-value-array-body {
  flex: 1 1 auto;
  min-width: 0;
}

.app-value-array-actions {
  display: flex;
  flex: 0 0 auto;
}

.app-nested {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
}

.app-nested > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.app-nested[open] > summary {
  border-bottom: 1px solid var(--app-border);
}

.app-nested > :not(summary) {
  display: block;
  padding: 4px 12px 12px;
}

/* How far the bound documents have been checked, under the heading of a schematic. */
.app-revision-checks {
  margin: -8px 0 16px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.app-binding-issue {
  color: var(--app-warning);
}

/* The picture of a component in the head of its card (zain2026 editor.md). */
.app-component-picture {
  align-self: center;
  width: auto;
  max-width: 96px;
  height: 40px;
  object-fit: contain;
  border: 1px solid var(--app-border);
  border-radius: 4px;
  background: var(--app-paper);
}

.app-nested-summary {
  min-width: 0;
  color: var(--app-muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* Binding a slot to a node: the buttons under the pill, and the picker in a dialog over the form,
   the search on the left, the node's card over its page of the PDF on the right. */
.app-binding-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-binding-dialog {
  box-sizing: border-box;
  width: min(1280px, calc(100vw - 32px));
  max-width: none;
  height: calc(100vh - 32px);
  max-height: none;
  padding: 20px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-paper);
  color: var(--app-text);
}

.app-binding-dialog::backdrop {
  background: var(--app-scrim);
}

.app-binding-dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.app-binding-picker-head h2 {
  margin: 0 40px 4px 0;
}

.app-binding-picker-head p {
  margin: 0 0 12px;
}

.app-binding-documents {
  margin-bottom: 12px;
}

.app-binding-picker {
  display: grid;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr);
  gap: 16px;
}

.app-binding-picker-search,
.app-binding-picker-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.app-binding-picker-search p {
  margin: 0;
}

.app-binding-card {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--app-border);
  border-radius: 6px;
}

.app-binding-card .app-node-title {
  margin-top: 0;
}

.app-binding-bind {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.app-binding-language {
  flex-basis: 100%;
  margin: 0;
}

.app-binding-language label {
  display: block;
  margin-top: 4px;
}

.app-binding-language-missing {
  color: var(--app-danger);
}

@media (max-width: 720px) {
  .app-binding-dialog {
    width: 100vw;
    height: 100vh;
    padding: 16px;
    border-radius: 0;
  }

  .app-binding-picker {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .app-value-slot {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-value-slot > :not(.app-value-slot-title) {
    grid-column: 1;
  }
}

/* Rich text editor (stage 13, Stimulus `richtext`): the text shown formatted, chips as pills that
   cannot be split. Focus changes the border colour only, so nothing in the form moves. */
.app-richtext {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.app-richtext-toolbar {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 0.875rem;
}

.app-richtext-toolbar-label {
  flex: 1 0 100%;
  min-height: 1.25rem;
}

.app-richtext-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.app-richtext-chip-actions {
  margin-inline-start: auto;
}

.app-richtext-group [hidden] {
  display: none;
}

.app-richtext-button {
  min-width: 2rem;
  min-height: 2rem;
  padding: 2px 8px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
  color: var(--app-text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
}

.app-richtext-button:hover {
  border-color: var(--app-input-border);
}

.app-richtext-button[aria-pressed="true"] {
  border-color: var(--app-heading);
  background: var(--app-heading);
  color: var(--app-paper);
}

.app-richtext-button:disabled {
  cursor: default;
  opacity: 0.5;
}

.app-richtext-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.app-richtext-button:focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: 1px;
}

.app-richtext-content,
.app-richtext-source {
  min-height: 2.5rem;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--app-input-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
  color: var(--app-text);
  font: inherit;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.app-richtext-content:focus {
  border-color: var(--app-accent);
  outline: none;
}

.app-richtext-content[contenteditable="false"] {
  background: var(--app-surface);
}

.app-richtext-content > :first-child { margin-top: 0; }
.app-richtext-content > :last-child { margin-bottom: 0; }
.app-richtext-content p { margin: 0 0 8px; }
.app-richtext-content :is(ul, ol) { margin: 0 0 8px; padding-inline-start: 1.5rem; }
.app-richtext-content h1 { margin: 12px 0 6px; font-size: 1.25rem; }
.app-richtext-content h2 { margin: 10px 0 6px; font-size: 1.0625rem; }

.app .app-richtext-markdown {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875rem;
}

/* A chip: a value from the document (green), typed by hand (grey), a number (bold), or one that
   publishes empty (red). */
.app-chip {
  padding: 0 4px;
  border: 1px solid var(--app-success-border);
  border-radius: 4px;
  background: var(--app-success-soft);
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.app-chip-hand {
  border-color: var(--app-border);
  background: var(--app-neutral-soft);
}

.app-chip-number {
  font-weight: 600;
}

.app-chip-broken {
  border-color: var(--app-danger-border);
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.app-chip-selected {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 1px var(--app-focus);
}

.app-richtext-problem:not([hidden]) {
  color: var(--app-warning);
}

/* ProseMirror needs these (prosemirror-view/style/prosemirror.css). */
.ProseMirror { position: relative; word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; font-variant-ligatures: none; }
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
.ProseMirror [draggable][contenteditable=false] { user-select: text; }
.ProseMirror-selectednode { outline: none; }
li.ProseMirror-selectednode { outline: none; }

/* Table grid of a table field (stage 13, ValueSet::TableGrid): the value as a grid that scrolls
   sideways on its own, so the page never does. Header rows shaded, totals bold, marked cells
   outlined in the warning colour, corrected ones in the success colour. */
.app-table-frame {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.app-table-grid-summary {
  margin: 0;
  font-size: 0.875rem;
}

.app-table-grid-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
}

.app-table-grid {
  border-collapse: collapse;
  font-size: 0.875rem;
  min-width: 100%;
}

.app-table-grid :is(th, td) {
  border: 1px solid var(--app-border);
  padding: 4px 8px;
  vertical-align: top;
  text-align: start;
}

/* A text cell may hold line breaks (table.ts); only the text keeps them, not the markup around it. */
.app-table-cell-text {
  white-space: pre-line;
}

.app-table-grid th,
.app-table-grid-units td {
  background: var(--app-surface);
  color: var(--app-heading);
  font-weight: 600;
}

.app-table-grid-units td {
  color: var(--app-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.app-table-grid td.app-table-cell-number {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-table-grid :is(.app-table-grid-total, .app-table-grid-subtotal, .app-table-grid-group) td {
  font-weight: 600;
}

/* Indent of a row's level (classes: the CSP allows no inline style); deeper levels stay at 4. */
.app-table-grid .app-table-level-1 { padding-inline-start: 1.5em; }
.app-table-grid .app-table-level-2 { padding-inline-start: 2.5em; }
.app-table-grid .app-table-level-3 { padding-inline-start: 3.5em; }
.app-table-grid .app-table-level-4 { padding-inline-start: 4.5em; }

.app-table-grid .app-table-cell-marked {
  background: var(--app-warning-soft);
  border-bottom: 2px dashed var(--app-warning);
}

.app-table-grid .app-table-cell-corrected {
  background: var(--app-success-soft);
}

.app-table-grid a.app-table-cell-link {
  color: inherit;
  text-decoration: none;
}

.app-table-grid .app-table-cell-number .app-table-cell-text {
  white-space: nowrap;
}

.app-table-grid a.app-table-cell-link:hover {
  color: var(--app-accent);
  text-decoration: underline;
}

.app-table-row-unit {
  margin-inline-start: 6px;
  color: var(--app-muted);
  font-size: 0.75rem;
  font-weight: 400;
}

.app .app-table-cell-input {
  min-width: 8rem;
  width: 100%;
  min-height: 0;
  padding: 2px 4px;
  font: inherit;
  resize: vertical;
}

.app-table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.app-table-select {
  flex: 1 1 100%;
}

.app-table-select > summary {
  cursor: pointer;
}

.app-table-select-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 12px;
}

.app-table-select-lists h4 {
  margin: 8px 0 4px;
}

.app-table-choices {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-table-choices .app-table-choices {
  padding-inline-start: 1.5em;
}

.app-table-choice-line {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.app-table-choice-line label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.app-table-select-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* The preview next to the form (stage 13): the form and the page of the stand side by side, the
   page held in view while the form scrolls. A page that is loading is covered whole, in words
   large enough to see. On a narrow screen the page stands under the bar of the form. */
.app-schematic-editor-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.app-preview {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  padding: 10px 0 16px;
}

.app-preview[hidden] {
  display: none;
}

.app-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-bottom: 10px;
}

.app-preview-where {
  flex: 1;
  min-width: 0;
}

.app-preview-frames {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-paper);
}

.app-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.app-preview-frame[hidden],
.app-preview-cover[hidden] {
  display: none;
}

.app-preview-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--app-paper);
  color: var(--app-heading);
  font-size: 1.5rem;
  text-align: center;
}

.app-preview-note {
  color: var(--app-warning);
}

/* A field opened by a click on the page: its border shows where it is, for a moment. */
.app-value-field-picked {
  border-radius: var(--app-radius);
  box-shadow: 0 0 0 2px var(--app-focus);
  transition: box-shadow 0.3s;
}

@media (max-width: 1100px) {
  .app-schematic-editor-preview {
    display: flex;
    flex-direction: column-reverse;
  }

  .app-preview {
    position: static;
    width: 100%;
    height: 70vh;
  }
}

/* The page of a schematic in its frame (schematics/show, with a preview). */
.app-schematic-page {
  display: block;
  min-width: 0;
}
