/* =========================================================
   単元の教材（本質・例題）
   ========================================================= */
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.unit-nav { position: sticky; top: var(--top-h); z-index: 20; background: var(--bg); padding: 8px 0; margin: 0 0 8px; }
.essence { font-size: 1rem; line-height: 1.9; }
.key-points { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: kp; display: grid; gap: 8px; }
.key-points li { counter-increment: kp; background: var(--primary-soft); border-radius: 12px; padding: 10px 12px 10px 44px; position: relative; font-weight: 700; }
.key-points li::before { content: counter(kp); position: absolute; left: 12px; top: 9px; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: .8rem; }
.example { border: 2px dashed var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.ex-title { font-weight: 800; color: var(--primary-dark); }
.ex-q { font-weight: 700; margin: 4px 0 8px; }
.example summary { cursor: pointer; font-weight: 700; color: #d97706; padding: 6px 0; min-height: 36px; }
.ex-steps { margin: 6px 0; padding-left: 22px; }
.ex-answer { background: #ecfdf5; border-radius: 10px; padding: 8px 12px; }
.drill-start { background: linear-gradient(135deg, #fff7ed, #fef3c7); border: 2px solid #fcd34d; }
.stars-mini span, .stars-big span { color: #e5e7eb; }
.stars-mini span.on, .stars-big span.on { color: #f59e0b; text-shadow: 0 1px 0 #b45309; }
.stars-mini { font-size: 1.6rem; letter-spacing: 2px; }

/* =========================================================
   4コマ漫画
   ========================================================= */
.comic { margin: 0 auto; max-width: 560px; }
.comic-title { font-weight: 900; font-size: 1.05rem; text-align: center; margin-bottom: 8px; letter-spacing: .05em; }
.comic-strip { display: grid; gap: 10px; background: #fff; border: 3px solid #111; padding: 10px; border-radius: 4px; }
.koma {
  position: relative; min-height: 250px; border: 3px solid #111; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 36px 8px 4px;
  background: #fff;
}
.koma::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(0,0,0,.09) 1px, transparent 1.2px); background-size: 6px 6px; pointer-events: none; }
.koma.fx-burst::after { content: ""; position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg at 50% 60%, rgba(0,0,0,.08) 0deg 2deg, transparent 2deg 9deg); pointer-events: none; }
.koma.fx-gloom::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(30,41,59,.12) 0 2px, transparent 2px 10px); pointer-events: none; }
.koma-no { position: absolute; top: 4px; right: 6px; font-weight: 900; font-size: .9rem; z-index: 3; }
.koma-prop { position: absolute; right: 10px; bottom: 6px; font-size: 3.2rem; opacity: .35; z-index: 0; }
.koma-img { width: 100%; height: auto; display: block; }
.narration {
  position: absolute; top: 6px; left: 6px; z-index: 3; max-width: 72%;
  background: #fffbe6; border: 2px solid #111; padding: 2px 8px; font-size: .78rem; font-weight: 700; color: #111;
}
.sfx {
  position: absolute; top: 34px; right: 14px; z-index: 3; transform: rotate(-10deg);
  font-weight: 900; font-size: 1.35rem; color: #fff; -webkit-text-stroke: 1.5px #111; paint-order: stroke fill;
  text-shadow: 2px 2px 0 #111; letter-spacing: .05em;
}
.actors { position: relative; z-index: 2; display: flex; align-items: flex-end; justify-content: space-around; gap: 6px; }
.actor { position: relative; display: flex; flex-direction: column; align-items: center; flex: 1 1 0; min-width: 0; max-width: 260px; }
.actors.n1 .actor { flex-direction: row; align-items: flex-end; max-width: 100%; gap: 8px; padding-left: 4%; }
.actors.n1 .actor .bubble { order: 2; align-self: flex-start; margin-bottom: 0; }
.actors.n1 .actor .chara { order: 1; }
.chara { width: 84px; height: 105px; flex: none; filter: drop-shadow(2px 2px 0 rgba(0,0,0,.12)); }
.actor-name { font-size: .65rem; font-weight: 800; background: #111; color: #fff; padding: 0 6px; border-radius: 4px; margin-top: -2px; white-space: nowrap; }
.actors.n1 .actor-name { position: absolute; bottom: 2px; left: calc(4% + 4px); z-index: 3; }
.bubble {
  position: relative; background: #fff; border: 2.5px solid #111; border-radius: 18px; color: #111;
  padding: 7px 10px; font-size: .82rem; line-height: 1.4; font-weight: 700; margin-bottom: 12px;
  max-width: 100%; word-break: break-word;
}
.bubble::after {
  content: ""; position: absolute; bottom: -11px; left: 50%; transform: translateX(-50%);
  border: 9px solid transparent; border-top-color: #111; border-bottom: 0;
}
.actors.n1 .bubble::after { left: -11px; bottom: auto; top: 14px; transform: none; border: 9px solid transparent; border-right-color: #111; border-left: 0; }
.bubble.mood-surprised, .bubble.mood-excited { border-radius: 6px; border-width: 3px; box-shadow: 3px 3px 0 #111; }
.bubble.mood-think { border-style: dashed; }
.comic-lesson { margin-top: 10px; background: #111; color: #fde68a; font-weight: 800; padding: 10px 14px; border-radius: 6px; text-align: center; }
.scene-classroom { background: linear-gradient(#e8f5e9 0 55%, #d7ccc8 55%); }
.scene-home { background: linear-gradient(#fff7ed 0 65%, #e7d3c0 65%); }
.scene-kitchen { background: linear-gradient(#fefce8 0 60%, #e5e7eb 60%); }
.scene-train { background: linear-gradient(#dbeafe 0 22%, #bfdbfe 22% 48%, #e2e8f0 48% 70%, #94a3b8 70%); }
.scene-street { background: linear-gradient(#e0f2fe 0 60%, #9ca3af 60%); }
.scene-shop { background: linear-gradient(#fef9c3 0 62%, #fde68a 62%); }
.scene-park { background: linear-gradient(#e0f2fe 0 58%, #bbf7d0 58%); }
.scene-lab { background: linear-gradient(#f0fdfa 0 62%, #cbd5e1 62%); }
.scene-office { background: linear-gradient(#f1f5f9 0 62%, #cbd5e1 62%); }
.scene-hospital { background: linear-gradient(#f0fdf4 0 62%, #ccfbf1 62%); }
.scene-nature { background: linear-gradient(#e0f2fe 0 50%, #a7f3d0 50%); }
.scene-sea { background: linear-gradient(#e0f2fe 0 45%, #7dd3fc 45%); }
.scene-space { background: radial-gradient(circle at 20% 30%, #fff 1px, transparent 2px) 0 0/40px 40px, linear-gradient(#1e1b4b, #312e81); }
.scene-stage { background: linear-gradient(90deg, #b91c1c 0 10%, #fef3c7 10% 90%, #b91c1c 90%); }
.scene-gym { background: linear-gradient(#fef3c7 0 60%, #fcd34d 60%); }
.scene-library { background: repeating-linear-gradient(90deg, #fde68a 0 16px, #fca5a5 16px 28px, #a5b4fc 28px 44px, #f5f5f4 44px 48px) top/100% 55% no-repeat, #f5f5f4; }
.scene-town { background: linear-gradient(#e0f2fe 0 55%, #d1d5db 55%); }
.scene-factory { background: linear-gradient(#e5e7eb 0 62%, #9ca3af 62%); }
.scene-farm { background: linear-gradient(#e0f2fe 0 50%, #fde68a 50% 60%, #86efac 60%); }
.scene-night { background: linear-gradient(#1e293b 0 60%, #334155 60%); }
.scene-worksite { background: linear-gradient(#fef3c7 0 60%, #d6d3d1 60%); }
.scene-space .koma-no, .scene-night .koma-no { color: #fff; }
.scene-space .actor-name, .scene-night .actor-name { background: #fde68a; color: #111; }
@media (min-width: 600px) { .chara { width: 96px; height: 120px; } .bubble { font-size: .88rem; } .koma { min-height: 270px; } }

/* =========================================================
   ドリル（ゲーム）
   ========================================================= */
.drill { position: relative; max-width: 680px; margin: 0 auto; }
.drill-hud { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; position: sticky; top: calc(var(--top-h) + 4px); z-index: 15; }
.drill-mode { font-size: .75rem; font-weight: 800; color: var(--muted); }
.drill-title { font-weight: 800; }
.drill-score { font-size: 1.5rem; font-weight: 900; color: var(--primary-dark); line-height: 1.1; }
.drill-combo { font-weight: 900; color: #ea580c; min-height: 1.2em; }
.drill-combo.bump { animation: mq-bump .4s ease; }
.drill-timer { height: 5px; background: var(--surface-2); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.drill-timer span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #34d399, #10b981); border-radius: 999px; }
.drill-timer span.low { background: linear-gradient(90deg, #fb923c, #ef4444); }
.drill-card { background: var(--surface); border-radius: 20px; box-shadow: 0 6px 24px rgba(31,41,55,.08); padding: 18px; }
.drill-unit { font-size: .78rem; color: var(--muted); font-weight: 700; }
.drill-q { font-size: 1.15rem; font-weight: 800; margin: 6px 0 14px; line-height: 1.6; }
.drill-choices { display: grid; gap: 10px; }
@media (min-width: 600px) { .drill-choices { grid-template-columns: 1fr 1fr; } }
.drill-choice {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: left;
  border: 2px solid var(--border); border-radius: 14px; background: #fff; font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer; color: var(--text);
  transition: transform .1s, border-color .15s;
}
.drill-choice:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-1px); }
.drill-choice:active:not(:disabled) { transform: scale(.98); }
.drill-choice .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; flex: none; font-weight: 900; }
.drill-choice.is-correct { border-color: var(--success); background: #ecfdf5; }
.drill-choice.is-wrong { border-color: var(--danger); background: #fef2f2; }
.drill-choice:disabled { cursor: default; }
.drill-tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drill-tf .drill-choice { flex-direction: column; justify-content: center; font-size: 2.4rem; min-height: 110px; text-align: center; }
.drill-tf small { font-size: .8rem; }
.drill-input { display: flex; gap: 8px; align-items: center; }
.drill-input input { flex: 1; font-size: 1.2rem; text-align: center; font-weight: 800; }
.drill-input .suffix { font-weight: 800; }
.drill-feedback { margin-top: 14px; border-radius: 14px; padding: 12px 14px; animation: mq-pop .3s ease; }
.drill-feedback.ok { background: #ecfdf5; border: 2px solid #6ee7b7; }
.drill-feedback.ng { background: #fef2f2; border: 2px solid #fca5a5; }
.fb-title { font-size: 1.2rem; font-weight: 900; }
.fb-answer { margin-top: 4px; }
.fb-explain { margin-top: 6px; font-size: .92rem; }
.score-pop { position: absolute; left: 50%; top: 120px; transform: translateX(-50%); font-size: 2rem; font-weight: 900; color: #f59e0b; text-shadow: 0 2px 0 #fff, 0 0 12px rgba(245,158,11,.5); pointer-events: none; animation: mq-floatup .9s ease forwards; z-index: 30; }
.drill.shake .drill-card { animation: mq-shake .35s; }
.pop-in { animation: mq-pop .25s ease; }
.boss-area { text-align: center; background: linear-gradient(180deg, #312e81, #4c1d95); color: #fff; border-radius: 20px; padding: 14px; margin-bottom: 12px; }
.boss { font-size: 4.2rem; line-height: 1.1; display: inline-block; animation: mq-float 2.4s ease-in-out infinite; }
.boss.hit { animation: mq-hit .45s ease; }
.boss-name { font-weight: 900; letter-spacing: .1em; }
.boss-hp { background: rgba(255,255,255,.2); margin: 6px auto 2px; max-width: 320px; }
.boss-hp > span { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.result-card { text-align: center; }
.result-big { font-size: 1.6rem; font-weight: 900; margin: 8px 0; }
.stars-big { font-size: 3rem; letter-spacing: 6px; }
.stars-big span.on { animation: mq-pop .5s ease both; }
.stars-big span.on:nth-child(2) { animation-delay: .15s; }
.stars-big span.on:nth-child(3) { animation-delay: .3s; }
.review-list { padding-left: 20px; text-align: left; }
.review-list li { margin-bottom: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.review-list li.ng { background: #fff1f2; }
@keyframes mq-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes mq-bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes mq-floatup { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -60px); } }
@keyframes mq-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes mq-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes mq-hit { 0% { transform: scale(1); filter: none; } 30% { transform: scale(.85) rotate(-8deg); filter: brightness(2); } 100% { transform: scale(1); filter: none; } }
@media (prefers-reduced-motion: reduce) { .boss, .score-pop, .drill.shake .drill-card, .pop-in, .drill-feedback, .stars-big span.on { animation: none !important; } }

/* =========================================================
   イラスト差し替え（public/illust の画像）
   ========================================================= */
.illust-icon { width: 1.25em; height: 1.25em; object-fit: contain; vertical-align: -0.28em; display: inline-block; }
.career-card .ico .illust-icon, .avatar-xl .illust-icon, .badge-item .ico .illust-icon, .tile .ico .illust-icon { width: 1.1em; height: 1.1em; vertical-align: middle; }
.boss .illust-icon { width: 1.6em; height: 1.6em; }
.guide-img { display: block; object-fit: contain; }
.guide-result { width: 160px; height: 160px; margin: 0 auto 4px; }
.reward .big .guide-img { width: 140px; height: 140px; margin: 0 auto; }
.guide-hello { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 8px; }
.guide-hello .guide-img { width: 88px; height: 88px; flex: none; }
.guide-hello .bubble { margin-bottom: 30px; }
.fb-guide { width: 84px; height: 84px; object-fit: contain; float: right; margin: -6px 0 4px 8px; }
.lesson-guide { width: 44px; height: 44px; object-fit: contain; display: inline-block; vertical-align: middle; }

/* 漫画: 背景画像・1コマまるごとの絵・キャラ画像 */
.koma-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
.koma.has-img::before, .koma.has-img::after, .koma.has-scene::before { display: none; }
.koma.has-img { justify-content: flex-start; padding-top: 34px; }
.img-bubbles { position: relative; z-index: 2; display: flex; gap: 8px; align-items: flex-start; }
.img-bubbles .bubble { flex: 1 1 0; margin-bottom: 0; font-size: .8rem; }
.img-bubbles .bubble::after { display: none; }
.img-bubbles .bubble .who { display: block; font-size: .66rem; color: #4f46e5; }
.chara-img { object-fit: contain; object-position: bottom; }
.chara-wrap { position: relative; display: inline-block; }
.pro-badge { position: absolute; right: 2px; bottom: 18px; font-size: 1rem; background: #fff; border: 2px solid #111; border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }

/* =========================================================
   ドリルの「もどる」
   ========================================================= */
.drill-topnav { margin-bottom: 8px; }
.drill-back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 14px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: .9rem; color: var(--text); text-decoration: none; }
.drill-back:hover { text-decoration: none; background: var(--surface-2); }

/* =========================================================
   つながる職業（すべて）
   ========================================================= */
.more-careers summary { cursor: pointer; font-weight: 700; color: var(--primary-dark); padding: 8px 0; min-height: 40px; }
.more-group { margin: 6px 0 10px; }
.more-label { font-size: .78rem; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.career-chip { text-decoration: none; color: var(--text); min-height: 32px; }
.career-chip:hover { text-decoration: none; filter: brightness(.96); }
.more-note { margin: 10px 0 0; font-size: .82rem; background: #f0f9ff; border-radius: 10px; padding: 8px 12px; color: #075985; }

/* =========================================================
   手書きパッド（例題）
   ========================================================= */
.hw { margin: 4px 0 8px; }
.hw > summary { cursor: pointer; font-weight: 700; color: var(--primary-dark); padding: 6px 0; min-height: 36px; }
.hw-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.hw-tools .btn.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }
.hw-grid-sel { font-size: .8rem; display: inline-flex; gap: 4px; align-items: center; margin-left: auto; }
.hw-grid-sel select { min-height: 34px; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.hw-pad { position: relative; height: 240px; border: 2px solid var(--border); border-radius: 12px; background-color: #fffef7; overflow: hidden; }
.hw-pad.is-writing { height: 300px; }
.hw-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hw-pad[data-grid="masu"] {
  background-image:
    linear-gradient(#cbd5e1 1px, transparent 1px), linear-gradient(90deg, #cbd5e1 1px, transparent 1px),
    linear-gradient(#eef2f7 1px, transparent 1px), linear-gradient(90deg, #eef2f7 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 80px 80px, 80px 80px;
  background-position: -1px -1px, -1px -1px, -1px 39px, 39px -1px;
}
.hw-pad[data-grid="lines"] {
  background-image: linear-gradient(to bottom, transparent 16px, #94a3b8 16px 17px, transparent 17px 36px, #dbe3ec 36px 37px, transparent 37px 56px, #f87171 56px 57px, transparent 57px 76px, #94a3b8 76px 77px, transparent 77px);
  background-size: 100% 96px;
}
.hw-pad[data-grid="grid"] {
  background-image: linear-gradient(#e2e8f0 1px, transparent 1px), linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
  background-size: 24px 24px;
}
@media (min-width: 768px) { .hw-pad { height: 280px; } .hw-pad.is-writing { height: 340px; } }

/* =========================================================
   管理: イラスト差し替え
   ========================================================= */
.illust-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.illust-kind { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); color: var(--text); text-decoration: none; font-size: .82rem; font-weight: 700; }
.illust-kind:hover { text-decoration: none; }
.illust-kind.active { outline: 3px solid var(--primary); }
.illust-kind small { color: var(--muted); font-weight: 600; }
.illust-list { display: grid; gap: 12px; margin-top: 8px; }
.illust-slot { display: flex; gap: 14px; align-items: flex-start; margin: 0; }
.illust-slot.is-done { border-left: 5px solid #10b981; }
.illust-preview { width: 120px; height: 120px; flex: none; border-radius: 12px; background: repeating-conic-gradient(#f1f5f9 0 25%, #fff 0 50%) 0 0/16px 16px; display: grid; place-items: center; overflow: hidden; }
.illust-preview.wide { width: 160px; height: 107px; }
.illust-preview img { width: 100%; height: 100%; object-fit: contain; }
.illust-preview .ph { font-size: 2.6rem; opacity: .6; }
.illust-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.illust-prompt { width: 100%; font-size: .78rem; line-height: 1.5; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: #f8fafc; resize: vertical; }
@media (max-width: 599px) { .illust-slot { flex-direction: column; } .illust-preview, .illust-preview.wide { width: 100%; height: 160px; } }

/* まとめてアップロード */
.bulk-upload summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.bulk-upload .muted { font-size: .82rem; }
.dropzone { margin-top: 8px; border: 3px dashed var(--border); border-radius: 14px; padding: 18px 12px; text-align: center; color: var(--muted); font-weight: 700; background: #f8fafc; }
.dropzone.is-over, .illust-slot.is-over { border-color: var(--primary); background: #eef2ff; outline: 3px dashed var(--primary); }
.bulk-table-wrap { max-height: 420px; overflow: auto; margin-top: 8px; }
.bulk-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.bulk-table td { border-top: 1px solid var(--border); padding: 4px 6px; vertical-align: middle; }
.bulk-table img { width: 56px; height: 56px; object-fit: contain; background: #f1f5f9; border-radius: 8px; }
.bulk-table .name { word-break: break-all; max-width: 220px; }
.bulk-table input { width: 100%; min-width: 160px; }
.bulk-table small { display: block; color: var(--muted); }
.bulk-table tr.ok { background: #ecfdf5; }
.bulk-table tr.ng { background: #fef2f2; }
.bulk-table .st { white-space: nowrap; }
@media (max-width: 599px) { .bulk-table .name { display: none; } }

/* なぞり書きのお手本 */
.hw-pad canvas.hw-guide { pointer-events: none; cursor: default; }
.hw-guide-sel { font-size: .8rem; display: inline-flex; gap: 4px; align-items: center; font-weight: 700; }
.hw-guide-text { flex: 1 1 160px; min-width: 120px; font-size: .9rem; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; }

/* 読み上げ */
.speak-btn { padding: 2px 10px; font-size: .78rem; min-height: 30px; vertical-align: middle; }
.speak-btn.is-playing { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.comic-title .speak-btn { margin-left: 6px; }
.drill-unit .speak-btn { margin-left: 8px; }
#essence .row.between h2 { margin-bottom: 0; }
