/* Wayfinder — 画面スタイル
 *
 * 会話が主役の画面。左に学習の地図、右に会話。
 * 資料の投入も、逆質問への回答も、学習中の不満も、すべて会話の中で起きる。
 */

:root {
  --bg: #14171a;
  --bg-2: #1a1e22;
  --panel: #1f2429;
  --panel-2: #252b31;
  --line: #2e353c;
  --line-soft: #262d34;
  --text: #e8ebed;
  --text-dim: #96a1aa;
  --text-faint: #6b7780;

  --accent: #4fd394;
  --accent-dim: #2f8a62;
  --accent-soft: rgba(79, 211, 148, .12);

  --t-concept: #5fc9d6;
  --t-theory: #8a8ff0;
  --t-hands_on: #4fd394;
  --t-application: #f0b45f;
  --t-project: #f0776b;
  --t-quiz: #c98ff0;

  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 12px 34px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .mark {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover;
  /* 白い被毛が暗い背景に溶けないよう、薄い地を敷いて縁を付ける */
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.brand h1 { margin: 0; font-size: 25px; font-weight: 700; letter-spacing: -.01em; }
.brand h1 .ai {
  color: var(--accent); margin-left: 6px;
  font-family: "JetBrains Mono", monospace; font-size: 15px;
}
.tagline {
  margin: 2px 0 0; font-size: 12.5px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
}
.topbar-meta { display: flex; align-items: center; gap: 10px; }

.conn {
  font-family: "JetBrains Mono", monospace; font-size: 12.5px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
}
.conn-on { color: var(--accent); border-color: var(--accent-dim); }
.conn-off { color: var(--text-faint); }

.btn-ghost {
  font: inherit; font-size: 13.5px; color: var(--text-dim);
  background: transparent; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 12px; cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn-ghost:disabled { opacity: .5; cursor: default; }

/* 言語切替。両方を並べ、現在の側を光らせる。
   「切り替わる先」だけを出すと、今どちらの言語なのか読み取れない。 */
.lang-toggle {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: var(--panel);
}
.lang-toggle button {
  font: inherit; font-size: 13px;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-faint); background: transparent;
  border: none; padding: 5px 11px; cursor: pointer;
  transition: color .15s, background .15s;
}
.lang-toggle button + button { border-left: 1px solid var(--line); }
.lang-toggle button:hover:not(.is-active) { color: var(--text-dim); }
.lang-toggle button.is-active {
  color: #0e1512; background: var(--accent); font-weight: 500;
}

.btn-primary {
  font: inherit; font-size: 14.5px; font-weight: 500;
  color: #0e1512; background: var(--accent);
  border: none; border-radius: 10px; padding: 9px 16px; cursor: pointer;
}
.btn-primary:disabled { opacity: .4; cursor: default; }

/* ---------------------------------------------------------------- layout */

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: 0;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
}

/* ----------------------------------------------------------- 学習の地図 */

.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.stage-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 22px 10px;
}
.stage-title { min-width: 0; flex: 1 1 auto; }
.stage-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.goal { margin: 3px 0 0; font-size: 13.5px; color: var(--text-dim); max-width: 64ch; }

.counters { display: flex; gap: 18px; white-space: nowrap; }
.counters span { display: flex; align-items: baseline; gap: 5px; }
.counters b {
  font-size: 20px; color: var(--text);
  font-variant-numeric: tabular-nums; font-weight: 700;
}
.counters i {
  font-style: normal; font-size: 12px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
}

.canvas-wrap { flex: 1 1 auto; position: relative; min-height: 0; overflow: hidden; }
#canvas { display: block; position: relative; z-index: 1; }

.stage-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-dim); pointer-events: none;
  /* 出るときも消えるときも、間を置く。地図と入れ替わる瞬間が見えるように */
  animation: openingIn .5s cubic-bezier(.22,.68,.32,1);
  transition: opacity .4s ease, transform .4s ease;
}
@keyframes openingIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.stage-empty.is-leaving {
  opacity: 0;
  transform: scale(.97);
}
@media (prefers-reduced-motion: reduce) {
  .stage-empty { animation: none; transition: none; }
}
.stage-empty .mascot {
  width: auto; height: min(58vh, 420px);
  margin-bottom: 18px;
  /* 主役はこれから描かれる地図なので、控えめに置く */
  opacity: .92;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, .45));
}
.stage-empty .big { margin: 0; font-size: 19px; }
.stage-empty .dim { margin: 2px 0 0; font-size: 15px; color: var(--text-faint); }

.legend {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 9px 22px 13px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--text-dim); min-height: 40px;
}
.legend .sw {
  display: inline-block; width: 9px; height: 9px;
  border-radius: 3px; margin-right: 5px; vertical-align: -1px;
}
.legend .sw.is-ref { background: var(--text-faint); }
.legend .sep { width: 1px; height: 13px; background: var(--line); }
.legend-hint { margin-left: auto; color: var(--text-faint); font-size: 12px; }

/* ------------------------------------------------------- グラフのノード */

.node { transition: transform .85s cubic-bezier(.22,.68,.32,1), opacity .5s ease; }
.node:focus { outline: none; }
.node:focus .node-card { stroke: var(--accent); stroke-width: 2; }
.node rect { transition: fill .6s ease, stroke .6s ease; }

.node-card { fill: var(--panel); stroke: var(--line); stroke-width: 1; }
.node:hover .node-card { fill: var(--panel-2); }
.node.is-ref .node-card { fill: #1b1f23; stroke: #2a3138; stroke-dasharray: 4 3; }
.node-accent { stroke: none; }

.node-title { fill: var(--text); font-size: 14px; font-weight: 500; }
.node.is-ref .node-title { fill: var(--text-faint); }
.node-meta { fill: var(--text-faint); font-size: 12px; }

.node.flash .node-card { stroke: var(--accent); stroke-width: 2.5; }

.order-badge { fill: #22282e; stroke: var(--line); stroke-width: 1; transition: fill .5s, stroke .5s; }
.order-badge.is-next { fill: var(--accent); stroke: var(--accent); }
.order-num {
  fill: var(--text-dim); font-size: 12.5px;
  font-family: "JetBrains Mono", monospace; transition: fill .5s;
}
.order-num.is-next { fill: #0e1512; font-weight: 500; }

.play-btn circle { fill: var(--accent-soft); stroke: var(--accent-dim); stroke-width: 1; }
.play-btn:hover circle { fill: rgba(79,211,148,.3); }
.play-tri { fill: var(--accent); stroke: none; }

.edge { fill: none; stroke: #39424a; stroke-width: 1.5; transition: d .85s cubic-bezier(.22,.68,.32,1); }
.lane-rule { stroke: var(--line-soft); stroke-width: 1; stroke-dasharray: 3 4; }
.lane-label {
  fill: var(--text-faint); font-size: 10px;
  font-family: "JetBrains Mono", monospace; letter-spacing: .06em;
}

/* ---------------------------------------------------------------- 会話 */

.chat {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2); border-left: 1px solid var(--line);
}
@media (max-width: 980px) {
  .chat { border-left: none; border-top: 1px solid var(--line); }
}

.log {
  flex: 1 1 auto; overflow-y: auto; min-height: 0;
  padding: 20px 18px 8px;
  display: flex; flex-direction: column; gap: 18px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.msg .avatar {
  flex: 0 0 auto; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 50%;
  background: var(--panel-2) center/cover no-repeat url("/mascot-face.png?v=1");
  border: 1px solid var(--line);
}

.msg .body { font-size: 15px; white-space: pre-wrap; }
.msg.agent .body { color: var(--text); }

.msg.user { justify-content: flex-end; }
.msg.user .col { align-items: flex-end; flex: 0 1 auto; max-width: 86%; }
.msg.user .body {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px; padding: 9px 13px;
}

/* 思考中 */
.thinking { display: flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 14px; }
.dots { display: inline-flex; gap: 3px; }
.dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: .35;
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* 選択肢 */
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button {
  font: inherit; font-size: 13.5px; text-align: left;
  color: var(--text-dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; cursor: pointer;
}
.choices button:hover:not(:disabled) { color: var(--text); border-color: var(--accent-dim); }
.choices button.sel { color: #0e1512; background: var(--accent); border-color: var(--accent); }
.choices button:disabled { opacity: .45; cursor: default; }

/* タグ */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  padding: 3px 8px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--text-dim);
}
.tag.mutated { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-soft); }
.tag.nochange { color: var(--text-faint); }

/* 添付した資料 */
.attachments { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; padding: 4px 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  max-width: 100%;
}
.file-chip .ft {
  font-style: normal; font-size: 9px; font-family: "JetBrains Mono", monospace;
  color: var(--accent); letter-spacing: .04em;
}
.file-chip .fn { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fs { color: var(--text-faint); font-family: "JetBrains Mono", monospace; font-size: 10px; }

/* 資料間の対応関係 */
.finding-head { margin: 0; font-size: 13.5px; color: var(--text-dim); }
.finding {
  border: 1px solid var(--line); border-left: 3px solid var(--accent-dim);
  border-radius: 10px; background: var(--panel); padding: 11px 13px;
  display: flex; flex-direction: column; gap: 4px;
}
.finding .side { min-width: 0; }
.finding .src {
  display: block; font-size: 9.5px; color: var(--accent);
  font-family: "JetBrains Mono", monospace;
}
.finding q { font-size: 13px; color: var(--text-dim); font-style: normal; }
.finding .link { color: var(--text-faint); font-size: 13px; padding-left: 2px; }
.finding .rel {
  margin: 5px 0 0; padding-top: 7px; font-size: 13px; color: var(--text);
  border-top: 1px solid var(--line-soft);
}

.signals {
  margin: 0; font-size: 13px; color: var(--text-dim);
  padding-left: 10px; border-left: 2px solid var(--line);
}

/* 根拠 */
.evidence { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.evidence li { font-size: 12.5px; padding-left: 9px; border-left: 2px solid var(--line); }
.evidence .src { color: var(--accent); font-family: "JetBrains Mono", monospace; margin-right: 6px; }
.evidence q { color: var(--text-dim); font-style: normal; }

/* 会話の中のドロップ枠 */
.inline-drop {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 100%; padding: 22px 16px;
  font: inherit; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 12px;
  background: var(--panel); cursor: pointer;
  transition: border-color .2s, background .2s;
}
.inline-drop:hover { border-color: var(--accent-dim); background: var(--accent-soft); }
.idrop-icon {
  width: 26px; height: 26px; border-radius: 8px; margin-bottom: 3px;
  background: linear-gradient(140deg, var(--accent), var(--t-concept)); opacity: .8;
}
.idrop-main { font-size: 14px; color: var(--text); }
.idrop-sub { font-size: 12px; color: var(--text-faint); font-family: "JetBrains Mono", monospace; }

/* 入力欄 */
.composer {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line-soft);
}
.composer-row { display: flex; align-items: stretch; gap: 8px; }

/* 送信を押すまで待機している添付 */
.staged { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.staged-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; padding: 4px 5px 4px 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  max-width: 100%;
}
.staged-chip .ft {
  font-style: normal; font-size: 9px; font-family: "JetBrains Mono", monospace;
  color: var(--accent); letter-spacing: .04em;
}
.staged-chip .fn { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staged-chip .fs { color: var(--text-faint); font-family: "JetBrains Mono", monospace; font-size: 10px; }
.chip-x {
  font: inherit; font-size: 13px; line-height: 1;
  width: 18px; height: 18px; padding: 0;
  color: var(--text-faint); background: transparent;
  border: none; border-radius: 5px; cursor: pointer;
}
.chip-x:hover { color: var(--text); background: var(--line); }

.attach-btn {
  flex: 0 0 auto; width: 40px; align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  font: inherit; line-height: 1;
  color: var(--text-dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.attach-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.attach-btn:disabled { opacity: .4; cursor: default; }

/* 入力欄は会話の主役なので、はっきり広く取る。
   1行分の高さだと「ここに書くのだ」と伝わらない。 */
.composer textarea {
  flex: 1 1 auto; font: inherit; font-size: 15.5px; line-height: 1.7;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; resize: none;
  min-height: 76px; max-height: 200px; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-faint); }
.composer textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(79, 211, 148, .1);
}

.send-btn {
  flex: 0 0 auto; align-self: stretch; min-width: 76px;
  font: inherit; font-size: 14.5px; font-weight: 500;
  color: #0e1512; background: var(--accent);
  border: none; border-radius: 12px; padding: 0 16px; cursor: pointer;
}
.send-btn:disabled { opacity: .4; cursor: default; }

/* ------------------------------------------------------------- スライド */

/* 地図はカリキュラムの構造を見せる。学ぶ中身そのものはこちらで見せる。
   図解（左・大きく）と挿絵（右上・小さく）で役割を分ける。 */

.mode-toggle {
  display: inline-flex; align-items: stretch; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 9px;
  overflow: hidden; background: var(--panel);
}
.mode-toggle button {
  font: inherit; font-size: 13px;
  color: var(--text-faint); background: transparent;
  border: none; padding: 6px 14px; cursor: pointer;
  transition: color .15s, background .15s;
}
.mode-toggle button + button { border-left: 1px solid var(--line); }
.mode-toggle button:hover:not(.is-active) { color: var(--text-dim); }
.mode-toggle button.is-active { color: #0e1512; background: var(--accent); font-weight: 500; }

.slide {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  padding: 4px 22px 12px; gap: 14px; overflow-y: auto;
}

.slide-head {
  flex: 0 0 auto;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
}
.slide-kicker {
  margin: 0; font-size: 11px; color: var(--accent);
  font-family: "JetBrains Mono", monospace; letter-spacing: .09em;
}
.slide-head h3 { margin: 5px 0 0; font-size: 21px; font-weight: 700; line-height: 1.45; }
.slide-meta { margin: 5px 0 0; font-size: 13px; color: var(--text-dim); }

.slide-nav { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.nav-btn {
  font: inherit; font-size: 19px; line-height: 1;
  width: 34px; height: 34px;
  color: var(--text-dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: 9px; cursor: pointer;
}
.nav-btn:hover { color: var(--text); border-color: var(--accent-dim); }
.nav-pos {
  font-size: 12.5px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace; min-width: 48px; text-align: center;
}

.slide-body {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 1fr 268px; gap: 16px;
}
@media (max-width: 1180px) {
  .slide-body { grid-template-columns: 1fr; }
}

.slide-visual {
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 14px; overflow: hidden;
}
.slide-visual svg { width: 100%; height: 100%; max-height: 100%; }
.slide-visual.is-empty { border-style: dashed; }

.slide-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.slide-illust {
  aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: 12px; overflow: hidden;
}
.slide-illust.is-empty { border-style: dashed; }
.slide-illust img { width: 100%; height: 100%; object-fit: cover; display: block; }

.slide-summary {
  margin: 0; font-size: 14px; color: var(--text-dim); line-height: 1.85;
}
.slide-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

.gen-btn {
  font: inherit; font-size: 13px;
  color: var(--accent); background: var(--accent-soft);
  border: 1px dashed var(--accent-dim); border-radius: 10px;
  padding: 10px 16px; cursor: pointer;
}
.gen-btn:hover:not(:disabled) { background: rgba(79, 211, 148, .22); }
.gen-btn:disabled { opacity: .6; cursor: default; }

/* --------------------------------------------- 変化のスポットライト（B案） */

/* 変異の瞬間だけ、変わっていないノードを沈めて視線を集める。
   会話と地図で視線が往復する弱点を、見せ場の数秒だけ補う。 */
/* 沈むのも立つのも、瞬間的に切り替えない。
   パッと入れ替わると「別の画面になった」に見え、**変わった**に見えない。
   0.45 秒かけて沈めることで、視線が変化そのものを追える。 */
.node { transition: opacity .45s ease, filter .45s ease; }
.node.dim { opacity: .18; }
.node.spot .node-card { stroke: var(--accent); stroke-width: 2.5; }
.node.spot {
  filter: drop-shadow(0 0 14px rgba(79, 211, 148, .3));
  animation: spotPulse 1.6s ease-in-out 3;
  transform-box: fill-box; transform-origin: center;
}
/* 3回だけ脈打って止める。鳴り続けると、ただの装飾として読み飛ばされる。 */
@keyframes spotPulse {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(79, 211, 148, .28)); }
  50%      { filter: drop-shadow(0 0 26px rgba(79, 211, 148, .72)); }
}
@media (prefers-reduced-motion: reduce) {
  .node { transition: none; }
  .node.spot { animation: none; }
}

.diff {
  /* #canvas は z-index:1 を持つ。指定しないと地図がパネルの**上**に描かれ、
     沈めたはずのノードがパネルを透かして見える（実測で6個重なっていた）。 */
  z-index: 6;
  position: absolute; top: 18px; right: 20px; width: 320px;
  background: rgba(26, 30, 34, .97);
  border: 1px solid var(--accent-dim); border-radius: 14px;
  padding: 15px 17px 13px;
  box-shadow: 0 16px 44px rgba(0,0,0,.45);
  animation: diffIn .32s cubic-bezier(.22,.68,.32,1);
}
@keyframes diffIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.diff-kicker {
  font-family: "JetBrains Mono", monospace; font-size: 9.5px;
  color: var(--accent); letter-spacing: .08em;
}
/* 何を根拠に変えたか。学習者が言っていない根拠（答案・忘却・節目）は
   色を変える。ここが本題であり、言われて直すだけの仕組みとの違いそのもの。 */
.diff-cause {
  margin-top: 7px; font-size: 12px; color: var(--text-faint);
  padding-left: 9px; border-left: 2px solid var(--line);
}
.diff-cause.evidence {
  color: var(--accent); border-left-color: var(--accent);
  font-weight: 600;
}
.diff-title { font-size: 16.5px; font-weight: 700; margin-top: 8px; }
.diff-msg { margin: 7px 0 0; font-size: 13.5px; color: var(--text-dim); }

.diff-count {
  display: flex; align-items: center; gap: 9px; margin-top: 11px;
  font-size: 11.5px; font-family: "JetBrains Mono", monospace;
}
.diff-count .was { color: var(--text-faint); text-decoration: line-through; }
.diff-count .arrow { color: var(--accent); }
.diff-count .now { color: var(--text); }

.diff-list {
  list-style: none; margin: 11px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.diff-list li {
  font-size: 13px; color: var(--text);
  padding: 5px 9px; border-left: 2px solid var(--accent-dim);
  background: var(--accent-soft); border-radius: 0 6px 6px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.diff-list li.more {
  background: none; border-left-color: var(--line);
  color: var(--text-faint); font-size: 10.5px;
}

.diff-close {
  font: inherit; font-size: 11px; margin-top: 12px;
  color: var(--text-faint); background: transparent;
  border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 11px; cursor: pointer;
}
.diff-close:hover { color: var(--text); border-color: var(--text-faint); }

/* ----------------------------------------------- 画面全体のドロップ受け */

.dropveil {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 14, 12, .86);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.dropveil-inner {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 46px 60px;
  border: 2px dashed var(--accent-dim); border-radius: 20px;
}
.dropveil-inner p { margin: 0; font-size: 15px; }
.dropveil-inner .dim { font-size: 12px; color: var(--text-faint); }
.dropveil-icon {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 8px;
  background: linear-gradient(140deg, var(--accent), var(--t-concept));
}

/* ------------------------------------------------------- オーバーレイ */

.overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(8, 10, 12, .8);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.overlay-box {
  width: min(720px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
}
.ov-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 16px 18px 13px; border-bottom: 1px solid var(--line-soft);
}
.ov-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.ov-meta { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }
.ov-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.ov-summary { margin: 0; font-size: 15px; color: var(--text); }
.ov-label {
  margin: 0; font-size: 10.5px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace; letter-spacing: .05em;
}
.ov-prereqs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; width: 100%; }
.ov-prereqs li {
  font-size: 14px; padding: 7px 11px;
  background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: 8px;
}
.ov-prereqs li.none { color: var(--text-faint); }
.overlay-box video { display: block; width: 100%; background: #000; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ノードの根拠（第3層の出口） */
.ov-evidence { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.ov-dim { margin: 0; font-size: 12px; color: var(--text-faint); }
.ev-item {
  padding: 8px 11px; border-left: 2px solid var(--accent-dim);
  background: var(--bg-2); border-radius: 0 8px 8px 0;
}
.ev-item .src {
  display: block; font-size: 9.5px; color: var(--accent);
  font-family: "JetBrains Mono", monospace; margin-bottom: 2px;
}
.ev-item q { font-size: 13.5px; color: var(--text-dim); font-style: normal; }

/* 理解度チェック */
.quiz-body { gap: 20px; }
.quiz-q {
  width: 100%; display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 18px; border-bottom: 1px solid var(--line-soft);
}
.quiz-q:last-child { border-bottom: none; padding-bottom: 0; }
.quiz-qtext { margin: 0; font-size: 15px; font-weight: 500; }
.quiz-answer {
  width: 100%; font: inherit; font-size: 15px; line-height: 1.6;
  color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; resize: vertical;
}
.quiz-answer:focus { outline: none; border-color: var(--accent-dim); }
.quiz-answer:disabled { opacity: .6; }
.quiz-row { display: flex; align-items: center; gap: 10px; }
.quiz-status { font-size: 11.5px; color: var(--text-dim); }

.quiz-result {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  display: flex; flex-direction: column; gap: 6px;
}
.quiz-result.is-correct { border-left-color: var(--accent); background: var(--accent-soft); }
.quiz-verdict { margin: 0; font-size: 15px; font-weight: 700; }
.quiz-result.is-correct .quiz-verdict { color: var(--accent); }
.quiz-feedback { margin: 0; font-size: 14px; color: var(--text); }
.quiz-plabel {
  margin: 4px 0 0; font-size: 10px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace; letter-spacing: .05em;
}
.quiz-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.quiz-points li { font-size: 13.5px; padding-left: 16px; position: relative; color: var(--text-dim); }
.quiz-points li::before { position: absolute; left: 0; font-family: "JetBrains Mono", monospace; }
.quiz-points.ok li::before { content: "✓"; color: var(--accent); }
.quiz-points.ng li::before { content: "·"; color: var(--text-faint); }
.quiz-by {
  margin: 4px 0 0; font-size: 10px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
}

/* 音声ブリーフィング */
.brief-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13.5px;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-dim); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
.brief-btn:hover { background: rgba(79, 211, 148, .22); }
.brief-btn:disabled { opacity: .55; cursor: default; }
.overlay-box audio { display: block; }
.brief-script {
  margin: 0; font-size: 12.5px; color: var(--text-dim);
  line-height: 1.9; white-space: pre-wrap;
}
.ov-foot {
  margin: 0; padding: 9px 18px 14px;
  font-size: 10.5px; color: var(--text-faint); font-family: "JetBrains Mono", monospace;
}

@media (prefers-reduced-motion: reduce) {
  .node, .edge, .log { transition: none; scroll-behavior: auto; }
  .dots i { animation: none; }
}




/* 答案からカリキュラムが変わったことの告知。
   構造を黙って変えられると不信になるので、必ず目立たせて理由を添える。 */
.quiz-adapt {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent-dim);
  background: color-mix(in srgb, var(--accent-dim) 10%, transparent);
}
.quiz-adapt-head {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
}
.quiz-adapt-why {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
}


/* 復習（フラッシュカード）。
   一度に見せるのは1枚だけ。並べると、めくる前に隣の答えが目に入る。 */
.cards {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 26px 30px;
}
.cards-head {
  display: flex; align-items: baseline; gap: 12px;
  font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--text-faint);
}
.cards-kicker { margin: 0; color: var(--text-dim); }

.card-face {
  width: min(680px, 100%);
  min-height: 190px;
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
  padding: 30px 34px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow);
}
.card-front { margin: 0; font-size: 21px; line-height: 1.6; font-weight: 500; }
.card-back {
  margin: 0; font-size: 18px; line-height: 1.75; color: var(--text-dim);
  padding-top: 16px; border-top: 1px solid var(--line-soft);
}

.cards-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.rate-row { display: flex; gap: 10px; }
.rate {
  padding: 11px 20px; font-size: 15px; font-weight: 500;
  border-radius: 10px; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line);
}
.rate:hover { border-color: var(--text-faint); }
.rate:disabled { opacity: .5; cursor: default; }
/* 「忘れた」だけ色を変える。ここが学習経路を組み替える入口なので、
   押した意味が他の2つと違うことが分かる必要がある。 */
.rate-forgot { border-color: var(--t-project); color: var(--t-project); }
.rate-knew { border-color: var(--accent-dim); color: var(--accent); }

.cards-note { margin: 0; font-size: 14px; color: var(--text-dim); min-height: 20px; }

/* 期限が来た枚数。0 のときは出さない（常に何か溜まって見えるため） */
.due-badge {
  margin-left: 7px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: #10221a;
  font-family: "JetBrains Mono", monospace; font-size: 11px; font-weight: 700;
}


/* 先生役のマスコット。
   カードやスライドを見ている間、右下に立って付き添う。
   pointer-events を切っているのは、下にあるボタンを塞がないため。 */
.tutor {
  position: absolute; right: 18px; bottom: 10px;
  /* 地図でも出すので、ノードの後ろに回す。
     万一かぶっても、学習の中身が犬に隠れることはない。 */
  z-index: 0;
  width: auto; height: clamp(120px, 24vh, 200px);
  pointer-events: none; user-select: none;
  opacity: .95;
  filter: drop-shadow(0 12px 26px rgba(0, 0, 0, .5));
  animation: tutorIn .45s cubic-bezier(.22,.68,.32,1);
}
@keyframes tutorIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: .95; transform: none; }
}
/* 幅が足りないと、めくったカードの本文に重なる */
@media (max-width: 1100px) { .tutor { display: none; } }
@media (prefers-reduced-motion: reduce) { .tutor { animation: none; } }

/* 先生の分だけカード側に余白を作り、重ならないようにする */
.cards { padding-right: 200px; }
@media (max-width: 1100px) { .cards { padding-right: 30px; } }


/* 本文が先生役に届いてしまう場合は、犬の方を引く。
   余白を常に空けておくと、短い本文のときに無駄な空白が残る。
   重なる時だけ消す方が、どちらの場合も収まりが良い。 */
.tutor.is-hidden { opacity: 0; pointer-events: none; }


/* 図を用意している間の控えめな表示。ボタンではないので、押す必要はない */
.gen-wait {
  margin: 0; font-size: 14px; color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
}

/* ------------------------------------------------- 語彙の橋（大きな面）

   取り込みの 50〜90 秒、左は空だった。そこへ読み取った対応関係を出す。
   会話欄と同じ内容だが、**大きさが違えば効き方も違う**。
   12px で正しく書いてあることと、伝わることは別である。          */

.bridge {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 clamp(20px, 5vw, 64px);
  /* #canvas は z-index:1 を持つ。同じ層に置くと地図が透けて、
     どちらも読めない画面になる（実機で発生）。必ず上に出す。 */
  z-index: 4; background: var(--bg);
  animation: bridgeIn .4s cubic-bezier(.22,.68,.32,1);
}
@keyframes bridgeIn { from { opacity: 0; } to { opacity: 1; } }

.bridge-head {
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  color: var(--accent); letter-spacing: .12em;
}
.bridge-sub {
  margin: 10px 0 0; font-size: clamp(17px, 2vw, 23px);
  font-weight: 700; color: var(--text); line-height: 1.4;
  max-width: 30ch;
}

.bridge-cols {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: clamp(10px, 2vw, 26px); margin-top: 26px;
  font-family: "JetBrains Mono", monospace; font-size: 10.5px;
  color: var(--text-faint); letter-spacing: .1em;
}
.bridge-cols span:last-child { text-align: right; }

.bridge-list { list-style: none; margin: 7px 0 0; padding: 0; }
.bridge-list li {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: clamp(10px, 2vw, 26px);
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
  /* 一斉に出さず、順に架ける。1本ずつ結びついていく様子が見える。 */
  opacity: 0; animation: bridgeRow .55s ease forwards;
}
@keyframes bridgeRow {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bridge { animation: none; }
  .bridge-list li { opacity: 1; animation: none; }
}

/* 学習者の言い方は引用として。教科書の用語は確定したものとして。
   同じ大きさで並べることで、**対等に結びついた**ことが伝わる。 */
.b-left, .b-right { font-size: clamp(15px, 1.7vw, 20px); line-height: 1.35; }
.b-left  { color: var(--text); font-style: italic; }
.b-right { color: var(--accent); text-align: right; font-weight: 600; }
.b-arrow { color: var(--text-faint); font-size: 17px; }

.bridge-more { margin: 12px 0 0; font-size: 12px; color: var(--text-faint); }

/* 見せ場の間、先生役は引っ込む。
   変わったノードへ視線を集める場面で、右下に大きな絵が居ると競合する。 */
.tutor.is-muted { opacity: 0; pointer-events: none; }

/* 見せ場の間、地図の収まる幅を狭めて差分パネルの場所を空ける。
   preserveAspectRatio="meet" なので、枠が狭まれば中身は自動で
   縮んで左へ寄る。パネルの裏にノードが入ることが**構造的に**起きない。 */
/* 見せ場の間は、地図が大きくても**必ず全体を収める**。
 *
 * 収まる場合と横スクロールする場合で処理を分けていたが、スクロール側では
 * 枠ごと横に流れるため、right 指定の差分パネルまで一緒に動いてしまった。
 * 経路が2つあることが原因なので、1つにする。
 * 縮んで小さくなっても、変わったノードは光っているので追える。 */
/* スクロールは止める。枠ごと流れると、right 指定のパネルまで動く。
   代わりに中身を平行移動して、変わった箇所を空いている側へ持ってくる。
   縮めないので、**ステップが増えた人ほど読めなくなる**ということが起きない。 */
.canvas-wrap.diff-open { overflow: hidden !important; }
.canvas-wrap #canvas { transition: transform .45s cubic-bezier(.22,.68,.32,1); }
@media (prefers-reduced-motion: reduce) {
  .canvas-wrap #canvas { transition: none; }
}
@media (prefers-reduced-motion: reduce) {
  .canvas-wrap #canvas { transition: none; }
}

/* 先生役の表情の切り替え。
   差し替えるだけだと「いつの間にか変わっている」ので、
   一度だけ小さく弾ませて、変わったことに気づけるようにする。 */
.tutor.mood-in { animation: moodPop .42s cubic-bezier(.34,1.56,.64,1); }
@keyframes moodPop {
  0%   { transform: scale(.9) translateY(6px); opacity: .75; }
  60%  { transform: scale(1.04) translateY(-2px); opacity: 1; }
  100% { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tutor.mood-in { animation: none; }
}

/* 採点結果の隣に立つ先生役。
   覆いの裏の先生役は見えないので、判定文のすぐ隣に置く。
   別の場所で反応しても気づかれない。 */
.quiz-result { position: relative; }
.quiz-mood {
  /* 反応しているのは**判定文**なので、その隣に置く。
     下端に置くと、直後の別の内容の隣に見えてしまう（実測でそうなった）。 */
  position: absolute; right: 8px; top: 8px;
  width: auto; height: clamp(72px, 10vh, 104px);
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .45));
}
/* 文が犬の下へ回り込まないよう、その分だけ空けておく */
.quiz-result { padding-right: clamp(58px, 8vh, 88px); }

/* 開始画面の絵も、待っている間は考える姿勢に差し替える。
   取り込みの80秒はここが映っているので、合わせないと一番長い待ち時間が
   静止画のままになる。 */
.stage-empty .mascot.mood-in { animation: moodPop .42s cubic-bezier(.34,1.56,.64,1); }
