/* ------------------------------------------------------------------ */
/* Grundlagen                                                           */
/* ------------------------------------------------------------------ */

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #dde3ec;
  --border-strong: #c3ccdb;
  --text: #17202e;
  --text-muted: #5a6679;
  --accent: #2f6feb;
  --accent-soft: #e8f0fe;
  /* Vordergrund auf farbigen Flächen. Im dunklen Schema sind Akzent und
     Gefahrfarbe so hell, dass weiße Schrift darauf zu wenig Kontrast hätte
     (2,9:1 bzw. 2,5:1); dort steht dunkle Schrift darauf. */
  --auf-akzent: #ffffff;
  --auf-gefahr: #ffffff;
  --danger: #c62f3f;
  --danger-soft: #fdecee;
  --ok: #17795e;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.22);
  --topbar-h: 60px;
  --statusbar-h: 30px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141c;
    --surface: #171c26;
    --surface-2: #1d2431;
    --border: #2a3342;
    --border-strong: #3a4557;
    --text: #e8ecf3;
    --text-muted: #98a3b5;
    --accent: #6096ff;
    --accent-soft: #1c2b45;
    --auf-akzent: #10141c;
    --auf-gefahr: #10141c;
    --danger: #ff7b86;
    --danger-soft: #3a1e23;
    --ok: #4ecfa5;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Kopfleiste                                                           */
/* ------------------------------------------------------------------ */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  color: var(--accent);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-name {
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  margin-left: -6px;
  font-size: 17px;
  font-weight: 600;
  width: min(38vw, 360px);
}

.form-name:hover {
  border-color: var(--border);
}

.form-name:focus {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  /* Nicht umbrechen – die Kopfzeile hat eine feste Höhe, auf die das
     Seitenlayout rechnet. Bei wenig Platz entfallen stattdessen die
     Beschriftungen (siehe unten). */
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.tool svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.tool:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
}

.tool:disabled {
  opacity: 0.4;
  cursor: default;
}

.tool[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--auf-akzent);
}

.tool-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  filter: brightness(1.08);
}

/* Ab hier reicht die Breite nicht mehr für alle Beschriftungen; die Knöpfe
   behalten ihren Tooltip. */
@media (max-width: 1560px) {
  .tool span {
    display: none;
  }
  .tool-primary span {
    display: inline;
  }
}

@media (max-width: 720px) {
  .tool-primary span {
    display: none;
  }
  .form-name {
    width: 40vw;
  }
}

/* ------------------------------------------------------------------ */
/* Layout                                                               */
/* ------------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 330px;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
}

.layout.is-preview {
  grid-template-columns: minmax(0, 1fr);
}

.layout.is-preview .palette,
.layout.is-preview .inspector {
  display: none;
}

.layout.is-regeln {
  grid-template-columns: minmax(0, 1fr) 330px;
}

.layout.is-regeln .palette {
  display: none;
}

.palette,
.inspector {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.palette {
  border-right: 1px solid var(--border);
}

.inspector {
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.panel-head {
  padding: 14px 14px 8px;
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-hint {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ */
/* Palette                                                              */
/* ------------------------------------------------------------------ */

.palette-search {
  position: relative;
  padding: 0 14px 10px;
}

.palette-search svg {
  position: absolute;
  left: 24px;
  top: 9px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.palette-search input {
  width: 100%;
  padding: 7px 9px 7px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 16px;
}

.palette-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 4px 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 9px;
  margin-bottom: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: grab;
}

.palette-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.palette-item:active {
  cursor: grabbing;
}

.palette-item .chip {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.palette-item .chip svg {
  width: 15px;
  height: 15px;
}

.palette-item-label {
  min-width: 0;
}

.palette-item-label strong {
  display: block;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-item-label small {
  color: var(--text-muted);
  font-size: 11px;
}

.palette-empty {
  padding: 20px 6px;
  color: var(--text-muted);
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Reiterleiste                                                         */
/* ------------------------------------------------------------------ */

.canvas-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.tabbar {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 8px 14px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  top: 1px;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  border-color: var(--border);
  box-shadow: 0 -2px 0 var(--accent) inset;
}

.tab.drop-before::before,
.tab.drop-after::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.tab.drop-before::before {
  left: -3px;
}

.tab.drop-after::after {
  right: -3px;
}

.tab.drop-into {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tab-count {
  font-size: 11px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.tab.is-active .tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-add {
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
}

.tab-add:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Arbeitsfläche                                                       */
/* ------------------------------------------------------------------ */

.canvas-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.canvas {
  max-width: 780px;
  margin: 0 auto;
  min-height: 100%;
}

.field-card {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 12px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.field-card:hover {
  border-color: var(--border-strong);
}

.field-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm);
}

.field-card.is-dragging {
  opacity: 0.4;
}

.field-card.drop-before::before,
.field-card.drop-after::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.field-card.drop-before::before {
  top: -6px;
}

.field-card.drop-after::after {
  bottom: -6px;
}

.field-grip {
  cursor: grab;
  color: var(--text-muted);
  padding: 2px 1px;
  flex: none;
}

.field-grip svg {
  width: 15px;
  height: 15px;
}

.field-body {
  flex: 1;
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.field-title {
  font-weight: 600;
}

.field-title.is-empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 500;
}

.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge-required {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.badge-type {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.field-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.field-control {
  margin-top: 8px;
  pointer-events: none;
}

.field-actions {
  display: flex;
  gap: 2px;
  flex: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.field-card:hover .field-actions,
.field-card.is-selected .field-actions,
.field-actions:focus-within {
  opacity: 1;
}

.icon-button {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.icon-button svg {
  width: 15px;
  height: 15px;
}

.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-button.is-danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

/* Nachbildung der Eingabeelemente in der Arbeitsfläche/Vorschau */
.mock {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.mock-textarea {
  min-height: 62px;
  align-items: flex-start;
}

.mock-lookup {
  justify-content: space-between;
}

.mock-yesno {
  border: none;
  background: none;
  padding: 0;
  gap: 16px;
}

.mock-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mock-radio i {
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  display: inline-block;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-2);
}

.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.dropzone-tail {
  min-height: 64px;
  padding: 16px;
  font-size: 13px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 34px 16px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--text);
}

.empty-state ol {
  display: inline-block;
  text-align: left;
  margin: 12px 0 0;
  padding-left: 18px;
}

/* ------------------------------------------------------------------ */
/* Vorschau                                                             */
/* ------------------------------------------------------------------ */

.preview-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.preview-row {
  margin-bottom: 15px;
}

.preview-row label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
}

.preview-row .req {
  color: var(--danger);
  margin-left: 3px;
}

.preview-row input,
.preview-row select,
.preview-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.preview-row textarea {
  min-height: 92px;
  resize: vertical;
}

.preview-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ------------------------------------------------------------------ */
/* Eigenschaften                                                        */
/* ------------------------------------------------------------------ */

.inspector-section {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.inspector-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: 15px;
}

.inspector-subtitle {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.field-row {
  margin-bottom: 12px;
}

.field-row > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.field-row input[type='text'],
.field-row input[type='search'],
.field-row select,
.field-row textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.field-row textarea {
  min-height: 76px;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.field-row .help {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.switch-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.switch-row label {
  font-size: 13px;
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.button {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.button:hover {
  background: var(--surface-2);
}

.button-danger {
  border-color: transparent;
  background: var(--danger);
  color: var(--auf-gefahr);
}

.button-danger:hover {
  background: var(--danger);
  filter: brightness(1.08);
}

.button-block {
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Statusleiste, Dialoge, Hinweise                                      */
/* ------------------------------------------------------------------ */

.statusbar {
  height: var(--statusbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.status-state.is-dirty {
  color: var(--danger);
}

.status-state.is-saved {
  color: var(--ok);
}

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(640px, 94vw);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.dialog::backdrop {
  background: rgba(10, 15, 25, 0.45);
}

.dialog-small {
  width: min(420px, 92vw);
  padding: 18px;
}

.dialog-small h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
  margin: 0;
  font-size: 16px;
}

.dialog-body {
  padding: 10px 16px 18px;
  max-height: 62vh;
  overflow-y: auto;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}

.library-item:last-child {
  border-bottom: none;
}

.library-item-main {
  flex: 1;
  min-width: 0;
}

.library-item strong {
  display: block;
}

.library-item small {
  color: var(--text-muted);
  font-size: 12px;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-md);
  max-width: 340px;
}

.toast.is-error {
  border-left-color: var(--danger);
}

.toast.is-ok {
  border-left-color: var(--ok);
}

/* ------------------------------------------------------------------ */
/* Schmale Fenster                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 1020px) {
  body {
    overflow: auto;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }
  .palette,
  .inspector {
    border: none;
    border-bottom: 1px solid var(--border);
    max-height: 340px;
  }
  .canvas-scroll {
    overflow: visible;
  }
}

/* Werteliste mit Code */

.code-liste {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.code-liste-kopf {
  display: flex;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.code-liste-zeile {
  display: flex;
  gap: 6px;
  align-items: center;
}

.code-liste-zeile input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* Regeln */

.tab-regeln {
  margin-left: auto;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  top: 0;
}

.tab-regeln svg {
  width: 15px;
  height: 15px;
}

.regel-kopf {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.regel-kopf-titel {
  margin: 0;
  font-size: 15px;
}

.regel-kopf-text {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  max-width: 52ch;
}

.regel-nummer {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.ausdruck-zeile {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.ausdruck-teile {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.ausdruck-operator {
  font-size: 12px;
  color: var(--text-muted);
  flex: none;
}

.ausdruck-zeile input,
.ausdruck-zeile select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.hinweis-liste {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--danger);
}

.hinweis-liste li {
  margin-bottom: 4px;
}

/* Ausdrücke in Regeln */

.ausdruck-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px;
  margin-bottom: 6px;
  background: var(--surface-2);
}

.ausdruck-reihe {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ausdruck-reihe + .ausdruck-reihe {
  margin-top: 6px;
}

.ausdruck-reihe input,
.ausdruck-reihe select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.verknuepfung-zeile {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.verknuepfung {
  padding: 3px 8px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.regel-hinweis {
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}

.regel-hinweis ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.hat-fehler {
  border-color: var(--danger) !important;
}

.help.ist-fehler {
  color: var(--danger);
}

.ausdruck-hinweis {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 5px;
}

/* Quellcode-Ansicht */

.dialog-gross {
  width: min(860px, 96vw);
}

.dialog-hinweis {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.quellcode {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  max-height: 52vh;
}

.dialog-fuss {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--auf-akzent);
}

.button-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

/* Feldsuche und Prüfung */

.canvas-suche {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.canvas-suche > svg {
  position: absolute;
  left: 29px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.canvas-suche input {
  flex: 1;
  padding: 6px 9px 6px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.suche-treffer {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.layout.is-regeln .canvas-suche,
.layout.is-preview .canvas-suche {
  display: none;
}

.treffer-reiter {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.befund {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
}

.befund:hover {
  background: var(--surface-2);
}

.befund:last-child {
  border-bottom: none;
}

.befund-marke {
  flex: none;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 9px;
  font-weight: 600;
}

.befund-fehler .befund-marke {
  background: var(--danger-soft);
  color: var(--danger);
}

.befund-hinweis .befund-marke {
  background: var(--accent-soft);
  color: var(--accent);
}

.pruefung-ok {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 6px;
  color: var(--ok);
}

.status-pruefung {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  padding: 0 6px;
  text-decoration: underline dotted;
}

.status-pruefung.hat-fehler {
  color: var(--danger);
}

.regel-grip {
  cursor: grab;
  color: var(--text-muted);
  padding: 2px 1px;
  flex: none;
}

.regel-grip svg {
  width: 15px;
  height: 15px;
}

/* Vorschau mit Regeln */

.vorschau-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.vorschau-kopf-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.preview-row.ist-inaktiv {
  opacity: 0.55;
}

.preview-hint.ist-regel {
  color: var(--accent);
}

.protokoll {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.protokoll h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.protokoll-zeile {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.protokoll-zeile:first-of-type {
  border-top: none;
}

.protokoll-marke {
  flex: none;
  min-width: 34px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.protokoll-marke.ist-wahr {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.protokoll-marke.ist-unwahr {
  background: var(--surface-2);
}

.protokoll-text {
  color: var(--text-muted);
}

.protokoll-hinweis {
  font-size: 12px;
  color: var(--danger);
  margin-top: 2px;
}

.protokoll-zeile.hat-problem .protokoll-marke {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

/* Anmeldung */

.anmeldung {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.anmeldung[hidden] {
  display: none;
}

.anmeldung-karte {
  width: min(360px, 100%);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.anmeldung-karte .brand-mark {
  width: 34px;
  height: 34px;
  color: var(--accent);
}

.anmeldung-karte h1 {
  margin: 10px 0 2px;
  font-size: 19px;
}

.anmeldung-text {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.anmeldung-karte label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.anmeldung-karte input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.anmeldung-fehler {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.anmeldung-fehler[hidden] {
  display: none;
}

.status-benutzer {
  margin-right: 10px;
}

.status-benutzer button {
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  padding: 0;
}

/* Überschrift einer Feldgruppe – gehört zu keinem einzelnen Eingabefeld. */
.field-row > .gruppen-titel {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}
