:root {
  color-scheme: light;
  --page: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #eef4fa;
  --ink: #172033;
  --muted: #607087;
  --line: #d7e0ea;
  --primary: #176b68;
  --primary-strong: #0e5553;
  --accent: #c9552d;
  --danger: #b4232f;
  --danger-soft: #fff0f1;
  --success: #147247;
  --focus: #e5792f;
  --shadow: 0 16px 45px rgb(21 42 73 / 10%);
  --radius: 18px;
  --radius-small: 10px;
  --content: 1180px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 8rem;
}

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgb(23 107 104 / 12%), transparent 26rem),
    var(--page);
  line-height: 1.5;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

input,
select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  padding: 0.62rem 0.75rem;
  background: var(--surface);
}

input[type="range"] {
  min-height: 2.2rem;
  padding-inline: 0;
  accent-color: var(--primary);
}

input[type="radio"] {
  width: 1.1rem;
  min-height: 1.1rem;
  accent-color: var(--primary);
}

input[type="file"] {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.16;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.75rem, 3vw, 2.65rem);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

h3 {
  margin-bottom: 0.5rem;
  font-size: 1.08rem;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-small);
  color: #fff;
  background: var(--primary-strong);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  padding: 0.65rem max(1rem, calc((100% - var(--content)) / 2));
  border-bottom: 1px solid rgb(215 224 234 / 88%);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: 0.8rem 0.8rem 0.8rem 0.25rem;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), #29928c);
  box-shadow: 0 6px 16px rgb(23 107 104 / 25%);
  font-size: 0.9rem;
  letter-spacing: -0.04em;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.account form {
  margin: 0;
}

.account-name {
  max-width: 13rem;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  border-radius: 99px;
  padding: 0.15rem 0.55rem;
  color: var(--primary-strong);
  background: #dff3ef;
  font-size: 0.76rem;
  font-weight: 800;
}

.status-badge--inactive {
  color: var(--danger);
  background: var(--danger-soft);
}

.section-nav {
  position: sticky;
  z-index: 15;
  top: 4.25rem;
  display: flex;
  gap: 0.25rem;
  max-width: var(--content);
  margin: 0 auto;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
  background: rgb(243 246 250 / 94%);
  backdrop-filter: blur(10px);
}

.section-nav a {
  flex: 0 0 auto;
  border-radius: 99px;
  padding: 0.42rem 0.72rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.section-nav a:hover {
  color: var(--primary-strong);
  background: var(--surface);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  width: min(calc(100% - 2rem), var(--content));
  margin: 1rem auto 3rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.65rem);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel--hero,
#terms,
#transfer,
.panel--wide {
  grid-column: 1 / -1;
}

.panel--hero {
  overflow: hidden;
  background:
    linear-gradient(135deg, rgb(255 255 255 / 97%), rgb(239 248 246 / 94%)),
    var(--surface);
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(10rem, 1.4fr) minmax(10rem, 1fr) 5.2rem 5.2rem;
  gap: 0.65rem;
  width: min(100%, 42rem);
}

.field {
  display: grid;
  align-content: start;
  gap: 0.35rem;
}

.field label,
.mode-choice legend {
  font-size: 0.84rem;
  font-weight: 800;
}

.field--compact input,
.field--compact select {
  min-height: 2.5rem;
  padding-block: 0.45rem;
}

.field--weight-filter input {
  min-width: 0;
}

.word-cloud {
  display: flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: clamp(0.55rem, 1.8vw, 1.35rem);
  min-height: clamp(16rem, 37vw, 25rem);
  border: 1px dashed #bbd2d0;
  border-radius: calc(var(--radius) - 5px);
  padding: clamp(1rem, 4vw, 3rem);
  background:
    radial-gradient(circle at 50% 50%, rgb(23 107 104 / 8%), transparent 52%),
    var(--surface-soft);
  flex-wrap: wrap;
}

.word-cloud[aria-busy="true"]::after {
  content: "Wolke wird geladen …";
  color: var(--muted);
}

.cloud-term {
  max-width: 100%;
  border: 0;
  border-radius: 0.65rem;
  padding: 0.22em 0.32em;
  color: var(--cloud-color, var(--primary-strong));
  background: transparent;
  font-size: var(--cloud-size, 1.25rem);
  font-weight: var(--cloud-weight, 700);
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
  transition: color 120ms ease, background 120ms ease, transform 120ms ease;
}

.cloud-term:nth-child(3n + 2) {
  --cloud-color: #9c3d25;
}

.cloud-term:nth-child(3n + 3) {
  --cloud-color: #345b91;
}

.cloud-term:hover {
  color: #fff;
  background: var(--primary-strong);
  transform: translateY(-2px);
}

.cloud-term--level-1 { font-size: 1rem; font-weight: 600; }
.cloud-term--level-2 { font-size: 1.18rem; font-weight: 625; }
.cloud-term--level-3 { font-size: 1.36rem; font-weight: 650; }
.cloud-term--level-4 { font-size: 1.58rem; font-weight: 675; }
.cloud-term--level-5 { font-size: 1.8rem; font-weight: 700; }
.cloud-term--level-6 { font-size: 2.04rem; font-weight: 725; }
.cloud-term--level-7 { font-size: 2.3rem; font-weight: 750; }
.cloud-term--level-8 { font-size: 2.62rem; font-weight: 775; }
.cloud-term--level-9 { font-size: 2.96rem; font-weight: 800; }
.cloud-term--level-10 { font-size: 3.45rem; font-weight: 850; }

.term-form,
.user-form {
  display: grid;
  grid-template-columns: minmax(12rem, 2fr) minmax(12rem, 1fr) auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.3rem;
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface-soft);
}

.user-form {
  grid-template-columns: minmax(10rem, 1fr) minmax(12rem, 1fr) minmax(8rem, 0.6fr) auto;
}

.form-actions,
.export-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  padding: 0.55rem 0.9rem;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button--primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 5px 13px rgb(23 107 104 / 20%);
}

.button--primary:hover:not(:disabled) {
  background: var(--primary-strong);
}

.button--secondary {
  border-color: var(--line);
  color: var(--primary-strong);
  background: var(--surface);
}

.button--secondary:hover:not(:disabled),
.button--quiet:hover:not(:disabled) {
  border-color: #9eb4c3;
  background: var(--surface-soft);
}

.button--danger {
  border-color: #e9b9be;
  color: var(--danger);
  background: var(--danger-soft);
}

.button--quiet {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.button--small {
  min-height: 2.15rem;
  padding: 0.38rem 0.62rem;
  font-size: 0.8rem;
}

.button--wide {
  width: 100%;
}

.icon-button {
  width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  font-size: 1.5rem;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td:last-child {
  width: 1%;
  white-space: nowrap;
}

.inline-editor {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) 5rem auto;
  gap: 0.5rem;
  align-items: center;
}

.inline-editor input {
  min-height: 2.25rem;
  padding: 0.35rem 0.5rem;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 4rem);
}

.stack {
  display: grid;
  gap: 1rem;
}

.drop-zone {
  border: 2px dashed #9fbebc;
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface-soft);
  transition: border-color 120ms ease, background 120ms ease;
}

.drop-zone.is-dragging {
  border-color: var(--primary);
  background: #ddf2ef;
}

.drop-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.preview {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}

.preview-table {
  max-height: 19rem;
  margin-block: 1rem;
  overflow-y: auto;
}

.mode-choice {
  display: flex;
  gap: 1rem 1.5rem;
  margin: 0 0 1rem;
  border: 0;
  padding: 0;
  flex-wrap: wrap;
}

.mode-choice legend {
  width: 100%;
  margin-bottom: 0.35rem;
}

.mode-choice label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.item-list,
.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-list li,
.timeline li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--line);
}

.item-list li:last-child,
.timeline li:last-child {
  border-bottom: 0;
}

.item-primary {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.item-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.empty-state {
  margin: 1rem 0 0;
  border-radius: 12px;
  padding: 1rem;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.notice {
  border: 1px solid #b9d8d0;
  border-radius: var(--radius-small);
  padding: 0.75rem 0.9rem;
  color: var(--primary-strong);
  background: #eef9f5;
}

.notice--error {
  border-color: #ecc3c7;
  color: var(--danger);
  background: var(--danger-soft);
}

.toast {
  position: fixed;
  z-index: 80;
  top: 5rem;
  right: max(1rem, calc((100% - var(--content)) / 2));
  width: min(calc(100% - 2rem), 28rem);
  border: 1px solid #b9d8d0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--primary-strong);
  background: #effbf7;
  box-shadow: var(--shadow);
  font-weight: 700;
}

.toast.is-error {
  border-color: #ecc3c7;
  color: var(--danger);
  background: var(--danger-soft);
}

dialog {
  width: min(calc(100% - 2rem), 32rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(10 25 45 / 30%);
}

dialog::backdrop {
  background: rgb(15 27 44 / 64%);
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-heading h2 {
  margin: 0;
}

.footer {
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.noscript {
  position: fixed;
  z-index: 90;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  border-radius: 10px;
  padding: 1rem;
  color: #fff;
  background: var(--danger);
  text-align: center;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 15% 15%, rgb(47 146 140 / 25%), transparent 30rem),
    radial-gradient(circle at 85% 85%, rgb(201 85 45 / 16%), transparent 28rem),
    #102840;
}

.login-shell {
  width: min(100%, 28rem);
}

.login-card {
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 24px;
  padding: clamp(1.5rem, 6vw, 2.5rem);
  background: var(--surface);
  box-shadow: 0 28px 90px rgb(0 0 0 / 28%);
}

.brand--login {
  margin-bottom: 1.6rem;
}

.brand--login .brand-mark {
  width: 3rem;
  height: 3rem;
  font-size: 1rem;
}

.login-intro {
  margin-bottom: 1.5rem;
  color: var(--muted);
}

.privacy-note {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (max-width: 900px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    grid-column: 1;
  }

  .panel-heading {
    display: grid;
  }

  .toolbar {
    width: 100%;
  }

  .term-form,
  .user-form {
    grid-template-columns: 1fr 1fr;
  }

  .form-actions,
  .term-form .form-actions,
  .user-form .button {
    align-self: end;
  }
}

@media (max-width: 650px) {
  html {
    scroll-padding-top: 7rem;
  }

  .topbar {
    min-height: 3.8rem;
    padding-inline: 0.75rem;
  }

  .brand > span:last-child,
  .role-badge,
  .account-name {
    display: none;
  }

  .section-nav {
    top: 3.8rem;
    padding-inline: 0.75rem;
  }

  .page-grid {
    width: min(calc(100% - 1rem), var(--content));
    margin-top: 0.5rem;
  }

  .panel {
    border-radius: 14px;
    padding: 1rem;
  }

  .toolbar,
  .term-form,
  .user-form,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar .field:first-child,
  .toolbar .field:nth-child(2) {
    grid-column: 1 / -1;
  }

  .word-cloud {
    min-height: 15rem;
    padding: 1rem 0.55rem;
  }

  .table-wrap {
    border-inline: 0;
    border-radius: 0;
  }

  th,
  td {
    padding-inline: 0.55rem;
  }

  .inline-editor {
    grid-template-columns: minmax(7rem, 1fr) 4.25rem;
  }

  .inline-editor .form-actions {
    grid-column: 1 / -1;
  }

  .mode-choice {
    display: grid;
  }

  .toast {
    top: auto;
    right: 0.5rem;
    bottom: 0.5rem;
    width: calc(100% - 1rem);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #101923;
    --surface: #182531;
    --surface-soft: #202f3c;
    --ink: #edf4f7;
    --muted: #adbdc9;
    --line: #344755;
    --primary: #56b7ae;
    --primary-strong: #79d0c8;
    --danger: #ff9aa3;
    --danger-soft: #43272d;
    --focus: #ff9b55;
    --shadow: 0 16px 45px rgb(0 0 0 / 22%);
  }

  body {
    background: radial-gradient(circle at 8% -10%, rgb(86 183 174 / 13%), transparent 26rem), var(--page);
  }

  .topbar {
    border-color: rgb(52 71 85 / 88%);
    background: rgb(24 37 49 / 92%);
  }

  .section-nav {
    background: rgb(16 25 35 / 94%);
  }

  .panel--hero {
    background: linear-gradient(135deg, rgb(24 37 49 / 97%), rgb(24 54 54 / 90%));
  }

  .role-badge,
  .status-badge {
    color: #a7eee7;
    background: #214941;
  }

  .cloud-term:nth-child(3n + 2) {
    --cloud-color: #ffad8c;
  }

  .cloud-term:nth-child(3n + 3) {
    --cloud-color: #a9c8ff;
  }

  .drop-zone.is-dragging {
    background: #244843;
  }

  .button--primary {
    color: #092725;
  }

  .login-page {
    background: radial-gradient(circle at 15% 15%, rgb(47 146 140 / 22%), transparent 30rem), #091725;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: currentColor;
  }

  .button,
  input,
  select,
  .panel {
    border-width: 2px;
  }
}
