:root {
  --ink: #23452b;
  --muted: #5b6d60;
  --line: #dce6df;
  --line-strong: #bdceba;
  --paper: #ffffff;
  --wash: #f5f8f3;
  --brand: #5eb02f;
  --brand-dark: #2f651d;
  --brand-soft: #eaf5e3;
  --surface-soft: #edf3e9;
  --surface-subtle: #f7faf5;
  --amber: #f0a43a;
  --shadow: 0 18px 55px rgba(35, 69, 43, .08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(94, 176, 47, .04) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--wash);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 104px;
  padding: 1.25rem max(2rem, calc((100vw - 1180px) / 2));
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 2px 12px rgba(35, 69, 43, .04);
}

.brand { display: flex; align-items: center; gap: 1.25rem; min-width: 0; }
.brand-logo { display: block; flex-shrink: 0; width: 6.5rem; height: auto; }
h1 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.75rem); line-height: 1.25; letter-spacing: .03em; }

.summary { display: flex; align-items: center; gap: 1.1rem; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.summary strong { color: var(--brand-dark); font-size: 1.05rem; }
.summary-divider { width: 1px; height: 28px; background: var(--line); }

main { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; }

.search-panel {
  position: relative;
  margin-top: 2rem;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  border: 1px solid var(--line);
  border-top: 5px solid var(--brand);
  border-radius: 5px 5px 16px 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.search-panel::after {
  content: "";
  position: absolute;
  top: -5px;
  right: 8%;
  width: 130px;
  height: 5px;
  background: var(--brand-dark);
}

.search-copy { margin-bottom: 1.35rem; }
.section-label { margin: 0 0 .2rem; color: var(--brand-dark); font: 700 .72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .16em; }
h2 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.35; letter-spacing: .02em; }
.search-copy > p:last-child { margin: .45rem 0 0; color: var(--muted); }

.search-box {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: .85rem;
  height: 64px;
  padding: 0 1rem 0 1.25rem;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  transition: border-color .16s, box-shadow .16s;
}
.search-box:focus-within { border-color: var(--brand-dark); box-shadow: 0 0 0 4px rgba(47, 101, 29, .12); }
.search-box svg { width: 24px; fill: none; stroke: var(--brand-dark); stroke-width: 2; stroke-linecap: round; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); font-size: 1.05rem; }
.search-box input::placeholder { color: var(--muted); }
kbd { padding: .2rem .48rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--surface-subtle); font: .72rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.segments { display: inline-flex; padding: 4px; border-radius: 8px; background: var(--surface-soft); }
.segment { min-height: 38px; padding: .35rem .9rem; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-weight: 700; }
.segment.is-active { color: var(--brand-dark); background: #fff; box-shadow: 0 2px 8px rgba(35, 69, 43, .1); }
.segment:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 2px; }

.select-wrap { display: flex; align-items: center; gap: .55rem; color: var(--muted); font-size: .9rem; }
.select-wrap select { min-height: 42px; padding: .35rem 2.3rem .35rem .75rem; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }

.results-section { padding: 2rem 0 1.5rem; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.results-head p { margin: 0; color: var(--muted); }
.results-head strong { color: var(--ink); font-size: 1.2rem; }
#clear-button { border: 0; color: var(--brand-dark); background: transparent; font-weight: 700; }

.result-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.book-card {
  position: relative;
  display: grid;
  grid-template-columns: 5px 1fr;
  gap: 1rem;
  min-width: 0;
  padding: 1.15rem 1.2rem 1.05rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.book-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 10px 28px rgba(35, 69, 43, .08); }
.spine { width: 5px; height: 100%; min-height: 84px; border-radius: 99px; background: var(--brand); }
.book-card[data-collection="other"] .spine { background: var(--amber); }
.card-body { min-width: 0; }
.card-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .42rem; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: .12rem .5rem; border-radius: 99px; color: var(--brand-dark); background: var(--brand-soft); font-size: .75rem; font-weight: 700; }
.book-card[data-collection="other"] .badge { color: #8b5610; background: #fff2dc; }
.location { color: var(--muted); font-size: .78rem; }
.book-title { margin: 0; font-size: 1rem; line-height: 1.52; overflow-wrap: anywhere; }
.book-meta { display: flex; flex-wrap: wrap; gap: .25rem .8rem; margin: .55rem 0 0; color: var(--muted); font-size: .79rem; }
.book-meta span { overflow-wrap: anywhere; }
.book-detail { display: flex; flex-wrap: wrap; gap: .4rem .65rem; margin-top: .55rem; }
.detail-tag { padding: .08rem .4rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--surface-subtle); font-size: .72rem; }

.more-button { display: block; width: min(320px, 100%); min-height: 48px; margin: 1.3rem auto 0; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--brand-dark); background: #fff; font-weight: 700; }
.more-button:hover { background: var(--brand-soft); }

.empty-state { padding: 4rem 1rem; border: 1px dashed var(--line-strong); border-radius: 10px; text-align: center; background: rgba(255,255,255,.7); }
.empty-state > div { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto .8rem; border-radius: 50%; color: var(--muted); background: var(--surface-soft); font: 700 1.2rem/1 ui-monospace, monospace; }
.empty-state h3 { margin: 0; font-size: 1.1rem; }
.empty-state p { margin: .35rem 0 0; color: var(--muted); }

.usage-note { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: .5rem 0 3rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.note-item { display: grid; grid-template-columns: 10px 1fr; gap: .7rem; }
.status-dot { width: 10px; height: 10px; margin-top: .5rem; border-radius: 50%; }
.status-dot.lendable { background: var(--brand-dark); }
.status-dot.reading { background: var(--amber); }
.note-item strong { font-size: .9rem; }
.note-item p { margin: .1rem 0 0; color: var(--muted); font-size: .82rem; }

footer { padding: 1.3rem 1rem 2rem; color: var(--muted); text-align: center; font-size: .78rem; }

@media (max-width: 760px) {
  .topbar { min-height: 96px; padding: 1rem; }
  .brand { gap: 1rem; }
  .brand-logo { width: 5.25rem; }
  .summary { display: none; }
  main { width: min(100% - 1rem, 1180px); }
  .search-panel { margin-top: .5rem; padding: 1.25rem 1rem 1rem; border-radius: 4px 4px 12px 12px; }
  .search-copy { margin-bottom: 1rem; }
  .search-copy > p:last-child { font-size: .87rem; }
  .search-box { grid-template-columns: 21px 1fr; height: 58px; padding: 0 .85rem; }
  .search-box svg { width: 21px; }
  kbd { display: none; }
  .controls { align-items: stretch; flex-direction: column; }
  .segments { display: grid; grid-template-columns: repeat(3, 1fr); }
  .segment { padding-inline: .45rem; }
  .select-wrap { justify-content: space-between; }
  .select-wrap select { flex: 1; max-width: 74%; }
  .results-section { padding-top: 1.3rem; }
  .result-list { grid-template-columns: 1fr; }
  .book-card { padding: 1rem .9rem; }
  .usage-note { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
