:root { color: #1b2434; background: #f7f9fd; font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif; line-height: 1.6; }
* { box-sizing: border-box; }
body { margin: 0; }
.lab { max-width: 1180px; margin: 0 auto; padding: 22px 20px 28px; }
header { margin-bottom: 16px; }
.eyebrow { margin: 0; color: #b3405a; font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 4px 0 6px; font-size: 25px; }
header > p:last-child { margin: 0; color: #56627a; }
button { min-height: 44px; padding: 9px 14px; border: 1px solid #c3cddd; border-radius: 10px; background: #fff; color: #1b2434; font: inherit; font-weight: 650; cursor: pointer; }
button:hover { border-color: #b3405a; }
button.primary, button.active { border-color: #b3405a; background: #b3405a; color: #fff; }
button:disabled { cursor: default; opacity: .85; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tabs button { flex: 0 1 auto; }

/* --- 血液の色分け。動脈血=鮮やかな赤、静脈血=暗い赤紫 --- */
.blood-arterial { --blood: #d0324b; --blood-soft: #fdeaee; }
.blood-venous { --blood: #5b5f9c; --blood-soft: #ebecf7; }
.blood-exchange { --blood: #2f8a63; --blood-soft: #e7f5ee; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.figure-side { display: grid; gap: 12px; }
.info-side { display: grid; gap: 12px; align-content: start; }

/* --- 心臓の3Dモデル --- */
.heart-split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.heart-scene { position: relative; height: 460px; min-height: 460px; overflow: hidden; border: 1px solid #d6dded; border-radius: 14px; background: #f2f5fb; touch-action: none; }
.heart-scene canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.heart-scene canvas:active { cursor: grabbing; }
.scene-message { position: absolute; inset: 0; display: grid; margin: 0; padding: 20px; place-content: center; color: #56627a; font-size: 14px; text-align: center; }
.scene-hint { margin: 0; color: #56627a; font-size: 12px; text-align: center; }
.phase-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rate-field { display: grid; gap: 5px; font-size: 14px; font-weight: 650; }
.rate-field output { color: #b3405a; font-weight: 800; }
.flow-legend { display: flex; flex-wrap: wrap; gap: 13px; justify-content: center; }
.valve-legend { --blood: #e7b64a; }
.caption { margin: 0; color: #56627a; font-size: 13px; text-align: center; }

.detail-card { padding: 15px; border-radius: 13px; background: #fdeaee; }
.detail-head { display: flex; align-items: baseline; gap: 9px; }
.detail-head b { font-size: 21px; }
.detail-head small { color: #56627a; }
.role { margin: 7px 0 10px; font-weight: 650; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid #ecc9d2; }
dl div:last-child { border-bottom: 0; }
dt { color: #56627a; }
dd { margin: 0; font-weight: 650; }

.hint { padding: 13px 15px; border-left: 4px solid #b3405a; border-radius: 0 10px 10px 0; background: #f1f4fa; }
.hint b { display: block; margin-bottom: 4px; color: #b3405a; }
.hint p { margin: 0; font-size: 14px; }
.note { margin: 6px 0 0; color: #56627a; font-size: 13px; }

/* --- 血液循環 --- */
.circulation { display: grid; gap: 16px; }
.loop-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend { display: flex; align-items: center; gap: 6px; color: #56627a; font-size: 13px; }
.legend::before { width: 14px; height: 14px; border-radius: 50%; background: var(--blood); content: ""; }
.flow-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin: 0; padding: 0; list-style: none; }
.flow-node { position: relative; display: grid; min-height: 84px; padding: 10px 8px; place-content: center; border: 2px solid #d6dded; border-radius: 12px; background: #fff; text-align: center; cursor: pointer; transition: all .2s ease; }
.flow-node b { display: block; font-size: 15px; }
.flow-node small { display: block; margin-top: 3px; color: #7a869c; font-size: 11px; }
.flow-index { position: absolute; top: 5px; left: 8px; color: #9aa5ba; font-size: 11px; font-weight: 700; }
.flow-node.done { border-color: var(--blood); background: var(--blood-soft); }
.flow-node.current { border-color: var(--blood); background: var(--blood); color: #fff; transform: translateY(-3px); box-shadow: 0 8px 18px rgba(27,36,52,.18); }
.flow-node.current small, .flow-node.current .flow-index { color: rgba(255,255,255,.82); }
.step-controls { display: flex; gap: 9px; justify-content: center; }
.step-explain { padding: 14px 16px; border-radius: 12px; background: #f1f4fa; }
.step-explain b { display: block; margin-bottom: 4px; color: #b3405a; }
.step-explain p { margin: 0; }

/* --- 血管 --- */
.vessels { display: grid; gap: 16px; }
.vessel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 13px; }
.vessel-card { padding: 14px; border: 2px solid var(--blood); border-radius: 12px; background: var(--blood-soft); }
.vessel-card.exception { box-shadow: 0 0 0 3px #e7b64a; }
.vessel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.vessel-head b { font-size: 19px; }
.badge { padding: 3px 9px; border-radius: 999px; background: #e7b64a; color: #3a2e08; font-size: 11px; font-weight: 800; }
.result { padding: 14px; border-left: 5px solid #8090aa; border-radius: 8px; background: #edf1f8; }
.result.correct { border-color: #138a62; background: #e6f7ef; }
.result.incorrect { border-color: #c64141; background: #fff0f0; }

/* --- 血液の成分 --- */
.blood-lab { display: grid; gap: 16px; }
.blood-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 13px; }
.blood-card { display: flex; gap: 13px; padding: 14px; border: 1px solid #d6dded; border-radius: 12px; background: #fff; }
.blood-card b { font-size: 17px; }
.blood-card .work { margin: 5px 0 0; font-weight: 650; color: #b3405a; }
.tag { margin-left: 7px; padding: 2px 8px; border-radius: 999px; background: #eef2f8; color: #56627a; font-size: 11px; font-weight: 650; }
.blood-icon { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; }
.blood-icon.red { background: radial-gradient(circle at center, #f4dbe0 28%, #d0324b 30%); }
.blood-icon.white { background: #eef1f8; border: 3px dotted #8b93a8; }
.blood-icon.platelet { width: 34px; height: 24px; margin-top: 9px; border-radius: 40% 60% 55% 45%; background: #e7b64a; }
.blood-icon.plasma { background: #f6edcd; border: 2px solid #d9c377; }
.hemoglobin { padding: 16px; border-radius: 13px; background: #fdeaee; }
.hemoglobin > b { display: block; margin-bottom: 5px; color: #b3405a; }
.hemoglobin p { margin: 0 0 10px; font-size: 14px; }
.hemoglobin label { display: grid; gap: 6px; margin-bottom: 13px; font-weight: 650; }
.hemoglobin output { color: #b3405a; font-weight: 800; }
input[type="range"] { width: 100%; height: 30px; accent-color: #b3405a; }
.hemo-state { display: flex; gap: 13px; align-items: center; padding: 13px; border-radius: 11px; background: #fff; }
.hemo-state b { display: block; }
.hemo-state p { margin: 3px 0 0; color: #56627a; font-size: 13px; }
.hemo-icon { display: grid; width: 52px; height: 52px; flex: 0 0 auto; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 800; }
.hemo-state.bound .hemo-icon { background: #d0324b; color: #fff; }
.hemo-state.released .hemo-icon { background: #5b5f9c; color: #fff; }

/* --- 器官 --- */
.organs { display: grid; gap: 16px; }
.organ-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.organ-tab { display: grid; gap: 2px; min-height: 62px; }
.organ-tab small { color: #7a869c; font-size: 11px; font-weight: 600; }
.organ-tab.primary small { color: rgba(255,255,255,.85); }
.organ-detail { padding: 16px; border-radius: 13px; background: #e7f5ee; }
.organ-detail > b { display: block; color: #1f7a55; }
.change { margin: 7px 0 0; font-size: 18px; font-weight: 750; }

/* --- 心拍出量 --- */
.beat { display: grid; gap: 16px; }
.beat-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.beat-controls label { display: grid; gap: 6px; font-weight: 650; }
.beat-controls output { color: #b3405a; font-weight: 800; }
.beat-heart { width: 74px; height: 74px; margin: 0 auto; background: #d0324b; clip-path: path("M37 68 C 8 46, 0 28, 0 20 A 20 20 0 0 1 37 12 A 20 20 0 0 1 74 20 C 74 28, 66 46, 37 68 Z"); animation: pulse var(--beat, .86s) ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 18% { transform: scale(1.16); } 36% { transform: scale(.98); } }
.beat-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 13px; }
.beat-card { display: grid; gap: 3px; padding: 15px; border-radius: 12px; background: #fdeaee; }
.beat-card small { color: #56627a; font-size: 12px; }
.beat-card b { font-size: 27px; color: #b3405a; }
.beat-card .note { margin: 2px 0 0; font-size: 12px; }

/* --- クイズ --- */
.quiz { display: grid; gap: 15px; }
.level { margin: 0; color: #b3405a; font-weight: 700; }
.question { margin: 0; font-size: 19px; font-weight: 700; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.choice { min-height: 58px; font-size: 15px; }
.choice.correct { border-color: #138a62; background: #e6f7ef; }
.choice.incorrect { border-color: #c64141; background: #fff0f0; }
.result b { display: block; margin-bottom: 3px; }
.result p { margin: 0; font-size: 14px; }

@media (max-width: 900px) {
  .split, .heart-split { grid-template-columns: 1fr; }
  .heart-scene { height: 400px; min-height: 400px; }
  .flow-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .lab { padding: 17px 13px; }
  .heart-scene { height: 340px; min-height: 340px; }
  .tabs button { flex: 1 1 44%; }
  .flow-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blood-card { flex-direction: column; }
  .step-controls { flex-wrap: wrap; }
  .step-controls button { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .beat-heart { animation: none; }
  .flow-node, .chamber-shape { transition: none; }
}

@media (prefers-color-scheme: dark) {
  :root { color: #edf2ff; background: #101522; }
  header > p:last-child, .note, dt, .caption, .flow-node small, .legend, .blood-card .tag, .beat-card small, .hemo-state p, .organ-tab small, .scene-hint, .scene-message { color: #b4bfd4; }
  button { color: #edf2ff; background: #1a2232; border-color: #46536b; }
  .detail-card, .hemoglobin, .beat-card { background: #2a1a24; }
  .hint, .step-explain, .result { background: #1a2232; }
  .organ-detail { background: #14281f; }
  .flow-node, .blood-card, .hemo-state { background: #1a2232; border-color: #46536b; }
  .vessel-card { background: #1a2232; }
  .heart-scene { background: #141b2b; border-color: #46536b; }
  dl div { border-color: #46536b; }
  .result.correct { background: #12392f; }
  .result.incorrect { background: #431f25; }
  .choice.correct { background: #12392f; }
  .choice.incorrect { background: #431f25; }
  .blood-icon.white { background: #222a3c; }
}

/* BodyParts3D のライセンス表示（実物モデル表示中は必須） */
.model-credit { margin: 6px 0 0; color: #63708a; font-size: 10.5px; line-height: 1.45; text-align: center; }
.model-credit a { color: #3157b7; }
.phase-controls button:disabled { opacity: .45; cursor: not-allowed; }
