/*
 * .limsport-config-builder is applied two different ways depending on
 * context:
 *   - standalone index.html: on <body>, so `body.limsport-config-builder`
 *     rules below apply

 *   - inline in docs page: on a wrapping <div>, so those same
 *     `body.limsport-config-builder` rules do NOT match, and the widget
 *     simply inherits the host page's background/font/text color instead
 *     of imposing its own
 */
.limsport-config-builder {
  --brand-green: #1da74a;
  --brand-blue: #116eb7;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --border: #dfe3e6;
  --border-strong: #c7c7c7;
  --text: #262626;
  --text-muted: #767676;
  --chevron-color: #555555;
  --action-accent: var(--brand-blue);
  --accent-contrast: #ffffff;
  --danger: #a3402f;
  --danger-bg: #fbeeec;
  --warning: #8a5a00;
  --warning-bg: #fdf5e3;
  --code-bg: #ffffff;
  --code-text: #000000;
  --radius: calc(0.2 * var(--unit));
  --mono: SFMono-Regular, Consolas, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  --unit: 1rem;
  --header-clearance: 0px;
  --page-max-width: min(1800px, 96vw);
  --chevron-svg: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0L8 0L4 5Z' fill='%23767676'/%3E%3C/svg%3E");
}


/* `div` limits this to the inline docs embed: the standalone page (body.limsport-config-builder)
   can also get [data-md-color-scheme] from an iframe host, but shouldn't shrink or add header space */
[data-md-color-scheme] div.limsport-config-builder {
  --unit: 0.8rem;
  --header-clearance: 2.4rem; /* don't let the box get hidden by the header */
}

/*
 * Fallback for a context with no Material theme wrapper around it (the
 * standalone index.html page)
 */
@media (prefers-color-scheme: dark) {
  .limsport-config-builder {
    --surface: #1e2129;
    --surface-2: #272a35;
    --border: #363840;
    --border-strong: #5d5f66;
    --text: #bfc1c6;
    --text-muted: #8c8e95;
    --chevron-color: #a5a7ad;
    --action-accent: var(--brand-green); /* no blue equivalent in dark mode -- see the base block's comment */
    --accent-contrast: #ffffff;
    --danger: #e18579;
    --danger-bg: #3a2320;
    --warning: #d9a440;
    --warning-bg: #3a3020;
    --code-bg: #272a35;
    --code-text: #b6b9c3;
    --chevron-svg: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0L8 0L4 5Z' fill='%238c8e95'/%3E%3C/svg%3E");
  }
}

/*
 * When embedded in the docs site, follow the SITE's own manual light/dark
 * toggle (Material/Zensical stamps [data-md-color-scheme="slate"|"light"]
 * on <html> once a reader picks a mode) instead of the OS preference above
 */
[data-md-color-scheme="slate"] .limsport-config-builder {
  --surface: #1e2129;
  --surface-2: #272a35;
  --border: #363840;
  --border-strong: #5d5f66;
  --text: #bfc1c6;
  --text-muted: #8c8e95;
  --chevron-color: #a5a7ad;
  --action-accent: var(--brand-green);
  --accent-contrast: #ffffff;
  --danger: #e18579;
  --danger-bg: #3a2320;
  --warning: #d9a440;
  --warning-bg: #3a3020;
  --code-bg: #272a35;
  --code-text: #b6b9c3;
  --chevron-svg: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0L8 0L4 5Z' fill='%238c8e95'/%3E%3C/svg%3E");
}

/* Re-assert the light values so an OS-level dark preference can't leak
   through when the reader has explicitly picked light mode on the site. */
[data-md-color-scheme="light"] .limsport-config-builder {
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --border: #dfe3e6;
  --border-strong: #c7c7c7;
  --text: #262626;
  --text-muted: #767676;
  --chevron-color: #555555;
  --action-accent: var(--brand-blue);
  --accent-contrast: #ffffff;
  --danger: #a3402f;
  --danger-bg: #fbeeec;
  --warning: #8a5a00;
  --warning-bg: #fdf5e3;
  --code-bg: #ffffff;
  --code-text: #000000;
  --chevron-svg: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0L8 0L4 5Z' fill='%23767676'/%3E%3C/svg%3E");
}

.limsport-config-builder,
.limsport-config-builder * {
  box-sizing: border-box;
}

.limsport-config-builder .hidden {
  display: none !important;
}

/* Only matches when .limsport-config-builder is on <body> (standalone page) */
body.limsport-config-builder {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
}

.limsport-config-builder code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
  font-size: 0.9em;
}

.limsport-config-builder .page-header {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: calc(2 * var(--unit)) calc(1.5 * var(--unit)) calc(1 * var(--unit));
}

.limsport-config-builder .page-header h1 {
  margin: 0 0 calc(0.5 * var(--unit));
  font-size: calc(1.6 * var(--unit));
}

.limsport-config-builder .page-header p {
  color: var(--text-muted);
  max-width: 70ch;
}

.limsport-config-builder .page-header a {
  color: var(--brand-green);
}

.limsport-config-builder .toolbar {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 0 calc(1.5 * var(--unit)) calc(1 * var(--unit));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: calc(0.75 * var(--unit));
}

.limsport-config-builder button {
  font-family: inherit;
  font-size: calc(0.9 * var(--unit));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: calc(0.45 * var(--unit)) calc(0.9 * var(--unit));
  cursor: pointer;
}

.limsport-config-builder button:hover {
  border-color: var(--brand-green);
}

.limsport-config-builder button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.limsport-config-builder #download-btn,
.limsport-config-builder #copy-btn {
  background: var(--action-accent);
  color: var(--accent-contrast);
  border-color: var(--action-accent);
}

/* The generic button:hover rule above only darkens the border, which these
   two already have -- give them their own visible hover feedback instead
   (a darker shade of the same accent, not a different color, so it still
   reads as "the same button, now pressed/hovered"). */
.limsport-config-builder #download-btn:hover:not(:disabled),
.limsport-config-builder #copy-btn:hover:not(:disabled) {
  background: var(--brand-green);
  border-color: var(--brand-green);
}

/* Dark mode gets a darkened hover instead of the pure brand green above --
   same two-tier override as the rest of the palette (media-query fallback
   for the standalone page, attribute-selector for the docs site, which
   wins on specificity regardless of source order). */
@media (prefers-color-scheme: dark) {
  .limsport-config-builder #download-btn:hover:not(:disabled),
  .limsport-config-builder #copy-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--brand-green) 85%, black);
    border-color: color-mix(in srgb, var(--brand-green) 85%, black);
  }
}

[data-md-color-scheme="slate"] .limsport-config-builder #download-btn:hover:not(:disabled),
[data-md-color-scheme="slate"] .limsport-config-builder #copy-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--brand-green) 85%, black);
  border-color: color-mix(in srgb, var(--brand-green) 85%, black);
}

/* Re-assert the light hover so the OS-dark media query above can't leak
   through when the reader has explicitly picked light mode on the site
   (mirrors the light palette re-assert near the top of this file). */
[data-md-color-scheme="light"] .limsport-config-builder #download-btn:hover:not(:disabled),
[data-md-color-scheme="light"] .limsport-config-builder #copy-btn:hover:not(:disabled) {
  background: var(--brand-green);
  border-color: var(--brand-green);
}

.limsport-config-builder #download-btn:disabled,
.limsport-config-builder #copy-btn:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

.limsport-config-builder .toolbar-secondary {
  color: var(--text-muted);
}

.limsport-config-builder .toolbar-open {
  display: flex;
  align-items: center;
  gap: calc(0.5 * var(--unit));
}

.limsport-config-builder .confirm-dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(1 * var(--unit)) calc(1.25 * var(--unit));
  max-width: min(28rem, calc(100vw - 2rem));
  font-size: calc(0.95 * var(--unit));
}

.limsport-config-builder .confirm-dialog::backdrop {
  background: rgb(0 0 0 / 0.4);
}

.limsport-config-builder .confirm-dialog p {
  margin: 0 0 calc(1 * var(--unit));
  text-align: center;
}

.limsport-config-builder .dialog-actions {
  display: flex;
  justify-content: center;
  gap: calc(0.6 * var(--unit));
}

.limsport-config-builder .dialog-confirm {
  background: var(--action-accent);
  color: var(--accent-contrast);
  border-color: var(--action-accent);
}

/* pointer-events: none keeps drag events landing on the page underneath,
   so app.js's dragenter/dragleave depth count stays balanced */
.limsport-config-builder .drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 3px dashed var(--action-accent);
  color: var(--text);
  font-size: calc(1.4 * var(--unit));
  pointer-events: none;
}

.limsport-config-builder .layout {
  max-width: var(--page-max-width);
  margin: 0 auto;
  padding: 0 calc(1.5 * var(--unit)) calc(3 * var(--unit));
  display: grid;
  /* minmax(0, 1fr), not plain 1fr -- a plain fr track still grows to fit an
     unbreakable-content descendant's min-content width (e.g. a long
     file_parsing command), which is what "blows out" the layout wider than
     the viewport. minmax(0, ...) caps each track at its fair half share and
     forces overflow to happen *inside* that track instead. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: calc(1.5 * var(--unit));
  align-items: start;
}

@media (max-width: 860px) {
  .limsport-config-builder .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.limsport-config-builder .form-pane {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.limsport-config-builder .column-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(1 * var(--unit)) calc(1.25 * var(--unit)) calc(1.25 * var(--unit));
  display: flex;
  flex-direction: column;
  gap: calc(0.75 * var(--unit));
  min-width: 0;
}

/* Grouped-list treatment: each card after the first sits exactly 1px
   higher, landing its top border directly on top of the previous card's
   bottom border so only ONE line ever renders between them (like table
   border-collapse), instead of two 1px lines close enough together to read
   as one thick, dark one. The touching edges are squared off since a
   rounded corner would poke out oddly at a seam that's now a single flat
   line; only the outermost corners of the whole stack stay rounded. */
.limsport-config-builder .column-card + .column-card {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.limsport-config-builder .column-card:not(:last-child) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.limsport-config-builder .column-card.collapsed {
  gap: 0;
}

.limsport-config-builder .column-body {
  display: flex;
  flex-direction: column;
  gap: calc(0.75 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(0.75 * var(--unit));
  color: var(--text-muted);
  font-size: calc(0.85 * var(--unit));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.limsport-config-builder .column-header-title {
  display: flex;
  align-items: baseline;
  gap: calc(0.5 * var(--unit));
  min-width: 0;
  color: var(--text-muted);
  font-size: calc(0.85 * var(--unit));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.limsport-config-builder .column-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: calc(0.9 * var(--unit));
}

.limsport-config-builder .column-header-actions {
  display: flex;
  align-items: center;
  gap: calc(0.25 * var(--unit));
  flex: 0 0 auto;
}

.limsport-config-builder .btn-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  border-color: transparent;
  background: transparent;
  padding: calc(0.5 * var(--unit));
}

.limsport-config-builder .btn-collapse .chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--chevron-color);
  transition: transform 0.15s ease;
}

.limsport-config-builder .section-header .btn-collapse .chevron {
  border-left-width: 7px;
  border-right-width: 7px;
  border-top: 9px solid var(--text);
}

/* titles toggle collapse on double-click (see app.js); don't select text */
.limsport-config-builder .column-header-title,
.limsport-config-builder .output-header-title,
.limsport-config-builder .section-header h3 {
  user-select: none;
}

.limsport-config-builder .column-card.collapsed > .column-header .btn-collapse .chevron,
.limsport-config-builder .set-qc-rule-card.collapsed > .column-header .btn-collapse .chevron,
.limsport-config-builder .file-parsing-output.collapsed .btn-collapse .chevron,
.limsport-config-builder .form-section.collapsed > .section-header .btn-collapse .chevron {
  transform: rotate(-90deg);
}

.limsport-config-builder .drag-handle {
  cursor: grab;
  color: var(--text);
  font-size: calc(1.1 * var(--unit));
  line-height: 1;
  user-select: none;
  align-self: center;
}

.limsport-config-builder .dragging {
  opacity: 0.5;
}

.limsport-config-builder .output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(0.75 * var(--unit));
  color: var(--text-muted);
  font-size: calc(0.85 * var(--unit));
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.limsport-config-builder .output-header-title {
  display: flex;
  align-items: baseline;
  gap: calc(0.5 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .output-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  font-size: calc(0.85 * var(--unit));
}

.limsport-config-builder .output-header-actions {
  display: flex;
  align-items: center;
  gap: calc(0.25 * var(--unit));
  flex: 0 0 auto;
}

.limsport-config-builder .field {
  display: flex;
  flex-direction: column;
  gap: calc(0.25 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .field-label {
  font-size: calc(0.85 * var(--unit));
  color: var(--text-muted);
}

.limsport-config-builder input[type="text"],
.limsport-config-builder select,
.limsport-config-builder textarea {
  font-family: inherit;
  font-size: calc(0.95 * var(--unit));
  padding: calc(0.45 * var(--unit)) calc(0.6 * var(--unit));
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.limsport-config-builder select {
  /* Replace the native OS arrow (which can't be recolored or repositioned)
     with the same triangle used for the collapse toggle, pulled in from
     the edge instead of sitting flush against the border. */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: var(--chevron-svg);
  background-repeat: no-repeat;
  background-position: right calc(0.65 * var(--unit)) center;
  background-size: 8px 5px;
  padding-right: calc(1.75 * var(--unit));
}

.limsport-config-builder textarea {
  font-family: var(--mono);
  font-size: calc(0.85 * var(--unit));
  resize: vertical;
  /* Commands are often one long, unbroken line (a real awk/python
     one-liner). Let the textarea scroll that line horizontally within its
     own fixed width rather than either overflowing the page or forcing
     word-wraps in the middle of the command. */
  white-space: pre;
  overflow-x: auto;
}

.limsport-config-builder .checkbox-field {
  display: flex;
  align-items: center;
  gap: calc(0.5 * var(--unit));
  font-size: calc(0.9 * var(--unit));
  color: var(--text-muted);
}

.limsport-config-builder .section {
  border-top: 1px solid var(--border);
  padding-top: calc(0.75 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .section h4 {
  margin: 0 0 calc(0.5 * var(--unit));
  font-size: calc(0.85 * var(--unit));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.limsport-config-builder .section.hidden {
  display: none;
}

.limsport-config-builder .qc-editor {
  display: flex;
  flex-direction: column;
  gap: calc(0.6 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .qc-body:empty {
  display: none;
}

.limsport-config-builder .conditions {
  display: flex;
  flex-direction: column;
  gap: calc(0.4 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .condition-row {
  display: flex;
  gap: calc(0.4 * var(--unit));
  align-items: center;
}

.limsport-config-builder .cond-operator {
  flex: 0 0 calc(5 * var(--unit));
}

.limsport-config-builder .cond-value {
  flex: 1 1 auto;
}

.limsport-config-builder .cond-tolerance {
  flex: 0 0 calc(7 * var(--unit));
}

.limsport-config-builder .cond-tolerance.hidden {
  display: none;
}

.limsport-config-builder .cond-force-string,
.limsport-config-builder .cond-case-insensitive {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: calc(0.2 * var(--unit));
  white-space: nowrap;
  font-size: 0.9em;
  color: var(--text-muted);
}

.limsport-config-builder .conditional-qc {
  display: flex;
  flex-direction: column;
  gap: calc(0.6 * var(--unit));
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: calc(0.75 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .rules {
  display: flex;
  flex-direction: column;
  /* No gap -- see the .rule-block + .rule-block overlap rule below. */
  gap: 0;
  min-width: 0;
}

.limsport-config-builder .rule-block {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(0.6 * var(--unit));
  display: flex;
  flex-direction: column;
  gap: calc(0.5 * var(--unit));
  background: var(--surface);
  min-width: 0;
}

/* Same grouped-list overlap treatment as .column-card. :last-of-type (not
   :last-child) because the "+ Add rule" button is appended as a trailing
   sibling inside .rules alongside the .rule-block divs -- :last-of-type
   still correctly means "the last .rule-block", ignoring that button. */
.limsport-config-builder .rule-block + .rule-block {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.limsport-config-builder .rule-block:not(:last-of-type) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.limsport-config-builder .rule-header {
  display: flex;
  gap: calc(0.5 * var(--unit));
  align-items: center;
}

.limsport-config-builder .rule-key {
  flex: 1;
}

.limsport-config-builder .default-body {
  display: flex;
  flex-direction: column;
  gap: calc(0.4 * var(--unit));
}

.limsport-config-builder .default-body.hidden {
  display: none;
}

.limsport-config-builder .file-parsing {
  display: flex;
  flex-direction: column;
  /* No gap -- see the .file-parsing-output + .file-parsing-output overlap
     rule below. */
  gap: 0;
  min-width: 0;
}

.limsport-config-builder .file-parsing-output {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(0.75 * var(--unit));
  display: flex;
  flex-direction: column;
  gap: calc(0.5 * var(--unit));
  background: var(--surface-2);
  min-width: 0;
}

/* Same grouped-list overlap treatment as .column-card. :last-of-type (not
   :last-child) because the "+ Add another output..." button is appended
   as a trailing sibling inside .file-parsing alongside the
   .file-parsing-output divs. */
.limsport-config-builder .file-parsing-output + .file-parsing-output {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.limsport-config-builder .file-parsing-output:not(:last-of-type) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.limsport-config-builder .file-parsing-output.collapsed {
  gap: 0;
}

.limsport-config-builder .output-body {
  display: flex;
  flex-direction: column;
  gap: calc(0.5 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .hint {
  font-size: calc(0.8 * var(--unit));
  color: var(--text-muted);
  margin: 0;
}

/* specific enough to beat the docs theme's own ul/li margins */
.limsport-config-builder .set-qc-rule-card ul.skip-from-rules-list {
  font-size: calc(0.85 * var(--unit));
  margin: 0;
  padding: 0;
  list-style-position: inside;
}

.limsport-config-builder .set-qc-rule-card ul.skip-from-rules-list > li {
  margin: 0;
  padding: 0;
}

.limsport-config-builder .btn-add {
  align-self: flex-start;
  border-style: dashed;
  color: var(--action-accent);
  background: transparent;
  /* Hover intentionally stays green -- the generic button:hover rule
     (border-color: var(--brand-green)) already applies here and is left alone
     on purpose, giving these buttons a blue resting state but a green
     hover state. */
}

/* .rules and .file-parsing are gap:0 (see the box-overlap rules above), so
   their trailing "+ Add ..." button would otherwise sit flush against the
   last box with no breathing room. .conditions never has this problem --
   its rows aren't bordered boxes needing the overlap treatment, so it kept
   its normal gap throughout, "+ Add condition" included. Match that same
   spacing here explicitly instead. */
.limsport-config-builder .rules > .btn-add,
.limsport-config-builder .file-parsing > .btn-add {
  margin-top: calc(0.4 * var(--unit));
}

.limsport-config-builder .btn-add-column {
  font-size: calc(1 * var(--unit));
  padding: calc(0.6 * var(--unit)) calc(1 * var(--unit));
  /* .form-pane is gap:0 (its #columns child needs zero space before the
     column-cards' own overlap rules can do their job) -- reintroduce the
     breathing room here instead, same as .rules/.file-parsing above. */
  margin-top: calc(0.4 * var(--unit));
}

/* .form-pane is gap:0 (see above), so each section after the first needs its
   own margin-top to separate it from the one above. */
.limsport-config-builder .form-section,
.limsport-config-builder .section-body {
  display: flex;
  flex-direction: column;
  gap: calc(0.6 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .form-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(0.75 * var(--unit)) calc(1 * var(--unit)) calc(1 * var(--unit));
}

.limsport-config-builder .form-section.collapsed {
  padding-bottom: calc(0.75 * var(--unit));
}

.limsport-config-builder .form-section + .form-section {
  margin-top: calc(1 * var(--unit));
}

.limsport-config-builder .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.limsport-config-builder .section-header h3 {
  margin: 0;
  font-size: calc(1 * var(--unit));
}

/* the case matcher stacks like .set-qc-match; keep the remove button level
   with its label instead of centered on the stack */
.limsport-config-builder .case-header {
  align-items: flex-start;
}

.limsport-config-builder .set-qc-match {
  display: flex;
  flex-direction: column;
  gap: calc(0.4 * var(--unit));
}

/* Same grouped-list overlap treatment as .column-card -- see the comment
   there for why this is -1px + squared corners instead of a gap. */
.limsport-config-builder .set-qc-rule-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(1 * var(--unit)) calc(1.25 * var(--unit)) calc(1.25 * var(--unit));
  display: flex;
  flex-direction: column;
  gap: calc(0.75 * var(--unit));
  min-width: 0;
}

.limsport-config-builder .set-qc-rule-card + .set-qc-rule-card {
  margin-top: -1px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.limsport-config-builder .set-qc-rule-card:not(:last-child) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.limsport-config-builder .set-qc-rule-card.collapsed {
  gap: 0;
}

.limsport-config-builder .btn-remove {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  font-size: calc(0.8 * var(--unit));
  padding: calc(0.2 * var(--unit)) calc(0.5 * var(--unit));
}

.limsport-config-builder .btn-icon {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  padding: calc(0.1 * var(--unit)) calc(0.4 * var(--unit));
  line-height: 1;
}

.limsport-config-builder .preview-pane {
  position: sticky;
  /* --header-clearance (0 standalone, 2.4rem embedded -- see where it's
     defined) clears the docs site's own fixed header, which sits sticky
     at the very top of the viewport too; without it this box would
     scroll partly behind that bar instead of stopping below it. The
     "+ Add ..." button's own small gap is layered on top of that as
     breathing room. max-height's subtraction mirrors both, twice the
     small-gap term, so that same buffer is echoed at the bottom of the
     viewport too. */
  top: calc(var(--header-clearance) + calc(0.4 * var(--unit)));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(1 * var(--unit)) calc(1.25 * var(--unit)) calc(1.25 * var(--unit));
  display: flex;
  flex-direction: column;
  gap: calc(0.75 * var(--unit));
  max-height: calc(100vh - var(--header-clearance) - calc(0.8 * var(--unit)));
  min-width: 0;
}

.limsport-config-builder .preview-pane h2 {
  margin: 0;
  font-size: calc(1 * var(--unit));
}

.limsport-config-builder #preview {
  font-family: var(--mono);
  font-size: calc(0.82 * var(--unit));
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(0.9 * var(--unit));
  overflow: auto;
  margin: 0;
  flex: 1 1 auto;
  min-height: 200px;
  min-width: 0;
  max-width: 100%;
  white-space: pre;
}

.limsport-config-builder .notice {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(0.6 * var(--unit)) calc(0.75 * var(--unit));
  font-size: calc(0.85 * var(--unit));
  margin: 0;
}

.limsport-config-builder .notice.hidden,
.limsport-config-builder .errors.hidden {
  display: none;
}

.limsport-config-builder .errors {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: calc(0.6 * var(--unit)) calc(0.75 * var(--unit));
  font-size: calc(0.85 * var(--unit));
  /* Always show every error in full -- never scroll internally. If space
     runs short, the yaml preview below (which can scroll) shrinks first. */
  flex-shrink: 0;
}

.limsport-config-builder .errors-heading {
  margin: 0 0 calc(0.4 * var(--unit));
  font-weight: 600;
  color: var(--danger);
}

.limsport-config-builder .errors-list {
  margin: 0;
  padding-left: calc(1.1 * var(--unit));
}

.limsport-config-builder .warnings {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: calc(0.6 * var(--unit)) calc(0.75 * var(--unit));
  font-size: calc(0.85 * var(--unit));
  flex-shrink: 0;
}

.limsport-config-builder .warnings.hidden {
  display: none;
}

.limsport-config-builder .warnings-heading {
  margin: 0 0 calc(0.4 * var(--unit));
  font-weight: 600;
  color: var(--warning);
}

.limsport-config-builder .preview-actions {
  display: flex;
  align-items: center;
  gap: calc(0.6 * var(--unit));
}

.limsport-config-builder .copy-status {
  color: var(--action-accent);
  font-size: calc(0.85 * var(--unit));
}
