/* 📖 単語帳 スタイル */
/* PM Kotoba の配色（#fbf8f4 背景・#c2703d アクセント）に合わせる */

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

body {
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
  background: #fbf8f4;
  color: #3d3229;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- ヘッダー ---- */
.wb-header {
  background: #fff;
  border-bottom: 1px solid #e8e0d5;
  padding: 12px 20px;
  /* スクロールで上に流れて隠れる（sticky にしない） */
  display: flex;
  align-items: center;
  justify-content: center; /* タイトルを中央寄せ */
  position: relative; /* 報告メニューを右端に絶対配置するための基準 */
}
.wb-header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wb-logo {
  font-weight: 700;
  color: #c2703d;
  text-decoration: none;
  font-size: 18px;
  cursor: pointer;
}
.wb-title {
  font-size: 18px;
  color: #3d3229;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.wb-title:hover { color: #c2703d; }
.wb-header-sep {
  color: #c9bda9;
  font-size: 18px;
  font-weight: 700;
}
/* 報告メニュー（X・Bluesky リンク）・ヘッダ右端に絶対配置 */
.report-menu {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}
.report-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b5d4e;
}
.report-btn:hover { background: #f0ebe2; }
.report-dropdown {
  position: absolute; top: 44px; right: 0;
  background: #fff; border: 1px solid #e8e0d5; border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 8px; min-width: 180px; z-index: 1000;
}
.report-dropdown-title {
  font-size: 12px; color: #8a7a68; padding: 4px 8px;
  border-bottom: 1px solid #f0ebe2; margin-bottom: 4px;
}
.report-link {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border: none; background: none;
  font-family: inherit; font-size: 14px; color: #3d3229;
  border-radius: 8px; cursor: pointer; text-decoration: none;
  box-sizing: border-box;
}
.report-link:hover { background: #f0ebe2; }

/* ---- ページ（左右レイアウト: 左=コンテンツ / 右=表示切替ツールバー） ---- */
.wb-page {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 0 16px;
  width: 100%;
  min-width: 0;
}
.wb-content {
  flex: 1 1 auto;
  min-width: 0; /* flex 内で縮める */
}
/* ---- メイン本体（左=グループセクション / 右=表示切替ツールバー） ---- */
.wb-main-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.wb-section {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---- フィルタバー（言語/レベル・スクロールで流れる） ---- */
.wb-filterbar {
  background: #fff;
  border-bottom: 1px solid #e8e0d5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 8px 20px;
}
/* ---- フィルタグループ（全選択 + チップを縦積み・中央寄せ） ---- */
.wb-filter-group {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column; /* 全選択ボタンをチップの上に */
  align-items: center;    /* 中央寄せ */
  gap: 6px;
  padding: 6px 0;
}
/* 2つ目以降のグループは区切り線で分離（言語/レベルを視覚的に明確化） */
.wb-filter-group + .wb-filter-group {
  border-top: 1px solid #f0ebe2;
  margin-top: 6px;
  padding-top: 10px;
}

/* ---- 言語選択（レベルと同じデザイン・チェックボックス+ラベル） ---- */
.wb-langs {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap; /* 1行で並べ、溢れたら横スクロール */
  overflow-x: auto;  /* 横スクロール */
  justify-content: flex-start; /* フォールバック: 左寄せ（先頭が切れない） */
  justify-content: safe center; /* 収まる場合は中央・はみ出す場合は左寄せ（先頭が切れない） */
  -webkit-overflow-scrolling: touch;
  flex: 1;           /* 全選択ボタンの右側を埋める */
  min-width: 0;      /* flex 内で縮める */
  width: 100%;       /* align-items:center でコンテンツ幅にならないよう親幅いっぱいに広げる */
  padding-bottom: 8px; /* スクロールバーをチップから離す（重ならない） */
  scrollbar-width: thin; /* スクロールバーを細く表示（チップに重ならない） */
  scrollbar-color: #d8d0c4 transparent; /* Chromium用: thumb=薄いグレー（::-webkit-scrollbarはscrollbar-width:thinで無効化されるため） */
}
/* 方式C: スクロールバーを細く薄く（Webkit/Chromium系） */
/* 言語・レベルチップはスクロールバーを細く表示（チップに重ならない） */
.wb-langs::-webkit-scrollbar,
.wb-levels::-webkit-scrollbar {
  height: 6px;
}
.wb-langs::-webkit-scrollbar-thumb,
.wb-levels::-webkit-scrollbar-thumb {
  background: #d8d0c4;
  border-radius: 3px;
}
.wb-langs::-webkit-scrollbar-track,
.wb-levels::-webkit-scrollbar-track {
  background: transparent;
}
.wb-group-nav::-webkit-scrollbar {
  height: 6px;
}
.wb-group-nav::-webkit-scrollbar-thumb {
  background: #d8d0c4;
  border-radius: 3px;
}
.wb-group-nav::-webkit-scrollbar-track {
  background: transparent;
}
/* 溢れた時は .wb-langs 自体が横スクロール（先頭が切れない） */
.wb-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 40px; /* タップターゲット確保 */
  border: 1px solid #e8e0d5;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
  user-select: none;
}
.wb-lang:hover { border-color: #c2703d; }
.wb-lang.on { border-color: #c2703d; background: #f7e8dc; }
.wb-lang input {
  width: 18px;
  height: 18px;
  accent-color: #c2703d;
  cursor: pointer;
  margin: 0;
  flex: 0 0 auto;
}
.wb-lang-label { white-space: nowrap; }

/* ---- 「全選択」ボタン（言語/レベルそれぞれ・チップ行に統合） ---- */
.wb-checkall-btn {
  flex: 0 0 auto; /* チップ行の中で縮まない */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px dashed #c2703d;
  border-radius: 999px;
  background: #fff;
  color: #c2703d;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  padding: 7px 12px;
  min-height: 40px; /* タップターゲット確保 */
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.wb-checkall-btn:hover:not(:disabled) { background: #f7e0cd; }
.wb-checkall-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.wb-checkall-btn:focus-visible {
  outline: 2px solid #c2703d;
  outline-offset: 2px;
}
/* 全選択状態: 背景色は使わず「枠線 + 文字色 + ✓アイコン」で表現 */
.wb-checkall-btn.on {
  border-style: solid;
  border-color: #c2703d;
  color: #c2703d;
  background: #fff; /* 背景は白のまま（#f7e8dc を削除） */
}
/* ✓ チェックアイコン（全選択時のみ表示） */
.wb-checkall-ico {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}
/* 未選択時もチェックボックス（□）を表示し、左側の空白をなくす */
.wb-checkall-ico::before {
  content: "□";
}
.wb-checkall-btn.on .wb-checkall-ico::before {
  content: "✓";
}

/* ---- 級フィルタ（個別/複数選択・コンパクト） ---- */
.wb-levels {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap; /* 1行で並べ、溢れたら横スクロール */
  overflow-x: auto;  /* 横スクロール */
  justify-content: flex-start; /* フォールバック: 左寄せ（先頭が切れない） */
  justify-content: safe center; /* 収まる場合は中央・はみ出す場合は左寄せ（先頭が切れない） */
  -webkit-overflow-scrolling: touch;
  flex: 1;           /* 全選択ボタンの右側を埋める */
  min-width: 0;      /* flex 内で縮める */
  width: 100%;       /* align-items:center でコンテンツ幅にならないよう親幅いっぱいに広げる */
  padding-bottom: 8px; /* スクロールバーをチップから離す（重ならない） */
  scrollbar-width: thin; /* スクロールバーを細く表示（チップに重ならない） */
  scrollbar-color: #d8d0c4 transparent; /* Chromium用: thumb=薄いグレー（::-webkit-scrollbarはscrollbar-width:thinで無効化されるため） */
}
/* 溢れた時は .wb-levels 自体が横スクロール（先頭が切れない） */
.wb-level {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 40px; /* タップターゲット確保 */
  border: 1px solid #e8e0d5;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.15s;
  user-select: none;
}
.wb-level:hover { border-color: #c2703d; }
.wb-level.on { border-color: #c2703d; background: #f7e8dc; }
.wb-level input {
  width: 18px;
  height: 18px;
  accent-color: #c2703d;
  cursor: pointer;
  margin: 0;
  flex: 0 0 auto;
}
.wb-level-label { white-space: nowrap; }
.wb-level-total {
  font-size: 13px;
  font-weight: 600;
  color: #c2703d;
  white-space: nowrap;
}
.wb-levels-empty { color: #b0a89c; font-size: 12px; }

/* ---- メイン ---- */
.wb-main {
  margin: 0 auto;
  flex: 1;
  width: 100%;
}
.wb-section {
  margin-bottom: 28px;
}
.wb-section-title {
  font-size: 15px;
  color: #7a6a58;
  margin-bottom: 10px;
  font-weight: 700;
}

/* ---- 全開閉ボタン（sticky：上部に張り付く。デグレ対策として固定する） ---- */
.wb-group-toolbar {
  position: sticky;
  top: 0; /* ブラウザ上部に張り付く */
  z-index: 40;
  margin: 0 0 20px; /* レベルチップとの間隔を確保 */
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  background: #fbf8f4; /* ページ背景と同色 → 下に潜る見出しを隠す */
  display: flex;
  align-items: center;
  gap: 10px;
}
.wb-group-toolbar[hidden] {
  display: none;
}
/* 絵文字ナビの左右ボタン（前/後グループへ遷移） */
.wb-group-arrow {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #fff;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  color: #3d3229;
  line-height: 1;
}
.wb-group-arrow:hover:not(:disabled) { border-color: #c2703d; background: #fdf3ea; }
.wb-group-arrow:disabled {
  opacity: 0.35;
  cursor: default;
  border-color: #e8e0d5;
  background: #f5f0e8;
}
.wb-group-arrow[hidden] { display: none; }
/* 絵文字ナビ（40グループ・横スクロール） */
.wb-group-nav-wrap {
  flex: 1;
  min-width: 0; /* flex子として縮みを許可（横スクロールを効かせる） */
}
.wb-group-nav-title {
  font-size: 14px; /* 見出しを大きめに（ユーザー要望） */
  font-weight: 700;
  color: #6b5d4f;
  letter-spacing: 0.04em;
  padding: 0 2px 6px; /* 下部に余白を持たせ、レベルチップとの間隔を確保 */
  /* 見出しはナビと一緒にスクロールして良い（sticky・固定にしない） */
  text-align: center;
}
.wb-group-nav-title[hidden] {
  display: none;
}
.wb-group-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto; /* 横スクロール */
  scrollbar-gutter: stable; /* 方式C: スクロールバー幅を常に確保してレイアウトが揺れない */
  scrollbar-width: thin; /* チップと同じスクロールバー（色・太さを統一） */
  scrollbar-color: #d8d0c4 transparent; /* Chromium用: thumb=薄いグレー */
  width: 100%;
  padding: 2px; /* 横の途切れ対策（スクロールバーとの余白を確保） */
}
.wb-group-nav[hidden] {
  display: none;
}
.wb-group-nav-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: #fff;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.wb-group-nav-btn:hover {
  border-color: #c2703d;
  transform: scale(1.1);
  background: #fdf9f3;
}
/* 選択中のグループ（1グループ固定表示）を強調 */
.wb-group-nav-btn.active {
  border-color: #c2703d;
  background: #f7e7d8;
  box-shadow: 0 0 0 1px #c2703d inset;
}

/* ---- グループ別セクション（単一グループ表示） ---- */
.wb-groups-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wb-group-block {
  background: #fff;
  border: 1px solid #e8e0d5;
  border-radius: 12px;
  /* overflow:hidden は sticky を壊すため使わない（角丸は head 側で処理） */
}
.wb-group-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center; /* 中央寄せ */
  gap: 8px;
  padding: 0;
  background: #f5f0e8;
  border: none;
  border-bottom: 1px solid #e8e0d5;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #3d3229;
  text-align: center;
  /* セクション内でブラウザ上部に張り付く（セクションが終わると自然にスクロールアウト） */
  /* top は JS（applyToolbarStickyTop）がツールバー実測高さから動的設定する */
  position: sticky;
  z-index: 20;
}
.wb-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0 12px 16px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #3d3229;
  text-align: left;
  /* 全再生ボタンも左寄せ（右寄せ廃止・toggle を広げない） */
}
.wb-group-play {
  width: auto;
  min-width: 96px; /* 停止/全再生で幅が変わらないよう固定（少し幅を縮小） */
  height: 36px;
  border: 1px solid #e8e0d5;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 12px;
  border-radius: 20px;
  transition: all 0.15s;
  line-height: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #c2703d;
}
.wb-group-play-label { white-space: nowrap; }
.wb-group-play:hover { border-color: #c2703d; background: #fdf6ee; transform: scale(1.05); }
.wb-group-play.playing {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
  /* 停止⏹表示は瞬時に切り替える（ラグ・アニメーションを出さない） */
  transition: none;
}
/* 再生中の制御UI（一時停止/続きから + 停止の2ボタン） */
.wb-group-play-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding-right: 16px;
}
.wb-group-pause,
.wb-group-stop {
  width: auto;
  min-width: 96px;
  height: 36px;
  border: 1px solid #e8e0d5;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 12px;
  border-radius: 20px;
  transition: all 0.15s;
  line-height: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #c2703d;
}
.wb-group-pause:hover,
.wb-group-stop:hover { border-color: #c2703d; background: #fdf6ee; transform: scale(1.05); }
.wb-group-stop.playing {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
  transition: none;
}
.wb-group-pause.playing {
  background: #c2703d;
  border-color: #c2703d;
  color: #fff;
  transition: none;
}
.wb-group-icon { font-size: 18px; }
.wb-group-label { white-space: nowrap; }
.wb-group-count {
  font-size: 12px;
  font-weight: 400;
  color: #7a6a58;
  background: #fff;
  border: 1px solid #e8e0d5;
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
}
.wb-group-body {
  padding: 14px;
}
.wb-group-body[hidden] {
  display: none; /* 閉じたときは padding ごと非表示（白い部分を出さない） */
}
.wb-group-empty {
  color: #b0a89c;
  text-align: center;
  padding: 24px 0;
  font-size: 14px;
}

/* ---- 表示項目（右上固定・ブラウザ上部に留まる） ---- */
/* ヘッダー・フィルタバーはスクロールで流れるため、右ツールバーだけ sticky で追従 */
/* .wb-page が flex 左右レイアウト。ツールバーは右カラムで sticky し、上端まで来ても画面外に出ない */
/* 挨拶等の最初のグループセクションの右横に配置される */
.wb-display-toggle {
  position: sticky;
  /* top は JS（applyToolbarStickyTop）がツールバー実測高さから動的設定する */
  align-self: flex-start;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 40px;
  flex: 0 0 auto;
}
.wb-display-toggle[hidden] {
  display: none;
}
.wb-display-btn {
  width: 100%;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d8d0c4;
  border-radius: 8px;
  background: #fffdf9;
  color: #8a7a68;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.wb-display-btn:hover {
  background: #f5f0e8;
  transform: scale(1.1);
}
.wb-display-ico {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.wb-display-btn.on {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
  box-shadow: 0 1px 3px rgba(217,72,15,0.4);
}
.wb-display-btn.on:hover { background: #e0551a; }
.wb-display-btn.off {
  background: #f5f2ee;
  border-color: #e8e0d5;
  color: #c9bda9;
}
.wb-display-btn.off:hover {
  background: #efe9e0;
  transform: scale(1.1);
}

/* ---- 単語一覧（グリッドレイアウト・論点AJ） ---- */
/* カード・セルとも横幅 180px 固定・中央寄せ */
.wb-words {
  display: grid;
  grid-template-columns: repeat(auto-fill, 180px);
  justify-content: center;
  gap: 10px;
}
/* テーブルモード時はグリッドを解除（block で親幅いっぱい・スクロールは .wb-table-scroll が持つ） */
.wb-words.wb-words-table {
  display: block;
  gap: 0;
}
.wb-card {
  background: #fff;
  border: 1px solid #e8e0d5;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  /* 長い単語・長い文字も折り返して収める（overflow させない） */
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  width: 180px; /* カード幅 180px 固定 */
  position: relative; /* ボタン（absolute）の基準 */
}
.wb-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
/* グループ全再生中のハイライト（カード・テーブルセル共通・やさしい背景色） */
.wb-card.playing {
  background: #fdf3ec;
  border-color: #f0c9b0;
  box-shadow: 0 2px 12px rgba(217,72,15,0.12);
}
.wb-td-cell.playing {
  background: #fdf3ec;
}
.wb-td-cell.playing .wb-word-trans,
.wb-td-cell.playing .wb-word-kana,
.wb-td-cell.playing .wb-word-reading {
  color: #c2703d;
}
/* ---- レベル見出し（構造化表示） ---- */
/* カードモード: グリッド内で全幅にまたがる小さなラベル・中央寄せ + その下のカード群 */
.wb-level-heading {
  font-weight: 700;
  font-size: 12px;
  color: #8a7a68;
  background: #f7f2ea;
  border-radius: 999px;
  padding: 3px 14px;
  margin: 6px auto 8px; /* 中央寄せ */
  display: inline-block;
  width: fit-content;
}
.wb-words > .wb-level-heading {
  grid-column: 1 / -1; /* グリッド全列にまたがる */
  justify-self: center; /* 中央寄せ */
  margin-left: auto;
  margin-right: auto;
}
.wb-level-cards {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, 180px);
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
/* テーブルモード: 見出しはテーブル外・上に置く（中央寄せ） */
.wb-group-body .wb-level-heading {
  display: block; /* margin:auto を効かせる（inline-block では効かない） */
  margin: 8px auto 4px;
}
/* ホバーで該当行をハイライト（デモ版キャンバスと同様） */
.wb-word-ja.hl, .wb-td-ja.hl,
.wb-word-trans.hl, .wb-td-word.hl,
.wb-word-kana.hl, .wb-td-kana.hl,
.wb-word-reading.hl, .wb-td-reading.hl {
  background: rgb(217 118 15 / 12%);
  border-radius: 8px;
}
/* カード構造: 1行目=再生ボタン（wb-card-actions）・2行目以降=本文（wb-card-body） */
.wb-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
  min-height: 26px; /* 空でも1行分の高さを確保 */
}
.wb-card-body {
  display: flex;
  flex-direction: column;
  align-items: center; /* 日本語・翻訳・カタカナ・発音記号を中央寄せ */
  text-align: center;
}
.wb-lang-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}
.wb-speak {
  margin-left: auto;
  border: 1px solid #e8e0d5;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  line-height: 1;
  /* 再生▶/停止⏹でアイコンが変わっても横幅が揺れないよう固定幅+中央寄せ */
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wb-speak:hover { border-color: #c2703d; transform: scale(1.05); }
.wb-speak.playing {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
  /* 停止⏹表示は瞬時に切り替える（ラグ・アニメーションを出さない） */
  transition: none;
}
.wb-speak-slow {
  border: 1px solid #e8e0d5;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  line-height: 1;
  /* 再生🐢/停止⏹でアイコンが変わっても横幅が揺れないよう固定幅+中央寄せ */
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wb-speak-slow:hover { border-color: #c2703d; transform: scale(1.05); }
.wb-speak-slow.playing {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
  /* 停止⏹表示は瞬時に切り替える（ラグ・アニメーションを出さない） */
  transition: none;
}

/* ---- 備考（note）ボタン ---- */
/* 亀（.wb-speak-slow）・再生（.wb-speak）と同じサイズ・角丸。noteフッター末尾の右下に配置 */
.wb-note-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;  /* ボタンを右端に。noteはその下へ展開 */
  margin-top: 8px;
}
.wb-note-btn {
  order: 0;              /* ボタンをフッター上部（本文直下）に置く → noteが開いても位置が動かない */
  flex-shrink: 0;
  border: 1px solid #e8e0d5;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;      /* 固定width/heightは使わず、アイコン+余白で自動サイズ */
  border-radius: 8px;
  transition: all 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wb-note-btn:hover { border-color: #c2703d; transform: scale(1.05); }
.wb-note-btn.on {
  background: #d9480f;
  border-color: #d9480f;
  color: #fff;
}

/* ---- 備考（note）本文 ---- */
/* カード/セルの下部に表示。デフォルトは閉じた状態（display.note で開閉） */
.wb-note {
  order: 2;              /* ボタン(order:0)の下に展開。ボタンは本文直下の右端に固定され開いても動かない */
  margin-top: 0;         /* 閉状態で余白を作らない（下の無駄な余白対策） */
  padding: 8px 10px;
  border-top: none;      /* 閉状態でボーダーを出さない（下の無駄な余白対策） */
  font-size: 0.75rem;
  color: #6a6a6a;
  line-height: 1.6;
  text-align: left;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  align-self: stretch;   /* フッター内で全幅に広げ、左寄せのまま（ボタンは上部右端） */
  transition: max-height 0.25s ease, opacity 0.25s ease;
}
.wb-note.open {
  max-height: 200px;
  opacity: 1;
  padding-top: 8px;
  padding-bottom: 4px;
  margin-top: 8px;       /* 開いたときのみボタンとの間隔を取る */
  border-top: 1px dashed #e8e0d5;  /* 開いたときのみボーダーを表示 */
}
/* （.wb-note.open の旧定義は統合済み） */
.wb-word-ja {
  font-size: 17px; /* 日本語 17px 固定 */
  font-weight: 700;
  color: #3d3229;
}
.wb-word-trans {
  font-size: 18px; /* 多言語 18px 固定 */
  color: #c2703d;
  font-weight: 700;
  margin-top: 2px;
}
.wb-word-kana {
  font-size: 14px;
  color: #7a6a58;
  margin-top: 2px;
}
.wb-word-reading {
  font-size: 13px;
  color: #b0a89c;
  margin-top: 2px;
}

/* ---- カタカナ改善（🔄提案 → 👍/👎） ---- */
/* ボタンはカタカナの最後の文字の直後にインライン配置（長いカタカナでも折返しは
   「その文字の次の文字位置」にボタンが追従し、別の行に落ちない） */
.wb-kana-improve {
  display: inline-block;
  vertical-align: baseline;
  max-width: 100%;
}
/* 🔄が付いたカタカナ行（カタカナ + 🔄を横に並べる） */
.wb-kana-improve .wb-kana-row {
  display: inline;
}
.wb-kana-improve .wb-kana-text {
  display: inline;
}
/* 提案カタカナ（カタカナの直下・破線枠）候補1の .kana-proposal */
.wb-kana-improve .wb-kana-proposal {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  padding: 2px 6px;
  border: 1px dashed #c9a58a;
  border-radius: 6px;
  color: #c2703d;
  background: #fdf8f3;
  max-width: fit-content;
}
/* 👍/👎はカタカナの下の別行・枠付き */
.wb-kana-improve .wb-kana-goodbad {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
/* 👍/👎は枠付きボタン（experimentals候補1の .gd-btn スタイルを復元） */
.wb-kana-improve .wb-kana-approve,
.wb-kana-improve .wb-kana-reject {
  background: #fff;
  border: 1px solid #e5ddd0;
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  opacity: 1;
  transition: all 0.15s;
  vertical-align: middle;
}
.wb-kana-improve .wb-kana-approve:hover { background: #e7f5e7; color: #2e7d32; border-color: #2e7d32; }
.wb-kana-improve .wb-kana-reject:hover { background: #fdeaea; color: #c62828; border-color: #c62828; }
.wb-kana-improve button:hover { opacity: 1; transform: scale(1.05); }
.wb-kana-improve button:disabled { opacity: 1; cursor: default; transform: none; }

.wb-kana-thanks {
  font-size: 11px;
  font-weight: 700;
  color: #2e7d32;
  background: #e7f5e7;
  border-radius: 6px;
  padding: 2px 6px;
  margin-top: 2px;
  display: none; /* 👍後（.show）にだけ表示 */
}
.wb-kana-thanks.show {
  display: inline-block;
  animation: wb-kana-fade 0.2s ease;
}
@keyframes wb-kana-fade {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}

/* ---- 複数言語: テーブルモード ---- */
/* セル幅固定・高さ可変・ヘッダは日本語+言語名のみ（同一フォント） */
/* スクロールwrapper（幅制限）→ タイトなwrapper（コンテンツ幅）→ テーブル */
.wb-table-scroll {
  /* 画面幅いっぱいまで広がり、テーブルが超えたらここで横スクロール */
  max-width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: safe center; /* テーブルを中央表示・溢れたら左端を優先してスクロール可能に */
}
.wb-table-wrap {
  /* コンテンツ幅（テーブル列合計）に収める。スクロールは外側の wrapper が持つ */
  width: max-content;
  flex: 0 0 auto;
  border: 1px solid #e8e0d5;
  border-radius: 12px;
  background: #fff;
}
.wb-table {
  /* 固定幅レイアウト: セル幅は列定義（th/td の width）で決まり、引き伸ばさない */
  /* テーブル全体の幅は JS で列数分（日本語130px + 各言語160px）に設定 */
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}
.wb-table th,
.wb-table td {
  padding: 8px 10px;
  border-right: 1px solid #f0ebe2;
  border-bottom: 1px solid #f0ebe2;
  text-align: center; /* セル内容を中央寄せ */
  vertical-align: top;
}
/* セル内の長い単語・長い文字も折り返して収める（overflow させない） */
.wb-table tbody td {
  position: relative;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}
/* セル内を縦積みにするラッパー（td は display:table-cell のまま維持） */
.wb-td-inner {
  display: flex;
  flex-direction: column;
  align-items: center; /* 日本語・翻訳・カタカナ・発音記号を中央寄せ */
}
/* セル構造: 1行目=再生ボタン（wb-td-actions）・本文は wb-td-inner */
.wb-td-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 4px;
  min-height: 26px; /* 空でも1行分の高さを確保 */
}
.wb-table th:last-child,
.wb-table td:last-child {
  border-right: none;
}
.wb-table thead th {
  background: #f5f0e8;
  font-weight: 700;
  font-size: 13px;
  color: #7a6a58;
  border-bottom: 1px solid #e8e0d5;
  white-space: nowrap;
}
.wb-table tbody tr:last-child td {
  border-bottom: none;
}
.wb-table tbody tr:hover {
  background: #fdf9f3;
}
.wb-th-ja,
.wb-td-ja {
  font-weight: 700;
  color: #3d3229;
  font-size: 17px; /* 日本語 17px 固定 */
  width: 180px; /* セル幅 180px 固定 */
}
/* 日本語テーブルセルは縦方向にも中央寄せ */
.wb-table tbody td.wb-td-ja {
  vertical-align: middle;
}
/* 横スクロール時も日本語列を左端に固定（sticky）して常に見えるようにする。
   ※ .wb-table tbody td の position:relative より特異性を上げて sticky を勝たせる */
.wb-table th.wb-th-ja,
.wb-table tbody td.wb-td-ja {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #fff; /* 不透明背景で下の列が透けないように */
  /* sticky 列の右ボーダー: border-collapse では隣接列に隠れるため box-shadow で再現 */
  box-shadow: inset -1px 0 0 #e8e0d5;
}
/* 日本語ヘッダーは縦固定（top:0）と横固定（left:0）を両立させるため z-index を上げる */
.wb-table thead th.wb-th-ja {
  z-index: 6;
  background: #f5f0e8;
}
/* 行ホバー時も日本語列の背景を維持（sticky 列が透けないように） */
.wb-table tbody tr:hover td.wb-td-ja {
  background: #fdf9f3;
}
.wb-th-lang {
  font-size: 13px;
  font-weight: 700;
  color: #7a6a58;
  width: 180px; /* セル幅 180px 固定 */
}
.wb-td-word {
  font-size: 18px; /* 多言語 18px 固定 */
  color: #c2703d;
  font-weight: 700;
}
.wb-td-kana {
  font-size: 14px; /* カードと 1:1 */
  color: #7a6a58;
  margin-top: 2px;
}
.wb-td-reading {
  font-size: 13px; /* カードと 1:1 */
  color: #b0a89c;
  margin-top: 2px;
}
.wb-td-empty {
  color: #c9bda9;
  text-align: center;
}

/* ---- 空状態・エラー ---- */
.wb-empty {
  color: #b0a89c;
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}
.wb-error {
  color: #d9534f;
  font-size: 14px;
}

/* ---- 音声設定ボタン（画面右下・固定・アプリ版と同デザイン） ---- */
.wb-voice-settings-btn {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 50;
  width: 36px;
  height: 36px;
  font-size: 18px;
  line-height: 1;
  border: 1px solid #d8d0c4;
  border-radius: 8px;
  background: #fffdf9;
  color: #5a5245;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: background 0.15s;
}
.wb-voice-settings-btn:hover { background: #f5f0e8; }
.wb-voice-settings-ico {
  font-size: 18px;
  line-height: 1;
}

/* ---- PWA インストール案内（ホーム画面に追加） ---- */
/* 言語選択（フィルタバー）の上に配置。右下固定ではなくインラインで表示。
   トップページ(#mobile-wip-banner)と同じく、モバイル幅(767px以下)でのみ表示。
   beforeinstallprompt 発火や iOS でも、デスクトップ幅では表示しない。 */
.wb-pwa-guide {
  display: none;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px;
}
@media (max-width: 767px) {
  .wb-pwa-guide:not([hidden]) { display: flex; }
}
.wb-install-app-btn {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid #c2703d;
  border-radius: 20px;
  background: #c2703d;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(194,112,61,0.35);
  transition: background 0.15s;
}
.wb-install-app-btn:hover { background: #a85f2f; }
.wb-install-app-btn:not([hidden]) { display: inline-block; }
.wb-ios-install-guide {
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #7a6a58;
  background: #fffdf9;
  border: 1px solid #d8d0c4;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  max-width: 300px;
}
@media (max-width: 767px) {
  .wb-ios-install-guide:not([hidden]) { display: block; }
}

/* ---- 音声設定モーダル ---- */
.wb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61,50,41,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.wb-modal-overlay.hidden { display: none; }
/* 汎用の非表示クラス（ドロップダウン等の開閉に使用） */
.hidden { display: none !important; }
.wb-voice-dialog {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(61,50,41,0.18);
}
.wb-voice-dialog h3 { margin: 0 0 8px; }
.wb-voice-note { font-size: 13px; color: #8a7a68; margin: 0 0 16px; line-height: 1.5; }
.wb-voice-lang-group { margin-bottom: 16px; }
.wb-voice-lang-group:last-child { margin-bottom: 0; }
.wb-voice-lang-label { font-weight: 700; font-size: 14px; color: #5a5245; margin-bottom: 4px; }
.wb-voice-lang-group .wb-voice-select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #d8d0c4;
  border-radius: 8px;
  background: #fffdf9;
  color: #5a5245;
  font-size: 14px;
}
.wb-voice-sel-row { display: flex; align-items: center; gap: 8px; }
.wb-voice-sample-btn {
  flex: none;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  border: 1px solid #e5b88a;
  border-radius: 8px;
  background: #fdf0e3;
  color: #a05a2a;
  cursor: pointer;
}
.wb-voice-sample-btn:hover { background: #fbe3c9; }
.wb-voice-sample-btn.playing { background: #fde8e8; border-color: #e5b0b0; color: #a03030; }
.wb-voice-sample-icon {
  display: inline-block;
  width: 1.2em;
  text-align: center;
}
.wb-voice-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}
.wb-voice-close {
  font-size: 14px;
  padding: 10px 28px;
  border-radius: 8px;
  border: 1px solid #d8d0c4;
  background: #fffdf9;
  color: #5a5245;
  cursor: pointer;
}
.wb-voice-close:hover { background: #f5f0e8; }

/* ---- レスポンシブ ---- */
@media (max-width: 600px) {
  /* カード幅160px固定・auto-fillでリキッド化: 375px(iPhone SE)で2列が必ず入る。
     180pxだと 2列+gap10px=370px > 親の実幅(375-padding)で2枚目が落ちるため縮小 */
  .wb-words { grid-template-columns: repeat(auto-fill, 160px); justify-content: center; }
  .wb-card { width: 160px; }
  .wb-level-cards { grid-template-columns: repeat(auto-fill, 160px); justify-content: center; }
  /* モバイル: フィルタグループの最大幅を解除（共通デザインの縦積み・中央寄せは共通CSSで適用） */
  .wb-filter-group {
    max-width: none; /* 不必要な最大幅（960px）をなくす */
  }
  /* モバイル: チップをコンパクトにして横スクロールで収まりやすく */
  .wb-langs,
  .wb-levels {
    flex: none;       /* 縦積みの親で flex:1 が縦に伸びるのを防ぐ */
    width: 100%;      /* 親幅に収め、overflow-x:auto で横スクロール */
  }
  /* モバイル: チップをコンパクトにして横スクロールで収まりやすく */
  .wb-lang,
  .wb-level {
    padding: 6px 10px;
    min-height: 36px;
  }
  /* モバイル: ページを縦積みにし、ツールバーを上部で横並び+sticky */
  .wb-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0; /* モバイルでは左右パディングをなくし、横幅を最大限使う */
  }
  .wb-content {
    align-self: stretch; /* column で交差軸（幅）を親に合わせる */
  }
  /* モバイル: グループと表示切替の2カラムを縦積みにする（左グループが0pxに潰れるのを防ぐ） */
  .wb-main-inner {
    flex-direction: column;
    gap: 8px;
  }
  /* モバイル: テーブル（width:max-content）に引っ張られて .wb-section が広がるのを防ぐ */
  .wb-section,
  .wb-groups-list,
  .wb-group-block,
  .wb-group-body {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
  .wb-display-toggle {
    order: -1; /* フィルタバーの上に表示 */
    position: sticky;
    top: 0;
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;
    gap: 6px;
    margin: 0;
    background: #fbf8f4;
    padding: 4px 0;
    border-bottom: 1px solid #e8e0d5;
    z-index: 40;
  }
  .wb-display-btn {
    width: 40px;
    height: 36px;
  }
  /* モバイル: グループ見出しの全再生ボタンをタップしやすく */
  .wb-group-play {
    width: auto;
    min-width: 96px; /* デスクトップと同じ幅（停止/全再生で不変） */
    height: 40px;
    font-size: 14px;
    padding: 0 12px;
  }
  .wb-group-pause,
  .wb-group-stop {
    width: auto;
    min-width: 84px; /* 2ボタン横並びのため幅を少し縮小 */
    height: 40px;
    font-size: 13px;
    padding: 0 10px;
  }
  .wb-group-toggle {
    padding: 12px 0 12px 12px;
  }
  .wb-group-count {
    margin-right: 8px;
  }
  /* モバイル: テーブル列幅を縮め、日本語列+1言語列（最低2列）が見えるようにする */
  .wb-th-ja,
  .wb-td-ja {
    width: 110px; /* 日本語列を縮める */
  }
  .wb-th-lang {
    width: 130px; /* 言語列を縮める */
  }
  /* モバイル: テーブルは横スクロール有り（既存 .wb-table-scroll の overflow-x:auto を維持） */
  .wb-table-scroll {
    display: flex; /* flex で justify-content:safe center による中央寄せを有効にする */
    min-width: 0; /* width:max-content の子に引っ張られて広がらないようにする */
    width: 100%; /* 画面幅いっぱいまで広がり、テーブルが超えたらここで横スクロール */
    justify-content: safe center; /* テーブルを中央表示・溢れたら左端を優先してスクロール可能に */
  }
  /* ---- SPレイアウト最適化: 幅をのびのび使う・二重マージン/パディング排除 ---- */
  /* メインの左右パディングを0にし、コンテンツを横幅いっぱいまで使う */
  .wb-main {
    padding: 12px 0;
  }
  /* フィルタバーの左右パディングを縮小（PCの20px→SPは8px） */
  .wb-filterbar {
    padding: 8px 8px;
  }
  /* グループツールバー: 絵文字ナビを横並び（sticky） */
  .wb-group-toolbar {
    flex-wrap: wrap;
    position: sticky; /* グループ切替を固定 */
    top: 0;
    margin: 0; /* 二重マージン排除（負マージンで打ち消す必要はない） */
    padding: 8px 12px;
  }
  /* グループ本文のパディングを縮小（PCの14px→SPは8px）してカードを横幅いっぱい使う */
  .wb-group-body {
    padding: 8px;
  }
  /* グループブロック: 閉じても幅が縮まないよう width:100% を維持 */
  .wb-group-block {
    width: 100%;
  }
  /* 表示切替ツール: 絵文字ナビの下に sticky で固定。
     1グループ固定表示になったので「すべて閉じる」は廃止。表示切替5ボタンを右寄せに配置 */
  /* top は JS（applyToolbarStickyTop）がツールバー実測高さから動的設定する */
  .wb-display-toggle {
    justify-content: flex-end; /* 表示切替を右寄せ */
    align-items: center;
    padding-right: 10px;
  }
  /* グループ見出し: 絵文字+表示切替の下に sticky で固定。top は JS が動的設定 */
}

/* ---- 読み込み中インジケーター（⏳砂時計回転・PMKotoba既存様式） ---- */
/* 絵文字ナビボタン自体に⏳回転ローディングを表示する。テーブルは置き換えず高さを保つ。 */
.wb-nav-loading .wb-group-nav-ico {
  display: inline-block;
  animation: hourglass-spin 1.2s linear infinite;
}
.wb-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 12px;
  color: #6b6257;
  font-size: 14px;
}
.wb-loading .hourglass {
  display: inline-block;
  animation: hourglass-spin 1.2s linear infinite;
  font-size: 20px;
}
@keyframes hourglass-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
/* ⚠️ iPad Safari バグ対策（WebKit 23113）: タッチデバイス（iPad/iPhone）では回転を無効化する */
@media (hover: none) and (pointer: coarse) {
  .wb-nav-loading .wb-group-nav-ico,
  .wb-loading .hourglass {
    animation: none;
  }
}