/* ==========================================================
   VocabApp Web — iOS版（SwiftUI / Liquid Glass）と同じ見た目
   VocabApp/VocabApp/Components/Theme.swift の値をそのまま使う
   ========================================================== */

:root {
  color-scheme: light dark;

  /* --- 色（iOS版 Theme.swift / システムカラー） --- */
  --primary: #007AFF;
  --primary-rgb: 0, 122, 255;
  --primary-glow: rgba(0, 122, 255, 0.35);
  --correct: #22C55E;
  --correct-rgb: 34, 197, 94;
  --wrong: #EF4444;
  --wrong-rgb: 239, 68, 68;
  --review: #16A34A;
  --review-rgb: 22, 163, 74;
  --purple: #A855F7;
  --purple-rgb: 168, 85, 247;
  --orange: #FF9500;
  --orange-rgb: 255, 149, 0;
  --primary-gradient: linear-gradient(135deg, #60A5FA 0%, #3B82F6 50%, #2563EB 100%);

  --text-main: #1D1D1F;
  --text-sub: rgba(60, 60, 67, 0.64);
  --text-tertiary: rgba(60, 60, 67, 0.34);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --separator: rgba(60, 60, 67, 0.16);

  /* --- Liquid Glass --- */
  --glass-bg: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-shadow:
    0 8px 28px rgba(31, 38, 135, 0.08),
    0 1px 3px rgba(31, 38, 135, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(255, 255, 255, 0.25);
  --glass-blur: blur(24px) saturate(1.8);
  --group-bg: rgba(255, 255, 255, 0.72);
  --sheet-bg: rgba(248, 250, 255, 0.82);
  --edge-fade: rgba(232, 244, 253, 0.72);

  /* --- 背景（AppBackground） --- */
  --app-backdrop:
    radial-gradient(circle at calc(50% - 140px) calc(50% - 260px), rgba(125, 211, 252, 0.45) 0, rgba(125, 211, 252, 0.22) 130px, rgba(125, 211, 252, 0) 330px),
    radial-gradient(circle at calc(50% + 150px) calc(50% + 220px), rgba(196, 181, 253, 0.45) 0, rgba(196, 181, 253, 0.22) 120px, rgba(196, 181, 253, 0) 320px),
    linear-gradient(135deg, #E0F7FA 0%, #E8F4FD 33%, #EDE9FE 66%, #DBEAFE 100%);

  /* --- 文字（Dynamic Type 相当。設定の文字サイズで --fs が変わる） --- */
  --fs: 1;
  --t-caption2: calc(11px * var(--fs));
  --t-caption: calc(12px * var(--fs));
  --t-footnote: calc(13px * var(--fs));
  --t-subhead: calc(15px * var(--fs));
  --t-callout: calc(16px * var(--fs));
  --t-body: calc(17px * var(--fs));
  --t-title3: calc(20px * var(--fs));
  --t-title2: calc(22px * var(--fs));
  --t-title1: calc(28px * var(--fs));
  --t-large: calc(34px * var(--fs));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Inter", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;

  /* --- 寸法 --- */
  --card-radius: 26px;
  --header-height: 56px;
  --tabbar-height: 62px;
  --tabbar-bottom: max(10px, calc(env(safe-area-inset-bottom) - 12px));
  --gutter: 16px;
  --app-height: 100vh;

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

html[data-theme="dark"] {
  --primary: #0A84FF;
  --primary-rgb: 10, 132, 255;
  --primary-glow: rgba(10, 132, 255, 0.4);
  --orange: #FF9F0A;
  --orange-rgb: 255, 159, 10;

  --text-main: #FFFFFF;
  --text-sub: rgba(235, 235, 245, 0.62);
  --text-tertiary: rgba(235, 235, 245, 0.32);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.36);
  --separator: rgba(84, 84, 88, 0.5);

  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.13);
  --glass-shadow:
    0 8px 28px rgba(0, 0, 0, 0.32),
    0 1px 3px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  --group-bg: rgba(28, 28, 32, 0.72);
  --sheet-bg: rgba(22, 24, 38, 0.86);
  --edge-fade: rgba(15, 23, 42, 0.72);

  --app-backdrop:
    radial-gradient(circle at calc(50% - 140px) calc(50% - 260px), rgba(59, 130, 246, 0.25) 0, rgba(59, 130, 246, 0.12) 130px, rgba(59, 130, 246, 0) 330px),
    radial-gradient(circle at calc(50% + 150px) calc(50% + 220px), rgba(139, 92, 246, 0.22) 0, rgba(139, 92, 246, 0.11) 120px, rgba(139, 92, 246, 0) 320px),
    linear-gradient(135deg, #0F172A 0%, #1E1B4B 33%, #172554 66%, #0C1A3D 100%);
}

/* ==========================================================
   ベース
   ========================================================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  height: 100vh;
  background-color: #E0F7FA;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  font-family: var(--font);
}

html[data-theme="dark"] {
  background-color: #0F172A;
}

body {
  width: 100%;
  min-height: 100vh;
  background: transparent;
  position: relative;
  color: var(--text-main);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

body,
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  margin: 0;
  font-weight: 700;
}

button {
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  outline: inherit;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

a {
  color: var(--primary);
}

input,
textarea,
select {
  -webkit-user-select: auto;
  user-select: auto;
  font-family: var(--font);
}

.hidden,
.hidden-input,
[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ic {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.125em;
  overflow: visible;
}

/* 画面全体の背景（iOS版 AppBackground） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--app-backdrop);
  pointer-events: none;
}

/* ==========================================================
   ガラス・ボタン・入力（iOS版 Theme.swift の部品）
   ========================================================== */
.glass-card,
.glass-capsule,
.glass-icon-btn,
.hero-card,
.tile,
.question-card,
.choices-grid button,
.mode-row,
.range-field,
.word-item,
.chip,
.level-badge,
.custom-select-trigger,
.btn-secondary,
.btn-circle-action,
.feedback,
.swipe-card {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.glass-card {
  border-radius: var(--card-radius);
  padding: 20px;
}

.glass-capsule {
  border-radius: 999px;
}

/* 色付きガラス（.tint-*） */
.tint-review { --tint: var(--review); --tint-rgb: var(--review-rgb); }
.tint-wrong { --tint: var(--wrong); --tint-rgb: var(--wrong-rgb); }
.tint-accent { --tint: var(--primary); --tint-rgb: var(--primary-rgb); }
.tint-purple { --tint: var(--purple); --tint-rgb: var(--purple-rgb); }
.tint-orange { --tint: var(--orange); --tint-rgb: var(--orange-rgb); }
.tint-correct { --tint: var(--correct); --tint-rgb: var(--correct-rgb); }

.c-correct { color: var(--correct); }
.c-wrong { color: var(--wrong); }
.c-review { color: var(--review); }
.c-accent { color: var(--primary); }
.c-purple { color: var(--purple); }
.c-orange { color: var(--orange); }
.c-secondary { color: var(--text-sub); }

/* 丸いガラスのアイコンボタン（GlassIconButton） */
.glass-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  font-size: 17px;
  flex-shrink: 0;
  transition: transform 0.45s var(--spring), background 0.2s;
}

.glass-icon-btn .ic {
  width: 0.98em;
  height: 0.98em;
}

.glass-icon-btn.small {
  width: 40px;
  height: 40px;
  font-size: 15px;
}

.glass-icon-btn.large {
  width: 60px;
  height: 60px;
  font-size: 23px;
}

.glass-icon-btn:active {
  transform: scale(0.9);
  transition-duration: 0.08s;
}

/* 主ボタン（PrimaryButtonStyle: 色付きガラスのカプセル） */
.btn {
  width: 100%;
  min-height: 52px;
  padding: 14px 20px;
  border-radius: 999px;
  border: none;
  font-weight: 600;
  font-size: var(--t-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  transition: transform 0.45s var(--spring), background 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn .ic {
  font-size: 0.95em;
}

.btn:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow:
    0 6px 18px rgba(var(--primary-rgb), 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.btn-primary:disabled {
  opacity: 1;
  background: var(--fill-strong);
  color: var(--text-sub);
  box-shadow: none;
}

/* 副ボタン（SecondaryButtonStyle: 透明なガラス、文字は色付き） */
.btn-secondary {
  color: var(--primary);
  font-size: var(--t-subhead);
  min-height: 48px;
}

.btn-secondary.muted {
  color: var(--text-sub);
}

.btn-small {
  min-height: 42px;
  padding: 10px 16px;
  font-size: var(--t-subhead);
}

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row .btn {
  flex: 1;
}

.btn-text-destructive {
  color: var(--wrong);
  font-size: var(--t-footnote);
  font-weight: 600;
  padding: 10px 16px;
}

/* フォーム */
.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: var(--fill);
  font-size: 16px !important;
  color: var(--text-main);
  transition: background 0.2s, border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-control:focus {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.55);
  background-color: var(--fill-strong);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

/* セグメント（iOS の Picker .segmented と同じ見た目） */
.segment-control {
  display: flex;
  position: relative;
  width: 100%;
  padding: 2px;
  border-radius: 10px;
  background: var(--fill);
  overflow: hidden;
}

.segment-control .segment-btn {
  flex: 1;
  position: relative;
  z-index: 2;
  min-height: 30px;
  padding: 5px 6px;
  border-radius: 8px;
  color: var(--text-main);
  font-size: var(--t-footnote);
  font-weight: 500;
  white-space: nowrap;
  text-align: center;
  transition: color 0.2s;
}

.segment-control .segment-btn.active {
  font-weight: 600;
}

.segment-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  z-index: 1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.3s var(--ease-out), width 0.3s var(--ease-out);
  pointer-events: none;
}

html[data-theme="dark"] .segment-indicator {
  background: #636366;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* トグル（iOS の Toggle） */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--fill-strong);
  border-radius: 31px;
  transition: background 0.25s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s var(--spring);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--correct);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 細い進捗バー（ProgressTrack） */
.progress-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.16);
  overflow: hidden;
}

.progress-track-fill {
  height: 100%;
  width: 0;
  min-width: 6px;
  border-radius: 999px;
  background: var(--primary-gradient);
  transition: width 0.4s var(--ease-out);
}

/* ==========================================================
   全画面（ログイン・読み込み・テスト・振り分け・聞き流し）
   ========================================================== */
#main-app {
  position: fixed;
  inset: 0;
  height: var(--app-height, 100vh);
  overflow: hidden;
}

.screen {
  display: none !important;
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 2000;
  flex-direction: column;
  background: var(--app-backdrop);
  background-color: #E0F7FA;
}

html[data-theme="dark"] .screen {
  background-color: #0F172A;
}

.screen.active {
  display: flex !important;
  animation: screenIn 0.3s var(--ease-out);
}

.screen.screen-fade-out {
  animation: screenOut 0.2s ease-in forwards;
}

/* 学習画面は下から出る（iOS版 .move(edge: .bottom)） */
.screen.app-shell.active {
  animation: sessionIn 0.38s var(--ease-out);
}

@keyframes screenIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes screenOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes sessionIn {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.center-content {
  justify-content: center;
  align-items: center;
}

.scrollable-y {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.large-title {
  font-size: var(--t-large);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.app-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}

.app-logo.large {
  width: 96px;
  height: 96px;
  border-radius: 22px;
}

/* 読み込み */
#loading-screen {
  gap: 20px;
}

.loading-progress-container {
  width: 200px;
  height: 4px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.2);
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease-out;
}

.loading-status-text {
  margin-top: -10px;
  font-size: var(--t-footnote);
  color: var(--text-sub);
}

/* ログイン・ようこそ */
.onboard {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.onboard .app-logo {
  margin-bottom: 8px;
}

.onboard-text {
  font-size: var(--t-subhead);
  color: var(--text-sub);
  line-height: 1.55;
}

.onboard-caption {
  margin-top: -8px;
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.onboard .btn {
  max-width: 340px;
}

.btn-google {
  margin-top: 8px;
  width: 100%;
  max-width: 320px;
  height: 44px;
  border-radius: 999px;
  background: #fff;
  color: #1F1F1F;
  border: 1px solid #747775;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: "Roboto", var(--font);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.2s, transform 0.3s var(--spring);
}

.btn-google:active {
  transform: scale(0.97);
}

html[data-theme="dark"] .btn-google {
  background: #131314;
  color: #E3E3E3;
  border-color: #8E918F;
}

.google-g {
  width: 18px;
  height: 18px;
}

.onboard-links {
  display: flex;
  gap: 20px;
  font-size: var(--t-caption);
}

.onboard-links a {
  text-decoration: none;
  font-weight: 500;
}

.status-text {
  font-size: var(--t-footnote);
  color: var(--text-sub);
}

/* アプリ内ブラウザ（X など）で開いたときの「ブラウザで開く」案内。縦が足りなければスクロール */
#login-screen {
  overflow-y: auto;
  justify-content: safe center;
}

.in-app-notice {
  width: 100%;
  padding: 20px;
  border-radius: var(--card-radius);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.in-app-notice-title {
  font-size: var(--t-title3);
  font-weight: 700;
  color: var(--text-main);
}

.in-app-notice-text,
.in-app-notice-hint {
  font-size: var(--t-footnote);
  color: var(--text-sub);
  line-height: 1.55;
}

.in-app-notice .btn {
  text-decoration: none;
}

.in-app-url {
  max-width: 100%;
  font-size: var(--t-caption);
  color: var(--text-sub);
  word-break: break-all;
  -webkit-user-select: text;
  user-select: text;
}

/* ==========================================================
   ヘッダー（レベル・単語帳の切り替え）
   ========================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: calc(var(--header-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

/* 下の内容がうっすら透けてぼける（iOS 26 のスクロールエッジ効果） */
.app-header::before {
  content: "";
  position: absolute;
  inset: 0 0 -18px 0;
  z-index: -1;
  background: linear-gradient(to bottom, var(--edge-fade) 0%, var(--edge-fade) 45%, transparent 100%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
  pointer-events: none;
}

#main-app[data-tab="settings"] .app-header {
  display: none;
}

/* 設定タブは見出しが大きいのでヘッダーを出さず、上端だけうっすらぼかす */
#main-app[data-tab="settings"]::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: calc(env(safe-area-inset-top) + 18px);
  background: linear-gradient(to bottom, var(--edge-fade), transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
  pointer-events: none;
}

.level-badge {
  justify-self: start;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  transition: transform 0.45s var(--spring);
}

.level-badge:active {
  transform: scale(0.94);
  transition-duration: 0.08s;
}

.lvl-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-sub);
}

.lvl-num {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.lvl-ring {
  width: 16px;
  height: 16px;
  transform: rotate(-90deg);
}

.lvl-ring circle {
  fill: none;
  stroke-width: 3;
}

.lvl-ring-track {
  stroke: rgba(127, 127, 127, 0.28);
}

.lvl-ring-fill {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.6s var(--ease-out);
}

.header-spacer {
  justify-self: end;
}

/* 単語帳の切り替え（BookSwitcher） */
.custom-select-wrapper {
  position: relative;
  z-index: 200;
}

.book-switcher {
  justify-self: center;
  min-width: 0;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  max-width: 220px;
  color: var(--text-main);
  font-size: var(--t-subhead);
  font-weight: 600;
  transition: transform 0.45s var(--spring);
}

.custom-select-trigger:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
}

.custom-select-label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-label .book-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-chevron {
  font-size: 11px;
  color: var(--text-main);
  transition: transform 0.3s var(--spring);
}

.custom-select-wrapper.open .custom-select-chevron {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  min-width: 250px;
  max-width: min(320px, calc(100vw - 32px));
  padding: 6px;
  border-radius: 22px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px) scale(0.96);
  transform-origin: top center;
  transition: opacity 0.18s ease, transform 0.3s var(--spring), visibility 0.18s;
}

.custom-select-wrapper.open .custom-select-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.custom-select-options {
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.custom-select-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: var(--t-body);
  font-weight: 400;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.custom-select-option:hover {
  background: var(--fill);
}

.custom-select-option:active {
  background: var(--fill-strong);
}

.custom-select-option .check-icon {
  font-size: 15px;
  color: var(--text-main);
  opacity: 0;
}

.custom-select-option.selected .check-icon {
  opacity: 1;
}

.custom-select-option .option-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-option.manage .ic {
  font-size: 17px;
  color: var(--text-main);
}

.custom-select-divider {
  height: 1px;
  margin: 4px 10px;
  background: var(--separator);
}

.option-sync-icon {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.sync-icon {
  font-size: 11px;
  color: var(--text-sub);
}

.sync-icon.offline {
  color: var(--orange);
}

.sync-icon.syncing {
  animation: spinSync 1.2s linear infinite;
}

@keyframes spinSync {
  to { transform: rotate(360deg); }
}

/* 設定内のドロップダウン（キーボード配列）は左寄せ・全幅 */
#custom-kb-layout-select .custom-select-trigger {
  max-width: none;
  width: 100%;
  justify-content: space-between;
  height: 44px;
}

#custom-kb-layout-select .custom-select-dropdown {
  left: 0;
  right: 0;
  min-width: 0;
  transform: translateY(-6px) scale(0.96);
}

#custom-kb-layout-select.open .custom-select-dropdown {
  transform: translateY(0) scale(1);
}

/* ==========================================================
   タブ（中身）とタブバー
   ========================================================== */
.main-content {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.tab-view {
  display: none !important;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: calc(var(--header-height) + env(safe-area-inset-top) + 12px);
  padding-bottom: calc(var(--tabbar-height) + var(--tabbar-bottom) + 28px);
  padding-left: calc(var(--gutter) + env(safe-area-inset-left));
  padding-right: calc(var(--gutter) + env(safe-area-inset-right));
}

.tab-view.active {
  display: block !important;
  animation: tabIn 0.3s var(--ease-out);
}

@keyframes tabIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* タブバー（iOS 26 の浮いたガラスのタブバー） */
.app-footer {
  position: fixed;
  left: 50%;
  bottom: var(--tabbar-bottom);
  z-index: 1000;
  width: calc(100% - 2 * (var(--gutter) + 8px) - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-width: 400px;
  transform: translateX(-50%);
  height: var(--tabbar-height);
  padding: 4px;
  border-radius: 999px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px) saturate(1.9);
  backdrop-filter: blur(20px) saturate(1.9);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 34px rgba(31, 38, 135, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

html[data-theme="dark"] .app-footer {
  background: rgba(40, 40, 52, 0.55);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.nav-container {
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 2px;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 999px;
  color: var(--text-main);
  transition: background 0.25s, color 0.25s, transform 0.4s var(--spring);
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
}

.nav-item.active {
  color: var(--primary);
  background: rgba(127, 127, 127, 0.14);
}

.nav-item:active {
  transform: scale(0.92);
  transition-duration: 0.08s;
}

/* ==========================================================
   学習タブ（本日の復習・ほかの単語から選ぶ）
   ========================================================== */
.home {
  gap: 24px;
}

.hero-card {
  --tint-rgb: var(--review-rgb);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  padding: 22px;
  border-radius: var(--card-radius);
  text-align: left;
  color: var(--text-main);
  background-image: linear-gradient(rgba(var(--tint-rgb), 0.12), rgba(var(--tint-rgb), 0.12));
  transition: transform 0.5s var(--spring), box-shadow 0.3s;
}

.hero-card:active {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--review);
  font-size: var(--t-body);
  font-weight: 600;
}

.hero-rate {
  font-size: var(--t-caption);
  font-weight: 600;
  color: var(--text-sub);
}

.hero-due {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.hero-count {
  font-family: var(--font-rounded);
  font-size: calc(56px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.hero-unit {
  font-size: var(--t-title3);
  font-weight: 700;
  color: var(--text-sub);
}

.hero-done {
  font-family: var(--font-rounded);
  font-size: calc(34px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.15;
}

.hero-sub {
  font-size: var(--t-subhead);
  color: var(--text-sub);
  line-height: 1.4;
}

.hero-action {
  display: flex;
  justify-content: flex-end;
}

.hero-start {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--primary-gradient);
  color: #fff;
  font-size: var(--t-body);
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hero-start .ic {
  font-size: 0.85em;
}

.hero-card:disabled {
  opacity: 0.6;
}

.section-caption {
  margin-bottom: -10px;
  padding: 0 4px;
  font-size: var(--t-body);
  font-weight: 600;
  color: var(--text-sub);
}

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

.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 108px;
  padding: 16px;
  border-radius: 22px;
  text-align: left;
  color: var(--text-main);
  background-image: linear-gradient(rgba(var(--tint-rgb), 0.12), rgba(var(--tint-rgb), 0.12));
  transition: transform 0.5s var(--spring), background-image 0.2s;
}

.tile:active {
  transform: scale(0.96);
  transition-duration: 0.08s;
  background-image: linear-gradient(rgba(var(--tint-rgb), 0.25), rgba(var(--tint-rgb), 0.25));
}

.tile-icon {
  font-size: var(--t-title3);
  color: var(--tint);
  margin-bottom: auto;
}

.tile-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.tile-num {
  font-family: var(--font-rounded);
  font-size: calc(26px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-num.small {
  font-size: var(--t-body);
  line-height: 1.6;
}

.tile-unit {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--text-sub);
}

.tile-title {
  font-size: var(--t-subhead);
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ==========================================================
   シート（開始・学習状況・単語の詳細・例文）
   ========================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2900;
  background: rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.sheet-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 3000;
  max-height: calc(100dvh - env(safe-area-inset-top) - 40px);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 560px;
  border-radius: 38px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(calc(100% + 24px));
  visibility: hidden;
  transition: transform 0.42s var(--ease-out), visibility 0.42s;
  overflow: hidden;
}

.sheet.open {
  transform: translateY(0);
  visibility: visible;
}

/* 開始シート・学習状況は iOS版と同じくグラデーション背景 */
#start-sheet,
#xp-sheet {
  background: var(--app-backdrop);
  background-color: #E8F4FD;
}

html[data-theme="dark"] #start-sheet,
html[data-theme="dark"] #xp-sheet {
  background-color: #172554;
}

.sheet.tall {
  height: calc(85dvh - 8px);
}

.sheet-grabber {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.4);
  z-index: 2;
}

.sheet-toolbar {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 6px;
  touch-action: none;
}

.sheet-toolbar > :last-child {
  justify-self: end;
}

.sheet-title {
  text-align: center;
  font-size: var(--t-body);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 6px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sheet-footer {
  flex-shrink: 0;
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom) * 0.4);
}

.sheet-heading {
  margin-bottom: -12px;
  font-size: var(--t-body);
  font-weight: 600;
}

/* 開始シート */
.start-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.start-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-title2);
  color: var(--tint);
  background: var(--glass-bg);
  background-image: linear-gradient(rgba(var(--tint-rgb), 0.2), rgba(var(--tint-rgb), 0.2));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  flex-shrink: 0;
}

.start-heading h2 {
  font-size: var(--t-title2);
  font-weight: 700;
}

.start-heading p {
  font-size: var(--t-subhead);
  color: var(--text-sub);
}

.start-heading p.empty {
  color: var(--wrong);
}

.range-fields {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px;
  border-radius: 18px;
  cursor: text;
}

.range-field span {
  font-size: var(--t-caption2);
  font-weight: 600;
  color: var(--text-sub);
}

.range-field input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-main);
  font-size: var(--t-title3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  scroll-margin: 80px;
}

.range-arrow {
  font-size: 15px;
  color: var(--text-sub);
}

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border-radius: 20px;
  text-align: left;
  color: var(--text-main);
  transition: transform 0.45s var(--spring), background-image 0.25s;
}

.mode-row:active {
  transform: scale(0.98);
  transition-duration: 0.08s;
}

.mode-row[aria-checked="true"] {
  background-image: linear-gradient(rgba(var(--primary-rgb), 0.18), rgba(var(--primary-rgb), 0.18));
}

.mode-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--t-title3);
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
  transition: background 0.25s, color 0.25s;
}

.mode-row[aria-checked="true"] .mode-icon {
  background: var(--primary);
  color: #fff;
}

.mode-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mode-title {
  font-size: var(--t-body);
  font-weight: 600;
}

.mode-detail {
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.mode-check {
  font-size: 22px;
  display: inline-flex;
}

.mode-check .on { display: none; color: var(--primary); }
.mode-check .off { color: var(--text-tertiary); }
.mode-row[aria-checked="true"] .mode-check .on { display: inline-block; }
.mode-row[aria-checked="true"] .mode-check .off { display: none; }

.mode-options {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.mode-options.active {
  display: flex;
}

.option-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.option-label {
  font-size: var(--t-caption);
  font-weight: 600;
  color: var(--text-sub);
}

.option-text {
  font-size: var(--t-callout);
  color: var(--text-sub);
  line-height: 1.5;
}

.option-note {
  font-size: var(--t-caption);
  color: var(--text-sub);
  line-height: 1.5;
}

/* 4択の切り替え（ガラスの枠に2行） */
.toggle-group {
  padding: 0 16px;
  border-radius: 20px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 10px 0;
  cursor: pointer;
}

.toggle-line + .toggle-line {
  border-top: 0.5px solid var(--separator);
}

/* 学習状況シート */
.xp-ring {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

.xp-ring svg,
.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(127, 127, 127, 0.14);
}

.ring-fill {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 1s ease-out;
}

.xp-ring .ring-track,
.xp-ring .ring-fill {
  stroke-width: 14;
}

.xp-ring .ring-fill {
  stroke: url(#xp-gradient);
}

.xp-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.xp-ring-label {
  font-size: var(--t-caption);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-sub);
}

.xp-ring-level {
  font-size: calc(52px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.xp-summary {
  text-align: center;
  margin-top: -8px;
}

.xp-progress {
  font-size: var(--t-title3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.xp-next {
  margin-top: 4px;
  font-size: var(--t-subhead);
  color: var(--text-sub);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-card h3 {
  font-size: var(--t-body);
  font-weight: 600;
}

.stat-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--t-body);
}

.stat-line .ic {
  width: 24px;
  font-size: 18px;
}

.stat-line span {
  flex: 1;
  min-width: 0;
}

.stat-line b {
  font-weight: 600;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 単語の詳細シート */
.word-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-head-top,
.word-head-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.word-head-bottom {
  align-items: baseline;
}

.word-head-en {
  font-size: calc(32px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.15;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
}

.word-head-ja {
  font-size: var(--t-title3);
  color: var(--text-sub);
  -webkit-user-select: text;
  user-select: text;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--primary);
  font-size: var(--t-subhead);
  font-weight: 600;
  white-space: nowrap;
  padding: 6px 0;
}

.section-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-card > h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-body);
  font-weight: 600;
}

.section-card > h3 .ic {
  color: var(--primary);
}

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--t-subhead);
}

.record-row span {
  color: var(--text-sub);
}

.record-row b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 例文 */
.example-block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.example-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 60px;
  -webkit-user-select: text;
  user-select: text;
}

.ex-en {
  font-size: var(--t-title3);
  line-height: 1.45;
  color: var(--text-main);
}

.ex-ja {
  font-size: var(--t-body);
  line-height: 1.55;
  color: var(--text-sub);
}

.ex-ja b {
  color: var(--primary);
  font-weight: 700;
}

.highlight-word {
  color: var(--primary);
  font-weight: 700;
}

.ex-message {
  color: var(--text-sub);
  font-size: var(--t-body);
}

.ex-message.error {
  color: var(--wrong);
  font-size: var(--t-footnote);
}

.ex-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 80px;
  color: var(--text-sub);
  font-size: var(--t-subhead);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid rgba(127, 127, 127, 0.25);
  border-top-color: var(--text-sub);
  animation: spinSync 0.8s linear infinite;
  flex-shrink: 0;
}

/* 隅の小さな丸アイコン（再生・例文） */
.corner-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
  color: var(--tint);
  background: rgba(var(--tint-rgb), 0.14);
  transition: transform 0.4s var(--spring), background 0.2s;
}

.corner-icon:active,
.corner-icon.active-key {
  transform: scale(0.88);
  transition-duration: 0.08s;
}

.corner-icon.has-cache {
  --tint: var(--correct);
  --tint-rgb: var(--correct-rgb);
}

.corner-icon.large {
  width: 48px;
  height: 48px;
  font-size: 19px;
}

.audio-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spinSync 0.9s linear infinite;
}

/* ==========================================================
   学習画面の上部バー（SessionTopBar）
   ========================================================== */
.session-top {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
}

.session-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.session-bar > :first-child {
  justify-self: start;
}

.session-bar > :last-child {
  justify-self: end;
}

.session-label {
  min-height: 42px;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.session-label.two-line {
  flex-direction: column;
  padding: 5px 18px;
  line-height: 1.2;
}

.session-label.two-line small {
  font-size: var(--t-caption);
  font-weight: 400;
  color: var(--text-sub);
}

.session-score {
  min-height: 42px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--t-subhead);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.session-score > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.score-correct { color: var(--correct); }
.score-wrong { color: var(--wrong); }

.session-score .ic {
  font-size: 0.85em;
}

/* ==========================================================
   4択テスト
   ========================================================== */
.test-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px calc(var(--gutter) + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left));
}

.question-card {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 24px;
  border-radius: var(--card-radius);
  text-align: center;
  cursor: default;
}

.question-card.tappable {
  cursor: pointer;
}

.question-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.question-label {
  font-size: var(--t-caption);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-sub);
}

.question-text {
  width: 100%;
  font-size: calc(36px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.question-hint {
  font-size: var(--t-caption);
  color: var(--text-tertiary);
}

.answer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

#choices-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#choices-container.hidden {
  display: none !important;
}

.choices-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choices-grid button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 20px;
  text-align: left;
  color: var(--text-main);
  font-size: var(--t-body);
  font-weight: 600;
  transition: transform 0.45s var(--spring), background-image 0.2s, border-color 0.2s, opacity 0.25s, color 0.2s;
}

.choices-grid button:active,
.choices-grid button.active-anim {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

.choice-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(127, 127, 127, 0.14);
  font-size: var(--t-caption);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.choice-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.choice-mark {
  display: none;
  font-size: 20px;
}

.choices-grid button.choice-correct {
  color: var(--correct);
  border: 1.5px solid var(--correct);
  background-image: linear-gradient(rgba(var(--correct-rgb), 0.3), rgba(var(--correct-rgb), 0.3));
  opacity: 1;
}

.choices-grid button.choice-wrong {
  color: var(--wrong);
  border: 1.5px solid var(--wrong);
  background-image: linear-gradient(rgba(var(--wrong-rgb), 0.3), rgba(var(--wrong-rgb), 0.3));
  opacity: 1;
}

.choices-grid button.choice-correct .mark-correct,
.choices-grid button.choice-wrong .mark-wrong {
  display: inline-block;
}

.choices-grid button:disabled {
  pointer-events: none;
}

.choices-grid button:disabled:not(.choice-correct):not(.choice-wrong) {
  opacity: 0.55;
}

.feedback {
  padding: 16px;
  border-radius: 20px;
  text-align: center;
  font-size: var(--t-body);
  font-weight: 600;
  line-height: 1.45;
  animation: popIn 0.35s var(--spring);
}

.feedback.correct {
  color: var(--correct);
  background-image: linear-gradient(rgba(var(--correct-rgb), 0.25), rgba(var(--correct-rgb), 0.25));
}

.feedback.incorrect {
  color: var(--wrong);
  background-image: linear-gradient(rgba(var(--wrong-rgb), 0.25), rgba(var(--wrong-rgb), 0.25));
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

#choices-container:not(.hidden),
#next-btn:not(.hidden) {
  animation: fadeUp 0.2s ease-out;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 不正解で揺らす（入れ物ごと） */
.question-card.shake {
  animation: shake 0.32s linear;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-14px); }
  37% { transform: translateX(12px); }
  59% { transform: translateX(-9px); }
  80% { transform: translateX(6px); }
}

/* ==========================================================
   結果（ResultView）
   ========================================================== */
.result-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 28px;
}

.score-ring {
  position: relative;
  width: 200px;
  height: 200px;
}

.score-ring .ring-track,
.score-ring .ring-fill {
  stroke-width: 16;
}

.score-ring .ring-fill {
  stroke: url(#score-gradient);
}

.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.score-value {
  font-size: calc(56px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-label {
  font-size: var(--t-caption);
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-sub);
}

#result-message {
  margin-top: -8px;
  font-size: var(--t-title3);
  font-weight: 600;
}

.result-actions {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================================
   左右振り分け
   ========================================================== */
.swipe-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px calc(24px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  gap: 22px;
}

/* カードは縦横比 0.72 のまま、入る大きさいっぱいに（最大 392px 幅） */
.swipe-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.card-stack {
  position: relative;
  width: min(100cqw, 392px, 72cqh);
  aspect-ratio: 0.72;
}

.swipe-card {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  border-radius: 32px;
  border-width: 3px;
  border-color: var(--glass-border);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  outline: none;
  transform-origin: 50% 100%;
  transition: transform 0.1s linear, filter 0.4s ease-out;
}

html[data-theme="dark"] .swipe-card {
  background: rgba(40, 42, 60, 0.6);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.swipe-card.dragging {
  cursor: grabbing;
}

.swipe-word-en {
  font-size: calc(38px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-main);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.swipe-word-jp {
  font-size: var(--t-title3);
  font-weight: 600;
  color: var(--text-sub);
  opacity: 0;
  filter: blur(10px);
  transition: opacity 0.3s, filter 0.3s;
}

.swipe-card.revealed .swipe-word-jp {
  opacity: 1;
  filter: none;
}

.swipe-tap-hint {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  font-size: var(--t-caption);
  color: var(--text-sub);
  transition: opacity 0.2s;
}

.swipe-card.revealed .swipe-tap-hint {
  opacity: 0;
}

.swipe-audio-btn {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 10;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
  transition: transform 0.3s var(--spring);
}

.swipe-audio-btn.has-cache {
  color: var(--correct);
  background: rgba(var(--correct-rgb), 0.14);
}

.swipe-audio-btn:active {
  transform: scale(0.9);
}

/* 奥のカードはうっすら */
.swipe-card.next-card {
  z-index: 0;
  transform: scale(0.94) translateY(20px);
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), opacity 0.3s, filter 0.4s;
}

.swipe-card.next-card .swipe-word-en,
.swipe-card.next-card-2 .swipe-word-en {
  opacity: 0.28;
}

.swipe-card.next-card .swipe-audio-btn,
.swipe-card.next-card-2 .swipe-audio-btn,
.swipe-card.next-card .swipe-tap-hint,
.swipe-card.next-card-2 .swipe-tap-hint {
  opacity: 0;
}

.swipe-card.next-card-2 {
  z-index: 0;
  transform: scale(0.88) translateY(40px);
  opacity: 0.56;
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), opacity 0.3s;
  animation: cardEnterBack 0.35s ease-out;
}

@keyframes cardEnterBack {
  from { opacity: 0; transform: scale(0.84) translateY(52px); }
  to { opacity: 0.56; transform: scale(0.88) translateY(40px); }
}

/* 判定（覚えた / もう一度）のラベル */
.swipe-overlay-label {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(calc(0.7 + 0.3 * var(--r, 0)));
  pointer-events: none;
  font-family: var(--font-rounded);
  font-size: 22px;
  font-weight: 800;
  transition: opacity 0.05s linear;
}

.swipe-overlay-label .overlay-icon {
  order: -1;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 50px;
  font-weight: 900;
  color: #fff;
  font-family: var(--font);
}

.swipe-label-right {
  color: var(--correct);
}

.swipe-label-right .overlay-icon {
  background: var(--correct);
  box-shadow: 0 0 24px rgba(var(--correct-rgb), 0.6);
}

.swipe-label-left {
  color: var(--wrong);
}

.swipe-label-left .overlay-icon {
  background: var(--wrong);
  box-shadow: 0 0 24px rgba(var(--wrong-rgb), 0.6);
}

@keyframes flyOutRight {
  to { transform: translate(140%, -4%) rotate(26deg); opacity: 0; }
}

@keyframes flyOutLeft {
  to { transform: translate(-140%, -4%) rotate(-26deg); opacity: 0; }
}

.swipe-out-right {
  animation: flyOutRight 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.swipe-out-left {
  animation: flyOutLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

#swipe-bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  transition: background-color 0.1s linear;
}

.swipe-screen-body {
  position: relative;
  z-index: 1;
}

/* 完了 */
.swipe-finished {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.swipe-finished .glass-card {
  width: 100%;
  max-width: 340px;
  padding: 28px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.swipe-finished h3 {
  font-family: var(--font-rounded);
  font-size: calc(40px * min(var(--fs), 1.6));
  font-weight: 900;
}

.swipe-finished p {
  color: var(--text-sub);
}

.swipe-finished .finish-stats {
  display: flex;
  gap: 18px;
  font-size: var(--t-subhead);
  font-weight: 600;
}

.swipe-finished .finish-stats span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swipe-finished .btn {
  max-width: 340px;
}

/* 下のボタン（✕・取り消し・✓） */
.swipe-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 28px;
  z-index: 10;
}

.btn-circle-action {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  overflow: hidden;
  transition: transform 0.28s var(--spring), background 0.2s;
}

.btn-circle-action .ic {
  position: relative;
  z-index: 2;
  transition: color 0.1s;
}

/* 判定ラインに近づくほど色が濃くなる */
.btn-circle-action::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: calc(var(--fill-scale, 0) * 0.3);
  transition: opacity 0.1s linear;
  z-index: 1;
}

.btn-circle-action.filled::before {
  opacity: 1;
}

.btn-circle-action.filled {
  transform: scale(1.16);
}

.btn-circle-action.filled .ic {
  color: #fff;
}

.btn-circle-action:active {
  transform: scale(0.9);
  transition-duration: 0.08s;
}

.btn-circle-action.left {
  color: var(--wrong);
}

.btn-circle-action.left::before {
  background: var(--wrong);
}

.btn-circle-action.right {
  color: var(--correct);
}

.btn-circle-action.right::before {
  background: var(--correct);
}

.btn-circle-action.undo {
  width: 52px;
  height: 52px;
  font-size: 20px;
  color: var(--text-main);
}

.btn-circle-action.undo:disabled {
  opacity: 0.45;
}

/* ==========================================================
   聞き流し（チャンツ）
   ========================================================== */
.chant-container {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.chant-voice {
  min-height: 42px;
  padding: 9px 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--t-caption);
  font-weight: 600;
  white-space: nowrap;
}

.chant-stage {
  flex: 1;
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 0 calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
}

.chant-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
}

.chant-no {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.chant-word {
  font-size: calc(44px * min(var(--fs), 1.6));
  font-weight: 800;
  line-height: 1.15;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.chant-meaning {
  font-size: var(--t-title3);
  font-weight: 600;
  color: var(--text-sub);
}

.chant-seq {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chant-seq-arrow {
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.chant-seg {
  width: 38px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--t-subhead);
  font-weight: 700;
  color: var(--text-sub);
  background: rgba(127, 127, 127, 0.12);
  transition: transform 0.2s var(--spring), background 0.2s, color 0.2s;
}

.chant-seg.active {
  color: #fff;
  background: var(--primary);
  transform: scale(1.08);
}

.chant-status {
  min-height: 36px;
  font-size: var(--t-footnote);
  color: var(--text-sub);
  text-align: center;
}

.chant-controls {
  display: flex;
  align-items: center;
  gap: 30px;
}

.chant-play {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #fff;
  background: var(--primary);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 10px 28px rgba(var(--primary-rgb), 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.4s var(--spring);
}

.chant-play:active {
  transform: scale(0.92);
  transition-duration: 0.08s;
}

.chant-end-actions {
  width: 100%;
  max-width: 380px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chant-audio {
  display: none;
}

/* ==========================================================
   単語帳タブ
   ========================================================== */
#tab-list {
  padding-top: 0;
  padding-left: 0;
  padding-right: 0;
}

.list-top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: calc(var(--header-height) + env(safe-area-inset-top) + 6px) 0 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 上端だけうっすらぼかす */
.list-top::before {
  content: "";
  position: absolute;
  inset: 0 0 -14px 0;
  z-index: -1;
  background: linear-gradient(to bottom, var(--edge-fade) 0%, var(--edge-fade) 70%, transparent 100%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 75%, transparent 100%);
  pointer-events: none;
}

.search-field {
  width: calc(100% - 2 * var(--gutter) - env(safe-area-inset-left) - env(safe-area-inset-right));
  max-width: calc(640px - 2 * var(--gutter));
  margin: 0 auto;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--fill);
  color: var(--text-sub);
  cursor: text;
}

.search-field .ic {
  font-size: 15px;
}

.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 16px;
}

.search-field input::placeholder {
  color: var(--text-sub);
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px calc(var(--gutter) + env(safe-area-inset-right)) 6px calc(var(--gutter) + env(safe-area-inset-left));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-main);
  font-size: var(--t-subhead);
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.4s var(--spring), background 0.2s, color 0.2s;
}

.chip-count {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.chip.active {
  color: #fff;
  background: var(--primary);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.chip.active .chip-count {
  color: rgba(255, 255, 255, 0.85);
}

.chip:active {
  transform: scale(0.95);
  transition-duration: 0.08s;
}

#word-list-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2px calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  cursor: pointer;
  contain: content;
  transition: transform 0.45s var(--spring);
}

.word-item:active {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

.word-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.word-id {
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.word-en {
  font-size: var(--t-title3);
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.word-ja {
  font-size: var(--t-subhead);
  color: var(--text-sub);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.word-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.word-badges:empty {
  display: none;
}

.badge-mistake {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: var(--t-caption2);
  font-weight: 700;
  color: var(--wrong);
  background: rgba(var(--wrong-rgb), 0.14);
}

.badge-learned,
.badge-review {
  font-size: var(--t-caption2);
  font-weight: 700;
}

.badge-learned { color: var(--correct); }
.badge-review { color: var(--review); }

.btn-list-audio {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.14);
  transition: transform 0.3s var(--spring);
}

.btn-list-audio.has-cache {
  color: var(--correct);
  background: rgba(var(--correct-rgb), 0.14);
}

.btn-list-audio:active {
  transform: scale(0.88);
}

.list-empty {
  padding-top: 40px;
  text-align: center;
  color: var(--text-sub);
}

/* ==========================================================
   設定タブ（iOS の inset grouped リスト）
   ========================================================== */
#tab-settings {
  padding-top: calc(env(safe-area-inset-top) + 16px);
}

.settings {
  gap: 0;
}

.settings-title {
  padding: 4px 4px 10px;
}

.settings-section-label {
  margin: 22px 20px 8px;
  font-size: var(--t-footnote);
  font-weight: 600;
  color: var(--text-sub);
}

.settings-group {
  border-radius: var(--card-radius);
  background: var(--group-bg);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 12px rgba(31, 38, 135, 0.05);
  overflow: hidden;
}

.settings-row {
  position: relative;
  display: block;
  width: 100%;
  color: var(--text-main);
  text-decoration: none;
  text-align: left;
}

/* 区切り線（アイコンの右から） */
.settings-row + .settings-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 58px;
  right: 0;
  height: 1px;
  background: var(--separator);
  transform: scaleY(0.5);
  transform-origin: top;
}

.settings-row:not(.expandable):not(.stacked):not(.info-row),
.settings-row .row-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 11px 16px;
}

.settings-row .row-header {
  width: 100%;
  text-align: left;
}

button.settings-row:active,
a.settings-row:active,
.settings-row .row-header:active {
  background: var(--fill);
}

.row-icon {
  width: 28px;
  font-size: 20px;
  color: var(--primary);
}

.settings-row.destructive,
.settings-row.destructive .row-icon {
  color: var(--wrong);
}

.row-title {
  flex: 1;
  min-width: 0;
  font-size: var(--t-body);
}

.row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-subtitle {
  font-size: var(--t-caption);
  color: var(--text-sub);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.row-value {
  font-size: var(--t-body);
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.row-chevron {
  font-size: 13px;
  color: var(--text-tertiary);
  transition: transform 0.3s var(--spring);
}

.settings-row.expandable.open .row-chevron {
  transform: rotate(90deg);
}

.settings-row.info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  min-height: 60px;
}

.settings-row.stacked {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
}

.row-line {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-row.toggle-row {
  cursor: pointer;
}

/* 開閉する行 */
.row-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s var(--ease-out);
}

.settings-row.open .row-body {
  grid-template-rows: 1fr;
}

.row-inner {
  min-height: 0;
  overflow: hidden;
}

.settings-row.open .row-inner.done {
  overflow: visible;
}

.row-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 16px 18px 58px;
}

.settings-desc {
  font-size: var(--t-footnote);
  color: var(--text-sub);
  line-height: 1.55;
}

.field-label {
  margin-bottom: -6px;
  font-size: var(--t-caption);
  font-weight: 600;
  color: var(--text-sub);
}

.settings-hint {
  margin-top: -6px;
  font-size: var(--t-caption);
  color: var(--text-sub);
  line-height: 1.5;
}

.settings-hint.align-right {
  text-align: right;
}

.settings-hint.split {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.settings-hint a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.settings-footer {
  margin: 8px 20px 0;
  font-size: var(--t-footnote);
  color: var(--text-sub);
  line-height: 1.5;
}

.inline-field {
  display: flex;
  gap: 8px;
}

.inline-field .btn {
  width: auto;
  flex-shrink: 0;
}

.usage-stats {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill);
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.usage-stats div {
  display: flex;
  justify-content: space-between;
}

.usage-stats p {
  margin-top: 4px;
  text-align: right;
  font-size: var(--t-caption2);
}

.size-control-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.size-slider {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.size-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.import-area-small {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-label-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  border-radius: 14px;
  border: 1.5px dashed var(--fill-strong);
  color: var(--primary);
  font-size: var(--t-subhead);
  font-weight: 600;
  cursor: pointer;
}

.file-name-disp {
  font-size: var(--t-caption);
  color: var(--text-sub);
  text-align: center;
}

.app-version-label {
  margin: 24px auto 0;
  padding: 6px 12px;
  font-size: var(--t-footnote);
  color: var(--text-sub);
  text-align: center;
  cursor: pointer;
}

.app-version-label:active {
  opacity: 0.6;
}

/* 単語帳の一覧（設定 > 単語帳） */
#book-management-list {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--fill);
  overflow: hidden;
}

#book-management-list:empty {
  display: none;
}

.book-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 8px 14px;
  min-height: 56px;
  cursor: pointer;
}

.book-item + .book-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 48px;
  right: 0;
  height: 1px;
  background: var(--separator);
  transform: scaleY(0.5);
}

.book-item:active {
  background: var(--fill);
}

.book-item-icon {
  font-size: 20px;
  color: var(--text-sub);
}

.book-item.current .book-item-icon {
  color: var(--primary);
}

.book-item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.book-item-name {
  font-size: var(--t-body);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-item-sub {
  font-size: var(--t-caption);
  color: var(--text-sub);
}

.book-kebab-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
  flex-shrink: 0;
}

.book-kebab-btn:active {
  background: var(--fill);
}

/* 操作ガイド */
.gamepad-guide-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-heading {
  font-size: var(--t-footnote);
  font-weight: 700;
  color: var(--text-main);
}

.gamepad-guide-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 3px 0;
  font-size: var(--t-footnote);
  color: var(--text-sub);
}

.gp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--fill);
  font-size: var(--t-caption2);
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ==========================================================
   アクションシート（単語帳のメニュー）
   ========================================================== */
.book-action-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.book-action-sheet-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.book-action-sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom) * 0.5);
  z-index: 5001;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 8px 10px;
  border-radius: 30px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(calc(100% + 24px));
  transition: transform 0.35s var(--ease-out);
}

.book-action-sheet.visible {
  transform: translateY(0);
}

.book-action-sheet-handle {
  width: 36px;
  height: 5px;
  margin: 2px auto 8px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.4);
}

.book-action-sheet-title {
  padding: 4px 16px 10px;
  text-align: center;
  font-size: var(--t-footnote);
  font-weight: 600;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.book-action-sheet-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: var(--t-body);
  color: var(--text-main);
  cursor: pointer;
}

.book-action-sheet-item:hover {
  background: var(--fill);
}

.book-action-sheet-item:active {
  background: var(--fill-strong);
}

.book-action-sheet-item .action-icon {
  width: 22px;
  height: 22px;
  color: var(--text-main);
  flex-shrink: 0;
}

.book-action-sheet-item.destructive,
.book-action-sheet-item.destructive .action-icon {
  color: var(--wrong);
}

.book-action-sheet-divider {
  height: 1px;
  margin: 4px 16px;
  background: var(--separator);
}

.book-action-sheet-cancel {
  margin-top: 6px;
  min-height: 50px;
  padding: 14px;
  border-radius: 999px;
  text-align: center;
  font-size: var(--t-body);
  font-weight: 600;
  color: var(--primary);
  background: var(--fill);
  cursor: pointer;
}

.book-action-sheet-cancel:active {
  background: var(--fill-strong);
}

/* ==========================================================
   ダイアログ（iOS のアラート）
   ========================================================== */
.custom-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.3);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
}

.custom-dialog-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex !important;
}

.custom-dialog-window {
  width: 100%;
  max-width: 320px;
  padding: 22px 18px 16px;
  border-radius: 34px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: dialogIn 0.3s var(--spring);
}

@keyframes dialogIn {
  from { opacity: 0; transform: scale(1.12); }
  to { opacity: 1; transform: scale(1); }
}

.dialog-message {
  margin-bottom: 18px;
  padding: 0 6px;
  font-size: var(--t-subhead);
  line-height: 1.5;
  text-align: center;
  word-break: break-word;
  color: var(--text-main);
}

.dialog-message .dialog-title {
  display: block;
  margin-bottom: 4px;
  font-size: var(--t-body);
  font-weight: 600;
}

.dialog-input {
  margin-top: 12px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

/* 選択肢のダイアログ（showCustomChoice）は、ボタンを縦に並べる */
.dialog-actions.stacked {
  flex-direction: column;
}

.dialog-actions .dialog-btn {
  flex: 1;
  min-height: 48px;
  padding: 12px 14px;
  font-size: var(--t-body);
}

.dialog-actions .btn-secondary {
  color: var(--text-main);
  background: var(--fill);
  border: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* ==========================================================
   お知らせ（更新・達成）
   ========================================================== */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-height) + var(--tabbar-bottom) + 14px);
  z-index: 2500;
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 18px;
  border-radius: 28px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  backdrop-filter: blur(30px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
  transform: translateX(-50%);
  animation: toastUp 0.4s var(--spring);
}

@keyframes toastUp {
  from { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.update-toast-content {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.update-toast-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.update-toast-title {
  font-size: var(--t-body);
  font-weight: 600;
}

.update-toast-desc {
  font-size: var(--t-footnote);
  color: var(--text-sub);
}

.update-toast-actions {
  display: flex;
  gap: 10px;
}

.update-toast-actions .btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  font-size: var(--t-subhead);
}

/* 達成のお知らせ（iOS版 ToastStack: 黄色みのガラスのカプセル） */
#achievement-toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  z-index: 2600;
  width: calc(100% - 32px);
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.achievement-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--sheet-bg);
  background-image: linear-gradient(rgba(255, 204, 0, 0.15), rgba(255, 204, 0, 0.15));
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  backdrop-filter: blur(30px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
  font-size: var(--t-subhead);
  font-weight: 600;
  color: var(--text-main);
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: toastDown 0.45s var(--spring);
}

.achievement-toast.hide {
  opacity: 0;
  transform: translateY(-16px) scale(0.92);
}

.achievement-toast-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes toastDown {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ホーム画面に追加の案内（iPhone の Safari） */
.ios-prompt {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 9999;
  width: 90%;
  max-width: 360px;
  padding: 22px;
  border-radius: 28px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  backdrop-filter: blur(30px) saturate(1.8);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
  animation: toastUp 0.45s var(--ease-out);
}

.ios-prompt-content {
  text-align: center;
}

.ios-prompt-title {
  margin-bottom: 6px;
  font-size: var(--t-body);
  font-weight: 600;
}

.ios-prompt-desc {
  margin-bottom: 16px;
  font-size: var(--t-footnote);
  color: var(--text-sub);
  line-height: 1.6;
}

.btn-close-prompt {
  padding: 10px 24px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--primary);
  font-size: var(--t-subhead);
  font-weight: 600;
}

.ios-prompt-arrow {
  display: none;
}

/* ==========================================================
   スクロールバー・ページ先頭へ・位置表示
   ========================================================== */
.scrollable-y::-webkit-scrollbar,
.tab-view::-webkit-scrollbar {
  display: none;
}

.scrollable-y,
.tab-view {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.custom-scrollbar {
  position: fixed;
  top: calc(var(--header-height) + env(safe-area-inset-top));
  right: 0;
  width: 20px;
  height: calc(100% - var(--header-height) - env(safe-area-inset-top) - var(--tabbar-height) - var(--tabbar-bottom) - 16px);
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.3s;
  touch-action: none;
  display: flex;
  justify-content: center;
}

.custom-scrollbar.visible {
  opacity: 1;
}

.scrollbar-thumb {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 5px;
  min-height: 40px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.55);
  cursor: pointer;
  touch-action: none;
}

.btn-back-to-top {
  position: fixed;
  right: calc(var(--gutter) + env(safe-area-inset-right));
  bottom: calc(var(--tabbar-height) + var(--tabbar-bottom) + 14px);
  z-index: 1500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.btn-back-to-top svg {
  width: 20px;
  height: 20px;
}

.btn-back-to-top.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.scroll-indicator {
  position: fixed;
  top: 50%;
  right: 26px;
  z-index: 1500;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.scroll-indicator.visible {
  opacity: 1;
}

/* ==========================================================
   キーボード・コントローラー操作
   ========================================================== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.form-control:focus-visible,
.search-field input:focus-visible,
.range-field input:focus-visible {
  outline: none;
}

.search-field:focus-within,
.range-field:focus-within {
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.5), var(--glass-shadow);
}

.swipe-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

#gamepad-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--primary-rgb), 0.7) 0%, rgba(var(--primary-rgb), 0.15) 60%, transparent 100%);
  border: 2.5px solid rgba(var(--primary-rgb), 0.85);
  box-shadow: 0 0 16px rgba(var(--primary-rgb), 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  will-change: transform;
}

#gamepad-cursor.active {
  opacity: 1;
}

.gp-hover {
  outline: 2px solid var(--primary) !important;
  outline-offset: 2px;
}

.gp-click {
  animation: gpPulse 0.2s ease-out;
}

@keyframes gpPulse {
  50% { transform: scale(0.94); }
}

/* 仮想キーボード（コントローラー用） */
.gamepad-keyboard {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 9999;
  width: 90%;
  max-width: 600px;
  padding: 16px;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%) translateY(150%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.gamepad-keyboard.active {
  transform: translateX(-50%) translateY(0);
}

.keyboard-preview {
  display: flex;
  gap: 8px;
  align-items: center;
}

.keyboard-preview input {
  flex: 1;
  padding: 12px 16px;
  border-radius: 14px;
  border: none;
  background: var(--fill);
  color: var(--text-main);
  font-size: var(--t-subhead);
  outline: none;
}

.btn-kb-action {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--fill);
  color: var(--text-sub);
  font-size: var(--t-footnote);
  font-weight: 600;
}

.keyboard-layout {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.kb-key {
  flex: 1;
  max-width: 48px;
  height: 46px;
  border-radius: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  font-size: var(--t-subhead);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
}

.kb-key:active,
.kb-key.gp-click {
  background: var(--fill-strong);
  transform: scale(0.95);
}

.kb-key.gp-hover {
  background: var(--primary);
  color: #fff;
}

.kb-row-bottom .kb-key {
  max-width: none;
  flex: auto;
  padding: 0 12px;
  font-size: var(--t-footnote);
}

.kb-space {
  flex: 3 !important;
}

.gamepad-guide-kb {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 4px;
  font-size: var(--t-caption2);
  color: var(--text-sub);
}

.gamepad-guide-kb span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================
   軽量化モード（ガラスのぼかし・アニメーションを控えめに）
   iOS版の liteMode と同じく、半透明の面に置き換える
   ========================================================== */
.lite-mode {
  --glass-bg: rgba(255, 255, 255, 0.86);
  --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --group-bg: rgba(255, 255, 255, 0.92);
  --sheet-bg: rgba(248, 250, 255, 0.98);
}

html[data-theme="dark"].lite-mode {
  --glass-bg: rgba(44, 44, 50, 0.92);
  --glass-shadow: none;
  --group-bg: rgba(28, 28, 32, 0.96);
  --sheet-bg: rgba(28, 30, 42, 0.98);
}

.lite-mode *,
.lite-mode *::before,
.lite-mode *::after {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

.lite-mode .screen.active,
.lite-mode .screen.screen-fade-out,
.lite-mode .tab-view.active,
.lite-mode .swipe-card.next-card-2,
.lite-mode .feedback,
.lite-mode .achievement-toast,
.lite-mode .update-toast,
.lite-mode .custom-dialog-window {
  animation: none !important;
}

.lite-mode .swipe-card.next-card,
.lite-mode .swipe-word-jp {
  filter: none !important;
}

.lite-mode .app-header::before,
.lite-mode .list-top::before {
  background: var(--edge-fade);
}

/* ==========================================================
   スマホの横向き（高さが低いとき）
   ========================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-height: 48px;
    --tabbar-height: 50px;
  }

  .level-badge,
  .custom-select-trigger {
    height: 38px;
  }

  .nav-label {
    display: none;
  }

  .nav-icon {
    font-size: 22px;
  }

  .app-footer {
    max-width: 300px;
  }

  .hero-card {
    padding: 16px 20px;
    gap: 8px;
  }

  .hero-count {
    font-size: 40px;
  }

  .tile-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* テスト: 問題と選択肢を左右に */
  .test-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 12px 16px;
    padding-top: 10px;
  }

  .question-card {
    position: sticky;
    top: 0;
    padding: 16px;
  }

  .question-text {
    font-size: 26px;
  }

  .choices-grid button {
    padding: 10px 14px;
  }

  .session-top {
    gap: 6px;
  }

  .glass-icon-btn {
    width: 38px;
    height: 38px;
  }

  .session-label,
  .session-score,
  .chant-voice {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  /* 振り分け: カードとボタンを横並び */
  .swipe-container {
    flex-direction: row;
    justify-content: center;
    padding-top: 10px;
  }

  .swipe-stage {
    flex: 0 1 auto;
    width: min(60vw, 420px);
    height: 100%;
  }

  .swipe-word-en {
    font-size: 26px;
  }

  .swipe-controls {
    flex-direction: column;
    gap: 14px;
  }

  .btn-circle-action {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .btn-circle-action.undo {
    width: 44px;
    height: 44px;
  }

  .chant-word {
    font-size: 30px;
  }

  .chant-card {
    padding: 16px;
    gap: 8px;
  }

  .chant-play {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }

  .result-container {
    gap: 14px;
  }

  .score-ring {
    width: 120px;
    height: 120px;
  }

  .score-value {
    font-size: 36px;
  }

  .custom-scrollbar,
  .btn-back-to-top {
    display: none !important;
  }

  .sheet.tall {
    height: calc(100dvh - 16px);
  }
}

/* ==========================================================
   広い画面（iPad・パソコン）
   ========================================================== */
@media (min-width: 700px) {
  :root {
    --gutter: 24px;
  }

  .sheet {
    bottom: auto;
    top: 50%;
    border-radius: 34px;
    transform: translateY(calc(-50% + 40px)) scale(0.98);
    opacity: 0;
    transition: transform 0.35s var(--ease-out), opacity 0.25s ease, visibility 0.35s;
  }

  .sheet.open {
    transform: translateY(-50%);
    opacity: 1;
  }

  .sheet.tall {
    height: min(760px, calc(100dvh - 48px));
  }

  .sheet-grabber {
    display: none;
  }

  .book-action-sheet {
    bottom: auto;
    top: 50%;
    transform: translateY(-40%) scale(0.98);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.3s var(--ease-out), opacity 0.2s, visibility 0.3s;
  }

  .book-action-sheet.visible {
    transform: translateY(-50%);
    opacity: 1;
    visibility: visible;
  }

  .book-action-sheet-handle {
    display: none;
  }
}

@media (hover: hover) {
  .tile:hover,
  .hero-card:hover,
  .mode-row:hover,
  .word-item:hover,
  .choices-grid button:not(:disabled):hover {
    border-color: rgba(var(--primary-rgb), 0.35);
  }

  .nav-item:not(.active):hover {
    background: rgba(127, 127, 127, 0.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
