:root {
  --accent: #255e17;
  --accent-light: #789c18;
  --accent-dark: #15350d;
  --accent-soft: #d9e0d8;
  --ink: #222;
  --muted: #6c6c6c;
  --line: #d9e0d8;
  --soft: #f3f7f2;
  --paper: #fff;
  --max: 1120px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "YuGothic", "Meiryo", sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }

.site-header { border-top: 7px solid var(--accent-light); border-bottom: 1px solid var(--line); }
.header-inner { max-width: var(--max); margin: 0 auto; padding: 24px 24px 20px; }
.kicker { margin: 0 0 4px; font-size: 12px; letter-spacing: .14em; color: var(--muted); }
.site-title {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(25px, 4vw, 38px);
  font-weight: 600;
  letter-spacing: .04em;
}
.site-title span { color: var(--accent); }

.notice { background: var(--soft); border-bottom: 1px solid var(--line); }
.notice-inner { max-width: var(--max); margin: 0 auto; padding: 10px 24px; font-size: 13px; color: #4c4c4c; }

main { max-width: var(--max); margin: 0 auto; padding: 34px 24px 72px; }
.intro { max-width: 820px; margin-bottom: 24px; }
.intro h1 {
  margin: 0 0 8px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 600;
}
.intro p { margin: 0; color: var(--muted); font-size: 14px; }
.intro .updated { margin-top: 6px; font-size: 12px; }

.search-panel { border-top: 3px solid var(--accent-light); background: var(--soft); padding: 22px; margin-bottom: 28px; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.search-input {
  width: 100%; min-height: 52px; border: 1px solid #aaa; border-radius: 0; padding: 11px 14px;
  background: #fff; font-size: 17px; outline: none;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,94,23,.12); }
.search-button {
  min-width: 118px; border: 0; background: var(--accent); color: #fff; padding: 0 22px;
  font-weight: 700; cursor: pointer;
}
.search-button:hover, .search-button:focus { background: var(--accent-dark); }
.help { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.filter label { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 700; color: #555; }
.filter select { width: 100%; height: 42px; border: 1px solid #bbb; background: #fff; padding: 0 10px; }

.toolbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 0;
}
.result-count { margin: 0; font-size: 15px; }
.result-count strong { color: var(--accent); font-size: 20px; }
.clear-button { border: 0; background: transparent; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 4px 0; font-size: 13px; }

.results { list-style: none; padding: 0; margin: 0; }
.book { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 22px 2px; border-bottom: 1px solid var(--line); }
.book-entry { min-width: 0; }
.book.has-cover .book-entry {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.book-main { min-width: 0; }
.book-cover-button {
  display: block;
  width: 88px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.book-result-cover {
  display: block;
  width: 88px;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}
.book-cover-button:focus-visible {
  outline: 2px solid rgba(37, 94, 23, .35);
  outline-offset: 3px;
}
.book-title {
  margin: 0 0 5px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 20px; line-height: 1.55; font-weight: 600;
}
.book-subtitle { margin: -1px 0 5px; color: #4f4f4f; font-size: 13px; }
.book-author { margin: 0 0 9px; font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 5px 14px; margin: 0; color: var(--muted); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { border: 1px solid #cfcfcf; padding: 2px 8px; font-size: 11px; color: #555; background: #fff; }
.tag.status { border-color: #a7c1a2; color: var(--accent-dark); background: #f3f7f2; }
.book-side { min-width: 132px; text-align: right; }
.price { margin: 0; font-size: 13px; white-space: nowrap; }
.empty, .loading, .error { padding: 42px 0; color: var(--muted); text-align: center; }
.error { color: var(--accent-dark); }

.pagination { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 7px; padding-top: 28px; }
.page-button { min-width: 40px; height: 40px; border: 1px solid #bbb; background: #fff; cursor: pointer; }
.page-button[aria-current="page"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-button:disabled { opacity: .4; cursor: default; }

.footer { border-top: 1px solid var(--line); background: var(--soft); }
.footer-inner {
  max-width: var(--max); margin: 0 auto; padding: 22px 24px 36px; color: var(--muted); font-size: 12px;
  display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}

@media (max-width: 720px) {
  .header-inner, .notice-inner, main, .footer-inner { padding-left: 16px; padding-right: 16px; }
  main { padding-top: 24px; }
  .search-panel { padding: 16px; }
  .search-row { grid-template-columns: 1fr; }
  .search-button { min-height: 46px; }
  .filters { grid-template-columns: 1fr; gap: 10px; }
  .toolbar { align-items: center; }
  .book { grid-template-columns: 1fr; gap: 8px; }
  .book.has-cover .book-entry { grid-template-columns: 72px minmax(0, 1fr); gap: 14px; }
  .book-cover-button, .book-result-cover { width: 72px; }
  .book-side { text-align: left; min-width: 0; }
}

/* --------------------------------------------------
   Book detail modal
-------------------------------------------------- */
.book-title-button {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
  cursor: pointer;
}
.book-title-button:hover,
.book-title-button:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .18em;
}
.book-title-button:focus-visible {
  outline: 2px solid rgba(37, 94, 23, .35);
  outline-offset: 3px;
}

body.modal-open { overflow: hidden; }
.book-modal[hidden] { display: none; }
.book-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 28px;
}
.book-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .54);
}
.book-modal-panel {
  position: relative;
  z-index: 1;
  width: min(860px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #fff;
  border-top: 6px solid var(--accent-light);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
}
.book-modal-content { padding: 36px 42px 44px; }
.book-modal-close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 2;
  width: 42px;
  height: 42px;
  margin: 12px 12px -54px 0;
  border: 1px solid #c8c8c8;
  border-radius: 50%;
  background: #fff;
  color: #333;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
}
.book-modal-close:hover,
.book-modal-close:focus-visible { border-color: var(--accent); color: var(--accent); }
.book-modal-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}
.book-modal-title {
  margin: 0;
  padding-right: 50px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.45;
  font-weight: 600;
}
.book-modal-subtitle { margin: 7px 0 0; color: #555; font-size: 15px; }
.book-modal-summary.has-cover {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}
.book-modal-cover {
  display: block;
  width: 180px;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}
.magazine-modal-summary.has-cover {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.magazine-modal-cover {
  display: block;
  width: 150px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
}
.book-modal-author { margin: 16px 0 0; font-size: 15px; }
.book-modal-tags { margin-top: 14px; }
.detail-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  margin: 24px 0 0;
  border-top: 1px solid var(--line);
}
.detail-row { display: contents; }
.detail-grid dt,
.detail-grid dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.detail-grid dt { color: var(--muted); font-weight: 700; }
.detail-grid dd { padding-left: 16px; }
.book-purchase-actions {
  margin-top: 22px;
}
.amazon-purchase-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid #232f3e;
  background: #fff;
  color: #232f3e;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.amazon-purchase-button:hover,
.amazon-purchase-button:focus-visible {
  background: #232f3e;
  color: #fff;
  border-color: #232f3e;
}
.amazon-purchase-button:focus-visible {
  outline: 2px solid rgba(35, 47, 62, .28);
  outline-offset: 3px;
}

.book-detail-section { margin-top: 30px; }
.book-detail-section h3 {
  margin: 0 0 10px;
  padding-left: 11px;
  border-left: 4px solid var(--accent);
  font-size: 17px;
}
.book-detail-copy { margin: 0; font-size: 14px; }

.book-detail-copy a,
.book-detail-toc a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .16em;
}
.book-detail-copy a:hover,
.book-detail-copy a:focus-visible,
.book-detail-toc a:hover,
.book-detail-toc a:focus-visible {
  color: var(--accent-dark);
}
.book-detail-toc {
  max-height: 340px;
  overflow: auto;
  padding: 16px 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.8;
}
.related-status {
  padding: 18px;
  background: #f3f7f2;
  border: 1px solid #d9e0d8;
}
.related-status h3 { margin-top: 0; }
.related-status ul { margin: 0 0 6px 1.2em; padding: 0; font-size: 13px; }
.related-status p { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .book-modal { padding: 10px; }
  .book-modal-panel { max-height: 92vh; }
  .book-modal-content { padding: 28px 20px 32px; }
  .book-modal-title { padding-right: 42px; font-size: 24px; }
  .book-modal-summary.has-cover { grid-template-columns: 110px minmax(0, 1fr); gap: 18px; }
  .book-modal-cover { width: 110px; }
  .magazine-modal-summary.has-cover { grid-template-columns: 100px minmax(0, 1fr); gap: 16px; }
  .magazine-modal-cover { width: 100px; }
  .detail-grid { grid-template-columns: 90px 1fr; }
  .detail-grid dd { padding-left: 10px; }
}

.back-home {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 24px 0;
  font-size: 13px;
}
.back-home a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.back-home a:hover { text-decoration: underline; }
