/* コマンダー土地検索 — refined MTG-flavored dark theme
 * 設計方針: Moxfield/Scryfall の整然さ + Pinterest のカード感 + 古書のような気品
 * - serif 見出し (Cormorant Garamond / Noto Serif JP) で「魔導書」的な雰囲気
 * - 本文は Inter / Noto Sans JP でクリスプに
 * - パレットは深いチャコール + 琥珀(amber) アクセント
 */

:root {
  /* ---- Surfaces (warm dark, slightly purple-brown) ---- */
  --bg: #0d0c0e;
  --bg-grad-top: #15131a;
  --bg-soft: #1a181d;
  --bg-card: #1f1c23;
  --bg-card-hover: #25212c;
  --border: #2c2830;
  --border-soft: #221f25;

  /* ---- Text ---- */
  --text: #e8e3d8;          /* warm off-white */
  --text-strong: #f5efe1;
  --text-dim: #9a948a;
  --text-faint: #6c6660;

  /* ---- Accents ---- */
  --accent: #c9a861;        /* amber / 琥珀 */
  --accent-soft: #d4b878;
  --accent-deep: #8a6f3c;
  --accent-glow: rgba(201,168,97,0.18);
  --accent-line: rgba(201,168,97,0.55);

  /* ---- Secondary accents ---- */
  --crimson: #7a1f1f;
  --teal-muted: #3d6961;
  --danger: #c46a5e;

  /* ---- Mana hues (kept for chip backgrounds) ---- */
  --w: #fff5d8;
  --u: #6cb1e0;
  --b: #8b7da3;
  --r: #e07b5b;
  --g: #6fb87a;
  --c: #b8b8b8;

  /* ---- Shadow ---- */
  --shadow-card: 0 6px 16px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.02) inset;
  --shadow-card-hover: 0 12px 28px rgba(0,0,0,0.6), 0 0 0 1px var(--accent-line) inset;
  --shadow-panel: 0 2px 10px rgba(0,0,0,0.35);

  /* ---- Typography ---- */
  --font-serif: 'Cormorant Garamond', 'Noto Serif JP', 'Hiragino Mincho ProN', serif;
  --font-sans:  'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', Consolas, 'Noto Sans Mono CJK JP', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Subtle warm gradient — avoids pure-black flatness */
  background:
    radial-gradient(ellipse at 50% -10%, var(--bg-grad-top) 0%, var(--bg) 55%) fixed,
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Subtle film grain — uses a tiny SVG noise pattern, very low opacity */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

body > * { position: relative; z-index: 1; }

a {
  color: var(--accent-soft);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ============================================================
   Header
============================================================ */
.site-header {
  text-align: center;
  padding: 56px 16px 28px;
  position: relative;
}
.site-header h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(34px, 5vw, 48px);
  letter-spacing: 0.015em;
  color: var(--text-strong);
  line-height: 1.1;
}
.site-header h1 .ornament {
  display: inline-block;
  color: var(--accent);
  font-size: 0.7em;
  vertical-align: middle;
  margin: 0 0.4em;
  opacity: 0.85;
}
.site-header .subtitle {
  margin: 14px 0 0;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  font-weight: 500;
}
/* Decorative gradient rule under the title */
.site-header .header-rule {
  display: block;
  margin: 22px auto 0;
  width: min(360px, 70%);
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent-line) 30%,
    var(--accent) 50%,
    var(--accent-line) 70%,
    transparent 100%
  );
  border: 0;
  opacity: 0.85;
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* ============================================================
   Filter panel
============================================================ */
.filters {
  background: linear-gradient(180deg, var(--bg-soft) 0%, #16141a 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.filter-label {
  color: var(--text-dim);
  min-width: 96px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}

.color-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}
.color-chip input { display: none; }
.color-chip .pip { font-size: 16px; line-height: 1; }
.color-chip .pip-svg {
  width: 22px;
  height: 22px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4));
}
.color-chip .ja {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.color-chip:hover {
  border-color: var(--accent-soft);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.color-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 0 14px rgba(201,168,97,0.18);
  color: var(--text-strong);
}
.color-chip:has(input:checked) .ja { color: var(--text-strong); }

/* カードタイプフィルタ chip group。color-chip と同じ pill UI を再利用。 */
.type-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  transition: all 0.18s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}
.type-chip input { display: none; }
.type-chip span {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.type-chip:hover {
  border-color: var(--accent-soft);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}
.type-chip:hover span { color: var(--text); }
.type-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 0 12px rgba(201,168,97,0.18);
}
.type-chip:has(input:checked) span { color: var(--text-strong); font-weight: 600; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-card);
  padding: 3px;
  gap: 2px;
}
.segmented label {
  position: relative;
  cursor: pointer;
  border-radius: 999px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: inline-block;
  padding: 6px 14px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  border-radius: 999px;
  transition: all 0.16s ease;
  font-weight: 500;
}
.segmented label:hover span { color: var(--text); }
.segmented label:has(input:checked) span {
  background: var(--accent);
  color: #0d0c0e;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Iteration 9 Fix 1: 並び順 (sort key) と並び方向 (asc/desc) を視覚的に分ける小さなギャップ */
.segmented.sort-direction { margin-left: 4px; }

.meta-row {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  margin-top: 4px;
  justify-content: space-between;
}
.result-count {
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.05em;
}
.btn-clear {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-family: var(--font-sans);
  transition: all 0.16s ease;
}
.btn-clear:hover {
  color: var(--accent-soft);
  border-color: var(--accent-soft);
  background: var(--accent-glow);
}

.status {
  min-height: 0;
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}
.status.loading::before { content: "⏳ "; }
.status.error { color: var(--danger); }

/* ============================================================
   Card grid
============================================================ */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 26px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  position: relative;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-line);
  box-shadow: var(--shadow-card-hover);
}

.card-image {
  display: block;
  width: 100%;
  aspect-ratio: 488 / 680;
  background: #0a090c;
  object-fit: cover;
}
.card-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
  font-family: var(--font-serif);
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 18px;
  color: var(--text-strong);
  margin: 0;
  line-height: 1.25;
  letter-spacing: 0.005em;
}
.card-name-en {
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
  letter-spacing: 0.06em;
  font-style: italic;
}
.card-type {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
}

.card-pips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.pip-mini {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5));
}

/* 俗称チップ (フェッチランド / ショックランド 等) */
.card-nickname {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--accent-soft);
  background: var(--accent-glow);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  padding: 2px 9px;
  line-height: 1.5;
  margin-left: 4px;
  white-space: nowrap;
  font-weight: 500;
}

.card-stats {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-dim);
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: auto;
  letter-spacing: 0.04em;
}
.card-stats .stat { display: inline-flex; gap: 4px; align-items: baseline; }
.card-stats .stat strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.card-stats .price strong { color: var(--accent-soft); }
.card-stats .reprints {
  border-left: 1px solid var(--border-soft);
  padding-left: 14px;
  margin-left: auto;
}

.card-note {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--text-dim);
  background: linear-gradient(90deg, var(--accent-glow) 0%, transparent 100%);
  border-left: 2px solid var(--accent);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
}

.card-link {
  font-size: 10px;
  color: var(--text-faint);
  text-align: right;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card-link:hover { color: var(--accent-soft); }

/* card-actions: Scryfall リンクと X ツイートボタンを横並びにするフッター行 */
.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.card-actions .card-link {
  flex: 1;
  text-align: left;
}

/* X (Twitter) ツイートボタン — モノクロームのアウトラインに hover で amber アクセント */
.tweet-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 10px;
  font-family: var(--font-sans);
  line-height: 1.4;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.tweet-btn::before {
  content: "𝕏";
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
}
.tweet-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  text-decoration: none;
  transform: translateY(-1px);
}

/* Budget filter disabled state */
.segmented[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================================
   Color identity toggle (pill switch)
   Phyrexian-MTG inspired: clean gray-when-off → amber-when-on switch.
============================================================ */
.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px;
  border-radius: 999px;
  transition: all 0.18s ease;
  position: relative;
}
.toggle-pill input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.toggle-track {
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.toggle-pill:hover .toggle-track {
  border-color: var(--accent-soft);
}
.toggle-pill:has(input:checked) .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(201,168,97,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.toggle-pill:has(input:checked) .toggle-thumb {
  left: 20px;
  background: #0d0c0e;
  box-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.toggle-pill input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}
.toggle-text {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 500;
  transition: color 0.18s ease;
}
.toggle-pill:has(input:checked) .toggle-text {
  color: var(--text-strong);
  font-weight: 600;
}

/* ============================================================
   Custom budget inputs
============================================================ */
.budget-or {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 6px;
  font-weight: 500;
}
.budget-custom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
  flex-wrap: wrap;
}
.budget-custom[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.budget-input {
  width: 90px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: all 0.16s ease;
}
.budget-input::-webkit-outer-spin-button,
.budget-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.budget-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 0 0 3px var(--accent-glow);
}
.budget-input:disabled { cursor: not-allowed; }

/* ============================================================
   Text search (テキスト検索)
   .filters の最上段に置く検索 input + クリア (×) ボタン。
   既存の filter-row の枠組みを再利用しつつ、入力欄は budget-input と
   同じビジュアル言語 (border / radius / focus glow) で揃える。
   モバイルでは button が指でタップしやすいよう min 44x44px (Apple HIG / WCAG 2.5.5) を守る。
============================================================ */
.text-search-row {
  /* filter-label の min-width に合わせて他の行と縦軸が揃う。 */
}
.text-search-input {
  flex: 1 1 280px;
  min-width: 220px;
  max-width: 480px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: all 0.16s ease;
  /* type="search" のブラウザ既定 × 装飾を消して独自ボタンに統一。 */
  -webkit-appearance: none;
  appearance: none;
}
.text-search-input::-webkit-search-cancel-button,
.text-search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.text-search-input::placeholder {
  color: var(--text-faint);
}
.text-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 0 0 3px var(--accent-glow);
}
.btn-clear-search {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
}
/* `display: inline-flex` の優先度は HTML 属性 [hidden] の UA 既定 display:none を
   上書きしてしまうため、明示的に [hidden] を打ち消す。 */
.btn-clear-search[hidden] {
  display: none;
}
.btn-clear-search:hover {
  color: var(--text);
  border-color: var(--accent);
}
.btn-clear-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset, 0 0 0 3px var(--accent-glow);
}

/* ============================================================
   Retailer search buttons
============================================================ */
.card-retailers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.retailer-label {
  width: 100%;
  font-size: 9px;
  color: var(--text-faint);
  margin-bottom: 4px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
}
.retailer-btn {
  display: inline-block;
  padding: 4px 9px;
  font-size: 11px;
  line-height: 1.3;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-dim);
  text-decoration: none;
  font-family: var(--font-sans);
  letter-spacing: 0.02em;
  transition: all 0.14s ease;
}
.retailer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
}

/* ============================================================
   Favorite (★) button on each card
   - Top-right of .card, absolute over the image area.
   - ☆ outline when not favorited, ★ filled gold when active.
   - 44x44 hit target via ::before pseudo (visual size = 30x30).
   - aria-pressed reflects state; styled via attribute selector.
============================================================ */
.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.45);
  background: rgba(13, 12, 14, 0.78);
  color: var(--text-strong);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-sans);
  /* iOS/Safari tap-highlight 抑止 */
  -webkit-tap-highlight-color: transparent;
  transition: color 0.16s ease, background 0.16s ease,
              border-color 0.16s ease, transform 0.16s ease;
}
/* 44x44 hit area without changing visual size — invisible expanded touch zone */
.fav-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}
.fav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(13, 12, 14, 0.92);
  transform: scale(1.06);
}
.fav-btn:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}
.fav-btn[aria-pressed="true"] {
  color: #d4a017;
  border-color: #d4a017;
  background: rgba(13, 12, 14, 0.85);
  text-shadow: 0 0 6px rgba(212, 160, 23, 0.55);
}
.fav-btn[aria-pressed="true"]:hover {
  color: #e6b835;
  border-color: #e6b835;
}

/* ============================================================
   Pagination
============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 12px;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
}
.page-btn {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  letter-spacing: 0.06em;
  transition: all 0.16s ease;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.page-indicator {
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 15px;
  min-width: 120px;
  text-align: center;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.page-size-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.page-size-select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.14s ease;
}
.page-size-select:hover { border-color: var(--accent); }

/* Note: 旧 ".price-jpy" 補助スタイルは円建て表示への移行で不要になり削除した。
   現在 priceText() は "¥190" 等のプレーンテキストを返し、
   .card-stats .price strong (line ~422) のスタイルだけが適用される。 */

.rate-note {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-faint);
  opacity: 0.85;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

/* iteration 5 Fix 1: 30 日以上経過したキャッシュ警告。
   控えめなトーンで「画像が出ない可能性」を伝える。空 textContent の時は
   ::empty で margin/padding を消して footer のレイアウトを乱さない。 */
.cache-age-warning {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--danger);
  opacity: 0.78;
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}
.cache-age-warning:empty {
  display: none;
  margin: 0;
}

/* ============================================================
   Footer
============================================================ */
.site-footer {
  text-align: center;
  padding: 32px 16px 40px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
  margin-top: 40px;
  position: relative;
}
.site-footer::before {
  content: "";
  display: block;
  width: min(280px, 60%);
  height: 1px;
  margin: 0 auto 22px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent-line) 50%,
    transparent 100%
  );
  opacity: 0.7;
}
.site-footer p { margin: 4px 0; }
.site-footer .footer-credits {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--text-dim);
}
.site-footer .footer-references a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin: 0 2px;
}
.site-footer .footer-references a:hover {
  color: var(--text);
}

/* Iteration 10: 1 つだけサイト全体をシェアする X ボタン (per-card 版から置き換え)。
   .tweet-btn の視覚言語 (X 文字 + アウトライン) を踏襲しつつ、footer 文脈に合うサイズに。 */
.footer-share { margin-top: 14px !important; }
.footer-tweet-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 11px;
  font-family: var(--font-sans);
  line-height: 1.4;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.14s ease;
  white-space: nowrap;
}
.footer-tweet-btn::before {
  content: "𝕏";
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}
.footer-tweet-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  text-decoration: none;
  transform: translateY(-1px);
}

/* Iteration 10: build-info.js が露出する commit/date を控えめに表示する。 */
.footer-build { margin-top: 10px !important; }
.build-info {
  color: #888;
  font-size: 0.75rem;
  opacity: 0.7;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ============================================================
   Mobile / responsive
============================================================ */
@media (max-width: 600px) {
  .site-header { padding: 36px 12px 20px; }
  .site-header h1 { font-size: 30px; }
  .site-header .subtitle { font-size: 10px; letter-spacing: 0.28em; }

  main { padding: 16px 12px 28px; }
  .filters { padding: 14px 14px; gap: 12px; }
  .filter-label { min-width: 100%; font-size: 10px; }

  .results-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .card-body { padding: 10px 12px 12px; gap: 6px; }
  .card-name { font-size: 15px; }
  .card-name-en { font-size: 10px; }
  .card-type { font-size: 9px; }
  .card-stats { flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  .card-stats .reprints { border-left: 0; padding-left: 0; margin-left: 0; }
  .card-note { font-size: 12px; padding: 5px 8px; }

  .pagination { gap: 8px; padding: 10px 12px; }
  .page-size-label { margin-left: 0; width: 100%; justify-content: flex-end; }
  .page-indicator { min-width: 100px; font-size: 13px; }
  .page-btn { padding: 6px 12px; font-size: 12px; }
}

/* iPhone SE / small phone tier (~375px wide).
 * mino-driven レビュー指摘 (MEDIUM): 600px のみで 375px は調整なしだった。
 * 横スクロール抑止と各 UI のタップ容易性を主目標に絞り込み。 */
@media (max-width: 480px) {
  body { font-size: 14px; }

  main { padding: 12px 10px 24px; }
  .site-header { padding: 28px 10px 16px; }
  .site-header h1 { font-size: 24px; letter-spacing: 0.01em; }
  .site-header h1 .ornament { margin: 0 0.25em; }
  .site-header .subtitle { font-size: 9px; letter-spacing: 0.22em; }

  /* Filter panel: ensure no horizontal overflow on 375px. */
  .filters { padding: 12px 10px; gap: 10px; }
  .filter-row { gap: 8px; }
  .filter-label { min-width: 100%; font-size: 9px; letter-spacing: 0.16em; }

  /* 色チップ: 1 行 6 個入れたいので chip 自体を縮小、wrap で 2 行に分けても OK。 */
  .color-checkboxes { gap: 6px; }
  .color-chip { padding: 6px 10px; gap: 6px; }
  .color-chip .pip-svg { width: 18px; height: 18px; }
  .color-chip .ja { font-size: 12px; }

  /* segmented (mode / budget preset): radio が 5 個ある予算 preset で wrap させる。 */
  .segmented { flex-wrap: wrap; padding: 2px; }
  .segmented span { padding: 5px 10px; font-size: 11px; }

  /* カスタム予算: 入力欄を縮小、改行可能に。 */
  .budget-or { margin: 0 4px; font-size: 10px; }
  .budget-custom { gap: 4px; font-size: 11px; }
  .budget-input { width: 72px; padding: 4px 8px; font-size: 12px; }

  /* グリッド: 375px 幅では 1 列〜2 列に。160px min は 375px 内で 2 列入る。 */
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-body { padding: 8px 10px 10px; gap: 5px; }
  .card-name { font-size: 14px; }
  .card-name-en { font-size: 9px; letter-spacing: 0.04em; }
  .card-type { font-size: 8px; letter-spacing: 0.12em; }
  .card-pips { gap: 4px; }
  .pip-mini { width: 16px; height: 16px; }
  .card-stats { font-size: 10px; gap: 6px; padding-top: 6px; }
  .card-note { font-size: 11px; padding: 4px 6px; }

  /* リテーラーボタン: 横スクロール防止のため折返し前提でフォントサイズを縮小。 */
  .retailer-btn { padding: 3px 7px; font-size: 10px; }
  .retailer-label { font-size: 8px; }

  /* tweet ボタン: 縮小 */
  .tweet-btn { padding: 2px 7px; font-size: 9px; }
  .card-link { font-size: 9px; }

  /* ページネーション: 全要素折返し可、横幅圧迫を解消 */
  .pagination { gap: 6px; padding: 8px 10px; }
  .page-btn { padding: 5px 10px; font-size: 11px; }
  .page-indicator { min-width: 80px; font-size: 12px; }
  .page-size-label { font-size: 10px; }

  /* footer 文字小型化 */
  .site-footer { padding: 22px 10px 26px; font-size: 10px; }
  .site-footer .footer-credits { font-size: 11px; }
  .rate-note { font-size: 10px; }
  .cache-age-warning { font-size: 10px; }
}
