/* 中学数学プリント。英単語ノート・ホームと同じ「罫線ノート」の配色・見た目を使う */
: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"] .unit-title { --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; }


/* 教科の色（カードの左の帯と1文字マーク） */
:root { --s-en: #2c6fb7; --s-ma: #c0582b; --s-ja: #2e8a5c; --s-sc: #8a4bb5; --s-so: #a8741a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-style]) { --s-en: #7fb4ff; --s-ma: #ff9f73; --s-ja: #6fd0a0; --s-sc: #c99bf0; --s-so: #e8bd62; } }
:root[data-theme="dark"]:not([data-style]) { --s-en: #7fb4ff; --s-ma: #ff9f73; --s-ja: #6fd0a0; --s-sc: #c99bf0; --s-so: #e8bd62; }
:root[data-style="chalk"] { --s-en: #9cc8ff; --s-ma: #ffb38a; --s-ja: #9fe0b9; --s-sc: #e3b5ff; --s-so: #f6d55c; }
:root[data-style="night"] { --s-en: #8fc1ff; --s-ma: #ffb38a; --s-ja: #7fe0b0; --s-sc: #d6a8ff; --s-so: #ffc857; }
:root[data-style="retro"] { --s-en: #7fd8ff; --s-ma: #ffb38a; --s-ja: #39ff88; --s-sc: #ff9bd6; --s-so: #ffd166; }

body { margin: 0; background: var(--desk); color: var(--ink); font-family: var(--font-jp); font-size: 15px; line-height: 1.7; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

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

/* 見出し */
.masthead { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; }
.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; }
.brand h1 { margin: 0; font-size: clamp(26px, 5vw, 38px); line-height: 1.2; font-weight: 700; letter-spacing: .02em; }
.brand h1::before { content: "数"; display: inline-grid; place-items: center; width: 1.2em; height: 1.2em; margin-right: .3em; border-radius: 50%; background: var(--s-ma); color: var(--paper); font-size: .75em; vertical-align: .12em; }
.lede { margin: 6px 0 0; color: var(--muted); }
.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-weight: 500; }
.who { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); padding: 3px; }
.who-btn { border: 0; background: none; border-radius: 999px; padding: 4px 16px; font-weight: 700; color: var(--muted); cursor: pointer; }
.who-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.guide p { margin: 0; font-size: 14px; background: var(--paper); border: 1px solid var(--rule); border-left: 6px solid var(--g1); border-radius: 8px; padding: 8px 14px; }
.guide .guide-teacher { display: none; border-left-color: var(--s-ma); }
:root[data-teacher="1"] .guide .guide-teacher { display: block; }
:root[data-teacher="1"] .guide .guide-student { display: none; }
.who-label { align-self: center; padding: 0 6px 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.jump { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.jump a { flex: none; font-size: 13px; color: var(--ink); text-decoration: none; background: var(--chip); border-radius: 6px; padding: 3px 10px; }
.jump a:hover { background: var(--accent); color: var(--accent-ink); }
.unit { scroll-margin-top: 12px; }
.teacher-only { display: none !important; }
:root[data-teacher="1"] .teacher-only { display: flex !important; }

/* しぼりこみ */
.controls { display: grid; gap: 10px; }
.search { width: 100%; border: 1px solid var(--rule); background: var(--paper); border-radius: 10px; padding: 9px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 4px 13px; cursor: pointer; font-weight: 500; color: var(--muted); }
.chip .n { font-family: var(--font-en); font-size: 12px; font-variant-numeric: tabular-nums; opacity: .8; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* 単元ごとのまとまり */
#list { display: grid; gap: 28px; }
.unit-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 21px; line-height: 1.3; padding-bottom: 6px; border-bottom: 2px solid var(--rule); }
.grade { font-size: 12px; font-weight: 700; color: var(--paper); background: var(--s-ma); border-radius: 6px; padding: 2px 8px; }
.count { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); }
.sub-title { margin: 14px 0 8px; font-size: 15px; color: var(--muted); }
.sub-title::before { content: "▸ "; color: var(--s-ma); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
@media (min-width: 1600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* カード */
.card { display: grid; grid-template-rows: 1fr auto; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 24px -20px rgba(20, 30, 60, .55); }
.card-open { display: grid; grid-template-rows: auto 1fr; align-content: start; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; }
.thumb { position: relative; aspect-ratio: 210 / 297; background: #fff; border-bottom: 1px solid var(--rule); overflow: hidden; }
.thumb.wide { aspect-ratio: 297 / 210; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .2s ease; }
.peek { position: absolute; inset: auto 8px 8px auto; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; opacity: 0; transform: translateY(4px); transition: .15s ease; }
.card-open:hover .peek, .card-open:focus-visible .peek { opacity: 1; transform: none; }
.card-open:hover .thumb img { transform: scale(1.03); }
.new { position: absolute; top: 8px; left: 8px; background: var(--redpen); color: #fff; font-family: var(--font-en); font-size: 11px; font-weight: 600; letter-spacing: .08em; border-radius: 4px; padding: 1px 7px; }
.card-body { display: grid; align-content: start; gap: 3px; padding: 10px 12px 12px; }
.kind { justify-self: start; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 7px; background: var(--chip); }
.k-test { background: var(--s-ma); color: var(--paper); }
.k-practice { background: color-mix(in srgb, var(--s-ma) 18%, var(--paper)); }
.k-exam { background: var(--ink); color: var(--paper); }
.k-summary { background: var(--g1); color: var(--paper); }
.card.is-summary { border-color: color-mix(in srgb, var(--g1) 55%, var(--rule)); }
.series { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.title { margin: 0; font-size: 16px; line-height: 1.4; font-weight: 700; }
.tags { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.tags li { font-size: 11px; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 6px; }
.card-act { gap: 6px; padding: 0 12px 12px; }
.card-act .btn { flex: 1; }
.empty { color: var(--muted); }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 16px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-style: dashed; }
.btn:hover { filter: brightness(1.05); }

/* プレビュー */
.viewer { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0; background: var(--desk); color: var(--ink); overflow-y: auto; overscroll-behavior: contain; }
.viewer::backdrop { background: rgba(10, 15, 30, .6); }
.v-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--paper); border-bottom: 1px solid var(--rule); }
.v-close { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: var(--desk); cursor: pointer; font-size: 18px; }
.v-head { min-width: 0; flex: 1; }
.v-series { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-title { margin: 0; font-size: 18px; line-height: 1.3; }
/* スマホ：見出しは1段目に、「できた」「答えも見る」は2段目に（見出しが細く割れないように） */
@media (max-width: 560px) {
  .v-bar { flex-wrap: wrap; row-gap: 8px; }
  .v-head { flex: 1 1 calc(100% - 56px); }
}
.v-ans { flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; background: var(--chip); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.v-ans input { width: 18px; height: 18px; accent-color: var(--accent); }
.v-tools { flex-wrap: wrap; gap: 8px; padding: 10px 16px 0; }
.v-pages { display: grid; gap: 14px; padding: 14px 16px 40px; }
/* PC：画面の幅に合わせて、プリントを2〜3ページ横にならべる */
@media (min-width: 1000px) {
  .v-pages { grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); gap: 20px; padding: 20px max(24px, 2.5vw) 48px; align-items: start; }
  .v-tools { padding-inline: max(24px, 2.5vw); }
  .v-bar { padding-inline: max(24px, 2.5vw); }
  .v-more { grid-column: 1 / -1; }
}
.v-page { position: relative; margin: 0; background: #fff; border-radius: 4px; box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .45); overflow: hidden; }
.v-page:not(.ready)::after { content: "読みこみ中…"; position: absolute; inset: 0; display: grid; place-items: center; color: #889; font-size: 14px; }
.v-page canvas { display: block; width: 100%; height: auto; }
.v-page figcaption { position: absolute; right: 8px; bottom: 6px; font-family: var(--font-en); font-size: 11px; color: #667; background: rgba(255, 255, 255, .85); border-radius: 4px; padding: 0 6px; }
.v-page.is-ans { outline: 3px solid color-mix(in srgb, var(--redpen) 55%, transparent); }
.v-more { justify-self: center; }
.v-msg { margin: 20px 16px; color: var(--redpen); font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); padding: 8px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .6); max-width: calc(100vw - 32px); }
.print-frame { position: fixed; right: 0; bottom: 0; width: 1px; height: 1px; border: 0; opacity: 0; }

.foot { color: var(--muted); font-size: 12px; }
.foot p { margin: 0; }

:root[data-style="chalk"] .card { box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .thumb img, .peek { transition: none; } }

/* 先生モードのパスワード */
.pw { width: min(360px, calc(100vw - 32px)); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); color: var(--ink); padding: 20px 22px; }
.pw::backdrop { background: rgba(10, 15, 30, .55); }
.pw h2 { margin: 0 0 4px; font-size: 18px; }
.pw p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.pw input { width: 100%; border: 1px solid var(--rule); background: var(--desk); border-radius: 8px; padding: 9px 12px; font-size: 16px; }
.pw .pw-err { margin: 8px 0 0; color: var(--redpen); font-weight: 700; }
.pw-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* 要望・不具合を送るリンク（ホームの問い合わせページへ） */
.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); }

/* ===== 一覧 ⇄ ロードマップ の切りかえ ===== */
.views { display: flex; gap: 6px; border-bottom: 2px solid var(--rule); }
.view-btn { display: inline-flex; align-items: center; gap: 6px; border: 2px solid transparent; border-bottom: 0; margin-bottom: -2px; background: none; border-radius: var(--radius) var(--radius) 0 0; padding: 8px 18px; font-weight: 700; font-size: 15px; color: var(--muted); cursor: pointer; }
.view-btn[aria-pressed="true"] { background: var(--paper); border-color: var(--rule); color: var(--ink); }
.view-btn:hover { color: var(--ink); }
.view-pct { font-family: var(--font-en); font-size: 12px; font-weight: 600; background: var(--chip); color: var(--ink); border-radius: 999px; padding: 0 8px; }
.view-pct:empty { display: none; }
.listview { display: grid; gap: 20px; }

/* 一覧のカード：できたプリント */
.done-badge { display: none; position: absolute; top: 8px; right: 8px; background: var(--g1); color: var(--paper); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 9px; }
.card.is-done .done-badge { display: block; }
.card.is-done .thumb img { opacity: .6; }

/* プレビューの「できた！」 */
.v-done { flex: none; border: 2px solid var(--g1); background: var(--paper); color: var(--g1); border-radius: 999px; padding: 4px 14px; font-weight: 700; cursor: pointer; }
.v-done[aria-pressed="true"] { background: var(--g1); color: var(--paper); }

/* 進み具合のバー */
.bar { height: 10px; background: var(--chip); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--g1); border-radius: inherit; transition: width .4s ease; }
.bar.big { height: 16px; }
.bar.thin { height: 6px; }

/* ===== ロードマップ ===== */
.road { display: grid; gap: 22px; }
.road-sum { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 760px) { .road-sum { grid-template-columns: 1fr; } }
.sum-main, .sum-next { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 6px; align-content: start; }
.sum-label { margin: 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.sum-num { margin: 0; font-family: var(--font-en); font-size: 18px; color: var(--muted); display: flex; align-items: baseline; gap: 4px; }
.sum-num b { font-size: 40px; line-height: 1; color: var(--ink); }
.sum-pct { margin-left: auto; font-size: 28px; font-weight: 600; color: var(--g1); }
.sum-sub { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.sum-next { border-left: 6px solid var(--accent); }
.sum-next.all-clear { border-left-color: var(--g1); }
.next-unit { margin: 0; font-size: 13px; color: var(--muted); }
.next-title { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.4; }
.next-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* 学年ごとのレーン：PCは横にならべる（左から右へ、上から下へ進む） */
.lanes { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); align-items: start; }
.lane { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 14px 10px; display: grid; gap: 8px; }
.lane-title { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 18px; }
.lane-title .grade { font-size: 14px; padding: 2px 10px; }
.lane-n { margin-left: auto; font-family: var(--font-en); font-size: 13px; font-weight: 500; color: var(--muted); }

/* ステージ（単元）。左の線でつながる */
.stages { list-style: none; margin: 6px 0 0; padding: 0; display: grid; }
.stage { position: relative; padding-bottom: 6px; }
.stage::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: -4px; width: 4px; background: var(--rule); border-radius: 2px; }
.stage.is-done::before { background: var(--g1); }
.stage:last-child::before { display: none; }
.stage details > summary { list-style: none; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center; cursor: pointer; border-radius: 8px; padding: 4px 6px 4px 0; }
.stage details > summary::-webkit-details-marker { display: none; }
.stage details > summary:hover { background: var(--chip); }
.st-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--rule); background: var(--paper); color: var(--muted); font-family: var(--font-en); font-weight: 600; font-size: 15px; }
.is-going .st-dot { border-color: var(--accent); color: var(--accent); }
.is-done .st-dot { border-color: var(--g1); background: var(--g1); color: var(--paper); font-size: 18px; }
.st-info { display: grid; gap: 3px; min-width: 0; }
.st-name { font-weight: 700; font-size: 15px; line-height: 1.35; }
.st-name::after { content: " ▾"; font-size: 11px; color: var(--muted); }
details[open] .st-name::after { content: " ▴"; }
.st-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.st-state { font-weight: 700; border-radius: 4px; padding: 0 6px; background: var(--chip); }
.is-going .st-state { background: color-mix(in srgb, var(--accent) 16%, var(--paper)); color: var(--accent); }
.is-done .st-state { background: var(--g1); color: var(--paper); }
.st-n { font-family: var(--font-en); margin-left: auto; }
.is-done .bar i { background: var(--g1); }
.is-going .bar i { background: var(--accent); }

.st-prints { list-style: none; margin: 6px 0 8px 48px; padding: 0; display: grid; gap: 4px; }
.st-sub { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 4px; }
.st-sub::before { content: "▸ "; color: var(--s-ma); }
.st-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: center; }
.tick { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--rule); background: var(--paper); color: var(--paper); font-weight: 700; cursor: pointer; display: grid; place-items: center; font-size: 16px; padding: 0; }
.tick:hover { border-color: var(--g1); }
.tick[aria-pressed="true"] { background: var(--g1); border-color: var(--g1); }
.st-open { display: flex; align-items: center; gap: 6px; min-width: 0; border: 0; background: none; text-align: left; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.st-open:hover { background: var(--chip); }
.st-title { font-size: 14px; line-height: 1.4; }
.st-open:hover .st-title { color: var(--accent); text-decoration: underline; }
.st-row.is-done .st-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.st-mark { width: 30px; height: 30px; display: grid; place-items: center; font-size: 17px; }
.st-summary .st-title { font-weight: 700; }

.road-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.road-foot p { margin: 0; }

/* 見た目ごとの調整 */
:root[data-style="dot"] :is(.lane, .sum-main, .sum-next) {
  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"] .bar { border: 2px solid var(--ink); }
:root[data-style="retro"] :is(.lane, .sum-main, .sum-next) { border-color: var(--accent); }
:root[data-style="retro"] .bar { border: 1px solid var(--accent); }
:root[data-style="forest"] .views { --muted: #c9d8bf; }
:root[data-style="forest"] .view-btn:not([aria-pressed="true"]):hover { color: #f6f2e7; }
:root[data-style="forest"] .road-foot { --muted: #c9d8bf; }
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* 国旗マスター（息ぬきゲーム）の枠 */
.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); }
:root[data-style="forest"] :is(.promo-label, .sub-title, .empty) { --muted: #c9d8bf; }
@media print { .promo { display: none !important; } }

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

/* このサイトについて・利用規約・著作権・プライバシー（ホームのページ）へのリンク */
.policy-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.policy-links a { color: inherit; }
/* 明るい赤ペン色の見た目では NEW の文字を濃くする（白だと読めない） */
:root:is([data-style="chalk"], [data-style="night"], [data-style="retro"]) .new { color: #1b1b1b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-style]) .new { color: #1b1b1b; } }
:root[data-theme="dark"]:not([data-style]) .new { color: #1b1b1b; }
