:root {
  color-scheme: light;
  --color-primary: #0DA2BD;
  --color-stone: #ABA79D;
  --color-bg: #F4F5F3;
  --color-text: #303438;
  --color-surface: #FFFFFF;
  --color-border: #D8D6CF;
  --color-likely: #0DA2BD;
  --color-maybe: #ABA79D;
  --color-rare: #6B7785;
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --ink: var(--color-text);
  --muted: #6B706A;
  --line: var(--color-border);
  --accent: var(--color-primary);
  --accent-dark: #087C91;
  --warm: var(--color-maybe);
  --rare: var(--color-rare);
  --shadow: 0 16px 36px rgba(48, 52, 56, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  /* 欧文は端末のUIフォント、日本語は Noto Sans JP。端末まかせだと太字が機械的に太らされて、字面が濁る */
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: var(--color-stone);
  cursor: not-allowed;
}

/* 上の帯。名前（操作しないもの）と検索（操作するもの）の種類を分けるための入れ物。
   帯に名前だけを置くと間が持たないので、検索もここに入れて帯に仕事をさせる。
   いちばん右はメニューボタン（画面に固定）のための空き */
/* 帯は名前（操作しないもの）だけを載せる枠。検索やレイヤーの切り替えは地図を操作するものなので
   地図の上に置く。両方を同じ面に丸い札で並べると、どれが主役か分からなくなる */
.app-header {
  position: relative;
  z-index: 1100;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 0 clamp(14px, 3vw, 22px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

/* 絵は favicon.svg と同じ（色も絵の中に持つ）。角丸の影だけここで付ける */
.app-logo {
  display: block;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 7px;
  box-shadow: 0 3px 9px rgba(13, 162, 189, 0.32);
}

.app-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.app-brand-text {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.app-brand-name {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* 説明は細い区切り線のうしろに小さく。狭い画面では隠す */
.app-brand-tagline {
  padding-left: 11px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .app-brand-tagline {
    display: none;
  }
}

/* メニューボタンのぶんの空き。ボタン自体は画面に固定してあるので、ここには何も入らない */
.app-header-menu-slot {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.layer-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}

/* 地図を画面いっぱいに敷いて、結果はその上に浮かせる。
   地図と結果を横に並べると、地図が「四角い部品のひとつ」に見えてしまう。
   --panel-w は結果パネルの幅。地図の上の操作や地図の出典表示も、この幅だけ左に逃がす */
/* 地図と結果は重ねずに左右へ分ける。地図の上に浮かせると、結果が「閉じられる付箋」に見えて、
   消す方法があると勘違いさせる。--panel-gap は地図の上に置く操作の内側の余白 */
.app-shell {
  position: relative;
  --panel-w: min(455px, 38vw);
  --panel-gap: 14px;
  height: calc(100vh - 52px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  overflow: hidden;
  transition: grid-template-columns 420ms cubic-bezier(0.4, 0, 0.2, 1);
}

.map-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  opacity: 1;
  transition: opacity 320ms ease;
}

.app-shell.map-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.map-collapsed .map-pane {
  opacity: 0;
  pointer-events: none;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #dce3d3;
}

.leaflet-container {
  width: 100%;
  height: 100%;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  position: relative;
  z-index: 1000;
  pointer-events: auto;
}

.inspect-popup {
  display: grid;
  gap: 5px;
  width: min(250px, 68vw);
}

.inspect-popup-address {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.inspect-popup-button {
  min-width: 132px;
  padding: 0 14px;
  white-space: nowrap;
}

.map-inspect-popup {
  position: absolute;
  z-index: 3000;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}

.map-inspect-popup::before {
  position: absolute;
  bottom: -10px;
  left: 50%;
  width: 18px;
  height: 18px;
  background: #fff;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.12);
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

/* 上に収まらないときは下側に出す。矢印も上向きに付け替える。 */
.map-inspect-popup.is-below::before {
  top: -9px;
  bottom: auto;
  box-shadow: -3px -3px 8px rgba(0, 0, 0, 0.1);
}

.map-inspect-popup[hidden] {
  display: none;
}

.map-inspect-popup .inspect-popup {
  position: relative;
  z-index: 1;
}

/* 地図と結果の境目に置く丸いつまみ。地図の上のほかの操作と形をそろえる */
.map-collapse-button,
.map-restore-button {
  position: absolute;
  z-index: 3200;
  display: grid;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.96);
  background-image: none;
  color: var(--muted);
  box-shadow: 0 6px 18px rgba(48, 52, 56, 0.18);
  transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

/* 地図の面の中に収める。境目にまたがらせると、地図の overflow: hidden で半分が切れる */
.map-collapse-button {
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}

/* 折りたたんだあとは結果パネルが画面いっぱいなので、その左端に重ねて置く */
.map-restore-button {
  top: 50%;
  left: 10px;
  z-index: 1300;
  background-color: #eef0ec;
  transform: translateY(-50%);
}

.map-restore-button[hidden] {
  display: none;
}

.map-collapse-button:hover,
.map-restore-button:hover {
  background-color: #e6f4f4;
  background-image: none;
  color: var(--accent-dark);
  box-shadow: 0 8px 20px rgba(48, 52, 56, 0.22);
}

.map-collapse-button:hover {
  transform: translateY(-50%);
}

.map-restore-button:hover {
  transform: translateY(-50%);
}

.map-collapse-button:active {
  transform: translateY(-50%);
}

.map-restore-button:active {
  transform: translateY(-50%);
}

.map-panel-handle-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
  transition: transform 160ms ease;
}

.map-collapse-button:hover .map-panel-handle-icon,
.map-collapse-button:active .map-panel-handle-icon {
  transform: translateX(-2px);
}

.map-restore-button:hover .map-panel-handle-icon,
.map-restore-button:active .map-panel-handle-icon {
  transform: translateX(2px);
}

/* 右上の操作を1列にまとめる。Leaflet は追加した順に積むので、並び順は order で決める。
   結果パネルの下に潜らせないよう、パネルの幅だけ左に逃がす */
.leaflet-top.leaflet-right {
  right: var(--panel-gap);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: calc(var(--panel-gap) - 8px);
}

.leaflet-top.leaflet-right .geology-control {
  order: 1;
}

.leaflet-top.leaflet-right .leaflet-control-zoom {
  order: 2;
}

.leaflet-right .leaflet-control {
  float: none;
  clear: both;
  margin-top: 8px;
  margin-right: 0;
}



.leaflet-bottom .leaflet-control {
  margin-bottom: 12px;
}



.leaflet-left .leaflet-control {
  margin-left: 12px;
}

/* 検索は地図を操作するものなので、地図の上に浮かせる。
   結果パネルの下に潜らせない（潜らせると入力欄が白いパネルの裏に消える） */
.map-search-bar {
  position: absolute;
  z-index: 3300;
  top: var(--panel-gap);
  left: var(--panel-gap);
  /* 右上の操作（36px）とその余白のぶんを空ける */
  right: calc(var(--panel-gap) + 46px);
  display: flex;
  pointer-events: none;
}

.map-search {
  display: flex;
  align-items: center;
  gap: 4px;
  width: min(420px, 100%);
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 24px rgba(48, 52, 56, 0.18);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  transition: box-shadow 160ms ease;
}

.map-search:focus-within {
  box-shadow: 0 8px 24px rgba(48, 52, 56, 0.18), 0 0 0 2px rgba(13, 162, 189, 0.4);
}

.map-search input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.93rem;
}

.map-search input:focus {
  outline: none;
}

.search-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.search-icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-icon-button:hover {
  background: rgba(48, 52, 56, 0.08);
  color: var(--ink);
}

.search-icon-button.is-submit {
  background: var(--accent);
  color: #fff;
}

.search-icon-button.is-submit:hover {
  background: var(--accent-dark);
  color: #fff;
}

/* 結果は地図の上に浮かぶ1枚のカード。幅が変わると地図の見える範囲も変わる */
/* 結果は地図の隣に並ぶ面。角丸や影は付けない（浮いていると「閉じられるもの」に見える） */
.result-pane {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

/* 切り替えは上に貼り付ける。中身が長いので、スクロールしても戻らずに切り替えられるようにする。
   右側はメニューボタン（画面に固定）のぶんを空けておく */
.result-head {
  position: sticky;
  z-index: 3;
  top: 0;
  display: grid;
  gap: 12px;
  padding: 16px 0 0;
  /* タブの下線で中身を切るので、ぼかさずに塗る */
  background: var(--panel);
}

/* 選んだ地点は「結果の見出し」。地図の上に帯で出すと、地質図の切り替えと同じ形になって、
   表示なのか操作なのか分からなくなる。小さな見出し＋地名の組みにして、面を持たせない */
.result-place {
  display: grid;
  gap: 2px;
  width: 100%;
  margin: 0;
  padding: 0 20px;
}

.result-place[hidden] {
  display: none;
}

.result-place-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.result-place-name {
  /* 逆引きの住所は長いことがあるので2行で打ち切る。全文は title 属性で出す */
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

/* 地質図の表示切り替え（Leaflet のコントロール） */

/* ズームも同じ幅・同じ角丸にそろえる */
.leaflet-control-zoom {
  border: 0 !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(48, 52, 56, 0.18);
}

.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  border: 0 !important;
  background: rgba(255, 255, 255, 0.97);
  color: var(--ink);
  font-size: 1.1rem;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid rgba(171, 167, 157, 0.35) !important;
}

.leaflet-control-zoom a:hover {
  background: #e6f4f4;
  color: var(--accent-dark);
}

/* 地図の操作は、同じ大きさ・同じ形のアイコンを縦に並べる。
   幅の違うもの（文字つきのスイッチと細い＋−）を重ねると、そろっていないように見える */
.map-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.97);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(48, 52, 56, 0.18);
  transition: background 160ms ease, color 160ms ease;
}

.map-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 押されている（地質図が出ている）ことを色で示す */
.map-icon-button.is-on {
  background: var(--accent);
  color: #fff;
}

.map-icon-button:hover {
  background: #e6f4f4;
  color: var(--accent-dark);
}

.map-icon-button.is-on:hover {
  background: var(--accent-dark);
  color: #fff;
}

/* 切り替えは半分ずつの2枚のタブ。幅を中身に合わせると、2つの項目の大きさが
   ちぐはぐになり、パネルの中で行き場のない形になる */
.tab-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
}

.tab-buttons button {
  position: relative;
  min-height: 46px;
  padding: 0 10px;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  box-shadow: none;
  transition: background 160ms ease, color 160ms ease;
}

/* いま見ているほうを下線で示す。枠で囲うより、2枚が地続きに見える */
.tab-buttons button::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
  transition: background 160ms ease;
}

.tab-buttons button:hover {
  background: rgba(171, 167, 157, 0.12);
  color: var(--ink);
}

.tab-buttons button:active {
  transform: none;
}

.tab-buttons button.active {
  background: transparent;
  color: var(--accent-dark);
}

.tab-buttons button.active::after {
  background: var(--accent);
}

/* 中身が短いときも断り書きが下に落ちるように、切り替えの箱が残りの高さを取る */
.tabs {
  flex: 1 0 auto;
}

.tab-panel {
  display: none;
  padding: 16px 20px 0;
}

.tab-panel.active {
  display: block;
}

/* 何も選んでいないとき。白いパネルに1行だけだと間が持たないので、
   目印の丸と手順を置く。手順は最初だけで、1度でも操作したら出さない（script.js） */
.panel-intro {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 46px 6px 20px;
  text-align: center;
}

/* 取得中や取得失敗のときは、案内の丸と手順を出さずに文だけにする */
.panel-intro:has(.empty-message[hidden]) {
  display: none;
}

.panel-intro-icon {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(13, 162, 189, 0.1);
  color: var(--accent-dark);
}

.panel-intro-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-message {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.7;
}

/* 手順。番号は丸い札にして、文は左ぞろえで読ませる */
.panel-steps {
  display: grid;
  gap: 11px;
  width: 100%;
  max-width: 320px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  text-align: left;
}

.panel-steps li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

/* hidden は display: grid に負けるので、明示的に消す */
.panel-steps[hidden] {
  display: none;
}

.panel-steps li::before {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(171, 167, 157, 0.2);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 700;
  counter-increment: step;
  content: counter(step);
}

.geology-list {
  display: grid;
  gap: 12px;
}

.rock-cards {
  display: grid;
  gap: 24px;
}

.rock-level-section {
  display: grid;
  gap: 14px;
}

.rock-section-header {
  display: grid;
  gap: 5px;
}

.rock-section-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin: 0;
  padding: 0;
  color: var(--rock-section-accent);
  font-size: 0.96rem;
}

.rock-section-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.rock-section-title::before {
  display: block;
  width: 4px;
  height: 1.35em;
  border-radius: 1px;
  background: var(--rock-section-accent);
  content: "";
}

.rock-grid {
  display: grid;
  align-items: stretch;
  justify-content: start;
  gap: var(--rock-gap);
  grid-template-columns: repeat(var(--rock-columns), minmax(0, 1fr));
}

.rock-level-likely {
  --rock-section-accent: var(--color-likely);
  --rock-card-size: 220px;
  --rock-name-size: 1.1rem;
  --rock-detail-size: 1.1rem;
  --rock-columns: 2;
  --rock-gap: 16px;
}

.rock-level-maybe {
  --rock-section-accent: var(--color-maybe);
  --rock-card-size: 180px;
  --rock-name-size: 0.95rem;
  --rock-detail-size: 0.95rem;
  --rock-columns: 3;
  --rock-gap: 16px;
}

.rock-level-rare {
  --rock-section-accent: var(--color-rare);
  --rock-card-size: 140px;
  --rock-name-size: 0.8rem;
  --rock-detail-size: 0.8rem;
  /* 浮かせたパネルの幅では4列にすると1列95pxしかなく、名前が縦に割れる */
  --rock-columns: 3;
  --rock-gap: 16px;
}

.app-shell.map-collapsed .rock-grid {
  display: flex;
  flex-wrap: wrap;
}

.geology-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.rock-card {
  width: 100%;
  display: grid;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(48, 52, 56, 0.08), 0 8px 20px rgba(48, 52, 56, 0.08);
  overflow: hidden;
  transition: box-shadow 180ms ease, transform 180ms ease;
}

/* 高さをそろえたぶんの余りは下に出す。写真と名前は上にそろえる */
.rock-card {
  align-content: start;
}

.rock-card:hover {
  box-shadow: 0 1px 2px rgba(48, 52, 56, 0.1), 0 12px 26px rgba(48, 52, 56, 0.14);
  transform: translateY(-2px);
}

.app-shell.map-collapsed .rock-card {
  width: var(--rock-card-size);
}

/* 開いているカードは、下に敷いた説明とつながって見えるように縁を色で示す */
.rock-card.is-expanded {
  border-color: var(--rock-section-accent);
}

.rock-photo-link {
  display: block;
  background: rgba(171, 167, 157, 0.14);
}

.rock-photo-link:focus-visible,
.rock-card-summary:focus-visible,
.rock-detail-link:focus-visible {
  outline: 3px solid rgba(46, 125, 91, 0.32);
  outline-offset: 3px;
}

.rock-photo {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.78;
  object-fit: cover;
}

.rock-card-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 42px;
  padding: 7px 10px 8px;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.rock-card-summary h4 {
  margin: 0;
  font-size: var(--rock-name-size);
  line-height: 1.12;
}

.rock-card-summary:hover {
  background: rgba(244, 245, 243, 0.9);
  color: var(--ink);
}

.rock-card-summary:active {
  transform: none;
}

.rock-toggle-icon {
  display: inline-grid;
  place-items: center;
  justify-self: end;
  width: 24px;
  height: 24px;
  color: var(--color-primary);
  transition: transform 180ms ease;
}

.rock-toggle-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rock-card-summary.is-open .rock-toggle-icon {
  transform: rotate(180deg);
}

.geology-card {
  padding: 14px;
}

/* 説明はカードの中ではなく、カードの行の下に幅いっぱいで敷く。
   カードを広げると押したカードが別の行へ飛ぶうえ、「珍しい」は幅110pxしか
   ないので、広げても本文が読める幅にならない（差し込む位置は
   script.js の layoutRockDetails() が決める）。 */
.rock-details {
  position: relative;
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  width: 100%;
  margin-top: 7px;
  border: 1px solid var(--rock-section-accent);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(48, 52, 56, 0.08);
  padding: 14px 16px 16px;
  color: var(--muted);
  /* 見つかる度が低いほど文字を小さくしているが、説明まで小さいと読めない */
  font-size: max(0.95rem, var(--rock-detail-size));
  line-height: 1.6;
}

/* どのカードの説明かを三角で指す。--notch-x はカードの中心の位置 */
.rock-details::before {
  position: absolute;
  top: -7px;
  left: clamp(16px, var(--notch-x, 24px), calc(100% - 16px));
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-top: 1px solid var(--rock-section-accent);
  border-left: 1px solid var(--rock-section-accent);
  border-radius: 3px 0 0 0;
  background: #fff;
  transform: rotate(45deg);
  content: "";
}

.rock-details p {
  margin: 0;
}

.rock-details[hidden] {
  display: none;
}

/* 見つけた／探したけど無かった。説明の下に細い線で区切って置く。
   2つは同じ重さの答えなので、同じ大きさの枠ボタンを半分ずつ並べ、選んでいるほうだけ塗る */
.rock-report {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.rock-details .rock-report-label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.rock-report-label a {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.rock-report-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rock-report-button {
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
}

.rock-report-button:hover {
  border-color: var(--accent);
  background: #fff;
  color: var(--accent-dark);
}

.rock-report-button.is-found.is-on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.rock-report-button.is-missing.is-on {
  border-color: var(--rare);
  background: var(--rare);
  color: #fff;
}

.rock-report-button:disabled:not(.is-on) {
  background: #fff;
  color: var(--muted);
  cursor: progress;
}

.rock-details .rock-report-count {
  color: var(--muted);
  font-size: 0.82rem;
}

.rock-details .rock-report-count:empty {
  display: none;
}

/* 結果の終わりのご意見箱へのリンク。結果より前に出ないよう、断り書きと同じくらい控えめに */
.rock-feedback {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.rock-feedback a,
.page-feedback a {
  color: var(--accent-dark);
  font-weight: 700;
}

/* 詳細ページ・用語集・分類マップの終わりの「このページの間違いを知らせる」 */
.page-feedback {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  margin: 0 auto;
  padding: 20px 16px 36px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* ===== このサイトについて（about.html） =====
   注意書き・出典など、読み物というより「確かめるための」ページ。長い箇条書きが続くと目が滑るので、
   冒頭に要点3つ（.about-points）、本文は「見出し語＋説明」の行（.about-rows）を基本にする */

.about-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.about-points a {
  display: grid;
  align-content: start;
  gap: 8px;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.about-points a:hover,
.about-points a:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(48, 52, 56, 0.08);
}

.about-points strong {
  font-size: 0.98rem;
  line-height: 1.4;
}

.about-points span:last-child {
  color: #4f5659;
  font-size: 0.86rem;
  line-height: 1.65;
}

/* いちばん伝えたい1文。本文と同じ段落だと埋もれるので、色の付いた帯にする */
.stone-info-panel p.about-callout {
  margin: 4px 0 14px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: rgba(13, 162, 189, 0.07);
  color: var(--ink);
}

.about-list {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
  padding-left: 1.2em;
  color: #3f4549;
  font-size: 0.98rem;
  line-height: 1.8;
}

.about-list li::marker {
  color: var(--accent);
}

.about-list-small {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* 見出し語＋説明の行。広い画面では左右に、狭い画面では上下に並べる */
.about-rows {
  margin: 0 0 14px;
  border-top: 1px solid var(--line);
}

.about-rows > div {
  display: grid;
  grid-template-columns: 11em minmax(0, 1fr);
  gap: 4px 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.about-rows dt {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.7;
}

.about-rows dd {
  margin: 0;
  color: #3f4549;
  font-size: 0.95rem;
  line-height: 1.75;
}

.about-rows a,
.about-page .stone-info-panel p a:not(.about-button) {
  color: var(--accent-dark);
  font-weight: 700;
}

/* 根拠の法律名。本文の後ろに小さな札で添える */
.about-law {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef0ed;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.7;
  white-space: nowrap;
}

.about-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: background 160ms ease;
}

.about-button:hover {
  background: var(--accent-dark);
}

/* ご意見の節は、このページでいちばんしてほしいこと。枠を色で縁取って目立たせる */
.detail-main .about-contact {
  border-color: rgba(13, 162, 189, 0.45);
  background: linear-gradient(180deg, rgba(13, 162, 189, 0.06), var(--panel) 160px);
}

/* 一緒に作りたい方への呼びかけ。送り先は同じご意見箱なので、ボタンは分けずに文だけ添える */
.stone-info-panel p.about-join {
  margin-bottom: 16px;
}

.stone-info-panel p.about-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* 作っている人の名前。名前を大きめに、学年は法律名と同じ小さな札で添える */
.stone-info-panel p.about-author {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 1.15rem;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

/* 右の列のご意見箱。狭い画面では本文の終わりにご意見の節があるので出さない。
   目次も狭い画面では出ないので、右の列ごと消す（空の列が残ると見出しの下に余白が倍に空く） */
.about-aside-contact {
  display: none;
}

@media (max-width: 999px) {
  .about-page .detail-aside {
    display: none;
  }
}

@media (min-width: 1000px) {
  .about-aside-sticky {
    position: sticky;
    top: 80px;
    display: grid;
    gap: 16px;
  }

  .about-page .detail-toc {
    position: static;
  }

  .about-aside-contact {
    display: grid;
    gap: 10px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
  }

  .about-aside-contact p {
    margin: 0;
    color: #4f5659;
    font-size: 0.88rem;
    line-height: 1.6;
  }
}

@media (max-width: 720px) {
  .about-points {
    grid-template-columns: minmax(0, 1fr);
  }

  /* 1列のときは、アイコンを左に置いた背の低い札にする */
  .about-points a {
    grid-template-columns: 30px minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 2px;
    padding: 12px 14px;
  }

  .about-points .stone-panel-icon {
    grid-row: span 2;
  }

  .about-rows > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

.rock-meta,
.geology-meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* 川原や埋立地など、石が他所から運ばれてくる場所での断り書き */
.rock-place-note {
  margin: 0;
  border-left: 3px solid var(--color-primary);
  border-radius: 0 6px 6px 0;
  padding: 11px 14px;
  background: rgba(46, 125, 91, 0.07);
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.65;
}

/* さらに広い範囲を取得中であることの断り */
.rock-widening-note {
  margin: 10px 0 0;
  border-radius: 6px;
  padding: 10px 13px;
  background: rgba(171, 167, 157, 0.16);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* 候補の根拠（この地点の地質 / 周辺の地質 / 運ばれてくる石） */
.rock-source {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.geology-group-title {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.geology-group-title:not(:first-child) {
  margin-top: 14px;
}

.geology-card-point {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(46, 125, 91, 0.22);
}

/* 見どころの鉱物 */
.mineral-section {
  /* 見出しの色棒は .rock-section-title::before がこの変数で描く。
     見つかる度の3セクションと違って、ここは石ではないのでアプリの色を使う */
  --rock-section-accent: var(--color-primary);
  display: grid;
  gap: 14px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.mineral-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mineral-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 5px;
  padding: 11px 13px;
  background: #fff;
}

.mineral-likely {
  border-left-color: var(--color-primary);
}

.mineral-maybe {
  border-left-color: var(--color-maybe);
}

.mineral-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.mineral-name {
  font-size: 1rem;
  font-weight: 700;
}

.mineral-level {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.mineral-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.mineral-item .tags {
  margin: 8px 0 0;
}

.mineral-source {
  margin: 8px 0 0;
  color: var(--color-primary);
  font-size: 0.78rem;
  line-height: 1.5;
}

.mineral-detail-link {
  margin-top: 10px;
}

.mineral-detail-link:focus-visible {
  outline: 3px solid rgba(46, 125, 91, 0.32);
  outline-offset: 3px;
}

/* 上流域の地質一覧 */
.catchment-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.catchment-list li {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px;
  font-size: 0.86rem;
  line-height: 1.5;
}

.catchment-share {
  color: var(--color-primary);
  font-weight: 700;
  text-align: right;
}

.catchment-lithology {
  color: var(--ink);
}

.geology-share {
  margin: 6px 0 0;
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 700;
}

.geology-rocks {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.6;
}

.geology-detail-link {
  margin-top: 10px;
}

/* 地質図の記号。石を拾うのには要らないので畳んでおく */
.geology-symbol {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.geology-symbol summary {
  width: fit-content;
  cursor: pointer;
}

.geology-symbol p {
  margin: 5px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.tag {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(171, 167, 157, 0.16);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(13, 162, 189, 0.1);
  color: var(--accent-dark);
  box-shadow: none;
  font-weight: 700;
  text-decoration: none;
}

.secondary-button:hover {
  background: rgba(13, 162, 189, 0.16);
}

.geology-color {
  width: 100%;
  height: 8px;
  background: var(--line);
}

/* 結果パネルの足もとの断り書き。中身より前に出ないよう、細い線のうしろに小さく置く */
.note {
  margin: 22px 20px 20px;
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.7;
}

.note a {
  color: var(--accent-dark);
  font-weight: 700;
}

html.stone-root,
body.stone-page {
  min-height: 100%;
  height: auto;
}

/* スクロールするのは html だけにする。body まで overflow: auto にすると body もスクロール枠になり、
   上のバーや用語集の索引の position: sticky が body に張り付いて、画面に残らなくなる */
html.stone-root {
  overflow: auto;
}

body.stone-page {
  overflow: visible;
}

.stone-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 60px;
  padding: 10px clamp(8px, 2vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 245, 243, 0.92);
  backdrop-filter: blur(12px);
}

/* 戻る先は直前のページ。矢印だけで伝わるので、文字と枠は持たせない（名前は aria-label と title） */
.stone-back-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.stone-back-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stone-back-button:hover {
  background: rgba(48, 52, 56, 0.07);
  color: var(--ink);
}

.stone-detail {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.stone-loading,
.stone-message-panel {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stone-message-panel h1 {
  margin-bottom: 12px;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
}

/* 標本写真の実寸は354pxしかない。写真の列をこれ以上広げても引き伸ばして
   ぼやけるだけなので、幅を実寸で頭打ちにして、余った幅は説明に回す */
.stone-hero {
  display: grid;
  grid-template-columns: minmax(0, 354px) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

/* 鉱物には写真がないので、見出しだけで1列に伸ばす */
.mineral-hero {
  grid-template-columns: minmax(0, 1fr);
}

.stone-gallery {
  /* 写真の下に出典とサムネイルを置くので縦並び */
  display: grid;
  gap: 10px;
}

.stone-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(48, 52, 56, 0.12);
}

.stone-main-photo {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.86;
  object-fit: cover;
  /* 指で送るとき、画像そのものがドラッグされてしまうのを止める */
  user-select: none;
  -webkit-user-drag: none;
}

/* 送り矢印。写真の上に重ねるので、下地が明るくても暗くても読めるようにする */
.stone-nav {
  position: absolute;
  top: 50%;
  display: grid;
  width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(48, 52, 56, 0.28);
  transform: translateY(-50%);
}

.stone-nav:hover {
  background: #fff;
  color: var(--accent-dark);
}

.stone-nav:active {
  transform: translateY(-50%);
}

.stone-nav-prev {
  left: 8px;
}

.stone-nav-next {
  right: 8px;
}

.stone-nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stone-counter {
  position: absolute;
  right: 8px;
  bottom: 8px;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(48, 52, 56, 0.62);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
}

.stone-thumbnail-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stone-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(22px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.stone-category {
  width: fit-content;
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 4px solid var(--accent);
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

/* 名前は目立てば足りる。64pxまで伸ばすと、開いた画面に見出ししか入らない */
.stone-summary h1 {
  margin-bottom: 4px;
  font-size: clamp(1.5rem, 2.6vw, 2.05rem);
  line-height: 1.15;
}

.stone-english {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 700;
}

.stone-short {
  /* 説明の列は800px近くまで広がる。1行が長いと読みにくいので頭打ちにする */
  max-width: 42em;
  margin-bottom: 0;
  color: #4f5659;
  font-size: 1rem;
  line-height: 1.75;
}

.stone-content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stone-info-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.stone-info-panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 1rem;
}

/* 見出しのアイコン。色は全部そろえる。見出しごとに変えると、色が意味を持って
   いるように見えてしまい、かえって読み取りづらい */
.stone-panel-icon {
  display: grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: rgba(13, 162, 189, 0.1);
  color: var(--accent);
}

.stone-panel-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stone-description-panel,
.stone-wide-panel {
  grid-column: 1 / -1;
}

/* 写真の出典。ライセンス上の表記義務なので、小さくても必ず出す */
.stone-credit {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

.stone-credit:empty {
  display: none;
}

/* 何の面を見ているか。出典と同じ行に置くので、色で切り分ける */
.stone-shot-label {
  margin-right: 8px;
  color: var(--ink);
  font-weight: 700;
}

.stone-credit a {
  color: var(--muted);
  text-decoration: underline;
}

.rock-credit {
  margin: 0;
  padding: 0 10px 7px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

/* 見分け方。現場でいちばん使うので目立たせる */
.stone-identify-panel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.stone-subheading {
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: 0.92rem;
}

.stone-test-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 1.2em;
  color: #4f5659;
  font-size: 0.93rem;
  line-height: 1.7;
}

/* 間違えやすい石。石の名前と決め手を対で並べる */
.stone-confuse-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.stone-confuse-list dt {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.stone-confuse-list dt::before {
  margin-right: 7px;
  color: var(--accent);
  content: "↔";
}

.stone-confuse-list dd {
  margin: 0;
  color: #4f5659;
  font-size: 0.93rem;
  line-height: 1.75;
}

.stone-info-panel p {
  margin-bottom: 12px;
  color: #4f5659;
  line-height: 1.85;
}

.stone-info-panel p:last-child {
  margin-bottom: 0;
}

.stone-tag-list,
.stone-mineral-list,
.stone-term-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stone-tag,
.stone-mineral,
.stone-term {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f7f8f6;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.stone-mineral {
  border-color: rgba(13, 162, 189, 0.26);
  background: #e6f4f4;
}

/* 鉱物ページから母岩の詳細へ飛ぶ。押せることが分かるように色と下線を付ける */
.stone-mineral-link {
  color: var(--accent-dark);
  text-decoration: underline;
}

.stone-mineral-link:hover {
  border-color: rgba(13, 162, 189, 0.55);
  background: #d7eef0;
}

/* 岩相の詳細ページ。石を「この地質そのもの／一緒に出る／混じる」の段に分ける */
.lithology-rock-groups {
  display: grid;
  gap: 14px;
  margin: 0 0 14px;
}

.lithology-rock-groups dt {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.lithology-rock-groups dd {
  margin: 0;
}

.stone-info-panel .lithology-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.7;
}

/* 用語の説明は「間違えやすい」の対とは違うので、↔ を付けない */
.lithology-term-list dt::before {
  content: none;
}

.lithology-mineral-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lithology-mineral-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.lithology-mineral-level {
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.lithology-mineral-reason {
  color: var(--muted);
  font-size: 0.86rem;
}

.lithology-age-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 8px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #4f5659;
  font-size: 0.9rem;
}

.lithology-age-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.lithology-age-swatch {
  flex: 0 0 auto;
  width: 28px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid rgba(48, 52, 56, 0.18);
  border-radius: 3px;
}

.stone-thumbnail {
  flex: 0 0 auto;
  min-height: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f6;
  box-shadow: none;
}

.stone-thumbnail:hover {
  border-color: rgba(13, 162, 189, 0.48);
  background: #e6f4f4;
}

.stone-thumbnail:active {
  transform: none;
}

/* 表示中の1枚。縁だけだと分かりにくいので、ほかを少し落として差を付ける */
.stone-thumbnail.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.stone-thumbnail img {
  display: block;
  width: 58px;
  height: 50px;
  border-radius: 4px;
  object-fit: cover;
  opacity: 0.62;
  transition: opacity 160ms ease;
}

.stone-thumbnail.is-active img,
.stone-thumbnail:hover img {
  opacity: 1;
}

/* 狭い画面では横に置けないので、地図を上、結果を下にする。
   結果は地図に少しかぶせて、下から出てきた紙のように見せる */
@media (max-width: 820px) {
  .app-shell {
    --panel-gap: 12px;
    height: calc(100vh - 52px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(300px, 46vh) minmax(0, 1fr);
    transition: grid-template-rows 420ms cubic-bezier(0.4, 0, 0.2, 1);
  }

  .app-shell.map-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 0 minmax(0, 1fr);
  }

  .result-pane {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  /* 狭い画面では結果欄の高さが半分しかない。「選択地点」とタブの帯を上に貼り付けると、それだけで
     結果を見る場所の3割近くを取ってしまう。だから
     - 「選択地点」は貼り付けず、スクロールすれば見えなくなる見出しにする
     - タブは、分類マップと同じく左端に縦書きのしおりとして出す（上下の場所を取らない）
     しおりを結果欄のスクロールに付いてこさせるため、.result-head を display: contents にして
     タブを .tabs の直接の子として扱う（.result-head の中のままだと、sticky が .result-head の高さで止まる） */
  .result-head {
    display: contents;
  }

  .result-place {
    padding: 14px 14px 0;
  }

  /* 高さ0の入れ物を上に貼り付け、しおりはそこから下へはみ出させる。高さ0なので中身の操作を邪魔しない */
  .tab-buttons {
    position: sticky;
    top: 14px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    height: 0;
    border: 0;
  }

  /* 入れ物の高さが0なので、縮めないように止める（縮むと1字ずつ横に並んでしまう） */
  .tab-buttons button {
    flex: none;
    min-height: 0;
    padding: 14px 8px;
    border-radius: 0 10px 10px 0;
    background: var(--panel);
    box-shadow: 0 2px 10px rgba(48, 52, 56, 0.14);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    writing-mode: vertical-rl;
    /* 選んでいないほうは少し引っこめて、選んでいるほうだけが出ているように見せる */
    transform: translateX(-5px);
    transition: transform 200ms ease, background 200ms ease, color 200ms ease;
  }

  .tab-buttons button:hover {
    background: var(--panel);
    transform: translateX(0);
  }

  .tab-buttons button.active {
    background: var(--accent-dark);
    color: #fff;
    transform: translateX(0);
  }

  /* 縦書きのしおりに「石を見る」は長いので、「石」「地質」だけにする */
  .tab-suffix {
    display: none;
  }

  /* 下線は横並びのタブのときだけのもの */
  .tab-buttons button::after,
  .tab-buttons button.active::after {
    display: none;
  }

  /* しおりの幅（約30px）のぶん、左を空ける */
  .tab-panel {
    padding: 14px 14px 0 44px;
  }

  .note {
    margin: 20px 14px 18px;
  }



  /* 上下に並ぶので、つまみの矢印も上下向きにする */
  .map-collapse-button {
    top: auto;
    right: 14px;
    bottom: 10px;
    transform: none;
  }

  /* つまみが右下に来るので、出典の文字はその左で折り返す（重なると出典が読めず、つまみも押しにくい） */
  .leaflet-control-attribution {
    margin-right: 56px !important;
  }

  .map-restore-button {
    top: auto;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
  }

  .map-collapse-button .map-panel-handle-icon,
  .map-collapse-button:hover .map-panel-handle-icon,
  .map-collapse-button:active .map-panel-handle-icon,
  .map-restore-button .map-panel-handle-icon,
  .map-restore-button:hover .map-panel-handle-icon,
  .map-restore-button:active .map-panel-handle-icon {
    transform: rotate(90deg);
  }

  .map-collapse-button:hover,
  .map-collapse-button:active,
  .map-restore-button:hover {
    transform: none;
  }

  .map-restore-button:hover,
  .map-restore-button:active {
    transform: translateX(-50%);
  }

  .app-header {
    padding: 0 12px;
  }

  .rock-cards {
    gap: 20px;
  }

  .rock-grid {
    --rock-gap: 12px;
    display: flex;
    flex-wrap: wrap;
  }

  .rock-level-likely {
    --rock-card-size: min(190px, 100%);
  }

  .rock-level-maybe {
    --rock-card-size: 160px;
  }

  .rock-level-rare {
    --rock-card-size: 132px;
  }

  .rock-card {
    width: var(--rock-card-size);
  }

  /* 結果パネル自体には余白を付けない（左右の余白は .result-place と .tab-panel が持つ）。
     上に余白があると、上に貼り付けた見出し（.result-head）の上に隙間ができ、スクロールした結果が透けて見える */

  .stone-header {
    min-height: 58px;
    padding: 10px 14px;
  }

  .stone-detail {
    width: min(100% - 24px, 680px);
    padding: 18px 0 32px;
  }

  .stone-hero,
  .stone-content-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .stone-hero {
    margin-bottom: 14px;
  }

  /* 1列になるので、写真は実寸354pxまでで中央に置く */
  .stone-gallery {
    justify-self: center;
    width: min(100%, 354px);
  }

  .stone-summary,
  .stone-info-panel {
    padding: 18px;
  }

  .stone-summary h1 {
    font-size: clamp(1.45rem, 6vw, 1.9rem);
  }
}

/* 名前の決まり方（classification.js）。分類の境目を物差しにして、その石の区間だけ色を付ける。
   目盛りと区間の境は控えめにし、色の付いた区間だけが目に入るようにする */
.classification-help-button {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.classification-help-button::before {
  content: "?";
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.78em;
}

/* ボタン全体の :hover は背景を濃い青緑にするが、このボタンは文字も同じ色なので溶けてしまう。
   薄い背景に変えるだけにする */
.classification-help-button:hover,
.classification-help-button:focus-visible {
  border-color: var(--accent);
  background: #e6f4f4;
  color: var(--accent-dark);
}

.classification-scale {
  margin: 0 0 22px;
}

.classification-scale figcaption {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.classification-title {
  font-weight: 700;
}

.classification-basis,
.classification-source {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.classification-basis {
  margin: 8px 0 0;
}

/* 図の読み方を1文で言う。見出しと横棒の関係がひと目で分かるように */
.classification-summary {
  line-height: 1.7;
}

/* 横棒の、その石の区間の真上に置く名札 */
.classification-tag-row {
  position: relative;
  height: 1.9em;
}

.classification-tag {
  position: absolute;
  bottom: 5px;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  transform: translateX(-50%);
}

.classification-tag::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  border: 5px solid transparent;
  border-top-color: var(--accent-dark);
  transform: translateX(-50%);
}

.classification-tag.is-start {
  transform: translateX(-12px);
}

.classification-tag.is-start::after {
  left: 12px;
}

.classification-tag.is-end {
  transform: translateX(calc(-100% + 12px));
}

.classification-tag.is-end::after {
  left: auto;
  right: 7px;
  transform: none;
}

.classification-bar {
  position: relative;
  height: 18px;
}

/* 区間どうしは2pxのすき間で区切る */
.classification-segment {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 2px solid var(--panel);
  background: #e4e5e1;
}

.classification-segment:first-child {
  border-radius: 4px 0 0 4px;
}

.classification-segment:last-child {
  border-right: 0;
  border-radius: 0 4px 4px 0;
}

.classification-segment.is-marked {
  background: var(--accent);
}

/* アルカリの量で境目が動く区間。色だけに頼らず斜線でも示す */
.classification-segment.is-boundary {
  background: repeating-linear-gradient(135deg, #e4e5e1 0 4px, #d2d4ce 4px 8px);
}

.classification-segment.is-boundary.is-marked {
  background: repeating-linear-gradient(135deg, var(--accent) 0 4px, #6cc7d8 4px 8px);
}

.classification-ticks {
  position: relative;
  height: 1.3em;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.classification-ticks span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.classification-ticks span:first-child {
  transform: none;
}

.classification-ticks span.is-end {
  transform: translateX(-100%);
}

.classification-legend {
  display: grid;
  gap: 4px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.classification-legend li {
  display: grid;
  grid-template-columns: 12px 8.5em minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.classification-legend li.is-marked {
  color: var(--ink);
  font-weight: 700;
}

.classification-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #e4e5e1;
}

.classification-swatch.is-boundary {
  background: repeating-linear-gradient(135deg, #e4e5e1 0 3px, #c4c6bf 3px 6px);
}

.is-marked > .classification-swatch {
  background: var(--accent);
}

.is-marked > .classification-swatch.is-boundary {
  background: repeating-linear-gradient(135deg, var(--accent) 0 3px, #6cc7d8 3px 6px);
}

.classification-range {
  font-variant-numeric: tabular-nums;
}

.classification-note {
  margin: 0 0 10px;
  line-height: 1.8;
}

.classification-source {
  margin: 0;
}

.classification-rock-title {
  margin: 22px 0 12px;
  font-size: 1rem;
}

.classification-rock-title:first-of-type {
  margin-top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.classification-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  line-height: 1.8;
}

.classification-dialog::backdrop {
  background: rgba(48, 52, 56, 0.4);
}

.classification-dialog h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.classification-dialog dt {
  margin-top: 10px;
  font-weight: 700;
}

.classification-dialog dd {
  margin: 2px 0 0;
}

.classification-dialog form {
  margin-top: 16px;
  text-align: right;
}

@media (max-width: 640px) {
  .classification-legend li {
    grid-template-columns: 12px minmax(0, 1fr);
    row-gap: 0;
  }

  .classification-label {
    grid-column: 2;
  }

  .classification-dialog {
    padding: 18px;
  }
}

/* 用語へのリンク（classification.js の termLink）。点線の下線で「説明がある言葉」と分かるようにし、
   ホバーかキーボードで選んだときに短い説明を吹き出しで出す。押すと用語ページが開く */
.term-link {
  position: relative;
  color: var(--accent-dark);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* 石・鉱物・用語リンクのホバーカード（link-preview.js）。地図画面の石カードに近い見た目にする。
   カードは押せなくてよい（押すのはリンク自体）ので、ポインターは素通りさせる */
.link-preview {
  position: fixed;
  z-index: 50;
  width: min(300px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.link-preview.is-visible {
  opacity: 1;
  visibility: visible;
}

/* どこに置いても入りきらない小さな画面の保険。高さを画面に合わせて抑える */
.link-preview {
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

/* 横長（link-preview.js が縦長で収まらないときに切り替える）。写真を左、文字を右に並べて背を低くする */
.link-preview.is-wide {
  width: min(470px, calc(100vw - 24px));
}

.link-preview.is-wide.has-visual {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  column-gap: 14px;
}

.link-preview.is-wide .link-preview-visual {
  margin: -12px 0 -12px -14px;
}

.link-preview.is-wide .link-preview-photo,
.link-preview.is-wide .link-preview-swatch {
  width: 100%;
  height: 128px;
  margin: 0;
  border-radius: 7px 0 0 0;
}

.link-preview.is-wide .link-preview-credit {
  margin: 4px 0 0 14px !important;
}

.link-preview.is-wide .link-preview-body {
  padding: 0;
}

.link-preview.is-wide .link-preview-more {
  margin-top: 6px !important;
}

.link-preview p {
  margin: 0;
}

.link-preview-photo,
.link-preview-swatch {
  display: block;
  width: calc(100% + 28px);
  margin: -12px -14px 8px;
  border-radius: 7px 7px 0 0;
  object-fit: cover;
}

.link-preview-photo {
  height: 150px;
  background: #1f2226;
}

.link-preview-swatch {
  height: 56px;
}

.link-preview-credit {
  margin: -4px 0 8px !important;
  color: var(--muted);
  font-size: 0.74rem;
}

.link-preview-kind {
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.link-preview-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.link-preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0;
}

.link-preview-tags span {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(171, 167, 157, 0.16);
  font-size: 0.76rem;
  font-weight: 700;
}

.link-preview-text {
  margin-top: 4px !important;
  color: var(--muted);
}

.link-preview-more {
  margin-top: 8px !important;
  padding: 5px;
  border-radius: 5px;
  background: #e6f4f4;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

/* 用語ページ */
.term-item-list {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 10px 14px;
  margin: 12px 0 0;
}

.term-item-list dd {
  margin: 0;
  line-height: 1.7;
}

.term-after {
  margin-top: 14px;
}

.term-source-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

@media (max-width: 640px) {
  .term-item-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .term-item-list dd {
    margin-bottom: 10px;
  }

  .term-item-list dt {
    justify-self: start;
  }
}

/* catalogLink() が作る、石・鉱物・用語の名前のリンク。チップの中でも文中でも、押せることが分かる色と下線にする */
.catalog-link {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stone-term.catalog-link:hover,
.stone-mineral.catalog-link:hover {
  border-color: rgba(13, 162, 189, 0.55);
  background: #d7eef0;
}

/* 地図画面の右上のメニュー（menu.js）。押すと右から引き出しが出る。
   ボタンは画面に固定して、引き出しより前に出す。何かの中に入れると、
   その要素が重なり順の入れ物になり、ボタンだけを引き出しより前に出せない。
   広い画面では結果パネルの右上の余白（.result-head の padding-right）に収まる */
.app-menu {
  position: fixed;
  top: 4px;
  right: 16px;
  z-index: 2200;
}

/* 詳細ページのバーは60px（地図画面は52px）。ボタンをバーの縦のまん中に合わせる */
.stone-page .app-menu {
  top: 8px;
}

/* 枠線も文字も持たない丸ボタン。開くと3本線が×に変わる */
.menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.menu-button:hover {
  background: rgba(48, 52, 56, 0.07);
}

.menu-bars {
  display: grid;
  gap: 5px;
  width: 22px;
}

.menu-bars i {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 220ms ease, opacity 160ms ease;
}

.menu-open .menu-bars i:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.menu-open .menu-bars i:nth-child(2) {
  opacity: 0;
}

.menu-open .menu-bars i:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.app-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1900;
  background: rgba(30, 34, 38, 0.32);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms;
}

.menu-open .app-menu-backdrop {
  opacity: 1;
  visibility: visible;
}

.app-menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  width: min(330px, 86vw);
  padding: 76px 22px 22px;
  background: var(--panel);
  box-shadow: -18px 0 44px rgba(30, 34, 38, 0.16);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1), visibility 260ms;
}

.menu-open .app-menu-drawer {
  transform: none;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .menu-bars i,
  .app-menu-backdrop,
  .app-menu-drawer {
    transition: none;
  }
}

.app-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: background 160ms ease;
}

.app-menu-item:hover,
.app-menu-item:focus-visible {
  background: #eef6f7;
}

.app-menu-item-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.app-menu-title {
  font-size: 1.16rem;
  font-weight: 700;
}

.app-menu-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.app-menu-arrow {
  width: 18px;
  height: 18px;
  margin-left: auto;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 160ms ease;
}

.app-menu-item:hover .app-menu-arrow,
.app-menu-item:focus-visible .app-menu-arrow {
  stroke: var(--accent);
  transform: translateX(3px);
}

/* 820px 以下ではヘッダーが縦並びになる（地図の高さもそれに合わせて計算している）。
   メニューのボタンだけは右上に置いたままにする */


/* ===== 用語集（glossary.html） =====
   詳細ページのカードを並べるのではなく、辞書の索引の見た目にする。
   1件1行の密な並びにして、広い画面では段組みに流し込む。説明はホバーのカード（link-preview.js）に任せる。 */
a.stone-back-button {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  text-decoration: none;
}

/* 1件の中身は最大273px。列がそれより大幅に広いと、行の右側が空いて見える */
.glossary {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 60px;
}

.glossary-head h1 {
  margin-bottom: 2px;
  font-size: 1.3rem;
}

.glossary-sub {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

/* 検索の帯。スクロールしても上に残す（以前は五十音の帯を残していたが、よく使うのは検索のほう）。
   左に検索欄、右に件数と開閉の矢印。矢印を押すと、下に種類の絞り込みと五十音の索引が開く */
.glossary-bar {
  position: sticky;
  top: 60px;
  z-index: 5;
  margin-top: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.glossary-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.glossary-search-box {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
}

.glossary-search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.glossary-search {
  width: 100%;
  min-height: 44px;
  padding: 0 16px 0 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  font-size: 0.98rem;
  box-shadow: none;
}

.glossary-search:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(13, 162, 189, 0.22);
  outline-offset: 1px;
}

.glossary-search::-webkit-search-cancel-button {
  cursor: pointer;
}

.glossary-count {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

/* 開閉の矢印。全体の button の指定（塗りつぶし・押すと沈む）を打ち消して、枠だけの丸にする */
.glossary-toggle {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-dark);
}

.glossary-toggle:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.glossary-toggle:active {
  transform: none;
}

.glossary-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 200ms ease;
}

.glossary-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* 絞り込んでいるときの目印。絞り込みは畳んだ中にあるので、閉じていても分かるようにする */
.glossary-toggle.has-filter::after {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.glossary-panel {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

/* hidden 属性より display: grid が強いので、隠す指定を明示しておく */
.glossary-panel[hidden] {
  display: none;
}

.glossary-panel-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.glossary-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* hidden 属性より display: flex が強いので、隠す指定を明示しておく */
.glossary-filters[hidden] {
  display: none;
}

.glossary-sub-filters {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 3px solid var(--line);
}

.glossary-chip {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(171, 167, 157, 0.16);
  color: var(--ink);
  font-size: 0.9rem;
}

.glossary-chip:hover {
  background: #e6f4f4;
  color: var(--accent-dark);
}

.glossary-chip[aria-pressed="true"] {
  background: var(--accent-dark);
  color: #fff;
}

.glossary-index {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.glossary-index-link {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(171, 167, 157, 0.12);
  color: var(--accent-dark);
  font-size: 0.98rem;
  font-weight: 700;
  text-decoration: none;
}

.glossary-index-link:hover {
  background: #e6f4f4;
}

.glossary-index-link.is-empty {
  background: none;
  color: #c9cbc4;
}

.glossary-loading,
.glossary-empty {
  margin: 28px 0 0;
  color: var(--muted);
}

/* 「か」のような大きな仮名を左に置いた区切り */
.glossary-group {
  margin-top: 26px;
}

.glossary-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--line);
  /* 上のバー（60px）と検索の帯（約65px）の下に見出しが来るように */
  scroll-margin-top: 140px;
}

.glossary-row-kana {
  color: var(--accent-dark);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.glossary-row-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.glossary-row-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

/* 段組みに流し込む。1件が段をまたがないようにする */
.glossary-items {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 1;
  column-gap: 26px;
}

.glossary-items li {
  break-inside: avoid;
}

/* 種類・名前・読みを左から詰めて置く。読みを右端まで押しやると、あいだが大きく空いて見える */
.glossary-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
}

.glossary-item:hover,
.glossary-item:focus-visible {
  background: #e6f4f4;
}

.glossary-kind {
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.glossary-kind-stone {
  background: #e0f1f4;
  color: var(--accent-dark);
}

.glossary-kind-mineral {
  background: #ece6f5;
  color: #5b3f86;
}

.glossary-kind-geology {
  background: #f2ecdf;
  color: #7a5518;
}

.glossary-kind-term {
  background: #eaebe8;
  color: #4b504a;
}

.glossary-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* 読みは名前のすぐ右。行が狭いときは読みから先に省略する */
.glossary-reading {
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.glossary-item:hover .glossary-name,
.glossary-item:focus-visible .glossary-name {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.glossary-reading {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

@media (min-width: 720px) {
  .glossary-items {
    columns: 2;
  }
}

@media (min-width: 1000px) {
  .glossary-items {
    columns: 3;
  }
}

/* 画面が広いときは列を増やす。列を広げるのではなく本数で埋める */
@media (min-width: 1280px) {
  .glossary {
    width: min(1200px, calc(100% - 32px));
  }

  .glossary-items {
    columns: 4;
  }
}

/* ===== 詳細ページの組み方（読みやすさ） =====
   日本語は1行35〜45字くらいが読みやすい。以前は本文の枠が1180pxまで広がり、1行が70字を超えていた。
   石のページは「左に本文・右に写真と要点」の2段組み、写真のないページは1段で幅を狭める。 */

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "title"
    "aside"
    "main";
  gap: 20px;
}

.detail-title {
  grid-area: title;
}

.detail-title h1 {
  margin-bottom: 4px;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.2;
}

.detail-lead {
  max-width: 36em;
  margin: 0;
  color: #3f4549;
  font-size: 1.08rem;
  line-height: 1.8;
}

.detail-aside {
  grid-area: aside;
  display: grid;
  align-content: start;
  gap: 16px;
}

.detail-main {
  grid-area: main;
  display: grid;
  align-content: start;
  gap: 20px;
  min-width: 0;
}

/* 目次から飛んだとき、見出しが上のバーの下に隠れないように */
.detail-main > article {
  scroll-margin-top: 80px;
}

/* 図鑑の「データ欄」。分類・特徴・主な鉱物を、ラベルと中身の2列で並べる */
.detail-facts {
  display: grid;
  grid-template-columns: 5.8em minmax(0, 1fr);
  gap: 12px 12px;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.detail-facts dt {
  padding-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-facts dd {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.7;
}

.detail-facts .stone-tag-list,
.detail-facts .stone-mineral-list {
  gap: 6px;
}

.detail-facts .stone-tag,
.detail-facts .stone-mineral {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 0.86rem;
}

.detail-toc {
  display: none;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--panel);
}

.detail-toc-title {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-toc a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.detail-toc a:hover,
.detail-toc a:focus-visible {
  background: #e6f4f4;
}

/* 本文の文字。少し大きく、行間を広く、色を濃くして読みやすくする（石以外のページも同じ） */
.stone-info-panel p,
.stone-confuse-list dd,
.stone-test-list,
.term-item-list dd {
  color: #3f4549;
  font-size: 1.02rem;
  line-height: 1.9;
}

.stone-info-panel h2 {
  font-size: 1.1rem;
}

.detail-main .stone-info-panel {
  padding: 24px 26px;
}

@media (min-width: 1000px) {
  /* 本文の列は 700px（1行40字前後）。右の列は写真の実寸（354px）に合わせる */
  .detail-layout {
    grid-template-columns: minmax(0, 700px) 340px;
    grid-template-areas:
      "title aside"
      "main aside";
    justify-content: center;
    align-items: start;
    column-gap: 36px;
    row-gap: 24px;
  }

  /* 右の列は本文と同じ高さまで伸ばし、その中で目次だけをスクロールに付いてこさせる */
  .detail-aside {
    align-self: stretch;
  }

  .detail-toc {
    display: block;
    position: sticky;
    top: 80px;
  }
}

/* 写真のないページ（鉱物・岩相・用語・用語集）は1段のまま幅を狭め、1行を短くする */
.stone-detail.is-narrow {
  width: min(760px, calc(100% - 32px));
}

@media (max-width: 640px) {
  .detail-main .stone-info-panel {
    padding: 20px 18px;
  }

  .detail-facts {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .detail-facts dd {
    margin-bottom: 8px;
  }
}

/* 間違えやすい石・鉱物（link-preview.js の confusedItem）。左に相手の石の写真、右に名前と見分け方 */
.confuse-list {
  display: grid;
  gap: 16px;
}

.confuse-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.confuse-item.no-thumb {
  grid-template-columns: minmax(0, 1fr);
}

.confuse-thumb {
  display: block;
  overflow: hidden;
  aspect-ratio: 1 / 0.86;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1f2226;
}

.confuse-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 160ms ease;
}

.confuse-thumb:hover img {
  transform: scale(1.04);
}

.confuse-thumb.is-empty {
  display: grid;
  place-items: center;
  background: #f1f2ef;
  color: #9a9e97;
  font-size: 0.76rem;
  font-weight: 700;
}

.stone-info-panel .confuse-name {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
}

.stone-info-panel .confuse-text {
  margin: 0;
}

.stone-info-panel .confuse-credit {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .confuse-item {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 12px;
  }
}

/* ===== 岩相・用語ページ（石のページと同じ .detail-layout の2段組み） ===== */

/* 岩相名は「苦鉄質片麻岩・角閃岩 高P/T型広域変成岩 アルバイト黒雲母帯」のように長いので一回り小さく */
.detail-title h1.lithology-title {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.detail-facts-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.lithology-code {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f8f6;
  font-size: 0.9rem;
  font-weight: 700;
}

.detail-facts .lithology-age-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  line-height: 1.5;
}

.detail-facts .lithology-age-list li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.detail-facts .lithology-age-swatch {
  width: 22px;
  height: 16px;
  margin-top: 2px;
  border: 1px solid rgba(48, 52, 56, 0.2);
  border-radius: 3px;
}

.detail-toc-more {
  display: block;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

/* 拾えそうな石の写真タイル（link-preview.js の stoneTile） */
.stone-info-panel .lithology-role {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.stone-info-panel .lithology-role:first-of-type {
  margin-top: 0;
}

.stone-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.stone-tile {
  display: grid;
  align-content: start;
  gap: 6px;
  padding-bottom: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.stone-tile:hover,
.stone-tile:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(48, 52, 56, 0.1);
}

.stone-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.86;
  object-fit: cover;
  background: #1f2226;
}

.stone-tile-name {
  padding: 0 10px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stone-tile-credit {
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .stone-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* 要点欄のうち、中身が長い項目は横幅いっぱいに使う（岩相ページの「時代と地図の色」） */
.detail-facts .facts-wide {
  grid-column: 1 / -1;
}

.detail-facts dd.facts-wide {
  margin-top: -6px;
}

.lithology-age-name {
  display: block;
}

.lithology-age-era {
  margin-right: 5px;
  color: var(--muted);
  font-size: 0.78em;
}

.lithology-age-more {
  margin-top: 6px;
}

.lithology-age-more summary {
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.lithology-age-more .lithology-age-list {
  margin-top: 6px;
}

/* ===== 石の分類マップ（rock-tree.html） =====
   左の「岩石」から右へ枝分かれする木。石は枝の先に横並びの房（.cluster）でまとめる。
   位置は rock-tree.js が計算して、箱は absolute で置き、枝の線は後ろの SVG に描く。 */
.rock-tree-page {
  --branch-root: #6b706a;
  --branch-igneous: #b4583c;
  --branch-sedimentary: #a07a2c;
  --branch-metamorphic: #4f7d56;
  --branch-vein: #6b7785;
}

.rock-tree {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 60px;
}

/* 見出しのすぐ下は見方（.tree-guide）。以前は間に1文の紹介があったが、見方と木で伝わるので消した */
.rock-tree-head h1 {
  margin-bottom: 14px;
  font-size: 1.3rem;
}

/* 横幅は枠に合わせて組むので、はみ出さない。
   ここを overflow: auto にすると、狭い画面の帯の文字（sticky）が枠のほうに張り付いて効かなくなる */
.tree-canvas {
  position: relative;
}

.tree-loading {
  color: var(--muted);
}

.tree-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.tree-branch-igneous { --branch: var(--branch-igneous); }
.tree-branch-sedimentary { --branch: var(--branch-sedimentary); }
.tree-branch-metamorphic { --branch: var(--branch-metamorphic); }
.tree-branch-vein { --branch: var(--branch-vein); }
.tree-branch-root { --branch: var(--branch-root); }

.tree-line {
  fill: none;
  stroke: var(--branch);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.55;
  transition: opacity 0.15s, stroke-width 0.15s;
}

/* 触れている石や枝から根までの道筋だけを濃くし、ほかの枝は薄くする */
.tree-canvas.has-lit .tree-line {
  opacity: 0.18;
}

.tree-canvas.has-lit .tree-line.is-lit {
  opacity: 1;
  stroke-width: 2.6;
}

/* 高さを測り終えるまでは見せない（いったん全部を上端に置いて測るため） */
.tree-list {
  margin: 0;
  padding: 0;
  list-style: none;
  visibility: hidden;
}

.tree-canvas.is-measured .tree-list {
  visibility: visible;
}

.tree-item {
  position: absolute;
  transform: translateY(-50%);
}

.tree-item.is-cluster-item,
.tree-item.is-bar-item {
  transform: none;
}

/* 枝の箱。名前と、どう分かれたかのひとこと。1段の高さはこの箱で決まるので、上下は詰めておく */
.tree-node {
  display: grid;
  gap: 1px;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--branch) 38%, transparent);
  border-left: 3px solid var(--branch);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}

.tree-node.is-major {
  background: color-mix(in srgb, var(--branch) 12%, var(--panel));
}

.tree-node-name {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.3;
}

.tree-node.is-major .tree-node-name,
.tree-node.is-root .tree-node-name {
  color: var(--branch);
  font-size: 1rem;
  font-weight: 800;
}

.tree-node-note {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

a.tree-node:hover .tree-node-name,
a.tree-node:focus-visible .tree-node-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tree-node.is-lit {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--branch) 45%, transparent);
}

/* 石の房。写真と名前の札を横に並べ、入りきらなければ折り返す */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--branch) 22%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--branch) 5%, var(--panel));
  list-style: none;
}

.cluster.is-lit {
  border-color: color-mix(in srgb, var(--branch) 55%, transparent);
}

.cluster-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 10px 2px 2px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.cluster-chip-photo {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px color-mix(in srgb, var(--branch) 55%, transparent);
}

.cluster-chip:hover,
.cluster-chip:focus-visible,
.cluster-chip.is-lit {
  background: color-mix(in srgb, var(--branch) 14%, transparent);
}

.cluster-chip:hover .cluster-chip-name,
.cluster-chip:focus-visible .cluster-chip-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 狭い画面：根と大枝は、子の範囲いっぱいに伸びた縦書きの帯（rock-tree.js の CLUSTER_SIZES.narrow）。
   長い帯でも名前が見えるよう、文字は画面上に残す */
.tree-node.is-bar {
  display: block;
  height: 100%;
  padding: 8px 0;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--branch) 14%, var(--panel));
  text-align: center;
}

.tree-node.is-bar .tree-node-name {
  position: sticky;
  top: var(--tree-sticky-top, 72px);
  display: inline-block;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
}

@media (max-width: 640px) {
  .rock-tree {
    width: calc(100% - 24px);
  }

  .tree-node {
    padding: 5px 7px;
  }

  .tree-node-name {
    font-size: 0.8rem;
  }

  /* 枝のひとことは、狭い箱では読めない長さになるので出さない（押した先の用語ページにある） */
  .tree-node-note {
    display: none;
  }

  .cluster {
    gap: 2px;
  }

  .cluster-chip {
    gap: 5px;
    padding: 2px 7px 2px 2px;
    font-size: 0.8rem;
  }

  .cluster-chip-photo {
    width: 24px;
    height: 24px;
  }
}

/* とても狭い画面（320px 前後）では枝の箱が50px まで細くなる。名前が何行にも折り返して
   隣の枝とぶつからないよう、余白と字を少し詰めて1行に3字入るようにする */
@media (max-width: 360px) {
  .tree-node:not(.is-bar) {
    padding: 4px 4px 4px 5px;
  }

  .tree-node:not(.is-bar) .tree-node-name {
    font-size: 0.74rem;
    line-height: 1.25;
  }
}

/* ===== 地質の分類マップ（litho-tree.html） =====
   木の描き方は石の分類マップと共通（tree-layout.js と上の節）。枝の先は写真ではなく、地質図の色の札 */
.rock-tree-page {
  --branch-accretion: #7a5a8c;
  --branch-other: #6b7785;
}

.tree-branch-accretion { --branch: var(--branch-accretion); }
.tree-branch-other { --branch: var(--branch-other); }

/* 系統の札。名前が長いもの（泥質片岩・泥質グラノフェルス・…）は折り返す。
   幅の上限は札ではなく入れ物の li に持たせる。札に max-width: 100% を付けると、li の幅が札の中身で決まるため
   循環して最小の幅で計算され、「チャート」のような短い名前まで2行に折れる */
.cluster > li {
  max-width: 100%;
}

/* 開閉する札は button。全体の button の指定（高さ42px・押すと沈む）を打ち消して、リンクの札と同じ見た目にする */
.litho-chip {
  min-height: 0;
  transform: none !important;
  padding: 4px 8px 4px 10px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  cursor: pointer;
}

.litho-count {
  flex: 0 0 auto;
  min-width: 1.6em;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--branch) 16%, transparent);
  color: color-mix(in srgb, var(--branch) 80%, var(--ink));
  font-size: 0.72rem;
  text-align: center;
}

.litho-chip.is-open {
  background: color-mix(in srgb, var(--branch) 18%, transparent);
}

.litho-chip.is-current {
  box-shadow: inset 0 0 0 2px var(--branch);
}

/* 開いた系統の中身。房の幅いっぱいに、帯・時代ちがいの地質を並べる */
.litho-variants {
  flex: 1 0 100%;
  margin: 2px 0 4px;
  padding: 6px 8px;
  border-left: 3px solid var(--branch);
  border-radius: 0 8px 8px 0;
  background: var(--panel);
}

.litho-variant-group + .litho-variant-group {
  margin-top: 6px;
}

.litho-variant-head {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

/* 岩相は1件1行。名前を左に、地質図の色を右に1列で並べる（色は折り返さない） */
/* 列は minmax(0, 1fr)。auto のままだと列の幅が行の最小幅（名前の5em＋縮む前の丸）になり、狭い画面ではみ出す */
.litho-variant-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.litho-variant {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.35;
  text-decoration: none;
}

/* 名前は長ければ折り返す。ただし色に押されて2字ずつにならないよう、最低の幅を持たせる */
.litho-variant-name {
  flex: 0 1 auto;
  min-width: 5em;
}

.litho-variant:hover .litho-variant-name,
.litho-variant:focus-visible .litho-variant-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 地質図でその地質が塗られている色。時代ごとに1つの丸で、古い順。触れると時代が出る（title）。
   多いもので26色あるので、幅が足りなければ丸を細い縦棒に縮めて、1列のまま収める */
.litho-colors {
  display: flex;
  flex: 0 1 auto;
  gap: 2px;
  min-width: 0;
}

/* 幅は flex-basis ではなく width で持たせる。basis だけだと入れ物の幅が「中身なし」で計算され、
   広い画面でも丸が最小の2pxまで縮んでしまう */
.litho-dot {
  flex: 0 1 auto;
  width: 10px;
  min-width: 2px;
  height: 10px;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(48, 52, 56, 0.28);
}

.litho-variant:hover,
.litho-variant:focus-visible {
  background: color-mix(in srgb, var(--branch) 12%, transparent);
}

.litho-variant.is-current {
  background: color-mix(in srgb, var(--branch) 18%, transparent);
  font-weight: 700;
}

@media (max-width: 640px) {
  .litho-chip {
    padding: 3px 7px;
    font-size: 0.78rem;
  }

  .litho-variants {
    padding: 5px 6px;
  }
}

/* 岩相ページの要点欄から、地質の分類マップへ */
.detail-facts-link {
  display: block;
  margin-top: 4px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

/* 地質の分類マップの「見方」。左に見本、右に説明の2列 */
.tree-guide {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  margin: 0 0 22px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 0.84rem;
}

.tree-guide dt,
.tree-guide dd {
  margin: 0;
}

.tree-guide-mark {
  display: flex;
  justify-content: center;
}

.tree-guide-mark .litho-chip {
  --branch: var(--branch-metamorphic);
  cursor: default;
}

.tree-guide-arrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .tree-guide {
    gap: 8px 10px;
    padding: 10px;
    font-size: 0.8rem;
  }

  .litho-colors {
    gap: 1px;
  }
}

/* 見方の「全部開く」。全体の button（高さ42px・塗りつぶし）ではなく、うすく色の付いた丸いボタンにして、
   上下に開く矢印を添える。触れると矢印が上下に広がり、全部開いているあいだは内向きに回る */
.tree-guide-with-button {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.tree-guide-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 0;
  padding: 5px 13px 5px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent-dark);
  font-size: 0.8rem;
  white-space: nowrap;
  transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.tree-guide-button:hover,
.tree-guide-button:focus-visible {
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* 全部開いているあいだは、塗りを濃くして「いま開いている」ことを示す */
.tree-guide-button[aria-pressed="true"] {
  background: var(--accent-dark);
  box-shadow: none;
  color: #fff;
}

.tree-guide-button[aria-pressed="true"]:hover,
.tree-guide-button[aria-pressed="true"]:focus-visible {
  background: color-mix(in srgb, var(--accent-dark) 85%, #000);
}

.open-all-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.open-all-up,
.open-all-down {
  transition: transform 220ms ease;
}

.open-all-up {
  transform-origin: 12px 7.5px;
}

.open-all-down {
  transform-origin: 12px 16.5px;
}

.tree-guide-button:hover .open-all-up,
.tree-guide-button:focus-visible .open-all-up {
  transform: translateY(-1.5px);
}

.tree-guide-button:hover .open-all-down,
.tree-guide-button:focus-visible .open-all-down {
  transform: translateY(1.5px);
}

.tree-guide-button[aria-pressed="true"] .open-all-up {
  transform: rotate(180deg);
}

.tree-guide-button[aria-pressed="true"] .open-all-down {
  transform: rotate(180deg);
}

/* 閉じる向きのときは、触れると矢印が内側へ寄る */
.tree-guide-button[aria-pressed="true"]:hover .open-all-up,
.tree-guide-button[aria-pressed="true"]:focus-visible .open-all-up {
  transform: translateY(1.5px) rotate(180deg);
}

.tree-guide-button[aria-pressed="true"]:hover .open-all-down,
.tree-guide-button[aria-pressed="true"]:focus-visible .open-all-down {
  transform: translateY(-1.5px) rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .open-all-up,
  .open-all-down {
    transition: none;
  }
}

.tree-guide-button[hidden] {
  display: none;
}

/* 見方の見本の枝。木の中では幅が決まっているが、見本は中身の幅でよい */
.tree-guide-node {
  display: inline-grid;
}

/* ===== 石と鉱物の分類マップの切り替え（rock-tree.html） ===== */
[data-tab-guide][hidden] {
  display: none;
}

/* 鉱物の枝の色。ケイ酸塩（岩石の鉱物のほとんど）・炭酸塩・酸化・硫化・元素 */
.rock-tree-page {
  --branch-silicate: #4f7d56;
  --branch-carbonate: #6b8fa8;
  --branch-oxide: #9a4a3c;
  --branch-sulfide: #a88a1f;
  --branch-native: #b0892a;
}

.tree-branch-silicate { --branch: var(--branch-silicate); }
.tree-branch-carbonate { --branch: var(--branch-carbonate); }
.tree-branch-oxide { --branch: var(--branch-oxide); }
.tree-branch-sulfide { --branch: var(--branch-sulfide); }
.tree-branch-native { --branch: var(--branch-native); }

/* 鉱物の札は写真を持たないので、名前だけの札にする */
.mineral-chip {
  padding: 4px 11px;
  font-size: 0.86rem;
}

/* 石と鉱物の切り替えタブ。画面の左端に縦書きで貼り付ける（しおりのように少し出っぱらせる）。
   上下の場所をまったく取らないので、スクロールしても木を見る場所が減らない。
   以前は 1024px より狭い画面ではヘッダーの下の細い帯にしていたが、狭い画面ほど上下の場所が惜しいので、どの幅でもしおりにした。
   札が木に重ならないよう、本文の左にしおりのぶんの場所を空けておく。
   ヘッダーには操作を入れない（ヘッダーに入れると、そこだけ浮いて見えた）。ここに落ち着くまでに試した形は CLAUDE.md に残してある */
.tree-tabbar {
  position: fixed;
  /* 上のバー（60px）のすぐ下あたり。真ん中寄り（34%）だと下すぎて目に入りにくかった */
  top: 96px;
  left: 0;
  z-index: 12;
}

.tree-switch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* 全体の button の指定（高さ42px・塗りつぶし・押すと沈む）を打ち消す。
   選んでいないほうは少し引っこめて、選んでいるほうだけが出ているように見せる */
.tree-switch-tab {
  min-height: 0;
  padding: 18px 9px;
  border-radius: 0 12px 12px 0;
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(48, 52, 56, 0.12);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  writing-mode: vertical-rl;
  transform: translateX(-5px);
  transition: transform 200ms ease, background 200ms ease, color 200ms ease;
}

.tree-switch-tab:hover {
  background: var(--panel);
  color: var(--ink);
  transform: translateX(0);
}

.tree-switch-tab:active {
  transform: translateX(0);
}

.tree-switch-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.tree-switch-tab.is-active {
  background: var(--accent-dark);
  color: #fff;
  font-weight: 800;
  transform: translateX(0);
}

/* 左端のしおりのぶん、本文の左を空ける。広い画面では左右対称にして、木が寄って見えないようにする */
.rock-tree.has-side-tabs {
  width: min(1200px, calc(100% - 112px));
}

@media (max-width: 1023px) {
  .rock-tree.has-side-tabs {
    width: auto;
    margin: 0 16px 0 48px;
  }
}

@media (max-width: 640px) {
  .tree-switch-tab {
    padding: 14px 7px;
    font-size: 0.85rem;
  }

  .rock-tree.has-side-tabs {
    margin: 0 12px 0 40px;
  }
}
