/* SK Study — 単語学習。SK Material App System Design1 で作る（Material Design 1 がベース）
   形・影・部品は Material Design 1（2014 年）: 紙を影（z-depth）で浮かせ、角は 2px、ボタンは高さ 36px・大文字、入力欄は下線だけ、押したときはインクの波紋
   配色は SK Material（SK's Blue）と同じ値: 帯・大きなカード=#2563eb、主ボタン・リンク=#004ac6、FAB=tertiary-container、地=surface-container、紙=surface
   正解・記憶済みは good（SK's Matcha の緑）、まちがい・弱点は error。記憶度は 記憶済み=緑・記憶中=黄・弱点=赤・未学習=灰
   学習の画面は問題を大きく、選択肢は下に横いっぱいで並べる（親指で押しやすく）
   ダークモードはサイトの「表示」で選んだものに合わせる（なければ端末の設定）。SK Material のダーク */
:root {
  --primary: #004ac6; --on-primary: #ffffff; --primary-container: #acbfff; --on-primary-container: #394c84;
  --secondary: #434655; --on-secondary: #ffffff; --secondary-container: #e1e2ed; --on-secondary-container: #191b23;
  --tertiary: #943700; --on-tertiary: #ffffff; --tertiary-container: #bc4800; --on-tertiary-container: #ffede6;
  --error: #ba1a1a; --on-error: #ffffff; --error-container: #ffdad6; --on-error-container: #93000a;
  --good: #006b2c; --on-good: #ffffff; --good-container: #baecbc; --on-good-container: #00531f;
  --accent: #bc4800; --on-accent: #ffede6;
  --st-mastered: #00873a; --st-learning: #ffb300; --st-weak: #ba1a1a; --st-new: #c3c6d7;
  --surface: #ededf9; --surface-dim: #e1e2ed;
  --surface-container-lowest: #faf8ff; --surface-container-low: #faf8ff; --surface-container: #f3f3fe;
  --surface-container-high: #e7e7f3; --surface-container-highest: #e1e2ed;
  --on-surface: #191b23; --on-surface-variant: #434655; --outline: #737686; --outline-variant: #c3c6d7;
  --inverse-surface: #2e3039; --inverse-on-surface: #f0f0fb; --inverse-primary: #b4c5ff;
  /* 上の帯・大きな色のカード */
  --app-bar: #2563eb; --on-app-bar: #eeefff; --hero: #2563eb; --on-hero: #eeefff;
  --chip: #e1e2ed; --on-chip: #191b23;
  /* 言語の色 */
  --lang-en: #004ac6; --lang-ko: #c2185b; --lang-zh: #e64a19; --lang-custom: #00796b; --lang-ja: #546e7a;
  --shadow: rgba(0, 0, 0, .2);
  /* z-depth（MD1 の影） */
  --z1: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .12), 0 1px 5px 0 rgba(0, 0, 0, .2);
  --z2: 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12), 0 2px 4px -1px rgba(0, 0, 0, .2);
  --z3: 0 6px 10px 0 rgba(0, 0, 0, .14), 0 1px 18px 0 rgba(0, 0, 0, .12), 0 3px 5px -1px rgba(0, 0, 0, .2);
  --z4: 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12), 0 5px 5px -3px rgba(0, 0, 0, .2);
  --z5: 0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12), 0 11px 15px -7px rgba(0, 0, 0, .2);
  --font: Roboto, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ko: Roboto, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", var(--font);
  --font-zh: Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", var(--font);
  --ease: cubic-bezier(.4, 0, .2, 1);           /* MD1 の標準の動き */
  --ease-emph: cubic-bezier(0, 0, .2, 1);       /* MD1 の減速の動き */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #b4c5ff; --on-primary: #002a78; --primary-container: #33467e; --on-primary-container: #a4b6f5;
    --secondary: #c3c6d7; --on-secondary: #2e3039; --secondary-container: #32343d; --on-secondary-container: #e1e2ed;
    --tertiary: #ffb596; --on-tertiary: #561f00; --tertiary-container: #bc4800; --on-tertiary-container: #ffede6;
    --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
    --good: #7fdc9b; --on-good: #00391a; --good-container: #0f3a1d; --on-good-container: #baecbc;
    --accent: #bc4800; --on-accent: #ffede6;
    --st-mastered: #7fdc9b; --st-learning: #ffd54f; --st-weak: #ffb4ab; --st-new: #434655;
    --surface: #11131b; --surface-dim: #11131b;
    --surface-container-lowest: #1d1f27; --surface-container-low: #1d1f27; --surface-container: #282a32;
    --surface-container-high: #32343d; --surface-container-highest: #3c3e48;
    --on-surface: #e1e2ed; --on-surface-variant: #c3c6d7; --outline: #8d90a0; --outline-variant: #434655;
    --inverse-surface: #e1e2ed; --inverse-on-surface: #2e3039; --inverse-primary: #0053db;
    --app-bar: #2563eb; --on-app-bar: #eeefff; --hero: #2563eb; --on-hero: #eeefff;
    --chip: #32343d; --on-chip: #e1e2ed;
    --lang-en: #b4c5ff; --lang-ko: #f48fb1; --lang-zh: #ff8a65; --lang-custom: #4db6ac; --lang-ja: #90a4ae;
    --shadow: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #b4c5ff; --on-primary: #002a78; --primary-container: #33467e; --on-primary-container: #a4b6f5;
  --secondary: #c3c6d7; --on-secondary: #2e3039; --secondary-container: #32343d; --on-secondary-container: #e1e2ed;
  --tertiary: #ffb596; --on-tertiary: #561f00; --tertiary-container: #bc4800; --on-tertiary-container: #ffede6;
  --error: #ffb4ab; --on-error: #690005; --error-container: #93000a; --on-error-container: #ffdad6;
  --good: #7fdc9b; --on-good: #00391a; --good-container: #0f3a1d; --on-good-container: #baecbc;
  --accent: #bc4800; --on-accent: #ffede6;
  --st-mastered: #7fdc9b; --st-learning: #ffd54f; --st-weak: #ffb4ab; --st-new: #434655;
  --surface: #11131b; --surface-dim: #11131b;
  --surface-container-lowest: #1d1f27; --surface-container-low: #1d1f27; --surface-container: #282a32;
  --surface-container-high: #32343d; --surface-container-highest: #3c3e48;
  --on-surface: #e1e2ed; --on-surface-variant: #c3c6d7; --outline: #8d90a0; --outline-variant: #434655;
  --inverse-surface: #e1e2ed; --inverse-on-surface: #2e3039; --inverse-primary: #0053db;
  --app-bar: #2563eb; --on-app-bar: #eeefff; --hero: #2563eb; --on-hero: #eeefff;
  --chip: #32343d; --on-chip: #e1e2ed;
  --lang-en: #b4c5ff; --lang-ko: #f48fb1; --lang-zh: #ff8a65; --lang-custom: #4db6ac; --lang-ja: #90a4ae;
  --shadow: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); color: var(--on-surface); background: var(--surface);
  line-height: 1.6; -webkit-font-smoothing: antialiased; letter-spacing: .01em;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
#app:focus { outline: none; }
[lang="ko"] { font-family: var(--font-ko); }
[lang="zh-CN"] { font-family: var(--font-zh); }
.muted { color: var(--on-surface-variant); }
.small { font-size: 12px; }
.muted .ms, .small .ms { font-size: 1.1em; vertical-align: -.18em; margin-right: 2px; }

/* Material Symbols（読み込む前は文字が見えないように） */
.ms {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr;
  font-feature-settings: "liga"; -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
  width: 1em; height: 1em; overflow: hidden; user-select: none; flex: none;
}

/* ---------- 上の帯（MD1 の app bar） ---------- */
:root { --bar-h: 64px; --drawer-w: 256px; }
@media (max-width: 640px) { :root { --bar-h: 56px; } }
.top-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  background: var(--app-bar); color: var(--on-app-bar); box-shadow: var(--z2);
}
.brand { display: inline-flex; align-items: center; gap: 12px; margin-left: 12px; color: inherit; text-decoration: none; font-weight: 500; font-size: 20px; line-height: 28px; border-radius: 2px; }
.brand img { border-radius: 2px; }
.top-title { display: none; flex: 1; min-width: 0; margin-left: 20px; font-size: 20px; line-height: 28px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; }
@media (max-width: 1023px) {
  .brand { display: none; }
  .top-title { display: block; }
}
.beta { font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: .5px; padding: 2px 6px; border-radius: 2px; background: var(--accent); color: var(--on-accent); text-transform: uppercase; }
.top-bar .icon-btn { color: inherit; }
.top-actions { display: flex; align-items: center; gap: 0; }
.top-actions sk-account-button { margin: 0 8px; }

.page { --page-w: 760px; max-width: var(--page-w); margin: 0 auto; padding: 32px 24px calc(48px + env(safe-area-inset-bottom)); }
body[data-view="home"] .page, body[data-view="sets"] .page, body[data-view="mine"] .page, body[data-view="prints"] .page, body[data-view="classes"] .page { --page-w: 1040px; }

/* ---------- 横のメニュー（MD1 の navigation drawer） ---------- */
.drawer {
  position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(320px, calc(100vw - 56px));
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-container-lowest); color: var(--on-surface); box-shadow: var(--z5);
  transform: translateX(-110%); transition: transform .25s var(--ease), visibility 0s linear .25s; visibility: hidden;
}
body.drawer-open .drawer { transform: none; visibility: visible; transition: transform .25s var(--ease-emph); }
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .5); animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.drawer-head {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; flex: none;
  min-height: 164px; padding: calc(16px + env(safe-area-inset-top)) 16px 12px; color: #fff;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, .16) 0 64px, transparent 65px),
    radial-gradient(circle at 62% 120%, rgba(255, 255, 255, .1) 0 96px, transparent 97px),
    linear-gradient(135deg, #004ac6, #2563eb);
}
.drawer-avatar {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  background: var(--accent); color: #fff; font-size: 28px; font-weight: 500; box-shadow: var(--z1);
}
.drawer-who { display: flex; flex-direction: column; min-width: 0; font-size: 14px; line-height: 20px; }
.drawer-who strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-who span { opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-switch {
  position: relative; width: 100%; border: 0; font: inherit; text-align: left; cursor: pointer; align-items: flex-start;
}
.drawer-switch:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.drawer-switch-icon { position: absolute; right: 12px; bottom: 14px; opacity: .85; }
.drawer-head.is-class {
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, .16) 0 64px, transparent 65px),
    radial-gradient(circle at 62% 120%, rgba(255, 255, 255, .1) 0 96px, transparent 97px),
    linear-gradient(135deg, #0b6b4f, #1a9a6c);
}
.drawer-list { flex: 1; padding: 8px 0; }
.drawer-item {
  position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent;
  display: flex; align-items: center; gap: 32px; width: 100%; min-height: 48px; padding: 0 16px;
  border: 0; background: transparent; color: var(--on-surface); font: inherit; font-size: 14px; font-weight: 500; letter-spacing: .1px;
  text-decoration: none; text-align: left; cursor: pointer;
}
.drawer-item .ms { color: var(--on-surface-variant); }
.drawer-item:hover { background: color-mix(in srgb, var(--on-surface) 5%, transparent); }
.drawer-item[aria-current="page"] { color: var(--primary); background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.drawer-item[aria-current="page"] .ms { color: var(--primary); }
.drawer-item:focus-visible { outline-offset: -3px; }
.drawer-divider { border: 0; border-top: 1px solid var(--outline-variant); margin: 8px 0; }
.drawer-sub { margin: 0; padding: 8px 16px 4px; font-size: 14px; font-weight: 500; color: var(--on-surface-variant); }
.drawer-foot { margin: 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 12px; line-height: 18px; color: var(--on-surface-variant); }
/* パソコン: 上の帯の下に出しっぱなし（☰ でしまえる）。本文はその右 */
@media (min-width: 1024px) {
  .drawer {
    top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 15; width: var(--drawer-w);
    box-shadow: none; border-right: 1px solid var(--outline-variant); transform: none; visibility: visible; transition: transform .25s var(--ease);
  }
  .drawer-head { min-height: 136px; padding-top: 16px; }
  body.drawer-closed .drawer { transform: translateX(-110%); visibility: hidden; transition: transform .25s var(--ease), visibility 0s linear .25s; }
  .scrim { display: none; }
  body:not(.drawer-closed):not([data-view="learn"]):not([data-view="print"]):not([data-view="gate"]) .page {
    margin-left: calc(var(--drawer-w) + max(0px, (100% - var(--drawer-w) - var(--page-w)) / 2)); margin-right: 0;
  }
}
body[data-view="learn"] .drawer, body[data-view="print"] .drawer, body[data-view="gate"] .drawer,
body[data-view="learn"] .scrim, body[data-view="print"] .scrim, body[data-view="gate"] .scrim { display: none; }
@media (prefers-reduced-motion: reduce) { .drawer, body.drawer-open .drawer { transition: none; } }

/* ページの見出し */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 24px; }
.page-head h1, body[data-view="prints"] .page > .section > .section-head h2, body[data-view="classes"] .page > .section > .section-head h2 {
  font-size: 34px; line-height: 40px; font-weight: 400;
}
.page-head p { margin: 4px 0 0; font-size: 14px; color: var(--on-surface-variant); }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
body[data-view="prints"] .page > .section > .section-head, body[data-view="classes"] .page > .section > .section-head { margin-bottom: 24px; }

/* MD1 の FAB（スマートフォンのマイ単語帳） */
.fab {
  position: fixed; right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 12;
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; isolation: isolate;
  background: var(--accent); color: var(--on-accent); box-shadow: var(--z3); text-decoration: none; transition: box-shadow .28s var(--ease);
}
.fab:hover { box-shadow: var(--z4); }
.fab:active { box-shadow: var(--z5); }
@media (min-width: 1024px) { .fab { display: none; } }
@media (max-width: 1023px) {
  body[data-view="mine"] .page-head-actions .filled-btn { display: none; }
  body[data-view="mine"] .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* ---------- ログイン ---------- */
body[data-view="gate"] .top-bar { display: none; }
body[data-view="gate"] .page { max-width: none; padding: 0; }
.gate {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--app-bar) 0 38%, var(--surface) 38%);
}
.gate-card { width: min(440px, 100%); border-radius: 2px; overflow: hidden; background: var(--surface-container-lowest); box-shadow: var(--z4); }
.gate-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 24px 24px;
  background: radial-gradient(circle at 90% 0, rgba(255, 255, 255, .14) 0 90px, transparent 91px), linear-gradient(135deg, #004ac6, #2563eb); color: #fff;
}
.gate-hero img { border-radius: 14px; box-shadow: var(--z2); }
.gate-name { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; font-size: 24px; line-height: 32px; font-weight: 500; }
.gate-tagline { margin: 0; max-width: 26em; font-size: 14px; opacity: .87; }
.gate-body { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.gate-body h1 { font-size: 20px; line-height: 28px; font-weight: 500; }
.gate-body > p { margin: 0; font-size: 14px; }
.gate-btn { width: 100%; min-height: 44px; margin-top: 4px; }
.gate-body .loading { padding: 12px 0; }
.gate-features { list-style: none; display: grid; gap: 14px; margin: 12px 0 0; padding: 20px 0 0; border-top: 1px solid var(--outline-variant); }
.gate-features li { display: flex; align-items: flex-start; gap: 16px; }
.gate-features .ms { color: var(--primary); }
.gate-features span { display: flex; flex-direction: column; }
.gate-features strong { font-size: 14px; font-weight: 500; }
.gate-features small { font-size: 13px; color: var(--on-surface-variant); }

/* ---------- ボタン ---------- */
.filled-btn, .tonal-btn, .outlined-btn, .text-btn, .danger-btn, .pill-btn {
  position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  isolation: isolate; min-height: 36px; min-width: 88px; padding: 0 16px; border-radius: 2px; border: 0; cursor: pointer;
  font-weight: 500; font-size: 14px; letter-spacing: .5px; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  transition: box-shadow .28s var(--ease), background-color .2s var(--ease);
}
.filled-btn .ms, .tonal-btn .ms, .outlined-btn .ms, .text-btn .ms, .danger-btn .ms { font-size: 18px; margin-left: -4px; }
/* raised button（影で浮かせる。押すと 8dp まで上がる） */
.filled-btn { background: var(--primary); color: var(--on-primary); box-shadow: var(--z1); }
.tonal-btn { background: var(--surface-container-lowest); color: var(--on-surface); box-shadow: var(--z1); }
.danger-btn { background: var(--error); color: var(--on-error); box-shadow: var(--z1); }
.pill-btn { min-height: 32px; min-width: 64px; padding: 0 12px; background: var(--primary); color: var(--on-primary); font-size: 13px; box-shadow: var(--z1); }
.filled-btn:hover, .tonal-btn:hover, .danger-btn:hover, .pill-btn:hover { box-shadow: var(--z2); }
.filled-btn:active, .tonal-btn:active, .danger-btn:active, .pill-btn:active { box-shadow: var(--z4); }
/* flat button（MD1 に枠のボタンはないので、outlined も flat にする） */
.outlined-btn { background: transparent; color: var(--primary); }
.outlined-btn[data-danger] { color: var(--error); }
.text-btn { background: transparent; color: var(--primary); padding: 0 8px; }
/* ダイアログの中のボタンは flat（MD1: ダイアログは flat ボタンで、内容と一体にする） */
.dialog .filled-btn, .dialog .tonal-btn, .dialog .danger-btn { background: transparent; box-shadow: none; }
.dialog .filled-btn, .dialog .tonal-btn { color: var(--primary); }
.dialog .danger-btn { color: var(--error); }
.text-btn .ms { margin-left: -2px; }
.wide { width: 100%; }
.filled-btn::after, .tonal-btn::after, .outlined-btn::after, .text-btn::after, .danger-btn::after, .pill-btn::after, .icon-btn::after,
.chip::after, .choice::after, .set-row::after {
  content: ""; position: absolute; inset: 0; z-index: -1; background: currentColor; opacity: 0; transition: opacity .15s linear; pointer-events: none; border-radius: inherit;
}
.filled-btn:hover::after, .tonal-btn:hover::after, .outlined-btn:hover::after, .text-btn:hover::after, .danger-btn:hover::after, .pill-btn:hover::after, .icon-btn:hover::after,
.chip:hover::after, .choice:not(:disabled):hover::after, .set-row:hover::after { opacity: .08; }
.filled-btn:active::after, .tonal-btn:active::after, .outlined-btn:active::after, .text-btn:active::after, .danger-btn:active::after, .pill-btn:active::after, .icon-btn:active::after,
.chip:active::after, .choice:not(:disabled):active::after { opacity: .12; }
button:disabled { cursor: default; }
.filled-btn:disabled, .tonal-btn:disabled, .danger-btn:disabled {
  background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); box-shadow: none;
}
.outlined-btn:disabled, .text-btn:disabled { color: color-mix(in srgb, var(--on-surface) 26%, transparent); }
button:disabled::after { display: none; }
/* 押したところから広がる波紋（app.js。MALU・Nagi と同じ） */
.icon-btn, .chip, .choice, .set-row, .segmented button, .print-tabs button, .pa-opt, .map-cell, .tc-mark, .mk-roles button { isolation: isolate; }
/* MD1 のインク（濃いめに広がって消える） */
.ripple { position: absolute; z-index: -1; border-radius: 50%; background: currentColor; opacity: .25; transform: scale(0); pointer-events: none; animation: ripple .6s var(--ease) forwards; }
@keyframes ripple { 55% { transform: scale(1); opacity: .25; } to { transform: scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ripple { display: none; } }

.icon-btn {
  position: relative; overflow: hidden; display: inline-grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: transparent; color: var(--on-surface-variant); cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn::after { inset: 4px; }
.icon-btn.speak { color: var(--primary); }
.icon-btn.speak.is-speaking::before { content: ""; position: absolute; inset: 4px; z-index: -1; border-radius: 50%; background: var(--primary-container); }
.icon-btn.speak.is-speaking .ms { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.speak.is-speaking .ms { animation: none; } }

.back-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px 8px 8px; margin: 0 0 4px -8px;
  border-radius: 2px; color: var(--on-surface-variant); text-decoration: none; font-weight: 500; font-size: 14px; letter-spacing: .1px;
}
.back-link:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }

.lang-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 2px; font-size: 12px; font-weight: 500; letter-spacing: .5px;
  color: var(--lang-custom); background: color-mix(in srgb, var(--lang-custom) 13%, transparent);
}
.lang-badge.lang-en { color: var(--lang-en); background: color-mix(in srgb, var(--lang-en) 13%, transparent); }
.lang-badge.lang-ko { color: var(--lang-ko); background: color-mix(in srgb, var(--lang-ko) 13%, transparent); }
.lang-badge.lang-zh { color: var(--lang-zh); background: color-mix(in srgb, var(--lang-zh) 13%, transparent); }
.lang-badge.lang-ja { color: var(--lang-ja); background: color-mix(in srgb, var(--lang-ja) 13%, transparent); }

.thumb {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  font-size: 18px; font-weight: 500; color: #fff; background: var(--lang-custom);
}
.thumb.lang-en { background: var(--lang-en); }
.thumb.lang-ko { background: var(--lang-ko); }
.thumb.lang-zh { background: var(--lang-zh); }
:root[data-theme="dark"] .thumb { color: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .thumb { color: var(--surface); } }

/* 輪のメーター */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-container-highest); }
.ring-fg { fill: none; stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease-emph); }
.ring-label { position: relative; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ring-check { position: relative; font-size: 20px; color: var(--st-mastered); font-variation-settings: "FILL" 0, "wght" 700, "GRAD" 0, "opsz" 24; }

/* ---------- ホーム ---------- */
.home-head { margin: 0 0 24px; }
.home-date { margin: 0; font-size: 14px; color: var(--on-surface-variant); }
.home-head h1 { margin: 4px 0 0; font-size: 34px; line-height: 40px; font-weight: 400; overflow-wrap: anywhere; }
.home-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; margin-bottom: 40px; }
.today {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 20px;
  margin: 0; padding: 24px; border-radius: 2px; overflow: hidden; position: relative; isolation: isolate;
  background: var(--hero); color: var(--on-hero); box-shadow: var(--z2);
}
.today-label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 500; letter-spacing: .1px; opacity: .87; }
.today-label .ms { font-size: 20px; }
.today-count { margin: 4px 0 0; font-size: 56px; font-weight: 300; line-height: 1; letter-spacing: -.25px; font-variant-numeric: tabular-nums; }
.today-count small { font-size: 24px; font-weight: 400; margin-left: 4px; letter-spacing: 0; }
.today-sub { margin: 12px 0 0; font-size: 14px; letter-spacing: .25px; }
/* 色のカードの上の目立つボタンは accent（MD1 の FAB と同じ色・影） */
.today-start { min-height: 48px; padding: 0 24px; border-radius: 2px; font-size: 14px; background: var(--accent); color: var(--on-accent); box-shadow: var(--z3); }
.today-start:hover { box-shadow: var(--z4); }
.today-start .ms { font-size: 24px; }
/* 記録（右に縦に 3 つ） */
.stat-grid { display: grid; grid-template-rows: repeat(3, 1fr); gap: 16px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-radius: 2px; background: var(--surface-container-low); box-shadow: var(--z1); }
.stat-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; color: #fff; background: #2563eb; }
.tone-fire .stat-icon { background: #bc4800; }
.tone-good .stat-icon { background: #006b2c; }
.stat-text { display: flex; flex-direction: column; min-width: 0; }
.stat-text strong { font-size: 24px; line-height: 30px; font-weight: 400; font-variant-numeric: tabular-nums; }
.stat-text small { margin-left: 2px; font-size: 14px; }
.stat-text span { font-size: 12px; letter-spacing: .3px; color: var(--on-surface-variant); }

/* 単語セットのカード（続きから・おすすめ） */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.set-card { display: flex; flex-direction: column; border-radius: 2px; overflow: hidden; background: var(--surface-container-low); box-shadow: var(--z1); transition: box-shadow .28s var(--ease); }
.set-card:hover { box-shadow: var(--z4); }
.set-card-main { position: relative; overflow: hidden; isolation: isolate; flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 16px; color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.set-card-main:focus-visible { outline-offset: -3px; }
.set-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.set-card-title { font-size: 20px; line-height: 28px; font-weight: 400; overflow-wrap: anywhere; }
.set-card-actions { display: flex; gap: 4px; padding: 8px; border-top: 1px solid var(--outline-variant); }

/* ショートカット */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.tile {
  position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px; border: 0; border-radius: 2px;
  background: var(--surface-container-low); box-shadow: var(--z1); color: var(--on-surface); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
  transition: box-shadow .28s var(--ease);
}
.tile:hover { box-shadow: var(--z4); }
.tile-icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px; border-radius: 50%; background: var(--primary-container); color: var(--primary); }
.tile strong { font-size: 16px; font-weight: 500; }
.tile > span:not(.tile-icon) { font-size: 13px; color: var(--on-surface-variant); }
@media (max-width: 760px) {
  .home-top { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); grid-template-rows: none; gap: 8px; }
  .stat-card { flex-direction: column; text-align: center; gap: 6px; padding: 12px 8px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-icon .ms { font-size: 18px; }
  .stat-text strong { font-size: 20px; line-height: 26px; }
}

.section { margin: 0 0 32px; }
.section h2 { font-size: 20px; line-height: 28px; font-weight: 500; }
.section > h2 { margin-bottom: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 16px; border: 0;
  background: var(--chip); color: var(--on-chip); font-weight: 400; font-size: 13px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip .ms { font-size: 18px; margin-left: -4px; }
/* 選んだチップは primary の色 */
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* 単語セットの行（MD1 のリストを、影のある白いカードにのせる） */
.set-list { display: flex; flex-direction: column; border-radius: 2px; overflow: hidden; background: var(--surface-container-low); }
.set-row { position: relative; display: flex; align-items: center; gap: 16px; padding: 12px 16px; min-height: 72px; }
.set-row + .set-row { border-top: 1px solid var(--outline-variant); }
.set-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-row-link { color: var(--on-surface); text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.set-row-link::before { content: ""; position: absolute; inset: 0; } /* 行のどこを押してもセットへ */
.set-row-link:focus-visible { outline: none; }
.set-row-link:focus-visible::before { outline: 3px solid var(--primary); outline-offset: -3px; border-radius: 2px; }
.set-row-sub { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; color: var(--on-surface-variant); flex-wrap: wrap; }
.set-row-title { font-weight: 500; font-size: 16px; line-height: 24px; letter-spacing: .15px; overflow-wrap: anywhere; }
.set-row-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; letter-spacing: .4px; color: var(--on-surface-variant); }
.set-row-meta > span { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.set-row-meta .ms { font-size: 15px; }
.set-row-meta .due { color: var(--tertiary); font-weight: 500; }
.set-row-end { position: relative; display: flex; align-items: center; gap: 10px; }

.empty { color: var(--on-surface-variant); padding: 16px; margin: 0; }
.empty-card {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 28px 20px; border-radius: 2px; background: var(--surface-container-low); color: var(--on-surface); font-size: 14px; letter-spacing: .25px;
}
.empty-card p { margin: 0; max-width: 34em; }
.empty-card .filled-btn, .empty-card .tonal-btn { margin-top: 12px; }
.empty-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; margin-bottom: 8px; overflow: visible;
  font-size: 28px; background: var(--primary-container); color: var(--on-primary-container);
}

.soon { display: flex; gap: 16px; align-items: flex-start; padding: 20px; border-radius: 2px; background: var(--surface-container-low); margin-bottom: 20px; }
.soon h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; }
.soon p { margin: 4px 0 0; color: var(--on-surface-variant); font-size: 14px; }
.soon-icon { font-size: 32px; color: var(--tertiary); }
.soon-pill { font-size: 12px; font-weight: 500; letter-spacing: .5px; padding: 2px 8px; border-radius: 2px; background: var(--tertiary-container); color: var(--on-tertiary-container); }
.footnote { text-align: center; font-size: 12px; letter-spacing: .4px; color: var(--on-surface-variant); }

/* ---------- 単語セット ---------- */
.set-head { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 20px; }
.set-head h1 { font-size: 24px; line-height: 32px; font-weight: 400; margin: 4px 0 6px; overflow-wrap: anywhere; }
.set-desc { margin: 0 0 6px; }
.set-head .muted { margin: 0; }

.memory-card, .start-card { padding: 20px; border-radius: 2px; background: var(--surface-container-low); margin-bottom: 12px; }
.memory-card h2 { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; margin-bottom: 12px; text-align: center; }
.memory-body { display: flex; align-items: center; justify-content: center; gap: 28px; flex-wrap: wrap; }
.donut { position: relative; flex: none; }
.donut svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut svg circle { transition: stroke-dasharray .8s var(--ease-emph); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-size: 34px; font-weight: 400; line-height: 1; }
.donut-center small { font-size: 14px; margin-left: 2px; }
.donut-center span { font-size: 12px; color: var(--on-surface-variant); margin-top: 4px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 180px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; letter-spacing: .25px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.legend-due { border-top: 1px solid var(--outline-variant); padding-top: 8px; color: var(--tertiary); }
.legend-due .ms { font-size: 16px; width: 12px; overflow: visible; display: inline-grid; place-items: center; }

.start-card { display: flex; flex-direction: column; gap: 12px; }
.start-btn { min-height: 48px; border-radius: 2px; font-size: 14px; }
.start-btn .ms { font-size: 24px; }
.start-note { margin: 0; font-size: 12px; letter-spacing: .4px; color: var(--on-surface-variant); text-align: center; }
.start-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; }
.option { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.option > span { white-space: nowrap; color: var(--on-surface-variant); }
.option .field-select { width: auto; min-height: 40px; padding: 6px 12px; }

.set-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }

/* 単語の一覧（上: 外国語、下: 日本語、右: 記憶度の輪） */
.word-list { list-style: none; margin: 0; padding: 0; border-radius: 2px; overflow: hidden; background: var(--surface-container-low); }
.word-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; min-height: 56px; }
.word-row + .word-row { border-top: 1px solid var(--outline-variant); }
.word-pair { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.word-line { display: grid; grid-template-columns: 3.2rem 1fr; align-items: baseline; gap: 8px; }
.word-tag { font-size: 12px; letter-spacing: .5px; font-weight: 500; color: var(--lang-custom); }
.word-tag.lang-en { color: var(--lang-en); }
.word-tag.lang-ko { color: var(--lang-ko); }
.word-tag.lang-zh { color: var(--lang-zh); }
.word-tag.lang-ja { color: var(--lang-ja); }
.word-text { min-width: 0; overflow-wrap: anywhere; }
.word-w { font-weight: 500; font-size: 16px; letter-spacing: .15px; margin-right: 8px; }
.word-r { display: block; font-size: 12px; line-height: 1.3; color: var(--on-surface-variant); }
.word-ex { display: flex; flex-direction: column; font-size: 12px; letter-spacing: .25px; color: var(--on-surface-variant); margin-left: calc(3.2rem + 8px); }
.word-row > .speak { width: 40px; height: 40px; }
.word-row > .speak::after { inset: 0; }
.word-row > .speak .ms { font-size: 20px; }
.word-status { flex: none; display: grid; }

/* ---------- 学習（問題は真ん中・答えは下） ---------- */
body[data-view="learn"] .top-bar { display: none; }
body[data-view="learn"] .page { padding-bottom: 0; }
.learn {
  position: relative; display: flex; flex-direction: column; max-width: 600px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh; padding-top: env(safe-area-inset-top);
}
.learn-head { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 8px 0; font-size: 14px; letter-spacing: .1px; }
.learn-head .icon-btn { margin-left: -12px; }
.learn-title { flex: 1; min-width: 0; color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learn-level { display: flex; align-items: center; gap: 8px; }
.level-dots { display: inline-flex; gap: 3px; }
.level-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-container-highest); }
.level-dots i.on { background: var(--primary); }
.retry-pill { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 500; color: var(--tertiary); }
.retry-pill .ms { font-size: 15px; }
.learn-count { font-weight: 500; color: var(--primary); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.learn-line { height: 4px; background: color-mix(in srgb, var(--primary) 25%, transparent); border-radius: 0; overflow: hidden; }
.learn-line span { display: block; height: 100%; width: 0; border-radius: 0; background: var(--primary); transition: width .4s var(--ease-emph); }
.learn-body { flex: 1; display: flex; flex-direction: column; }

.q-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; min-height: 36vh; padding: 24px 0;
}
.q-tag { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: var(--on-surface-variant); font-size: 14px; letter-spacing: .1px; }
.q-tag .ms { font-size: 16px; }
.q-text { margin: 0; font-size: clamp(32px, 8vw, 45px); font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.q-reading { margin: 0; color: var(--on-surface-variant); }
.a-area { display: flex; flex-direction: column; gap: 12px; padding: 0 0 calc(16px + env(safe-area-inset-bottom)); }

/* 4 択（横いっぱいの行を重ねる） */
.choices { display: flex; flex-direction: column; border-top: 1px solid var(--outline-variant); margin: 0 -16px; }
/* M3 のリストの行（押すと重ね色と波紋） */
.choice {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; padding: 10px 56px; border: 0; border-bottom: 1px solid var(--outline-variant); -webkit-tap-highlight-color: transparent;
  background: transparent; color: var(--on-surface); font-size: 20px; font-weight: 400; cursor: pointer; text-align: center;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.choice-num {
  position: absolute; left: 16px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 12px; font-weight: 500; color: var(--on-surface-variant); background: var(--surface-container-highest);
}
@media (hover: none) { .choice-num { display: none; } }
.choice-text { overflow-wrap: anywhere; }
.choice-none { color: var(--on-surface-variant); font-size: 16px; font-weight: 500; }
.choice.is-correct { background: var(--good-container); color: var(--on-good-container); }
.choice.is-correct .choice-num { background: var(--good); color: var(--on-good); border-color: transparent; }
.choice.is-wrong { background: var(--error-container); color: var(--on-error-container); }
.choice.is-wrong .choice-num { background: var(--error); color: var(--on-error); border-color: transparent; }
.choice:disabled:not(.is-correct):not(.is-wrong):not(.is-picked) { color: color-mix(in srgb, var(--on-surface) 38%, transparent); }

/* 書き取り */
.write-form { display: flex; gap: 8px; width: 100%; max-width: 420px; margin-top: 20px; }
.write-input {
  flex: 1; min-width: 0; min-height: 56px; padding: 8px 16px; text-align: center; font-size: 24px;
  border: 0; border-radius: 0; box-shadow: inset 0 -1px 0 var(--outline);
  background: transparent; color: var(--on-surface);
}
.write-input:focus { outline: none; box-shadow: inset 0 -2px 0 var(--primary); }
.write-input:disabled { opacity: .7; }
.write-form .filled-btn { min-height: 48px; align-self: flex-end; border-radius: 2px; }
.write-helpers { display: flex; justify-content: center; gap: 4px; }
.hint { margin: 0; text-align: center; font-weight: 500; letter-spacing: .12em; color: var(--tertiary); }

/* ○・× */
.q-area { position: relative; }
.judge {
  position: absolute; left: 50%; top: 50%; z-index: 4; width: 170px; height: 170px; margin: -85px 0 0 -85px;
  pointer-events: none; opacity: 0;
}
.judge.is-ok::before {
  content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 18px solid color-mix(in srgb, var(--primary) 80%, transparent);
}
.judge.is-ng::before, .judge.is-ng::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 170px; height: 18px; margin: -9px 0 0 -85px; border-radius: 2px;
  background: color-mix(in srgb, var(--error) 80%, transparent); transform: rotate(45deg);
}
.judge.is-ng::after { transform: rotate(-45deg); }
.judge.show { animation: judge .9s var(--ease-emph) forwards; }
@keyframes judge {
  0% { opacity: 0; transform: scale(.6); }
  20% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) { .judge.show { animation-duration: .01s; opacity: 0; } }

/* 答え合わせ */
.feedback:empty { display: none; }
.feedback { display: flex; flex-direction: column; gap: 8px; animation: rise .3s var(--ease-emph); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .feedback { animation: none; } }
.verdict { margin: 0; font-size: 24px; line-height: 28px; font-weight: 400; }
.verdict.ok { color: var(--good); }
.verdict.ng { color: var(--error); }
.your-answer { margin: 0; color: var(--on-surface-variant); }
.your-answer span { text-decoration: line-through; text-decoration-color: var(--error); }
.detail { padding: 12px 16px; border-radius: 2px; background: var(--surface-container-low); }
.detail-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-row .speak { width: 32px; height: 32px; }
.detail-w { font-size: 24px; font-weight: 400; }
.detail-r { color: var(--on-surface-variant); }
.detail-m { margin: 2px 0 0; font-weight: 500; }
.detail-ex { display: flex; flex-direction: column; margin: 6px 0 0; font-size: 14px; letter-spacing: .25px; color: var(--on-surface-variant); }
.fix-row { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0; }
.next-btn { min-height: 48px; border-radius: 2px; font-size: 14px; width: 100%; }
.a-area .next-btn { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 3; box-shadow: var(--z3); }

/* 単語カード（めくると裏返る） */
.card-area { flex: 1; display: flex; align-items: center; padding: 20px 0; }
.flashcard { width: 100%; perspective: 1400px; min-height: 320px; cursor: pointer; border-radius: 2px; -webkit-tap-highlight-color: transparent; }
.flashcard:focus-visible { outline-offset: 4px; }
.flashcard-inner { position: relative; display: grid; min-height: 320px; transform-style: preserve-3d; transition: transform .55s var(--ease-emph); }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 28px 20px; border-radius: 2px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface-container-low); box-shadow: var(--z2);
}
.face-back { transform: rotateY(180deg); background: var(--hero); color: var(--on-hero); }
.face-back .face-tap { color: inherit; opacity: .7; }
.face-big { margin: 0; font-size: clamp(32px, 7vw, 45px); font-weight: 400; line-height: 1.25; overflow-wrap: anywhere; }
.face-reading, .face-sub { margin: 0; font-size: 16px; opacity: .85; }
.face-ex { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 0; font-size: 14px; opacity: .85; max-width: 30em; }
.face-tap { display: flex; align-items: center; gap: 4px; margin: 12px 0 0; font-size: 12px; letter-spacing: .4px; color: var(--on-surface-variant); }
.face-tap .ms { font-size: 18px; }
.face-back .speak { color: inherit; }
@media (prefers-reduced-motion: reduce) { .flashcard-inner { transition: none; } }
.rate { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rate .filled-btn, .rate .outlined-btn { min-height: 48px; border-radius: 2px; font-size: 14px; }
.rate-ng { color: var(--error); background: var(--surface-container-lowest); box-shadow: var(--z1); }
.rate-ok { background: var(--good); color: var(--on-good); }
.shortcuts { margin: 0; text-align: center; font-size: 12px; letter-spacing: .3px; color: var(--on-surface-variant); }
.shortcuts kbd { font: inherit; font-weight: 500; padding: 1px 7px; margin: 0 4px 0 8px; border-radius: 2px; border: 1px solid var(--outline-variant); border-bottom-width: 2px; background: var(--surface-container-low); }
@media (hover: none) { .shortcuts { display: none; } }

/* 小テスト */
.start-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.start-more .tonal-btn, .start-more .outlined-btn { min-height: 40px; }
.test-note { display: flex; align-items: center; justify-content: center; gap: 4px; color: var(--primary); font-weight: 500; }
.test-note .ms { font-size: 18px; }
.test-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; margin-right: 6px; border-radius: 2px; background: var(--tertiary-container); color: var(--on-tertiary-container); font-size: 12px; font-weight: 500; letter-spacing: .5px; }
.test-pill.big { height: 28px; font-size: 14px; letter-spacing: .1px; margin: 0; }
.choice.is-picked { background: var(--secondary-container); color: var(--on-secondary-container); }
.test-list { list-style: none; margin: 12px 0 0; padding: 0; width: 100%; text-align: left; border-top: 1px solid var(--outline-variant); }
.test-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--outline-variant); }
.test-q { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.test-prompt { font-weight: 500; font-size: 16px; }
.test-type { font-size: 12px; color: var(--on-surface-variant); border: 1px solid var(--outline-variant); border-radius: 2px; padding: 0 4px; }
.test-given, .test-correct { flex-basis: 100%; font-size: 14px; color: var(--on-surface-variant); }
.test-given s { text-decoration-color: var(--error); color: var(--error); }
.test-row.ok .test-correct strong { color: var(--good); }

/* 結果 */
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 24px 0 32px; }
.result .ring-label { font-size: 34px; font-weight: 400; }
.result h2 { font-size: 24px; line-height: 32px; font-weight: 400; }
.result-score { margin: 0; color: var(--on-surface-variant); font-weight: 500; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.result-list { list-style: none; margin: 12px 0 0; padding: 0; width: 100%; text-align: left; border-top: 1px solid var(--outline-variant); }
.result-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--outline-variant); }
.result-row .word-pair { gap: 0; }
.mark { flex: none; width: 28px; text-align: center; font-size: 24px; font-weight: 500; line-height: 1; }
.mark.ok { color: var(--primary); }
.mark.ng { color: var(--error); }

/* ---------- 単語帳を作る ---------- */
.edit-bar {
  position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top)); z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; background: var(--surface);
}
.edit-bar .back-link { margin: 0 0 0 -8px; }
.edit-title { font-size: 24px; line-height: 32px; font-weight: 400; margin: 4px 0 16px; }
.edit-card { display: flex; flex-direction: column; gap: 16px; padding: 20px; border-radius: 2px; background: var(--surface-container-low); margin-bottom: 16px; }
.edit-card .section-head { margin: 0; }
.edit-card h2 { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field-label { font-size: 12px; font-weight: 400; letter-spacing: .2px; color: var(--on-surface-variant); transition: color .2s var(--ease); }
.field:focus-within .field-label { color: var(--primary); }
.field-note { font-size: 12px; letter-spacing: .4px; color: var(--on-surface-variant); }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-input, .field-select {
  width: 100%; min-height: 44px; padding: 8px 2px; border-radius: 0; font-size: 16px; letter-spacing: .15px;
  border: 0; border-bottom: 1px solid var(--outline); background: transparent; color: var(--on-surface);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field-input:hover, .field-select:hover { border-bottom-color: var(--on-surface); }
.field-select { background-color: transparent; cursor: pointer; }
.field-select option { background: var(--surface-container-lowest); color: var(--on-surface); }
textarea.field-input { resize: vertical; line-height: 1.5; }
.field-input:focus, .field-select:focus { outline: none; border-bottom-color: var(--primary); box-shadow: 0 1px 0 var(--primary); }
.share-url { font-size: 12px; word-break: break-all; margin-top: 8px; }

.edit-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.edit-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: start; padding: 8px 4px; border-radius: 0; background: transparent; border-bottom: 1px solid var(--outline-variant); }
.edit-num { padding-top: 12px; text-align: center; font-size: 12px; font-weight: 500; color: var(--on-surface-variant); }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.edit-fields .field-input { min-height: 40px; padding: 6px 2px; }
.edit-extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-tools { display: flex; }
.paste { border-radius: 2px; background: var(--surface-container); padding: 4px 16px; }
.paste summary { display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; font-weight: 500; color: var(--primary); list-style: none; }
.paste summary::-webkit-details-marker { display: none; }
.paste[open] { padding-bottom: 14px; }
.paste[open] .field-input { margin: 4px 0 10px; }
.form-error { margin: 0 0 16px; padding: 12px 16px; border-radius: 2px; background: var(--error-container); color: var(--on-error-container); font-weight: 500; }
.edit-bottom { display: flex; justify-content: flex-end; }

/* ---------- 受け取り ---------- */
.import { max-width: 640px; margin: 16px auto 0; display: flex; flex-direction: column; gap: 12px; }
.import .set-head { margin: 0; }
.import p { margin: 0; }
.import-label { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--primary); }
.import .result-actions { justify-content: flex-start; margin-top: 6px; }

/* ---------- メッセージ・読み込み ---------- */
.message { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 64px 16px; }
.message h1 { font-size: 24px; line-height: 32px; font-weight: 400; }
.message p { margin: 0 0 8px; color: var(--on-surface-variant); }
.message-icon { font-size: 48px; color: var(--outline); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 64px 0; color: var(--on-surface-variant); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--primary); border-right-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.warn { display: flex; align-items: center; gap: 6px; color: var(--error); }

/* ---------- プリント（左にもとのプリント、右で答える） ---------- */
body[data-view="print"] .top-bar { display: none; }
body[data-view="print"] .page { max-width: none; padding: 0; }
.print-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.print-head {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: calc(4px + env(safe-area-inset-top)) 8px 4px;
  background: var(--app-bar); color: var(--on-app-bar); box-shadow: var(--z2);
}
.print-head .icon-btn { color: inherit; }
.print-title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-progress { font-size: 12px; font-weight: 500; color: inherit; opacity: .87; font-variant-numeric: tabular-nums; white-space: nowrap; }
.print-head .filled-btn { min-height: 36px; padding: 0 16px; background: var(--accent); color: var(--on-accent); }
.print-head .exam-timer { color: var(--on-surface); }
.print-tabs { display: none; position: relative; z-index: 1; background: var(--app-bar); box-shadow: var(--z1); }
.print-tabs button {
  position: relative; overflow: hidden; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; font-size: 14px; font-weight: 500; letter-spacing: .5px; text-transform: uppercase; color: color-mix(in srgb, var(--on-app-bar) 70%, transparent); cursor: pointer;
}
.print-tabs button .ms { font-size: 20px; }
.print-tabs button[aria-selected="true"] { color: var(--on-app-bar); border-bottom-color: var(--accent); }
.print-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); }
.print-sheet { min-height: 0; background: var(--surface-container-highest); }
.sheet-frame { display: block; width: 100%; height: 100%; border: 0; }
.print-panel {
  min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); background: var(--surface-container-lowest); box-shadow: var(--z2);
}
.print-panel > * { flex-shrink: 0; }
.pp-context { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; font-size: 12px; color: var(--on-surface-variant); }
.pp-context span + span::before { content: "›"; margin-right: 10px; color: var(--outline); }
.pp-context .pp-index { margin-left: auto; font-weight: 500; color: var(--primary); }
.pp-context .pp-index::before { content: none; }
.pp-prompt { padding: 14px 16px; border-radius: 2px; background: var(--surface-container); max-height: 46vh; overflow-y: auto; }
.pq { font-size: 14px; line-height: 2.1; overflow-wrap: anywhere; }
.pq .p-body { display: block; }
.pq .p-qn { font-weight: 500; color: var(--primary); margin-right: .5em; }
.pq .p-choice { display: block; margin-top: 4px; }
.pq .p-choice > span { display: block; padding-left: 1em; text-indent: -1em; line-height: 1.7; margin: 2px 0; }
.pq .p-fill { display: block; margin-top: 6px; }
.pq .p-bs { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; font-weight: 500; }
.pq .p-ws { text-decoration: underline wavy; text-underline-offset: 4px; }
.pq .p-ref { border: 1px solid var(--on-surface); padding: 0 .2em; }
.pq .p-cap { margin-left: .4em; }
.pq .p-src { font-size: .8em; }
.pq-kanji { margin-top: 8px; padding: 12px; border-radius: 2px; background: var(--surface-container-lowest); font-size: 20px; }
.pq-kanji .p-kn { margin-right: .4em; color: var(--on-surface-variant); }
.pchip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 3.2em; min-height: 1.9em; margin: 0 3px; padding: 0 8px;
  vertical-align: middle; line-height: 1.4; border: 1.5px solid var(--outline); border-radius: 2px; background: var(--surface-container-lowest);
  color: var(--on-surface-variant); font: inherit; font-size: .92em; cursor: pointer; text-indent: 0;
}
.pchip small { font-size: .72em; color: var(--outline); }
.pchip.is-lines { display: flex; width: 100%; min-height: 2.6em; margin: 6px 0 0; }
.pchip.is-filled { color: var(--primary); font-weight: 500; border-style: solid; }
.pchip.is-cur { border-color: var(--primary); border-width: 2.5px; background: var(--primary-container); color: var(--on-primary-container); }
.pchip.is-ok { border-color: var(--good); background: var(--good-container); color: var(--on-good-container); }
.pchip.is-ng { border-color: var(--error); background: var(--error-container); color: var(--on-error-container); }
.pchip.is-partial { border-color: var(--st-learning); }
.pa-label { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.type-pill { font-size: 12px; font-weight: 500; letter-spacing: .5px; padding: 2px 8px; border-radius: 2px; background: var(--secondary-container); color: var(--on-secondary-container); }
.type-pill.type-self { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.pp-answer { display: flex; flex-direction: column; gap: 10px; }
.pp-answer .pa-label { margin: 0; }
.pa-input { font-size: 16px; }
textarea.pa-input { font-size: 16px; }
.pa-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.pa-opt {
  position: relative; overflow: hidden; min-height: 56px; border-radius: 2px; border: 1px solid var(--outline); background: transparent;
  font-size: 24px; font-weight: 400; cursor: pointer; color: var(--on-surface);
}
.pa-opt:hover:not(:disabled) { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.pa-opt.is-picked { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: var(--z1); }
.pa-opt:disabled { cursor: default; opacity: .75; }
.verdict.partial { color: var(--tertiary); }
.model { padding: 10px 14px; border-radius: 2px; background: var(--surface-container); }
.model p { margin: 2px 0 0; font-weight: 500; }
.model-tag, .pp-ex-tag { font-size: 12px; font-weight: 500; color: var(--on-surface-variant); border: 1px solid var(--outline-variant); border-radius: 2px; padding: 0 4px; }
.pp-ex { font-size: 14px; color: var(--on-surface-variant); }
.pp-ex p { margin: 4px 0 0; }
.self-grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.self-grade .outlined-btn { padding: 0 8px; }
.sg-ok { color: var(--good); } .sg-partial { color: var(--tertiary); } .sg-ng { color: var(--error); }
.pp-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.pp-nav .filled-btn, .pp-nav .outlined-btn { min-height: 48px; }
.pp-map-wrap summary { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 500; color: var(--on-surface-variant); list-style: none; }
.pp-map-wrap summary::-webkit-details-marker { display: none; }
.pp-map { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.map-cell {
  width: 32px; height: 32px; border-radius: 2px; border: 1px solid var(--outline-variant); background: var(--surface-container-lowest);
  font-size: 12px; font-weight: 500; color: var(--on-surface-variant); cursor: pointer; font-variant-numeric: tabular-nums;
}
.map-cell.is-filled { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.map-cell.is-ok { background: var(--good-container); color: var(--on-good-container); }
.map-cell.is-ng { background: var(--error-container); color: var(--on-error-container); }
.map-cell.is-partial { background: var(--tertiary-container); color: var(--on-tertiary-container); }
.map-cell.is-cur { outline: 2.5px solid var(--primary); outline-offset: 1px; }
.pp-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding-top: 8px; border-top: 1px solid var(--outline-variant); }
.mode-select { width: auto; min-height: 38px; padding: 4px 10px; font-size: 12px; margin-right: auto; }
.pp-tools .text-btn[data-danger] { color: var(--error); }
.pp-score { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: 2px; background: var(--primary-container); color: var(--on-primary-container); }
.pp-score .ring-label { font-size: 14px; }
.pp-score .ring-bg { stroke: color-mix(in srgb, var(--surface-container-lowest) 70%, transparent); }
.pp-score-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pp-score-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pp-score-actions .filled-btn { min-height: 36px; padding: 0 14px; }
.pp-score .warn { color: var(--tertiary); }
.print-thumb { background: var(--tertiary); }
.print-thumb .ms { font-size: 22px; }
.import-print { display: flex; flex-direction: column; gap: 10px; }
.found-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.found-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.found-list li .ms { font-size: 20px; color: var(--primary); }
.found-list li strong { margin-left: auto; }
.found-list li.warn, .found-list li.warn .ms { color: var(--error); }
@media (max-width: 900px) {
  .print-tabs { display: flex; }
  .print-body { grid-template-columns: 1fr; }
  .print-view[data-tab="answer"] .print-sheet { display: none; }
  .print-view[data-tab="sheet"] .print-panel { display: none; }
  .print-panel { border-left: 0; }
  .pp-prompt { max-height: 40vh; }
}

.pc-note { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 12px; border-radius: 2px; background: var(--tertiary-container); color: var(--on-tertiary-container); font-size: 12px; }
.pc-note .ms { font-size: 18px; }
.tools-note { margin-right: auto; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 試験 ---------- */
.exam-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; margin-right: 6px; border-radius: 2px; background: var(--error); color: var(--on-error); font-size: 12px; font-weight: 500; letter-spacing: .5px; vertical-align: 2px; }
.exam-pill.big { height: 28px; font-size: 14px; letter-spacing: .1px; margin: 0; align-self: flex-start; }
.print-thumb.is-exam { background: var(--error); }
.exam-box { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 2px; background: var(--error-container); color: var(--on-error-container); font-size: 14px; }
.exam-timer { font-weight: 500; font-variant-numeric: tabular-nums; padding: 4px 10px; border-radius: 2px; background: var(--surface-container-high); white-space: nowrap; }
.exam-timer.is-low { background: var(--error); color: var(--on-error); }
.exam-lobby { max-width: 640px; margin: 24px auto; }
.lobby-card { display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: 2px; background: var(--surface-container-low); }
.lobby-card h1 { font-size: 24px; line-height: 32px; font-weight: 400; }
.lobby-facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lobby-facts li { display: flex; align-items: center; gap: 10px; }
.lobby-facts .ms { color: var(--primary); }
.lobby-rules { padding: 14px 16px; border-radius: 2px; background: var(--surface-container-high); font-size: 14px; }
.lobby-rules p { margin: 6px 0 0; }
.lobby-card .warn { margin: 0; }
.exam-guard {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 24px; text-align: center; background: var(--surface); color: var(--on-surface);
}
.exam-guard p { max-width: 32em; margin: 0 0 8px; color: var(--on-surface-variant); }
.guard-icon { font-size: 56px; color: var(--error); }
.print-view.is-exam .pp-prompt, .print-view.is-exam .pq { user-select: none; -webkit-user-select: none; }
.print-view.is-guarded .print-body { visibility: hidden; }
.exam-done { background: var(--surface-container); color: var(--on-surface); }
.exam-done strong { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.pass-row { display: flex; gap: 8px; margin-top: 8px; }
.pass-row .field-input { min-height: 40px; }
.exam-log { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 12px; }
.exam-log p { display: flex; align-items: center; gap: 6px; margin: 0; }
.exam-log .ms { font-size: 16px; }
.exam-log ul { margin: 0; padding-left: 26px; color: var(--on-surface-variant); max-height: 8em; overflow: auto; }
.exam-log .warn { color: var(--error); }

/* ---------- PDF からプリントを作る（パソコン向け） ---------- */
body[data-view="maker"] .page { --page-w: 1280px; }
.mk-head h1 { font-size: 24px; line-height: 32px; font-weight: 400; margin: 4px 0 4px; }
.mk-head p { margin: 0 0 16px; }
.mk-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.mk-side { display: flex; flex-direction: column; gap: 16px; }
.mk-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 2px; background: var(--surface-container-low); margin-bottom: 16px; }
.mk-side .mk-card { margin-bottom: 0; }
.mk-card h2 { display: flex; align-items: center; gap: 12px; font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: .15px; }
.mk-step { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: 12px; }
.mk-drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 24px; border-radius: 2px; cursor: pointer; text-align: center;
  border: 1px dashed var(--outline); background: var(--surface-container);
}
.mk-drop.is-over { border-color: var(--primary); background: var(--primary-container); }
.mk-drop p { margin: 0; }
.mk-drop-icon { font-size: 40px; color: var(--error); }
.mk-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 70vh; overflow: auto; }
.mk-page { margin: 0; border-radius: 2px; overflow: hidden; border: 2px solid var(--outline-variant); background: var(--surface-container); }
.mk-page img { display: block; width: 100%; height: auto; background: #fff; }
.mk-page.role-a { border-color: var(--tertiary); }
.mk-page.role-skip img { opacity: .35; }
.mk-page-loading { display: grid; place-items: center; aspect-ratio: 1 / 1.41; }
.mk-page figcaption { display: flex; align-items: center; gap: 6px; padding: 6px; font-size: 12px; font-weight: 500; }
.mk-roles { display: flex; flex: 1; border: 1px solid var(--outline-variant); border-radius: 2px; overflow: hidden; }
.mk-roles button { flex: 1; min-height: 26px; padding: 0 2px; border: 0; background: transparent; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--on-surface-variant); }
.mk-roles button + button { border-left: 1px solid var(--outline-variant); }
.mk-roles button[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.mk-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mk-mode { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 2px; border: 1px solid var(--outline-variant); cursor: pointer; }
.mk-mode.is-on { border-color: var(--primary); background: var(--primary-container); color: var(--on-primary-container); }
.mk-mode input { margin-top: 4px; accent-color: var(--accent); }
.mk-mode span { display: flex; flex-direction: column; gap: 2px; }
.mk-mode small { font-size: 12px; opacity: .85; }
.mk-exam { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 2px; background: var(--error-container); color: var(--on-error-container); }
.mk-exam .field-label { color: inherit; }
.mk-minutes { max-width: 12em; }
.mk-rules { margin: 0; padding-left: 20px; font-size: 12px; display: grid; gap: 4px; }
.mk-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.mk-model { max-width: 16em; }
.mk-status { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--primary); font-weight: 500; }
.mk-status:empty { display: none; }
.mk-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mk-counts { margin: 0; font-weight: 500; color: var(--on-surface-variant); }
.mk-article { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 2px; border: 1px solid var(--outline-variant); }
.mk-section { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 2px; background: var(--surface-container); }
.mk-q { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 2px; background: var(--surface-container-low); border: 1px solid var(--outline-variant); }
.mk-q-head { display: flex; align-items: flex-end; gap: 10px; }
.mk-q-head .grow { flex: 1; }
.mk-q-head > .muted { flex: 1; padding-bottom: 12px; }
.mk-n { flex: 0 0 6em; }
.mk-blanks { width: 100%; border-collapse: collapse; font-size: 14px; }
.mk-blanks th { text-align: left; font-size: 12px; color: var(--on-surface-variant); padding: 0 4px 4px; font-weight: 500; }
.mk-blanks td { padding: 3px 4px; vertical-align: middle; }
.mk-blanks .field-input, .mk-blanks .field-select { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.mk-blanks .field-input.is-empty { border-color: var(--error); background: var(--error-container); }
.mk-bn { font-family: ui-monospace, monospace; color: var(--on-surface-variant); white-space: nowrap; }
.mk-summary { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mk-summary li { display: flex; align-items: center; gap: 8px; }
.mk-summary .warn { color: var(--error); }

/* ---------- クラス（生徒） ---------- */
.class-thumb { background: var(--secondary); }
.thumb.kind-words { background: var(--lang-en); }
.thumb.kind-wordtest { background: var(--tertiary); }
.thumb.kind-print { background: var(--lang-custom); }
.thumb.is-exam { background: var(--error); }
.thumb .ms { font-size: 22px; }

.kind-pill, .code-pill, .pub-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 2px; font-size: 12px; letter-spacing: .5px; font-weight: 500; background: var(--surface-container-high); color: var(--on-surface-variant); }
.code-pill { font-family: ui-monospace, monospace; letter-spacing: .08em; }
.pub-pill.on { background: var(--good-container); color: var(--on-good-container); }
.set-row-meta .done, .tc-table .done { color: var(--good); display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.set-row-meta .warn, .set-row-sub .warn { color: var(--error); font-weight: 500; }
.set-list.flat { background: transparent; border: 1px solid var(--outline-variant); }
.class-home { display: flex; flex-direction: column; gap: 10px; }
.class-join-row { display: flex; justify-content: flex-start; }
.class-banner { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 12px 16px; border-radius: 2px; background: var(--secondary-container); color: var(--on-secondary-container); font-size: 14px; }
.code-input { font-family: ui-monospace, monospace; font-size: 24px; letter-spacing: .3em; text-align: center; text-transform: uppercase; margin-top: 8px; }
.join-info { margin-top: 12px; }
.join-found { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 2px; background: var(--primary-container); color: var(--on-primary-container); }
.join-found strong { font-size: 16px; }
.join-found p { margin: 6px 0 0; }
.class-box { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.class-box p { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.class-box .ms { font-size: 18px; }
.teacher-grade { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--primary); }
.task-lobby { max-width: 560px; margin: 16px auto; }
.task-result { max-width: 640px; margin: 0 auto; }
.task-result h1 { font-size: 20px; }

/* ---------- 指導者メニュー（パソコン向け） ---------- */
body[data-view="teach"] .page { --page-w: 1120px; }
.tc-head { margin: 4px 0 18px; }
.tc-head h1 { font-size: 24px; line-height: 32px; font-weight: 400; margin: 2px 0 4px; }
.tc-head p { margin: 0; }
.tc-eyebrow { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 500; color: var(--tertiary); }
.tc-eyebrow .ms { font-size: 18px; }
.tc-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.tc-grid > .mk-card { margin-bottom: 16px; }
.tc-code { align-items: stretch; }
.code-big { margin: 0; font-family: ui-monospace, monospace; font-size: 2.6rem; font-weight: 500; letter-spacing: .2em; text-align: center; color: var(--on-primary-container); padding: 8px 0; border-radius: 2px; background: var(--primary-container); }
.tc-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.tc-dl dt { color: var(--on-surface-variant); font-size: 12px; }
.tc-dl dd { margin: 0; }
.tc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tc-table th { text-align: left; font-size: 12px; color: var(--on-surface-variant); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--outline-variant); }
.tc-table td { padding: 8px; border-bottom: 1px solid var(--outline-variant); vertical-align: middle; }
.tc-table tr.is-missing td { color: var(--on-surface-variant); }
.tc-table td.warn { color: var(--error); font-weight: 500; }
.tc-table .ms { font-size: 18px; }
.tc-actions { text-align: right; white-space: nowrap; }
.tc-form { display: flex; flex-direction: column; gap: 14px; }
.tc-kinds { grid-template-columns: repeat(3, 1fr); }
.tc-kinds .ms { font-size: 18px; vertical-align: -3px; }
.tc-source { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 2px; background: var(--surface-container-low); }
.dialog.dialog-wide { width: min(860px, calc(100vw - 32px)); }
.tc-detail { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow: auto; }
.tc-blanks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tc-blank { padding: 10px 12px; border-radius: 2px; border: 1px solid var(--outline-variant); border-left-width: 4px; }
.tc-blank.mark-ok { border-left-color: var(--good); }
.tc-blank.mark-ng { border-left-color: var(--error); }
.tc-blank.mark-partial { border-left-color: var(--st-learning); }
.tc-blank.mark-pending { border-left-color: var(--tertiary); background: color-mix(in srgb, var(--tertiary-container) 40%, transparent); }
.tc-blank-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tc-blank-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 6px; }
.tc-blank-body p { margin: 2px 0 0; overflow-wrap: anywhere; }
.tc-answer { font-weight: 500; }
.tc-marks { display: flex; gap: 6px; }
.tc-mark { position: relative; overflow: hidden; min-width: 48px; min-height: 32px; border-radius: 2px; border: 1px solid var(--outline-variant); background: transparent; font-weight: 500; cursor: pointer; color: var(--on-surface); }
.tc-mark.ok[aria-checked="true"] { background: var(--good); color: var(--on-good); border-color: var(--good); }
.tc-mark.partial[aria-checked="true"] { background: var(--st-learning); color: #241a00; border-color: var(--st-learning); }
.tc-mark.ng[aria-checked="true"] { background: var(--error); color: var(--on-error); border-color: var(--error); }
@media (max-width: 900px) {
  .mk-grid, .tc-grid, .tc-kinds, .tc-blank-body { grid-template-columns: 1fr; }
}

/* ---------- 読み上げの設定 ---------- */
.speech-settings { display: flex; flex-direction: column; gap: 16px; }
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch-row input {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; order: 2; margin: 0 6px 0 auto; cursor: pointer;
  width: 36px; height: 14px; border-radius: 7px; border: 0; background: color-mix(in srgb, var(--on-surface) 26%, transparent);
  transition: background-color .2s var(--ease);
}
.switch-row input::before {
  content: ""; position: absolute; top: 50%; left: -2px; width: 20px; height: 20px; border-radius: 50%; background: #fafafa;
  transform: translateY(-50%); box-shadow: var(--z1); transition: left .2s var(--ease), background-color .2s var(--ease);
}
:root[data-theme="dark"] .switch-row input::before { background: #bdbdbd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .switch-row input::before { background: #bdbdbd; } }
.switch-row input:checked { background: color-mix(in srgb, var(--accent) 50%, transparent); }
.switch-row input:checked::before { left: 18px; background: var(--accent); }
.switch-row input:focus-visible { outline: none; }
.switch-row input:focus-visible::before { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent), var(--z1); }
.switch-row span { display: flex; flex-direction: column; }
.switch-row strong { font-weight: 400; font-size: 16px; letter-spacing: .15px; }
.switch-row small { color: var(--on-surface-variant); font-size: 14px; letter-spacing: .25px; }
.setting-block { display: flex; flex-direction: column; gap: 8px; }
.segmented.small { display: flex; border-radius: 2px; overflow: hidden; background: var(--surface-container-lowest); box-shadow: var(--z1); }
.segmented.small button { position: relative; overflow: hidden; flex: 1; min-height: 40px; border: 0; background: transparent; cursor: pointer; font-weight: 500; font-size: 14px; letter-spacing: .5px; color: var(--on-surface-variant); }
.segmented.small button + button { border-left: 1px solid var(--outline-variant); }
.segmented.small button[aria-checked="true"] { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: var(--primary); }
.voice-row { display: grid; grid-template-columns: 4.5em 1fr; align-items: center; gap: 8px; }
.voice-row p { margin: 0; }
.voice-name { font-weight: 500; font-size: 14px; }
.voice-pick { display: flex; align-items: center; gap: 4px; min-width: 0; }
.voice-pick .field-select { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.speech-settings > .muted { margin: 0; }

/* ---------- ダイアログ・お知らせ ---------- */
.dialog {
  width: min(560px, calc(100vw - 80px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); padding: 24px 24px 8px; border: 0; border-radius: 2px;
  background: var(--surface-container-lowest); color: var(--on-surface); box-shadow: var(--z5);
  font-size: 14px; letter-spacing: .25px;
}
.dialog[open] { animation: dialog-in .25s var(--ease-emph); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.9); } }
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog h2 { font-size: 20px; line-height: 28px; font-weight: 500; margin-bottom: 16px; }
.dialog p { margin: 0 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 24px -16px 0; }
/* 簡単なダイアログ（選ぶとすぐ決まる）にはボタンを置かない */
.dialog-simple { padding-bottom: 8px; }
.dialog-simple .dialog-actions { display: none; }
.dialog-simple h2 { margin-bottom: 8px; }
.snackbar {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  min-width: 288px; max-width: min(568px, calc(100vw - 32px)); min-height: 48px; padding: 14px 24px; border-radius: 2px;
  background: var(--inverse-surface); color: var(--inverse-on-surface); font-size: 14px; line-height: 20px;
  box-shadow: var(--z3);
  transform: translate(-50%, 100%); opacity: 0; pointer-events: none; transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.snackbar.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 600px) {
  .snackbar { left: 0; right: 0; bottom: 0; min-width: 0; max-width: none; padding-bottom: calc(14px + env(safe-area-inset-bottom)); border-radius: 0; transform: translateY(100%); }
  .snackbar.show { transform: none; }
}
/* スナックバーが出ている間は、FAB をその分だけ上げる */
.fab { transition: box-shadow .28s var(--ease), transform .25s var(--ease); }
body:has(.snackbar.show) .fab { transform: translateY(-56px); }

/* ---------- ホーム画面に追加（Nagi と同じ） ---------- */
.install {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 12px; max-width: 560px; margin: 0 auto; padding: 12px 12px 12px 16px;
  border-radius: 2px; background: var(--surface-container-lowest); box-shadow: var(--z4);
  animation: rise .3s var(--ease-emph) both;
}
.install img { border-radius: 2px; flex: none; }
.install-text { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; }
.install-text strong { display: block; font-weight: 500; }
.install-text span { color: var(--on-surface-variant); font-size: 13px; }
.install .filled-btn { padding: 0 16px; }
body[data-view="learn"] .install, body[data-view="print"] .install, body[data-view="gate"] .install { display: none; }
@media (max-width: 480px) { .install { flex-wrap: wrap; } .install-text { flex-basis: calc(100% - 52px); } .install .text-btn { margin-left: auto; } }

/* ---------- スマートフォン ---------- */
@media (max-width: 640px) {
  .page { padding: 20px 16px calc(48px + env(safe-area-inset-bottom)); }
  .home-head h1, .page-head h1, body[data-view="prints"] .page > .section > .section-head h2, body[data-view="classes"] .page > .section > .section-head h2 { font-size: 24px; line-height: 32px; }
  .today { grid-template-columns: 1fr; padding: 20px 20px 16px; }
  .today-start { width: 100%; }
  .today-count { font-size: 48px; }
  .set-row { gap: 12px; padding: 12px 14px; }
  .thumb { width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
  .set-row-end .ring { width: 46px !important; height: 46px !important; }
  .set-head .thumb { display: none; }
  .set-head h1 { font-size: 24px; line-height: 32px; }
  .memory-body { gap: 18px; }
  .legend { min-width: 0; width: 100%; grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .legend-due { grid-column: 1 / -1; }
  .edit-fields { grid-template-columns: 1fr; }
  .edit-extra { grid-template-columns: 1fr; }
  .edit-row { grid-template-columns: 22px 1fr; }
  .edit-tools { grid-column: 2; justify-content: flex-end; margin-top: -4px; }
  .choice { padding: 10px 20px; }
}

/* ---------- MD1 の紙（カードは白い面に 2dp の影） ---------- */
.set-list, .word-list, .memory-card, .start-card, .edit-card, .mk-card, .lobby-card, .soon, .empty-card, .detail, .pp-score, .join-found {
  box-shadow: var(--z1);
}
.set-list.flat { box-shadow: none; }
.set-row:hover::after { opacity: .04; }
.set-list .set-row + .set-row, .word-list .word-row + .word-row { border-top-color: var(--outline-variant); }

/* ---------- 設定の画面（MD1 の Settings パターン） ---------- */
/* ラベルは画面タイトルの左端にそろえる。押す範囲だけ左右に広げる（波紋が端まで広がる） */
.settings { max-width: 720px; }
.settings-group h2 { margin: 0; padding: 16px 0 4px; font-size: 14px; line-height: 20px; font-weight: 500; letter-spacing: .1px; color: var(--primary); }
.settings-divider { height: 1px; margin: 8px 0 0; border: 0; background: var(--outline-variant); }
.setting-item {
  position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  width: calc(100% + 32px); min-height: 72px; margin: 0 -16px; padding: 12px 16px; border: 0; border-radius: 0; background: transparent;
  color: var(--on-surface); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.setting-item:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.setting-item:disabled { cursor: default; }
.setting-item:disabled strong { color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.setting-item strong { font-weight: 400; font-size: 16px; line-height: 24px; }
.setting-item small { color: var(--on-surface-variant); font-size: 14px; line-height: 20px; }
.setting-item.switch-row { flex-direction: row; align-items: center; gap: 16px; }
.setting-item.switch-row > span { flex: 1; min-width: 0; }
.setting-item.switch-row input { margin-right: 0; }
/* ラジオの簡単なダイアログ */
.radio-list { display: flex; flex-direction: column; margin: 0 -16px; }
.radio-row { display: flex; align-items: center; gap: 16px; min-height: 48px; padding: 0 16px; cursor: pointer; font-size: 16px; }
.radio-row:hover { background: color-mix(in srgb, var(--on-surface) 4%, transparent); }
.radio-row input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 20px; height: 20px; margin: 0; border-radius: 50%;
  border: 2px solid var(--on-surface-variant); background: transparent; cursor: pointer; transition: border-color .2s var(--ease);
}
.radio-row input::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary); transform: scale(0); transition: transform .2s var(--ease); }
.radio-row input:checked { border-color: var(--primary); }
.radio-row input:checked::before { transform: scale(1); }
.radio-row input:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

/* ---------- 動き（画面の切りかえ・一覧・問題・ダイアログ） ---------- */
/* 画面の切りかえ（app.js の route。View Transitions API）。Android のアクティビティの動きにそろえる
   上の帯・横のメニュー・FAB は動かさず、本文だけ入れかえる
   forward: 新しい画面が右の端から上にかぶさる（影つき）。前の画面は 25% だけ左へずれて暗くなる
   back   : いまの画面が右へ抜ける（上に重ねたまま）。前の画面が左から戻って明るくなる
   fade   : fade through（前の画面がすっと消え、新しい画面が 92% の大きさから広がって出る） */
:root { --ease-android: cubic-bezier(.2, 0, 0, 1); }   /* Material の emphasized（Android の fast_out_extra_slow_in に近い） */
.top-bar { view-transition-name: app-bar; }
.drawer { view-transition-name: drawer; }
.fab { view-transition-name: fab; }
::view-transition-group(*) { animation-duration: .4s; animation-timing-function: var(--ease-android); }
::view-transition-old(root), ::view-transition-new(root) { mix-blend-mode: normal; }
:root[data-motion="forward"]::view-transition-old(root) { animation: mo-push-out .4s var(--ease-android) both; }
:root[data-motion="forward"]::view-transition-new(root) { animation: mo-slide-in .4s var(--ease-android) both; box-shadow: -8px 0 32px rgba(0, 0, 0, .28); }
:root[data-motion="back"]::view-transition-old(root) { z-index: 1; animation: mo-slide-out .36s var(--ease-android) both; box-shadow: -8px 0 32px rgba(0, 0, 0, .28); }
:root[data-motion="back"]::view-transition-new(root) { animation: mo-pull-in .36s var(--ease-android) both; }
:root[data-motion="fade"]::view-transition-old(root) { animation: mo-fade-out .09s linear both; }
:root[data-motion="fade"]::view-transition-new(root) { animation: mo-through-in .21s cubic-bezier(0, 0, .2, 1) .09s both; }
/* View Transitions API がないブラウザは、新しい画面だけ動かす（残る transform を作らないよう backwards） */
.enter-forward { animation: mo-in-right .32s var(--ease-android) backwards; }
.enter-back { animation: mo-in-left .32s var(--ease-android) backwards; }
.enter-fade { animation: mo-through-in .25s cubic-bezier(0, 0, .2, 1) backwards; }
@keyframes mo-slide-in { from { transform: translateX(100%); } }
@keyframes mo-slide-out { to { transform: translateX(100%); } }
@keyframes mo-push-out { to { transform: translateX(-25%); filter: brightness(.7); } }
@keyframes mo-pull-in { from { transform: translateX(-25%); filter: brightness(.7); } }
@keyframes mo-in-right { from { opacity: 0; transform: translateX(64px); } }
@keyframes mo-in-left { from { opacity: 0; transform: translateX(-64px); } }
@keyframes mo-fade-out { to { opacity: 0; } }
@keyframes mo-fade-in { from { opacity: 0; } }
@keyframes mo-through-in { from { opacity: 0; transform: scale(.92); } }

/* 一覧・カードは、上から順に浮かんでくる（MD1 の stagger） */
.home-head, .home-top > *, .page-head, .gate-card,
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > * { animation: mo-item .4s var(--ease-emph) backwards; }
.home-top > :nth-child(2) { animation-delay: .06s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(2) { animation-delay: .03s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(3) { animation-delay: .06s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(4) { animation-delay: .09s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(5) { animation-delay: .12s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(6) { animation-delay: .15s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(7) { animation-delay: .18s; }
:is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > :nth-child(n+8) { animation-delay: .21s; }
.word-list > :nth-child(n+13) { animation: none; } /* 長い単語の一覧は、見えるところだけ */
@keyframes mo-item { from { opacity: 0; transform: translateY(16px); } }

/* 学習: 問題が変わるたびに、右から入る。選択肢は上から順に。まちがえた選択肢は横にゆれる */
.q-area > :not(.judge) { animation: mo-q .32s var(--ease-emph) backwards; }
.choices > .choice { animation: mo-item .3s var(--ease-emph) backwards; }
.choices > .choice:nth-child(2) { animation-delay: .04s; }
.choices > .choice:nth-child(3) { animation-delay: .08s; }
.choices > .choice:nth-child(4) { animation-delay: .12s; }
.choices > .choice:nth-child(n+5) { animation-delay: .16s; }
.choice.is-wrong { animation: mo-shake .4s var(--ease); }
.choice.is-correct { animation: mo-pop .3s var(--ease-emph); }
.card-area > .flashcard { animation: mo-q .35s var(--ease-emph) backwards; }
.result > * { animation: mo-item .4s var(--ease-emph) backwards; }
.result > :nth-child(2) { animation-delay: .06s; }
.result > :nth-child(3) { animation-delay: .12s; }
.result > :nth-child(n+4) { animation-delay: .18s; }
@keyframes mo-q { from { opacity: 0; transform: translateX(32px); } }
@keyframes mo-shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes mo-pop { 50% { transform: scale(1.02); } }

/* ダイアログ: 開くときは広がり、閉じるときは縮んで消える（app.js の openDialog） */
.dialog[open]::backdrop { animation: mo-fade-in .25s var(--ease); }
.dialog.is-closing { animation: mo-dialog-out .18s cubic-bezier(.4, 0, 1, 1) forwards; }
.dialog.is-closing::backdrop { animation: mo-fade-out .18s linear forwards; }
@keyframes mo-dialog-out { to { opacity: 0; transform: scale(.94); } }

/* 動きを減らす設定のときは、どれも動かさない */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .enter-forward, .enter-back, .enter-fade,
  .home-head, .home-top > *, .page-head, .gate-card,
  :is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > *,
  .q-area > :not(.judge), .choices > .choice, .choice.is-wrong, .choice.is-correct, .card-area > .flashcard, .result > *,
  .dialog[open], .dialog[open]::backdrop, .dialog.is-closing, .dialog.is-closing::backdrop { animation: none !important; }
}

/* 横に入れかわったページでは、一覧が下から浮かぶ動きはしない（app.js の route が is-sliding を付ける） */
#app.is-sliding :is(.card-grid, .tile-grid, .stat-grid, .set-list, .word-list) > *,
#app.is-sliding :is(.home-head, .page-head), #app.is-sliding .home-top > * { animation: none; }

/* ---------- 答え合わせのシート（Android の bottom sheet。app.js の openSheet） ---------- */
/* 答えると、問題の場所を小さくして選択肢を上に残し、結果は下から出るシートに出す */
.learn .q-area { transition: min-height .3s var(--ease-android, var(--ease)), padding .3s var(--ease-android, var(--ease)); }
.learn.is-answered .q-area { min-height: 0; flex: 0 0 auto; padding: 12px 0 16px; }
.learn.is-answered .q-text { font-size: clamp(26px, 6vw, 34px); transition: font-size .3s var(--ease-android, var(--ease)); }
.learn.is-answered .q-reading, .learn.is-answered .q-tag { display: none; }
.learn.is-answered .a-area { padding-bottom: 0; }
.result-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0 auto; max-width: 632px;
  display: flex; flex-direction: column; gap: 12px; max-height: min(70vh, 70dvh); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 20px calc(16px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0;
  background: var(--surface-container-lowest); color: var(--on-surface); box-shadow: 0 -4px 24px rgba(0, 0, 0, .18), 0 -1px 4px rgba(0, 0, 0, .08);
  animation: mo-sheet-up .35s var(--ease-android, var(--ease)) both;
}
.result-sheet.is-ok { background: color-mix(in srgb, var(--good-container) 55%, var(--surface-container-lowest)); }
.result-sheet.is-ng { background: color-mix(in srgb, var(--error-container) 55%, var(--surface-container-lowest)); }
.sheet-verdict { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 22px; line-height: 28px; font-weight: 500; }
.sheet-verdict .ms { font-size: 30px; }
.result-sheet.is-ok .sheet-verdict { color: var(--good); }
.result-sheet.is-ng .sheet-verdict { color: var(--error); }
.sheet-verdict .ms { animation: mo-verdict .4s var(--ease-android, var(--ease)) .1s backwards; }
.sheet-body { display: flex; flex-direction: column; gap: 8px; }
.sheet-body .detail { padding: 12px 14px; background: color-mix(in srgb, var(--surface-container-lowest) 70%, transparent); box-shadow: none; }
.sheet-body .your-answer, .sheet-body .fix-row { margin: 0; }
.result-sheet .next-btn { width: 100%; min-height: 48px; font-size: 15px; box-shadow: var(--z1); }
.result-sheet.is-ok .next-btn { background: var(--good); color: var(--on-good); }
.result-sheet.is-ng .next-btn { background: var(--error); color: var(--on-error); }
@keyframes mo-sheet-up { from { transform: translateY(100%); } }
@keyframes mo-verdict { from { transform: scale(.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .result-sheet, .sheet-verdict .ms { animation: none; }
  .learn .q-area, .learn.is-answered .q-text { transition: none; }
}
/* 答えると問題の場所が小さくなるので、○・× は画面に対して出す（選択肢の上あたり） */
.learn.is-answered .judge { position: fixed; top: 38%; top: 38dvh; }
