:root {
  --wall: #E6EAEC;
  --wall-grain: #DCE1E4;
  --surface: #FFFFFF;
  --ink: #1B2228;
  --muted: #56626C;
  --line: #C6CED3;
  --accent: #1F4E79;
  --accent-ink: #FFFFFF;

  /* Moderationskarten bleiben Papier, auch im Dunkelmodus */
  --card-ink: #1B2228;
  --c-gelb: #F7DC5C;
  --c-blau: #A9D3EE;
  --c-gruen: #AEDBA2;
  --c-rosa: #F4B4C4;
  --c-orange: #F7BE7A;
  --c-weiss: #FBFBF7;
  --dot: #D2353F;

  --hand: "Kalam", "Segoe Print", "Comic Sans MS", cursive;
  --text: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall: #1D252B; --wall-grain: #222B32; --surface: #27323B;
    --ink: #E4E9EC; --muted: #9CA8B1; --line: #3B4853;
    --accent: #8EC1E8; --accent-ink: #10202D;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall: #1D252B; --wall-grain: #222B32; --surface: #27323B;
  --ink: #E4E9EC; --muted: #9CA8B1; --line: #3B4853;
  --accent: #8EC1E8; --accent-ink: #10202D;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 72px); }
body {
  margin: 0;
  font: 400 1.0625rem/1.55 var(--text);
  color: var(--ink);
  background-color: var(--wall);
  background-image: radial-gradient(var(--wall-grain) 1px, transparent 1px);
  background-size: 6px 6px;
  min-height: 100vh;
  padding-bottom: 72px;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface);
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }

/* Kopfleiste */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: 1240px; margin: 0 auto; padding: .75rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
}
.brand { font: 700 1.35rem/1 var(--hand); color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
  padding: .4rem .75rem; border-radius: 4px; color: var(--muted);
  text-decoration: none; font-weight: 700; font-size: .95rem;
}
.nav a:hover { color: var(--ink); background: var(--wall); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 2.5rem 1.25rem 3rem; outline: none; }
.section-head { max-width: 62ch; margin-bottom: 2rem; }
.section-head h1 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); margin-bottom: .5rem; }
.section-head p { color: var(--muted); }

/* Moderationskarte */
.card {
  position: relative; display: block; width: 100%; text-align: left;
  background: var(--c-weiss); color: var(--card-ink);
  border: 0; border-radius: 2px; padding: 1.1rem 1rem .9rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 6px 14px -8px rgba(0,0,0,.35);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease;
}
.card::before { /* Pinnnadel */
  content: ""; position: absolute; top: 7px; left: 50%; width: 9px; height: 9px;
  margin-left: -4.5px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0 15%, #5B6670 40%, #2E363C);
}
button.card { cursor: pointer; }
button.card:hover { transform: rotate(0deg) translateY(-2px); box-shadow: 0 1px 0 rgba(0,0,0,.08), 0 12px 20px -10px rgba(0,0,0,.45); }
.card__title { font: 700 1.3rem/1.2 var(--hand); }
.card__text { font-size: .95rem; margin-top: .35rem; }
.card--gelb { background: var(--c-gelb); }
.card--blau { background: var(--c-blau); }
.card--gruen { background: var(--c-gruen); }
.card--rosa { background: var(--c-rosa); }
.card--orange { background: var(--c-orange); }

/* Start */
.hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.hero__question { padding: 2.25rem 2rem 2rem; --tilt: -1deg; }
.hero__question .label { font-size: .9rem; font-weight: 700; opacity: .7; margin-bottom: .5rem; display: block; }
.hero__question p { font: 700 clamp(1.6rem, 3.2vw, 2.4rem)/1.2 var(--hand); }
.hero__meta h1 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: .75rem; }
.hero__meta p { color: var(--muted); max-width: 40ch; }
.hero__meta dl { margin: 1.25rem 0 0; display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; }
.hero__meta dt { color: var(--muted); }
.hero__meta dd { margin: 0; font-weight: 700; }

.agenda { margin-top: 3.5rem; }
.agenda h2 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.agenda__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; counter-reset: ag; }
.agenda__list li { counter-increment: ag; }
.agenda__list .card { height: 100%; padding-top: 1.6rem; }
.agenda__num { font: 700 2rem/1 var(--hand); opacity: .45; }
.agenda__time { font-size: .85rem; font-weight: 700; margin-top: .6rem; display: block; }

/* Tool-Landkarte */
.tools-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 2rem; align-items: start; }
.tool-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.5rem 1.25rem; }
.tool-group h2 { font-size: 1rem; color: var(--muted); margin-bottom: .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--line); }
.tool-group__cards { display: grid; gap: 1rem; }
.tool-groups.is-filtering .card { opacity: .3; }
.tool-groups.is-filtering .card.is-match { opacity: 1; transform: rotate(0deg) scale(1.04); box-shadow: 0 0 0 3px var(--accent), 0 12px 20px -10px rgba(0,0,0,.45); }

.helper { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1.25rem; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 80px); }
.helper h2 { font-size: 1.15rem; margin-bottom: .25rem; }
.helper > p { color: var(--muted); font-size: .95rem; margin-bottom: 1rem; }
.helper__list { display: grid; gap: .5rem; }
.chip-btn {
  text-align: left; background: var(--wall); border: 1px solid var(--line); border-radius: 4px;
  padding: .55rem .7rem; cursor: pointer; font-size: .95rem;
}
.chip-btn:hover { border-color: var(--accent); }
.chip-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.helper__answer { margin-top: 1rem; font-weight: 700; min-height: 1.5em; }

/* Zuständigkeiten */
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: 1.25rem; font-size: .95rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.raci { border-collapse: collapse; width: 100%; min-width: 760px; }
.raci th, .raci td { border-bottom: 1px solid var(--line); padding: .55rem .6rem; text-align: center; vertical-align: middle; }
.raci thead th { font-size: .9rem; color: var(--muted); font-weight: 700; }
.raci th[scope="row"] { text-align: left; font-weight: 700; min-width: 220px; }
.raci tbody tr:last-child > * { border-bottom: 0; }
.raci-cell {
  width: 2.6rem; height: 2.6rem; border-radius: 4px; border: 1px dashed var(--line);
  background: transparent; cursor: pointer; font: 700 1.2rem/1 var(--hand); color: var(--card-ink);
}
.raci-cell:hover { border-color: var(--accent); }
.raci-cell[data-v="R"] { background: var(--c-blau); border-style: solid; border-color: transparent; }
.raci-cell[data-v="A"] { background: var(--c-gelb); border-style: solid; border-color: transparent; }
.raci-cell[data-v="C"] { background: var(--c-gruen); border-style: solid; border-color: transparent; }
.raci-cell[data-v="I"] { background: var(--c-weiss); border-style: solid; border-color: var(--line); }
.swatch { width: 1.6rem; height: 1.6rem; border-radius: 3px; display: inline-grid; place-items: center; font: 700 1rem/1 var(--hand); color: var(--card-ink); }
.status { font-size: .85rem; font-weight: 700; white-space: nowrap; padding: .2rem .5rem; border-radius: 999px; }
.status--ok { background: var(--c-gruen); color: var(--card-ink); }
.status--open { background: var(--c-orange); color: var(--card-ink); }

/* Prozesse */
.process-tabs { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.process-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1.5rem; }
.process-toolbar label { font-weight: 700; display: flex; gap: .5rem; align-items: center; }
select, input[type="text"], textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: .45rem .6rem;
}
.flow { display: flex; flex-wrap: wrap; align-items: stretch; row-gap: 1.5rem; padding: 1rem .25rem 1.5rem; }
.flow > * { flex: 0 0 200px; }
@media (max-width: 600px) { .flow { flex-direction: column; } .flow > * { flex-basis: auto; } .flow__arrow { transform: rotate(90deg); height: 34px; } }
.flow__arrow { flex: 0 0 34px; display: grid; place-items: center; color: var(--muted); }
.flow__arrow svg { width: 26px; height: 26px; }
.flow .card { height: 100%; display: flex; flex-direction: column; gap: .5rem; }
.step__num { font: 700 1.5rem/1 var(--hand); opacity: .45; }
.step__meta { margin-top: auto; display: flex; flex-wrap: wrap; gap: .3rem; }
.tag { font-size: .78rem; font-weight: 700; padding: .1rem .45rem; border-radius: 3px; background: rgba(27,34,40,.1); }
.flow.is-filtering .card.step { opacity: .35; }
.flow.is-filtering .card.step.is-match { opacity: 1; box-shadow: 0 0 0 3px var(--accent), 0 12px 20px -10px rgba(0,0,0,.45); }
.card .kind { font-size: .82rem; font-weight: 700; opacity: .7; }

/* Vereinbarungen */
.agreements { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.5rem 1.25rem; }
.agreement { display: flex; flex-direction: column; gap: 1rem; min-height: 170px; }
.agreement .card__title { font-size: 1.25rem; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; margin-top: auto; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #F27D84, var(--dot) 60%); box-shadow: 0 1px 1px rgba(0,0,0,.3); }
.agreement__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.agreement__actions button {
  background: rgba(27,34,40,.08); border: 0; border-radius: 3px; padding: .3rem .6rem; cursor: pointer; font-size: .88rem; font-weight: 700; color: var(--card-ink);
}
.agreement__actions button:hover { background: rgba(27,34,40,.16); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: .45rem .8rem; font-weight: 700; font-size: .92rem;
}
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--ghost { background: transparent; }
.btn--small { padding: .25rem .55rem; font-size: .85rem; }
.edit-only { display: none !important; }
body.is-editing .edit-only { display: inline-flex !important; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* Moderationsleiste */
.modbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem calc(.6rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line);
}
.modbar__actions { display: flex; gap: .5rem; }
.modbar__actions[hidden] { display: none; }
.switch { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; cursor: pointer; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

/* Detailansicht */
.drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer::before { content: ""; position: absolute; inset: 0; background: rgba(10,15,20,.4); opacity: 0; transition: opacity .2s; }
.drawer.is-open { pointer-events: auto; }
.drawer.is-open::before { opacity: 1; }
.drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%);
  background: var(--surface); padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 1.5rem 1.5rem;
  overflow-y: auto; transform: translateX(100%); transition: transform .22s ease;
}
.drawer.is-open .drawer__panel { transform: none; }
.drawer__close { position: absolute; top: calc(.75rem + env(safe-area-inset-top, 0px)); right: .75rem; background: none; border: 0; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); }
.detail .card { margin-bottom: 1.5rem; }
.detail dl { margin: 0; display: grid; gap: 1rem; }
.detail dt { font-size: .88rem; color: var(--muted); font-weight: 700; }
.detail dd { margin: .2rem 0 0; }
.detail .empty { color: var(--muted); font-style: italic; }

/* Formular */
.form-dialog { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: min(520px, calc(100% - 2rem)); padding: 1.5rem; }
.form-dialog::backdrop { background: rgba(10,15,20,.45); }
.form-dialog h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.field { display: grid; gap: .3rem; margin-bottom: .9rem; }
.field span { font-weight: 700; font-size: .92rem; }
.field textarea { min-height: 4.5rem; resize: vertical; }
.form-dialog__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }

@media (max-width: 900px) {
  .hero, .tools-layout { grid-template-columns: 1fr; }
  .helper { position: static; }
}
@media (max-width: 600px) {
  .drawer__panel { top: auto; width: 100%; max-height: 85%; border-radius: 12px 12px 0 0; transform: translateY(100%); padding-top: 1.5rem; }
  .drawer__close { top: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; }
  .card { transform: none; }
}

/* Anmeldung */
.login-page { padding-bottom: 0; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login__card { width: min(400px, 100%); padding: 2.25rem 1.75rem 1.75rem; --tilt: -0.8deg; display: grid; gap: .6rem; }
.login__card .card__title { font-size: 1.7rem; }
.login__label { font-weight: 700; margin-top: .75rem; }
.login__pin {
  font: 700 2rem/1 var(--text); letter-spacing: .5em; text-align: center;
  padding: .6rem .5rem .6rem 1rem; border: 2px solid var(--card-ink); border-radius: 4px;
  background: #FFFDF2; color: var(--card-ink); width: 100%;
}
.login__msg { font-weight: 700; background: rgba(27,34,40,.1); padding: .5rem .65rem; border-radius: 3px; }
.login__btn { justify-content: center; padding: .7rem 1rem; font-size: 1rem; margin-top: .4rem; }
.modbar__logout { margin-left: auto; color: var(--muted); font-weight: 700; font-size: .92rem; }
