/* =================================================== */
/* ★★★ Impactフォント定義と調整用変数 ★★★ */
/* =================================================== */
@font-face {
  font-family: 'Impact Numbers';
  src: url('Impact.ttf') format('truetype');
  /* block: 読み込み中はフォールバックを見せず（不可視で待つ）、読み込めたら表示する。
     先読み(__fontsReady)で事前に読み込むため待ち時間はほぼ無く、番号(#108・日時等)が
     一瞬だけ別フォントで見えるチラつき(FOUT)を防ぐ。 */
  font-display: block;
}

/* 変数・レイアウト */
:root {
  /* ▼▼▼ ここでImpactフォントの見た目を調整できます ▼▼▼ */
  --impact-scale: 110%;       /* 縦幅の倍率 (100%が基準) */
  --impact-y-offset: 0.010em; /* 縦位置のオフセット (マイナスで上に、プラスで下に) */

  --impact-scale-meta: 120%; /* 「公開日時・動画時間」の縦幅 */
  --impact-y-offset-meta: 0.015em; /* 「公開日時・動画時間」の縦位置 */

  --impact-scale-ts: 110%;       /* タイムスタンプの縦幅 */
  --impact-y-offset-ts: 0.04em;  /* タイムスタンプの縦位置 */
  
  --bg-color: #f9fafe;
  --card-bg: #fff;
  --text-color: #242943;
  /* 補助の灰色（公開日時・動画時間・下部ナビの文字など）。本番サイト（searchtheradio.com）と同じ色 */
  --muted: #7c8798;
  --radius: 11px;
  --shadow: 0 8px 24px -10px rgba(14, 14, 24, 0.13);
  --transition: .18s cubic-bezier(.47,.17,.21,.92);
  --btn-main: #6654e8;
  --btn-hover: #5945d9;
  --btn-reset-bg: #f4f7fb;
  --btn-reset-border: #bfc8d6;
  --btn-reset-color: #3a4251;
  --filter-btn-active: #ebe9fd;
  --active-filter: #7c3aed;
  --active-filter-text: #fff;
  --sticky-z: 2050;
  --search-z: 2060;
}

/* htmlタグからは overflow-x: hidden を削除します */
html { margin:0; padding:0; }

/* bodyタグのみに適用します */
body { overflow-x: hidden; margin:0; padding:0; }

body {
  background: var(--bg-color);
  color: var(--text-color);
  font-family: fot-udkakugoc70-pro, 'Segoe UI', system-ui,-apple-system,sans-serif;
  font-weight: 400; /* 標準の太さを指定 */
  min-height: 100%;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ======================================================================== */
/* ===== ★★★ 固定ヘッダー内のコントロールを太字に変更 ★★★ ===== */
/* ======================================================================== */

/* --- ボタンとセレクトボックスのフォントを太字に変更 --- */
#filterToggleBtn,
#favOnlyToggleBtn,
#randomBtn,
#mainResetBtn,
#sortSelect {
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important;
  font-weight: 700 !important;
}

.sticky-search-area {
  position: fixed;
  top: 0; left: 0; right: 0;
  width: 100vw; z-index: var(--sticky-z);
  background: var(--bg-color);
  box-shadow: 0 2px 14px -8px #5744d814;
  padding: 0.38rem 0 0.21rem 0;
  border-radius: 0 0 14px 14px;
  border-bottom: 1.5px solid #ececec;
  display: flex; flex-direction: column; align-items: center;
  transition: box-shadow 0.14s;
}
.search-card {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.4em 15px 0.36em 15px;
  display: flex;
  flex-direction: column;
}
.search-row { display: flex; flex-direction: row; gap: 8px; align-items: center; width: 100%; }
.search-row-keyword { width: 100%; margin-bottom: 7px; }
.search-row-controls {
  display: flex; flex-direction: row; gap: 8px; width: 100%;
  position: relative;
}
.search-row-controls > * { min-width: 0; }
.searchbox-input {
  flex: 6 1 320px; min-width: 0;
  font-size: 1.05em; height: 2.3em;
  border-radius: 0.7em;
  padding: 0.32em 1em;
  border: 1.2px solid #e3e3ec;
  background: #fafdff;
  box-shadow: none;
  transition: border var(--transition), box-shadow var(--transition);
}
.searchbox-input:focus {
  border-color: var(--btn-main);
  box-shadow: 0 0 0 2px #7c3aed25;
  outline: none;
  background: #fff;
}
.searchbox-select {
  width: 100%;
  font-size: 1.01em;
  border-radius: 0.65em; height: 2.5em;
  
  /* ★修正: 矢印のスペース確保 (右パディングを 2.5em に変更) */
  padding: 0.18em 1.7em 0.18em 1em; 

  border: 1.1px solid #e3e3ec;
  
  /* ★修正: background -> background-color */
  background-color: #fafcff;
  
  transition: border var(--transition), box-shadow var(--transition);
  
  /* ★修正: appearance: none; に変更 */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  
  z-index: 1;
  text-align-last: center; /* ★ 文字中央揃え */

  /* ★★★ 以下を追記 (矢印SVG) ★★★ */
  /* currentColor を使うことで、文字色に合わせて矢印の色が変わります */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7em center;
  background-size: 12px 12px;
}
.results-count-under-bar {
  width: 100%; text-align: left; max-width: 860px; margin: 0 auto;
  font-size: 1.09em; font-weight: 600; color: #5744d8;
  background: none; padding: 0.33em 1.2em 0.2em 1.2em;
  letter-spacing: 0.01em;
  user-select: text;
  pointer-events: auto;
  position: relative;
  z-index: 2;
}
@media (max-width: 900px) {
  .search-card { max-width: 99vw; }
  .results-count-under-bar { max-width: 99vw; padding-left:0.5em; }
  .sort-wrapper { max-width: 99vw;}
}
@media (max-width: 600px) {
  .search-card { max-width: 100vw; border-radius: 9px; }
  .search-row-controls { gap: 5px; }
  .results-count-under-bar { padding-left:0.1em;}
  .sort-wrapper { flex: 2 1 90px;}
}
.filters-bar {
  /* 100vwはスクロールバー幅を含むため、兄弟要素(search-card等)とズレて
     ウィンドウ幅変更時にタグ位置が動いて見える。100%で揃える。 */
  width: 100%; max-width: 860px; margin: 0 auto;
  background: rgba(250,250,255,0.95);
  padding: 2.5px 0 3px 0;
  box-shadow: 0 2px 8px -6px #7c3aed13;
  min-height: 32px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px;
  justify-content: flex-start;
  user-select: none;
  position: relative;
  top: 0;
  left: 0;
  z-index: 2;
}
/* 選択中のフィルタのタグが無いときは、タグ用の帯の高さを取らない
   （空の帯が「表示数」の下に32pxの空白として残っていた。ホーム画面アプリ版と同じ扱いにする） */
.filters-bar:empty {
  min-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  box-shadow: none !important;
}
/* search-cardのブレークポイントと同じ幅にしてタグ位置のズレを防ぐ
   （基本ルールより後に書かないと max-width: 860px に負けるため、この位置に置く） */
@media (max-width: 900px) {
  .filters-bar { max-width: 99vw; }
}
@media (max-width: 600px) {
  .filters-bar { max-width: 100vw; }
}
.filter-tag {
  background: var(--active-filter); color: var(--active-filter-text);
  border-radius: 13px; padding: 2.5px 11px 2.5px 8px;
  font-size: 0.97em; font-weight: 500; display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; border: none; box-shadow: 0 2px 7px -6px #7c3aed20;
  transition: background 0.13s;
  outline: none;
  max-width: 100%;
  overflow: visible; text-overflow: clip; white-space: normal;
  /* ★折り返しはラベル文字の中だけで行う（nowrap＋.tag-label内で改行）。
     wrapにするとアイコンごと折り返して✕が2行目に落ち、崩れて見える */
  flex-wrap: nowrap;
  word-break: break-word;
  line-height: 1.25;
}
.filter-tag > i { flex: 0 0 auto; }
.filter-tag .tag-label {
  min-width: 0;
  text-align: left;
  overflow-wrap: anywhere;
}

.filter-tag:focus, .filter-tag:hover {
  background: #9b6ee9;
  color: #fff;
}
.filter-tag .fa-xmark { font-size: 0.93em; margin-left: 2px; }
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2045 !important;
  transition: opacity 0.22s;
}
.drawer-backdrop.show { display: block; opacity: 1; }
#filterDrawer { /* centered without transform */
  display: none; max-width: 1400px; /* iPad(〜1366px)まで画面いっぱい。超ワイドPCのみ抑制 */
  background: var(--bg-color, #f9fafe) !important;
  border-radius: 0 0 14px 14px;
  border: 1px solid #e7e7ef;
  box-shadow: 0 10px 32px -8px rgba(80,80,160,0.13);
  padding: var(--drawer-pt) var(--drawer-px) calc(var(--drawer-pt) - 2px) var(--drawer-px);
  z-index: 2050 !important;
  border-top: none;
  transition: opacity .17s;
}
@keyframes fadein-drawer { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: translateY(0);} }
/* フィルタードロワー専用: 移動なしのフェードのみ（開閉時に「ちょっと動く」見え方を無くす）。
   fadein-drawer は「もしかして」やお気に入り見出しが使い続けるため残している。 */
@keyframes fade-only-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-only-out { from { opacity: 1; } to { opacity: 0; } }
/* 閉じる時: main.jsが .closing を付与→フェードアウト完了後に display:none にする */
#filterDrawer.closing { animation: fade-only-out 0.17s ease-in forwards; }
.filter-section { margin-bottom: 13px; padding-left: 1.2rem; padding-right: 1.2rem; }
@media (min-width: 780px){
  .filter-section { padding-left: 0; padding-right: 0; }
}

@media (max-width: 600px) {
  #filterDrawer { /* centered without transform */ max-width: 100vw; }
  .filter-section { padding-left: 0.5rem; padding-right: 0.5rem; }
}
.filter-title {
  font-size: 1.02rem; font-weight: 700; margin-bottom: 8px; letter-spacing: 0.01em; color: #463d94;
  /* アイコンと文字はベースラインで揃える（ボックス中央揃えだとフォント内部の余白差で
     図形が上下にズレて見える。FAアイコンと見出しフォントはベースライン基準のインク範囲が
     ほぼ同じ(-0.88〜+0.12em / -0.86〜+0.09em)なので、同じ文字サイズならこれで高さも中心も一致する） */
  display: flex; align-items: baseline; gap: 6px;
}
/* 見出しアイコン: 絵文字（OS依存の見た目）ではなくFont Awesomeで統一。幅を固定して文字位置を揃える */
.filter-title > i {
  /* 箱幅は図形そのもの＋一定gapにして「アイコン右端→文字」の距離を揃える。
     文字よりほんの少し小さく(0.9em)。縮小するとインクの中心がベースライン寄りに下がるため、
     文字のインク中心(-0.385em)に合うよう計算値ぶん(約0.045em)だけ上げる */
  width: auto; font-size: 0.9em; line-height: 1;
  position: relative; top: -0.03em;
}
/* 画素実測に基づく個別補正（4倍解像度のスクリーンショットでインク中心を文字と±0.3px以内に）。
   カレンダー・ラジオは同サイズでも図形が僅かに低く描かれるため少し上げ、隙間の差も揃える */
.filter-title > i.fa-user { top: -0.06em; }
.filter-title > i.fa-calendar-days { top: -0.08em; margin-right: 0.5px; }
.filter-title > i.fa-radio { top: -0.08em; margin-right: -0.5px; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.guest-button, .btn-corner, .btn-year {
  padding: 8px 0;
  border-radius: 22px;
  font-weight: 500;
  border: 1.3px solid rgba(80,80,160,0.10);
  background: #fff;
  cursor: pointer;
  /* transition:all は全プロパティを監視して重いため、実際に変化するものだけに限定
     （動き系のtransitionは末尾の統一モーションブロックが !important で管理） */
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  position: relative;
  outline: none;
  box-shadow: none;
  width: 100%;
  font-size: 1.01em;
  margin-bottom: 0 !important;
  letter-spacing: 0.01em;
  overflow: hidden;
  white-space: normal;
  text-overflow: ellipsis;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 39px;
  /* translateZ(0)による常時レイヤー化は撤去（27ボタン分の合成レイヤーがスクロールを重くしていた）。
     ホバーの浮き上がり時だけ統一モーションブロックが一時的にレイヤーを作るので問題ない */
}
.btn-corner, .guest-button {
  font-size: 0.97em;
}
.btn-corner {
  font-size: clamp(0.90em, 3vw, 1em);
  line-height: 1.2;
  padding: 9px 2px 8px 2px;
}
.guest-button[aria-pressed="true"], .guest-button.active,
.btn-corner[aria-pressed="true"], .btn-corner.active,
.btn-year[aria-pressed="true"], .btn-year.active {
  outline: none;
  background: #ece8ff !important;
  border-color: #6c60e8 !important;
  box-shadow: 0 0 0 2.5px rgba(79,70,229,0.19) !important;
}

/* ホバーエフェクトを、マウス操作が可能なデバイスにのみ適用します */
@media (hover: hover) {
  .guest-button:hover, .btn-corner:hover, .btn-year:hover {
    transform: translateY(-1px) scale(1.03); box-shadow: 0 6px 18px -6px #978df644; background: #f5f4ff;
    color: #242943;
  }
}

.filter-section:last-child { margin-bottom: 0; }

.main-content {
  padding-top: var(--header-offset);
  max-width: 900px; margin: 0 auto;
  transition: margin-top 0.18s cubic-bezier(.4,1,.7,1.2);
}

/* フィルタボタンの長いラベル用: 文字サイズは変えず水平方向だけ圧縮する（JSがscaleXを設定） */
.btn-label-fit {
  display: inline-block;
  white-space: nowrap;
  transform-origin: center;
  /* will-change: transform は撤去。scaleXは一度きりの静的変形でアニメーションしないため
     恒常的なレイヤー確保はメモリの無駄になっていた */
}

@media (max-width: 600px) {
  .btn-corner, .guest-button, .btn-year {
    font-size: 0.95em;
    min-height: 37px;
  }
  /* 長いコーナー名は fitFilterButtons() が文字サイズを変えずに水平圧縮(scaleX)で収める。
     旧: font-size: clamp() でフォント自体を縮小していたが廃止 */
  .btn-corner[data-corner="ぼっち・ざ・おーでぃしょん！"] {
    padding-left: 2px;
    padding-right: 2px;
    line-height: 1.2;
  }
  .main-content {
    padding-left: 15px;
    padding-right: 15px;
  }
}
#results {
  display: grid; grid-template-columns: 1fr 1fr; gap: 13px 10px; margin: 0; padding: 0;
}
@media (max-width: 779px) {
  #results { grid-template-columns: 1fr; gap: 9px 0; }
}
.episode-item { border-radius: 11px; background: var(--card-bg);
  margin-bottom: 0; text-decoration: none; color: inherit;
  border: 1px solid #e5e7ef; cursor: pointer; min-width: 0;
  transform: translateZ(0);
}

/* カードのホバーエフェクトも、マウス操作が可能なデバイスにのみ適用します */
@media (hover: hover) {
  .episode-item:hover {
    background: #f5f7fa;
    border-color: #d0d7de;
  }
}

.thumbnail {
  width: 120px; flex-shrink: 0; border-radius: 9px; object-fit: cover; aspect-ratio: 16/9;
  opacity: 1;
  transition: none;
}

.thumbnail.loaded {
  opacity: 1;
}

.no-results {
  color: #888; font-size: 1.1em;
  background: #fcfcff; border-radius: 10px; box-shadow: 0 1px 8px -5px #aaa3; min-height: 100px; width: 100%;
}
.pagination-area {
  margin: 19px 0 10px 0; text-align: center;
}
.page-btn {
  background: #ebeafd; color: #463d94;
  border: 1px solid transparent; border-radius: 16px; padding: 9px 23px; margin: 0 3px 6px 3px;
  font-weight: 500; font-size: 1.02em; cursor: pointer;
  transition: background .17s, color .15s;
  box-shadow: 0 1.5px 4px -2px #7669ff15;
  transform: translateZ(0);
}
.page-btn.active {
  background: #7c3aed; color: #fff;
}
.page-btn:disabled { opacity: 0.55; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
footer { text-align: center; margin: 60px 0 20px; font-size: 0.8rem; color: var(--muted); }

/*
  数字を囲むspanタグに、Impactフォントを最優先で強制適用し、
  サイズと位置を調整するスタイル
*/
.impact-number {
  font-family: 'Impact Numbers' !important; /* 他の指定を上書きして強制適用 */
  font-weight: normal !important; /* ブラウザによる擬似的な太字化をリセット */
  display: inline-block; /* transformを有効にするため */
  /* CSS変数を使ってスケールと位置を適用 */
  transform: scaleY(var(--impact-scale, 1)) translateY(var(--impact-y-offset, 0));
}

/*
  公開日時・動画時間 (.episode-meta 内の数字) にだけ、
  独立した縦幅スケールを適用するための上書きルール
*/
.episode-meta .impact-number {
  transform: scaleY(var(--impact-scale-meta, 1)) translateY(var(--impact-y-offset-meta, 0));
}

/*
  タイムスタンプボタン (.ts-btn 内の数字) にだけ、
  独立したスケールと位置を適用するための上書きルール
*/
.ts-btn .impact-number {
  transform: scaleY(var(--impact-scale-ts, 1)) translateY(var(--impact-y-offset-ts, 0));
}

/* --- 以下、ダークモードや細部の追加CSS --- */

/* === ベース背景・テキスト === */
body.dark-mode {
  background: #22272e;
}

/* 固定ヘッダー */
body.dark-mode .sticky-search-area {
  background: #252c35 !important;
  border-bottom: 1.5px solid #2e3640 !important;
}
body.dark-mode .search-card {
  background: #2d333b !important;
  color: #f1f3f7 !important;
}

/* 入力欄・セレクト */
body.dark-mode .searchbox-input,
body.dark-mode .form-select.searchbox-select {
  border-color: #394150 !important;
  padding-right: 2.5em !important;
  /* ★ 矢印の background-image 指定をここから削除します */
}

/* ★★★ 以下のブロックを「新しく追加」してください ★★★ */
body.dark-mode .form-select.searchbox-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") !important;
}
body.dark-mode .searchbox-input:focus {
  background: #262e36 !important;
}
/* 検索結果件数バー */
body.dark-mode .results-count-under-bar {
  color: #a6e1fa !important;
  background: #252c35 !important;
}

/* 選択中フィルターエリア */
body.dark-mode .filters-bar {
  background: #232a33ee !important;
  box-shadow: 0 2px 8px -6px #0006 !important;
}

/* フィルターDrawer（詳細フィルター） */
body.dark-mode #filterDrawer { /* centered without transform */
  margin: 0 auto;
  background: #2b323b !important;
}

body.dark-mode .filter-title {
  color: #8de0ee !important;
}
body.dark-mode .guest-button,
body.dark-mode .btn-corner,
body.dark-mode .btn-year {
  background: #232c35 !important;
  color: #e0f1f1 !important;
  border: 1.3px solid #40605a !important;
}
body.dark-mode .guest-button[aria-pressed="true"],
body.dark-mode .guest-button.active,
body.dark-mode .btn-corner[aria-pressed="true"],
body.dark-mode .btn-corner.active,
body.dark-mode .btn-year[aria-pressed="true"],
body.dark-mode .btn-year.active {
  background: #364a55 !important;
}

/* ダークモードのホバーエフェクトも同様に制限します */
@media (hover: hover) {
  body.dark-mode .guest-button:hover,
  body.dark-mode .btn-corner:hover,
  body.dark-mode .btn-year:hover {
    background: #384d5d !important;
    color: #96e5c4 !important;
  }
}

/* 見出しアイコンは文字色をそのまま継承させる（以前の薄緑指定は文字と色味がズレて見えたため廃止） */

/* ページネーション */
body.dark-mode .pagination-area {
  background: none !important;
}
body.dark-mode .page-btn {
  background: #283240 !important;
  color: #a6e1fa !important;
  border: 1px solid transparent !important;
  border-radius: 16px;
  box-shadow: 0 2px 8px -6px #121a2160;
}
body.dark-mode .page-btn:disabled {
  background: #323a47 !important;
  color: #a9b8c0 !important;
}

/* 検索結果カード */
body.dark-mode .episode-item {
  border: 1px solid #33404c !important;
  background: #252c35 !important;
}

/* ダークモードのカードホバーエフェクトも同様に制限します */
@media (hover: hover) {
  body.dark-mode .episode-item:hover,
  body.dark-mode .episode-item:focus-visible {
    background: #27343b !important;
    border: 1px solid #4a5967 !important;
  }
}

body.dark-mode input::placeholder,
body.dark-mode .searchbox-input::placeholder {
  color: #8ca2b3 !important;   /* 見やすい淡いブルーグレー */
  opacity: 1 !important;
}

@media (min-width: 900px) {
  .main-content {
    max-width: 1160px;
  }
  .search-card,
  .filters-bar,
  .results-count-under-bar {
    max-width: 1160px;
  }
}

.episode-item {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.episode-item .thumbnail {
  width: 120px;
  flex-shrink: 0;
}

.episode-meta {
  color: var(--muted);
  margin: 3px 0 0 0;
  line-height: 1.4;
  white-space: normal !important;
  word-break: break-word !important;
  overflow-wrap: anywhere !important;
  overflow: visible !important;
}

/* テーマ変更ボタンのスタイル（こちらで表示を制御します） */
#theme-toggle-btn {
  /* 位置とレイヤー */
  position: fixed;
  right: 18px;
  /* ★整理: ここにあった z-index: 3010 !important は削除。後方の #theme-toggle-btn
     { z-index: 10 !important } に常に負けていて実効値は10だった（実挙動は変更なし） */

  /* アイコンの中央揃え */
  display: flex;
  align-items: center;
  justify-content: center;

  /* 見た目 */
  width: 55px;
  height: 55px;
  font-size: 30px;
  padding: 0;

  background: var(--card-bg, #ffffff);
  color: var(--muted, #7c8798);
  border: 2px solid var(--btn-reset-border, #e5e7eb);

  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
  transform: translateZ(0);
}

#loading-screen.fadeout {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.45s ease-out; /* フェードは素早く（表示時間の長さで魅せる） */
  }

  #loading-screen {
  background: #fff;
  transition: background 0.3s;
}

body.dark-mode #aboutModalContent {
  box-shadow: 0 8px 30px -6px #23244080;
}
body.dark-mode #aboutModalContent a {
  color: #8de0ee !important;
}

/* 跳ねる4つの丸ローディング */
.loading-ball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  animation: bounce 0.6s infinite ease-in-out;
  
  /* ★追加: スマホでのカクつきを防ぐため、GPU処理を強制する */
  will-change: transform;
  transform: translateZ(0); 
}

/* 遅れはマイナスで指定する（周期0.6sから引いた値。見た目の波は 0/0.15/0.3/0.45s 遅れと同じ）。
   プラスの遅れだと、表示された瞬間から動き出すとき（通信が遅いときのPWA起動など）に
   2〜4個目の玉が最大0.45秒止まったままになり、波がつっかえて「かくつく」ように見えていた。
   マイナスなら最初のフレームから全部の玉が途中から動いている */
.ball1 { background-color: #ff6496; animation-delay: 0s;    }
.ball2 { background-color: #fabe00; animation-delay: -0.45s;}
.ball3 { background-color: #006ebe; animation-delay: -0.3s; }
.ball4 { background-color: #e60046; animation-delay: -0.15s;}

@keyframes bounce {
  0%, 80%, 100% {
    /* ★変更: translateY を translate3d に変えることでGPUアクセラレーションを確実にする */
    transform: translate3d(0, 0, 0);
  }
  40% {
    /* ★変更: translateY を translate3d に変える */
    transform: translate3d(0, -12px, 0);
  }
}

/* 初期描画の一瞬だけ使うプレロード用フラグ */
html.dark-preload,
html.dark-preload body {
  background: #22272e !important;
  color: #e5ecec !important;
}

/* ローディング画面が透けて白く見えないように */
body.dark-mode #loading-screen {
  background: #22272e; /* 透明だと背面が白く見える端末がある */
}
#results h5.mb-1,
.ts-episode-card h5.mb-1 {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.25;
  max-width: 100%;

  /* ▼▼▼ 以下2行を追加 ▼▼▼ */
  min-width: 0; /* Flexboxレイアウト内で正しく縮むようにするおまじない */
  overflow: hidden; /* この要素自体のはみ出しも防ぐ */
}
.guest-one-line {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  vertical-align: top;
  /* 長い名前は main.js が scaleX で水平圧縮する。左端を基点に縮める */
  transform-origin: left center;
}

/* 各カードに★ボタン */
.episode-item{ position:relative; } /* 既存に追加でOK */
.fav-btn{
  position:absolute;right:10px;top:10px;width:34px;height:34px;border-radius:50%;
  background:#fff;border:1px solid #e6e6f3;box-shadow:0 2px 10px -6px #0002;
  display:flex;align-items:center;justify-content:center;cursor:pointer;
  transition:transform .12s, box-shadow .12s, background .12s;
  transform: translateZ(0);
}
.fav-btn i{
  font-size:16px;
  color: #333742;
}
.fav-btn:hover{ transform:scale(1.06); }
.fav-btn.active{ background:#fff3c4; border-color:#f5b301; }
.fav-btn.active i{ color:#f5b301; }

/* ”0件”のときは .no-results が使われる（既存） */

/* 全体に少し動き：カードのフェードアップ */
@keyframes rise{ from{opacity:0; transform:translateY(6px)} to{opacity:1; transform:translateY(0)} }
#results .episode-item{
  animation:rise .24s ease both;
  /* 段差ディレイは最初の8枚まで（最大160ms）。以前は20枚分（最大380ms）待たされ、
     連打時に画面全体が長くゴースト状態になり「押せていない」ように見えた。
     見た目の段差感は維持しつつ、全カードが約0.4秒で出揃う */
  animation-delay: calc(min(var(--i), 8) * 20ms);
}

/* === Dark mode variable overrides for hover colors === */
body.dark-mode {
  --filter-btn-active: rgba(200, 200, 255, 0.15);
  --btn-main: #4d6272;
}

/* ダークモード調整 */
body.dark-mode .fav-btn{border-color:#394150; }

/* ===== Favorite button (dark mode) ===== */
body.dark-mode .fav-btn{
  background:#2a2f37 !important;
  border:1px solid #41505f !important;
  color:#e7eef6 !important;       /* 非アクティブ時の星色 */
}
body.dark-mode .fav-btn i{ color:#e7eef6 !important; }

/* アクティブ時は明るい背景＋濃い星（色反転で視認性アップ） */
body.dark-mode .fav-btn.active{
  background:#ffd24e !important;
  border-color:#ffd24e !important;
  color:#2b2b2b !important;
}
body.dark-mode .fav-btn.active i{ color:#2b2b2b !important; }

/* 0件カードをグリッド1行いっぱいにして中央へ */
#results .no-results{
  grid-column: 1 / -1;      /* 2カラム時も横いっぱい */
  max-width: 760px;          /* 広すぎ防止 */
  margin: 6px auto;          /* 中央寄せ */
}

/* ダークモード配色 */
body.dark-mode .no-results{
  background:#2d333b !important;
  color:#bcd6ea !important;
  border:1px solid #394150 !important;
  box-shadow: 0 1px 10px -6px #000a !important;
}

/* ★を右下に配置（既存の right/top 指定を上書き） */
#results .episode-item { position: relative; }           /* 念のため */
#results .episode-item .fav-btn{
  top: auto;                 /* 右上→解除 */
  bottom: 10px;              /* 右下に固定 */
  right: var(--card-pad-r, 10px); /* 右端をテキスト列の右端と揃える */
}
#results .episode-item .photo-btn{
  right: calc(var(--card-pad-r, 10px) + 42px); /* ★の左隣（34px＋間隔8px） */
}
/* スマホ幅: 画素実測で ★/リンク ボタンが「公開日時／動画時間」の文字中心より僅かに上に
   見えていたため2px下げ、PC/iPad（文字中心の約1px下）と同じ見え方に揃える */
@media (max-width: 600px) {
  #results .episode-item .fav-btn,
  #results .episode-item .photo-btn { bottom: 8px; }
}

/* ===== 端末でのダブルタップ拡大を抑止 ===== */
button, a, select, input, label { touch-action: manipulation; }
/* サムネ + タイムスタンプ表示 */
.thumb-col { width:120px; flex-direction:column; }
.ts-buttons { display:flex; flex-wrap:wrap; gap:6px; }
.ts-btn {
  display:inline-block;
  background:#ebeafd; line-height:1.2;
}
/* ダークモード */
body.dark-mode .ts-btn { background:#25323c; }

/* --- Autocomplete (検索候補) -------------------- */
.search-row-keyword { position: relative; }

.autocomplete[hidden] { display: none !important; }
.autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #e3e3ec;
  border-radius: 10px;
  box-shadow: 0 12px 28px -10px rgba(60,60,110,0.18);
  max-height: 320px;
  overflow-y: auto;
  z-index: var(--search-z);

  transform: translateZ(0);
  will-change: transform, opacity;
}

.autocomplete-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; font-size: 0.98em;
}
/* ★:hoverはマウス環境限定にする。iOSはタッチした要素に:hoverを適用するため、
   無条件だと候補リストをスクロールする指の接触のたびに背景が点いて消え、
   「点滅」して見えていた（キーボード選択のaria-selectedは全環境で有効のまま） */
.autocomplete-item[aria-selected="true"] { background: #f4f6ff; }
@media (hover: hover) {
  .autocomplete-item:hover { background: #f4f6ff; }
}
.autocomplete-item .type { line-height: 1;
  border: 1px solid #e3e3ec; border-radius: 999px; color: #7c8798;
}
.autocomplete-item .label { flex: 1 1 auto; min-width: 0; }

/* Dark mode */
body.dark-mode .autocomplete {
  background: #2d333b; border-color: #394150; box-shadow: 0 14px 34px -12px #000a;
}
body.dark-mode .autocomplete-item[aria-selected="true"] { background: #2b3a46; }
@media (hover: hover) {
  body.dark-mode .autocomplete-item:hover { background: #2b3a46; }
}

/* =================================================== */
/* ★★★ Adobe Fonts 読み込み対策 (FOUC防止) ★★★ */
/* =================================================== */

/* フォント読み込み中 (.wf-loading) は、検索候補欄を透明にしておく。
  .wf-loading は index.html のAdobe Fontsスクリプト (L140) によって自動で付与されます。
*/
html.wf-loading #autocomplete {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

/* フォント読み込み完了時 (.wf-active) に、検索候補欄を表示する。
  .wf-active もAdobe Fontsスクリプトによって自動で付与されます。
*/
html.wf-active #autocomplete {
  visibility: visible;
  opacity: 1;
}

/* --- iOS PWA の安全域対応（ノッチ・ステータスバーを回避） --- */

/* 既存の .sticky-search-area に追記 */
.sticky-search-area{
  /* 上パディングを安全域ぶんだけ増やす */
  padding-top: calc(0.38rem + var(--safe-top));
  /* 横も端末によっては必要になるので入れておくと安心 */
  padding-left:  max(0px, var(--safe-left));
  padding-right: max(0px, var(--safe-right));
}

/* 旧iOS対策（古いSafariで constant() を見る端末向け・任意） */
@supports (padding: constant(safe-area-inset-top)) {
  .sticky-search-area{
    padding-top: calc(0.38rem + constant(safe-area-inset-top));
  }
}

/* === Radio History Timeline (refined) === */
:root{
  --history-line: #dfe5f5;
  --history-dot: #6c5ce7;
  --history-dot-ring: 36, 28, 170; /* rgb base for ring alpha */
  --history-card-bg: #ffffff;
  --history-card-bd: #e9edf7;
  --history-muted: #667085;
  --history-year: #3b3486;
}
@media (prefers-color-scheme: dark){
  :root{
    --history-line: #384154;
    --history-dot: #9ad9de;
    --history-dot-ring: 154, 217, 222;
    --history-card-bg: #22272e;
    --history-card-bd: #364152;
    --history-muted: #9aa4b2;
    --history-year: #9ad9de;
  }
}

.history-section{
  width: 100%;
  /* 幅いっぱい(960px)の細い帯だと中の短い文字が浮いて見えるため、中身に見合う幅に絞る */
  max-width: 640px;
  /* ページ番号(下余白10px)との間隔が広すぎたため上余白を詰める（合計約30px） */
  margin: 20px auto 24px;
  padding: 0 16px;
}
.history-toggle{
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  padding: 16px 18px; border-radius: 14px; border: 1px solid var(--history-card-bd);
  background: var(--history-card-bg); color: inherit; cursor: pointer;
  font-weight: 750; letter-spacing: .01em;
  transform: translateZ(0);
}
.history-toggle .title{ font-size: 1.06em; }
/* ★整理: .history-toggle .sub は削除（該当クラスの要素がHTML/JSのどこにも存在しない） */
.history-toggle:focus-visible{ outline: 3px solid rgba(99,102,241,.45); outline-offset: 2px; }

.history-body{ position: relative; padding: 14px 2px 2px; }

@media (prefers-color-scheme: dark){
  .history-sticky-year{ background: rgba(33,38,46,.6); }
}

.history-timeline{
  position: relative; margin: 8px 0 0 28px; padding-left: 24px;
}
.history-timeline::before{
  content:""; position:absolute; top: 0; bottom: 0;
  width: 2px; background: linear-gradient(var(--history-line), transparent 60%), var(--history-line);
  border-radius: 2px;
}

/* 年の見出し */
.history-year{
  position: relative; margin: 22px 0 10px;
  font-weight: 900; color: var(--history-year); letter-spacing: .02em;
}

/* アイテム */
.history-item.has-link { cursor: pointer; } /* リンク付きカードは全体がクリック可能 */
/* ストレッチリンク: リンクの当たり判定をカード全面に拡張
   （.history-itemがposition:relativeなのでカード全体を覆う） */
.history-item.has-link .label a::after {
  content: '';
  position: absolute;
  inset: 0;
}
.history-item{
  position: relative; padding: 12px 14px 14px 16px; margin: 12px 0 14px;
  background: var(--history-card-bg); border: 1px solid var(--history-card-bd); border-radius: 12px;
  transform: translateZ(0);
  animation: historyFade .35s ease both;
}
@keyframes historyFade {
  from { opacity: 0; translate: 0 6px; }
  to   { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: reduce){
  .history-item{ animation: none; }
}

.history-item::before{
  content:""; position:absolute; top: 18px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--history-dot);
  box-shadow:
    0 0 0 4px rgba(var(--history-dot-ring), .18),
    0 10px 24px -8px rgba(16,16,64,.35);
}
@media (hover: hover) {
  .history-item:hover{
    border-color: color-mix(in oklab, var(--history-card-bd), var(--history-dot) 20%);
  }
}

.history-item .date{ margin-bottom:4px; color: color-mix(in oklab, var(--history-year), #ffffff); }
.history-item .label{ font-weight:800; line-height: 1.5; }
.history-item .desc{ color: var(--history-muted); margin-top: 2px; }
.history-item a{ color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* 小さめ画面最適化 */
@media (max-width: 640px){
  .history-section{ margin-top: 16px; } /* スマホ: ページ番号との間隔 合計約26px */
  .history-timeline{ margin-left: 22px; padding-left: 18px; }
  .history-item{ padding: 12px 12px 14px 14px; }
  .history-sticky-year{ font-size: 13px; padding: 5px 10px; }
}

/* === Radio History Timeline: tweaks === */
/* タイトル中央揃え（開閉ボタン） */
.history-toggle{
  position: relative;
  display:flex; align-items:center; justify-content:flex-end; gap:12px;
}
.history-toggle-chevron{
  font-size: 0.9em;
  opacity: 0.45;
  transition: transform .15s, opacity .15s;
}
@media (hover: hover) {
  .history-toggle:hover .history-toggle-chevron{ opacity: 0.9; transform: translateX(2px); }
}
.history-toggle .title{
  position:absolute; left:50%; transform:translateX(-50%);
  text-align:center; pointer-events:none; /* クリックはボタン全体に委譲 */
  font-weight: 800;
}

/* ダークモード強化（ヒストリー一式） */
body.dark-mode .history-toggle{
  background:#2d333b !important; border-color:#3b4552 !important;
  color:#e9f2f6 !important;
}
body.dark-mode .history-year{ color:#9ad9de !important; }
body.dark-mode .history-item{
  background:#2d333b !important; border-color:#3b4552 !important;
}
body.dark-mode .history-item .date{ color:#9ad9de !important; }
body.dark-mode .history-sticky-year{
  background: rgba(33,38,46,.6) !important; border-color:#3b4552 !important;
  color:#9ad9de !important;
}

.history-item .date{
  font-weight: 800;
  font-size: 13px;       /* 13.5→13 に微下げ */
  opacity: .95;
}

/* Fix for circle misalignment on mobile */

/* Stylish design improvements */

/* Connectors */

/* Mobile: タイムラインの丸位置を微修正（18px padding, 線は4px → 左端 -21px） */

.history-timeline::before { left: -7px; }
.history-item::before      { left: -38px; }
@media (max-width: 640px){
  .history-timeline .history-item::before { left: -32px; }
}

/* ラジオの歴史：年バッジを使わない */
.history-sticky-year { display: none !important; }

/* ラジオの歴史：説明文の行間を調整 */
.history-item .desc { line-height: 1.55; }   /* 元は 1.7 */
@media (max-width: 640px){
  .history-item .desc { line-height: 1.4; }  /* スマホはさらに少しタイトに */
}

/* === Modal 基本 === */
.modal-overlay{
  display: none;
  position: fixed; inset: 0;
  /* モーダル背後はしっかり暗くして、モーダルに視線を集める（全カラー共通） */
  background: rgba(0, 0, 0, 0.78) !important;
  align-items: center; justify-content: center;
}

/* ダークモード時はオーバーレイ濃いめ */
body.dark-mode .modal-overlay,
body.theme-blue .modal-overlay,
body.theme-red .modal-overlay {
  /* 暗色系テーマはさらに濃く。青みのない純黒にする（青成分が入ると背景が青っぽく見える） */
  background: rgba(0, 0, 0, 0.85) !important;
}

.modal-content.history-modal{
  background: var(--history-card-bg);
  color: inherit;
  width: min(960px, 95vw);
  max-height: min(80vh, calc(100vh - 80px));
  border: 1px solid var(--history-card-bd);
  border-radius: 16px;
  overflow: auto;
  position: relative;
}

/* スマホでは少し低めにして、URLバーの有無で伸びすぎないようにsvhで制御 */
@media (max-width: 600px) {
  .modal-content.history-modal {
    /* ちょい低め：76svh くらいが体感バランス良い */
    max-height: min(76svh, calc(100svh - 96px));
  }
}

/* svh非対応ブラウザ用の軽いフォールバック（あれば上書きされる） */
@supports not (height: 1svh) {
  @media (max-width: 600px) {
    .modal-content.history-modal {
      max-height: min(76vh, calc(100vh - 96px));
    }
  }
}

/* モーダル固定ヘッダー（タイトル中央＋×固定） */
.history-modal .modal-header{
  position: sticky; top: 0; z-index: 10;
  background: var(--history-card-bg);
  border-bottom: 1px solid var(--history-card-bd);
}
.history-modal .modal-title{
  margin: 0 auto; font-size: 1.15rem; font-weight: 800;
  text-align: center; line-height: 1.2;
  color: var(--history-year);
  display: block;
}

/* ダーク時のカード境界色・背景は変数で自動適用 */
body.dark-mode .modal-content.history-modal{
  background: var(--history-card-bg);
  border-color: var(--history-card-bd);
}

/* モーダル内の“現在の年”バッジがヘッダーの下に来るよう微調整 */
#historyStickyYear{
  top: 56px;            /* ヘッダー高の分だけ下げる */
  z-index: 2;
}

/* 追加：サイトのダーク切替でも色変数を上書き */
body.dark-mode{
  --history-line:#384154;
  --history-dot:#ffffff;
  --history-dot-ring:154,217,222;
  --history-card-bg:#22272e;
  --history-card-bd:#364152;
  --history-muted:#9aa4b2;
  --history-year:#ffffff;
}

/* 追加：フェードイン＆ポップ */
.modal-overlay[hidden]{display:none;}
.modal-overlay.show{display:flex; animation:modalFade .22s ease-out both;}
/* 開く時は動かさずフェードインのみ（オーバーレイのopacityが上げる）。位置・サイズは固定 */
.history-modal{transform:none; animation:none; will-change: opacity;}
@keyframes modalFade{from{opacity:0}to{opacity:1}}
@keyframes modalPop{to{transform:translateY(0) scale(1)}}

.history-modal .modal-close i{ font-size:1.25rem; }

@media (hover: hover) {
  .history-modal .modal-close:hover{ transform: scale(1.06); background: rgba(255,255,255,0.92); }
}
.history-modal .modal-close:active{ transform: scale(0.98); }
.history-modal .modal-close:focus-visible{ outline: 3px solid #8de0ee; outline-offset: 2px; }

/* ダークモードの閉じるボタン */
body.dark-mode .history-modal .modal-close{
  background: rgba(255,255,255,0.10);
  color: #eaf4f6;
  border-color: #3b4552;
  box-shadow: 0 8px 24px -12px rgba(0,0,0,.6);
}
@media (hover: hover) {
  body.dark-mode .history-modal .modal-close:hover{
    background: rgba(255,255,255,0.16);
  }
}

/* 余白を少し広げる＆タイトル右に×のスペース確保 */
.history-modal .modal-header{ padding:14px 56px 12px; } /* 右=56pxで×が食い込まない */
.history-modal .history-body{  padding:16px 22px 22px 16px; } /* ←右側にゆとり */

/* 閉じる時：フェードアウト。
   display:flex を明示しないと show を外した瞬間に base の display:none になり、
   アニメーションが見えないまま消えてしまう（＝フェードアウトが無効になる）ので必ず指定する。
   ★整理: 同一セレクタで modalFadeOut 版→modalHide 版と二重定義されていたため後勝ちの
   modalHide 版のみ残した。modalFadeOut のkeyframes自体は #aboutModal.closing が使うので残す。
   未使用だった modalPopOut（2定義）は削除。 */
.modal-overlay.closing{ display: flex; animation: modalHide .18s ease-in both; }
/* 閉じる時は動かさず、開いた位置に留めたままフェードアウトのみ（オーバーレイのopacityが下げる） */
.modal-overlay.closing .history-modal{ animation: none; transform: translateY(0) scale(1); }

@keyframes modalFadeOut { from{opacity:1} to{opacity:0} }
@keyframes modalHide { from{opacity:1} to{opacity:0} }

body.fav-only #radio-history { display: none !important; }

/* ★整理: .close ルールは削除（class="close" の要素はどこにも存在しない） */

/* === Radio History modal: CLOSE button (single source of truth) === */

#historyModal .modal-close {
  position: absolute;
  top: 4px;
  right: 8px;                          /* ← もっと右寄せしたいなら 0～4px */
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#aboutCloseBtn i,
#historyCloseBtn i {
  font-size: 1.1rem; /* 他モーダルの×と同一 */
}

/* ダークモードの見た目（既存と同じでOK。必要なら残す） */
body.dark-mode #aboutCloseBtn,
body.dark-mode #historyModal .modal-close {
  background: #000000;
  color: #e7e9ea;
  border-color: #2f3336;
}
@media (hover: hover) {
  body.dark-mode #historyModal .modal-close:hover{
    background: #16181c;
  }
}

/* ライトテーマ時の閉じるボタン（落ち着いた中間トーン） */
#aboutCloseBtn,
#historyModal .modal-close {
  background: #ffffff;
  color: #6b7280;                 /* 他モーダルの×と同一色 */
  border: 1.5px solid #e5e7eb;    /* 他モーダルの×と同一枠線 */
}
@media (hover: hover) {
  #historyModal .modal-close:hover {
    background: #f6f8fc;            /* うっすらホバー */
  }
}

/* === FIX: Force light theme colors for history when site is in light mode,
   even if the OS is set to dark (iOS Safari was applying @media(prefers-color-scheme: dark)
   and overriding these CSS variables only for the history section). === */
body:not(.dark-mode){
  --history-line: #dfe5f5;
  --history-dot: #6c5ce7;
  --history-dot-ring: 36, 28, 170;
  --history-card-bg: #ffffff;
  --history-card-bd: #e9edf7;
  --history-muted: #667085;
  --history-year: #3b3486;
}

/* === iPhoneでfooterが隠れる対策（FAB & セーフエリア対応） === */

/* 1) 下固定ボタンをセーフエリア分だけ持ち上げる */
#theme-toggle-btn {
  bottom: calc(18px + var(--safe-bottom)) !important;
}

/* 古いiOS向け（optional） */
@supports (bottom: constant(safe-area-inset-bottom)) {
  #theme-toggle-btn {
    bottom: calc(18px + constant(safe-area-inset-bottom)) !important;
  }
}

/* 2) ページ末尾に余白を用意して、ボタンに被らないようにする */
.main-content {
  padding-bottom: calc(60px + var(--safe-bottom));
}

footer {
  padding-bottom: calc(8px + var(--safe-bottom));
}

/* 「ぼっち・ざ・らじお！の歴史」を1行固定に */
.history-toggle .title{
  white-space: nowrap;       /* 改行しない */
  overflow: hidden;          /* はみ出しを隠す */
  text-overflow: ellipsis;   /* 入り切らない時は … */
  flex: 1 1 auto;            /* 右側の要素の分だけ縮められるように */
  min-width: 0;              /* flex子の省略幅を許可（ellipsisに必須） */
}

@media (max-width: 380px){
  .history-toggle .title{ font-size: 1em; }
}

/* === SNS share buttons (under the history button) === */
.share-buttons{
  display:flex;
  justify-content:center;
  gap:16px;
  margin:12px auto 0;
}

/* ラベル付きのピル型（丸アイコン1つだけだと孤立して浮いて見えるため） */
.share-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:9px;
  width:auto; height:44px;
  padding:0 22px 0 18px;
  border-radius:999px;
  background:#ffffff;
  color:#374151;
  border:1px solid #e5e9f7;
  font-size:15px;
  font-weight:700;
  box-shadow:none; /* 影なし（周囲のフラットなボタンと統一） */
  transition:transform .15s, background .15s;
  -webkit-tap-highlight-color: transparent; /* モバイルの青ハイライト除去 */
  transform: translateZ(0);
}
@media (hover: hover) {
  .share-btn:hover{ transform:translateY(-1px); background:#f7f8ff; }
}

/* ダークモード調整 */
body.dark-mode .share-btn{
  background:#283240;
  color:#a6e1fa;
  border-color:#33404c;
}
@media (hover: hover) {
  body.dark-mode .share-btn:hover{
    background:#323a47;
  }
}

/* シェアボタンの下線を完全に無効化（hover/focus含む） */
.share-btn,
.share-btn:link,
.share-btn:visited,
.share-btn:hover,
.share-btn:focus,
.share-btn:active {
  text-decoration: none !important;
}

/* アイコンの行高を詰めてセンタリングを安定 */
.share-btn i {
  line-height: 1;
  font-size: 19px;
  pointer-events: none; /* クリックを <a> に通す保険 */
}
.share-btn .share-label { line-height: 1; pointer-events: none; }

/* キーボード操作用のフォーカスリング（下線消した代わり） */
.share-btn:focus-visible {
  outline: 2px solid #5744D8;
  outline-offset: 2px;
}
body.dark-mode .share-btn:focus-visible {
  outline-color: #8de0ee;
}

@media (max-width: 600px){
  .share-btn{
    height:48px;         /* 指標：タップターゲット 48px以上 */
    padding:0 24px 0 20px;
    font-size:15px;
  }
}

/* Radio History modal — close button (single source of truth) */
/* 左右対称の余白にする（左16px/右60pxだとタイトルが中央から左へずれて見える） */
#historyModal .modal-header { padding:12px 60px 10px; }
#aboutCloseBtn,
#historyCloseBtn {
  position: absolute;
  top: 14px;   /* 他モーダルの×と同一位置 */
  right: 14px;
  width: 38px; /* 他モーダルの×と同一サイズ */
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}

/* ★ボタンの分だけ右側にスペース（スマホ） */
@media (max-width: 640px){
  #results .episode-item,
  .ts-episode-card .episode-item{ --card-pad-r: 12px; padding-right: var(--card-pad-r); } /* テキスト列の右端＝ボタン右端 */
}

@media (max-width: 640px){
  .episode-meta{
    line-height: 1.35;
  }

  #results h5.mb-1,
  .ts-episode-card h5.mb-1{
    font-size: 13.5px;
    /* PC版と行間の感覚を合わせるため1.2に戻します */
    line-height: 1.2;
    /* h5自体の下の余白は無くし、上の.episode-meta側で管理します */
  }
}

/* ===== SP: 4ボタン等幅 + 並び替えは下段（gridで統一） ===== */
@media (max-width: 1069px){
  .search-row-controls{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;                        /* 横・縦の間隔＝行間もこれで調整 */
    align-items: stretch;
  }

  /* 4ボタンを完全等幅に（既存の min-width を無効化） */
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn{
    min-width: 0 !important;
    max-width: none !important;
    width: 100% !important;
    padding-left: .4em;
    padding-right: .4em;
  }

  /* 並び替えは2段目で左半分 */
  .search-row-controls .sort-wrapper{
    grid-column: 1 / 3; /* 1 / -1 (全幅) から変更 */
    margin-top: 0;
    width: 100%;
    min-width: 0; /* ▼ 追加: 縮小時にレイアウトが崩れるのを防ぎます */
  }
  .search-row-controls .sort-wrapper select{
    width: 100%;
    height: 100%; /* 高さをグリッド行に合わせる */
    min-height: 42px; /* 最小高さを保証 */
  }
  
  /* ▼▼▼ ここに #latestBtn のスタイルを新しく追加 ▼▼▼ */
  #latestBtn {
    grid-column: 3 / 5 !important; /* 2段目で右半分 */
    width: 100%;
    height: 100%; /* 高さをグリッド行に合わせる */
    min-height: 42px; /* 最小高さを保証 */
    justify-content: center;
    padding: 0 6px !important; /* 垂直中央揃え */
    min-width: 0;
    /* font-size, gap, white-space, overflow, text-overflow は不要になったため削除 */
  }

  /* レイアウト切替時の“にゅるっ”を防ぐ（保険） */
  .search-row-controls > * { transition: none !important; }
}

  /* 2) 「フィルタ」はアイコンのみなので擬似要素でテキストを追加 */
  #filterToggleBtn{
    display: flex; align-items: center; justify-content: center; gap: .35em;
  }
  #filterToggleBtn::after{
    content: " フィルタ";            /* ←お好みで「フィルター」に */
    font-size: .95em;
    font-weight: 500;
  }

  /* 3) 他のボタンも中央寄せ（見た目を揃える） */
  #favOnlyToggleBtn,
  #randomBtn,
  .reset-btn{
    display: flex; align-items: center; justify-content: center; gap: .35em;
  }

/* === Controls: 自動調整用の共通サイズ変数＋形崩れ防止 === */
@media (max-width: 779px){
  /* 文字サイズを JS から上書きするための CSS 変数（初期値 15px） */
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn{                 /* ← JS がここを書き換えます */
    white-space: nowrap;            /* ぜったい改行しない */
    overflow: hidden;
    text-overflow: ellipsis;                   /* 高さは固定 → 形崩れしない */                 /* アイコンと文字のベース */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: 10px;
  }

  /* アイコンの大きさも文字と一緒に縮む */

  /* フィルタのラベルは ::after で付与しているので、サイズ連動 */
  #filterToggleBtn::after{      /* JSで data-label="フィルタ" を付けます */
    font-size: var(--ctl-fs);
  }

  /* リセットにも記号を追加して左右バランスを統一（FontAwesome不要） */

}

/* === SPボタン: 見た目の統一（アイコン行高/記号サイズ） === */
@media (max-width: 779px){
  /* 自動調整フォント用 変数（JSで更新） */
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn{
    --ctl-fs: 15px;                 /* JSがここを上書き */
    line-height: 1;
    height: 37px;                   /* 高さ固定で形崩れ防止 */
  }

  /* FAアイコンの行高をきっちり揃える */
  #favOnlyToggleBtn i,
  #randomBtn i,
  #filterToggleBtn i{
    font-size: calc(var(--ctl-fs) + 1px);
    line-height: 1;
  }

  /* リセットにも記号（↺）— 他と同サイズに */

}

/* ===== SP: 4ボタンの太さと余白を完全統一 ===== */  /* アイコンと文字の統一間隔 */

@media (max-width: 779px){
  /* 4ボタンの太さはすべて同じ（500）に統一。余白は margin で管理 */
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn{
    font-weight: 500 !important;
    gap: 0 !important;                /* gapに依存せず margin に統一 */
  }

  /* フィルタのラベル（::after）は太さ/間隔を統一 */
  #filterToggleBtn::after{
    margin-left: var(--ctl-gap) !important;      /* ←600になっていたのを上書き */
  }

  /* 既存 <span> ラベルは左マージンで統一（先頭スペース除去はJS側で） */
  #favOnlyToggleBtn span,
  #randomBtn span{
    display: inline !important;
    margin-left: var(--ctl-gap);
    line-height: 1;
  }

  /* リセットの記号（↺）も同スケール・同間隔に */

}

/* === Desktop: 4ボタンの見た目を統一（並び替えは上段のまま） === */
:root{
  --ctl-gap-d: .45em;          /* アイコンと文字の間隔（PC） */
  --ctl-fs-d: 15.5px;          /* ボタンの基準フォントサイズ（PC） */
}

/* ===== PC: 4ボタンは等幅／余りは並び替えが吸収 ===== */

/* ===== Controls (Unified) — SP/PC 共通の見た目・間隔・幅 ===== */
:root{
  --pc-btn-w: clamp(124px, 12vw, 144px);
  --ctl-gap: .38em;
}

/* 「お気に入りだけ」ON時の保険（JSがクラス付与する前提）。
   検索結果グリッド内のみに限定する。#results外のエピソードカード
   （タイムスタンプモーダル内に複製したカード）まで隠さないようにするため。 */
body.fav-only #results .episode-item:not(.is-fav) {
  display: none !important;
}

/* >=641pxでも検索結果枠の外側に同じ余白を付与 */
@media (min-width: 641px) {
  .main-content { padding-left: 15px; padding-right: 15px; }
}

/* === Buttons: focus-visible はアウトラインのみ（色は変えない） === */
#historyToggle:focus-visible {
  outline: 2px solid var(--btn-hover);
  outline-offset: 2px;
}

/* Fix for long selected filter tags being cut off */

/* ===== iOSスタンドアロン最適化 ===== */

/* 100vh問題対策（--vh は JS で更新） */
html, body {
  min-height: calc(var(--vh, 1vh) * 100);
}

/* ローディング全面背景をdvhベースに */

/* 置き換え：前回の .ios-standalone .sticky-search-area を削除して、これを入れる */

/* 置き換え：以前の .ios-standalone .main-content をこれに */

/* 置き換え */

/* 画面下固定ボタン（トップへ/ダークモード）のホームバー干渉回避 */

/* 下部に並ぶページネーション・余白もホームバーに配慮 */

/* フィルター選択タグが端で切れないよう左右も配慮 */

/* モーダル/ドロワー表示時の背景固定（スクロールロック） */

/* 視覚ノイズ低減：PWA時は若干のシャドウ強度を抑え、にじみを減らす */

/* ←PWA（ホーム画面から起動）時だけホームバー分を加算 */

/* ▼ すでに入れている iOS セーフエリア下寄せは、スタンドアロン時にのみ適用 */

/* 読み込み中/失敗時の背景色を明示してチラつき低減 */
.thumbnail { background: #2b323b; }
body.dark-mode .thumbnail { background: #1f262d; }

/* ★整理: .thumb-fallback は削除（フォールバックはmain.jsのsrc差し替えで行われ、このクラスは付与されない） */

/* sticky stability */
#filterDrawer{
  contain: layout;
}

/* === Filter drawer sticky footer (restored) === */

#filterDrawer .drawer-footer{
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;

  /* ▼ここからが変更・追加箇所です▼ */
  margin-left: calc(-1 * var(--drawer-px));
  margin-right: calc(-1 * var(--drawer-px));
  padding: 12px var(--drawer-px);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
  /* ▲ここまで▲ */

  background: rgba(246,245,255,.92);
  border-top: 1px solid rgba(60,60,80,.18);
  display: flex;
  justify-content: center;
  gap: 12px;
  z-index: 3;
  backdrop-filter: saturate(120%) blur(4px);
}
/* ★整理: .dark / html[data-theme="dark"] のセレクタは削除（サイトはbody.dark-modeのみ使用） */
body.dark-mode #filterDrawer .drawer-footer{
  background: rgba(22,28,34,.88);
  border-top: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 -4px 12px -10px rgba(0,0,0,.6);
}
#filterDrawer .drawer-close-btn{
  appearance: none;
  border: 1.3px solid #bfc8d6;
  background: #fff;
  color: #374151;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
  width: 100%; /* フィルタボタンの並び（グリッド）と同じ全幅にする（iPadでも） */
  box-shadow: 0 2px 14px -10px rgba(0,0,0,.25);
  transition: background .15s, border .15s, transform .08s;
}
@media (hover: hover) {
  #filterDrawer .drawer-close-btn:hover,
  #filterDrawer .drawer-close-btn:focus{
    background: #f1f5ff;
    border-color: #6654e8;
  }
}
#filterDrawer .drawer-close-btn:active{ transform: translateY(1px); }
#filterDrawer{ padding-bottom: 0 !important; }
#filterDrawer > :last-child{ margin-bottom: 0 !important; }

/* ======================================================================== */
/* ===== フィルター画面のレイアウト (全デバイス対応) ===== */
/* ======================================================================== */

/* --- 基本スタイル (スマホ・タブレット向け) --- */
#filterDrawer {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  margin: 0 auto !important;
  width: min(100vw, 1400px) !important; /* iPad(〜1366px)まで画面いっぱい。超ワイドPCのみ抑制 */
  top: var(--header-height, 96px) !important;
  bottom: max(0px, env(safe-area-inset-bottom, 0px)) !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  transform: none !important;
  animation: fade-only-in 0.17s ease-out; /* 移動なしのフェードインのみ */
  border-top-left-radius: 0 !important;
  border-top-right-radius: 0 !important;
  will-change: transform, opacity;
}

:root{
  /* 既存… */
  --header-offset: 186px; /* フォールバック値 */

  /* 追加: Drawer の余白（PC時に効く） */
  --drawer-px: clamp(12px, 2.2vw, 22px); /* 左右 */
  --drawer-pt: clamp(10px, 1.8vw, 18px); /* 上下 */
}
/* 780px以上では .filter-section の左右パディング(1.2rem)が0になり、
   --drawer-px の22px頭打ちだけになって左右が急に狭くなる。
   広い画面でも余白を保つため、この帯だけ横パディングを広げる。 */
@media (min-width: 780px) {
  :root { --drawer-px: 34px; }
}

/* ===== これより下を全て差し替えてください ===== */

/* ★整理: .theme-switcher ルールは削除（実際のパネルは .floating-panel。該当クラスは未使用） */
.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 5px -2px rgba(0,0,0,0.2);
  min-width: 32px;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
}
@media (hover: hover) {
  .theme-btn:hover {
    transform: translateY(-2px);
  }
}
.theme-btn.active {
  box-shadow: 0 0 0 3px var(--btn-main, #6654e8);
  border-color: #fff;
}
body.dark-mode .theme-btn,
body.theme-blue .theme-btn,
body.theme-red .theme-btn {
  border-color: rgba(255, 255, 255, 0.2);
}
body.dark-mode .theme-btn.active,
body.theme-blue .theme-btn.active,
body.theme-red .theme-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--btn-hover, #a6e1fa);
}

/* テーマ色（ピンク〜グリーンの5色）は本番サイト（searchtheradio.com）の値に合わせてある（2026-11-14、ぱせの指示）。
   以前のコントラスト調整版は admin/backup/20261114-155000-テーマ色本番合わせ前/style.css に残してある */
/* --- ピンクテーマ --- */
body.theme-pink {
  --bg-color: #ff6496;
  --card-bg: #eb5b89;
  --item-bg: #eb5b89;
  --text-color: #ffffff;
  --muted: #ffffff;
  --btn-bg: #ff85ab;
  --btn-main: #ffffff;
  --btn-hover: #ffffff;
  --filter-btn-active: #ff79a5;
  --active-filter: #ffffff;
  --active-filter-text: #eb5b89;
  --history-card-bg: var(--card-bg);
  --history-card-bd: #ff85ab;
  --history-year: #ffffff;
  --history-muted: var(--muted);
  --history-dot: #ffffff;
  --history-line: #ff85ab;
  --history-dot-ring: 255, 255, 255;
  --input-border: #ff85ab;
  --input-focus-shadow: rgba(255, 255, 255, 0.3);
  background: var(--bg-color) !important;
  color: var(--text-color) !important;

  /* ボタン用の変数を追加 */
  --btn-control-bg: #ff85ab;
  --btn-control-text: #ffffff;
  --btn-control-bg-active: #ffffff;
  --btn-control-text-active: #eb5b89;
}
/* --- イエローテーマ --- */
body.theme-yellow {
  --bg-color: #fabe00;
  --card-bg: #e1ac00;
  --item-bg: #e1ac00;
  --text-color: #ffffff;
  --muted: #ffffff;
  --btn-bg: #ffca2a;
  --btn-main: #ffffff;
  --btn-hover: #ffffff;
  --filter-btn-active: #ffc418;
  --active-filter: #ffffff;
  --active-filter-text: #e1ac00;
  --history-card-bg: var(--card-bg);
  --history-card-bd: #ffca2a;
  --history-year: #ffffff;
  --history-muted: var(--muted);
  --history-dot: #ffffff;
  --history-line: #ffca2a;
  --history-dot-ring: 255, 255, 255;
  --input-border: #ffca2a;
  --input-focus-shadow: rgba(255, 255, 255, 0.3);
  background: var(--bg-color) !important;
  color: var(--text-color) !important;

  /* ボタン用の変数を追加 */
  --btn-control-bg: #ffca2a;
  --btn-control-text: #ffffff;
  --btn-control-bg-active: #ffffff;
  --btn-control-text-active: #e1ac00;
}
/* --- ブルーテーマ --- */
body.theme-blue {
  --bg-color: #006ebe;
  --card-bg: #0063a9;
  --item-bg: #0063a9;
  --text-color: #ffffff;
  --muted: #ffffff;
  --btn-bg: #1982d2;
  --btn-main: #ffffff;
  --btn-hover: #ffffff;
  --filter-btn-active: #0f78ca;
  --active-filter: #ffffff;
  --active-filter-text: #0063a9;
  --history-card-bg: var(--card-bg);
  --history-card-bd: #1982d2;
  --history-year: #ffffff;
  --history-muted: var(--muted);
  --history-dot: #ffffff;
  --history-line: #1982d2;
  --history-dot-ring: 255, 255, 255;
  --input-border: #1982d2;
  --input-focus-shadow: rgba(255, 255, 255, 0.3);
  background: var(--bg-color) !important;
  color: var(--text-color) !important;

  /* ボタン用の変数を追加 */
  --btn-control-bg: #1982d2;
  --btn-control-text: #ffffff;
  --btn-control-bg-active: #ffffff;
  --btn-control-text-active: #0063a9;
}
/* --- レッドテーマ --- */
body.theme-red {
  --bg-color: #e60046;
  --card-bg: #cb003d;
  --item-bg: #cb003d;
  --text-color: #ffffff;
  --muted: #ffffff;
  --btn-bg: #f32263;
  --btn-main: #ffffff;
  --btn-hover: #ffffff;
  --filter-btn-active: #ef105a;
  --active-filter: #ffffff;
  --active-filter-text: #cb003d;
  --history-card-bg: var(--card-bg);
  --history-card-bd: #f32263;
  --history-year: #ffffff;
  --history-muted: var(--muted);
  --history-dot: #ffffff;
  --history-line: #f32263;
  --history-dot-ring: 255, 255, 255;
  --input-border: #f32263;
  --input-focus-shadow: rgba(255, 255, 255, 0.3);
  background: var(--bg-color) !important;
  color: var(--text-color) !important;

  /* ボタン用の変数を追加 */
  --btn-control-bg: #f32263;
  --btn-control-text: #ffffff;
  --btn-control-bg-active: #ffffff;
  --btn-control-text-active: #cb003d;
}

/* --- グリーンテーマ --- */
body.theme-green {
  --bg-color: #13a286;
  --card-bg: #108a72;
  --item-bg: #108a72;
  --text-color: #ffffff;
  --muted: #e0f2f1;
  --btn-bg: #16b896;
  --btn-main: #ffffff;
  --btn-hover: #ffffff;
  --filter-btn-active: #15ad8f;
  --active-filter: #ffffff;
  --active-filter-text: #108a72;
  --history-card-bg: var(--card-bg);
  --history-card-bd: #16b896;
  --history-year: #ffffff;
  --history-muted: var(--muted);
  --history-dot: #ffffff;
  --history-line: #16b896;
  --history-dot-ring: 255, 255, 255;
  --input-border: #16b896;
  --input-focus-shadow: rgba(255, 255, 255, 0.3);
  background: var(--bg-color) !important;
  color: var(--text-color) !important;

  /* ボタン用の変数を追加 */
  --btn-control-bg: #16b896;
  --btn-control-text: #ffffff;
  --btn-control-bg-active: #ffffff;
  --btn-control-text-active: #108a72;
}

/* ===== テーマ別共通スタイル ===== */
body[class*="theme-"] .sticky-search-area { background: var(--bg-color) !important; border-bottom-color: var(--history-card-bd) !important; }
body[class*="theme-"] .search-card { background: var(--card-bg) !important; }
body[class*="theme-"] .searchbox-input, 
body[class*="theme-"] .searchbox-select { 
  background-color: var(--btn-bg) !important;
  border-color: var(--history-card-bd) !important;
  color: var(--text-color) !important;
  padding-right: 2.5em !important;
  /* ★ 矢印の background-image 指定をここから削除します */
}

/* ★★★ 以下のブロックを「新しく追加」してください ★★★ */
body[class*="theme-"] .searchbox-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") !important;
}
body[class*="theme-"] .searchbox-input::placeholder { color: var(--muted) !important; opacity: 1 !important; }
body[class*="theme-"] .searchbox-input:focus { border-color: var(--btn-main) !important; box-shadow: 0 0 0 2px var(--input-focus-shadow) !important; }
body[class*="theme-"] .results-count-under-bar { color: var(--btn-hover) !important; background: transparent !important; }
body[class*="theme-"] #filterDrawer { background: var(--bg-color) !important; border-color: var(--bg-color) !important; }
body[class*="theme-"] .filter-title { color: var(--btn-hover) !important; }
/* イエローは白い文字が読めないので、表示数・フィルタの見出しも文字の色（濃い茶色）にする */
body.theme-yellow .results-count-under-bar,
body.theme-yellow .filter-title { color: var(--text-color) !important; }
body[class*="theme-"] .guest-button, body[class*="theme-"] .btn-corner, body[class*="theme-"] .btn-year { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; color: var(--text-color) !important; }

/* テーマカラーのホバーエフェクトも同様に制限します */
@media (hover: hover) {
  body[class*="theme-"] .guest-button:hover,
  body[class*="theme-"] .btn-corner:hover,
  body[class*="theme-"] .btn-year:hover {
    background: var(--filter-btn-active) !important;
    border-color: var(--btn-main) !important;
  }
}

body[class*="theme-"] .episode-item { border-color: var(--history-card-bd) !important; background: var(--item-bg) !important; color: var(--text-color) !important; }
@media (hover: hover) {
  body[class*="theme-"] .episode-item:hover {
    background: var(--filter-btn-active) !important;
    border-color: var(--btn-main) !important;
  }
}
body[class*="theme-"] .episode-meta, body[class*="theme-"] .fav-btn i { color: var(--muted) !important; }
body[class*="theme-"] .page-btn { background: var(--btn-bg) !important; color: var(--btn-hover) !important; border: 1px solid var(--history-card-bd) !important; }
body[class*="theme-"] .page-btn.active { background: var(--active-filter) !important; color: var(--active-filter-text) !important; border-color: var(--active-filter) !important; }
@media (hover: hover) {
  body[class*="theme-"] .page-btn:not(.active):hover { background: var(--filter-btn-active) !important; }
}
body[class*="theme-"] .fav-btn { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; }
body[class*="theme-"] .fav-btn.active { background: var(--active-filter) !important; border-color: var(--active-filter) !important; }
body[class*="theme-"] .fav-btn.active i { color: var(--active-filter-text) !important; }
body[class*="theme-"] .history-toggle { background: var(--history-card-bg) !important; border-color: var(--history-card-bd) !important; }
body[class*="theme-"] .history-toggle .title, body[class*="theme-"] .history-modal .modal-title { color: var(--history-year) !important; }
body[class*="theme-"] .filters-bar { background: var(--bg-color) !important; }
body[class*="theme-"] .filter-tag { background: var(--active-filter) !important; color: var(--active-filter-text) !important; }
body[class*="theme-"] .share-btn { background: var(--btn-bg) !important; color: var(--btn-main) !important; border-color: var(--history-card-bd) !important; }
@media (hover: hover) {
  body[class*="theme-"] .share-btn:hover { border-color: var(--btn-main) !important; background: var(--filter-btn-active) !important;}
}
body[class*="theme-"] #filterDrawer .drawer-footer { background: var(--bg-color) !important; border-top-color: var(--history-card-bd) !important; backdrop-filter: none !important; }
body[class*="theme-"] #filterDrawer .drawer-close-btn { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; color: var(--btn-main) !important; }
@media (hover: hover) {
  body[class*="theme-"] #filterDrawer .drawer-close-btn:hover { background: var(--filter-btn-active) !important; border-color: var(--btn-main) !important; }
}
body[class*="theme-"] #results .no-results { background: var(--card-bg) !important; border: 1px solid var(--history-card-bd) !important; color: var(--text-color) !important; box-shadow: none !important; }
/* 他モーダルと同じ配色体系（背景=--btn-bg / カード=--card-bg）に統一 */
body[class*="theme-"] .modal-content.history-modal, body[class*="theme-"] .history-modal .modal-header { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; }
body[class*="theme-"] .history-modal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.4) !important;
  border-bottom-color: color-mix(in srgb, var(--text-color) 40%, transparent) !important;
}
body[class*="theme-"] .history-item { background: var(--card-bg) !important; border-color: transparent !important; box-shadow: none !important; }

body[class*="theme-"] #aboutCloseBtn,
body[class*="theme-"] #historyCloseBtn {
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.55) !important;
  border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  color: var(--text-color) !important;
}
@media (hover: hover) {
  /* 2つ目のセレクタにテーマスコープが欠けていて、ライトモードの閉じるボタンhover色まで上書きしていたのを修正 */
  body[class*="theme-"] #aboutCloseBtn:hover, body[class*="theme-"] #historyCloseBtn:hover { background: var(--filter-btn-active) !important; }
}
body[class*="theme-"] #aboutModalContent b, body[class*="theme-"] #aboutModalContent a, body[class*="theme-"] #aboutCloseBtn, body[class*="theme-"] .about-title { color: var(--muted) !important; }
body[class*="theme-"] .autocomplete { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; }
@media (hover: hover) {
  body[class*="theme-"] .autocomplete-item:hover, body[class*="theme-"] .autocomplete-item[aria-selected="true"] { background: var(--filter-btn-active) !important; }
}
body[class*="theme-"] .ts-btn { background-color: var(--active-filter) !important; color: var(--active-filter-text) !important; border-color: var(--active-filter) !important; }
body[class*="theme-"] .loading-ball { background-color: var(--btn-main) !important; }
body[class*="theme-"] #loading-screen { background: var(--bg-color) !important; }
body[class*="theme-"] .floating-panel { background: color-mix(in srgb, var(--bg-color), transparent 20%) !important; border-color: var(--history-card-bd) !important; }
body[class*="theme-"] #theme-toggle-btn { background-color: var(--card-bg) !important; color: var(--text-color) !important; border: 1px solid var(--history-card-bd) !important; }
body[class*="theme-"] .site-footer { color: var(--muted) !important; }
body[class*="theme-"] .site-footer a { color: var(--muted) !important; }

/* ===== フローティングテーマパネル ===== */
#theme-toggle-btn {
  z-index: 10 !important;
}

.floating-panel {
  position: fixed;
  right: 18px;
  bottom: 80px; /* トリガーボタンの少し上 */
  z-index: 3005; /* ← z-indexをボタンよりは下、他のUIよりは上に設定 */
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 10px;
  border-radius: 999px; /* ピルケース形状 */
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.2);

  /* 非表示時の状態 */
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* これを追加 */
.floating-panel.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ★意図的な指定（削除しないこと）:
   カラーテーマのページ背景は、テーマ定義の --bg-color ではなく一段明るい --btn-bg を使う。
   歴史的にはセレクタ書き漏れ由来だが、明るい背景の方が視認性が良いためこの色を正とする。
   ヘッダー(.sticky-search-area)やローディング画面は --bg-color のままで、ページ本体との
   色差はデザインとして許容。フィルタドロワー（スマホ）・タイムスタンプ/関連リンク
   モーダルの背景もこの「実効背景 --btn-bg」に合わせている（変更時は3箇所も連動させる）。 */
body[class*="theme-"] {
  background: var(--btn-bg) !important;
  color: var(--btn-main) !important;
}

/* ===== 「このサイトについて」モーダル (競合解決版) ===== */

/* モーダル背景のオーバーレイ */
#aboutModal {
  /* display: flex; ← JSで制御するため、ここでの指定は不要 */
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(30, 29, 52, 0.25);
  will-change: transform, opacity;

  /* 競合の原因だった transition と opacity は削除しました */
}

/* モーダル本体の見た目 */
#aboutModalContent {
  position: relative;
  background: #fdfdff;
  border-radius: 16px;
  padding: 40px 24px 28px;
  width: 90vw;
  max-width: 480px;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.2);
  text-align: center;
  border: 1px solid rgba(0,0,0,0.05);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  will-change: transform, opacity;

  /* 競合の原因だった transform と transition は削除しました */
}

/* アニメーションは、style.css の別箇所で定義済みの
  #aboutModal.show { animation: modalFade ... }
  #aboutModal.closing { animation: modalFadeOut ... }
  が正しく適用されます。
*/

@media (hover: hover) {
  #aboutCloseBtn:hover { background: #f3f4f6; }
}

/* ロゴ・タイトル・本文 */
.about-logo { width: 200px; margin-bottom: 16px; }
.about-title { font-size: 1.25rem; font-weight: 700; color: var(--text-color); margin-bottom: 12px; }
.about-body { font-size: 0.95rem; line-height: 1.8; color: var(--text-color); }
.about-body b { color: #5744d8; }

/* ダークモード・テーマカラー対応 */
body.dark-mode #aboutModalContent { background: #23242d !important; color: #e5ecec !important; }
/* 他モーダルと同じ配色体系に統一 */
body[class*="theme-"] #aboutModalContent { background: var(--btn-bg) !important; color: var(--text-color) !important; }
body[class*="theme-"] #aboutCloseBtn {
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.55) !important;
  border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  color: var(--text-color) !important;
}
/* タイムラインの縦線・ドットが新しい背景(--btn-bg)と同化しないよう白系にする */
body[class*="theme-"] .history-modal {
  --history-line: rgba(255, 255, 255, 0.5);
  --history-dot: #ffffff;
  --history-dot-ring: 255, 255, 255;
}
body[class*="theme-"] #aboutModalContent b,
body[class*="theme-"] #aboutModalContent a,
body[class*="theme-"] .about-title { color: var(--muted) !important; }

/* === ダークモードの水色を白に完全統一する最終修正 === */

/* === ダークモードのアクセントカラー（水色）を白に統一する修正 === */
body.dark-mode {
  --btn-hover: #ffffff; /* ホバー用の変数を白に変更 */
}

body.dark-mode .results-count-under-bar,
body.dark-mode .filter-title,
body.dark-mode .history-year,
body.dark-mode .history-item .date,
body.dark-mode .history-sticky-year,
body.dark-mode #aboutModalContent a,
body.dark-mode #aboutCloseBtn,
body.dark-mode .share-btn,
body.dark-mode .ts-btn {
  color: #ffffff !important;
}

/* ホバー時などに色が戻ってしまうのを防ぐための追加指定 */
@media (hover: hover) {
  body.dark-mode .share-btn:hover {
    color: #ffffff !important;
  }
}

/* 1. 並び替えセレクトボックスの文字色を白に */
body.dark-mode .searchbox-select {
  color: #ffffff !important;
}

/* 2. 検索ボックス選択時の青い枠線を白に変更 */
body.dark-mode .searchbox-input:focus {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25) !important;
}

/* 3. フィルター内のアクティブなボタンの青緑色を白に変更 */
body.dark-mode .guest-button[aria-pressed="true"],
body.dark-mode .guest-button.active,
body.dark-mode .btn-corner[aria-pressed="true"],
body.dark-mode .btn-corner.active,
body.dark-mode .btn-year[aria-pressed="true"],
body.dark-mode .btn-year.active {
  color: #ffffff !important;
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2) !important;
}

/* 4. ページ番号ボタンのアクティブ時の水色の背景を白に変更 */
body.dark-mode .page-btn.active {
  background: #ffffff !important; /* 背景が白になるため、文字はダークカラーにします */
}

/* === ダークモードの水色を白に完全統一する最終修正（追記） === */

/* フィルターDrawer内のボタン (アクティブ時) */

/* フィルターDrawer内のボタン (ホバー時) */
@media (hover: hover) {
  body:not(.dark-mode):not([class*="theme-"]) .guest-button:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-corner:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-year:hover {
    box-shadow: none !important; /* 浮き上がり撤去（枠線＋暗転に統一） */
  }
}

/* タイムスタンプボタン */
body:not(.dark-mode):not([class*="theme-"]) .ts-btn {
  background: #eeeeee !important;
  color: #000000 !important;
  border-color: #dcdcdc !important;
}

/* 検索結果件数バーの文字色 */
body:not(.dark-mode):not([class*="theme-"]) .results-count-under-bar {
  color: #000000 !important;
}

/* ページ番号ボタンの配色 */
body:not(.dark-mode):not([class*="theme-"]) .page-btn {
  color: #000000 !important;
  background: #eeeeee !important;
}
body:not(.dark-mode):not([class*="theme-"]) .page-btn.active {
  background: #000000 !important;
  color: #ffffff !important;
}
@media (hover: hover) {
  body:not(.dark-mode):not([class*="theme-"]) .page-btn:not(.active):hover {
    background: #dddddd !important;
  }
}

/* 検索ボックスのフォーカスリング */
body:not(.dark-mode):not([class*="theme-"]) .searchbox-input:focus {
  border-color: #000000 !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1) !important;
}

/* 「このサイトについて」モーダル内の強調文字 */
body:not(.dark-mode):not([class*="theme-"]) .about-body b {
  color: #000000 !important;
}

/* 「ひすとりー」モーダル内の日付の色 */
body:not(.dark-mode):not([class*="theme-"]) .history-item .date {
  color: #000000 !important;
}

/* 1. ダークモード時に --text-color 変数自体を上書きする */
body.dark-mode {
  --text-color: #e5ecec; /* テキストカラー変数を明るい色に */
}

/* 2. 変数を使っていない太字(b)やリンク(a)の色を個別に指定する */
body.dark-mode #aboutModalContent .about-title,
body.dark-mode #aboutModalContent .about-body,
body.dark-mode #aboutModalContent .about-body b,
body.dark-mode #aboutModalContent .about-body a {
  color: #ffffff !important; /* タイトル、本文、強調文字、リンクをすべて純粋な白に */
}

/* ===== デザイン改善提案: フィルター選択色の強調 ===== */

/* --- 1. 通常（ライト）モードの選択色を上書き --- */
body:not(.dark-mode):not([class*="theme-"]) .guest-button[aria-pressed="true"],
body:not(.dark-mode):not([class*="theme-"]) .btn-corner[aria-pressed="true"],
body:not(.dark-mode):not([class*="theme-"]) .btn-year[aria-pressed="true"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #000000 !important;
  box-shadow: 0 0 0 2.5px rgba(0, 0, 0, 0.15) !important;
}

/* --- 2. ダークモードの選択色を上書き --- */
body.dark-mode .guest-button[aria-pressed="true"],
body.dark-mode .btn-corner[aria-pressed="true"],
body.dark-mode .btn-year[aria-pressed="true"] {
  background: #ffffff !important;
  color: #27363f !important; /* ダークモードの濃い背景色に合わせる */
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2.5px rgba(255, 255, 255, 0.3) !important;
}

/* --- 3. 各カラーテーマの選択色を上書き --- */
body[class*="theme-"] .guest-button.active,
body[class*="theme-"] .btn-corner.active,
body[class*="theme-"] .btn-year.active {
  background: #ffffff !important;
  color: var(--bg-color) !important; /* 各テーマの背景色を文字色として使用 */
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2.5px rgba(255, 255, 255, 0.4) !important;
}

/* --- 4. ホバー時のスタイルも調整（任意ですが推奨） --- */
/* 選択されていないボタンのホバーエフェクトを少し抑えめにして、選択状態との差を明確にします */
@media (hover: hover) {
  .guest-button:not([aria-pressed="true"]):hover,
  .btn-corner:not([aria-pressed="true"]):hover,
  .btn-year:not([aria-pressed="true"]):hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: 0 4px 12px -4px rgba(0,0,0,0.1);
  }
}

/* ===== 修正: スマホ表示時のテーマ選択ボタンの比率を修正 ===== */

/*
  ===== スマホでの描画バグ対策 (色が即時反映されない問題) =====
  タップ時に即座にスタイルが反映されない問題を解決するため、
  主要なボタンやカード要素に3D変換を適用してGPUレンダリングを促します。
  見た目上の変化はありませんが、ブラウザの描画を安定させます。
*/

/* ===== 検索候補のアイコンスタイル ===== */

/* アイコンを格納する.type要素のスタイル調整 */
.autocomplete-item .type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;  /* アイコンの背景の幅 */
  height: 28px; /* アイコンの背景の高さ */
  padding: 0;   /* 元のpaddingをリセット */
  font-size: 14px; /* アイコンのサイズ */
}

/* 通常（ライト）モードのアイコン色 */
body:not(.dark-mode):not([class*="theme-"]) .autocomplete-item .type {
  border-color: #dcdcdc !important;
  color: #000000 !important;
}

/* メモ候補の★は専用色を持たず、他のアイコンと同じ各モードの色
   （ライト=黒 / ダーク=白 / カラーテーマ=テーマ文字色）で表示して形だけで区別する */

/* ダークモードのアイコン色 */
body.dark-mode .autocomplete-item .type {
  border-color: #415766 !important;
  color: #ffffff !important;
}

/* カラーテーマのアイコン色
   （丸枠が --history-card-bd だと候補パネルの背景と同化して見えないテーマがあるため、
     テーマ文字色ベースの半透明にして必ず視認できるようにする） */
body[class*="theme-"] .autocomplete-item .type {
  border-color: rgba(255, 255, 255, 0.55) !important; /* color-mix非対応環境用 */
  border-color: color-mix(in srgb, var(--text-color) 50%, transparent) !important;
  color: var(--text-color) !important;
}

/* 公開日時などのメタ情報をさらに控えめに */
.episode-meta {
  font-size: clamp(0.75rem, 3vw, 0.85rem);
  opacity: 0.7;
}

/* ===== 全テーマ共通: ボタン背景色をカードと統一 ===== */

/* --- 1. 通常（ライト）モード --- */
body:not(.dark-mode):not([class*="theme-"]) .page-btn,
body:not(.dark-mode):not([class*="theme-"]) .share-btn {
  background-color: var(--card-bg) !important; /* カード背景色（白）を適用 */
  border-color: #e5e9f7 !important;
}

/* --- 2. ダークモード --- */
/*カード背景色を基準に、関連ボタンの背景と文字色を完全に統一。*/

/* --- 対象ボタンの文字色を「白」に強制指定 --- */
body.dark-mode .page-btn,
body.dark-mode .share-btn,
body.dark-mode .history-toggle {
  color: #ffffff !important;
}

/* --- ページ番号、SNS、ひすとりーボタンの基本背景色をカード背景(#252c35)に合わせる --- */
body.dark-mode .page-btn,
body.dark-mode .share-btn,
body.dark-mode .history-toggle {
  background-color: #252c35 !important;
  border-color: #33404c !important;
}

/* --- ページ番号ボタン「選択中」のスタイル --- */
body.dark-mode .page-btn.active {
  background-color: #33414d !important; /* 少し明るいグレーで選択状態を表現 */
  border-color: #ffffff !important;     /* 枠線を白にして強調 */
  color: #ffffff !important;            /* 文字色も白を維持 */
}

/* --- ホバー時のスタイル --- */
@media (hover: hover) {
  body.dark-mode .page-btn:not(.active):hover,
  body.dark-mode .share-btn:hover {
    background-color: #33414d !important; /* 選択中ボタンと同じ背景色に */
    border-color: #4a5967 !important;
  }
}

/* ===== ダークモードのカード内テキストが水色になる問題の修正 ===== */
body.dark-mode .episode-item h5 {
  color: #ffffff !important; /* タイトルとゲスト名の文字色を白に強制 */
}

/* --- 3. カラーテーマ（前回と同じ） --- */
body[class*="theme-"] .page-btn,
body[class*="theme-"] .share-btn {
  background-color: var(--card-bg) !important;
}

/* ===== ダークモードの「ひすとりー」モーダル内のラベル文字色を修正 ===== */
body.dark-mode .history-item .label {
  color: #ffffff !important; /* ラベル（太字）の文字色を白に強制 */
}

/* ===== いいねマークが降るアニメーション ===== */

/* いいねマークの基本スタイル */
.good-mark {
  position: fixed; /* 画面に固定 */
  top: -60px; /* 画面の上部外からスタート */
  font-size: 2rem; /* マークの大きさ */
  pointer-events: none; /* マークがクリックなどを邪魔しないように */
  user-select: none; /* テキスト選択を無効に */
  z-index: 9999; /* 常に最前面に表示 */

  /* アニメーションの設定 */
  animation-name: fall-animation;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* 落下アニメーションの定義 */
@keyframes fall-animation {
  from {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: translateY(110vh) rotate(360deg); /* 画面の下端外まで移動し、回転する */
    opacity: 0;
  }
}

/* 画面の高さが特に低いデバイス（例: 700px以下）では、余白をさらに詰めて見やすくする */
@media (max-height: 700px) {
  #aboutModalContent {
    padding-top: 25px;
    padding-bottom: 20px;
  }
  .about-logo {
    width: 150px; /* ロゴも少し小さくする */
    margin-bottom: 12px;
  }
}

/* 画面全体のスクロールを止めるための新しいスタイル (点滅しない方法) */
/* ======================================================================== */
/* ===== (V28・最終確定版) 上部コントロールボタン スタイル ===== */
/* ======================================================================== */

/* --- 0. ボタンの基本構造 (全テーマ共通) --- */
#filterToggleBtn,
#favOnlyToggleBtn,
#randomBtn,
.reset-btn,
#latestBtn {
  display: inline-flex !important; align-items: center !important; justify-content: center !important;
  border: 1px solid !important; border-radius: 10px !important; font-weight: 700 !important;
  line-height: 1 !important; white-space: nowrap !important;
  transition: background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease, transform 0.1s ease, opacity 0.2s ease !important;
  cursor: pointer !important; user-select: none !important;
  box-shadow: none !important;
}

/* --- 1. アイコンとテキストのスタイル調整 (全テーマ共通) --- */
#filterToggleBtn i, #favOnlyToggleBtn i, #randomBtn i,
#filterToggleBtn::after, #favOnlyToggleBtn span, #randomBtn span, .reset-btn {
  font-size: 1em !important; margin: 0 !important; flex-shrink: 0 !important;
}
#filterToggleBtn i, #favOnlyToggleBtn i, #randomBtn i {
  width: 1.1em !important; text-align: center !important;
}
/* アイコン垂直位置の微調整 */
#filterToggleBtn i { 
  position: relative; top: -0.0005em;
 }
#favOnlyToggleBtn i {
  position: relative; top: -0.02em;
 }
#randomBtn i { 
  position: relative; top: 0.009em;
 }
.reset-btn::before { 
  font-size: 1.10em !important; position: relative; top: 0.040em;
 }

/* --- 2. デバイスごとのレイアウトとスタイル --- */

/* スマホ (779px以下)
   ★整理: このブロックに大量にあった「(V2.1)を打ち消す」宣言群
   （flex-direction: row / height: 42px / アイコン1em / ↺アイコン等）は削除した。
   打ち消し対象のV2.1ブロック（後方の @media (max-width:1069px)、縦並び60px・
   アイコン22px・ラベル11px）の方がファイル上で後にあり同一詳細度・同一!importantの
   ため常に勝っていて、これらの宣言は一度も効いたことがない（現在の見た目=V2.1の縦並び）。
   実際に効いている宣言（visibility/opacityの初期非表示、フォント初期サイズ、
   ラベルのline-height、フィルタ文言、再生リストボタン）だけを残している。 */
@media (max-width: 779px) {
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn {
    visibility: hidden; /* ★計算完了まで完全に非表示 */
    opacity: 0;
    font-size: 14px !important; /* JSが調整するまでの安全な初期サイズ */
  }

  /* ラベルの行高（V2.1はここのline-heightを設定しないため、この指定が実際に効く） */
  #filterToggleBtn::after,
  #favOnlyToggleBtn span,
  #randomBtn span {
    line-height: 1 !important;
  }

  /* 下段のボタン */
  #latestBtn {
    height: 42px !important;
    padding: 0 10px !important;
    font-size: 15.5px !important;
    gap: 0.5em !important;
  }

  /* ★JSの準備完了合図で表示 */
  body.buttons-ready #filterToggleBtn,
  body.buttons-ready #favOnlyToggleBtn,
  body.buttons-ready #randomBtn,
  body.buttons-ready .reset-btn {
    visibility: visible;
    opacity: 1;
  }
  #filterToggleBtn::after {
      content: "フィルタ" !important;
      font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important;
      font-weight: 700 !important;
  }
}

/* タブレット (780〜1069px)
   ★整理: height/padding/gap の各宣言は削除。後方のV2.1ブロック
   （.search-row-controls #〜 の縦並び定義）の方が詳細度が高く常に負けていた。 */
@media (min-width: 780px) and (max-width: 1069px) {

  #filterToggleBtn, #favOnlyToggleBtn, #randomBtn, .reset-btn {
    font-size: 14px !important;     /* JSが調整するまでの安全な初期サイズ */
    visibility: hidden; /* ★計算完了まで完全に非表示 */
    opacity: 0;
  }

  #latestBtn {
    height: 42px !important;
    padding: 0 10px !important;
    font-size: 15.5px !important;
    gap: 0.5em !important;
  }

  /* ★JSの準備完了合図で表示 */
  body.buttons-ready #filterToggleBtn,
  body.buttons-ready #favOnlyToggleBtn,
  body.buttons-ready #randomBtn,
  body.buttons-ready .reset-btn {
    visibility: visible;
    opacity: 1;
  }
  #filterToggleBtn::after {
      content: "フィルタ" !important;
      font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important;
      font-weight: 700 !important;
    }

  /* ★整理: ここにあった .reset-btn::before { content:"↺" } は削除。
     後方のV2.1ブロックの content:"\f2ea"(Font Awesome) に常に負けていた。 */
}
/* PC (1070px以上) */
@media (min-width: 1070px) {
  .search-row-controls { display: flex !important; gap: 10px !important; }
  .search-row-controls .sort-wrapper {
    flex: 1 1 0 !important; /* ★ 変更 */
    min-width: 0 !important; /* ★ 変更 */
  }
  
  #latestBtn {
    height: 40px !important; /* 高さを他のボタン(40px)と統一 */
    padding: 0 1em !important; /* paddingを他のボタンと合わせる */
    font-size: 15.5px !important; /* フォントサイズを他のボタンと合わせる */
    gap: 0.55em !important; /* gapを他のボタンと合わせる */
    flex-shrink: 0; /* ボタンが縮まないようにする */
    
    /* ▼▼▼ 以下の2行を追加 ▼▼▼ */
    flex: 1 1 0 !important; /* 均等に伸びるようにする */
    min-width: 0 !important; /* 最小幅の制限を解除 */
  }

  /* 4つのボタンを左に、並び替えと再生リストボタンを右に分ける */
  .search-row-controls .reset-btn + .sort-wrapper {
    margin-left: auto !important;
  }
  #filterToggleBtn, #favOnlyToggleBtn, #randomBtn, .reset-btn {
    height: 40px !important;
    font-size: 15.5px !important;
    padding: 0 0.9em !important;
    width: calc(12.5% - 8.75px) !important; flex: 0 0 auto !important;
    gap: 0.55em !important;
  }

  /* --- PWAモード (PC) の場合のレイアウト上書き (V4・カード2枚幅) --- */
    /* (左4ボタン非表示に伴い、残り2ボタンを均等幅にする) */

    /* ズレ修正: .sort-wrapper と #latestBtn をグループ化 */
    html.is-standalone .search-row-controls .sort-wrapper,
    html.is-standalone #latestBtn {
      /* ▼▼▼ flex の3番目の値（flex-basis）をカード1枚幅の計算値に変更 ▼▼▼ */ /* 修正前: 1 1 0 !important; */ 
      box-sizing: border-box !important;
    }
    
    /* ズレ修正: select要素の高さをボタン(40px)と合わせる */
    html.is-standalone .search-row-controls .sort-wrapper,
    html.is-standalone #sortSelect {
      height: 40px !important; /* ★ 高さを 40px に強制統一 */
    }

  #filterToggleBtn::after {
      content: "フィルタ" !important;
      font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important;
      font-weight: 700 !important;
    }
    
  .reset-btn::before { content: "↺" !important; }
  #filterToggleBtn { gap: 0 !important; }
  #filterToggleBtn::after { margin-left: 0.55em !important; }
}

/* --- 3. ボタンを押した瞬間の共通動作 --- */
#filterToggleBtn:active, #favOnlyToggleBtn:active, #randomBtn:active, .reset-btn:active {
  transform: translateY(1px) !important;
}

/* ================================================= */
/* ===== テーマごとの色設定と挙動定義 (変更なし) ===== */
/* ================================================= */

/* --- 1. ライトモード --- */
body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn,
body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn,
body:not(.dark-mode):not([class*="theme-"]) #randomBtn,
body:not(.dark-mode):not([class*="theme-"]) .reset-btn,
body:not(.dark-mode):not([class*="theme-"]) #latestBtn { /* ← ここに追加 */
  background-color: #ffffff !important; color: #22272e !important; border-color: #d0d7de !important;
}

/* ★★★ ↓↓ このブロックを新しく追加 ↓↓ ★★★ */
body:not(.dark-mode):not([class*="theme-"]) #latestBtn {
  background-color: #e52d27 !important; /* YouTubeの赤 */
  color: #ffffff !important;
  border-color: #e52d27 !important;
}

body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn[aria-expanded="true"],
body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn[aria-pressed="true"] {
  background-color: #22272e !important; color: #ffffff !important; border-color: #22272e !important;
}
@media (hover: hover) {
  /* テーマと同じ「控えめな背景変化＋枠線強調・文字色不変」パターンに統一 */
  body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn:not([aria-expanded="true"]):hover,
  body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn:not([aria-pressed="true"]):hover,
  body:not(.dark-mode):not([class*="theme-"]) #randomBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .reset-btn:hover {
    background-color: #f3f4f6 !important; color: #22272e !important; border-color: #9aa4b2 !important;
  }
  /* ★★★ ↓↓ このブロックを新しく追加 ↓↓ ★★★ */
  body:not(.dark-mode):not([class*="theme-"]) #latestBtn:hover {
    background-color: #c21d19 !important; /* 暗い赤 */
    border-color: #c21d19 !important;
    color: #ffffff !important;
  }
}

/* --- 2. ダークモード --- */
body.dark-mode #filterToggleBtn, body.dark-mode #favOnlyToggleBtn, body.dark-mode #randomBtn, body.dark-mode .reset-btn,
body.dark-mode #latestBtn { /* ← ここに追加 */
  background-color: #2d333b !important; color: #e5ecec !important; border-color: #394150 !important;
}

body.dark-mode #filterToggleBtn[aria-expanded="true"], body.dark-mode #favOnlyToggleBtn[aria-pressed="true"] {
  background-color: #e5ecec !important; color: #22272e !important; border-color: #e5ecec !important;
}

/* --- 3. カラーテーマ共通 --- */
body[class*="theme-"] #filterToggleBtn,
body[class*="theme-"] #favOnlyToggleBtn,
body[class*="theme-"] #randomBtn,
body[class*="theme-"] .reset-btn,
body[class*="theme-"] #latestBtn { /* ← ここに追加 */
  background-color: var(--btn-control-bg) !important;
  color: var(--btn-control-text) !important;
  border-color: var(--btn-control-bg) !important;
}

/* ★★★ ↓↓ このブロックを新しく追加 ↓↓ ★★★ */
body[class*="theme-"] #latestBtn {
  background-color: #ffffff !important; /* 白 */
  /* 文字はテーマの濃いほうの色（背景色そのままだと、イエロー・ピンクで白地に読めなかった） */
  color: var(--btn-control-text-active) !important;
  border-color: #ffffff !important;
}

body[class*="theme-"] #filterToggleBtn[aria-expanded="true"],
body[class*="theme-"] #favOnlyToggleBtn[aria-pressed="true"] {
  background-color: var(--btn-control-bg-active) !important;
  color: var(--btn-control-text-active) !important;
  border-color: var(--btn-control-bg-active) !important;
}

@media (hover: hover) {
  body[class*="theme-"] #filterToggleBtn:hover,
  body[class*="theme-"] #favOnlyToggleBtn:hover,
  body[class*="theme-"] #randomBtn:hover,
  body[class*="theme-"] .reset-btn:hover,
  body[class*="theme-"] #latestBtn:hover { /* ← ここに追加 */
    background-color: var(--btn-control-bg-active) !important;
    color: var(--btn-control-text-active) !important;
    border-color: var(--btn-control-bg-active) !important;
  }
  /* ★★★ ↓↓ このブロックを新しく追加 ↓↓ ★★★ */
  body[class*="theme-"] #latestBtn:hover {
    background-color: #f0f0f0 !important; /* 少し暗い白 */
    border-color: #f0f0f0 !important;
    color: var(--btn-control-text-active) !important;
  }
}

/* ======================================================================== */
/* ===== YouTubeプレイリスト作成ボタンのスタイル ===== */
/* ======================================================================== */
.results-count-under-bar {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 件数とボタンを両端に配置 */
  gap: 16px;
}

#latestBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: #e52d27; /* YouTubeの赤 */
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

@media (hover: hover) {
  #latestBtn:hover {
    background-color: #c21d19;
  }
}

/* ボタンがhidden属性を持つ場合は非表示にする */
#latestBtn[hidden] {
  display: none;
}

/* ダークモード時の調整 */

/* ===== オーバーレイ上でのタッチ操作によるスクロールを防止 ===== */
#drawerBackdrop,
#aboutModal,
#historyModal {
  touch-action: none;
}

/* style.css の一番下に追加してください */

/* =================================================== */
/* ★★★ PWA/モバイル対応強化スタイル ★★★ */
/* =================================================== */

/* --- PWAモードのセーフエリア対応 --- */
/* :rootで定義済みのセーフエリア変数を活用します */

/* PWAモードで起動された場合のみ、ヘッダーの上の余白を調整 */
.is-standalone .sticky-search-area {
  padding-top: calc(0.38rem + var(--safe-top));
}

/* PWAモードで起動された場合のみ、コンテンツ全体の左右の余白を調整 */
.is-standalone .main-content {
  padding-left: max(15px, var(--safe-left));
  padding-right: max(15px, var(--safe-right));
}

/* PWAモードで起動された場合のみ、画面下のボタン等がホームバーに被らないように調整 */
.is-standalone .pagination-area,
.is-standalone footer {
  padding-bottom: var(--safe-bottom);
}
.is-standalone #theme-toggle-btn {
  bottom: calc(18px + var(--safe-bottom));
}

/* --- 100vh問題対策 --- */
/* JSで設定した --vh 変数を使ってローディング画面の高さを設定 */

/* style.cssの一番下に追加 */

/* 「このサイトについて」モーダルにも開閉アニメーションを定義 */
#aboutModal.show {
  animation: modalFade .22s ease-out both;
}
#aboutModal.show #aboutModalContent {
  animation: modalPop .24s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#aboutModal.closing {
  animation: modalFadeOut .20s ease-in forwards;
}
/* 閉じる時は動かさず、フェードアウトのみ（オーバーレイのopacityが下げる） */
#aboutModal.closing #aboutModalContent {
  animation: none;
  transform: translateY(0) scale(1);
}

html {
  scroll-padding-top: var(--header-offset, 186px);
}

/* style.css の L3062 あたりからを、丸ごと差し替えてください */

/* ======================================================================== */
/* ===== (V2.1) スマホ表示時: コントロールボタンのデザインを微調整 ===== */
/* ======================================================================== */
@media (max-width: 1069px) {

  /* 4つのボタンに共通の縦並びレイアウトを適用 */
  .search-row-controls #filterToggleBtn,
  .search-row-controls #favOnlyToggleBtn,
  .search-row-controls #randomBtn,
  .search-row-controls .reset-btn {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important; /* 左右中央揃え */
    height: auto !important;
    min-height: 60px;
    padding: 8px 4px !important;
    gap: 4px !important;
  }

  /* アイコンのスタイルを調整 */
  #filterToggleBtn i,
  #favOnlyToggleBtn i,
  #randomBtn i,
  .reset-btn::before {
    font-size: 22px !important;
    line-height: 1 !important;
    margin: 0 !important;
    width: 1.1em !important; /* 左右の表示幅を統一 */
    text-align: center !important; /* 幅内部でアイコンを中央に */
    font-weight: 900 !important;
    position: relative; /* ★修正1: 垂直位置調整(top)の基準点とします */
  }

  /* アイコンのスタイルを調整 (L3036 の既存のルールは削除して、
     上の L3030 のルールにマージしました) */

  /* リセットボタンのアイコンをFontAwesomeに統一 */
  .reset-btn::before {
      font-family: "Font Awesome 6 Free" !important;
      content: "\f2ea" !important; /* fa-rotate-left アイコン */
  }

  /*
   * ▼▼▼ ここからが修正箇所です ▼▼▼
   *
   * 「リセット」ボタンのスタイルを分離して、
   * IDセレクタ (#mainResetBtn) を使い詳細度を上げます。
   */

  /* テキスト部分のスタイルを調整 (フィルタ、お気に入り、ランダム) */

  /* リセットボタン本体のテキストスタイルを調整 */
  #mainResetBtn {
    font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important; /* 既存の .reset-btn のスタイルをここに含めます */
  }
  
  /* ▲▲▲ 修正はここまでです ▲▲▲ */

  /*
   * ★★★ 修正2: 以下のルールブロックを新しく追加します ★★★
   * (PWA版のL3048-L3066の調整値を、こちらの非PWA版にも適用します)
   */

  /* 「フィルタ」アイコン (fa-filter) */
  #filterToggleBtn i {
    top: 0.05em !important; /* 約 1px 下に移動 */
  }

  /* 「お気に入り」アイコン (fa-star) */
  #favOnlyToggleBtn i {
    top: 0.05em !important; /* 約 0.4px 下に移動 */
  }

  /* 「ランダム」アイコン (fa-shuffle) */
  #randomBtn i {
    top: 0.08em !important; /* 約 1px 下に移動 */
  }

  /* 「リセット」アイコン (fa-rotate-left) */
  .reset-btn::before {
    /* L3043で position: relative が指定済みのため、topのみ指定 */
    top: 0.15em !important;
  }

  /* テキスト部分のスタイルを調整 */
  #filterToggleBtn::after,
  #favOnlyToggleBtn span,
  #randomBtn span
  {
    font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif !important; /* ★この行を追加 */
    font-size: 11px !important;
    font-weight: 700 !important;
  }

}

/* ======================================================================== */
/* ===== 全画面共通: お気に入りボタンのアイコンを塗りつぶしに統一 ===== */
/* ======================================================================== */

/* お気に入りボタンのアイコンを常にSolidスタイル(塗りつぶし)で表示 */
#favOnlyToggleBtn i {
  font-weight: 900 !important;
}

/* ======================================================================== */
/* ===== (最終・確定版) カードレイアウト 全デバイス強制修正 ===== */
/* ======================================================================== */

/* --- 1. まず、既存のカードスタイルの一部をリセット --- */
/* (ここは変更しないでください) */
.episode-item,
.episode-item > a,
.episode-item .thumb-col,
.episode-item a > div:last-of-type {
  gap: 0;
  flex: none;
}
#results h5.mb-1,
.ts-episode-card h5.mb-1,
.episode-meta {
  margin: 0;
}

/* --- 2. カード全体の基本設定 --- */
/* (ここは変更しないでください) */
.episode-item {
  /* カード内側の右余白。テキスト列の右端とボタン（★/リンク）の右端をこの位置で揃える */
  --card-pad-r: 12px;
  padding: 12px;
  padding-right: var(--card-pad-r);
}

/* --- 3. リンクエリアのレイアウトを再構築 (最重要) --- */
/* (ここは変更しないでください) */
.episode-item > a {
  display: flex !important;
  align-items: center !important;
  gap: 0 !important;
  width: 100%;
}

/* --- 4. サムネイルの領域を固定 --- */
/* (ここは変更しないでください) */
.episode-item .thumb-col {
  flex-shrink: 0;
}

/* --- 5. テキストエリアをマージンで強制的に配置 --- */
/* (ここは変更しないでください) */
.episode-item a > div:last-of-type {
  flex-grow: 1;
  min-width: 0;
}

/* ======================================================================== */
/* ★★★ スマホ表示 (幅 779px 以下) の調整エリア ★★★ */
/* ======================================================================== */
@media (max-width: 779px) {
  /* --- サムネイル (幅120px / 高さ67.5px) --- */
  .episode-item .thumbnail {
    width: 130px; 
  }

  /* --- テキストエリア全体の配置 --- */
  .episode-item a > div:last-of-type {
    margin-left: 12px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 73px;
  }

  /*
   * ▼▼▼ (1) エピソード名 (スマホ) ▼▼▼
   */
  #results h5.mb-1,
  .ts-episode-card h5.mb-1 {
    margin-top: 0.2rem;
    font-size: 1.2em;
    line-height: 1.2rem;
    word-break: normal;
    overflow-wrap: normal;
  }

  /*
   * ▼▼▼ (2) ゲスト名 (スマホ) ▼▼▼
   */
  .guest-one-line {
    margin-top: 1.0px; 
    font-size: 0.85rem; 
    line-height: 1.25;
    display: block !important;
    width: 100% !important;
    min-height: 1.1rem;
  }

  /*
   * ▼▼▼ (3) 公開日時・(4) 動画時間 (スマホ) ▼▼▼
   */
  .episode-meta {
    margin-top: 0; 
    font-size: 0.75rem;
    line-height: 1.35; 
    opacity: 0.7;
  }
}

/* ======================================================================== */
/* ★★★ タブレット表示 (iPad縦・横) (幅 780px ～ 1069px) の調整エリア ★★★ */
/* ======================================================================== */
@media (min-width: 780px) and (max-width: 1069px) {
  .episode-item {
    --card-pad-r: 14px;
    padding: 14px;
    padding-right: var(--card-pad-r);
  }
  
  /* --- サムネイル (幅150px / 高さ84.375px) --- */
  .episode-item .thumbnail {
    width: 150px;
  }

  /* --- テキストエリア全体の配置 --- */
  .episode-item a > div:last-of-type {
    margin-left: 12px; /* サムネイルとテキスト間の隙間 */
    height: 84px; /* サムネイルの高さに固定 */
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /*
   * ▼▼▼ (1) エピソード名 (タブレット) ▼▼▼
   */
  #results h5.mb-1,
  .ts-episode-card h5.mb-1 {
    margin-top: 3px;
    font-size: 1.4rem;
    line-height: 1.0;
  }
  
  /*
   * ▼▼▼ (2) ゲスト名 (タブレット) ▼▼▼
   */
  .guest-one-line {
    margin-top: 2px; 
    font-size: 1.1rem;
    line-height: 1.2; 
    display: block;
    width: 100%;
  }

  /*
   * ▼▼▼ (3) 公開日時・(4) 動画時間 (タブレット) ▼▼▼
   */
  .episode-meta {
    margin-top: 3px; 
    font-size: 0.8rem; 
    line-height: 1.3; 
    opacity: 0.7;
  }
}

/* ======================================================================== */
/* ★★★ PC表示 (幅 1070px 以上) の調整エリア ★★★ */
/* ======================================================================== */
@media (min-width: 1070px) {
  .episode-item {
    --card-pad-r: 14px;
    padding: 14px;
    padding-right: var(--card-pad-r);
  }
  
  /* --- サムネイル (幅150px / 高さ84.375px) --- */
  .episode-item .thumbnail {
    width: 150px;
  }

  /* --- テキストエリア全体の配置 --- */
  .episode-item a > div:last-of-type {
    margin-left: 12px; /* サムネイルとテキスト間の隙間 */
    height: 84px; /* サムネイルの高さに固定 */
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  /*
   * ▼▼▼ (1) エピソード名 (PC) ▼▼▼
   */
  #results h5.mb-1,
  .ts-episode-card h5.mb-1 {
    margin-top: 3px;
    font-size: 1.4rem;
    line-height: 1.0;
  }
  
  /*
   * ▼▼▼ (2) ゲスト名 (PC) ▼▼▼
   */
  .guest-one-line {
    margin-top: 2px; 
    font-size: 1.1rem;
    line-height: 1.2; 
    display: block;
    width: 100%;
  }

  /*
   * ▼▼▼ (3) 公開日時・(4) 動画時間 (PC) ▼▼▼
   */
  .episode-meta {
    margin-top: 3px; 
    font-size: 0.8rem; 
    line-height: 1.3; 
    opacity: 0.7;
  }
}

/* ======================================================================== */
/* ===== (最終・確定コード) ゲスト名がはみ出す問題の根本対策 ===== */
/* ======================================================================== */
/* (ここは変更しないでください) */
.episode-item > a > div:last-of-type {
  flex: 1;
  min-width: 0;
}
.episode-item h5.mb-1 {
  width: 100%;
}

/* ======================================================================== */
/* ===== (再修正) タイムスタンプをサムネイル右下に表示 (PC/SP両対応) ===== */
/* ======================================================================== */

/* --- 基本設定 (全デバイス共通) --- */

/* 1. サムネイルを含む親要素(.thumb-col)を、絶対位置指定の基準点にします */
.thumb-col {
  position: relative;
  /* display:flexやflex-directionをリセットし、シンプルな箱にします */
  display: block;
  flex-shrink: 0;
}

/* 2. タイムスタンプのコンテナを、親要素の右下に絶対配置します */
.ts-buttons {
  position: absolute;
  bottom: 5px;
  right: 5px;
  margin-top: 0;
  z-index: 1; /* 画像の上に確実に表示されるように念のため指定 */
}

/* 3. タイムスタンプボタンの見た目を調整します */
.ts-btn {
  background-color: rgba(0, 0, 0, 0.75);
  color: white;
  border: none;
  font-size: 0.8em;
  font-weight: bold;
  padding: 3px 7px;
  border-radius: 4px;
  backdrop-filter: blur(2px);
}

/* 4. ダークモードでも同じスタイルを適用します */

/* --- デバイスごとの幅調整 --- */

/* 5. スマホ表示 (幅 779px 以下) のコンテナ幅をサムネイルに合わせます */
@media (max-width: 779px) {
  .thumb-col {
    width: 130px; /* スマホ用サムネイル幅 */
  }
}

/* 6. タブレット・PC表示 (幅 780px 以上) のコンテナ幅をサムネイルに合わせます */
@media (min-width: 780px) {
  .thumb-col {
    width: 150px; /* タブレット・PC用サムネイル幅 */
  }
}

/* ======================================================================== */
/* ===== (JS連携) 最小フォントでも収まらない場合に省略表示を適用 ===== */
/* ======================================================================== */
.guest-one-line.needs-ellipsis {
  text-overflow: ellipsis !important;
}

/* style.css に追記 */

/* =================================================== */
/* ★★★ モーダル表示中の背景スクロールを安定的に禁止 ★★★ */
/* =================================================== */
html.scroll-locked {
  overflow: hidden !important;
}

/* タイムスタンプモーダル表示中（スマホ）: iOSはoverflow:hiddenを無視して
   キーボード表示時にページをスクロールさせるため、bodyごと固定して
   背景ページが物理的に動けないようにする（topはJSが -scrollY を設定） */
body.ts-kb-lock {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  overflow: hidden !important;
}

.sort-wrapper {
  display: block;
  position: relative;
}

/* =================================================== */
/* ★★★ 全体的な左右の余白を統一 ★★★ */
/* =================================================== */
.results-count-under-bar,
.filters-bar,
.main-content {
  /* 左右に15pxの余白を追加して、全体の縦のラインを揃えます */
  padding-left: 15px !important;
  padding-right: 15px !important;

  /* 余白を追加してもレイアウトが崩れないようにします */
  box-sizing: border-box !important;
}

/* =================================================== */
/* ★★★ 検索ボックスのクリアボタン ★★★ */
/* =================================================== */

/* inputとボタンを囲むラッパー */
.search-input-wrapper {
  position: relative;
  width: 100%; /* 横幅いっぱいに広がるように */
}

/* 既存のinputスタイルはそのままに、クリアボタンのスペースを確保 */
.search-input-wrapper .searchbox-input {
  width: 100%;
  /* 右側のpaddingを増やしてボタンと文字が被らないようにします */
}

/* クリアボタンのスタイル */

/* JavaScriptによってhidden属性が外されたら表示する */
.clear-search-btn:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

@media (hover: hover) {
  .clear-search-btn:hover {
    background-color: #9ca3af;
    color: #ffffff;
  }
}

/* --- ダークモード対応 --- */

/* --- カラーテーマ対応 --- */
body[class*="theme-"] .clear-search-btn {
    background-color: var(--filter-btn-active);
    color: var(--btn-main);
}

@media (hover: hover) {
    body[class*="theme-"] .clear-search-btn:hover {
        background-color: var(--active-filter);
        color: var(--active-filter-text);
    }
}

/* style.css に追記（既存のクリアボタンのスタイルもこちらで上書き・調整します） */

/* =================================================== */
/* ★★★ 検索ボックス内ボタン (クリア＆検索) ★★★ */
/* =================================================== */

/* 2つのボタンを配置するため、入力欄の右側の余白を広げます */
.search-input-wrapper .searchbox-input {
  /* 以前は38pxでしたが、72pxに拡張します */
  padding-right: 72px !important;
}

/* クリアボタンの位置を、新しい検索ボタンの左隣に調整します */
.clear-search-btn {
  /* 以前は right: 8px でしたが、44px に変更します */
  right: 44px;

  /* 以下は既存のスタイルですが、念のため記載します */
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  background-color: #d1d5db;
  color: #4b5563;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s, background-color 0.15s;
}

/* ★★★↓ここから新しい検索ボタンのスタイルを追加します↓★★★ */
.main-search-btn {
  position: absolute;
  top: 50%;
  right: 8px; /* 右端に配置 */
  transform: translateY(-50%);

  display: flex;
  align-items: center;
  justify-content: center;

  width: 32px;
  height: 32px;
  padding: 0;

  background-color: transparent;
  color: #5f6e86;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.15s, color 0.15s;
}

@media (hover: hover) {
  .main-search-btn:hover {
    background-color: #f0f2f5; /* ほんのり背景色を付ける */
  }
}

/* --- ダークモード対応 --- */
body.dark-mode .main-search-btn {
  color: #bdc6d2;
}
@media (hover: hover) {
  body.dark-mode .main-search-btn:hover {
    background-color: #394150;
  }
}

/* --- カラーテーマ対応 --- */
body[class*="theme-"] .main-search-btn {
  color: var(--muted);
}
@media (hover: hover) {
  body[class*="theme-"] .main-search-btn:hover {
    background-color: var(--filter-btn-active);
  }
}

/* =================================================== */
/* ★★★ フォントの太さを使い分ける設定 ★★★ */
/* =================================================== */

/* 見出しやボタンなど、強調したいテキストに太いフォントを適用します */
h1, h2, h3, h4, h5, b, strong, .filter-title, .guest-button, .btn-corner, .btn-year, .page-btn, .history-toggle .title, .history-item .label, .share-btn .share-label, .filter-tag, #latestBtn, .drawer-close-btn, .about-title, .results-count-under-bar, .is-standalone .pwa-bottom-nav-btn {
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* 他のスタイル設定に確実に打ち勝って太字にするため、
    font-weight に !important を付けています。
  */
  font-weight: 700 !important;
}

/* =================================================== */
/* ★★★ PWA専用 下部ナビゲーション スタイル ★★★ */
/* =================================================== */

/* 下部ナビゲーションバーを通常は非表示に */

/* PWAモード(.is-standalone)の時だけ表示し、スタイルを適用 */
.is-standalone .pwa-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(60px + var(--safe-bottom, 0px)); /* iPhoneのホームバーエリアを考慮 */
  padding-bottom: var(--safe-bottom, 0px);
  background-color: var(--card-bg, #ffffff);
  border-top: 1px solid var(--btn-reset-border, #e5e7eb);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  z-index: 3000;
}

/* ナビゲーションバー内の各ボタンのスタイル */
.is-standalone .pwa-bottom-nav-btn {
  flex: 1; /* 4つのボタンが等幅に広がる */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted, #7c8798);
  font-family: inherit;
  font-size: 11px;
  -webkit-tap-highlight-color: transparent; /* スマホでのタップ時のハイライトを消す */
  transition: color 0.15s ease;
}

.is-standalone .pwa-bottom-nav-btn i {
  font-size: 20px;
}

/* ボタンがアクティブ（選択中）の時のスタイル */
.is-standalone .pwa-bottom-nav-btn.is-active {
  color: var(--btn-main, #6654e8);
}

/* PWAモードの時、元々あった上部のボタンを非表示にする */
.is-standalone .search-row-controls #filterToggleBtn,
.is-standalone .search-row-controls #favOnlyToggleBtn,
.is-standalone .search-row-controls #randomBtn,
.is-standalone .search-row-controls #mainResetBtn {
  display: none !important;
}

/* PWAモードの時、コンテンツの最下部がナビゲーションバーに隠れないように余白を追加 */
.is-standalone .main-content {
  padding-bottom: 80px; /* ナビゲーションバーの高さ + α */
}

/* ★整理: ここにあった .is-standalone.dark-mode / .is-standalone[class*="theme-"] の
   各ルールは削除。is-standaloneはhtml要素、dark-mode/theme-*はbody要素に付与されるため
   同一要素の複合セレクタは絶対にマッチしなかった。正しい記述
   （html.is-standalone body.dark-mode ... 等）が後方に存在し、そちらが機能している。 */

/* =================================================== */
/* ★★★ PWA/モバイル対応強化スタイル (修正版V2) ★★★ */
/* =================================================== */

/* --- PWAモードのセーフエリア対応 --- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

/* JSでhtmlタグに .is-standalone クラスが付与されることを前提とします */
html.is-standalone .sticky-search-area {
  padding-top: calc(0.38rem + var(--safe-top));
  padding-left: max(0px, var(--safe-left));
  padding-right: max(0px, var(--safe-right));
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

/* --- メインコンテンツを画面いっぱいに広げる設定 --- */
html.is-standalone .main-content {
  padding-left: max(15px, var(--safe-left));
  padding-right: max(15px, var(--safe-right));

  /* ★修正1: 余白(隙間)の原因を修正 */
  /* 固定の80pxではなく、ナビゲーションバーの高さと完全に一致させる */
  padding-bottom: calc(60px + var(--safe-bottom)); 

  /* 画面の高さを最低でも100%確保し、Flexboxで縦並びにする */
  min-height: calc(var(--vh, 1vh) * 100);
  /* ★修正: iOSのPWA起動直後はJS計測の--vhが実際より小さい値のまま残ることがあり、
     お気に入りが少ない時にフッターが浮いて画面がずれて見えた。対応環境では
     ブラウザが自動追従するdvhを優先する（非対応環境は上の--vh計算のまま） */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* フッターを強制的に最下部に配置 */
html.is-standalone .site-footer {
  margin-top: auto; /* これにより、上の空きスペースを埋めて下に配置されます */
}

/* --- 100vh問題対策 & ロード画面修正 --- */
#loading-screen {
  /* ★修正2: ロード画面の重なり順を最強にして、ナビバーが透けるのを防ぐ */
  z-index: 2147483647 !important;

  /* 高さの計算をより厳密に */
  height: 100vh;      /* フォールバック */
  height: 100dvh;     /* アドレスバー等を考慮した動的な高さ */
  min-height: 100%;
}
/* ★起動時の帯チラつき対策（根本対策）:
   iOSのPWA起動の最初の描画では dvh が一瞬実際より短く（例: 852px中799px）、
   ローディング画面の下から body 背景（テーマの明るい色）が1フレームだけ見えて
   「下部がチラつく」原因になっていた。同色の延長領域を下に400pxぶら下げておき、
   高さ計算がどう転んでも隙間が絶対にできないようにする（はみ出しは画面外で無害）。 */
#loading-screen::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 400px;
  background: inherit;
}

/* --- PWA専用 下部ナビゲーション --- */
.pwa-bottom-nav {
  display: none;
}

html.is-standalone .pwa-bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* ナビバーの高さ定義 (メインコンテンツのpadding-bottomと一致) */
  height: calc(60px + var(--safe-bottom, 0px));
  padding-bottom: var(--safe-bottom, 0px);

  background-color: var(--card-bg, #ffffff);
  border-top: 1px solid var(--btn-reset-border, #e5e7eb);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  z-index: 3000;
  transition: transform 0.25s ease-in-out;
}

/* ★修正: モーダル表示中もナビバーを隠さない（下に引っ込ませない）ように変更 */
html.is-standalone.scroll-locked .pwa-bottom-nav {
  transform: translateY(0) !important;
}

html.is-standalone .pwa-bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--muted, #7c8798);
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700 !important;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

html.is-standalone .pwa-bottom-nav-btn i { line-height: 1; position: relative; }
html.is-standalone .pwa-bottom-nav-btn span { line-height: 1; position: relative; }
html.is-standalone .pwa-bottom-nav-btn.is-active { color: var(--btn-main, #6654e8); }

/* PWAモード時は、既存のヘッダー内ボタンを非表示にする */
html.is-standalone .search-row-controls #filterToggleBtn,
html.is-standalone .search-row-controls #favOnlyToggleBtn,
html.is-standalone .search-row-controls #randomBtn,
html.is-standalone .search-row-controls #mainResetBtn {
  display: none !important;
}

/* --- テーマカラー対応 --- */

/* 位置調整 */

/* ナビアイコン位置の微調整 */

/* --- テーマカラー対応 (前回同様) --- */
/* ダークモード */
html.is-standalone body.dark-mode .pwa-bottom-nav {
  background-color: #252c35;
  border-top-color: #394150;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.2);
}

/* その他カラーテーマ */
html.is-standalone body[class*="theme-"] .pwa-bottom-nav {
  background-color: var(--card-bg);
  border-top-color: var(--history-card-bd);
}
html.is-standalone body[class*="theme-"] .pwa-bottom-nav-btn { color: var(--muted); }
html.is-standalone body[class*="theme-"] .pwa-bottom-nav-btn.is-active { color: var(--btn-main); }

/*
 * カラー変更ボタンの位置を、!important を付けて確実に上書き
 */
html.is-standalone #theme-toggle-btn {
  bottom: calc(60px + 18px + var(--safe-bottom)) !important;
}
/* テーマパネルも同様に上にずらす */

/* ★修正: フィルタードロワーがナビゲーションバーと被らないよう、ナビバーの高さ分だけ下を空ける */
html.is-standalone #filterDrawer {
  bottom: calc(60px + var(--safe-bottom, 0px)) !important; 
}

/* モーダルのオーバーレイをPWAナビゲーションより手前に表示 */
.modal-overlay {
  z-index: 3001 !important;
}

/* =================================================== */
/* ★★★ ローディングロゴ・スピナーの表示設定 ★★★ */
/* =================================================== */

/* PWA起動時のフラッシュを防ぐため、初期状態からロゴを表示(opacity: 1)します。
   フェードイン演出は削除し、即座に表示されるように変更しました。
*/

#loading-logo {
  opacity: 1;
  /* transitionは削除、または不要 */
}

/* .loaded クラスによる制御は削除 */

#spinner {
  opacity: 1;
  /* transitionは削除、または不要 */
}

/* ================================================================= */
/* ★★★ 「ひすとりー」リンク下線のガタつきを修正 (最終・確定版) ★★★ */
/* ================================================================= */

/* 1. リンク本体のデフォルト下線を無効化します */
.history-item .label a {
  text-decoration: none;
}

/* 2. リンクにホバーした時だけ、カスタム下線を描画します */
.history-item .label a{
    /* 背景画像として直線を描画し、下線として利用します */
    background-image: linear-gradient(currentColor, currentColor);
    background-position: 0% 100%; /* 下線の位置（テキストの下端） */
    background-repeat: no-repeat;
    background-size: 100% 1.5px;  /* 下線の太さ */
    padding-bottom: 2px;          /* テキストと下線の間の余白 */
  }

/* 3. リンク内のspan要素には下線が適用されないようにします */
.history-item .label a .impact-number {
  text-decoration: none;
}

/* =================================================== */
/* ★★★ PWA 下部ナビ アイコン/テキスト 独立・精密調整 ★★★ */
/* =================================================== */

/* --- 1. 全てのアイコンとテキストに relative を指定 --- */
html.is-standalone .pwa-bottom-nav-btn i,
html.is-standalone .pwa-bottom-nav-btn span {
  position: relative;
}

/* --- 2. 各ボタンの個別調整 ---
  top: 垂直位置 (プラスで下に、マイナスで上に)
  left: 水平位置 (プラスで右に、マイナスで左に)
  font-size: 大きさ
*/

/* --- フィルタボタン (#pwa-filterToggleBtn) --- */
html.is-standalone #pwa-filterToggleBtn i {
  font-size: 21px;
  top: -0.08em;  /* (ベース位置: 約2px上) */
  left: 0;
}
html.is-standalone #pwa-filterToggleBtn span {
  font-size: 10px;
  top: -0.15em; 
  left: 0.07em;
}

/* --- お気に入りボタン (#pwa-favOnlyToggleBtn) --- */
html.is-standalone #pwa-favOnlyToggleBtn i {
  font-size: 19px;
  top: -0.1em;
  left: 0;
}
html.is-standalone #pwa-favOnlyToggleBtn span {
  font-size: 10px;
  top: 0.0em;
  left: 0.05em;
}

/* --- ランダムボタン (#pwa-randomBtn) --- */
html.is-standalone #pwa-randomBtn i {
  font-size: 22px;
  top: -0.05em;
  left: 0;
}
html.is-standalone #pwa-randomBtn span {
  font-size: 10px;
  top: -0.15em;
  left: 0.05em;
}

/* --- リセットボタン (#pwa-mainResetBtn) --- */
html.is-standalone #pwa-mainResetBtn i {
  font-size: 22px;
  top: -0.05em;
  left: 0;
}
html.is-standalone #pwa-mainResetBtn span {
  font-size: 10px;
  top: -0.15em;
  left: 0;
}

/* style.css の一番下に追記 */

/*
 * ===================================================
 * ★★★ PWA 下部ナビ 5ボタン (中央フロート型) スタイル ★★★
 * ===================================================
 */

/* PWAモードの時は、右下の丸いテーマボタンを非表示に */
html.is-standalone #theme-toggle-btn {
  /* display: none; の代わりに、画面の外に移動させます。
    これにより、見た目は消えますが、JSからのクリックは受け付けるようになります。
  */
  position: fixed !important;
  top: -100px !important;     /* 画面の上外に配置 */
  left: -100px !important;    /* 画面の左外に配置 */
  opacity: 0 !important;
}

/* ナビゲーションバー自体の設定 (ボタンを中央揃えに) */
html.is-standalone .pwa-bottom-nav {
  justify-content: center;
  align-items: flex-start; /* 上揃えにして、中央ボタンのはみ出しを許可 */
}

/* 4つの通常ボタンのスタイル */
html.is-standalone .pwa-bottom-nav-btn {
  flex: 1; /* 均等幅 */
  max-width: 20%; /* 5ボタンなので */
  position: relative;
  height: 100%; /* 高さをナビバーに合わせる */
}

/* ★★★ 中央の「カラー」ボタンのスタイル ★★★ */
html.is-standalone #pwa-theme-toggle-btn {
  flex-grow: 0; /* 均等幅の対象外にする */
  flex-shrink: 0;
  
  position: relative; /* topを効かせるため */
  top: -18px; /* ★上に18pxはみ出す */
  
  /* 丸い形状を作成 */
  width: 68px;
  height: 68px;
  min-width: 68px; /* 縮まないように */
  border-radius: 50%;
  background-color: var(--card-bg, #ffffff);
  border: 2px solid var(--btn-reset-border, #e5e7eb);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);

  /* 左右のボタンとの間に少しマージン */
  margin: 0 8px;
}

/* 中央ボタンのアイコン */
html.is-standalone #pwa-theme-toggle-btn i {
  font-size: 30px; /* アイコンを大きく */
  top: 0;
  left: 0;
  color: var(--muted, #7c8798);
}

/* 中央ボタンのテキストを非表示に */
html.is-standalone #pwa-theme-toggle-btn span {
  display: none;
}

/* 中央ボタンがアクティブ (パネル表示中) のスタイル */
html.is-standalone #pwa-theme-toggle-btn.is-active {
  background-color: var(--btn-main, #6654e8);
  border-color: var(--card-bg, #ffffff);
}
/* アクティブ時のアイコン色 */
html.is-standalone #pwa-theme-toggle-btn.is-active i {
  color: var(--card-bg, #ffffff);
}

/* --- テーマ別の中央ボタン調整 --- */

/* ダークモード */

/* カラーテーマ */
html.is-standalone body[class*="theme-"] #pwa-theme-toggle-btn {
  background-color: var(--card-bg);
  border-color: var(--bg-color);
}
html.is-standalone body[class*="theme-"] #pwa-theme-toggle-btn i {
  color: var(--btn-main);
}
html.is-standalone body[class*="theme-"] #pwa-theme-toggle-btn.is-active {
  background-color: var(--btn-main);
  border-color: var(--card-bg);
}
html.is-standalone body[class*="theme-"] #pwa-theme-toggle-btn.is-active i {
  color: var(--card-bg);
}

/* * フローティングパネルの位置を、
 * 下部ナビゲーションバーの「上」＆「画面中央」に変更 
 */
html.is-standalone .floating-panel {
  /* 中央ボタンの上 + ナビバーの高さ + 余白 + セーフエリア */
  bottom: calc(60px + 18px + var(--safe-bottom)) !important;
  
  /* 左右中央に配置 */
  left: 50% !important;
  right: auto !important; /* right指定を解除 */
  
  /* パネルの形状を横並びのピルケースに変更 */
  flex-direction: row !important;
  border-radius: 999px !important;
  padding: 10px 14px !important;
  gap: 12px !important;

  /* アニメーションの基準点を調整 */
  transform-origin: bottom center !important;
}

/* パネルが開くときのアニメーションを調整 (上に開くように) */
html.is-standalone .floating-panel {
  opacity: 0;
  transform: translateX(-50%) scale(0.95) !important; 
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html.is-standalone .floating-panel.show {
  opacity: 1;
  transform: translateX(-50%) scale(1) !important;
  pointer-events: auto;
}

/*
 * ===================================================
 * ★★★ 非PWA版 (PC/スマホ) テーマボタンの色統一 ★★★
 * ===================================================
 */

/* --- アクティブ時 (ライトモード) --- */
#theme-toggle-btn.is-active {
  background-color: var(--btn-main, #6654e8);
  border-color: var(--card-bg, #ffffff);
  color: var(--card-bg, #ffffff); /* アイコン色 */
}

/* --- ダークモード (非アクティブ時) --- */
body.dark-mode #theme-toggle-btn {
  background-color: #252c35;
  color: #8ca2b3; /* アイコン色 */
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* --- ダークモード (アクティブ時) --- */
body.dark-mode #theme-toggle-btn.is-active {
  background-color: #ffffff;
  border-color: #252c35;
  color: #252c35; /* アイコン色 */
}

/* --- カラーテーマ (非アクティブ時) --- */
body[class*="theme-"] #theme-toggle-btn {   /* カード背景色（例: 濃いピンク） */
  border-color: var(--bg-color);     /* メイン背景色（例: ピンク） */            /* アイコン色（例: 白） */
}

/* --- カラーテーマ (アクティブ時) --- */
body[class*="theme-"] #theme-toggle-btn.is-active {
  background-color: var(--btn-main);   /* メインテキスト色（例: 白） */
  border-color: var(--card-bg);      /* カード背景色（例: 濃いピンク） */
  color: var(--card-bg);             /* アイコン色（例: 濃いピンク） */
}

/*
 * ===================================================
 * ★★★ PWA 下部ナビ 左右ボタンの余白調整 ★★★
 * ===================================================
 */

/* フィルタボタン(一番左)を少し右にずらす */
html.is-standalone #pwa-filterToggleBtn {
  position: relative;
  /* この数値(8px)を増減させて、お好みの位置に調整してください */
  left: 8px;
}

/* リセットボタン(一番右)を少し左にずらす */
html.is-standalone #pwa-mainResetBtn {
  position: relative;
  /* この数値(8px)を増減させて、お好みの位置に調整してください */
  right: 8px;
}

/* =================================================== */
/* ★★★ 「もしかして」機能のスタイル (リファイン版) ★★★ */
/* =================================================== */

/* 0件表示のラッパー */
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  /* 既存のスタイルを維持しつつ、中身のレイアウトを調整 */
}

.no-results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.no-results-icon {
  /* ★修正: サイト共通の太字フォントを指定 */
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700 !important;
  
  font-size: 1.0em;
  opacity: 0.9;
  
  /* ★修正: アイコンとテキストの位置関係を整理 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* アイコンと文字の間隔をしっかり空ける */
  line-height: 1.5; /* 行の高さに余裕を持たせて「切れ」を防ぐ */
  width: 100%;
}

/* 0件のときのヒントと「検索と絞り込みをリセット」 */
.no-results-hint {
  margin: -6px 0 0;
  font-size: 0.86em;
  line-height: 1.7;
  color: var(--muted);
  text-wrap: balance;
  word-break: auto-phrase;
}
.no-results-reset {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid #d5d9e2;
  border-radius: 999px;
  background: var(--card-bg, #fff);
  color: var(--text-color);
  font: inherit;
  font-size: 0.9em;
  font-weight: 700;
  cursor: pointer;
}
.no-results-reset i { font-size: 0.92em; }
@media (hover: hover) {
  .no-results-reset:hover { border-color: var(--text-color); }
}
body.dark-mode .no-results-reset { background: #2a2f37; border-color: #394150; color: #f1f3f7; }
body[class*="theme-"] .no-results-reset { background: var(--btn-bg) !important; border-color: var(--history-card-bd) !important; color: var(--btn-main) !important; }

/* アイコン自体の微調整 */
.no-results-icon i {
  flex-shrink: 0; /* アイコンが潰れるのを防ぐ */
  font-size: 1.15em; /* 少しだけ大きく */
  padding: 2px; /* 周囲に余白を持たせて描画切れを防ぐ */
}

/* もしかしてエリアのコンテナ */

/* ラベル ("💡 もしかして:") */

/* 提案キーワードのボタン */

/* --- テーマ別の微調整 --- */

/* ダークモード */

/* カラーテーマ適用時 */

/* =================================================== */
/* ★★★ 自動もしかして検索結果のスタイル (Refined) ★★★ */
/* =================================================== */

.did-you-mean-alert {
  grid-column: 1 / -1;
  width: 100%;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  animation: fadein-drawer 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dym-alert-content {
  width: 100%;
  max-width: 760px;
  /* ガラス風の半透明背景 */
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 18px 24px;
  box-shadow: 0 8px 24px -6px rgba(0,0,0,0.08);
  
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

/* 上部の補足メッセージ（見つかりませんでした） */

/* メインメッセージエリア */
.dym-alert-main {
  font-size: 1.1em;
  color: var(--text-color);
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  line-height: 1.4;
}

.dym-prefix {
  opacity: 0.9;
}

/* 提案ワードのボタンデザイン */
.dym-word-btn {
  appearance: none;
  background: transparent;
  border: 2px solid var(--btn-main, #6654e8);
  color: var(--btn-main, #6654e8);
  border-radius: 99px;
  padding: 4px 16px;
  font-size: 1.05em;
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
  transform: translateZ(0);

  /* ★修正: "all" ではなく、ホバー演出に必要なプロパティだけを指定する */
  /* これにより、JSによるフォントサイズ変更が即時反映（アニメーションなし）になります */
  transition: background-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;

  max-width: 75vw;
  width: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; 
  vertical-align: middle;
  flex-shrink: 1;
}

/* PCなどの広い画面では最大幅を固定ピクセルにする */
@media (min-width: 780px) {
  .dym-word-btn {
    max-width: 600px;
  }
}

/* スマホ用の微調整 */
@media (max-width: 600px) {
  .dym-word-btn {
    padding: 4px 12px;
    font-size: 1em;
  }
}

/* ホバー時の挙動 */
@media (hover: hover) {
  .dym-word-btn:hover {
    background: var(--btn-main, #6654e8);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }
}

.dym-word-btn:active {
  transform: translateY(0);
}

/* --- テーマ別調整 --- */

/* ダークモード */
body.dark-mode .dym-alert-content {
  background-color: rgba(30, 35, 45, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
}
body.dark-mode .dym-word-btn {
  border-color: #8de0ee;
  color: #8de0ee;
}
@media (hover: hover) {
  body.dark-mode .dym-word-btn:hover {
    background: #8de0ee;
    color: #22272e;
  }
}

/* カラーテーマ適用時 */
body[class*="theme-"] .dym-alert-content {
  background-color: var(--card-bg); /* カード色に合わせる */
  border-color: rgba(255, 255, 255, 0.3);
}
body[class*="theme-"] .dym-word-btn {
  border-color: #fff;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}
@media (hover: hover) {
  body[class*="theme-"] .dym-word-btn:hover {
    background: #fff;
    color: var(--active-filter-text);
  }
}

/* =================================================== */
/* ★★★ お気に入り画面の見出しスタイル (Simple Ver.) ★★★ */
/* =================================================== */

.favorites-title-header {
  display: flex;
  justify-content: center;
  /* 上下の余白を少し調整 */
  margin-top: 4px;
  margin-bottom: 12px;
  animation: fadein-drawer 0.2s ease-out;
}

.favorites-title-inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  
  /* --- 装飾を全削除 --- */
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  
  /* 文字スタイル */
  color: var(--text-color); /* 通常の文字色を使用 */
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

/* --- テーマ別調整 --- */

/* ダークモード */
body.dark-mode .favorites-title-inner {
  /* 背景などの指定は不要。文字色は --text-color で自動的に白になります */
  background: transparent;
  border: none;
  box-shadow: none;
}

/* カラーテーマ適用時 */
body[class*="theme-"] .favorites-title-inner {
  /* こちらも同様にリセット */
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-color);
}

/* =================================================== */
/* ★★★ お気に入りヘッダー＆トップへ戻るボタン ★★★ */
/* =================================================== */

/* ヘッダー全体を縦並び・中央寄せにするコンテナ */
.favorites-header-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px; /* タイトルとボタンの間隔 */
  width: 100%;
  margin-bottom: 10px;
}

/* トップへ戻るボタンのスタイル */
.fav-home-btn {
  appearance: none;
  background-color: #ffffff;
  color: #444;
  border: 1.5px solid #d0d7de;
  
  padding: 8px 24px;
  border-radius: 99px;
  
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700 !important;
  font-size: 0.95rem;
  
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* --- テーマ対応 --- */

/* ダークモード */
body.dark-mode .fav-home-btn {
  background-color: #2d333b;
  color: #e5ecec;
  border-color: #394150;
}
@media (hover: hover) {
  body.dark-mode .fav-home-btn:hover {
    background-color: #374151;
  }
}

/* カラーテーマ (テーマ色を反映) */
body[class*="theme-"] .fav-home-btn {
  color: var(--btn-main);
  border-color: var(--history-card-bd);
  background-color: var(--card-bg);
}
@media (hover: hover) {
  body[class*="theme-"] .fav-home-btn:hover {
    background-color: var(--filter-btn-active);
  }
}

/* =================================================== */
/* ★★★ ダークモード時のフィルタードロワー「閉じる」ボタン ★★★ */
/* =================================================== */

body.dark-mode #filterDrawer .drawer-close-btn {
  border-color: #394150 !important;
}

/* ======================================================================== */
/* ===== PC版: フィルターの左サイドバー常時表示化 (ワイド版) ===== */
/* ======================================================================== */

@media (min-width: 1070px) {
  /* --- 1. 全体の最大幅を広げる (1160px -> 1300px) --- */
  .main-content,
  .search-card,
  .filters-bar,
  .results-count-under-bar {
    max-width: 1300px !important;
  }

  /* --- 2. フィルター開閉ボタンなどを非表示 --- */
  #filterToggleBtn,
  .drawer-backdrop,
  #filterDrawer .drawer-footer {
    display: none !important;
  }

  /* --- 3. 上部ボタンの幅を均等に調整 --- */
  #favOnlyToggleBtn, 
  #randomBtn, 
  .reset-btn {
    width: calc(16.6% - 8px) !important;
  }

  /* --- 4. フィルタドロワーを左固定のサイドバーに変換 --- */
  #filterDrawer {
    display: block !important;
    position: fixed !important;
    top: calc(var(--header-offset) + 2px) !important;
    
    /* ▼ サイドバーの幅。ボタンを2列（スマホと同じ並び）にしても長いコーナー名が
       潰れすぎないよう、1列だったころの280pxから広げている（ボタン1つ約155px） */
    width: 340px !important;
    height: calc(100vh - var(--header-offset) - 20px) !important;
    
    /* 画面中央(max-width:1300px)の左端にピタッと合わせる計算 */
    left: 50% !important;
    margin-left: -650px !important;
    
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 12px 20px 5px !important; /* 右側に少しゆとり（スクロールバーの分） */
    overflow-y: auto !important;
    z-index: 100 !important;
    transform: none !important;
    animation: none !important;
  }

  /* 画面幅が1300pxをやや下回る場合は左端に固定して見切れを防止 */
  @media (max-width: 1320px) {
    #filterDrawer {
      left: 10px !important;
      margin-left: 0 !important;
    }
  }

  /* ダークモードやカラーテーマ適用時の背景色リセットを確実に */
  body[class*="theme-"] #filterDrawer,
  body.dark-mode #filterDrawer {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* サイドバーのスクロールバーを少し細くスマートに */
  #filterDrawer::-webkit-scrollbar {
    width: 6px;
  }
  #filterDrawer::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
  }
  body.dark-mode #filterDrawer::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
  }

  /* --- 5. フィルター内ボタンの隙間を少し広げて見栄え良く --- */

  /* --- 6. メインコンテンツの配置をサイドバー拡張に合わせて調整 --- */
  .main-content {
    padding-left: 365px !important; /* サイドバーの幅(340px)＋左の10px＋隙間15px */
    padding-right: 15px !important;
  }

  /* --- フィルター内のボタンはスマホと同じく横に2つ並べる --- */
  #filterDrawer .filter-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important; /* ボタン間の縦横の隙間 */
  }
  /* 文字の大きさもスマホと同じにする（長い名前は fitFilterButtons() が横だけ縮めて収める） */
  #filterDrawer .guest-button,
  #filterDrawer .btn-corner,
  #filterDrawer .btn-year {
    font-size: 0.95em;
    min-height: 37px;
  }
}

/* ======================================================================== */
/* ===== カラーテーマ適用時のフィルターボタン視認性修正 ===== */
/* ======================================================================== */

body[class*="theme-"] #filterDrawer .guest-button,
body[class*="theme-"] #filterDrawer .btn-corner,
body[class*="theme-"] #filterDrawer .btn-year {
  /* 右側の検索結果カードと同じ背景色を適用 */
  background-color: var(--card-bg) !important;

  color: var(--text-color) !important;
}

/* マウスホバー時の少し明るくなるエフェクト */
@media (hover: hover) {
  body[class*="theme-"] #filterDrawer .guest-button:hover,
  body[class*="theme-"] #filterDrawer .btn-corner:hover,
  body[class*="theme-"] #filterDrawer .btn-year:hover {
    background-color: var(--filter-btn-active) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
  }
}

/* ======================================================================== */
/* ===== カラーテーマ: フィルターボタン選択時（アクティブ）の反転修正 ===== */
/* ======================================================================== */

body[class*="theme-"] #filterDrawer .guest-button.active,
body[class*="theme-"] #filterDrawer .guest-button[aria-pressed="true"],
body[class*="theme-"] #filterDrawer .btn-corner.active,
body[class*="theme-"] #filterDrawer .btn-corner[aria-pressed="true"],
body[class*="theme-"] #filterDrawer .btn-year.active,
body[class*="theme-"] #filterDrawer .btn-year[aria-pressed="true"] {
  /* 背景を真っ白に、文字色をテーマのベースカラーに反転 */
  background-color: #ffffff !important;
  color: var(--bg-color) !important;
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2.5px rgba(255, 255, 255, 0.4) !important;
}

/* 選択中のボタンにマウスを乗せた際、色が戻ってしまわないように固定 */
@media (hover: hover) {
  body[class*="theme-"] #filterDrawer .guest-button.active:hover,
  body[class*="theme-"] #filterDrawer .guest-button[aria-pressed="true"]:hover,
  body[class*="theme-"] #filterDrawer .btn-corner.active:hover,
  body[class*="theme-"] #filterDrawer .btn-corner[aria-pressed="true"]:hover,
  body[class*="theme-"] #filterDrawer .btn-year.active:hover,
  body[class*="theme-"] #filterDrawer .btn-year[aria-pressed="true"]:hover {
    background-color: #ffffff !important;
    color: var(--bg-color) !important;
    border-color: #ffffff !important;
  }
}

/* ======================================================================== */
/* ===== iPad・スマホ版: フィルター内のカラーをPC版と完全に統一 ===== */
/* ======================================================================== */

@media (max-width: 1069px) {
  /* 1. ドロワー本体の背景色をメイン背景色(--bg-color)に変更。
     これによりボタン(--card-bg)と同化せず、PC版と同じコントラストになります */
  body[class*="theme-"] #filterDrawer {
    background-color: var(--bg-color) !important;
    border-color: var(--bg-color) !important;
  }
}

/* 2. 非選択時ボタンの枠線を透明にして、PC版スクショのようなフラットな質感に統一 */
body[class*="theme-"] #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]),
body[class*="theme-"] #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]),
body[class*="theme-"] #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]) {
  border-color: transparent !important;
}

/* ======================================================================== */
/* ===== フィルターボタンのホバー挙動をコンテンツカードと統一 ===== */
/* ======================================================================== */

@media (hover: hover) {

  /* 1. 通常（ライト）モードのホバー色をカードと統一 */
  body:not(.dark-mode):not([class*="theme-"]) #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body:not(.dark-mode):not([class*="theme-"]) #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body:not(.dark-mode):not([class*="theme-"]) #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]):hover {
    background-color: #f5f7fa !important;
    border-color: #d0d7de !important;
    color: var(--text-color) !important;
  }

  /* 2. ダークモードのホバー色をカードと統一 */
  body.dark-mode #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body.dark-mode #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body.dark-mode #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]):hover {
    background-color: #27343b !important;
    border-color: #4a5967 !important;
    color: #ffffff !important;
  }

  /* 3. カラーテーマ（ピンク～グリーン）のホバー色をカードと統一 */
  body[class*="theme-"] #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]):hover {
    background-color: var(--filter-btn-active) !important;
    border-color: var(--btn-main) !important;
    color: var(--text-color) !important;
  }
}

/* ======================================================================== */
/* ===== タブレット・PCでのPWA表示最適化 (PC版UI完全復元) ===== */
/* ======================================================================== */
@media (min-width: 1070px) {
  /* 1. ボトムナビゲーションを非表示 */
  html.is-standalone .pwa-bottom-nav {
    display: none !important;
  }

  /* 2. PWAモードで隠されていた上部ボタンを復活（フィルタ以外） */
  html.is-standalone .search-row-controls #favOnlyToggleBtn,
  html.is-standalone .search-row-controls #randomBtn,
  html.is-standalone .search-row-controls #mainResetBtn,
  html.is-standalone .search-row-controls .reset-btn {
    display: inline-flex !important;
  }

  /* 左サイドバーが出るため、上部のフィルタボタンは引き続き非表示 */
  html.is-standalone .search-row-controls #filterToggleBtn {
    display: none !important;
  }

  /* 3. PWAモードで強制されていた上部レイアウトの崩れをリセット */
  html.is-standalone .search-row-controls .reset-btn + .sort-wrapper {
    margin-left: auto !important;
  }
  html.is-standalone .search-row-controls .sort-wrapper,
  html.is-standalone #latestBtn {
    flex: 1 1 0 !important;
    width: auto !important;
  }

  /* 4. メインコンテンツの下部余白(ナビバー分)を通常仕様にリセット */
  html.is-standalone .main-content {
    padding-bottom: calc(20px + var(--safe-bottom)) !important;
  }

  /* 5. 非表示にされていた右下のカラーテーマ切替ボタンを元の位置に復活 */
  html.is-standalone #theme-toggle-btn {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 18px !important;
    bottom: calc(18px + var(--safe-bottom)) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* 6. フローティングテーマパネル(カラー選択)を元の縦並び・右下配置に戻す */
  html.is-standalone .floating-panel {
    bottom: calc(80px + var(--safe-bottom)) !important;
    left: auto !important;
    right: 18px !important;
    transform: translateY(10px) scale(0.95) !important;
    flex-direction: column !important;
    border-radius: 999px !important;
    padding: 14px 10px !important;
  }
  html.is-standalone .floating-panel.show {
    transform: translateY(0) scale(1) !important;
  }
}

/* =================================================== */
/* ★★★ フォトメモリンク (カメラボタン＆モーダル) ★★★ */
/* =================================================== */

/* --- カメラボタン (リスト上のボタン) --- */
.photo-btn {
  position: absolute;
  bottom: 10px;
  right: 52px; 
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #e6e6f3;
  box-shadow: 0 2px 10px -6px #0002;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: transform .12s, box-shadow .12s, background .12s;
  transform: translateZ(0);
}
.photo-btn i {
  font-size: 15px;
  color: #333742;
}
@media (hover: hover) {
  .photo-btn:hover { transform: scale(1.06); }
}

/* --- モーダル全体 --- */
.modal-content.photo-modal {
  background: #ffffff;
  width: min(500px, 92vw); /* 横幅を少し広げて調整 */
  
  /* 最大高さを制限し、画面端にぴったりくっつかないよう上下にマージンを確保 */
  max-height: 75vh;
  margin-bottom: 20px; 
  
  display: flex;
  flex-direction: column;
  border-radius: 24px;     /* 角丸を少し強調して柔らかい印象に */
  position: relative;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 15px 50px -12px rgba(0,0,0,0.2);
  overflow: hidden; /* 子要素の角丸をはみ出させない */
}

/* --- モーダルヘッダー (固定) --- */
.photo-modal .modal-header {
  box-sizing: border-box; /* min-heightにpaddingを含め、×ボタン(top:14px+38px)と同じ帯で中央揃えにする */
  position: relative;
  flex-shrink: 0; /* ヘッダーが潰れないように固定 */
  min-height: 66px; /* 閉じるボタンと同じ高さ帯にタイトルを中央配置 */
  padding: 8px 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05); /* 境界線を薄く追加 */
  z-index: 10;
}
.photo-modal .modal-title {
  margin: 0 auto;
  /* タイムスタンプモーダルのタイトルと同じサイズ・太さに統一 */
  font-size: 1.15rem;
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  color: #222;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

/* --- 閉じるボタン --- */
.photo-modal .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.1s;
}
@media (hover: hover) {
  .photo-modal .modal-close:hover { background: #f3f4f6; }
}

/* --- リンクボタン群 (スクロールエリア) --- */
.photo-body {
  padding: 20px 24px 24px; /* 下部余白は他モーダルと揃えて控えめに */
  display: flex;
  flex-direction: column;
  gap: 14px;
  
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ★★★ スクロールバーを常に薄く表示して、スクロール可能であることを伝える ★★★ */
.photo-body::-webkit-scrollbar {
  width: 6px;
}
.photo-body::-webkit-scrollbar-track {
  background: transparent;
}
.photo-body::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.12); /* 薄いグレーのバー */
  border-radius: 10px;
}

.photo-link-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 1.5px solid #e2e8f0; /* 枠線幅は1.5pxで統一 */
  border-radius: 16px;
  background: #ffffff;
  color: #333;
  text-decoration: none !important;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
@media (hover: hover) {
  .photo-link-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  }
}
.photo-link-icon {
  font-size: 1.5rem;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}
.photo-link-text {
  font-size: 0.95rem;
  /* モーダルタイトル「関連リンク集」と同じ書体・太さに統一 */
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  line-height: 1.4;
}

/* =================================================== */
/* ダークモード対応 */
/* =================================================== */
body.dark-mode .photo-btn {
  background: #2a2f37 !important;
  border-color: #41505f !important;
}
body.dark-mode .photo-btn i {
  color: #e7eef6 !important;
}
body.dark-mode .modal-content.photo-modal {
  background: #252c35;
  border-color: #394150;
}
body.dark-mode .photo-modal .modal-header {
  border-bottom-color: #394150;
}
body.dark-mode .photo-modal .modal-title {
  color: #ffffff;
}
body.dark-mode .photo-modal .modal-close {
  background: #2d333b;
  border-color: #394150;
  color: #a0aec0;
}
body.dark-mode .photo-link-btn {
  background: #2d333b;
  border-color: #394150;
  color: #e5ecec;
}
@media (hover: hover) {
  body.dark-mode .photo-link-btn:hover {
    background: #374151;
    border-color: #4b5563;
  }
}
body.dark-mode .photo-link-icon {
  color: #9aa4b2;
}
/* ダークモード用スクロールバー */
body.dark-mode .photo-body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
}

/* =================================================== */
/* 各カラーテーマ対応 */
/* =================================================== */
body[class*="theme-"] .photo-btn {
  background: var(--btn-bg) !important;
  border-color: var(--history-card-bd) !important;
}
body[class*="theme-"] .photo-btn i {
  color: var(--muted) !important;
}
/* ページ実効背景(--btn-bg)と同じ色にして、フィルタ画面と完全に同じトーンにする */
body[class*="theme-"] .modal-content.photo-modal {
  background: var(--btn-bg);
  border-color: var(--history-card-bd);
}
/* 区切り線は背景(--btn-bg)と同化しないよう、テーマ文字色ベースの半透明にする */
body[class*="theme-"] .photo-modal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.4); /* color-mix非対応環境用 */
  border-bottom-color: color-mix(in srgb, var(--text-color) 40%, transparent);
}
body[class*="theme-"] .photo-modal .modal-title {
  color: var(--text-color);
}
body[class*="theme-"] .photo-modal .modal-close {
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.55) !important;
  border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  color: var(--text-color) !important;
}
body[class*="theme-"] .photo-link-btn {
  background: var(--card-bg);
  border-color: transparent; /* フィルタボタンと同様に枠線なし */
  color: var(--text-color);
}
@media (hover: hover) {
  body[class*="theme-"] .photo-link-btn:hover {
    background: var(--filter-btn-active);
  }
}
body[class*="theme-"] .photo-link-icon {
  color: var(--muted);
}
/* カラーテーマ用スクロールバー */
body[class*="theme-"] .photo-body::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.3);
}

/* =================================================== */
/* ★★★ 公開日時・動画時間のテキスト被り回避＆自動縮小 ★★★ */
/* =================================================== */
.episode-item .episode-meta {
  display: flex !important;
  flex-direction: column;
  width: 100% !important;
  box-sizing: border-box !important; 
  
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  
  /* ★修正: 右下のボタン類と被らないように【確実な】余白を確保
     （カードの右paddingを10pxに詰めた分、+6pxしてボタンとの距離は従来どおり） */
  padding-right: 44px !important; /* お気に入りボタン(☆)のみ: ボタン幅34px + 余白10px */
}
.episode-item .episode-meta.has-photo-btn {
  padding-right: 86px !important; /* リンク+★: 34+8+34 + 余白10px */
}

/* 各行（公開日時 / 動画時間）のラッパー */
.meta-one-line {
  /* ★修正: blockにして幅を100%に固定し、絶対に改行させない指定を追加 */
  display: block; 
  width: 100%;
  white-space: nowrap !important; 
  overflow: hidden;
}

/* 限界まで文字を縮小しても入り切らない場合は「...」で省略する */
.meta-one-line.needs-ellipsis {
  text-overflow: ellipsis !important;
}

/* =================================================== */
/* ★★★ 誤タップ防止：ボタンのタッチ判定エリア拡大 ★★★ */
/* =================================================== */

/* リンクボタンとお気に入りボタンの周囲に「透明なタップ領域」を設けて、
   背後の動画リンク(aタグ)を誤って押してしまうのを防ぎます。 */
.fav-btn::after,
.photo-btn::after {
  content: '';
  position: absolute;
  
  /* 上下は指で押しやすいように大きめに広げる (+14pxずつ) */
  top: -14px;
  bottom: -14px;
  
  /* 左右は2つのボタンの判定が重ならない程度に広げる (+5pxずつ) */
  left: -5px;
  right: -5px;
  
  /* タップ判定の形状を少し丸くする */
  border-radius: 50px;
}

/* ======================================================================== */
/* ===== X(Twitter) ブラックテーマ風 ダークモード完全上書き設定 (統合版) ===== */
/* ======================================================================== */

/* --- 1. 全体と各種パーツの背景色を完全な黒（ピュアブラック）に --- */
body.dark-mode,
body.dark-mode .sticky-search-area,
body.dark-mode .search-card,
body.dark-mode .filters-bar,
body.dark-mode #filterDrawer,
body.dark-mode .episode-item,
body.dark-mode .modal-content.history-modal,
body.dark-mode .history-item,
body.dark-mode .modal-header,
body.dark-mode #aboutModalContent,
body.dark-mode .autocomplete,
body.dark-mode .modal-content.photo-modal,
body.dark-mode .photo-link-btn,
body.dark-mode .pwa-bottom-nav,
body.dark-mode .history-toggle,
body.dark-mode #loading-screen,
body.dark-mode #theme-toggle-btn,
body.dark-mode .results-count-under-bar,
body.dark-mode .dym-alert-content,
body.dark-mode #filterDrawer .drawer-footer {
  background-color: #000000 !important;
  background: #000000 !important;
}

/* サムネイルのフォールバック背景色 */
body.dark-mode .thumbnail {
  background-color: #16181c !important;
}

/* --- 2. 境界線（ボーダー）の基本色とレイアウトズレ防止 --- */
/* 一般的なパーツの境界線 */
body.dark-mode .episode-item,
body.dark-mode .modal-content.history-modal,
body.dark-mode .history-item,
body.dark-mode #aboutModalContent,
body.dark-mode .autocomplete,
body.dark-mode .modal-content.photo-modal,
body.dark-mode .photo-link-btn,
body.dark-mode .history-toggle {
  border-color: #2f3336 !important;
  border: 1px solid #2f3336 !important;
  box-shadow: none !important;
}

/* ガタつき（レイアウトズレ）防止用の個別枠線設定 */
body.dark-mode .sticky-search-area {
  border-color: #2f3336 !important;
  border-style: solid !important;
  border-width: 0 0 1.5px 0 !important;
  box-shadow: none !important;
}
body.dark-mode #filterDrawer {
  border-color: #2f3336 !important;
  border-style: solid !important;
  border-width: 0 1px 1px 1px !important;
}
body.dark-mode .modal-header {
  border-color: #2f3336 !important;
  border-style: solid !important;
  border-width: 0 0 1px 0 !important;
}
body.dark-mode .pwa-bottom-nav {
  border-color: #2f3336 !important;
  border-style: solid !important;
  border-width: 1px 0 0 0 !important;
}
body.dark-mode #theme-toggle-btn {
  border-color: #2f3336 !important;
  border-style: solid !important;
  border-width: 2px !important;
}

/* --- 3. 検索ボックスとセレクトボックス --- */
body.dark-mode .searchbox-input,
body.dark-mode .form-select.searchbox-select {
  background-color: #000000 !important;
  border: 1px solid #2f3336 !important;
  color: #e7e9ea !important;
}
body.dark-mode .searchbox-input:focus {
  background-color: #000000 !important; /* Xの青色アクセント */
}

/* --- 4. テキスト・アイコンカラーの調整 --- */
body.dark-mode {
  color: #e7e9ea !important; /* Xの基本テキストカラー */
}
body.dark-mode .filter-title,
body.dark-mode .history-year,
body.dark-mode .history-item .date,
body.dark-mode .history-sticky-year,
body.dark-mode #aboutModalContent a,
body.dark-mode .results-count-under-bar,
body.dark-mode .photo-modal .modal-title,
body.dark-mode .dym-alert-main {
  color: #e7e9ea !important;
}

/* サブテキスト（メタ情報など）は少し暗いグレーに */
body.dark-mode .episode-meta,
body.dark-mode .history-item .desc,
body.dark-mode .about-body,
body.dark-mode .photo-link-icon,
body.dark-mode .autocomplete-item .type,
body.dark-mode .site-footer,
body.dark-mode .site-footer a {
  color: #71767b !important;
}

/* パレットアイコン */
body.dark-mode #theme-toggle-btn,
body.dark-mode #theme-toggle-btn i {
  color: #ffffff !important;
}

/* --- 5. ボタン類（通常時） --- */
body.dark-mode .guest-button,
body.dark-mode .btn-corner,
body.dark-mode .btn-year,
body.dark-mode .page-btn,
body.dark-mode .share-btn,
body.dark-mode .drawer-close-btn,
body.dark-mode .photo-btn,
body.dark-mode .fav-btn,
body.dark-mode .fav-home-btn,
body.dark-mode #filterToggleBtn,
body.dark-mode #favOnlyToggleBtn,
body.dark-mode #randomBtn,
body.dark-mode .reset-btn,
body.dark-mode .dym-word-btn,
body.dark-mode #latestBtn {
  background-color: #000000 !important;
  border: 1px solid #2f3336 !important; /* 暗いグレーの枠線に統一 */
  color: #e7e9ea !important;
}

/* タイムスタンプボタン */
body.dark-mode .ts-btn {
  background-color: #16181c !important;
  color: #ffffff !important; /* 白色に変更 */
  border-color: #2f3336 !important;
}

/* --- 6. ホバーエフェクト（マウスオーバー時） --- */
@media (hover: hover) {
  /* エピソードカードと各種ボタンのホバー色を完全統一 */
  body.dark-mode .episode-item:hover,
  body.dark-mode #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body.dark-mode #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body.dark-mode #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]):hover,
  body.dark-mode .guest-button:hover,
  body.dark-mode .btn-corner:hover,
  body.dark-mode .btn-year:hover,
  body.dark-mode .page-btn:not(.active):hover,
  body.dark-mode .share-btn:hover,
  body.dark-mode #filterDrawer .drawer-close-btn:hover,
  body.dark-mode .drawer-close-btn:hover,
  body.dark-mode .photo-link-btn:hover,
  body.dark-mode .photo-btn:hover,
  body.dark-mode .fav-home-btn:hover,
  body.dark-mode .dym-word-btn:hover,
  body.dark-mode .autocomplete-item:hover {
    background-color: #16181c !important; /* 少し明るい黒 */
    border-color: #536471 !important; /* グレーの枠線 */
    color: #e7e9ea !important;
  }

  /* コントロールボタンのホバー: 全カラー統一パターン
     （控えめな背景変化＋枠線強調・文字色不変。旧: 白黒反転） */
  body.dark-mode #filterToggleBtn:not([aria-expanded="true"]):hover,
  body.dark-mode #favOnlyToggleBtn:not([aria-pressed="true"]):hover,
  body.dark-mode #randomBtn:hover,
  body.dark-mode .reset-btn:hover {
    background-color: #16181c !important;
    color: #e7e9ea !important;
    border-color: #536471 !important;
  }
}

/* --- 7. アクティブ・選択中の状態 --- */
body.dark-mode .guest-button[aria-pressed="true"],
body.dark-mode .guest-button.active,
body.dark-mode .btn-corner[aria-pressed="true"],
body.dark-mode .btn-corner.active,
body.dark-mode .btn-year[aria-pressed="true"],
body.dark-mode .btn-year.active,
body.dark-mode .page-btn.active,
body.dark-mode #filterToggleBtn[aria-expanded="true"],
body.dark-mode #favOnlyToggleBtn[aria-pressed="true"] {
  background-color: #e7e9ea !important; /* 背景を白に */
  color: #0f1419 !important; /* 文字色を黒に */
  border-color: #e7e9ea !important;
}

/* お気に入り(☆)ボタンのアクティブ状態 */
body.dark-mode #results .episode-item .fav-btn.active {
  background-color: #000000 !important;
  border-color: #ffd24e !important;
}
body.dark-mode #results .episode-item .fav-btn.active i {
  color: #ffd24e !important; /* 星らしい黄色 */
}

body.dark-mode .history-timeline::before {
  background: #2f3336 !important;
}

body.dark-mode .clear-search-btn {
  background-color: #2f3336 !important;
  color: #e7e9ea !important;
}
@media (hover: hover) {
  body.dark-mode .clear-search-btn:hover {
    background-color: #536471 !important;
  }
}

/* ======================================================================== */
/* ===== 最終修正：並び替えボタンのズレ解消 ＆ 再生リストボタン色統一 ===== */
/* ======================================================================== */

/* 1. フィルタ欄の不要なグレー枠線と検索カードの枠線切れを修正 */
body.dark-mode #filterDrawer {
  border: none !important;
  box-shadow: none !important;
}
body.dark-mode .search-card {
  border: none !important;
  box-shadow: inset 0 0 0 1px #2f3336 !important; 
}

/* 2. 左に寄る原因となっていた余白を消去し、ホワイトカラーと全く同じ設定に強制統一 */
body.dark-mode .form-select.searchbox-select,
body[class*="theme-"] .form-select.searchbox-select {
  padding: 0.18em 1.7em 0.18em 1em !important; /* ホワイトカラーと同じ上下左右の余白 */
  height: 2.5em !important;
  line-height: normal !important;
  text-align-last: center !important; /* 中央揃え */
}

/* 3. 検索キーワード入力欄もホワイトカラーと統一 */
/* ★右paddingは72pxを維持すること。1emにすると長いキーワードの文字が
   ✕ボタン・虫眼鏡ボタンの下に潜り込んで崩れて見える（ライトは別途72px指定済み） */
body.dark-mode .searchbox-input,
body[class*="theme-"] .searchbox-input {
  padding: 0.32em 72px 0.32em 1em !important;
  height: 2.3em !important;
  line-height: normal !important;
}

/* 4. 再生リスト作成ボタンをダークモードでも赤（YouTube色）に */
/* （ホワイトカラーは設定済み。他のテーマカラーは元の色に戻す） */
body.dark-mode #latestBtn {
  background-color: #e52d27 !important;
  color: #ffffff !important;
  border-color: #e52d27 !important;
}

/* マウスを乗せた時の色（少し暗い赤） */
@media (hover: hover) {
  body.dark-mode #latestBtn:hover {
    background-color: #c21d19 !important;
    color: #ffffff !important;
    border-color: #c21d19 !important;
  }
}

/* ======================================================================== */
/* ===== 追加修正：「0件」表示 ＆ ひすとりーの丸マークの色変更 ===== */
/* ======================================================================== */

/* 1. 「一致する回が見つかりませんでした」のエリアを黒背景・枠線付きに変更 */
body.dark-mode #results .no-results {
  background: #000000 !important;
  background-color: #000000 !important;
  color: #e7e9ea !important;
  border: 1px solid #2f3336 !important;
  box-shadow: none !important;
}

/* 2. 「ひすとりー」モーダル内のタイムラインの丸マークを白色に変更 */
body.dark-mode .history-item::before {
  background: #ffffff !important;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2) !important;
}

/* ======================================================================== */
/* ===== 追加修正：モーダルの閉じる(×)ボタンをダークモードに馴染ませる ===== */
/* ======================================================================== */

body.dark-mode #aboutCloseBtn,
body.dark-mode #historyModal .modal-close,
body.dark-mode .photo-modal .modal-close {
  background: #000000 !important;
  color: #e7e9ea !important;
  border: 1px solid #2f3336 !important;
  box-shadow: none !important;
}

@media (hover: hover) {
  body.dark-mode #aboutCloseBtn:hover,
  body.dark-mode #historyModal .modal-close:hover,
  body.dark-mode .photo-modal .modal-close:hover {
    background: #16181c !important;
  }
}

/* ======================================================================== */
/* ===== 追加修正：検索入力欄のフォーカス色とプレースホルダーの文字色 ===== */
/* ======================================================================== */

/* 1. キーワード入力欄を選択（フォーカス）した時の枠線を「青」から「白」に変更 */
body.dark-mode .searchbox-input:focus {
  border-color: #ffffff !important;
}

/* 2. キーワード入力欄の薄い文字（プレースホルダー）を「薄い白色」に変更 */
body.dark-mode .searchbox-input::placeholder {
  color: rgba(255, 255, 255, 0.5) !important; /* 真っ白を半透明にして薄い白を表現 */
  opacity: 1 !important; /* ブラウザ仕様で透明度が二重にかかるのを防ぐ */
}

/* （※一部のブラウザで確実に色を適用するための予備設定） */
body.dark-mode .searchbox-input::-webkit-input-placeholder {
  color: rgba(255, 255, 255, 0.5) !important;
}
body.dark-mode .searchbox-input::-moz-placeholder {
  color: rgba(255, 255, 255, 0.5) !important;
}

/* ======================================================================== */
/* ===== 追加修正：検索エリアのボタンと入力欄をエピソードカードに統一 ===== */
/* ======================================================================== */

/* --- 1. ホワイトカラー（ライトモード）の枠線太さと角丸 --- */
body:not(.dark-mode):not([class*="theme-"]) .searchbox-input,
body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn,
body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn,
body:not(.dark-mode):not([class*="theme-"]) #randomBtn,
body:not(.dark-mode):not([class*="theme-"]) .reset-btn {
  border-width: 1px !important; /* エピソードカードと同じ太さ */
  border-radius: var(--radius, 11px) !important; /* エピソードカードと同じ角丸(11px) */
}

/* ホワイトカラーの「通常時」の枠線色（入力・ON状態を保護して除外） */
body:not(.dark-mode):not([class*="theme-"]) .searchbox-input:not(:focus),
body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn:not([aria-expanded="true"]),
body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn:not(.active):not([aria-pressed="true"]),
body:not(.dark-mode):not([class*="theme-"]) #randomBtn,
body:not(.dark-mode):not([class*="theme-"]) .reset-btn {
  border-color: #d3d8e0 !important; /* エピソードカードと同じ少し濃いグレー */
}

/* --- 2. ダークカラーの枠線太さと角丸 --- */
body.dark-mode .searchbox-input,
body.dark-mode #filterToggleBtn,
body.dark-mode #favOnlyToggleBtn,
body.dark-mode #randomBtn,
body.dark-mode .reset-btn {
  border-width: 1px !important; /* ダーク時のエピソードカードと同じ太さ */
  border-radius: var(--radius, 11px) !important; /* 角丸を統一 */
}

/* ダークカラーの「通常時」の枠線色（入力・ON状態を保護して除外） */
body.dark-mode .searchbox-input:not(:focus),
body.dark-mode #filterToggleBtn:not([aria-expanded="true"]),
body.dark-mode #favOnlyToggleBtn:not(.active):not([aria-pressed="true"]),
body.dark-mode #randomBtn,
body.dark-mode .reset-btn {
  border-color: #2f3336 !important; /* ダーク時のエピソードカードと同じX風グレー */
}

/* ======================================================================== */
/* ===== 追加修正：並び替え(セレクトボックス)のデザインを他ボタンと統一 ===== */
/* ======================================================================== */

/* ホワイトカラー（ライトモード）時の並び替えボタンのデザイン統一 */
body:not(.dark-mode):not([class*="theme-"]) .form-select.searchbox-select {
  background-color: #ffffff !important; /* 背景色をピュアな白に統一 */
  color: #22272e !important;            /* 文字色を統一 */
  border-width: 1px !important;         /* 枠線の太さを1pxに統一 */
  border-color: #d3d8e0 !important;     /* 枠線の色を少し濃いグレーに統一 */
  border-radius: var(--radius, 11px) !important; /* 角丸を統一 */
}

/* 並び替えボタンを選択（フォーカス）した時のスタイル統一 */
body:not(.dark-mode):not([class*="theme-"]) .form-select.searchbox-select:focus {
  border-color: #000000 !important;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1) !important;
}

/* ======================================================================== */
/* ===== 追加修正：フィルターの「閉じる」ボタンをダークモード色に統一 ===== */
/* ======================================================================== */
body.dark-mode #filterDrawer .drawer-close-btn {
  background-color: #000000 !important; /* 背景色を真っ黒に統一 */
  color: #e7e9ea !important;            /* 文字色を統一 */
  border: 1px solid #2f3336 !important; /* 枠線を他のボタンと統一 */
  box-shadow: none !important;
}

/* マウスホバー・タップ時の色も他のボタンに合わせる */
@media (hover: hover) {
  body.dark-mode #filterDrawer .drawer-close-btn:hover,
  body.dark-mode #filterDrawer .drawer-close-btn:focus {
    background-color: #16181c !important;
    border-color: #536471 !important;
  }
}

/* ======================================================================== */
/* ===== 追加修正：フィルターの「閉じる」ボタンを他のボタンと統一（ライトモード） ===== */
/* ======================================================================== */
body:not(.dark-mode):not([class*="theme-"]) #filterDrawer .drawer-close-btn {
  border-width: 1px !important;         /* ダークモードや他のボタンと同じ1pxに統一 */
  border-color: #d3d8e0 !important;     /* 他のボタンと同じ枠線色に統一 */
  border-radius: var(--radius, 11px) !important; /* 角丸も他のボタンと統一 */
}

/* ======================================================================== */
/* ===== 【最終確定版】スマホ・iPad版のフィルタ背景色をPC版と完全統一 ===== */
/* ======================================================================== */
@media screen and (max-width: 1069px) {
  /* 1. ホワイトカラー（ライトモード） */
  /* PC版と同じピュアな白寄りの明るい色に強制統一 */
  html body:not(.dark-mode):not([class*="theme-"]) div#filterDrawer {
    background: var(--bg-color, #f9fafe) !important;
    background-color: var(--bg-color, #f9fafe) !important;
  }
  
  /* 2. カラーテーマ全般（ピンク・ブルーなど） */
  /* PC版で実際に透けて見えている「一番明るい背景色（--btn-bg）」に合わせる */
  html body[class*="theme-"] div#filterDrawer {
    background: var(--btn-bg) !important;
    background-color: var(--btn-bg) !important;
    border-color: var(--btn-bg) !important;
  }
  
  /* 3. ダークモード（ブラック統一） */
  html body.dark-mode div#filterDrawer {
    background: #000000 !important;
    background-color: #000000 !important;
  }
}

/* ======================================================================== */
/* ===== 追加修正：PWA版下部ナビゲーションをPC版ダークカラーと完全統一 ===== */
/* ======================================================================== */

/* 1. 通常ボタンのアイコンと文字色をPC版の白系グレーに統一 */
html.is-standalone body.dark-mode .pwa-bottom-nav-btn {
  color: #e7e9ea !important;
}

/* 2. 中央の「カラー」丸ボタンの背景・枠線・アイコン色をPC版ボタンに統一 */
html.is-standalone body.dark-mode #pwa-theme-toggle-btn {
  background-color: #000000 !important;
  border-color: #2f3336 !important;
  box-shadow: none !important;
}
html.is-standalone body.dark-mode #pwa-theme-toggle-btn i {
  color: #e7e9ea !important;
}

/* 3. 中央の「カラー」丸ボタンがアクティブ(開いている)時の色を白黒反転（PC版と同じ） */
html.is-standalone body.dark-mode #pwa-theme-toggle-btn.is-active {
  background-color: #e7e9ea !important;
  border-color: #e7e9ea !important;
}
html.is-standalone body.dark-mode #pwa-theme-toggle-btn.is-active i {
  color: #0f1419 !important;
}

/* 4. 通常ボタンがアクティブ(ON)になった時は真っ白にして強調 */
html.is-standalone body.dark-mode .pwa-bottom-nav-btn.is-active {
  color: #ffffff !important;
}

/* ======================================================================== */
/* ===== 追加修正：スマホ・iPad版でのフィルタ上部の隙間(描画誤差)を埋める ===== */
/* ======================================================================== */
@media (max-width: 1069px) {
  #filterDrawer {
    /* サブピクセル描画による1pxの隙間を埋めるため、少しだけ上に食い込ませる */
    margin-top: -1px !important; 
  }
}

/* ======================================================================== */
/* ===== 追加修正：ダークモード時のカラーパレット背景色を黒に統一 ===== */
/* ======================================================================== */

body.dark-mode .floating-panel {
  background-color: rgba(0, 0, 0, 0.85) !important; /* 黒系の半透明に */
  border-color: #2f3336 !important; /* 枠線を他のダークモードUIと統一 */
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.6) !important; /* 影を濃くして馴染ませる */
}

/* ======================================================================== */
/* ===== 追加修正：全テーマで検索エリア外側の枠線と背景色を完全に消去 ===== */
/* ===== （＋表示数との隙間を最適化）                                 ===== */
/* ======================================================================== */

.search-card,
body.dark-mode .search-card,
body[class*="theme-"] .search-card {
  background: transparent !important; /* 背景色を完全に透明化 */
  border: none !important;            /* 枠線を消去 */
  box-shadow: none !important;        /* 影や疑似的な枠線を消去 */
  padding-bottom: 0 !important;       /* ★追加：検索カード下部の余分な隙間を詰める */
}

/* ======================================================================== */
/* ===== 追加修正：検索エリア・表示数・フィルタタグ間の縦余白を最適化 ===== */
/* ======================================================================== */

/* 1. 検索ボタン群の下の余白を削る */
.search-card {
  padding-bottom: 0 !important;
}

/* 2. 表示数（XX件）の上下の余白をバランス良く整える */
.results-count-under-bar {
  padding-top: 6px !important;    /* 上のボタン群との間隔 */
  padding-bottom: 2px !important; /* 下のフィルタタグとの間隔 */
}

/* 3. フィルタタグエリアの上余白を詰めて一体感を出す */
.filters-bar {
  padding-top: 0 !important;
  padding-bottom: 6px !important;
}


/* ===================================================
   タイムスタンプ登録モーダル（お気に入り後継機能）
   PC/iPad: 中央モーダル / スマホ: ボトムシート
   =================================================== */
.modal-content.ts-modal {
  background: #ffffff;
  width: min(480px, 92vw);
  /* 高さは内容量によらず固定（スマホの全画面表示と同じ感覚に統一）。
     登録が少なくてもモーダルの縦幅が変わらず、リストが長い時は .ts-body だけがスクロールする */
  height: 84vh;
  max-height: 84vh;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  position: relative;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 15px 50px -12px rgba(0,0,0,0.2);
  overflow: hidden;
}
.ts-modal .modal-header {
  box-sizing: border-box; /* min-heightにpaddingを含め、×ボタン(top:14px+38px)と同じ帯で中央揃えにする */
  position: relative;
  flex-shrink: 0;
  min-height: 66px; /* 閉じるボタン(top:14px + 38px + 14px)と同じ帯 */
  padding: 8px 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 10;
}
.ts-modal .modal-title {
  margin: 0 auto;
  font-size: 1.15rem;
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  color: #222;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
.ts-modal .modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #e5e7eb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.1s;
}
@media (hover: hover) {
  .ts-modal .modal-close:hover { background: #f3f4f6; }
}

.ts-body {
  padding: 14px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0; /* フッター固定時にこの領域だけがスクロールするように */
  overflow-y: auto;
  /* スクロールバー領域を常に確保し、件数の増減でバーが出たり消えたりしても
     リスト行の横幅が変わらないようにする（オーバーレイスクロールバー環境では
     確保幅0のまま＝影響なし）。右paddingの微調整はJS側の実測補正が行う */
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
.ts-body::-webkit-scrollbar { width: 6px; }
.ts-body::-webkit-scrollbar-track { background: transparent; }
.ts-body::-webkit-scrollbar-thumb { background-color: rgba(0,0,0,0.12); border-radius: 10px; }

/* 下部固定エリア（編集/すべて削除・確認パネル・ヒント）。
   リストが長いときは .ts-body 側だけがスクロールし、ここは常に見える */
.ts-footer {
  flex-shrink: 0;
  margin-top: auto; /* 内容が少なくてもモーダル最下部に張り付ける */
  padding: 12px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.ts-footer[hidden] { display: none !important; } /* 編集中はフッターごと隠す */

/* --- エピソードカード（トップ画面の .episode-item をそのまま表示するコンテナ） ---
   ヘッダー直下に固定し、スクロールするのはその下の .ts-body（リスト）だけにする */
.ts-episode-card {
  list-style: none;
  flex-shrink: 0;
  margin: 14px 20px 0; /* 左右は .ts-body の横paddingと揃える */
  padding: 0 0 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06); /* スクロール領域との区切り */
}
.ts-episode-card[hidden] { display: none; }
/* 文字サイズ・余白は #results h5.mb-1 系の各ルールに .ts-episode-card を併記して完全一致させている */

/* --- 入力エリア（「編集」タップ時のみ表示。複数行で一括登録） --- */
.ts-add-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ts-add-area[hidden] { display: none !important; }
.ts-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 16px; /* iOSの自動ズーム防止のため16px以上 */
  line-height: 1.6;
  font-family: inherit;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  color: #111827;
  outline: none;
  resize: none;           /* 高さはJSで内容に合わせて自動調整 */
  overflow-y: auto;
  /* ★変更: max-height の152px固定上限は撤去。実際の上限はJS(tsInputMaxHeight)が
     モーダルの空きスペースから算出する（スマホの編集モードではエピソードカードを
     非表示にした分だけ広く使える）。CSS側は保険として画面高の80%までに制限 */
  max-height: 80dvh;
  transition: border-color 0.2s, background 0.2s;
}
.ts-input:focus {
  border-color: #64748b;
  background: #ffffff;
}
.ts-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
/* 入力欄の下に並ぶボタンは同じ横幅で分け合う
   （flex-basis:0%だと内容量の差で幅がわずかにズレるため、50%基準で完全均等にする） */
.ts-actions > button { flex: 1 1 50%; min-width: 0; }
.ts-cancel-btn {
  padding: 8px 16px;
  min-height: 39px; /* フィルタボタンと同じ縦幅 */
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: transparent;
  color: #6b7280;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}
@media (hover: hover) {
  .ts-cancel-btn:hover { background: #f3f4f6; }
}
/* 入力欄の右上に重ねる小型コピーボタン（下書き＝登録済み一覧のコピー用） */
.ts-input-wrap { position: relative; }
.ts-input-wrap .ts-input { padding-right: 52px; } /* ボタンの下に文字が潜らないように */
.ts-copy-btn {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 38px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  color: #6b7280;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
@media (hover: hover) {
  .ts-copy-btn:hover { background: #f3f4f6; }
}
.ts-copy-btn:disabled {
  opacity: 0.45;
  pointer-events: none; /* ホバー演出も無効にする */
}
.ts-input-error { animation: tsShake 0.4s ease; border-color: #ef4444 !important; }
@keyframes tsShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.ts-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 39px; /* フィルタボタンと同じ縦幅 */
  border: 1.5px solid #000000;
  border-radius: 14px;
  background: #000000;
  color: #ffffff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ts-add-btn:active { transform: scale(0.96); }
@media (hover: hover) {
  .ts-add-btn:hover { background: #1f2937; border-color: #1f2937; }
}
/* テーマ色に埋もれないよう、赤地×白文字のボックスで表示する */
.ts-error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.ts-error[hidden] { display: none; } /* display:flex が hidden 属性に勝つのを防ぐ */
.ts-error-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  overflow-wrap: anywhere;
}

/* --- まとめて編集ボタン（登録ボタンと横並び・同形状） --- */
.ts-edit-all-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  min-height: 39px; /* フィルタボタンと同じ縦幅 */
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  color: #374151;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .ts-edit-all-btn:hover { background: #f3f4f6; border-color: #cbd5e1; }
}

/* --- 登録済みリスト（入力エリアとの間に区切り線） --- */
.ts-list[hidden] { display: none; } /* display:flex がhidden属性に勝つのを防ぐ */
.ts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  /* カード下の区切り線（.ts-episode-card側）があるため、ここでは線を引かない */
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ts-item {
  display: flex;
  align-items: stretch;
  gap: 8px;
  /* ★撤去: ここにあった content-visibility: auto（画面外行の描画省略）は、
     iOSで高速スクロール時に行の描画が間に合わず「途切れるように表示される」
     原因になっていたため削除した。行は軽量なので省略なしでも十分速い。 */
}
.ts-play {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px; /* 縦幅を少し詰める（旧12px） */
  border: 1.5px solid #e2e8f0; /* 枠線幅は1.5pxで統一 */
  border-radius: 14px;
  background: #ffffff;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ts-play:active { transform: scale(0.985); }
@media (hover: hover) {
  .ts-play:hover { background: #f8fafc; border-color: #cbd5e1; }
}
.ts-time {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 4.6em; /* 3:00 と 12:34 などで幅を揃え、メモの開始位置を揃える */
  padding: 4px 12px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.85rem;
}
.ts-time i { font-size: 0.7rem; }
.ts-label {
  min-width: 0;
  font-size: 0.92rem;
  color: #374151;
  overflow-wrap: anywhere;
}
.ts-label-none { color: #6b7280; }

/* モーダル内のUIテキストをタイトルと同じ書体・太さ（700）に統一する */
.ts-modal .ts-add-btn,
.ts-modal .ts-cancel-btn,
.ts-modal .ts-copy-btn,
.ts-modal .ts-edit-all-btn,
.ts-modal .ts-clear-all-btn,
.ts-modal .ts-clear-confirm,
.ts-modal .ts-time,
.ts-modal .ts-label,
.ts-modal .ts-empty,
.ts-modal .ts-error,
.ts-modal .ts-hint {
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
}
.ts-delete {
  flex-shrink: 0;
  width: 44px;
  border: 1.5px solid #fecaca;
  border-radius: 14px;
  background: #fff1f2;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s, transform 0.1s;
}
.ts-delete:active { transform: scale(0.94); }
@media (hover: hover) {
  .ts-delete:hover { background: #fee2e2; }
}
/* --- リスト下の操作行（コピー / すべて削除を同じ横幅で並べる） --- */
.ts-list-actions {
  display: flex;
  gap: 8px;
}
.ts-list-actions[hidden] { display: none; }
.ts-list-actions > button { flex: 1 1 50%; min-width: 0; }
.ts-list-actions > button[hidden] { display: none; } /* 0件時は「すべて削除」だけ隠す */
.ts-clear-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 39px; /* フィルタボタンと同じ縦幅 */
  border: 1.5px solid #fecaca;
  border-radius: 14px;
  background: #fff1f2;
  color: #dc2626;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ts-clear-all-btn:active { transform: scale(0.98); }
@media (hover: hover) {
  .ts-clear-all-btn:hover { background: #fee2e2; border-color: #fca5a5; }
}

/* --- すべて削除の確認パネル（サイト内confirm） --- */
.ts-clear-confirm {
  border: 1.5px solid #fecaca;
  border-radius: 14px;
  background: #fff1f2;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ts-clear-confirm[hidden] { display: none; }
.ts-clear-confirm-text {
  margin: 0;
  color: #b91c1c;
  font-size: 0.88rem;
  text-align: center;
  line-height: 1.6;
}
/* スマホ（狭い画面）では「よろしいですか？」を改行して2行で綺麗に見せる */
@media (max-width: 600px) {
  .ts-clear-confirm-q { display: block; }
}
.ts-clear-confirm-actions { display: flex; gap: 8px; }
.ts-clear-confirm-actions > button { flex: 1; }
.ts-clear-cancel-btn {
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  color: #374151;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
@media (hover: hover) {
  .ts-clear-cancel-btn:hover { background: #f3f4f6; }
}
.ts-clear-ok-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: none;
  border-radius: 12px;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.ts-clear-ok-btn:active { transform: scale(0.97); }
@media (hover: hover) {
  .ts-clear-ok-btn:hover { background: #b91c1c; }
}

.ts-empty {
  list-style: none;
  text-align: center;
  color: #6b7280;
  font-size: 0.92rem;
  padding: 22px 0;
  display: flex;
  flex-direction: column; /* 1行目: アイコン+本文 / 2行目: 登録方法の案内 */
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.ts-empty-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ts-empty-sub {
  font-size: 0.8rem;
  opacity: 0.85;
}
.ts-hint[hidden] { display: none !important; } /* 編集中は一覧向けのヒント文を隠す */
.ts-hint {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: #6b7280;
  text-align: center;
  line-height: 1.7;
}

/* --- ★ボタンの件数バッジ（.fav-btn は元々 position:absolute なので基準にできる） --- */
.fav-count {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #f5b301; /* お気に入り★と同じゴールドで統一 */
  color: #2b2b2b;
  font-family: 'Impact Numbers', fot-udkakugoc80-pro, sans-serif; /* 件数もサイト共通の数字フォントで表示 */
  font-size: 0.72rem;
  font-weight: normal;
  letter-spacing: 0.02em;
  line-height: 17px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* --- PC/iPad: 入力欄は内容に合わせて伸び、上限はモーダル下端まで ---
   最初はスマホと同じ3行程度で表示し、入力が増えるとキャンセル/保存ボタンごと
   下がっていき、ボタンがモーダル下部に達する高さで打ち止め（以降は内部スクロール）。
   上限値はJS（tsInputMaxHeight）が .ts-body の空きスペースから算出する */
@media (min-width: 601px) {
  .ts-modal .ts-body { flex: 1 1 auto; }
  /* 入力欄とキャンセル/保存ボタンの間隔は .ts-add-area の gap(8px) のままにして
     スマホ版と同じ見た目に揃える */
  /* スマホ向けの152px上限を外す（実際の上限はJSが算出） */
  .ts-input { max-height: none; }
}

/* --- スマホ: ボトムシート化（キーボードと相性の良い下部配置） --- */
@media (max-width: 600px) {
  #tsModal { align-items: flex-end; }
  /* スマホは最初から全画面表示（キーボード表示時の高さ変化をなくし挙動を安定させる） */
  .modal-content.ts-modal {
    /* 100dvh指定は端末やアドレスバーの状態によって実際の画面高さとズレ、
       上に隙間が出ることがある（一部iOS等）。ビューポートの四辺に直接
       固定すれば、単位の解釈差に関係なく常に全画面になる */
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    height: auto;
    max-height: none;
    border-radius: 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
    /* ★修正: 以前はヘッダーのpadding-topでステータスバーを避けていたが、
       ヘッダー基準で absolute 配置の×ボタン(top:14px)だけが上に取り残されて
       ステータスバーに隠れ、タイトル行とずれて見えた。セーフエリア分の余白は
       モーダル本体に持たせ、ヘッダー・タイトル・×ボタンが常に一体で下がるようにする */
    padding-top: env(safe-area-inset-top, 0px);
  }

  /* 入力中（コンポーズモード）: リスト・下部固定エリア・エピソードカードを畳み、
     入力欄を画面上部へ。カードまで表示すると入力が長い時（自動リサイズで最大6行）に
     キャンセル/保存ボタンがキーボードに沈んで押せなくなるため、入力中は畳む。
     どの回への登録かはヘッダーの「#108 タイムスタンプ」表記で確認できる。 */
  .ts-typing .ts-list,
  .ts-typing .ts-footer,
  .ts-typing .ts-episode-card {
    display: none !important;
  }
}

/* --- ダークモード（サイト共通の純黒パレットに統一） --- */
/* 枠線なし: スマホでは全画面シートになるため、枠線があると画面の外周に線が見えてしまう */
body.dark-mode .modal-content.ts-modal {
  background: #000000 !important;
  border: none !important;
  box-shadow: none !important;
}
body.dark-mode .ts-modal .modal-title { color: #e7e9ea; }
body.dark-mode .ts-modal .modal-close {
  background: #000000 !important;
  color: #e7e9ea !important;
  border: 1px solid #2f3336 !important;
  box-shadow: none !important;
}
@media (hover: hover) {
  body.dark-mode .ts-modal .modal-close:hover { background: #16181c !important; }
}
body.dark-mode .ts-input { background: #000000; border-color: #2f3336; color: #e7e9ea; }
body.dark-mode .ts-input::placeholder { color: #71767b; }
body.dark-mode .ts-input:focus { border-color: #71767b; background: #000000; }
body.dark-mode .ts-cancel-btn { border-color: #2f3336; color: #71767b; }
body.dark-mode .ts-copy-btn { background: #000000; border-color: #2f3336; color: #71767b; }
@media (hover: hover) {
  body.dark-mode .ts-cancel-btn:hover, body.dark-mode .ts-copy-btn:hover { background: #16181c; }
}
/* ダークでは登録ボタンを白の反転ボタンに、時間バッジは半透明白で馴染ませる */
body.dark-mode .ts-add-btn { background: #e7e9ea; border-color: #e7e9ea; color: #0f1419; }
@media (hover: hover) {
  body.dark-mode .ts-add-btn:hover { background: #ffffff; border-color: #ffffff; }
}
body.dark-mode .ts-time { background: rgba(255, 255, 255, 0.16); color: #e7e9ea; }
body.dark-mode .ts-episode-card { border-bottom-color: #2f3336; }
body.dark-mode .ts-footer { border-top-color: #2f3336; }
body.dark-mode .ts-edit-all-btn { background: #000000; border-color: #2f3336; color: #e7e9ea; }
@media (hover: hover) {
  body.dark-mode .ts-edit-all-btn:hover { background: #16181c; border-color: #71767b; }
}
body.dark-mode .ts-play { background: #000000; border-color: #2f3336; }
@media (hover: hover) {
  body.dark-mode .ts-play:hover { background: #16181c; border-color: #71767b; }
}
body.dark-mode .ts-label { color: #e7e9ea; }
body.dark-mode .ts-label-none, body.dark-mode .ts-empty, body.dark-mode .ts-hint { color: #71767b; }
body.dark-mode .ts-delete { background: #000000; border-color: rgba(239,68,68,0.45); color: #f87171; /* 黒地で読める明るい赤 */ }
@media (hover: hover) {
  body.dark-mode .ts-delete:hover { background: rgba(239,68,68,0.15); }
}
body.dark-mode .ts-clear-all-btn { background: #000000; border-color: rgba(239,68,68,0.45); color: #f87171; /* 黒地で読める明るい赤 */ }
@media (hover: hover) {
  body.dark-mode .ts-clear-all-btn:hover { background: rgba(239,68,68,0.15); }
}
body.dark-mode .ts-clear-confirm { background: #000000; border-color: rgba(239,68,68,0.45); }
body.dark-mode .ts-clear-confirm-text { color: #f87171; }
body.dark-mode .ts-clear-cancel-btn { background: #000000; border-color: #2f3336; color: #e7e9ea; }
@media (hover: hover) {
  body.dark-mode .ts-clear-cancel-btn:hover { background: #16181c; }
}

/* --- カラーテーマ（背景=ページ実効背景の--btn-bg / ボタン=--card-bg でフィルタ画面と統一） --- */
body[class*="theme-"] .modal-content.ts-modal {
  background: var(--btn-bg);
  border-color: var(--history-card-bd);
}
/* 区切り線は背景(--btn-bg)と同化しないよう、テーマ文字色ベースの半透明にする */
body[class*="theme-"] .ts-modal .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.4); /* color-mix非対応環境用 */
  border-bottom-color: color-mix(in srgb, var(--text-color) 40%, transparent);
}
body[class*="theme-"] .ts-modal .modal-title { color: var(--text-color); }
/* ×ボタンは塗りつぶしだと浮くため、アウトライン型にして馴染ませる */
body[class*="theme-"] .ts-modal .modal-close {
  background: transparent !important;
  border: 1.5px solid rgba(255, 255, 255, 0.55) !important;
  border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  color: var(--text-color) !important;
}
/* 入力欄・ボタン類はフィルタボタンと同じ配色（--btn-bg / --history-card-bd）に
   揃えて、フィルタドロワーと同じトーンでまとまるようにする */
body[class*="theme-"] .ts-input {
  background: var(--card-bg);
  border-color: transparent; /* フィルタボタンと同様に枠線なし */
  color: var(--text-color);
}
body[class*="theme-"] .ts-input::placeholder { color: var(--muted); opacity: 0.85; }
body[class*="theme-"] .ts-input:focus { border-color: var(--text-color); background: var(--card-bg); }
body[class*="theme-"] .ts-add-btn {
  background: var(--active-filter);
  border-color: transparent;
  color: var(--active-filter-text);
}
body[class*="theme-"] .ts-play {
  background: var(--card-bg);
  border-color: transparent;
}
@media (hover: hover) {
  body[class*="theme-"] .ts-play:hover { background: var(--filter-btn-active); border-color: transparent; }
}
/* 時間バッジは行から浮かないよう、テーマの文字色を薄く敷いた半透明ピルにする */
body[class*="theme-"] .ts-time {
  background: rgba(255, 255, 255, 0.22); /* color-mix非対応ブラウザ用 */
  background: color-mix(in srgb, var(--text-color) 16%, transparent);
  color: var(--text-color);
}
body[class*="theme-"] .ts-label { color: var(--text-color); }
body[class*="theme-"] .ts-label-none,
body[class*="theme-"] .ts-empty,
body[class*="theme-"] .ts-hint { color: var(--muted); opacity: 0.85; }
/* 削除系はどのテーマでも「赤＝危険」で統一し、テーマ色に埋もれないようにする */
body[class*="theme-"] .ts-delete,
body[class*="theme-"] .ts-clear-all-btn {
  background: #fff1f2;
  border-color: transparent; /* フィルタボタンと同様に枠線なし */
  color: #dc2626;
}
body[class*="theme-"] .fav-count { background: var(--active-filter); color: var(--active-filter-text); }
body[class*="theme-"] .ts-cancel-btn { background: var(--card-bg); border-color: transparent; color: var(--text-color); }
/* コピーはカード色の入力欄の上に載るため、ひとつ明るい色で浮かせる */
body[class*="theme-"] .ts-copy-btn { background: var(--filter-btn-active); border-color: transparent; color: var(--text-color); }
@media (hover: hover) {
  body[class*="theme-"] .ts-cancel-btn:hover,
  body[class*="theme-"] .ts-copy-btn:hover { background: var(--filter-btn-active); }
}
body[class*="theme-"] .ts-episode-card {
  border-bottom-color: rgba(255, 255, 255, 0.4);
  border-bottom-color: color-mix(in srgb, var(--text-color) 40%, transparent);
}
body[class*="theme-"] .ts-footer {
  border-top-color: rgba(255, 255, 255, 0.4);
  border-top-color: color-mix(in srgb, var(--text-color) 40%, transparent);
}
/* テーマではモーダル内の枠線を全て排除（フィルタボタンと同じ枠線なしの見た目に統一） */
body[class*="theme-"] .ts-clear-confirm { border-color: transparent; }
body[class*="theme-"] .ts-episode-card .episode-item { border-color: transparent !important; }
body[class*="theme-"] .ts-edit-all-btn { background: var(--card-bg); border-color: transparent; color: var(--text-color); }
@media (hover: hover) {
  body[class*="theme-"] .ts-edit-all-btn:hover { background: var(--filter-btn-active); }
}

/* ======================================================================== */
/* ===== カラーテーマ: PCホバーの統一（背景=--filter-btn-active / 枠線1.5px表示 / 動きなし） ===== */
/* タッチ端末(スマホ/iPad)は hover:hover 判定で自動的に無効になる                  */
/* ======================================================================== */

/* ホバー時に枠線が出ても位置がズレないよう、枠線幅を1.5px(透明)で予約しておく */
body[class*="theme-"] .history-item { border-width: 1.5px !important; }

@media (hover: hover) {
  /* 通常サーフェス: 背景がひとつ明るくなり、半透明白の枠線が現れる */
  body[class*="theme-"] .ts-play:hover,
  body[class*="theme-"] .ts-edit-all-btn:hover,
  body[class*="theme-"] .ts-cancel-btn:hover,
  body[class*="theme-"] .ts-copy-btn:hover,
  body[class*="theme-"] .photo-link-btn:hover,
  body[class*="theme-"] .history-item:hover {
    background: var(--filter-btn-active) !important;
    border-color: rgba(255, 255, 255, 0.55) !important; /* color-mix非対応環境用 */
    border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  }
  /* 危険操作(赤系)は赤トーンのまま、同じ「枠線が現れる」挙動に統一 */
  body[class*="theme-"] .ts-delete:hover,
  body[class*="theme-"] .ts-clear-all-btn:hover {
    background: #fee2e2 !important;
    border-color: rgba(220, 38, 38, 0.45) !important;
  }
  /* ×ボタン: 枠線が濃くなって反応を示す */
  body[class*="theme-"] .ts-modal .modal-close:hover,
  body[class*="theme-"] .photo-modal .modal-close:hover,
  body[class*="theme-"] #historyCloseBtn:hover,
  body[class*="theme-"] #aboutCloseBtn:hover {
    background: var(--filter-btn-active) !important;
    border-color: rgba(255, 255, 255, 0.9) !important;
    border-color: color-mix(in srgb, var(--text-color) 90%, transparent) !important;
  }
}

/* ======================================================================== */
/* ===== カラーテーマ: サイト全体のPCホバー統一（最終マスタールール）          ===== */
/* 1) 通常ボタン: 背景=--filter-btn-active ＋ 半透明白の枠線 ＋ 動きなし          */
/* 2) 白アクセントボタン: 白を保ちわずかに暗く(#f0f0f0) ＋ 動きなし              */
/* 3) 危険操作(赤系)は前段の赤トーンルールを維持                                  */
/* タッチ端末は hover:hover 判定で自動的に無効                                    */
/* ======================================================================== */
@media (hover: hover) {
  body[class*="theme-"] .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] .btn-year:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] #filterDrawer .guest-button:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] #filterDrawer .btn-corner:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] #filterDrawer .btn-year:not(.active):not([aria-pressed="true"]):hover,
  body[class*="theme-"] .page-btn:not(.active):hover,
  body[class*="theme-"] .share-btn:hover,
  body[class*="theme-"] .episode-item:hover,
  body[class*="theme-"] #filterToggleBtn:not([aria-expanded="true"]):hover,
  body[class*="theme-"] #favOnlyToggleBtn:not([aria-pressed="true"]):hover,
  body[class*="theme-"] #randomBtn:hover,
  body[class*="theme-"] .reset-btn:hover,
  body[class*="theme-"] .drawer-close-btn:hover,
  body[class*="theme-"] .history-toggle:hover,
  body[class*="theme-"] .fav-btn:not(.active):hover,
  body[class*="theme-"] .photo-btn:hover,
  body[class*="theme-"] .dym-word-btn:hover,
  body[class*="theme-"] .fav-home-btn:hover,
  body[class*="theme-"] #theme-toggle-btn:hover {
    background: var(--filter-btn-active) !important;
    background-color: var(--filter-btn-active) !important;
    border-color: rgba(255, 255, 255, 0.55) !important; /* color-mix非対応環境用 */
    border-color: color-mix(in srgb, var(--text-color) 55%, transparent) !important;
  }
  /* 制御ボタンは旧ルールがホバーで文字色を反転させるため、文字色は変えないよう固定する */
  body[class*="theme-"] #filterToggleBtn:not([aria-expanded="true"]):hover,
  body[class*="theme-"] #favOnlyToggleBtn:not([aria-pressed="true"]):hover,
  body[class*="theme-"] #randomBtn:not([aria-pressed="true"]):hover,
  body[class*="theme-"] .reset-btn:not([aria-pressed="true"]):hover {
    color: var(--btn-control-text) !important;
  }
  /* 白アクセントボタン: ブランドの白を保ち、わずかに暗くして反応を示す */
  body[class*="theme-"] #latestBtn:hover,
  body[class*="theme-"] .ts-add-btn:hover,
  body[class*="theme-"] .ts-btn:hover,
  body[class*="theme-"] #filterToggleBtn[aria-expanded="true"]:hover,
  body[class*="theme-"] #favOnlyToggleBtn[aria-pressed="true"]:hover,
  body[class*="theme-"] .guest-button.active:hover,
  body[class*="theme-"] .guest-button[aria-pressed="true"]:hover,
  body[class*="theme-"] .btn-corner.active:hover,
  body[class*="theme-"] .btn-corner[aria-pressed="true"]:hover,
  body[class*="theme-"] .btn-year.active:hover,
  body[class*="theme-"] .btn-year[aria-pressed="true"]:hover,
  body[class*="theme-"] .page-btn.active:hover {
    background: #f0f0f0 !important;
    background-color: #f0f0f0 !important;
    filter: none !important;
  }
}

/* ======================================================================== */
/* ===== 全モード共通: PCホバーのマイクロインタラクション（浮き上がり+影+押し込み） ===== */
/* 色は各モードのルールに任せ、「動き」だけをここで一元管理する                       */
/* ======================================================================== */

/* 行き帰りとも滑らかに動くよう、遷移は常時（非ホバー時にも）定義しておく */
.guest-button, .btn-corner, .btn-year, .page-btn, .share-btn,
#filterToggleBtn, #favOnlyToggleBtn, #randomBtn, .reset-btn,
.drawer-close-btn, .history-toggle, .fav-btn, .photo-btn, .ts-btn,
.dym-word-btn, .fav-home-btn, #theme-toggle-btn, #latestBtn,
.photo-link-btn, .history-item, .episode-item,
.ts-play, .ts-edit-all-btn, .ts-cancel-btn, .ts-copy-btn, .ts-add-btn,
.ts-delete, .ts-clear-all-btn, .ts-clear-ok-btn, .ts-clear-cancel-btn, .fav-clear-btn,
.modal-close, #historyCloseBtn, #aboutCloseBtn {
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s cubic-bezier(0.2, 0.6, 0.3, 1),
    box-shadow 0.18s ease !important;
}

@media (hover: hover) {
  /* ホバー: 浮き上がり・影は使わず、枠線＋控えめな暗転で反応を示す（別ブロックで色付け） */
  .guest-button:hover, .btn-corner:hover, .btn-year:hover, .page-btn:hover, .share-btn:hover,
  #filterToggleBtn:hover, #favOnlyToggleBtn:hover, #randomBtn:hover, .reset-btn:hover,
  .drawer-close-btn:hover, .history-toggle:hover, .fav-btn:hover, .photo-btn:hover, .ts-btn:hover,
  .dym-word-btn:hover, .fav-home-btn:hover, #theme-toggle-btn:hover, #latestBtn:hover,
  .photo-link-btn:hover, .history-item:hover, .episode-item:hover,
  .ts-play:hover, .ts-edit-all-btn:hover, .ts-cancel-btn:hover, .ts-copy-btn:hover, .ts-add-btn:hover,
  .ts-delete:hover, .ts-clear-all-btn:hover, .ts-clear-ok-btn:hover, .ts-clear-cancel-btn:hover, .fav-clear-btn:hover,
  .modal-close:hover, #historyCloseBtn:hover, #aboutCloseBtn:hover {
    transform: none !important;
    box-shadow: none !important;
  }
  /* クリック（押し込み）: 浮かず、わずかに沈むだけの控えめな反応 */
  .guest-button:active, .btn-corner:active, .btn-year:active, .page-btn:active, .share-btn:active,
  #filterToggleBtn:active, #favOnlyToggleBtn:active, #randomBtn:active, .reset-btn:active,
  .drawer-close-btn:active, .history-toggle:active, .fav-btn:active, .photo-btn:active, .ts-btn:active,
  .dym-word-btn:active, .fav-home-btn:active, #theme-toggle-btn:active, #latestBtn:active,
  .photo-link-btn:active, .history-item:active, .episode-item:active,
  .ts-play:active, .ts-edit-all-btn:active, .ts-cancel-btn:active, .ts-copy-btn:active, .ts-add-btn:active,
  .ts-delete:active, .ts-clear-all-btn:active, .ts-clear-ok-btn:active, .ts-clear-cancel-btn:active, .fav-clear-btn:active,
  .modal-close:active, #historyCloseBtn:active, #aboutCloseBtn:active {
    transform: scale(0.985) !important;
    box-shadow: none !important;
  }

  /* お気に入りボタンはベースの枠線ルールが:not()連打で詳細度が高くホバーに勝つため、
     同等詳細度で「統一ホバーの枠線色」を適用する（ランダム/リセットと同じ見た目にする） */
  body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn:not(.active):not([aria-pressed="true"]):hover { border-color: #9aa4b2 !important; }
  body.dark-mode #favOnlyToggleBtn:not(.active):not([aria-pressed="true"]):hover { border-color: #536471 !important; }

  /* エピソードカード/ひすとりーカードは入場アニメーション(fill:both)がtransformを
     保持し続けて浮き上がりを妨げるため、ホバー中だけfillを解除する
     （アニメーション完了後なのでfill解除による見た目の変化はない） */
  .episode-item:hover,
  .history-item:hover {
    animation-fill-mode: none !important;
  }

  /* ダークモードも浮き上がり影は使わない（枠線＋暗転に統一） */
  body.dark-mode .episode-item:hover,
  body.dark-mode .history-item:hover,
  body.dark-mode .photo-link-btn:hover,
  body.dark-mode .history-toggle:hover {
    box-shadow: none !important;
  }

  /* ===== ホバーの反応を「枠線＋控えめな暗転」に統一 =====
     暗転は色に依存しない filter:brightness で一律に効かせる（白/黒/色ボタン共通）。
     テーマは既存マスターが背景=--filter-btn-active で暗転＋枠線を付けるので filter は掛けない。 */
  body:not(.dark-mode):not([class*="theme-"]) .guest-button:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-corner:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-year:hover,
  body:not(.dark-mode):not([class*="theme-"]) .page-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .share-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #randomBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .reset-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .drawer-close-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .history-toggle:hover,
  body:not(.dark-mode):not([class*="theme-"]) .fav-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .photo-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .dym-word-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .fav-home-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #theme-toggle-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #latestBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .photo-link-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .history-item:hover,
  body:not(.dark-mode):not([class*="theme-"]) .episode-item:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-play:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-edit-all-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-cancel-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-copy-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-add-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-delete:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-clear-all-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-clear-ok-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-clear-cancel-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .fav-clear-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .modal-close:hover,
  body:not(.dark-mode):not([class*="theme-"]) #historyCloseBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #aboutCloseBtn:hover {
    filter: brightness(0.95) !important; /* 控えめな暗転 */
  }
  /* ライト: 危険系以外は暗いグレーの枠線を出す（危険系は赤枠を維持） */
  body:not(.dark-mode):not([class*="theme-"]) .guest-button:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-corner:hover,
  body:not(.dark-mode):not([class*="theme-"]) .btn-year:hover,
  body:not(.dark-mode):not([class*="theme-"]) .page-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .share-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #filterToggleBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #favOnlyToggleBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #randomBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .reset-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .drawer-close-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .history-toggle:hover,
  body:not(.dark-mode):not([class*="theme-"]) .fav-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .photo-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .dym-word-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .fav-home-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #theme-toggle-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .photo-link-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .history-item:hover,
  body:not(.dark-mode):not([class*="theme-"]) .episode-item:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-play:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-edit-all-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-cancel-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .ts-copy-btn:hover,
  body:not(.dark-mode):not([class*="theme-"]) .modal-close:hover,
  body:not(.dark-mode):not([class*="theme-"]) #historyCloseBtn:hover,
  body:not(.dark-mode):not([class*="theme-"]) #aboutCloseBtn:hover {
    border-color: #b8c2d0 !important;
  }
  /* ダーク: 暗転は効きにくいので枠線を主役にする（背景の微変化は既存ルール維持） */
  body.dark-mode .guest-button:hover,
  body.dark-mode .btn-corner:hover,
  body.dark-mode .btn-year:hover,
  body.dark-mode .page-btn:hover,
  body.dark-mode .share-btn:hover,
  body.dark-mode #filterToggleBtn:hover,
  body.dark-mode #favOnlyToggleBtn:hover,
  body.dark-mode #randomBtn:hover,
  body.dark-mode .reset-btn:hover,
  body.dark-mode .drawer-close-btn:hover,
  body.dark-mode .history-toggle:hover,
  body.dark-mode .fav-btn:hover,
  body.dark-mode .photo-btn:hover,
  body.dark-mode .ts-btn:hover,
  body.dark-mode .dym-word-btn:hover,
  body.dark-mode .fav-home-btn:hover,
  body.dark-mode #theme-toggle-btn:hover,
  body.dark-mode .photo-link-btn:hover,
  body.dark-mode .history-item:hover,
  body.dark-mode .episode-item:hover,
  body.dark-mode .ts-play:hover,
  body.dark-mode .ts-edit-all-btn:hover,
  body.dark-mode .ts-cancel-btn:hover,
  body.dark-mode .ts-copy-btn:hover,
  body.dark-mode .modal-close:hover,
  body.dark-mode #historyCloseBtn:hover,
  body.dark-mode #aboutCloseBtn:hover {
    border-color: #565b62 !important;
  }
}

/* ======================================================================== */
/* ===== お気に入り一覧の一括削除ボタン（確認パネルはtsモーダルと共通クラス） ===== */
/* ======================================================================== */
/* トップへ戻る/すべて削除は、tsモーダルのコピー/すべて削除と同じデザイン
   （均等幅50%・角丸14px・同パディング）で統一する */
.fav-header-actions {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  width: min(480px, 100%);
}
.fav-header-actions > button { flex: 1 1 50%; min-width: 0; }
/* ボタン・文字サイズはフィルタボタン(.guest-button等)と同一規格:
   フォント0.95rem / 角丸22px / min-height39px / 枠線1px */
.fav-clear-btn {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 39px;
  border: 1px solid #fecaca;
  border-radius: 11px; /* エピソードカードと同じ角丸 */
  background: #fff1f2;
  color: #dc2626;
  font-size: 0.95rem;
  cursor: pointer;
}
/* トップへ戻るも同じ形状に（色はニュートラル面） */
.fav-header-actions .fav-home-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 39px;
  border-width: 1px;
  border-radius: 11px; /* エピソードカードと同じ角丸 */
  border-color: #e2e8f0;
  background: #ffffff;
  color: #374151;
  font-size: 0.95rem;
}
body.dark-mode .fav-header-actions .fav-home-btn { background: #000000; border-color: #2f3336; color: #e7e9ea; }
body[class*="theme-"] .fav-header-actions .fav-home-btn { background: var(--card-bg) !important; border-color: transparent !important; color: var(--text-color) !important; }
.fav-clear-btn[hidden] { display: none; }
.fav-clear-confirm { width: min(480px, 100%); box-sizing: border-box; }
/* フォントをサイト共通の太字書体に統一 */
.fav-clear-btn,
.favorites-header-layout .ts-clear-confirm {
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700;
}
/* ダークモード */
body.dark-mode .fav-clear-btn { background: #000000; border-color: rgba(239,68,68,0.45); color: #f87171; }
body.dark-mode .favorites-header-layout .ts-clear-confirm { background: #000000; border-color: rgba(239,68,68,0.45); }
body.dark-mode .favorites-header-layout .ts-clear-confirm-text { color: #f87171; }
body.dark-mode .favorites-header-layout .ts-clear-cancel-btn { background: #000000; border-color: #2f3336; color: #e7e9ea; }
/* カラーテーマ（統一ルール: 淡赤ソリッド・枠線なし） */
body[class*="theme-"] .fav-clear-btn { background: #fff1f2; border-color: transparent; color: #dc2626; }
body[class*="theme-"] .favorites-header-layout .ts-clear-confirm { border-color: transparent; }
/* PCホバー（統一パターン: 危険操作は赤トーン＋赤枠線、浮き上がりは共通モーションで付与） */
@media (hover: hover) {
  .fav-clear-btn:hover { background: #fee2e2; border-color: rgba(220, 38, 38, 0.45); }
  body.dark-mode .fav-clear-btn:hover { background: rgba(239,68,68,0.15); }
}

/* ===================================================
 * ローディング画面のカクつき対策（主にスマホ）
 * ===================================================
 * contain: ローディング画面内部のレイアウト・描画を文書本体から分離する。
 * 裏で進む検索結果の描画・フォント適用・スタイル再計算がローディング画面の
 * レイアウトへ波及しなくなり、跳ねる球のアニメーションが乱れにくくなる。
 * will-change: フェードアウト(opacity遷移)も含めて事前にコンポジタ層へ昇格し、
 * 消える瞬間のガタつきを防ぐ。 */
#loading-screen {
  contain: layout style paint;
  will-change: opacity;
}
/* 球のコンテナごと独立レイヤー化し、親のリフローの影響を受けにくくする */
#spinner {
  /* 玉の真上にある最下段「RADIO!」の黒い部分の重心（画素計測: 画像の50.7%位置）に揃える。
     端から端の中点(54%)だと「!」に引っ張られて右に寄りすぎ、画像中心(50%)だと僅かに左に見える */
  transform: translate3d(calc(min(330px, 70vw) * 0.007), 0, 0);
  will-change: transform;
}

/* カラーテーマ時、selectを開いた際のoption（UA描画）が「白背景に白文字」になり
   読めなくなる環境（Windows Chrome等）への保険。optionは常に黒文字×白背景で描画する */
body[class*="theme-"] .searchbox-select option {
  color: #22272e;
  background: #ffffff;
}

/* ★PWA起動時ちらつき対策: iOSは起動中のビューポート確定時にfixed要素の合成タイミングが
   ずれ、最前面のローディング画面より先に下部ナビが一瞬描画されることがある。
   ローディングが終わる（main.jsがbodyにapp-readyを付与する）までナビ自体を不可視にして、
   合成順に関係なく絶対に見えないようにする。 */
.pwa-bottom-nav {
  visibility: hidden;
  /* フェイルセーフ: 版ズレ等で app-ready が永久に付かなくても4秒後に必ず表示する */
  animation: navAutoReveal 0s 4s forwards;
}
@keyframes navAutoReveal { to { visibility: visible; } }
body.app-ready .pwa-bottom-nav { visibility: visible; animation: none; }

/* ★撤去: ここにあったPWA版tsモーダルのステータスバー帯（濃色）は、
   実機確認で「時計まわりが暗く見える」と不評だったため削除した。
   セーフエリア領域はモーダル背景と同色で塗られる。 */

/* ★起動時の帯チラつき最終対策:
   起動中（app-ready付与前=ローディング表示中）はbody背景をスプラッシュと同じ
   --bg-color に揃える。起動中は html / body / ローディング画面 / カバーの全レイヤーが
   完全に同一色になり、iOSの起動処理でどのレイヤーが一瞬露出しても色差が無いため
   チラつきとして視認できない。app-ready（フェード開始）と同時に本来の --btn-bg へ戻る。
   （ダーク/ライトは元々スプラッシュとbodyが同色なので影響なし） */
/* ★撤去: 「起動中はbodyを--bg-colorへ寄せる」ルールは削除した。
   キャッシュの版ズレで古いmain.js（app-readyを付けない）と新しいCSSが混在すると、
   このルールが永久に効き続けて全テーマの背景色が壊れる事故が起きたため。
   起動中の帯対策はローディング画面の下方延長・高さ固定・写真ストリップで足りている */

/* ★ボタン連打対応: ピンチズーム許可(アクセシビリティ対応)の副作用で、iOSが素早い
   2回目のタップを「ダブルタップズーム」と解釈してボタンのクリックを食べてしまい、
   お気に入り・リセット等が連打できなくなっていた。manipulation はダブルタップズーム
   だけを無効化し、ピンチズームとスクロールはそのまま使える。 */
body { touch-action: manipulation; }

/* ★スナップショット用: バックグラウンド移行時にmain.jsがhtmlへ付与。
   OSが保存する画面写真から下部ナビを消し、コールド起動時の
   「下部ボタンちらつき」と復帰時のロゴ表示を同時に防ぐ */
html.snap-hide-nav .pwa-bottom-nav { visibility: hidden !important; }

/* ★方針変更: 出現アニメーションは毎回再生する（タップの手応えとして必要という要望）。
   代わりに段差ディレイへ上限を設けて空白時間を短縮した（#results .episode-item 参照） */

/* ★タイムスタンプ一覧のスクロール安定化: リスト端でのスクロールが背景ページへ
   連鎖してラバーバンドが二重にかかり、動きが不安定に見えるのを防ぐ */
.ts-body {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}


/* ★スナップショット用の下部ストリップ:
   バックグラウンド移行時（html.snap-hide-nav中）に、隠したナビの位置へ
   ローディング画面と同色（--bg-color）の帯を重ねてからOSに写真を撮らせる。
   コールド起動時の「写真の下部（bodyの明るい色）→ローディング（暗い色）」の
   色差の帯が構造的に発生しなくなる。復帰時はクラスが外れて即消える。 */
html.snap-hide-nav body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  /* ★重要: bottom:0のみだと、バックグラウンド移行中にビューポートが縮んだ瞬間
     （852→780px等）の写真で「縮んだビューポートの下端」までしか覆えず、
     実画面の最下部にbodyの明るい色が写り込んで帯が残る。下へ300px延長して
     ビューポートの変動に関係なく実画面の下端まで必ず覆う（はみ出しは無害） */
  bottom: -300px;
  height: calc(370px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-color, #f9fafe);
  z-index: 3001;
  pointer-events: none;
}
/* ダークモードは--bg-colorを定義していないため明示指定（ローディング画面と同じ黒） */
html.snap-hide-nav body.dark-mode::after { background: #000000; }

/* ★テーマ切替中はトランジションを無効化（main.jsのapplyThemeが付与）。
   要素ごとに違う速度で色が変わって一瞬混在配色に見えるのを防ぎ、一斉に切り替える */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}
/* 上のユニバーサル指定はIDセレクタの transition !important（コントロールボタンの
   共通ルール）に詳細度で負けるため、該当ボタンはID級で明示的に上書きする。
   これがないと、お気に入り・ランダム・再生リスト作成等のボタンだけ
   テーマ切替時に0.1〜0.2秒遅れて色が変わる */
html.theme-switching #filterToggleBtn,
html.theme-switching #favOnlyToggleBtn,
html.theme-switching #randomBtn,
html.theme-switching #latestBtn,
html.theme-switching #mainResetBtn,
html.theme-switching #sortSelect,
html.theme-switching .reset-btn {
  transition: none !important;
}

/* ★起動中の色統一（版ズレ耐性版）:
   ローディング画面が表示されている間だけ、bodyをスプラッシュと同じ --bg-color にする。
   JSが付与するクラスではなく「#loading-screen がbody直下に存在するか」を :has() で
   直接条件にしているため、キャッシュの版ズレで古いJSと組み合わさっても
   （ローディング画面の除去は全バージョン共通のため）暗色のまま固定される事故が起きない。
   フェードアウト開始(.fadeout)と同時に通常色へ戻り、UIの出現と色が連続する。
   :has() 非対応の古い環境ではこのルールが無視されるだけで、他の帯対策が引き続き働く。 */
body[class*="theme-"]:has(> #loading-screen:not(.fadeout)) {
  background: var(--bg-color) !important;
}

/* ★スマホ版タイムスタンプモーダル: 編集モード中（編集タップ〜保存/キャンセル）は
   エピソードカードを非表示にし、その分入力欄を広く使う（main.jsが .ts-editing を付与。
   従来は入力欄フォーカス中(.ts-typing)のみ非表示だった。PCでは従来どおり表示） */
@media (max-width: 600px) {
  .modal-content.ts-modal.ts-editing .ts-episode-card {
    display: none !important;
  }
  /* 編集モード中は .ts-body をシートの残り空間いっぱいまで伸ばす。
     （flex:1..の指定はPC用メディアクエリ内にしかなく、スマホでは
     コンテンツ高のままだったため、入力欄の上限計算が広がらなかった） */
  .modal-content.ts-modal.ts-editing .ts-body {
    flex: 1 1 auto;
  }
  /* スマホは全画面シートになるため、左右余白をトップ画面のエピソードカード(15px)と揃える。
     エピソードカードは .ts-body の外（ヘッダー直下固定）にあるため margin も個別に指定 */
  .ts-modal .ts-body {
    padding-left: 15px;
    padding-right: 15px;
  }
  .ts-modal .ts-episode-card {
    margin-left: 15px;
    margin-right: 15px;
  }
  .ts-modal .ts-footer {
    padding-left: 15px;
    padding-right: 15px;
  }
}

/* ★検索候補のスクロール時点滅対策: iOSはタッチした要素に既定のハイライトを
   一瞬表示するため、候補リストをスクロールしようと指を置くたびに触れた項目が
   点滅して見えていた。タップの視覚フィードバックは:hover/選択状態で別途あるため
   既定ハイライトは無効化する */
.autocomplete-item {
  -webkit-tap-highlight-color: transparent;
}

/* ===================================================
   フィルター見出しのカテゴリ別カラー（ホワイト／ブラックカラー時のみ）
   アイコンは文字色を継承するので同色になる。カラーテーマ時は各テーマの見出し色のまま。
   =================================================== */
body:not([class*="theme-"]) .filter-title.filter-title--guest  { color: #ed6e96 !important; }
body:not([class*="theme-"]) .filter-title.filter-title--year   { color: #f1c142 !important; }
body:not([class*="theme-"]) .filter-title.filter-title--corner { color: #2f6cb8 !important; }
body:not([class*="theme-"]) .filter-title.filter-title--other  { color: #d32d4b !important; }

/* ===================================================
   フィルターボタン選択時のカラー（ホワイト／ブラックカラー時のみ）
   各セクションの見出し色と同じ色にする:
   出演者=ピンク / 公開年=イエロー / コーナー=ブルー / その他=レッド
   カラーテーマ時は各テーマの選択色のまま。
   =================================================== */
/* 出演者検索: ピンク */
body:not([class*="theme-"]) .guest-button[data-guest][aria-pressed="true"],
body:not([class*="theme-"]) .guest-button[data-guest].active,
body:not([class*="theme-"]) .guest-button[data-guest][aria-pressed="true"]:hover {
  background: #ed6e96 !important;
  color: #ffffff !important;
  border-color: #ed6e96 !important;
  box-shadow: none !important;
}
/* 公開年検索: イエロー */
body:not([class*="theme-"]) .btn-year[data-year][aria-pressed="true"],
body:not([class*="theme-"]) .btn-year[data-year].active,
body:not([class*="theme-"]) .btn-year[data-year][aria-pressed="true"]:hover {
  background: #f1c142 !important;
  color: #ffffff !important;
  border-color: #f1c142 !important;
  box-shadow: none !important;
}
/* コーナー検索: ブルー */
body:not([class*="theme-"]) .btn-corner[data-corner][aria-pressed="true"],
body:not([class*="theme-"]) .btn-corner[data-corner].active,
body:not([class*="theme-"]) .btn-corner[data-corner][aria-pressed="true"]:hover {
  background: #2f6cb8 !important;
  color: #ffffff !important;
  border-color: #2f6cb8 !important;
  box-shadow: none !important;
}
/* その他: レッド */
body:not([class*="theme-"]) .btn-corner[data-other][aria-pressed="true"],
body:not([class*="theme-"]) .btn-corner[data-other].active,
body:not([class*="theme-"]) .btn-corner[data-other][aria-pressed="true"]:hover {
  background: #d32d4b !important;
  color: #ffffff !important;
  border-color: #d32d4b !important;
  box-shadow: none !important;
}

/* 表示数の下に出る選択中フィルターのタグも、同じセクション色にする（ホワイト／ブラック時のみ）。
   出演者タグはJSが出演者ごとの色をインラインで付けるため !important で上書きする */
body:not([class*="theme-"]) .filter-tag[data-type="guest"]  { background: #ed6e96 !important; color: #ffffff !important; border: none !important; }
body:not([class*="theme-"]) .filter-tag[data-type="year"]   { background: #f1c142 !important; color: #ffffff !important; border: none !important; }
body:not([class*="theme-"]) .filter-tag[data-type="corner"] { background: #2f6cb8 !important; color: #ffffff !important; border: none !important; }
body:not([class*="theme-"]) .filter-tag[data-type="other"]  { background: #d32d4b !important; color: #ffffff !important; border: none !important; }

/* ===================================================
   折りたたみスマホ（iPhone Duo 等）を広げた縦持ち・小型タブレット縦（幅 600〜779px）
   2列にするには狭いので1列のまま、カードの中身をiPadサイズ（780〜1069px と同じ値）に
   拡大して、横に長いカードに余白だけが目立つ状態を防ぐ。畳んだ時（〜599px）は従来のスマホ表示。
   =================================================== */
@media (min-width: 600px) and (max-width: 779px) {
  .episode-item {
    --card-pad-r: 14px;
    padding: 14px;
    padding-right: var(--card-pad-r);
  }
  .episode-item .thumbnail { width: 150px; }
  .thumb-col { width: 150px; } /* サムネイルを包む枠（時刻バッジ付き）も同じ幅に */
  .episode-item a > div:last-of-type {
    margin-left: 14px;
    height: 84px;
  }
  #results h5.mb-1,
  .ts-episode-card h5.mb-1 {
    margin-top: 3px;
    font-size: 1.4rem;
    line-height: 1.0;
  }
  .guest-one-line {
    margin-top: 2px;
    font-size: 1.1rem;
    line-height: 1.2;
  }
  .episode-meta {
    margin-top: 3px;
    font-size: 0.8rem;
    line-height: 1.3;
  }
}

/* ===================================================
   スマホ横向き（高さ 500px 以下の横長画面・モバイルUI時のみ）
   縦持ち用の2段ヘッダー(172px)＋下部ナビ(81px)だと、本文が画面の約1/3しか残らなかった。
   ・ヘッダー: 検索欄と「並び替え／再生リスト作成」を1行に並べて高さを半分以下に
   ・下部ナビ: アイコンと文字を横並びにして薄くし、カラーの丸ボタンも小さく
   ・左右: ノッチ（カメラ）側の安全領域を全要素で同じように避ける
   =================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  /* --- ヘッダー --- */
  /* ヘッダー内の左右端を本文カードの左右端と揃える（どちらも max(15px, 安全領域)） */
  html.is-standalone .sticky-search-area {
    padding-top: calc(4px + var(--safe-top));
    padding-bottom: 8px; /* 表示数／タグの行の下にもゆとりを持たせる */
    padding-left: 0;
    padding-right: 0;
  }
  html.is-standalone .search-card,
  html.is-standalone .results-count-under-bar,
  html.is-standalone .filters-bar {
    max-width: none !important;
    padding-left: max(15px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(15px, env(safe-area-inset-right, 0px)) !important;
  }
  html.is-standalone .search-card {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  /* 「表示数」とフィルタータグを同じ行に並べる（検索の行の下に1行だけ） */
  html.is-standalone .sticky-search-area {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start; /* タグが2行になっても「表示数」は1行目のタグと並ぶ */
  }
  html.is-standalone .sticky-search-area > .search-card { flex: 0 0 100%; }
  html.is-standalone .sticky-search-area > .results-count-under-bar {
    flex: 0 0 auto;
    width: auto !important;
    margin: 0 !important;
    padding-right: 0 !important; /* 右隣のタグとの間隔はタグ側の左余白(10px)だけにする */
    white-space: nowrap;
  }
  html.is-standalone .sticky-search-area > .filters-bar {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
    margin: 0 !important;
    padding-left: 14px !important; /* 「表示数」とタグの間 */
    padding-top: 6px !important;   /* 「表示数」の文字とタグの中心をそろえる（画素実測で合わせた値） */
    padding-bottom: 0 !important;
    row-gap: 8px !important;       /* タグが2行になった時の行間 */
    min-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  /* 選択中フィルターのタグが無い時は、タグ用の帯の高さを取らない */
  html.is-standalone .filters-bar:empty {
    min-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
  }
  html.is-standalone .search-row-keyword {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    margin-bottom: 0;
  }
  html.is-standalone .search-row-controls {
    display: flex !important; /* 縦持ち用の格子(grid)をやめ、右端まで詰めて横に並べる */
    flex: 0 0 auto;
    gap: 8px !important;
    width: auto;
    min-width: 0;
  }
  html.is-standalone .search-input-wrapper { flex: 1 1 auto; width: 100%; }
  /* 検索欄・並び替え・再生リスト作成の高さを40pxで揃える（縦持ち用の min-height:42px にも勝たせる） */
  html.is-standalone .searchbox-input,
  html.is-standalone .search-row-controls .sort-wrapper,
  html.is-standalone #sortSelect,
  html.is-standalone #latestBtn {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    box-sizing: border-box !important;
  }
  html.is-standalone .search-row-controls .sort-wrapper { width: 190px !important; flex: 0 0 190px !important; }
  html.is-standalone #latestBtn { width: 170px !important; flex: 0 0 170px !important; font-size: 14px !important; }
  html.is-standalone #sortSelect { font-size: 14px !important; }
  /* 検索欄の行との間を空ける（以前は1pxしかなく窮屈だった） */
  html.is-standalone .results-count-under-bar {
    padding-top: 7px !important;
    padding-bottom: 0 !important;
    font-size: 0.95em;
  }

  /* --- 本文: 左右の安全領域を避ける --- */
  html.is-standalone .main-content {
    padding-left: max(15px, env(safe-area-inset-left, 0px)) !important;
    padding-right: max(15px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: calc(46px + var(--safe-bottom)) !important;
  }

  /* --- 下部ナビ: 薄く、アイコンと文字を横並びに --- */
  html.is-standalone .pwa-bottom-nav {
    height: calc(46px + var(--safe-bottom, 0px));
    padding-left: max(0px, env(safe-area-inset-left, 0px));
    padding-right: max(0px, env(safe-area-inset-right, 0px));
  }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn {
    flex-direction: row;
    gap: 6px;
  }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn i {
    font-size: 17px !important;
    top: 0 !important;
    left: 0 !important;
  }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn span {
    font-size: 12px !important;
    top: 0 !important;
    left: 0 !important;
  }
  html.is-standalone #pwa-theme-toggle-btn {
    top: 0;
    width: 38px;
    height: 38px;
    min-width: 38px;
    align-self: center;
    box-shadow: none;
  }
  html.is-standalone .pwa-bottom-nav #pwa-theme-toggle-btn i { font-size: 18px !important; }

  /* --- フィルター画面: 下端を薄くした下部ナビ(46px)の上端に合わせる（縦持ち用の60pxのままだと14pxの隙間ができる）。
         中身はノッチ（カメラ）側の安全領域を避ける --- */
  html.is-standalone #filterDrawer {
    bottom: calc(46px + var(--safe-bottom, 0px)) !important;
    padding-left: max(var(--drawer-px), env(safe-area-inset-left, 0px)) !important;
    padding-right: max(var(--drawer-px), env(safe-area-inset-right, 0px)) !important;
  }
  html.is-standalone #filterDrawer .drawer-footer {
    margin-left: calc(-1 * max(var(--drawer-px), env(safe-area-inset-left, 0px)));
    margin-right: calc(-1 * max(var(--drawer-px), env(safe-area-inset-right, 0px)));
    padding-left: max(var(--drawer-px), env(safe-area-inset-left, 0px));
    padding-right: max(var(--drawer-px), env(safe-area-inset-right, 0px));
  }

}

/* ===================================================
   ローディング画面: 横向きスマホ（高さ 500px 以下）
   縦持ち用の330pxロゴのままだと、下の玉が画面外にはみ出していた。
   ロゴを画面の高さに合わせて縮め、玉との間隔も詰める。
   ※ PWA起動直後はモバイルUI判定より先に表示されるため、is-standalone 条件は付けない
   =================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --loading-logo-w: min(330px, 70vw, calc(100dvh - 110px)); }
  #loading-logo {
    width: var(--loading-logo-w) !important;
    max-width: none !important;
  }
  #spinner {
    margin-top: 22px !important;
    transform: translate3d(calc(var(--loading-logo-w) * 0.007), 0, 0);
  }
  .loading-ball { width: 14px; height: 14px; }
}

/* ===================================================
   タイムスタンプモーダルの2列表示（左: エピソードカード / 右: 一覧）
   ・スマホ横向き（高さ500px以下）
   ・折りたたみスマホを広げた横長画面（iPhone Duo 等、下の「展開時レイアウト」と同じ条件）
   =================================================== */
@media (orientation: landscape) and (max-height: 500px), (orientation: landscape) and (pointer: coarse) and (min-width: 780px) and (max-width: 1069px) and (min-height: 501px) {
  /* --- タイムスタンプモーダル: 縦に積むと一覧が34pxしか残らないため、
         横長に広げて「左: エピソードカード ／ 右: 一覧＋編集ボタン」の2列にする --- */
  html.is-standalone .modal-content.ts-modal {
    display: grid !important;
    grid-template-columns: minmax(300px, 42%) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head head"
      "card body"
      "hint body"
      "hint foot";
    width: min(860px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px));
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    margin-bottom: 0;
  }
  html.is-standalone .ts-modal .modal-header {
    grid-area: head;
    min-height: 46px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  html.is-standalone .ts-modal .modal-close {
    top: 5px;
    width: 36px;
    height: 36px;
  }
  html.is-standalone .ts-modal .ts-episode-card {
    grid-area: card;
    align-self: start;
    margin: 12px 0 12px 15px;
    padding-bottom: 0;
    border-bottom: none;
  }
  html.is-standalone .ts-modal .ts-body {
    grid-area: body;
    padding-top: 12px;
  }
  /* フッターの中身（編集ボタン／削除確認／説明文）をそれぞれ別の場所に置くため、枠だけ解除する。
     編集中は従来どおりフッターごと非表示（.ts-footer[hidden] の display:none が優先される） */
  html.is-standalone .ts-modal .ts-footer {
    display: contents;
  }
  html.is-standalone .ts-modal .ts-list-actions,
  html.is-standalone .ts-modal .ts-clear-confirm {
    grid-area: foot;
    margin: 0;
    padding: 8px 20px 10px 0;
    border-top: 1px solid rgba(127, 127, 127, 0.18);
    padding-top: 10px;
  }
  /* 説明文は左列（エピソードカードの下）に小さめに置く */
  html.is-standalone .ts-modal .ts-hint {
    grid-area: hint;
    align-self: end;
    margin: 0;
    padding: 0 6px 12px 15px;
    font-size: 11px;
    line-height: 1.55;
    text-align: left;
  }
  /* 左列のエピソードカード: スマホ縦と同じ大きさにして、公開日時などが省略されないようにする */
  html.is-standalone .ts-modal .ts-episode-card .episode-item {
    --card-pad-r: 12px;
    padding: 12px;
  }
  html.is-standalone .ts-modal .ts-episode-card .thumbnail,
  html.is-standalone .ts-modal .ts-episode-card .thumb-col { width: 120px; }
  html.is-standalone .ts-modal .ts-episode-card .episode-item a > div:last-of-type {
    margin-left: 10px;
    height: auto;
  }
  html.is-standalone .ts-modal .ts-episode-card h5.mb-1 { font-size: 1.15rem; line-height: 1.15; }
  html.is-standalone .ts-modal .ts-episode-card .guest-one-line { font-size: 0.9rem; }
  html.is-standalone .ts-modal .ts-episode-card .episode-meta {
    font-size: 0.75rem;
    padding-right: 0 !important; /* モーダル内のカードには★/リンクボタンが無いので避ける余白は不要 */
  }
}

/* ===================================================
   展開時レイアウト：折りたたみスマホを広げた横長画面（iPhone Duo 約890×626 等）
   Appleの指針「内側の画面ではiPad版をそのまま広げた画面に／タブバーは右端に縦に並べる」に合わせ、
   純正アプリと同じ3列構成にする:
     左: フィルター（常に表示するサイドバー） / 中央: 検索と一覧 / 右端: 縦に並ぶナビ
   条件: 横長・タッチ操作・幅780〜1069px・高さ501px以上（スマホ横向きやPC、iPad全画面は対象外）
   =================================================== */
@media (orientation: landscape) and (pointer: coarse) and (min-width: 780px) and (max-width: 1069px) and (min-height: 501px) {
  :root {
    --duo-sb-w: 268px;  /* 左サイドバーの幅 */
    --duo-rail-w: 76px; /* 右端ナビの幅 */
    --duo-left: calc(var(--duo-sb-w) + env(safe-area-inset-left, 0px));
    --duo-right: calc(var(--duo-rail-w) + env(safe-area-inset-right, 0px));
  }

  /* --- 左: フィルターを常に表示するサイドバーにする --- */
  html.is-standalone #filterDrawer {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: auto !important;
    width: var(--duo-left) !important;
    height: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: calc(14px + var(--safe-top, 0px)) 12px calc(16px + var(--safe-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    border: none !important;
    border-right: 1px solid rgba(127, 127, 127, 0.18) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    animation: none !important; /* リセット時の「閉じる」フェードで消えないように */
    opacity: 1 !important;
    z-index: 2050 !important;
  }
  /* サイドバー上部の大見出し（純正アプリのサイドバーと同じ見せ方） */
  html.is-standalone #filterDrawer::before {
    content: "フィルタ";
    display: block;
    font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-weight: 700;
    font-size: 1.55rem;
    letter-spacing: 0.01em;
    margin: 2px 4px 14px;
  }
  html.is-standalone #filterDrawer .filter-section { padding-left: 0; padding-right: 0; }
  html.is-standalone #filterDrawer .filter-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  html.is-standalone #filterDrawer .guest-button,
  html.is-standalone #filterDrawer .btn-corner,
  html.is-standalone #filterDrawer .btn-year {
    min-height: 40px;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
  }
  /* 常に見えているので、開閉用の部品は使わない */
  html.is-standalone #filterDrawer .drawer-footer,
  html.is-standalone .drawer-backdrop,
  html.is-standalone #pwa-filterToggleBtn {
    display: none !important;
  }

  /* --- 中央: 検索ヘッダーをサイドバーと右端ナビの間に収め、1行に詰める --- */
  html.is-standalone .sticky-search-area {
    left: var(--duo-left) !important;
    right: var(--duo-right) !important;
    width: auto !important;
    padding: calc(8px + var(--safe-top, 0px)) 0 8px !important;
    border-radius: 0 0 14px 14px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  html.is-standalone .sticky-search-area > .search-card {
    flex: 0 0 100%;
    max-width: none !important;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0 16px !important;
  }
  html.is-standalone .search-row-keyword { flex: 1 1 auto; width: auto; min-width: 0; margin-bottom: 0; }
  html.is-standalone .search-input-wrapper { flex: 1 1 auto; width: 100%; }
  html.is-standalone .search-row-controls {
    display: flex !important;
    flex: 0 0 auto;
    gap: 8px !important;
    width: auto;
    min-width: 0;
  }
  html.is-standalone .searchbox-input,
  html.is-standalone .search-row-controls .sort-wrapper,
  html.is-standalone #sortSelect,
  html.is-standalone #latestBtn {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    box-sizing: border-box !important;
  }
  html.is-standalone .search-row-controls .sort-wrapper { width: 172px !important; flex: 0 0 172px !important; }
  html.is-standalone #latestBtn { width: 150px !important; flex: 0 0 150px !important; font-size: 14px !important; }
  html.is-standalone #sortSelect { font-size: 14px !important; }
  /* 「表示数」とフィルタータグは同じ行に */
  html.is-standalone .sticky-search-area > .results-count-under-bar {
    flex: 0 0 auto;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 7px 0 0 16px !important;
    white-space: nowrap;
  }
  html.is-standalone .sticky-search-area > .filters-bar {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 6px 16px 0 14px !important;
    row-gap: 8px !important;
    min-height: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  html.is-standalone .filters-bar:empty { padding: 0 !important; }

  /* --- 中央: 一覧などの本文をサイドバーと右端ナビの間に --- */
  html.is-standalone .main-content {
    padding-left: calc(var(--duo-left) + 16px) !important;
    padding-right: calc(var(--duo-right) + 16px) !important;
    padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    max-width: none !important;
  }
  html.is-standalone #results { grid-template-columns: 1fr !important; }
  html.is-standalone .site-footer {
    padding-left: var(--duo-left);
    padding-right: var(--duo-right);
  }

  /* --- 右端: 下部ナビを縦に並ぶナビにする（純正アプリのタブバーと同じ位置） --- */
  html.is-standalone .pwa-bottom-nav {
    top: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    right: 0 !important;
    width: var(--duo-right) !important;
    height: auto !important;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 6px;
    padding: var(--safe-top, 0px) env(safe-area-inset-right, 0px) var(--safe-bottom, 0px) 0 !important;
    border-top: none !important;
    border-left: 1px solid var(--btn-reset-border, #e5e7eb);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.06);
  }
  html.is-standalone body.dark-mode .pwa-bottom-nav { border-left-color: #394150; }
  html.is-standalone body[class*="theme-"] .pwa-bottom-nav { border-left-color: var(--history-card-bd); }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    height: 64px;
    flex-direction: column;
    gap: 5px;
  }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn i { font-size: 21px !important; top: 0 !important; left: 0 !important; }
  html.is-standalone .pwa-bottom-nav .pwa-bottom-nav-btn span { font-size: 10.5px !important; top: 0 !important; left: 0 !important; }
  html.is-standalone #pwa-theme-toggle-btn {
    top: 0;
    width: 52px;
    height: 52px;
    min-width: 52px;
    margin: 6px auto;
    align-self: center;
    box-shadow: none;
  }
  html.is-standalone .pwa-bottom-nav #pwa-theme-toggle-btn i { font-size: 24px !important; }
  /* 横並び用の位置補正（端のボタンを内側へ8pxずらす）は縦並びでは不要なので打ち消す */
  html.is-standalone .pwa-bottom-nav #pwa-mainResetBtn,
  html.is-standalone .pwa-bottom-nav #pwa-filterToggleBtn { left: 0; right: 0; }

  /* カラー選択パネルは右端ナビの左隣に縦に出す */
  html.is-standalone .floating-panel {
    top: 50% !important;
    bottom: auto !important;
    left: auto !important;
    right: calc(var(--duo-right) + 12px) !important;
    flex-direction: column !important;
    padding: 14px 10px !important;
    transform: translateY(-50%) scale(0.95) !important;
    transform-origin: right center !important;
  }
  html.is-standalone .floating-panel.show {
    transform: translateY(-50%) scale(1) !important;
  }
}

/* ======================================================================== */
/* ===== 追加修正：フィルタ見出し・ボタンの左端を検索欄と揃える ===== */
/* ======================================================================== */
/* スクリーンショットで「出演者検索」の見出しがキーワード検索欄・表示数より
   少し左に出ていた原因：ドロワー(#filterDrawer)は画面幅いっぱい(最大1400px)
   なのに、検索カード(.search-card)と表示数(.results-count-under-bar)は
   最大860px(900px以上は1160px)で中央寄せのため、幅900px前後で中身の左端が
   合わなかった。PC版サイドバー(1070px以上)でもドロワーの左余白が5pxで、
   検索カードの15pxより10px左に出ていた。
   ドロワーの横幅と左右余白を検索エリアと同じにし、見出し・ボタンの左端を
   検索欄の左端に合わせる。フッターの負マージンは --drawer-px を参照して
   いるため、--drawer-px を15pxに揃えればフッターもそのまま全幅になる。 */
@media (max-width: 899px) {
  #filterDrawer { max-width: 860px !important; }
  :root { --drawer-px: 15px; }
  #filterDrawer .filter-section { padding-left: 0 !important; padding-right: 0 !important; }
}
@media (min-width: 900px) and (max-width: 1069px) {
  #filterDrawer { max-width: 1160px !important; }
  :root { --drawer-px: 15px; }
  #filterDrawer .filter-section { padding-left: 0 !important; padding-right: 0 !important; }
}
@media (min-width: 1070px) {
  #filterDrawer { padding-left: 15px !important; }
}

/* ======================================================================== */
/* ===== 追加修正：フィルタを選んでも画面が下に動かないように ===== */
/* ======================================================================== */
/* 選択中タグの帯（.filters-bar）は、タグが無いとき高さを0に潰すルール
   （.filters-bar:empty）が効いていたため、フィルタを1つ選ぶたびに帯が
   32px伸びて、固定ヘッダー全体の高さが変わり、--header-offset 経由で
   下の結果一覧がその分だけ下にずれていた（解除すると上に戻る）。
   空のときも1行分の高さと上下の余白を確保して、帯の高さが選択の
   有無で変わらないようにする。影は空のとき消えたまま（元のルール）。
   タグが2行以上に折り返すときは、その分だけ帯が伸びるのは今まで通り。 */
.filters-bar:empty {
  min-height: 32px !important;
  padding-top: 2.5px !important;
  padding-bottom: 3px !important;
}

/* =================================================================
   ★★★ 長谷川育美非公式サイト(検) 固有のスタイル ★★★
   ここより上は、さーち・ざ・らじお！の style.css と同一
   （「再生リスト作成」ボタン #createPlaylistBtn の指定だけ、同じ位置に置いた
     「最新回を聴く」ボタン #latestBtn に読み替えている）。
   ここから下はこのサイトだけの差分。
   ================================================================= */

/* --- ローディング画面: このサイトはロゴのみ（玉のアニメーションは無し）。
       ロゴは横長(16:9)なので、横向きスマホでは高さに合わせて縮める --- */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --loading-logo-w: min(420px, 60vw, calc((100dvh - 60px) * 16 / 9)); }
}

/* --- 「最新回を聴く」ボタン（<a>要素）: 下線などリンク既定の見た目を消す。
       ホワイトカラー時の色は育美さんのイメージカラー（レッド）にする --- */
#latestBtn,
#latestBtn:hover,
#latestBtn:focus,
#latestBtn:visited { text-decoration: none !important; }
#latestBtn[hidden] { display: none !important; }
body:not(.dark-mode):not([class*="theme-"]) #latestBtn {
  background-color: #e60046 !important;
  border-color: #e60046 !important;
  color: #ffffff !important;
}
@media (hover: hover) {
  body:not(.dark-mode):not([class*="theme-"]) #latestBtn:hover {
    background-color: #c4003c !important;
    border-color: #c4003c !important;
    color: #ffffff !important;
  }
}

/* --- フィルター見出し（カテゴリ検索など）は色分けせず、通常の見出し色のまま。
       追加したアイコンの高さだけ文字に合わせる --- */
.filter-title > i.fa-folder-open { top: -0.06em; }
.filter-title > i.fa-tv { top: -0.06em; }

/* --- カテゴリボタン選択時（ホワイト／ブラック時のみ。カラーテーマ時はテーマの選択色） --- */
body:not([class*="theme-"]) .btn-corner[data-category][aria-pressed="true"],
body:not([class*="theme-"]) .btn-corner[data-category].active,
body:not([class*="theme-"]) .btn-corner[data-category][aria-pressed="true"]:hover {
  background: #e60046 !important;
  color: #ffffff !important;
  border-color: #e60046 !important;
  box-shadow: none !important;
}

/* 選択中フィルターのタグも、選択ボタンと同じ色にする（ホワイト／ブラック時のみ） */
body:not([class*="theme-"]) .filter-tag[data-type="category"] { background: #e60046 !important; color: #ffffff !important; border: none !important; }
body:not([class*="theme-"]) .filter-tag[data-type="works"]    { background: #13a286 !important; color: #ffffff !important; border: none !important; }
body:not([class*="theme-"]) .filter-tag[data-type="person"]   { background: #ed6e96 !important; color: #ffffff !important; border: none !important; }

/* --- 出演作品名・人物名のプルダウン（フィルター画面内） ---
   見た目は隣のフィルターボタン（ピル型・太字）にそろえる --- */
.filter-select-wrap { margin-bottom: 6px; }
#filterDrawer .form-select.searchbox-select.drawer-select {
  width: 100%;
  height: auto !important;
  min-height: 39px;
  padding: 8px 2.4em 8px 2.4em !important; /* 左右対称にして文字を中央に */
  border-radius: 22px !important;
  font-size: 0.97em;
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  text-align: center;
  text-align-last: center !important;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
body:not(.dark-mode):not([class*="theme-"]) #filterDrawer .form-select.searchbox-select.drawer-select {
  background-color: #ffffff !important;
  border: 1.3px solid rgba(80,80,160,0.10) !important;
  color: var(--text-color) !important;
}
body[class*="theme-"] #filterDrawer .form-select.searchbox-select.drawer-select {
  background-color: var(--card-bg) !important;
  border-color: var(--history-card-bd) !important;
  color: var(--text-color) !important;
}
@media (max-width: 600px) {
  #filterDrawer .form-select.searchbox-select.drawer-select { font-size: 0.95em; min-height: 37px; }
}
/* 折りたたみスマホ展開時のサイドバーでは、ボタンと同じ高さに */
@media (orientation: landscape) and (pointer: coarse) and (min-width: 780px) and (max-width: 1069px) and (min-height: 501px) {
  html.is-standalone #filterDrawer .form-select.searchbox-select.drawer-select { min-height: 40px; }
}
/* 選択中はタグと同じ色で塗る */
body:not([class*="theme-"]) #filterDrawer #worksSelect.active {
  background-color: #13a286 !important; border-color: #13a286 !important; color: #ffffff !important;
}
body:not([class*="theme-"]) #filterDrawer #personSelect.active {
  background-color: #ed6e96 !important; border-color: #ed6e96 !important; color: #ffffff !important;
}
body[class*="theme-"] #filterDrawer .form-select.searchbox-select.drawer-select.active {
  background-color: #ffffff !important; border-color: #ffffff !important; color: var(--bg-color) !important;
}
/* 選択肢リスト（ネイティブ表示）は読みやすい通常色に戻す */
#filterDrawer .drawer-select option { color: #22272e; background: #ffffff; font-weight: 500; }

/* --- エピソードカードのタイトル行（「激重感情ヘアです」等） ---
   文字を圧縮して詰め込むと回ごとに字詰めがバラバラになるため、
   文字の大きさは全カード共通のまま、入りきらない分は「…」で省略する。
   （全文は PC ではマウスを乗せると表示される） */
.episode-item .guest-one-line {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: none !important;
  visibility: visible !important;
}
/* 先頭が「や『で始まるタイトルは、括弧の前の空き（全角の左半分）を詰めて、
   上の「第89回」と左端をそろえる（さーち・ざ・らじお！の「ゲスト：〜」と同じ見え方） */
.episode-item .guest-one-line.starts-bracket { text-indent: -0.5em; }

/* --- 『ラジオの歴史』『スタジオオンショット』の2ボタンを縦に並べる --- */
.history-section .history-toggle + .history-toggle { margin-top: 12px; }

/* --- リンク一覧モーダル（フォトメモリンク／スタジオオンショット）の日付行 --- */
.photo-link-date {
  display: block;
  font-size: 0.78em;
  font-weight: 500;
  opacity: 0.65;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}
.photo-link-empty {
  margin: 8px 0;
  text-align: center;
  opacity: 0.7;
}

/* --- メンテナンス画面（maintenance.json の on が true のとき。index.html のスクリプトが出す） --- */
#maintenance-screen {
  position: fixed;
  inset: 0;
  /* ローディング画面（z-index: 2147483647 !important）と同じ最大値。後に置いてあるので上に重なる */
  z-index: 2147483647 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  /* テーマ（ブラック・レッドなど）に関係なく、いつも白地に濃い文字（ホワイトテーマと同じ色） */
  background: #f9fafe;
  color: #242943;
  text-align: center;
  font-family: fot-udkakugoc80-pro, 'Segoe UI', system-ui, -apple-system, sans-serif;
}
#maintenance-screen[hidden] { display: none; }
html.is-maintenance, html.is-maintenance body { overflow: hidden; }
/* 読み込み画面は消す（フェードの途中で上に残り、文字が薄く透けて見えていた） */
html.is-maintenance #loading-screen { display: none !important; }
#maintenance-screen .maint-logo {
  width: 360px;
  max-width: 78vw;
  height: auto;
  margin-bottom: 10px;
}
#maintenance-screen .maint-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #242943;
}
#maintenance-screen .maint-msg {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.8;
  white-space: pre-line; /* maintenance.json の \n で改行 */
  color: #242943;
}
