:root {
  /* Height of the sticky result tabs; offset for sticky elements below them. */
  --result-nav-height: 3.6rem;
  --color-bg: #f5f6f8;
  --color-panel: #ffffff;
  --color-border: #d7dbe0;
  --color-text: #1f2933;
  --color-muted: #647382;
  --color-found: #1b7f4d;
  --color-found-bg: #e5f5ec;
  --color-not-found: #8a6d1f;
  --color-not-found-bg: #fbf3dd;
  --color-error: #b02a37;
  --color-error-bg: #fbe3e5;
  --color-not-queryable: #5b6672;
  --color-not-queryable-bg: #eceff2;
  --color-warning: #b02a37;
  --color-warning-bg: #fde3e3;
  --color-accent: #1f5fbf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.4;
}

.app-header {
  padding: 1.5rem 2rem 0.75rem;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.app-logo {
  color: var(--color-accent);
  flex: none;
}

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

/* --- Help "?" popover next to the title --- */

.app-help {
  position: relative;
  display: inline-flex;
}

.help-button {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.help-button:hover {
  color: var(--color-text);
  border-color: var(--color-muted);
}

.help-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.help-popover {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 10;
  width: max-content;
  max-width: 22rem;
  padding: 0.6rem 0.8rem;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgb(31 41 51 / 12%);
  color: var(--color-text);
  font-size: 0.9rem;
}

.help-popover[hidden] {
  display: none;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem 2rem 3rem;
}

/* --- Top-navigation tabs --- */

.tabs {
  padding: 0 2rem;
  border-bottom: 1px solid var(--color-border);
}

.tablist {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.tab {
  padding: 0.65rem 1.25rem;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-muted);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: -1px;
  transition:
    color 0.12s ease,
    border-color 0.12s ease;
}

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

.tab[aria-selected="true"] {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  border-radius: 4px;
}

.tabpanel[hidden] {
  display: none;
}

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

.panel {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.panel h2 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-grow {
  flex: 1 1 240px;
}

.field-actions {
  justify-content: flex-end;
}

/* Search button + the small info bubble behind it. */
.search-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.info-bubble {
  position: relative;
  /* "leicht erhöht": sits slightly above the button's top edge like a superscript. */
  transform: translateY(-0.4rem);
}

.info-bubble .info-bubble-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  cursor: help;
}
.info-bubble .info-bubble-icon:hover:not(:disabled),
.info-bubble .info-bubble-icon:focus-visible {
  background: transparent;
  color: var(--color-accent);
}
.info-bubble .info-bubble-icon:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}
.info-bubble-text {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  background: #202124;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 400;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

.info-bubble:hover .info-bubble-text,
.info-bubble:focus-within .info-bubble-text {
  visibility: visible;
  opacity: 1;
}

/* Keep the submit button in an action field from stretching to the full field width. */
.field-actions button {
  align-self: flex-start;
}

.form-inline .field-actions button {
  align-self: stretch;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.95rem;
}

button {
  padding: 0.5rem 1.1rem;
  min-height: 2.3rem;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition:
    background 0.12s ease,
    border-color 0.12s ease;
}

button:hover:not(:disabled) {
  background: #1a52a6;
  border-color: #1a52a6;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* The "?" help toggle and other secondary controls opt out of the primary button look. */
.help-button {
  min-height: 0;
  font-weight: 700;
}

.help-button:hover:not(:disabled) {
  background: var(--color-panel);
  border-color: var(--color-muted);
}

.field-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.status-note {
  margin: 0.5rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.error-note {
  margin: 0.5rem 0 0;
  color: var(--color-error);
  font-weight: 600;
  min-height: 1.2em;
}

.error-note:empty {
  display: none;
}

/* --- Partial view cards --- */

.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--color-not-queryable-bg);
  color: var(--color-not-queryable);
}

.badge-alert {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-ok {
  background: var(--color-found-bg);
  color: var(--color-found);
}

.status-pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-found {
  background: var(--color-found-bg);
  color: var(--color-found);
}

.status-not_found {
  background: var(--color-not-found-bg);
  color: var(--color-not-found);
}

.status-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.status-not_queryable {
  background: var(--color-not-queryable-bg);
  color: var(--color-not-queryable);
}

/* --- Search-page rate-limit status strip (not in the result matrix) --- */

.rate-limit-details {
  margin: 0 0 0.4rem;
}

.rate-limit-title {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.rate-limit-table {
  border-collapse: collapse;
  font-size: 0.85rem;
}

.rate-limit-table th,
.rate-limit-table td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.7rem;
  text-align: left;
}

.rate-limit-table thead th {
  background: var(--color-not-queryable-bg);
  font-weight: 700;
}

.rate-limit-table .rate-system {
  font-weight: 700;
}

.rate-limit-table .rate-row-warning {
  background: var(--color-warning-bg);
}

.rate-limit-table .rate-row-warning td {
  color: var(--color-warning);
}

.rate-limit-table .rate-warn-flag {
  color: var(--color-warning);
  font-weight: 700;
}

/* --- Result views below the search form (tabs + rate-limit chip) --- */
.result-nav {
  /* Stays reachable while a long view (e.g. a long JSON) is scrolled. */
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
  padding: 0.4rem;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.view-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.view-tab {
  cursor: pointer;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-panel);
  color: var(--color-text);
  padding: 0.25rem 0.9rem;
  font-size: 0.9rem;
}

.view-tab:hover {
  border-color: var(--color-muted);
}

.view-tab[aria-selected="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.view-tab:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.view-panel[hidden] {
  display: none;
}

/* Rate-limit icon between the search input and the button; details live in the tooltip. */
.rate-limit-bubble {
  transform: none;
}

.rate-limit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  min-height: 2.3rem;
  padding: 0;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: #44505c;
  cursor: help;
}

.rate-limit-icon:hover:not(:disabled),
.rate-limit-icon:focus-visible {
  background: var(--color-panel);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Nothing to show yet (no search / no data): greyed out. */
.rate-limit-icon[data-level="none"] {
  color: #8895a1;
}

.rate-limit-icon-warning,
.rate-limit-icon-warning:hover:not(:disabled) {
  border-color: var(--color-warning);
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* The tooltip is dark: re-colour the table that renderRateLimitStatus puts into it. */
.rate-limit-status {
  min-width: 14rem;
  white-space: normal;
}

.rate-limit-status .rate-limit-title {
  margin: 0 0 0.4rem;
  color: #fff;
}

.rate-limit-status .rate-limit-table th,
.rate-limit-status .rate-limit-table td {
  border-color: #4a4d52;
  color: #fff;
  white-space: nowrap;
}

.rate-limit-status .rate-limit-table thead th {
  background: #34373c;
}

.rate-limit-status .rate-limit-table .rate-row-warning {
  background: #5c2327;
}

.rate-limit-status .rate-limit-table .rate-row-warning td,
.rate-limit-status .rate-limit-table .rate-warn-flag {
  color: #ffb4b4;
}

/* --- Collapsible value-matrix wrapper --- */

.value-matrix-details {
  margin: 1rem 0;
}

.value-matrix-details > summary {
  cursor: pointer;
  font-weight: 600;
}

/* --- Summary section (configurable overview) --- */

.summary-remove {
  cursor: pointer;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-panel);
  color: var(--color-muted);
  border-radius: 4px;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  min-height: 0;
}

.summary-remove:hover {
  color: var(--color-text);
  border-color: var(--color-muted);
  background: var(--color-panel);
}

.evaluation .hint {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0;
}

.summary-table {
  border-collapse: collapse;
  min-width: 24rem;
}

.summary-table th,
.summary-table td {
  text-align: left;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.summary-table th {
  font-weight: 600;
  white-space: nowrap;
}

.summary-table td {
  overflow-wrap: anywhere;
}

.summary-table .summary-missing {
  color: var(--color-muted);
}

/* Spaces are data: keep them (and wrap only at real breaks). */
.summary-cell {
  white-space: pre-wrap;
}

/* Only values are tinted, template text is not, so spaces inside a value show as gaps. */
.summary-val {
  background: #e8f0fb;
  border-radius: 3px;
  padding: 0 2px;
}

.summary-val-missing {
  color: var(--color-muted);
}

/* System icon, superscript so it does not break the reading flow. */
.summary-src {
  display: inline-block;
  margin-left: 2px;
  font-size: 0;
  line-height: 0;
  color: var(--color-muted);
  vertical-align: super;
  white-space: normal;
}

.summary-src svg {
  width: 0.7rem;
  height: 0.7rem;
}

/* --- JSON viewer (filter + copy) inside the raw-data view --- */

.raw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0 0;
}

.raw-filter {
  flex: 1 1 14rem;
}

.raw-copy {
  min-height: 0;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  background: var(--color-panel);
  color: var(--color-accent);
  border: 1px solid var(--color-border);
}

.raw-copy:hover:not(:disabled) {
  background: #eef4fd;
  border-color: var(--color-accent);
}

.raw-copy.copied {
  background: var(--color-found-bg);
  color: var(--color-found);
  border-color: var(--color-found);
}

/* The JSON block is dark with light text, so a hit needs its OWN dark text colour: inheriting the
   light text on the light-yellow background was unreadable. #0f1620 on #ffd24a is about 12:1. */
mark.raw-hit {
  background: #ffd24a;
  color: #0f1620;
  font-weight: 700;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #ffd24a;
}

pre.json {
  margin: 0.4rem 0 0;
  padding: 0.6rem;
  background: #0f1620;
  color: #e6edf3;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.8rem;
}

/* --- History --- */

.history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-total {
  font-size: 0.9rem;
  color: var(--color-muted);
}

.history-item {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

.history-item time {
  font-weight: 600;
}

.history-caller {
  color: var(--color-muted);
}

.history-systems {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.history-actions {
  margin-top: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* --- Diff --- */

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.diff-table th,
.diff-table td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.diff-table th {
  background: var(--color-not-queryable-bg);
}

.diff-row-changed td {
  background: var(--color-not-found-bg);
}

.diff-attr {
  font-weight: 600;
  color: var(--color-muted);
}

/* --- Multi-response per system (FEAT-003) --- */
.response-omitted {
  font-style: italic;
  color: var(--color-muted);
  margin: 0.3rem 0 0;
}

/* --- Server consistency view (FEAT-003) --- */
.consistency-system {
  margin: 0.5rem 0;
}
.consistency-system-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.3rem;
}
.consistency-system-name {
  font-weight: 600;
}
.consistency-diff {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.consistency-diff th,
.consistency-diff td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.consistency-diff th {
  background: var(--color-not-queryable-bg);
}
.consistency-path {
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}
.consistency-value-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.2rem;
}
.consistency-value .consistency-origin {
  color: var(--color-muted);
  margin-left: 0.4rem;
  font-size: 0.8rem;
}
.consistency-value.absent .consistency-val {
  font-style: italic;
  color: var(--color-not-found);
}
.consistency-echo {
  margin-left: 0.4rem;
  color: var(--color-muted);
  font-size: 0.75rem;
}
.diff-present-absent td {
  background: var(--color-not-found-bg);
}
.diff-mismatch td {
  background: var(--color-error-bg);
}

/* --- Trace graph (FEAT-003) --- */
.trace-graph {
  width: 100%;
  max-width: 720px;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-panel);
}
.trace-node rect {
  fill: var(--color-bg);
  stroke: var(--color-border);
  stroke-width: 1.5;
}
.trace-node-input rect {
  fill: var(--color-not-queryable-bg);
}
.trace-node-query rect {
  fill: var(--color-found-bg);
}
.trace-node-inconsistent rect {
  fill: var(--color-error-bg);
  stroke: var(--color-error);
}
.trace-node-label {
  font-size: 11px;
  font-weight: 600;
  fill: var(--color-text);
}
.trace-node-sublabel {
  font-size: 9px;
  fill: var(--color-muted);
}
.trace-edge {
  stroke: var(--color-muted);
  stroke-width: 1.2;
}
.trace-edge-reveals {
  stroke: var(--color-accent);
  stroke-dasharray: 4 3;
}
.trace-edge-queries {
  stroke: var(--color-found);
}

/* ===================================================================================
   Phase-1 value matrix (FEAT-002). Scoped under .value-matrix so these rules never
   collide with other tables. Ported from
   mock.html; chain dimming is driven by a JS-toggled `.dimmed`/`.off` class instead
   of the mock's pure-CSS hidden checkboxes.
   =================================================================================== */
.value-matrix {
  /* Fixed 5-slot chain palette + the grey/amber/cell tokens from the mock. */
  --chain-1: #1a73e8;
  --chain-2: #8430ce;
  --chain-3: #00897b;
  --chain-4: #c76d00;
  --chain-5: #ad1457;
  --vm-cell-bg: #f6f7f8;
  --vm-cell-br: #cdd0d4;
  --vm-grey-bg: #e8eaed;
  --vm-amber-bg: #fef7e0;
  --vm-amber-fg: #8a5300;
  --vm-amber-br: #e37400;
  --vm-dim: 0.18;
}
.value-matrix:empty {
  display: none;
}
.value-matrix .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.value-matrix .legend-title {
  font-size: 12px;
  color: var(--color-muted);
}
.value-matrix .chaintoggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 3px 9px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 12px;
  background: #fff;
  color: var(--color-text);
  transition:
    opacity 0.12s,
    background 0.12s;
}
.value-matrix .chaintoggle:hover {
  background: #f1f3f4;
}
.value-matrix .chaintoggle .chainbar {
  width: 12px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
  background: var(--color-muted);
}
.value-matrix .chaintoggle.c1 .chainbar {
  background: var(--chain-1);
}
.value-matrix .chaintoggle.c2 .chainbar {
  background: var(--chain-2);
}
.value-matrix .chaintoggle.c3 .chainbar {
  background: var(--chain-3);
}
.value-matrix .chaintoggle.c4 .chainbar {
  background: var(--chain-4);
}
.value-matrix .chaintoggle.c5 .chainbar {
  background: var(--chain-5);
}
.value-matrix .chaintoggle.off {
  opacity: 0.45;
  background: #f1f3f4;
  text-decoration: line-through;
}
.value-matrix .hint {
  font-size: 11.5px;
  color: var(--color-muted);
}
.value-matrix .value-matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
  margin-bottom: 8px;
}
.value-matrix .value-matrix-table th,
.value-matrix .value-matrix-table td {
  border: 1px solid var(--color-border);
  padding: 8px 10px;
  vertical-align: top;
  text-align: left;
}
.value-matrix .value-matrix-table thead th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.value-matrix .value-matrix-table tbody th.value-matrix-rowhead {
  background: #f8f9fa;
  font-weight: 600;
  white-space: nowrap;
  width: 128px;
}
.value-matrix .value-matrix-table td.grey {
  background: var(--vm-grey-bg);
  text-align: center;
  color: var(--color-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.value-matrix .value-matrix-table td.empty {
  color: var(--color-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}
.value-matrix .cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.value-matrix .val {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--vm-cell-bg);
  border: 1px solid var(--vm-cell-br);
  width: fit-content;
  max-width: 100%;
  border-left-width: 4px;
  transition:
    opacity 0.12s,
    filter 0.12s;
}
.value-matrix .val.c1 {
  border-left-color: var(--chain-1);
}
.value-matrix .val.c2 {
  border-left-color: var(--chain-2);
}
.value-matrix .val.c3 {
  border-left-color: var(--chain-3);
}
.value-matrix .val.c4 {
  border-left-color: var(--chain-4);
}
.value-matrix .val.c5 {
  border-left-color: var(--chain-5);
}
/* Shared (branch-point) value: split two chain colors and drop the single left bar. The two
   owning chains are expressed through the paired c{n} classes already on the element. */
.value-matrix .val.shared {
  border-left: none;
  border: 1px solid var(--vm-cell-br);
}
.value-matrix .val.shared.c1.c2 {
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--chain-1) 22%, #fff) 0 50%,
    color-mix(in srgb, var(--chain-2) 22%, #fff) 50% 100%
  );
  box-shadow:
    inset 4px 0 0 var(--chain-1),
    inset -4px 0 0 var(--chain-2);
}
.value-matrix .val.shared.c1.c3 {
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--chain-1) 22%, #fff) 0 50%,
    color-mix(in srgb, var(--chain-3) 22%, #fff) 50% 100%
  );
  box-shadow:
    inset 4px 0 0 var(--chain-1),
    inset -4px 0 0 var(--chain-3);
}
/* Any other shared pairing still reads as shared via a neutral two-tone + both end bars. */
.value-matrix .val.shared {
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--color-muted) 14%, #fff) 0 50%,
    color-mix(in srgb, var(--color-muted) 4%, #fff) 50% 100%
  );
}
/* A value whose every chain is toggled off: recede into the background but stay just readable.
   Driven by the JS-toggled `.dimmed` class (NOT the mock's pure-CSS checkboxes). */
.value-matrix .val.dimmed {
  opacity: var(--vm-dim);
  filter: grayscale(0.7);
}
.value-matrix .value-matrix-table td.error {
  background: var(--vm-amber-bg);
}
.value-matrix .errorcell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--vm-amber-fg);
  font-size: 12px;
}
.value-matrix .errorcell .top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.value-matrix .errorcell .msg {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}
/* Red warning box above the table when the 5-chain cap was reached. */
.value-matrix .warnbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fce8e6;
  border: 1px solid #c5221f;
  border-left: 5px solid #c5221f;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 8px 0 10px;
  color: #a50e0e;
  font-size: 13px;
}
.value-matrix .warnbox strong {
  display: block;
  margin-bottom: 2px;
}
/* A discovered-but-unfollowed (open) value: dashed, hatched, muted, with an `offen` badge. */
.value-matrix .val.open {
  border-style: dashed;
  color: var(--color-muted);
  background: repeating-linear-gradient(45deg, #fff, #fff 5px, #f3f4f6 5px, #f3f4f6 10px);
}
.value-matrix .openbadge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #a36200;
  background: var(--vm-amber-bg);
  border: 1px solid var(--vm-amber-br);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 2px;
}

/* ===================================================================================
   Profiles + search path (matrix). "Ketten" are shown to end users as PROFILES (P1, P2, …):
   coloured P-tags on values, a two-row legend, a numbered hover path inside the matrix and a
   collapsible search-path tree below the table.
   =================================================================================== */
.value-matrix .legend.profile-legend {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.value-matrix .legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.value-matrix .legend-row > .legend-title {
  min-width: 118px;
}
.value-matrix .ptag {
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.5;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--color-muted);
}
.value-matrix .ptag.pt1 {
  background: var(--chain-1);
}
.value-matrix .ptag.pt2 {
  background: var(--chain-2);
}
.value-matrix .ptag.pt3 {
  background: var(--chain-3);
}
.value-matrix .ptag.pt4 {
  background: var(--chain-4);
}
.value-matrix .ptag.pt5 {
  background: var(--chain-5);
}

/* Path line above the table. */
.value-matrix .pathline {
  min-height: 22px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f1f3f4;
  color: var(--color-muted);
  font-size: 12.5px;
}
.value-matrix .pathline strong {
  color: var(--color-text);
}

/* Hover: IDs that led to the hovered value are numbered; everything else recedes. */
.value-matrix.hovering .val:not(.pathused):not(.target) {
  opacity: 0.22;
  filter: grayscale(0.6);
}
.value-matrix .val.pathused {
  position: relative;
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}
.value-matrix .val.pathused::after {
  content: attr(data-n);
  position: absolute;
  top: -9px;
  right: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1a73e8;
  color: #fff;
  font:
    700 11px system-ui,
    sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}
.value-matrix .val.target {
  outline: 3px solid #188038;
  outline-offset: 1px;
  background: #e6f4ea;
}
.value-matrix .val.hl {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
  background: #e8f0fe;
}
.value-matrix .val:focus-visible {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}

/* Search-path tree below the table. */
.value-matrix .searchpath {
  margin-top: 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 14px;
}
.value-matrix .searchpath > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.value-matrix .ptree {
  list-style: none;
  margin: 6px 0 0;
  padding-left: 22px;
  border-left: 1px dashed #bdc1c6;
}
.value-matrix .ptree.ptree-root {
  padding-left: 0;
  border-left: none;
}
.value-matrix .pnode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
  padding: 3px 9px;
  font-size: 12.5px;
  background: var(--vm-cell-bg);
  border: 1px solid var(--vm-cell-br);
  border-left: 4px solid var(--color-muted);
  border-radius: 6px;
  transition: background 0.1s;
}
.value-matrix .pnode.pc1 {
  border-left-color: var(--chain-1);
}
.value-matrix .pnode.pc2 {
  border-left-color: var(--chain-2);
}
.value-matrix .pnode.pc3 {
  border-left-color: var(--chain-3);
}
.value-matrix .pnode.pc4 {
  border-left-color: var(--chain-4);
}
.value-matrix .pnode.pc5 {
  border-left-color: var(--chain-5);
}
.value-matrix .pnode-miss {
  color: var(--color-muted);
}
.value-matrix .pnode-status {
  font-size: 11px;
  font-style: italic;
}
.value-matrix .pnode-new {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--color-muted);
  border-radius: 999px;
  padding: 0 6px;
}
.value-matrix .pnode.hl {
  background: #e8f0fe;
  outline: 2px solid #1a73e8;
}
.value-matrix .searchpath.dim .pnode:not(.hl) {
  opacity: 0.45;
}
#search-form[aria-busy="true"] button[type="submit"] {
  cursor: progress;
}

/* --- Raw-data view: search-path tree (left) + request details (right) --- */
.raw-heading {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}

.raw-layout {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 800px) {
  .raw-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .raw-tree {
    position: static;
    max-height: 14rem;
  }
}

.raw-tree,
.raw-detail {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.6rem;
}

/* The tree stays in view next to a long JSON (below the sticky result tabs) and scrolls itself
   when it is longer than the window. */
.raw-tree {
  position: sticky;
  top: var(--result-nav-height);
  max-height: calc(100vh - var(--result-nav-height) - 1rem);
  overflow-y: auto;
}

/* A long JSON scrolls inside its own box, so the facts, search and copy stay on screen. */
.raw-detail pre.json {
  max-height: calc(100vh - var(--result-nav-height) - 14rem);
  min-height: 8rem;
  overflow: auto;
}

.raw-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.raw-tree-list .raw-tree-list {
  margin-left: 0.6rem;
  padding-left: 0.7rem;
  border-left: 1px dashed var(--color-border);
}

.raw-tree-list li {
  margin: 0.15rem 0;
}

.raw-node {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  width: 100%;
  min-height: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  font-weight: 400;
  text-align: left;
}

.raw-node:hover:not(:disabled) {
  background: #eef4fd;
  border-color: transparent;
}

.raw-node.selected {
  background: #e8f0fb;
  border-color: var(--color-accent);
}

.raw-node:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.raw-node-empty {
  opacity: 0.55;
}

.raw-node-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.raw-node-sys {
  font-weight: 600;
}

.raw-node-id {
  color: var(--color-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.raw-node-profile {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-accent);
}

.raw-node-new {
  font-size: 0.72rem;
  color: #6a2fb0;
}

.raw-detail-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.raw-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.2rem 0.9rem;
  margin: 0 0 0.75rem;
}

.raw-facts dt {
  color: var(--color-muted);
}

.raw-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.raw-delivered {
  margin: 0;
}

.raw-delivered-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  max-width: 100%;
}

.raw-delivered-table th,
.raw-delivered-table td {
  border: 1px solid var(--color-border);
  padding: 0.25rem 0.6rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.raw-delivered-table thead th {
  background: var(--color-not-queryable-bg);
  font-weight: 700;
}

.raw-delivered-table .raw-delivered-type {
  font-weight: 600;
  white-space: nowrap;
}

/* --- Auswertung: menu (groups of summaries and checks) + panels --- */
.eval-layout {
  display: grid;
  grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 800px) {
  .eval-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.eval-nav {
  position: sticky;
  top: var(--result-nav-height);
  max-height: calc(100vh - var(--result-nav-height) - 1rem);
  overflow-y: auto;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem;
}

@media (max-width: 800px) {
  .eval-nav {
    position: static;
    max-height: 16rem;
  }
}

.eval-group + .eval-group {
  margin-top: 0.6rem;
}

.eval-group-title {
  margin: 0 0 0.2rem;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.eval-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.eval-item {
  display: flex;
  align-items: stretch;
  gap: 0.2rem;
  margin: 0.1rem 0;
}

.eval-item-main {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.5rem;
  min-height: 0;
  padding: 0.3rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-text);
  font-weight: 400;
  text-align: left;
}

button.eval-item-main:hover:not(:disabled) {
  background: #eef4fd;
  border-color: transparent;
}

.eval-item-main.open {
  background: #e8f0fb;
  border-color: var(--color-accent);
}

.eval-item-main:focus-visible,
.eval-item-add:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.eval-item-invalid {
  color: var(--color-error);
  text-decoration: line-through;
  cursor: help;
}

.eval-item-name {
  overflow-wrap: anywhere;
}

.eval-kind {
  width: 0.8rem;
  text-align: center;
  color: var(--color-muted);
  font-weight: 700;
}

.eval-dot {
  flex: none;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 2px solid transparent;
}

.eval-dot-passed {
  background: var(--color-found);
}

.eval-dot-failed {
  background: var(--color-error);
}

.eval-dot-not_evaluable {
  background: transparent;
  border-color: var(--color-not-queryable);
}

.eval-item-add {
  flex: none;
  width: 1.6rem;
  min-height: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--color-muted);
  font-size: 1rem;
  font-weight: 400;
}

.eval-item-add:hover:not(:disabled) {
  background: var(--color-panel);
  border-color: var(--color-muted);
  color: var(--color-text);
}

.eval-item-add:disabled {
  visibility: hidden;
}

.eval-panels {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
  min-width: 0;
}

.eval-panel {
  min-width: 0;
}

.eval-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.4rem;
}

.eval-panel-title {
  margin: 0;
  font-size: 1.05rem;
}

/* Check table: Regel | Ist | Soll | Status */
.check-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.check-summary-passed {
  background: var(--color-found-bg);
  border-color: var(--color-found);
  color: var(--color-found);
}

.check-summary-failed {
  background: var(--color-error-bg);
  border-color: var(--color-error);
  color: var(--color-error);
}

.check-summary-not_evaluable {
  background: var(--color-not-queryable-bg);
  border-color: var(--color-not-queryable);
  color: var(--color-not-queryable);
}

.check-symbol {
  font-weight: 700;
}

.check-table {
  border-collapse: collapse;
  min-width: 30rem;
}

.check-table th,
.check-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
}

.check-table thead th {
  background: var(--color-not-queryable-bg);
  font-weight: 700;
}

.check-row-failed {
  background: var(--color-error-bg);
}

.check-row-passed .check-status {
  color: var(--color-found);
}

.check-row-failed .check-status {
  color: var(--color-error);
  font-weight: 700;
}

.check-row-not_evaluable {
  background: var(--color-not-queryable-bg);
}

.check-row-not_evaluable .check-status {
  color: var(--color-not-queryable);
}

.check-status {
  white-space: nowrap;
}

.check-label {
  font-weight: 600;
}

.check-system {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.check-group-label {
  font-style: italic;
}

.check-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.check-missing,
.check-reason {
  color: var(--color-muted);
  font-style: italic;
}

.check-reason {
  font-size: 0.85rem;
}

.check-compare {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--color-muted);
}
