/* =====================================================
   化学のおべんきょう 共通スタイル
   ===================================================== */
:root {
  --bg: #fff8fb;
  --paper: #ffffff;
  --ink: #3b3355;
  --sub: #7a7196;
  --line: #efe4f2;
  --accent: #ff7eb6;
  --accent2: #7ec8e3;
  --ok: #34c38f;
  --ng: #ff6b81;
  --star: #ffc93c;
  --radius: 20px;
  --shadow: 0 6px 20px rgba(140, 100, 170, 0.12);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffe3f1 0, transparent 40%),
    radial-gradient(circle at 90% 30%, #e0f4ff 0, transparent 40%),
    var(--bg);
  line-height: 1.85;
  font-size: 17px;
}
img { max-width: 100%; }
a { color: inherit; }
sub, sup { font-size: 0.7em; line-height: 0; }
.f { font-family: "Times New Roman", serif; font-size: 1.08em; white-space: nowrap; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

/* ---------- ヘッダー ---------- */
.site-head {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 10px; height: 56px; }
.logo { font-weight: 900; text-decoration: none; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.logo .flask { font-size: 22px; }
.site-head nav { margin-left: auto; display: flex; gap: 8px; }
.site-head nav a {
  text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px;
  background: #fff0f7; color: var(--accent); font-weight: 700;
}

/* ---------- 見出し・セクション ---------- */
h1, h2, h3 { line-height: 1.4; }
.chapter-hero {
  display: flex; align-items: center; gap: 20px;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin: 24px 0;
  border-top: 8px solid var(--c, var(--accent));
}
.chapter-hero .teacher { width: 130px; flex-shrink: 0; }
.chapter-hero .no { font-size: 14px; color: var(--sub); font-weight: 700; }
.chapter-hero h1 { margin: 2px 0 6px; font-size: 28px; }
.chapter-hero p { margin: 0; color: var(--sub); }

.section {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; margin: 24px 0;
}
.section > h2 {
  margin: 0 0 16px; font-size: 22px;
  display: flex; align-items: center; gap: 10px;
}
.section > h2 .num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 16px; flex-shrink: 0;
}

.point {
  background: #fff6d6; border-left: 6px solid var(--star); border-radius: 12px;
  padding: 12px 16px; margin: 16px 0;
}
.point::before { content: "💡 ポイント"; display: block; font-weight: 900; font-size: 14px; color: #b7791f; }

/* ---------- 会話 ---------- */
.talk { display: flex; align-items: flex-start; gap: 12px; margin: 14px 0; }
.talk.right { flex-direction: row-reverse; }
.talk .avatar {
  width: 72px; height: 72px; flex-shrink: 0;
  background: #fff; border-radius: 50%; border: 3px solid var(--c);
}
/* 全身イラストの顔だけを丸く切り抜く（--fy = 顔の高さ、--ar = 画像の縦÷横） */
.icon-crop { position: relative; overflow: hidden; display: block; }
.icon-crop img {
  position: absolute; width: 300%; max-width: none;
  left: -100%; top: calc(50% - var(--fy) * 300% * var(--ar, 1));
}
.icon-crop img.is-placeholder { width: 100%; left: 0; top: 0; }
.talk .bubble {
  position: relative; background: #fff; border: 2px solid var(--c);
  border-radius: 18px; padding: 10px 16px; max-width: calc(100% - 90px);
}
.talk .bubble .who { display: block; font-size: 13px; font-weight: 900; }
.talk.left .bubble::before, .talk.right .bubble::before {
  content: ""; position: absolute; top: 22px; width: 12px; height: 12px;
  background: #fff; border: 2px solid var(--c); transform: rotate(45deg);
}
.talk.left .bubble::before { left: -8px; border-right: none; border-top: none; }
.talk.right .bubble::before { right: -8px; border-left: none; border-bottom: none; }

/* ---------- ボタン ---------- */
.btn {
  appearance: none; border: none; cursor: pointer; font-family: inherit; font-weight: 900;
  font-size: 16px; padding: 10px 22px; border-radius: 999px;
  background: var(--accent); color: #fff; box-shadow: 0 4px 0 #e05d97;
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #e05d97; }
.btn.sub { background: #fff; color: var(--accent); border: 2px solid var(--accent); box-shadow: 0 4px 0 #ffd0e5; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- クイズ ---------- */
.quiz { border: 3px dashed #ffd0e5; border-radius: var(--radius); padding: 18px; background: #fffafd; }
.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.quiz-head .mascot { width: 110px; height: 110px; object-fit: contain; flex-shrink: 0; }
.quiz-head .say {
  background: #fff; border: 2px solid #ffd0e5; border-radius: 16px; padding: 8px 14px; flex: 1; font-size: 15px;
}
.quiz-meta { display: flex; justify-content: space-between; font-size: 14px; color: var(--sub); font-weight: 700; }
.quiz-bar { height: 10px; background: #f3e8f7; border-radius: 99px; overflow: hidden; margin: 6px 0 14px; }
.quiz-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .3s; }
.quiz-q { font-size: 19px; font-weight: 700; margin: 6px 0 14px; }
.quiz-choices { display: grid; gap: 10px; }
.quiz-choices button {
  text-align: left; font-family: inherit; font-size: 17px; cursor: pointer; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px 16px;
  transition: border-color .15s, background .15s;
}
.quiz-choices button:disabled { color: var(--ink); cursor: default; }
.quiz-choices button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-choices button.correct { border-color: var(--ok); background: #e8fbf3; }
.quiz-choices button.wrong { border-color: var(--ng); background: #fff0f3; }
.quiz-input { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.quiz-input input {
  font-family: inherit; font-size: 18px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--line); min-width: 0; flex: 1 1 160px;
}
.quiz-input input:focus { outline: none; border-color: var(--accent); }
.quiz-input .unit { font-weight: 700; }
.quiz-input .preview { width: 100%; font-size: 14px; color: var(--sub); }
.quiz-fb { margin-top: 14px; border-radius: 14px; padding: 12px 16px; display: none; }
.quiz-fb.show { display: block; }
.quiz-fb.ok { background: #e8fbf3; border: 2px solid var(--ok); }
.quiz-fb.ng { background: #fff0f3; border: 2px solid var(--ng); }
.quiz-fb .title { font-weight: 900; font-size: 18px; }
.quiz-foot { margin-top: 14px; display: flex; justify-content: flex-end; gap: 10px; }
.quiz-result { text-align: center; padding: 10px; }
.quiz-result .score { font-size: 44px; font-weight: 900; color: var(--accent); }
.quiz-result .mascot { width: 120px; height: 120px; object-fit: contain; }
.hint-btn { font-size: 14px; background: none; border: none; color: var(--sub); cursor: pointer; text-decoration: underline; font-family: inherit; }
.hint { font-size: 15px; background: #f5f0ff; border-radius: 10px; padding: 8px 12px; margin-top: 8px; }

/* ---------- フッター ---------- */
.page-nav { display: flex; justify-content: space-between; gap: 10px; margin: 30px 0; }
.page-nav a { text-decoration: none; }
footer { text-align: center; color: var(--sub); font-size: 13px; padding: 30px 0 40px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .chapter-hero { flex-direction: column; text-align: center; }
  .chapter-hero .teacher { width: 110px; }
  .section { padding: 18px 14px; }
  .talk .avatar { width: 56px; height: 56px; }
  .talk .bubble { max-width: calc(100% - 70px); }
  .site-head nav a { padding: 4px 10px; font-size: 13px; }
}

/* ---------- バディ（ツールの横の生徒役） ---------- */
.buddy { display: flex; align-items: flex-end; gap: 10px; margin-top: 12px; }
.buddy .buddy-img { width: 96px; height: 96px; object-fit: contain; flex-shrink: 0; }
.buddy .buddy-say {
  position: relative; flex: 1; background: #fff; border: 2px solid var(--c); border-radius: 16px;
  padding: 8px 14px; font-size: 15px; margin-bottom: 16px; min-height: 2.4em;
}
.buddy .buddy-say::before {
  content: ""; position: absolute; left: -8px; bottom: 14px; width: 12px; height: 12px;
  background: #fff; border-left: 2px solid var(--c); border-bottom: 2px solid var(--c); transform: rotate(45deg);
}
.buddy .buddy-say .who { display: block; font-size: 12px; font-weight: 900; color: var(--c); }

/* ---------- 今日のまとめ ---------- */
.summary {
  display: grid; grid-template-columns: 130px 1fr 120px; align-items: end; gap: 12px;
  background: linear-gradient(180deg, #fff, #fff8fc); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 3px solid var(--c); padding: 18px; margin: 24px 0;
}
.summary .summary-t { width: 130px; height: auto; }
.summary .summary-m { width: 120px; height: 120px; object-fit: contain; }
.summary .summary-title { font-size: 20px; font-weight: 900; margin-bottom: 6px; }
.summary ul { margin: 0; padding-left: 1.2em; line-height: 1.9; }
.summary-body { align-self: center; }
@media (max-width: 600px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .summary .summary-body { grid-column: 1 / -1; grid-row: 1; }
  .summary .summary-t { width: 110px; justify-self: center; }
  .summary .summary-m { width: 110px; height: 110px; justify-self: center; }
  .buddy .buddy-img { width: 80px; height: 80px; }
}
