:root {
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #211f1b;
  --muted: #6f6a60;
  --faint: #9b958a;
  --line: #d6d0c4;
  --line-strong: #bcb4a7;
  --thread: #a6211b;
  --thread-dark: #7f1713;
  --warning: #b86b19;
  --warning-soft: #f7e7cf;
  --ready: #66794b;
  --ready-soft: #e4ead8;
  --sage: #dfe5d7;
  --mustard: #efe3b8;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
  --header-height: 68px;
  --sidebar-width: 224px;
  --focus: 0 0 0 3px rgba(166, 33, 27, 0.22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
}

button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:not(:disabled), a { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

:focus-visible { outline: none; box-shadow: var(--focus); }

.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;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.app-shell {
  display: grid;
  grid-template: var(--header-height) minmax(0, 1fr) / var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  min-height: 680px;
  background: var(--paper);
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(280px, 760px) 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  min-width: 0;
  z-index: 20;
}

.brand {
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-right: 1px solid var(--line);
  color: var(--ink);
  font: 700 26px/1 var(--serif);
  text-decoration: none;
  letter-spacing: -0.025em;
}

.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  margin-left: 24px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  border-radius: 4px;
  padding: 0 12px;
}

.global-search-wrap:focus-within { border-color: var(--thread); box-shadow: var(--focus); }
.global-search-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; }
.global-search-wrap input::placeholder { color: var(--faint); }
.global-search-wrap kbd { border: 1px solid var(--line); border-radius: 3px; color: var(--muted); padding: 2px 6px; font: 11px var(--mono); white-space: nowrap; }

.search-results {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: -1px;
  right: -1px;
  max-height: min(70vh, 640px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  box-shadow: 0 14px 30px rgba(38, 33, 26, 0.14);
}

.search-result {
  width: 100%;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: var(--surface-strong);
}
.search-result:hover, .search-result:focus-visible { background: #f2eee5; }
.search-result strong { display: block; font: 600 15px var(--sans); }
.search-result small { display: block; margin-top: 2px; color: var(--muted); font: 12px var(--mono); }
.search-result .kind-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

.top-actions { justify-self: end; display: flex; align-items: center; gap: 6px; padding: 0 20px; }
.session-logout { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.session-logout > span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: auto;
  padding: 28px;
  background: var(--paper);
}

.login-card {
  width: min(100%, 430px);
  padding: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.login-eyebrow { margin: 0 0 8px; color: var(--thread); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.login-card h1 { margin: 0; font: 700 38px/1.1 var(--serif); letter-spacing: -0.025em; }
.login-intro { margin: 14px 0 28px; color: var(--muted); }
.login-feedback { margin: 0 0 18px; padding: 10px 12px; border-left: 3px solid var(--thread); background: #f5e7e3; color: var(--thread-dark); }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 8px; font-size: 13px; font-weight: 700; }
.login-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface-strong); }
.login-form input:focus { border-color: var(--thread); outline: none; box-shadow: var(--focus); }
.login-form button { min-height: 46px; margin-top: 14px; border: 1px solid var(--thread); border-radius: 3px; background: var(--thread); color: #fff; font-weight: 700; }
.login-form button:hover { background: var(--thread-dark); }
.quiet-button, .outline-button, .icon-button, .save-button, .segmented {
  min-height: 44px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 3px;
  font-size: 14px;
}
.quiet-button:hover { background: #eee9df; }
.wall-back-button { display: none; color: var(--thread-dark); text-decoration: none; }
body.view-wall .wall-back-button { display: inline-flex; }
.outline-button { border-color: var(--line-strong); background: var(--surface); }
.outline-button:hover { border-color: var(--ink); }
.save-button { min-width: 112px; border-color: var(--thread); background: var(--thread); color: white; font-weight: 650; }
.save-button:hover { background: var(--thread-dark); }
.save-button:disabled { opacity: .5; }
.icon-button { width: 44px; padding: 0; font-size: 25px; }

.sidebar {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}

.main-nav { display: grid; gap: 3px; padding: 18px 12px; }
.main-nav a {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  border-radius: 3px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 540;
}
.main-nav a:hover { background: #eee9df; }
.main-nav a.active { background: var(--thread); color: white; }

.sidebar-tools { margin: 4px 14px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sidebar-tools button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--muted);
  padding: 0 8px;
  font-size: 13px;
}
.sidebar-tools button:not(:disabled):hover { color: var(--ink); background: #eee9df; }

.sidebar-recent { min-height: 0; display: flex; flex-direction: column; padding: 16px 12px; }
.sidebar-recent h2 { margin: 0 5px 10px; font: 600 13px var(--sans); }
.recent-list { display: grid; gap: 2px; min-height: 0; overflow: auto; }
.recent-item {
  display: grid;
  grid-template-columns: 23px 1fr;
  gap: 8px;
  align-items: start;
  width: 100%;
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  text-align: left;
  padding: 8px 5px;
  font-size: 12px;
}
.recent-item:hover { background: #eee9df; border-left-color: var(--thread); }
.recent-item .icon { width: 18px; height: 18px; }
.recent-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item small { grid-column: 2; color: var(--faint); font: 10px var(--mono); }

.control-view {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 26px clamp(24px, 3vw, 48px) 36px;
  background: var(--paper);
}

.week-section { max-width: 1500px; margin: 0 auto; }
.section-heading, .panel-heading, .graph-toolbar, .document-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h1, .graph-toolbar h1 { margin: 0; font: 700 clamp(38px, 4vw, 58px)/1 var(--serif); letter-spacing: -0.035em; }
.section-heading p, .graph-toolbar p { margin: 8px 0 0; color: var(--muted); }

.fact-strip { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 14px; }
.fact {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.58);
  border-radius: 3px;
  font-size: 13px;
}
.fact-action { font-family: inherit; color: inherit; cursor: pointer; }
.fact-action:hover { background: rgba(255, 253, 248, 0.9); border-color: var(--warning); }
.fact.warning { border-color: #d7ae78; }
.fact.ready { border-color: #aab58f; }
.fact .icon { width: 18px; height: 18px; }
.fact.warning .icon { color: var(--warning); }
.fact.ai-review-fact .icon { color: var(--thread); }
.fact.ready .icon { color: var(--ready); }

.agenda { max-height: min(49vh, 560px); overflow: auto; border-top: 1px solid var(--line-strong); background: var(--surface); }
.agenda-head, .agenda-row {
  display: grid;
  grid-template-columns: 42px minmax(240px, 1.6fr) 150px 120px 46px;
  align-items: center;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
}
.agenda-head { position: sticky; z-index: 2; top: 0; min-height: 42px; color: var(--muted); font-size: 12px; background: var(--paper); }
.agenda-head > *, .agenda-row > * { padding: 0 12px; min-width: 0; }
.agenda-row { position: relative; border-left: 4px solid transparent; transition: background .16s ease, border-color .16s ease; }
.agenda-row:hover, .agenda-row.selected { background: #f5f0e7; border-left-color: var(--thread); }
.agenda-row button.title-button { border: 0; background: transparent; text-align: left; padding: 0 12px; overflow: hidden; }
.agenda-row .title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 17px var(--serif); }
.agenda-row .path { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--faint); font: 10px var(--mono); margin-top: 3px; }
.row-number { color: var(--muted); font: 12px var(--mono); }
.row-menu { width: 44px; height: 44px; border: 0; background: transparent; font-size: 22px; }

.status-label { display: inline-flex; align-items: center; min-height: 26px; width: fit-content; padding: 2px 8px; border: 1px solid var(--line); border-radius: 3px; font-size: 12px; background: var(--paper); }
.status-label.bio_offen { background: var(--warning-soft); border-color: #dfb982; }
.status-label.ki_pruefen { color: var(--thread-dark); background: #f5d8d5; border-color: #d79b96; }
.status-label.blockiert { color: var(--thread-dark); background: #f5d8d5; border-color: #d79b96; }
.status-label.bereit { background: var(--ready-soft); border-color: #acba91; }
.status-label.entwurf { background: var(--mustard); border-color: #d8c789; }

.agenda-footer { border-bottom: 1px solid var(--line); background: var(--surface); padding: 8px 12px; }
.agenda-footer button { min-height: 42px; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--muted); }
.agenda-footer button:hover { color: var(--thread); }

.control-lower { max-width: 1500px; margin: 18px auto 0; display: grid; grid-template-columns: minmax(360px, .8fr) minmax(440px, 1.2fr); gap: 18px; }
.calendar-panel, .todo-panel { border: 1px solid var(--line); background: var(--surface); min-height: 420px; }
.panel-heading { min-height: 62px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font: 700 23px var(--serif); }
.panel-heading > span { color: var(--muted); font-size: 12px; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(34px, 1fr)); gap: 3px; padding: 14px 16px 9px; }
.calendar-weekday { min-height: 28px; display: grid; place-items: center; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.calendar-day {
  position: relative;
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 13px;
}
.calendar-day.other-month { color: #bbb4a9; }
.calendar-day.has-event { border-color: #ddd0b0; background: #f7efd8; font-weight: 700; }
.calendar-day.has-event:hover { border-color: var(--thread); background: #f4e4c0; }
.calendar-day.is-today { border-radius: 50%; background: var(--thread); color: white; border-color: var(--thread); }
.calendar-day .event-dot { position: absolute; bottom: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--thread); }
.calendar-day:disabled:not(.has-event) { cursor: default; opacity: .45; }
.calendar-events { display: grid; gap: 4px; padding: 8px 20px 16px; border-top: 1px solid var(--line); max-height: 142px; overflow: auto; }
.calendar-event { display: grid; grid-template-columns: 10px 70px 1fr; gap: 8px; align-items: center; min-height: 28px; font-size: 12px; }
.calendar-event i { width: 7px; height: 7px; border-radius: 50%; background: var(--thread); }
.calendar-event.newsletter i { background: var(--warning); }
.calendar-event time { color: var(--muted); font: 11px var(--mono); }

.todo-list { display: grid; }
.todo-item { display: grid; grid-template-columns: 28px 1fr 24px; gap: 8px; align-items: start; min-height: 68px; padding: 12px 16px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; font: inherit; text-align: left; color: inherit; }
.todo-item:hover, .todo-item:focus-visible { background: #f5f0e7; }
.todo-item .icon { width: 19px; height: 19px; color: var(--warning); margin-top: 2px; }
.todo-item strong { display: block; font-size: 14px; }
.todo-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.todo-item .chevron { color: var(--muted); font-size: 20px; }
.empty-state { padding: 28px; color: var(--muted); text-align: center; }

/* Heute: verdichtetes Cockpit mit klarer Reihenfolge Jetzt → Woche → Kontext. */
body.view-control .control-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  align-content: start;
  gap: 20px;
  max-width: 1800px;
  margin: 0 auto;
}
body.view-control .week-section { max-width: none; min-width: 0; }
body.view-control .section-heading { margin-bottom: 20px; }
body.view-control .section-heading p { font-size: 14px; }
.now-panel { min-height: 0; margin-bottom: 20px; border: 1px solid var(--line-strong); }
.now-panel .panel-heading { min-height: 54px; }
.now-panel .panel-heading h2, .subsection-heading h2 { font-size: 25px; }
.now-panel .todo-list { max-height: 258px; overflow: auto; }
.now-panel .todo-item { min-height: 72px; padding: 12px 16px; }
.revision-panel .todo-list { max-height: 360px; }
.revision-stand { margin: 0; padding: 8px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.revision-item .row-number { margin-top: 3px; }
.revision-item p.revision-markers { color: var(--warning); font-weight: 600; }
.week-agenda-section { border: 1px solid var(--line); background: var(--surface); }
.subsection-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.subsection-heading h2 { margin: 0; font-family: var(--serif); }
.subsection-heading span { color: var(--muted); font-size: 12px; }
body.view-control .agenda { max-height: min(42vh, 460px); border-top: 0; }
body.view-control .control-lower { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: 1fr; align-content: start; gap: 16px; max-width: none; margin: 0; }
.status-panel { border: 1px solid var(--line); background: var(--surface); }
.status-panel .fact-strip { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.status-panel .fact { min-height: 48px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.status-panel .fact:last-child { border-bottom: 0; }
body.view-control .calendar-panel { min-height: 0; }
body.view-control .calendar-events { max-height: 118px; }

.workspace-dialog { width: min(620px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); }
.workspace-dialog::backdrop { background: rgba(33,31,27,.42); }
.workspace-dialog form { display: grid; gap: 14px; padding: 20px; }
.workspace-dialog .dialog-heading { align-items: start; }
.workspace-dialog .dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.workspace-dialog input { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface-strong); color: var(--ink); }
.workspace-list { display: grid; gap: 6px; max-height: 240px; overflow: auto; }
.workspace-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); text-align: left; }
.workspace-item:hover { border-color: var(--thread); background: #fff9f2; }
.workspace-item.active { border-color: var(--ready); background: #f4f7ed; }
.workspace-item strong, .workspace-item small { display: block; }
.workspace-item strong { font-size: 14px; }
.workspace-item small { margin-top: 2px; color: var(--muted); font: 11px var(--mono); overflow-wrap: anywhere; }
.workspace-item em { flex: 0 0 auto; color: var(--ready); font-size: 12px; font-style: normal; }

@media (max-width: 1320px) {
  body.view-control .control-view { grid-template-columns: 1fr; }
  body.view-control .control-lower { grid-column: 1; grid-row: auto; grid-template-columns: minmax(0, 1fr) minmax(320px, .75fr); }
  body.view-control .status-panel { grid-column: 1; }
  body.view-control .calendar-panel { grid-column: 2; grid-row: 1 / span 2; }
}

/* Wall screen */
body.view-wall .app-shell { grid-template-columns: 1fr; }
body.view-wall .topbar { grid-template-columns: 250px minmax(280px, 720px) 1fr; }
body.view-wall .sidebar { display: none; }
/* Links die Liste aller Texte, rechts roter Faden und Text, dazwischen der
   ziehbare Trenner (--graph-height wird aus wall.mjs gesetzt). */
.wall-view { grid-column: 1; grid-row: 2; min-width: 0; min-height: 0; display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-rows: var(--graph-height, 40%) 7px minmax(0, 1fr);
  background: var(--paper); }

.document-browser { grid-column: 1; grid-row: 1 / -1; min-height: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 12px 0; border-right: 1px solid var(--line-strong); background: var(--surface); }
.browser-heading { display: flex; align-items: baseline; justify-content: space-between; }
.browser-heading h2 { font-family: var(--serif); font-size: 17px; }
.browser-heading span { color: var(--muted); font: 600 11px var(--mono); }
.document-browser input[type="search"] { min-height: 32px; padding: 0 9px; border: 1px solid var(--line-strong); background: var(--surface-strong); font-size: 13px; }
.browser-toggle { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; cursor: pointer; }
.browser-list { flex: 1; min-height: 0; overflow: auto; margin: 0 -12px; padding: 0 6px 12px; }
.browser-item { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 7px 8px; border: 0; border-left: 3px solid transparent;
  background: none; text-align: left; cursor: pointer; }
.browser-item:hover { background: var(--surface-strong); }
.browser-item.active { border-left-color: var(--thread); background: var(--surface-strong); }
.browser-item strong { font-size: 13px; font-weight: 600; line-height: 1.3; }
.browser-item small { color: var(--muted); font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; }

.pane-splitter { grid-column: 2; grid-row: 2; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
  background: var(--surface); cursor: row-resize; }
.pane-splitter:hover, .pane-splitter.dragging { background: var(--thread); }
.pane-splitter:focus-visible { outline: 2px solid var(--thread); outline-offset: -2px; }

.graph-section { grid-column: 2; grid-row: 1; min-height: 0; display: grid; grid-template-rows: 72px minmax(0, 1fr); }
.graph-section.collapsed { overflow: hidden; }
.graph-toolbar { padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.graph-toolbar h1 { color: var(--thread); font-size: 34px; }
.graph-toolbar p { margin-top: 2px; font-size: 12px; }
.graph-actions { display: flex; gap: 8px; }
.graph-depth-control { display: flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 11px; }
.graph-depth-control select { min-height: 32px; border: 0; border-left: 1px solid var(--line); padding: 0 18px 0 8px; background: transparent; color: var(--ink); font: 600 12px var(--mono); }
.graph-depth-control select:focus-visible { outline: 2px solid var(--thread); outline-offset: 2px; }

.graph-stage { position: relative; min-height: 0; overflow: hidden; background-color: #f7f3eb; cursor: grab; touch-action: none; }
.graph-stage.panning { cursor: grabbing; }
.thread-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.thread-layer line { stroke: var(--thread); stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.thread-layer line.verlinkt_von { stroke-dasharray: 7 5; opacity: .72; }
.thread-layer line.geplant { stroke: var(--muted); stroke-dasharray: 3 5; opacity: .74; }
.thread-layer line.vorheriger, .thread-layer line.naechster { stroke: var(--thread); stroke-width: 2.8; }
.thread-layer line.vorheriger { opacity: .5; }
.graph-nodes { position: absolute; inset: 0; transform: scale(1); transform-origin: 0 0; }
.graph-nodes.zoom-76 { transform: scale(.76); }
.graph-nodes.zoom-84 { transform: scale(.84); }
.graph-nodes.zoom-92 { transform: scale(.92); }
.graph-nodes.zoom-108 { transform: scale(1.08); }
.graph-nodes.zoom-116 { transform: scale(1.16); }
.graph-nodes.zoom-124 { transform: scale(1.24); }
.graph-nodes.zoom-128 { transform: scale(1.28); }
.graph-node {
  position: absolute;
  width: 154px;
  height: 98px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 10px 8px;
  border: 1px solid #d4cab9;
  border-radius: 2px;
  background: #fffdf7;
  box-shadow: 0 5px 12px rgba(53, 43, 31, .10);
  text-align: center;
  transition: border-color .16s ease, transform .16s ease;
  cursor: grab;
  touch-action: none;
}
.graph-node.dragging { cursor: grabbing; z-index: 6; transition: none; box-shadow: 0 10px 22px rgba(53, 43, 31, .22); }
.graph-node:nth-child(1) { left: 50%; top: 49%; }
.graph-node:nth-child(2) { left: 15%; top: 16%; }
.graph-node:nth-child(3) { left: 38%; top: 16%; }
.graph-node:nth-child(4) { left: 62%; top: 16%; }
.graph-node:nth-child(5) { left: 85%; top: 16%; }
.graph-node:nth-child(6) { left: 10%; top: 49%; }
.graph-node:nth-child(7) { left: 30%; top: 49%; }
.graph-node:nth-child(8) { left: 70%; top: 49%; }
.graph-node:nth-child(9) { left: 90%; top: 49%; }
.graph-node:nth-child(10) { left: 15%; top: 82%; }
.graph-node:nth-child(11) { left: 38%; top: 82%; }
.graph-node:nth-child(12) { left: 62%; top: 82%; }
.graph-node:nth-child(13) { left: 85%; top: 82%; }
.graph-node::before { content: ""; position: absolute; top: -8px; width: 13px; height: 13px; border-radius: 50%; background: #27231e; box-shadow: 0 2px 4px rgba(0,0,0,.28); }
.graph-node:hover { border-color: var(--thread); transform: translate(-50%, -50%) scale(1.03); }
.graph-node.selected { width: 168px; height: 110px; border: 2px solid var(--thread); box-shadow: 0 0 0 3px rgba(166, 33, 27, .13), 0 5px 12px rgba(53, 43, 31, .10); }
.graph-node.selected::before { background: var(--thread); }
.graph-node strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 3; font: 700 15px/1.16 var(--serif); }
.graph-node small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; text-transform: capitalize; }
.graph-node .icon { width: 15px; height: 15px; }
.graph-node.kind-newsletter { background: #fffaf1; }
.graph-node.kind-funnel { background: #f2f4e9; }
.graph-node.kind-planung { background: #f1ede4; border-style: dashed; }
.graph-nodes.expanded .graph-node { width: 118px; min-height: 76px; height: auto; padding: 9px 8px 7px; }
.graph-nodes.expanded .graph-node.selected { width: 132px; min-height: 86px; }
.graph-nodes.expanded .graph-node strong { font-size: 13px; }
.graph-nodes.expanded .graph-node small { font-size: 10px; }

.graph-legend { position: absolute; left: 14px; bottom: 13px; width: 162px; display: grid; gap: 8px; padding: 11px; border: 1px solid var(--line); background: rgba(255,253,248,.94); font-size: 10px; }
.graph-legend strong { font-size: 11px; }
.graph-legend span { display: flex; align-items: center; gap: 8px; }
.graph-legend .line { display: block; width: 26px; border-top: 2px solid var(--thread); }
.graph-legend .backlink { border-top-style: dashed; }
.graph-legend .planned { border-top-color: var(--muted); border-top-style: dotted; }
.graph-legend .sequence { border-top-width: 2.6px; }
.zoom-controls { position: absolute; right: 14px; bottom: 13px; display: flex; border: 1px solid var(--line-strong); background: var(--surface); }
.zoom-controls button { width: 43px; height: 42px; border: 0; background: transparent; }
.zoom-controls button:hover { background: #eee9df; }
.zoom-controls output { min-width: 55px; display: grid; place-items: center; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font: 11px var(--mono); }

.document-section { grid-column: 2; grid-row: 3; min-height: 0; overflow: hidden; display: grid; grid-template-rows: 50px minmax(0, 1fr); background: var(--surface-strong); }
.document-toolbar { border-bottom: 1px solid var(--line); padding: 0 16px; }
.document-path, .save-state, .editor-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.document-path { flex: 1; color: var(--muted); font: 12px var(--mono); overflow: hidden; }
.document-path span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { color: var(--muted); font-size: 11px; }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ready); }
.save-state.dirty .save-dot { background: var(--warning); }
.save-state.error .save-dot { background: var(--thread); }
.editor-actions { justify-content: flex-end; }
.mode-switch, .history-actions { display: flex; }
.segmented { min-height: 36px; border-color: var(--line-strong); }
.segmented.active { background: var(--ink); color: white; }
.history-actions .quiet-button { min-height: 36px; min-width: 36px; justify-content: center; font-size: 17px; }
.history-actions .quiet-button:disabled { opacity: .35; cursor: default; }
.autosave-toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.autosave-toggle input { accent-color: var(--thread); width: 17px; height: 17px; }
.document-toolbar .save-button { min-height: 36px; }
.document-toolbar .document-action { min-height: 36px; white-space: nowrap; }
.document-toolbar .document-action .icon { width: 17px; height: 17px; }

.document-workspace { min-height: 0; height: 100%; overflow: hidden; display: grid; grid-template-columns: minmax(320px, .95fr) minmax(360px, 1.15fr) 260px; }
.markdown-preview { min-width: 0; min-height: 0; height: 100%; overflow: auto; border-right: 1px solid var(--line); padding: 18px 24px 48px; background: var(--surface-strong); }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 { font-family: var(--serif); letter-spacing: -.02em; }
.markdown-preview h1 { margin: 0 0 18px; font-size: 30px; line-height: 1.1; }
.markdown-preview h2 { clear: both; margin: 28px 0 10px; font-size: 21px; }
.markdown-preview h3 { margin: 22px 0 8px; font-size: 18px; }
.markdown-preview p, .markdown-preview li { max-width: 72ch; line-height: 1.65; }
.markdown-preview blockquote { margin: 20px 0; padding: 8px 16px; border-left: 3px solid var(--thread); color: var(--muted); }
.markdown-preview .article-table-scroll, .rich-editor .article-table-scroll { max-width: 72ch; margin: 22px 0 28px; overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.markdown-preview .article-table, .rich-editor .article-table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.markdown-preview .article-table th, .markdown-preview .article-table td, .rich-editor .article-table th, .rich-editor .article-table td { padding: 10px 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.markdown-preview .article-table th:last-child, .markdown-preview .article-table td:last-child, .rich-editor .article-table th:last-child, .rich-editor .article-table td:last-child { border-right: 0; }
.markdown-preview .article-table tr:last-child td, .rich-editor .article-table tr:last-child td { border-bottom: 0; }
.markdown-preview .article-table th, .rich-editor .article-table th { background: #eee9df; font-weight: 700; }
.markdown-preview .article-table tbody tr:nth-child(even), .rich-editor .article-table tbody tr:nth-child(even) { background: #faf7f0; }
.markus-insert { max-width: 72ch; margin: 26px 0; padding: 14px 18px 10px; border-left: 4px solid var(--ready); background: var(--ready-soft); }
.markus-insert-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.markus-insert-heading strong { font: 700 18px var(--serif); }
.markus-insert-heading span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
.markus-insert p { margin: 7px 0; }
.markdown-preview code { padding: 1px 4px; background: #eee9df; font-family: var(--mono); font-size: .9em; }
.markdown-preview pre { overflow: auto; padding: 14px; background: #27241f; color: #f8f3e8; }
.markdown-preview pre code { padding: 0; background: none; color: inherit; }
.markdown-preview a { color: var(--thread-dark); text-underline-offset: 3px; }
.unsafe-link { color: var(--thread); text-decoration: line-through; }

.goodie-card {
  margin: 26px 0;
  padding: 16px 20px 14px;
  max-width: 72ch;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--thread);
  border-radius: 6px;
}
.goodie-card .goodie-eyebrow { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.goodie-card .goodie-titel { margin: 4px 0 6px; font-family: var(--serif); font-size: 19px; letter-spacing: -.01em; }
.goodie-card .goodie-text { margin: 0 0 12px; }
.goodie-card .goodie-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 0; }
.goodie-card .goodie-button { display: inline-block; padding: 7px 14px; background: var(--thread); color: #fff; text-decoration: none; border-radius: 4px; font-weight: 600; }
.goodie-card .goodie-button:hover { background: var(--thread-dark); }
.goodie-card .goodie-cta { color: var(--thread-dark); }
.goodie-card .goodie-file { margin: 10px 0 0; font-family: var(--mono); font-size: 12px; color: var(--faint); }
.goodie-card .goodie-image-link { display: inline-block; margin: 0 0 12px; }
.goodie-card .goodie-image { display: block; max-width: 340px; max-height: 260px; width: auto; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.goodie-card .goodie-image-figure { margin: 0 0 12px; }
.goodie-card .goodie-image-figure figcaption,
.markdown-preview .article-image figcaption { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.markdown-preview .article-image { margin: 18px 0 26px; }
.markdown-preview .article-image img { display: block; max-width: min(100%, 720px); max-height: 560px; width: auto; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.markdown-preview .article-image--float { max-width: min(42%, 320px); margin-top: 4px; margin-bottom: 18px; }
.markdown-preview .article-image--right { float: right; margin-left: 24px; }
.markdown-preview .article-image--left { float: left; margin-right: 24px; }
.markdown-preview .article-image--float img { max-width: 100%; max-height: 360px; }
.markdown-preview::after { content: ""; display: block; clear: both; }
.markdown-preview .material-image { display: block; margin: 12px 0; max-width: min(100%, 480px); height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }

.editor-pane { position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; display: grid; grid-template-columns: 48px minmax(0, 1fr); background: #fbfaf6; }
.line-numbers { height: 100%; overflow: hidden; padding: 57px 9px 40px 0; border-right: 1px solid var(--line); color: #b1aa9f; text-align: right; font: 13px/1.65 var(--mono); user-select: none; white-space: pre; }
.editor-column { min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.editor-format-toolbar { min-height: 42px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow: auto; padding: 5px 9px; border-bottom: 1px solid var(--line); background: #f2efe8; }
.format-group { display: flex; align-items: center; gap: 4px; }
.format-divider { width: 1px; height: 23px; background: var(--line-strong); }
.format-button { min-width: 31px; min-height: 29px; padding: 3px 8px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--ink); font-size: 12px; }
.format-button:hover:not(:disabled), .format-button:focus-visible { border-color: var(--line-strong); background: var(--surface); }
.format-button:disabled { opacity: .45; cursor: not-allowed; }
.format-button.marker-button { color: var(--thread-dark); border-color: #d9b0aa; background: #f9e9e6; }
.format-button.marker-button:hover:not(:disabled), .format-button.marker-button:focus-visible { background: #f5d8d5; }
.format-button.image-button { color: var(--thread-dark); border-color: #c8c0ad; background: #eee9df; }
.format-button.image-button:hover:not(:disabled), .format-button.image-button:focus-visible { background: #e3dccd; }
.asset-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); }
.asset-dialog::backdrop { background: rgb(31 38 36 / 42%); }
.asset-dialog-form { display: grid; gap: 14px; padding: 22px; }
.asset-dialog-form h2 { margin: 0; font-family: var(--serif); font-size: 21px; }
.asset-dialog-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.asset-dialog-form input[type="file"],
.asset-dialog-form input[type="text"] { width: 100%; box-sizing: border-box; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink); font: inherit; }
.asset-dialog-form textarea { width: 100%; box-sizing: border-box; padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; color: var(--ink); font: inherit; resize: vertical; min-height: 62px; }
.asset-dialog-hint { margin: -4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.asset-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.goodie-dialog { width: min(640px, calc(100vw - 32px)); }
.goodie-dialog-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .goodie-dialog-row { grid-template-columns: 1fr; } }
.goodie-file-actions { display: flex; justify-content: flex-end; margin: -8px 0 0; }
.material-library-dialog { width: min(1180px, calc(100vw - 28px)); height: min(820px, calc(100vh - 28px)); max-width: none; max-height: none; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink); overflow: hidden; }
.material-library-dialog::backdrop { background: rgb(31 38 36 / 48%); }
html:has(.material-library-dialog[open]), body:has(.material-library-dialog[open]) { overflow: hidden; }
.material-library-shell { height: 100%; min-height: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr); }
.material-library-header { display: flex; align-items: start; justify-content: space-between; gap: 24px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.material-library-header h2 { margin: 2px 0 4px; font: 700 28px/1.1 var(--serif); letter-spacing: -.02em; }
.material-library-header p { margin: 0; color: var(--muted); font-size: 13px; }
.material-library-header .material-library-eyebrow { color: var(--thread-dark); font-size: 10px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.material-library-header-actions { display: flex; align-items: center; gap: 8px; }
.material-library-controls { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(140px, .6fr)); gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: #f5f1e9; }
.material-library-controls label { display: grid; gap: 5px; min-width: 0; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.material-library-controls input, .material-library-controls select { width: 100%; min-height: 40px; box-sizing: border-box; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface); color: var(--ink); padding: 0 10px; font: 13px var(--sans); }
.material-library-controls input:focus, .material-library-controls select:focus { outline: 2px solid color-mix(in srgb, var(--thread) 35%, transparent); outline-offset: 1px; }
.material-library-meta { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.material-library-meta p { margin: 0; }
.material-library-grid { min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); grid-auto-rows: max-content; align-content: start; gap: 12px; padding: 16px 24px 28px; }
.material-card { min-width: 0; min-height: 277px; display: grid; grid-template-rows: 150px minmax(88px, auto) auto; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); overflow: hidden; }
.material-card-media { position: relative; display: grid; place-items: center; min-height: 0; padding: 10px; border-bottom: 1px solid var(--line); background: #efede6; overflow: hidden; }
.material-card-media img { display: block; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.material-card-media.is-missing img { display: none; }
.material-card-fallback { display: none; color: var(--faint); font: 11px var(--mono); text-align: center; }
.material-card-media.is-missing .material-card-fallback { display: block; }
.material-card-filetype { width: 62px; height: 76px; display: grid; place-items: end center; padding-bottom: 12px; border: 1px solid #b8ad9d; background: #fbfaf6; color: var(--thread-dark); font: 750 13px var(--sans); letter-spacing: .08em; box-shadow: 5px 5px 0 #dcd5c9; }
.material-card-copy { min-width: 0; padding: 11px 12px 10px; }
.material-card-copy h3 { display: -webkit-box; overflow: hidden; margin: 0 0 6px; font: 650 14px/1.3 var(--sans); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.material-card-copy p { overflow: hidden; margin: 0; color: var(--faint); font: 10px/1.35 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.material-card-badge { position: absolute; top: 8px; left: 8px; padding: 3px 6px; border: 1px solid rgb(112 99 80 / 20%); border-radius: 999px; background: rgb(251 250 246 / 92%); color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.material-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.material-card-actions.one-action { grid-template-columns: 1fr; }
.material-card-actions button { min-height: 36px; border: 0; background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 650; }
.material-card-actions button:hover, .material-card-actions button:focus-visible { background: #ece6db; color: var(--thread-dark); }
.material-library-empty { grid-column: 1 / -1; padding: 52px 20px; border: 1px dashed var(--line-strong); color: var(--muted); text-align: center; }
.editor-pane textarea { width: 100%; height: 100%; min-height: 0; overflow: auto; resize: none; border: 0; outline: 0; padding: 15px 18px 40px; background: transparent; color: var(--ink); font: 14px/1.65 var(--mono); tab-size: 2; }
.editor-pane textarea:disabled { color: var(--muted); }

.relation-inspector { min-width: 0; min-height: 0; height: 100%; overflow: auto; border-left: 1px solid var(--line); background: #faf8f2; padding: 10px; }
.inspector-section { border: 1px solid var(--line); background: var(--surface); margin-bottom: 9px; }
.inspector-section h3 { margin: 0; min-height: 36px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; border-bottom: 1px solid var(--line); font: 650 12px var(--sans); }
.inspector-section ul { list-style: none; margin: 0; padding: 5px 10px 8px; }
.inspector-section li { padding: 5px 0; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inspector-section .empty { color: var(--faint); font-style: italic; }
.inspector-section .warning-item { color: var(--thread-dark); }
.placeholder-list li { padding: 0; white-space: normal; }
.placeholder-jump {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 8px;
  align-items: start;
  min-height: 42px;
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
}
.placeholder-jump:hover, .placeholder-jump:focus-visible { color: var(--thread-dark); background: #f5f0e7; }
.placeholder-jump strong { color: var(--thread-dark); font-size: 11px; }
.placeholder-jump span { justify-self: end; color: var(--muted); font: 10px var(--mono); }
.placeholder-jump small { grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 13px 16px; border: 1px solid var(--ink); background: var(--ink); color: white; border-radius: 3px; box-shadow: 0 8px 20px rgba(0,0,0,.16); }
.toast.error { background: var(--thread-dark); border-color: var(--thread-dark); }
.prompt-dialog { width: min(720px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line-strong); background: var(--surface-strong); color: var(--ink); border-radius: 4px; }
.prompt-dialog::backdrop { background: rgba(33,31,27,.42); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font: 700 24px var(--serif); }
.dialog-field { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.prompt-dialog input, .prompt-dialog textarea { width: 100%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 3px; }
.prompt-dialog input { min-height: 42px; padding: 0 12px; }
.prompt-dialog textarea { height: min(42vh, 360px); resize: vertical; padding: 12px; font: 13px/1.55 var(--mono); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.loading-line { height: 58px; border-bottom: 1px solid var(--line); background: #f1ede5; animation: pulse 1.2s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .5; } to { opacity: 1; } }

body.layout-single .companion-button span { min-width: 86px; }
body.layout-single .wall-view { grid-template-rows: var(--graph-height, 34%) 7px minmax(0, 1fr); }
body.layout-single .control-view { padding-top: 20px; }

@media (max-width: 1180px) {
  :root { --sidebar-width: 190px; }
  .topbar { grid-template-columns: var(--sidebar-width) minmax(260px, 1fr) auto; }
  .top-actions .quiet-button span { display: none; }
  .control-lower { grid-template-columns: 1fr; }
  .document-workspace { grid-template-columns: 1fr 1fr; }
  .relation-inspector { display: none; }
}

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; grid-template: 62px auto 1fr / 1fr; }
  .topbar { grid-column: 1; grid-template-columns: 1fr auto; padding: 0 10px; }
  .brand { border: 0; padding: 0 8px; font-size: 22px; }
  .global-search-wrap { grid-column: 1 / -1; position: fixed; z-index: 50; left: 8px; right: 8px; top: 68px; margin: 0; display: none; }
  .global-search-wrap.mobile-open { display: flex; }
  .top-actions { padding: 0; }
  .top-actions .quiet-button:first-child { display: none; }
  .sidebar { grid-column: 1; grid-row: 2; border: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .main-nav { display: flex; padding: 6px 8px; overflow-x: auto; }
  .main-nav a { min-width: 52px; justify-content: center; padding: 0 12px; }
  .main-nav a span { display: none; }
  .sidebar-tools, .sidebar-recent { display: none; }
  .control-view { grid-column: 1; grid-row: 3; overflow: visible; padding: 22px 12px 40px; }
  .section-heading h1 { font-size: 38px; }
  .section-heading .outline-button { font-size: 0; width: 44px; padding: 0; }
  .section-heading .outline-button .icon { margin: 0; }
  .agenda { overflow-x: auto; }
  .agenda-head, .agenda-row { min-width: 720px; }
  .control-lower { grid-template-columns: 1fr; }
  .calendar-panel, .todo-panel { min-height: 0; }
  body.view-wall .app-shell { display: grid; grid-template: 62px minmax(0, 1fr) / 1fr; height: 100vh; }
  body.view-wall .topbar { grid-template-columns: 1fr auto; }
  /* Schmale Fenster: Textliste über die Kopfzeilensuche erreichbar, der
     Arbeitsbereich bekommt die ganze Breite. */
  .wall-view { grid-row: 2; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--graph-height, 40%) 7px minmax(0, 1fr); }
  .document-browser { display: none; }
  .graph-section, .pane-splitter, .document-section { grid-column: 1; }
  .graph-toolbar { padding: 0 12px; }
  .graph-toolbar h1 { font-size: 27px; }
  .graph-toolbar p, .graph-actions .outline-button:first-child { display: none; }
  .graph-node { width: 120px; min-height: 80px; }
  .graph-node strong { font-size: 15px; }
  .graph-legend { display: none; }
  .document-toolbar { padding: 0 8px; }
  .save-state, .autosave-toggle, .segmented, .document-toolbar .document-action .icon { display: none; }
  .document-toolbar .document-action { min-width: 0; padding: 0 8px; font-size: 12px; }
  .document-workspace { grid-template-columns: 1fr; }
  .markdown-preview { display: none; }
  .editor-pane { display: grid; }
  .material-library-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .material-library-header { padding: 16px; }
  .material-library-controls { grid-template-columns: 1fr 1fr; padding: 12px 16px; }
  .material-search { grid-column: 1 / -1; }
  .material-library-meta { padding: 0 16px; }
  .material-library-meta p:last-child { display: none; }
  .material-library-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding: 12px 16px 20px; }
}

@media (max-width: 520px) {
  .material-library-header { gap: 10px; }
  .material-library-header-actions { align-items: flex-end; flex-direction: column-reverse; }
  .material-library-controls { grid-template-columns: 1fr; }
  .material-search { grid-column: auto; }
  .material-library-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .material-card { grid-template-rows: 120px minmax(84px, auto) auto; }
  .material-card-actions { grid-template-columns: 1fr; }
}

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

/* ── Drip-Fahrplan (view=funnel) ─────────────────────────────────────────── */
.funnel-view {
  grid-column: 2; grid-row: 2; min-width: 0; min-height: 0;
  display: grid; grid-template-columns: 224px minmax(0, 1fr) 404px;
  background: var(--paper);
}
.funnel-side, .funnel-detail { min-height: 0; background: var(--surface); }
.funnel-side { padding: 18px 16px; border-right: 1px solid var(--line); overflow: auto; }
.funnel-eyebrow { margin: 0 0 5px; color: var(--muted); font: 700 10px var(--sans); letter-spacing: .09em; text-transform: uppercase; }
.funnel-side-title { margin: 0; font: 700 18px var(--serif); }
.funnel-filters { display: grid; gap: 8px; margin-top: 16px; }
.funnel-filter { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: start; padding: 9px 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); cursor: pointer; }
.funnel-filter input { margin: 2px 0; accent-color: var(--thread); }
.funnel-filter b { display: block; font-size: 12px; }
.funnel-filter small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.funnel-count { padding: 2px 5px; height: fit-content; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font: 10px var(--mono); }
.funnel-legend { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.funnel-legend h2 { margin: 0 0 10px; font: 700 13px var(--serif); }
.funnel-lr { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); font-size: 11px; }
.funnel-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ready); }
.funnel-dot.warn { background: var(--warning); }
.funnel-dot.offer { background: var(--thread); }
.funnel-sq { width: 9px; height: 9px; border-radius: 2px; border: 1.5px solid var(--thread); background: var(--surface); }
.funnel-star { color: var(--thread); }
.funnel-note { margin-top: 18px; padding: 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.45; }

.funnel-board { min-width: 0; min-height: 0; display: grid; grid-template-rows: 46px minmax(0, 1fr); }
.funnel-tools { display: flex; align-items: center; gap: 12px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }

/* Versandplan: Linsen-Umschalter */
.vp-lens { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.vp-lens button { padding: 6px 12px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 600 12px var(--sans); }
.vp-lens button:last-child { border-right: 0; }
.vp-lens button.on { background: var(--thread); color: #fff; }

/* Versandplan: Fließ-Layout (Kalender + Video) statt horizontaler Spuren */
.vp-flow { padding: 16px; display: grid; gap: 12px; align-content: start; }
.nl-month { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); overflow: hidden; }
.nl-month-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper); }
.nl-month-label { font: 700 14px var(--serif); }
.nl-ziel { padding: 2px 8px; border-radius: 10px; font-size: 10px; color: #3a352c; }
.nl-swatch { width: 11px; height: 11px; border-radius: 3px; }
.zg-privat, .nl-swatch.zg-privat { background: #e3ccc8; } .nl-ziel.zg-privat { background: #eddcd8; }
.zg-beruf, .nl-swatch.zg-beruf { background: #cdd8c2; } .nl-ziel.zg-beruf { background: #dde7d1; }
.zg-trainer, .nl-swatch.zg-trainer { background: #d8cdb0; } .nl-ziel.zg-trainer { background: #e7dcbf; }
.zg-alle, .nl-swatch.zg-alle { background: #d2cdc2; } .nl-ziel.zg-alle { background: #e2ddd2; }
.nl-editions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 12px; }
@media (max-width: 1180px) { .nl-editions { grid-template-columns: 1fr; } }
.nl-videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.nl-card { display: grid; gap: 5px; padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--ready); border-radius: 3px; background: var(--surface); text-align: left; min-height: 62px; }
.nl-card.b { border-left-color: var(--muted); }
.nl-card.video { border-left-color: var(--warning); }
.nl-card:hover { border-color: var(--thread); background: #fff9f2; }
.nl-card.sel { box-shadow: var(--focus); border-color: var(--thread); }
.nl-card.nl-empty { color: var(--faint); font-size: 11px; align-items: center; justify-content: center; border-style: dashed; border-left-style: dashed; background: transparent; }
.nl-card-kind { color: var(--muted); font: 10px var(--mono); text-transform: uppercase; letter-spacing: .04em; }
.nl-card-subject { font: 600 13px/1.3 var(--serif); color: var(--ink); }
.nl-card-badges { display: flex; gap: 4px; min-height: 12px; }
.nl-flag-plan { padding: 0 4px; height: 12px; display: inline-flex; align-items: center; border: 1px dashed var(--muted); border-radius: 2px; color: var(--muted); font: 8px var(--mono); }
.funnel-chip { padding: 4px 7px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); }
.funnel-push { margin-left: auto; }
.funnel-scroll { min-height: 0; overflow: auto; }
.funnel-timeline { position: relative; min-height: 100%; padding-bottom: 24px; }
.funnel-axis { position: sticky; top: 0; z-index: 20; height: 58px; border-bottom: 1px solid var(--line); background: rgba(246, 243, 236, .97); }
.funnel-axis-name { position: absolute; left: 14px; top: 15px; width: 90px; color: var(--muted); font-size: 11px; line-height: 1.25; }
.funnel-axis-line { position: absolute; left: 190px; right: 32px; top: 33px; height: 1px; background: var(--ink); opacity: .55; }
.funnel-tick { position: absolute; top: 25px; width: 1px; height: 21px; background: var(--ink); opacity: .5; }
.funnel-tick span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); white-space: nowrap; color: var(--muted); font: 10px var(--mono); }
.funnel-guide { position: absolute; top: 58px; bottom: 0; width: 1px; background: #e0dacd; z-index: 1; pointer-events: none; }

.funnel-lane { position: relative; min-height: 150px; border-bottom: 1px solid var(--line); background: var(--paper); }
.funnel-lane:nth-child(even) { background: #f9f6f0; }
.funnel-lh { position: sticky; left: 0; z-index: 8; width: 120px; padding: 14px 12px; border-right: 1px solid var(--line); background: inherit; }
.funnel-lc { color: var(--thread); font: 700 10px var(--mono); }
.funnel-ln { margin-top: 5px; font: 700 15px/1.15 var(--serif); }
.funnel-lt { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.funnel-lane-open { margin-top: 7px; color: var(--warning); font-size: 10px; line-height: 1.3; }
.funnel-track { position: absolute; left: 190px; right: 32px; top: 30px; height: 2px; background: var(--line); }
.funnel-track::before { content: ""; position: absolute; inset: 0; background: var(--thread); opacity: .14; }

.funnel-sw { position: absolute; top: 25px; z-index: 5; }
.funnel-stem { position: absolute; left: 0; top: 6px; width: 1px; height: calc(var(--lv) * 40px + 17px); background: var(--line); }
.funnel-mark { position: absolute; left: -5px; top: 0; width: 11px; height: 11px; border: 2px solid var(--surface); border-radius: 50%; background: var(--ready); outline: 1px solid var(--ready); }
.funnel-sw.open .funnel-mark { background: var(--warning); outline-color: var(--warning); }
.funnel-sw.offer .funnel-mark { background: var(--thread); outline-color: var(--thread); }
.funnel-sw.ask .funnel-mark { border-radius: 2px; background: var(--surface); border-color: var(--thread); outline-color: var(--thread); }
.funnel-station { position: absolute; left: 0; top: calc(22px + var(--lv) * 40px); transform: translateX(-50%); min-height: 31px; display: grid; place-items: center; gap: 2px; padding: 4px 5px; border: 1px solid var(--line); border-top: 3px solid var(--ready); border-radius: 3px; background: var(--surface); white-space: nowrap; }
.funnel-sw.open .funnel-station { border-top-color: var(--warning); }
.funnel-sw.offer .funnel-station, .funnel-sw.ask .funnel-station { border-top-color: var(--thread); }
.funnel-station:hover, .funnel-station.sel { border-color: var(--thread); background: #fff9f2; }
.funnel-station.sel { box-shadow: var(--focus); }
.funnel-code { font: 700 11px var(--mono); }
.funnel-flags { display: flex; gap: 3px; min-height: 11px; }
.funnel-good, .funnel-warn, .funnel-role { display: inline-flex; height: 12px; align-items: center; justify-content: center; border-radius: 2px; font: 8px var(--mono); }
.funnel-good { padding: 0 3px; border: 1px solid var(--thread); color: var(--thread); }
.funnel-warn { width: 12px; background: var(--warning); color: var(--surface); font-weight: 800; }
.funnel-role { width: 12px; border: 1px solid var(--thread); color: var(--thread); font-weight: 800; }

.funnel-gap { position: absolute; top: 24px; width: 0; z-index: 4; }
.funnel-gap::before { content: ""; position: absolute; left: -5px; width: 10px; height: 10px; border: 1px dashed var(--warning); border-radius: 50%; background: var(--paper); }
.funnel-gap span { position: absolute; top: 18px; left: 0; transform: translateX(-50%); padding: 3px 5px; border: 1px dashed var(--warning); border-radius: 2px; background: var(--paper); color: var(--warning); font: 9px var(--mono); white-space: nowrap; }

.funnel-tip { position: fixed; z-index: 100; max-width: 290px; padding: 8px 10px; border: 1px solid var(--ink); border-radius: 3px; background: var(--ink); color: var(--surface); font-size: 11px; line-height: 1.35; pointer-events: none; }
.funnel-tip b { display: block; margin-bottom: 3px; font: 700 13px var(--serif); }

.funnel-detail { border-left: 1px solid var(--line); display: grid; grid-template-rows: auto auto minmax(0, 1fr); overflow: hidden; }
.funnel-detail-empty { padding: 28px 20px; color: var(--muted); font-size: 13px; }
.funnel-dh { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.funnel-dc { color: var(--thread); font: 700 11px var(--mono); }
.funnel-dt { margin-top: 5px; font: 700 21px/1.16 var(--serif); }
.funnel-status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.funnel-pill { padding: 3px 7px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); color: var(--muted); font-size: 10px; }
.funnel-pill.ok { border-color: var(--ready); color: var(--ready); }
.funnel-pill.bad { border-color: var(--warning); color: var(--warning); }
.funnel-open { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--thread); border-radius: 3px; background: #fff9f2; color: var(--thread); font: 650 12px var(--sans); }
.funnel-open + .funnel-open { margin-left: 8px; }
.funnel-open .icon { width: 16px; height: 16px; }
.funnel-meta { display: grid; grid-template-columns: 104px 1fr; gap: 7px 10px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 12px; }
.funnel-meta dt { color: var(--muted); }
.funnel-meta dd { margin: 0; min-width: 0; }
.funnel-mono { font-family: var(--mono); }
.funnel-link { display: inline-flex; padding: 4px 7px; border: 1px solid var(--thread); border-radius: 3px; background: #fff9f2; color: var(--thread); font: 11px var(--mono); text-decoration: none; }

.funnel-dm { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.funnel-dtab { display: flex; padding: 10px 18px 0; border-bottom: 1px solid var(--line); }
.funnel-dtab button { min-width: 108px; padding: 8px 10px; border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); }
.funnel-dtab button.on { border-color: var(--line); background: var(--surface); color: var(--thread); font-weight: 650; transform: translateY(1px); }
.funnel-dtab button:disabled { color: #aaa49a; }
.funnel-ds { min-height: 0; overflow: auto; padding: 16px 18px 24px; }
.funnel-mail { font: 15px/1.6 var(--serif); }
.funnel-loading { color: var(--muted); font-size: 12px; }
.funnel-opens { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.funnel-opens h3, .funnel-gh h3 { margin: 0 0 10px; font: 700 14px var(--serif); }
.funnel-olist { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.funnel-oi { display: flex; gap: 7px; align-items: center; padding: 7px 8px; border: 1px solid #dfc29d; border-radius: 3px; background: #fff9ef; color: #6e481f; font-size: 11px; }
.funnel-oi::before { content: "!"; flex: 0 0 15px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--warning); color: var(--surface); font-weight: 800; }
.funnel-open-prose { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.funnel-none { color: var(--ready); font-size: 12px; }

.funnel-gp { display: grid; gap: 12px; }
.funnel-gh { display: flex; align-items: start; gap: 10px; }
.funnel-gh p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.funnel-type { margin-left: auto; padding: 3px 6px; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); font: 9px var(--mono); white-space: nowrap; }
.funnel-stage { min-height: 420px; display: grid; place-items: center; padding: 10px; border: 1px solid var(--line); background: var(--paper); }
.funnel-goodie-img { max-width: 100%; max-height: 560px; border: 1px solid var(--line); background: var(--surface); }
.funnel-goodie-frame { width: 100%; height: 540px; border: 1px solid var(--line); background: var(--surface); }
.funnel-goodie-missing { padding: 24px; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.funnel-goodie-missing code { font: 11px var(--mono); color: var(--ink); }
.funnel-ctrl { display: flex; flex-wrap: wrap; gap: 8px; }
.funnel-btn { padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); color: var(--muted); text-decoration: none; font-size: 12px; }
.funnel-btn:hover { border-color: var(--thread); color: var(--thread); }

@media (max-width: 1180px) {
  .funnel-view { grid-template-columns: 200px minmax(0, 1fr) 340px; }
}

/* Schreiben im gerenderten Fenster: jeder Textblock ist ein eigenes Feld,
   gesperrte Blöcke (Goodie, Markus) sind als solche erkennbar. */
/* Schreibmodus: nur das gerenderte Fenster plus Beziehungen. Der
   Markdown-Editor erscheint erst, wenn jemand ihn ausdrücklich anfordert. */
body:not(.mode-markdown) .document-workspace { grid-template-columns: minmax(0, 1fr) 260px; }
body:not(.mode-markdown) .editor-pane { display: none; }
body:not(.mode-markdown) .markdown-preview { border-right: 0; padding: 22px 40px 64px; }
body:not(.mode-markdown) .markdown-preview p,
body:not(.mode-markdown) .markdown-preview li { max-width: 76ch; }

.rich-block { border-left: 3px solid transparent; padding-left: 9px; margin-left: -12px; }
.rich-editor.editing .rich-block[contenteditable]:hover { border-left-color: var(--line-strong); }
.rich-editor.editing .rich-block[contenteditable]:focus { outline: none; border-left-color: var(--thread); background: #fffdf8; }
.rich-block.locked { opacity: .92; }
.rich-editor.editing { caret-color: var(--thread); }

/* Light-Variante (Ronja): nur ihre Texte, ohne Redaktionsbetrieb */
.light [data-nav="funnel"] { display: none; }
.light #insertImageButton,
.light #insertGoodieImageButton,
.light #insertGoodieButton,
.light #titelbildButton,
.light #finishButton,
.light #uploadZipButton,
.light #todayUploadZipButton { display: none; }
/* Alles in einem Fenster: kein Zweitfenster, kein Cockpit-Wechsel */
.light #companionButton,
.light #singleWindowButton,
.light #wallBackButton,
.light #openControlButton,
.light [data-nav="control"],
.light .sidebar-tools,
.light .main-nav { display: none; }
/* Kalender und Veröffentlichungsplanung gehören nicht in ihre Variante */
.light .calendar-panel,
.light .status-panel,
.light .week-agenda-section,
.light .control-lower,
.light .inspector-section.scheduled { display: none; }
.light .sidebar { display: flex; flex-direction: column; }
