*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at top left, #edf4ff 0%, #f3f6fb 40%, #eef2ff 100%);
  color: #1f2937;
}

/* Native <button> elements ignore the body font by default, which made
   buttons render at inconsistent sizes depending on whether they were a
   <button> or an <a class="button">. Force every button onto the page
   font/size baseline; specific classes (e.g. .menu-button) still override
   this further down and remain intentionally distinct. */
button {
  font-family: inherit;
  font-size: 1rem;
}

.menu-bar,
.app-chrome {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: block;
  width: 100%;
  margin: 0;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #dbe4f0;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(12px);
}

.menu-bar-inner,
.app-chrome-inner {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  max-width: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-auto-flow: column;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.menu-zone {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.menu-zone--left {
  justify-self: start;
  justify-content: flex-start;
}

.menu-zone--center {
  justify-self: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.menu-zone--right {
  justify-self: end;
  justify-content: flex-end;
  flex-shrink: 0;
}

.brand-block {
  display: grid;
  gap: 0.15rem;
  color: #0f172a;
  text-decoration: none;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.page-shell {
  max-width: 1200px;
  margin: 1.25rem auto 2rem;
  padding: 2rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

h1, h2, h3, p, pre {
  margin-top: 0;
}

/* Headings are flush (margin-top: 0) only when they open their container.
   Once anything precedes them - a list, a form, another paragraph - they
   need breathing room, or they visually merge into that prior content.
   This is a recurring class of bug (e.g. "Öffentlicher Link" hugging the
   share form above it), so it's handled once here for every h2/h3 in the
   app instead of a one-off margin-top on each new heading as it's added. */
h2:not(:first-child),
h3:not(:first-child) {
  margin-top: 1.5rem;
}

ul {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-subtitle {
  margin-top: 0.35rem;
  color: #64748b;
}

.page-subtitle:empty {
  display: none;
}

.page-shell--centered {
  max-width: 560px;
}

.page-shell--centered .page-header {
  text-align: center;
}

.page-shell--centered .auth-panel {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.page-shell--centered .auth-panel h2 {
  text-align: center;
}

.page-shell--centered .auth-form {
  max-width: none;
}

.app-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
  margin: 0;
}

.menu-button,
.app-nav-link {
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #1f2937;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.menu-button:hover,
.app-nav-link:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.menu-button.active,
.app-nav-link.active {
  background: #2d6cdf;
  border-color: #2d6cdf;
  color: #ffffff;
}

.logout-form {
  margin: 0;
  padding: 0;
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
}

.logout-button {
  background: #e5e7eb;
}

.panel {
  margin-top: 1.5rem;
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
}

.auth-panel,
.panel {
  backdrop-filter: blur(6px);
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sub-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #ffffff;
}

.sub-panel:first-of-type {
  margin-top: 0;
}

.sub-panel > h3 {
  margin-top: 0;
}

.auth-form {
  display: grid;
  gap: 1rem;
  max-width: 360px;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.auth-form input,
.inline-form input,
.inline-form select {
  padding: 0.7rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
}

.import-panel form {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.stack-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

/* Button color = action intent: create = blue, update = light blue,
   delete = red, everything else (navigation, cancel, toggle, ...) = gray. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: #2d6cdf;
  color: white;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.button.secondary {
  background: #e5e7eb;
  color: #1f2937;
}

.button.update {
  background: #dbeafe;
  color: #1d4ed8;
}

.button.danger {
  background: #b91c1c;
  color: #ffffff;
}

.table-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.table-title-link {
  color: #0f172a;
  font-weight: 700;
  text-decoration: none;
}

.table-title-link:hover,
.table-title-link:focus-visible {
  color: #1d4ed8;
  text-decoration: underline;
}

.docs-cta-panel {
  display: grid;
  gap: 0.6rem;
  margin-top: 0;
}

.diagram-grid,
.docs-grid,
.settings-grid {
  display: grid;
  gap: 1.5rem;
}

.diagram-grid,
.docs-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.diagram-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1rem;
}

.danger-zone {
  display: grid;
  align-content: start;
  gap: 0.8rem;
}

.notice {
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.notice.success-notice {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.muted {
  color: #64748b;
}

.small-text {
  font-size: 0.875rem;
}

.is-selected-row td {
  background: #f8fbff;
}

.toast-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.45);
}

.toast-backdrop[hidden] {
  display: none;
}

.toast-panel {
  display: grid;
  gap: 1rem;
  width: min(420px, 100%);
  padding: 1.5rem;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.25);
}

.toast-panel h3 {
  margin: 0;
}

.toast-panel label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.toast-panel input {
  padding: 0.7rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
}

.guide-steps {
  display: grid;
  gap: 1rem;
}

.guide-step {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #dbe4f0;
}

a.guide-step {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

a.guide-step:hover {
  border-color: #2d6cdf;
}

.guide-step.is-active {
  border-color: #2d6cdf;
  box-shadow: inset 0 0 0 1px #2d6cdf;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #1f2937;
  font-weight: 600;
  font-size: 0.85rem;
}

.chip--action {
  background: #dbeafe;
  color: #1d4ed8;
}

.chip--placeholder {
  background: #fef3c7;
  color: #92400e;
}

.chip--ignored {
  background: #f1f5f9;
  color: #64748b;
  text-decoration: line-through;
}

.chip--done {
  background: #dcfce7;
  color: #166534;
}

.chip-form {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.chip-form--grouped {
  padding: 0.3rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.form-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  margin-bottom: 1rem;
}

.form-card > h3,
.form-card > h4 {
  margin: 0;
}

.category-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.category-row:last-child {
  border-bottom: none;
}

.category-row-label {
  font-weight: 700;
  min-width: 140px;
}

.category-row-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
}

/* Small filled pill buttons for the actions inside a chip (Node anlegen,
   Platzhalter anlegen, Ignorieren, Rückgängig) - same color language as
   .button/.button.update/.button.danger, just compact enough to sit inside
   a chip's rounded pill instead of looking like a plain underlined link. */
.chip-action {
  border: 0;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  background: #2d6cdf;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.chip-action:hover {
  filter: brightness(0.93);
}

.chip-action--update {
  background: #dbeafe;
  color: #1d4ed8;
}

.chip-action--danger {
  background: #b91c1c;
  color: #ffffff;
}

.step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.hint-list {
  display: grid;
  gap: 0.75rem;
  padding-left: 1.15rem;
}

.panel hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 1.5rem 0;
}

.settings-list {
  margin: 0;
  display: grid;
  gap: 1rem;
}

.settings-list div {
  display: grid;
  gap: 0.2rem;
}

.settings-list dt {
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
}

.settings-list dd {
  margin: 0;
}

.category-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid #e2e8f0;
}

.category-list li:last-child {
  border-bottom: none;
}

.code-block {
  margin-bottom: 0;
  padding: 1rem;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
}

.diagram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.diagram-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#sankey-chart {
  width: 100%;
  min-height: 420px;
  border-radius: 8px;
  background: white;
  border: 1px solid #e5e7eb;
}

.sankey-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
}

.diagram-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #f8fafc;
}

.diagram-metadata div {
  display: grid;
  gap: 0.1rem;
}

.diagram-metadata dt {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
}

.diagram-metadata dd {
  margin: 0;
  font-weight: 600;
}

.two-column-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 720px) {
  .two-column-row {
    grid-template-columns: 1fr;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  padding: 0.8rem;
  border: 1px solid #e5e7eb;
  text-align: left;
}

th {
  background: #eef4ff;
}

@media (max-width: 700px) {
body {
    padding-bottom: 1rem;
  }

  .menu-bar-inner,
  .app-chrome-inner {
    grid-template-columns: auto 1fr auto;
    grid-auto-flow: column;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
  }

  .panel-actions,
  .diagram-header,
  .import-panel form,
  .table-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .diagram-meta-grid,
  .diagram-grid,
  .docs-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .app-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: thin;
  }

  .menu-zone {
    flex-direction: row;
    flex-wrap: nowrap;
  }

  .menu-zone--center {
    overflow-x: auto;
    max-width: 100%;
  }

  .menu-zone--right {
    flex-shrink: 0;
  }

  .page-shell {
    margin: 1rem;
    padding: 1.25rem;
  }
}
