/* Alte Briefe – ruhige Buchoptik: Libertinus Serif, cremefarbener Grund,
   graue Kapitälchen, dünne graue Linien. Keine Farbflächen, keine Animationen. */

@font-face {
  font-family: "Libertinus Serif";
  src: url("fonts/LibertinusSerif-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libertinus Serif";
  src: url("fonts/LibertinusSerif-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Libertinus Serif";
  src: url("fonts/LibertinusSerif-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libertinus Serif Display";
  src: url("fonts/LibertinusSerifDisplay-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --grund: #fffdf7;
  --text: #1e1c18;
  --grau: #6b675f;
  --linie: #c9c4b8;
  --link: #4a4640;
  --dunkel: #2b2823;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 18px/1.6 "Libertinus Serif", Georgia, serif;
  font-variant-numeric: oldstyle-nums;
  overflow-wrap: break-word;
}

h1, h2, h3 {
  font-family: "Libertinus Serif Display", "Libertinus Serif", Georgia, serif;
  font-weight: 400;
  line-height: 1.2;
  margin: 1.2em 0 0.5em;
}
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

a { color: var(--link); text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:hover { color: var(--text); }

hr { border: 0; border-top: 1px solid var(--linie); margin: 2rem 0; }

.kapitaelchen {
  font-variant-caps: all-small-caps;
  color: var(--grau);
  letter-spacing: 0.08em;
}

.leise { color: var(--grau); font-size: 0.9rem; }

/* Kopfzeile */
.kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0.9rem 16px;
  border-bottom: 1px solid var(--linie);
}
.buchtitel {
  font-family: "Libertinus Serif Display", "Libertinus Serif", Georgia, serif;
  font-size: 1.3rem;
  color: var(--text);
  text-decoration: none;
}
.kopf-rechts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-size: 1.05rem;
}
.kopf-rechts a { color: var(--grau); text-decoration: none; }
.kopf-rechts a:hover { color: var(--text); text-decoration: underline; }
.kopf-name { color: var(--text); text-decoration: none; }
.kopf-name:hover { text-decoration: underline; }

main {
  max-width: 38rem;
  margin: 0 auto;
  padding: 1.5rem 16px 4rem;
}

footer { min-height: 2rem; }

/* Hinweise und Fehlermeldungen: dunkler Text mit dünner Linie links. */
.hinweis {
  margin: 1rem 0 1.5rem;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 1px solid var(--grau);
  color: var(--text);
}

/* Formulare */
form.inline { display: inline; margin: 0; }
form.schmal { display: flex; flex-direction: column; gap: 0.5rem; max-width: 22rem; }
label { display: block; }

input, textarea, select, button {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--linie);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  max-width: 100%;
}
input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 1px solid var(--grau);
  outline-offset: 1px;
}
button { cursor: pointer; }
button.primaer {
  background: var(--dunkel);
  border-color: var(--dunkel);
  color: var(--grund);
  align-self: flex-start;
  padding: 0.4rem 1.2rem;
}
button.primaer:hover { background: var(--text); }
button.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--grau);
  font-variant-caps: inherit;
  letter-spacing: inherit;
}
button.link:hover { color: var(--text); text-decoration: underline; }

/* Zugangsseite */
.zugang { margin-top: 3rem; }
.zugang h1 { margin-top: 0.1em; }
.zugang .kapitaelchen { margin: 0; }

img { max-width: 100%; height: auto; }

/* Inhaltsverzeichnis */
.untertitel { margin-top: -0.3rem; font-size: 1.1rem; }
ol.inhalt {
  list-style: none;
  counter-reset: brief;
  padding: 0;
  margin: 2rem 0;
}
ol.inhalt li {
  counter-increment: brief;
  position: relative;
  padding-left: 2.2rem;
  margin: 0 0 0.9rem;
}
ol.inhalt li::before {
  content: counter(brief);
  position: absolute;
  left: 0;
  width: 1.6rem;
  text-align: right;
  color: var(--grau);
  font-size: 0.85em;
  top: 0.15em;
}
ol.inhalt .unterzeile { display: block; }
.unterzeile { color: var(--grau); }
.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--linie);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
}

/* Briefansicht */
.briefkopf .kapitaelchen { margin: 0; }
.briefkopf h1 { margin-top: 0.1em; }
.briefkopf .unterzeile { margin: 0; }
.briefkopf + hr { margin: 1rem 0 1.5rem; }
.seite { margin: 0 0 2.5rem; }
.seite p { margin: 0 0 0.9em; }
.seitenmeta { color: var(--grau); font-size: 0.85em; }
.seitenmeta a { color: var(--grau); }
hr.trenner { border: 0; margin: 1.2em 0; text-align: center; }
hr.trenner::after { content: "— · —"; color: var(--grau); font-size: 0.9em; }
blockquote { margin: 1em 0 1em 1.5em; padding: 0; font-size: 0.95em; }
s, u { text-decoration-thickness: 1px; }
sup.fn { line-height: 0; }
sup.fn a { text-decoration: none; }
ol.fussnoten {
  font-size: 0.9em;
  color: var(--grau);
  margin: 1.5rem 0 0;
  padding: 0.6rem 0 0 1.4rem;
  position: relative;
}
ol.fussnoten::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  border-top: 1px solid var(--linie);
}
.blaetter {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--linie);
}

/* Leseansicht: festes Foto der gerade gelesenen Seite. Auf schmalen
   Bildschirmen oben (wie der Editor), ab 64rem Breite als Spalte links. */
body.lesen .kopf { max-width: none; }
body.lesen main { max-width: none; padding: 0; }
body.lesen main > .hinweis { margin: 0.5rem 16px; }
#view.lesefoto {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 40vh;
  height: 40dvh;
  border-bottom: 1px solid var(--linie);
}
.lesetext { padding: 1.5rem 16px 4rem; min-width: 0; }
.seite.aktuell .seitenmeta, .seite.aktuell .seitenmeta a { color: var(--text); }
@media (min-width: 64rem) {
  .lese-flaeche { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 42rem); }
  #view.lesefoto { height: 100vh; height: 100dvh; border-bottom: 0; }
  .lesetext { padding: 1.5rem 2rem 4rem; }
}

/* Foto-Overlay */
body.overlay-offen { overflow: hidden; }
.foto-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(30, 28, 24, 0.92);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.foto-overlay.zieht { cursor: grabbing; }
.foto-overlay img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.foto-schliessen {
  position: absolute;
  top: 12px;
  right: 16px;
  background: var(--grund);
  border-color: var(--grau);
}

/* Handbuch */
.handbuch table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
.handbuch th, .handbuch td { border-bottom: 1px solid var(--linie); padding: 0.3rem 0.5rem; text-align: left; }
.handbuch pre { overflow-x: auto; }

/* Editor: volle Breite, Foto links, Text rechts, Statuszeile unten. */
.unsichtbar {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
body.editor {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.editor .kopf { max-width: none; width: 100%; }
body.editor main {
  max-width: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
body.editor main > .hinweis { margin: 0.5rem 16px; }
body.editor footer { display: none; }
.editor-leiste, .editor-fuss {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 1.2rem;
  padding: 0.4rem 16px;
  font-size: 0.95rem;
}
.editor-leiste { border-bottom: 1px solid var(--linie); }
.editor-titel { flex: 1; }
.editor-links { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; }
.editor-links .aus { color: var(--linie); }
#praesenz { color: var(--grau); font-style: italic; }
#verbindung { color: #8a2a1e; }
.editor-flaeche {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
#view {
  position: relative;
  overflow: hidden;
  background: #333;
  cursor: grab;
  touch-action: none;
}
#view.zieht { cursor: grabbing; }
#view img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}
.editor-text { display: flex; min-height: 0; margin: 0; }
.editor-text textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  border-left: 1px solid var(--linie);
  border-radius: 0;
  padding: 1rem 1.2rem;
  background: var(--grund);
  font: 17px/1.6 "Libertinus Serif", Georgia, serif;
  white-space: pre-wrap;
}
.editor-text textarea:focus { outline: none; }
.editor-fuss { border-top: 1px solid var(--linie); align-items: center; }
#status { flex: 1; color: var(--grau); }
#status.dirty, #status.fehler { color: #8a2a1e; }
kbd {
  font: 0.8em/1 ui-monospace, monospace;
  border: 1px solid var(--linie);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  background: #fff;
}
.konflikt, .meintext {
  max-height: 45vh;
  overflow: auto;
  padding: 0.5rem 16px 1rem;
  border-top: 1px solid var(--grau);
}
.konflikt h2 { font-size: 1.2rem; margin: 0.3rem 0; }
.konflikt-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.konflikt h3 { margin: 0.5rem 0 0.3rem; font-size: 1rem; }
.konflikt-knoepfe { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.meintext pre { white-space: pre-wrap; background: #fff; border: 1px solid var(--linie); padding: 0.6rem; max-height: 20vh; overflow: auto; }

/* Diffs (Konflikt, Historie) */
.diff { font-size: 0.95em; white-space: normal; }
ins { background: #e3eed9; text-decoration: none; }
del { background: #f3dcd6; text-decoration: line-through; text-decoration-thickness: 1px; }

/* Historie */
ol.historie { list-style: none; padding: 0; }
ol.historie li { border-bottom: 1px solid var(--linie); padding: 0.5rem 0; }
ol.historie summary { cursor: pointer; }
ol.historie .diff { margin: 0.6rem 0; }

@media (max-width: 50rem) {
  .editor-flaeche { grid-template-columns: 1fr; grid-template-rows: 40% 60%; }
  .editor-text textarea { border-left: 0; border-top: 1px solid var(--linie); }
  .konflikt-spalten { grid-template-columns: 1fr; }
}

/* Verwaltung */
body.verwaltung main { max-width: 60rem; }
.verwaltung table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
.verwaltung th, .verwaltung td { border-bottom: 1px solid var(--linie); padding: 0.3rem 0.5rem; text-align: left; vertical-align: top; }
.verwaltung form.zeile { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; margin: 0 0.5rem 0.3rem 0; }
.verwaltung form.zeile input[type="text"] { width: 9rem; }
.verwaltung table input[type="text"] { width: 100%; box-sizing: border-box; }
.verwaltung .unterseiten { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; list-style: none; padding: 0; }
.verwaltung .kennzahlen { list-style: none; padding: 0; }
.verwaltung .filter { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: end; margin-bottom: 1rem; }
.verwaltung table input[type="number"] { width: 4rem; }

.handbuch nav.inhaltsverzeichnis { color: var(--grau); font-size: 0.9rem; margin: 0 0 1.5rem; }
.handbuch nav.inhaltsverzeichnis ol { list-style: none; margin: 0; padding: 0; }
.handbuch nav.inhaltsverzeichnis li { margin: 0.15rem 0; }
.handbuch nav.inhaltsverzeichnis a { color: inherit; }
