/* Layout: 罫線ノートの1ページ。左に赤い余白線、単語は1行ずつ罫線にのせ、意味は赤ペンの色（赤シートで消える） */
:root {
  --paper: #fbfcfe;
  --desk: #eef2f8;
  --ink: #1d2740;
  --muted: #5d6781;
  --rule: #d5deee;
  --margin: #e58b8b;
  --accent: #2c4fa3;
  --accent-ink: #ffffff;
  --redpen: #d23a3a;
  --sheet: #e0473f;
  --chip: #e6ecf8;
  --g1: #2e8a5c;
  --g2: #2c6fb7;
  --g3: #8a4bb5;
  --font-en: "Lexend", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1a2030; --desk: #121724; --ink: #e7ebf5; --muted: #a2abc2; --rule: #2c3550; --margin: #a65a5a;
    --accent: #8fb0ff; --accent-ink: #10172a; --redpen: #ff8a80; --sheet: #c8473f; --chip: #252e45;
    --g1: #6fd0a0; --g2: #7fb4ff; --g3: #c99bf0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1a2030; --desk: #121724; --ink: #e7ebf5; --muted: #a2abc2; --rule: #2c3550; --margin: #a65a5a;
  --accent: #8fb0ff; --accent-ink: #10172a; --redpen: #ff8a80; --sheet: #c8473f; --chip: #252e45;
  --g1: #6fd0a0; --g2: #7fb4ff; --g3: #c99bf0; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* ===== 見た目の切り替え（右上の「見た目」）。ライト／ダークに関係なく、それぞれ決まった配色 ===== */
:root[data-style="chalk"] {
  --paper: #24443a; --desk: #1b342c; --ink: #f1efe6; --muted: #b9d1c5; --rule: #3b5d51; --margin: #f4b2c0;
  --accent: #f6d55c; --accent-ink: #1b342c; --redpen: #f6d55c; --sheet: #c96a5f; --chip: #2f5246;
  --g1: #9fe0b9; --g2: #9cc8ff; --g3: #e3b5ff;
  --font-en: "Kalam", "Comic Sans MS", "Segoe Print", cursive; --font-jp: "Klee One", "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  color-scheme: dark;
}
:root[data-style="washi"] {
  --paper: #fbf7ee; --desk: #efe6d2; --ink: #2b2420; --muted: #6e6255; --rule: #e3d8c2; --margin: #c8402a;
  --accent: #b2361f; --accent-ink: #fffaf0; --redpen: #b2361f; --sheet: #b2361f; --chip: #f1e6cf;
  --g1: #3d7a4e; --g2: #2d5f8a; --g3: #7b4a8c;
  --font-en: "EB Garamond", Georgia, serif; --font-jp: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --radius: 6px; color-scheme: light;
}
:root[data-style="grid"] {
  --paper: #ffffff; --desk: #e9f1ee; --ink: #1c2b2a; --muted: #55706b; --rule: #cfe3dc; --margin: #2a9d8f;
  --accent: #127566; --accent-ink: #ffffff; --redpen: #d1495b; --sheet: #d1495b; --chip: #dcefe9;
  --g1: #2e8a5c; --g2: #2c6fb7; --g3: #8a4bb5;
  --font-en: "Space Grotesk", "Segoe UI", sans-serif; --font-jp: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  --radius: 4px; color-scheme: light;
}
:root[data-style="night"] {
  --paper: #18213f; --desk: #0e1530; --ink: #eef0ff; --muted: #a9b1d6; --rule: #2a3560; --margin: #ffc857;
  --accent: #ffc857; --accent-ink: #1a1a2e; --redpen: #ff9e7a; --sheet: #d0583f; --chip: #243058;
  --g1: #7fe0b0; --g2: #8fc1ff; --g3: #d6a8ff;
  --radius: 12px; color-scheme: dark;
}
:root[data-style="sakura"] {
  --paper: #ffffff; --desk: #fcecf1; --ink: #3a2a33; --muted: #7a6470; --rule: #f5d9e2; --margin: #f08aa8;
  --accent: #c2416b; --accent-ink: #ffffff; --redpen: #c2416b; --sheet: #c2416b; --chip: #fde2ea;
  --g1: #3f8a5e; --g2: #3c76b8; --g3: #9a4fa6;
  --font-en: "Quicksand", "Segoe UI", sans-serif; --font-jp: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", sans-serif;
  --radius: 18px; color-scheme: light;
}
:root[data-style="kraft"] {
  --paper: #fff8c9; --desk: #c9ab7d; --ink: #3a2c1a; --muted: #5e4c33; --rule: #eadf9f; --margin: #e07a3f;
  --accent: #3a2c1a; --accent-ink: #fff8c9; --redpen: #c2410c; --sheet: #c2410c; --chip: #f5ea9a;
  --g1: #3d7a3a; --g2: #2d5f8a; --g3: #8a3f7b;
  --font-en: "Kosugi Maru", "Hiragino Maru Gothic ProN", sans-serif; --font-jp: "Kosugi Maru", "Hiragino Maru Gothic ProN", sans-serif;
  --radius: 2px; color-scheme: light;
}
:root[data-style="ocean"] {
  --paper: #ffffff; --desk: #e9f6fc; --ink: #0c2a43; --muted: #4f6b82; --rule: #d3e7f3; --margin: #3aa6d9;
  --accent: #0a6fb5; --accent-ink: #ffffff; --redpen: #e0553b; --sheet: #e0553b; --chip: #d6ecf8;
  --g1: #13866f; --g2: #0a6fb5; --g3: #7a4fc2;
  --font-en: "Nunito", "Segoe UI", sans-serif; --font-jp: "M PLUS 1p", "Hiragino Sans", sans-serif;
  --radius: 14px; color-scheme: light;
}
:root[data-style="forest"] {
  --paper: #f6f2e7; --desk: #e9e4d3; --ink: #23301f; --muted: #5d6a55; --rule: #e1dbc8; --margin: #7aa35b;
  --accent: #3f6b3a; --accent-ink: #f6f2e7; --redpen: #b5482a; --sheet: #b5482a; --chip: #e5e3cf;
  --g1: #3f6b3a; --g2: #2d5f8a; --g3: #7b4a8c;
  --font-en: "Merriweather Sans", "Segoe UI", sans-serif;
  --radius: 8px; color-scheme: light;
}
:root[data-style="retro"] {
  --paper: #0d1a12; --desk: #07110b; --ink: #c6f7d1; --muted: #82c093; --rule: #1e3a27; --margin: #39ff88;
  --accent: #39ff88; --accent-ink: #07110b; --redpen: #ffd166; --sheet: #b88a1c; --chip: #15301f;
  --g1: #39ff88; --g2: #7fd8ff; --g3: #ff9bd6;
  --font-en: "DotGothic16", "MS Gothic", monospace; --font-jp: "DotGothic16", "MS Gothic", monospace;
  --radius: 0px; color-scheme: dark;
}
/* ドット：Chiko Log と同じ、昔のゲームのウィンドウ風 */
:root[data-style="dot"] {
  --paper: #f6f1e3; --desk: #e6dfcc; --ink: #2e2a33; --muted: #6b6470; --rule: #d9d0b8; --margin: #c4473a;
  --accent: #1f5f8b; --accent-ink: #ffffff; --redpen: #c4473a; --sheet: #c4473a; --chip: #ebe3cc;
  --g1: #2f7a4a; --g2: #1f5f8b; --g3: #7b4a8c;
  --font-en: "DotGothic16", "MS Gothic", monospace; --font-jp: "DotGothic16", "MS Gothic", "Osaka-Mono", monospace;
  --radius: 0px; color-scheme: light;
}
:root[data-style="dot"] body { background-image: radial-gradient(rgba(46,42,51,.09) 1px, transparent 1.4px); background-size: 12px 12px; }
:root[data-style="dot"] *, :root[data-style="dot"] *::before, :root[data-style="dot"] *::after { border-radius: 0 !important; }
:root[data-style="dot"] :is(.side, .words, .test-form, .sheet-paper, .card, .howto, .sent, .deck-done, .fc-face, .modes, .qr-dialog, .pw) {
  border-color: transparent;
  box-shadow: 0 -4px 0 0 var(--ink), 0 4px 0 0 var(--ink), -4px 0 0 0 var(--ink), 4px 0 0 0 var(--ink), 4px 8px 0 0 rgba(46,42,51,.25), 8px 4px 0 0 rgba(46,42,51,.25);
}
:root[data-style="dot"] h1 { font-weight: 400; letter-spacing: .03em; }
:root[data-style="dot"] h1::after { content: "_"; color: #c4473a; animation: dot-blink 1s steps(1) infinite; }
@keyframes dot-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { :root[data-style="dot"] h1::after { animation: none; } }
@media print { :root[data-style="dot"] h1::after { content: none; } :root[data-style="dot"] :is(.side, .words, .test-form, .sheet-paper, .card, .howto) { box-shadow: none; } }
:root[data-style="kraft"] :is(input:not([type="checkbox"]):not([type="radio"]), textarea, select) { background-color: #fffbe3; }
/* 見た目ごとの背景の模様 */
:root[data-style="grid"] body { background-image: linear-gradient(#d6e6e0 1px, transparent 1px), linear-gradient(90deg, #d6e6e0 1px, transparent 1px); background-size: 20px 20px; }
:root[data-style="ocean"] body { background-image: linear-gradient(180deg, #bfe4f7 0, #e9f6fc 360px); background-repeat: no-repeat; }
:root[data-style="night"] body { background-image: radial-gradient(1px 1px at 12% 3%, #fff9, transparent), radial-gradient(1px 1px at 78% 2%, #fff7, transparent), radial-gradient(1.5px 1.5px at 52% 1%, #fff8, transparent), radial-gradient(1px 1px at 92% 6%, #fff6, transparent); background-repeat: no-repeat; }
/* 森：机（背景）が暗い緑なので、紙の外に出ている文字は明るい色にする */
:root[data-style="forest"] body { background: #2f4a3a; }
:root[data-style="forest"] .masthead, :root[data-style="forest"] .foot, :root[data-style="forest"] .count, :root[data-style="forest"] .cards-range, :root[data-style="forest"] .cards-opts, :root[data-style="forest"] .c-count, :root[data-style="forest"] .c-keys, :root[data-style="forest"] .c-actions, :root[data-style="forest"] .promo-label { --ink: #f6f2e7; --muted: #c9d8bf; --accent: #c9e4a8; color: var(--ink); }
:root[data-style="forest"] .masthead :is(select, input, .modes, .btn, .contact-link, .who) { --ink: #23301f; --muted: #5d6a55; --accent: #3f6b3a; }
:root[data-style="forest"] .cards-opts .seg { --paper: #23301f; }
:root[data-style="chalk"] .en { font-weight: 700; font-size: 25px; }
:root[data-style="chalk"] .ex-en { color: #f4b2c0; }
:root[data-style="chalk"] .page { background-image: radial-gradient(ellipse at 30% 0%, rgba(255,255,255,.05), transparent 60%); }
:root[data-style="dot"] .en { font-weight: 400; font-size: 25px; }
:root[data-style="washi"] .en { font-weight: 600; font-size: 25px; }
:root[data-style="sakura"] .en, :root[data-style="grid"] .en { font-weight: 600; }
:root[data-style="ocean"] .en { font-weight: 800; }
:root[data-style="kraft"] .en { font-size: 24px; }
:root[data-style="kraft"] .words { box-shadow: 4px 6px 0 rgba(0,0,0,.15); }

body { margin: 0; background: var(--desk); color: var(--ink); font-family: var(--font-jp); font-size: 15px; line-height: 1.7; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.page {
  max-width: 980px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 48px;
  display: grid; gap: 20px;
}

@media (min-width: 1100px) { .page { max-width: none; padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); } }

/* PC: 左に操作パネル、右に単語。スマホ: 上から順に */
.layout { display: grid; gap: 16px; }
.layout .main { min-width: 0; display: grid; gap: 10px; align-content: start; }
.side { min-width: 0; }
@media (min-width: 1100px) {
  .layout { grid-template-columns: 320px minmax(0, 1fr); gap: 28px; align-items: start; }
  .side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); max-height: calc(100vh - 32px); overflow-y: auto; }
}

/* 見出し */
.masthead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; }
.mast-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.style-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.style-pick select { border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 5px 8px; font: inherit; font-weight: 500; }
.brand h1 { margin: 0; font-size: clamp(26px, 5vw, 36px); line-height: 1.2; font-weight: 700; letter-spacing: .02em; text-wrap: balance; }
.home-link { display: inline-block; margin-bottom: 2px; font-size: 13px; font-weight: 700; color: var(--muted); text-decoration: none; }
.home-link:hover { color: var(--accent); text-decoration: underline; }
.lede { margin: 4px 0 0; color: var(--muted); }
.lede b { font-family: var(--font-en); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.modes { display: flex; gap: 4px; background: var(--paper); padding: 4px; border-radius: 999px; border: 1px solid var(--rule); }
.mode { text-decoration: none; color: var(--muted); padding: 6px 16px; border-radius: 999px; font-weight: 500; }
.mode[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* 操作パネル */
.controls {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 14px;
  box-shadow: 0 6px 18px -14px rgba(20, 30, 60, .5);
}
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button, .seg label span {
  display: inline-block; border: 1px solid var(--rule); background: transparent; border-radius: 8px;
  padding: 5px 12px; cursor: pointer; font-weight: 500; color: var(--muted);
}
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.search input {
  width: 100%; border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 9px 12px;
}
.group { display: grid; gap: 6px; min-width: 0; }
.group > .label { font-size: 13px; color: var(--muted); font-weight: 700; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.cat {
  flex: none; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: transparent;
  border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 14px; color: var(--ink); text-align: left;
}
.cat span { font-family: var(--font-en); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.cat[aria-pressed="true"] span { color: inherit; opacity: .75; }
@media (min-width: 1100px) {
  .cats { display: grid; grid-template-columns: 1fr; gap: 2px; overflow: visible; }
  .cat { justify-content: space-between; border-color: transparent; padding: 5px 10px; }
  .cat:hover { background: var(--chip); }
}
.side-actions { display: grid; gap: 6px; }
.btn.ghost { border-color: transparent; color: var(--muted); font-weight: 500; }
.locked .group, .locked .side-actions, .test-form.locked .field:not(.keep) { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid transparent; background: var(--chip); border-radius: 999px; padding: 2px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.toggles { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { accent-color: var(--sheet); width: 18px; height: 18px; }

.count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* 単語ノート */
.words {
  list-style: none; margin: 0; padding: 0;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
}
.word {
  position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 20px;
  padding: 12px 14px 12px 0; box-shadow: 0 1px 0 var(--rule), 1px 0 0 var(--rule);
}
.word::before { content: ""; position: absolute; top: 0; bottom: 0; left: 64px; width: 2px; background: var(--margin); opacity: .55; }
.no { text-align: right; font-family: var(--font-en); font-size: 12px; color: var(--muted); padding-top: 6px; font-variant-numeric: tabular-nums; }
.body { min-width: 0; display: grid; gap: 2px; }
.line1 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.en { font-family: var(--font-en); font-weight: 500; font-size: 22px; letter-spacing: .01em; line-height: 1.3; overflow-wrap: anywhere; }
.pos { font-size: 12px; border: 1px solid currentColor; border-radius: 4px; padding: 0 6px; color: var(--muted); line-height: 1.6; }
.gr { font-size: 11px; font-weight: 700; color: var(--paper); border-radius: 4px; padding: 0 6px; line-height: 1.7; }
.gr.g1 { background: var(--g1); } .gr.g2 { background: var(--g2); } .gr.g3 { background: var(--g3); }
.say {
  border: 1px solid var(--rule); background: var(--paper); color: var(--accent); border-radius: 999px;
  width: 30px; height: 30px; display: inline-grid; place-items: center; cursor: pointer; padding: 0; flex: none;
}
.say:hover { background: var(--chip); }
.say svg { width: 16px; height: 16px; }
.say.small { width: 26px; height: 26px; }
.say.small svg { width: 13px; height: 13px; }
.say.playing { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.mean { color: var(--redpen); font-weight: 500; border-radius: 4px; width: fit-content; max-width: 100%; }
.sheet-on .mean { color: transparent; background: var(--sheet); cursor: pointer; user-select: none; }
.sheet-on .mean.peek { color: var(--redpen); background: transparent; }
.sheet-on .ex-ja { color: transparent; background: color-mix(in srgb, var(--sheet) 70%, transparent); cursor: pointer; border-radius: 4px; }
.sheet-on .ex-ja.peek { color: var(--muted); background: transparent; }

.ex { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 8px; align-items: start; margin-top: 4px; font-size: 14px; }
.ex-en { font-family: var(--font-en); line-height: 1.5; padding-top: 2px; }
mark, .ex-en mark { background: none; color: inherit; text-decoration: underline 2px var(--margin); text-underline-offset: 3px; font-weight: 600; }
.ex-ja { grid-column: 2; color: var(--muted); font-size: 13px; width: fit-content; max-width: 100%; }
.hide-ex .ex { display: none; }

.empty { margin: 0; padding: 24px; text-align: center; color: var(--muted); background: var(--paper); border-radius: var(--radius); border: 1px dashed var(--rule); }

/* テスト */
.test-form { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.field { display: grid; grid-template-columns: 7em minmax(0, 1fr); gap: 8px; align-items: center; }
@media (min-width: 1100px) { .test-form .field { grid-template-columns: minmax(0, 1fr); gap: 4px; } }
.field select { border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 6px 8px; max-width: 100%; }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.label { font-weight: 700; font-size: 14px; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ex-input { width: 100%; box-sizing: border-box; border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 6px 10px; }
.ex-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.ex-note:empty { display: none; }
.ex-note .miss { display: block; color: var(--accent); }
.out-btn { margin-left: auto; flex: none; border: 1px solid var(--rule); background: transparent; color: var(--muted); border-radius: 999px; padding: 1px 10px; font-size: 12px; cursor: pointer; }
.out-btn:hover { background: var(--chip); color: var(--ink); }
.word.is-out { opacity: .5; }
.word.is-out .out-btn { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.range input { width: 6.5em; border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 5px 8px; font-family: var(--font-en); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--ink); background: transparent; border-radius: 8px; padding: 8px 16px; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .4; cursor: default; }
@media (max-width: 560px) { .field { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

.sheet-paper { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; display: grid; gap: 16px; }
.paper-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.paper-head h2 { margin: 0; font-size: 20px; }
.paper-head p { margin: 0; color: var(--muted); font-size: 13px; }
.paper-name { display: flex; align-items: end; gap: 8px; font-size: 14px; }
.blank { display: inline-block; width: 9em; border-bottom: 1px solid var(--ink); height: 1.4em; }
.blank.short { width: 3em; }
.qs { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; counter-reset: q; }
@media (max-width: 640px) { .qs { grid-template-columns: minmax(0, 1fr); } }
/* 問題の並び「縦に」：1 2 3 を左の列に上から、続きを右の列へ */
/* 縦順は段組みにする（gridの縦流しだと複数ページのとき 1ページ目が 1〜12 と 26〜37 のように飛ぶため）。段組みならページごとに左の列→右の列の順になる */
body.order-col .qs { display: block; columns: 2; column-gap: 28px; }
@media screen and (max-width: 640px) { body.order-col .qs { columns: 1; } }
.order-seg { flex-wrap: wrap; }
.q { counter-increment: q; display: grid; grid-template-columns: 2.2em minmax(0, 1fr); gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--rule); break-inside: avoid; }
.q::before { content: counter(q) "."; font-family: var(--font-en); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.q-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.q-word { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.q-word.en-q { font-family: var(--font-en); }
.q-ans { grid-column: 2; min-height: 1.6em; border-bottom: 1px dotted var(--muted); color: var(--redpen); font-weight: 700; }
.q-ans.en-a { font-family: var(--font-en); font-weight: 500; }
.answers-hidden .q-ans { color: transparent; }

/* QRで開いたときの範囲 */
.assigned {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--paper); border: 2px solid var(--redpen); border-radius: var(--radius); padding: 14px 16px;
}
.assigned p { margin: 0; }
.assigned-kicker { font-size: 13px; color: var(--redpen); font-weight: 700; }
.assigned-range { font-size: 18px; font-weight: 700; }
.assigned-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* QRダイアログ */
.qr-dialog { border: 0; padding: 0; border-radius: 14px; background: var(--paper); color: var(--ink); width: min(440px, calc(100vw - 32px)); }
.qr-dialog::backdrop { background: rgba(15, 20, 35, .55); }
.qr-sheet { padding: 22px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.qr-sheet h2 { margin: 0; font-size: 20px; }
.qr-range { margin: 0; font-weight: 700; color: var(--redpen); }
.qr-code { background: #fff; padding: 12px; border-radius: 8px; line-height: 0; min-height: 100px; }
.qr-code svg { display: block; width: 220px; height: 220px; max-width: 100%; }
.qr-fail { line-height: 1.6; color: #1d2740; max-width: 20em; margin: 0; }
.qr-howto { margin: 0; font-size: 13px; color: var(--muted); }
.qr-url { display: flex; gap: 6px; width: 100%; }
.qr-url input { flex: 1; min-width: 0; border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 6px 8px; font-family: var(--font-en); font-size: 12px; }
.qr-sheet .actions { justify-content: center; }

/* 広告枠 */
.promo { display: grid; gap: 8px; margin-top: 12px; }
.promo-label { margin: 0; font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.promo iframe { display: block; width: 100%; border-radius: var(--radius); background: var(--paper); }

.foot { color: var(--muted); font-size: 12px; display: grid; gap: 2px; }
.foot p { margin: 0; }
.policy-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.policy-links a { color: inherit; }

@media (max-width: 480px) {
  .word::before { left: 46px; }
  .word { grid-template-columns: 34px minmax(0, 1fr); gap: 0 18px; }
  .en { font-size: 20px; }
}

/* 印刷: テスト用紙だけを出す */
@media print {
  :root, :root[data-style] { --paper: #fff; --desk: #fff; --ink: #000; --muted: #444; --rule: #bbb; --redpen: #c00; --margin: #e58b8b; color-scheme: light; }
  :root[data-style] { --font-en: "Lexend", "Segoe UI", Arial, sans-serif; --font-jp: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif; }
  .page, body { background-image: none !important; }
  body { background: #fff; font-size: 12pt; }
  .masthead, .test-form, .promo, .foot, #view-list, .say { display: none !important; }
  .page { padding: 0; max-width: none; }
  .sheet-paper { border: 0; padding: 0; }
  .q { padding: 7pt 0; }
}
@media print {
  body.print-qr .page { display: none !important; }
  body.print-qr .qr-dialog { position: static; display: block; width: auto; box-shadow: none; }
  body.print-qr .qr-url, body.print-qr .qr-sheet .actions { display: none !important; }
  body.print-qr .qr-sheet { padding-top: 40pt; gap: 16pt; }
  body.print-qr .qr-sheet h2 { font-size: 24pt; }
  body.print-qr .qr-range { font-size: 16pt; }
  body.print-qr .qr-code svg { width: 7cm; height: 7cm; }
  body:not(.print-qr) .qr-dialog { display: none !important; }
  .assigned, .side { display: none !important; }
}
/* 範囲の単語一覧プリント（印刷のときだけ出す） */
.print-sheet { display: none; }
@media print {
  body.print-list:not(.print-qr) .page, body.print-list:not(.print-qr) .qr-dialog { display: none !important; }
  body.print-list:not(.print-qr) .print-sheet { display: block !important; color: #000; font-size: 10pt; }
  .ps-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16pt; border-bottom: 2pt solid #000; padding-bottom: 6pt; margin-bottom: 8pt; }
  .ps-head h2 { margin: 0; font-size: 16pt; }
  .ps-head p { margin: 2pt 0 0; }
  .ps-range { font-size: 13pt; font-weight: 700; }
  .ps-note { font-size: 9pt; color: #444; }
  .ps-qr svg { width: 2.6cm; height: 2.6cm; display: block; }
  .ps-table { width: 100%; border-collapse: collapse; }
  .ps-table thead { display: table-header-group; }
  .ps-table th { font-size: 8.5pt; text-align: left; border-bottom: 1pt solid #000; padding: 3pt 4pt; }
  .ps-table td { border-bottom: 0.5pt solid #999; padding: 4pt; vertical-align: top; }
  .ps-table tr { break-inside: avoid; }
  .ps-chk { width: 14pt; }
  .ps-chk .box { display: inline-block; width: 9pt; height: 9pt; border: 0.8pt solid #000; }
  .ps-no { width: 26pt; color: #444; font-family: var(--font-en); font-variant-numeric: tabular-nums; }
  .ps-en { font-family: var(--font-en); font-weight: 600; font-size: 12pt; white-space: nowrap; }
  .ps-pos { font-size: 8pt; color: #444; white-space: nowrap; }
  .ps-m { font-weight: 700; }
  .ps-ex { font-family: var(--font-en); font-size: 8.5pt; }
  .ps-ja { font-family: var(--font-jp); color: #444; }
  @page { margin: 12mm; }
}
.opts { display: grid; gap: 4px; font-size: 14px; }
.switch.small { font-size: 13px; color: var(--muted); }
.paper-key { display: none; }
@media print {
  /* 解答ページ：2ページ目から（両面印刷で裏になる） */
  body.with-key .paper-key { display: grid !important; break-before: page; }
  .paper-key .q-ans { color: var(--redpen) !important; }
  /* A4 1枚に収める：用紙の高さいっぱい（A4 297mm − 上下の余白 24mm − ずれの見こみ 7mm）を使い、問題の行を均等に広げる */
  body.fit-a4 #paper, body.fit-a4.with-key .paper-key { display: flex !important; flex-direction: column; height: var(--fit-page, 266mm); gap: 8pt; }
  body.fit-a4 .paper-head { padding-bottom: 4pt; flex: none; }
  body.fit-a4 .paper-head h2 { font-size: 14pt; }
  body.fit-a4 .qs { flex: 1; min-height: 0; grid-template-columns: repeat(var(--fit-cols, 2), minmax(0, 1fr)); grid-template-rows: repeat(var(--fit-rows, 10), minmax(0, 1fr)); grid-auto-rows: 0; gap: 0 14pt; font-size: var(--fit-font, 11pt); }
  body.fit-a4 .q { padding: 3pt 0 2pt; grid-template-rows: auto minmax(0, 1fr); gap: 1pt 6pt; line-height: 1.2; overflow: hidden; }
  body.fit-a4 .q-word.long { font-size: .8em; letter-spacing: -.02em; }
  body.fit-a4 .q-word { font-size: 1.15em; }
  body.fit-a4 .q-ans { min-height: 1.3em; }
  body.fit-a4 .pos { font-size: .7em; flex: none; }
  body.fit-a4 .q-top { flex-wrap: nowrap; align-items: baseline; }
  body.fit-a4 .q-word { min-width: 0; }
  body.fit-a4 .sheet-paper:not(.paper-key) { break-after: auto; }
  /* 縦順の段組みが grid の中だとページをまたいだ最後の問題が消えることがあるので、用紙を block にする */
  body.order-col:not(.fit-a4) .sheet-paper { display: block !important; }
  body.order-col:not(.fit-a4) .paper-head { margin-bottom: 16px; }
  /* A4 1枚のときは1ページに必ず収まるので、行数を決めた grid の縦流しにする */
  body.order-col.fit-a4 .qs { display: grid; grid-auto-flow: column; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===== 1語ずつカード（リングでとじた単語カード）===== */
.cards-view { display: grid; gap: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.cards-bar { display: grid; gap: 8px; }
.cards-range { margin: 0; font-weight: 700; }
.cards-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.deck { display: grid; gap: 12px; }
.deck .prog { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.deck .prog i { display: block; height: 100%; width: 0; background: var(--g1); transition: width .3s; }
.c-count { margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.card-stage { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px 24px; padding-bottom: 12px; }
.c-nav { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); font-size: 20px; cursor: pointer; }
.c-nav:disabled { opacity: .35; cursor: default; }
.fcard {
  position: relative; min-height: min(420px, 60vh); perspective: 1400px; cursor: pointer; outline: none;
  /* 下に重なっているカード */
  filter: drop-shadow(0 10px 14px rgba(10, 20, 40, .16));
}
.fcard::before, .fcard::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px; background: var(--paper); border: 1px solid var(--rule);
  transform: translate(6px, 6px) rotate(1.2deg); z-index: 0;
}
.fcard::after { transform: translate(12px, 11px) rotate(2.4deg); z-index: -1; }
.fcard:focus-visible .fc-face { outline: 3px solid var(--accent); outline-offset: 3px; }
.fc-face {
  position: absolute; inset: 0; z-index: 1; border-radius: 14px; border: 1px solid var(--rule); background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  padding: 28px 28px 28px 72px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform .45s cubic-bezier(.3, .7, .3, 1);
}
/* リングの穴と金具（左はし） */
.fc-face::before { content: ""; position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; background: var(--desk); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .35); }
.fc-face::after { content: ""; position: absolute; left: -16px; top: 50%; width: 52px; height: 30px; margin-top: -15px; border: 4px solid #a9afba; border-top-color: #d7dbe2; border-radius: 50%; }
.fc-back { transform: rotateY(180deg); background: color-mix(in srgb, var(--paper) 90%, var(--accent)); }
.fcard.flipped .fc-front { transform: rotateY(-180deg); }
.fcard.flipped .fc-back { transform: rotateY(0); }
.fcard.is-known .fc-front { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--g1) 55%, transparent); }
.fc-meta { position: absolute; top: 14px; right: 16px; display: flex; gap: 6px; align-items: center; }
.fc-no { font-family: var(--font-en); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fc-word { font-family: var(--font-en); font-weight: 600; font-size: clamp(40px, 8vw, 72px); line-height: 1.1; overflow-wrap: normal; word-break: keep-all; max-width: 100%; }
.fc-word.small { font-size: 22px; color: var(--muted); font-weight: 500; }
.fc-mean { color: var(--redpen); font-weight: 700; font-size: clamp(28px, 5.5vw, 44px); line-height: 1.3; }
.fc-tap { font-size: 14px; color: var(--muted); }
.fc-ex { display: grid; gap: 4px; max-width: 34em; font-size: 16px; }
.fc-ex .ex-en { font-size: 20px; }
.fc-ja { color: var(--muted); font-size: 15px; }
.c-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.c-actions .btn { min-width: 8em; padding: 12px 20px; font-size: 17px; }
.c-got { background: var(--g1) !important; border-color: var(--g1) !important; color: var(--paper) !important; }
.c-keys { text-align: center; }
.deck-done { display: grid; gap: 10px; justify-items: center; text-align: center; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 32px 16px; }
.dd-title { margin: 0; font-size: 22px; font-weight: 700; }
.dd-sum { margin: 0; color: var(--muted); }
@media (max-width: 560px) {
  .card-stage { grid-template-columns: minmax(0, 1fr); padding: 0 12px 12px 14px; }
  .c-nav { display: none; }
  .c-actions { flex-wrap: nowrap; }
  .c-actions .btn { flex: 1; min-width: 0; padding: 12px 6px; font-size: 16px; }
  .fcard { min-height: 260px; }
  .fc-face { padding: 40px 18px 22px 56px; }
  .fc-face::before { left: 10px; } .fc-face::after { left: -18px; }
}
@media (prefers-reduced-motion: reduce) { .fc-face { transition: none; } }
@media print { #view-cards { display: none !important; } }

/* 要望・不具合を送るリンク（ホームの問い合わせページへ） */
.contact-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted);
  text-decoration: none; border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 4px 12px;
}
.contact-link:hover { color: var(--accent); border-color: var(--accent); }

/* ===== ロードマップ（星3つ）とクイズ ===== */
:root { --star: #e0a21b; --star-off: color-mix(in srgb, var(--muted) 30%, transparent); --ok: var(--g1); --ng: var(--redpen); }
:root[data-style="chalk"], :root[data-style="night"] { --star: #ffd54a; }
:root[data-style="retro"] { --star: #ffd166; }
.road-pct { font-size: 12px; font-family: var(--font-en); opacity: .85; margin-left: 2px; }
.road-view, .quiz-view { display: grid; gap: 14px; width: 100%; }
.road-box { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.road-box p { margin: 0; }
.road-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; }
.road-k { font-size: 13px; font-weight: 700; color: var(--muted); }
.road-big { font-family: var(--font-en); margin: 2px 0 6px !important; line-height: 1.2; }
.road-big b { font-size: 40px; font-weight: 600; }
.road-big > span { color: var(--muted); font-size: 18px; }
.road-bar { height: 12px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.road-bar i { display: block; height: 100%; width: 0; background: var(--star); border-radius: inherit; transition: width .4s; }
.road-sub { font-size: 13px; color: var(--muted); margin-top: 8px !important; }
.road-legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--muted); }
.road-next { border-left: 5px solid var(--accent); display: grid; align-content: start; gap: 6px; }
.road-next-title { font-size: 20px; font-weight: 700; }
.road-next-title span { font-size: 14px; color: var(--muted); font-weight: 500; }
.road-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.stars { display: inline-flex; gap: 2px; font-size: 22px; line-height: 1; }
.star { color: var(--star-off); }
.star.on { color: var(--star); text-shadow: 0 1px 0 rgba(0,0,0,.12); }
.road-legend .star { font-size: 15px; }
.road-grades { display: flex; flex-wrap: wrap; gap: 8px; justify-self: start; }
.road-grades .grade span { font-family: var(--font-en); font-size: 12px; margin-left: 8px; opacity: .85; }
.road-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.road-tile { background: var(--paper); border: 1.5px solid var(--rule); border-radius: var(--radius); padding: 10px 12px 12px; display: grid; gap: 4px; align-content: start; }
.road-tile p { margin: 0; }
.road-tile.clear { border-color: color-mix(in srgb, var(--ok) 55%, var(--rule)); background: color-mix(in srgb, var(--ok) 7%, var(--paper)); }
.road-tile.now { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.rt-no { display: flex; gap: 6px; align-items: baseline; font-family: var(--font-en); font-size: 12px; font-weight: 600; color: var(--muted); }
.rt-no b { font-family: var(--font-jp); color: var(--accent); }
.rt-n { margin-left: auto; font-weight: 400; }
.rt-title { font-weight: 700; font-size: 15px; line-height: 1.4; min-height: 2.8em; }
.rt-mini { height: 5px; border-radius: 9px; background: var(--chip); overflow: hidden; }
.rt-mini i { display: block; height: 100%; background: var(--ok); }
.rt-sub { font-size: 12px; color: var(--muted); }
.rt-acts { display: flex; gap: 6px; margin-top: 4px; }
.rt-acts .btn { flex: 1; padding: 5px 8px; font-size: 13px; }
.road-hint { margin: 0; }
/* クイズ */
.quiz-view { max-width: 760px; margin: 0 auto; }
.quiz-box { display: grid; gap: 12px; padding: 18px 20px 20px; }
.quiz-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 700; }
.quiz-count { font-family: var(--font-en); color: var(--muted); }
.quiz-box .road-bar i { background: var(--accent); }
.quiz-ask { color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 6px !important; }
.quiz-q { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 92px; text-align: center; flex-wrap: wrap; }
.qz-word { font-family: var(--font-en); font-size: clamp(30px, 7vw, 46px); font-weight: 600; overflow-wrap: anywhere; }
.qz-mean { font-size: clamp(22px, 5vw, 30px); font-weight: 700; }
.quiz-q .pos { font-size: 13px; }
.quiz-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.qz-choice { display: flex; align-items: center; gap: 10px; text-align: left; min-height: 56px; padding: 10px 14px; border: 1.5px solid var(--rule); border-radius: var(--radius); background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; overflow-wrap: anywhere; }
.qz-choice.en { font-family: var(--font-en); font-size: 18px; font-weight: 500; }
.qz-choice:hover:not(:disabled) { border-color: var(--accent); }
.qz-choice:disabled { cursor: default; opacity: .6; }
.qz-choice.right { opacity: 1; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, var(--paper)); }
.qz-choice.wrong { opacity: 1; border-color: var(--ng); background: color-mix(in srgb, var(--ng) 14%, var(--paper)); }
.qz-key { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--chip); color: var(--muted); font-family: var(--font-en); font-size: 12px; font-weight: 600; }
.quiz-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-top: 4px; }
.quiz-fb { font-weight: 700; }
.quiz-fb.ok { color: var(--ok); }
.quiz-fb.ng { color: var(--ng); }
.quiz-fb b { color: var(--ink); }
.quiz-foot #qz-next { flex-shrink: 0; white-space: nowrap; }   /* 解説が長くても「次へ」が縦に折れないように */
.quiz-result { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 8px 0; }
.quiz-result .stars { font-size: 40px; gap: 6px; }
.qr-title { font-size: 26px; font-weight: 700; }
.qr-score { font-family: var(--font-en); color: var(--muted); }
.qr-score b { font-size: 34px; color: var(--ink); }
.qr-miss { width: 100%; max-width: 420px; text-align: left; background: var(--desk); border-radius: var(--radius); padding: 10px 14px; }
.qr-miss ul { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 14px; }
.qr-miss [lang="en"] { font-family: var(--font-en); font-weight: 600; }
.quiz-result .road-acts { justify-content: center; }
.quiz-back { justify-self: start; }
/* お祝いの通知 */
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 20px; border-radius: 999px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 32px); text-align: center; }
.toast.show { animation: toast-in .35s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .toast.show { animation: none; } }
@media (max-width: 760px) {
  .road-top { grid-template-columns: minmax(0, 1fr); }
  .road-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .rt-title { min-height: 0; }
  .rt-acts .btn { padding: 4px 4px; }
}
@media (max-width: 480px) {
  .quiz-choices { grid-template-columns: minmax(0, 1fr); }
  .road-big b { font-size: 34px; }
}
@media print { #view-road, #view-quiz, .toast { display: none !important; } }
/* 見た目ごとの調整 */
:root[data-style="dot"] :is(.road-box, .road-tile, .qz-choice) { border-color: transparent; box-shadow: 0 -3px 0 0 var(--ink), 0 3px 0 0 var(--ink), -3px 0 0 0 var(--ink), 3px 0 0 0 var(--ink); }
:root[data-style="dot"] .road-tile.now { box-shadow: 0 -3px 0 0 var(--accent), 0 3px 0 0 var(--accent), -3px 0 0 0 var(--accent), 3px 0 0 0 var(--accent), 4px 6px 0 0 rgba(46,42,51,.25); }
:root[data-style="dot"] .qz-choice.right { box-shadow: 0 -3px 0 0 var(--ok), 0 3px 0 0 var(--ok), -3px 0 0 0 var(--ok), 3px 0 0 0 var(--ok); }
:root[data-style="dot"] .qz-choice.wrong { box-shadow: 0 -3px 0 0 var(--ng), 0 3px 0 0 var(--ng), -3px 0 0 0 var(--ng), 3px 0 0 0 var(--ng); }
:root[data-style="dot"] :is(.road-grid, .quiz-choices) { gap: 14px; }
:root[data-style="retro"] :is(.road-box, .road-tile, .qz-choice) { border-color: var(--rule); }
:root[data-style="kraft"] :is(.road-box, .road-tile) { box-shadow: 3px 4px 0 rgba(0,0,0,.14); }
:root[data-style="forest"] .road-hint { color: #e6efd9; }
:root[data-style="forest"] .road-grades { --paper: #f6f2e7; }
.road-grades .grade { background: var(--paper); font-size: 15px; padding: 6px 16px; }
/* タブが4つになったので、せまい画面では1行に収める */
.mode { white-space: nowrap; }
@media (max-width: 560px) {
  .modes { width: 100%; display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; }
  .mode { padding: 6px 10px; text-align: center; font-size: 14px; letter-spacing: 0; }
  .road-pct { display: none; }
}
.quiz-fb .say { vertical-align: middle; margin-left: 6px; }

/* 問題数を指定 */
.tn-num-row { margin-top: 6px; }
.tn-num-row input { width: 7em; }

/* 印刷：ブラウザが自動で付けるURL・日付・タイトル・ページ番号を最初から出さない。
   上下の余白に空の欄（ページ余白ボックス）を置くと、Chrome / Edge はそこに何も入れなくなる。余白の広さは変わらない */
@page {
  @top-left { content: ""; } @top-center { content: ""; } @top-right { content: ""; }
  @bottom-left { content: ""; } @bottom-center { content: ""; } @bottom-right { content: ""; }
}

/* ===== 古文単語ノート（元素記号ノートの作りを流用） ===== */
.words { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.type-dou, .type-ke { color: var(--g1); } .type-kei, .type-kd { color: var(--g2); } .type-mei, .type-fuku, .type-etc { color: var(--g3); } .type-ke { color: var(--redpen); }
.word.el-row .line1 .out-btn { margin-left: auto; }
.pl-forms { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.pl-forms .f-ing { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--rule); }
.el-forms .f-base .f-v { font-size: 24px; color: var(--redpen); }
.el-forms .f-name .f-v { font-family: var(--font-jp); font-size: 17px; font-weight: 700; padding-top: 4px; color: var(--ink); }
.fc-back .fc-mean { color: var(--ink); }
.el-forms .f-ing .f-v { font-size: 14px; }
.el-forms .f-ing b { font-family: var(--font-en); }
.fx { font-family: var(--font-en); font-variant-numeric: lining-nums; white-space: nowrap; }
.fx sub, .fx sup { font-size: .62em; line-height: 0; }
.fx sub { vertical-align: -.28em; }
.fx sup { vertical-align: .62em; }
.rx { display: flex; gap: 8px; align-items: baseline; margin-top: 6px; font-size: 15px; overflow-x: auto; }
.rx-k { flex: none; font-size: 11px; font-weight: 700; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px; }
.hide-ex .rx { display: none; }
.sheet-on .mean { color: transparent !important; background: var(--sheet); cursor: pointer; user-select: none; border-radius: 4px; }
.sheet-on .mean.peek { color: var(--ink) !important; background: transparent; }
.pl-note { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.pl-note::before { content: "ポイント："; font-weight: 700; color: var(--redpen); }
.fc-note { font-size: 14px; color: var(--redpen); font-weight: 600; max-width: 34em; }
.fc-word.fx { white-space: nowrap; max-width: 100%; overflow: hidden; }
.fc-back .fc-word { font-size: clamp(36px, 7vw, 60px); }
.fc-hl { color: var(--redpen); }
.fc-ex .ex-en { white-space: nowrap; max-width: 100%; overflow: hidden; }
.qz-word.qz-ja { font-family: var(--font-jp); }
.qz-choice.fx { font-size: 20px; }
.qz-note { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.vt .vt-pr { width: 5.5em; text-align: center; }
.forms { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 6px 0 2px; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.f { display: grid; gap: 0; padding: 4px 8px 5px; min-width: 0; }
.f + .f { border-left: 1px solid var(--rule); }
.f-k { font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.f-v { font-family: var(--font-en); font-size: 19px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; border-radius: 4px; width: fit-content; max-width: 100%; }
.f-base .f-v { color: var(--ink); }
.f-past .f-v, .f-pp .f-v { color: var(--redpen); }
.f-ing .f-v { font-size: 15px; font-weight: 500; color: var(--muted); padding-top: 3px; }
.f-base { background: var(--chip); }
.sheet-forms .hide-me { color: transparent !important; background: var(--sheet); cursor: pointer; user-select: none; }
.sheet-forms .hide-me.peek { color: var(--redpen) !important; background: transparent; }

/* カード */
.fc-forms { flex: none; width: 100%; overflow: hidden; font-family: var(--font-en); font-size: clamp(30px, 6vw, 52px); font-weight: 600; line-height: 1.15; white-space: nowrap; display: flex; gap: .25em; align-items: baseline; justify-content: center; max-width: 100%; }
.fc-forms i { font-style: normal; color: var(--muted); font-weight: 400; }
.fc-forms .fc-hl { color: var(--redpen); }
.fc-ing { color: var(--muted); font-size: 15px; }
.fc-ing span { font-family: var(--font-en); font-weight: 600; }
.fc-mean.small { font-size: clamp(18px, 3.5vw, 24px); color: var(--muted); font-weight: 500; }
.fc-ask { font-size: 15px; color: var(--accent); font-weight: 700; }
.fc-back .fc-mean { font-size: clamp(20px, 4vw, 30px); }
.fc-ex .ex-en { font-size: 17px; }
.qz-mean.small { font-size: 16px; color: var(--muted); font-weight: 500; width: 100%; }

/* 活用テストの表 */
.dir-seg { flex-wrap: wrap; }
.vt-wrap { overflow-x: auto; }
.vt { width: 100%; border-collapse: collapse; font-size: 15px; }
.vt th { font-size: 12px; font-weight: 700; text-align: left; padding: 4px 6px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
.vt td { padding: 0 6px; height: 2.4em; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.vt td + td, .vt th + th { border-left: 1px solid var(--rule); }
.vt .vt-no { width: 2.4em; text-align: right; color: var(--muted); font-family: var(--font-en); font-variant-numeric: tabular-nums; }
.vt .vt-m { width: 26%; }
.vt td.vt-en { font-family: var(--font-en); font-weight: 500; }
.vt .vt-blank { background: color-mix(in srgb, var(--chip) 40%, transparent); }
.vt .vt-ans { color: var(--redpen); font-weight: 700; }
.answers-hidden .vt-ans { color: transparent; }
.vt.with-ing .vt-m { width: 22%; }
@media (max-width: 640px) { .vt { font-size: 13px; } .vt th { font-size: 10.5px; } .vt td, .vt th { padding: 0 3px; } }
@media print {
  .vt { font-size: var(--fit-font, 11.5pt); color: #000; }
  .vt th { font-size: 9pt; border-bottom: 1.2pt solid #000; padding: 3pt 4pt; }
  .vt td { height: 26pt; border-bottom: .6pt solid #777; padding: 0 4pt; }
  .vt td + td, .vt th + th { border-left: .6pt solid #999; }
  .vt tr { break-inside: avoid; }
  .vt thead { display: table-header-group; }
  .vt .vt-blank { background: none; }
  .paper-key .vt-ans { color: var(--redpen) !important; }
  body.fit-a4 .vt-wrap { flex: 1; min-height: 0; overflow: hidden; }
  body.fit-a4 .vt td { height: var(--row-h, 26pt); }
  .ps-ing { font-weight: 400 !important; font-size: 10pt !important; color: #333; }
  .ps-table .ps-en { font-size: 11pt; }
  .ps-table .ps-m { width: 17%; font-size: 9.5pt; }
  .ps-table .ps-ex { width: 36%; font-size: 8pt; line-height: 1.3; }
  .ps-table td { padding: 3pt 4pt; }
  .vt .vt-m { width: 30%; font-size: .78em; line-height: 1.2; }
  .vt.with-ing .vt-m { width: 26%; }
}
@media (max-width: 640px) {
  .fc-back { justify-content: flex-start; padding-top: 44px; gap: 6px; }
  .fc-back .fc-ex > :nth-child(n+3) { display: none; }
  .fc-ing { font-size: 13px; }
  .fc-ex .ex-en { font-size: 15px; }
}

/* 古文単語：見出し・例文は日本語の書体で */
.f-v, .fc-word, .ex-en, .qz-word, .qz-choice, .vt td.vt-en, .ps-en, .ps-ex, .fc-forms { font-family: var(--font-jp); }
.kb-row .f-base .f-v { font-size: 22px; font-weight: 700; }
.f-v small, .fc-word small, .qz-word small, .vt small, .ps-en small { font-size: .6em; font-weight: 500; }
.kj { display: inline-block; margin-left: .5em; font-size: 13px; font-weight: 500; color: var(--muted); }
.sheet-forms .hide-me .kj { color: transparent; }
.sheet-forms .hide-me.peek .kj { color: var(--muted); }
.kb-row .f-name .f-v { font-size: 15.5px; line-height: 1.45; }
.ko-b { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--redpen); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; line-height: 1.5; margin-left: 6px; }
.kb-row .ex { display: block; margin-top: 6px; }
.kb-row .ex-en { display: block; font-size: 15px; }
.kb-row .ex-ja { display: block; }
mark, .ex-en mark { background: none; color: inherit; text-decoration: underline 2px var(--redpen); text-underline-offset: 4px; font-weight: 700; }
.src { font-size: 11.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.fc-ex { text-align: center; }
.fc-ex .ex-en { font-size: 18px; white-space: normal; overflow: visible; }
.fc-ex .ex-ja { font-size: 14px; color: var(--muted); }
.fc-ing .ko-b { font-family: var(--font-jp); }
.fc-back .fc-mean { font-size: clamp(18px, 3.4vw, 26px); text-align: center; }
.fc-front .fc-mean { font-size: clamp(20px, 4vw, 30px); text-align: center; }
.qz-word.qz-m { font-size: clamp(18px, 3.6vw, 26px); }
.qz-word.qz-ex { font-size: clamp(18px, 3.4vw, 24px); line-height: 1.6; }
.qz-choice { font-size: 16px; line-height: 1.4; text-align: left; }
.qz-choice.qz-kogo { font-size: 20px; font-weight: 700; }
.vt .vt-w { width: 30%; font-weight: 700; }
.kb-vt.dir-ex .vt-ex { width: 52%; font-size: .95em; line-height: 1.45; padding: 4px 6px; }
.kb-vt .vt-m { width: auto; }
.kb-vt .vt-pr { width: 6.5em; }
.kb-vt .vt-ans { font-size: .92em; }
@media print {
  .vt .vt-m, .vt.with-ing .vt-m { width: auto; }
  .kb-vt.dir-ex .vt-ex { width: 55%; font-size: .9em; }
  .ps-table .ps-m { width: 26%; }
  .ps-table .ps-ex { width: 38%; }
  .ps-table .ps-en { font-size: 11.5pt; font-weight: 700; white-space: nowrap; }
  .ex-en mark { text-decoration-color: #000; }
}
.kb-row .forms { grid-template-columns: minmax(6.5em, max-content) minmax(0, 1fr); }
.kb-row .f-name .f-v { width: auto; overflow-wrap: break-word; }
.fc-ex { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.fc-ex .ex-ja { grid-column: auto; }
@media (max-width: 640px) {
  .fc-back { gap: 4px; }
  .fc-back .fc-word { font-size: 34px; }
  .fc-back .fc-mean { font-size: 17px; }
  .fc-ex .ex-en { font-size: 14.5px; }
  .fc-ex .ex-ja { font-size: 12px; }
  .fc-back .fc-note { font-size: 12px; }
}
@media (max-width: 400px) { .fc-back .fc-note { display: none; } }
/* スマホ：例文の長いカード（和歌・枕草子など）でも訳が切れないように、カードを少し高くする */
@media (max-width: 560px) { .fcard { min-height: 300px; } }
/* 頻出 */
.hin-b { display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 4px; padding: 0 6px; line-height: 1.6; margin-left: 6px; }
.fc-meta .hin-b { margin-left: 0; }
.cat-hin { font-weight: 700; color: var(--accent); }
.cat-hin[aria-pressed="true"] { color: inherit; }
