:root { --accent: #2F6783; --bg: #f6f7f8; --card: #fff; --text: #1d2327; --muted: #5f6b73; --line: #dde3e7; --thumb: #e9eef1; --icon: #46525a; --paper: #fbfaf7; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; background: var(--bg); color: var(--text); overflow-wrap: anywhere; }
body.locked { overflow: hidden; }
button { font: inherit; cursor: pointer; }
/* 画面上部に固定するのは検索窓だけ（スマホで一覧が見える範囲を広く取る） */
.top { background: var(--card); padding: 12px 16px 0; }
h1 { margin: 0; font-size: 18px; color: var(--accent); }
.searchbar { position: sticky; top: 0; z-index: 5; background: var(--card); padding: 8px 16px; }
.controls { background: var(--card); border-bottom: 1px solid var(--line); padding: 0 16px 8px; }
#q { width: 100%; min-height: 44px; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); font-size: 15px; color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"] .ic { color: #fff; }
.countbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 0; }
.count { margin: 0; font-size: 14px; color: var(--muted); }
.linkbtn { border: 0; background: none; padding: 2px 4px; font-size: 14px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.linkbtn[hidden] { display: none; }
/* 右下のボタンに最後の表紙が隠れないよう、下に余白を取る */
main { padding: 12px 16px 96px; max-width: 1200px; margin: 0 auto; }
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.group-title { grid-column: 1 / -1; margin: 12px 0 0; font-size: 16px; color: var(--accent); }
.item { display: flex; gap: 12px; align-items: center; width: 100%; min-width: 0; min-height: 44px; padding: 10px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: inherit; }
.thumb { flex: none; width: 64px; height: 84px; border-radius: 6px; overflow: hidden; background: var(--thumb); display: flex; align-items: center; justify-content: center; }
.thumb img, .big img { width: 100%; height: 100%; object-fit: contain; display: block; }
.body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.title { font-weight: 700; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.icons { display: inline-flex; gap: 8px; }
.ic { display: inline-flex; width: 18px; height: 18px; flex: none; color: var(--icon); }
.ic svg { width: 100%; height: 100%; }
.date { font-variant-numeric: tabular-nums; }
.list.cover { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.list.cover .item { flex-direction: column; align-items: stretch; }
.list.cover .thumb { width: 100%; height: auto; aspect-ratio: 3 / 4; }
@media (min-width: 720px) {
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list.cover { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .list.cover { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--accent); background: var(--card); color: var(--accent); font-size: 16px; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }
.backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .4); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: 640px; max-height: 90vh; margin: 0 auto; overflow-y: auto; background: var(--card); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: none; font-size: 28px; color: var(--muted); }
.big { width: 160px; height: 212px; margin: 8px auto; border-radius: 8px; overflow: hidden; background: var(--thumb); display: flex; align-items: center; justify-content: center; }
.sheet h2 { margin: 8px 0; font-size: 20px; overflow-wrap: anywhere; }
.badge-direct { display: inline-block; margin: 0 0 8px; padding: 2px 10px; border-radius: 6px; background: #fdf1e6; color: #9a4b00; font-weight: 700; }
.notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--thumb); color: var(--text); }
.info { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 8px 0 16px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 20; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: #222; color: #fff; overflow-wrap: anywhere; }

/* 表紙の画像が無いときの文字の表紙。小さい枠では雰囲気だけ、大きい枠では読める大きさにする */
.textcover { width: 100%; height: 100%; display: flex; padding: 5px; background: var(--paper); }
.textcover .frame { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 5px; border: 1px solid var(--line); text-align: center; overflow: hidden; }
.tc-brand { font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", serif; font-size: 7.5px; line-height: 1.2; text-transform: uppercase; color: var(--text); overflow-wrap: normal; word-break: normal; }
.tc-rule { align-self: center; width: 40%; height: 1px; background: var(--accent); }
.tc-title { font-size: 7px; line-height: 1.3; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tc-foot { display: flex; justify-content: center; gap: 3px; }
.tc-foot .ic { width: 12px; height: 12px; }
.list.cover .textcover .frame, .big .textcover .frame { gap: 10px; padding: 16px 12px; }
.list.cover .tc-brand, .big .tc-brand { font-size: clamp(12px, 4vw, 16px); letter-spacing: .03em; }
.list.cover .tc-title, .big .tc-title { font-size: 12px; }
.list.cover .tc-foot .ic, .big .tc-foot .ic { width: 16px; height: 16px; }

/* 右下に固定する「並び替え」「絞り込み」と、そこから開く面 */
.fabs { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 8; display: flex; gap: 8px; }
.fab { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 18px; border: 1px solid var(--accent); border-radius: 24px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .22); }
.fab .ic { color: #fff; }
.fab.light { background: var(--card); color: var(--accent); }
.fab.light .ic { color: var(--accent); }
.panel { display: grid; gap: 14px; }
.panel-title { margin: 4px 48px 0 0; font-size: 18px; }
.grp { display: grid; gap: 8px; }
.gl { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.btn.wide { width: 100%; }
.opts { display: grid; gap: 6px; }
.opts button { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text); font-size: 16px; text-align: left; }
.opts button .ic { visibility: hidden; color: var(--accent); }
.opts button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
.opts button[aria-pressed="true"] .ic { visibility: visible; }
