/* Heldenchronik – Gestaltung im Stil eines mittelreichischen Regelbands (DSA 4.1) */
:root {
  --bg: #E8DCBF;
  --surface: #F3EAD3;
  --surface-2: #E0D1AE;
  --ink: #22160D;
  --muted: #5A4632;
  --line: #C4AE84;
  --gold: #A9822F;
  --gold-hell: #D8B865;
  --leder: #3A2314;
  --leder-2: #4E3020;
  --pergament-hell: #F6EED9;
  --primary: #8A1F18;
  --primary-ink: #F6EED9;
  --t-held: #2F5B37;
  --t-nsc: #2C4A78;
  --t-gegner: #8A1F18;
  --t-ort: #6E4B1C;
  --t-plan: #8E6A14;
  --t-faden: #5A3A7A;
  --t-unbekannt: #7A6A58;
  --h-freund: #3D7A3F;
  --h-verbuendet: #2E6E7A;
  --h-neutral: #8A7D6A;
  --h-misstrauisch: #B07A12;
  --h-feind: #9E2A1E;
  --h-schuldet: #6B4A92;
  --focus: #2C4A78;
  --radius-s: 3px;
  --radius-m: 4px;
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --sans: 'Alegreya Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --titel: 'Alegreya', Georgia, serif;
  --fraktur: 'Alegreya', Georgia, serif;
  --zier: 'Cinzel', Georgia, serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  /* Kerzenlicht: dunkles Leder, Pergament als Schrift */
  :root {
    --bg: #1D140D;
    --surface: #2A1D13;
    --surface-2: #362619;
    --ink: #EADCBC;
    --muted: #B59C78;
    --line: #5A4128;
    --gold: #C9A04E;
    --gold-hell: #E2C175;
    --leder: #120C07;
    --leder-2: #22170E;
    --pergament-hell: #F1E5C8;
    --primary: #B8463A;
    --primary-ink: #F6EED9;
    --t-held: #7DB07A;
    --t-nsc: #86A6D8;
    --t-gegner: #E07560;
    --t-ort: #CFA368;
    --t-plan: #DDB654;
    --t-faden: #B496D6;
    --t-unbekannt: #A8957C;
    --h-freund: #7DB07A;
    --h-verbuendet: #6DB3BE;
    --h-neutral: #A8957C;
    --h-misstrauisch: #E0B04A;
    --h-feind: #E8705C;
    --h-schuldet: #B496D6;
    --focus: #E2C175;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  padding-bottom: calc(72px + var(--safe-b));
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; flex: 1; color: var(--primary); }
.brand span { font-family: var(--serif); font-weight: 800; font-size: 1.25rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.sync-dot { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg); background: var(--t-unbekannt); }
.sync-dot.ok { background: var(--h-freund); }
.sync-dot.ausstehend { background: var(--h-misstrauisch); }
.sync-dot.fehler, .sync-dot.offline { background: var(--h-feind); }

.tabs-top { display: none; }
.tabs-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs-bottom:empty { display: none; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; text-decoration: none; color: var(--muted); font-size: .78rem; border-radius: var(--radius-s); }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--primary); font-weight: 700; }
@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .tabs-bottom { display: none; }
  .tabs-top { display: flex; gap: 2px; }
  .tabs-top .tab { flex-direction: row; gap: 6px; font-size: .95rem; padding: 8px 12px; }
  .tabs-top .tab svg { width: 18px; height: 18px; }
  .tabs-top .tab[aria-current="page"] { background: var(--surface-2); }
  .brand { flex: 0 1 auto; margin-right: 12px; }
  .topbar-actions { margin-left: auto; }
}

/* Grundlayout */
main { max-width: 780px; margin: 0 auto; padding: 20px 16px 32px; outline: none; }
main.wide { max-width: 1100px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.4rem; font-weight: 600; margin: 28px 0 10px; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--h-feind); }
.btn.ghost { background: none; border-color: transparent; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list > li { border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; padding: 14px 4px; text-decoration: none; }
a.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; }
.row .sub { color: var(--muted); font-size: .92rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.swatch { width: 6px; align-self: stretch; border-radius: 3px; background: var(--t-unbekannt); flex: none; }

/* Typfarben */
.t-held { --tc: var(--t-held); }
.t-nsc { --tc: var(--t-nsc); }
.t-gegner { --tc: var(--t-gegner); }
.t-ort { --tc: var(--t-ort); }
.t-plan { --tc: var(--t-plan); }
.t-faden { --tc: var(--t-faden); }
.t-unbekannt { --tc: var(--t-unbekannt); }
.swatch[class*="t-"] { background: var(--tc); }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge[class*="t-"] { color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); }

/* Erwähnungs-Chips */
.chip {
  display: inline; padding: 0 6px 0 6px; border-radius: 4px; text-decoration: none; font-weight: 600;
  color: var(--tc, var(--muted));
  background: color-mix(in srgb, var(--tc, var(--muted)) 13%, transparent);
  box-shadow: inset 2px 0 0 var(--tc, var(--muted));
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
a.chip:hover { background: color-mix(in srgb, var(--tc) 24%, transparent); }
.chip.neu { border: 1px dashed var(--tc); box-shadow: none; }

/* Sitzungsliste */
.session-row .nr { font-family: var(--serif); font-weight: 800; font-size: 1.6rem; color: var(--primary); width: 44px; text-align: right; flex: none; }
.session-row .date { font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .95rem; }

/* Sitzungsansicht */
.session-date { font-family: var(--serif); font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 800; line-height: 1.02; color: var(--primary); margin-bottom: 6px; }
.session-date.leer { font-size: 1.4rem; color: var(--muted); font-weight: 600; }
.session-meta { color: var(--muted); margin: 6px 0 20px; }
.prose { font-family: var(--serif); font-size: 1.16rem; line-height: 1.62; max-width: 68ch; }
.prose p { margin: 0 0 1em; }
.summary-box { border-left: 3px solid var(--primary); padding: 4px 0 4px 14px; margin: 0 0 22px; font-family: var(--serif); font-style: italic; font-size: 1.1rem; color: var(--muted); }
.meta-grid { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0; }
.meta-grid dt { color: var(--muted); }
.meta-grid dd { margin: 0; }

/* Formulare */
form.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; }
.field > span { font-weight: 700; font-size: .92rem; }
.field .hint { font-size: .85rem; color: var(--muted); }
.field-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: var(--surface);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.big { min-height: 320px; font-family: var(--serif); font-size: 1.08rem; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: calc(72px + var(--safe-b)); padding: 10px 0; background: linear-gradient(transparent, var(--bg) 30%); }
@media (min-width: 900px) { .form-actions { bottom: 0; } }

/* Erwähnungs-Vorschläge */
.mention-wrap { position: relative; }
.mention-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.suggest {
  position: absolute; left: 0; right: 0; z-index: 30; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: 0 10px 30px rgba(0,0,0,.18); max-height: 260px; overflow: auto; list-style: none; padding: 4px; margin-left: 0;
}
.suggest li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--radius-s); cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.detected { margin-top: 8px; font-size: .9rem; color: var(--muted); line-height: 1.9; }

/* Segmente */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; overflow-x: auto; margin-bottom: 14px; }
.seg a, .seg button { flex: 1; text-align: center; padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 700; border: 0; background: none; cursor: pointer; white-space: nowrap; }
.seg [aria-current="page"], .seg [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* Gegner-Uhr */
.clock { display: inline-flex; gap: 3px; vertical-align: middle; }
.clock i { width: 14px; height: 14px; border-radius: 3px; border: 2px solid var(--t-gegner); }
.clock i.on { background: var(--t-gegner); }
.clock.big { gap: 6px; }
.clock.big button { width: 34px; height: 34px; border-radius: 6px; border: 2px solid var(--t-gegner); background: none; cursor: pointer; padding: 0; }
.clock.big button.on { background: var(--t-gegner); }
.clock-card { border: 1px solid color-mix(in srgb, var(--t-gegner) 40%, var(--line)); border-radius: var(--radius-m); padding: 14px; background: color-mix(in srgb, var(--t-gegner) 6%, var(--surface)); margin: 16px 0; }
.clock-card.voll { border-color: var(--t-gegner); }

/* Entity-Kopf */
.entity-head { border-left: 6px solid var(--tc, var(--muted)); padding-left: 14px; margin-bottom: 14px; }
.entity-head h1 { margin: 4px 0; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.quick select { width: auto; min-height: 36px; padding: 4px 10px; }

/* Beziehungen */
.rel { display: flex; align-items: center; gap: 10px; padding: 10px 2px; }
.rel .line { width: 26px; height: 0; border-top: 3px solid var(--hc); flex: none; }
.rel .line.dash { border-top-style: dashed; }
.h-freund { --hc: var(--h-freund); } .h-verbuendet { --hc: var(--h-verbuendet); } .h-neutral { --hc: var(--h-neutral); }
.h-misstrauisch { --hc: var(--h-misstrauisch); } .h-feind { --hc: var(--h-feind); } .h-schuldet { --hc: var(--h-schuldet); }

/* Netz */
.graph-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; touch-action: none; }
.graph-wrap svg { display: block; width: 100%; height: min(62vh, 620px); user-select: none; -webkit-user-select: none; }
.graph-wrap .node { cursor: pointer; }
.graph-wrap .node text { font-family: var(--sans); font-size: 13px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.graph-wrap .edge-label { font-family: var(--sans); font-size: 11px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.slider-box { display: grid; gap: 4px; margin: 14px 0; }
.slider-box .stand { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--primary); min-height: 36px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .88rem; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Fäden & Pläne */
.thread { display: flex; gap: 12px; align-items: flex-start; padding: 12px 2px; }
.thread input[type=checkbox] { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--t-faden); flex: none; }
.thread .grow { flex: 1; min-width: 0; }
.thread.zu .text { text-decoration: line-through; color: var(--muted); }
.plan-col h2 { display: flex; align-items: baseline; gap: 8px; }
.plan-card { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--t-plan); border-radius: var(--radius-s); }
.plan-card + .plan-card { margin-top: 8px; }
.plan-card .foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.plan-card select { width: auto; min-height: 34px; padding: 2px 8px; }
@media (min-width: 900px) {
  .plan-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: start; }
  .plan-board h2 { margin-top: 0; }
}

/* Leerzustand & Karten */
.empty { padding: 28px 18px; border: 1px dashed var(--line); border-radius: var(--radius-m); text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; }
.panel + .panel { margin-top: 12px; }
.welcome { padding: 8px 0 18px; }
.welcome h1 { font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: 1; }
.welcome p { font-family: var(--serif); font-size: 1.15rem; color: var(--muted); max-width: 52ch; margin-top: 12px; }

/* Modal */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10,16,14,.5); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); animation: hoch .22s ease-out; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
@keyframes hoch { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Rückblick */
.recap-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.recap-item .when { font-family: var(--serif); font-style: italic; color: var(--muted); }
.recap-item .text { font-family: var(--serif); font-size: 1.08rem; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* Suche */
.search-input { font-size: 1.15rem; min-height: 52px; }
mark { background: color-mix(in srgb, var(--t-plan) 35%, transparent); color: inherit; border-radius: 2px; }

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


/* ================= Mittelreich-Schicht ================= */
body {
  font-size: 18px;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 30%, transparent 55%, color-mix(in srgb, var(--leder) 22%, transparent) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .12 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--titel); letter-spacing: .02em; }
h1 { font-weight: 700; font-size: 1.85rem; }
h2 { font-weight: 600; font-size: 1.25rem; color: var(--primary); }
h3 { font-weight: 600; font-size: 1.02rem; }

/* Lederleiste */
.topbar {
  background: var(--leder);
  background-image: linear-gradient(180deg, var(--leder-2), var(--leder));
  border-bottom: 3px double var(--gold);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  color: var(--pergament-hell);
}
.brand { color: var(--gold-hell); }
.brand span { font-family: var(--fraktur); font-weight: 400; font-size: 1.55rem; color: var(--gold-hell); letter-spacing: .01em; }
.topbar .icon-btn { color: var(--gold-hell); }
.topbar .icon-btn:hover { background: rgba(255,255,255,.08); color: var(--pergament-hell); }
.sync-dot { border-color: var(--leder); }
.tabs-top .tab { color: color-mix(in srgb, var(--pergament-hell) 75%, transparent); font-family: var(--titel); font-size: .85rem; letter-spacing: .04em; }
.tabs-top .tab[aria-current="page"] { background: none; color: var(--gold-hell); box-shadow: inset 0 -2px 0 var(--gold-hell); border-radius: 0; }
.tabs-bottom { background: var(--leder); background-image: linear-gradient(0deg, var(--leder-2), var(--leder)); border-top: 3px double var(--gold); }
.tabs-bottom .tab { color: color-mix(in srgb, var(--pergament-hell) 70%, transparent); font-family: var(--titel); font-size: .68rem; letter-spacing: .03em; }
.tabs-bottom .tab[aria-current="page"] { color: var(--gold-hell); }

/* Zierlinie unter Überschriften */
.view-head { position: relative; padding-bottom: 18px; }
.view-head::after, .zier {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 14'%3E%3Cpath d='M30 1l5 6-5 6-5-6z' fill='%23A9822F'/%3E%3Ccircle cx='17' cy='7' r='1.8' fill='%23A9822F'/%3E%3Ccircle cx='43' cy='7' r='1.8' fill='%23A9822F'/%3E%3C/svg%3E") center / 60px 14px no-repeat,
    linear-gradient(var(--gold), var(--gold)) left center / calc(50% - 34px) 1px no-repeat,
    linear-gradient(var(--gold), var(--gold)) right center / calc(50% - 34px) 1px no-repeat;
}
.zier { position: static; display: block; margin: 26px 0; }

/* Knöpfe: Siegel und Pergament */
.btn { border-radius: var(--radius-s); font-family: var(--titel); font-weight: 600; font-size: .86rem; letter-spacing: .04em; border-color: color-mix(in srgb, var(--ink) 45%, transparent); background: var(--pergament-hell); }
.btn.small { font-size: .78rem; }
.btn.primary {
  background: var(--primary); color: var(--primary-ink);
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 3px color-mix(in srgb, var(--gold) 70%, transparent), 0 2px 0 color-mix(in srgb, var(--leder) 50%, transparent);
}
.btn.ghost { background: none; border-color: transparent; box-shadow: none; }
.btn.danger { color: var(--primary); }

/* Gerahmte Flächen wie Kästen im Regelband */
.panel, .empty, .clock-card, .plan-card, .graph-wrap, .modal {
  background: var(--surface);
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: var(--radius-m);
}
.empty { border-style: solid; }
.empty h3 { font-family: var(--titel); }
.panel h3 { color: var(--primary); }
.plan-card { border-left: 4px solid var(--t-plan); padding: 14px 16px; }
.clock-card { background: color-mix(in srgb, var(--t-gegner) 7%, var(--surface)); border-color: var(--t-gegner); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--t-gegner) 7%, var(--surface)), inset 0 0 0 4px color-mix(in srgb, var(--t-gegner) 45%, transparent); }
.clock-card h3 { color: var(--t-gegner); }
.clock.big button { border-radius: 50%; }
.clock i { border-radius: 50%; }
.modal { background: var(--bg); border-width: 2px; }
.modal-head h2 { color: var(--primary); }

/* Listen */
.list { border-top: 1px solid var(--line); }
.row .title { font-weight: 600; font-size: 1.05rem; }
.swatch { width: 5px; border-radius: 0; }
.session-row .nr { font-family: var(--fraktur); font-weight: 400; font-size: 2rem; color: var(--primary); }

/* Sitzungsansicht wie eine Buchseite */
.session-date { font-family: var(--fraktur); font-weight: 400; color: var(--primary); font-size: clamp(2.1rem, 8vw, 3.4rem); line-height: 1.05; }
.summary-box { border-left: 0; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); padding: 10px 6px; text-align: center; font-size: 1.12rem; color: var(--muted); }
.prose { font-size: 1.2rem; line-height: 1.58; hyphens: auto; -webkit-hyphens: auto; text-align: justify; }
.prose p + p { text-indent: 1.4em; margin-top: -.6em; }
.prose.buch > p:first-child:not(.muted)::first-letter {
  font-family: var(--fraktur); float: left; font-size: 3.7em; line-height: .82; color: var(--primary);
  padding: .06em .1em 0 0; margin-top: .04em;
}
.meta-grid dt, .session-meta { font-style: italic; }

/* Erwähnungen: Rubrizierung statt Markierung */
.chip { background: none; box-shadow: none; padding: 0; border-bottom: 1px solid color-mix(in srgb, var(--tc, var(--muted)) 55%, transparent); border-radius: 0; font-weight: 600; font-variant: small-caps; letter-spacing: .02em; }
a.chip:hover { background: color-mix(in srgb, var(--tc) 12%, transparent); }
.chip.neu { border: 0; border-bottom: 1px dashed var(--tc); }
.badge { border-radius: 2px; font-family: var(--titel); font-size: .68rem; letter-spacing: .05em; padding: 2px 7px; }

/* Formulare */
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], input[type=search], select, textarea {
  background: var(--pergament-hell); border-color: var(--line); border-radius: var(--radius-s);
}
.field > span { font-family: var(--titel); font-size: .8rem; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.seg { background: none; border: 1px solid var(--gold); border-radius: var(--radius-s); padding: 3px; }
.seg a, .seg button { border-radius: 2px; font-family: var(--titel); font-size: .8rem; letter-spacing: .04em; }
.seg [aria-current="page"], .seg [aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); box-shadow: none; }

/* Startseite */
.welcome h1 { font-family: var(--fraktur); font-weight: 400; font-size: clamp(2.6rem, 10vw, 4rem); color: var(--primary); letter-spacing: 0; }
.welcome p { font-style: italic; }

/* Netz */
.graph-wrap .node text { font-family: var(--serif); font-size: 14px; font-weight: 600; }
.graph-wrap .edge-label { font-family: var(--serif); font-style: italic; font-size: 12px; }

#toast { background: var(--leder); color: var(--gold-hell); border: 1px solid var(--gold); border-radius: var(--radius-s); font-family: var(--titel); font-size: .85rem; letter-spacing: .03em; }
mark { background: color-mix(in srgb, var(--gold-hell) 45%, transparent); }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
@media (max-width: 600px) { .prose { text-align: left; } }

/* ================= Zeitstrahl ================= */
.timeline { list-style: none; margin: 18px 0 0; padding: 0 0 0 60px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 23px; top: 6px; bottom: 30px; width: 0; border-left: 3px double var(--gold); }
.station { position: relative; padding: 2px 0 26px; scroll-margin-top: 90px; }
.station .marker {
  position: absolute; left: -60px; top: 0; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--primary);
  border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--gold) 60%, transparent);
  font-family: var(--fraktur); font-size: 1.35rem;
}
.station.now .marker { color: var(--muted); border-style: dashed; box-shadow: none; }
.station.now .st-title { color: var(--muted); }
.station.hervor .marker { background: var(--primary); color: var(--primary-ink); }
.st-date { font-family: var(--fraktur); color: var(--primary); font-size: 1.45rem; line-height: 1.1; }
.st-title { display: inline-block; font-family: var(--titel); font-weight: 700; font-size: 1.08rem; text-decoration: none; margin-top: 2px; }
.st-title:hover { text-decoration: underline; }
.st-meta { font-style: italic; color: var(--muted); font-size: .92rem; }
.st-sum { font-style: italic; margin: 8px 0 0; }
.gap { position: relative; padding: 0 0 22px; font-style: italic; color: var(--muted); font-size: .92rem; }
.gap::before { content: "⁂"; position: absolute; left: -46px; top: -2px; color: var(--gold); font-style: normal; background: var(--bg); padding: 2px 0; }
.meet-group { margin-top: 12px; }
.meet-group h4 { margin: 0 0 6px; font-family: var(--titel); font-size: .74rem; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.meets { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.meet a {
  display: flex; flex-direction: column; padding: 8px 12px; text-decoration: none;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--tc) 45%, var(--line)); border-left: 4px solid var(--tc); border-radius: var(--radius-s);
}
.meet a:hover { background: color-mix(in srgb, var(--tc) 8%, var(--surface)); }
.meet-name { font-weight: 700; color: var(--tc); font-variant: small-caps; letter-spacing: .02em; font-size: 1.05rem; }
.meet-rolle { font-size: .92rem; color: var(--ink); }
.meet-rolle em { color: var(--muted); }
.again { margin: 10px 0 0; font-size: .95rem; color: var(--muted); line-height: 1.9; }
.first-meet { font-style: italic; color: var(--muted); margin-top: 4px; }
.first-meet a { color: var(--primary); }
.tabs-bottom .tab { min-width: 0; }
.tabs-bottom .tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.prose::after { content: ""; display: block; clear: both; }


/* ================= Lesbarkeit (überschreibt die Schmuckschicht) ================= */
body {
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .12 0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main { padding: 22px 18px 40px; }
h1, h2, h3, h4 { font-family: var(--serif); letter-spacing: 0; }
h1 { font-size: 2rem; font-weight: 800; line-height: 1.12; }
h2 { font-size: 1.35rem; font-weight: 700; margin: 30px 0 12px; }
h3 { font-size: 1.12rem; font-weight: 700; }

/* Kopfzeile: ruhig und klar */
.brand span { font-family: var(--zier); font-weight: 700; font-size: 1.15rem; letter-spacing: .03em; }

/* Reiter: groß genug zum Lesen und Tippen */
.tabs-bottom { padding: 4px 2px calc(4px + var(--safe-b)); }
.tabs-bottom .tab, .tabs-top .tab {
  font-family: var(--sans); font-size: .8rem; font-weight: 500; letter-spacing: 0;
  color: color-mix(in srgb, var(--pergament-hell) 82%, transparent);
}
.tabs-bottom .tab { padding: 6px 0; gap: 3px; }
.tabs-bottom .tab svg { width: 23px; height: 23px; }
.tabs-bottom .tab[aria-current="page"], .tabs-top .tab[aria-current="page"] {
  color: var(--leder); background: var(--gold-hell); font-weight: 700; border-radius: 8px; box-shadow: none;
}
.tabs-top .tab { font-size: 1rem; }
@media (max-width: 380px) { .tabs-bottom .tab { font-size: .72rem; } }

/* Knöpfe */
.btn { font-family: var(--sans); font-size: 1rem; font-weight: 700; letter-spacing: 0; min-height: 44px; border-radius: 8px; border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
.btn.small { font-size: .92rem; min-height: 38px; }
.btn.primary { box-shadow: 0 2px 0 color-mix(in srgb, var(--leder) 45%, transparent); border: 1px solid color-mix(in srgb, var(--leder) 40%, var(--primary)); }

/* Rahmen: eine klare Goldlinie statt Doppelrahmen */
.panel, .empty, .clock-card, .plan-card, .graph-wrap, .modal, .meet a {
  box-shadow: 0 1px 2px color-mix(in srgb, var(--leder) 12%, transparent);
  border-radius: 10px;
}
.panel, .empty { padding: 18px; }
.clock-card { box-shadow: none; }
.plan-card { border-radius: 8px; }

/* Formulare */
.field > span { font-family: var(--sans); font-size: .95rem; font-weight: 700; letter-spacing: 0; color: var(--ink); }
.field .hint { font-size: .9rem; }
input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], input[type=search], select, textarea {
  font-family: var(--sans); font-size: 1.05rem; min-height: 48px; border-radius: 8px; border-color: color-mix(in srgb, var(--ink) 28%, transparent);
}
textarea.big { font-family: var(--serif); font-size: 1.12rem; line-height: 1.6; }

/* Segmente */
.seg { border-radius: 10px; padding: 4px; gap: 4px; }
.seg a, .seg button { font-family: var(--sans); font-size: .98rem; font-weight: 700; letter-spacing: 0; padding: 9px 10px; border-radius: 7px; }

/* Abzeichen */
.badge { font-family: var(--sans); font-size: .82rem; font-weight: 700; letter-spacing: 0; border-radius: 6px; padding: 2px 8px; }

/* Listen */
.row { padding: 15px 6px; }
.row .title { font-size: 1.08rem; font-weight: 700; }
.row .sub { font-size: .98rem; color: var(--muted); }
.session-row .nr { font-family: var(--serif); font-weight: 800; font-size: 1.7rem; }

/* Erwähnungen: farbig und fett, ohne Kapitälchen */
.chip { font-variant: normal; letter-spacing: 0; font-weight: 700; border-bottom-width: 2px; }

/* Sitzungsansicht */
.session-date { font-family: var(--serif); font-weight: 800; font-style: italic; font-size: clamp(1.7rem, 6.5vw, 2.6rem); line-height: 1.1; }
.session-meta { font-style: normal; font-size: 1rem; }
.summary-box { text-align: left; font-size: 1.12rem; color: var(--ink); background: color-mix(in srgb, var(--gold) 10%, transparent); border: 0; border-left: 4px solid var(--gold); border-radius: 0 8px 8px 0; padding: 12px 16px; font-style: italic; }
.prose { font-size: 1.18rem; line-height: 1.7; text-align: left; hyphens: manual; -webkit-hyphens: manual; color: var(--ink); }
.prose p + p { text-indent: 0; margin-top: 0; }
.prose.buch > p:first-child:not(.muted)::first-letter {
  font-family: var(--serif); font-weight: 800; font-size: 3.1em; line-height: .9; padding: .04em .08em 0 0;
}

/* Startseite */
.welcome h1 { font-family: var(--serif); font-weight: 800; font-size: clamp(2.2rem, 9vw, 3.2rem); }
.welcome p { font-style: normal; color: var(--ink); opacity: .85; }

/* Zeitstrahl */
.station .marker { font-family: var(--serif); font-weight: 800; font-size: 1.25rem; box-shadow: none; }
.st-date { font-family: var(--serif); font-weight: 800; font-style: italic; font-size: 1.3rem; }
.st-title { font-family: var(--serif); font-size: 1.2rem; }
.st-meta { font-style: normal; font-size: .95rem; }
.st-sum { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); }
.meet-group h4 { font-family: var(--sans); font-size: .9rem; font-weight: 700; letter-spacing: 0; color: var(--muted); }
.meet-name { font-variant: normal; letter-spacing: 0; font-size: 1.08rem; }
.meet-rolle { font-size: .98rem; }
.again { font-size: 1rem; }
.gap { font-size: 1rem; }

/* Netz & Sonstiges */
.graph-wrap .node text { font-family: var(--sans); font-size: 14px; font-weight: 700; }
.graph-wrap .edge-label { font-family: var(--sans); font-style: normal; font-size: 12.5px; }
#toast { font-family: var(--sans); font-size: 1rem; letter-spacing: 0; border-radius: 10px; }
.first-meet { font-style: normal; }
.small { font-size: .95rem; }
.prose.buch > p:first-child:not(.muted)::first-letter { font: inherit; float: none; color: inherit; padding: 0; margin: 0; }

/* Dunkelmodus: Felder und Knöpfe dunkel mit heller Schrift */
@media (prefers-color-scheme: dark) {
  input[type=text], input[type=number], input[type=date], input[type=url], input[type=password], input[type=search], select, textarea {
    background: #140E09; color: var(--ink); border-color: #6B5236;
  }
  input::placeholder, textarea::placeholder { color: #9C8668; opacity: 1; }
  input[type=date] { color-scheme: dark; }
  .btn { background: var(--surface-2); color: var(--ink); border-color: #6B5236; }
  .btn:hover { border-color: var(--gold); }
  .btn.primary { background: #A93B30; color: #FFF6E6; border-color: #C9A04E; }
  .btn.danger { color: #F08A78; }
  .btn.ghost { background: none; }
  .meet a, .plan-card { background: var(--surface-2); }
  .seg [aria-current="page"], .seg [aria-pressed="true"] { background: #A93B30; color: #FFF6E6; }
  .suggest { background: var(--surface-2); }
  .muted, .row .sub, .st-meta { color: #C2AA86; }
}
