:root {
  --paper: #f6f1e7;
  --paper-2: #fffdf8;
  --ink: #211c16;
  --muted: #6f6557;
  --accent: #8a2b1f;      /* oxblood */
  --accent-2: #c2703d;    /* warm clay */
  --gold: #d29a2b;
  --line: #e3d9c6;
  --ok: #2f7d4f;
  --bad: #a23b2c;
  --shadow: 0 1px 2px rgba(33,28,22,.08), 0 8px 24px rgba(33,28,22,.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #f0e7d4 0%, transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, #efe4cf 0%, transparent 55%),
    var(--paper);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

h1, h2, h3, .brand { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; }
h1 { font-size: 2rem; letter-spacing: -.01em; margin: .2em 0 .4em; }
h2 { font-size: 1.4rem; margin: 1.4em 0 .5em; }
h3 { margin: 0 0 .2em; font-size: 1.08rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: .9rem; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.2rem;
  padding: .7rem 1.2rem;
  background: rgba(246,241,231,.85);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); font-weight: 500; }
.topbar nav .who { color: var(--muted); font-size: .85rem; padding-left: .4rem; border-left: 1px solid var(--line); }
.cta {
  background: var(--accent); color: #fff !important; padding: .42rem .8rem;
  border-radius: 999px; font-weight: 600;
}
.cta:hover { background: #74221a; text-decoration: none; }

/* ---- Layout ---- */
.container { max-width: 1040px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 1rem 3rem; }

/* ---- Book grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1.3rem; }
.card {
  display: flex; flex-direction: column; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .14s ease;
  color: var(--ink);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 4px 8px rgba(33,28,22,.10), 0 16px 40px rgba(33,28,22,.16); text-decoration: none; }
.cover { aspect-ratio: 2/3; background: #ece2cf; display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.nocover {
  padding: 1rem; text-align: center; font-family: Georgia, serif; color: var(--muted);
  font-size: .95rem; background: linear-gradient(135deg,#efe6d4,#e2d6bf);
  width: 100%; height: 100%; display: grid; place-items: center;
}
.card .meta { padding: .7rem .8rem .9rem; display: flex; flex-direction: column; gap: .25rem; }
.card .author { color: var(--muted); font-size: .88rem; margin: 0; }
.card .by { color: var(--muted); font-size: .78rem; margin: .25rem 0 0; }

/* ---- Stars ---- */
.stars { display: inline-flex; align-items: center; gap: 1px; }
.stars .star { color: #d8cdb6; font-size: 1rem; }
.stars .star.on { color: var(--gold); }
.stars .count { color: var(--muted); font-size: .8rem; margin-left: .4rem; }

form.rate { display: inline-flex; align-items: center; gap: .5rem; }
form.rate .starbtns { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
form.rate .star {
  background: none; border: none; cursor: pointer; font-size: 1.7rem; line-height: 1;
  color: #d8cdb6; padding: 0 1px; transition: color .08s ease;
}
form.rate .star.on { color: var(--gold); }
/* Hover: erst alle leeren, dann den Bereich vom linken Rand bis zum Cursor fuellen.
   Dank row-reverse sind die optisch linken Sterne spaetere DOM-Geschwister. */
form.rate .starbtns:hover .star { color: #d8cdb6; }
form.rate .starbtns .star:hover,
form.rate .starbtns .star:hover ~ .star { color: var(--gold); }
form.rate .muted { margin-left: .25rem; }

/* ---- Detail ---- */
.detail { display: grid; grid-template-columns: 220px 1fr; gap: 1.8rem; align-items: start; }
.detail .cover { border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.detail .review { white-space: pre-wrap; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.handout { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.handout-img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.banner { background: #fbecdf; border: 1px solid #e7c3a3; color: #8a4b22; padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.pill { display: inline-block; font-size: .75rem; padding: .15rem .55rem; border-radius: 999px; font-weight: 600; }
.pill.pending { background: #fbeccf; color: #8a6a1f; }
.pill.approved { background: #d8f0e0; color: var(--ok); }
.pill.rejected { background: #f3d8d2; color: var(--bad); }

/* ---- Comments ---- */
.comment { border-top: 1px solid var(--line); padding: .8rem 0; }
.comment .who { font-weight: 600; }
.comment .when { color: var(--muted); font-size: .8rem; }

/* ---- Forms ---- */
form.stack { display: flex; flex-direction: column; gap: .8rem; max-width: 560px; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .25rem; }
input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper-2); color: var(--ink); font: inherit;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
.row { display: grid; grid-template-columns: 1fr 120px; gap: .8rem; }

button, .btn {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: .6rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover, .btn:hover { background: #74221a; text-decoration: none; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.ghost:hover { background: var(--paper-2); }
button.ok { background: var(--ok); }
button.bad { background: var(--bad); }
button.link { background: none; border: none; color: var(--accent); padding: 0; font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Search helper ---- */
#ol-results { display: flex; flex-direction: column; gap: .4rem; margin: .6rem 0; }
.hit {
  display: flex; gap: .7rem; align-items: center; text-align: left;
  background: var(--paper-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: .4rem .5rem; cursor: pointer; font-weight: 400;
}
.hit:hover { border-color: var(--accent-2); background: #fff; }
.hit img { width: 38px; height: 56px; object-fit: cover; border-radius: 4px; }
.hit .nocover { width: 38px; height: 56px; border-radius: 4px; }

/* ---- Auth / hero ---- */
.hero { max-width: 460px; margin: 8vh auto 0; text-align: center; }
.hero .card-box {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 2rem 1.8rem; text-align: left; margin-top: 1.4rem;
}
.hero h1 { text-align: center; }
.lede { color: var(--muted); text-align: center; }

/* ---- Tables (Admin) ---- */
table { width: 100%; border-collapse: collapse; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { background: #efe6d4; font-family: Georgia, serif; }
tr:last-child td { border-bottom: none; }
code.codeval { background: #efe6d4; padding: .15rem .4rem; border-radius: 6px; font-size: .9rem; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.flash { background: #d8f0e0; border: 1px solid #b6dcc3; color: var(--ok); padding: .6rem 1rem; border-radius: 10px; margin-bottom: 1rem; }

@media (max-width: 640px) {
  .detail { grid-template-columns: 1fr; }
  .detail .cover { max-width: 200px; }
}
