.apex-root {
  --cp-bg: var(--background-base, #0c0c0c);
  --cp-panel: var(--color-card, #141414);
  --cp-box: var(--color-secondary, #1c1c1c);
  --cp-box-hover: var(--color-accent, #242424);
  --cp-yellow: var(--midground-base, #f5c300);
  --cp-cyan: #00ddf5;
  --cp-red: var(--color-destructive, #ff2878);
  --cp-red-hi: #ff2878;
  --cp-green: var(--color-success, #00ddf5);
  --cp-border: rgba(245, 195, 0, .3);
  --cp-text: #ffffff;
  --cp-text-dim: #888888;
  --cp-on-accent: #000;
  --cp-notch: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  --apex-bg: var(--cp-bg);
  --apex-panel: var(--cp-panel);
  --apex-box: var(--cp-box);
  --apex-box-hover: var(--cp-box-hover);
  --apex-border: var(--cp-cyan);
  --apex-text: var(--cp-text);
  --apex-text-dim: var(--cp-text-dim);
  --apex-amber: var(--cp-yellow);
  --apex-amber-hi: var(--cp-yellow);
  --apex-on-amber: var(--cp-on-accent);
  --apex-ok: var(--cp-green);
  --apex-info: var(--cp-cyan);
  --apex-warn: var(--cp-yellow);
  --apex-err: var(--cp-red-hi);
  --apex-node-basis: 104px;
  --apex-node-basis-narrow: 132px;
  min-height: calc(100vh - 96px);
  color: var(--apex-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 0;
  background: var(--cp-bg);
  font-family: "Rajdhani", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.apex-root,
.apex-root * {
  box-sizing: border-box;
}

.apex-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.apex-eyebrow {
  margin: 0 0 4px;
  color: var(--cp-yellow);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.apex-header h1,
.apex-file-head h2 {
  margin: 0;
  color: var(--apex-text);
  line-height: 1.1;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.apex-header h1 {
  font-size: 34px;
}

.apex-loading,
.apex-level-label {
  color: var(--cp-yellow);
  font-size: 12px;
}

.apex-error,
.apex-warnings,
.apex-notice,
.apex-truncated {
  border: 1px solid var(--cp-cyan);
  background: var(--cp-panel);
  color: var(--cp-text);
  clip-path: var(--cp-notch);
  padding: 10px 16px 10px 12px;
  font-size: 13px;
}

.apex-error {
  border-color: var(--cp-red-hi);
  color: var(--cp-red-hi);
}

.apex-notice {
  border-color: var(--cp-green);
  color: var(--cp-green);
}

.apex-warnings,
.apex-truncated {
  color: var(--cp-yellow);
}

.apex-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.apex-pyramid {
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  border: 1px solid var(--cp-cyan);
  background: var(--cp-panel);
  padding: 14px;
}

.apex-level {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 7px 0;
  overflow: visible;
}

.apex-level + .apex-level {
  border-top: 1px solid rgba(2, 215, 242, .34);
}

.apex-level-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.apex-level-nodes {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.apex-node-wrap {
  position: relative;
  flex: 1 1 var(--apex-node-basis, 104px);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  overflow: visible;
  z-index: 1;
}

.apex-node-wrap:hover,
.apex-node-wrap:has(.apex-node:focus-visible) {
  z-index: 40;
}

.apex-node {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--cp-cyan);
  background: var(--cp-box);
  color: var(--apex-text);
  clip-path: var(--cp-notch);
  padding: 12px 16px 12px 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease, transform .16s ease;
}

.apex-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  width: max-content;
  max-width: min(280px, calc(100vw - 48px));
  padding: 9px 15px 10px 11px;
  border: 1px solid var(--cp-cyan);
  background: var(--cp-panel);
  color: var(--cp-text);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  box-shadow: 0 10px 24px rgba(0, 0, 0, .38), 0 0 16px rgba(2, 215, 242, .18);
  font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: opacity .08s ease, transform .08s ease, visibility 0s linear .08s;
  z-index: 1000;
}

.apex-tooltip-head,
.apex-tooltip-body {
  display: block;
}

.apex-tooltip-head {
  margin-bottom: 7px;
  border-bottom: 1px solid var(--cp-border);
  padding-bottom: 6px;
  color: var(--cp-cyan);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.apex-tooltip-body {
  color: var(--cp-text);
}

.apex-node-wrap:hover .apex-tooltip,
.apex-node:focus-visible + .apex-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 0s;
}

.apex-level-0 .apex-node {
  border-color: var(--cp-yellow);
}

.apex-node:hover,
.apex-node:focus-visible,
.apex-node-active {
  border-color: var(--cp-yellow);
  background: var(--cp-box-hover);
  box-shadow: 0 0 10px rgba(252, 238, 10, .12);
  outline: none;
}

.apex-node:hover,
.apex-node:focus-visible {
  transform: translateY(-1px);
}

.apex-node-label {
  min-width: 0;
  color: var(--apex-text);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .02em;
}

.apex-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 0 100%);
  padding: 0 9px 0 6px;
  color: var(--cp-on-accent);
  font-size: 11px;
  font-weight: 900;
}

.apex-badge-empty {
  background: var(--cp-panel);
  color: var(--cp-text-dim);
  border: 1px solid var(--cp-cyan);
}

.apex-badge-open {
  background: var(--cp-yellow);
  color: var(--cp-on-accent);
}

.apex-badge-submitted {
  background: var(--cp-cyan);
  color: var(--cp-on-accent);
}

.apex-badge-done {
  background: var(--cp-green);
  color: var(--cp-on-accent);
}

.apex-panel,
.apex-file-modal {
  border: 1px solid var(--cp-cyan);
  background: var(--cp-panel);
}

.apex-panel {
  position: sticky;
  top: 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding: 14px;
}

.apex-panel-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  border-bottom: 1px solid rgba(2, 215, 242, .5);
  padding-bottom: 10px;
}

.apex-panel-head h2 {
  margin: 0;
  color: var(--apex-text);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.apex-panel-head code {
  display: inline-block;
  max-width: 100%;
  background: var(--cp-yellow);
  color: var(--cp-on-accent);
  border: 1px solid var(--cp-yellow);
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 0 100%);
  padding: 3px 12px 3px 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.apex-detail {
  margin: 0;
  color: var(--apex-text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.apex-panel-empty {
  color: var(--apex-text-dim);
  font-size: 13px;
}

.apex-node-actions,
.apex-annotation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.apex-annotation-actions {
  margin-top: 8px;
  justify-content: flex-end;
}

.apex-annotations {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.apex-annotation {
  border: 1px solid var(--cp-cyan);
  background: var(--cp-box);
  clip-path: var(--cp-notch);
  padding: 10px 16px 10px 10px;
}

.apex-annotation-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--cp-yellow);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.apex-annotation-status {
  color: var(--cp-cyan);
}

.apex-annotation p,
.apex-answer p {
  margin: 6px 0 0;
  color: var(--apex-text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.apex-answer {
  margin-top: 8px;
  border-left: 2px solid var(--cp-green);
  padding-left: 8px;
}

.apex-answer strong {
  color: var(--cp-green);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.apex-form {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid rgba(2, 215, 242, .5);
  padding-top: 10px;
}

.apex-type-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.apex-type-switch button,
.apex-save,
.apex-footer button,
.apex-file-button,
.apex-file-head button,
.apex-node-actions button,
.apex-annotation-actions button {
  border: 1px solid var(--cp-yellow);
  background: var(--cp-yellow);
  color: var(--cp-on-accent);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
  min-height: 32px;
  min-width: 0;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: box-shadow .16s ease, transform .16s ease;
}

.apex-type-switch button *,
.apex-save *,
.apex-footer button *,
.apex-file-button *,
.apex-file-head button *,
.apex-node-actions button *,
.apex-annotation-actions button *,
.apex-badge-open *,
.apex-panel-head code * {
  color: var(--cp-on-accent);
}

.apex-type-switch button:hover,
.apex-type-switch button:focus-visible,
.apex-type-switch .apex-type-active,
.apex-save:hover,
.apex-save:focus-visible,
.apex-footer button:hover:not(:disabled),
.apex-footer button:focus-visible:not(:disabled),
.apex-file-button:hover,
.apex-file-button:focus-visible,
.apex-file-head button:hover,
.apex-file-head button:focus-visible,
.apex-node-actions button:hover:not(:disabled),
.apex-node-actions button:focus-visible:not(:disabled),
.apex-annotation-actions button:hover:not(:disabled),
.apex-annotation-actions button:focus-visible:not(:disabled) {
  box-shadow: 0 0 10px rgba(252, 238, 10, .14);
  outline: none;
  transform: translateY(-1px);
}

.apex-form textarea {
  width: 100%;
  min-width: 0;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--cp-cyan);
  background: var(--cp-bg);
  color: var(--apex-text);
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
}

.apex-form textarea:focus {
  border-color: var(--cp-yellow);
  box-shadow: 0 0 10px rgba(252, 238, 10, .12);
  outline: none;
}

.apex-save:disabled,
.apex-footer button:disabled,
.apex-node-actions button:disabled,
.apex-annotation-actions button:disabled {
  cursor: default;
  opacity: .48;
}

.apex-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid var(--cp-cyan);
  background: rgba(12, 12, 12, .94);
  padding: 10px 0;
}

.apex-footer button {
  min-height: 38px;
  min-width: 0;
  max-width: calc(100vw - 32px);
  font-size: 13px;
  white-space: nowrap;
}

.apex-modal-backdrop {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(12, 12, 12, .9);
}

.apex-file-modal {
  width: 100%;
  max-width: min(1180px, calc(100vw - 44px));
  min-width: 0;
  max-height: calc(100vh - 44px);
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  padding: 16px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, .58);
}

.apex-file-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid rgba(2, 215, 242, .5);
  padding-bottom: 10px;
}

.apex-file-head > div {
  min-width: 0;
  max-width: 100%;
}

.apex-file-head h2 {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  background: var(--cp-yellow);
  color: var(--cp-on-accent);
  border: 1px solid var(--cp-yellow);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%);
  padding: 5px 15px 5px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.apex-file-body {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.apex-file-body pre {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--cp-cyan);
  background: var(--cp-bg);
  color: var(--apex-text);
  padding: 14px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.apex-modal-annotations {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-top: 1px solid rgba(2, 215, 242, .5);
  padding-top: 10px;
}

.apex-modal-annotations h3 {
  margin: 0 0 8px;
  color: var(--apex-text);
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .apex-header,
  .apex-file-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .apex-layout {
    grid-template-columns: 1fr;
  }

  .apex-panel {
    position: static;
    max-height: none;
  }

  .apex-level {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .apex-level-0 .apex-level-nodes,
  .apex-level-1 .apex-level-nodes {
    padding: 0;
  }

  .apex-node-wrap {
    flex-basis: var(--apex-node-basis-narrow, 132px);
  }

  .apex-modal-backdrop {
    padding: 8px;
  }

  .apex-file-modal {
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
}

/* Sehr schmale Fenster: Knoten einspaltig stapeln, damit keine zweite
   Spalte ueber den Viewport-Rand laeuft (Vorfall 2026-06-13). */
@media (max-width: 520px) {
  .apex-level-nodes {
    flex-direction: column;
  }

  .apex-node-wrap {
    flex: 1 1 auto;
    width: 100%;
  }
}
