:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #171a20;
  --muted: #616a78;
  --line: #e2e6ee;
  --line-strong: #cdd4e0;
  --accent: #1f5fbf;
  --accent-dark: #174a97;
  --err: #c0392b;
  --err-soft: rgba(192, 57, 43, 0.09);
  --warn: #9a6700;
  --warn-soft: rgba(154, 103, 0, 0.10);
  --ok: #1d7a46;
  --code-size: 13px;
  --code-line: 20px;
  --pad: 12px;
  --gutter: 54px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

code, .mono, textarea {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Kopfzeile ------------------------------------------------------------------------------ */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.mark {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14px; font-weight: 650; white-space: nowrap; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

.file { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; flex: 0 1 auto; }

.narrow-only { display: none; }
.label-short { display: none; }
@media (max-width: 560px) { .label-long { display: none; } }

.filename {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions { display: flex; align-items: center; gap: 8px; }

button { font: inherit; cursor: pointer; }

button.primary {
  white-space: nowrap;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.primary:disabled { opacity: 0.55; cursor: default; }

button.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 13px;
}
button.ghost:hover { border-color: #a9b3c4; }

.chip {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #b8bfcc; }
.chip.ok .dot { background: var(--ok); }
.chip.bad .dot { background: var(--err); }
.chip.busy .dot { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

select {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 6px 8px;
  max-width: 210px;
}

/* Aufteilung ------------------------------------------------------------------------------ */
main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
}

.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.editorbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { background: rgba(29, 122, 70, 0.12); color: var(--ok); }
.pill.bad { background: var(--err-soft); color: var(--err); }
.pill.busy { background: var(--warn-soft); color: var(--warn); }
.pill.pending { opacity: 0.55; }

/* Editor surface ------------------------------------------------------------------------- */
.spacer { flex: 1; }

/* Menus: the actions that are not needed on every run stay behind one click. */
.menu { position: relative; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid transparent;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { border-color: var(--line-strong); color: var(--ink); }
.menu[open] > summary { border-color: var(--line-strong); background: #f7f9fc; color: var(--ink); }
.menu > .menu-items {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(23, 30, 45, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu > .menu-items button {
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12.5px;
  color: var(--ink);
}
.menu > .menu-items button:hover { background: #f2f5fa; }
.menu.add > summary { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-size: 12px; line-height: 1.3; }
.menu.add > .menu-items { left: 0; right: auto; }
.chipbtn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
}
.chipbtn:hover { border-color: var(--accent); color: var(--accent); }
.chipbtn:disabled { opacity: 0.45; cursor: default; }
button.ghost.small { padding: 5px 9px; font-size: 12px; white-space: nowrap; }

.codewrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--panel);
  overflow: hidden;
}

.gutter {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--gutter);
  overflow: hidden;
  padding-top: var(--pad);
  background: #fafbfd;
  border-right: 1px solid var(--line);
  text-align: right;
  user-select: none;
}
.gutter-inner { will-change: transform; }
.ln {
  height: var(--code-line);
  line-height: var(--code-line);
  padding-right: 10px;
  font: 11.5px/var(--code-line) ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #a4adbb;
}
.ln.err { color: var(--err); font-weight: 700; }
.ln.warn { color: var(--warn); font-weight: 700; }

.bands {
  position: absolute;
  top: 0; left: var(--gutter); right: 0; bottom: 0;
  overflow: hidden;
  pointer-events: none;
}
.bands-inner { position: absolute; inset: 0; will-change: transform; }
.band {
  position: absolute;
  left: 0; right: 0;
  height: var(--code-line);
  background: var(--err-soft);
  box-shadow: inset 3px 0 0 var(--err);
}

#code {
  position: absolute;
  top: 0; left: var(--gutter); right: 0; bottom: 0;
  width: auto;
  margin: 0;
  padding: var(--pad) 16px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-size: var(--code-size);
  line-height: var(--code-line);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}
#code::selection { background: rgba(31, 95, 191, 0.22); }

.statusbar {
  display: flex;
  gap: 16px;
  padding: 6px 14px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:hover { color: var(--accent-dark); }

#meta { margin-left: auto; }

/* Seitenleiste ---------------------------------------------------------------------------- */
aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }

.tabbtn {
  border: 0;
  background: transparent;
  padding: 8px 11px 9px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tabbtn.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

.badge {
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}
.badge.bad { background: var(--err-soft); color: var(--err); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.panel { flex: 1; overflow: auto; padding: 10px 12px 16px; }
.panel.hidden { display: none; }

.empty { color: var(--muted); font-size: 12.5px; padding: 8px 4px; }
.empty p { margin: 0 0 6px; }

.issue {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 3px solid var(--err);
  background: #fff;
  border-radius: 7px;
  padding: 9px 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--ink);
}
.issue:hover { border-color: var(--line-strong); background: #fbfcfe; }
.issue.warning { border-left-color: var(--warn); }
.issue .head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.issue .line {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f1f3f7;
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 6px;
}
.issue .src { margin-left: auto; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: #98a1b0; }
.issue .msg { display: block; white-space: pre-wrap; word-break: break-word; }

.legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 7px; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sw.err { background: var(--err); }
.sw.warn { background: var(--warn); }

/* Preview --------------------------------------------------------------------------------- */
.counts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-bottom: 12px; }
.count { background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; }
.count b { display: block; font-size: 16px; line-height: 1.2; }
.count span { font-size: 10.5px; color: var(--muted); }

.pv-sec { margin: 14px 0 0; }
.pv-sec > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #8d97a6;
  padding: 4px 0;
  border-radius: 5px;
}
.pv-sec > summary::-webkit-details-marker { display: none; }
.pv-sec > summary:hover { color: var(--ink); }
.pv-sec > summary::before {
  content: "▸";
  font-size: 9px;
  color: #b8bfcc;
  transform: rotate(0deg);
  transition: transform 0.12s ease;
}
.pv-sec[open] > summary::before { transform: rotate(90deg); }
.pv-sec .n { font-size: 10.5px; color: #a2aab8; letter-spacing: 0; text-transform: none; }
.pv-body { padding: 2px 0 6px 13px; }

.pv-case { margin: 8px 0 0; }
.pv-case > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  padding: 3px 0;
}
.pv-case > summary::-webkit-details-marker { display: none; }
.pv-case > summary b { font-size: 12.5px; }
.pv-case > summary .meta { font-size: 11px; color: var(--muted); }
.pv-case[open] > summary { margin-bottom: 5px; }

.pv-desc { margin: 6px 0 4px; font-size: 12px; color: #5a6272; line-height: 1.45; }
.pv-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.pv-list .desc { flex-basis: 100%; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.pv-list .rights { flex-basis: 100%; font-size: 11px; color: #6b748a; }
#preview .jumpable { cursor: pointer; }
#preview .jumpable:hover { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
#code.flash { animation: jump 0.9s ease; }
.gutter .ln.hit { background: rgba(31, 95, 191, 0.16); color: var(--accent); border-radius: 3px; font-weight: 700; }
@keyframes jump {
  0% { background: rgba(31, 95, 191, 0.12); }
  100% { background: transparent; }
}
.stage-desc { font-size: 10.5px; color: var(--muted); line-height: 1.3; margin: 2px 0 4px; }

.appline { display: flex; flex-direction: column; gap: 2px; }
.appline strong { font-size: 14.5px; }
.appline span { font-size: 12px; color: var(--muted); }


.pv-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 5px; }
.pv-list li { font-size: 12px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pv-list li b { font-weight: 600; }
.pv-list .muted, .pv-note { color: var(--muted); font-size: 11.5px; }
.pv-list .meta { color: var(--muted); font-size: 11.5px; margin-left: auto; text-align: right; }

.tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #586172;
  background: #f1f3f7;
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}
.tag.sys { background: #e9f0fb; color: #1f5fbf; }

.case-head { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.case-head b { font-size: 13px; }
.case-head span { font-size: 11px; color: var(--muted); }
.case-head .tag { margin-left: auto; }

.stage-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 7px;
}
.stage-col {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: #fff;
  min-width: 0;
}
.stage-title { display: flex; align-items: baseline; gap: 6px; margin-bottom: 5px; }
.stage-title b { font-size: 12.5px; }
.stage-title span { font-size: 10.5px; color: var(--muted); margin-left: auto; }

.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.steps li { font-size: 11.5px; display: flex; gap: 5px; align-items: baseline; flex-wrap: wrap; }
.steps .step-name { flex: 1 1 auto; min-width: 0; }
.steps .who { color: var(--muted); font-size: 10.5px; margin-left: auto; }

.badge {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #45536b;
  background: #eaeef6;
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}
.badge.plain { background: transparent; color: #9aa3b2; padding-left: 0; }

.pv-sub {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a2aab8;
  margin: 10px 0 5px;
}

.pv-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pv-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #8d97a6;
  font-weight: 600;
  padding: 0 6px 4px 0;
  border-bottom: 1px solid var(--line);
}
.pv-table td { padding: 4px 6px 4px 0; border-bottom: 1px dotted var(--line); vertical-align: top; }
.pv-table td.name { font-weight: 600; }
.pv-table .pdot { color: var(--accent); font-size: 8px; margin-left: 4px; vertical-align: 1px; }
.pv-table td.type { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 11px; white-space: nowrap; text-align: right; width: 88px; }
.pv-table th:last-child { text-align: right; }
.pv-table .desc { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-top: 1px; line-height: 1.35; }
.pv-table .muted { color: var(--muted); }

/* Report ---------------------------------------------------------------------------------- */
.report-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.report-head .actions { display: flex; gap: 6px; margin-left: auto; }
.report-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; line-height: 1.5; }
.report-meta b { color: var(--ink); }
.filing {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--panel);
}
.filing.hint { border-left-color: var(--accent); }
.filing.ok { border-left-color: var(--ok); color: var(--ink); }
.filing.ok a { color: var(--accent); }
.filing.failed { border-left-color: var(--err); background: var(--err-soft); color: var(--ink); }
.filing.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--ink); }
.filing code { font-size: 11.5px; }
.finding {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 7px;
  font-size: 12.5px;
}
.finding.loss { border-left-color: var(--err); }
.finding .top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.finding .top b { font-size: 12.5px; }
.finding .kind { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: #98a1b0; margin-left: auto; }
.finding .path { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: #8b95a4; word-break: break-all; display: block; margin-bottom: 4px; }
.finding .reason { display: block; }
.finding .action { display: block; margin-top: 3px; color: var(--muted); }
.finding .action::before { content: "Follow-up: "; font-weight: 600; }

/* Dialog ---------------------------------------------------------------------------------- */
dialog {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 20px 22px;
  width: min(560px, 92vw);
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.18);
}
dialog::backdrop { background: rgba(16, 24, 40, 0.35); }
dialog h2 { margin: 0 0 4px; font-size: 17px; }
dialog .sub { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
.grid label.wide { grid-column: 1 / -1; }
.grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: 100%;
  font-size: 12.5px;
  color: var(--ink);
}
.grid label.check input { width: 16px; height: 16px; margin: 0; padding: 0; }
.grid input {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
}
.grid input:focus { outline: 2px solid rgba(31, 95, 191, 0.25); border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Hinweisbox ------------------------------------------------------------------------------ */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 20px);
  max-width: min(680px, 90vw);
  background: #1b2029;
  color: #fff;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #8f2b21; }

@media (max-width: 1020px) {
  header { gap: 12px; }
  .filename { display: none; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 40vh); }
  aside { border-left: 0; border-top: 1px solid var(--line); }
  .hint { display: none; }
  .brand-text span { display: none; }
}

@media (max-width: 720px) {
  .brand-text span { display: none; }
  #btnJson { display: none; }
}

/* Phone: the brand keeps its name, the session chip shrinks to its dot, and the toolbar wraps so
   "+ Add" can never be pushed off screen. */
@media (max-width: 560px) {
  header { height: auto; min-height: 52px; padding: 6px 10px; gap: 8px; flex-wrap: wrap; }
  .brand { flex: 1 1 auto; }
  .mark { width: 36px; height: 36px; border-radius: 9px; font-size: 13px; }
  .brand-text strong { font-size: 14.5px; }
  .brand-text span { display: none; }
  .file { display: none; }
  .actions { gap: 6px; }
  .chip#btnSession { padding: 6px 8px; }
  .chip#btnSession #sessionText { display: none; }
  #btnBlueprint { padding: 8px 11px; font-size: 12.5px; }
  #btnBlueprint .label-long { display: none; }
  #btnBlueprint .label-short { display: inline; }

  .editorbar { flex-wrap: wrap; padding: 6px 10px; }
  .editorbar #addMenu { order: -1; }
  #btnImport { padding: 5px 8px; font-size: 12px; }
}

/* Raw blocks: marked at the margin instead of highlighted in the text. */
.gutter .ln.raw { color: #b08968; }
.chip.raw { background: #f6efe6; color: #8a6d4d; border-color: #e6d7c3; }
.chip.raw:empty { display: none; }

.pill { cursor: pointer; }

.legend[hidden] { display: none; }
