/* =========================================================
   英単語アプリ - style.css
   モバイル最適化 / ダークモード自動 / prefers-reduced-motion 対応
   （Starllite のデザイントークンを踏襲）
   ========================================================= */

/* ---------- CSS 変数（テーマ） ---------- */
:root {
  --bg-page: #f4f5f9;
  --bg-card: #ffffff;
  --bg-header: linear-gradient(135deg, #1a1a2e 0%, #2d2d5f 100%);
  --bg-input: #ffffff;
  --bg-soft: #f0f2f8;

  --fg-primary: #1f2933;
  --fg-secondary: #5a6473;
  --fg-muted: #8a96a5;
  --fg-on-header: #ffffff;
  --fg-on-header-sub: rgba(255, 255, 255, 0.85);
  --fg-link: #4a6cf7;

  --accent: #4a6cf7;
  --accent-hover: #3a5bd9;
  --highlight: #ff9500;   /* 例文中の強調語（オレンジ） */

  --border-soft: #e3e6ec;
  --border-input: #cfd4dc;
  --border-focus: #4a6cf7;

  --shadow-card: 0 1px 3px rgba(20, 30, 50, 0.08);
  --shadow-card-hover: 0 6px 18px rgba(20, 30, 50, 0.14);
  --shadow-header: 0 2px 12px rgba(26, 26, 46, 0.25);

  --status-new:      #a0a4ab;  /* 未習得（グレー） */
  --status-review:   #ff9500;  /* 要復習（オレンジ） */
  --status-mastered: #34c759;  /* 習得済（グリーン） */
  --status-correct:  #34c759;
  --status-wrong:    #ff3b30;

  --radius-card: 14px;
  --radius-input: 10px;
  --radius-pill: 999px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  --tap-min: 44px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ---------- ダークモード ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #14141e;
    --bg-card: #1f2030;
    --bg-header: linear-gradient(135deg, #0e0e1c 0%, #1f1f4a 100%);
    --bg-input: #1f2030;
    --bg-soft: #262838;

    --fg-primary: #e8eaf0;
    --fg-secondary: #b4bac6;
    --fg-muted: #828892;

    --border-soft: #2c2e3f;
    --border-input: #3a3d52;

    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-card-hover: 0 6px 18px rgba(0, 0, 0, 0.5);

    --fg-link: #7c95ff;
    --accent: #7c95ff;
    --accent-hover: #97acff;
  }
}

/* ---------- リセット ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--fg-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
               "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

body { display: flex; flex-direction: column; }

button, input, select { font: inherit; color: inherit; }

/* スクリーンリーダー専用 */
.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus {
  position: fixed; left: var(--space-md); top: var(--space-md);
  width: auto; height: auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--accent); color: #fff;
  border-radius: var(--radius-input); z-index: 1000;
}

/* ---------- ヘッダー ---------- */
.site-header {
  background: var(--bg-header);
  color: var(--fg-on-header);
  box-shadow: var(--shadow-header);
  padding-top: calc(var(--space-lg) + var(--safe-top));
  padding-bottom: var(--space-lg);
  padding-left: calc(var(--space-lg) + var(--safe-left));
  padding-right: calc(var(--space-lg) + var(--safe-right));
}
.site-header-inner { max-width: 720px; margin: 0 auto; text-align: center; }
.site-title {
  margin: 0 0 var(--space-xs);
  font-size: 1.5rem; font-weight: 700; letter-spacing: 0.02em;
  display: inline-flex; align-items: center; gap: var(--space-sm);
}
.site-subtitle {
  margin: 0; font-size: 0.95rem; color: var(--fg-on-header-sub);
}

/* ---------- メイン ---------- */
.site-main {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: var(--space-lg);
  padding-left: calc(var(--space-lg) + var(--safe-left));
  padding-right: calc(var(--space-lg) + var(--safe-right));
}

.screen[hidden] { display: none; }

/* ---------- 共通ボタン ---------- */
.btn-primary {
  min-height: var(--tap-min);
  padding: 10px 18px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-input);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }

.btn-ghost {
  min-height: var(--tap-min);
  padding: 8px 14px;
  background: transparent; color: var(--fg-link);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color 0.15s ease;
}
.btn-ghost:hover { background: rgba(128, 128, 128, 0.1); }
.btn-ghost:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }

/* ---------- ホーム: デッキ一覧 ---------- */
.decks { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 600px) { .decks { grid-template-columns: repeat(2, 1fr); } }

.deck-card {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  text-align: center;
}
.deck-card-my { border-left: 4px solid var(--accent); }

/* ドーナツリング */
.donut {
  position: relative;
  width: 120px; height: 120px;
  flex-shrink: 0;
}
.donut-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-bg {
  fill: none; stroke: var(--bg-soft); stroke-width: 10;
}
.donut-fg {
  fill: none; stroke: var(--status-mastered); stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-percent { font-size: 1.6rem; font-weight: 800; color: var(--fg-primary); line-height: 1; }
.donut-label { font-size: 0.75rem; color: var(--fg-muted); margin-top: 2px; }

.deck-info { width: 100%; }
.deck-name { margin: 0 0 var(--space-xs); font-size: 1.15rem; font-weight: 700; color: var(--fg-primary); }
.deck-stats { margin: 0 0 2px; font-size: 0.85rem; color: var(--fg-secondary); }
.deck-total { margin: 0; font-size: 0.78rem; color: var(--fg-muted); }

.deck-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
  justify-content: center; width: 100%;
}
.deck-empty-note { font-size: 0.85rem; color: var(--fg-muted); padding: 10px 0; }

/* ---------- 学習バー（上部） ---------- */
.study-bar {
  display: flex; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.study-bar-spacer { flex: 1; }
.study-progress { flex: 1; text-align: center; font-weight: 700; color: var(--fg-secondary); }
.quiz-score { font-weight: 700; color: var(--accent); white-space: nowrap; }

/* ---------- フラッシュカード: 面切替タブ ---------- */
.face-tabs {
  display: flex; gap: var(--space-xs);
  margin-bottom: var(--space-md);
  background: var(--bg-soft);
  padding: 4px; border-radius: var(--radius-input);
}
.face-tab {
  flex: 1; min-height: 40px;
  padding: 8px 4px;
  background: transparent; color: var(--fg-secondary);
  border: none; border-radius: 8px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.face-tab.is-active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-card); }
.face-tab:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }

/* カード本体 */
.flashcard {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-xl);
  margin-bottom: var(--space-md);
}
.flashcard-inner { width: 100%; text-align: center; }

.fc-word { margin: 0 0 var(--space-sm); font-size: 2rem; font-weight: 800; color: var(--fg-primary); word-break: break-word; }
.fc-meta { margin: 0 0 var(--space-md); font-size: 1rem; color: var(--fg-secondary); }
.fc-meaning { margin: 0; font-size: 1.2rem; color: var(--fg-primary); }
.fc-meaning-big { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--fg-primary); }
.fc-example-en { margin: 0; font-size: 1.5rem; font-weight: 600; color: var(--fg-primary); line-height: 1.5; word-break: break-word; }
.fc-example-ja { margin: 0; font-size: 1.4rem; color: var(--fg-primary); line-height: 1.6; }

/* 例文の強調語（オレンジ） */
mark.hl {
  background: transparent;
  color: var(--highlight);
  font-weight: 800;
}

/* フラッシュカードのツール（解説・読み上げ） */
.flash-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.btn-tool {
  min-height: var(--tap-min);
  padding: 8px 14px;
  background: var(--bg-card); color: var(--fg-primary);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-tool:hover { background: var(--bg-soft); }
.btn-tool:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.btn-tool[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.speak-group { display: inline-flex; align-items: center; gap: var(--space-sm); }
.speak-group[hidden] { display: none; }
.speak-rate-label { font-size: 0.85rem; color: var(--fg-secondary); }
.speak-rate {
  min-height: var(--tap-min);
  padding: 6px 10px;
  background: var(--bg-input); color: var(--fg-primary);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
  cursor: pointer; -webkit-appearance: none; appearance: none;
}
.speak-rate:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }

/* 解説ボックス */
.explain-box {
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  font-size: 0.95rem; color: var(--fg-primary); line-height: 1.6;
}
.explain-box[hidden] { display: none; }

/* わかる / わからない */
.judge-bar { display: flex; gap: var(--space-md); }
.btn-judge {
  flex: 1; min-height: 56px;
  border: none; border-radius: var(--radius-input);
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn-judge:active { transform: translateY(1px); }
.btn-judge:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.btn-judge-no  { background: rgba(255, 59, 48, 0.12); color: var(--status-wrong); }
.btn-judge-yes { background: rgba(52, 199, 89, 0.14); color: #1c8f43; }
.btn-judge-no:hover  { filter: brightness(0.96); }
.btn-judge-yes:hover { filter: brightness(0.96); }
@media (prefers-color-scheme: dark) {
  .btn-judge-yes { color: var(--status-mastered); }
}

/* ---------- 4択クイズ ---------- */
.quiz-direction { margin: 0 0 var(--space-sm); font-size: 0.9rem; color: var(--fg-secondary); text-align: center; }
.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  min-height: 110px;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  font-size: 1.6rem; font-weight: 700; text-align: center;
  color: var(--fg-primary); word-break: break-word;
}
.quiz-choices { display: grid; grid-template-columns: 1fr; gap: var(--space-sm); }
.quiz-choice {
  min-height: var(--tap-min);
  padding: 12px 16px;
  background: var(--bg-card); color: var(--fg-primary);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
  font-size: 1rem; font-weight: 600; cursor: pointer; text-align: left;
  -webkit-appearance: none; appearance: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.quiz-choice:hover { background: var(--bg-soft); }
.quiz-choice:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.quiz-choice:disabled { cursor: default; }
.quiz-choice.is-correct {
  background: rgba(52, 199, 89, 0.16);
  border-color: var(--status-correct);
  color: #1c8f43;
}
.quiz-choice.is-wrong {
  background: rgba(255, 59, 48, 0.14);
  border-color: var(--status-wrong);
  color: var(--status-wrong);
}
@media (prefers-color-scheme: dark) {
  .quiz-choice.is-correct { color: var(--status-mastered); }
}

.quiz-next-wrap { margin-top: var(--space-lg); text-align: center; }
.quiz-next-wrap[hidden] { display: none; }

/* ---------- 結果画面 ---------- */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-xl);
  text-align: center;
  margin-top: var(--space-xl);
}
.result-title { margin: 0 0 var(--space-md); font-size: 1.4rem; font-weight: 800; }
.result-body { margin: 0 0 var(--space-xl); font-size: 1.1rem; color: var(--fg-secondary); }
.result-actions { display: flex; justify-content: center; }

/* ---------- MY単語帳 編集 ---------- */
.my-edit-hint {
  margin: 0 0 var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-soft);
  border-radius: var(--radius-input);
  font-size: 0.88rem; color: var(--fg-secondary); line-height: 1.6;
}
.my-edit-search { margin: 0 0 var(--space-sm); }
.my-search-input {
  width: 100%; box-sizing: border-box;
  padding: 10px var(--space-md);
  font-size: 0.95rem;
  background: var(--bg-input); color: var(--fg-primary);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
}
.my-search-input:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 1px; }
.my-edit-notice { margin: 0 0 var(--space-sm); font-size: 0.8rem; color: var(--fg-muted); }
.my-edit-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.my-row {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
}
.my-star {
  flex-shrink: 0;
  width: var(--tap-min); height: var(--tap-min);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1;
  background: transparent; color: var(--fg-muted);
  border: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.my-star.is-on { color: var(--status-review); }
.my-star:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; border-radius: var(--radius-input); }
.my-row-text { display: flex; flex-direction: column; min-width: 0; }
.my-row-word { font-size: 1.05rem; font-weight: 700; color: var(--fg-primary); }
.my-row-meaning { font-size: 0.85rem; color: var(--fg-secondary); }

/* ---------- モード選択モーダル ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 24, 0.55); z-index: 1000; }
.modal {
  position: fixed; inset: 0; z-index: 1001;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-lg);
  padding-top: calc(var(--space-lg) + var(--safe-top));
  padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
}
.modal[hidden], .modal-backdrop[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 420px; max-height: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-card); color: var(--fg-primary);
  border: 1px solid var(--border-soft); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-hover);
  animation: modal-pop 0.18s ease;
}
@keyframes modal-pop {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.modal-header {
  display: flex; align-items: flex-start; gap: var(--space-sm);
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
}
.modal-title { flex: 1; margin: 0; font-size: 1.15rem; font-weight: 700; }
.modal-close {
  flex-shrink: 0; width: var(--tap-min); height: var(--tap-min);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-input); color: var(--fg-secondary);
  cursor: pointer; -webkit-appearance: none; appearance: none;
}
.modal-close:hover { background: rgba(128, 128, 128, 0.12); }
.modal-close:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.modal-body { padding: 0 var(--space-lg) var(--space-lg); }
.modal-deck-name { margin: 0 0 var(--space-lg); font-weight: 700; color: var(--fg-secondary); text-align: center; }

.mode-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.mode-choices[hidden] { display: none !important; }
.mode-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: var(--space-lg) var(--space-md);
  background: var(--bg-soft); color: var(--fg-primary);
  border: 1px solid var(--border-soft); border-radius: var(--radius-card);
  cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.mode-choice:hover { border-color: var(--accent); }
.mode-choice:active { transform: translateY(1px); }
.mode-choice:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.mode-choice-icon { font-size: 2rem; line-height: 1; }
.mode-choice-label { font-size: 1rem; font-weight: 700; }
.mode-choice-desc { font-size: 0.75rem; color: var(--fg-muted); text-align: center; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--space-xl) + var(--safe-bottom));
  transform: translateX(-50%) translateY(8px);
  max-width: 88%;
  padding: 10px 18px;
  background: rgba(20, 22, 34, 0.94); color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.9rem; font-weight: 600;
  box-shadow: var(--shadow-card-hover);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast[hidden] { display: none; }
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- フッター ---------- */
.site-footer {
  margin-top: auto;
  padding: var(--space-lg);
  padding-left: calc(var(--space-lg) + var(--safe-left));
  padding-right: calc(var(--space-lg) + var(--safe-right));
  padding-bottom: calc(var(--space-lg) + var(--safe-bottom));
}
.footer-note {
  max-width: 720px; margin: 0 auto;
  font-size: 0.75rem; color: var(--fg-muted);
  text-align: center; line-height: 1.55;
}
.backup-controls {
  display: flex; gap: var(--space-sm);
  justify-content: center; flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}
.backup-btn { font-size: 0.85rem; padding: 6px 14px; }

/* 今日の学習語数（SRS 復習キュー） */
.deck-today {
  margin: 0 0 2px;
  font-size: 0.85rem; font-weight: 600;
  color: var(--accent);
}
.deck-today-done { color: var(--status-mastered); font-weight: 500; }

/* ---------- studyType 切替バー ---------- */
.study-type-bar {
  display: flex; gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.study-type-btn {
  flex: 1;
  min-height: 72px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: var(--space-md) var(--space-sm);
  background: var(--bg-card); color: var(--fg-secondary);
  border: 2px solid var(--border-soft); border-radius: var(--radius-card);
  cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.study-type-btn:hover { border-color: var(--accent); color: var(--fg-primary); }
.study-type-btn[aria-pressed="true"] {
  border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}
.study-type-btn:focus-visible { outline: 3px solid var(--border-focus); outline-offset: 2px; }
.study-type-icon { font-size: 1.6rem; line-height: 1; }
.study-type-label { font-size: 0.95rem; font-weight: 700; }
.study-type-desc  { font-size: 0.72rem; color: var(--fg-muted); }
.study-type-btn[aria-pressed="true"] .study-type-desc { color: var(--accent); opacity: 0.8; }

/* ---------- 単語テスト: モーダル内設定 ---------- */
.spell-setup-section {
  width: 100%; margin-bottom: var(--space-md);
}
.spell-setup-label {
  margin: 0 0 var(--space-xs); font-size: 0.82rem; font-weight: 700;
  color: var(--fg-secondary); text-transform: uppercase; letter-spacing: 0.06em;
}
.spell-setup-row {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
}
.spell-radio-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.9rem; cursor: pointer;
  padding: 6px 10px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  transition: border-color 0.12s ease;
}
.spell-radio-label:has(input:checked) {
  border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}
.spell-radio { accent-color: var(--accent); }
.spell-start-btn { width: 100%; margin-top: var(--space-sm); }

/* ---------- 単語テスト: 出題画面 ---------- */
.spell-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  min-height: 140px;
  padding: var(--space-xl);
  margin-bottom: var(--space-md);
}
.spell-qtype-label {
  margin: 0 0 var(--space-sm);
  font-size: 0.82rem; font-weight: 700;
  color: var(--fg-secondary); text-transform: uppercase; letter-spacing: 0.05em;
}
.spell-prompt {
  font-size: 1.4rem; font-weight: 600; color: var(--fg-primary);
  line-height: 1.6; word-break: break-word;
}
.spell-blank {
  display: inline-block;
  min-width: 80px; padding: 0 4px;
  border-bottom: 3px solid var(--accent);
  color: var(--accent); font-style: italic;
  letter-spacing: 0.08em;
}
.spell-ja {
  margin: var(--space-sm) 0 0;
  font-size: 0.95rem; color: var(--fg-secondary); line-height: 1.5;
}
.spell-ja[hidden] { display: none; }

/* 文字判定行 */
.spell-input-area { margin-bottom: var(--space-md); }
.spell-char-row {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 48px;
  margin-bottom: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-soft); border-radius: var(--radius-input);
}
.spell-char {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 36px;
  border-radius: 6px;
  font-size: 1.1rem; font-weight: 700;
}
.spell-char-empty { background: transparent; color: var(--fg-muted); font-style: italic; }
.spell-char-ok    { background: rgba(52, 199, 89, 0.18); color: #1c8f43; }
.spell-char-ng    { background: rgba(255, 59, 48, 0.18); color: var(--status-wrong); }
@media (prefers-color-scheme: dark) {
  .spell-char-ok { color: var(--status-mastered); }
}

.spell-input {
  width: 100%; box-sizing: border-box;
  min-height: var(--tap-min);
  padding: 10px var(--space-md);
  font-size: 1.1rem; font-weight: 600;
  background: var(--bg-input); color: var(--fg-primary);
  border: 2px solid var(--border-input); border-radius: var(--radius-input);
  -webkit-appearance: none; appearance: none;
  transition: border-color 0.15s ease;
}
.spell-input:focus { outline: none; border-color: var(--border-focus); }
.spell-input:disabled { opacity: 0.6; cursor: default; }

/* フィードバック */
.spell-feedback {
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-md);
  border-radius: var(--radius-input);
  font-size: 1.05rem; font-weight: 700;
}
.spell-feedback[hidden] { display: none; }
.spell-feedback-ok {
  background: rgba(52, 199, 89, 0.16);
  border: 1px solid var(--status-correct);
  color: #1c8f43;
}
.spell-feedback-ng {
  background: rgba(255, 59, 48, 0.14);
  border: 1px solid var(--status-wrong);
  color: var(--status-wrong);
}
@media (prefers-color-scheme: dark) {
  .spell-feedback-ok { color: var(--status-mastered); }
}

/* アクションボタン列 */
.spell-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
  align-items: center;
}
.spell-actions .btn-ghost { font-size: 0.9rem; }

/* ---------- 単語テスト: 読み上げグループ ---------- */
.spell-speak-group {
  margin-top: var(--space-sm);
}
/* speak-group は既存スタイルを継承。spellSpeakBtn が hidden のとき非表示 */

/* ---------- CSV取込パネル ---------- */
.csv-panel {
  max-width: 720px; margin: var(--space-lg) auto 0;
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.csv-panel[hidden] { display: none; }
.csv-panel-title {
  margin: 0 0 var(--space-sm);
  font-size: 1rem; font-weight: 700; color: var(--fg-primary);
}
.csv-panel-desc {
  margin: 0 0 var(--space-md);
  font-size: 0.85rem; color: var(--fg-secondary); line-height: 1.6;
}
.csv-format-sample {
  margin-bottom: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-soft);
  border-radius: var(--radius-input);
}
.csv-format-label {
  margin: 0 0 2px;
  font-size: 0.78rem; font-weight: 700; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.csv-format-code {
  display: block;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.82rem;
  color: var(--fg-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: var(--space-sm);
  word-break: break-all;
}
.csv-format-note {
  margin: 0;
  font-size: 0.78rem; color: var(--fg-muted);
}
.csv-textarea {
  width: 100%; box-sizing: border-box;
  padding: 10px var(--space-md);
  font-size: 0.88rem; font-family: "Courier New", Courier, monospace;
  background: var(--bg-input); color: var(--fg-primary);
  border: 1px solid var(--border-input); border-radius: var(--radius-input);
  resize: vertical;
  margin-bottom: var(--space-sm);
  -webkit-appearance: none; appearance: none;
}
.csv-textarea:focus { outline: 3px solid var(--border-focus); outline-offset: 1px; }
.csv-actions {
  display: flex; flex-wrap: wrap; gap: var(--space-sm);
  align-items: center; margin-bottom: var(--space-sm);
}
.csv-action-btn { font-size: 0.9rem; }
.csv-clear-btn { color: var(--status-wrong); border-color: var(--status-wrong); }
.csv-clear-btn:hover { background: rgba(255, 59, 48, 0.08); }
.csv-import-status {
  margin: 0;
  font-size: 0.88rem; font-weight: 600; color: var(--accent);
}
.csv-import-status[hidden] { display: none; }

/* ---------- モーション抑制 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
