:root {
  --moss: #4a5d3a;
  --moss-dark: #36452a;
  --moss-soft: #e4e9da;
  --wood: #94643c;
  --wood-soft: #f3e7d6;
  --basalt: #34383b;
  --basalt-soft: #676d71;
  --paper: #f6f1e7;
  --card: #fffcf6;
  --line: #e1d7c5;
  --danger: #a13d2d;
  --danger-soft: #f8e3dd;
  --ok-soft: #e4ecd9;
  --radius: 14px;
  --touch: 48px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--basalt);
  font: 17px/1.55 var(--sans);
}
a { color: var(--moss); text-underline-offset: 2px; }
a:hover { color: var(--moss-dark); }
h1, h2, h3 { font-family: var(--serif); color: var(--basalt); line-height: 1.25; }
h1 { font-size: 1.75rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.3rem; margin: 0 0 .75rem; }
h3 { font-size: 1.08rem; margin: 1.1rem 0 .4rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--wood-soft); padding: .05em .3em; border-radius: 4px; }
.muted { color: var(--basalt-soft); }
.small { font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* --- Layout ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem 1rem; background: var(--moss); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.brand:hover { color: #fff; }
.topbar .logout button.link { color: #eef2e6; font-size: .88rem; min-height: 40px; }
.page { max-width: 780px; margin: 0 auto; padding: 1rem 1rem 6.5rem; }

.mainnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgb(52 56 59 / .06);
}
.mainnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; text-decoration: none; color: var(--basalt-soft); font-size: .8rem; font-weight: 500;
}
.mainnav a span { font-size: 1.25rem; line-height: 1; }
.mainnav a.active { color: var(--moss); font-weight: 700; box-shadow: inset 0 3px 0 var(--moss); }

@media (min-width: 760px) {
  .mainnav {
    position: sticky; top: 0; bottom: auto; box-shadow: none; border-top: 0; border-bottom: 1px solid var(--line);
    display: flex; justify-content: center; gap: .5rem; padding: 0;
  }
  .mainnav a { flex-direction: row; gap: .45rem; min-height: 50px; padding: 0 1rem; font-size: .95rem; }
  .mainnav a.active { box-shadow: inset 0 -3px 0 var(--moss); }
  .page { padding: 1.5rem 1.5rem 4rem; }
  h1 { font-size: 2rem; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .6rem; }
.back { margin: 0 0 .25rem; font-size: .95rem; }
.back a { display: inline-block; padding: .5rem 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: 0 0 1rem;
}

/* --- Buttons & Forms ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--touch); padding: .55rem 1.1rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--basalt); font: 600 1rem var(--sans);
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--wood); color: var(--basalt); }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.primary:hover { background: var(--moss-dark); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: .35rem .9rem; font-size: .92rem; }
.btn.wide { width: 100%; }
.btn[disabled], .btn.busy { opacity: .6; pointer-events: none; }
.btn-row, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: .75rem; }

button.link {
  background: none; border: 0; padding: .4rem 0; min-height: 40px; color: var(--moss);
  font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
button.link.small { font-size: .88rem; }
.danger { color: var(--danger) !important; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  font-size: 1.15rem; color: var(--basalt); cursor: pointer;
}
.icon-btn:disabled { opacity: .3; cursor: default; }

label { display: block; font-weight: 600; margin: .8rem 0 .3rem; }
input:not([type=radio]):not([type=checkbox]), select, textarea {
  width: 100%; min-height: var(--touch); padding: .6rem .75rem;
  border: 1px solid #cfc4b0; border-radius: 10px; background: #fff; color: var(--basalt);
  font: 1rem/1.5 var(--sans);
}
textarea { resize: vertical; }
textarea.mono, .mono { font-family: var(--mono); font-size: .9rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 3px solid rgb(74 93 58 / .35); outline-offset: 2px; border-color: var(--moss);
}
.row { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 520px) { .row { grid-template-columns: 2fr 1fr; } }

.segmented { border: 0; padding: 0; margin: .75rem 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  margin: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: .3rem .4rem; border: 1px solid #cfc4b0; background: #fff; font-size: .86rem; font-weight: 600; cursor: pointer;
}
.segmented label:nth-of-type(1) { border-radius: 10px 0 0 10px; }
.segmented label:nth-of-type(3) { border-radius: 0 10px 10px 0; }
.segmented label + input + label { border-left: 0; }
.segmented input:checked + label { background: var(--moss); border-color: var(--moss); color: #fff; }
.segmented input:focus-visible + label { outline: 3px solid rgb(74 93 58 / .35); }

.alert { background: var(--danger-soft); border: 1px solid #e6b7aa; color: #6d2418; border-radius: 10px; padding: .7rem .9rem; margin: .5rem 0 1rem; }
.alert p { margin: .2rem 0; }
.note { background: var(--wood-soft); border-radius: 10px; padding: .7rem .9rem; margin: .5rem 0 1rem; }
.note.success { background: var(--ok-soft); }
.empty { text-align: center; color: var(--basalt-soft); padding: 2rem 0; }

/* --- Login ------------------------------------------------------------- */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login .form { text-align: left; }
.login-mark { font-size: 3rem; }
.login h1 { margin: .2rem 0 0; }

/* --- Übersicht --------------------------------------------------------- */
.greeting { margin-top: .2rem; }
.big { font-size: 1.12rem; margin: .2rem 0 .6rem; }
progress {
  appearance: none; -webkit-appearance: none; width: 100%; height: 16px; border: 0; border-radius: 999px;
  background: var(--moss-soft); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--moss-soft); border-radius: 999px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--moss), #6b8352); border-radius: 999px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--moss), #6b8352); border-radius: 999px; }
.top-questions { padding-left: 1.3rem; margin: 0; }
.top-questions li { margin: .55rem 0; }
.top-questions a { font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 0 0 1rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .1rem;
  padding: .9rem .4rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--basalt);
}
.tile:hover { border-color: var(--wood); color: var(--basalt); }
.tile-icon { font-size: 1.5rem; color: var(--wood); }
.tile span:last-child { font-size: .8rem; color: var(--basalt-soft); }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { padding: .5rem 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; }

/* --- Fragen ------------------------------------------------------------ */
.filters { display: flex; gap: .45rem; overflow-x: auto; padding: .2rem 0 .8rem; margin: 0 -1rem; padding-left: 1rem; padding-right: 1rem; scrollbar-width: none; }
.pill {
  flex: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 42px; padding: .3rem .9rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--basalt);
  text-decoration: none; font-weight: 600; font-size: .92rem;
}
.pill .count { font-weight: 500; color: var(--basalt-soft); }
.pill.active { background: var(--basalt); border-color: var(--basalt); color: #fff; }
.pill.active .count { color: #d6d9db; }

.qgroup h2 { margin: 1.4rem 0 .6rem; font-size: 1.15rem; color: var(--wood); }
.qcard {
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--line);
  border-radius: var(--radius); margin: 0 0 .6rem; overflow: hidden;
}
.qcard.status-offen.prio-1 { border-left-color: var(--wood); }
.qcard.status-offen { border-left-color: #d9b48f; }
.qcard.status-beantwortet { border-left-color: var(--moss); }
.qcard.status-zurueck { border-left-color: #b9b9b0; }
.qcard > summary {
  list-style: none; cursor: pointer; padding: .85rem 1rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem;
  min-height: var(--touch); -webkit-tap-highlight-color: transparent;
}
.qcard > summary::-webkit-details-marker { display: none; }
.qtitle { font-weight: 650; color: var(--basalt); }
.chips { display: flex; gap: .3rem; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.qsnippet { grid-column: 1 / -1; color: var(--basalt-soft); font-size: .9rem; font-weight: 400; }
.qcard[open] .qsnippet { display: none; }
.qcard[open] > summary { border-bottom: 1px solid var(--line); background: #fbf7ef; }
.chip { display: inline-block; font-size: .74rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: var(--wood-soft); color: #6b4526; white-space: nowrap; }
.status-beantwortet .chip-status { background: var(--moss-soft); color: var(--moss-dark); }
.status-zurueck .chip-status { background: #ebeae5; color: var(--basalt-soft); }
.prio-1 .chip-prio { background: var(--wood); color: #fff; }
.chip-comments { background: #e8eef3; color: #2f4a5e; }
.qbody { padding: .4rem 1rem 1rem; }
.qbody .context { background: var(--wood-soft); border-radius: 10px; padding: .55rem .8rem; font-size: .93rem; margin: .5rem 0; }
.current-answer { border: 1px dashed var(--wood); border-radius: 10px; padding: .3rem .8rem; margin: .5rem 0; }
.saved-info { font-size: .86rem; color: var(--basalt-soft); }
.saved-info.just-saved { color: var(--moss-dark); font-weight: 600; animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--moss-soft); } to { background: transparent; } }
.qedit { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .5rem; }
:where(details:not(.qcard)) > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--basalt-soft); }
.qedit form + form { margin-top: .6rem; }

/* --- Kommentare -------------------------------------------------------- */
.comments { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.badge { background: var(--wood); color: #fff; border-radius: 999px; font-size: .75rem; padding: .05rem .5rem; }
.comment-list { list-style: none; margin: .3rem 0; padding: 0; }
.comment { background: #f4efe4; border-radius: 12px; padding: .55rem .8rem .2rem; margin: .45rem 0; }
.comment.author-julia { background: #efe7f0; }
.comment.author-tim { background: #e6edf1; }
.comment.resolved { opacity: .65; }
.comment-head { display: flex; gap: .5rem; align-items: baseline; font-size: .85rem; }
.comment-head time { color: var(--basalt-soft); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: .4rem; margin-top: .4rem; }
.comment-form .btn { justify-self: start; }
.done-comments > summary { font-size: .88rem; }

/* --- Konzept ----------------------------------------------------------- */
.toc h2 { font-size: 1.05rem; margin-bottom: .3rem; }
.toc ol { margin: 0; padding-left: 1.4rem; columns: 1; }
@media (min-width: 620px) { .toc ol { columns: 2; } }
.toc li { padding: .22rem 0; break-inside: avoid; }
.section { scroll-margin-top: 1rem; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.section-head h2 { margin: .2rem 0 .4rem; font-size: 1.4rem; }
.section-tools { display: flex; gap: .3rem; flex: none; }
.section-foot { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.section-foot .meta { font-size: .85rem; color: var(--basalt-soft); }
.to-top { text-align: right; margin: .3rem 0 0; font-size: .85rem; }
@media (min-width: 760px) { .section { scroll-margin-top: 64px; } html { scroll-padding-top: 64px; } }

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 1.3rem; }
.md li { margin: .25rem 0; }
.md blockquote { margin: .6rem 0; padding: .2rem .9rem; border-left: 4px solid var(--wood); color: var(--basalt-soft); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: .3rem .55rem; }
.md pre { background: #f0ebe0; padding: .7rem; border-radius: 8px; overflow-x: auto; }
.md img { max-width: 100%; }

.tabs { display: flex; gap: .3rem; margin: 1rem 0 .4rem; border-bottom: 1px solid var(--line); }
.tab {
  min-height: 44px; padding: .4rem 1rem; border: 0; background: none; font: 600 .98rem var(--sans); color: var(--basalt-soft);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.tab.active { color: var(--moss); border-bottom-color: var(--moss); }
.preview { min-height: 12rem; border: 1px dashed var(--line); border-radius: 10px; padding: .8rem; background: #fff; }
.editor textarea#body_md { min-height: 16rem; }
.danger-zone { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-top: 1rem; }

.versions { list-style: none; padding: 0; }
.versions li + li { border-top: 1px solid var(--line); }
.versions a { display: flex; flex-direction: column; padding: .7rem .2rem; text-decoration: none; color: var(--basalt); }
.versions a span { font-size: .88rem; color: var(--basalt-soft); }
pre.source { white-space: pre-wrap; overflow-wrap: anywhere; font: .85rem/1.5 var(--mono); background: #f0ebe0; padding: .7rem; border-radius: 8px; }

/* --- Export ------------------------------------------------------------ */
.export-text { min-height: 16rem; font-size: .8rem; }
.copy-status { color: var(--moss-dark); font-weight: 600; min-height: 1.2em; margin: .4rem 0 0; }
.import-preview { border: 2px solid var(--moss-soft); border-radius: 12px; padding: .6rem .9rem; margin: .6rem 0 1rem; background: #fbfcf8; }
.import-preview ul { padding-left: 1.2rem; }
.import-preview li { margin: .35rem 0; }
