* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- Farb-/Schrift-System "Lesenische" ---------- */
:root {
  --bg: #fbf1e2;
  --card: #fffcf5;
  --ink: #3b2e22;
  --muted: #8a7a68;
  --border: #ecdfc7;
  --hover: #f3e6d2;

  --terracotta: #e2734f;
  --terracotta-dark: #c85f3d;
  --terracotta-soft: #fbe3d7;
  --terracotta-ink: #b6502a;

  --sage: #6f9464;
  --sage-dark: #5c7f52;
  --sage-soft: #e3ecdd;
  --sage-ink: #3f6134;

  --gold: #d8a03d;
  --gold-soft: #f8ecd2;
  --gold-ink: #8a5f1c;

  --danger: #c25a45;
  --danger-soft: #f6e0da;

  --shadow: rgba(94, 66, 41, 0.14);
}

body {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding: 16px;
  max-width: 700px;
  margin: 0 auto;
}

h1, h2, h3 { font-family: "Baloo 2", sans-serif; font-weight: 600; }

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 32px; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 24px var(--shadow);
}
.login-card h1 { font-size: 22px; margin-bottom: 8px; }
.login-card .error { color: var(--danger); font-size: 14px; }

/* ---------- Layout ---------- */
input, select, button {
  font-family: inherit; font-size: 15px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--ink);
}
button {
  background: var(--terracotta); color: #fff; border: none; cursor: pointer; font-weight: 700;
  font-family: "Baloo 2", sans-serif;
}
button:hover { background: var(--terracotta-dark); }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar h1 { font-size: 22px; }
.logout { color: var(--muted); font-size: 13px; text-decoration: none; }
.logout:hover { text-decoration: underline; }

.subnav { display: flex; gap: 16px; margin-bottom: 16px; }
.subnav a { color: var(--terracotta-ink); font-size: 13px; text-decoration: none; font-weight: 700; }
.subnav a:hover { text-decoration: underline; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter-bar input, .filter-bar select { flex: 1; min-width: 120px; }
.filter-bar button { flex-shrink: 0; }

.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.flash { color: var(--sage-ink); background: var(--sage-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 16px; font-size: 14px; }
.error { color: var(--danger); font-size: 14px; margin-bottom: 12px; }

/* ---------- Bücherregal ---------- */
.shelf-group { margin-bottom: 26px; }
.shelf-heading { font-size: 19px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.shelf-heading .count { font-family: "Nunito", sans-serif; font-weight: 700; font-size: 13px; color: var(--muted); }

.book-grid { display: flex; flex-direction: column; gap: 14px; }
.book-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 12px; box-shadow: 0 4px 14px var(--shadow);
}
.book-row-head { display: flex; align-items: flex-start; gap: 8px; }
.book-main { display: flex; gap: 12px; text-decoration: none; color: inherit; flex: 1; min-width: 0; }

/* "Bearbeiten"-Link: eigenständiger Link statt Teil des großen Cover/Titel-
   Links (der führt weiter zur Detailseite) — HTML erlaubt sowieso keine
   verschachtelten <a>, daher als Geschwisterelement daneben. Auf der
   Detailseite (book_detail.html) steht derselbe Linktext oben rechts neben
   "← Regal", im Regal (index.html) nur das Icon, um pro Buch-Kachel nicht
   zu viel Platz zu beanspruchen. */
.edit-link {
  font-size: 13px; color: var(--terracotta-ink); text-decoration: none; font-weight: 700;
}
.edit-link:hover { text-decoration: underline; }
.edit-link-shelf {
  flex-shrink: 0; font-size: 16px; padding: 4px 6px; border-radius: 8px; line-height: 1;
}
.edit-link-shelf:hover { background: var(--hover); text-decoration: none; }

.book-cover {
  flex-shrink: 0; width: 56px; height: 84px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, var(--terracotta-soft), var(--gold-soft));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px var(--shadow);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-cover-placeholder { font-size: 24px; }
.book-cover-large { width: 100px; height: 150px; border-radius: 14px; }

.book-info { display: flex; flex-direction: column; justify-content: center; gap: 3px; min-width: 0; }
.book-title { font-family: "Baloo 2", sans-serif; font-weight: 600; font-size: 16px; }
.book-author { font-size: 13px; color: var(--muted); }
.stars { color: var(--gold); font-size: 13px; letter-spacing: 1px; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.pill, .shelf {
  display: inline-block; font-size: 11px; font-weight: 800; color: var(--gold-ink); background: var(--gold-soft);
  border-radius: 999px; padding: 3px 10px; width: fit-content;
}
.pill-type { color: var(--sage-ink); background: var(--sage-soft); }

/* Buch/Artikel-Umschalter im Erfassungs-/Bearbeiten-Formular — steuert per JS,
   welche Felder sichtbar sind (siehe book_add.html/book_edit.html). */
.type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-toggle button {
  flex: 1; padding: 10px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--card); color: var(--muted); font-weight: 700; font-size: 14px;
  font-family: inherit; cursor: pointer;
}
.type-toggle button.active { border-color: var(--terracotta); color: var(--terracotta-ink); background: var(--terracotta-soft); }
.field-book, .field-article { display: flex; flex-direction: column; gap: 10px; }

/* Zitat-/Notiz-Kacheln im Regal — kleine, leicht schiefe Karteikarten unter
   Cover/Titel, nur wenn das Buch welche hat (siehe index.html). Absichtlich
   horizontal scrollbar statt umbrechend: bleibt eine Zeile pro Buch, das
   Regal wächst nicht in die Höhe, egal wie viele Zitate ein Buch hat. */
.snippets {
  display: flex; gap: 10px; overflow-x: auto; padding: 14px 2px 2px;
  margin-top: 10px; border-top: 1px dashed var(--border);
}
.snippet {
  flex: 0 0 auto; width: 160px; border-radius: 12px; padding: 9px 11px 10px;
  box-shadow: 0 4px 10px var(--shadow); font-family: "Literata", serif;
}
.snippet:nth-child(3n+1) { transform: rotate(-2deg); }
.snippet:nth-child(3n+2) { transform: rotate(1.4deg); }
.snippet:nth-child(3n+3) { transform: rotate(-1deg); }
.snippet.quote { background: var(--terracotta-soft); }
.snippet.note { background: var(--sage-soft); }
.snippet-kind {
  font-family: "Nunito", sans-serif; font-size: 9.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 5px;
}
.snippet.quote .snippet-kind { color: var(--terracotta-ink); }
.snippet.note .snippet-kind { color: var(--sage-ink); }
.snippet-text {
  font-size: 13px; line-height: 1.45; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.snippet-more {
  flex: 0 0 auto; width: 56px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--border); color: var(--muted); font-weight: 800; font-size: 13px;
  text-decoration: none;
}
.snippet-more:hover { border-color: var(--terracotta); color: var(--terracotta-ink); }

/* ---------- Buchdetail ---------- */
.book-header { display: flex; gap: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 18px; margin-bottom: 16px; box-shadow: 0 4px 14px var(--shadow); }
.book-header-info { display: flex; flex-direction: column; gap: 4px; }
.book-header-info h2 { font-size: 21px; }
.badge-status { display: inline-block; font-size: 12px; font-weight: 700; color: var(--terracotta-ink); margin: 2px 0; }
.meta-line { font-size: 13px; color: var(--muted); }
.book-description { font-size: 14px; margin-top: 6px; }

/* Kopfzeile über Detail-/Bearbeiten-Seite: Zurück-Link links, Bearbeiten-
   Link rechts (book_detail.html) bzw. nur der Zurück-Link (book_edit.html,
   dort führt er zurück zum Buch statt zum Regal). */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.back-link { font-size: 13px; color: var(--muted); text-decoration: none; font-weight: 700; }
.back-link:hover { color: var(--ink); text-decoration: underline; }

.danger-zone {
  margin-top: 8px; padding: 16px; border: 1px dashed var(--danger); border-radius: 16px;
}
.danger-zone form { margin: 0; }
.danger-zone .delete {
  width: 100%; background: none; border: 1px solid var(--danger); border-radius: 10px;
  padding: 10px 12px; font-weight: 700;
}
.danger-zone .delete:hover { background: var(--danger-soft); }

.section-heading { font-size: 17px; margin: 22px 0 12px; }

/* ---------- Zitat-/Notiz-Karten (Detailseite) ---------- */
.highlight-list { display: flex; flex-direction: column; gap: 14px; }
.highlight-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 3px 10px var(--shadow);
}
.highlight-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.date { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 3px 10px; border-radius: 999px; color: #fff;
}
.badge-quote { background: var(--terracotta); }
.badge-note { background: var(--sage); }

.highlight-photo { max-width: 100%; border-radius: 10px; margin: 8px 0; display: block; }

.highlight-text {
  border-left: 3px solid var(--gold); padding-left: 12px; margin: 10px 0;
  font-family: "Literata", serif; font-size: 15.5px; white-space: pre-line;
}

.highlight-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.highlight-foot form { margin: 0; }
.highlight-foot .delete { font-size: 12px; }
.source-link { font-size: 13px; color: var(--terracotta-ink); text-decoration: none; font-weight: 600; }
.source-link:hover { text-decoration: underline; }
.source-book { font-size: 13px; color: var(--muted); font-style: italic; }

.chip {
  font-size: 11px; background: var(--hover); color: var(--muted); padding: 3px 10px; border-radius: 999px; font-weight: 700;
}

/* ---------- Erfassungsformulare ---------- */
.entry-form {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px;
  box-shadow: 0 3px 10px var(--shadow);
}
.entry-form label { font-size: 13px; font-weight: 700; color: var(--muted); }
.entry-form textarea { font-family: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; resize: vertical; background: var(--card); color: var(--ink); }

/* ---------- Link-Import ---------- */
.import-box { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; box-shadow: 0 3px 10px var(--shadow); }
.import-box label { font-size: 13px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 6px; }
.import-row { display: flex; gap: 8px; }
.import-row input { flex: 1; }
.import-status { font-size: 13px; margin-top: 8px; min-height: 1em; }
.import-status-ok { color: var(--sage-ink); }
.import-status-error { color: var(--danger); }

/* ---------- Sammlungen ---------- */
.add-collection { display: flex; gap: 8px; margin-bottom: 20px; }
.add-collection input { flex: 1; }
.collection-list { display: flex; flex-direction: column; gap: 8px; }
.collection-list li {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 3px 10px var(--shadow);
}
.collection-name { font-weight: 700; flex: 1; font-family: "Baloo 2", sans-serif; }
.collection-list .count { font-size: 12px; color: var(--muted); }
.collection-list form { margin: 0; }

button.delete, .delete { background: none; color: var(--danger); font-weight: 600; padding: 4px 8px; font-family: inherit; }
button.delete:hover, .delete:hover { background: var(--danger-soft); }
