*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1c1917;
  --text-sub: #6b7280;
  --accent: #b45309;
  --accent-light: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── ヘッダー ─── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.site-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -.02em;
}
nav { display: flex; gap: 1.5rem; }
nav a { color: var(--text-sub); font-size: .9rem; }
nav a:hover { color: var(--text); text-decoration: none; }

/* ─── フッター ─── */
footer {
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-sub);
  font-size: .85rem;
}

/* ─── コンテナ ─── */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ─── 展覧会カード ─── */
.ex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.ex-card-wrap {
  position: relative;
  display: flex;
}
.ex-card-wrap .ex-card { flex: 1; min-width: 0; }

/* ☆ PickUP トグル */
.pickup-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .15);
  background: rgba(255, 255, 255, .9);
  color: #6b7280;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  transition: transform .12s, color .12s, background .12s;
}
.pickup-btn:hover { transform: scale(1.08); color: var(--accent); }
.pickup-btn.picked {
  color: #d97706;
  background: #fff7ed;
  border-color: #fdba74;
}

/* ヘッダの PickUP バッジ */
.pickup-badge {
  display: none;
  margin-left: .25rem;
  padding: .05rem .4rem;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  vertical-align: middle;
}
.pickup-badge.has-count { display: inline-block; }

/* マイページ用 */
.mypage-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.mypage-controls .result-count { margin-bottom: 0; }

.ex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.ex-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
/* フライヤー (A4 縦) を切らずに表示するため縦長 + contain. レターボックス分はニュートラル背景. */
.ex-card-img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #1f2937;
}
.ex-card-img-placeholder {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 2.5rem;
}
.ex-card-body { padding: .9rem 1rem; flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.ex-card-title { font-size: .95rem; font-weight: 700; line-height: 1.4; color: var(--text); }
.ex-card-venue { font-size: .82rem; color: var(--text-sub); }
.ex-card-dates { font-size: .8rem; color: var(--text-sub); margin-top: auto; padding-top: .4rem; }

/* Phase 3b: タイトル分解の表示 (prefix / sub) + ジャンルバッジ */
.ex-card-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .15rem; line-height: 1; }
.ex-card-prefix, .ex-card-genre {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
}
.ex-card-prefix { background: #fef3c7; color: #92400e; }
.ex-card-genre  { background: #e0e7ff; color: #3730a3; }
.ex-card-sub {
  font-size: .82rem;
  color: var(--text-sub);
  margin-bottom: .15rem;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ex-card-area {
  display: inline-block;
  font-size: .72rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* ─── バッジ ─── */
.badge-ending {
  display: inline-block;
  font-size: .7rem;
  padding: .1rem .4rem;
  border-radius: 999px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 600;
}

/* ─── 検索フォーム ─── */
.search-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.search-bar label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .82rem;
  color: var(--text-sub);
  font-weight: 600;
}
.search-bar select,
.search-bar input[type=text] {
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  background: #fff;
  color: var(--text);
  min-width: 130px;
}
.search-bar select:focus,
.search-bar input[type=text]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn-search {
  padding: .5rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-search:hover { background: #92400e; }
.btn-clear {
  padding: .5rem 1rem;
  background: #e5e7eb;
  color: var(--text);
  border: none;
  border-radius: 6px;
  font-size: .9rem;
  cursor: pointer;
}

/* ─── エリア ポップアップ ─── */
.area-picker {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.area-picker-label {
  font-size: .82rem;
  color: var(--text-sub);
  font-weight: 600;
}
.area-btn {
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-width: 180px;
  justify-content: space-between;
}
.area-btn:hover { border-color: var(--accent); }
.area-btn[aria-expanded="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#area-btn-text { color: var(--text-sub); }
#area-btn-text.has-selection { color: var(--text); font-weight: 600; }
.area-btn-caret { font-size: .7rem; color: var(--text-sub); }

.area-popup {
  position: absolute;
  top: calc(100% + .3rem);
  left: 0;
  /* Leaflet の panes は最大 700, controls は 1000. それより上に表示するため. */
  z-index: 2000;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: .9rem 1rem .7rem;
  min-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
}
.area-popup[hidden] { display: none; }
.area-popup-group + .area-popup-group {
  margin-top: .7rem;
  padding-top: .7rem;
  border-top: 1px dashed var(--border);
}
.area-popup-heading {
  font-size: .75rem;
  color: var(--text-sub);
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}
.area-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: .45rem;
  padding: .25rem .15rem;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  border-radius: 4px;
}
.area-check:hover { background: var(--surface); }
.area-check input[type=checkbox] {
  margin: 0;
  cursor: pointer;
}
.area-check input[type=checkbox]:disabled ~ span,
.area-check input[type=checkbox]:disabled + span {
  color: var(--border);
  cursor: not-allowed;
}
.area-count {
  margin-left: auto;
  font-size: .78rem;
  color: var(--text-sub);
}
.area-popup-footer {
  display: flex;
  gap: .5rem;
  margin-top: .8rem;
  padding-top: .7rem;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.area-popup-btn {
  padding: .35rem .85rem;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  font-size: .85rem;
  cursor: pointer;
  color: var(--text);
}
.area-popup-btn:hover { background: var(--surface); }
.area-popup-btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.area-popup-btn-primary:hover { background: #92400e; }

@media (max-width: 600px) {
  .area-popup {
    left: 0;
    right: 0;
    min-width: 0;
  }
}

/* ─── 件数表示 ─── */
.result-count { font-size: .9rem; color: var(--text-sub); margin-bottom: 1rem; }
.result-count strong { color: var(--text); }

/* ─── ヒーロー ─── */
.hero {
  background: linear-gradient(135deg, #1c1917 0%, #44403c 100%);
  color: #fff;
  padding: 3.5rem 1.5rem;
  text-align: center;
}
.hero h1 { font-size: 2rem; font-weight: 800; margin-bottom: .5rem; }
.hero p { color: #d6d3d1; font-size: 1rem; margin-bottom: 1.5rem; }
.hero-search {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  gap: .5rem;
}
.hero-search input {
  flex: 1;
  padding: .65rem 1rem;
  border-radius: 6px;
  border: none;
  font-size: 1rem;
}
.hero-search button {
  padding: .65rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
}

/* ─── セクション見出し ─── */
.section-heading {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

/* ─── 詳細ページ ─── */
.ex-detail { max-width: 800px; margin: 0 auto; }
.ex-detail-img { width: 100%; max-height: 400px; object-fit: contain; border-radius: var(--radius); background: #f3f4f6; margin-bottom: 1.5rem; }
.ex-meta { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.25rem; font-size: .9rem; margin: 1.25rem 0; }
.ex-meta dt { color: var(--text-sub); font-weight: 600; }
.ex-meta dd { color: var(--text); }

/* ─── 詳細ページのアクションボタン ─── */
.ex-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 1.5rem 0;
}
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1.1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #92400e; }
.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.alt-sources { margin-top: 1rem; padding: .8rem 1rem; background: var(--surface); border-radius: 6px; border: 1px solid var(--border); }
.alt-sources-heading { font-size: .8rem; font-weight: 700; color: var(--text-sub); margin-bottom: .4rem; }
.alt-sources ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .8rem; }
.alt-sources li { font-size: .85rem; }
.alt-sources a { color: var(--accent); text-decoration: none; }
.alt-sources a:hover { text-decoration: underline; }

/* ─── レスポンシブ ─── */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.4rem; }
  .hero-search { flex-direction: column; }
  .ex-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .search-bar { flex-direction: column; align-items: stretch; }
}
@media (max-width: 400px) {
  .ex-grid { grid-template-columns: 1fr; }
}
