@font-face {
  font-family: "Literata";
  src: url("fonts/literata-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 200 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("fonts/literata-latin-wght-italic.woff2") format("woff2-variations");
  font-weight: 200 900; font-style: italic; font-display: swap;
}

:root {
  --paper: #f7f4ee;
  --surface: #fffdf9;
  --ink: #1f1d1a;
  --muted: #6d665c;
  --faint: #a59d91;
  --line: #e3ddd2;
  --accent: #8a2e2a;
  --accent-ink: #fffdf9;
  --accent-soft: #f1e3df;
  --focus: #8a2e2a55;
  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171614;
    --surface: #201e1b;
    --ink: #ece6dc;
    --muted: #a39b8e;
    --faint: #6f685e;
    --line: #34302b;
    --accent: #d27a6f;
    --accent-ink: #1a1816;
    --accent-soft: #3a2724;
    --focus: #d27a6f55;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
.icon { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Kopf ---------- */
.kopf {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.kopf-innen {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.marke { font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: .01em; margin-right: auto; }
.marke span { color: var(--accent); }
.kinder { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.kinder button {
  border: 0; background: none; padding: 6px 16px; border-radius: 999px; cursor: pointer; color: var(--muted);
  font-family: var(--serif); font-size: 16px;
}
.kinder button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.knopf-icon {
  border: 0; background: none; width: 38px; height: 38px; border-radius: 50%;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted);
}
.knopf-icon:hover { background: var(--surface); color: var(--ink); }

.reiter { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; }
.reiter button {
  border: 0; background: none; cursor: pointer; padding: 10px 12px 11px; color: var(--muted);
  border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 8px;
}
.reiter button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---------- Bedienelemente ---------- */
.knopf {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: var(--r); font-size: 15px; white-space: nowrap;
}
.knopf:hover { border-color: var(--faint); }
.knopf.primaer { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.knopf.primaer:hover { filter: brightness(1.06); }
.knopf.leise { background: none; border-color: transparent; color: var(--muted); padding-inline: 10px; }
.knopf.leise:hover { color: var(--ink); background: var(--surface); }
.knopf:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

label.feld { display: block; margin-bottom: 18px; }
.feld > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; letter-spacing: .01em; }
.feld small { display: block; color: var(--faint); font-size: 13px; margin-top: 6px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--faint); box-shadow: 0 0 0 3px var(--focus); }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.zeile { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.zeile > .wachsen { flex: 1 1 200px; }

/* ---------- Tage ---------- */
.tage-layout { display: grid; grid-template-columns: 300px 1fr; gap: 40px; align-items: start; }
.kalender { position: sticky; top: 130px; }
.raster { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.raster button {
  aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  font-family: var(--serif); font-size: 18px; cursor: pointer; position: relative; color: var(--muted);
}
.raster button.notiz { color: var(--ink); }
.raster button.notiz::after {
  content: ""; position: absolute; bottom: 6px; left: 50%; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--faint);
}
.raster button.fertig { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.raster button.heute { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent); }
.raster button[aria-current="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.raster button.fertig[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.legende { display: flex; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); margin-right: 6px; vertical-align: -1px; }
.legende i.n { background: var(--surface); position: relative; }
.legende i.f { background: var(--ink); border-color: var(--ink); }
.fortschritt { margin-top: 18px; font-size: 14px; color: var(--muted); }

.tag-kopf { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.tag-kopf h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1; margin: 0; }
.tag-kopf .monat { font-family: var(--serif); font-variant-caps: all-small-caps; letter-spacing: .12em; color: var(--muted); font-size: 18px; }
.tag-kopf .status { margin-left: auto; font-size: 13px; color: var(--faint); }

.block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.block h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.block textarea.notizen { min-height: 110px; background: var(--paper); }

.kapitel input.titel {
  font-family: var(--serif); font-style: italic; font-size: 24px; border: 0; padding: 0 0 6px;
  background: none; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: 16px;
}
.kapitel input.titel:focus { box-shadow: none; border-bottom-color: var(--accent); }
.kapitel textarea.text {
  font-family: var(--serif); font-size: 18px; line-height: 1.7; border: 0; padding: 0; background: none;
  min-height: 120px; resize: none; overflow: hidden; border-radius: 0;
}
.kapitel textarea.text:focus { box-shadow: none; }
.kapitel .meta { font-size: 13px; color: var(--faint); margin-top: 12px; }
.leer {
  text-align: center; color: var(--muted); padding: 40px 20px; font-family: var(--serif); font-style: italic;
}
.leer .icon { width: 28px; height: 28px; color: var(--faint); display: block; margin: 0 auto 10px; }
.arbeitet { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 28px 4px; font-family: var(--serif); font-style: italic; }
.wunsch { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.wunsch input { flex: 1 1 260px; }
.aktionen { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Figuren & Geschichte ---------- */
.schmal { max-width: 760px; }
.einleitung { color: var(--muted); margin: 0 0 24px; max-width: 62ch; }
.figur { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; }
.figur input.name { font-family: var(--serif); font-size: 20px; }
.figur textarea { grid-column: 1 / -1; min-height: 80px; }
h1.seite { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 0 0 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

/* ---------- Anmeldung, Dialoge, Meldungen ---------- */
.anmeldung { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.anmeldung form { width: 100%; max-width: 380px; }
.anmeldung h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 0 0 6px; }
.anmeldung p { color: var(--muted); margin: 0 0 28px; }
.fehler { color: var(--accent); font-size: 14px; margin: -6px 0 14px; min-height: 1em; }

dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgb(20 18 16 / .45); }
.dialog-kopf { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-kopf h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0; }
.dialog-inhalt { padding: 20px; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-size: 15px;
  max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgb(0 0 0 / .2);
}
.toast.fehler-toast { background: var(--accent); color: var(--accent-ink); }

/* ---------- Druckvorschau ---------- */
.vorschau { position: fixed; inset: 0; z-index: 40; background: #3b3833; display: flex; flex-direction: column; }
.vorschau-leiste {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.vorschau-leiste .titel { font-family: var(--serif); font-size: 18px; margin-right: auto; }
.vorschau-leiste select { width: auto; padding: 7px 10px; }
.vorschau-seiten { flex: 1; overflow: auto; padding: 32px 16px 60px; display: flex; flex-direction: column; align-items: center; gap: 28px; }

@media (max-width: 860px) {
  .tage-layout { grid-template-columns: 1fr; gap: 24px; }
  .kalender { position: static; }
  .raster { grid-template-columns: repeat(8, 1fr); }
  .tag-kopf h2 { font-size: 32px; }
}
@media (max-width: 520px) {
  .kopf-innen { padding: 10px 16px; gap: 4px 6px; }
  .kinder { order: 5; width: 100%; }
  .kinder button { flex: 1; }
  .marke { font-size: 18px; }
  .reiter, main { padding-inline: 16px; }
  .raster { grid-template-columns: repeat(6, 1fr); }
  .kinder button { padding: 6px 12px; }
  .reiter button { padding-inline: 8px; }
  .block { padding: 16px; }
}
