:root {
  --bg: #f6f1e7;
  --card: #fffdf8;
  --ink: #2b2a28;
  --muted: #6f6a60;
  --line: #e4dccb;
  --accent: #b5412a;
  --accent-dark: #8f3220;
  --teal: #2f5d6b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(60, 40, 10, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--teal); }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.eyebrow { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--teal); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-family: Georgia, serif; font-size: 1.25rem; letter-spacing: .02em; }
.brand span { opacity: .8; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a, .topbar nav button.link { color: #fff; text-decoration: none; opacity: .9; font-size: .95rem; }
.topbar nav a:hover, .topbar nav button.link:hover { opacity: 1; text-decoration: underline; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
form.inline { display: inline; margin: 0; }

.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 20px 48px; }
.page-head { margin-bottom: 20px; }
.footer {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  padding: 18px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line);
}
.footer a { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 40px auto; }
.flash { background: #e7f1ea; border: 1px solid #bfd9c6; color: #1f5130; padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; }
.error { background: #fbe9e5; border: 1px solid #efc2b8; color: #7a2816; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.warn { background: #fff4df; border: 1px solid #f0d9a6; color: #6b4a00; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: .95rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  font: inherit; padding: 9px 11px; border: 1px solid #cfc6b2; border-radius: 9px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 120px; resize: vertical; }
input[type=file] { font: inherit; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }
button, .button {
  font: inherit; cursor: pointer; border-radius: 9px; padding: 9px 16px; border: 1px solid transparent; text-decoration: none; display: inline-block;
}
button.primary, .button.primary { background: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-dark); }
button.ghost, .button.ghost { background: transparent; border-color: #cfc6b2; color: var(--ink); }
button.ghost:hover { background: #f1eadb; }
button.danger { background: transparent; color: #8f3220; border-color: #e5b9ae; }
button.danger:hover { background: #fbe9e5; }
button.small { padding: 5px 10px; font-size: .85rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.row > .auto { flex: 0 0 auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px; }
.book-card { display: block; text-decoration: none; color: inherit; }
.book-card .cover { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #ddd3bf; transition: transform .15s ease; }
.book-card:hover .cover { transform: translateY(-3px); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; text-align: center; font-family: Georgia, serif; color: #5a5040; }
.badge { position: absolute; top: 10px; left: 10px; background: rgba(43, 42, 40, .8); color: #fff; font-size: .75rem; padding: 3px 8px; border-radius: 999px; }
.badge.progress { left: auto; right: 10px; background: var(--accent); }
.badge.inline { position: static; }
.book-meta { padding: 10px 2px 0; }
.book-meta h2 { font-size: 1.1rem; margin-bottom: .1em; }
.book-meta .author { color: var(--muted); font-size: .9rem; margin: 0; }

.book-hero { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 28px; align-items: start; margin-bottom: 24px; }
.cover.large { aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #ddd3bf; }
.book-info .author { font-size: 1.1rem; color: var(--muted); }
.description { max-width: 60ch; }

.player audio { width: 100%; margin: 10px 0; }
.now-playing { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.now-playing .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.player-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.player-controls .speed { flex-direction: row; align-items: center; gap: 6px; margin-left: auto; font-weight: 400; color: var(--muted); }
.player-controls .speed select { width: auto; padding: 6px 8px; }
.chapters { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.chapters li { border-bottom: 1px solid var(--line); }
.chapters button.chapter {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: none; border: 0; padding: 11px 6px; border-radius: 0; color: inherit;
}
.chapters button.chapter:hover { background: #f1eadb; }
.chapters li.active button.chapter { background: #eef3f4; }
.chapters li.active .title { color: var(--teal); font-weight: 600; }
.chapters .num { width: 28px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chapters .title { flex: 1; }
.chapters .dur { font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
td form { margin: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status { font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: #e9e3d4; }
.status.processing { background: #fff1c7; }
.status.error { background: #fbd6cf; }
.status.ok { background: #d9eadf; }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.admin-nav { display: flex; gap: 14px; margin-bottom: 20px; font-size: .95rem; }
.admin-nav a.active { font-weight: 600; color: var(--ink); }
.section + .section { margin-top: 24px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { width: auto; min-width: 180px; }
.cover-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; }
code { background: #efe9db; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .page { padding: 20px 16px 40px; }
  h1 { font-size: 1.6rem; }
  .book-hero { grid-template-columns: 1fr; }
  .cover.large { max-width: 260px; }
  .card { padding: 18px; }
  table { font-size: .9rem; }
  .player-controls .speed { margin-left: 0; }
}
