:root {
  --bg: #f6f1e8;
  --card: #fffdf8;
  --ink: #2b2620;
  --muted: #8a7f70;
  --line: #e7dcc8;
  --accent: #b3541e;
  --accent-dark: #8f3f14;
  --green: #2e7d4f;
  --gold: #d99a2b;
  --chip: #efe6d3;
  --shadow: 0 10px 30px rgba(80, 55, 20, 0.12);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  background: var(--bg); color: var(--ink);
  background-image: radial-gradient(circle at 15% 0%, #fdf8ee 0, transparent 40%);
}
.topbar { background: #2e2118; color: #f7efe2; position: sticky; top: 0; z-index: 5; }
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { font-size: 34px; background: #4a3423; border-radius: 12px; padding: 4px 8px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.5px; }
.brand .sub { margin: 0; color: #c9b79d; font-size: 13px; font-family: system-ui, sans-serif; }
.top-actions { display: flex; gap: 8px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 20px 40px; }

.btn {
  border: 1px solid transparent; border-radius: 999px; padding: 9px 16px;
  font: 600 14px/1 system-ui, sans-serif; cursor: pointer; transition: 0.15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(128,110,90,.4); }
.topbar .btn.ghost { color: #f7efe2; }
.btn.ghost:hover { border-color: currentColor; }
.linklike { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 800; }
.stat .l { font: 500 12px system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.toolbar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 8px; }
.search-row { display: flex; gap: 10px; }
.search-row input[type="search"] { flex: 1; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: 400 14px system-ui, sans-serif; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.filter-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; padding: 7px 14px; cursor: pointer; font: 600 13px system-ui, sans-serif; color: #5d4f3f; }
.chip.active { background: #2e2118; color: #ffe9c9; border-color: #2e2118; }
.filter-selects { display: flex; gap: 8px; }
.filter-selects select { width: auto; }

.result-count { color: var(--muted); font: 500 13px system-ui, sans-serif; margin: 12px 2px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; gap: 12px; padding: 14px; }
.cover {
  width: 64px; height: 92px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h3 { margin: 0; font-size: 17px; line-height: 1.25; }
.author { margin: 2px 0 6px; color: var(--muted); font: italic 400 13px Georgia, serif; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.pill { font: 600 11px system-ui, sans-serif; background: var(--chip); border-radius: 999px; padding: 3px 9px; color: #6b5c48; }
.pill.status-reading { background: #dcefe2; color: #20603c; }
.pill.status-finished { background: #2e2118; color: #ffe1b3; }
.pill.status-want { background: #e8e0f3; color: #53407a; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 14px; }
.stars button { background: none; border: none; cursor: pointer; font-size: 16px; padding: 0 1px; color: #cfc2ab; }
.stars button.on { color: var(--gold); }
.progress { height: 8px; background: #eee2cb; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.prow { display: flex; align-items: center; gap: 6px; font: 500 12px system-ui, sans-serif; color: var(--muted); }
.prow input { width: 64px; padding: 4px 6px; }
.mini { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.mini:hover { border-color: var(--accent); color: var(--accent); }
.notes { font-size: 13px; color: #5d5347; background: #faf5ea; border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.card-actions { display: flex; gap: 6px; margin-top: 6px; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--muted); }
.icon-btn:hover { color: var(--accent); }

.empty { text-align: center; padding: 50px 20px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-art { font-size: 48px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.empty-actions .btn.ghost { color: var(--ink); }
.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; color: var(--muted); font: 400 13px system-ui, sans-serif; }

.overlay { position: fixed; inset: 0; background: rgba(46,33,24,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; z-index: 10; overflow: auto; }
.overlay[hidden] { display: none; }
.modal { background: var(--card); border-radius: 18px; max-width: 620px; width: 100%; padding: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0 0 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font: 600 13px system-ui, sans-serif; }
.err { color: #a33; font: 400 12px system-ui, sans-serif; min-height: 14px; }
.rating-field { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0; }
.rating-field legend { font: 600 13px system-ui, sans-serif; padding: 0 6px; }
.star-input button { background: none; border: none; font-size: 24px; cursor: pointer; color: #cfc2ab; padding: 0 2px; }
.star-input button.on { color: var(--gold); }
.notes-label { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; font: 600 13px system-ui, sans-serif; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-actions .btn.ghost { color: var(--ink); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #2e2118; color: #ffe9c9; padding: 10px 18px; border-radius: 999px;
  font: 500 14px system-ui, sans-serif; box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 20;
}
.toast[hidden] { display: none; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:last-child { grid-column: span 2; }
  .search-row { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; align-items: stretch; }
}
