/* CSVocab アプリ本体のCSS。v1.2.888 で app/index.html の2つの <style> から切り出した（中身は不変）。
   ・前半＝旧1つ目の <style>（head の中）、後半＝旧2つ目の <style>（body の途中）。境目に目印のコメントがある。
     コメント中の「2つ目の <style> の末尾に置く」は、このファイルの末尾（＝後半の最後）のこと。
     後ろに書いたものが勝つ順番は、切り出す前と同じ。
   ・中身を直したら、index.html の <link rel="stylesheet" href="css/app.css?v=…"> の v をその回の版数に上げること
     （上げ忘れると、キャッシュ済みの古いCSSが1回分出る）。sw.js はこの href を読んでキャッシュする。 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
  background-color: #F8F9FA; /* v1.2.906: v1.2.905 の白を元に戻した（--bg と同値） */
  color-scheme: light;
  scrollbar-gutter: stable;
  /* iOS PWA viewport lock: prevent browser-level scroll so the keyboard can't push fixed elements */
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
html.dark-mode {
  background-color: #121018;
  color-scheme: dark;
  /* v1.2.179: #bootMask は var(--bg) を使うが、body.dark-mode が付くのは
     initDarkMode() まで待つことになる。html 側にも宣言しておくことで、
     起動直後のマスクも最初から暗い。
     v1.2.211: 値は上の background-color と必ず同じにすること（下記参照）。 */
  --bg: #121018;
}

:root {
  /* v1.2.905 で地の色を #FFFFFF にしたが、PCで目が疲れるとの本人の判断で v1.2.906 で #F8F9FA に戻した
     （文字の濃さ・下部タブ・カードの1px線は v1.2.905 のまま）。
     同値を持つ場所＝html の background-color／index.html の meta theme-color と #bootMask／
     01-core.js の StatusBar と theme-color（戻すときはこの5箇所とセット）。 */
  --bg: #F8F9FA;
  /* --ui-zoom: ここは「掛かっていない状態」の既定値。
     PCだけ上書きしている（2つ目の <style> 末尾）：幅1600px以上＝1.1（v1.2.287。境目は v1.2.596 で1400→1600px）／
     幅1024〜1399px＝0.8（v1.2.593）。間の1400〜1599pxは等倍。
     <head> の viewport height manager がこれを読んで --app-height を割り戻すので、
     **zoom を書き換えるときは必ず同値でこちらも書き換えること**。
     倍率を変える場所は「上書き側のブロックだけ」で、ここは 1 のまま触らない。 */
  --ui-zoom: 1;
  /* --brand-*: アプリのブランドカラー（深い緑系・Material系）。
     スタートボタン、メイン強調、選択中の枠線、リンク色など
     「アプリの基調色」が必要なところで使う。色の系統名ではなく役割名なので注意。 */
  --brand-50: #E8F5E9;
  --brand-100: #C8E6C9;
  --brand-200: #A5D6A7;
  --brand-300: #81C784;
  --brand-400: #66BB6A;
  --brand-500: #388E3C;
  --brand-600: #2E7D32;
  /* --green-*: セマンティックな「成功/完了」色（Tailwind系の鮮やかな緑）。
     習得済みバッジ、達成カウントなど「OK・できた」を示す場面で使う。
     ブランド色とは別の意味なので、混同しない。 */
  --green-400: #4ADE80;
  --green-500: #22C55E;
  --green-600: #16A34A;
  --blue-50: #EFF6FF;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --yellow-500: #EAB308;
  --red-400: #DC2626;
  --red-500: #B91C1C;
  --purple-400: #3B82F6;
  --purple-100: #DBEAFE;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6C6C74;
  --gray-600: #484850;
  --gray-700: #3A3A42;
  --gray-800: #2C2C34;
  --gray-900: #1C1C24;
  --bookmark: #F59E0B;
  /* v1.2.629: 「メモあり」の点の色。絞り込みピル（.filter-tab.noted.active の
     --fp-dot）と絞り込みメニューの点で同じ値を使うために変数にした。
     6色（グレー/アンバー/ブルー/イエロー/グリーン）と被らないティール。 */
  --dot-noted: #0D9488;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.15);
  --radius: 16px;
  --radius-sm: 10px;


  /* === v1.2.164: 未定義だった別系統の変数を接続 ===
     メモエディタ・重複警告リスト・出題数モーダル等が --text-secondary 系の
     命名で書かれていたが、宣言がどこにも無く 46 箇所が無効値になっていた
     （color は継承、background は transparent、border-color は currentColor）。
     値は既存のフォールバック（--text-secondary, var(--gray-500) 等）と
     アプリの慣習（枠線は --gray-200 が最多）に合わせている。
     新規コードではこちらではなく --gray-* / --label-* を使うこと。 */
  --text-primary:   var(--gray-800);
  --text-secondary: var(--gray-500);
  --bg-primary:     #fff;
  --bg-secondary:   var(--gray-100);
  --border-color:   var(--gray-200);
  --card-bg:        #fff;
}

body.dark-mode {
  /* ★--bg は「ページの地の色」。body の background と同じ値でなければならない。
     v1.2.211 まで --bg は #1a1520、body の background は #121018 と別値だった。
     スマホ幅では画面いっぱいなので気づかないが、PCでは全画面スクリーン
     （クイズ・出題範囲・詳細設定）が max-width:480px の柱として立つので、
     左右の地の色との境目が縦線になって見えていた。ライトはどちらも
     #F8F9FA で一致していたため、ダークだけで起きる症状だった。 */
  --bg: #121018;
  --brand-50: #1a1520;
  --brand-100: #231e2a;
  --brand-200: #332a3d;
  --brand-300: #81C784;
  --brand-400: #66BB6A;
  --brand-500: #4CAF50;
  --brand-600: #43A047;
  --green-400: #4ADE80;
  --green-500: #22C55E;
  --green-600: #16A34A;
  --blue-50: #1e1a2e;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --yellow-500: #EAB308;
  --red-400: #DC2626;
  --red-500: #B91C1C;
  --purple-400: #60A5FA;
  --purple-100: #1e2a4a;
  --gray-50: #1e1a28;
  --gray-100: #2a2535;
  --gray-200: #3a3545;
  --gray-300: #4a4555;
  --gray-400: #8a8595;
  --gray-500: #AEAEB6;
  --gray-600: #C7C7CF;
  --gray-700: #E5E5EA;
  --gray-800: #F2F2F7;
  --gray-900: #FFFFFF;
  --bookmark: #FBBF24;
  --dot-noted: #14B8A6; /* v1.2.629: ダークは暗い地に合わせて明るいティール */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.45);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.5);


  /* !!! ここは6つ全部を再宣言すること !!!
     カスタムプロパティの var() は「使う要素」ではなく「宣言した要素」で
     解決される。:root に --bg-secondary: var(--gray-100) と書くと、その場で
     ライト値 #F3F4F6 に置換されて確定し、body.dark-mode で --gray-100 を
     上書きしても追随しない（v1.2.164 で実際にダークが壊れた）。
     この rule 内の var(--gray-*) は同じ body 要素上の宣言を見るので正しい。 */
  --text-primary:   var(--gray-800);
  --text-secondary: var(--gray-500);
  --bg-primary:     #1e1a28;
  --bg-secondary:   var(--gray-100);
  --border-color:   var(--gray-200);
  --card-bg:        #1e1a28;
}

/* === v1.2.177: transition のルール（ネイティブ寄せ） ===
   タップできる要素では **色を補間しない**。background / color / border-color を
   transition の対象にすると、押した瞬間・選択した瞬間の見た目の変化が数百ms
   遅れて届き、それがそのまま「Webアプリっぽさ」になる。ネイティブは色は即時に
   切り替え、動き（transform）と影だけを短く補間する。
   そのため `transition: all` は全廃した（v1.2.177で19箇所）。新しくルールを
   書くときも `all` は使わず、補間したいプロパティを個別に列挙すること。
   既知の教訓（v1.2.126 のハンバーガー、テーマ切替の遅れ）と同じ話。 */

/* v1.2.840〜841 で韓国語表示だけ漢字・かなを日本語フォントに決め打ちしていたが、v1.2.842 で取り消した。
   字形は単語ごとの lang（contentLang）で決める。--font-ui は全言語共通の1本だけ。 */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  font-family: var(--font-ui);
  /* v1.2.164: ネイティブ寄せの土台。
     - font-smoothing: SF Proの細い線が太らないようにする（一番効く1行）
     - optical-sizing: 20px境界で SF Pro Text / Display を自動で切り替える
     - tabular-nums: 数字の字幅を固定。周回カウントや残り枚数がガタつかない */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  /* v1.2.211: 直値をやめて --bg を参照する。全画面スクリーンの背景も同じ
     変数を見ているので、ここを一箇所直せば地の色が必ず揃う。 */
  background: var(--bg);
  /* iOS PWA viewport lock (traditional pattern):
     - height:100% + overflow:hidden on html+body prevents document-level scroll,
       so iOS can't push fixed elements up when the keyboard opens.
     - We intentionally do NOT use position:fixed on body, because iOS WebKit
       treats a fixed body as a containing block for position:fixed descendants,
       causing bottom-nav / modal overlays to anchor to the (possibly shorter) body
       bottom instead of the viewport bottom. */
  width: 100%;
  height: 100%;
  margin: 0;
  position: relative;
  color: var(--gray-800);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body.dark-mode {
  background: var(--bg);
  color: var(--gray-800);
}
body.dark-mode .quiz-card,
body.dark-mode .quiz-card-next,
body.dark-mode .quiz-result,
body.dark-mode .confirm-modal,
body.dark-mode .edit-word-modal {
  background: #1e1a28;
  color: var(--gray-800);
}
body.dark-mode .edit-word-textarea {
  color: var(--gray-800);
}
body.dark-mode .import-area {
  background: #1e1a28;
  border-color: #3a3545;
}
@media (hover: hover) {
body.dark-mode .import-area:hover {
  border-color: var(--brand-400);
}
}
body.dark-mode .format-hint {
  background: #1e1a28;
}
body.dark-mode .format-hint code {
  background: #2a2535;
  color: var(--gray-700);
}
body.dark-mode .format-tab {
  background: #2a2535;
  color: var(--gray-600);
}
body.dark-mode .format-tab.active {
  background: var(--brand-500);
  color: #fff;
}
body.dark-mode .action-btn {
  background: #1e1a28;
}
body.dark-mode .deck-card {
  background: #1e1a28;
  border-color: #3a3545;
}
body.dark-mode .deck-card.active {
  background: #2a2040;
  border-color: var(--brand-500);
}
body.dark-mode .editor-word-item {
  background: #1e1a28;
}
body.dark-mode .search-bar {
  background: #2a2535;
}
body.dark-mode .search-bar input {
  color: var(--gray-800);
}
body.dark-mode .rename-input {
  background: #2a2535;
  border-color: #3a3545;
}
/* v1.2.189: 溝＋つまみ方式に合わせてダークも調整。トラックは var(--gray-100)
   （ダークでは #2a2535）がそのまま効くので指定不要。つまみはライトの白に相当する
   「一段明るい面」＝ var(--gray-200) にし、文字はブランド緑を載せる。
   旧実装のようにつまみをブランド単色で塗ると、ライト側と見た目の作りが変わる。 */
body.dark-mode .mode-toggle-btn {
  color: var(--gray-600);
}
body.dark-mode .mode-toggle-btn.active {
  background: var(--gray-200);
  color: var(--brand-400);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
body.dark-mode select {
  background: #2a2535;
  color: var(--gray-800);
  border-color: #3a3545;
}
body.dark-mode .secondary-btn {
  background: #2a2535;
  color: var(--gray-700);
  border-color: #3a3545;
}
body.dark-mode .confirm-cancel {
  background: #2a2535;
  color: var(--gray-600);
  border-color: #3a3545;
}
body.dark-mode .demo-item {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-700);
}
@media (hover: hover) {
body.dark-mode .demo-item:hover {
  background: #3a3040;
  border-color: var(--brand-400);
}
}
body.dark-mode .demo-item.selected,
body.dark-mode .demo-item.selected:active,
body.dark-mode .demo-item.selected:focus,
body.dark-mode .demo-item.selected:focus-visible {
  background: #3a3040 !important;
  border: 2px solid var(--brand-400) !important;
  outline: 2px solid var(--brand-400) !important;
  outline-offset: -2px;
  color: var(--brand-400) !important;
}
/* Prevent iOS Safari from showing a focused demo-item as pre-selected
   when an export/import modal opens — force the focus state to match
   the default style (not hover/selected).
   Exclude .selected so the demo picker's selection highlight is not
   overridden by :focus when the user taps a choice. */
.demo-item:not(.selected):focus,
.demo-item:not(.selected):focus-visible {
  background: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-700);
}
body.dark-mode .demo-item:not(.selected):focus,
body.dark-mode .demo-item:not(.selected):focus-visible {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-700);
}
/* v1.2.504: ダークだけ行が「タイル」に見えていたのを解消。ライトの
   .deck-edit-btn は background: var(--gray-50) だが --gray-50 はライトの
   :root に宣言が無く、実際には transparent＝モーダルと同じ面。ダークだけ
   ここで #2a2535 を当てていたため、同じ画面でも印象が変わっていた。
   background の宣言を外すと、ダークでは --gray-50 = #1e1a28 ＝
   .confirm-modal / .deck-edit-modal の背景と同値になり、ライトと同じく
   区切りの無い並びになる。副次的に .deck-edit-btn.lap（もう1周する）の
   ブランド色の下地もダークで効くようになる（これまでは本ルールの
   specificity に負けて消えていた）。 */
body.dark-mode .deck-edit-btn {
  color: var(--gray-700);
}
@media (hover: hover) {
body.dark-mode .deck-edit-btn:hover {
  background: #3a3040;
}
}
body.dark-mode .deck-edit-btn.danger {
  color: var(--red-500);
}
@media (hover: hover) {
body.dark-mode .deck-edit-btn.danger:hover {
  background: #3a2530;
}
}
body.dark-mode .confirm-overlay {
  background: rgba(0,0,0,0.7);
}
body.dark-mode .result-close-btn {
  background: #2a2535;
  color: var(--gray-600);
}
/* v1.2.342: 器 .filter-tabs を廃止したので、ダークの配色を要素側へ移した。
   （移し忘れると、ダークモードで絞り込みピルだけ白いまま残る）
   下の .filter-tab.<key>.active はどれも詳細度が上なので、色は勝つ。 */
body.dark-mode .filter-tab {
  background: #2a2535;
  color: var(--gray-600);
}
/* v1.2.627: 絞り込み中は塗りではなく色の点（定義は .filter-tab.active::before）。
   ダークで値が違うのは「メモあり」の点だけ。ほかはライトの --fp-dot をそのまま使う。
   v1.2.629: その「メモあり」は --dot-noted（:root とダークの両方で定義）に移したので、
   ここでの上書きは不要になった。 */
body.dark-mode .deck-edit-modal {
  background: #1e1a28;
  color: var(--gray-800);
}
body.dark-mode .quiz-back {
  background: #2a2535;
  color: var(--gray-600);
}
body.dark-mode .quiz-img-toggle {
  background: #2a2535;
}
body.dark-mode .result-btn.review-btn {
  background: #2a2535;
  color: var(--gray-700);
}
body.dark-mode .result-btn.next-quiz-btn {
  background: #2a2535;
}
body.dark-mode .unified-setup {
  background: #1e1a28;
}
body.dark-mode .level-select-card {
  background: #1e1a28;
}
body.dark-mode .editor-word-item .ew-inner {
  background: #1e1a28;
}
body.dark-mode .drill-desc {
  color: var(--gray-500);
}
body.dark-mode .swipe-overlay.swipe-right-overlay {
  background: linear-gradient(to right, transparent, rgba(20,184,166,0.25));
}
body.dark-mode .swipe-overlay.swipe-left-overlay {
  background: linear-gradient(to left, transparent, rgba(148,163,184,0.22)); /* v1.2.668: 赤系→スレート灰に戻す */
}
body.dark-mode .swipe-overlay .swipe-label { background: rgba(20,18,28,0.6); }

body.dark-mode .start-quiz-btn {
  box-shadow: 0 4px 16px rgba(249,115,22,0.3);
}
body.dark-mode .missed-list .missed-item {
  background: #2a2535;
}
/* v1.2.378: カード下段の区切り線。ライトは --gray-100 で足りるが、ダークの
   --gray-100 は #2a2535 ＝ ダークのカード地色そのものなので線が消えていた。
   カードの枠線（--gray-200 = #3a3545）と同じだと今度は弱いので、内側の
   仕切りだけ1段濃い --gray-300 にする。 */
body.dark-mode .missed-foot {
  border-top-color: var(--gray-300);
}
/* Hamburger menu button */
.hamburger-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* v1.2.126: transition:all だと背景色・文字色までアニメーション対象になり、
     ダークモード切替時にこのボタンだけ 0.2s かけて遅れて暗くなる（他の要素は
     即座に切り替わるので浮いて見える）。押した時の縮小フィードバックだけ
     補間し、色は即時反映させる。 */
  transition: transform 0.15s;
  z-index: 10;
  line-height: 1;
  padding: 0;
}
.hamburger-btn:active {
  transform: scale(0.9);
}
body.dark-mode .hamburger-btn {
  background: #2a2535;
}
/* Settings menu overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  /* v1.2.178: display:none → visibility に変更。display を同フレームで切り替えると
     初期状態（translateX(-100%)）が一度もレイアウトされないため transition が発火せず、
     パネルが最初からいきなり表示位置に出ていた。閉じる側も同じ理由で瞬間消えだった。
     visibility は最後にまとめて切り替えたいので transition-delay で遅らせる。 */
  visibility: hidden;
  transition: visibility 0s linear 0.24s;
  -webkit-tap-highlight-color: transparent;
}
/* 暗転は ::before に分離。.settings-overlay 自体を opacity で薄くすると
   子であるパネルまで半透明になり、スライド中に背景が透けてしまうため。 */
.settings-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.24s ease;
}
.settings-overlay.show {
  visibility: visible;
  transition: visibility 0s;
}
.settings-overlay.show::before {
  opacity: 1;
}
body.dark-mode .settings-overlay::before {
  background: rgba(0,0,0,0.65);
}
.settings-panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 80vw;
  height: 100%;
  background: #fff;
  box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  transform: translateX(-100%);
  /* 閉じるときは加速して素早く引っ込む */
  transition: transform 0.24s cubic-bezier(0.4, 0, 1, 1);
  display: flex;
  flex-direction: column;
  padding: max(env(safe-area-inset-top, 16px), 16px) 0 env(safe-area-inset-bottom, 16px) 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-overlay.show .settings-panel {
  transform: translateX(0);
  /* 開くときは減速カーブでゆっくり止まる＝「ぬるっと」出る感触。
     iOS のシートで使われる曲線で、easeOutQuint より立ち上がりが穏やか。 */
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@media (prefers-reduced-motion: reduce) {
  .settings-overlay::before,
  .settings-overlay.show::before,
  .settings-panel,
  .settings-overlay.show .settings-panel {
    transition-duration: 0.01s;
  }
}
body.dark-mode .settings-panel {
  background: #1e1a28;
  box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}
.settings-menu-list {
  padding: 12px 0 8px;
  flex: 1;
}
.settings-menu-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  /* v1.2.178: 1行の高さを 60px → 46px に。ドロワーの標準は44〜48px
     （Material のナビゲーションドロワー48px、iOSのテーブル行44px）。 */
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}
/* v1.2.455: <a> で使う項目（使い方ガイド）の下線と色を打ち消す */
a.settings-menu-item {
  text-decoration: none;
  color: var(--gray-700);
}
.settings-menu-item:active {
  background: var(--gray-100);
}
body.dark-mode .settings-menu-item:active {
  background: #2a2535;
}
/* v1.2.178: PCでの行ハイライト。タッチ端末は hover が貼り付いたままになるので
   (hover: hover) で囲う。button に限定しているのは、押せない div の行が
   光ると誤解を招くため（v1.2.490 でストレージ使用量の行は削除済み）。 */
@media (hover: hover) {
button.settings-menu-item:hover {
  background: var(--gray-100);
}
button.settings-menu-item:active {
  background: var(--gray-200);
}
body.dark-mode button.settings-menu-item:active {
  background: #363040;
}
}
button.settings-menu-item:focus-visible {
  background: var(--gray-100);
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}
/* v1.2.960: 右にバッジが無い項目は折り返さない。flex-wrap: wrap はバッジを下の行へ逃がすためのものだが、
   文言が長い言語（ベトナム語の「Thêm vào Màn hình chính」など）だと、文字だけがアイコンの下の行へ落ちていた。
   バッジが無ければ文字はアイコンの横のまま。入りきらなければ、アイコンの右で2行に折り返す。 */
.settings-menu-item:not(:has(.menu-badge)) { flex-wrap: nowrap; }
.settings-menu-item:not(:has(.menu-badge)) .menu-label { white-space: normal; overflow-wrap: anywhere; }
.settings-menu-item .menu-icon {
  /* v1.2.178: 角丸スクエアの下地を廃止しグリフのみに。枠は行揃えのために残す。 */
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--gray-500);
}
.settings-menu-item .menu-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}
.settings-menu-item .menu-label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-menu-item .menu-sublabel {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-menu-item .menu-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gray-100);
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
}
body.dark-mode .settings-menu-item .menu-badge {
  background: #2a2535;
}
.settings-menu-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 16px;
}
/* v1.2.189: .answer-color-picker（詳細設定に置いていた8色の横並び）は、
   選択肢シートに移したので削除。.color-dot 自体はリスニング設定でまだ使う。 */
.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s; /* v1.2.177: 選択枠は即時、hoverの拡大だけ補間 */
  padding: 0;
  outline: none;
  flex-shrink: 0;
}
@media (hover: hover) {
.color-dot:hover {
  transform: scale(1.1);
}
}
.color-dot.active {
  border-color: var(--gray-800);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--gray-400);
}
/* 「ブラック（問題文と同じ色）」のドットは、ダークでは問題文自体が明るいので
   ドットも明るく塗り替える。v1.2.189 で詳細設定側はシートの .sheet-opt-dot に移動。 */
body.dark-mode .sheet-opt-dot.is-match,
body.dark-mode #listeningColorDotMatch {
  background: #f5f0ff !important;
}
.settings-panel-footer {
  padding: 12px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--gray-400);
  border-top: 1px solid var(--gray-200);
}
/* v1.2.149: 計測ON/OFFの7回タップ受け皿。見た目は変えないが、連打で
   文字が選択状態になったりタップ時に灰色くハイライトされるのを止める。
   padding は当たり判定を少しだけ広げるためで、行の高さは変えない
   （font-size 11px + 上下4px = 約23px。footer の padding 12px と合わせて足りる）。 */
/* v1.2.414: フッターの規約・ポリシーのリンク行。文字はフッターと同じ11pxのグレー、
   下線だけで「押せる」ことを示す。版数行との間は margin-bottom で10px空ける。 */
.settings-legal-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.settings-legal-links button {
  background: none;
  border: none;
  padding: 4px 2px;
  font-family: inherit;
  font-size: 11px;
  color: var(--gray-400);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.settings-legal-links button:active { color: var(--gray-600); }
.settings-legal-sep { color: var(--gray-300); }
#settingsFooterVersion {
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.dashboard-top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
/* v1.2.137: ハンバーガーの隣に置くPWAインストールボタン。見た目は
   .hamburger-btn をそのまま継承し、中身が文字(☰)ではなくSVGなので
   サイズ指定だけ足す。display:none が初期値で、JS側が外す。 */
.pwa-header-btn.pwa-header-btn { display: none; }
.pwa-header-btn.is-shown.is-shown { display: flex; }
.pwa-header-btn svg {
  width: 21px;
  height: 21px;
}
.app-version-footer {
  text-align: center;
  font-size: 11px;
  color: #767676;
  font-family: monospace;
  margin-top: 16px;
  padding-bottom: 12px;
  user-select: none;
}
body.dark-mode .app-version-footer {
  color: #555;
}

/* Bottom navigation bar
   注意: .bottom-nav は必ず body 直下に置くこと（v1.2.168でHTMLを修正済み）。
   .app の中に入れると、iPad横向きなどで .app が overflow-y:auto の
   スクロールコンテナになったとき、iOS Safari が .app 内の position:fixed 要素を
   .app のクリップ領域に閉じ込めてしまい、両端ボタンが見切れる。 */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  display: none;
  justify-content: space-around;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Force GPU compositing. Without this, iOS can throttle/cancel the
     active -webkit-overflow-scrolling momentum scroll whenever this
     fixed-position element's transform animates, because the paint ends
     up on the same layer as the scrolling content. */
  transform: translate3d(0, 0, 0);
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: transform 0.22s ease;
}
.bottom-nav.scroll-hidden {
  transform: translate3d(0, 100%, 0);
}
/* NOTE: Previously we shrunk #wordItems/#editorWordList padding-bottom when
   the nav hid, but iOS WebKit cancels in-flight momentum scrolls whenever
   the scroll container's scrollHeight changes mid-gesture (even without a
   clientHeight change). We now keep padding-bottom constant and instead
   force-show the nav when the user nears the list's bottom, which removes
   both the scroll-cancel symptom and the "70px empty strip" artifact. */
body.dark-mode .bottom-nav {
  background: #1e1a28;
  border-top-color: #3a3545;
}
.bottom-nav.show {
  display: flex;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 6px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  /* transition削除: アクティブタブ切り替え時の色変化を即時反映にして
     タップ反応を早める */
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item .nav-icon .nav-svg-fill { display: none; } /* v1.2.910: 塗りのアイコンは既定で隠す */
.bottom-nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
  color: var(--gray-400);
}
.bottom-nav-item .nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
}
.bottom-nav-item.active .nav-label {
  color: var(--brand-500);
}
.bottom-nav-item.active .nav-icon {
  color: var(--brand-500);
  transform: scale(1.1);
}
.bottom-nav-item:active {
  opacity: 0.6;
}
/* v1.2.408: キーボード操作時のフォーカスリング。
   これまで .bottom-nav-item / .rail-toggle にフォーカス系の指定が無かったため、
   Chromeの既定 outline:auto（黒＋白の二重枠）がそのまま出ていた。
   症状：マウスで「リスニング」を押す → その button にフォーカスが残る →
   リスニング画面で Space や矢印キーを叩くと、Chromeがキーボード操作中と
   判定を切り替えてサイドバーの行に黒枠が出る。
   ★outline:none で消さないこと。リスニングは Space／←→ で操作する画面なので、
     キーボード主体のユーザーが現在位置を見失うと操作不能になる。
   ★:focus ではなく :focus-visible。マウスのクリックでは出さないため。
   ★outline-offset は内側(-2px)。外へ出すと隣の行と干渉する。角丸は outline が
     要素の border-radius（PC時10px）に追従するので再指定不要。 */
.bottom-nav-item:focus-visible,
.rail-toggle:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}
body.dark-mode .bottom-nav-item:focus-visible,
body.dark-mode .rail-toggle:focus-visible {
  outline-color: var(--brand-400);
}
body.has-bottom-nav .app {
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}
/* v1.2.263: サイドバー専用の部品。PC用ブロック（スタイル末尾）でだけ表示する。
   ★CSSコメント内に閉じstyleタグを書かないこと。HTMLのパーサはCSSコメントを
     解釈しないので、その時点でスタイルが打ち切られてページが崩れる。 */
.rail-brand,
.rail-settings-host,
.rail-toggle,
.rail-section-label {
  display: none;
}

/* Study stats & heatmap */
.study-stats-card {
  background: white;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--gray-200);
}
body.dark-mode .study-stats-card {
  background: #1e1a28;
  border-color: #3a3545;
}
.stats-summary {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.stat-box {
  flex: 1;
  text-align: center;
  padding: 8px 2px;
  border-radius: 10px;
  background: var(--gray-50);
  min-width: 0;
}
body.dark-mode .stat-box {
  background: #2a2535;
}
/* v1.2.169: 行の高さは --stat-value-size（基準サイズ）で固定する。
   autoFitStatValues() は長い値（「39時間48分」など）の font-size を
   インラインで縮めるが、line-height:1 のままだと行の高さまで縮んで、
   その箱だけ値もラベルも上にずれて見える。line-height を基準サイズに
   固定しておけば、縮んだ文字はその行の中で縦中央に置かれ、5つの箱が
   必ず揃う。※インラインの font-size は line-height に影響しない。 */
.stat-box .stat-value {
  --stat-value-size: 16px;
  font-family: var(--font-ui);
  font-size: var(--stat-value-size);
  font-weight: 600;
  color: var(--gray-500);
  line-height: var(--stat-value-size);
  white-space: nowrap;
}
.stat-box .stat-label {
  font-size: 8px;
  font-weight: 600;
  color: var(--gray-400);
  margin-top: 3px;
}
.stat-box.streak .stat-value {
  color: var(--bookmark);
}
.heatmap-section {
  margin-top: 0;
}

.heatmap-cell.today {
  outline: 2px solid var(--brand-500);
  outline-offset: -1px;
}
/* v1.2.498: 押した日（下のパネルに出ている日）は濃い枠線。today より後に書いて
   今日を選んだ時は枠が濃色に置き換わる。パネルが閉じると外れる。
   曜日見出し（.cal-dow）も同じ枠で「集計中」を示す（年月は本人の判断で囲まない）。 */
/* v1.2.576: 押した日は灰色の枠をやめ、マスごと濃い灰色で塗って数字を白に（A案）。
   枠線は「今日」専用にしたので、今日を押しても緑の枠は消えない。
   選択中はそのマスの「勉強した日の緑」が隠れる（記録は下のパネルに出る）。
   ダークは v1.2.579 で同じく塗りに変更（下の body.dark-mode 側）。
   v1.2.575 で試した B案（数字を丸で囲む）は本人判断でA案に差し替え。
   元: .heatmap-cell.selected { outline: 2px solid var(--gray-500); outline-offset: -1px; }
       .heatmap-cell.selected .cal-day { color: var(--gray-700); } */
body:not(.dark-mode) .heatmap-cell.selected { background: var(--gray-700); }
body:not(.dark-mode) .heatmap-cell.selected .cal-day { color: #fff; }
/* v1.2.577: 曜日見出しも日付マス（v1.2.576）と同じく、灰色の枠→濃い塗り＋白文字に。
   日／土の赤・青も選択中は白（濃い地の上で読めるように）。ダークは v1.2.579 で同じ塗りに。
   元: .cal-dow.selected { outline: 2px solid var(--gray-500); outline-offset: -1px; border-radius: 4px; }
       .cal-dow.selected { color: var(--gray-700); } */
/* v1.2.631: 選択時に下余白を上下へ振り分けると文字が --dow-pb/2 だけ下がる（ダークで特に目立った）。
   文字は動かさず、塗りを疑似要素にして文字の上下へ均等に（上へ --dow-pb/2 はみ出させて）置く。
   元: .cal-dow.selected { padding-top: calc(var(--dow-pb) / 2); padding-bottom: calc(var(--dow-pb) / 2); } */
.cal-dow { position: relative; isolation: isolate; }
.cal-dow.selected::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--dow-pb) / -2);
  bottom: calc(var(--dow-pb) / 2);
  border-radius: 4px;
  background: var(--dow-sel-bg);
  z-index: -1;
  pointer-events: none;
}
body:not(.dark-mode) .cal-dow.selected,
body:not(.dark-mode) .cal-dow.sun.selected,
body:not(.dark-mode) .cal-dow.sat.selected { --dow-sel-bg: var(--gray-700); color: #fff; }
/* v1.2.579: ダークも枠をやめて塗りに（本人の希望で解禁。B案＝中間の紫グレー #6f6888＋白文字）。
   明るい塗り（#c4bfd2）は暗い画面でそこだけ光るので不採用。今日の緑枠はダークでも残る。
   元: body.dark-mode .heatmap-cell.selected / .cal-dow.selected { outline: 2px solid #8a849c; outline-offset: -1px; }
       選択中の文字色 #c4bfd2（v1.2.508）、日／土は選択中も赤／青のまま */
body.dark-mode .heatmap-cell.selected,
body.dark-mode .heatmap-cell.studied.selected { background: #6f6888; }
body.dark-mode .heatmap-cell.selected .cal-day { color: #fff; }
body.dark-mode .cal-dow.selected,
body.dark-mode .cal-dow.sun.selected,
body.dark-mode .cal-dow.sat.selected { --dow-sel-bg: #6f6888; color: #fff; }
.heatmap-cell.other-month {
  opacity: 0.3;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-dow {
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-400);
  --dow-pb: 3px; /* v1.2.577: 下余白を変数化（選択中の塗りで文字を上下中央に置くため） */
  padding-bottom: var(--dow-pb);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.cal-dow.sun { color: var(--red-400); }
.cal-dow.sat { color: var(--blue-400); }
.heatmap-cell {
  border-radius: 4px;
  background: var(--gray-100);
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
body.dark-mode .heatmap-cell {
  background: #2a2535;
}
.heatmap-cell.studied {
  background: rgba(34,197,94,0.25);
}
body.dark-mode .heatmap-cell.studied {
  background: rgba(34,197,94,0.3);
}
.heatmap-cell .cal-day {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  line-height: 1;
  pointer-events: none;
}
.heatmap-cell.today .cal-day {
  color: var(--brand-500);
  font-weight: 600;
}
.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.cal-month-nav button {
  border: none;
  background: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--gray-500);
  padding: 2px 6px;
  border-radius: 4px;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.cal-month-nav button:active { background: var(--gray-100); }
.cal-month-nav span {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-700);
  min-width: 70px;
  text-align: center;
}
/* v1.2.737: 年月ラベルと曜日見出しは押せる要素なのに文字選択が効いていた
   （PCでダブルクリック等すると選択→Chromeの翻訳拡張のアイコンが出る）。
   矢印ボタン・日付マスと同じく選択不可に。 */
.cal-month-nav span,
.cal-dow {
  -webkit-user-select: none;
  user-select: none;
}
/* v1.2.578: 年月をタップして月の集計を開いている間は、日付・曜日と同じ濃い塗り＋白文字。
   余白を足すと矢印の位置や行の高さが動くので、塗りは同色の box-shadow で外へ2pxだけ広げる。
   ダークは v1.2.579 で同じ塗りを追加（下）。 */
body:not(.dark-mode) .cal-month-nav span.selected {
  background: var(--gray-700);
  color: #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 2px var(--gray-700);
}
/* v1.2.579: ダークの年月も同じ塗り（色は日付・曜日のダークと同じ #6f6888） */
body.dark-mode .cal-month-nav span.selected {
  background: #6f6888;
  color: #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #6f6888;
}
/* v1.2.506: 記録カード（表示中の月のカレンダー＋連続日数・累計を1枚の画像に
   して共有シートへ渡す）のボタン。月ナビの右端に absolute で置き、◀ 年月 ▶ の
   中央揃えを崩さない。表示中の月に学習日が無いときは renderHeatmap が隠す。 */
.cal-month-nav { position: relative; }
.cal-share-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.cal-share-btn svg { width: 16px; height: 16px; }
.cal-share-btn:active { background: var(--gray-100); }
.cal-share-btn.hidden { display: none; }

@keyframes calPopIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
.listening-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  padding: 24px 20px 20px;
  min-height: 0;
  width: 100%;
  /* v1.2.2: ビューポートが狭い時(ブラウザのURLバー表示中など)に
     再生ボタンが切れて見えなくなる問題を解消するため、
     .editor-word-list と同じスクロール構成に揃える。 */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
}
@media (max-width: 600px) {
  .listening-player {
    padding: 12px 16px 12px;
  }
}
.listening-player::-webkit-scrollbar { display: none; }
.listening-progress {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 8px;
  flex-shrink: 0;
}
.listening-seekbar {
  width: 100%;
  max-width: 400px;
  margin-bottom: 20px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
  outline: none;
  flex-shrink: 0;
}
.listening-seekbar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #888;
  cursor: pointer;
}
.listening-seekbar::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #888;
  cursor: pointer;
  border: none;
}
.listening-seekbar::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: transparent;
}
.listening-card {
  background: white;
  border-radius: var(--radius);
  padding: 36px 24px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 400px;
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 10px;
  position: relative;
  /* Allow card to shrink inside flex parent so overflow:auto on children works */
  min-height: 0;
  flex: 0 0 auto;
  overflow: hidden;
}
body.dark-mode .listening-card {
  background: #1e1a28;
}
/* Mobile: FIXED card height so controls/save button never move.
   Overflowing text scrolls inside the question/answer areas. */
@media (max-width: 600px) {
  .listening-card {
    height: 240px;
    min-height: 240px;
    max-height: 240px;
    padding: 20px 20px;
    gap: 12px;
    justify-content: flex-start;
  }
}
.listening-question {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.5;
  width: 100%;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.listening-answer {
  font-size: 18px;
  font-weight: 600;
  color: var(--listening-answer-color, #22C55E);
  line-height: 1.5;
  min-height: 26px;
  width: 100%;
  overflow-y: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
/* リスニング: 「問題と同色」モード時は問題と同じ色（gray-800）にする。
   詳細設定の answer-match-question とは独立して切り替え可能。 */
body.listening-answer-match .listening-answer {
  color: var(--gray-800);
}
/* v1.2.526: 停止中に答えを伏せている間の案内（「タップで答えを表示」）。
   答えの色設定（緑／問題と同色）やメディアクエリの font-size に負けないよう
   .listening-card を付けて詳細度を上げている。 */
.listening-card .listening-answer.is-hint {
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}
.listening-card.can-reveal { cursor: pointer; }
/* Mobile: flex-fill so question/answer share the fixed card height
   and scroll independently when content is long. */
@media (max-width: 600px) {
  .listening-question {
    flex: 1 1 0;
  }
  .listening-answer {
    flex: 1 1 0;
    min-height: 0;
  }
}
.listening-controls {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .listening-controls {
    margin-bottom: 12px;
  }
}
.listening-ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-600);
  padding: 8px;
  border-radius: 50%;
  transition: background 0.15s;
}
.listening-ctrl-btn:active {
  background: var(--gray-100);
}
.listening-ctrl-btn.play {
  background: var(--brand-500);
  color: white;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.listening-ctrl-btn.play:active {
  background: var(--brand-600);
}
.listening-speed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.listening-speed span {
  min-width: 48px;
}
.listening-speed-btn {
  background: none;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
}
.listening-speed-btn.active {
  border-color: var(--brand-500);
  color: var(--brand-500);
}
/* v1.2.410: 再生間隔の select。ラベル(問→答/答→次)は他行の min-width:48px を
   継がず内容幅にして、2組が1行に収まるようにする。 */
/* v1.2.411: 設定パネルの各行は、先頭ラベルの幅を揃えて操作部の左端を1本に揃える。
   一番長い「答えの文字色」(13px×6文字≒78px) が入る幅。行の高さも揃える。 */
/* v1.2.868: PCではシートが画面幅いっぱいなので、パネルを一番長い行（速度）が入る幅に絞って中央へ。
   行の中は左揃えのまま（ラベル幅で操作部の左端を揃える v1.2.411 の作りを崩さない）。スマホは行幅に収まるので見た目は変わらない。 */
#listeningSettingsPanel { width: 100%; max-width: 400px; margin: 0 auto; }
#listeningSettingsPanel .listening-speed { min-height: 34px; margin-bottom: 8px; }
#listeningSettingsPanel .listening-speed > span:first-child { min-width: 84px; flex-shrink: 0; }
/* 2つ目のラベル（答→次）は内容幅のまま。前の select との間だけ少し空ける */
.listening-delay-row span + .listening-delay-select { margin-right: 6px; }
.listening-delay-select {
  font-size: 12px;
  padding: 6px 8px;
  color: var(--gray-500);
}
/* v1.2.411: 読み上げ速度スライダー。シークバーの見た目を借りるが、行内に収める。 */
.listening-rate-row { flex-wrap: nowrap; }
/* 後ろにある PC 向け media の .listening-seekbar { margin-bottom; max-width } に
   負けないよう、行クラスと組み合わせて詳細度を上げている。 */
.listening-rate-row .listening-rate-slider {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 260px; /* PCでシートが横長でも伸ばしすぎない。スマホでは行幅に収まる */
  margin: 0;
  height: 4px;
  align-self: center;
}
.listening-rate-value {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--brand-500);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
/* v1.2.171: z-index は .deck-edit-overlay 等（2000）より1段だけ上。v1.2.170まで
   この要素はHTML上で他のオーバーレイより後ろにあり、同じ2000でも文書順で
   前面になっていた。HTML上の位置を前に戻したので、その前後関係を z-index で
   維持する（#dupWarningOverlay の2600、.settings-overlay の3000より下のまま。
   .confirm-overlay は v1.2.494 で 3100 に上げたので、これより上）。 */
.listening-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.listening-sheet-overlay.show {
  opacity: 1;
  visibility: visible;
}
.listening-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 16px) + 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  overflow-y: auto;
}
.listening-sheet-overlay.show .listening-sheet {
  transform: translateY(0);
}
body.dark-mode .listening-sheet {
  background: #1e1a28;
}
.listening-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 0 auto 16px;
}
body.dark-mode .listening-sheet-handle {
  background: #3a3545;
}
.listening-sheet-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 16px;
  text-align: center;
}
body.dark-mode .listening-sheet-title {
  color: #e0dde6;
}
/* v1.2.189: 設定の選択肢シート。出題順・答えの文字色のように「選択肢が多い」
   「めったに触らない」設定を、行の中に並べず下からのシートで選ばせる。
   見た目・アニメーションは既存の .listening-sheet に揃えてある。
   z-index は .listening-sheet-overlay / #editWordOverlay と同じ2050で足りる
   （詳細設定画面は z-index:50 なので確実に上に乗る）。 */
.setting-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.setting-sheet-overlay.show {
  opacity: 1;
  visibility: visible;
}
.setting-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 12px 20px calc(env(safe-area-inset-bottom, 16px) + 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.setting-sheet-overlay.show .setting-sheet {
  transform: translateY(0);
}
body.dark-mode .setting-sheet {
  background: #1e1a28;
}
.setting-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.setting-sheet-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
  text-align: center;
}
/* v1.2.486: 見出しが問題文のとき（結果画面の習熟度シート）。長文は1行で省略。 */
.setting-sheet-title.is-word {
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 12px;
}
.setting-sheet-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 15px 2px;
  background: none;
  border: none;
  border-top: 0.5px solid var(--gray-200);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.setting-sheet-option:first-of-type {
  border-top: none;
}
.setting-sheet-option .sheet-opt-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--gray-300);
}
/* v1.2.629: 絞り込みメニュー（一覧・リスニング）の点。18px は「色そのものを選ぶ」
   シート（答えの文字色・習熟度）の色見本の大きさで、項目の目印としては強すぎるので
   こちらは 10px・輪郭なしにする。付けるのは #settingSheetBody 側のクラス（dotSmall）。 */
#settingSheetBody.dots-small .sheet-opt-dot {
  width: 10px;
  height: 10px;
  border: none;
}
/* 「すべて」用＝点は出さず場所だけ空ける。ピルと同じ「点がある＝絞り込み中」の
   読み方を、メニューの中でも崩さないため（ラベルの左端は他の行と揃う）。 */
.setting-sheet-option .sheet-opt-dot.is-blank {
  background: none;
  border: none;
}
.setting-sheet-option .sheet-opt-label {
  flex: 1;
}
.setting-sheet-option .sheet-opt-desc {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}
.setting-sheet-option .sheet-opt-check {
  width: 18px;
  height: 18px;
  color: var(--brand-500);
  flex-shrink: 0;
  visibility: hidden;
}
.setting-sheet-option.selected .sheet-opt-check {
  visibility: visible;
}
/* v1.2.538: ポップオーバー表示。openSettingSheet(key, anchorEl) でボタンを渡すと、
   下からのシートではなくそのボタンの真下に出す（一覧の「編集」・絞り込み・並び替えと、リスニングの絞り込み・並び替え）。
   位置（top / right / max-height）は JS が毎回書く。中身の組み立ては共通のまま、
   つまみと見出しを隠して行を詰めるだけ。 */
.setting-sheet-overlay.is-popover { background: rgba(0,0,0,0.12); }
.setting-sheet-overlay.is-popover .setting-sheet {
  bottom: auto;
  left: auto;
  margin: 0;
  width: 290px;
  max-width: calc(100vw - 24px);
  border-radius: 14px;
  padding: 2px 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
  transform: scale(0.96);
  transform-origin: top right;
  opacity: 0;
  transition: transform 0.15s ease-out, opacity 0.15s ease-out;
}
.setting-sheet-overlay.is-popover.show .setting-sheet {
  transform: none;
  opacity: 1;
}
.setting-sheet-overlay.is-popover .setting-sheet-handle,
.setting-sheet-overlay.is-popover .setting-sheet-title { display: none; }
.setting-sheet-overlay.is-popover .setting-sheet-option { padding: 12px 2px; }
.listening-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timer-popup {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.timer-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--brand-500);
  color: white;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 8px;
  line-height: 1.2;
}
.timer-popup-btn {
  background: none;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
}
.timer-popup-btn.active {
  border-color: var(--brand-500);
  color: var(--brand-500);
}
.month-summary-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
  background: white;
  border-radius: 12px;
  padding: 0 16px;
  margin-top: 0;
  box-shadow: none;
}
.month-summary-panel.open {
  max-height: 300px;
  padding: 14px 16px;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
body.dark-mode .month-summary-panel {
  background: #1e1a28;
}
.month-summary-panel .cdp-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}
.month-summary-panel .cdp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.month-summary-panel .cdp-label {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
}
.month-summary-panel .cdp-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.month-summary-panel .cdp-none {
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
  padding: 4px 0;
}
.month-summary-panel .cdp-top-wrong {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color, #eee);
  align-items: flex-start;
  gap: 12px;
}
.month-summary-panel .cdp-top-wrong .cdp-value {
  text-align: right;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}
/* v1.2.209: 誤答回数は語の「下」に独立した1行として置く。
   v1.2.207〜208 は語と回数を横並び（align-items:baseline）にしていたが、
   語が2行以上に折り返すと回数だけが1行目の末尾に残り、文の途中に
   「2回」が挟まって見える状態になっていた。縦積みならその崩れが起きない。
   表示は1件だが、複数件を縦に積める形のまま残してある
   （件数は JS 側 getTopWrongWords の引数だけで変えられる）。 */
.month-summary-panel .cdp-tw-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.month-summary-panel .cdp-tw-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  max-width: 100%;
}
.month-summary-panel .cdp-tw-word {
  text-align: right;
  word-break: break-word;
  min-width: 0;
}
/* 語そのものと見分けがつくよう、小さく・薄く・太字を外す。
   「ミス」を付けているのは、右揃えで数字だけ置くと答えの一部
   （「10年」の下に「2回」）に見えるため。 */
.month-summary-panel .cdp-tw-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-400);
  white-space: nowrap;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 100px;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  position: relative;
  z-index: 1;
  /* Internal scroll (body is fixed, so scrolling happens here) */
  height: var(--app-height, 100dvh);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-sizing: border-box;
  /* Hide the scrollbar visually. Scrolling still works via mouse wheel
     (see initWheelRedirect — unified handler for both inner column and
     outer margins), touchpad, touch, and keyboard. The scrollbar is hidden
     because .app is a centered 480px column on desktop, so the native
     scrollbar would appear in the middle of the viewport rather than at
     the window's right edge — which looks unnatural. Keeping a consistent
     "mobile-like" borderless look across desktop and mobile is the
     intentional tradeoff. */
  scrollbar-width: none;
}
.app::-webkit-scrollbar { display: none; }
/* Screens that take the full viewport and manage their own internal scroll
   (wordlist, word-editor, listening) should not also make .app scrollable —
   otherwise the desktop browser shows a redundant outer scrollbar. On these
   screens, .app keeps only top safe-area padding and hides its overflow; the
   screen itself carries the 20px top breathing room that .app normally
   provides. We intentionally do NOT set padding-bottom here so the inner
   scroll region can extend to the viewport's bottom edge (under the home
   indicator), matching the iOS-native pattern — safe-area is handled inside
   each screen's own bottom padding instead. */
body:has(#screen-word-editor.active) .app,
body:has(#screen-listening.active) .app,
body:has(#screen-memo-editor.active) .app {
  padding-top: env(safe-area-inset-top);
  padding-bottom: 0;
  overflow-y: hidden;
}
/* Compact layout for short viewports. Goal: keep the "学習を始める" CTA visible
   above the bottom-nav on first paint without scrolling. Strategy: shrink
   everything *around* the CTA (stats card, calendar, deck section, etc.)
   so the CTA itself keeps its prominent size.

   ★v1.2.282：(pointer: coarse) を足して**タッチ環境（スマホ・タブレット）専用**にした。
   PCから外した理由：CSS上のビューポート高はブラウザのズームを上げるほど「減る」ので、
   PCでは拡大するほどこの分岐に入りやすい。入った瞬間に本文列が480→400pxに縮み、
   カレンダーのマス目も詰まるため、**拡大したのに小さくなる**という段差になる。
   実測：24.5インチ(911px)は150%で607px、14インチ(551px)は80%で689pxに落ちてここへ入る。
   本人の実測7ケースで「気に入った状態＝この分岐に入っていない」「嫌いな状態＝入っている」が
   完全に一致したため、PCでは適用しない方針に変えた。
   代償：背の低いPCではCTAが画面に入り切らずスクロールが要る場合がある。
   （スマホは元々ブラウザUIの出入りで高さが変わるので、こちらは従来どおり必要） */
/* ★v1.2.474：旧 @media (max-height:700px) の圧縮分岐を廃止。
   スクショ比較（v1.2.473、iPhone）で、PWA（高さ約850px）は通常表示なのに、ブラウザ5種
   （Safari/Chrome/Brave/Google/Twitter内蔵）はURLバー＋ツールバーで650〜700pxに落ちて
   全部この分岐に入り、カレンダーだけ「つぶれて」見えていた。本人判断で
   「ブラウザでもPWAと完全に同じ見た目にし、CTA（学習を始める）が隠れる分は
   スクロールで許容する」に切り替えた。実測でクラスを付け外しする中間段
   （body.home-compact + fitHomeLayout()）も一度作ったが、同じ理由で同バージョン内で撤回。
   下の620px未満（古い小型機・横向き）の非常用圧縮だけ残す。 */
/* 非常用：620px未満（古い小型機・横向き）。v1.2.282でタッチ環境専用に。
   v1.2.474：旧700px分岐の内容をここへ集約（この分岐は単独で完結させる）。 */
@media (max-height: 620px) and (pointer: coarse) {
  .app {
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  body.has-bottom-nav .app {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  .study-stats-card { padding: 5px; margin-bottom: 5px; }
  .stats-summary { margin-bottom: 3px; gap: 3px; }
  .stat-box { padding: 4px 2px; border-radius: 8px; }
  .stat-box .stat-value { --stat-value-size: 13px; }
  .stat-box .stat-label { font-size: 8px; margin-top: 1px; }
  .cal-grid { gap: 2px; }
  .heatmap-cell { padding: 1px 0; min-height: 16px; }
  .heatmap-cell .cal-day { font-size: 8px; }
  .cal-month-nav { margin-bottom: 2px; }
  .cal-month-nav span { font-size: 12px; }
  .cal-dow { --dow-pb: 1px; font-size: 9px; }
  .deck-carousel-section { margin-bottom: 8px; }
  .deck-carousel-header { margin-bottom: 6px; }
  .action-section { margin-top: 4px; margin-bottom: 8px; }
}
/* 横向きのタブレット等：背は低いが幅は広い環境向け。
   （v1.2.282でPCを除外したので「ノートPC向け」ではなくなった。名前は履歴として残す） Strategy: narrow the content
   column so it scales proportionally (like a zoom-out), then apply a few
   modest vertical tightenings on top. Phones (narrow width) are unaffected. */
@media (max-height: 700px) and (min-width: 600px) and (pointer: coarse) {
  /* Narrow the column so the layout looks proportionally scaled, not
     vertically squished. Combined with the vertical tightening below this
     gives a "zoomed-out" feel rather than a "stretched" one. */
  .app {
    max-width: 400px;
    padding-top: calc(0px + env(safe-area-inset-top));
  }
  body.has-bottom-nav .app {
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  }
  /* Stats card */
  .study-stats-card { padding: 6px; margin-bottom: 3px; }
  .stats-summary { margin-bottom: 3px; }
  .stat-box { padding: 4px 2px; }
  .stat-box .stat-value { --stat-value-size: 13px; }
  .stat-box .stat-label { font-size: 8px; }
  /* Calendar */
  .cal-grid { gap: 1px; }
  .heatmap-cell { padding: 1px 0; min-height: 16px; }
  .heatmap-cell .cal-day { font-size: 10px; }
  .cal-month-nav { margin-bottom: 1px; }
  .cal-month-nav span { font-size: 12px; }
  .cal-dow { --dow-pb: 1px; font-size: 9px; }
  /* Deck section */
  .deck-carousel-section { margin-bottom: 3px; }
  .deck-carousel-header { margin-bottom: 1px; }
  .deck-card { padding: 10px 14px; }
  .deck-card .dc-donut { width: 40px; height: 40px; }
  /* "新しいデッキを追加" button */
  .secondary-btn { padding: 10px; font-size: 14px; }
  /* Action section */
  .action-section { margin-top: 0; margin-bottom: 0; }
}
/* Listening screen: tighten layout for short viewports so the play
   controls stay visible above the bottom-nav.
   v1.2.282：他のコンパクト分岐と揃えてタッチ環境専用にした（理由は上のブロック参照）。 */
@media (max-height: 700px) and (pointer: coarse) {
  /* 絞り込み＋並び替えの行（v1.2.342で2行→1行。v1.2.343で見出しも撤去） */
  #screen-listening .list-filter-bar { margin-bottom: 6px; }
  /* Player area: tighten top padding */
  #screen-listening.active { padding-top: 8px; }
  .listening-player { padding: 8px 20px 8px; }
  .listening-progress { margin-bottom: 2px; font-size: 12px; }
  .listening-seekbar { margin-bottom: 8px; }
  /* Card: less internal padding */
  .listening-card { padding: 16px 20px; }
  /* Controls: reduce gap and bottom margin */
  .listening-controls { margin-bottom: 4px; margin-top: 4px; gap: 16px; }
  .listening-ctrl-btn.play { width: 56px; height: 56px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .app {
    max-width: 700px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
  /* Stats card */
  .study-stats-card { padding: 18px; margin-bottom: 20px; border-radius: 20px; }
  .stats-summary { gap: 6px; margin-bottom: 14px; }
  .stat-box { padding: 16px 4px; border-radius: 12px; }
  .stat-box .stat-value { --stat-value-size: 22px; }
  .stat-box .stat-label { font-size: 11px; margin-top: 5px; }
  /* Calendar */
  .heatmap-section { margin-top: 6px; }
  .cal-month-nav span { font-size: 15px; }
  .cal-month-nav button { font-size: 18px; }
  .cal-grid { gap: 6px; }
  .cal-dow { font-size: 12px; --dow-pb: 6px; }
  .heatmap-cell { padding: 14px 0; border-radius: 8px; }
  .heatmap-cell .cal-day { font-size: 15px; }
  /* Deck section */
  .deck-carousel-section { margin-bottom: 18px; }
  .deck-carousel-header { margin-bottom: 12px; }
  .deck-carousel-header h3 { font-size: 16px; }
  .deck-list-grid { gap: 8px; }
  .deck-card { padding: 16px 20px; min-width: 200px; gap: 14px; border-radius: 14px; }
  .deck-card .dc-name { font-size: 16px; }
  .deck-card .dc-meta { font-size: 12px; }
  .deck-card .dc-donut { width: 52px; height: 52px; }
  .deck-card .dc-pct { font-size: 11px; letter-spacing: -0.3px; }
  .deck-card .dc-pct-label { font-size: 6px; }
  .dc-thumb { width: 72px; height: 72px; border-radius: 12px; }
  .deck-card { min-height: 108px; } /* v1.2.800: 72 + 16×2 + 2×2 */
  .secondary-btn { padding: 16px; font-size: 16px; border-radius: 14px; }
  /* Action section */
  .action-section { margin-top: 8px; }
  .action-btn { padding: 28px; gap: 20px; border-radius: 20px; }
  .action-btn.study { min-height: 150px; }
  .action-btn .icon { width: 72px; height: 72px; border-radius: 50%; }
  .action-btn .text h3 { font-size: 20px; }
  .action-btn .text p { font-size: 14px; }
  .level-select-row { justify-content: center; }
}

/* ===== v1.2.143: タブレット（タテ）のリスニング画面 =====
   iPadのタテではプレイヤーが上に寄り、下に画面の4割ほど余白が残る。対策は
     ①カードと文字・ボタンを一回り大きくする
     ②縦の余りを上下に配分する（＝中央寄せ。下のブロック）
   条件を (min-width:768px) and (max-width:1023px) にしているのは、上のホーム用
   ブロックと同じ範囲＝タブレットのタテだけを対象にするため。iPadのヨコは
   1180pxなので従来どおり480px列のまま、PC（1024px以上）も変わらない。
   ※iPad mini のタテは744pxなので対象外。含めたければ上のホーム用ブロックと
     このブロックの 768px を両方 740px に下げる（スマホは最大でも約440px）。 */
@media (min-width: 768px) and (max-width: 1023px) {
  /* 中央列が700pxあるので、400px固定のままだと細く見える */
  .listening-seekbar { max-width: 560px; }
  /* カードは高さを固定する（モバイル用<=600pxと同じ考え方）。可変のままだと
     長文で背が伸び、下の中央寄せがはみ出す原因になる。長い問題文・答えは
     従来どおり .listening-question / .listening-answer 内でスクロールする。 */
  .listening-card {
    max-width: 560px;
    height: 340px;
    min-height: 340px;
    max-height: 340px;
    padding: 32px 28px;
    gap: 20px;
    border-radius: 20px;
  }
  /* v1.2.164: 22px以上になるのはこの幅から。光学トラッキングもここで掛ける。 */
  .listening-question { font-size: 30px; letter-spacing: -0.02em; }
  .listening-answer { font-size: 26px; min-height: 34px; letter-spacing: -0.02em; }
  .listening-progress { font-size: 16px; margin-bottom: 10px; }
  /* 操作系：タブレットは目からの距離が遠いので一回り大きく。
     SVGのwidth/height属性はCSS側で上書きできる。 */
  .listening-controls { gap: 32px; }
  .listening-controls .listening-ctrl-btn svg { width: 32px; height: 32px; }
  .listening-controls .listening-ctrl-btn.play { width: 80px; height: 80px; }
  .listening-controls .listening-ctrl-btn.play svg { width: 42px; height: 42px; }
}
/* 縦の余りを上下に配分する。ただし .listening-player は overflow-y:auto の
   スクロールコンテナなので、内容が入り切らない高さで中央寄せにすると上側が
   はみ出してスクロールで戻れなくなる（flexの既知の罠）。そこで二重の保険：
     ①高さ800px以上でのみ有効化（カード340px固定なら必ず収まる高さ）
     ②safe center 対応ブラウザではそちらが後勝ちで適用され、はみ出す時は
       自動で上寄せに戻る。未対応ブラウザは1行目のcenterが残るだけで無害。 */
@media (min-width: 768px) and (max-width: 1023px) and (min-height: 800px) {
  .listening-player {
    justify-content: center;
    justify-content: safe center;
  }
}
/* v1.2.597: iPad（タテ）で上下に余白が残るので、問題枠を縦に広げる（340→440px）。
   実測（820x1180）：プレイヤーの高さ約930pxに対し中身は約570px＝上下で約360px余っていた。
   100pxを枠に回し、残りは上の中央寄せが上下に均等に配る。
   min-height:1000px で切るのは、SafariのURLバー表示中の 768x1024 級など背の低い
   タブレットでは従来の340pxのままにして、中央寄せがはみ出さないようにするため。 */
@media (min-width: 768px) and (max-width: 1023px) and (min-height: 1100px) {
  /* v1.2.598: 440→500px（まだ上下が余って見えたので、さらに60px枠へ回す）。
     中身は約730pxになるが、この条件の下限（高さ1000px）でもプレイヤーは約800px取れるので収まる。 */
  /* v1.2.599: 500→550px。あわせて条件を min-height:1000px→1100px に上げた（上のコメントの
     「1000px」「約800px取れる」は見積もりが甘かった）。スクショ実測ではプレイヤーに使えるのは
     画面高さ−約250px（上のバー類145＋下部ナビ105）、中身は上下paddingを含めて 枠＋約274px。
     768x1024 だと使えるのは約774pxで、500pxの時点で既にぎりぎりだった。1100px はホームの
     タブレット用ブロックと同じしきい値（768x1024 級を除外）。1100px時：850px に対し中身824px。 */
  .listening-card {
    height: 550px;
    min-height: 550px;
    max-height: 550px;
  }
}

/* Header */
.header {
  text-align: center;
  padding: 24px 0 20px;
}
.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-600);
  letter-spacing: -0.5px;
}
.header h1 span { font-size: 32px; }
.header p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
}
.header { position: relative; min-height: 40px; }
.header h1 { padding-right: 90px; }
/* Import screen: extra top breathing room (initial home) */
#screen-import {
  padding-top: 80px;
}
@media (max-width: 640px) {
  #screen-import {
    padding-top: 24px;
  }
}
/* Import screen header: hamburger left, help right */
#screen-import .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
#screen-import .hamburger-btn {
  position: static;
}


/* Celebration */
/* ===== v1.2.788: 連続記録の1枚（その日最初のクイズ完走→結果画面の前に挟む） =====
   全画面・不透明。地は --bg（ライト／ダーク共通の変数）。z-index は確認ダイアログ
   （3100）より下・設定パネル（3000）より上＝結果画面と同じ層の一番上。
   紙吹雪の canvas（9999）はこの上に乗る。 */
.streak-overlay {
  position: fixed; inset: 0; z-index: 3050;
  display: none;
  background: var(--bg);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.streak-overlay.show { display: flex; animation: fadeInOverlay 0.2s ease; }
.streak-flame { width: 96px; height: 115px; display: block; margin: 0 auto 6px; overflow: visible; }
/* v1.2.791: 節目のきらめき。点灯後にポンと出て、以後ゆっくり明滅。星の位置は
   記録カードと同じ（右上と左中）。節目以外は出さない。 */
.streak-flame .sf-star { fill: #FBBF24; opacity: 0; transform-box: fill-box; transform-origin: center; transform: scale(0); }
.streak-overlay.is-milestone.lit .sf-star { animation: streakStarPop 0.45s cubic-bezier(.2,1.5,.5,1) 0.25s forwards, streakStarTwinkle 1.6s ease-in-out 0.7s infinite; }
.streak-overlay.is-milestone.lit .sf-star2 { animation-delay: 0.4s, 1.1s; }
@keyframes streakStarPop { from { opacity: 0; transform: scale(0) rotate(-30deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes streakStarTwinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.8); } }
/* v1.2.791: 節目は数字を一回り大きく（72→90px、単位も 26→32px） */
.streak-overlay.is-milestone .streak-num { font-size: 90px; }
.streak-overlay.is-milestone .streak-unit { font-size: 32px; }
.streak-flame .sf-outer { fill: #D1D5DB; transition: fill 0.35s ease; }
.streak-flame .sf-inner { fill: #E5E7EB; transition: fill 0.35s ease; }
body.dark-mode .streak-flame .sf-outer { fill: #4a4556; }
body.dark-mode .streak-flame .sf-inner { fill: #5c5769; }
.streak-overlay.lit .streak-flame .sf-outer { fill: #F97316; }
.streak-overlay.lit .streak-flame .sf-inner { fill: #FCD34D; }
.streak-overlay.lit .streak-flame { animation: streakFlamePop 0.5s cubic-bezier(.2,1.4,.5,1); }
@keyframes streakFlamePop { 0% { transform: scale(0.92); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }
/* 数字：縦ロール。.streak-num の高さ 1em の窓の中で、前日までの数字と今日の数字を
   縦に並べた .streak-roll を上へ 1em 動かす。 */
.streak-num {
  display: inline-flex; align-items: baseline; justify-content: center;
  font-family: var(--font-ui);
  font-size: 72px; font-weight: 800; line-height: 1;
  color: var(--gray-400);
  transition: color 0.35s ease;
  letter-spacing: -0.02em;
}
.streak-overlay.lit .streak-num { color: #EA580C; }
.streak-overlay.lit.is-milestone .streak-num { color: #D97706; }
.streak-num-win { display: inline-block; height: 1em; overflow: hidden; vertical-align: baseline; }
.streak-roll { display: flex; flex-direction: column; transition: transform 0.55s cubic-bezier(.3,1.1,.4,1); }
.streak-roll > span { display: block; height: 1em; line-height: 1; }
.streak-overlay.lit .streak-roll { transform: translateY(-1em); }
.streak-unit { font-size: 26px; font-weight: 700; margin-left: 4px; }
.streak-line {
  font-size: 17px; font-weight: 600; color: var(--gray-600);
  margin-top: 10px; min-height: 24px;
  opacity: 0; transform: translateY(6px); transition: opacity 0.35s ease 0.25s, transform 0.35s ease 0.25s;
}
.streak-overlay.lit .streak-line { opacity: 1; transform: none; }
.streak-overlay.is-milestone .streak-line { color: #D97706; }
body.dark-mode .streak-overlay.is-milestone .streak-line { color: #F59E0B; }
/* 直近7日：右端が今日。学習した日はブランド緑、していない日は薄い灰。
   今日のマスは点灯の少し後に塗られる（.today に .on）。 */
.streak-week { display: flex; gap: 8px; justify-content: center; margin-top: 26px; }
.streak-day { width: 34px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.streak-day .sd-label { font-size: 11px; font-weight: 600; color: var(--gray-400); }
.streak-day .sd-cell {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--gray-200);
  transition: background 0.3s ease, transform 0.3s cubic-bezier(.2,1.4,.5,1);
}
.streak-day.done .sd-cell { background: var(--brand-500); }
.streak-day.today .sd-cell { box-shadow: inset 0 0 0 2px var(--brand-500); }
.streak-day.today.on .sd-cell { background: var(--brand-500); transform: scale(1.12); }
.streak-day.today .sd-label { color: var(--gray-600); }
.streak-continue {
  margin-top: 36px;
  background: var(--brand-500); color: #fff; border: none;
  padding: 15px 48px; border-radius: 50px;
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  opacity: 0; transition: opacity 0.3s ease 0.6s, transform 0.15s;
}
.streak-overlay.lit .streak-continue { opacity: 1; }
.streak-continue:active { transform: scale(0.97); }
@media (prefers-reduced-motion: reduce) {
  .streak-overlay.show { animation: none; }
  .streak-flame .sf-outer, .streak-flame .sf-inner, .streak-num, .streak-roll, .streak-line,
  .streak-day .sd-cell, .streak-continue { transition: none !important; animation: none !important; }
  .streak-overlay.is-milestone.lit .sf-star { animation: none !important; opacity: 1; transform: none; }
}
.celebration-modal { text-align: center; }

/* v1.2.163: 「◯周目クリア！」の行。3周目以降は .is-gold で金色になる。
   transition:all を持たせないのは既知の教訓（v1.2.126）どおり。 */
.celebration-lap {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-500);
  margin-bottom: 10px;
  letter-spacing: 0.2px;
}
.celebration-lap.is-gold {
  color: #D97706;
  text-shadow: 0 0 10px rgba(217, 119, 6, 0.25);
}
body.dark-mode .celebration-lap.is-gold { color: #F59E0B; }

/* Demo picker */
.demo-picker-modal { max-height: 80vh; }
/* v1.2.690: 記録カードのダイアログは max-height:80vh を外す。ノートPC（zoom 0.8）では
   80vh が実質64%に縮む一方、中身（プレビュー260px＋ボタン3つ＋案内＋閉じる）は
   縮まず、上限を超えた分が白い箱の外にはみ出していた（overflow 未指定）。
   丈は中身なりにし、入り切らない背の低い窓では .confirm-overlay 側のスクロールに
   任せる（margin:auto で上端が切れないように）。背の低い窓ではプレビューも一回り小さく。 */
#recordCardOverlay .confirm-modal { max-height: none; margin: auto; }
@media (max-height: 700px) {
  #recordCardPreviewWrap { max-width: 210px !important; }
}
.demo-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.demo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: transform 0.15s;
  text-align: left;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  background-clip: padding-box;
  background-image: none;
}
.demo-list-picker .demo-item {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  justify-content: initial;
  text-align: left;
}
.demo-list-picker .demo-item .demo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.demo-list-picker .demo-item .demo-label {
  text-align: center;
  color: var(--gray-700);
  font-weight: 600;
  font-size: 14px;
}
.demo-list-picker .demo-item .demo-count {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}
/* v1.2.804: 英語表示では右の「30 cards」が 28px の列に収まらず枠の外に切れていた。
   英語デモの一覧だけ左右の列を 60px に広げる（左右同幅のままなので項目名の中央寄せは崩れない）。 */
.demo-list-en.demo-list-picker .demo-item {
  grid-template-columns: 60px 1fr 60px;
}
@media (hover: hover) {
.demo-item:hover { border-color: var(--brand-400); background: var(--brand-50); }
}
.demo-item:active { background: var(--gray-50); }
.demo-item.selected,
.demo-item.selected:active,
.demo-item.selected:focus,
.demo-item.selected:focus-visible {
  border: 2px solid var(--brand-400) !important;
  outline: 2px solid var(--brand-400) !important;
  outline-offset: -2px;
  background: var(--brand-50) !important;
  color: var(--brand-500) !important;
  position: relative;
  z-index: 1;
}

/* CSV Table Preview */
.csv-table-modal {
  background: white;
  border-radius: 20px;
  max-width: 95vw;
  width: 600px;
  /* v1.2.274: PC拡大が1.21倍になったので 85vh のままだと 85×1.21≒103% で
     画面からはみ出す。#pwaGuideCard / .img-lightbox img と同じ理由で
     zoom補正済みの --app-height に置き換える（v1.2.154 の落とし穴と同じ）。 */
  max-height: 85vh;
  max-height: calc(var(--app-height, 100dvh) * 0.85);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s ease;
  overflow: hidden;
}
.csv-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.csv-table-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}
.csv-table-dl {
  display: flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: var(--brand-500);
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.csv-table-dl:active { opacity: 0.8; }
.csv-table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.csv-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.csv-table-wrap th {
  position: sticky;
  top: 0;
  /* v1.2.851: ライトの :root に --gray-50 が無く透明になり、スクロールした中身が見出しに透けて重なっていた。
     ライトだけ既定値 #F9FAFB を当てる（ダークは従来どおり --gray-50 / 下の dark-mode ルール）。 */
  background: var(--gray-50, #F9FAFB);
  z-index: 1;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
@media (hover: hover) {
.csv-table-wrap th:hover { color: var(--brand-500); }
}
.csv-table-wrap th .sort-arrow {
  display: inline-block;
  margin-left: 3px;
  font-size: 10px;
  color: var(--gray-300);
}
.csv-table-wrap th.sorted .sort-arrow { color: var(--brand-500); }
.csv-table-wrap td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.csv-table-wrap tr:last-child td { border-bottom: none; }
.csv-table-wrap td:nth-child(n+5),
.csv-table-wrap th:nth-child(n+5) {
  text-align: center;
}
/* Note column (4th) — left-align text */
.csv-table-wrap td:nth-child(4),
.csv-table-wrap th:nth-child(4) {
  text-align: left;
}
body.dark-mode .csv-table-modal { background: #1e1a28; }
body.dark-mode .csv-table-header { border-color: #3a3545; }
body.dark-mode .csv-table-wrap th { background: #2a2535; color: var(--gray-400); border-color: #3a3545; }
body.dark-mode .csv-table-wrap td { border-color: #2a2535; }

/* CSV Table deck tabs */
.csv-table-tabs {
  display: none;
  gap: 0;
  border-top: 1px solid var(--gray-200);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
  background: var(--gray-50);
  border-radius: 0 0 20px 20px;
}
.csv-table-tabs.show { display: flex; }
.csv-table-tab {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-right: 1px solid var(--gray-200);
}
.csv-table-tab:active { opacity: 0.7; }
.csv-table-tab.active {
  color: var(--brand-500);
  background: white;
  font-weight: 600;
}
body.dark-mode .csv-table-tabs { background: #2a2535; border-color: #3a3545; }
body.dark-mode .csv-table-tab { color: var(--gray-500); border-color: #3a3545; }
body.dark-mode .csv-table-tab.active { color: var(--brand-400); background: #1e1a28; }
.demo-item span {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 500;
  flex-shrink: 0;
}

/* Format tabs */
.format-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.format-tab {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-200);
  background: white;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
}
.format-tab.active {
  background: var(--brand-500);
  color: white;
  border-color: var(--brand-500);
}

/* Screen transitions */
/* Fade-in removed (v1.0.94): the 0.12s opacity animation was visible as a
   "薄い→濃い" flicker every time a screen activated, especially noticeable
   when returning to the dashboard on iOS PWA. Showing screens instantly
   eliminates the flicker and also removes the brief tap-deadzone that
   existed during the animation. */
.screen { display: none; position: relative; }
.screen.active { display: block; }

/* Import screen */
/* v1.2.468: 初回画面のコンセプト1行。上余白は #screen-import の padding-top に任せる。
   色は --gray-900/--gray-500 なのでダークモードは既存の変数反転に乗る。 */
.intro-block {
  text-align: center;
  margin-bottom: 18px;
}
.intro-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.4;
  margin: 0;
}
.intro-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 26px;
  letter-spacing: 0.02em;
}
.intro-brand img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  flex: none;
}
.intro-sub {
  font-size: 13px;
  color: var(--gray-500);
  margin: 8px 0 0;
  line-height: 1.5;
}
.import-dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 0;
}
.import-dual-row .import-area {
  padding: 18px 12px;
}
.import-dual-row .import-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  font-size: 22px;
}
.import-dual-row .import-area h3 {
  font-size: 13px;
  margin-bottom: 4px;
  line-height: 1.4;
}
.import-dual-row .import-area p {
  font-size: 11px;
  line-height: 1.4;
}
.import-json-area {
  border-color: var(--gray-200);
}
/* v1.2.479: 「他の端末から移行」の小リンク。タイルより一段下の存在感にする。 */
.import-migrate-row {
  margin-top: 10px; /* v1.2.794: 最下段になったのでタイル直下の20px→他の行と同じ10px */
}
/* v1.2.480: 中央寄せの下線リンクだと左右に余白が残りバランスが悪いので、
   下の .format-hint と同じ幅いっぱいのグレー行に揃える（左に文言・右に ›）。 */
.import-migrate-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--gray-100);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.import-migrate-link::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--gray-500);
  border-bottom: 2px solid var(--gray-500);
  transform: rotate(-45deg);
  margin-right: 6px;
}
/* v1.2.516: 補足（JSONファイル）は薄く */
.import-migrate-link .import-migrate-sub { font-size: 11px; }
body.dark-mode .import-migrate-link { background: #1e1a28; }
@media (hover: hover) {
.import-migrate-link:hover { color: var(--gray-700); }
}
@media (hover: hover) {
.import-json-area:hover {
  border-color: var(--gray-300);
}
}
.import-area {
  background: white;
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid #E5E7EB;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s; /* v1.2.177: 枠線・背景は即時 */
  position: relative;
  overflow: hidden;
}
@media (hover: hover) {
.import-area:hover {
  border-color: var(--gray-300);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}
}
.import-area.dragover {
  border-color: var(--brand-500);
  background: var(--brand-50);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.import-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--brand-100);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.import-area h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--gray-800);
}
.import-area p {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.6;
}
.import-area input { display: none; }

.format-hint {
  margin-top: 20px; /* v1.2.794: タイル直下に来たので旧 .import-migrate-row と同じ20px */
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: left;
}
/* v1.2.468: 折りたたみの見出し。既定のマーカーは消して右端に ▾ を置く（開くと ▴）。 */
.format-hint-summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.format-hint-summary::-webkit-details-marker { display: none; }
.format-hint-summary::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--gray-500);
  border-bottom: 2px solid var(--gray-500);
  transform: rotate(-45deg);
  margin-right: 6px;
  transition: transform 0.15s;
}
/* v1.2.480: 上の「引き継ぐ」行と矢印を揃えて閉時は ›、開くと ˅ に回転 */
.format-hint[open] .format-hint-summary::after {
  transform: rotate(45deg);
}
.format-hint code {
  display: block;
  font-family: monospace;
  font-size: 13px;
  color: var(--gray-600);
  line-height: 1.8;
}

/* v1.2.468: 初回画面の主役ボタン（旧 .demo-btn のピルを置き換え）。
   幅いっぱい・主文＋副文の2段。色はブランド緑でライト／ダーク共通。
   transition:all は使わない（テーマ切替が遅れる既知の問題）。 */
.demo-hero-btn {
  display: block;
  width: 100%;
  background: var(--brand-500);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 16px 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(74,158,63,0.3);
  -webkit-tap-highlight-color: transparent;
}
.demo-hero-btn:active { transform: scale(0.98); }
.demo-hero-main {
  display: block;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
@media (hover: hover) {
.demo-hero-btn:hover {
  background: var(--brand-600);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(74,158,63,0.4);
}
}
/* 「自分の単語帳を作る」の区切り見出し。左右に線。 */
.import-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 10px;
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
}
.import-section-label::before,
.import-section-label::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--gray-200);
}

/* v1.2.132: 初回画面（#screen-import）から使い方ガイドへの導線。
   デッキ0件の新規ユーザーはこの画面しか見えないので、ここが唯一の入口。
   デモボタンと競合しないよう、あえて控えめなテキストリンク調にする。
   transition:all は使わない（テーマ切替が遅れる既知の問題）。 */
/* v1.2.480: 上の「引き継ぐ」「フォーマット例」と同じ幅いっぱいのグレー行に統一 */
.guide-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  color: var(--gray-600);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.guide-link::after {
  content: '';
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--gray-500);
  border-bottom: 2px solid var(--gray-500);
  transform: rotate(-45deg);
  margin-right: 6px;
}
body.dark-mode .guide-link { background: #1e1a28; }
@media (hover: hover) {
  .guide-link:hover { color: var(--gray-700); }
}

/* ===== Deck Selector ===== */
/* Horizontal Deck Carousel */
.deck-carousel-section {
  margin-bottom: 12px;
}
.deck-carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.deck-carousel-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
}
.section-icon {
  vertical-align: -3px;
  margin-right: 2px;
}
.deck-list-grid {
  display: flex;
  flex-direction: row;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.deck-list-grid.dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}
.deck-list-grid::-webkit-scrollbar { display: none; }
.deck-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  /* transition:allは選択時のborder/backgroundの切り替わりを遅らせていた。
     色関連は即時反映、transformのみ短い補間で押した感だけ残す */
  transition: transform 0.1s;
  border: 2px solid var(--gray-200);
  flex-shrink: 0;
  min-width: 160px;
  /* v1.2.800: サムネの有無で高さが変わらないように、サムネあり（56px＋上下 padding 10px×2＋枠 2px×2）と
     同じ高さを最低限にする。ほかの画面幅の値は各 @media の .dc-thumb の隣で上書き */
  min-height: 80px;
  position: relative; /* .dc-memo-badge / .dc-checkbox など子要素の絶対配置の基準 */
}
.deck-card:active { transform: scale(0.98); }
.deck-card.active {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 1px var(--brand-200);
  background: var(--brand-50);
}
.deck-card .dc-donut,
.deckrow .dc-donut {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  position: relative;
}
.dc-crown {
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
}
.dc-crown.gold {
  filter: none;
}
.dc-conic {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  -webkit-mask: radial-gradient(farthest-side, transparent 62%, #000 63%);
  mask: radial-gradient(farthest-side, transparent 62%, #000 63%);
}
.deck-card .dc-donut-center,
.deckrow .dc-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.deck-card .dc-pct,
.deckrow .dc-pct {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-700);
  line-height: 1;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}
.deck-card .dc-pct-label,
.deckrow .dc-pct-label {
  font-size: 5px;
  color: var(--gray-400);
  margin-top: 0;
}
.deck-card-info {
  flex: 1;
  min-width: 0;
}
.deck-card .dc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}
.deck-card.active .dc-name {
  color: var(--gray-800);
}
.deck-card .dc-meta {
  font-size: 10px;
  color: var(--gray-400);
}

/* v1.2.163: 「◯周目」バッジ。デッキカードと全デッキ一覧の meta 行で共用する。
   周回を1度も終えていないデッキでは JS 側が要素ごと出さないので、
   初めて使う人の画面には現れない。高さを増やさないよう inline 表示。 */
.dc-lap {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
  font-weight: 600;
  white-space: nowrap;
}
body.dark-mode .dc-lap {
  background: rgba(255, 255, 255, 0.08);
  color: var(--gray-400);
}

/* ===== Deck thumbnail ===== */
.dc-thumb {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--gray-100);
  display: none;
  /* 画像アイコン風プレースホルダー（山+太陽のSVG） */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bfc3cf' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='18' rx='2' ry='2'/><circle cx='8.5' cy='9' r='1.5'/><path d='M21 15l-5-5L5 21'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 56%;
}
.dc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
  background: var(--gray-100);
}
.dc-thumb.has-img { display: block; }

/* All Decks (deckrow) 画面ではサムネが無くても枠を常時表示して左端位置を揃える */
.deckrow .dc-thumb { display: block; }

/* Deck edit modal thumbnail */
.de-thumb-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.de-thumb-preview {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--gray-100);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gray-200);
  cursor: pointer;
  position: relative;
}
.de-thumb-preview.has-img {
  border-style: solid;
  border-color: var(--gray-200);
}
.de-thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.de-thumb-preview .de-thumb-placeholder {
  color: var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
}
.de-thumb-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.de-thumb-btn {
  border: none;
  background: var(--gray-50);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.de-thumb-btn:active { opacity: 0.7; }
.de-thumb-btn.remove { color: var(--red-400); }
body.dark-mode .de-thumb-preview {
  background: #2a2535;
  border-color: #3a3545;
}
/* v1.2.508: ライトの背景 --gray-50 はモーダルの白とほぼ同色で箱に見えないが、
   ダークの #2a2535 はモーダル地（#1e1a28）より明るく枠付きに見えていた。透明に。 */
body.dark-mode .de-thumb-btn {
  background: transparent;
  color: var(--gray-400);
}
body.dark-mode .dc-thumb {
  background-color: #2a2535;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234a4558' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='18' rx='2' ry='2'/><circle cx='8.5' cy='9' r='1.5'/><path d='M21 15l-5-5L5 21'/></svg>");
}
body.dark-mode .dc-thumb img {
  background: #2a2535;
}

/* ===== All Decks (deckrow) long-press drag reorder ===== */
/* Live-swap style: the held row itself lifts and follows the pointer. */
.deckrow.deckrow-live-drag {
  position: relative;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  background: white;
  cursor: grabbing;
  /* translateY is set inline during drag; no transition so it tracks the
     pointer 1:1. Other rows DO animate as they slide into place. */
  transition: none;
}
body.dark-mode .deckrow.deckrow-live-drag {
  background: #1f1a2a;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
/* Non-held rows animate their position change during live swaps. */
.all-decks-list .deckrow:not(.deckrow-live-drag) {
  transition: transform 0.18s ease;
}
/* Deck select mode */
.deck-card .dc-checkbox,
.deckrow .dc-checkbox {
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: white;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.deck-select-mode .deck-card .dc-checkbox,
.deck-select-mode .deckrow .dc-checkbox {
  display: flex;
}
.deck-card .dc-checkbox.checked,
.deckrow .dc-checkbox.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.deck-card .dc-checkbox.checked::after,
.deckrow .dc-checkbox.checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
/* v1.2.498: 全デッキのチェックは「一覧」（.ew-checkbox）と同じ作り＝小さな角丸四角を
   カード左上角に絶対配置。flex の流れから外すのでサムネや文字が右に押されず、
   選択モードに入っても行の中身が動かない。タップは行全体で受ける。 */
.deckrow { position: relative; }
.deckrow .dc-checkbox {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--gray-300);
  z-index: 2;
  pointer-events: none;
}
.deckrow .dc-checkbox.checked::after {
  width: 4px;
  height: 7px;
  border-width: 0 2px 2px 0;
}
body.dark-mode .deck-card .dc-checkbox,
body.dark-mode .deckrow .dc-checkbox {
  background: #2a2535;
  border-color: #3a3545;
}
body.dark-mode .deck-card .dc-checkbox.checked,
body.dark-mode .deckrow .dc-checkbox.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
/* Deck edit overlay */
.deck-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeInOverlay 0.2s ease;
  overflow-y: auto;
}
.deck-edit-overlay.show { display: flex; }
.deck-edit-modal {
  background: white;
  border-radius: 20px;
  /* v1.2.157: 見出し「デッキを編集」を削除した。見出しが右上のアイコンボタン
     （top:14px / 高さ36px = 50pxまで占有）の下へコンテンツを押し出す役割も
     兼ねていたため、padding-top で同等の余白を確保する。24pxのままだと
     サムネイル欄がボタンに重なる。 */
  padding: 58px 20px 20px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s ease;
  position: relative;
}
/* デッキ編集モーダル右上の印刷ボタン。
   印刷は破壊的操作（リセット/削除）と性質が違い、使用頻度も高いので、
   ボタンリストに混ぜず一等地（右上）にアイコン昇格させている。 */
.deck-edit-print-btn,
.deck-edit-export-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent; /* 塗りも枠線もなし・アイコンだけ（クイズカード上部と同じ。ホバー・ダークは元から同じ方針） */
  border: none;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  padding: 0;
  z-index: 1;
}
@media (hover: hover) {
.deck-edit-print-btn:hover,
.deck-edit-export-btn:hover {
  background: var(--gray-200);
}
}
.deck-edit-print-btn:active,
.deck-edit-export-btn:active {
  transform: scale(0.92);
}
/* v1.2.418: エクスポートボタン。印刷ボタンと同じ見た目で、その左隣（📌と印刷の間）。
   right の 58px = 印刷の right(14px) + 幅(36px) + 間隔(8px)。 */
.deck-edit-export-btn {
  right: 58px;
}
/* v1.2.187: ダークモードでは下敷き（背景と枠線）を消してアイコンだけにする。
   ★元の不具合：ここは background: var(--gray-800) と書いてあったが、
   ダークモードではグレースケールが反転していて --gray-800 は #F2F2F7＝ほぼ白。
   つまり「濃いグレーの下敷き」のつもりが白い四角になり、#1e1a28 のモーダル上で
   浮いていた。--gray-700/800/900 はダーク時は明るい側なので、背景に使わないこと。
   押した感触はホバーと :active の縮小で担保する。 */
body.dark-mode .deck-edit-print-btn,
body.dark-mode .deck-edit-export-btn {
  background: transparent;
  border-color: transparent;
  color: var(--gray-600);
}
@media (hover: hover) {
body.dark-mode .deck-edit-print-btn:hover,
body.dark-mode .deck-edit-export-btn:hover {
  background: var(--gray-100);
}
}
/* デッキ編集モーダル右上のピン留め（ホーム画面表示）ボタン。
   v1.2.148: 左上から印刷ボタンの左隣へ移動。左右に離すより、同種の
   アイコンボタンを右上にまとめた方が視線移動が少なく、押し分けもしやすい。
   v1.2.418: エクスポートボタンがこの右隣に入ったので right を 58px→102px に。
   102px = 印刷(14px) + 幅(36px) + 間隔(8px) + エクスポート幅(36px) + 間隔(8px)。
   印刷・エクスポート側のサイズを変えたらこの値も合わせること。
   タップで isFavorite をトグルし、ホーム画面の表示/非表示を切り替える。
   塗りつぶし（オレンジ）＝ホーム表示中、枠線のみ＝ホーム非表示。
   色は全デッキ画面の📌ボタンと同じ --bookmark に統一。 */
.deck-edit-fav-btn {
  position: absolute;
  top: 14px;
  right: 102px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent; /* 塗りも枠線もなし・アイコンだけ */
  border: none;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  padding: 0;
  z-index: 1;
}
@media (hover: hover) {
.deck-edit-fav-btn:hover {
  background: var(--gray-200);
}
}
.deck-edit-fav-btn:active {
  transform: scale(0.92);
}
.deck-edit-fav-btn.is-fav {
  color: var(--bookmark);
}
/* ピン留めされている時はアイコンを少し傾ける。
   ボタンの :active scale と干渉しないよう、回転は SVG にだけ掛ける。 */
.deck-edit-fav-btn svg { transition: transform 0.15s ease; }
.deck-edit-fav-btn.is-fav svg { transform: rotate(25deg); }
/* v1.2.187: 印刷ボタンと同じ理由で下敷きを消す（上のコメント参照）。
   ピン留め中(.is-fav)のオレンジは下敷きが無くても十分目立つので据え置き。 */
body.dark-mode .deck-edit-fav-btn {
  background: transparent;
  border-color: transparent;
  color: var(--gray-500);
}
@media (hover: hover) {
body.dark-mode .deck-edit-fav-btn:hover {
  background: var(--gray-100);
}
}
body.dark-mode .deck-edit-fav-btn.is-fav {
  color: var(--bookmark);
}
.deck-edit-name-ce {
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  min-height: 20px;
  margin-bottom: 10px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
  word-break: break-all;
}
.deck-edit-name-ce:focus {
  border-color: var(--brand-400);
}
.deck-edit-name-ce:empty::before {
  content: attr(data-placeholder);
  color: var(--gray-300);
  pointer-events: none;
}
.deck-edit-name-ce br { display: none; }
.deck-edit-name-ce * { display: inline; }
.deck-edit-save-btn {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--brand-500);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 16px;
  transition: transform 0.12s; /* v1.2.177: :active の opacity は即時に落とす */
}
.deck-edit-save-btn:active { opacity: 0.8; transform: scale(0.98); }
.deck-edit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deck-edit-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: var(--gray-50);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s;
  text-align: left;
}
@media (hover: hover) {
.deck-edit-btn:hover { background: var(--gray-100); }
}
.deck-edit-btn:active { transform: scale(0.98); }
.deck-edit-btn .de-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
  /* Force GPU compositing so Safari doesn't reposition subpixels
     during modal open animation. Also lock transform to identity
     so nothing inherits or interpolates from a parent animation. */
  transform: translateZ(0);
  will-change: transform;
  contain: layout style paint;
}
.deck-edit-btn .de-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  transform: translateZ(0);
}
.deck-edit-btn.danger {
  color: var(--red-500);
}
@media (hover: hover) {
.deck-edit-btn.danger:hover {
  background: #FEE2E2;
}
}
/* v1.2.164: 全問習得済みのときの「デッキをもう1周する」。同じスロットの
   ボタンが赤からブランド色に変わる＝破壊的な操作ではないことを色で示す。
   transition は .deck-edit-btn 側の transform 限定のまま（v1.2.126の教訓）。 */
.deck-edit-btn.lap {
  color: var(--brand-500);
  background: var(--brand-50);
}
@media (hover: hover) {
.deck-edit-btn.lap:hover {
  background: var(--brand-50);
  filter: brightness(0.96);
}
}

/* Export picker: keep each option on a single line (no wrapping).
   Main label stays readable; the parenthetical descriptor renders
   as a slightly smaller inline sub-label so the longest option
   (CSVファイル（Excel・スプレッドシート用）) fits the modal. */
#exportPickerOverlay .confirm-modal,
#deckExportOverlay .confirm-modal {
  padding-left: 18px;
  padding-right: 18px;
}
#exportPickerOverlay .deck-edit-btn,
#deckExportOverlay .deck-edit-btn {
  white-space: nowrap;
  padding-left: 12px;
  padding-right: 12px;
  gap: 8px;
  overflow: hidden;
}
#exportPickerOverlay .deck-edit-btn .de-sub,
#deckExportOverlay .deck-edit-btn .de-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-500);
  margin-left: 1px;
}

/* Dashboard */

/* Action buttons */
.action-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.action-btn {
  background: white;
  border: none;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  /* transition:all はタップ時の視覚反応を遅らせる。hover変化だけ短めに残す */
  transition: box-shadow 0.2s, transform 0.1s;
  text-align: left;
}
@media (hover: hover) {
.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
}
.action-btn:active { transform: scale(0.98); }
.action-btn .icon {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.action-btn.study .icon {
  /* v1.2.569: 斜めグラデーション（brand-400→600）をやめ、リスニングの再生ボタンと同じ単色に揃えた */
  background: var(--brand-500);
  border-radius: 50%;
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
}
.action-btn.study {
  position: relative;
  min-height: 130px;
  padding-top: 36px;
  padding-bottom: 36px;
}
.action-btn.study .text {
  width: 100%;
  text-align: center;
}
.action-btn .text h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
}
.action-btn .text p {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 3px;
}
.secondary-btn {
  flex: 1;
  background: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
@media (hover: hover) {
.secondary-btn:hover { background: var(--gray-100); }
}

/* Quiz screen */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
/* v1.2.343: リスニング見出し用の上書き（#screen-listening .quiz-header /
   .quiz-progress-text）は、見出しごと撤去したので削除した。
   .quiz-header と .quiz-progress-text 本体はクイズ画面が使っているので残す。 */
.quiz-back {
  background: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--gray-200); /* v1.2.749: 影→1pxの灰色の輪（問題カードと統一） */
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) {
.quiz-back:hover { background: var(--gray-100); }
}
.quiz-progress-text {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
}
/* v1.2.866: クイズ画面の進捗バー（.quiz-progress-bar／#quizProgressFill）は削除。
   上の「n / N」と役割が重なり、タイマーONでカード上端のタイマーのバーと横線が2本並んでいたため。 */

#screen-quiz {
  display: none;
  flex-direction: column;
  touch-action: none;
  overscroll-behavior: none;
}
#screen-quiz.active {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Use --app-height so the screen shrinks with the visual viewport when the iOS keyboard opens.
     This lets flex:1 on .quiz-card-area distribute space correctly (no giant gap below the card). */
  height: var(--app-height, 100dvh);
  z-index: 50;
  background: var(--bg, #F8F9FA);
  padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) env(safe-area-inset-bottom) calc(16px + env(safe-area-inset-left));
  overflow: visible;
  max-width: 480px;
  margin: 0 auto;
}
/* When the on-screen keyboard is open (iOS PWA typing mode), the home-indicator
   safe area is already covered by the keyboard/accessory bar, so the bottom
   safe-area padding would create a visible gap between the input-hint and
   the keyboard toolbar. Collapse bottom padding and tighten the hint. */
html[data-kb-open] #screen-quiz.active {
  padding-bottom: 0;
  /* v1.2.761: キーボード表示中は、iOS が「見えている範囲」（visual viewport）だけを下へずらす
     ことがある（入力欄をタップし直したとき等）。fixed の top:0 は見えない範囲の上端なので、
     画面ごと上に隠れて下に同じだけ余白ができていた。見えている範囲の上端に追従させる。 */
  top: var(--vv-top, 0px);
}
html[data-kb-open] .input-hint {
  padding: 4px 0 2px;
}
/* タブレット・PC（min-width: 768px以上）のカードモード時のみ、
   クイズ画面が縦に伸びすぎて画面下端と重ならないよう下部に余白を追加する。
   タイピングモード（.typing-mode）ではソフトキーボードのためのレイアウトを維持するため適用しない。 */
@media (min-width: 768px) {
  #screen-quiz.active:not(.typing-mode) {
    padding-bottom: calc(env(safe-area-inset-bottom) + 40px);
  }
}
@media (min-width: 1024px) {
  #screen-quiz.active:not(.typing-mode) {
    padding-bottom: calc(env(safe-area-inset-bottom) + 60px);
  }
}
.quiz-card-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: visible;
}
.quiz-card-next {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: white;
  border-radius: 16px;
  padding: 14px 16px 10px;
  text-align: center;
  box-shadow: 0 0 0 1px var(--gray-200); /* v1.2.748: 影の代わりに1pxの灰色の縁（box-shadowで描くので中身の位置は動かない） */
  z-index: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.quiz-card-next::before {
  display: none;
}
.quiz-card-next.is-empty { visibility: hidden; } /* v1.2.884: 最後の1枚の裏には何も置かない */
.quiz-card {
  background: white;
  border-radius: 16px;
  padding: 14px 16px 10px;
  text-align: center;
  box-shadow: 0 0 0 1px var(--gray-200); /* v1.2.747: にじむ影を削除 → v1.2.748: 1pxの灰色の縁。borderではなくbox-shadowなのは、4択・タイピングの透明2px枠（判定用の場所取り）と干渉させないため */
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  z-index: 2;
  will-change: transform;
}
/* Timer bar */
.quiz-timer-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  z-index: 2;
  background: var(--gray-200);
  overflow: hidden;
}
.quiz-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--gray-400);
  transform-origin: left;
}
.quiz-card::before {
  display: none;
}
/* 角丸：カード＝16px、4択（問題枠・選択肢・わからない）＝9px、タイピング＝9px
   （タイピングは以前5pxだったが、他に5px系の部品が無く、内側の入力欄より外枠が
   角張る逆転になっていたので4択に揃えた） */
.choice-mode .quiz-card,
.choice-mode .quiz-card-next,
.typing-mode .quiz-card,
.typing-mode .quiz-card-next {
  border-radius: 9px;
}
.quiz-card .english-word,
.quiz-card-next .english-word {
  font-family: var(--font-ui);
  font-size: 40px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.5px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* ★v1.2.283：中身が入り切らないときの保険。通常の center は、はみ出しが
     上下に均等に出るので上端（＝問題文）から先に消える。safe center は
     はみ出す場合だけ flex-start と同じ挙動になり、切れるのは必ず下側になる。
     未対応のブラウザはこの行を無視して上の center が残るだけなので安全。 */
  justify-content: safe center;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.3;
  overflow: hidden;
}

/* ===== Answer reveal area ===== */
.answer-reveal {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center; /* v1.2.283：理由は .english-word 側のコメント参照 */
  overflow: hidden;
}
.answer-tap-hint {
  font-size: 14px;
  color: var(--gray-400);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.answer-text-area {
  display: none;
  font-family: var(--font-ui);
  font-size: 40px;
  font-weight: 700;
  color: var(--answer-color, #22C55E);
  letter-spacing: -0.5px;
  line-height: 1.3;
  animation: revealFade 0.3s ease;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
  text-align: center;
  width: 100%;
  height: 100%;
}
body.answer-match-question .answer-text-area {
  color: var(--gray-900);
}
body.answer-match-question .input-result.correct {
  color: var(--gray-900);
}
.quiz-card.revealed .answer-tap-hint { display: none; }
.quiz-card.revealed .answer-text-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center; /* v1.2.283：理由は .english-word 側のコメント参照 */
}
.quiz-card.revealed { cursor: default; }
/* v1.2.883: iPhone で、答えが出たあと（せり上がりの終わり際）に2行目あたりの文字が1pxほど動く件。
   アニメーション中だけ別レイヤーで描かれ、終わった瞬間に通常の描画へ戻るとき行の位置の丸めが変わる
   （行の高さ＝文字サイズ×1.3 で端数が出る2行目以降でずれやすい）。答えを開いている間は
   ずっと同じレイヤーのままにして、描き直しを起こさない。 */
.quiz-card.revealed .answer-text-area { will-change: transform; }
/* v1.2.872: カードモードだけ、問題と答えを境目（カードの40%の高さ）に寄せる。
   旧：上下半々の箱のそれぞれ中央 → PCの縦長カードで問題と答えが350pxほど離れ、
   パッと見で両方が目に入らなかった。箱の高さは固定のままなので、めくっても問題文は動かない
   （v1.2.309 で困った「答えが出た瞬間に問題文が跳ねる」は起きない）。
   余白は主にカードの下側に回る。safe flex-end は v1.2.283 と同じ理由（入り切らないときは下側が切れる）。
   タイピング・4択は従来どおり。 */
#screen-quiz:not(.typing-mode):not(.choice-mode) .quiz-card .english-word,
#screen-quiz:not(.typing-mode):not(.choice-mode) .quiz-card-next .english-word {
  flex: 0.8 1 0;
  justify-content: flex-end;
  justify-content: safe flex-end;
  padding-bottom: 16px;
}
#screen-quiz:not(.typing-mode):not(.choice-mode) .answer-reveal {
  flex: 1.2 1 0;
  justify-content: flex-start;
  padding-top: 16px;
}
#screen-quiz:not(.typing-mode):not(.choice-mode) .quiz-card.revealed .answer-text-area {
  justify-content: flex-start;
}
/* v1.2.873: 境目の高さを画像の位置で変える（問題を出した時点で決まるので、めくっても動かない）。
   問題だけに画像＝60%、両方に画像＝50%、それ以外＝40%（上の既定）。
   40%固定だと、問題側の画像が問題文ごと上へ積み上がり、かたまり全体が上に寄りすぎていた。 */
#screen-quiz:not(.typing-mode):not(.choice-mode) .q-img .english-word { flex: 1.2 1 0; }
#screen-quiz:not(.typing-mode):not(.choice-mode) .q-img .answer-reveal { flex: 0.8 1 0; }
#screen-quiz:not(.typing-mode):not(.choice-mode) .dual-img .english-word,
#screen-quiz:not(.typing-mode):not(.choice-mode) .dual-img .answer-reveal { flex: 1 1 0; }
/* v1.2.901: 文字だけのカードは、問題＋答えのかたまりがカードの上下の真ん中に来るよう、
   問題の箱の高さを JS（setQuizCenterLayout）で px 指定する（上の 40% はその保険）。v1.2.900 の q-long は取り消し。 */

/* ===== Input mode ===== */
.input-answer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.quiz-card.revealed .input-answer-wrap {
  flex: 0 0 auto;
  padding: 8px 0;
}
/* In typing mode, answer-text-area (image only) should not dominate */
.quiz-card.revealed .input-answer-wrap ~ .answer-text-area {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

/* === v1.2.66: タイピングモード時のクイズカード内スクロール対応 ===
   スマホ/タブレットでソフトキーボードが常時表示される際、長文や例文・解説で
   コンテンツが見切れる問題に対応。カード全体（.typing-mode .quiz-card）内部を
   縦スクロール可能にし、内部要素のflex:1とoverflow:hiddenを解除する。
   PC（min-width:768px）ではソフトキーボードが出ないため、従来のflex伸縮
   レイアウトを維持する。 */
@media (max-width: 767px) {
  #screen-quiz.active.typing-mode {
    touch-action: pan-y;
  }
  .typing-mode .quiz-card-area {
    overflow: visible;
  }
  .typing-mode .quiz-card {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* スクロール時にカード内コンテンツが上下に詰まり過ぎないよう、
       上下paddingを少し増やす（左右はそのまま） */
    padding-top: 14px;
    padding-bottom: 14px;
  }
  /* スクロール可能にするため、英単語エリアと回答エリアのflex:1を解除し、
     overflow:hiddenを解除して自然な高さで表示させる */
  .typing-mode .quiz-card .english-word {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
    /* 短い単語の場合は中央寄せを維持するため、最低限の上余白だけ確保 */
    padding: 12px 0 8px;
  }
  .typing-mode .quiz-card .answer-reveal {
    flex: 0 0 auto;
    overflow: visible;
    min-height: 0;
  }
  .typing-mode .quiz-card .answer-text-area {
    overflow: visible;
  }
  /* 入力欄ラッパーもflex:1を解除（中身の高さで広がるように） */
  .typing-mode .quiz-card .input-answer-wrap {
    flex: 0 0 auto;
    min-height: 0;
    padding: 12px 0;
  }
  /* タイピングモード時の解説パネルは絶対配置のままだとスクロールできないため、
     カード内に通常フローで表示し、カードと一緒にスクロールできるようにする */
  .typing-mode .quiz-card .explain-panel.visible {
    position: static;
    margin-top: 12px;
    max-height: none;
  }
}
/* ===== v1.2.131: 4択モード =====
   選択肢はカードの下（#quizBody）に置く。カード自体の構造は
   カードモードと同じままなので、答え表示・答え画像・解説パネルは
   既存のロジックがそのまま効く。
   v1.2.739: 配置を「でた単」風の2x2タイル→mikan等と同じ縦1列のリストに変更
   （2x2は4つを見渡しづらい・長い文章の問題に弱い）。選択肢は文字＋余白の高さで
   下に詰めて置き、余った縦幅は問題カードに回す（旧：カード36%固定・残り全部をタイルに）。 */
.choice-mode .quiz-card-area {
  flex: 1 1 auto;
  min-height: 110px;
}
.choice-mode #quizBody {
  flex: 0 0 auto;
  min-height: 0;
  padding-bottom: 2px;
  display: flex;
  flex-direction: column;
}
.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
  padding: 8px 0 0;
}
/* 「わからない」ボタン。回答後は visibility で隠すので高さは動かず、
   その位置をタップすると #quizBody に抜けて「次へ」になる。
   v1.2.742: 選択肢の下の全幅ボタン → 問題カードと選択肢の間・右端の小さなピルに
   （mikan最新版のSKIPと同じ位置関係。選択肢の列と混ぜない・親指の斜め上・目立たせない）。 */
.choice-skip-btn {
  flex: 0 0 auto;
  align-self: flex-end;
  margin: 8px 0 0;
  padding: 0 14px;
  height: 32px;
  border-radius: 16px;
  background: transparent;
  border: 1.5px solid var(--gray-200);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: transform 0.12s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.choice-skip-btn:active {
  transform: scale(0.96);
}
.choice-skip-btn.is-hidden {
  visibility: hidden;
}
body.dark-mode .choice-skip-btn {
  border-color: var(--gray-200);
  color: var(--gray-500);
}
.choice-btn {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  height: auto;
  min-height: 60px; /* v1.2.741: 答え併記を足しても伸びない高さ */
  padding: 10px 14px;
  border-radius: 9px;
  background: white;
  border: 1.5px solid var(--gray-200);
  box-shadow: none; /* v1.2.749: 影を削除（灰色の枠はもともとあるので輪は足さない） */
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  text-align: left; /* v1.2.739: 縦リストは左寄せ（mikanと同じ） */
  line-height: 1.35;
  cursor: pointer;
  /* 教訓：transition:all は色の補間まで巻き込んで反応が鈍く見えるので transform だけ */
  transition: transform 0.12s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  word-break: break-word;
  overflow-wrap: break-word;
  overflow: hidden;
}
.choice-btn:active {
  transform: scale(0.97);
}
/* v1.2.745: 選択肢の左端に薄い番号（1〜4）。mikan最新版と同じ。PCの1〜4キーの手がかりにもなる。
   v1.2.131 で一度消した左上の小さな番号とは別物＝行の左に文字と同じ大きさで並べる。 */
.choice-num {
  flex: 0 0 auto;
  align-self: center;
  width: 16px;
  margin-right: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-300);
  text-align: center;
  line-height: 1;
}
body.dark-mode .choice-num {
  color: var(--gray-400);
}
.choice-btn.is-correct .choice-num { color: #14B8A6; }
.choice-btn.dim .choice-num { color: var(--gray-300); }
/* v1.2.216: 表裏の切り替えは即時。回転アニメーションは使わない。
   3D回転は描画自体は軽いが、読めるまで約0.5秒待たされるのが本質的な遅さだった。
   これに伴い perspective / preserve-3d / backface-visibility を全て撤去。
   iOS で overflow:hidden と preserve-3d が競合する既知の穴もこれで無くなる。 */
/* v1.2.739: 縦1列でタイルの高さは中身で決まるので、.choice-face は絶対配置ではなく
   通常フローで縦積み（旧：absolute inset:0 は height:100% のタイル前提だった）。 */
.choice-flip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  width: 100%;
  align-self: stretch;
}
.choice-face {
  position: static;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
/* v1.2.741: 答え併記の行は回答前は無し（v1.2.740 の透明の場所取りは、回答前の問題文が
   枠の中で上に寄って見えたので不採用）。代わりにタイルの高さを固定（min-height 60px）にし、
   回答前は問題文だけを上下中央、押したら「答え＋問題文」の塊が同じ高さの中で中央に並ぶ。
   1行の選択肢なら 15px＋3px＋14px が 60px の内側に収まるので高さは動かない。 */
/* v1.2.746: 2行以上の長い選択肢は 60px を超えるので、押すと併記の行ぶん（14px＋間隔3px＝17px）
   タイルが伸びていた。要素を透明で置く（v1.2.740）と問題文が上に寄るので、代わりに回答前だけ
   .choice-flip の上下に 8.5px ずつ余白を足して同じ 17px を確保する＝問題文は中央のまま、
   押したら余白を外して併記の行が同じ場所に入る。1行の選択肢は 60px の内側なので従来どおり。
   併記後の問題文のクランプも回答前と同じ4行に（3行だと4行の選択肢が押したとき縮む）。 */
.choice-btn:not(.owner-shown) .choice-flip { padding: 8.5px 0; }
.choice-back {
  display: none;
  height: 14px;
  font-weight: 500;
  color: var(--gray-500);
  font-size: 11px;
  line-height: 14px;
}
.choice-back .choice-text {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.choice-btn.flipped .choice-front { display: none; }
.choice-btn.flipped .choice-back { display: flex; }
/* v1.2.314: 確定後は全タイルに「その選択肢が何の答えだったか」を並べて出す。
   裏返し（.flipped）は回答前の誤答タイル用で表と裏を入れ替えるが、こちらは
   表の下に小さく足す＝答えと問題文を同時に読める。
   .choice-face は既定で absolute なので、この時だけ通常フローに戻して縦積みにする。 */
/* v1.2.739: 縦積み自体は既定の .choice-flip が持つので、ここは裏面の表示と文字だけ */
.choice-btn.owner-shown .choice-front { display: flex; }
.choice-btn.owner-shown .choice-back {
  display: flex;
}
.choice-btn.owner-shown .choice-front .choice-text { -webkit-line-clamp: 4; } /* v1.2.746: 3→4（回答前と同じ行数で高さを変えない） */
/* 押さなかったタイルは薄くしているが、問題文を読ませるのが目的なので
   0.4 のままだと読めない。控えめに落とすだけにする。 */
.choice-btn.owner-shown.dim {
  opacity: 0.7;
}
.choice-btn .choice-text {
  width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4; /* v1.2.739: 1列で幅があるので6→4行 */
  -webkit-box-orient: vertical;
}
/* v1.2.743: 長い選択肢のときは「問題枠を小さく・選択肢を大きく」。
   旧：len-l 14px／len-xl 13px に縮めていた（v1.2.739）→ 文字は縮めず15pxのまま、
   行間と余白・間隔を広げて4つの区切りをはっきりさせる。場所は問題枠側から取る
   （下の .choice-mode.choice-long .quiz-card-area）。 */
.choice-grid.len-m .choice-btn { font-size: 15px; }
.choice-grid.len-l .choice-btn,
.choice-grid.len-xl .choice-btn { font-size: 15px; line-height: 1.45; padding: 12px 16px; }
.choice-grid.len-l,
.choice-grid.len-xl { gap: 10px; }
/* v1.2.744: 長さに関係なく規則は一つ＝余りは問題枠へ・選択肢は中身の高さ・足りなければ
   問題枠が110pxまで縮み、それでも入らなければ選択肢側がスクロール。
   （v1.2.743 の「.choice-long で余りを選択肢側に渡す」は、選択肢の塊が中身の高さしか
   持たないので下に空白が残った＝不採用。28%の上限も撤去） */
.choice-mode .quiz-card-area {
  flex: 1 1 0;
  min-height: 110px;
}
.choice-mode #quizBody {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* v1.2.757: 4択のときはヒント行（「スペース / タップで次へ」）を選択肢の下＝画面の最下段へ。
   HTMLの並びは カード→ヒント行→#quizBody なので、そのままだと問題枠と「わからない」の間に
   1行ぶんの隙間が空いていた。order で #quizBody の後ろへ回すだけ（行の高さは変わらないので
   問題枠・選択肢の大きさは不変）。PCは v1.2.284④で position:absolute の下端固定なので影響なし。 */
.choice-mode .input-hint { order: 1; }
/* 回答後：タップは下の #quizBody に抜けて「次へ」になる */
.choice-btn.locked {
  pointer-events: none;
  box-shadow: none;
}
/* v1.2.215: 誤答タイルは確定するまでタップを受け続ける（裏返しの切替のため）。
   .locked より後に書いて pointer-events を戻している。 */
.choice-btn.locked.flippable {
  pointer-events: auto;
  cursor: pointer;
}
.choice-btn.is-correct {
  background: #F0FDFA;
  border-color: #14B8A6;
  color: #0F766E;
}
/* v1.2.668: 押した誤答タイルを赤→スレート灰に戻す（タイピングの不正解カードと同じ配色）。
   文字は通常色のまま。問題カードは無色（C案）。 */
.choice-btn.is-wrong {
  background: #F1F5F9;
  border-color: #94A3B8;
}
.choice-btn.dim {
  opacity: 0.4;
}
body.dark-mode .choice-btn {
  background: #1e1a28;
  border-color: var(--gray-200);
  color: var(--gray-800);
}
body.dark-mode .choice-btn.is-correct {
  background: #0a1c1a;
  border-color: #14B8A6;
  color: #5EEAD4;
}
body.dark-mode .choice-btn.is-wrong {
  background: #1a1e24;
  border-color: #94A3B8; /* v1.2.668: 赤→スレート灰（タイピングの不正解と同じ） */
}
/* 回答時に付く .input-correct / .input-wrong の2px枠のぶんだけ
   カード内の中身が動かないよう、あらかじめ透明の枠で場所を取っておく */
.choice-mode .quiz-card {
  border: 2px solid transparent;
}
/* 4択で見せるものが無い問題は、答え欄を最初から消しておく。
   回答前だけヒント等を置くと、回答後にそれが消えた分だけ
   問題文の中央位置が下にずれてしまうため、常に非表示にする。 */
.answer-reveal.choice-collapsed {
  display: none;
}

/* v1.2.651: 判定は枠の色だけ。地は塗らない（塗ると上部ボタン（opacity 0.6）に色が透けて
   ぼやけて見えた。塗りが無ければ赤の主張も一段下がる）。ダークも同じく枠のみ。 */
/* v1.2.653: C案＝問題カードは判定の色を持たない（枠も地も変えない）。正誤は
   4択ならタイル（正解＝ティール／押した誤答＝灰）、タイピングなら音となぞり入力で読む。
   .input-correct / .input-wrong は再入力・メモ解禁などの制御で使うのでクラス自体は残す。
   4択は .choice-mode .quiz-card の透明2px枠で場所取り済み。タイピングは枠が付かなくなった分、
   答え表示時の2pxのずれも無くなる。 */
/* v1.2.655: C案＝問題カードは判定の色を持たない（枠も地も変えない）。正誤はタイル側で
   見せる（正解＝ティール／押した誤答＝赤）。クラスは再入力・メモ解禁の制御で使うので残す。 */
.quiz-card.input-correct,
.quiz-card.input-wrong {
  /* 見た目の指定なし（4択） */
}
/* v1.2.665: タイピングの判定色を今日の変更前（v1.2.649）の配色に戻す＝正解はティール、
   不正解はスレート灰（赤は使わない）。4択は無色のまま。透明2pxの場所取りは残す。 */
.typing-mode .quiz-card {
  border: 2px solid transparent;
}
.typing-mode .quiz-card.input-wrong {
  border-color: #94A3B8;
  background: #F1F5F9;
}
body.dark-mode .typing-mode .quiz-card.input-wrong {
  background: #1a1e24;
}
.typing-mode .quiz-card.input-correct {
  border-color: #14B8A6;
  background: #F0FDFA;
}
/* v1.2.748: 判定の色枠が出ているあいだは、外側の灰色の縁を消す（二重線にしない） */
.typing-mode .quiz-card.input-wrong,
.typing-mode .quiz-card.input-correct {
  box-shadow: none;
}
body.dark-mode .typing-mode .quiz-card.input-correct {
  background: #0a1c1a;
}
/* v1.2.197: 入力欄と答え表示欄を同じ場所にするため、input をラッパで包む。
   不正解のあとは .retyping が付き、ゴースト層（.input-ghost）が上に重なる。 */
.input-field-box {
  position: relative;
  width: 85%;
}
.input-answer-field {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 2px solid transparent; /* 枠線なし・灰色の塗りだけ（ライト） */
  border-radius: 12px; /* 外枠は9pxだが、入力欄は12pxのほうが好み（v1.2.692で9にして v1.2.693 で戻した） */
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  text-align: center;
  outline: none;
  min-height: 44px;
  background: var(--gray-100);
  transition: border-color 0.15s;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
}
/* v1.2.664: フォーカス時の枠をブランド緑→濃いめの灰に（答えの文字の緑と溶けて見えた。
   カード内に入力欄は1つしか無いので、フォーカスの主張は「少し濃くなる」で足りる）。 */
.input-answer-field:focus {
  border-color: transparent; /* 塗りだけの見た目なのでフォーカスでも枠は出さない */
}
.input-answer-field::placeholder {
  color: var(--gray-400);
  font-weight: 500;
}
body.dark-mode .input-answer-field {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-900);
}
body.dark-mode .input-answer-field:focus {
  border-color: #6b6580; /* v1.2.664: 緑→灰（なぞり入力中の灰と同じ系統） */
}
body.dark-mode .input-answer-field::placeholder {
  color: #6b6580;
}
/* === v1.2.197: 不正解のあとの「なぞり入力」 ===
   実際の <input> の文字色を透明にし、同じ位置・同じ書体のゴースト層に
   「入力済み（濃い）＋ まだの分（薄い）」を描く。キャレットは caret-color で
   見えるので、入力欄としての操作感（選択・カーソル移動）はそのまま残る。
   v1.2.633: ゴースト層はもう input に重ねていない（下の .input-ghost のコメント参照）。
   input は透明な捕獲面なので、書体や余白を input と揃える必要は無くなった。 */
.input-field-box.retyping .input-answer-field {
  /* v1.2.198: 中央揃えのまま。実 <input> は入力を受けるだけの透明な捕獲面にして、
     見えるものは全部ゴースト層が描く（キャレットも自前で描く）。
     input 自身のキャレットは「入力済みの文字列だけ」を中央寄せした位置に出るため、
     答え全体を中央寄せしたゴーストとは必ずズレる。だから消している。 */
  color: transparent;
  caret-color: transparent;
  text-align: center;
  border-color: var(--gray-300);
  /* v1.2.633: 箱の高さは見本（.input-ghost）が決める。<input> は1行しか持てないので、
     なぞり入力中は箱いっぱいに広げた透明な面にして、入力を受けるのと枠線を描くのだけを
     任せる。inset だけでは <input> は伸びないので width / height も明示する。 */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
/* v1.2.680: 普通の入力中も、なぞり入力と同じ仕組みで打った文字を折り返して見せる（.mirroring）。
   <input> は1行しか持てず、長い答えは横にスクロールして打ち始めが見えなくなっていた。
   <input> は透明な受け皿にして箱いっぱいに広げ、見えるものは .input-ghost が描く（キャレットも自前）。
   見た目は従来の入力欄（灰色の塗り・枠なし／ダークは枠あり）のまま。1行のうちは高さも同じ
   （JS が切り替える直前の入力欄の高さを min-height に入れる）。 */
.input-field-box.mirroring .input-answer-field {
  color: transparent;
  caret-color: transparent;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.input-field-box.mirroring .input-answer-field::selection { background: transparent; }
.input-ghost .g-typed { color: var(--gray-900); }
/* v1.2.695: 空のときのプレースホルダ（旧 ::placeholder と同じ薄さ・太さ） */
.input-ghost .g-ph { color: var(--gray-400); font-weight: 500; }
body.dark-mode .input-ghost .g-ph { color: #6b6580; }
.input-ghost { display: none; }
.input-field-box.mirroring .input-ghost,
.input-field-box.retyping .input-ghost {
  display: flex;
  align-items: center;
  justify-content: center; /* v1.2.198: 答え全体を中央に。回答後の答え表示と軸が揃う */
  /* v1.2.633: 見本を通常フローに置き、長い答えは折り返す（カードの答え表示
     .input-result と同じ考え方＝ただのブロックなので何行でも伸びる）。
     旧実装は <input> の上に inset:0 で貼り付けた1行固定（white-space: pre＋
     overflow: hidden）で、入らない答えは文字を 11px まで詰め、それでも駄目なら
     なぞり入力そのものを諦めていた。
     上下の余白は <input>（12px）より小さい 8px。1行のときの箱の高さは JS が
     min-height に「切り替える直前の入力欄の高さ」を入れて揃える（enterTypingRetype）。 */
  position: relative;
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 14px;
  border: 2px solid transparent;
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  pointer-events: none;
  /* === v1.2.201: 「薄い文字」と「打った緑の文字」で位置がズレる件の対策 ===
     ゴーストは答えを g-done / g-next / g-rest に切り分けて描くが、分割位置が
     1文字進むたびに変わる。字詰め（カーニング）や合字が効いていると、同じ答えでも
     切り分け方が変わった瞬間に字送りが微妙に変わり、文字が数分の1pxずつ動く。
     ここで切っておけば、どこで分割しても字送りが変わらない。 */
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "kern" 0, "liga" 0, "clig" 0, "calt" 0;
}
/* v1.2.903: iPhone で日本語を打つと、見本と関係ない場所に青い下線が出る件。
   透明な <input> の中でも iOS は変換中の文字に下線（青）を引き、color: transparent では消えない。
   <input> は箱いっぱいの1行で文字を上下中央に置くので、見本が2行以上だと下線が見本の途中に浮く。
   → 受け皿の <input> は opacity: 0 で丸ごと見えなくし（入力・フォーカスはそのまま効く）、
     塗り・枠・角丸は同じ位置・同じ大きさの .input-ghost に描かせる（色は従来の <input> と同じ）。 */
.input-field-box.mirroring .input-answer-field,
.input-field-box.retyping .input-answer-field { opacity: 0; }
.input-field-box.mirroring .input-ghost,
.input-field-box.retyping .input-ghost {
  background: var(--gray-100);
  border-radius: 12px;
}
.input-field-box.retyping .input-ghost { border-color: var(--gray-300); }
body.dark-mode .input-field-box.mirroring .input-ghost,
body.dark-mode .input-field-box.retyping .input-ghost { background: #2a2535; }
body.dark-mode .input-field-box.mirroring .input-ghost { border-color: #3a3545; }
body.dark-mode .input-field-box.has-focus .input-ghost { border-color: #6b6580; }
/* v1.2.201: 答え全体を「1本のインライン行」として描く。以前は g-done / g-rest などを
   直接フレックスアイテムにしていたため、各断片の幅が個別に丸められ、分割位置が動く
   たびに文字が微妙に動いていた。中身をこの1枚に入れて素のインラインで流す。 */
.input-ghost .g-line {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  /* v1.2.633: 折り返す。英語は空白で、日本語は字間で切れる。空白の無い長い語が
     1行を超えるときだけ語の途中で切る（anywhere）。中の断片（g-done など）は
     white-space を継がせること＝断片側に pre を書くと折り返さなくなる。 */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: center;
}
/* 自前のキャレット。input 側は caret-color:transparent で消してある。
   v1.2.201: 幅を持たせると、キャレットの左右にある文字がキャレットの幅ぶん
   押し出される。だからレイアウトに一切効かない形で描く。
   v1.2.633: キャレット専用の要素（幅0の inline-block）をやめた。inline-block は
   前後に「改行してよい位置」を作るので、折り返しを有効にすると語の途中
   （abun|dant）でも行が切れ、1文字打つたびに行が組み変わる。代わりに
   「キャレットの右隣の1文字」を包んだ .caret-l の ::before か、右隣が無いときは
   「左隣の1文字」を包んだ .caret-r の ::after を絶対配置で描く。絶対配置は行の
   組み方に参加しないので、どこで断片を切っても改行位置は答えの文字だけで決まる。
   ・包むのは必ず1文字だけ。行をまたぐ断片に付けると top: 50% の基準が
     「最初の行の上端〜最後の行の下端」になって棒が行間に浮く。
   ・.g-rest / .g-next そのものには付けない（opacity: 0.5 が棒にも掛かる）。
     色の付かない素の <span> で外から包む（typingCaretWrap）。 */
.input-ghost .caret-l,
.input-ghost .caret-r { position: relative; }
.input-ghost .caret-l::before,
.input-ghost .caret-r::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 1.15em;
  border-radius: 1px;
  background: var(--brand-500);
  animation: retypeCaretBlink 1.06s steps(1) infinite;
}
.input-ghost .caret-l::before { left: -1px; top: 50%; margin-top: -0.575em; }
.input-ghost .caret-r::after { right: -1px; bottom: 50%; margin-bottom: -0.575em; }
/* 入力欄からフォーカスが外れている間はキャレットを出さない（PCでは
   キーボードが消えないので「もう一度クリックが要る」状態が見えなかった） */
/* v1.2.759: :focus-within → JS で付け外しする .has-focus に。iOS は入力欄をタップし直して
   フォーカスが戻っても、:focus-within の変化を子孫の ::before / ::after に反映しないことが
   あり、入力はできるのにキャレットが出ないままになっていた。 */
.input-field-box:not(.has-focus) .input-ghost .caret-l::before,
.input-field-box:not(.has-focus) .input-ghost .caret-r::after { display: none; }
@keyframes retypeCaretBlink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}
.input-ghost .g-done { color: var(--answer-color, #22C55E); }
.input-ghost .g-rest { color: var(--gray-400); opacity: 0.5; }
/* v1.2.587: IME 変換中の文字。見本（薄い）とも入力済み（答えの色）とも違う「未確定」を下線で示す */
.input-ghost .g-comp { color: var(--gray-900); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* === v1.2.200: なぞり入力での誤打の見せ方 ===
   誤打はもう <input> に入れない（JS 側で弾く）。代わりに「次に打つべき1文字」を
   赤くして「押すのはこのキー」と示す。ふだんは .g-rest と同じ見た目にしておくこと
   （ここが常に目立っていると、正しく打てているときも間違いのように見える）。 */
.input-ghost .g-next { color: var(--gray-400); opacity: 0.5; }
/* v1.2.638: 次に打つ1文字が空白のとき、その位置に薄い下線を出す。
   空白は形が無いので、「促進する / 奨励する」の「る」の後ろで止まっていても、なぜ進めないのか
   画面から読み取れなかった（記号は自動で送られるが、空白は答えの文字なので打つ必要がある）。
   文字も要素も足さず、空白そのものの下端に背景で線を引く＝字送りは一切変わらない。
   誤打の直後は下の .bad の赤い下地が勝つ（background を上書きする）。 */
.input-ghost .g-next.sp {
  opacity: 1;
  background: linear-gradient(var(--gray-400), var(--gray-400)) left bottom / 100% 2px no-repeat;
}
.input-ghost .g-next.bad {
  color: #EF4444;
  opacity: 1;
  /* 次に打つ文字が半角スペースのこともある（"go out" など）。文字色だけだと
     そのとき何も見えないので、薄い下地を敷いて位置が分かるようにする。 */
  background: rgba(239, 68, 68, 0.16);
  border-radius: 3px;
  animation: retypeMisKey 0.34s ease;
}
/* v1.2.201: 以前は translateX で横に震わせていたが、g-next は素のインライン要素に
   なったので transform が効かない（インラインには適用されない）。字送りを一切
   動かさない下地の点滅に変えた。ここを transform に戻すと位置ズレが再発する。 */
@keyframes retypeMisKey {
  0%   { background-color: rgba(239, 68, 68, 0.55); }
  60%  { background-color: rgba(239, 68, 68, 0.16); }
  80%  { background-color: rgba(239, 68, 68, 0.45); }
  100% { background-color: rgba(239, 68, 68, 0.16); }
}
body.answer-match-question .input-ghost .g-done { color: var(--gray-900); }
/* === v1.2.784: なぞり入力で「自分が間違えたところ」 ===
   .g-miss＝打たなかった／違う字を打った答えの字。答えの文字色が赤系に設定されていても区別できるよう、
   文字の赤に薄い赤の下地を敷く（誤打の .g-next.bad と同じ色味・点滅はしない）。
   まだなぞっていない薄い見本の中でも見えるよう opacity は 1 に戻す（地を薄くして濃さを抑える）。
   .g-ins / .g-ins-r＝答えに無い字を余分に打った位置。字の左（末尾なら右）に赤い縦線。字送りは変えない。
   なぞり完了後の答え表示（.input-result）にも同じ印を残す。 */
.input-ghost .g-miss,
.input-result .g-miss {
  color: #EF4444;
  background: rgba(239, 68, 68, 0.14);
  border-radius: 3px;
}
.input-ghost .g-rest.g-miss,
.input-ghost .g-next.g-miss:not(.bad) { opacity: 0.75; background: rgba(239, 68, 68, 0.10); }
.input-ghost .g-ins,
.input-ghost .g-ins-r,
.input-result .g-ins,
.input-result .g-ins-r { position: relative; }
.input-ghost .g-ins::before,
.input-ghost .g-ins-r::after,
.input-result .g-ins::before,
.input-result .g-ins-r::after {
  content: '';
  position: absolute;
  top: 10%;
  bottom: 10%;
  width: 2px;
  border-radius: 1px;
  background: #EF4444;
}
.input-ghost .g-ins::before,
.input-result .g-ins::before { left: -2px; }
.input-ghost .g-ins-r::after,
.input-result .g-ins-r::after { right: -3px; }
body.dark-mode .input-ghost .g-miss,
body.dark-mode .input-result .g-miss { color: #F87171; background: rgba(248, 113, 113, 0.16); }
.input-result {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  word-break: break-word;
  /* v1.2.197: ○/×スタンプを廃止したので左右対称の素直な padding に戻す。
     正解・不正解は カードの枠色／背景色 だけで示す。 */
  padding: 4px 12px;
}
.input-result.correct {
  color: var(--answer-color, #22C55E);
  letter-spacing: -0.02em;
  font-size: 32px;
}

/* ===== Swipe feedback ===== */
.quiz-card.swiping {
  transition: none !important;
  will-change: transform;
}
.quiz-card.swipe-fly {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}
/* v1.2.860: PCではマウスでもカードを掴んで投げられる。答えを開いた後だけ「掴める」カーソルにする */
@media (hover: hover) and (pointer: fine) {
  #screen-quiz:not(.typing-mode):not(.choice-mode) .quiz-card.revealed { cursor: grab; }
  #screen-quiz .quiz-card.revealed.swiping { cursor: grabbing; }
}
/* v1.2.861: PCのカードモードで、列の左右の余白をクリックすると「まだ（左）／覚えた（右）」。
   ボタンは置かない（本人判断）。普段は透明で、マウスを乗せた側だけ薄く色づき、列寄りに文字が出る。
   ・PC（hover/pointer:fine・幅760px以上）のカードモード、かつ答えを開いた後だけ出す
     （開く前・4択・タイピング・他画面では display:none ＝クリックは下の地にそのまま落ちる）。
   ・幅は「画面の半分 − 列の半分（240px）」。縦はカードと同じ（JS が top/height を入れる）。 */
.pc-zone { display: none; }
@media screen and (hover: hover) and (pointer: fine) and (min-width: 760px) {
  body:has(#screen-quiz.active):has(#quizCard.pc-zone-on.revealed:not(.swipe-fly)) .pc-zone {
    display: flex;
    align-items: center;
    position: fixed;
    width: calc(50% - 240px);
    z-index: 5;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
  }
}
.pc-zone-l { left: 0; justify-content: flex-end; }
.pc-zone-r { right: 0; justify-content: flex-start; }
.pc-zone-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 0 28px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.pc-zone-sym { font-size: 26px; line-height: 1; }
.pc-zone-word { font-size: 14px; }
.pc-zone:hover .pc-zone-label { opacity: 1; }
.pc-zone-r { color: #0D9488; }
.pc-zone-l { color: #64748B; }
.pc-zone-r:hover { background: linear-gradient(to right, rgba(20,184,166,0.12), rgba(20,184,166,0)); }
.pc-zone-l:hover { background: linear-gradient(to left, rgba(100,116,139,0.12), rgba(100,116,139,0)); }
body.dark-mode .pc-zone-r { color: #2DD4BF; }
body.dark-mode .pc-zone-l { color: #94A3B8; }
body.dark-mode .pc-zone-r:hover { background: linear-gradient(to right, rgba(20,184,166,0.18), rgba(20,184,166,0)); }
body.dark-mode .pc-zone-l:hover { background: linear-gradient(to left, rgba(148,163,184,0.16), rgba(148,163,184,0)); }

.swipe-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 16px; /* カード本体（.quiz-card）と同じ。24pxだと四隅が塗り残る */
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  transition: opacity 0.05s ease;
}
/* v1.2.642: スタンプを記号（○／×）から言葉（覚えた／まだ）に。初見テストで × が
   「採点」ではなく「送ると出る演出」と受け取られていた。2〜3文字になるので 48→30px。 */
.swipe-overlay .swipe-label {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 8px 20px;
  background: rgba(255,255,255,0.72);
  border-radius: 14px;
  border: 4px solid;
  transform: rotate(15deg);
}
.swipe-overlay.swipe-right-overlay {
  background: rgba(20,184,166,0.10);
}
.swipe-overlay.swipe-right-overlay .swipe-label {
  color: #0D9488;
  border-color: #14B8A6;
}
.swipe-overlay.swipe-left-overlay {
  background: rgba(100,116,139,0.10); /* v1.2.668: 赤系→スレート灰に戻す（赤は責められている感じが強い） */
}
.swipe-overlay.swipe-left-overlay .swipe-label {
  color: #64748B;
  border-color: #94A3B8;
  transform: rotate(-15deg);
}
/* Bookmark button */
.bookmark-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1; /* v1.2.651: 0.6→1（地の色が透けてぼやけて見えた。アイコン自体が灰色なので1で足りる） */
  flex-shrink: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.bookmark-btn.active {
  background: var(--bookmark);
  border-color: var(--bookmark);
  opacity: 1;
  color: white;
}
.bookmark-btn.active svg {
  stroke: white;
}
.quiz-card-topbar {
  display: flex;
  align-items: center;
  z-index: 10;
  position: relative;
}
.quiz-card-topbar .card-camera,
.quiz-card-topbar .card-bookmark {
  position: static;
  width: 34px;
  height: 34px;
  font-size: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
  border: none; /* 枠線なし・丸の中身だけ（メモ・調べると同じ） */
  /* v1.2.694: 白い塗りも消してアイコンだけに（白いカードでは見えないが、スワイプの
     「まだ」やタイピングの判定で地の色が変わると白丸が浮き出ていた。ダークは元から透明） */
  background: transparent;
}
.quiz-card-topbar .card-camera {
  margin-right: 2px;
}
.quiz-card-topbar .card-bookmark {
  margin-right: 4px;
}
.quiz-card-topbar .card-bookmark.active {
  background: var(--bookmark);
  border-color: var(--bookmark);
  opacity: 1;
  color: white;
}
.quiz-card-topbar .card-bookmark.active svg {
  stroke: white;
}
body.dark-mode .quiz-card-topbar .card-camera,
body.dark-mode .quiz-card-topbar .card-bookmark {
  background: transparent; /* ライトと同じく丸を見せずアイコンだけ（カード地 #1e1a28 に溶かす） */
}
body.dark-mode .quiz-card-topbar .card-bookmark.active {
  background: var(--bookmark);
  border-color: var(--bookmark);
  opacity: 1;
  color: white;
}
body.dark-mode .quiz-card-topbar .card-bookmark.active svg {
  stroke: white;
}

/* Pre-rendered copy menu */
.copy-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2999;
}
.copy-menu-backdrop.show {
  display: block;
}
.copy-menu-popup {
  display: none;
  position: fixed;
  z-index: 3000;
  background: white;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}
.copy-menu-popup.show {
  display: flex;
  animation: calPopIn 0.15s ease;
}
body.dark-mode .copy-menu-popup {
  background: #1e1a28;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
/* v1.2.124: 英辞郎検索メニュー。
   ポップアップの見た目は copy-menu-popup を流用し、項目だけ <a> にする。
   iOS PWA では JS の window.open がポップアップブロック扱いになることがあるため、
   実リンク(target=_blank)のタップにして確実にアプリ内ブラウザで開かせる。 */
.copy-menu-popup .alc-menu-link {
  display: block;
  border: none;
  background: var(--gray-100);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  /* v1.2.292: コピーは <button> なので、<a> と高さ・カーソルを揃える */
  cursor: pointer;
  line-height: 1.35;
}
body.dark-mode .copy-menu-popup .alc-menu-link {
  background: #2a2535;
  color: var(--gray-500);
}
.copy-menu-popup .alc-menu-link:active {
  opacity: 0.7;
}

/* v1.2.291: 「調べる」メニューを 対象（問題／答え）× 手段（英辞郎／画像）の
   2軸レイアウトにした。項目4つを「問題を英辞郎で調べる」のような長い1行×4で
   並べると、どれも同じ見た目・同じ長さで一瞬では読み分けられなかったため。
   見出しで対象を1回だけ示し、ボタン側は手段の名前だけにして短くする。 */
.lookup-menu {
  min-width: 188px;
  gap: 8px;
}
.lookup-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--gray-400);
  letter-spacing: 0.04em;
  padding: 0 2px 4px;
}
.lookup-row {
  display: flex;
  gap: 4px;
}
/* v1.2.432: 「答え」グループだけ、詳細設定の「答えの文字色」で染める。
   問題／答えの2グループはボタン列が同一で、小さな見出しを読まないと区別
   できず押し間違えていた。クイズ画面で答えがこの色で出ている＝色の意味は
   既に決まっているので、新しい約束を覚えさせずに一瞥で分けられる。
   ・見出しと文字を答えの色に、ボタンは細い縁＋薄い下地（塗りつぶしは
     3つ並ぶと重いのでしない）。問題側はグレーのまま。
   ・答えの文字色が「ブラック（問題文と同じ色）」＝body.answer-match-question
     のときは --answer-color が無いので、濃いグレーの縁で区別だけ残す。 */
#lookupGroupAnswer .lookup-group-label {
  color: var(--answer-color, #22C55E);
}
#lookupGroupAnswer .alc-menu-link {
  color: var(--answer-color, #22C55E);
  box-shadow: inset 0 0 0 1.5px var(--answer-color, #22C55E);
  background: color-mix(in srgb, var(--answer-color, #22C55E) 8%, transparent);
}
body.dark-mode #lookupGroupAnswer .alc-menu-link {
  color: var(--answer-color, #22C55E);
  background: color-mix(in srgb, var(--answer-color, #22C55E) 14%, transparent);
}
body.answer-match-question #lookupGroupAnswer .lookup-group-label { color: var(--gray-700); }
body.answer-match-question #lookupGroupAnswer .alc-menu-link {
  color: var(--gray-700);
  box-shadow: inset 0 0 0 1.5px var(--gray-500);
  background: var(--gray-100);
}
body.dark-mode.answer-match-question #lookupGroupAnswer .lookup-group-label { color: var(--gray-300); }
body.dark-mode.answer-match-question #lookupGroupAnswer .alc-menu-link {
  color: var(--gray-300);
  box-shadow: inset 0 0 0 1.5px var(--gray-500);
  background: #2a2535;
}
/* 画像だけの問題（テキストが空）では検索・コピーの項目が落ちるので、
   行に残る個数は1〜3で変わる。flex:1 にしておけば残ったぶんで行幅を分け合う。 */
.lookup-row .alc-menu-link {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
}
/* v1.2.433: ボタンはアイコン（上）＋文字（下）の縦積み。アイコンだけに
   しないのは、「英辞郎」を表す絵が無く、飛び先が名前で分からないと押し
   にくいため。英辞郎の本のアイコンはカード上部の #quizAlcBtn と同じ図形＝
   「あのボタンとこれは同じもの」と対応が取れる。 */
.lookup-row .alc-menu-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 6px;
  font-size: 11px;
}
.lookup-row .alc-menu-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* v1.2.883: v1.2.882（フェードだけ）を取り消し、せり上がりに戻す（本人の判断・カクつきも直らなかった）。 */
@keyframes revealFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Swipe hint (shown after answer reveal in flashcard mode) */
.swipe-hint {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  opacity: 0;
  /* v1.2.613: 消えるときは即時。ふわっと出す transition は .revealed 側だけに持たせる。
     ここに置くと、次の問題へ移って .revealed が外れた後も 0.3秒待ち＋0.4秒かけて
     消えるので、答えを開いていない新しいカードにヒントが残って見える。 */
  transition: none;
  pointer-events: none;
  letter-spacing: 0.5px;
  z-index: 3;
}
.quiz-card.revealed .swipe-hint {
  opacity: 1;
  transition: opacity 0.4s ease 0.3s;
}
/* v1.2.642: はじめての人向けのヒントを、スマホ・タブレットでは下端の1行ではなく
   カードの左右の端（高さは真ん中）に置く。初見テストで下端の大きいヒント（14px）に
   気づかれなかった＝視線はカード中央の答えにある。引く方向の側に言葉がある。
   ・出すのは .hint-sides の回だけ（タッチ環境 かつ 卒業前。JS が付ける）。この回は下端のヒントを出さない。
   ・帯のぶん、問題・答え・メモの左右を空ける。答えを開いた瞬間ではなく、その回の最初から
     空けておく（開いた瞬間に折り返しが変わるとがたつくため）。上部のボタン列は動かさない。
   ・色は --gray-*（ダークで自動的に反転する）。PCは従来どおり下端のキー表記。 */
.swipe-side {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  pointer-events: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--gray-200);
  color: var(--gray-800);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: none;
}
.swipe-side .ss-word { writing-mode: vertical-rl; letter-spacing: 0.12em; }
html:not([lang="ja"]) .swipe-side .ss-word { letter-spacing: 0.02em; }
html[lang="zh-CN"] .swipe-side .ss-word { letter-spacing: 0.12em; } /* v1.2.806: 中国語は日本語と同じく縦書き */
html[lang="ko"] .swipe-side .ss-word { letter-spacing: 0.12em; } /* v1.2.834: 韓国語も縦に積む */
html[lang="zh-TW"] .swipe-side .ss-word { letter-spacing: 0.12em; } /* v1.2.892: 繁體中文も簡体字と同じく縦書き */
/* v1.2.723: 英語表示では、英辞郎（英和辞典）と「AIで問題を作る」（依頼文が日本語）を出さない
   v1.2.805: 以下の出し分けは「日本語か、それ以外か」で書く（英語以外の言語は、自分の版が無いものは英語の版を出す） */
html:not([lang="ja"]) #alcMenuQuestionLink, html:not([lang="ja"]) #alcMenuAnswerLink { display: none !important; }
/* v1.2.729: デモの一覧は表示言語で出し分け（日本語＝英単語・韓国語・歴史・資格試験／英語＝Spanish・Japanese・SAT・World Capitals） */
html:not([lang="ja"]) .demo-list-ja { display: none !important; }
html[lang="ja"] .demo-list-en { display: none !important; }
/* v1.2.808: 中国語は自分のデモ（demo-list-zh）を出し、英語の版は隠す */
html[lang="zh-CN"] .demo-list-en { display: none !important; }
/* v1.2.809: ご意見の Google フォーム（日本語）は中国本土から開けないので、中国語表示ではメールだけにする */
html[lang="zh-CN"] .contact-form-btn { display: none !important; }
html:not([lang="zh-CN"]) .gdrive-zh-note { display: none !important; } /* v1.2.811 */
html:not([lang="zh-CN"]) .demo-list-zh { display: none !important; }
/* v1.2.834: 韓国語は自分のデモ（demo-list-ko）・入力例（format-tabs-ko）を出し、英語の版は隠す */
html[lang="ko"] .demo-list-en, html[lang="ko"] .format-tabs-en { display: none !important; }
html:not([lang="ko"]) .demo-list-ko, html:not([lang="ko"]) .format-tabs-ko { display: none !important; }
/* v1.2.892: 繁體中文も自分のデモ（demo-list-tw）・入力例（format-tabs-tw）を出し、英語の版は隠す。
   簡体字だけの処置（ご意見フォームを隠す・Drive の注意書き）は zh-CN のままで、繁體中文には付けない。 */
html[lang="zh-TW"] .demo-list-en, html[lang="zh-TW"] .format-tabs-en { display: none !important; }
html:not([lang="zh-TW"]) .demo-list-tw, html:not([lang="zh-TW"]) .format-tabs-tw { display: none !important; }
/* v1.2.958: ベトナム語も自分のデモ（demo-list-vi）・入力例（format-tabs-vi）を出し、英語の版は隠す */
html[lang="vi"] .demo-list-en, html[lang="vi"] .format-tabs-en { display: none !important; }
html:not([lang="vi"]) .demo-list-vi, html:not([lang="vi"]) .format-tabs-vi { display: none !important; }
html[lang="vi"] .lc-label { width: 74px; white-space: nowrap; } /* v1.2.958: 結果画面の「Gần thuộc」「Chưa học」が2行に折れないように */
/* v1.2.730: 入力例のタブも同じく出し分け */
html:not([lang="ja"]) .format-tabs-ja { display: none !important; }
html[lang="ja"] .format-tabs-en { display: none !important; }
/* v1.2.807: 中国語は自分の版（format-tabs-zh）を出し、英語の版は隠す */
html[lang="zh-CN"] .format-tabs-en { display: none !important; }
html:not([lang="zh-CN"]) .format-tabs-zh { display: none !important; }
/* v1.2.731: 「AIで問題を作る」は英語の依頼文（AIGEN_PROMPTS_EN）を持ったので英語表示でも出す（v1.2.723 の非表示を撤去） */
/* v1.2.724: 一覧で隠した問題・答えの「タップ」 */
html:not([lang="ja"]) .editor-word-item .ew-eng.hidden-question::after,
html:not([lang="ja"]) .editor-word-item .ew-jpn.hidden-answer::after { content: 'Tap'; }
html[lang="zh-CN"] .editor-word-item .ew-eng.hidden-question::after,
html[lang="zh-CN"] .editor-word-item .ew-jpn.hidden-answer::after { content: '点按'; } /* v1.2.806 */
html[lang="zh-TW"] .editor-word-item .ew-eng.hidden-question::after,
html[lang="zh-TW"] .editor-word-item .ew-jpn.hidden-answer::after { content: '點按'; } /* v1.2.892 */
html[lang="ko"] .editor-word-item .ew-eng.hidden-question::after,
html[lang="ko"] .editor-word-item .ew-jpn.hidden-answer::after { content: '탭'; } /* v1.2.834 */
html[lang="vi"] .editor-word-item .ew-eng.hidden-question::after,
html[lang="vi"] .editor-word-item .ew-jpn.hidden-answer::after { content: 'Chạm'; } /* v1.2.958 */ /* v1.2.722: 英語は横倒しになるので字間を詰める */
.swipe-side-l { left: 0; border-radius: 0 14px 14px 0; }
.swipe-side-r { right: 0; border-radius: 14px 0 0 14px; }
.quiz-card.hint-sides .swipe-side { display: flex; }
.quiz-card.hint-sides.revealed .swipe-side { opacity: 1; transition: opacity 0.4s ease 0.3s; }
.quiz-card.hint-sides.explain-open:not(.explain-inline) .swipe-side { opacity: 0; }
.quiz-card.hint-sides > .english-word,
.quiz-card.hint-sides > .answer-reveal,
.quiz-card.hint-sides > .explain-panel {
  margin-left: 24px;
  margin-right: 24px;
}
/* v1.2.261: 既定はスワイプ表記。マウス環境だけ <style> 末尾のブロックで入れ替える。 */
.swipe-hint .hint-keys { display: none; }
/* v1.2.608: はじめての人向けの大きいヒント（.teach）。カードモードで○×を
   3回（SWIPE_TEACH_MAX）付けるまでの間だけ JS が付ける（swipeTeachCount 参照）。文言は
   「← × まだ　　覚えた ○ →」。--gray-700 はダークで明るい色に再定義されているので
   ダーク用の上書きは要らない。 */
.swipe-hint .hint-word,
.swipe-hint .hint-gap { display: none; }
.swipe-hint.teach {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  letter-spacing: 0;
  bottom: 9px;
}
.swipe-hint.teach .hint-word { display: inline; }
.swipe-hint.teach .hint-sep  { display: none; }
.swipe-hint.teach .hint-gap  { display: inline-block; width: 3em; }
/* v1.2.609: 大きいヒントでは記号を減らす。「まだ／覚えた」の言葉があるので ○× は
   出さない。スマホは「← まだ　　覚えた →」。 */
.swipe-hint.teach .hint-sym,
.swipe-hint.teach .hint-slash { display: none; }
.swipe-hint.teach .hint-touch .hint-arrow-l { margin-right: 4px; }
.swipe-hint.teach .hint-touch .hint-arrow-r { margin-left: 4px; }
/* v1.2.610〜611: PCのキー表記（.hint-keys）は、はじめての人向けも卒業後も同じ形
   ＝［A］［←］ まだ　　覚えた ［→］［D］。
   ・矢印キーの無いコンパクトキーボードでも A / D は必ずあるので両方並べる
   ・裸の「/」「×」「｜」「○」は出さず、キーの形の枠だけで「押せるキーが2つずつ」と読ませる
   ・違いは大きさと濃さだけ：はじめての人は .teach（14px・濃い・太字）、卒業後は従来の
     12px・薄い灰色（毎クイズ先頭3問に出るものなので、主張は弱いままにする）
   .hint-keys はマウス環境でしか表示されないので、ここに @media は要らない。 */
.swipe-hint .hint-keys .hint-sym,
.swipe-hint .hint-keys .hint-slash,
.swipe-hint .hint-keys .hint-sep { display: none; }
.swipe-hint .hint-keys .hint-word { display: inline; }
.swipe-hint .hint-keys .hint-gap  { display: inline-block; width: 3em; }
.swipe-hint .hint-keys .hint-key,
.swipe-hint .hint-keys .hint-arrow-l,
.swipe-hint .hint-keys .hint-arrow-r {
  display: inline-block;
  animation: none;
  opacity: 1;
  min-width: 22px;
  padding: 0 5px;
  border: 1px solid var(--gray-300);
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1.45;
  font-weight: 600;
  text-align: center;
}
.swipe-hint .hint-keys .hint-arrow-l { margin-right: 6px; }
.swipe-hint .hint-keys .hint-arrow-r { margin-left: 6px; }
.swipe-hint .hint-keys .hint-ad:first-child .hint-key { margin-right: 4px; }
.swipe-hint .hint-keys .hint-ad:last-child .hint-key  { margin-left: 4px; }
.swipe-hint:not(.teach) .hint-keys { letter-spacing: 0; font-size: 11px; }
/* v1.2.614: 卒業後（毎クイズ先頭3問）のキー表記は、枠のぶん旧「A / ← × ｜ ○ → / D」より
   大きく見えていたので一回り小さく。枠の高さを旧12pxの1行（約17px）に収める。 */
.swipe-hint:not(.teach) .hint-keys .hint-key,
.swipe-hint:not(.teach) .hint-keys .hint-arrow-l,
.swipe-hint:not(.teach) .hint-keys .hint-arrow-r {
  min-width: 16px;
  padding: 0 3px;
  border-bottom-width: 1px;
  border-radius: 4px;
  line-height: 1.3;
  font-weight: 500;
}
.swipe-hint:not(.teach) .hint-keys .hint-gap { width: 2em; }
.swipe-hint:not(.teach) .hint-keys .hint-arrow-l { margin-right: 4px; }
.swipe-hint:not(.teach) .hint-keys .hint-arrow-r { margin-left: 4px; }
.swipe-hint:not(.teach) .hint-keys .hint-ad:first-child .hint-key { margin-right: 3px; }
.swipe-hint:not(.teach) .hint-keys .hint-ad:last-child .hint-key  { margin-left: 3px; }
@keyframes swipeHintPulse {
  0%, 100% { transform: translateX(0); opacity: 0.6; }
  50% { transform: translateX(4px); opacity: 1; }
}
.swipe-hint .hint-arrow-r {
  display: inline-block;
  animation: swipeHintPulse 1.5s ease-in-out infinite;
}
@keyframes swipeHintPulseL {
  0%, 100% { transform: translateX(0); opacity: 0.6; }
  50% { transform: translateX(-4px); opacity: 1; }
}
.swipe-hint .hint-arrow-l {
  display: inline-block;
  animation: swipeHintPulseL 1.5s ease-in-out infinite;
}

/* Input mode hint (next question) — outside the card */
.input-hint {
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
  pointer-events: none;
  letter-spacing: 0.5px;
  padding: 6px 0 2px;
  display: none;
}
.input-hint.visible {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}
/* === v1.2.636: なぞり入力中の「スキップ」をボタンの見た目にする ===
   旧：ヒント行の文字「答えを入力して次へ ｜ タップでスキップ」全体がスキップの当たり判定。
   12px の薄い灰色の説明文にしか見えず、押せると気づけなかった（答えが出たあとの
   「タップで次へ」は画面のどこでも効くのに、こちらは文字の上だけ、という食い違いもあった）。
   v1.2.635 で Enter のスキップを外したので、ここが唯一のスキップ手段。
   ・なぞり入力中は行そのものを押せなくして（.retype）、ピルだけを押せるようにする。
   ・ピルの上下は負の margin で行の高さに食い込ませる＝行の高さを変えない
     （変えるとなぞり入力に入った瞬間にカードが数px縮む）。
   ・指で押しやすいよう、当たり判定だけ ::after で見た目より広げてある。 */
.input-hint.retype {
  cursor: default;
  /* 行の高さの中でピルを上下中央に置く（inline の vertical-align だと行の下へ 1〜2px はみ出す） */
  display: flex !important; /* 表示／非表示は JS が style.display で切り替えているので、なぞり中だけ上書き */
  align-items: center;
  justify-content: center;
}
/* v1.2.637: 行の中身がピルだけになったので、文字1行ぶんの高さをこれで確保する
   （ピルは負の margin で行に食い込ませてあるため、これが無いと行が数px低くなり、
   なぞり入力に入った瞬間にカードが伸びる）。 */
.input-hint.retype::before { content: '\200b'; flex: 0 0 0; width: 0; }
.input-hint .retype-skip-btn {
  position: relative;
  z-index: 5; /* 広げた当たり判定（::after）がカードの下端に少し掛かるので、カードより手前に */
  flex: 0 0 auto;
  margin: -7px 0 -3px; /* 行の余白が上6px・下2pxなので、そのぶん上へ寄せて行の中に収める */
  padding: 2px 12px; /* 高さ約22px。キーボード表示中の行（22px）からはみ出さない */
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--card-bg, #fff);
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.input-hint .retype-skip-btn::after {
  content: '';
  position: absolute;
  inset: -9px -14px;
}
.input-hint .retype-skip-btn:active { background: var(--gray-100); }
.input-hint .retype-skip-btn .skip-key { display: none; }
@media (hover: hover) and (pointer: fine) {
  .input-hint .retype-skip-btn:hover { border-color: var(--gray-400); color: var(--gray-800); }
  /* PCは Esc でもスキップできる（マウス環境のときだけキー名を添える） */
  .input-hint .retype-skip-btn .skip-key { display: inline; font-weight: 500; opacity: 0.7; margin-left: 4px; }
}
body.dark-mode .input-hint .retype-skip-btn {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-600);
}

/* Quiz result */
.quiz-result {
  background: white;
  border-radius: 24px;
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* v1.2.305: 結果画面の地の色（v1.2.227 のスコア帯4色 + v1.2.228 の満点
   グラデーション）は廃止した。結果画面の背景は他画面と同じ var(--bg)。
   .result-close-btn の半透明の下地も、色の付いた地の上でグレーの丸が浮く
   のを防ぐためだけの上書きだったので一緒に撤去し、素の var(--gray-100) に
   戻している。ステータスバーの theme-color も切り替えない。
   満点の star アイコン・紙吹雪・ファンファーレは地の色とは別機能なので残す。 */

/* v1.2.227 で「地の色を見せる面積を稼ぐ」ために足した上余白。v1.2.305 で
   地の色は廃止したが、結果画面の詰まり具合はこの値で見慣れているので残す。
   不要なら padding-top ごと消して .app の既定（20px）に戻せばよい。
   ★.app の padding-top は上書きしないこと。@media (max-height:700px) と
     (max-height:700px and min-width:600px) が背の低い画面向けに 8px / 0px へ
     意図的に詰めており、body 側で上書きするとその調整を潰す。
     #screen-result 自身に持たせれば .app 側の調整と衝突しない。 */
#screen-result { padding-top: 24px; }
@media (max-height: 700px) and (pointer: coarse) {
  #screen-result { padding-top: 10px; }
}
.result-close-btn {
  position: sticky;
  top: calc(12px + env(safe-area-inset-top));
  left: 0;
  margin-left: calc(12px + env(safe-area-inset-left));
  margin-bottom: -36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 100;
}
@media (hover: hover) {
.result-close-btn:hover {
  background: var(--gray-200);
}
}
.result-close-btn:active {
  transform: scale(0.9);
}
/* v1.2.523: 結果画面右上の「ご意見」ボタン（v1.2.436〜）は削除。
   ご意見・お問い合わせは設定メニューから。 */
.quiz-result .result-icon {
  margin-bottom: 16px;
}
/* v1.2.546: 中身を帯別のSVGからアプリのアイコン（img）に変更。
   56pxは旧SVGと同じ＝下の見出しの位置は動かない。角丸は初回画面の
   .intro-brand img（44px／11px）と同じ比率。 */
.quiz-result .result-icon img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: block;
  margin: 0 auto;
}
.quiz-result h2 {
  /* v1.2.541: 24px → 17px。文言を語りかける文にして長くなったため。
     高さは2行ぶんで固定し、1行の文でも下の行とボタンが動かないようにする
     （1行のときは上下中央）。文言の上限は _resultMessages の注記を参照。 */
  letter-spacing: -0.01em;
  font-size: 17px;
  line-height: 1.5;
  min-height: 3em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}
/* v1.2.542: 「N問中 M問正解」（14px灰色の1行）を「M / N 問正解」に変更。
   旧表示は N と M が同じ強さで、知りたい正解数より先に「N問中」へ目が行っていた。
   正解数だけを大きく濃くし、残りは小さく薄くする。見出しを 17px に下げた
   （v1.2.541）ので、この数字が結果カードで一番大きい要素になる。
   ★「問正解」は消さない（「4 / 5」だけだと何の数か一瞬迷う）。
   ★正答率（%）は出さない。少問数だと大げさに動くため（v1.2.234 の判断と同じ）。
   読み上げは aria-label の「N問中 M問正解」で従来どおり。
   下の .quiz-result p は他の段落用に残してある。 */
.quiz-result .result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  margin-bottom: 24px;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
}
.quiz-result .result-score__num {
  font-size: 36px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--gray-800);
}
.quiz-result .result-score__total { font-size: 17px; }
.quiz-result .result-score__unit { font-size: 12px; margin-left: 2px; }
.quiz-result p {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 24px;
  line-height: 1.6;
}
/* v1.2.234: .result-stats / .result-stat（正解・不正解・正答率の3数字）は削除。
   同じ内容は見出し直下の「N問中 M問正解」の1行で足りている。 */
.result-btn {
  background: var(--gray-200);
  color: var(--gray-700);
  border: none;
  padding: 16px 40px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s; /* v1.2.177: 背景色は即時 */
}
@media (hover: hover) {
.result-btn:hover {
  background: var(--gray-50);
  transform: translateY(-1px);
}
}
.result-btn.next-quiz-btn {
  background: white;
  color: var(--gray-600);
  border: 2px solid var(--gray-300);
  margin-bottom: 10px;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
}
/* v1.2.641: アプリ内ブラウザ（LINEで脱出に失敗した時／Instagram／Facebook）向けの案内の帯。
   ・出すのは初回画面とホームだけ（クイズ等の「1画面に収める」画面には被せない）。:has の無い古い端末では出ない。
   ・帯の高さぶんだけ .app を透明の上枠で下げる（構造も既存の余白も変えない）。高さは JS が実測して --iab-bar-h に入れる。
   ・色は固定値（ライト／ダークで同じ見た目。--gray-* はダークで反転するため使わない）。 */
.iab-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  box-sizing: border-box;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 6px 6px 14px;
  background: #2f2f35;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.iab-bar__msg { flex: 1 1 auto; min-width: 0; }
.iab-bar__btn {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #2f2f35;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.iab-bar__close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: none; background: transparent; color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer; opacity: 0.8;
}
body.has-iab-bar:has(#screen-import.active, #screen-dashboard.active) .iab-bar { display: flex; }
body.has-iab-bar:has(#screen-import.active, #screen-dashboard.active) .app {
  /* padding-top は画面幅ごとに別の値が入っているので触らず、透明の上枠で帯のぶんだけ下げる */
  border-top: var(--iab-bar-h, 44px) solid transparent;
}
/* v1.2.639: デモ直行の結果画面の主ボタン（初回画面の .demo-hero-btn と同じブランド色） */
.result-btn.demo-own-btn {
  background: var(--brand-500);
  color: white;
  margin-bottom: 10px;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
}
@media (hover: hover) {
  .result-btn.demo-own-btn:hover { background: var(--brand-500); color: white; }
}
.result-btn.review-btn {
  background: white;
  color: var(--gray-600);
  border: 2px solid var(--gray-300);
  box-shadow: none;
  margin-bottom: 10px;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
}
/* v1.2.316: 誤タップ防止の遅延表示から、フェードとスライドを外した。
   当時は「角丸＋2pxボーダーのボタンが transform で動く間の専用レイヤー」を
   疑っていたが、★これは外れ。v1.2.322 で真因は読み上げの打ち切り後に iOS が
   音声セッションを畳む処理だと判明した（stopAllAudio の上のまとめを参照）。
   目的（1.5秒間は押せない）は pointer-events だけで足りるので、いまの形の
   ままにしてある。フェードを戻したい場合は、最後のアニメの終了時刻が
   1.8秒付近に来ないように（＝1.2秒までに終わるように）すること。 */
.result-actions-delayed {
  opacity: 0;
  pointer-events: none;
}
.result-actions-delayed.show {
  opacity: 1;
  pointer-events: auto;
}
.missed-section {
  text-align: left;
  margin: 20px 0;
  width: 100%;
}
.missed-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0;
  text-align: left;
  flex: 1;
}
.missed-section h4.missed-heading { color: var(--gray-800); }
.missed-section h4.correct-heading { color: var(--gray-800); }

/* Pending delete section on result screen */
.pending-delete-section {
  background: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.pending-delete-section .missed-section-header {
  margin-bottom: 6px;
}
.pd-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.pd-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pd-item:has(.pd-checkbox:checked) {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.35);
}
.pd-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--red-500);
}
.pd-eng {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--gray-800);
  word-break: break-word;
}
.pd-jpn {
  flex: 1;
  min-width: 0;
  color: var(--gray-600);
  font-size: 13px;
  word-break: break-word;
}
.missed-section-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  margin-bottom: 10px;
}
/* v1.2.247: 「間違えた問題を復習する」から下は v1.2.226 の体裁に戻した。
   v1.2.231〜233 の白いカード／折りたたみ／メモ行はすべて撤去し、
   1本の区切り線で区切るだけの素の一覧に戻している。 */
.missed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 0;
  overflow: visible;
}
/* v1.2.335: 結果画面の「正解した問題」は既定で折りたたむ（見たいのは
   まず間違えた方なので、正解の一覧で画面が埋まらないようにする）。
   v1.2.385: ただし全問正解の回は .is-collapsed を付けずに描く＝開いた状態
   で出す。間違えた側のセクションが無いので、閉じると見出しだけになる。 */
/*
   見出し h4 自体がトグル＝ヘッダーに同居する「問題を隠す／答えを隠す」
   ボタンのタップを飲み込まない。
   ※ v1.2.231〜233 の折りたたみとは別物。あちらは白いカード表示・メモ行
   とセットで、v1.2.247 に丸ごと差し戻した。ここで足すのは正解セクション
   1つの開閉だけで、行のテンプレートも素の一覧のまま。 */
.result-correct-section h4.correct-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 4px 0;
}
.result-correct-section .cc-chevron {
  display: inline-flex;
  color: var(--gray-400);
  transition: transform 0.2s;
}
.result-correct-section.is-collapsed .cc-chevron {
  transform: rotate(-90deg);
}
.result-correct-section.is-collapsed .missed-list {
  display: none;
}
/* v1.2.375: 結果画面の一覧を縦積みカード（mikan 方式）に変更。
   v1.2.374 までは 問題｜答え の2列で、答えの右隣に .result-pin-btn が
   来るため左右の余白が非対称になり、それを余白の調整で吸収していた。
   構造ごと変えて、問題と答えを左揃えで縦に積み、操作（読み上げ・
   しおり）は区切り線の下の段にまとめる。
   ・1問あたりの高さは約2.5倍。伸びるのは「間違えた問題」と、開いた
     ときの正解一覧（正解側は既定で折りたたみ）。
   ・「問題を隠す／答えを隠す」は行内のグレー帯に変わる（旧実装は列の
     高さいっぱいの面だった）。
   ・行のテンプレートは間違えた側・正解した側の2箇所にコピーされている。
     片方だけ直さないこと（v1.2.247 のコメント参照）。 */
.missed-item {
  display: block;
  background: var(--card-bg, #fff);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  text-align: left;
}
.missed-eng {
  display: block;
  font-weight: 600;
  font-size: 16px;
  color: var(--gray-700);
  word-break: break-word;
  border-radius: 4px;
  min-height: 22px;
}
.missed-jpn {
  display: block;
  color: var(--gray-600);
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
  border-radius: 4px;
  margin-top: 2px;
  min-height: 21px;
}
.missed-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}
.result-speak-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 2px;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
}
.result-pin-btn {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.3;
  padding: 2px;
  flex-shrink: 0;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
}
.result-pin-btn.active {
  opacity: 1;
}
/* v1.2.486: 結果画面の行から習熟度を変えるピル（● ラベル ⌄）。
   押すと既存の setting-sheet（SETTING_SHEETS.resultLevel）が開く。
   ドットの色は出題範囲・一覧のバッジと同じ変数を使う。 */
.result-level-pill {
  margin-left: auto;
  margin-right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 8px 5px 10px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
}
.result-level-pill:active { opacity: 0.7; }
.result-level-pill .rlp-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray-400);
  flex-shrink: 0;
}
.result-level-pill[data-level="weak"] .rlp-dot { background: var(--purple-400); }
.result-level-pill[data-level="fuzzy"] .rlp-dot { background: var(--yellow-500); }
.result-level-pill[data-level="mastered"] .rlp-dot { background: var(--green-500); }
.result-level-pill .rlp-chev { color: var(--gray-400); flex-shrink: 0; }
body.dark-mode .result-level-pill {
  background: var(--gray-200);
  color: var(--gray-800);
}
.result-pin-btn.active svg {
  stroke: var(--bookmark);
  fill: var(--bookmark);
}
/* Level change summary */
/* v1.2.234: 見出し「ステータス変化」をやめたので h4 のルールも削除。
   上との隔たりは .level-change-section の margin で取る。 */
.level-change-section {
  width: 100%;
  margin: 20px 0;
  text-align: left;
}
.lc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  animation: lcRowSlide 0.4s ease both;
}
.lc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}
.lc-bar-wrap {
  flex: 1;
  height: 28px;
  background: var(--gray-100);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  /* v1.2.315: animateLevelBars() は width をトランジションさせる＝レイアウトが
     動くプロパティなので、0.8秒間ずっと結果ページ全体を測り直していた。
     結果画面には間違えた問題＋正解した問題が全件並ぶので、1回のレイアウトが
     そもそも重い。contain でこのラッパーの中に閉じ込める。
     高さは 28px 固定・幅は flex で外から決まるので、中身が外の寸法に
     影響することはなく、見た目は変わらない。 */
  contain: layout paint;
}
.lc-bar {
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 13px;
  font-weight: 600;
  color: white;
  min-width: 28px;
}
.lc-count {
  font-size: 13px;
  font-weight: 600;
}
/* v1.2.239: 件数が 0 の段は色の付いたバーを描かず、数字だけを置く。
   数字の左端は .lc-bar の padding-left と同じ 10px に揃えてあるので、
   0 の段と 1 以上の段で数字の位置が動かない。
   v1.2.244: グレーの溝は他の段と同じように残す（消すと行の高さは同じでも
   段の並びが揃って見えなかったため）。 */
.lc-bar-wrap.is-zero {
  display: flex;
  align-items: center;
  padding-left: 10px;
}
.lc-zero {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.5;
}
.lc-diff {
  font-size: 16px;
  font-weight: 600;
  width: 40px;
  flex-shrink: 0;
  opacity: 0;
}

/* v1.2.317: transform を外して opacity だけにした。
   当時は「小さな文字の scale が専用レイヤーを作るせい」と見ていたが、
   ★これは外れ。v1.2.322 で真因は読み上げの打ち切り後に iOS が音声セッションを
   畳む処理だと判明した（stopAllAudio の上のまとめを参照）。
   transform を戻しても固まりは増えないので、見た目の好みで戻してよい。 */
@keyframes diffPop {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes lcRowSlide {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--gray-200);
  transition: border-color 0.2s;
  flex-shrink: 0;
}
.search-bar:focus-within { border-color: var(--brand-400); }
.search-bar .search-icon { margin-right: 8px; color: var(--gray-400); display: flex; align-items: center; }
.search-bar input {
  flex: 1;
  /* v1.2.306: min-width:0 が無いと、フレックスアイテムの min-width:auto が
     input の固有幅（既定 size=20 ＝ 170px前後）で下げ止まる。狭い端末では
     .search-bar からはみ出したぶんを、shrink できる隣の ✕ ボタンが全部
     引き受けて幅0まで潰れる＝「入力しても ✕ が出ない」に見えていた。 */
  min-width: 0;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 16px;
  background: transparent;
  color: var(--gray-800);
}
.search-bar input::placeholder { color: var(--gray-300); }
.search-clear {
  display: none;
  border: none;
  background: var(--gray-200);
  color: var(--gray-500);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  /* v1.2.306: 上記のとおり、ここが潰れる側だったので明示的に止める。 */
  flex-shrink: 0;
  margin-left: 8px;
  padding: 0;
  line-height: 1;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
/* v1.2.306: 見た目は24pxのまま、当たり判定だけ40px角に広げる。
   メモ帳の「ここで分割」と同じ手。指で確実に押せるようにする。 */
.search-clear::after {
  content: '';
  position: absolute;
  top: -8px; right: -8px; bottom: -8px; left: -8px;
}
.search-clear:active { background: var(--gray-300); }
.search-clear.show { display: flex; }
/* v1.2.306: ダーク用の指定が無く、--gray-200 の下地に --gray-500 の文字で
   ほとんど沈んでいた。 */
body.dark-mode .search-clear {
  background: rgba(255, 255, 255, 0.14);
  color: var(--gray-800);
}
body.dark-mode .search-clear:active { background: rgba(255, 255, 255, 0.24); }

/* ===== Deck Selector (1デッキ表示→アコーディオン展開) ===== */
.deck-selector {
  position: relative;
  margin-bottom: 12px;
  flex-shrink: 0;
}
/* 展開時は兄弟要素（.editor-word-list等）より上に来るよう
   stacking contextを引き上げる。これがないとリスト内のカードが
   ドロップダウンの上に被ってしまう。 */
.deck-selector.open {
  z-index: 100;
}
.deck-selector-current {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 20px;
  border: none;
  background: var(--gray-700);
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s;
}
.deck-selector-current:active {
  transform: scale(0.98);
}
body.dark-mode .deck-selector-current {
  background: #8b8597;
  color: white;
}
.deck-selector-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-selector-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  transition: transform 0.2s;
}
.deck-selector.open .deck-selector-chevron {
  transform: rotate(180deg);
}
.deck-selector-options {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px;
  z-index: 100;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}
.deck-selector-options::-webkit-scrollbar {
  width: 6px;
}
.deck-selector-options::-webkit-scrollbar-track {
  background: transparent;
}
.deck-selector-options::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.25);
  border-radius: 3px;
}
body.dark-mode .deck-selector-options {
  scrollbar-color: var(--gray-500) transparent;
}
body.dark-mode .deck-selector-options::-webkit-scrollbar-thumb {
  background-color: var(--gray-500);
}
@media (hover: hover) {
body.dark-mode .deck-selector-options::-webkit-scrollbar-thumb:hover {
  background-color: var(--gray-600);
}
}
.deck-selector.open .deck-selector-options {
  display: block;
}
/* v1.2.224: プルダウン内のグループ見出し。グループが2つ以上あるときだけ出る。
   ボタンではないのでタップ判定は持たせない。
   v1.2.225: 区切り線はグループの境目に引く。位置は見出しの上端＝前のグループの
   最後のデッキと次の見出しの間。見出しの下に引くと、見出しが自分の配下の
   デッキから切り離されて見えてしまう。
   先頭の見出しには線を出さない（リストの一番上に線が来るため）。 */
.deck-selector-group {
  margin-top: 6px;
  padding: 12px 12px 5px;
  border-top: 1px solid var(--gray-200);
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  letter-spacing: 0.02em;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.deck-selector-group:first-child {
  margin-top: 0;
  padding-top: 2px;
  border-top: none;
}
body.dark-mode .deck-selector-group {
  color: var(--gray-400);
  border-top-color: #3a3545;
}
.deck-selector-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s;
}
.deck-selector-option:active {
  transform: scale(0.98);
}
.deck-selector-option.active {
  background: var(--brand-50);
  color: var(--brand-600);
}
.deck-selector-option-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-selector-option-count {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-400);
}
.deck-selector-option.active .deck-selector-option-count {
  color: var(--brand-500);
}
body.dark-mode .deck-selector-options {
  background: var(--gray-100);
  border-color: var(--gray-300);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
body.dark-mode .deck-selector-option {
  background: transparent;
  color: var(--gray-800);
}
body.dark-mode .deck-selector-option.active {
  background: var(--brand-200);
  color: var(--brand-500);
}
body.dark-mode .deck-selector-option-count {
  color: var(--gray-500);
}
body.dark-mode .deck-selector-option.active .deck-selector-option-count {
  color: var(--brand-400);
}

/* Word list */
/* ===== Memo Editor (メモ帳デッキ) ===== */
#screen-memo-editor {
  display: none;
  flex-direction: column;
  height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top));
  overflow: hidden;
  padding-top: 20px;
  font-family: var(--font-ui);
  /* ★背景は指定しない。body の var(--bg) をそのまま透かす＝#screen-word-editor
     など他の全画面スクリーンと同じ流儀。
     経緯：v1.2.211 まではここに background: var(--bg-primary) があり、ダーク側だけ
     var(--bg) に戻していた。ライトでも #fff（画面）と #fff（.memo-row）が同色で
     カードの輪郭が消え、逆に 480px の柱だけが #F8F9FA の地から白く浮いて
     「背景が2層」に見えていたため、v1.2.360 でライト・ダークとも指定ごと削除。 */
}
#screen-memo-editor.active {
  display: flex;
}
.memo-header {
  display: flex;
  align-items: center;
  padding: 8px 12px 12px;
  gap: 10px;
  flex-shrink: 0;
}
.memo-header .quiz-back { flex-shrink: 0; }
.memo-header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.memo-header-title > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* v1.2.126: メモ帳ヘッダーのコピーボタン（「完成」の左）。
   「データをエクスポート → デッキ内容をコピー」と同じ出力を、画面を離れずに
   取れるようにするためのショートカット。完成ボタンより弱い見た目にして
   誤タップ時の心理的コストを下げる。 */
.memo-copy-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid var(--gray-200);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.1s, opacity 0.15s;
}
.memo-copy-btn:active { transform: scale(0.94); opacity: 0.7; }
.memo-finish-btn {
  background: var(--brand-500);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, opacity 0.15s;
}
.memo-finish-btn:active { transform: scale(0.96); opacity: 0.85; }
.memo-table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* PWA で env(safe-area-inset-bottom) が想定外に大きい値で評価される
     ケースがあり、最下行の下に巨大な余白が出ることがあった。min()で
     上限を 34px に制限。これでホームインジケーターは保護しつつ過剰な
     余白を防げる（iPhone のホームインジケーター実寸はおおむね 34px）。 */
  padding: 0 12px min(env(safe-area-inset-bottom, 16px), 34px);
}
.memo-table {
  background: transparent;
  /* 最終行のすぐ下が画面端に詰まらないよう、余白を確保。安全領域(env)とは別に
     視覚的な余白を持たせる目的。「+ 行を追加」ボタンを廃止した分、最終行の
     + ボタンや削除ボタンが指で扱いやすくなるよう少し厚めに。 */
  margin-bottom: 80px;
}
/* 行はカード化：他画面の word-item と同じ流儀（白背景・角丸・影）。
   行同士は margin で区切り、罫線は使わない。 */
.memo-table-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.memo-row {
  display: grid;
  /* 列構成: 2列等分(1fr 1fr)で問題と答えを完全に半々に。上段の答えセルは
     画面右端まで伸びる（+/ゴミ箱用の余白を取らない）。
     下段の例文・解説セル(または toggle ボタン)は2列分（全幅）を占有して、
     +とゴミ箱は absolute 配置で下段右端に重ねる。これで例文セルが+ボタンの
     直前まで伸び、答えセルとの境界線も縦に貫通させやすくなる。 */
  position: relative;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "q a"
    "toggle toggle";
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.memo-row.has-note {
  grid-template-areas:
    "q a"
    "note note";
}
.memo-cell-q { grid-area: q; }
.memo-cell-a { grid-area: a; }
.memo-note-toggle { grid-area: toggle; }
.memo-cell-n { grid-area: note; }
/* +とゴミ箱を下段右端に絶対配置で重ねる。下段の例文・解説セル/toggleは2列分
   占有して+ボタン直前まで広がり、actions は画面の重ね合わせで右端に寄る。
   textarea が actions の下に潜り込まないよう、toggle/cell-n に padding-right:72px を
   設けてテキスト幅を制限している。actions 自身は背景を透明にして、下段の上端に
   引いている border-top の点線が actions エリアでも途切れずに見えるようにする。
   タップ判定は button 要素自体に効くので、背景透明でも + ボタンは押せる。 */
.memo-row-actions {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  background: transparent;
  z-index: 2;
}
/* 折りたたみ/展開：grid-template-areasで上下段の構成を切り替える。
   .memo-cell-n は has-note 時のみ note area に配置され、それ以外は
   display: none で消える（grid に行が予約されない）。 */
.memo-row:not(.has-note) .memo-cell-n { display: none; }
.memo-row.has-note .memo-note-toggle { display: none; }
/* v1.2.590: 押せる範囲を「＋ メモを追加」の文字のところだけに縮める。
   旧実装はこのボタンが行の横幅いっぱい（toggle エリア全体）を占めていて、
   真上にある小さな「ここで分割」を数px下に外すと必ずここに落ちていた。
   justify-self:start で中身の幅に縮め、残りの帯は何も起きない空白にする。
   点線はボタンと一緒に縮むと途切れるので、上段セルの border-bottom へ移した。 */
.memo-row:not(.has-note) .memo-cell-q,
.memo-row:not(.has-note) .memo-cell-a {
  border-bottom: 1px dashed var(--gray-200);
}
.memo-note-toggle {
  justify-self: start;
  background: transparent;
  border: none;
  padding: 8px 10px 8px 12px;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0.6;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.memo-note-toggle:active {
  opacity: 1;
  background: var(--bg-primary);
  color: var(--text-primary);
}
@media (hover: hover) {
.memo-note-toggle:hover {
  opacity: 1;
  background: var(--bg-primary);
  color: var(--text-primary);
}
}
.memo-cell-n {
  border-top: 1px dashed var(--gray-200);
}
/* 例文・解説セル(cell-n)と右側の actions(+/🗑️) を視覚的に区切る縦線。
   actions は absolute 配置で右端から幅 64px を占めるため、cell-n の右端から
   64px の位置に縦線を引くと actions の左端とちょうど揃う。
   高さは cell-n の全領域に渡って引き、テキストが長文で折り返した場合でも
   下まで貫通させる。textarea の padding-right: 72px により、テキストは縦線の
   手前で必ず折り返す（縦線から 8px 内側）。 */
.memo-cell-n::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 64px;
  width: 1px;
  background: var(--gray-200);
  pointer-events: none;
}
body.dark-mode .memo-row { background: var(--gray-100); }
.memo-cell {
  position: relative;
}
.memo-cell textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--gray-600);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
  /* 空白を含まない長い英字列(例: fffff...）をセル幅で必ず折り返す。
     textarea のデフォルトは空白区切りでしか改行せず、長い連続文字列は
     横スクロールしてはみ出る。anywhere にしておくと grid の min-content
     計算でも語中改行が許可され、列幅(1fr 1fr)が崩れない。 */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* cell-n の textarea は actions(+/🗑️=64px) の裏に潜らないよう、右側に 72px の
   padding を確保する。.memo-cell textarea より「後に」宣言することで、
   詳細度が同じでも CSS 順序で後勝ちさせて padding を確実に上書きする。
   （以前は前に宣言されていたため padding:12px に上書きされ、textarea が
   actions の裏まで伸びる潜在バグになっていた） */
.memo-cell-n textarea {
  padding: 10px 72px 10px 12px; /* 右側は +/ゴミ箱(64px) + 余白(8px) ぶん確保 */
  min-height: 36px;
}
.memo-cell textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.4;
  font-style: italic;
  font-weight: 400;
}
/* 問題と答えの境界に薄い縦線。編集画面（.editor-word-item）と
   同じ流儀で gray-200 の線を使い、見た目を統一する。
   上段だけ縦線を引き、下段(例文・解説)には貫通させない。 */
.memo-cell-a {
  border-left: 1px solid var(--gray-200);
}
/* 未入力セル（placeholder 表示中）に薄背景を敷いて、入力済みのテキストと
   視覚的に区別。色の濃淡だけだと判別しづらいので「塗りの有無」で構造を示す。
   :has() でセル全体にかかるので textarea の透明背景越しに見える。
   .is-error の赤背景はこの後の宣言で上書きされるので干渉しない。 */
.memo-cell:has(textarea:placeholder-shown) {
  background: rgba(0, 0, 0, 0.025);
}
body.dark-mode .memo-cell:has(textarea:placeholder-shown) {
  background: rgba(255, 255, 255, 0.03);
}
/* 完成チェックで未入力だったセル。修正中（入力開始）で外す＝徐々に消えていく。
   背景は box-shadow inset で領域全体を覆い、textareaの透明背景越しに見せる。
   plain border は隣接セルとのレイアウトずれを起こすため使わない。 */
.memo-cell.is-error {
  background: rgba(239, 68, 68, 0.08);
  box-shadow: inset 0 0 0 2px #ef4444;
}
.memo-cell.is-error textarea::placeholder {
  color: #ef4444;
  opacity: 0.7;
}
body.dark-mode .memo-cell.is-error {
  background: rgba(239, 68, 68, 0.15);
}
/* 「ここで分割」ボタン。問題セルにフォーカスがあって、かつテキストがある時のみ表示。
   問題セルの右下にコンパクトに配置し、textareaの編集を邪魔しないよう
   見た目は最小限。タップでカーソル/選択範囲位置を境に問題→答えへテキストを移動。 */
.memo-split-btn {
  position: absolute;
  right: 6px;
  bottom: 4px;
  display: none;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  background: var(--brand-500);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* v1.2.126: iOS PWA でワンタップが落ちる対策。
     ① スクロールコンテナ(.memo-table-wrap)内にあるため、ボタン上で指がわずかに
        動くとブラウザがパン開始と判断して pointercancel → click が飛ばない。
        touch-action:none でこのボタン上だけパン判定を止める。
     ② タップ判定自体は pointerdown/pointerup で行う（下の memoBindSplitTaps）。
        pointerdown で preventDefault すると iOS では合成 click が抑止される
        ことがあり、click 依存だと「押しても反応しない」が再現する。 */
  touch-action: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  z-index: 2;
  opacity: 0.92;
  transition: transform 0.12s, opacity 0.12s;
}
.memo-split-btn:active,
.memo-split-btn.is-pressed {
  transform: scale(0.94);
  opacity: 1;
}
/* v1.2.126: 見た目は変えずにタップ判定だけ少し広げる。ボタン実寸が
   約20px高しかなく、指の中心が数px外れただけで外していたため。 */
.memo-split-btn::after {
  content: '';
  position: absolute;
  top: -8px;
  right: -6px;
  bottom: -6px;
  left: -8px;
}
/* v1.2.590: 問題セルの分割ボタンは、真下の帯（メモを追加の段）の高さぶんまで
   当たり判定を下へ伸ばす。メモを追加を文字幅に縮めて空いた場所なので、
   下に外しても分割が効く。メモ欄が開いている行（.has-note）は真下がメモの
   textarea なので伸ばさない。答えセル側は真下が ＋／ゴミ箱なので対象外。 */
.memo-row:not(.has-note) .memo-cell-q .memo-split-btn::after {
  bottom: -40px;
}
/* v1.2.104: 問題セルの分割ボタンは「答えセルが空」のときだけ表示。
   答えにすでに入力があれば分割しても上書きできない（memoSplitToAnswerが弾く）ので、
   ボタン自体を非表示にしてユーザーに無駄なタップをさせない。
   行の親に a-has-text クラスが付いていれば、問題セルの分割ボタンは隠す。 */
.memo-row.a-has-text .memo-cell-q.has-text:focus-within .memo-split-btn {
  display: none;
}
.memo-row.a-has-text .memo-cell-q.has-text:focus-within textarea {
  padding-bottom: 0;
}
.memo-cell-q.has-text:focus-within .memo-split-btn,
.memo-cell-a.has-text:focus-within .memo-split-btn {
  display: inline-flex;
}
/* 分割ボタンがテキストにかぶらないよう、表示時は問題/答えセルのtextarea下部に
   余白を確保。改行直後にボタンが文字に触れるのを防ぐ。
   ボタンと同じ条件（フォーカス中かつテキストあり）にして、フォーカスが
   外れたら通常レイアウトに戻る。 */
.memo-cell-q.has-text:focus-within textarea,
.memo-cell-a.has-text:focus-within textarea {
  padding-bottom: 26px;
}
.memo-split-btn svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}
.memo-row-del {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
@media (hover: hover) {
/* hover はマウスのある環境のみ。タッチ環境では行が削除されてDOMが詰まった
   ときに、移動してきた隣の行のボタンに :hover が乗りっぱなしになる現象を
   防ぐ。:active はタップ中の一瞬だけなので残しても良いが、削除直後に
   位置が動いた要素には乗らない作りで十分。 */
@media (hover: hover) {
  .memo-row-del:hover {
    opacity: 1;
    color: #ef4444;
  }
}
}
.memo-row-del:active {
  opacity: 1;
  color: #ef4444;
}
/* 「この行の下に追加」ボタン。ゴミ箱の左隣に並べ、同じ流儀（透明・薄表示）で
   UIノイズを抑える。色は緑系で削除と視覚的に区別。 */
.memo-row-add {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
@media (hover: hover) {
  .memo-row-add:hover {
    opacity: 1;
    color: #22c55e;
  }
}
.memo-row-add:active {
  opacity: 1;
  color: #22c55e;
}
.memo-add-row-btn {
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  margin: 4px 0;
}
.memo-add-row-btn:active {
  background: var(--bg-primary);
  color: var(--text-primary);
}
@media (hover: hover) {
.memo-add-row-btn:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}
}
/* 先頭挿入バリアント。テーブル枠が無くなったので破線も不要。 */
.memo-add-row-btn--top { }

/* ===== Memo loading indicator =====
   大量行（500行〜）のメモ帳デッキを開いた直後、autosize処理が完了して
   wrap が visible になるまでの間に表示する。wrap が hidden の間に
   .memo-table-wrap の領域に重ねる absolute 配置。150ms 以上待った場合のみ
   フェードインで出す（小デッキでは表示されない）。 */
.memo-loading {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 5;
}
.memo-loading.show {
  opacity: 1;
}
.memo-loading-text {
  color: var(--text-secondary, var(--gray-500));
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* v1.2.460: 「元に戻す」付きトースト。旧メモ帳の行削除用トーストを
   デッキ削除の Undo 用に流用・改名。下部ナビの上に出す（右下の緑FABと同じ高さ）。
   グローバル .toast とは独立（ボタンを受け取るので pointer-events と構造が違う）。 */
.undo-toast {
  position: fixed;
  bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--gray-800);
  color: white;
  padding: 8px 8px 8px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9998;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
  max-width: calc(100vw - 32px);
}
.undo-toast.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.undo-toast__msg {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.undo-toast__btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}
.undo-toast__btn:active {
  background: rgba(255, 255, 255, 0.28);
}
@media (hover: hover) {
.undo-toast__btn:hover {
  background: rgba(255, 255, 255, 0.28);
}
}
body.dark-mode .undo-toast {
  background: #2a2535;
  color: #f5f0ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
/* v1.2.461: メモ帳画面には下部ナビが無いので、その中のトーストは元の高さ（30px）に */
#screen-memo-editor #memoUndoToast {
  bottom: 30px;
}
/* Deck card memo badge */
.dc-memo-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #6b7280);
  line-height: 1;
}
.dc-memo-badge svg {
  width: 100%;
  height: 100%;
  display: block;
}
.deck-card.is-memo .dc-thumb { opacity: 0.6; }
/* メモ帳デッキ かつ サムネ未設定のとき、バッジ📝（左上に絶対配置）が
   デッキ名と被る。サムネはdisplay:noneなので、テキスト側に左余白を確保する。 */
.deck-card.is-memo .dc-thumb:not(.has-img) + .deck-card-info {
  padding-left: 26px;
}
/* ===== /Memo Editor ===== */

/* v1.2.342: 横スクロールの器 .filter-tabs は、2画面ともピル1個に
   置き換わったので削除した。.filter-tab / .tab-count はそのピルが
   そのまま使っている（色の定義もここに残っている）。 */
/* v1.2.248: 影を外してフラットに（上部が模様に見えていたため）。
   v1.2.342 以降、このクラスを使うのは各画面の絞り込みピル1個だけ。
   高さ 30px は .list-filter-bar の min-height と揃えてある。 */
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: none;
  font-family: inherit;
  /* v1.2.164: 11px → 13px。iOSのセグメンテッドコントロールは 13px Semibold。 */
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--gray-500);
  white-space: nowrap;
  flex-shrink: 0;
}
/* v1.2.248: 括弧をやめて数字だけを一段小さく薄く添える。
   旧実装は min-width:1.6em で桁揃えしていたが、0件のとき
   「保存済み ( 0 )」と間延びして見えるのが上部のノイズになっていた。
   桁揃えは tabular-nums だけで足りる（幅は内容なりに変わってよい）。 */
.filter-tab .tab-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
}
/* v1.2.627: 絞り込み中のピルを「全面塗り」→「白いピル＋色の点」に変更。
   塗りは「＋追加」の緑・デッキバーの黒と並んで上部の主張が強く、しかも絞り込みごとに
   色が変わるので画面の印象が毎回変わっていた。色は 8px の点（::before）だけに残す。
   ・点がある＝絞り込み中／点なし＝すべて、という読み方（v1.2.340 の
     「絞り込んだまま忘れない」目的は維持）
   ・色の意味（習熟度の色）はそのまま。値は --fp-dot で渡す
   ・文字と件数の色は「すべて」のときと同じ（.active で白にしない）
   一覧とリスニングの両方のピルに効く。 */
.filter-tab.active::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fp-dot, var(--gray-400));
  flex-shrink: 0;
}
.filter-tab.all.active::before { display: none; }
.filter-tab.unlearned.active { --fp-dot: var(--gray-400); }
.filter-tab.weak.active { --fp-dot: var(--purple-400); }
.filter-tab.fuzzy.active { --fp-dot: var(--yellow-500); }
.filter-tab.bookmarked.active { --fp-dot: var(--bookmark); }
/* v1.2.181: 「メモあり」。既存6色（グレー/アンバー/グレー/ブルー/イエロー/グリーン）
   と被らない色が要るのでティールを直値で入れる。--purple-400 は名前に反して
   ブルー(#3B82F6)で「苦手」が使っており、--blue-500 も同値なので選べない。
   ライトは白文字とのコントラストを確保するため teal-600 相当まで濃くする。 */
.filter-tab.noted.active { --fp-dot: var(--dot-noted); } /* v1.2.629: 直値→変数（絞り込みメニューの点と共用） */
.filter-tab.mastered.active { --fp-dot: var(--green-500); }

/* v1.2.342: 並び順のセグメンテッドコントロール（.sort-row / .sort-btn）は
   削除した。一覧（編集）もリスニングも、並び替えは .list-sort-trigger →
   選択肢シート（SETTING_SHEETS.editorSort / listeningSort）に変わったため。
   同じ理由で syncSortRow() も撤去済み。 */



/* Quiz mode selector */
#screen-level-select {
  display: none;
}
#screen-level-select.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--bg, #F8F9FA);
  padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) env(safe-area-inset-bottom) calc(16px + env(safe-area-inset-left));
  max-width: 480px;
  margin: 0 auto;
}
#screen-level-select .unified-setup {
  flex-shrink: 0;
}
.ls-thumb-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ls-bottom-spacer {
  flex: 1;
}
.ls-thumb-img {
  display: none;
  max-width: 80%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 12px;
}
.ls-thumb-area.has-thumb .ls-thumb-img {
  display: block;
}
.unified-setup {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}
.advanced-nav-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 10px;
  transition: background 0.15s;
}
.advanced-nav-btn:active {
  background: var(--gray-100);
}
#screen-listening {
  display: none;
  font-family: var(--font-ui);
}
#screen-listening.active {
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  padding-top: 20px;
}
body.has-bottom-nav #screen-listening.active {
  height: calc(var(--app-height, 100dvh) - 70px - env(safe-area-inset-bottom, 0px));
}
#screen-advanced-settings {
  display: none;
}
#screen-advanced-settings.active {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: var(--bg, #F8F9FA);
  /* v1.2.192: 下側の余白は「入れ物の padding」ではなく「中身の padding」で確保する。
     WebKit はフレックスコンテナをスクロールさせるとき、コンテナ自身の
     padding-bottom をスクロール可能領域に含めない。v1.2.191 でここに 28px を
     足したのに、最後まで送っても最後のカードが下端に貼り付いたままだったのは
     このため。safe-area も同じ理由で中身側に移してある。 */
  padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
  max-width: 480px;
  margin: 0 auto;
  /* v1.2.189: 従来 overflow の指定が無く、内容が画面高を超えると
     はみ出した分に到達できなくなっていた（小さい端末・文字サイズ拡大時に
     現実的に起こりうる）。設定項目は今後も増えるのでスクロールを許可する。
     .unified-setup の margin:auto による上下中央寄せは、フレックスの仕様上
     「余白が負のとき auto マージンは 0 として扱われる」ので、
     はみ出し時に上が切れて戻れなくなる罠（listening-player で踏んだやつ）は起きない。
     overscroll-behavior:contain は iOS PWA で背後や pull-to-refresh へ
     スクロールが伝播しないようにするため。 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* v1.2.211: 詳細設定のスクロールバーは非表示にする（本人の指示）。
   経緯＝v1.2.196 で「max-width:480px の中央寄せなので、既定の太いバーが
   画面のど真ん中に立つ」のを嫌って 4px の細いつまみに揃えたが、
   結局 .app や一覧の横スクロール帯と同じく、出さない方が収まりが良い。
   スクロール自体は overflow-y:auto のまま生きているので、
   ホイール／スワイプ／キーボードでは今までどおり最後まで送れる。
   標準プロパティと webkit の両方を書くのは、Chrome 121+ が
   scrollbar-width を優先し、それ以外のブラウザは webkit 側を見るため
   （どちらが勝っても「消す」で結果が一致する組み合わせなので併記して良い）。 */
#screen-advanced-settings.active {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#screen-advanced-settings.active::-webkit-scrollbar { display: none; }
/* v1.2.189: 詳細設定は .unified-setup（白カード1枚）をやめて .settings-groups に。
   .unified-setup は出題範囲画面でも使っているので、そちらに影響が出ないよう
   クラスごと分けている。 */
#screen-advanced-settings .settings-groups {
  flex: none;
  display: flex;
  flex-direction: column;
  margin-top: auto;
  margin-bottom: auto;
  width: 100%;
  /* v1.2.192: 上の理由で、画面下の余白はここが持つ。中身のボックスの一部なので
     スクロールしきった位置でも必ず残る。margin ではなく padding にするのは、
     フレックスアイテムの margin-bottom も同じくスクロール領域から落ちるため。 */
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}
.settings-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: 0.02em;
  padding: 0 6px 5px;
  margin-top: 14px;
}
.settings-groups > .settings-group-label:first-child {
  margin-top: 0;
}
.settings-group {
  background: white;
  border-radius: 14px;
  padding: 2px 14px;
  box-shadow: var(--shadow-sm);
}
body.dark-mode .settings-group {
  background: #1e1a28;
}
/* 行の区切りは border-top で引く。border-bottom にすると、行のすぐ下に
   補助テキスト(.drill-desc)がぶら下がる行で「行とその説明文の間」に
   線が入ってしまう。border-top なら常に「前の行＋その説明文」と
   「次の行」の境目に落ちる。 */
.settings-group .setting-row,
.settings-group .setting-nav-row {
  border-top: 0.5px solid var(--gray-200);
}
.settings-group > .setting-row:first-child,
.settings-group > .setting-nav-row:first-child {
  border-top: none;
}
.settings-group .setting-row {
  margin-bottom: 0;
  padding: 9px 0;
}
/* ★詳細度を .setting-row .setting-label（0,2,0）より高くしておく。
   このブロックは .setting-row の定義より前にあるので、同点だと後勝ちで負ける
   （タブレット用ブロックが丸ごと死んでいた v1.2.147 と同じ罠）。 */
.settings-group .setting-row .setting-label,
.settings-group .setting-nav-row .setting-label {
  font-size: 14px;
  color: var(--gray-800);
  min-width: 76px;
}
.settings-group .drill-desc {
  margin: -3px 0 10px;
}
.setting-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 14px 0;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.setting-nav-value {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
}
.setting-nav-chevron {
  width: 15px;
  height: 15px;
  color: var(--gray-400);
  flex-shrink: 0;
}
.setup-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 8px;
  margin-top: 16px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.setting-row .setting-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
  min-width: 80px;
  flex-shrink: 0;
}
.setting-row .mode-toggle {
  margin-bottom: 0;
  flex: 1;
}
.setting-row .mode-toggle-btn {
  padding: 8px 3px;
  font-size: 13px;
}
.toggle-switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--brand-500);
}
.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(18px);
}
body.dark-mode .toggle-slider {
  background: #3a3545;
}
body.dark-mode .toggle-switch input:checked + .toggle-slider {
  background: var(--brand-500);
}
.timer-seconds-select {
  padding: 6px 10px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  background: white;
  cursor: pointer;
}
body.dark-mode .timer-seconds-select {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-900);
}
/* v1.2.584: 読み上げ言語のシート。1枚のシートに「問題」「答え」の2段を出し、
   選択肢は行ではなくチップで並べる（8択×2段を行で積むと画面に収まらない）。
   値が2つあるので、選んでもシートは閉じない（トグル行と同じ扱い）。 */
.sheet-section-label {
  margin: 14px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
}
.sheet-section-label:first-child { margin-top: 4px; }
/* v1.2.843: シートのタイトル直下の補足1行（言語シート） */
.sheet-note {
  margin: -4px 2px 2px;
  font-size: 12px;
  color: var(--gray-500);
  text-align: center;
}
.sheet-note + .sheet-section-label { margin-top: 10px; }
.sheet-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* v1.2.893: 言語が9個（中国語を簡体・繁体に分けた）になったので 4列→3列（3×3）。このグリッドは言語シートだけ */
  gap: 6px;
}
.sheet-chip {
  padding: 10px 2px;
  border: none;
  border-radius: 8px;
  background: var(--gray-100);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sheet-chip.selected {
  background: var(--brand-500);
  color: white;
}
/* v1.2.894: 言語シートを「問題」「答え」の2行＋ホイールに（チップの .sheet-chip-grid は使わなくなったが、
   他で使う可能性を残して定義はそのまま）。行の高さ 52px、ホイールは 40px×5段＝真ん中が選択位置。 */
.lang-slots {
  margin-top: 12px;
  border-radius: 12px;
  background: var(--gray-50, #f9fafb);
  overflow: hidden;
}
.lang-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  background: none;
  border: none;
  border-top: 0.5px solid var(--gray-200);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lang-slot:first-child { border-top: none; }
.lang-slot-label { flex: 1; font-size: 15px; font-weight: 600; color: var(--gray-800); }
.lang-slot-value { font-size: 15px; font-weight: 600; color: var(--brand-600, var(--brand-500)); }
.lang-slot-chev {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: var(--gray-400); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}
.lang-slot.open .lang-slot-chev { transform: rotate(180deg); }
.lang-wheel-wrap {
  position: relative;
  height: 0;
  overflow: hidden;
  transition: height 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.lang-wheel-wrap.open { height: 200px; }
.lang-wheel-band {
  position: absolute;
  left: 10px; right: 10px;
  top: 80px; height: 40px;
  border-radius: 8px;
  background: var(--gray-100);
  pointer-events: none;
}
.lang-wheel {
  position: relative;
  height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  padding: 80px 0;
  box-sizing: border-box;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 35%, #000 65%, transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 35%, #000 65%, transparent 100%);
}
.lang-wheel::-webkit-scrollbar { display: none; }
.lang-wheel-item {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  scroll-snap-align: center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lang-wheel-item.centered { font-size: 16px; font-weight: 700; color: var(--gray-900); }
body.dark-mode .lang-slots { background: #2a2535; }
body.dark-mode .lang-wheel-band { background: #3a3545; }
.quiz-count-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
  outline: none;
}
.quiz-count-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-500);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(249,115,22,0.3);
}
.quiz-count-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-500);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(249,115,22,0.3);
}
.quiz-count-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-500);
  min-width: 56px;
  text-align: center;
  flex-shrink: 0;
  padding: 5px 10px;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.quiz-count-value:active {
  transform: scale(0.95);
  background: var(--brand-100);
}
body.dark-mode .quiz-count-slider {
  background: #3a3545;
}
/* v1.2.189: セグメンテッドコントロールを「溝（トラック）＋つまみ」方式に変更。
   旧実装は選択肢1つ1つが border:2px + radius:12px を持っていたため、詳細設定の
   画面上に独立した角丸が20個並び、それが散らかって見える最大の原因だった。
   ネイティブ（iOS/Android）のセグメンテッドコントロールは輪郭が1つだけなので、
   .mode-toggle 側に背景と padding を持たせ、ボタンからは border を外して
   active の時だけ白いつまみを敷く。
   ★transition は敢えて付けない。既知の教訓「押下時の色変化は即時に」に従う
   （background/color を補間すると反応が鈍く感じる）。 */
.mode-toggle {
  display: flex;
  gap: 2px;
  border-radius: 10px;
  background: var(--gray-100);
  padding: 3px;
  overflow: visible;
  margin-bottom: 8px;
}
.mode-toggle-btn {
  flex: 1;
  padding: 12px 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mode-toggle-btn.active {
  background: white;
  color: var(--brand-600);
  box-shadow: 0 1px 2px rgba(0,0,0,0.10), 0 0 0 0.5px rgba(0,0,0,0.04);
}
/* v1.2.189: 補助テキストの主張を下げる。旧実装はブランド緑・太字・中央揃えで、
   説明しているはずの設定行より目立っていた。左揃え・グレー・通常寄りの太さにして、
   直前の行にぶら下がって見えるよう上マージンを詰める。 */
.drill-desc {
  font-size: 12px;
  color: var(--gray-500);
  text-align: left;
  margin: -4px 0 10px;
  font-weight: 500;
  line-height: 1.5;
}
/* ===== v1.2.211: 補助テキストの高さを固定する =====
   旧実装は display:none / block の切り替えだったので、ヒントの無い選択肢
   （カード・ノーマル・自動表示×カード）と有る選択肢を行き来するたびに
   カードの高さが1〜2行ぶん跳ねていた。
   対策＝その設定行で出しうる文言を全部このスロットに入れ、CSS グリッドで
   1つのセルに重ねる。トラックの高さは「一番背の高い文言」で決まるので、
   何も出していない状態でもその高さが確保され、枠は一切動かない。
   ・切り替えは display ではなく visibility（display:none だとセルから
     外れて高さの計算に入らないため、必ず visibility を使うこと）。
   ・文言を JS で textContent に流し込むのはやめ、HTML に置いた
     data-desc 付きの div を setDescSlot() で選ぶ方式にした。
     文言を1つ増やしたら自動的に確保高さも追従する。
   ・折り返しの行数は画面幅で変わるが、この方式なら幅ごとに実測されるので
     min-height を決め打ちする必要がない（PCで1行／スマホで2行でも正しい）。 */
.drill-desc-slot {
  display: grid;
}
.drill-desc-slot > .drill-desc {
  grid-area: 1 / 1;
  visibility: hidden;
}
.drill-desc-slot > .drill-desc.is-on {
  visibility: visible;
}

/* Level select grid */
.level-select-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 4px;
}
.level-select-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
  cursor: pointer;
  /* transition: all 0.2s は、タップでselectedクラスが付いてから
     border/background/box-shadowが200msかけて補間されるため、
     「タップしても反応が遅い」という体感の主因になっていた。
     色関連は即時反映、transformのみ短い補間にする */
  transition: transform 0.1s;
  border: 2px solid var(--gray-200);
  min-width: 80px;
  flex-shrink: 0;
  /* iOS PWA: 横スクロール可能な親内のカードは、Safariがタップとスクロールの
     どちらの意図か判定待ちするため押下反応が遅れる。manipulation指定で
     ダブルタップズーム判定等を切り、タップを即時確定させる */
  touch-action: manipulation;
}
.level-select-card:active { transform: scale(0.97); }
.level-select-card.selected {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 1px var(--brand-200);
  background: var(--brand-50);
}
.level-select-card.disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}
.level-select-card .ls-icon { font-size: 18px; margin-bottom: 2px; }
.level-select-card .ls-label {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 1px;
}
.level-select-card .ls-count {
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-ui);
}
.level-select-card.all .ls-label, .level-select-card.all .ls-count { color: var(--gray-700); }
.level-select-card.unlearned .ls-label, .level-select-card.unlearned .ls-count { color: var(--gray-600); }
.level-select-card.bookmarked .ls-label, .level-select-card.bookmarked .ls-count { color: var(--bookmark); }
.level-select-card.weak .ls-label, .level-select-card.weak .ls-count { color: var(--purple-400); }
.level-select-card.fuzzy .ls-label, .level-select-card.fuzzy .ls-count { color: var(--yellow-500); }
.level-select-card.mastered .ls-label, .level-select-card.mastered .ls-count { color: var(--green-500); }
.level-select-card.locked {
  opacity: 0.5;
  cursor: pointer;
  position: relative;
  background: var(--gray-50);
  border: 2px dashed var(--gray-300);
}
.level-select-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  /* 横スクロール専用と明示。縦スクロール判定が混ざらないため、
     子カードのタップ確定がさらに速くなる */
  touch-action: pan-x;
}
.level-select-row.dragging {
  cursor: grabbing;
}
.level-select-row::-webkit-scrollbar { display: none; }
/* v1.2.219: 琥珀色のグラデーション＋影をやめ、親カード（.unified-setup）の
   背景に溶かす。達成感は絵文字と緑の見出しで足りていて、塗りは主張が強すぎた。
   transparent にしているのでライト／ダークどちらも親に追従する。 */
.level-praise-banner {
  background: transparent;
  border-radius: var(--radius);
  padding: 16px 16px 4px;
  text-align: center;
  margin-bottom: 14px;
}
.level-praise-banner .praise-emoji {
  font-size: 28px;
  margin-bottom: 6px;
}
.level-praise-banner .praise-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-600);
  margin-bottom: 4px;
}
.level-praise-banner .praise-sub {
  font-size: 12px;
  color: var(--gray-600);
  line-height: 1.5;
}
/* v1.2.164: バナー内の周回導線。v1.2.219 でバナーの塗りを外したので、
   この緑のピルがこの一帯で唯一の面になる。 */
.level-praise-banner .praise-lap-btn {
  margin-top: 12px;
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: var(--brand-600);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s;
  box-shadow: 0 2px 8px rgba(46, 125, 50, 0.28);
}
.level-praise-banner .praise-lap-btn:active { transform: scale(0.97); }

.start-quiz-btn {
  width: 100%;
  margin-top: 16px;
  background: var(--brand-500);
  color: white;
  border: none;
  padding: 16px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(74,158,63,0.3);
  /* transition:allはタップ時の視覚反応を遅らせる。
     hover時のbackground変化だけ短めの補間を残す（タップには効かない） */
  transition: background-color 0.15s;
}
@media (hover: hover) {
.start-quiz-btn:hover { background: var(--brand-600); }
}
.start-quiz-btn:disabled {
  background: var(--gray-300);
  box-shadow: none;
  cursor: not-allowed;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  padding: 14px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.toast.show {
  opacity: 1;
  visibility: visible;
}
/* v1.2.498: Google Drive 同期の進行表示（トーストと同じ見た目・位置。どの画面でも見える） */
.gdrive-progress {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: white;
  padding: 14px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9998;
  box-shadow: var(--shadow-xl);
  display: none;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.gdrive-progress.show { display: flex; }
.gdrive-progress svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  animation: gdriveProgressSpin 1s linear infinite;
}
@keyframes gdriveProgressSpin { to { transform: rotate(360deg); } }
body.dark-mode .gdrive-progress {
  background: #2a2535;
  color: #f5f0ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
body.dark-mode .toast {
  background: #2a2535;
  color: #f5f0ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Level badge colors */
/* v1.2.686: クイズカード上部の学習段階バッジを復活（v1.2.667 で削除→本人判断で戻す）。
   上段の中央に absolute で置くので、左右のボタンの並び・高さには影響しない。 */
.quiz-card .level-badge,
.quiz-card-next .level-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 12px;
  align-self: center;
}
.quiz-card-topbar .level-badge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 0;
}
.badge-unlearned { background: var(--gray-200); color: var(--gray-500); }
.badge-weak { background: var(--purple-100); color: var(--purple-400); }
.badge-fuzzy { background: #FEF9C3; color: var(--yellow-500); }
.badge-mastered { background: #DCFCE7; color: var(--green-500); }

/* Confirm modal */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  /* v1.2.494: 2000 だとデッキ編集モーダル（同じ2000・文書順で後ろ）の裏に
     隠れた。確認ダイアログはどの画面・シート・パネルから呼ばれても最前面に
     出るべきなので、設定パネル（3000）より上・トースト（5000）より下に置く。 */
  z-index: 3100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeInOverlay 0.2s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.confirm-overlay.show { display: flex; }
/* Duplicate warning can be opened while the one-by-one edit modal is still open.
   Keep it above #editWordOverlay so the warning is readable and clickable. */
#dupWarningOverlay { z-index: 2600; }
@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }
/* Quiz count input modal — pin to top so the iOS keyboard accessory bar
   doesn't cover the cancel/confirm buttons. Keyboard + accessory bar takes
   roughly the bottom half of the screen; anchoring near the top keeps the
   modal fully visible without requiring the user to scroll. */
#quizCountInputOverlay {
  align-items: flex-start;
  /* v1.2.619: --kb-pad-top はJS（_kbDock*）が「キーボードのすぐ上」になる値を入れる。
     未設定（PC・キーボードが出ていない・高さ不明の初回）は従来の上寄せ。 */
  padding-top: var(--kb-pad-top, max(80px, env(safe-area-inset-top, 20px)));
  transition: padding-top 0.2s ease;
}
/* v1.2.181: クイズ中のメモ入力シート。理由は #quizCountInputOverlay と同じで、
   iOS のソフトキーボード＋アクセサリバーが画面下半分を占めるため上寄せにする。 */
#quizNoteOverlay {
  align-items: flex-start;
  padding-top: var(--kb-pad-top, max(60px, env(safe-area-inset-top, 20px))); /* v1.2.619 */
  transition: padding-top 0.2s ease;
}
/* v1.2.620: スマホ・タブレット（data-kb-dock）では、ダイアログ本体を最初から不透明で出す。
   従来は overlay ごと opacity 0→1 でフェードしていたので、0.2秒のあいだダイアログが半透明になり、
   真下の問題文・答えが透けて見えた（上寄せのときは下に文字が少なく目立たなかった）。
   暗幕だけを背景色でフェードさせ、本体のフェード／ポップは止める。PCは従来どおり。 */
@keyframes kbDockDim { from { background-color: transparent; } }
#quizCountInputOverlay[data-kb-dock],
#quizNoteOverlay[data-kb-dock] { animation: kbDockDim 0.2s ease; }
#quizCountInputOverlay[data-kb-dock] .confirm-modal,
#quizNoteOverlay[data-kb-dock] .confirm-modal { animation: none; }
/* v1.2.619: 開いた瞬間に「前回覚えた位置」へ置くときは動かさずに即座に。 */
#quizCountInputOverlay.kb-dock-instant,
#quizNoteOverlay.kb-dock-instant { transition: none; }
/* v1.2.618: 上寄せはソフトキーボード対策なので、キーボードが出ないPC（マウス環境）では
   他のダイアログと同じ画面中央に戻す。スマホ・タブレットは従来どおり上寄せ。 */
@media (hover: hover) and (pointer: fine) {
  #quizCountInputOverlay,
  #quizNoteOverlay {
    align-items: center;
    padding-top: 24px; /* .confirm-overlay の既定値に戻す */
  }
}
#quizNoteOverlay .confirm-modal {
  max-width: 380px;
  padding: 22px 20px 20px;
  /* v1.2.181: modalPop の scale(0.9)→scale(1) はやめる。開いた瞬間に
     textarea へ同期 focus するので、transform がアニメーション中の要素に
     フォーカスが入ると iOS がキャレット位置を測り損ねてスクロールが飛ぶ。
     既存の #newDeckModalContent と同じく不透明度だけのフェードにする。 */
  animation: modalFade 0.2s ease;
}
#quizNoteWord {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 14px;
  word-break: break-word;
  overflow-wrap: break-word;
}
#quizNoteField {
  min-height: 5.6em;
  text-align: left;
}
/* Hide browser default number-spinner UI on the quiz-count input
   (it adds visual noise and isn't needed — keyboard input is the point). */
#quizCountInputField::-webkit-inner-spin-button,
#quizCountInputField::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
#quizCountInputField:focus {
  outline: none;
  border-color: var(--brand-500);
}
.confirm-modal {
  background: white;
  border-radius: 20px;
  padding: 32px 24px 24px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalPop 0.25s ease;
  touch-action: manipulation;
}
@keyframes modalPop {
  from { transform: scale(0.9); }
  to { transform: scale(1); }
}
/* New Deck modal: use opacity-only fade instead of scale-pop.
   Measurement confirmed that the scale(0.9)->scale(1) animation
   causes icons inside flex-row buttons to visibly drift during
   the 250ms animation on mobile. */
#newDeckModalContent {
  animation: modalFade 0.2s ease !important;
}
/* v1.2.896: 言語設定のダイアログも拡大（modalPop）をやめてフェードだけに。
   PC（1920px幅で :root に zoom 1.1）では文字の位置が半端なピクセルになり、
   拡大の終わりに文字が描き直されて一部が少し動いて見えていた。 */
#uiLangOverlay .confirm-modal {
  animation: modalFade 0.2s ease;
}
/* v1.2.897: PC（マウス環境）では、拡大しながら出るダイアログ・メニュー全部をフェードだけにする。
   理由は v1.2.896 と同じ（拡大の終わりに文字が描き直されて少し動く）。
   modalPop＝確認ダイアログ全般（.confirm-modal）・デッキ編集（.deck-edit-modal）・CSVの表（.csv-table-modal）、
   calPopIn＝「調べる」などの小さいメニュー（.copy-menu-popup）。
   キーフレームを差し替えるだけなので、各ダイアログの animation の指定は触らない。スマホ・タブレットは従来どおり。 */
@media (hover: hover) and (pointer: fine) {
  @keyframes modalPop {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  @keyframes calPopIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}
/* v1.2.898: ダイアログの中のボタンの文字は選択できないようにする。
   PCで、開いたダイアログのボタン（「共有用ファイル」「このデッキをリセット」など）の
   文字が青く選択された状態で出ることがあった。ボタンの文字を選ぶ用事は無いので一律に止める。
   入力欄（input・textarea）は対象外なので、デッキ名などは今までどおり選択・コピーできる。 */
.confirm-modal button,
.deck-edit-modal button,
.csv-table-modal button {
  -webkit-user-select: none;
  user-select: none;
}
@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.confirm-modal .confirm-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.confirm-modal h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 8px;
}
.confirm-modal p {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.6;
  margin-bottom: 24px;
}
.confirm-buttons {
  display: flex;
  gap: 10px;
}
.confirm-cancel {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--gray-200);
  background: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
}
@media (hover: hover) {
.confirm-cancel:hover { background: var(--gray-100); }
}
.confirm-danger {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--red-500);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  transition: background 0.05s, box-shadow 0.05s;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
@media (hover: hover) {
.confirm-danger:hover { background: #DC2626; }
}
.confirm-danger:disabled {
  background: var(--gray-300);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.6;
}
@media (hover: hover) {
.confirm-danger:disabled:hover { background: var(--gray-300); }
}
@media (hover: hover) {
/* v1.2.164: 周回導線の確認だけ、実行ボタンを赤からブランド色にする。
   confirmAction(..., { light: true }) が .is-lap を付け外しする。
   :hover と box-shadow は上の赤い定義より後ろに置かないと勝てない。 */
.confirm-danger.is-lap {
  background: var(--brand-600);
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}
}
@media (hover: hover) {
.confirm-danger.is-lap:hover { background: var(--brand-500); }
}

/* ==== Import Preview (v1.2.17) ==== */
/* Pin to top so the modal stays visible even with the iOS keyboard's
   accessory bar showing. Also lets the table scroll naturally without
   the modal needing to grow vertically. */
#importPreviewOverlay {
  align-items: flex-start;
  padding-top: max(40px, env(safe-area-inset-top, 20px));
}
.ipv-modal-desc {
  font-size: 13px;
  color: var(--gray-500);
  margin: 4px 0 12px;
  line-height: 1.5;
}
#importPreviewSummary {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 8px;
  text-align: left;
}
#importPreviewTableWrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: white;
  text-align: left;
}
body.dark-mode #importPreviewTableWrap {
  background: #1e1a28;
  border-color: #3a3545;
}
#importPreviewTable {
  /* Use auto layout but enforce per-column min widths via td/th rules
     below. When totals exceed the wrapper, the wrapper scrolls
     horizontally — much better than letters wrapping vertically. */
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#importPreviewTable th,
#importPreviewTable td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: top;
  /* Avoid breaking English words mid-letter — let the wrapper scroll
     horizontally instead. Long Japanese phrases still wrap naturally
     between characters. */
  word-break: normal;
  overflow-wrap: anywhere;
  color: var(--gray-800);
}
/* Per-column minimum widths so a narrow modal doesn't crush English
   words like "follow" into 1-letter-per-line stacks. The wrapper
   handles horizontal overflow. */
#importPreviewTable thead th:nth-child(2),
#importPreviewTable tbody td:nth-child(2),
#importPreviewTable thead th:nth-child(3),
#importPreviewTable tbody td:nth-child(3) {
  min-width: 110px;
}
#importPreviewTable thead th:nth-child(4),
#importPreviewTable tbody td:nth-child(4) {
  min-width: 160px;
}
/* Sticky header. CRITICAL: background MUST be fully opaque (white in
   light mode, dark color via override in dark mode) — earlier
   versions used a made-up `--bg-primary` var that didn't exist, which
   left the header transparent and let body cells show through it
   when the user scrolled. See the "見出しと下の問題が被る" bug. */
#importPreviewTable thead th {
  position: sticky;
  top: 0;
  background: white;
  z-index: 3;
  border-bottom: 2px solid var(--gray-200);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
}
body.dark-mode #importPreviewTable thead th {
  background: #1e1a28;
  border-bottom-color: #3a3545;
  color: var(--gray-400);
}
/* v1.2.179: ダークの色指定に注意。--gray-* はダークで**反転**しており、
   --gray-200 は #3a3545（面・罫線の色）で文字色ではない。ここは以前
   color: var(--gray-200) を指定していて、背景 #1e1a28 にほぼ同化した
   文字が出ていた。基底の rule が color: var(--gray-800) を持ち、これは
   ダークで #F2F2F7 に解決されるので、ダーク側で色を上書きしないのが正解。 */
body.dark-mode #importPreviewTable th,
body.dark-mode #importPreviewTable td {
  border-bottom-color: #2a2535;
}
#importPreviewTable .ipv-row-controls-cell {
  width: 58px;
  text-align: center;
  padding: 4px 4px;
  /* Pin to left during horizontal scroll — keeps shift buttons
     always reachable even when the table is wider than the wrapper.
     thead cells get z-index 3, so theirs wins over body cells (2). */
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
}
#importPreviewTable thead th.ipv-row-controls-cell {
  z-index: 4;
}
body.dark-mode #importPreviewTable .ipv-row-controls-cell {
  background: #1e1a28;
}
#importPreviewTable .ipv-row-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
/* Compact left/right shift buttons. Per-row only — touching one row
   does not affect others, which matches how copy-pasted tables go
   wrong: usually one or two rows are off by a column. Shifting is
   non-destructive (per-row buffers in JS), so users can undo. */
#importPreviewTable .ipv-shift-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
#importPreviewTable .ipv-shift-btn:hover { background: var(--gray-100); color: var(--gray-800); }
}
#importPreviewTable .ipv-shift-btn:active { background: var(--brand-50); }
/* Column-wide shifters in the header — slightly emphasised so the
   user notices the "全行まとめて" affordance vs. per-row buttons. */
#importPreviewTable .ipv-shift-all {
  background: var(--brand-50);
  color: var(--brand-600);
  border-color: var(--brand-100);
  font-size: 11px;
  letter-spacing: -1px;
}
@media (hover: hover) {
#importPreviewTable .ipv-shift-all:hover {
  background: var(--brand-100);
  color: var(--brand-600);
}
}
body.dark-mode #importPreviewTable .ipv-shift-btn {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-600); /* ‹ › は 1 文字なので --gray-400 だと沈む */
}
@media (hover: hover) {
body.dark-mode #importPreviewTable .ipv-shift-btn:hover {
  background: #3a3545;
  color: var(--gray-800); /* 旧 --gray-200 は背景 #3a3545 と同色で消えていた */
}
}
#importPreviewTable .ipv-col-select {
  /* Fill the cell but with a minimum so the label is always readable.
     The min-width here works with the per-column th min-widths above
     to ensure 「問題」「答え」 actually appear, not just the arrow. */
  width: 100%;
  min-width: 96px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  /* Prevent iOS Safari font-size auto-shrink quirk */
  -webkit-appearance: menulist;
}
#importPreviewTable .ipv-col-select:focus { outline: 2px solid var(--brand-400); }
body.dark-mode #importPreviewTable .ipv-col-select {
  background: #2a2535;
  border-color: #3a3545;
  /* color は指定しない。基底の var(--gray-800) がダークで #F2F2F7 になる。 */
}
/* Mark columns that are slated for deletion with a subtle visual cue. */
#importPreviewTable td.ipv-col-removed,
#importPreviewTable th.ipv-col-removed {
  opacity: 0.4;
  background: repeating-linear-gradient(
    45deg,
    transparent 0 4px,
    var(--gray-100) 4px 8px
  );
}
body.dark-mode #importPreviewTable td.ipv-col-removed,
body.dark-mode #importPreviewTable th.ipv-col-removed {
  background: repeating-linear-gradient(
    45deg,
    transparent 0 4px,
    #2a2535 4px 8px
  );
}
#importPreviewSummary .ipv-summary-warn { color: var(--brand-500); font-weight: 600; }

/* Mobile: shrink padding, lower per-column min widths a touch, and
   keep the horizontal scroll affordance visible. The goal is to show
   at least the role selectors clearly even on a 360px screen. */
@media (max-width: 600px) {
  #importPreviewOverlay .confirm-modal {
    max-width: 96vw !important;
    width: 96vw !important;
    padding: 18px 10px 12px !important;
  }
  .ipv-modal-desc {
    font-size: 12px;
    margin: 4px 0 8px;
  }
  #importPreviewTable thead th:nth-child(2),
  #importPreviewTable tbody td:nth-child(2),
  #importPreviewTable thead th:nth-child(3),
  #importPreviewTable tbody td:nth-child(3) {
    min-width: 96px;
  }
  #importPreviewTable thead th:nth-child(4),
  #importPreviewTable tbody td:nth-child(4) {
    min-width: 140px;
  }
  #importPreviewTable .ipv-col-select {
    min-width: 86px;
    font-size: 11px;
  }
  #importPreviewTable .ipv-row-controls-cell {
    width: 52px;
  }
  #importPreviewTable .ipv-shift-btn {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }
  #importPreviewTable th,
  #importPreviewTable td {
    padding: 5px 6px;
    font-size: 12px;
  }
  #importPreviewTableWrap {
    max-height: 50vh;
  }
}

.confirm-check-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 16px;
  -webkit-tap-highlight-color: transparent;
}
.confirm-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.confirm-checkbox.checked {
  background: var(--red-500);
  border-color: var(--red-500);
}
.confirm-checkbox.checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
/* v1.2.480: 「すべてのデータを削除」だけは、チェック1つではなく「削除」と入力
   させる（誤タップ2回で全消しにならないように）。他の確認は従来どおり。 */
.confirm-type-row {
  display: none;
  margin: 18px 0 16px;
}
.confirm-type-row.show { display: block; }
.confirm-type-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.confirm-type-hint b { color: var(--red-500); font-weight: 700; }
.confirm-type-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px;
  text-align: center;
  outline: none;
}
.confirm-type-input:focus { border-color: var(--red-500); }
.confirm-check-label {
  font-size: 13px;
  color: var(--gray-500);
  text-align: left;
}
/* 重複警告：問題 / 答え を列で揃えた表形式。
   v1.2.368: 検知が同じデッキの中だけになり、デッキ名の列は常に見出しと
   同じ名前（または空）になったので廃止した。 */
/* v1.2.179: 罫線は「セルごとの border-bottom を横に連結して1本に見せる」方式。
   そのため column-gap は 0 固定（gap を入れると列の間で線が切れて破線になる）。
   列間の余白は各セルの padding-right で作る。align-items も stretch 固定
   （center にすると行内でセルの高さが揃わず、罫線が段違いの高さに出る）。 */
#dupWarningList {
  padding-right: 6px; /* スクロールバーと最終列が重ならないように */
}
/* v1.2.369: 要約 → 内訳 → 2つの行動、の順で見せる。
   v1.2.370: 内訳は常時表示（中身を見ずに削除を選ぶ人はいない）。 */
#dupWarningOverlay .dup-desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 10px 0 0;
}
#dupWarningOverlay .dup-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 10px 0 0;
}
#dupWarningOverlay .dup-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin: 10px 0 0;
}
#dupWarningList .dup-sub {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 0 2px;
}
#dupWarningList.no-check .dup-check { visibility: hidden; }
#dupWarningList.no-check .dup-cat { display: none; } /* 見出しの説明文と重複するため */
#dupWarningList.no-check .dup-hint { display: none; }
#dupWarningOverlay .confirm-danger:disabled,
#dupWarningOverlay .confirm-cancel:disabled { /* v1.2.928: 「除いて追加」が白いボタンになったので */
  opacity: 0.45;
  cursor: default;
}
#dupWarningList .dup-grid {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 0;
  align-items: stretch;
}
#dupWarningList .dup-cat {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 14px 0 4px;
}
#dupWarningList .dup-cat:first-child { margin-top: 0; }
#dupWarningList .dup-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 10px 6px 0;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
#dupWarningList .dup-row { display: contents; cursor: pointer; }
#dupWarningList .dup-check,
#dupWarningList .dup-cell {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--border-color);
  min-width: 0;
}
#dupWarningList .dup-check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 8px; /* 17px のチェックボックスが収まるよう内寸を 18px 確保 */
}
#dupWarningList .dup-check input {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin: 0;
}
#dupWarningList .dup-cell {
  font-size: 12.5px;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
#dupWarningList .dup-c-en { color: var(--text-primary); font-weight: 600; }
#dupWarningList .dup-c-ja { color: var(--text-primary); }
/* v1.2.179: 組（重複ペア）の区切りは余白だけで表す。以前は border-top を
   持たせていたが、直前の行が持つ border-bottom と並んで二重線になっていた。 */
#dupWarningList .dup-sep {
  grid-column: 1 / -1;
  height: 10px;
}
.rename-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.rename-input:focus { border-color: var(--brand-400); }
input[type="search"].rename-input::-webkit-search-decoration,
input[type="search"].rename-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.rename-editable {
  min-height: 20px;
  line-height: 1.4;
  cursor: text;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  touch-action: manipulation;
}
/* Ensure all contenteditable elements allow iOS long-press context menu */
[contenteditable="true"] {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
  touch-action: manipulation !important;
}
.rename-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--gray-300);
  pointer-events: none;
}
.rename-editable:focus {
  outline: none;
  border-color: var(--brand-400);
}
.rename-editable br { display: none; }
.rename-editable * { display: inline; }
.edit-word-wrap {
  text-align: center;
}
.edit-word-wrap:focus-within {
  border-color: var(--brand-400);
}
.edit-word-textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  padding: 0;
  margin: 0;
  text-align: center;
  min-height: 2.8em;
  color: inherit;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Word editor */
#screen-word-editor {
  display: none;
  flex-direction: column;
  /* Extend to the viewport's bottom edge — bottom safe-area is absorbed by
     .editor-word-list's own padding-bottom so the scrollable list visually
     runs under the home indicator, iOS-native style. */
  height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top));
  overflow: hidden;
  margin-bottom: -30px;
  padding-top: 20px;
  font-family: var(--font-ui);
}
#screen-word-editor.active {
  display: flex;
}
.editor-header {
  padding: 0;
  /* v1.2.339: 下の余白は最後の子（.list-filter-bar の margin-bottom）に
     任せる。ここに 12px を足すと「隠す」行と離れすぎる。 */
  margin-bottom: 0;
  flex-shrink: 0;
  /* v1.2.532: 集中モードの削除に伴い、畳むための max-height / overflow /
     transition / .scroll-hidden を撤去した。 */
}
/* デッキセレクタ展開時は、兄弟の .editor-word-list より前面に出すため z-index も上げる
   （.deck-selector.open の z-index だけでは、親が auto のままなので
   後から描画されるリストに負ける）。 */
.editor-header:has(#editorDeckSelector.open) {
  position: relative;
  z-index: 100;
}
/* v1.2.340: 絞り込みピル＋並び替えの行。高さは旧フィルタ行と同じ30px。 */
.list-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
  min-height: 30px;
}
/* ピルの見た目は .filter-tab をそのまま使う（色は .filter-tab.weak.active 等の
   既存定義に乗る）。.active を付けるのは絞り込み中だけ＝白いピル＝絞り込みなし。 */
.list-filter-bar .list-filter-pill {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}
.list-filter-pill-chevron {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin-left: -1px;
  opacity: 0.75;
}
/* 並び替え側は枠を持たない素のテキスト＋アイコン。ピルと同じ形にすると
   「絞り込みが2つある」ように見えるので、質感で役割を分ける。 */
.list-sort-trigger {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 4px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.list-sort-trigger:active {
  opacity: 0.6;
}
body.dark-mode .list-sort-trigger {
  color: var(--gray-400);
}
/* シートの選択肢に件数を出す（絞り込みシート用）。 */
.setting-sheet-option .sheet-opt-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
/* v1.2.532: 道具の行（.editor-hide-row＝[集中][メモ]…[問][答]）を廃止。
   集中モードは削除、メモ／赤シート／読み上げ／選択は検索欄の右のピル
   （#editorSelectBtn.editor-mode-btn）から開くシートに集約した。
   ピルは今のモード名を出し、編集以外の間は brand 色で塗る（ONのまま忘れて
   「タップしても編集が開かない」と戸惑うのを防ぐ）。選択中だけは従来どおり
   青の「完了」（.active）で、押すとシートを開かずに抜ける。 */
.editor-select-btn.editor-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.editor-mode-btn .editor-mode-chevron {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.7;
}
/* v1.2.540: 編集以外のモードで緑にする .mode-on は廃止。今のモードはラベルの文字で分かる。 */
.editor-select-btn.editor-mode-btn.active .editor-mode-chevron { display: none; }
/* シートのトグル行（メモを表示／赤シート中も読み上げる）。
   選択肢（1つ選ぶ）と見分けが付くよう、右端は
   チェックではなくスイッチにする。押してもシートは閉じない。 */
.setting-sheet-option.is-toggle .sheet-opt-switch {
  margin-left: auto;
  width: 40px;
  height: 24px;
  border-radius: 12px;
  background: var(--gray-300);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}
.setting-sheet-option.is-toggle .sheet-opt-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.setting-sheet-option.is-toggle.on .sheet-opt-switch { background: var(--brand-500); }
.setting-sheet-option.is-toggle.on .sheet-opt-switch::after { transform: translateX(16px); }
body.dark-mode .setting-sheet-option.is-toggle .sheet-opt-switch { background: #4a4556; }
body.dark-mode .setting-sheet-option.is-toggle.on .sheet-opt-switch { background: var(--brand-500); }
/* ===== v1.2.339: 編集画面の赤シート =====
   旧・一覧画面の .word-item .eng.hidden-question を、編集画面のカード構造
   （.ew-text-row > .ew-eng + .ew-jpn）に移植したもの。相違点は2つ。
   ① 灰色は要素の background ではなく ::before で描く（v1.2.357。それ以前は
      background-clip:content-box だった）。詳細は下のコメント。
   ② 隠している間だけ .ew-text-row を stretch にして、左右の灰色ブロックの
      高さを揃える。文字は上揃えのままなので通常時の見た目は変わらないが、
      揃えないと「短い側のブロックが小さい＝文字数のヒント」になる。 */
#screen-word-editor.hiding .ew-text-row {
  align-items: stretch;
}
/* v1.2.832: 隠している間は問題・答えの文字を選択できないように。
   PCでタップ（クリック）を重ねると、透明にした文字や見えている側の文字が
   選択状態になり、Chromeの翻訳ボタンが出ていたため。コピーは「調べる」から。 */
#screen-word-editor.hiding .ew-text-row,
#screen-word-editor.hiding .ew-text-row * {
  -webkit-user-select: none;
  user-select: none;
}
.editor-word-item .ew-eng.hidden-question,
.editor-word-item .ew-jpn.hidden-answer {
  color: transparent;
  position: relative;
}
/* v1.2.357: 灰色を要素の background から ::before に移し、上下 -6px 広げた。
   ・.ew-eng / .ew-jpn の高さは文字1行ぶん（約22px）しかなく、カードの縦
     padding 18px に対して帯が細すぎて、指で押す範囲とのズレが違和感になっていた。
   ・padding で太らせると、個別タップで表に戻した瞬間にカードの高さが変わって
     リストがガタつく。絶対配置なら行の高さに影響しない。
   ・疑似要素は生成元のクリック判定に含まれるので、タップ範囲も同じだけ広がる
     （タップ先は .ew-eng / .ew-jpn の onclick のまま）。
   ・左右は従来どおり 13px を空ける。ここまで塗ると .ew-content::after
     （問題と答えの境界線）に灰色が接してしまうため。
   ・-6px の根拠＝下に .ew-note があるときの隙間が .ew-content の gap 8px なので、
     2px 残る値。これ以上広げるならメモの border-top と接するので gap も見ること。 */
.editor-word-item .ew-eng.hidden-question::before,
.editor-word-item .ew-jpn.hidden-answer::before {
  content: '';
  position: absolute;
  top: -6px;
  bottom: -6px;
  background: var(--gray-200);
  border-radius: 6px;
}
.editor-word-item .ew-eng.hidden-question::before { left: 0; right: 13px; }
.editor-word-item .ew-jpn.hidden-answer::before { left: 13px; right: 0; }
/* 「タップ」は ::before より後に描かれるので帯の上に乗る。inset:0 は要素の箱
   ＝帯と上下中心が同じなので、帯を広げても中央のままでよい。 */
.editor-word-item .ew-eng.hidden-question::after,
.editor-word-item .ew-jpn.hidden-answer::after {
  content: 'タップ';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 600;
}
.editor-word-item .ew-eng.hidden-question::after { right: 13px; }
.editor-word-item .ew-jpn.hidden-answer::after { left: 13px; }
/* 隠している間は、テキスト以外の「答えが見えてしまう場所」も伏せる。
   ・画像サムネイル … 答え側の画像が出たままだと赤シートにならない。
   ・メモ（例文・解説）… 答えの語がそのまま書いてあることが多い。
   判定は画面単位ではなくカード単位（:has）にしてある。個別タップで表に
   戻した1枚だけは画像もメモも戻る、という往復に合わせるため。
   ★メモは visibility ではなく color を透明にする。.ew-note の白背景は
     .ew-content::after（縦の境界線）をカード下端まで隠す役目を持っていて、
     visibility:hidden にすると背景ごと消えて線が復活する。 */
.editor-word-item .ew-content:has(.ew-eng.hidden-question) .ew-thumb-q,
.editor-word-item .ew-content:has(.ew-jpn.hidden-answer) .ew-thumb-a {
  visibility: hidden;
}
.editor-word-item .ew-content:has(.ew-eng.hidden-question) .ew-note,
.editor-word-item .ew-content:has(.ew-jpn.hidden-answer) .ew-note {
  color: transparent;
}
/* v1.2.258: 見出しを撤去して「検索 ＋追加 選択」の1行に。検索欄が伸縮し、
   ボタン2つは固定幅。高さは3つとも40pxで揃える（旧ボタンは padding 6px で
   約34px しかなく、ピル化した検索欄と並べると段差が出るため）。 */
.editor-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  position: relative;
  min-height: 40px;
}
.editor-header-top .search-bar {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
  /* メルカリ／Amazon 参考。角丸12px → ピル。 */
  border-radius: 999px;
  padding: 0 14px;
  height: 40px;
}
.editor-header-top .editor-add-btn,
.editor-header-top .editor-select-btn {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 14px;
  /* 検索欄がピルなので、同じ行のボタンも角丸をそろえる。 */
  border-radius: 999px;
}
.editor-word-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  /* v1.2.180: カード間は 8px。以前は gap 6px ＋
     .editor-word-item の margin-bottom 2px で合計8pxという分かりにくい
     書き方だったので、gap 側に一本化した（見た目は変わらない）。 */
  gap: 8px;
  padding-right: 4px;
  /* Keep the bottom clear of the bottom-nav (70px) + breathing room. */
  padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}
.editor-word-list::-webkit-scrollbar { width: 4px; }
.editor-word-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
#screen-word-editor.select-mode .editor-word-list {
  /* Bulk toolbar can wrap to 2 rows on narrow viewports (5 buttons in
     word-editor mode: 全選択/移動/コピー/保存済み解除/削除), so reserve
     enough space for the worst case. Otherwise the last item (e.g.
     "bound for~") hides behind the toolbar in select mode. */
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
  /* In select mode, default is pan-y so the user can scroll the list with
     a one-finger drag like normal. Long-press initiates drag-select, and
     only at that point do we lock the list (drag-selecting class). */
}
#screen-word-editor.select-mode .editor-word-list.drag-selecting {
  touch-action: none;
  -webkit-overflow-scrolling: auto;
}
#screen-word-editor.select-mode .editor-word-item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#screen-word-editor.select-mode .editor-word-item .ew-inner {
  cursor: default;
}
/* Visual feedback while waiting for long-press to confirm. Subtle scale-down
   so the user sees their press is being registered without a jarring color
   change. Once long-press fires, this class is removed and the actual
   selection state is shown. */
#screen-word-editor.select-mode .editor-word-item.long-press-pending .ew-inner {
  transform: scale(0.97);
  opacity: 0.85;
}
/* v1.2.422: スクロール開始で押し込みを取り消すときは遷移なしで戻す
   （0.25s の戻りが「プルン」と震えて見えていた） */
#screen-word-editor.select-mode .editor-word-item.no-press-anim .ew-inner {
  transition: none;
}
/* v1.2.363: v1.2.362 でグレーに落としたが、一覧画面から色が完全に消えて
   寂しくなったため緑に戻した。以後この色を触るときは、彩度を減らすことが
   この画面にとって得かどうかを先に確かめること。 */
.editor-add-btn {
  background: var(--brand-500);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.editor-select-btn {
  background: var(--gray-200);
  color: var(--gray-600);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.editor-select-btn.active {
  background: var(--blue-500);
  color: white;
}
body.dark-mode .editor-select-btn {
  background: #2a2535;
  color: var(--gray-500);
}
body.dark-mode .editor-select-btn.active {
  background: var(--blue-500);
  color: white;
}

/* ===== All Decks button (on home deck header) ===== */
.all-decks-btn {
  display: inline-flex;
  align-items: center;
  background: var(--gray-200);
  color: var(--gray-600);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}
.all-decks-btn:active { transform: scale(0.96); }
body.dark-mode .all-decks-btn {
  background: #2a2535;
  color: var(--gray-500);
}

/* ===== All Decks screen =====
   iOS PWA scroll fix: when .active, the screen uses position: fixed; inset: 0
   so its scrollable child (.all-decks-list) becomes the first-level overflow
   from body's perspective. iOS PWA (standalone WKWebView) often fails to
   scroll a second-level overflow nested inside body > .app (overflow:hidden)
   > #screen (height: calc(...)) > .list (overflow:auto). Hoisting the screen
   to body level via position:fixed bypasses that limitation. Same pattern
   resolved the 59px bottom-gap issue for #screen-quiz.
   Safe-area padding is applied here (not on .app) so the screen itself
   occupies the full viewport including under the status bar + home indicator
   zones, matching iOS-native behavior. */
#screen-all-decks {
  display: none;
  flex-direction: column;
  padding: calc(20px + env(safe-area-inset-top)) 16px 0;
  font-family: var(--font-ui);
}
#screen-all-decks.active {
  display: flex;
  position: fixed;
  inset: 0;
  /* Higher than .bottom-nav (z-index: 100). The All Decks screen is a
     modal-style overlay reached via the "全デッキ" button on home; covering
     the bottom-nav while it's open is intentional — the screen has its own
     "←" back button. Still below modals (2000+) and toasts (9999+). */
  z-index: 101;
  background: var(--gray-50, #f7f8fa);
  /* Desktop: still keep the centered 480px column for consistency */
  max-width: 480px;
  margin: 0 auto;
}
/* v1.2.211: ここも直値 #1a1523 で地の色とわずかにズレていた（PCで境目が見える）。 */
body.dark-mode #screen-all-decks.active {
  background: var(--bg);
}
.all-decks-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-shrink: 0;
  position: relative;
  min-height: 40px;
}
.all-decks-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 210px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  pointer-events: none;
}
.all-decks-count {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
}
.all-decks-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 12px;
  flex-shrink: 0;
}
/* Inline 📌 SVG within the hint line. Tinted in bookmark orange so it
   immediately reads as "this matches the pin button you'll see on decks".
   Slight tilt mirrors the .is-fav active state of the deck-row pin. */
.all-decks-hint .hint-pin {
  color: var(--bookmark);
  vertical-align: -2px;
  margin-right: 1px;
  transform: rotate(25deg);
}
.all-decks-list {
  flex: 1;
  /* min-height: 0 is critical — without it, a flex item defaults to
     min-height: auto (= content's intrinsic height), which lets the list
     grow past its parent when there are many decks. That breaks both the
     flex: 1 height cap AND overflow-y: auto, making the screen un-scrollable.
     Same pattern as .editor-word-list. */
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Screen covers the bottom-nav (z-index 101 > 100), so only the home
     indicator safe-area + a small breathing room is needed at the bottom. */
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  /* Breathing room on the right so the scrollbar (iOS PWA overlay-style or
     desktop 4px thumb) doesn't visually overlap deck rows. */
  padding-right: 6px;
}
/* Slim scrollbar matching .editor-word-list on desktop. */
/* Hide per-group edit (•••) button while in deck-select mode — the user is
   in a bulk-action flow, and tapping the group menu would feel like it
   conflicts with the selection. The header itself stays visible (and still
   collapses) so users can scope what they see. */
.deck-select-mode .dg-edit-btn { visibility: hidden; pointer-events: none; }
/* v1.2.498: 以前は display:none で ••• を消していたため、選択モードに入ると
   見出し行の高さが縮み、一覧全体が上にずれていた。visibility:hidden なら
   高さも「N個」の横位置も変わらない。 */
/* When the bulk toolbar is showing, it covers the bottom of the screen
   (~60–80px depending on safe-area). Without extra padding, the last deck row
   sits behind it and gets clipped. Apply only to the All Decks list — the
   home dashboard scrolls horizontally and isn't affected by the toolbar. */
#screen-all-decks.deck-select-mode .all-decks-list {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
.all-decks-list::-webkit-scrollbar { width: 4px; }
.all-decks-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ===== Deck Groups (folder-style sections in All Decks) ===== */
/* Each group is a collapsible section with a header row + body of deckrows.
   Visual style is intentionally restrained — group headers should feel like
   list section headers (Apple-style), not like deck rows. */
.deck-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}
.deck-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.deck-group-header:active { background: var(--gray-100); }
/* v1.2.211: 上の explain-panel と同じ誤り。ダークの --gray-200 は #3a3545 で
   透明背景（#1e1a28）にほぼ溶ける。素の指定 --gray-700 はダークで #E5E5EA に
   解決されるので、この上書きは元から不要。 */
body.dark-mode .deck-group-header { color: var(--gray-700); }
body.dark-mode .deck-group-header:active { background: rgba(255,255,255,0.05); }
.dg-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--gray-500);
}
.deck-group.collapsed .dg-chevron { transform: rotate(-90deg); }
.dg-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Only show the deck count when the group is expanded.
   When collapsed, the header stays minimal (chevron + name + menu). */
.dg-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.deck-group.collapsed .dg-count { display: none; }
.dg-edit-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  border-radius: 6px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.dg-edit-btn:active { background: var(--gray-100); }
body.dark-mode .dg-edit-btn:active { background: rgba(255,255,255,0.08); }
.deck-group-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0 6px 0;
}
.deck-group.collapsed .deck-group-body { display: none; }
/* "Uncategorized" group has a subtler header — it's not a user-created group */
.deck-group.uncategorized .deck-group-header { color: var(--gray-500); font-weight: 600; }
body.dark-mode .deck-group.uncategorized .deck-group-header { color: var(--gray-400); }

/* Empty group placeholder */
.dg-empty {
  font-size: 12px;
  color: var(--gray-400);
  padding: 6px 12px;
  font-style: italic;
}
.deckrow {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  background: white;
  border: 0.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  transition: transform 0.1s;
  /* iOS長押しドラッグ並び替え中に指の下のテキストが選択されるのを防ぐ。
     touchstart時点で既にiOSが選択準備に入るため、クラス付与では間に合わず、
     常時無効化が必要。タップ/クリックには影響しない。 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.deckrow:active { transform: scale(0.99); }
/* 子孫要素にも明示的に適用（iOS Safariで一部子要素が個別に選択対象になる現象を防ぐ） */
.deckrow * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.deckrow-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.deckrow-info {
  flex: 1;
  min-width: 0;
}
.deckrow-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.deckrow-meta {
  font-size: 11px;
  color: var(--gray-400);
}
.deckrow-fav-btn {
  background: transparent;
  border: none;
  padding: 8px;
  line-height: 0;
  cursor: pointer;
  color: var(--gray-300);
  transition: transform 0.1s;
  flex-shrink: 0;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}
.deckrow-fav-btn:active { transform: scale(0.9); }
.deckrow-fav-btn.is-fav { color: var(--bookmark); }
/* ピン留めされている時はアイコンを少し傾けて、刺さっている感を出す。
   ボタン側の :active scale と干渉しないよう、回転は SVG にだけ掛ける。 */
.deckrow-fav-btn svg { transition: transform 0.15s ease; }
.deckrow-fav-btn.is-fav svg { transform: rotate(25deg); }
body.dark-mode .deckrow {
  background: #1f1a2a;
  border-color: rgba(255,255,255,0.08);
}
body.dark-mode .deckrow-name { color: var(--gray-800); }
body.dark-mode .deckrow-fav-btn { color: #4a4558; }
body.dark-mode .deckrow-fav-btn.is-fav { color: var(--bookmark); }

/* v1.2.498: 選択モードでは行のタップは「チェックの付け外し」なので、
   押下時の縮み（.deckrow:active の scale）は出さない。 */
.deck-select-mode .deckrow:active { transform: none; }
/* Hide favorite button during select mode to avoid accidental taps. */
.deck-select-mode .deckrow .deckrow-fav-btn {
  pointer-events: none;
  opacity: 0.3;
}

/* ===== Home deck list — empty state (no favorites) ===== */
.deck-empty-state {
  flex: 1;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  background: var(--gray-100);
  border-radius: 12px;
  border: 1px dashed var(--gray-300);
}
.des-icon {
  color: var(--gray-400);
  line-height: 0;
  display: flex;
}
.des-text {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 600;
}
.des-btn {
  background: var(--brand-400);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.1s;
}
.des-btn:active { transform: scale(0.97); }
body.dark-mode .deck-empty-state {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.1);
}
/* v1.2.423: チェックボックスは flex の流れから外してカード左上角に絶対配置。
   以前は .ew-inner の flex 子要素だったため、選択モードに入ると 22px＋gap
   10px ぶん .ew-content が右に押され、問題／答えの境界線（.ew-content::after
   の left:50%）が右にずれて左右対称が崩れていた。絶対配置なら .ew-content の
   幅は変わらず、線は中央のまま。.ew-inner の padding（18px 16px）の内側に
   収まるサイズにしてテキストにかぶらないようにする。タップはカード全体で
   受けるので箱が小さくても操作性は落ちない。
   チェック済みは brand 色で塗りつぶし＋白のチェック（小さい箱でも判別しやすく）。 */
.ew-checkbox {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--gray-300);
  background: white;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  pointer-events: none;
}
body.dark-mode .ew-checkbox {
  background: #2a2535;
  border-color: #3a3545;
}
/* ダークモードの未選択ルール（body.dark-mode .ew-checkbox）は .ew-checkbox.checked より
   詳細度が高く、選択後も塗りが上書きされていた。選択済みは明示的に brand 緑で塗る。 */
body.dark-mode .ew-checkbox.checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}
.select-mode .ew-checkbox {
  display: flex;
}
.ew-checkbox.checked {
  border-color: var(--brand-500);
  background: var(--brand-500);
}
.ew-checkbox.checked::after {
  content: '';
  display: block;
  width: 4px;
  height: 7px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.bulk-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.1);
}
body.dark-mode .bulk-toolbar {
  background: #1e1a28;
  border-top-color: #3a3545;
}
.bulk-toolbar.show {
  display: flex;
}
/* When the All Decks screen is open, its centered 480px column visually
   "owns" the viewport. Keep the deck bulk toolbar aligned with that column
   so it doesn't bleed into the desktop side gutters. Word-editor bulk
   toolbar (#bulkToolbar) is unaffected — it belongs to a full-width screen. */
body.all-decks-active #deckBulkToolbar.bulk-toolbar {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: 480px;
  width: 100%;
}
.bulk-toolbar .bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  /* Fix width so the number changing (0→1→10→100件選択) doesn't
     shift the action buttons on the right. font-variant-numeric
     keeps digit widths constant across fonts. */
  min-width: 68px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.bulk-toolbar .bulk-actions {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: flex-end;
}
.bulk-action-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
/* v1.2.489: 移動・コピー・保存済み解除の塗り（青・緑・オレンジ）を廃止し、
   全選択と同じグレーに。塗りで残すのは削除の赤だけ＝「取り消せない操作」が
   一番際立つ配置にする。保存済み解除はしおりの色 --bookmark を**文字色**で
   残す（塗りにしないのは、このアプリのオレンジ塗りは「保存済みである」
   という状態表示に揃えているため。解除ボタンまで塗ると意味が濁る）。
   旧 v1.2.488 以前は緑とオレンジを HTML のインライン style で直書きしていた。 */
.bulk-action-btn.move {
  background: var(--gray-200);
  color: var(--gray-600);
}
body.dark-mode .bulk-action-btn.move {
  background: #2a2535;
  color: var(--gray-500);
}
.bulk-action-btn.unsave { color: var(--bookmark); }
body.dark-mode .bulk-action-btn.unsave { color: var(--bookmark); }
.bulk-action-btn.delete {
  background: var(--red-500);
  color: white;
}
.bulk-action-btn.select-all {
  background: var(--gray-200);
  color: var(--gray-600);
}
body.dark-mode .bulk-action-btn.select-all {
  background: #2a2535;
  color: var(--gray-500);
}
/* v1.2.804: スマホ幅だと一覧の選択バー（5ボタン）が横に収まらず「削除」が画面外に切れ、
   日本語でもボタン内の文字が縦に折り返していた。狭い画面だけ「N件選択」を1段目、
   ボタン5つを2段目（横幅いっぱいに均等寄り）にする。2段分の下余白は
   #screen-word-editor.select-mode .editor-word-list の 120px で確保済み。 */
@media (max-width: 520px) {
  #bulkToolbar.bulk-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding-left: 12px;
    padding-right: 12px;
  }
  #bulkToolbar .bulk-count {
    flex: 1 1 100%;
    min-width: 0;
  }
  #bulkToolbar .bulk-actions {
    flex: 1 1 100%;
    gap: 6px;
  }
  #bulkToolbar .bulk-action-btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 6px;
    white-space: nowrap;
  }
}
.editor-word-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  /* v1.2.180: margin-bottom:2px は .editor-word-list の gap に統合した。 */
  flex-shrink: 0;
}
.editor-word-item .ew-inner {
  background: white;
  /* v1.2.180: 18px 16px（旧 12px 14px。詰まって見えていた原因はここだった）。
     ★v1.2.339 で一覧を廃止し、この画面が「見渡す場所」と「覚える場所」を
     兼ねるようになった。一覧では覚えやすさを優先して 22px にしていたので、
     赤シートで使っていて窮屈なら 22px にする余地がある（その場合は
     .ew-content::after の top/bottom も -22px に合わせること。縦 padding の
     打ち消しなので、食い違うと境界線がカード端まで届かない）。 */
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
  transition: transform 0.25s ease;
  cursor: pointer;
}
.editor-word-item .ew-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* v1.2.180: 一覧の .eng-container / .jpn-container と同じ 8px（テキストと
     サムネイルの間隔）。 */
  gap: 8px;
  position: relative; /* v1.2.173: ::after（境界線）の基準 */
}
/* v1.2.173: 問題と答えの境界線。v1.2.172 は .ew-jpn の border-left で描いて
   いたが、それだとテキスト行の高さぶんしか伸びず、画像サムネイルのある
   カードでは線が途中で切れていた（一覧はサムネイルが .jpn-container の
   中にあるのでカード全体を貫通する）。編集画面はサムネイルがテキスト行の
   下に別ブロックで並ぶ構造なので、border ではなく .ew-content の疑似要素
   として、カードの上下端まで届く1本の線を絶対配置で描く。
   ・left:50% … .ew-eng / .ew-jpn は flex:1 で gap:0 なので、コンテンツ幅の
     ちょうど中央が2つの境界。border-left で描いていた位置と一致する。
   ・top/bottom:-18px … .ew-inner の縦 padding を打ち消してカード端まで伸ばす
     （v1.2.180 で padding を 12px→18px にしたのに合わせて -12px から変更）。
   ・z-index:-1 … デッキバッジやサムネイル画像の背面を通す。.ew-inner が
     position:relative + z-index:1 で stacking context を作っているので、
     負の z-index でも .ew-inner の白背景より手前に描画される。 */
.editor-word-item .ew-content::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -18px;
  bottom: -18px;
  width: 1px;
  background: var(--gray-200);
  z-index: -1;
  pointer-events: none;
}
/* gap ではなく左右 13px の padding で間隔を作る。gap があると中央と
   境界がずれて、上の left:50% と一致しなくなる。 */
.editor-word-item .ew-text-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
}
.editor-word-item .ew-thumbs {
  display: flex;
  gap: 6px;
  align-items: center;
}
.editor-word-item .ew-thumb {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 8px;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* v1.2.379: min-height:50px から固定 100px へ。
     描画直後にリストが震える原因がここだった。renderEditorList() が
     innerHTML を書いた時点で .ew-thumb は空＝50px。そこへ
     loadEditorThumbs() が画像を差し込むと、border-box なので
     中身 80px + padding 16 + border 4 = 100px まで伸びる。
     行ごとに最大 50px 背が高くなる計算。

     しかも揃って起きない。ずれる段が2つある。
       ① IndexedDB の読み出しが Promise.all で並列に走り、完了時刻が行ごとに違う
       ② src を入れてもデコードが終わるまで高さ0なので、そこでもう一度ばらつく
     結果、開いた直後の数百 ms に何十回も別々のタイミングで行が伸びる。
     画像の無いデッキで起きないのはこのため。

     直し方は「来る前に、来たあとと同じ高さを取っておく」こと。
     100px にしたのは今の最大値と同じだから＝画像の見え方は変わらない。
     縦長の画像がある行はもともと 100px あったので、上限は動かない。
     ★横長の画像は上下に余白が出る（今までは 50px 前後で収まっていた）。
       赤シート中は visibility:hidden で場所だけ残るので、そこが
       100px の空白として気になるようなら 80px（中身 60px）へ。 */
  height: 100px;
}
.editor-word-item .ew-thumb-a {
  margin-left: auto;
}
.editor-word-item .ew-thumb img {
  max-width: 100%;
  /* v1.2.379: 上の固定高さに追従させる（直値 80px だと箱の値を変えた時に
     追いつかず、また高さが動く原因になる）。 */
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.dark-mode .editor-word-item .ew-thumb {
  background: transparent;
  border-color: transparent;
}
.editor-word-item .ew-eng {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-600);
  word-break: break-word;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  padding-right: 13px;
}
/* Cross-deck search: badge showing source deck for foreign words */
.editor-word-item .ew-deck-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--brand-500);
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-radius: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.dark-mode .editor-word-item .ew-deck-badge {
  color: var(--brand-300);
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.35);
}
.editor-word-item .ew-jpn {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-600);
  word-break: break-word;
  flex: 1;
  min-width: 0;
  text-align: right;
  padding-left: 13px;
}
/* ===== v1.2.181: 例文・解説(note)のプレビュー =====
   検索が note も対象になった以上、ヒットしても行に何も出ないと
   「なぜこれが出たのか」が分からない。カードの一番下に2行だけ出す。
   ・position:relative + 背景色 … .ew-content::after（問題と答えを分ける縦線、
     z-index:-1）を隠す。この行は全幅なので、縦線が貫通すると誤読を招く。
     .ew-inner と同じ背景色にすること（ダークは #1e1a28）。
   ・margin-bottom:-18px / padding-bottom:18px … .ew-inner の下 padding を
     打ち消して、縦線をカード下端まで隠しきる。必ず .ew-content の最後の
     子にすること（途中に置くと下側で縦線が復活する）。
   ・上の 8px の隙間は .ew-content の gap。そこだけ縦線が見えて border-top に
     突き当たる形になり、区切りとして自然に見える。 */
.editor-word-item .ew-note {
  position: relative;
  background: white;
  margin-bottom: -18px;
  padding: 8px 0 18px;
  border-top: 1px solid var(--gray-200);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
  color: var(--gray-500);
  text-align: left;
  word-break: break-word;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
body.dark-mode .editor-word-item .ew-note {
  background: #1e1a28;
  border-top-color: #3a3545;
}
/* ===== v1.2.427: メモ（例文・解説）のプレビューは既定で隠す =====
   v1.2.358〜359 はヘッダーにトグルを置いて「ごちゃつく」で撤回。v1.2.426 は
   各カードに「例文・解説 ▸」の1行を残す形にしたが、文字が並んで余計に
   ごちゃついた。v1.2.427 は並び替えシートの末尾に行を足したが「自分以外は
   気付けない」で v1.2.428 で集中モードの右隣のアイコンボタンに移した。
   ・隠している間は .ew-note ごと display:none。メモの無いカードと同じ
     見た目になる（縦の境界線がカード下端まで届く通常の形）。
   ・検索中は状態に関わらず表示（renderEditorList）。メモがヒットした理由が
     見えないと検索として不親切なため。 */
.editor-word-list.notes-collapsed .editor-word-item .ew-note { display: none; }
.edit-word-modal .rename-input { margin-bottom: 10px; }
/* v1.2.450: 挿入位置の select の文字を中央に（同じモーダルの問題・答え・メモ欄と揃える）。
   text-align は Chrome/Firefox で無視されることがあるので text-align-last も併記。
   iOS Safari はネイティブ描画の select で中央寄せが効かない場合がある。 */
/* v1.2.451（v1.2.453で再採用）: 閉じた表示は中央、開いた一覧（option）は左寄せ。
   中央だと桁数の違いで番号の位置が1行ごとにずれて読みにくいため。
   ※「番号は左・語は中央」の2列配置はネイティブの select では不可（v1.2.452で説明済み）。 */
.insert-pos-select { text-align: center; text-align-last: center; }
.insert-pos-select option { text-align: left; }
/* v1.2.442: 編集画面の「調べる」ボタン（一覧側のみ表示）。 */
.edit-lookup-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.edit-lookup-btn:active { transform: scale(0.97); }
body.dark-mode .edit-lookup-btn {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-400);
}
/* v1.2.171: z-index を2050にする理由は .listening-sheet-overlay と同じ。 */
#editWordOverlay {
  position: fixed;
  inset: 0;
  z-index: 2050;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  animation: fadeInOverlay 0.2s ease;
}
#editWordOverlay.show {
  display: flex;
}
#editWordOverlay .confirm-modal {
  flex-shrink: 0;
  margin: auto;
  max-width: 400px;
  width: 100%;
  /* Override modalPop (scale 0.9→1) with opacity-only fade.
     The scale animation causes images inside .img-attach-box to
     visibly shrink horizontally on desktop during the 250ms pop,
     because their max-width:100% is recomputed as the modal scales. */
  animation: modalFade 0.2s ease !important;
}
/* Floating back-arrow header is hidden in overlay mode —
   tap-outside-to-close + cancel button provide the close affordance,
   matching the pattern used by .confirm-overlay and other modals. */
.edit-word-panel-header {
  display: none;
}
.edit-word-panel-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0;
}
.edit-word-panel-close {
  background: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
}
body.dark-mode .edit-word-panel-close {
  background: #2a2535;
  color: var(--gray-500);
}
/* Image attachment */
.img-attach-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.img-attach-box {
  flex: 1;
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  position: relative;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
@media (hover: hover) {
.img-attach-box:hover { border-color: var(--brand-300); }
}
.img-attach-box .img-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  margin-bottom: 4px;
}
.img-attach-box .img-add-icon {
  font-size: 20px;
  color: var(--gray-300);
}
.img-attach-box img {
  max-width: 100%;
  max-height: 80px;
  border-radius: 6px;
  object-fit: contain;
  -webkit-touch-callout: none;
  pointer-events: none;
}
.img-attach-box .img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red-400); /* v1.2.416: 画像の✕は赤丸に戻す */
  color: white;
  border: none;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
/* v1.2.295: クリップボードから貼り付けるボタン（空の画像枠の右上）。
   枠本体のタップ＝ファイル選択は従来どおりで、この小さいボタンだけが
   navigator.clipboard.read() 経路に入る。長押しはQ/A入れ替えドラッグに
   使われているので、貼り付けは独立したボタンにしている。 */
.img-attach-box .img-paste-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--gray-100);
  color: var(--gray-500);
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  touch-action: manipulation;
}
/* 実寸が小さいので当たり判定だけ広げる（iOS PWAでのワンタップ不発対策） */
.img-attach-box .img-paste-btn::after {
  content: '';
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
}
.img-attach-box .img-paste-btn.is-pressed {
  background: var(--gray-200);
}
body.dark-mode .img-attach-box .img-paste-btn {
  background: #2e2938;
  color: var(--gray-400);
}
body.dark-mode .img-attach-box {
  border-color: #3a3545;
}
.img-attach-box.img-dragging {
  opacity: 0.4;
  border-color: var(--brand-400);
}
.img-attach-box.img-drop-target {
  border-color: var(--brand-500);
  border-style: solid;
  background: var(--brand-50);
}
.img-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.85;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  filter: brightness(0.95);
  max-width: 100px;
  max-height: 80px;
  object-fit: contain;
  transform: translate(-50%, -50%) scale(1.05);
}
/* Quiz image display */
.quiz-question-img, .quiz-answer-img {
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  object-fit: contain;
  margin: 4px auto;
  display: block;
  cursor: zoom-in;
  flex-shrink: 1;
  /* ★v1.2.283：min-height:0 が無いと画像は絶対に縮まない。
     flex アイテムの min-height は既定が auto ＝「中身より小さくならない」なので、
     flex-shrink:1 を書いても画像には効いていなかった。
     結果、カードの高さが 160px+文字 を下回る環境（14インチのブラウザ100%など）では
     中身が箱からはみ出す。親は justify-content:center なので、はみ出しは上下に
     均等に出る＝**上にある問題文が切れて見えなくなる**（本人からの指摘）。
     min-height:0 を入れると、余白が足りないときは画像の方が先に縮み、
     object-fit:contain が縦横比を保つので、問題文は常に残る。 */
  min-height: 0;
}
.quiz-card.dual-img .quiz-question-img,
.quiz-card.dual-img .quiz-answer-img,
.quiz-card-next.dual-img .quiz-question-img,
.quiz-card-next.dual-img .quiz-answer-img {
  max-height: 110px;
}
/* ★v1.2.310：v1.2.285/286/309 の dual-img 用レイアウト上書きを撤去し、
   v1.2.176 と同じ「上下半々」に戻した。
   285 は flex:0 1 auto ＋ margin:auto で「中身の高さで分けて中央に寄せる」
   ようにして、同じ画像が同じ大きさで出るようにしたもの。309 はその副作用
   （答えが出た瞬間に問題文が上へ動く）を、答えの場所を先に確保して潰したもの。
   どちらも狙いどおり効いていたが、代償として問題と答えがカード中央に固まり、
   上下に大きな余白が残る見た目になった＝本人の判断で撤去。
   これで .english-word / .answer-reveal は既定の flex:1 に戻り、
   問題は常に上半分の中央、答えは常に下半分の中央に固定される。
   戻ってくる既知の症状：問題文が3行あるようなカードでは、上の箱が文字で
   埋まり、min-height:0（v1.2.283）により画像のほうが先に縮むので、
   同じ画像を入れていても問題側だけ小さく出ることがある。
   画像に min-height で下限を入れる手は、v1.2.283 で直した「問題文が切れる」
   を呼び戻すので採らない。 */
/* Copy button */
.quiz-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: var(--gray-100);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-400);
  z-index: 3;
  opacity: 0.6;
  transition: opacity 0.15s;
  margin-left: 4px;
  flex-shrink: 0;
}
.quiz-copy-btn svg {
  width: 18px;
  height: 18px;
}
.quiz-copy-btn:active { opacity: 1; }
body.dark-mode .quiz-copy-btn { background: #2a2535; }
/* カード上部の「調べる」は編集・保存ボタン（.card-camera/.card-bookmark）と同じ見た目に揃える：
   灰色の塗り・角丸 → 白丸＋2px枠線、opacity 1 */
.quiz-card-topbar .quiz-alc-btn {
  background: transparent; /* v1.2.694: white→透明（地の色が変わると白丸が見えていた） */
  border: none; /* 枠線なし・丸の中身だけ */
  border-radius: 50%;
  opacity: 1;
}
body.dark-mode .quiz-card-topbar .quiz-alc-btn {
  background: transparent; /* ライトと同じくアイコンだけ */
}

/* v1.2.124: 「調べる」ボタン（英辞郎・画像検索・コピー）。
   編集・保存ボタンの左隣に置くため margin-left:auto はこのボタンが持つ。
   ★v1.2.292でカード上部の単独コピーボタンを廃止したため、.quiz-copy-btn は
     いまこのボタン専用のスタイルになっている（クラス名だけ当時のまま）。 */
.quiz-alc-btn svg {
  width: 18px;
  height: 18px;
}

/* Quiz explain (3rd column / note) button — sits next to the copy button.
   Always visible to communicate the feature exists, but disabled-looking
   (low opacity, no pointer events) until the current word has a note AND
   the answer has been revealed. */
.quiz-explain-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--gray-100);
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-400);
  z-index: 3;
  opacity: 0.3;
  pointer-events: none;
  /* v1.2.181: note の有無にかかわらず常時表示する。note が無い問題では
     「その場でメモを書く」入口として機能させるため。v1.2.180 までは
     visibility:hidden で note のある問題にしか出しておらず、そもそも
     機能があること自体に気づけなかった。
     回答表示前は薄いまま操作不可なのは従来どおり。 */
  visibility: visible;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
  margin-left: 4px;
  flex-shrink: 0;
  font-family: inherit;
  padding: 0;
}
.quiz-explain-btn:focus,
.quiz-explain-btn:focus-visible {
  outline: none;
}
/* v1.2.181: 回答表示後はどの問題でも押せるようにする。
   note あり → 例文・解説パネルを開く／note なし → メモ入力シートを開く。
   回答前に押せないのは従来どおり（note が答えのヒントになりうるため）。
   v1.2.308: .note-unlocked は「まだ .revealed ではないが、採点はもう
   不正解で確定している」状態（4択で誤答タイルを押した直後、タイピングの
   なぞり入力中）。この間は note がヒントになっても採点に影響しないので、
   .revealed と同じ扱いで解禁する。 */
.quiz-card.revealed .quiz-explain-btn,
.quiz-card.note-unlocked .quiz-explain-btn {
  opacity: 0.5;
  pointer-events: auto;
}
/* note がある問題。v1.2.181 の初版では brand-500 のベタ塗り（緑）にしていたが、
   ボタンが常時表示になった今は毎カード緑が点灯して目障りなので廃止した。
   自動表示なら例文はカード内に見えているので、強い印から機能の存在を
   知らせる必要はもう無い。区別は濃さだけに留める。 */
.quiz-card.revealed .quiz-explain-btn.has-note,
.quiz-card.note-unlocked .quiz-explain-btn.has-note {
  opacity: 1;
}
.quiz-explain-btn svg {
  width: 18px;
  height: 18px;
}
.quiz-card.revealed .quiz-explain-btn:active,
.quiz-card.note-unlocked .quiz-explain-btn:active { opacity: 0.6; }
/* パネルが開いている状態。v1.2.181: インライン表示（自動表示）では
   .active を付けない（showExplainPanel 参照）ので、これが出るのは
   ボタンで開いたフローティング表示のときだけ。 */
.quiz-explain-btn.active {
  background: var(--brand-600);
  color: white;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
body.dark-mode .quiz-explain-btn { background: #2a2535; }
body.dark-mode .quiz-explain-btn.active {
  background: var(--brand-600);
  color: white;
}
/* カード上部のメモボタンも「調べる」「編集」「保存」と同じ白丸＋2px枠線に揃える。
   濃さ（回答前0.3／回答後0.5／メモあり1）の状態表現はそのまま。 */
.quiz-card-topbar .quiz-explain-btn {
  background: transparent; /* v1.2.694: white→透明（地の色が変わると白丸が見えていた） */
  border: none; /* 枠線なし・丸の中身（白）だけ */
  border-radius: 50%;
}
.quiz-card-topbar .quiz-explain-btn.active {
  background: var(--brand-600);
}
body.dark-mode .quiz-card-topbar .quiz-explain-btn {
  background: transparent; /* ライトと同じくアイコンだけ */
}
body.dark-mode .quiz-card-topbar .quiz-explain-btn.active {
  background: var(--brand-600);
}

/* Explain panel — shown below the quiz card when the explain button is toggled on */
.explain-panel {
  display: none;
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  max-height: 50%;
  overflow-y: auto;
  background: white;
  /* v1.2.586: 枠と「メモ」見出しを答えの文字色に合わせる（未設定時は従来のブランド緑）。 */
  border: 1.5px solid var(--answer-color, var(--brand-500));
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--gray-900);
  text-align: left;
  word-break: break-word;
  overflow-wrap: break-word;
  -webkit-overflow-scrolling: touch;
  z-index: 5;
  box-shadow: none; /* v1.2.751: 影を削除（答えの色の1.5px枠がもともとあるので輪は足さない） */
  font-weight: 500;
}
.explain-panel.visible { display: block; }
/* Hide swipe-hint while the floating explain panel is open (z-index already
   covers it, but fading it out feels cleaner).
   v1.2.181: インライン表示のときは隠さない。パネルがカードの一部として
   通常フローに入るので、○×のヒントは今までどおり読めるべき。 */
.quiz-card.explain-open:not(.explain-inline) .swipe-hint { opacity: 0; }

/* ===== v1.2.181: 例文・解説のインライン表示 =====
   自動表示（詳細設定の既定）では、フローティングではなく通常フローで出す。
   absolute の bottom:12px / max-height:50% のまま自動で開くと、毎回
   答えとスワイプヒントの上に被さってしまうため。
   .english-word と .answer-reveal はどちらも flex:1 なので、パネルが
   場所を取ったぶんだけ自動で縮む（開いた直後に autoSizeQuizWord を
   掛け直して文字サイズを合わせる。showExplainPanel 参照）。 */
/* v1.2.874: 自動表示も通常フローをやめ、カードに重ねる（本人の判断）。通常フローだと
   開いた分だけ問題・答えの箱が縮み、めくった瞬間に問題文が上へ動いていた。
   v1.2.872 で問題と答えを境目（40%前後）に寄せたので、重ねても答えにはほぼ被らない。
   動き（タップで閉じない・○×ヒントは出したまま・ボタンは緑にしない）は従来のインラインのまま。
   ヒントの上に乗るよう、下端の位置だけヒントの有無で変える（旧 margin-bottom と同じ値＋12px）。 */
.quiz-card.explain-inline .explain-panel.visible {
  max-height: 46%;
  bottom: 30px;
  box-shadow: none;
}
/* v1.2.312: ヒントを出さない回は、ヒントの分を空けない。 */
.quiz-card.hint-hidden.explain-inline .explain-panel.visible {
  bottom: 12px;
}
/* v1.2.608: 大きいヒント（14px）の間は、メモ枠と重ならないよう下を10px広げる。 */
.quiz-card.hint-teach.explain-inline .explain-panel.visible {
  bottom: 40px;
}
/* v1.2.611: PCはヒントがキーの形の枠つきで背が高いので、卒業後の小さいヒントでも
   同じだけ下を空ける（ヒントを出さない回は上の .hint-hidden が 0 にする）。 */
/* v1.2.614: 卒業後のヒントを小さくしたので、この上乗せは不要になった（18pxに戻す）。
   はじめての人向けの大きいヒントは上の .hint-teach が 28px を確保する。 */
/* タイピング・4択では .explain-inline を付けない（explainInlineAllowed 参照）。
   その2モードのパネルは従来どおりで、スマホのタイピングだけ
   @media (max-width:767px) 内の .typing-mode ルールが通常フローに落とす。 */
.explain-panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--answer-color, var(--brand-500));
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
/* v1.2.586: 答えの文字色が「ブラック（問題文と同じ色）」のときは --answer-color が無い。
   緑に戻すと答え（黒）と合わなくなるので、濃いグレーにする（調べるメニューの答えグループと同じ扱い。
   --gray-* はダークで反転するので、ダークでは明るいグレーになる）。 */
body.answer-match-question .explain-panel { border-color: var(--gray-500); }
body.answer-match-question .explain-panel-label { color: var(--gray-700); }
/* v1.2.211: ダークで例文・解説がほぼ読めなかった不具合を修正。
   ダークの --gray-100 は #2a2535（＝暗い側）なので、背景 #1e1a28 に
   ほぼ同色の文字を載せていた。ライト側の指定 color: var(--gray-900) は
   ダークだと #FFFFFF に解決されるので、そもそもこの上書き自体が不要
   だったが、真っ白は眩しいので本文色（--gray-800 = #F2F2F7）に揃える。
   v1.2.188 の .print-color-trigger / .print-check-row と同じ種類のミス。 */
body.dark-mode .explain-panel {
  background: #1e1a28;
  color: var(--gray-800);
  box-shadow: none; /* v1.2.751: ダークも影なし */
}
/* Quiz image toggle */
.quiz-img-toggle {
  width: 40px;
  height: 40px;
  border: none;
  outline: none;
  background: white;
  cursor: pointer;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--gray-200); /* v1.2.749: 影→1pxの灰色の輪（問題カードと統一）。オフ時は従来どおり輪なし */
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
.quiz-img-toggle:hover { background: var(--gray-100); }
}
.quiz-img-toggle svg {
  width: 22px;
  height: 22px;
}
.quiz-img-toggle.off {
  color: var(--gray-300);
  background: transparent;
  box-shadow: none;
}
.quiz-img-toggle.off::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background: var(--red-400);
  transform: rotate(-45deg);
  border-radius: 1px;
}
/* Image lightbox */
.img-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
  animation: fadeInOverlay 0.15s ease;
}
.img-lightbox img {
  max-width: 95%;
  /* v1.2.154: 90vh のままだと PC拡大時に 90×1.1＝99% となり、画像が上下いっぱいに
     広がってオーバーレイの余白(20px)が効かなくなる。#pwaGuideCard と同じ理由で
     zoom補正済みの --app-height を使う。 */
  max-height: 90vh;
  max-height: calc(var(--app-height, 100dvh) * 0.9);
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 4px 30px rgba(0,0,0,0.4);
}
/* Google Drive sync */
.gdrive-status {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  color: var(--gray-400);
  margin: 6px 0;
}
.gdrive-status.connected {
  color: var(--gray-600);
}
.gdrive-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.gdrive-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gdrive-btn.upload { background: var(--brand-500); color: white; box-shadow: 0 4px 12px rgba(249,115,22,0.3); }
@media (hover: hover) {
.gdrive-btn.upload:hover:not(:disabled) { background: var(--brand-600); box-shadow: 0 4px 16px rgba(249,115,22,0.4); }
}
/* v1.2.413: 「Googleでログイン」ボタンを Google のブランドガイドライン
   （developers.google.com/identity/branding-guidelines）に合わせた。
   ライト＝白地・#747775の枠・#1F1F1Fの文字、ダーク＝#131314地・#8E918F枠・#E3E3E3文字、
   Gロゴは公式の4色SVG 20px、Roboto 500 14px、角丸4px（矩形型）。色・ロゴ・字体は
   ガイドラインの指定なので、他のボタンに合わせて橙色や独自アイコンに戻さないこと。 */
.gdrive-btn.google {
  background: #FFFFFF;
  color: #1F1F1F;
  border: 1px solid #747775;
  border-radius: 4px;
  font-family: Roboto, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-weight: 500;
  font-size: 14px;
  min-height: 40px;
  padding: 0 12px;
  gap: 10px;
}
.gdrive-btn.google .gdrive-google-logo { flex: 0 0 20px; }
@media (hover: hover) {
.gdrive-btn.google:hover:not(:disabled) { background: #F2F2F2; }
}
body.dark-mode .gdrive-btn.google { background: #131314; color: #E3E3E3; border-color: #8E918F; }
@media (hover: hover) {
body.dark-mode .gdrive-btn.google:hover:not(:disabled) { background: #1F1F20; }
}
/* v1.2.406: 取得は主ボタンから外し、テキストリンクに格下げ */
.gdrive-sub-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.gdrive-sub-link {
  background: none;
  border: none;
  padding: 8px 6px;
  font-family: inherit;
  font-size: 12px;
  color: var(--gray-500);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.gdrive-sub-link:disabled { opacity: 0.5; cursor: default; }
.gdrive-sub-sep { font-size: 12px; color: var(--gray-300); }
.gdrive-history-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.gdrive-history-item {
  width: 100%;
  border: 1px solid var(--gray-200);
  background: var(--gray-50, #fafafa);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
/* v1.2.439: 1行目＝データの時点と端末、2行目＝デッキ数・単語数・累計学習時間と出所。
   サイズと「保存前／取得前」の操作名ラベルは廃止（中身を言っていなかった）。 */
.gdrive-history-item .gh-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.gdrive-history-item .gh-date { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.gdrive-history-item .gh-device { font-size: 11px; color: var(--gray-500); white-space: nowrap; }
.gdrive-history-item .gh-stats { font-size: 12px; color: var(--gray-600); }
.gdrive-history-item .gh-src { font-size: 11px; color: var(--gray-400); white-space: nowrap; }
.gdrive-history-item .gh-badge {
  align-self: flex-start;
  font-size: 10px; font-weight: 600;
  color: var(--green-600, #2e7d32);
  background: rgba(46,125,50,0.10);
  border-radius: 999px; padding: 1px 8px; margin-top: 2px;
}
/* 今Driveにある本体。比較用に先頭へ出すだけで、選べない */
.gdrive-history-item.is-main { cursor: default; border-style: dashed; background: transparent; }
.gdrive-history-item.is-main .gh-date { color: var(--gray-500); }
.gdrive-history-item.no-info .gh-stats { color: var(--gray-400); font-style: italic; }
.gdrive-history-empty { font-size: 12px; color: var(--gray-400); text-align: center; padding: 12px 0; }
body.dark-mode .gdrive-history-item { background: #2a2535; border-color: #3a3448; }
body.dark-mode .gdrive-history-item.is-main { background: transparent; }
body.dark-mode .gdrive-history-item .gh-date { color: var(--gray-300); }
body.dark-mode .gdrive-history-item .gh-stats { color: var(--gray-400); }
.gdrive-btn.disconnect { background: var(--gray-200); color: var(--gray-600); font-size: 12px; padding: 8px; }
body.dark-mode .gdrive-btn.disconnect { background: #2a2535; color: var(--gray-500); }
.gdrive-btn:disabled { opacity: 0.5; cursor: default; }
.gdrive-last-sync {
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  margin-top: 8px;
}
.gdrive-migrate-notice {
  font-size: 11px;
  color: var(--gray-600);
  background: var(--gray-100);
  border-left: 3px solid var(--brand-500);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
  line-height: 1.6;
}
body.dark-mode .gdrive-migrate-notice {
  background: #2a2535;
  color: var(--gray-400);
}
.gdrive-permission-note {
  font-size: 11px;
  color: var(--gray-400);
  text-align: left;
  line-height: 1.5;
  margin: 10px 0 0;
}
/* v1.2.315: この @media (prefers-reduced-motion) は @media (hover: hover) の
   中に入れ子になっていた。入れ子は両方が真のときだけ効くので、
   hover: none のスマホ・タブレットでは一度も適用されていない。
   ＝OSの「視差効果を減らす」をONにしても、止まるのは紙吹雪だけ
   （launchConfetti の JS 判定）で、CSSアニメは全部動いていた。外に出す。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* iOS: prevent sticky :hover states on touch devices */
@media (hover: none) {
  .confirm-cancel:hover { background: white; }
  .confirm-danger:hover { background: var(--red-500); }
  .confirm-danger:disabled:hover { background: var(--gray-300); }
  .deck-edit-btn:hover { background: var(--gray-50); }
  .deck-edit-btn.danger:hover { background: var(--gray-50); }
  .secondary-btn:hover { background: white; }
  .action-btn:hover { transform: none; box-shadow: var(--shadow-md); }
  .quiz-back:hover { background: white; }
  .quiz-img-toggle:hover { background: white; }
  .result-close-btn:hover { background: var(--gray-100); }
  .result-btn:hover { background: white; transform: none; }
  .result-btn.review-btn:hover { background: white; color: var(--gray-600); }
  .result-btn.demo-own-btn:hover { background: var(--brand-500); color: white; transform: none; }
  .start-quiz-btn:hover { background: var(--brand-500); }
  .demo-hero-btn:hover { background: var(--brand-500); transform: none; }
  .demo-item:hover { border-color: var(--gray-200); background: var(--gray-50); }
  /* Dark-mode hover states must also be neutralized on touch devices
     to avoid sticky-hover after tap making buttons look selected. */
  body.dark-mode .demo-item:hover { border-color: #3a3545; background: #2a2535; }
  body.dark-mode .deck-edit-btn:hover { background: #2a2535; }
  body.dark-mode .confirm-cancel:hover { background: #2a2535; }
  .import-area:hover { border-color: var(--gray-300); }
  .import-json-area:hover { border-color: var(--gray-300); }
  .img-attach-box:hover { border-color: var(--gray-200); }
  .color-dot:hover { transform: none; }
  body.dark-mode .confirm-cancel:hover { background: #2a2535; }
}

/* === v1.2.66: 印刷設定モーダル === */
/* v1.2.100: 親.confirm-modalがtext-align:centerなのを左寄せに上書き。
   各設定行のラベル・トリガー・色一覧をすべて左揃えにするため。 */
.print-setting-row {
  margin-bottom: 14px;
  text-align: left;
}
.print-setting-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
/* メインラベルの右に薄く出る補助テキスト（例：「紙幅に応じて自動調整」） */
.print-setting-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--gray-400);
  margin-left: 8px;
  letter-spacing: 0;
}
.print-segmented {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 3px;
}
.print-segmented-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* v1.2.766: 4列→3列×2行（出題範囲が6つに） */
}
.print-segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.print-segmented button.active {
  background: white;
  color: var(--brand-500);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
body.dark-mode .print-segmented {
  background: #2a2535;
}
/* v1.2.508: 選択中を「溝より暗い穴」（#1e1a28）で表していたが、回答方式などの
   .mode-toggle-btn.active は「溝より一段明るいつまみ」（--gray-200）なので
   見た目が食い違っていた。同じ作りに揃える。 */
body.dark-mode .print-segmented button {
  color: var(--gray-600);
}
body.dark-mode .print-segmented button.active {
  background: var(--gray-200);
  color: var(--brand-400);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.print-check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 14px;
  color: var(--gray-700);
  user-select: none;
  /* v1.2.102: 行全体ではなくチェックボックス自体だけがタップ対象。
     以前は <label> で囲っており行どこでもタップで切り替わる仕様だったが、
     テキスト誤タップが多くて意図せずON/OFFが切り替わる事故が起きていた。
     今は <div> + テキストはただの説明、判定は □ の中だけ。 */
}
.print-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-500);
  cursor: pointer;
}
/* v1.2.98: 色ピッカーをアコーディオン化。
   常時は選択中の色丸と色名のみ表示、トリガータップで色一覧を展開。
   理由：8色×2行（問題/答え）の常時表示は印刷設定モーダル内で場所を取りすぎ、
   ユーザーが本当に色を変えたい場面だけ展開する方がスッキリする。
   .print-setting-row は block 構造なので、要素は縦に積まれる。
   トリガーは自身の幅だけ取って左寄せ、その下にアコーディオン本体が伸びる形。 */
.print-color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}
.print-color-picker .color-dot {
  width: 26px;
  height: 26px;
}
.print-color-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1.5px solid var(--gray-200);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  /* iOS遅延対策: transition:all を避け、必要な箇所だけ補間 */
  transition: border-color 0.12s, background 0.12s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
.print-color-trigger:hover {
  border-color: var(--gray-300);
  background: var(--gray-100);
}
}
.print-color-trigger .color-dot-current {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}
.print-color-trigger .color-name-current {
  min-width: 0;
}
.print-color-trigger .chevron {
  color: var(--gray-400);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.print-color-row.open .print-color-trigger .chevron {
  transform: rotate(180deg);
}
/* 色一覧パネル。max-height トランジションで開閉。
   閉時は max-height:0 + overflow:hidden で完全に畳む。
   開時は max-height をピクセル指定（中身に十分な余裕）+ padding で間隔確保。 */
.print-color-row .print-color-picker {
  max-height: 0;
  overflow: hidden;
  padding: 0 2px;
  transition: max-height 0.22s ease, padding 0.22s ease, margin 0.22s ease;
  margin-top: 0;
}
.print-color-row.open .print-color-picker {
  max-height: 120px;
  padding: 8px 2px 4px;
  margin-top: 8px;
}
/* v1.2.188: ダーク時の文字色が var(--gray-200) になっていたが、ダークでは
   グレースケールが反転していて --gray-200 は #3a3545＝ほぼ背景と同じ暗さ。
   「ブラック」「グリーン」の文字が読めなくなっていた。本文と同じ明るい側に直す。
   hover の背景 var(--gray-800) も同じ理由でほぼ白＝文字が消えるので差し替え。 */
body.dark-mode .print-color-trigger {
  border-color: #3a3545;
  color: var(--gray-700);
}
@media (hover: hover) {
body.dark-mode .print-color-trigger:hover {
  border-color: var(--gray-600);
  background: var(--gray-100);
}
}
body.dark-mode .print-color-trigger .chevron {
  color: var(--gray-500);
}
/* v1.2.188: 上と同じ理由。「例文を載せる」等の説明文が読めなくなっていた。 */
body.dark-mode .print-check-row {
  color: var(--gray-700);
}
/* 印刷設定モーダルの下部ボタン（キャンセル/プレビューを開く）。
   スマホでタップしやすいよう .confirm-cancel 系と同等の十分な高さを確保。 */
.confirm-btn {
  padding: 14px 16px;
  min-height: 48px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.05s, box-shadow 0.05s;
  touch-action: manipulation;
}
.confirm-btn.cancel {
  border: 2px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
}
@media (hover: hover) {
.confirm-btn.cancel:hover { background: var(--gray-100); }
}
.confirm-btn.ok {
  border: none;
  background: var(--brand-500);
  color: white;
  box-shadow: 0 4px 12px rgba(56,142,60,0.3);
}
@media (hover: hover) {
.confirm-btn.ok:hover { background: var(--brand-600); }
}
/* v1.2.508: ダークのグレースケールは反転しているので --gray-800 は #F2F2F7＝
   ほぼ白の面になっていた。他の確認ダイアログの .confirm-cancel と同じ値に揃える。 */
body.dark-mode .confirm-btn.cancel {
  background: #2a2535;
  border-color: #3a3545;
  color: var(--gray-600);
}
@media (hover: hover) {
body.dark-mode .confirm-btn.cancel:hover { background: #3a3545; }
}



/* ===== Touch devices: dark mode scrollbar contrast =====
   On phones/tablets, overlay scrollbars can blend into the dark page background.
   Make the visible scroll thumb a little wider and brighter only on touch devices. */
@media (hover: none), (pointer: coarse) {
  body.dark-mode .editor-word-list,
  body.dark-mode .all-decks-list,
  body.dark-mode .deck-selector-options,
  body.dark-mode .memo-table-wrap {
    /* v1.2.211: #screen-advanced-settings.active はこのリストから外した。
       あの画面はバーごと非表示にしたので、ここに残すと
       ダーク×タッチ端末のときだけ復活してしまう。
       メモ帳デッキ(.memo-table-wrap)を追加。ダークだと地の色にバーが溶けて
       位置が分からなかったため、他のリストと同じ明るいサムに揃える。
       （v1.2.360 でメモ帳の地は body の --bg #121018 に統一した） */
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 240, 255, 0.66) rgba(255, 255, 255, 0.08);
  }

  body.dark-mode .editor-word-list::-webkit-scrollbar,
  body.dark-mode .all-decks-list::-webkit-scrollbar,
  body.dark-mode .deck-selector-options::-webkit-scrollbar,
  body.dark-mode .memo-table-wrap::-webkit-scrollbar {
    width: 7px;
  }

  body.dark-mode .editor-word-list::-webkit-scrollbar-track,
  body.dark-mode .all-decks-list::-webkit-scrollbar-track,
  body.dark-mode .deck-selector-options::-webkit-scrollbar-track,
  body.dark-mode .memo-table-wrap::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
  }

  body.dark-mode .editor-word-list::-webkit-scrollbar-thumb,
  body.dark-mode .all-decks-list::-webkit-scrollbar-thumb,
  body.dark-mode .deck-selector-options::-webkit-scrollbar-thumb,
  body.dark-mode .memo-table-wrap::-webkit-scrollbar-thumb {
    background-color: rgba(245, 240, 255, 0.66);
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.18);
  }
}

/* ===== v1.2.147: タブレット（タテ）のホーム画面 =====
   ★このブロックは必ず <style> の末尾に置くこと。理由は下記。

   v1.2.144〜146 で「指定しても大きくならない」現象が起きた原因：
   メディアクエリは詳細度を一切上げない。上の
   @media (min-width:768px) and (max-width:1023px) のブロックは1つ目の <style> の
   前のほうにあり、一方 .deck-card / .action-btn / .secondary-btn / .all-decks-btn の
   素の定義は**それより後**で同じ詳細度(0,1,0)で再定義されている。
   （v1.2.525: 行番号での参照は編集のたびにズレるので、セレクタ名での参照に改めた）
   同点なら後勝ちなので、あの位置に書いたタブレット用の指定は最初から死んでいた。
   （.app / .study-stats-card / .heatmap-cell などは定義が前にあるので効いていた。
     ＝カレンダーと統計カードだけ大きくなり、ボタン類が変わらなかったのはこのため。）
   リスニング用のブロック(v1.2.143)は .listening-* の定義がすべて前にあるので
   あの位置のままで問題ない。

   配分：実測で「学習を始める」の下に約167pxの余白がある。うち約120pxを
   デッキカード／全デッキ／新しいデッキを追加／学習を始める に配り、
   45px前後は詰まって見えないように残す。

   高さ条件 (min-height:1060px) の理由：
   iPad 9世代など 768x1024 のタテは余白が少なく、同じ拡大をすると
   「学習を始める」が画面外に押し出される。1024を確実に外しつつ、Safariの
   ツールバー分の目減りにも耐えられる妥協点として1060pxにしている。 */
@media (min-width: 768px) and (max-width: 1023px) and (min-height: 1060px) {
  /* デッキ見出しと「全デッキ」 */
  .deck-carousel-section { margin-bottom: 20px; }
  .deck-carousel-header { margin-bottom: 12px; }
  .deck-carousel-header h3 { font-size: 17px; }
  .all-decks-btn { padding: 10px 20px; font-size: 16px; border-radius: 10px; }
  /* デッキカード：カード自体がタップ対象なので配分の主役 */
  .deck-card {
    padding: 20px 22px;
    min-width: 240px;
    gap: 16px;
    border-radius: 16px;
  }
  .deck-card .dc-donut { width: 60px; height: 60px; }
  .deck-card .dc-name { font-size: 17px; }
  .deck-card .dc-meta { font-size: 13px; }
  .dc-thumb { width: 76px; height: 76px; }
  .deck-card { min-height: 120px; } /* v1.2.800: 76 + 20×2 + 2×2 */
  /* 「＋ 新しいデッキを追加」 */
  .secondary-btn { padding: 18px; font-size: 16px; border-radius: 16px; }
  /* CTA：ホームで一番押されるボタン。残りの余白はここに寄せる。
     .action-btn.study .icon は position:absolute なので left も合わせて調整する。 */
  .action-section { margin-top: 12px; }
  .action-btn.study { min-height: 180px; }
  .action-btn.study .icon { width: 78px; height: 78px; left: 28px; }
  .action-btn .text h3 { font-size: 22px; }
}

/* ===== v1.2.281: PCの自動ズームを全廃した（旧 v1.2.153〜275） =====
   ここには以前、ビューポートの高さ800pxを境に :root へ zoom 1.21 / 0.99 を
   出し分けるメディアクエリが2つ置いてあった。廃止した理由：

   ブラウザのズームを上げると、CSS上のビューポート高は逆に「減る」。
   そのため拡大するほど「背の低い画面」と判定されて段が入れ替わり、
   拡大したのに縮む・縮小したのに大きくなる、という反転が必ず起きていた。
   （実測：14インチはブラウザ83%を境に段が入れ替わっていた）

   加えて、物理的な画面サイズはCSSからは見えない。ビューポートの寸法から
   推測するしかないが、その推測の材料をブラウザズームが直接動かしてしまう。
   つまりこの方式は原理的に外れる。

   ★v1.2.287：上記のうち「高さで段を出し分ける」方式だけを廃止のまま維持し、
     **幅だけを条件にした1段の拡大**を復活させた（このファイルの2つ目の <style>
     末尾を参照）。幅はブラウザズームを上げても 1920→1745→1600 と減るだけで
     1400px を割らないため、反転が原理的に起きない。高さの条件を足すと
     ここに書いた反転が復活するので、**絶対に足さないこと**。

   ★zoom を扱う際に必ず思い出すこと：
     ①zoom は vh / dvh / vw を補正しない（85vh以上は var(--app-height) を使う）
     ②高さで切り替わるメディアクエリは、ビューポート実高ではなく zoom を割り戻した
       レイアウト高さで判定しないと誤発火する。現状、マウス環境のPCで効く高さ条件は
       1つも無い（コンパクト分岐は pointer:coarse 専用、リスニングの高さ2段は
       v1.2.591 で廃止）。新しく足さないこと。
     ③--ui-zoom を zoom と必ず同値にする（<head> が --app-height の計算に使う） */

/* ===== v1.2.182 → v1.2.183 改訂: PC（大画面）のリスニング画面 =====
   ★このブロックも必ず <style> の末尾に置くこと（タブレット用・PCズーム用と同じ理由。
     メディアクエリは詳細度を上げないので、後で再定義された同詳細度の指定に負ける）。

   症状：PCでリスニングを開くと再生ボタンの下に大きな余白が残り、カードも細い。
   スクショの実測（1920x911のビューポート／zoom 1.1）＝レイアウト上の高さは
   911÷1.1≈828px、下部ナビの70pxを引いて758px。対してコンテンツは631pxで終わり、
   下に127pxが空いていた。カード幅400px・高さ147pxもモニターでは小さい。

   対策（v1.2.183で方針変更）：
     ①カード幅・文字・再生ボタンを一回り大きくする
     ②余った縦の高さは**カードだけに吸わせる**（.listening-card を flex:1 1 0）。
       v1.2.182ではプレイヤー全体を中央寄せにして余りを上下へ散らしていたが、
       それだとシークバー（何問目のバー）まで下へ動くため取り止めた。
       シークバー・保存・操作ボタンは従来の位置のまま、問題枠だけが縦に伸びる。

   ★縦の高さによる出し分けは v1.2.591 で廃止（v1.2.184〜281 の2段・しきい値800px）。
     この段が必要とする縦（実測約771px）は、背の低い窓でも <head> の fitZoom が
     .listening-player を「縦825px相当」に縮めて確保する（2つ目の style 末尾の
     v1.2.591 ブロック）。横幅をデッキバーに揃える指定もそちらにある。

   条件の根拠：
   ・(hover:hover) and (pointer:fine) …… マウス環境＝PCに限定（タブレットを除外）。
   ・min-width:1024px …… 横向きスマホの除外用。fitZoom の条件（FIT_MQ）と同じ値。 */
/* ===== v1.2.188: テーマ切替中は transition を全部止める =====
   ライト⇔ダークで色が変わるだけの要素が、うっかり transition の対象に
   なっていると、その要素だけ0.15秒ほど遅れて色が追いついてくる。
   （実例：設定メニューの行は `transition: background 0.15s` を持っていて、
   PCではクリック後もカーソルが乗ったまま＝:hover の背景が当たっているので、
   ダークモードの行だけが遅れて変わって見えていた。）
   個別に潰すと同じ事故が別の場所で再発するので、切替の一瞬だけ全部止める。
   付け外しは toggleDarkMode() が行う（あちらの強制リフローの注意書きも参照）。 */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

/* --- PCのリスニング（拡大＋伸ばす） --- */
@media screen and (hover: hover) and (pointer: fine)
   and (min-width: 1024px) {
  /* 400pxのままだと24.5インチでは細く見える */
  .listening-progress { font-size: 15px; margin-bottom: 10px; }
  .listening-seekbar { max-width: 520px; margin-bottom: 22px; }
  /* ★v1.2.183：カードの高さは固定せず「残りの高さを全部もらう」方式にする。
     モバイル(<=600px)・タブレットは固定値だが、PCは同じ手を使えない。
     固定＋プレイヤー全体の中央寄せだと、①シークバーの位置が画面ごとに動く
     ②余りが上下に散る。ここでは flex:1 1 0 でカードだけを伸ばすので、
     シークバー・保存・操作ボタンの位置は従来のまま（＝上寄せ）で、
     空いていた分がそのままカードの背に変わる。
     ・flex-basis を 0 にするのは、内容の量でカードの背が変わらないようにするため
       （長い問題文は従来どおり .listening-question の中でスクロールする）。
     ・min-height は入り切らない高さになった時の下限。ここを割るとプレイヤー側が
       スクロールに切り替わるだけで、見切れはしない。
     ・max-height は4Kなど極端に縦長のモニターでカードが間延びしないための上限。
       本人の1920x1080では約260pxになるので通常は効かない。 */
  .listening-card {
    max-width: 520px;
    flex: 1 1 0;
    min-height: 200px;
    max-height: 420px;
    padding: 28px 32px;
    gap: 16px;
    border-radius: 20px;
  }
  /* v1.2.164のルール：22px以上には光学トラッキングを掛ける */
  .listening-question { font-size: 24px; letter-spacing: -0.02em; }
  .listening-answer { font-size: 21px; min-height: 30px; }
  /* 再生ボタンだけ大きくする。左右の小さいアイコン（タイマー・前後・設定）は
     行の高さを決めていないので触らない＝見た目の重心を変えない。 */
  .listening-controls { gap: 28px; }
  .listening-controls .listening-ctrl-btn.play { width: 72px; height: 72px; }
  .listening-controls .listening-ctrl-btn.play svg { width: 40px; height: 40px; }
  /* v1.2.183：プレイヤー全体の中央寄せ（v1.2.182）は取り止め。
     中央寄せにするとシークバーごと下へ動いてしまうため、上寄せ（既定の
     flex-start）のまま、余りは上のカードの flex:1 に吸わせる。
     ※副次的な利点として、overflow-y:auto のコンテナを中央寄せにすると
       内容が入り切らない時に上側へスクロールで戻れなくなる flex の罠も回避できる。 */
}

/* ===== v1.2.261: PCではスワイプヒントを「実際に効くキー」の表記に差し替える =====
   ★このブロックも必ず <style> の末尾に置くこと（上のタブレット用・PCズーム用・
     PCリスニング用と同じ理由。メディアクエリは詳細度を上げないので、後で再定義
     された同詳細度の指定に負ける）。

   経緯：回答方式「カード」で答えを表示したあとの ○×（answerKnowledge）は、
   キー（→ ← D A）かスワイプでしか行えず、画面上に操作口が無い。ところが
   ヒントの表記は「← × ｜ ○ →」だけなので、矢印キーの無いコンパクトキーボード
   （60%配列など）では、案内されたキーがそもそも存在しないことになる。
   D / A も効くのに書いていないため、自力では気づけない。

   対策：マウス環境のときだけ「A / ← × ｜ ○ → / D」に差し替える。
   スマホ・タブレットは条件に該当しないので従来のスワイプ表記のまま。

   条件について：
   ・min-width は付けない。PCでウィンドウを細くしただけでキー案内が消えてしまう
     ため（上の zoom 用ブロックが min-width:1024px を要求しているのは横向きスマホ
     を除外する都合であって、こちらは文言の出し分けなので幅で切る理由がない）。
   ・iPadOSは外付けキーボード／トラックパッドを繋いでも hover:none・pointer:coarse
     のままなので、キー表記は出ない（矢印キーは実際には効くが、スワイプもできる
     ので操作不能にはならない）。
   ・タッチ対応のWindowsノートは pointer:fine 側に入るのでキー表記が出るが、
     キーも実際に効くので実害はない。 */
@media (hover: hover) and (pointer: fine) {
  .swipe-hint .hint-touch { display: none; }
  .swipe-hint .hint-keys  { display: inline; }
}

/* ===== v1.2.263: PCでは下部ナビを「左端のサイドバー」にする =====
   ★このブロックも必ず <style> の末尾に置くこと（上のタブレット用・PCズーム用・
     PCリスニング用と同じ理由。メディアクエリは詳細度を上げないので、後で再定義
     された同詳細度の指定に負ける）。

   経緯：v1.2.165 で一度これを入れたが、本人判断で削除された（機能は良かったが
   見た目が悪かった）。当時は背景も枠も持たない裸のピルを right:calc(50% + 260px)
   で本体列の左脇に「浮かせて」いたため、どこにも接地していないボタンの束に見えた。
   今回は Twitter / YouTube と同じく **画面の左端に貼り付いた面（壁）** として作る。
   面と境界線があれば、本体列から離れていても孤立して見えない。

   ★アクティブ表示から緑（--brand-500 / --brand-50）を外している。理由は2つ。
     ①参考にした2サイトともサイドバーに accent 色を使っておらず、色ではなく
       「濃さ」で現在地を示している（YouTube＝グレーのピル＋黒に近い文字）。
     ②ダークの --brand-50 は #1a1520 で、サイドバーの面 #1e1a28 より暗い。
       塗ると光らずに「穴」に見える。v1.2.165 が特にダークで悪く見えた一因。
   緑に戻したいときは下の --rail-active-bg / --rail-active-fg を
   var(--brand-50) / var(--brand-500) に差し替えるだけでよい（他は触らない）。

   条件：(hover:hover) and (pointer:fine) …… マウス環境＝PCに限定（タブレットを除外）。
         min-width:1024px …… 横向きスマホの除外用（上の zoom / リスニング用と同値）。
   ★幅の指定に vw は使わないこと（:root の zoom は % と ICB は補正するが vw/vh は
     補正しない。v1.2.154 の落とし穴と同じ）。px と % だけで組んである。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  :root {
    --rail-w: 240px;
    /* 折りたたみ時の幅。YouTubeのミニレールと同じ72px。 */
    --rail-w-mini: 72px;
    /* サイドバーの面を白(#FFF)から var(--bg)(#F8F9FA) に変えた分、
       現在地のピルを --gray-100(#F3F4F6) のままにすると差が
       5階調しかなく、ライトでほぼ見えなくなる。一段濃い --gray-200 に上げる。
       ダークは面 #121018 / ピル #322c40 で差が十分なので下の指定のまま。 */
    --rail-active-bg: var(--gray-200);
    --rail-active-fg: var(--gray-900);
    --rail-hover-bg: rgba(0, 0, 0, 0.04);
  }
  body.dark-mode {
    --rail-active-bg: #322c40;
    --rail-hover-bg: rgba(255, 255, 255, 0.06);
    /* v1.2.271: ★ここが無いとダークで現在地の文字が読めない。
       --gray-* のダーク値は body.dark-mode に宣言してあるが、
       --rail-active-fg は :root で宣言している。var() は「使う側」ではなく
       「宣言した要素」で解決されるので、:root の --rail-active-fg は
       body.dark-mode を見ずにライトの --gray-900(#1C1C24) を拾ってしまう。
       結果、#322c40 のピルにほぼ黒の文字が乗っていた。
       同じ宣言をここへ置き直すと #FFFFFF に解決される。 */
    --rail-active-fg: var(--gray-900);
  }

  /* 帯 → 壁。left/top/bottom で画面左端に貼り付ける。 */
  .bottom-nav {
    top: 0;
    bottom: 0;
    right: auto;
    width: var(--rail-w);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    box-sizing: border-box;
    padding: 20px 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    border-top: none;
    border-right: 1px solid var(--gray-200);
    /* 幅だけを遷移させる。開閉ボタンの left と同じ 0.22s に揃えてある。
       ★padding を transition に入れてはいけない。折りたたみ時は
         padding-top が 20px→74px と縦に動くので、幅の横移動と混ざって
         アイコンが斜めに滑って見える。padding は一瞬で切り替え、
         動くのは壁の右端だけにする。 */
    transition: transform 0.22s ease, width 0.22s ease;
    /* サイドバーの面はコンテンツ列と同じ地の色にする。
       スマホの下部ナビ（白 / #1e1a28）は触らず、PCのサイドバーだけを
       var(--bg) に寄せている。ライト #F8F9FA / ダーク #121018。
       白い壁に戻したいときはこの1行を消せば元の見え方になる。 */
    background: var(--bg);
  }
  body.dark-mode .bottom-nav {
    border-top-color: transparent;
    border-right-color: #3a3545;
    /* 上の .bottom-nav より詳細度が高いので、ここでも同じ値を宣言しないと
       ダークだけ #1e1a28 のまま残る。 */
    background: var(--bg);
  }
  /* 集中モードからの手動非表示は残す。ただし下ではなく左へ逃がす。
     （スクロール連動の自動非表示は attachScrollHide 側でPCでは止めてある） */
  .bottom-nav.scroll-hidden { transform: translate3d(-100%, 0, 0); }
  /* v1.2.265: 開閉。閉じたときも .app は動かさない（列はビューポート中央の
     ままなので、開閉でコンテンツが左右に飛ばない）。 */
  /* v1.2.273: 折りたたみ＝全消しをやめて、YouTubeと同じ「細いアイコンだけの列」
     にする。閉じている間もホーム／編集／リスニングには1クリックで行ける。
     ロゴ・「メニュー」見出し・設定リストは畳んだ側に隠す（YouTubeのミニレールも
     主要導線だけで、それ以外は開かないと出てこない）。
     .app は開閉で動かさない設計のままなので、ここは触らない。 */
  body.rail-collapsed .bottom-nav {
    width: var(--rail-w-mini);
    /* 左右パディングを12→6pxに詰めて、中身の幅を60px確保する。
       10pxの文字なら「リスニング」5文字＝約50pxで収まる。 */
    padding-left: 6px;
    padding-right: 6px;
    /* 開閉ボタン（fixed / top:20px / 高さ36px）の真下から始める。
       74px は開いている時の1項目目の位置と同じ値なので、開閉しても
       アイコンの行が縦に飛ばない。 */
    padding-top: 74px;
  }
  body.rail-collapsed .rail-brand,
  body.rail-collapsed .rail-section-label,
  body.rail-collapsed .rail-settings-host {
    display: none;
  }
  body.rail-collapsed .bottom-nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 14px 0 12px;
  }
  body.rail-collapsed .bottom-nav-item .nav-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    max-width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* 設定を全部載せると項目が15個を超えて画面に入り切らないので、
     サイドバー自体をスクロールさせる。スクロールバーは出さない。 */
  /* v1.2.268: サイドバー全体のスクロールをやめる。
     ロゴ〜リスニング〜「メニュー」行までは常に見えていてほしいので、
     スクロールさせるのは畳んだ中身（.rail-settings-host）だけにする。
     縦は flex なので、上の固定分を引いた残りが自動でその器の高さになる。 */
  .bottom-nav {
    overflow: hidden;
  }

  /* 開閉ボタン。開いている間はサイドバー内のロゴ行の右端に、
     閉じている間は画面の左上に居座る。位置だけを動かして同じボタンを使い回す。 */
  body.has-bottom-nav .rail-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 20px;
    left: 190px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--gray-500);
    cursor: pointer;
    z-index: 101;
    transition: left 0.22s ease, background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }
  body.has-bottom-nav .rail-toggle:hover { background: var(--rail-hover-bg); }
  /* 閉じている時は72pxのミニレールの中央に置く（(72-36)/2 = 18px）。 */
  body.rail-collapsed.has-bottom-nav .rail-toggle { left: 18px; }

  /* ---- サイドバーに移設した設定メニュー ----
     元は幅280pxのドロワー用に組まれていて、そのままだと240pxの中で窮屈。
     行の高さと文字を一段落として詰める。色や区切り線は元のまま。 */
  .rail-settings-host {
    display: block;
    /* 残り高さを全部もらって、そこで縦スクロールする。
       min-height:0 が無いと flex アイテムは中身の高さより縮まないので、
       器がはみ出してスクロールが効かない（flexの定番の落とし穴）。 */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    /* v1.2.269: スクロールバーを出す。
       ★はみ出し方向へ 6px 広げてから同じだけ内側に戻しているのは、
         バーの幅ぶん中身が細って、上のナビ4項目と右端が揃わなくなるのを
         避けるため。バーは .bottom-nav の右パディング(12px)の中に置かれる。 */
    margin-right: -6px;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
  }
  .rail-settings-host::-webkit-scrollbar { width: 6px; }
  .rail-settings-host::-webkit-scrollbar-track { background: transparent; }
  .rail-settings-host::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
  }
  .rail-settings-host::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
  .rail-settings-host .settings-menu-list { padding: 0; }
  .rail-settings-host .settings-menu-item {
    padding: 9px 12px;
    font-size: 13px;
    gap: 4px 10px;
    border-radius: 10px;
  }
  .rail-settings-host .settings-menu-item:hover { background: var(--rail-hover-bg); }
  .rail-settings-host .settings-menu-divider { margin: 6px 12px; }
  .rail-settings-host .settings-panel-footer {
    padding: 12px 12px 4px;
    /* v1.2.272: 左寄せをやめて元の中央寄せに戻す（.settings-panel-footer の
       既定が center なので上書きしない）。左寄せだと、上のメニュー項目は
       アイコン24px＋間隔10pxのぶん文字が右に始まるのに対し、
       フッターだけ左端12pxから始まって手前に飛び出して見えていた。
       （v1.2.501 でクレジット行 .app-credit は削除済み） */
    border-top: none;
  }

  /* v1.2.264: 緑の文字ロゴをやめてアプリアイコンに差し替え。
     左padding は .bottom-nav-item と同じ12pxにして、下のナビのアイコン列と
     縦のラインを揃えている。
     ★src が絶対パス(/icon-192.png)なので、ローカルにHTML単体を置いて
       file:// で開いた時だけ画像が出ない（Cドライブの直下を見に行くため）。
       csvocab.com では正しく出る。 */
  .rail-brand {
    /* v1.2.831: アイコンの右に「CSVocab」の文字を並べるため block → flex。 */
    display: flex;
    align-items: center;
    gap: 10px;
    /* v1.2.268: サイドバー自体がスクロールしなくなったので、v1.2.267 で入れた
       sticky と padding の移設は不要になった。元の値に戻してある。 */
    padding: 4px 12px 20px;
    flex: 0 0 auto;
    line-height: 0;
    user-select: none;
  }
  .rail-brand img {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: block;
    flex-shrink: 0;
  }
  /* v1.2.831: サイドバー上のアプリ名。--gray-800 はダークで明るい色に
     入れ替わるので、ライト・ダークとも同じ指定で読める。
     畳んだ時は既存の body.rail-collapsed .rail-brand で丸ごと消える。 */
  .rail-brand-text {
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
    color: var(--gray-800);
    white-space: nowrap;
  }
  /* 縦積みなので flex:1 だと項目が縦に引き伸ばされる。横並びのピルに組み替える。
     v1.2.266：寸法・文字・アイコンを下の設定行（.settings-menu-item）に合わせた。
     アイコン枠24px／SVG20px／stroke-width 1.7／文字13px・600 がその値。
     nav-icon の SVG は width="22" 等の属性を持っているが、CSSの方が
     プレゼンテーション属性より強いのでここで上書きできる。 */
  .bottom-nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 0;
    border-radius: 10px;
  }
  .bottom-nav-item .nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 0;
    color: var(--gray-500);
  }
  .bottom-nav-item .nav-icon svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.7;
  }
  .bottom-nav-item .nav-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
  }

  /* v1.2.270: 「メニュー」は押せない小見出し。アイコンは付けない
     （押せないものにアイコンを付けると行と同じ「押せる部品」に見える）。
     上に1pxの区切り線を引いてナビ4項目と縁を切る。YouTube・Gmail・Slack の
     サイドバーはいずれも「面を塗る」でも「箱で囲む」でもなく、
     1pxの横線＋前後の余白でグループを分けている。ここもそれに合わせた。 */
  .rail-section-label {
    display: block;
    position: relative;
    flex: 0 0 auto;
    margin: 16px 0 2px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    user-select: none;
  }
  .rail-section-label::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gray-200);
  }
  .bottom-nav-item:hover { background: var(--rail-hover-bg); }
  .bottom-nav-item.active { background: var(--rail-active-bg); }
  .bottom-nav-item.active .nav-icon,
  .bottom-nav-item.active .nav-label { color: var(--rail-active-fg); }
  /* 行の高さがガタつくので拡大は掛けない（v1.2.165 と同じ判断） */
  .bottom-nav-item.active .nav-icon { transform: none; }
  .bottom-nav-item:active { opacity: 1; background: var(--rail-active-bg); }

  /* 本体列の横位置。
     v1.2.263 は left:calc(var(--rail-w)/2) で「サイドバーを除いた残りの中央」に
     置いていた。左右の余白は数値上ぴったり等しくなるが、実際に見ると右に寄って
     感じる。目はサイドバーを「左側のコンテンツ」として数えるので、幾何学的な
     中心と、見た目の重心が一致しないため。
     v1.2.264：ずらすのをやめてビューポートの中央に戻す。サイドバーと列の間が
     詰まり、余白は右に多めに残る＝Twitterのような左寄りの重心になる。
     ★微調整はこの1行だけで効く。もっと左へ寄せたいなら負の値、
       v1.2.263の見え方に戻すなら calc(var(--rail-w) / 2)。
     ★transform ではなく left を使うこと。transform は position:fixed の
       包含ブロックを作ってしまい、.app 内に fixed 要素が増えた時に壊れる。 */
  body.has-bottom-nav .app {
    left: 0;
  }

  /* 下端の帯が無くなった分、各画面に確保していた70〜78pxを詰める。 */
  body.has-bottom-nav .app { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  body.has-bottom-nav .editor-word-list { padding-bottom: 12px; }
  body.has-bottom-nav #screen-listening.active { height: var(--app-height, 100dvh); }

  /* 設定の入口はサイドバー下端に一本化する（ヘッダーと2箇所に散らさない）。
     PWAインストールボタン(.pwa-header-btn)は別機能なので残す。 */
  body.has-bottom-nav .dashboard-top-bar .hamburger-btn:not(.pwa-header-btn) {
    display: none;
  }

  /* 緑のFAB(#pwaInstallWrap)は下部ナビの「リスニング」を避けるため66px上げて
     いたが、PCではその帯が無いので通常位置に戻す。#id より詳細度を上げて
     後方の <style> にある元の指定に勝たせている。 */
  body.has-bottom-nav #pwaInstallWrap {
    bottom: 24px;
  }
}

/* ===== v1.2.278: サイドバーの開閉アニメーション =====
   ★このブロックもスタイルの末尾（上のサイドバー用ブロックより後）に置くこと。
     body.rail-collapsed 系と詳細度が同じ(0,2,1)なので、後に書かないと勝てない。

   症状（v1.2.275まで）：閉じた状態から開くと、メニューの中身がごちゃごちゃ
   動いてから収まる。

   原因：幅だけが 0.22秒かけて 72px → 240px に動くのに対し、中身の指定は
   body.rail-collapsed が外れた瞬間（t=0）に全部が開いた形へ切り替わる。
   つまりアニメーションの0.22秒間ずっと、「開いた形の中身」が幅48pxしかない
   箱の中で組まれる。ラベルが縦に折り返り、設定リスト15項目が折り返しながら
   整列し直し、幅が広がるにつれて元に戻っていく。動いていたのは文字であって、
   壁ではない。

   ★v1.2.276〜277 で「アニメーション中だけ中身の幅を固定する」方法を試したが、
     固定した幅が最終的な幅と1pxでもずれると、終わった瞬間に右端のもの
     （ダークモードのOFF、Google同期の「未接続」、ストレージの数字とバー、
     スクロールバー）がピクッと跳ねる。.rail-settings-host は
     margin-right:-6px / padding-right:6px（v1.2.269のスクロールバー対策）を
     持っていて、そこにブラウザ実装依存のスクロールバー幅まで絡むので、
     「正しい固定値」を式で当てにいくやり方自体を捨てた。

   対策（v1.2.278）：**幅を一切動かさない。** アニメーションの間は
   .bottom-nav を開いた幅・開いた padding のまま固定し、動かすのは
   clip-path の右端だけにする。clip-path は塗りだけの指定でレイアウトを
   一切触らないので、中身は原理的に一度も組み直されない＝ずれようがない。
   見た目は「壁が左から拭き出される／拭き取られる」で、幅を動かしていた時と
   ほぼ同じになる。

   ★止まっている時（開いた状態・畳んだ状態）は clip-path: inset(0 0 0 0)。
     transition から width を外してあるので、幅の変化は必ず一瞬で終わる。
     幅が変わるのは「クリップで隠れている間」か「アニメーションの前後で
     transition を切っている1フレーム」だけなので、動いて見えることはない。

   ★clip-path は border-right(1px) も一緒に切る。拭いている0.22秒の間だけ
     壁の右端の細い線が出ないが、動いている縁なのでまず気付かない。

   ★JS側は transitionend ではなく setTimeout で後始末している。
     transitionend は transform と clip-path の2本で複数回発火するうえ、
     このメディアクエリの外（スマホ幅）では何も変化せず一度も発火しない。
     発火しないと rail-collapsed が永久に付かず、閉じられなくなる。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  /* 止まっている時はクリップ無し。transition から width を外し、
     代わりに clip-path を入れる。 */
  .bottom-nav {
    clip-path: inset(0 0 0 0);
    transition: transform 0.22s ease, clip-path 0.22s ease;
  }

  /* アニメーション中は「開いた形・開いた幅」で固定して組む。
     動くのはクリップの右端だけ。 */
  body.rail-anim .bottom-nav {
    width: var(--rail-w);
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 20px;
  }

  /* 畳んだ幅ぶんだけ右を隠す（240 - 72 = 168px）。 */
  body.rail-anim-clip .bottom-nav {
    clip-path: inset(0 calc(var(--rail-w) - var(--rail-w-mini)) 0 0);
  }
  /* 開閉ボタンもクリップの状態に合わせる。畳んだ側の位置は
     body.rail-collapsed 側と同じ 18px（72pxのミニレールの中央）。 */
  body.rail-anim-clip.has-bottom-nav .rail-toggle {
    left: 18px;
  }

  /* 開始値を当てる1フレームと、終了後に畳んだ形へ差し替える1フレームだけ
     transition を切る。ここを切らないと、開く時は逆再生になり、
     閉じ終わりは「幅72pxの箱にクリップ168pxが残ったまま」＝真っ白から
     0.22秒かけて出てくる、という妙な動きになる。 */
  body.rail-anim-instant .bottom-nav,
  body.rail-anim-instant .rail-toggle {
    transition: none;
  }

  /* ===== v1.2.383: 閉じるときの「残像」対策 =====
     症状：閉じる途中、幅72pxまで拭き取られた時点で「開いた形の中身」
     （ロゴ・『メニュー』見出し・設定リスト・ラベルの頭1文字・現在地ピルの
     切れ端）がまだ見えていて、そこから畳んだ形へパッと差し替わる。
     その切れ端が残像に見える。

     対策：拭き取っている 0.22s の間に、開いた状態にしかない中身を
     opacity で消していく。アイコンだけが残った状態で畳んだ形に差し替わる
     （アイコンの左端は開いた形 12+12=24px、畳んだ形 6+(60-24)/2=24px で
     同じ位置なので横に飛ばない）。開くときはこの逆で、隠れた状態から
     拭き出しと同時に浮かび上がる。
     ★これらは display:none ではないので、レイアウトは一切変わらない
       （v1.2.278 の「中身を組み直さない」方針はそのまま）。 */
  body.rail-anim .rail-brand,
  body.rail-anim .rail-section-label,
  body.rail-anim .rail-settings-host,
  body.rail-anim .bottom-nav-item .nav-label {
    transition: opacity 0.18s ease;
  }
  body.rail-anim .bottom-nav-item {
    transition: background-color 0.18s ease;
  }
  body.rail-anim-clip .rail-brand,
  body.rail-anim-clip .rail-section-label,
  body.rail-anim-clip .rail-settings-host,
  body.rail-anim-clip .bottom-nav-item .nav-label {
    opacity: 0;
  }
  body.rail-anim-clip .bottom-nav-item,
  body.rail-anim-clip .bottom-nav-item.active {
    background-color: transparent;
  }
  body.rail-anim-instant .rail-brand,
  body.rail-anim-instant .rail-section-label,
  body.rail-anim-instant .rail-settings-host,
  body.rail-anim-instant .bottom-nav-item,
  body.rail-anim-instant .bottom-nav-item .nav-label {
    transition: none;
  }
  /* 畳んだ形に差し替わった直後だけ、小さいラベルと現在地ピルを
     ふわっと出す。rail-collapsed 自体に付けると起動時にも再生されるので、
     JS が着地の一瞬だけ付ける rail-just-collapsed で当てる。 */
  @keyframes railMiniIn {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  body.rail-just-collapsed .bottom-nav-item .nav-label,
  body.rail-just-collapsed .bottom-nav-item.active {
    animation: railMiniIn 0.16s ease both;
  }
}

/* ==========================================================================
   ここから旧2つ目の <style>（v1.2.887 まで body の途中・インストール案内の直前にあったもの）
   ========================================================================== */
/* Floating Install Button */
#pwaInstallWrap {
  display: none;
  position: fixed;
  /* v1.2.137: 旧値は bottom:24px で、下部ナビ（.bottom-nav）の右端＝
     「リスニング」に重なりタップを邪魔していた。ナビの実高は
     8+22+2+10+6＋境界線 ≒ 50px なので、safe-area の上に 66px 取って
     約15pxの余白を空ける。ナビを出さない画面では少し浮くが、
     FABが主に出るのはホームなので許容。 */
  bottom: calc(66px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  z-index: 99999;
}
#pwaInstallWrap.show { display: block; }
#pwaInstallWrap.hide-on-screen { display: none !important; }
#pwaInstallFab {
  display: flex;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green-500, #22C55E);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#pwaInstallFab:active { transform: scale(0.92); }
#pwaInstallFab svg { width: 28px; height: 28px; fill: #fff; }

/* Pulse animation */
@keyframes pwa-pulse {
  0% { box-shadow: 0 4px 14px rgba(0,0,0,0.3), 0 0 0 0 rgba(34,197,94,0.5); }
  70% { box-shadow: 0 4px 14px rgba(0,0,0,0.3), 0 0 0 12px rgba(34,197,94,0); }
  100% { box-shadow: 0 4px 14px rgba(0,0,0,0.3), 0 0 0 0 rgba(34,197,94,0); }
}
#pwaInstallWrap.pulse #pwaInstallFab { animation: pwa-pulse 2s ease-in-out 3; }

/* Guide Overlay */
#pwaGuideOverlay {
  display: none;
  position: fixed;
  inset: 0;
  /* v1.2.137: .settings-overlay と同じ濃さに揃える（ライト0.4／ダーク0.65）。
     旧値は常時0.75で、ライトモードだと背後が沈みすぎていた。 */
  background: rgba(0,0,0,0.4);
  z-index: 100000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
body.dark-mode #pwaGuideOverlay {
  background: rgba(0,0,0,0.65);
}
#pwaGuideOverlay.show { display: flex; }

/* v1.2.137: 旧実装は LP のダークセクションから配色をそのまま移植していたため、
   アプリがライトモードでもガイドだけ常に暗かった。カード内で完結する
   ローカル変数（--pg-*）を定義し、既定をライト、body.dark-mode で
   ダークへ差し替える。各所の直値はこの変数に置き換えてある。 */
#pwaGuideCard {
  --pg-bg: #fff;
  --pg-fg: var(--gray-700);
  --pg-strong: var(--gray-800);
  --pg-muted: var(--gray-500);
  --pg-shot-bg: var(--gray-100);
  --pg-shot-border: var(--gray-200);
  --pg-shadow: rgba(0,0,0,0.18);
  background: var(--pg-bg);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  /* v1.2.2: ランディングページ風の画像付き4ステップガイドに対応するため、
     カード自体をスクロール可能にする。
     v1.2.154: PC拡大(:root の zoom)下では **vh / dvh だけが zoom 補正を受けない**。
     100dvh は補正前のビューポート高(例:911px)のまま返り、それが1.1倍で描画される
     ので、カードが画面より約10%高くなり上下の余白が消えて見切れていた。
     zoom補正済みの --app-height（head のスクリプトが z で割って設定している）を
     使えば、拡大していてもしていなくても正しい高さになる。 */
  max-height: calc(100vh - 40px);
  max-height: calc(var(--app-height, 100dvh) - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  text-align: center;
  color: var(--pg-fg);
  position: relative;
  box-shadow: 0 8px 32px var(--pg-shadow);
}
body.dark-mode #pwaGuideCard {
  --pg-bg: #1e1a28;
  --pg-fg: #e0e0e0;
  --pg-strong: #fff;
  --pg-muted: #b0b0b0;
  --pg-shot-bg: #2a2535;
  --pg-shot-border: rgba(255,255,255,0.08);
  --pg-shadow: rgba(0,0,0,0.4);
}
#pwaGuideCard::-webkit-scrollbar { display: none; }
#pwaGuideCard h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--pg-strong);
  font-weight: 600;
}
#pwaGuideCard p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--pg-muted);
  text-align: left;
}
#pwaGuideCard p.pwa-note {
  margin: -12px 0 20px;
}
#pwaGuideCard p.pwa-note .pwa-note-label { display: block; text-align: left; color: #B91C1C; font-weight: 600; }
body.dark-mode #pwaGuideCard p.pwa-note .pwa-note-label { color: #EF4444; } /* v1.2.762: #F87171 はサーモン寄りで本文の灰と明るさが近く、薄く見えた */
#pwaGuideCard .pwa-steps {
  text-align: left;
  margin-bottom: 20px;
}
#pwaGuideCard .pwa-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
#pwaGuideCard .pwa-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green-500, #22C55E);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
#pwaGuideCard .pwa-step-text {
  font-size: 14px;
  line-height: 1.5;
  padding-top: 3px;
  flex: 1;
  min-width: 0;
}
#pwaGuideCard .pwa-step-text strong {
  color: var(--pg-strong);
}
/* v1.2.2: ランディングページ準拠の画像付きステップ。
   v1.2.645: 姉の初見テストで「文字より画像を頼りに操作していた」ため、
   横並びのサムネ（84px・上部クロップ）をやめて縦積みにし、画像を主役にする。
   数字＋見出し → 画像（幅いっぱい・クロップなし） → 短い説明文。 */
#pwaGuideCard .pwa-step.with-shot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 28px;
}
#pwaGuideCard .pwa-step.with-shot .pwa-step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
#pwaGuideCard .pwa-step.with-shot .pwa-step-shot {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: var(--pg-shot-bg);
  border: 1px solid var(--pg-shot-border);
}
#pwaGuideCard .pwa-step.with-shot .pwa-step-shot img {
  width: 100%;
  height: auto;
  display: block;
}
#pwaGuideCard .pwa-step.with-shot h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--pg-strong);
  line-height: 1.4;
}
#pwaGuideCard .pwa-step.with-shot .pwa-step-text {
  padding-top: 0;
  font-size: 13px;
  color: var(--pg-muted);
  line-height: 1.55;
  text-align: center;
}
/* Android-向けの緑ノート(iOS表示時のみ出す補助情報) */
#pwaGuideCard .pwa-install-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 4px 0 18px;
  padding: 12px 14px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 10px;
  text-align: left;
}
#pwaGuideCard .pwa-install-note-ic {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green-500, #22C55E);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  margin-top: 1px;
}
#pwaGuideCard .pwa-install-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--pg-fg);
}
#pwaGuideCard .pwa-install-note strong {
  color: var(--pg-strong);
  font-weight: 600;
}
#pwaGuideClose {
  background: var(--green-500, #22C55E);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
}
#pwaGuideClose:active { opacity: 0.8; }

/* Safari share icon inline */
.pwa-share-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: text-bottom;
  margin: 0 2px;
}

/* ===== v1.2.284: PCのクイズ画面の枠まわり =====
   ★このブロックも必ず style の末尾に置くこと（他のPC用・タブレット用と同じ理由。
     メディアクエリは詳細度を上げないので、後で再定義された同詳細度の指定に負ける）。

   カード／タイピング／4択の枠の高さを揃え、縦を少しでも枠の背に回すための指定。
   ※元はここに「①列幅を縦の高さから決める式」（max-width: min(480px, --app-height×0.69)）が
     あり、縦の足りない14インチで枠が横長になるのを防いでいた。v1.2.591 で画面ごと
     「縦825px相当」に縮める方式（fitZoom）になって常に480pxで頭打ち＝効かなく
     なったため、v1.2.594 で削除した。番号は経緯を追えるよう②から残してある。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  /* ②進捗バーの下の余白を詰める指定があったが、v1.2.866 でバーごと削除 */

  /* ③下部の余白をモードによらず同じにする。
     元は :not(.typing-mode) だけ60pxだったので、タイピングだけ枠が32px高かった。
     26pxにしてあるのは、④で浮かせるヒント行を収める帯として使うため。 */
  #screen-quiz.active,
  #screen-quiz.active:not(.typing-mode) {
    padding-bottom: calc(env(safe-area-inset-bottom) + 26px);
  }

  /* ④ヒント行（「Enter で答え合わせ」「スペース / タップで次へ」）は
     .quiz-card-area の兄弟＝カードの外にあり、タイピングと4択のときだけ
     display:block になる。つまりこの1行ぶんの高さをカードモードだけが
     払っていなかった。流れから外して③の帯に重ねることで、
     カード／タイピング／4択の枠の高さが完全に一致する。
     位置の基準は position:fixed の #screen-quiz.active。 */
  .input-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(env(safe-area-inset-bottom) + 4px);
    padding: 0;
  }
}

/* ===== v1.2.355: PCの全デッキ画面で、下部の一括操作バーを画面全幅に戻す =====
   ★このブロックも必ず <style> の末尾に置くこと（他のPC用・タブレット用と同じ理由）。

   前段の `body.all-decks-active #deckBulkToolbar.bulk-toolbar`（1つ目の <style> 内）は
   バーを中央480px列に揃える指定。スマホでは画面幅＝列幅なので違いが出ないが、
   PCでは「スマホ幅の帯が広い画面の真ん中に浮いている」形になってしまう。
   マウス環境だけ left:0 / right:0 の全幅（＝.bulk-toolbar の素の値）へ戻す。

   ・セレクタの詳細度は上記の前段の指定と同じ。2つ目の <style> にあり後勝ちで効く。
   ・タッチ環境（スマホ・タブレット）は対象外＝中央480pxのまま。
   ・単語編集側の #bulkToolbar は元から全幅なので何も変わらない。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  body.all-decks-active #deckBulkToolbar.bulk-toolbar {
    left: 0;
    right: 0;
    transform: none;
    max-width: none;
    width: auto;
  }
}

/* ===== v1.2.287: 大きいモニターの既定表示サイズを1.1倍にする =====
   ★このブロックは必ず <style> の末尾に置くこと（他のPC用・タブレット用と同じ理由）。

   狙い：新規ユーザーはブラウザのズームを触らないので、既定値がそのまま体験になる。
   24.5インチの実機ではブラウザ110%が最も見やすかったため、その大きさを既定にする。
   （本人はこれまで手動で110%にしていた＝**この版を確認する前にブラウザを100%へ
     戻すこと**。戻さないと 1.1×1.1＝1.21倍で二重に掛かる。）

   ★条件は「幅だけ」。高さを条件に入れてはいけない。
     ブラウザズームを上げるとCSS上のビューポートは縦横とも減るが、
     ・高さ … 911px→110%で828px→120%で759px と、しきい値(800px)を跨ぐ。
              跨いだ瞬間に拡大が外れて「拡大したのに縮む」反転が起きる（v1.2.281の廃止理由）。
     ・幅 …… 1920px→110%で1745px→120%で1600px と、120%までは1600pxを割らない
              （125%以上は下の等倍の帯に落ちる。v1.2.596 で境目を上げた代償）。
              つまり幅だけなら反転しない。
     ★v1.2.596：境目を 1400px → 1600px に上げた。1400〜1599px は「何も掛けない＝等倍」の帯。
       理由：この帯に入るのは外部モニターではなくノート（1536x864＝15.6インチのフルHDで
       Windows拡大率125%、1440x900＝MacBook Air級）。窓の縦が約695〜760pxしかなく、
       1.1倍だと 1536px幅でレイアウト上の縦が約632px＝ホーム（必要約690px）の
       「学習を始める」が約50px切れていた。等倍なら約695pxで収まる。
       0.8倍（下の段）まで下げると今度は字が小さすぎるので、間の等倍にしてある。
       本人の2台（1280px→0.8倍／1920px→1.1倍）の見え方は変わらない。
     ※14インチをブラウザ80%にすると幅1600pxでここに入る。常用100%なので現状は無害。

   ★倍率を 1.1 から上げる時の注意。
     1440x900（MacBook Air級）がこの段の下限の想定環境。1.1 なら 900÷1.1≈818px で
     クイズ／リスニングの fitZoom（縦825px相当）はほぼ等倍のまま。上げるほど
     レイアウト上の縦が減り、その分 fitZoom がカード系の画面だけを縮め戻す
     （＝ホーム・一覧は大きく、カード系は据え置き、という差が開く）。

   ★zoom は vh / dvh / vw を補正しない。
     ビューポート高に近い値（おおむね85vh以上）を新しく書くときは
     vh ではなく var(--app-height) を使うこと。現状の該当箇所は対応済み：
       #pwaGuideCard（100dvh-40px）／.img-lightbox img（90vh）／.csv-table-modal（85vh）
     80vh以下（.demo-picker-modal など）は 80×1.1=88% で余裕があるため据え置き。

   ★高さで切り替わる他のメディアクエリとの関係：
     max-height:700px / 620px のコンパクト分岐は3箇所とも (pointer: coarse) が
     付いておりマウス環境では発火しない。リスニングの高さ2段も v1.2.591 で廃止したので、
     マウス環境のPCで効く高さ条件は現状1つも無い。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1600px) {
  :root {
    zoom: 1.1;
    --ui-zoom: 1.1;  /* ★zoom と必ず同値。<head> がこれで --app-height を割り戻す */
  }
}

/* ===== v1.2.593: ノートPC（幅1400px未満のマウス環境）の既定表示サイズを0.8倍にする =====
   ★このブロックも必ず style の末尾側に置くこと（他のPC用・タブレット用と同じ理由）。

   経緯：14インチノート（1280x551・Windowsの拡大率150%）で、スクロールして読む画面
   （ホーム・一覧）はブラウザ80%が最適、と本人が実機で確認した。上の v1.2.287
   （v1.2.596 から幅1600px以上＝1.1倍）の下、1400px未満を0.8倍にする。
   間の 1400〜1599px は何も掛けない等倍の帯（理由は上の v1.2.287 のコメント参照）。
   サイドバー・各種シートも一緒に0.8倍になる（ブラウザ80%で見ていた状態と同じ）。

   ・クイズ／リスニングの見え方は変わらない。fitZoom は「レイアウト上の縦÷825」なので、
     551÷0.8≈689px → f≈0.835、合計 0.8×0.835≈0.668 ＝ v1.2.591/592 と同じ倍率に落ちる。
   ・ホームは必要な縦が約690px。551÷0.8≈689px なので「学習を始める」が
     スクロールなしでほぼ収まる（100%では収まっていなかった）。
   ・★zoom と --ui-zoom は必ず同値（<head> と uiZoomFactor() がこれで割り戻す）。
   ・★既知の段差：この段の端末でブラウザを90%以下に縮小すると、CSS上の幅が1400pxを
     超えて等倍の帯に、80%以下で1600pxを超えて1.1倍の段に入る＝
     「縮小したのに大きくなる」。常用100%なら無害。
     幅以外（高さ・dppx）を条件に足すと別の反転が出るので足さないこと（v1.2.281の教訓）。
   ・★確認前にブラウザのズームを100%へ戻すこと（80%のままだと 0.8×0.8＝0.64倍）。
   ・戻すとき：このブロックを消すだけ。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) and (max-width: 1399.98px) {
  :root {
    zoom: 0.8;
    --ui-zoom: 0.8;
  }
}

/* ===== v1.2.591: PCの「1画面に収める」系の画面を、いつも縦825px相当で見せる =====
   ★このブロックも必ず style の末尾側に置くこと（他のPC用・タブレット用と同じ理由）。

   対象：#screen-quiz（カード／タイピング／4択）と、リスニングの .listening-player
        （v1.2.592 から。デッキバーと絞り込み行は等倍）。
   対象外：ホーム・一覧・設定・結果・サイドバー・各種シート（文字が10〜16pxと小さく、
           縮めると読めなくなるため。こちらは今までどおり等倍）。

   仕組み：<head> の fitZoom() が「レイアウト上の縦 ÷ 825」（上限1.0・下限0.6）を
   --fit-zoom に入れる。ここではそれを画面の要素自身に zoom として掛けるだけ。
     ・14インチ（縦551px・ブラウザ100%）… 0.668 ＝ 本人が好んだ「ブラウザ67%」と同じ見え方
     ・24.5インチ（縦911px÷1.1≈828px）… 1.0   ＝ 今までと完全に同じ
   zoom を掛けた要素は自分の height も f 倍で描かれるので、--app-height を
   f で割った値（--app-height-fit）に差し替える。この上書きは要素の中だけに効く。
   同じ要素の height: var(--app-height) はこの値で解決される。

   ★メディアクエリの条件は <head> の FIT_MQ と必ず同じにすること。
   ★副作用（仕様）：この2画面ではブラウザのズーム（Ctrl＋/−）が打ち消される範囲がある。
     拡大すると窓の縦が減る→ f が下がる→見た目が変わらない。f が上限1.0／下限0.6に
     当たった先では普通に効く。
   ★この2画面の中で JS が実ピクセルを CSS の px に書く時は、uiZoomFactor() に加えて
     fitZoomFactor() でも割ること（現状の該当はカードのスワイプのみ）。
     「調べる」メニューや設定シートは body 直下＝この zoom の外なので従来どおり。
   ★戻すとき：このブロックと <head> の fitZoom 関連を消すだけでは足りない。
     背の低い窓用の指定（1つ目の style のリスニング①段、v1.2.284 の列幅の式と
     リスニング詰め直し）は削除済みなので、v1.2.590 から戻す必要がある。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  #screen-quiz.active {
    zoom: var(--fit-zoom, 1);
    --app-height: var(--app-height-fit, 100dvh);
  }
  /* v1.2.592: リスニングは「画面ごと」ではなく、デッキバーと絞り込み行の下＝
     .listening-player だけを縮める（本人の選択＝A案）。
     v1.2.591 は画面ごと縮めていたので、デッキバーが一覧・ホームより小さくなり、
     サイドバーで一覧⇔リスニングを行き来すると同じ部品の大きさが変わって見えた。
     バーと絞り込み行はサイドバーと同じ「画面の枠」として等倍に残す。
       ・プレイヤーは flex:1 の子なので、高さは親（等倍）が決める＝--app-height の
         差し替えは不要。幅は % 指定なので列幅（448px）のまま＝バーと問題枠の幅は揃う。
       ・代わりに14インチでは問題枠が横長になる（実測448×252px）。縦551pxの中で
         「バー等倍」「幅を揃える」「枠を縦長に」の3つは同時に成り立たないための割り切り。
       ・モニター（f=1.0）では v1.2.591 と完全に同じ。 */
  .listening-player {
    zoom: var(--fit-zoom, 1);
  }

  /* --- リスニング：デッキバーと、シークバー／問題枠／保存の横幅を揃える ---
     ずれていた原因：デッキバーと絞り込み行は列幅いっぱい（448px）なのに、
     シークバー以下は .listening-player の左右padding 20px の内側＋max-width で
     最大408pxまでしか広がれなかった。
     対策：max-width を外し、プレイヤーを左右に16pxずつはみ出させて同じだけ
     padding を取る＝中身の幅がちょうど列幅（448px）になる。padding を 0 にしないのは、
     プレイヤーが overflow-x:hidden なので問題枠の左右の影が切れるため。
     同じ理由で画面側の overflow も visible にする（縦は flex:1 / min-height:0 の
     プレイヤーが受け持っているので、画面がはみ出すことはない）。 */
  #screen-listening.active { overflow: visible; }
  .listening-player {
    width: calc(100% + 32px);
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .listening-seekbar,
  .listening-card { max-width: none; }
}

/* ===== v1.2.380: スマホのリスニングで再生ボタンの下に残る余白をカードに吸わせる =====
   ★このブロックも必ず <style> の末尾に置くこと（他のPC用・タブレット用と同じ理由。
     メディアクエリは詳細度を上げないので、後で再定義された同詳細度の指定に負ける）。

   経緯：v1.2.342（絞り込み＋並び替えを1行に統一）と v1.2.343（見出し「リスニング」を
   撤去）で、画面の上側から合計90px前後が浮いた。ところがスマホ(<=600px)の
   .listening-card は高さ240px固定・.listening-player は上寄せ(flex-start)なので、
   浮いた分はカードにも操作ボタンにも回らず、そのまま**再生ボタンの下の空白**に
   なっていた。背の高い端末ほど目立つ（実測の見積り：iPhone 14 Pro のSafariで
   約70px、ホーム追加(PWA)で約120px、Pro Max級では200px超）。

   対策：PC用（v1.2.183）と同じ「余りはカードだけに吸わせる」方式を <=600px にも入れる。
     ・flex: 1 1 240px …… 基準は従来と同じ240px。余りがあればカードだけが伸びる。
       flex-basis を 240px（auto ではなく固定値）にするのは、問題文の長短で
       カードの背が変わらないようにするため＝v1.2.183 で basis を 0 にしたのと同じ狙い。
       長文は従来どおり .listening-question / .listening-answer の中でスクロールする。
     ・min-height: 240px …… 余りが無い（＝従来どおり入り切らない）端末では、
       伸び幅0で今までと完全に同じ見た目になる。入り切らない時は
       .listening-player 側のスクロールに落ちるだけで壊れない。
     ・max-height: 440px …… 背の高い端末でカードだけが間延びしないための上限。
       440pxを超える余りが出る端末では、超えた分は従来どおり下に残る。
   結果としてシークバー（何問目のバー）は今までの位置のまま動かず、
   保存バーと再生ボタンだけが下（＝親指の届く側）へ寄る。

   ★プレイヤー全体の中央寄せ（justify-content: center）にはしないこと。
     シークバーごと下へ動く上、overflow-y:auto のコンテナを中央寄せにすると
     内容が入り切らない時に上へスクロールで戻れなくなる（v1.2.182 で踏んだ罠）。 */
@media (max-width: 600px) {
  .listening-card {
    height: auto;
    flex: 1 1 240px;
    min-height: 240px;
    max-height: 440px;
  }
}

/* ===== v1.2.381: スマホのリスニングで問題と答えが上下に離れて見える件 =====
   ★このブロックも必ず <style> の末尾に置くこと（他のPC用・タブレット用と同じ理由）。

   症状：スマホ(<=600px)だけ、問題がカードの上端寄り・答えが真ん中あたりに置かれ、
   下半分が大きく空く。読み上げ中（答えがまだ空文字の間）は特に「問題だけが
   天井に貼り付いている」形に見える。

   原因：<=600px では .listening-question / .listening-answer が flex:1 1 0 で
   カードの高さを**半分ずつ山分け**している（長文でも互いを押しのけず、各自の中で
   スクロールさせるため。答えが出た瞬間に問題が動かない利点もある）。ところが
   各自の枠の中では既定の上寄せなので、短い語だと「上半分の上端」「下半分の上端」＝
   全体の0%と50%の位置に文字が来る。カードが背の低い240px固定だった間は目立たな
   かったが、v1.2.380 でカードが最大440pxまで伸びるようになって顕在化した。

   対策：山分けは維持したまま、**中央線で向かい合わせる**。
     ・問題 … 自分の枠の下寄せ（safe flex-end）＝最終行が中央線のすぐ上に来る
     ・答え … 自分の枠の上寄せ＝1行目が中央線のすぐ下に来る
   結果、PC・タブレット（justify-content:center で2つを塊として中央寄せ）と
   同じ見え方になる。長文時は従来どおり各自の枠いっぱいに広がってスクロールし、
   答えが出ても問題の位置は動かない（山分けを崩していないため）。

   ★safe flex-end を併記する理由：overflow-y:auto の要素を flex-end で寄せると、
     内容がはみ出した時に上側へスクロールで戻れなくなる（v1.2.182 と同じ罠）。
     safe 対応ブラウザでは自動で上寄せに戻り、未対応でも1行目の flex-end が
     残るだけなので無害。 */
@media (max-width: 600px) {
  .listening-question {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    justify-content: safe flex-end;
  }
  .listening-answer {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }
}

/* ===== v1.2.382: タブレットのヨコ（iPadなど）のリスニングの余白 =====
   ★このブロックも必ず <style> の末尾に置くこと（他のPC用・タブレット用と同じ理由）。

   症状：iPadを横向きにすると再生ボタンの下に大きな余白が残る（v1.2.380 で
   スマホ側を直しても、こちらは何も変わらなかった）。

   原因：横向きのiPadはどの分岐にも入らない「谷間」だった。
     ・タブレット用ブロック … (min-width:768px) and (max-width:1023px)＝タテ専用。
       iPadのヨコは1180pxなので範囲外。
     ・PC用ブロック … (hover:hover) and (pointer:fine) が必須。iPadOSは外付け
       キーボードやトラックパッドを繋いでも hover:none / pointer:coarse のままなので
       絶対に当たらない（v1.2.261 のコメント参照）。
   結果、素の指定（カード min-height:200px・flex:0 0 auto、プレイヤーは上寄せ）が
   そのまま効き、伸びる要素が無いので余りが全部下に溜まっていた。
   実測の見積り：1180x820 で available≈729px に対しコンテンツ≈577px＝約150px。

   対策：スマホ(v1.2.380)・PC(v1.2.183)と同じ「余りはカードだけに吸わせる」。
     ・flex: 1 1 200px …… 基準は素の min-height と同じ200px。余りがあればカードだけ伸びる。
       basis を固定値にするのは、問題文の長短でカードの背が変わらないようにするため。
     ・max-height: 380px …… 中央列が480px＝カード幅400pxなので、これ以上伸ばすと
       縦長に間延びする。iPad(820px)なら約352pxで収まるので、実質この上限には当たらない。
     ・入り切らない高さ（iPad mini のヨコ744pxなど）では伸び幅が減るだけで、
       足りなければ従来どおり .listening-player 側のスクロールに落ちる。

   ★文字と再生ボタンの大きさには触っていない。今回の指摘は余白だけなので、
     サイズまで動かすと切り分けができなくなる。大きくするなら
     PC用（v1.2.183）と同じ値を、このブロックに (min-height: 800px) を足した
     別ブロックとして入れるのが筋（iPad mini のヨコ744pxを巻き込まないため）。 */
@media (hover: none) and (pointer: coarse) and (min-width: 1024px) {
  .listening-card {
    flex: 1 1 200px;
    min-height: 200px;
    max-height: 380px;
  }
}

/* ===== v1.2.487→488: タブレット（タテ）の一覧（編集画面）の行を大きく =====
   ★このブロックも必ず <style> の末尾に置くこと（他のタブレット用と同じ理由）。

   症状：iPadのタテで一覧を開くと行の文字が小さく見づらい。ヨコは「完璧」。
   原因：文字サイズはヨコもタテも同じ16px。違うのは列幅で、ヨコは480px列、
   タテは (min-width:768px) and (max-width:1023px) で700px列に広がる。
   幅だけ広がって中身が16pxのままなので、相対的に小さく・疎に見えていた
   （ヨコと同じ比率なら 16×700÷480≒23px。v1.2.487の20pxでは「もう少し」
   とのことで v1.2.488 で22pxに）。

   条件に (hover:none) and (pointer:coarse) を付けているのは、PCの狭い
   ウィンドウ（768〜1023px）を確実に外すため。スマホは幅で外れ、iPadのヨコは
   1180pxで外れるので、どちらも無変更。

   ★連動している値：.ew-inner の縦 padding を 18→26 にしたので、
     .ew-content::after の top/bottom（縦線をカード端まで伸ばす打ち消し）と
     .ew-note の margin-bottom / padding-bottom（下 padding の打ち消し）も
     -26 / 26 に揃えている。食い違うと縦線がカード端まで届かなくなる。
   触っていないもの：上部のコントロール類（検索・追加・選択・デッキ選択・
   フィルタ・並び順・問／答）、行間、ホーム・リスニング画面。 */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) and (max-width: 1023px) {
  .editor-word-item .ew-inner { padding: 26px 22px; }
  .editor-word-item .ew-content::after { top: -26px; bottom: -26px; }
  .editor-word-item .ew-eng,
  .editor-word-item .ew-jpn { font-size: 22px; }
  .editor-word-item .ew-note {
    font-size: 15px;
    margin-bottom: -26px;
    padding-bottom: 26px;
  }
  .editor-word-item .ew-thumb { height: 130px; }
}
/* ===== v1.2.648: PWA窓（standalone）のPCで、ホームの中身を縦の「見た目の中央」に置く =====
   ★このブロックも必ず style の末尾側に置くこと（他のPC用ブロックと同じ理由）。

   経緯：ホーム画面に追加した窓で開くとブラウザのタブ・アドレスバーが無い分だけ
   ビューポートが縦に長く（24.5インチで約911→約1003px）、ホームは上詰め
   （.app の padding-top 20px）なので伸びた分が全部「学習を始める」の下に溜まっていた
   （実測でブラウザ約200px→PWA約340px）。本人の指定で PWA で開いたときだけ直す。

   仕組み：#screen-dashboard を縦の flex にして min-height:100%（.app は height が
   var(--app-height) で決まる scroll コンテナなので % が効く＝padding を除いた内側の高さ）。
   ::before / ::after を flex-basis 0 の空き箱にして、余りを 4:6 で山分けする
   （幾何学的な真ん中よりやや上＝目には真ん中に見える位置）。
   ・余りが無い（デッキが多い等）ときは grow が 0 で効かず、従来どおり上詰めでスクロール。
   ・中の各セクションは全部 margin-bottom だけで間隔を取っているので、
     flex にしても margin の相殺は起きない＝間隔は不変。
   ・条件の (display-mode: standalone) はブラウザのタブで開くと偽。
     hover/pointer/min-width は他のPC用ブロックと同じ（スマホ・タブレットのPWAは対象外）。 */
/* v1.2.649: 比較のため PC全般に広げた版＝(display-mode: standalone) を条件から外した。
   PWA限定に戻すときは条件に (display-mode: standalone) を足すだけ。
   v1.2.688: 余りの山分け（::before/::after の flex）をやめ、JS（fitDashboardTop）が決めた
   固定の padding-top に変更。山分けだと学習カレンダーの「その日の記録」を開閉するたびに
   中身の高さが変わって上端まで動いていた。padding は「ホームを出したとき・窓サイズ・
   デッキ一覧の描画・月の切り替え」でだけ計算し、パネルの開閉では計算しない＝開くと下へ伸びるだけ。
   条件が外れる幅・環境では JS 側が 0 に戻す。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  #screen-dashboard.active {
    padding-top: var(--dash-top, 0px);
  }
}

/* v1.2.696: 「AIで問題を作る」モーダル。色は --gray-* / --brand-* だけ（ダークで再定義される2系統）。
   .confirm-modal.aigen-modal とクラス2個にして、前方の .confirm-modal { text-align:center } に勝たせる。 */
.confirm-modal.aigen-modal {
  text-align: left;
  max-width: 420px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px 20px;
}
.aigen-modal h3 { text-align: center; margin-bottom: 14px; }
.aigen-theme { margin: 2px 0 8px; }
.aigen-theme input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--gray-100);
  color: var(--gray-800);
  outline: none;
}
.aigen-theme input:focus { border-color: var(--gray-400); }
.aigen-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 10px; }
.aigen-tab {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: transparent;
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.aigen-tab.active { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.aigen-text {
  width: 100%;
  height: 170px;
  box-sizing: border-box;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  font-family: inherit;
  background: var(--gray-100);
  color: var(--gray-800);
  resize: vertical;
  outline: none;
  margin-bottom: 14px;
}
.aigen-services { display: flex; gap: 8px; margin-bottom: 10px; }
.aigen-service {
  flex: 1;
  max-width: 100%;
  display: block;
  box-sizing: border-box;
  text-align: center;
  padding: 14px 4px;
  border-radius: 12px;
  border: none;
  background: var(--brand-500);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(74,158,63,0.3);
  touch-action: manipulation;
  white-space: nowrap;
}
@media (hover: hover) {
  .aigen-service:hover { background: var(--brand-600, var(--brand-500)); }
}
.aigen-service:active { transform: scale(0.98); }
.aigen-proceed { width: 100%; }
.aigen-close { width: 100%; margin-top: 10px; }
.aigen-tabs-inner { display: contents; }
.aigen-tab.aigen-help {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--gray-500);
  border-style: dashed;
}
/* ===== v1.2.865: リスニングの保存ボタンをカード右下のしおりアイコンに =====
   ★このブロックも必ず <style> の末尾に置くこと（上の各画面幅のカード指定に後勝ちさせるため）。
   ・カードの下にあった「保存」バー（.listening-save-bar）を撤去し、クイズと同じ見た目の
     しおり（34px・枠なし・保存済みは琥珀の丸に白）をカード内の右下に置いた。右下なのは親指が届くため。
   ・バーが占めていた高さ（実測：スマホ54px／背の低いスマホ48px／iPadタテ83px／
     iPadヨコ72px／PC82px＝バーの高さ＋下の余白）を、そのままカードの背に足した＝
     再生ボタンなどの操作列は従来の位置のまま。
   ・ボタンの当たり判定は ::after で44px角に広げる（見た目はクイズと同じ34px）。
   ・カードの下側のpaddingを広げ、長い答えがボタンの下に潜らないようにする。 */
.listening-card .listening-card-bookmark {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--gray-400);
  z-index: 2;
}
.listening-card .listening-card-bookmark::after {
  content: '';
  position: absolute;
  inset: -5px;
}
.listening-card .listening-card-bookmark.active {
  background: var(--bookmark);
  color: white;
}
.listening-card .listening-card-bookmark.active svg { stroke: white; }
body.dark-mode .listening-card .listening-card-bookmark { background: transparent; }
body.dark-mode .listening-card .listening-card-bookmark.active { background: var(--bookmark); }
.listening-card { padding-bottom: 48px; }
@media (max-width: 600px) {
  .listening-card {
    flex: 1 1 294px;
    min-height: 294px;
    max-height: 494px;
  }
}
@media (max-width: 600px) and (max-height: 700px) and (pointer: coarse) {
  .listening-card {
    flex: 1 1 288px;
    min-height: 288px;
    max-height: 488px;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .listening-card { height: 423px; min-height: 423px; max-height: 423px; }
}
@media (min-width: 768px) and (max-width: 1023px) and (min-height: 1100px) {
  .listening-card { height: 633px; min-height: 633px; max-height: 633px; }
}
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .listening-card { min-height: 282px; max-height: 497px; }
  /* v1.2.977: 枠が上限（497px）まで伸びてもまだ縦が余るとき（ホーム画面に追加したアプリの窓・全画面など）、
     デッキバーから再生ボタンまでを1つのかたまりとして、ホーム（fitDashboardTop）と同じ 上4：下6 で真ん中に置く。
     上の空きの高さは JS（19-listening.js の fitListeningTop）が測って --lsn-top に入れる。
     余りが出ない窓（ブラウザ）では 0 のまま＝何も変わらない。 */
  #screen-listening.active::before {
    content: '';
    flex: 0 0 var(--lsn-top, 0px);
  }
}
/* 601〜767px（狭めたPCのウィンドウ）はカードが中身の高さなので、下のpaddingで背を足す（36→108px） */
@media (min-width: 601px) and (max-width: 767px) {
  .listening-card { padding-bottom: 108px; }
}
@media (hover: none) and (pointer: coarse) and (min-width: 1024px) {
  .listening-card {
    flex: 1 1 272px;
    min-height: 272px;
    max-height: 452px;
  }
}


/* ===== v1.2.905: ライトモードをネイティブアプリ寄りに（白い地・濃い文字・締まったタブ） =====
   iPad のスプリットビューで標準カレンダーと並べたときの本人の指摘3点への対応。ダークは一切変えない。
   ① 地を白にしたので（:root の --bg）、白いカードが地に溶けないよう --shadow-sm を
      「1pxの外側リング」に置き換える（寸法が変わらない）。md/lg は影のまま。
      自前の枠線を持つ要素と濃い色のピルはリングを付けない（線が二重になるため）。
   ② 統計の数字・カレンダーの日付を --gray-800、ラベル・曜日を --gray-500 に。
   ③ 下部タブ：選ばれていないタブを --gray-600、線の太さ 2→1.7、選択中の1.1倍拡大をやめる。
   元に戻すときはこのブロックを丸ごと消し、--bg 系の5箇所を #F8F9FA に戻す。 */
body:not(.dark-mode) {
  --shadow-sm: 0 0 0 1px var(--gray-200);
}
body:not(.dark-mode) .study-stats-card,
body:not(.dark-mode) .search-bar,
body:not(.dark-mode) .deck-selector-current { box-shadow: none; }
/* v1.2.912: 一覧（.editor-word-list）はスクロールの器で、左と上に余白が無いため、
   カード外側の1pxの線（上の --shadow-sm）が左端と先頭カードの上端で切れていた。
   右は padding-right:4px があるので見えていた。線の分だけ左と上に1px空ける。 */
body:not(.dark-mode) .editor-word-list { padding-left: 1px; padding-top: 1px; }

body:not(.dark-mode) .stat-box .stat-value { color: var(--gray-800); }
body:not(.dark-mode) .stat-box.streak .stat-value { color: var(--bookmark); }
body:not(.dark-mode) .stat-box .stat-label { color: var(--gray-500); }
body:not(.dark-mode) .heatmap-cell .cal-day { color: var(--gray-800); }
body:not(.dark-mode) .heatmap-cell.today .cal-day { color: var(--brand-500); }
body:not(.dark-mode) .heatmap-cell.selected .cal-day { color: #fff; }
body:not(.dark-mode) .cal-dow { color: var(--gray-500); }
body:not(.dark-mode) .cal-dow.sun { color: var(--red-400); }
body:not(.dark-mode) .cal-dow.sat { color: var(--blue-400); }
body:not(.dark-mode) .cal-dow.selected,
body:not(.dark-mode) .cal-dow.sun.selected,
body:not(.dark-mode) .cal-dow.sat.selected { color: #fff; }

/* 下部タブはスマホ・タブレットの下のナビだけ。PCの左サイドバー（同じ .bottom-nav-item）は対象外。 */
@media not screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  body:not(.dark-mode) .bottom-nav-item .nav-icon,
  body:not(.dark-mode) .bottom-nav-item .nav-label { color: var(--gray-600); }
  body:not(.dark-mode) .bottom-nav-item.active .nav-icon,
  body:not(.dark-mode) .bottom-nav-item.active .nav-label { color: var(--gray-900); } /* v1.2.911: 選択中は緑→黒（v1.2.908 と同じ） */
  body:not(.dark-mode) .bottom-nav-item .nav-icon .nav-svg-line { stroke-width: 1.7; }
  /* v1.2.910: 選択中は中まで塗ったアイコンに差し替え（v1.2.911 で色を黒に。iOS標準のタブと同じ見せ方） */
  body:not(.dark-mode) .bottom-nav-item.active .nav-icon .nav-svg-line { display: none; }
  body:not(.dark-mode) .bottom-nav-item.active .nav-icon .nav-svg-fill { display: inline; }
  body:not(.dark-mode) .bottom-nav-item.active .nav-icon { transform: none; }
}


/* ===== v1.2.913: スマホ・タブレットの「設定」タブ =====
   左上の☰（ドロワー）をやめ、下部タブの4つ目に「設定」を置く。中身は
   js/11-pc-sidebar.js が #settingsScreenHost へ移動させる。PCは従来どおりサイドバー。 */
#screen-settings { padding-bottom: 16px; }
.settings-screen-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin: 4px 4px 14px;
}
.settings-screen-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 16px;
}
body.dark-mode .settings-screen-card { background: #1e1a28; }
.settings-screen-card .settings-menu-list { padding: 4px 0; }
.settings-screen-card .settings-menu-item { padding: 13px 16px; font-size: 15px; }
.settings-screen-card .settings-menu-divider { margin: 4px 0; }
.settings-screen-pwa { display: none; }
.settings-screen-pwa.is-shown { display: block; }
#settingsScreenFooterHost .settings-panel-footer { border-top: none; padding-top: 4px; }

/* スマホ・タブレット：ホームの☰と「ホーム画面に追加」ボタンを見えなくする。
   v1.2.914: 上の帯の場所（高さ40px＋下8px）は詰めずに空けたまま残す（本人の指示。
   ここのデザインは後で考える）。visibility:hidden なので押すこともできない。 */
@media not screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  #screen-dashboard .dashboard-top-bar > * { visibility: hidden; pointer-events: none; }
}
/* v1.2.915: PCもホーム上部の丸ボタン（ホーム画面に追加）をサイドバーへ移した。
   上の帯の場所はスマホと同じく空けたまま残す（高さ40px。デザインは後で考える）。 */
#screen-dashboard .dashboard-top-bar { min-height: 40px; }
#screen-dashboard .dashboard-top-bar > * { visibility: hidden; pointer-events: none; }
/* サイドバーの「ホーム画面に追加」はPCでインストール前だけ出す */
.pc-pwa-menu-item.pc-pwa-menu-item { display: none; }
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .pc-pwa-menu-item.is-shown.is-shown { display: flex; }
}
/* PC：「設定」タブは出さない（サイドバーに中身がある） */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  #navSettings { display: none; }
}

/* ===== v1.2.917: リスニングのカードで、問題＋答えのかたまりをカードに収めて真ん中寄せ =====
   枠の高さ・文字サイズは JS（setListeningCenterLayout）が px で決める。ここは枠の中の寄せ方だけ。
   問題は自分の枠の下寄せ、答えは上寄せ＝2つがくっついたまま、余りが上4：下6 に分かれる
   （スマホは v1.2.381 で既に同じ寄せ方。PC・タブレットもこれに揃える）。
   safe flex-end の理由は v1.2.381 と同じ（はみ出したときに上へスクロールで戻れるように）。 */
.listening-card.lsn-center { justify-content: flex-start; }
.listening-card.lsn-center .listening-question {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  justify-content: safe flex-end;
  min-height: 0;
}
.listening-card.lsn-center .listening-answer {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
}

/* ===== v1.2.929: PCの一覧（編集）画面だけ、列を480px→600pxに広げる =====
   v1.2.930: 本人の「横と縦をもっと大きく」で 600→720px。行も大きくした（文字20px等）が、
   v1.2.931 で縦（行の大きさ）だけ取り消し＝幅720pxだけ残す。
   ★このブロックも必ず app.css の末尾側に置くこと（他のPC用ブロックと同じカスケードの理由）。
   ・中身の配置は変えない（問題｜答えは行の真ん中で左右半分ずつ、メモはその下＝
     「メモを表示」の既存トグルどおり）。.app ごと広げるので、検索バー・デッキバー・
     絞り込み行・行の一覧が同じ幅にそろう（リスニングで幅がずれて嫌だった件と同じ理由）。
     一括操作バー(#bulkToolbar)はもともと全幅なので触らない。
   ・幅は min(600px, 100% − 520px) を 480px で下支え。520px＝左のサイドバー 240px＋
     余白 20px の左右分。列はビューポートの中央なので、レイアウト上の幅が1120px未満だと
     600pxではサイドバーに食い込む＝そのときだけ自動で狭める（今のPCズームの段
     ＝1024〜1399px は0.8倍で1280px以上になるので、実際には効かない保険）。本人の2台
     （1280px×0.8倍＝1600px／1920px×1.1倍≈1745px）はどちらも600px。
   ・条件はサイドバーと同じ (hover:hover) and (pointer:fine) and (min-width:1024px)。
     スマホ・タブレットは変更なし。
   ・戻すとき：このブロックを消すだけ。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  body:has(#screen-word-editor.active) .app {
    max-width: max(480px, min(720px, calc(100% - 520px)));
  }
}

/* ===== v1.2.938: 一覧の行の中のレイアウト（全端末） =====
 v1.2.933〜935 で PC だけに入れた「縦横とも真ん中寄せ」を、本人の判断でスマホ・タブレットにも
 広げた（上の @media から外に出しただけで、中身は同じ）。文字・余白・画像の大きさは端末ごとの
 既存の値のまま（タブレット用ブロックの22px等もそのまま効く）。
 ★このブロックも app.css の末尾側に置くこと（.ew-jpn の text-align:right 等の元の指定に後勝ちさせる）。 */
/* v1.2.933: 問題・答えとも、それぞれの半分の中で真ん中寄せ（v1.2.932 の左寄せから本人の指示で変更）。
   画像も同じくそれぞれの半分の真ん中へ（.ew-thumbs を左右半分ずつのグリッドに。
   ±13px は文字側の padding-right / padding-left と同じ＝真ん中の線からの間隔をそろえる）。
   line-height は問題（.ew-eng の 1.4）にそろえる（答えだけ1〜2px下にずれていたため）。
   メモ（.ew-note）は文章なので左寄せのまま。 */
.editor-word-item .ew-eng,
.editor-word-item .ew-jpn { text-align: center; }
/* v1.2.934: 2行以上になると最後の行だけが真ん中に来て、ほかの行とずれていた。
   文字を .ew-txt（v1.2.934 で追加した span）で包み、その塊を inline-block にして
   真ん中に置き、塊の中は左寄せにする＝1行なら真ん中、2行以上なら行頭がそろう。 */
/* v1.2.941: 2行以上でも各行を真ん中寄せに（本人の指示。v1.2.934〜940 の「塊は真ん中・中は左寄せ」は
   取り消し）。各行が真ん中に並ぶので、折り返しの余りで左に寄って見える問題も起きない
   （v1.2.940 の幅を測る JS は不要になったので削除）。 */
.editor-word-item .ew-txt {
  display: inline-block;
  max-width: 100%;
  text-align: center;
  vertical-align: top;
}
/* v1.2.935: 縦も真ん中に。片方が長くて行が縦に伸びたとき、短い側の文字が上に寄って
   見えていた。行の中の問題・答えの箱を常に行の高さいっぱいに伸ばし（stretch＝赤シート中の
   .hiding と同じ）、箱の中で .ew-txt を縦横とも真ん中に置く。
   ★.ew-eng / .ew-jpn の中身は .ew-txt 1つだけなので flex にしても崩れない
     （赤シートの ::before / ::after は position:absolute なので flex の並びに入らない）。 */
.editor-word-item .ew-text-row { align-items: stretch; }
.editor-word-item .ew-eng,
.editor-word-item .ew-jpn {
  display: flex;
  align-items: center;
  justify-content: center;
}
.editor-word-item .ew-txt { min-width: 0; }
.editor-word-item .ew-jpn { line-height: 1.4; }
.editor-word-item .ew-thumbs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}
.editor-word-item .ew-thumb-q { grid-column: 1; justify-self: center; margin-left: 0; margin-right: 16px; }
.editor-word-item .ew-thumb-a { grid-column: 2; justify-self: center; margin-left: 16px; }
/* v1.2.939: 真ん中寄せが見た目の真ん中から約1.5pxずれていた（答えは左、問題は右＝どちらも
   真ん中の線の側へ）。行の外側の余白（.ew-inner の左右 padding）が16pxなのに、線の側の余白が
   13pxしかなく、箱の中で真ん中に置いても見た目の半分の真ん中にならなかったため。
   線の側も16pxにそろえる（画像の±16pxも同じ理由）。赤シートの灰色の帯（::before の 13px）は
   箱の外形に対する位置なので変わらない。
   ★.ew-inner の左右 padding（16px）を変えたら、ここの3か所も同じ値にそろえること。
     タブレット用ブロックは .ew-inner が 22px なので、そちらは下の @media で 22px にしている。 */
/* v1.2.942: メモ（.ew-note）も真ん中寄せに（本人の指示。v1.2.938 では文章なので左寄せのままにしていた）。 */
.editor-word-item .ew-note { text-align: center; }
.editor-word-item .ew-eng { padding-right: 16px; }
.editor-word-item .ew-jpn { padding-left: 16px; }
@media (hover: none) and (pointer: coarse) and (min-width: 768px) and (max-width: 1023px) {
  .editor-word-item .ew-eng { padding-right: 22px; }
  .editor-word-item .ew-jpn { padding-left: 22px; }
  .editor-word-item .ew-thumb-q { margin-right: 22px; }
  .editor-word-item .ew-thumb-a { margin-left: 22px; }
}

@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  /* v1.2.943: PCだけ、枠の大きさは変えずに中の文字を大きく（本人の指示）。
     問題・答え 16px→18px、メモ 12px→14px（v1.2.945 で 19px / 15px にしたが v1.2.946 で戻した）。行の高さは「1行の高さ × 行数＋上下 padding」で
     決まるので、1行の高さを今と同じ値（問題・答え＝16px×1.4＝22.4px、メモ＝12px×1.5＝18px）に
     px で固定して、文字だけ大きくする＝1行の行は枠の高さが1pxも変わらない。
     ★全端末用の v1.2.938 ブロック（.ew-jpn の line-height:1.4）より後ろに置くこと。
     ★2行以上になる行は、文字が大きくなったぶん折り返しが増えることがある（そのときだけ背が伸びる）。 */
  .editor-word-item .ew-eng,
  .editor-word-item .ew-jpn { font-size: 18px; line-height: 22.4px; }
  .editor-word-item .ew-note { font-size: 14px; line-height: 18px; }
}

/* v1.2.944: スマホも PC（v1.2.943）と同じく、枠の大きさは変えずに文字だけ大きく（本人の指示）。
   条件はタッチ環境で幅767px以下＝スマホ（タブレットの768〜1023pxは専用ブロックの22pxのまま）。
   中身は上の PC 用と同じ値。★全端末用の v1.2.938 ブロックより後ろに置くこと。 */
@media (pointer: coarse) and (max-width: 767px) {
  .editor-word-item .ew-eng,
  .editor-word-item .ew-jpn { font-size: 18px; line-height: 22.4px; }
  .editor-word-item .ew-note { font-size: 14px; line-height: 18px; }
}

/* v1.2.947: 一覧をエクセルの表のような囲み方に（全端末・ライト／ダーク共通）。
   角の丸み（--radius-sm 10px）と行の間のすき間（gap 8px）をやめ、各行を1pxの線で囲む。
   隣り合う行は margin-top:-1px で線を重ね、境目が2本（2px）にならないようにする。
   線を box-shadow ではなく border で描くので、v1.2.912 の「線が切れないように左と上に1px空ける」は不要＝0に戻す。
   元に戻すときはこのブロックを丸ごと消す。 */
.editor-word-list { gap: 0; }
.editor-word-item {
  border-radius: 0;
  box-shadow: none;
  border: 1px solid var(--gray-200);
}
/* v1.2.952: 境目は margin-top:-1px で線を重ねる方式をやめ、2行目以降の上の線を消す方式に。
   PC は画面全体を zoom で縮小しているため、-1px の重なりが端数で丸められると、下の行の上の線が
   上の行の .ew-inner（z-index:1 の白い地）の下に潜って、ところどころ区切り線が消えていた。
   重ねなければ各線はどちらか1行の持ち物になり、白い地に隠れない。 */
.editor-word-item + .editor-word-item { border-top: none; }
body:not(.dark-mode) .editor-word-list { padding-left: 0; padding-top: 0; }

/* v1.2.948〜950: スマホ・タブレット（タッチ端末）では一覧の表を列の左右いっぱいまで広げる（v1.2.950 でタブレットにも適用）。
   ★#screen-word-editor が overflow:hidden なので、リストに負のマージンを付けても切り取られる（v1.2.948 で効かなかった原因）。
   画面そのものを .app の左右 padding（16px＋セーフエリア）の分だけ外へ広げ、ヘッダーにだけ同じ分の padding を戻す。
   画面の端に当たる左右の縦線は消し、行の中の文字の余白（.ew-inner の 16px）はそのまま。PC は従来どおり。 */
@media (hover: none) and (pointer: coarse) {
  #screen-word-editor {
    margin-left: calc(-16px - env(safe-area-inset-left));
    margin-right: calc(-16px - env(safe-area-inset-right));
  }
  #screen-word-editor .editor-header {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  .editor-word-list { padding-right: 0; }
  .editor-word-item { border-left: none; border-right: none; }
}

/* v1.2.951: タブレットでは一覧の画面だけ、中央の列（タテ700px／ヨコ480px）の幅の制限を外して画面いっぱいに使う
   （本人の指示。でた単のように縦向き・横向きとも左右の余白なし）。検索欄・デッキバーも画面幅いっぱいになる。
   ヨコ向きは今まで480pxの列で文字16pxだったので、幅に合わせてタテと同じ大きさ（文字22px・余白26/22px・メモ15px・画像130px）にそろえる。
   条件の (hover:none) and (pointer:coarse) で PC は外れる。スマホは幅767px以下なので外れる。 */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) {
  body:has(#screen-word-editor.active) .app { max-width: none; }
}
@media (hover: none) and (pointer: coarse) and (min-width: 1024px) {
  .editor-word-item .ew-inner { padding: 26px 22px; }
  .editor-word-item .ew-content::after { top: -26px; bottom: -26px; }
  .editor-word-item .ew-eng,
  .editor-word-item .ew-jpn { font-size: 22px; }
  .editor-word-item .ew-note { font-size: 15px; margin-bottom: -26px; padding-bottom: 26px; }
  .editor-word-item .ew-thumb { height: 130px; }
  .editor-word-item .ew-eng { padding-right: 22px; }
  .editor-word-item .ew-jpn { padding-left: 22px; }
  .editor-word-item .ew-thumb-q { margin-right: 22px; }
  .editor-word-item .ew-thumb-a { margin-left: 22px; }
}

/* v1.2.953: 問題・答えとメモを分ける横線（.ew-note の border-top）を行の左右の端まで伸ばす。
   今までは .ew-inner の左右 padding（16px、タブレットは22px）の内側で止まっていたので、
   その分を負のマージンで外へ広げ、文字の位置は同じ値の padding で元に戻す。
   ★.ew-inner の左右 padding を変えたら、ここも同じ値にそろえること。 */
.editor-word-item .ew-note {
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
}
@media (hover: none) and (pointer: coarse) and (min-width: 768px) {
  .editor-word-item .ew-note {
    margin-left: -22px;
    margin-right: -22px;
    padding-left: 22px;
    padding-right: 22px;
  }
}

/* ===== v1.2.961: リスニングの並び替え＋スマホ・タブレットで枠を画面の左右いっぱいに =====
   ① 「n / N」とシークバーを枠の上→再生ボタンの上へ（HTMLの並びを変更、全端末）。
      枠との間は .listening-card の margin-bottom 10px＋ここの margin-top。
      シークバーの下の余白（再生ボタンとの間）は少し詰めて、全体の高さが増えないようにする。
   ② タッチ端末（スマホ・タブレット）は一覧（v1.2.949〜951）と同じく、画面を .app の左右 padding
      （16px＋セーフエリア）の分だけ外へ広げ、デッキバーと絞り込み行にだけ同じ分の余白を戻す。
      枠はプレイヤーの左右 padding（--lsn-pad）の分も外へはみ出させて画面の端から端まで。
      端で切れて見えないよう角は四角・影なし、上下だけ一覧の表と同じ1pxの線。PCは従来どおり。
   ★元に戻すときはこのブロックを丸ごと消し、index.html の並びを戻す。 */
.listening-progress { margin-top: 8px; }
.listening-seekbar { margin-bottom: 12px; }
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .listening-seekbar { margin-bottom: 14px; }
}
@media (max-height: 700px) and (pointer: coarse) {
  .listening-progress { margin-top: 4px; }
  .listening-seekbar { margin-bottom: 6px; }
}
@media (hover: none) and (pointer: coarse) {
  #screen-listening {
    margin-left: calc(-16px - env(safe-area-inset-left));
    margin-right: calc(-16px - env(safe-area-inset-right));
  }
  #screen-listening > .deck-selector,
  #screen-listening > .list-filter-bar {
    margin-left: calc(16px + env(safe-area-inset-left));
    margin-right: calc(16px + env(safe-area-inset-right));
  }
  /* シークバー・再生ボタンの左右の位置は今までどおり（.app の余白＋プレイヤーの16px）。 */
  .listening-player {
    --lsn-pl: calc(32px + env(safe-area-inset-left));
    --lsn-pr: calc(32px + env(safe-area-inset-right));
    padding-left: var(--lsn-pl);
    padding-right: var(--lsn-pr);
  }
  .listening-card {
    width: calc(100% + var(--lsn-pl) + var(--lsn-pr));
    max-width: none;
    margin-left: calc(var(--lsn-pl) * -1);
    margin-right: calc(var(--lsn-pr) * -1);
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
  }
}
/* タブレットは一覧（v1.2.951）と同じく、リスニングの画面だけ中央の列（タテ700px／ヨコ480px）の幅の制限を外す。 */
@media (hover: none) and (pointer: coarse) and (min-width: 768px) {
  body:has(#screen-listening.active) .app { max-width: none; }
}

/* ===== v1.2.962: リスニングの問題・答えの文字を一回り大きく（本人の指示、全端末で約2割増し） =====
   ここが JS（setListeningCenterLayout）の基準サイズになる。長くて収まらないときは従来どおり JS が縮める。
   スマホ 20/18→24/21px、タブレット（タテ）30/26→34/30px、タブレット（ヨコ）20/18→30/26px（v1.2.961 で枠が画面幅になったため）、PC 24/21→28/25px。
   「タップで答えを表示」（.is-hint）は詳細度が高いので 13px のまま。元に戻すときはこのブロックを消す。 */
.listening-question { font-size: 24px; }
.listening-answer { font-size: 21px; }
@media (min-width: 768px) and (max-width: 1023px) {
  .listening-question { font-size: 34px; }
  .listening-answer { font-size: 30px; }
}
@media (hover: none) and (pointer: coarse) and (min-width: 1024px) {
  .listening-question { font-size: 30px; letter-spacing: -0.02em; }
  .listening-answer { font-size: 26px; letter-spacing: -0.02em; }
}
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  .listening-question { font-size: 28px; }
  .listening-answer { font-size: 25px; }
}

/* ===== v1.2.969: リスニングの操作まわりを Amazon Music 風に（本人の指示、スマホ・タブレット・PC共通） =====
   ① 再生ボタン：塗りつぶしをやめ、地に色をうっすら重ねた丸＋くっきりした三角。
      ダーク＝白15%の丸＋白い三角／ライト＝黒7%の丸＋黒い三角。影なし。押した瞬間は重ねる色を少し濃く。
      （v1.2.963〜968 の黒丸・白丸・#8b8597 はこれで置き換え）
   ② 再生位置のバー（#listeningSeekbar だけ。速度スライダーは従来どおり）：線を6→3px、つまみを18→14pxにして白／黒に。
      線の塗り色は JS の updateSeekbarFill が決める（つまみの大きさを変えたらそちらの thumbHalf も合わせる）。
   ③ アイコンの強弱：前へ・次へは濃く（ダーク白／ライト黒に近い）、タイマー・設定は薄く沈める。
   元に戻すときはこのブロックを消し、19-listening.js の updateSeekbarFill の isSeek 分岐も戻す。 */
/* ① 再生ボタン */
.listening-ctrl-btn.play { background: rgba(0,0,0,0.07); color: #111; box-shadow: none; }
.listening-ctrl-btn.play:active { background: rgba(0,0,0,0.13); }
body.dark-mode .listening-ctrl-btn.play { background: rgba(255,255,255,0.15); color: #fff; }
body.dark-mode .listening-ctrl-btn.play:active { background: rgba(255,255,255,0.24); }
/* ② 再生位置のバー */
#listeningSeekbar { height: 3px; border-radius: 2px; }
#listeningSeekbar::-webkit-slider-thumb {
  width: 14px; height: 14px;
  background: #3a3a42;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
#listeningSeekbar::-moz-range-thumb {
  width: 14px; height: 14px;
  background: #3a3a42;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
#listeningSeekbar::-moz-range-track { height: 3px; }
body.dark-mode #listeningSeekbar::-webkit-slider-thumb { background: #fff; }
body.dark-mode #listeningSeekbar::-moz-range-thumb { background: #fff; }
/* ③ アイコンの強弱（前へ・次へ＝濃く／タイマー・設定＝薄く） */
.listening-controls .listening-ctrl-btn:not(.play) { color: #1f1f24; }
#listeningTimerBtn,
.listening-controls .listening-ctrl-btn[onclick^="toggleListeningSettings"] { color: var(--gray-400); }
body.dark-mode .listening-controls .listening-ctrl-btn:not(.play) { color: #fff; }
body.dark-mode #listeningTimerBtn,
body.dark-mode .listening-controls .listening-ctrl-btn[onclick^="toggleListeningSettings"] { color: rgba(255,255,255,0.45); }

/* ===== v1.2.970: PCのリスニングの列幅を一覧（v1.2.929〜931）と同じに =====
   一覧と同じ式（最大720px、サイドバーに食い込む幅では自動で狭める）。デッキバー・絞り込み行・問題枠・
   シークバーが同じ幅で広がる（シークバーと問題枠の幅を揃える指定は v1.2.591 ブロックのまま効く）。
   元に戻すときはこのブロックを消す。 */
@media screen and (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  body:has(#screen-listening.active) .app {
    max-width: max(480px, min(720px, calc(100% - 520px)));
  }
}

/* v1.2.971→972: リスニングの問題枠の角。PCは「四角すぎる」ので 4px だけ丸める（本人の指示）。
   スマホ・タブレットは画面の端まで届く枠なので v1.2.961 のまま角0。 */
.listening-card { border-radius: 4px; }
@media (hover: none) and (pointer: coarse) {
  .listening-card { border-radius: 0; }
}
