:root {
  --bg: #f8f6f1;
  --card: #ffffff;
  --text: #222222;
  --muted: #666666;
  --line: #dddddd;
  --accent: #6f7f8f;
  --good: #5f7f6a;
  --risk: #b86b6b;
  --shadow: 0 8px 24px rgba(34,34,34,.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}
.app-header {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}
h1 { margin: 0; font-size: clamp(26px, 5vw, 42px); letter-spacing: .02em; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-weight: 700; letter-spacing: .08em; font-size: 12px; text-transform: uppercase; }
.header-meta { color: var(--muted); font-size: 13px; }
.tabs {
  max-width: 1120px;
  margin: 0 auto 18px;
  padding: 0 18px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.tab {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.65);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
  cursor: pointer;
}
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
main { max-width: 1120px; margin: 0 auto; padding: 0 18px 56px; }
.view { display: none; }
.view.active { display: block; }
.panel {
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat .num { font-size: 30px; font-weight: 800; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; font: inherit; color: var(--text);
}
button.primary { background: var(--text); color:#fff; border: 0; border-radius: 12px; padding: 12px 14px; font: inherit; cursor:pointer; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.book-card {
  min-height: 182px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
  background: linear-gradient(135deg, #fff, #eef2f4);
  box-shadow: 0 6px 14px rgba(0,0,0,.05);
  cursor: pointer;
  display:flex; flex-direction:column; justify-content:space-between;
}
.book-card.tag-haruki { background: linear-gradient(135deg, #ffffff, #dfe7ec); }
.book-card.tag-gothic { background: linear-gradient(135deg, #ffffff, #e8e2ee); }
.book-card.tag-dark { background: linear-gradient(135deg, #ffffff, #d9d9d7); }
.book-card.tag-classic { background: linear-gradient(135deg, #ffffff, #f0eadb); }
.book-title { font-weight: 800; line-height: 1.35; }
.book-author { color: var(--muted); font-size: 13px; margin-top: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge { display:inline-flex; align-items:center; border-radius: 999px; background: rgba(255,255,255,.72); border:1px solid rgba(0,0,0,.08); padding: 2px 8px; font-size: 12px; color: var(--muted); }
.badge.good { color: var(--good); }
.badge.risk { color: var(--risk); }
.list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list th, .list td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.list th { background: #eeeae2; font-size: 12px; color: var(--muted); }
.recommend-card { border:1px solid var(--line); border-radius: 16px; padding:16px; background:#fff; margin-bottom:12px; }
.recommend-card h3 { margin: 0 0 4px; }
.score { color: var(--accent); font-weight: 800; }
.reason-box { display:grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap:10px; margin-top:10px; }
.reason-box div { background: #f7f7f5; border-radius:12px; padding:10px; }
.book-dialog { border: 0; border-radius: 18px; max-width: 680px; width: calc(100% - 32px); padding: 20px; box-shadow: var(--shadow); }
.book-dialog::backdrop { background: rgba(0,0,0,.35); }
.close-button { float: right; border:1px solid var(--line); background:#fff; border-radius:999px; padding:8px 12px; }
.muted { color: var(--muted); }
@media (max-width: 720px) {
  .app-header { align-items: start; flex-direction: column; }
  .shelf-grid { grid-template-columns: repeat(2, 1fr); }
  .list { font-size: 13px; }
  .list th:nth-child(4), .list td:nth-child(4) { display:none; }
}
