/* Weltenfeder — Schreibwerkstatt-Layout: Leiste links (Manuskript), Arbeitsfläche Mitte, Details rechts.
   Flechtengrün-Neutral + Lapisblau als Tinte, Bernstein für Markierungen. */
:root {
  --bg: #EEF0EA;
  --surface: #F8F9F5;
  --surface-2: #E5E9E1;
  --page: #FFFFFD;
  --ink: #1B231F;
  --muted: #5B665F;
  --line: #D4D9CF;
  --accent: #3150C4;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCE2F7;
  --amber: #A86E0C;
  --amber-soft: #F6E7C4;
  --rose: #B4413C;
  --rose-soft: #F5DCD9;
  --moss: #3B7A4D;
  --moss-soft: #D8EBDC;
  --violet: #7B4FB8;
  --violet-soft: #E9DFF6;
  --st-idee: #8A8F9C;
  --st-entwurf: #B07812;
  --st-ueber: #3150C4;
  --st-fertig: #3B7A4D;
  --shadow: 0 1px 2px rgba(22, 34, 28, .06), 0 10px 28px rgba(22, 34, 28, .09);
  --shadow-sm: 0 1px 2px rgba(22, 34, 28, .08);
  --f-display: "Cinzel", "Trajan Pro", "Times New Roman", serif;
  --f-text: "Literata", "Iowan Old Style", Georgia, serif;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  --ed-size: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1412; --surface: #161C19; --surface-2: #1F2723; --page: #141A17;
    --ink: #E2E7E1; --muted: #95A198; --line: #2A3430;
    --accent: #8FA3FF; --accent-ink: #0D1330; --accent-soft: #222B4E;
    --amber: #E3AE4A; --amber-soft: #3A2F16; --rose: #E57B72; --rose-soft: #3E2220;
    --moss: #7CC48F; --moss-soft: #1D3424; --violet: #B79AF0; --violet-soft: #2E2445;
    --st-idee: #8E94A3; --st-entwurf: #E3AE4A; --st-ueber: #8FA3FF; --st-fertig: #7CC48F;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1412; --surface: #161C19; --surface-2: #1F2723; --page: #141A17;
  --ink: #E2E7E1; --muted: #95A198; --line: #2A3430;
  --accent: #8FA3FF; --accent-ink: #0D1330; --accent-soft: #222B4E;
  --amber: #E3AE4A; --amber-soft: #3A2F16; --rose: #E57B72; --rose-soft: #3E2220;
  --moss: #7CC48F; --moss-soft: #1D3424; --violet: #B79AF0; --violet-soft: #2E2445;
  --st-idee: #8E94A3; --st-entwurf: #E3AE4A; --st-ueber: #8FA3FF; --st-fertig: #7CC48F;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 var(--f-ui); -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex: none; }
.icon-btn svg, .project-btn svg, .mini svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App-Gerüst ---------- */
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100%; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: .08em; white-space: nowrap; }
.brand .quill { width: 22px; height: 22px; fill: var(--accent); }
.project-btn {
  display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--bg);
  border-radius: 999px; padding: 4px 8px 4px 12px; max-width: 220px; min-width: 0;
}
.project-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.nav { display: flex; gap: 2px; overflow-x: auto; min-width: 0; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  border: 0; background: none; padding: 7px 11px; border-radius: 8px; white-space: nowrap;
  color: var(--muted); font-weight: 500;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.save-state { color: var(--muted); font-size: 12px; white-space: nowrap; margin-right: 4px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.only-narrow, .only-mid { display: none; }

.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--amber-soft); color: var(--ink); border-bottom: 1px solid var(--line); font-size: 13px;
}
.banner strong { font-weight: 600; }

.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr) 312px; min-height: 0; }
#binder, #inspector { background: var(--surface); overflow-y: auto; min-height: 0; }
#binder { border-right: 1px solid var(--line); padding-bottom: 32px; }
#inspector { border-left: 1px solid var(--line); padding-bottom: 40px; }
#view { overflow: auto; min-width: 0; min-height: 0; position: relative; outline: none; }
.scrim { display: none; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .only-mid { display: inline-grid; }
  #inspector {
    position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(340px, 92vw);
    transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .show-insp #inspector { transform: none; }
  .show-insp .scrim, .show-binder .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 14, 12, .35); z-index: 45; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .only-narrow { display: inline-grid; }
  .brand span { display: none; }
  .save-state { display: none; }
  .topbar { flex-wrap: wrap; }
  .nav { order: 5; flex-basis: 100%; }
  #binder {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; width: min(300px, 88vw);
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top, 0px); padding-left: env(safe-area-inset-left, 0px);
  }
  .show-binder #binder { transform: none; }
}

/* ---------- Binder ---------- */
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 16px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.mini { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.mini:hover { background: var(--surface-2); color: var(--ink); }
.mini svg { width: 15px; height: 15px; }
.tree { list-style: none; margin: 0; padding: 0 6px; }
.tree li { list-style: none; }
.row {
  display: flex; align-items: center; gap: 6px; width: 100%; border: 0; background: none; text-align: left;
  padding: 5px 8px; border-radius: 7px; color: var(--ink); min-width: 0;
}
.row:hover { background: var(--surface-2); }
.row.sel { background: var(--accent-soft); color: var(--accent); }
.row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .n { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row.chap { font-weight: 600; }
.row.chap .caret { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; fill: none; stroke: currentColor; stroke-width: 2; }
.row.chap.closed .caret { transform: rotate(-90deg); }
.row.scene { padding-left: 28px; }
.row.note { padding-left: 10px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--st-idee); }
.dot.entwurf { background: var(--st-entwurf); }
.dot.ueberarbeitet { background: var(--st-ueber); }
.dot.fertig { background: var(--st-fertig); }
.dot.idee { background: transparent; border: 1.5px solid var(--st-idee); }
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-into { background: var(--accent-soft) !important; }
.binder-foot { margin: 18px 16px 0; padding: 12px; border-radius: var(--radius); background: var(--bg); font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.binder-foot b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* ---------- Gemeinsame Bausteine ---------- */
.view-wrap {
  padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  max-width: 1200px; margin: 0 auto;
}
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.view-head h1 { font-family: var(--f-display); font-weight: 600; font-size: 26px; letter-spacing: .03em; margin: 0; text-wrap: balance; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
h2.sec { font-family: var(--f-display); font-size: 17px; font-weight: 600; letter-spacing: .04em; margin: 28px 0 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  padding: 7px 13px; border-radius: 8px; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--rose); }
.btn.danger[data-armed] { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--ink); white-space: nowrap;
}
button.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 500; }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--muted); }
.empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
  display: grid; gap: 10px; justify-items: center;
}
.empty h3 { margin: 0; color: var(--ink); font-family: var(--f-display); font-weight: 600; letter-spacing: .03em; }

label.f { display: grid; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
.field, .f input, .f textarea, .f select {
  width: 100%; border: 1px solid var(--line); background: var(--page); border-radius: 8px; padding: 7px 10px;
  color: var(--ink); font-size: 14px; font-weight: 400;
}
.f textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.f input:focus, .f textarea:focus, .f select:focus, .field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f .hint { font-weight: 400; font-size: 11px; }

/* ---------- Inspector ---------- */
.insp { display: grid; gap: 14px; padding: 16px; }
.insp .eyebrow { margin-bottom: -6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--page); padding: 7px 6px; font-size: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.snap { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--page); font-size: 12px; }
.snap .t { flex: 1; min-width: 0; }
.snap .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; font-weight: 600; }
.stat span { font-size: 11px; color: var(--muted); }

/* ---------- Editor ---------- */
.editor-wrap {
  padding-block: 22px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.ed-tools {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  max-width: 46em; margin: 0 auto 14px; padding: 6px; border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px);
}
.ed-tools .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tool { border: 0; background: none; min-width: 32px; height: 32px; border-radius: 7px; color: var(--muted); padding: 0 8px; font-weight: 600; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
.tool.on { background: var(--accent-soft); color: var(--accent); }
.ed-tools .grow { flex: 1; }
.ed-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.scene-title {
  display: block; width: 100%; max-width: 46em; margin: 0 auto 10px; text-align: center; border: 0; background: none;
  font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: .04em; color: var(--ink); padding: 6px;
}
.scene-title:focus { outline: none; box-shadow: 0 2px 0 var(--accent); }
.page {
  max-width: 46em; margin: 0 auto; background: var(--page); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow-sm); padding: 56px clamp(20px, 7vw, 72px) 72px; min-height: 60vh;
  font-family: var(--f-text); font-size: var(--ed-size); line-height: 1.75; outline: none;
  overflow-wrap: break-word; hyphens: auto;
}
.page:focus { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.page p, .page div { margin: 0; }
.page p + p, .page div + div, .page p + div, .page div + p { text-indent: 1.5em; }
.page hr { border: 0; height: 2.2em; margin: .6em 0; text-align: center; overflow: visible; }
.page hr::before { content: "✦   ✦   ✦"; white-space: pre; color: var(--muted); font-size: .8em; line-height: 2.8em; }
.page hr + p, .page hr + div { text-indent: 0; }
.page blockquote { margin: .8em 2em; font-style: italic; }
.page:empty::before { content: attr(data-ph); color: var(--muted); font-style: italic; }
.scriv + .scriv { margin-top: 0; }
.scriv .page { border-radius: 0; border-top: 0; min-height: 0; padding-top: 18px; padding-bottom: 28px; }
.scriv:first-of-type .page { border-top: 1px solid var(--line); border-radius: 4px 4px 0 0; padding-top: 48px; }
.scriv:last-of-type .page { border-radius: 0 0 4px 4px; padding-bottom: 72px; }
.scriv-head { max-width: 46em; margin: 0 auto; display: flex; align-items: center; gap: 8px; background: var(--page); border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 14px clamp(20px, 7vw, 72px) 0; font-size: 11px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.scriv:first-of-type .scriv-head { border-top: 1px solid var(--line); border-radius: 4px 4px 0 0; padding-top: 28px; }
.scriv:first-of-type .page { border-top: 0; border-radius: 0; padding-top: 18px; }
.scriv-head button { border: 0; background: none; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; padding: 0; }
.scriv-head button:hover { color: var(--accent); }
.chapter-head { text-align: center; margin: 4px auto 18px; max-width: 46em; }
.chapter-head .eyebrow { display: block; margin-bottom: 4px; }
.chapter-head h1 { font-family: var(--f-display); font-weight: 600; font-size: 28px; margin: 0; letter-spacing: .04em; text-wrap: balance; }

/* Stil-Lupe */
.style-panel { max-width: 46em; margin: 0 auto 14px; display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.style-top { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.read-score { display: flex; align-items: baseline; gap: 8px; }
.read-score b { font-size: 26px; font-variant-numeric: tabular-nums; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border: 1px solid var(--line); padding: 3px 10px 3px 8px; border-radius: 999px; cursor: pointer; background: var(--page); }
.legend input { margin: 0; accent-color: var(--accent); }
.legend i { width: 12px; height: 12px; border-radius: 3px; }
.mk-fill { background: var(--amber-soft); box-shadow: inset 0 -2px 0 var(--amber); }
.mk-rep { background: var(--violet-soft); box-shadow: inset 0 -2px 0 var(--violet); }
.mk-pass { background: var(--rose-soft); box-shadow: inset 0 -2px 0 var(--rose); }
.mk-long { text-decoration: underline wavy color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 5px; text-decoration-thickness: 1px; }
.mk-adv { background: var(--moss-soft); box-shadow: inset 0 -2px 0 var(--moss); }
.lens:not(.show-fill) .mk-fill, .lens:not(.show-rep) .mk-rep, .lens:not(.show-pass) .mk-pass, .lens:not(.show-adv) .mk-adv { background: none; box-shadow: none; }
.lens:not(.show-long) .mk-long { text-decoration: none; }
.lens .page { cursor: default; }
.lens .page p { margin: 0; }
.top-words { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.top-words span { background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.top-words b { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; margin-left: 3px; }

/* Fokusmodus */
.focus .topbar, .focus #binder, .focus #inspector, .focus .banner, .focus .ed-tools { display: none; }
.focus .shell { grid-template-columns: minmax(0, 1fr) !important; }
.focus #view { background: var(--bg); }
.focus .editor-wrap { padding-top: 12vh; padding-bottom: 50vh; }
.focus .page { border-color: transparent; box-shadow: none; background: transparent; }
.focus .scene-title { opacity: .5; }
.focus-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 60;
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 8px 6px 16px; box-shadow: var(--shadow); font-size: 12px; color: var(--muted); opacity: .35; transition: opacity .2s;
}
.focus-bar:hover { opacity: 1; }
.focus-bar .meter { width: 90px; }

/* ---------- Pinnwand ---------- */
.cork-chapter { margin-bottom: 28px; }
.cork-chapter > header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cork-chapter > header h2 { font-family: var(--f-display); font-size: 16px; font-weight: 600; letter-spacing: .04em; margin: 0; }
.cork-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; min-height: 60px; border-radius: var(--radius); padding: 2px; }
.card {
  background: var(--page); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px 10px;
  display: grid; grid-template-rows: auto 1fr auto; gap: 6px; min-height: 150px; box-shadow: var(--shadow-sm);
  cursor: grab; text-align: left; color: var(--ink); width: 100%;
  background-image: repeating-linear-gradient(var(--page) 0 23px, color-mix(in srgb, var(--accent) 10%, transparent) 23px 24px);
  background-position: 0 38px;
}
.card:hover { border-color: var(--muted); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card h3 { margin: 0; font-size: 14px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.card h3 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card p { margin: 0; font-family: var(--f-text); font-size: 13px; line-height: 24px; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card p.none { color: var(--muted); font-style: italic; }
.card footer { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.card footer .grow { flex: 1; }
.plot-dots { display: inline-flex; gap: 3px; }
.plot-dots i { width: 9px; height: 9px; border-radius: 2px; }
.card.add { display: grid; place-items: center; background: none; border-style: dashed; box-shadow: none; color: var(--muted); cursor: pointer; min-height: 150px; }
.card.dragging { opacity: .4; }

/* ---------- Gliederung ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.outline { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 13px; }
.outline th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; }
.outline td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.outline tr.chap td { background: var(--bg); font-weight: 600; }
.outline input, .outline select, .outline textarea { width: 100%; border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 6px; font-size: 13px; }
.outline textarea { resize: vertical; min-height: 30px; line-height: 1.4; font-family: var(--f-text); }
.outline input:hover, .outline select:hover, .outline textarea:hover { border-color: var(--line); }
.outline input:focus, .outline select:focus, .outline textarea:focus { outline: none; border-color: var(--accent); background: var(--page); }
.outline .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.outline tfoot td { font-weight: 600; background: var(--bg); }

/* ---------- Handlung ---------- */
.plot-grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.plot-grid th, .plot-grid td { padding: 0; }
.plot-grid thead th { font-weight: 500; color: var(--muted); padding: 4px; text-align: center; min-width: 38px; }
.plot-grid thead th.ch { text-align: left; border-left: 1px solid var(--line); padding-left: 8px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.plot-grid tbody th { text-align: left; padding: 6px 12px 6px 4px; white-space: nowrap; font-weight: 500; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.plot-grid td { text-align: center; border-top: 1px solid var(--line); }
.plot-grid td.cs { border-left: 1px solid var(--line); }
.cell { width: 38px; height: 34px; border: 0; background: none; display: grid; place-items: center; border-radius: 6px; }
.cell:hover { background: var(--surface-2); }
.cell i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); }
.cell.on i { border-color: transparent; }
.plot-name { display: flex; align-items: center; gap: 8px; }
.plot-name .sw { width: 12px; height: 12px; border-radius: 3px; }
.plot-name input { border: 1px solid transparent; background: none; padding: 3px 6px; border-radius: 6px; width: 170px; font-weight: 500; }
.plot-name input:hover { border-color: var(--line); }
.plot-name input:focus { outline: none; border-color: var(--accent); background: var(--page); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.beats { display: grid; gap: 0; counter-reset: beat; }
.beat { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 220px); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.beat:first-child { border-top: 0; }
.beat .no { font-family: var(--f-display); font-weight: 600; color: var(--muted); font-size: 15px; padding-top: 1px; text-align: right; }
.beat h4 { margin: 0 0 2px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.beat p { margin: 0 0 6px; color: var(--muted); font-size: 12.5px; }
.beat textarea { width: 100%; border: 1px solid var(--line); background: var(--page); border-radius: 6px; padding: 6px 8px; font-size: 13px; min-height: 34px; resize: vertical; }
.beat select { width: 100%; border: 1px solid var(--line); background: var(--page); border-radius: 6px; padding: 6px; font-size: 12px; }
.beat.done .no { color: var(--moss); }
.beat input[type="checkbox"] { accent-color: var(--moss); width: 16px; height: 16px; margin: 0; }
@media (max-width: 640px) { .beat { grid-template-columns: 24px minmax(0, 1fr); } .beat > :last-child { grid-column: 2; } }

/* ---------- Zeitstrahl ---------- */
.timeline-scroll { overflow-x: auto; padding: 8px 2px 18px; }
.timeline { display: flex; gap: 18px; position: relative; padding-top: 34px; min-width: min-content; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 16px; height: 2px; background: var(--line); }
.tevent { position: relative; width: 236px; flex: none; background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 6px; box-shadow: var(--shadow-sm); }
.tevent::before { content: ""; position: absolute; top: -24px; left: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--page); border: 2.5px solid var(--accent); }
.tevent .when { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.tevent h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tevent p { margin: 0; font-family: var(--f-text); font-size: 13px; color: var(--ink); line-height: 1.5; }
.tevent .acts { display: flex; gap: 2px; justify-content: flex-end; margin-top: 2px; }
.tevent .link { font-size: 12px; color: var(--muted); }
.tevent .link button { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Welt ---------- */
.world-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .world-layout { grid-template-columns: minmax(0, 1fr); } }
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.wcard { border: 1px solid var(--line); background: var(--page); border-radius: var(--radius); overflow: hidden; text-align: left; padding: 0; display: grid; grid-template-rows: 110px auto; color: var(--ink); }
.wcard:hover { border-color: var(--muted); }
.wcard.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.wcard .pic { background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.wcard .pic img { width: 100%; height: 100%; object-fit: cover; }
.mono { font-family: var(--f-display); font-size: 34px; font-weight: 600; color: var(--muted); }
.wcard .meta { padding: 8px 10px 10px; display: grid; gap: 2px; min-width: 0; }
.wcard .meta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .meta span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wdetail { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; }
.wdetail-top { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: start; }
.portrait { width: 120px; height: 140px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); position: relative; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .pbtns { position: absolute; inset: auto 4px 4px 4px; display: flex; gap: 4px; justify-content: center; }
.portrait .pbtns button { font-size: 11px; padding: 3px 7px; border-radius: 6px; border: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink); }
.wname { font-family: var(--f-display); font-size: 22px; font-weight: 600; border: 0; background: none; width: 100%; padding: 2px 0; letter-spacing: .03em; color: var(--ink); }
.wname:focus { outline: none; box-shadow: 0 2px 0 var(--accent); }
.wfields { display: grid; gap: 12px; }
.appears { display: grid; gap: 4px; }
.appears button { border: 0; background: none; color: var(--accent); text-align: left; padding: 2px 0; font-size: 13px; }

/* ---------- Denkbrett ---------- */
.mind-wrap { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr; }
.mind-tools {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--surface);
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.mind-tools .hint { font-size: 12px; color: var(--muted); }
.mind { position: relative; overflow: hidden; touch-action: none; cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(color-mix(in srgb, var(--muted) 35%, transparent) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.mind.panning { cursor: grabbing; }
.mind-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mind svg.links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.mind svg.links line { stroke: var(--muted); stroke-width: 1.6; }
.mnode {
  position: absolute; transform: translate(-50%, -50%); min-width: 90px; max-width: 220px; padding: 9px 14px;
  border-radius: 12px; background: var(--page); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 13.5px; text-align: center; cursor: move; user-select: none; line-height: 1.35; color: var(--ink);
}
.mnode.t1 { background: var(--accent-soft); border-color: var(--accent); }
.mnode.t2 { background: var(--amber-soft); border-color: var(--amber); }
.mnode.t3 { background: var(--moss-soft); border-color: var(--moss); }
.mnode.t4 { background: var(--rose-soft); border-color: var(--rose); }
.mnode.t5 { background: var(--violet-soft); border-color: var(--violet); }
.mnode.sel { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.mnode.src { outline: 2px dashed var(--accent); outline-offset: 3px; }
.mnode[contenteditable="true"] { cursor: text; user-select: text; outline: none; }
.tone-btn { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--page); padding: 0; }
.tone-btn.t1 { background: var(--accent-soft); border-color: var(--accent); }
.tone-btn.t2 { background: var(--amber-soft); border-color: var(--amber); }
.tone-btn.t3 { background: var(--moss-soft); border-color: var(--moss); }
.tone-btn.t4 { background: var(--rose-soft); border-color: var(--rose); }
.tone-btn.t5 { background: var(--violet-soft); border-color: var(--violet); }

/* ---------- Ziele ---------- */
.goal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.goal-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; align-content: start; }
.goal-card h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.big { font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.ring-row { display: flex; align-items: center; gap: 16px; }
.ring { width: 96px; height: 96px; }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--f-ui); }
.chart .bar { fill: var(--accent); }
.chart .bar.today { fill: var(--amber); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--amber); stroke-width: 1.4; stroke-dasharray: 4 4; }
.stack { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.stack i { display: block; height: 100%; }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.legend-row .dot { width: 9px; height: 9px; }
.goal-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.chapter-bars { display: grid; gap: 8px; }
.chapter-bars div { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 12.5px; }
.chapter-bars .lbl { display: grid; gap: 4px; min-width: 0; }
.chapter-bars .lbl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-bars .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 14, 12, .45); z-index: 80; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: min(86vh, 900px); display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.modal.wide { width: min(860px, 100%); }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; gap: 12px; }
.modal > header h2 { margin: 0; font-family: var(--f-display); font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.modal .body { padding: 8px 18px 14px; overflow: auto; display: grid; gap: 14px; align-content: start; min-height: 0; }
.modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.plist { display: grid; gap: 8px; }
.pitem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--page); }
.pitem.cur { border-color: var(--accent); }
.pitem .t { flex: 1; min-width: 0; }
.pitem .t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem .t span { font-size: 12px; color: var(--muted); }
.opt-list { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--page); text-align: left; width: 100%; color: var(--ink); }
.opt:hover { border-color: var(--accent); }
.opt b { display: block; font-weight: 600; margin-bottom: 2px; }
.opt span { font-size: 12.5px; color: var(--muted); }
.opt .ext { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 3px 6px; background: var(--accent-soft); color: var(--accent); flex: none; margin-top: 1px; min-width: 44px; text-align: center; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.names button { border: 1px solid var(--line); background: var(--page); border-radius: 8px; padding: 10px; font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: .03em; color: var(--ink); }
.names button:hover { border-color: var(--accent); color: var(--accent); }
.diff { font-family: var(--f-text); font-size: 15px; line-height: 1.7; background: var(--page); border: 1px solid var(--line); border-radius: 8px; padding: 16px 20px; max-height: 50vh; overflow: auto; white-space: pre-wrap; }
.diff ins { background: var(--moss-soft); text-decoration: none; }
.diff del { background: var(--rose-soft); color: var(--rose); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90; background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 13px; transition: .2s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

#print-root { display: none; }
@media print {
  @page { margin: 2.5cm 2.2cm; }
  body { background: #fff; color: #000; padding: 0; }
  .app, #modal-root, .toast, .focus-bar { display: none !important; }
  #print-root { display: block; font-family: var(--f-text); font-size: 12pt; line-height: 1.6; color: #000; }
  #print-root h1.book { font-family: var(--f-display); text-align: center; font-size: 26pt; margin: 30vh 0 6pt; }
  #print-root .by { text-align: center; font-size: 13pt; }
  #print-root h2 { font-family: var(--f-display); text-align: center; font-size: 17pt; page-break-before: always; margin: 18vh 0 28pt; font-weight: 600; }
  #print-root p { margin: 0; text-align: justify; hyphens: auto; }
  #print-root p + p { text-indent: 1.5em; }
  #print-root .sep { text-align: center; margin: 12pt 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
