/* coupona Docs – Farben, Schriften und gemeinsame Bausteine wie coupona Plan:
   Kopfzeile mit Personenkreis, Konto-Menü, Knöpfe, Felder, Avatare, Dialoge,
   Meldungen und die Anmeldung. Namen der Farben wie in Plan (assets/app.css dort). */

:root {
  --ground:  #F4F2ED;
  --surface: #FFFDF8;
  --line:    #E3DFD6;
  --hair:    #EFEBE3;

  --ink:     #1F1D1A;
  --muted:   #6B6559;
  --faint:   #8E887B;
  --fainter: #A79F91;

  --teal:    #0F6C63;  --teal-bg:  #DCEBE8;  --teal-fg:  #0B4F49;  --teal-bd:  #B5D5D0;
  --clay:    #B4552F;  --clay-bg:  #F6E3D9;  --clay-fg:  #8A3D1D;  --clay-bd:  #EAC5B1;
  --olive:   #5C7A46;  --olive-bg: #E4EBDC;  --olive-fg: #3F5730;  --olive-bd: #C9D8BC;
  --stone:   #9A9183;  --stone-bg: #EDE9E1;  --stone-fg: #4A453C;  --stone-bd: #DCD5C8;
  --block:   #1F1D1A;
  --edge:    #C4BCAE;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 14px;

  /* Rollen im Wiki, aus den Farben oben */
  --paper: var(--ground);
  --side: var(--hair);
  --card: var(--surface);
  --line-2: var(--stone-bd);
  --line-soft: var(--hair);
  --ink-2: var(--stone-fg);
  --ink-3: var(--muted);
  --accent: var(--teal);
  --accent-ink: var(--teal-fg);
  --accent-bg: var(--teal-bg);
  --accent-soft: #EAF2EF;
  --warn-bg: #FBEBD3;
  --warn-line: #EFC98F;
  --warn-ink: #6B3A05;
  --danger: var(--clay-fg);
  --add-bg: var(--olive-bg);
  --add-ink: var(--olive-fg);
  --add-hl: var(--olive-bd);
  --del-bg: var(--clay-bg);
  --del-ink: var(--clay-fg);
  --del-hl: var(--clay-bd);
  --code-bg: var(--ink);
  --code-ink: var(--hair);
  --inline-code: var(--hair);
  --shadow: 0 14px 34px rgba(31, 29, 26, .14), 0 2px 6px rgba(31, 29, 26, .06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.012em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ic { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--mono); }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ico { display: inline-flex; flex-shrink: 0; color: var(--ink-3); }
.ico svg, .btn svg, .menu-item svg, .icon-btn svg, .tool svg { display: block; flex-shrink: 0; }
.vr, .sep { width: 1px; height: 20px; flex-shrink: 0; background: var(--line); }
.only-narrow { display: none !important; }

/* ---------- Knöpfe, Felder, Avatare (wie Plan) ---------- */

.btn {
  height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--muted);
  font-size: 13.5px; font-weight: 500; line-height: 1; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--stone-bd); color: var(--ink); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #FFFDF8; font-weight: 600; }
.btn-primary:hover { background: var(--teal-fg); border-color: var(--teal-fg); color: #FFFDF8; }
/* Endgültiges dunkel statt rot – wie „Löschen“ in Plan */
.btn-danger { background: var(--block); border-color: var(--block); color: #FFFDF8; font-weight: 600; }
.btn-danger:hover { background: #3B3731; border-color: #3B3731; color: #FFFDF8; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: transparent; background: var(--hair); color: var(--ink); }
.btn-ghost.is-danger { color: var(--clay-fg); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hair); color: var(--ink); }
.icon-btn-lg { width: 36px; height: 36px; }

.link { border: none; background: none; padding: 0; font-size: 12.5px; color: var(--teal); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--teal-fg); }
.link.danger { color: var(--clay-fg); }

.input {
  width: 100%; height: 44px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--ground);
  font-size: 15px; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 3px rgba(15, 108, 99, .12); }
.input-sm { height: 38px; font-size: 14px; width: auto; border-radius: var(--r-sm); }
.input-title { height: 48px; font: 600 26px/1 var(--serif); letter-spacing: -0.012em; }
select.input { padding-right: 8px; }

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lbl, .eyebrow {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--faint);
}
.hint { font-size: 12.5px; color: var(--ink-3); }
.hint code, .hint-strong { font-family: var(--mono); color: var(--ink-2); }
.hint-strong { font-family: var(--sans); font-size: 13px; }
.lead { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); }

/* Helle Fläche, Initialen in der Personenfarbe: --pc/--pb setzt avatarStyle() in app.js
   aus der Tabelle people, auf den Seiten vor der App gate.php. */
.avatar {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pb, var(--stone-bg)); color: var(--pc, #514C43);
  border: 1.5px solid var(--surface);
  font-size: 11px; font-weight: 600; line-height: 1;
}
.avatar-xs { width: 18px; height: 18px; border-width: 0; font-size: 9px; }
.avatar-sm { width: 22px; height: 22px; font-size: 10px; }
.avatar-lg { width: 32px; height: 32px; font-size: 12.5px; }
.avatar-xl { width: 38px; height: 38px; font-size: 14px; }

.tag {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  background: var(--stone-bg); color: var(--stone-fg); font-size: 11px; font-weight: 500; white-space: nowrap;
}
.tag-accent { background: var(--teal-bg); color: var(--teal-fg); font-weight: 600; }

/* ---------- Grundgerüst ---------- */

.app { height: 100%; }
.shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* Kopfzeile wie in Plan: 56 px, Wortmarke 18 px, rechts der Personenkreis */
.topbar {
  position: relative; z-index: 20; height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
/* Breite so, dass die Suche an der Kante des Seitenbaums beginnt (20 + 268 + 12 = 300) */
.brand { width: 268px; flex-shrink: 0; display: flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
/* Wortmarke: Unterlänge des „p“ ausgleichen, damit die x-Höhe mittig sitzt */
.brand-logo { display: block; flex-shrink: 0; width: auto; height: 18px; margin-top: 5px; }
.topbar .btn-primary.top-new { height: 34px; padding: 0 14px; font-size: 13px; }

.search { position: relative; width: 420px; min-width: 0; }
.search input {
  width: 100%; height: 34px; padding: 0 60px 0 34px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--ground);
  font-size: 13px; color: var(--ink); outline: none;
}
.search input::placeholder { color: var(--fainter); }
.search input:focus { border-color: var(--teal); background: var(--surface); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 11px; top: 9px; color: var(--faint); pointer-events: none; }
.search-kbd {
  position: absolute; right: 6px; top: 6px; height: 22px; padding: 0 6px;
  display: flex; align-items: center; border-radius: 4px;
  background: var(--hair); color: var(--muted); font: 500 10.5px/1 var(--mono); pointer-events: none;
}
.search-pop {
  position: absolute; top: 42px; left: 0; right: 0; z-index: 30; max-height: min(460px, 70vh); overflow: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.search-hit { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; }
.search-hit:hover, .search-hit.is-active { background: var(--ground); color: var(--ink); }
.search-hit .ico { margin-top: 2px; }
.search-text { display: flex; flex-direction: column; min-width: 0; }
.search-title { font-size: 14px; font-weight: 500; }
.search-path { font-size: 12px; color: var(--faint); }
.search-snip { margin-top: 2px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.search-empty { margin: 0; padding: 10px; font-size: 13px; color: var(--muted); }

.online { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* Personenkreis und Konto-Menü – wie .me/.me-pop in Plan.
   Das Menü sitzt acht Pixel unter der Kopfzeile: (56 − 34) / 2 + 8 = 19. */
.me-wrap { position: relative; flex: none; }
.me {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.me:hover { border-color: var(--stone-bd); }
.me.open { border-color: var(--teal); }
.me-pop {
  position: absolute; z-index: 40; top: calc(100% + 19px); right: 0; width: 272px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.me-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--hair); }
.me-head .avatar { width: 32px; height: 32px; font-size: 12.5px; border: none; }
.me-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.35; }
.me-who strong { font-size: 13.5px; font-weight: 600; }
.me-who strong, .me-who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-who span { font-size: 12px; color: var(--muted); }
.me-sep { height: 1px; margin: 4px; background: var(--hair); }
.me-form { margin: 0; display: flex; flex-direction: column; }
.me-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  border: none; border-radius: var(--r-sm); background: transparent;
  font-size: 13px; color: var(--ink); text-align: left; text-decoration: none; white-space: nowrap;
}
.me-item:hover, .me-item:focus-visible { background: var(--ground); color: var(--ink); outline: none; }
.me-item .ic { width: 15px; height: 15px; stroke-width: 1.5; color: var(--muted); }

/* Weitere Menüs (… an einer Seite) im selben Stil */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; min-width: 240px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.menu-item {
  width: 100%; height: 36px; display: flex; align-items: center; gap: 10px; padding: 0 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink);
  font-size: 13px; text-align: left; text-decoration: none; white-space: nowrap;
}
.menu-item:hover { background: var(--ground); color: var(--ink); }
.menu-item svg { color: var(--muted); }
.menu-item.is-danger, .menu-item.is-danger svg { color: var(--clay-fg); }

.layout { flex: 1; min-height: 0; display: flex; }

/* ---------- Seitenbaum ---------- */

.sidebar {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--side); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 20px; }
.side-actions { display: flex; gap: 2px; }
.tree { flex: 1; min-height: 0; overflow: auto; padding: 0 10px 16px; }
.tree-row {
  position: relative; height: 34px; display: flex; align-items: center; gap: 2px;
  padding-left: calc(4px + var(--depth, 0) * 18px); border-radius: 6px;
}
.tree-row:hover { background: rgba(31, 29, 26, 0.045); }
.tree-row.is-current { background: var(--accent-bg); }
.tree-row.is-dragging { opacity: 0.45; }
.tree-row.drop-inside { background: var(--accent-bg); box-shadow: inset 0 0 0 2px var(--accent); }
.tree-row.drop-before::before, .tree-row.drop-after::after {
  content: ''; position: absolute; left: calc(4px + var(--depth, 0) * 18px); right: 4px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
.tree-row.drop-before::before { top: -1px; }
.tree-row.drop-after::after { bottom: -1px; }
.tree-toggle {
  width: 24px; height: 24px; flex-shrink: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 4px; background: transparent; color: var(--ink-3);
}
.tree-toggle:hover { background: rgba(31, 29, 26, 0.08); }
.tree-toggle svg { transition: transform 0.15s; }
.tree-toggle.is-open svg { transform: rotate(90deg); }
.tree-spacer { width: 24px; flex-shrink: 0; }
.tree-link {
  flex: 1; min-width: 0; height: 34px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 2px; color: var(--ink); font-size: 14px; text-decoration: none;
}
.tree-link:hover { color: var(--ink); }
.is-current .tree-link { color: var(--accent-ink); font-weight: 600; }
.is-current .tree-link .ico { color: var(--accent-ink); }
.tree-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-root-drop {
  margin: 8px 4px 0; padding: 10px; border: 1px dashed var(--line-2); border-radius: 8px;
  font-size: 13px; color: var(--ink-3); text-align: center;
}
.tree-root-drop.is-over { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); }
.tree-empty { margin: 8px 10px; font-size: 14px; color: var(--ink-3); }
.side-foot { display: flex; flex-direction: column; gap: 6px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.side-link { align-self: flex-start; display: flex; align-items: center; gap: 10px; padding: 4px 0; color: var(--ink-2); font-size: 14px; text-decoration: none; }
.side-link:hover { color: var(--ink); }
.side-hint { font-size: 12px; line-height: 1.45; color: var(--ink-3); }
.scrim { position: fixed; inset: 56px 0 0 0; z-index: 14; background: rgba(31, 29, 26, .18); }

/* ---------- Inhalt ---------- */

.main { flex: 1; min-width: 0; overflow: auto; }
.state-loading { margin: 48px 64px; color: var(--ink-3); }
.state { max-width: 640px; margin: 64px; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.content-wrap { display: flex; align-items: flex-start; gap: 56px; padding: 36px 40px 96px 64px; }
.article { flex: 1; min-width: 0; max-width: 760px; }
.rail {
  width: 232px; flex-shrink: 0; position: sticky; top: 36px;
  display: flex; flex-direction: column; gap: 36px; padding-top: 34px; font-size: 14px;
}
.rail .eyebrow { margin-bottom: 12px; }

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.crumb { display: inline-flex; gap: 6px; }
.crumb-current { color: var(--ink); }

.page-title { margin: 14px 0 0; font: 600 44px/1.1 var(--serif); letter-spacing: -0.015em; text-wrap: balance; }
.state .page-title { margin: 0; }
.h1-sm { margin: 2px 0 0; font: 600 30px/1.15 var(--serif); letter-spacing: -0.01em; }
.h2 { margin: 0; font: 600 30px/1.15 var(--serif); }
.page-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; margin-top: 18px; flex-wrap: wrap; }
.page-meta { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--ink-3); }
.page-meta strong { color: var(--ink); font-weight: 500; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page-actions .menu { min-width: 220px; }
.rule { height: 1px; margin: 26px 0 24px; border: 0; background: var(--line); }

.banner { display: flex; align-items: center; gap: 10px; margin: 20px 0 0; padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.banner-warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); }
.banner-info { background: var(--accent-soft); border: 1px solid var(--teal-bd); color: var(--teal-fg); }
.banner strong { font-weight: 600; }

.empty-note { margin: 16px 0 0; color: var(--ink-3); }
.empty-box {
  margin: 0; padding: 32px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  border: 1px dashed var(--line-2); border-radius: 10px; color: var(--ink-3); text-align: center;
}
.empty-box p { margin: 0; }

.subpages { margin-top: 40px; }
.subpages .eyebrow { margin-bottom: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  color: var(--ink); text-decoration: none;
}
.card:hover { border-color: var(--line-2); color: var(--ink); box-shadow: 0 2px 8px rgba(31, 29, 26, 0.06); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }

.list { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.list-head, .list-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 220px; gap: 16px; align-items: center; padding: 12px 16px; }
.list-head {
  padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3);
}
.list-row { border-top: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; }
.list-head + .list-row, .list > .list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--paper); color: var(--ink); }
.list-row-static { grid-template-columns: minmax(0, 1fr) auto; }
.list-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 15px; font-weight: 500; }
.list-sub { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.list-who { display: flex; align-items: center; gap: 8px; }
.trash-text { display: flex; flex-direction: column; min-width: 0; }

.toc, .recent { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.toc { gap: 8px; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--accent-ink); text-decoration: underline; }
.toc-l3 { padding-left: 14px; font-size: 13px; }
.recent { gap: 4px; }
.recent-item {
  display: flex; align-items: flex-start; gap: 10px; margin-left: -8px; padding: 6px 8px;
  border-radius: 6px; color: var(--ink); text-decoration: none;
}
.recent-item:hover { background: rgba(31, 29, 26, 0.05); color: var(--ink); }
.recent-item .avatar { margin-top: 1px; }
.recent-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.recent-title { font-size: 14px; font-weight: 500; line-height: 1.35; }
.recent-meta { font-size: 12px; color: var(--ink-3); }

/* ---------- Markdown ---------- */

.prose { font-size: 16px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.prose > * { margin: 0; }
.prose > * + * { margin-top: 14px; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; scroll-margin-top: 24px; }
.prose h1 { font-size: 32px; }
.prose h2 { margin-top: 30px; font-size: 27px; }
.prose h3 { margin-top: 24px; font-size: 21px; }
.prose h4 { margin-top: 20px; font-size: 18px; }
.prose p { text-wrap: pretty; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 6px; }
.prose li > ul, .prose li > ol { margin-top: 6px; }
.prose li:has(> input[type="checkbox"]) { list-style: none; margin-left: -22px; }
.prose li > input[type="checkbox"] { margin: 0 8px 0 0; accent-color: var(--accent); }
.prose strong { font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { color: var(--accent-ink); }
.prose a.is-missing { color: var(--clay-fg); text-decoration-style: dashed; }
.prose code { padding: 2px 5px; border-radius: 4px; background: var(--inline-code); font-family: var(--mono); font-size: 0.86em; }
.prose pre {
  padding: 16px 20px; overflow: auto; border-radius: 8px;
  background: var(--code-bg); color: var(--code-ink); font: 14px/1.65 var(--mono);
}
.prose pre code { padding: 0; background: none; font-size: inherit; color: inherit; }
.prose blockquote {
  position: relative; padding: 14px 16px 14px 44px; border-radius: 8px;
  background: var(--accent-soft); color: var(--teal-fg); font-size: 15px; line-height: 1.6;
}
.prose blockquote::before {
  content: ''; position: absolute; left: 16px; top: 17px; width: 18px; height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230B4F49' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 7.25v4M8 4.75v.25'/%3E%3C/svg%3E") no-repeat center / contain;
}
.prose blockquote > * { margin: 0; }
.prose blockquote > * + * { margin-top: 8px; }
.prose blockquote code { background: rgba(15, 108, 99, .1); }
.prose hr { height: 1px; margin: 28px 0; border: 0; background: var(--line); }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose .table-wrap { overflow-x: auto; }
/* break-word statt anywhere: Spalten werden mindestens so breit wie ihr längstes Wort, sonst
   drückt width: 100% sie auf dem Handy auf einen Buchstaben zusammen. Was nicht passt, scrollt. */
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; overflow-wrap: break-word; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--side); font-weight: 600; }
.prose td.cell-num { white-space: nowrap; }

/* ---------- Anhänge und Diagramme ---------- */

.prose .file-image { display: inline-block; max-width: 100%; }
.prose .file-image img { display: block; }
.prose .file-link { font-weight: 500; }
.file-missing {
  display: inline-flex; align-items: center; padding: 2px 8px; border: 1px dashed var(--edge); border-radius: 6px;
  font-size: 13px; color: var(--muted);
}

.prose figure.diagram { margin-left: 0; margin-right: 0; display: flex; flex-direction: column; gap: 8px; }
.diagram-view {
  display: block; overflow: hidden; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: #FFFFFF;
}
.diagram-view img { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; border-radius: 0; }
.diagram-caption { font-size: 13px; color: var(--muted); }
.diagram-wait {
  padding: 28px 16px; border: 1px dashed var(--line); border-radius: var(--r-md);
  font-size: 13px; color: var(--muted); text-align: center;
}
.diagram-links { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.diagram-links a { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.diagram-sep { color: var(--fainter); }
.link-btn {
  padding: 0; border: 0; background: none; font-size: 13px; color: var(--teal); text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--teal-fg); }
.diagram-note { margin: 0; font-size: 13px; color: var(--warn-ink); }
.diagram-error {
  padding: 12px 14px; border: 1px solid var(--clay-bd); border-radius: var(--r-md); background: var(--clay-bg);
  font-size: 14px; line-height: 1.5; color: var(--clay-fg);
}
.diagram-error strong { font-weight: 600; }
.prose .diagram-error pre {
  margin: 10px 0 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font-size: 12.5px;
}
.diagram-error .is-line { display: inline; background: var(--clay-bd); }
.prose .diagram-source { margin: 0; }
.uml-frame { position: fixed; left: -10000px; top: 0; width: 1200px; height: 800px; border: 0; opacity: 0; pointer-events: none; }

.files {
  margin-top: 36px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  display: flex; flex-direction: column; gap: 8px;
}
.files.is-over { border-color: var(--teal); border-style: dashed; background: var(--teal-bg); }
.files-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.files-head .eyebrow { flex: 1; }
.files-add { cursor: pointer; }
.files-add:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-row { border: 1px solid var(--hair); border-radius: var(--r-sm); }
.file-row.is-open { border-color: var(--line); }
.file-main { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 6px 6px 12px; }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none; }
.file-name:hover { color: var(--teal-fg); text-decoration: underline; text-underline-offset: 3px; }
.file-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.file-actions { display: flex; flex-shrink: 0; gap: 2px; }
.file-versions { display: flex; flex-direction: column; border-top: 1px solid var(--hair); background: #FAF8F3; border-radius: 0 0 var(--r-sm) var(--r-sm); }
.file-version { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px; }
.file-version + .file-version { border-top: 1px solid var(--hair); }
.file-version-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.files-empty { margin: 0; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); font-size: 13px; color: var(--muted); text-align: center; }
.files-hint { margin: 4px 0 0; }
.files-hint code { font-size: 12px; }

.menu-files { left: 0; right: auto; width: 280px; }
.menu-empty { margin: 0; padding: 8px 10px; font-size: 13px; line-height: 1.45; color: var(--muted); white-space: normal; }
.trash-files { margin-top: 28px; }
.trash-files .eyebrow { margin-bottom: 10px; }

/* ---------- Verlauf ---------- */

.history { min-height: 100%; display: flex; flex-direction: column; }
.history-head {
  display: flex; align-items: center; gap: 16px; padding: 20px 40px 18px 24px;
  border-bottom: 1px solid var(--line); background: var(--card);
}
.history-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-body { flex: 1; display: flex; align-items: flex-start; }
.versions {
  width: 360px; flex-shrink: 0; align-self: stretch; display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px 24px; background: var(--side); border-right: 1px solid var(--line);
}
.version {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left;
}
.version:hover { background: rgba(31, 29, 26, 0.04); }
.version.is-on { border-color: var(--teal-bd); background: var(--card); }
.vbadge {
  min-width: 34px; height: 24px; flex-shrink: 0; padding: 0 6px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--line); color: var(--ink); font: 500 12px/1 var(--mono);
}
.version.is-on .vbadge { background: var(--accent); color: #FFFDF8; }
.vtext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vnote { font-size: 14px; font-weight: 500; line-height: 1.35; }
.vmeta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--ink-3); }
.diff-panel { flex: 1; min-width: 0; padding: 28px 40px 48px; }
.diff-panel > div { display: flex; flex-direction: column; gap: 14px; }
.diff-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.diff-head .page-meta { margin-top: 8px; }
.diff-stats { margin: 6px 0 0; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-2); }
.stat-add { font-family: var(--mono); font-weight: 500; color: var(--add-ink); }
.stat-del { font-family: var(--mono); font-weight: 500; color: var(--del-ink); }
.legend { margin: 0; display: flex; gap: 20px; font-size: 13px; }

.diff { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font: 13.5px/1.75 var(--mono); }
.diff-row { display: grid; grid-template-columns: 48px 48px 28px minmax(0, 1fr); }
.diff-row .ln { padding-right: 10px; text-align: right; color: var(--ink-3); user-select: none; }
.diff-row .sign { text-align: center; font-weight: 600; user-select: none; }
.diff-row .code { padding-right: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-row.is-add { background: var(--add-bg); color: var(--add-ink); }
.diff-row.is-del { background: var(--del-bg); color: var(--del-ink); }
.diff-row.is-add .hl { background: var(--add-hl); border-radius: 3px; }
.diff-row.is-del .hl { background: var(--del-hl); border-radius: 3px; }
.diff-row.is-skip {
  display: block; padding: 6px 16px; background: var(--paper); color: var(--ink-3);
  font: 13px/1.5 var(--sans); border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.diff-row.is-skip .ln, .diff-row.is-skip .sign { display: none; }

/* ---------- Editor ---------- */

.editor-screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }
.ed-head {
  height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.ed-crumb { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.ed-label { font-size: 15px; font-weight: 600; }
.ed-status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.ed-status .ok { color: var(--accent); display: inline-flex; }
.ed-note { width: 290px; }
.ed-banner {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 10px 20px 10px 28px;
  font-size: 14px; border-bottom: 1px solid var(--warn-line);
}
.ed-banner.banner-info { border-bottom-color: var(--teal-bd); }
.ed-meta {
  flex-shrink: 0; display: flex; align-items: flex-start; gap: 24px; padding: 18px 28px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.ed-parent { width: 440px; flex-shrink: 0; }
.ed-parent .input { height: 48px; }
.ed-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--card); }
.ed-toolbar {
  height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 2px; padding: 0 16px;
  border-bottom: 1px solid var(--line-soft); color: var(--ink-2);
}
.tool {
  width: 36px; height: 32px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 6px; background: transparent; color: var(--ink-2);
}
.tool:hover { background: var(--paper); color: var(--ink); }
.tool-text { font-size: 13px; font-weight: 600; }
.tool-bold { font-size: 15px; font-weight: 700; }
.tool-wide { width: auto; padding: 0 10px; font-size: 13px; }
.tool-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--line); }
.ed-tools { min-width: 0; display: flex; align-items: center; gap: 2px; }
.seg { flex-shrink: 0; display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(31, 29, 26, .1); }
.ed-preview-body { flex: 1; min-height: 0; overflow: auto; padding: 28px 48px 64px; }
.ed-preview-body > .prose, .ed-preview-body > .page-title-preview { max-width: 680px; margin-left: auto; margin-right: auto; }
.page-title-preview { margin: 0 0 20px; font-size: 38px; }
.ed-foot {
  height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 20px 0 32px; background: var(--card); border-top: 1px solid var(--line);
  font-size: 12px; color: var(--ink-3); white-space: nowrap;
}
.ed-hints { display: flex; gap: 14px; overflow: hidden; }
.ed-hints code { font-family: var(--mono); }
.ed-tabs { flex-shrink: 0; gap: 4px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.ed-tabs button { flex: 1; height: 36px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--card); font-size: 14px; font-weight: 500; }
.ed-tabs button.is-on { background: var(--accent); border-color: var(--accent); color: #FFFDF8; }

/* ---------- Editor: CodeMirror mit Live-Vorschau (assets/editor.js) ----------
   Drei Klassen tief, damit die Regeln die Grundeinstellungen von CodeMirror schlagen,
   die es als eigenes <style> nach app.css einhängt. */

.ed-cm { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ed-cm .cm-editor { flex: 1; min-height: 0; background: var(--card); color: var(--ink); }
.ed-cm .cm-editor.cm-focused { outline: none; }
.ed-cm .cm-editor .cm-scroller { overflow: auto; font-family: var(--sans); font-size: 16px; line-height: 1.7; }
/* Spalte so breit wie die Leseansicht; das Innenmaß füllt die Ränder, damit auch ein Klick daneben trifft */
.ed-cm .cm-editor .cm-content { padding: 28px max(48px, calc((100% - 680px) / 2)) 40vh; caret-color: var(--ink); }
/* --pad: Innenabstand links (Hinweis, Code), --hang: hängender Einzug umbrochener Listenzeilen */
.ed-cm .cm-editor .cm-line { padding: 0 0 0 calc(var(--pad, 0px) + var(--hang, 0em)); text-indent: calc(-1 * var(--hang, 0em)); }
.ed-cm .cm-editor .cm-placeholder { color: var(--fainter); }

.ed-cm .cm-editor .cm-md-h1, .ed-cm .cm-editor .cm-md-h2, .ed-cm .cm-editor .cm-md-h3, .ed-cm .cm-editor .cm-md-h4 {
  font-family: var(--serif); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em;
}
.ed-cm .cm-editor .cm-md-h1 { font-size: 32px; }
.ed-cm .cm-editor .cm-line.cm-md-h2 { padding-top: 16px; font-size: 27px; }
.ed-cm .cm-editor .cm-line.cm-md-h3 { padding-top: 10px; font-size: 21px; }
.ed-cm .cm-editor .cm-line.cm-md-h4 { padding-top: 6px; font-size: 18px; }
.ed-cm .cm-editor .cm-md-h5, .ed-cm .cm-editor .cm-md-h6 { font-weight: 600; }

.ed-cm .cm-editor .cm-md-mark { color: var(--fainter); }
.ed-cm .cm-editor .cm-md-strong { font-weight: 600; }
.ed-cm .cm-editor .cm-md-em { font-style: italic; }
.ed-cm .cm-editor .cm-md-strike { text-decoration: line-through; }
/* box-shadow statt padding: sieht aus wie Innenabstand, verschiebt aber keine Zeichen */
.ed-cm .cm-editor .cm-md-code {
  border-radius: 3px; background: var(--inline-code); box-shadow: 0 0 0 2px var(--inline-code);
  font-family: var(--mono); font-size: 0.86em;
}
.ed-cm .cm-editor .cm-md-link { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ed-cm .cm-editor .cm-md-link.is-missing { color: var(--clay-fg); text-decoration-style: dashed; }
.ed-cm .cm-editor .cm-md-file { font-weight: 500; }
.ed-cm .cm-editor .cm-md-html { font-family: var(--mono); font-size: 13.5px; color: var(--muted); }
.ed-cm .cm-editor .cm-md-table { font-family: var(--mono); font-size: 13.5px; }

/* Listen: Einrückung und Zeichen in Mono (0,6em je Zeichen), siehe listMark() in editor.js */
.ed-cm .cm-editor .cm-md-indent, .ed-cm .cm-editor .cm-md-listmark, .ed-cm .cm-editor .cm-md-olmark { font-family: var(--mono); }
.ed-cm .cm-editor .cm-md-listmark { color: var(--fainter); }
.ed-cm .cm-editor .cm-md-olmark { color: var(--muted); }
.ed-cm .cm-editor .cm-md-bullet { display: inline-block; padding-left: 0.2em; text-indent: 0; color: var(--muted); }
.ed-cm .cm-editor .cm-md-task {
  width: 15px; height: 15px; margin: 0 calc(1.6em - 18px) 0 3px; vertical-align: -2px;
  font-size: inherit; text-indent: 0; accent-color: var(--accent); cursor: pointer;
}

.ed-cm .cm-editor .cm-line.cm-md-quote { --pad: 44px; padding-right: 16px; background: var(--accent-soft); color: var(--teal-fg); font-size: 15px; }
.ed-cm .cm-editor .cm-line.cm-md-quote-first {
  padding-top: 12px; border-radius: 8px 8px 0 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230B4F49' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 7.25v4M8 4.75v.25'/%3E%3C/svg%3E") no-repeat 16px 15px / 18px 18px, var(--accent-soft);
}
.ed-cm .cm-editor .cm-line.cm-md-quote-last { padding-bottom: 12px; border-radius: 0 0 8px 8px; }
.ed-cm .cm-editor .cm-line.cm-md-quote-first.cm-md-quote-last { border-radius: 8px; }
.ed-cm .cm-editor .cm-md-quote .cm-md-mark { color: var(--teal); }

.ed-cm .cm-editor .cm-line.cm-md-pre {
  --pad: 20px; padding-right: 20px; background: var(--code-bg); color: var(--code-ink);
  font: 14px/1.65 var(--mono); caret-color: var(--code-ink);
}
.ed-cm .cm-editor .cm-line.cm-md-pre-first { padding-top: 8px; border-radius: 8px 8px 0 0; }
.ed-cm .cm-editor .cm-line.cm-md-pre-last { padding-bottom: 8px; border-radius: 0 0 8px 8px; }
.ed-cm .cm-editor .cm-line.cm-md-pre-first.cm-md-pre-last { border-radius: 8px; }
.ed-cm .cm-editor .cm-line.cm-md-fence { line-height: 8px; }
.ed-cm .cm-editor .cm-md-pre .cm-md-mark { color: var(--faint); }
.ed-cm .cm-editor .cm-line.cm-md-hr { background: linear-gradient(var(--line), var(--line)) no-repeat 0 50% / 100% 1px; }

/* Tabellen, PlantUML und Bilder als fertige Darstellung – ein Klick zeigt das Markdown */
.ed-cm .cm-editor .cm-md-block { padding: 6px 0; border-radius: 8px; cursor: text; }
.ed-cm .cm-editor .cm-md-block:hover { outline: 1px dashed var(--line-2); outline-offset: 4px; }
.ed-cm .cm-editor .cm-md-block .prose > p { margin: 0; }
.ed-cm .cm-editor .cm-md-block .diagram-links, .ed-cm .cm-editor .cm-md-block .diagram-source { display: none; }
.ed-cm .cm-editor .cm-md-block a { pointer-events: none; }

/* Vorschläge nach [[ und Suchleiste (⌘/Strg F) */
.ed-cm .cm-editor .cm-tooltip { border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.ed-cm .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul { min-width: 280px; max-width: min(520px, 90vw); max-height: 300px; padding: 4px; font-family: var(--sans); }
.ed-cm .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li {
  display: flex; align-items: baseline; gap: 12px; padding: 6px 10px; border-radius: 6px;
  font-size: 14px; line-height: 1.35; color: var(--ink);
}
.ed-cm .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--accent-bg); color: var(--accent-ink); }
.ed-cm .cm-editor .cm-completionLabel { white-space: nowrap; }
.ed-cm .cm-editor .cm-completionDetail { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-style: normal; color: var(--muted); }
.ed-cm .cm-editor .cm-completionMatchedText { text-decoration: none; font-weight: 600; }
.ed-cm .cm-editor .cm-panels { border-color: var(--line); background: var(--paper); color: var(--ink); font-family: var(--sans); }
.ed-cm .cm-editor .cm-panels-top { border-bottom: 1px solid var(--line); }
.ed-cm .cm-editor .cm-search { padding: 8px 12px; font-size: 13px; }
.ed-cm .cm-editor .cm-search label { font-size: 13px; }
.ed-cm .cm-editor .cm-textfield { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font: 13px var(--sans); }
.ed-cm .cm-editor .cm-button { padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); background-image: none; font: 13px var(--sans); color: var(--ink-2); }
.ed-cm .cm-editor .cm-searchMatch { background: var(--warn-bg); outline: 1px solid var(--warn-line); }
.ed-cm .cm-editor .cm-searchMatch-selected { background: var(--warn-line); }

/* ---------- Dialoge (Kästen wie in Plan) ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(31, 29, 26, .24);
}
.modal-top { z-index: 120; }
.modal {
  width: 600px; max-width: 100%; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  box-shadow: 0 24px 64px rgba(31, 29, 26, .18);
}
.modal-wide { width: 880px; }
.modal-sm { width: 460px; }
.modal-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 20px 0 28px; }
.modal-head h2 { margin: 0; font: 600 26px/1.2 var(--serif); letter-spacing: -0.012em; }
.modal-body { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 20px; padding: 18px 28px 24px; }
.modal-body > p { margin: 0; }
.modal-foot {
  flex-shrink: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 28px; background: #FAF8F3; border-top: 1px solid var(--hair);
}

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); text-align: left;
}
.choice:hover { border-color: var(--ink-3); }
.choice.is-on { border-color: var(--accent); background: #F1F7F6; box-shadow: 0 0 0 1px var(--accent); }
.choice-ico { color: var(--ink-3); margin-top: 2px; }
.choice.is-on .choice-ico { color: var(--accent); }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-size: 15px; font-weight: 600; }
.choice-sub { font-size: 13px; line-height: 1.4; color: var(--ink-2); }

.picker {
  height: 236px; overflow: auto; display: flex; flex-direction: column; gap: 1px; padding: 6px;
  border: 1px solid var(--line-2); border-radius: 10px;
}
.pick {
  height: 34px; flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 0 10px 0 calc(10px + var(--depth, 0) * 20px); border-radius: 6px; font-size: 14px; cursor: pointer;
}
.pick:hover { background: var(--paper); }
.pick.is-on { background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.pick.is-on .ico { color: var(--accent-ink); }
.pick input { margin: 0; accent-color: var(--accent); }

/* „Mit Claude verbinden“ – wie in Plan */
.modal.conn { width: 560px; gap: 16px; padding: 28px; overflow-y: auto; }
.conn > p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.conn b { font-weight: 600; color: var(--ink); }
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conn-head h2 { margin: 0; font-size: 26px; line-height: 1.2; }
.conn-head .icon-btn { margin-right: -8px; }
.conn-fresh {
  display: flex; flex-direction: column; gap: 16px; padding: 16px;
  background: var(--teal-bg); border: 1px solid var(--teal-bd); border-radius: var(--r-md);
}
.conn-fresh .lbl { color: var(--teal-fg); }
.conn-hint { font-size: 12px; line-height: 1.45; color: var(--teal-fg); opacity: .8; }
.conn-copy { display: flex; align-items: flex-start; gap: 8px; }
.conn-copy code {
  flex-grow: 1; min-width: 0; padding: 9px 11px; background: var(--surface); border: 1px solid var(--teal-bd);
  border-radius: var(--r-sm); font-family: var(--mono); font-size: 11.5px; line-height: 1.5; word-break: break-all;
  user-select: all;
}
.conn-copy .btn { flex: none; height: 36px; padding: 0 12px; }
.conn-warn { margin: 0; font-size: 12px; line-height: 1.45; color: var(--teal-fg); }
.conn-list { display: flex; flex-direction: column; gap: 6px; }
.conn-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.conn-tail { flex: none; font-family: var(--mono); font-size: 12px; color: var(--faint); white-space: nowrap; }
.conn-name { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.conn-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-meta { font-size: 12px; color: var(--faint); }
.conn-row .link { flex: none; }
.conn-new { display: flex; gap: 8px; }
.conn-new input {
  flex-grow: 1; min-width: 0; height: 38px; padding: 0 12px; background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--r-sm); font-size: 13.5px; outline: none;
}
.conn-new input:focus { border-color: var(--teal); background: var(--surface); }
.conn-new .btn { height: 38px; }

/* Meldungen unten rechts, dunkel wie in Plan */
.toasts {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 200;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none;
}
.toast {
  max-width: min(480px, calc(100vw - 48px)); padding: 11px 14px; border-radius: 12px;
  background: var(--ink); color: var(--ground); font-size: 13px; line-height: 1.45;
  box-shadow: 0 12px 30px rgba(31, 29, 26, .22);
}
.toast.is-error { background: var(--clay-fg); color: #FFF7F2; }

/* ---------- Anmelden und die Seiten vor der App (lib/views/gate.php) – wie in Plan ---------- */

.login {
  min-height: 100%; padding: 48px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  /* Linien wie auf Notizpapier */
  background: var(--ground) repeating-linear-gradient(to bottom, transparent 0, transparent 31px, #EAE6DD 31px, #EAE6DD 32px);
}
.login-mark { display: block; height: 22px; width: auto; }
.login-box {
  width: 100%; max-width: 400px; padding: 32px; display: flex; flex-direction: column; gap: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 1px 2px rgba(31, 29, 26, .04), 0 12px 32px rgba(31, 29, 26, .06);
}
.login-box h1 { margin: 0; font-size: 28px; line-height: 1.2; }
.login-box p { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.login-box code { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.login-box .field > label { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.login-box .btn { height: 44px; font-size: 14px; }
.login-box .btn:not(.btn-primary) { color: var(--ink); }
.login-box button:focus-visible, .login-box a:focus-visible, .login-keep input:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.login-head { display: flex; flex-direction: column; gap: 10px; }
.login-off { opacity: .55; }

.login-pw { position: relative; display: flex; align-items: center; }
.login-pw input {
  width: 100%; height: 44px; padding: 0 48px 0 13px; background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 15px; font-weight: 500; color: var(--ink); outline: none;
}
.login-pw input:focus { border-color: var(--teal); }
.login-pw input.err { background: var(--surface); border-color: var(--clay); box-shadow: 0 0 0 3px var(--clay-bg); }
.login-pw input:disabled { background: var(--hair); cursor: not-allowed; }
.login-eye {
  position: absolute; right: 4px; width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-sm); background: transparent; color: var(--muted); cursor: pointer;
}
.login-eye:hover { color: var(--ink); }
.login-eye:disabled { cursor: not-allowed; }
.login-eye .ic { width: 16px; height: 16px; stroke-width: 1.5; }
.login-eye .ic-off, .login-eye.on .ic-on { display: none; }
.login-eye.on .ic-off { display: block; }

.login-err { display: flex; align-items: flex-start; gap: 8px; margin-top: 2px; font-size: 13px; line-height: 1.45; color: var(--clay-fg); }
.login-note {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; font-size: 13px; line-height: 1.45;
  background: var(--clay-bg); border: 1px solid var(--clay-bd); border-radius: var(--r-md); color: var(--clay-fg);
}
.login-err .ic, .login-note .ic { width: 16px; height: 16px; margin-top: 1px; stroke-width: 1.5; }
.login-err strong, .login-note strong { font-weight: 600; }
.login-note .mono { font-weight: 500; }

.login-keep { display: flex; align-items: center; gap: 10px; min-height: 24px; font-size: 13.5px; cursor: pointer; }
.login-keep input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--teal); }
.login-keep .mono { margin-left: auto; font-size: 12px; color: var(--muted); }

.login-lock {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
  background: var(--stone-bg); border: 1px solid var(--stone-bd); border-radius: var(--r-md); color: var(--stone-fg);
}
.login-lock .ic { width: 18px; height: 18px; stroke-width: 1.5; }
.login-code {
  margin: 0; padding: 14px 16px; overflow-x: auto; white-space: pre;
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7; color: var(--ink);
}
.login-code .c { color: var(--muted); }
.login-code .s { color: var(--teal-fg); }

/* „Wer bist du?“ – Kacheln wie in Plan; die gerade gewählte Person in ihrer Farbe */
.who-row { display: flex; flex-wrap: wrap; gap: 10px; }
.who-btn {
  flex: 1 1 96px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--ink);
}
.who-btn:hover { border-color: var(--teal); background: var(--teal-bg); }
.who-btn .avatar { border: none; }
.who-btn.on { border-color: var(--pc); background: var(--pb); color: var(--pc); font-weight: 600; }
.who-btn.on .avatar { background: var(--pc); color: #FFFDF8; }
.who-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: -6px; }
.login-foot form { margin: 0; }
.login-link {
  min-height: 32px; display: inline-flex; align-items: center; padding: 0; border: 0; background: none;
  font-size: 13px; color: var(--teal); text-decoration: underline; text-underline-offset: 3px;
}
.login-link:hover { color: var(--teal-fg); }

/* ---------- Schmalere Fenster ---------- */

@media (max-width: 1180px) {
  .rail { display: none; }
  .content-wrap { padding: 32px 40px 80px; }
  .brand { width: auto; margin-right: 8px; }
}

/* Handy und Home-Bildschirm-App. Als App kann iOS oben Platz für die Statusleiste und unten
   für den Home-Balken verlangen; Kopfzeile, Seitenbaum und Fuß rücken dann mit. Sonst sind
   die env()-Werte 0. */
@media (max-width: 900px) {
  .only-narrow { display: flex !important; }
  .hide-narrow { display: none !important; }
  .topbar { height: calc(56px + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 12px 0 8px; gap: 10px; }
  .topbar > .grow { display: none; }
  .brand { margin-right: 0; }
  .brand-logo { height: 19px; }
  /* Neue Seite nur als Symbol, neutral wie „Neues Todo“ in Plan */
  .topbar .btn-primary.top-new { width: 34px; padding: 0; background: var(--surface); border-color: var(--line); color: var(--muted); }
  .me { width: 40px; height: 40px; border: none; }
  .me-item, .menu-item { height: 44px; font-size: 14px; }
  .search { width: auto; flex: 1; }
  .search-kbd { display: none; }
  .search input { padding-right: 10px; }
  .sidebar {
    position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); bottom: 0; left: 0; z-index: 15; width: min(320px, 86vw);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: none; }
  .scrim { top: calc(56px + env(safe-area-inset-top, 0px)); }
  .content-wrap { padding: 24px 16px calc(64px + env(safe-area-inset-bottom, 0px)); }
  .page-title { font-size: 34px; }
  /* Breite Tabellen scrollen bis an den Bildschirmrand, damit man sieht, dass es weitergeht */
  .prose .table-wrap { margin-right: -16px; margin-left: -16px; padding: 0 16px; }
  .prose table { font-size: 14px; }
  .prose th, .prose td { padding: 8px 10px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
  .list-head { display: none; }
  .list-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .list-row-static { grid-template-columns: minmax(0, 1fr); }
  .history-head { padding: 16px; }
  .history-body { flex-direction: column; align-items: stretch; }
  .versions { width: auto; max-height: 260px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .diff-panel { padding: 20px 16px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .ed-head { height: calc(56px + env(safe-area-inset-top, 0px)); gap: 10px; padding: env(safe-area-inset-top, 0px) 12px 0; }
  .ed-meta { flex-direction: column; gap: 14px; padding: 14px 16px; }
  .ed-parent { width: 100%; }
  .ed-toolbar { padding: 0 8px; }
  .tool-wide { width: 36px; padding: 0; }
  .tool-label { display: none; }
  .ed-cm .cm-editor .cm-content { padding: 20px 16px 40vh; }
  .ed-preview-body { padding: 20px 16px 48px; }
  .ed-banner { padding: 10px 16px; }
  .ed-foot { height: auto; min-height: 36px; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-body { padding: 16px 20px 20px; }
  .modal-head { padding: 16px 16px 0 20px; }
  .modal-foot { padding: 14px 20px; flex-wrap: wrap; }
  .modal.conn { padding: 20px 16px; }
  .conn-new, .conn-copy { flex-direction: column; align-items: stretch; }
  .conn-new input, .conn-new .btn { height: 44px; font-size: 16px; }
  .toasts { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { max-width: none; }
  .file-main { flex-wrap: wrap; }
  .file-actions { width: 100%; justify-content: flex-end; }
  .file-actions .icon-btn { width: 40px; height: 40px; }
  .file-version { flex-wrap: wrap; }
  .file-version-text { flex-basis: calc(100% - 50px); }
  .menu-files { width: min(280px, calc(100vw - 32px)); }

  .login { justify-content: flex-start; padding-top: calc(112px + env(safe-area-inset-top, 0px)); }
  .login-mark { height: 20px; }
  .login-box { padding: 24px 20px; }
  .login-box h1 { font-size: 26px; }
  .login-box .btn { height: 48px; font-size: 15px; border-radius: 10px; }
  .login-pw input { height: 48px; padding-right: 52px; font-size: 16px; }
  .login-eye { right: 2px; width: 44px; height: 44px; }
  .login-keep { min-height: 44px; gap: 12px; font-size: 14px; }
  .login-keep input { width: 20px; height: 20px; }
  .login-link { min-height: 44px; font-size: 14px; }
}

@media (max-width: 480px) {
  .brand-logo { height: 15px; }
}

@media (max-width: 340px) {
  .topbar .brand { display: none; }
}
