:root {
  --bg: #f4f1ea; --surface: #fffdf8; --ink: #22201c; --muted: #6f6a60; --line: #e2dccf;
  --accent: #1f6f5c; --accent-soft: #dcefe8; --warn: #b4532a; --stage: #fbfaf6;
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171614; --surface: #211f1c; --ink: #eeeae2; --muted: #a39d92; --line: #36332e;
          --accent: #5cc2a5; --accent-soft: #1e3a33; --warn: #e48a5e; --stage: #1c1b18; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.6; }
button { font: inherit; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: .55em 1.2em; cursor: pointer; white-space: nowrap; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .85rem; letter-spacing: .05em; margin: 0 0 .3em; }

/* 開始画面 */
.start { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.start-card { max-width: 640px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 36px; }
.start-card h1 { margin: 0 0 .2em; font-size: 2rem; }
.goal { color: var(--muted); }
.flow { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0; }
.flow li { flex: 1 0 auto; background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; text-align: center; font-size: .85rem; white-space: nowrap; }
.flow span { display: block; color: var(--muted); }
.consent h2 { font-size: 1rem; margin-bottom: .3em; }
.consent ul { padding-left: 1.2em; color: var(--muted); font-size: .9rem; }
.warn { color: var(--warn); font-size: .9rem; }
.start-form .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.agree { display: block; margin-top: 12px; }
.teacher-badge { position: relative; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; flex: none; }
.teacher-badge.big { width: 64px; height: 64px; margin-bottom: 12px; }
.teacher-badge .ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
.teacher-badge[data-state="speaking"] .ring { animation: pulse 1.1s ease-out infinite; }
.teacher-badge[data-state="listening"] { background: var(--muted); }
@keyframes pulse { 0% { opacity: .8; transform: scale(.95); } 100% { opacity: 0; transform: scale(1.25); } }

/* 授業画面 */
.classroom { display: grid; grid-template-columns: 340px 1fr; grid-template-rows: auto 1fr; height: 100vh; }
.classroom.with-debug { grid-template-rows: auto 1fr 300px; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.course { font-weight: 700; }
.phases { display: flex; gap: 4px; list-style: none; margin: 0 auto; padding: 0; font-size: .8rem; }
.phases li { padding: 4px 12px; border-radius: 999px; color: var(--muted); }
.phases li.done { color: var(--accent); }
.phases li.current { background: var(--accent); color: #fff; font-weight: 600; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.timer.low { color: var(--warn); }
.end { border-color: var(--warn); color: var(--warn); }
.stage { grid-column: 2; grid-row: 2; padding: 24px; display: flex; flex-direction: column; min-height: 0; }
.slide { flex: 1; background: var(--stage); border: 1px solid var(--line); border-radius: 16px; padding: 48px 56px; overflow: auto; box-shadow: 0 8px 30px rgb(0 0 0 / .05); }
.slide-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; align-items: center; }
.slide-art { width: 100%; max-height: 52vh; object-fit: contain; background: #fff; border-radius: 14px; padding: 8px; }
@media (max-width: 900px) { .slide-body { grid-template-columns: 1fr; } .slide-art { max-height: 32vh; } }
.slide.enter { animation: enter .35s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.slide h2 { font-size: 2.1rem; margin: 0 0 .6em; }
.slide .lead { font-size: 1.35em; font-weight: 600; color: var(--accent); }
.slide ul { font-size: 1.2em; padding-left: 1.2em; }
.slide li { margin: .45em 0; }
.slide table { border-collapse: collapse; width: 100%; font-size: 1.05em; }
.slide th, .slide td { border-bottom: 1px solid var(--line); padding: .6em .8em; text-align: left; vertical-align: top; }
.slide thead th { color: var(--muted); font-size: .9em; }
.cover { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.cover h1 { font-size: 2.6rem; margin: 0 0 .3em; }
.cover p { color: var(--muted); font-size: 1.1rem; }
.slide-progress { display: flex; align-items: center; gap: 12px; padding-top: 10px; color: var(--muted); font-size: .85rem; }
.slide-progress .bar { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
.slide-progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .4s; }
.teacher-panel { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); background: var(--surface); padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.teacher { display: flex; gap: 12px; align-items: center; }
.teacher-name { font-weight: 700; }
.teacher-status { color: var(--muted); font-size: .85rem; }
.caption { flex: 1; overflow: auto; font-size: .95rem; min-height: 0; }
.caption p { margin: 0 0 .7em; }
.caption p.learner { color: var(--muted); text-align: right; }
.caption p.learner::before { content: "あなた: "; }
.caption .hint { color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.controls button { flex: 1 0 auto; }
.mic[aria-pressed="false"] { color: var(--warn); border-color: var(--warn); }
.phase-label { margin: 0; color: var(--accent); font-size: .85rem; font-weight: 600; }

.debug { grid-column: 1 / -1; border-top: 1px solid var(--line); background: var(--surface); font: 12px/1.5 ui-monospace, monospace; display: flex; flex-direction: column; min-height: 0; }
.debug-head { display: flex; gap: 8px; padding: 6px 12px; align-items: center; border-bottom: 1px solid var(--line); }
.debug-head button, .debug-head select, .debug-head input { font: inherit; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.debug-head input { flex: 1; }
.debug-cols { display: grid; grid-template-columns: 1fr 1.3fr 1fr; flex: 1; min-height: 0; }
.debug-cols > div { overflow: auto; padding: 0 12px; border-right: 1px solid var(--line); }
.debug-cols h4 { margin: 6px 0; position: sticky; top: 0; background: var(--surface); }
.debug ol { margin: 0; padding-left: 0; list-style: none; }
.debug li.error { color: var(--warn); }
.debug li.tool, .debug li.result { color: var(--accent); }
.debug li.notice { color: #8a6d1d; }
.debug li.learner { color: var(--muted); }

@media (max-width: 860px) {
  .classroom { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; }
  .phases { display: none; }
  .teacher-panel, .stage { grid-column: 1; grid-row: auto; }
  .teacher-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .slide { padding: 24px; min-height: 60vh; }
  .flow li { flex-basis: 40%; }
  .start-card { padding: 24px; }
}

/* 理解度テスト */
.quiz-choices { list-style: none; padding: 0; display: grid; gap: 12px; max-width: 760px; }
.quiz-choices button { width: 100%; display: flex; gap: 16px; align-items: center; text-align: left; font: inherit; font-size: 1.15rem;
  padding: 16px 20px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: inherit; cursor: pointer; }
.quiz-choices button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-choices button:disabled { opacity: .6; cursor: default; }
.quiz-choices b { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; }
.quiz-result { display: inline-block; padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.quiz-result.ok { background: #dcefe6; color: #1f6b4f; }
.quiz-result.ng { background: #fbe3d6; color: #9a4a1c; }
.quiz-hint { color: var(--muted); }

/* ピヨルドさん(動きは public/avatar.js) */
.teacher:has(.avatar) { flex-direction: column; text-align: center; gap: 4px; }
.avatar { width: 200px; height: 200px; border-radius: 50%; background: #fff; overflow: hidden; box-shadow: 0 0 0 4px transparent; transition: box-shadow .3s; }
.avatar[data-state="speaking"] { box-shadow: 0 0 0 4px var(--accent); }
.pjord { width: 100%; height: 100%; display: block; }
.pj-eyes > g { display: none; }
.pjord[data-mood="open"] .eyes-open, .pjord[data-mood="happy"] .eyes-happy,
.pjord[data-mood="surprised"] .eyes-surprised, .pjord[data-mood="think"] .eyes-think { display: inline; }
@media (max-width: 900px) { .avatar { width: 120px; height: 120px; } }

/* 振り返り */
.review-score { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.review-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.review-cols h3 { font-size: 1rem; color: var(--muted); margin: 0 0 .4em; }
.review-cols ul { font-size: 1.05rem; }
.review-ask { margin-top: 20px; padding: 16px 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 1.15rem; }
@media (max-width: 900px) { .review-cols { grid-template-columns: 1fr; } }

/* ログイン */
.login { max-width: 440px; margin: 12vh auto; padding: 32px 16px; text-align: center; }
.login .alert { color: #b42318; }
.login form.guest { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.login form.guest p { width: 100%; margin: 0; font-size: 13px; opacity: .7; }
.login input { padding: 8px 10px; border: 1px solid #ccc; border-radius: 8px; }
.whoami { position: absolute; top: 12px; right: 16px; font-size: 14px; white-space: nowrap; }

/* スライドの根拠(主張を支える例・図・対比)。siro/slide-guidelines.md に沿う */
.slide h2 { font-size: 1.9em; line-height: 1.35; }
.slide .slide-body { display: block; }
.slide mark { background: #fff1a8; color: inherit; padding: 0 .15em; border-radius: 3px; }
.ev-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 1em 0; }
.ev-items div { border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ev-items b { display: block; color: var(--accent); margin-bottom: .3em; }
.ev-items span { font-size: 1.15em; }
.ev-chat { display: flex; flex-direction: column; gap: 12px; margin: 1em 0; max-width: 720px; }
.ev-chat > div { padding: 12px 16px; border-radius: 14px; max-width: 85%; }
.ev-chat .me { align-self: flex-end; background: #eef2ff; }
.ev-chat .ai { align-self: flex-start; background: #f3f4f6; }
.ev-chat b { font-size: .85em; color: var(--muted); }
.ev-chat p { margin: .2em 0 0; font-size: 1.2em; }
.ev-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; margin: 1em 0; }
.ev-compare > div:not(.arrow) { border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.ev-compare .right { border-color: var(--accent); }
.ev-compare h3 { margin: 0 0 .4em; font-size: 1em; color: var(--muted); }
.ev-compare .right h3 { color: var(--accent); }
.ev-compare .arrow, .ev-tokens .arrow { align-self: center; font-size: 1.8em; color: var(--muted); }
.ev-tokens { display: flex; gap: 20px; align-items: center; margin: 1.2em 0; font-size: 1.5em; }
.ev-tokens .in { border: 2px solid var(--line); border-radius: 10px; padding: 10px 18px; }
.ev-tokens ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ev-tokens li { padding: 4px 14px; border-radius: 8px; color: var(--muted); }
.ev-tokens li.top { background: #fff1a8; color: inherit; font-weight: 700; }
.ev-tokens small { margin-left: .6em; font-size: .8em; }
.ev-steps { list-style: none; padding: 0; margin: 1em 0; display: flex; flex-direction: column; gap: 12px; }
.ev-steps li { display: grid; grid-template-columns: 7em 1fr; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 1.2em; }
.ev-steps b { color: var(--accent); }
.ev-note { color: var(--muted); font-size: 1.05em; margin-top: 1em; }
@media (max-width: 700px) { .ev-compare { grid-template-columns: 1fr; } .ev-compare .arrow { transform: rotate(90deg); justify-self: center; } }

.slide { font-size: clamp(16px, 1.15vw, 26px); }
.slide h2 { font-size: 1.9em; }
