:root {
  --bg: #f4f2ef;
  --ink: #1c1b1a;
  --muted: #5c5854;
  --card: #fff;
  --accent: #c45c26;
  --line: #ddd8d1;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; background: #111; color: #fff;
}
.top a { color: #fff; text-decoration: none; margin-left: 16px; }
.brand { font-weight: 700; margin-left: 0 !important; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { margin: 0 0 8px; font-size: 1.75rem; }
.lead { color: var(--muted); margin: 0 0 20px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters select, .filters input, .filters button, button, textarea, input, select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); display: flex; flex-direction: column;
  text-decoration: none; color: inherit; transition: transform .15s ease, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.card .cover {
  aspect-ratio: 3/4; background: #e8e4de center/cover no-repeat;
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px;
}
.card .meta { padding: 10px 12px 14px; }
.card .brand-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.card h2 { font-size: 15px; margin: 4px 0 0; line-height: 1.3; font-weight: 600; }
.card .pages { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Viewer */
.page-viewer { background: #16161a; color: #eee; min-height: 100vh; }
.page-viewer .top { background: #0d0d10; }
.viewer-wrap { height: calc(100vh - 52px); }
#book { height: 100%; width: 100%; --fb-bg: #16161a; }
.viewer-toolbar-extra {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px;
}

/* Admin */
.page-admin main { max-width: 960px; }
.admin-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.table th { background: #efebe6; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eee; }
.badge.live { background: #d7f5df; }
.badge.draft { background: #fff1c9; }
.badge.archived { background: #e8e8e8; }
.drop {
  border: 2px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center;
  background: #fff; margin-bottom: 20px; cursor: pointer;
}
.drop.drag { border-color: var(--accent); background: #fff7f2; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button { cursor: pointer; font-size: 12px; padding: 5px 8px; }
.msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.msg.ok { background: #d7f5df; }
.msg.err { background: #ffd9d9; }
.snippet {
  width: 100%; min-height: 72px; font-family: ui-monospace, monospace; font-size: 12px;
}
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 12px; padding: 20px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto;
}
.modal h3 { margin-top: 0; }
.form-grid { display: grid; gap: 10px; }
.form-grid label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
@media (max-width: 600px) {
  .card h2 { font-size: 14px; }
}
