/* css/viewer-stage.css
   ================================================================
   解説ビューアの操作部品と収録モード（2026-10-12）。js/viewer-stage.js と対
   先生の指示「ヒントのボタンの位置やその他の機能ボタンも最適化して」
             「問題解説動画を画面収録で生成したいのでタッチペン機能や画面配置も最適化して」
   ・右上に横並びだったボタン（ヒント・QR・ブックマーク・印刷）と右下の丸いコメントのボタンを、
     授業ページと同じ「右端の列」（48px の四角に絵＋語）1 本にまとめた
   ・ヒントの入口は題の下の小さな札 1 つ（大きな黄色い帯はやめた）
   ・画面の左右の端に浮いていた ‹ › は、カードの下の「次へ：(2) …」に替えた
   ・位置と大きさはこのファイルだけが決める。JS は中身と出す／出さないだけ
   ・効くのは作り直した解説（題に data-expl-v2 の印 → <html class="expl-v2">）だけ。
     右端の列は viewer-stage.js が、印を見つけたときに今までの右上のボタンを移して作る。
     印の無い解説は、作り直すまで今までの形（右上の横並び・黄色い帯・左右の ‹ ›）のまま（先生の指示「他の問題はまだ」）
   ・中身の見た目は css/explanation-v2.css
   ================================================================ */

/* 右端の列のぶん、本文の幅を空ける（760px 以上。それ未満は列を題の右上に横に並べる） */
@media screen and (min-width: 760px) {
  html.expl-v2 { --card-width: min(1100px, calc(100vw - 128px)); }
}
/* 今までの右上の横並び（ボタンは右端の列へ移したので空になる） */
html.expl-v2 .viewer-toolbar { display: none !important; }

.vw-rail {
  position: fixed;
  z-index: var(--z-header, 100);
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(6px + env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vw-rail-btn {
  position: relative;          /* コメントの件数のバッジ（annotation.js）を角に置く */
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 3px 0 2px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid rgba(14, 165, 233, 0.35);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: #0369a1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}
.vw-rail-btn[hidden] { display: none; }
.vw-rail-btn .rail-ico { font-size: 18px; line-height: 1.1; }
.vw-rail-btn .rail-lbl { font-size: 10.5px; font-weight: 700; line-height: 1.15; white-space: nowrap; letter-spacing: 0; }
.vw-rail-btn:hover { background: #e0f2fe; }
.vw-rail-btn:focus-visible { outline: 2px solid #0284c7; outline-offset: 2px; }
.vw-rail-btn.bookmarked { color: #b45309; border-color: rgba(245, 158, 11, 0.6); background: #fffbeb; }
.vw-rail-btn--rec { color: #be123c; border-color: rgba(225, 29, 72, 0.4); }
.vw-rail-btn--rec:hover { background: #fff1f2; }
.embed-mode .vw-rail .qr-trigger { display: none; }

@media (max-width: 759px) {
  .vw-rail {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 8px;
    flex-direction: row;
    gap: 4px;
  }
  .vw-rail-btn { width: 44px; height: 44px; border-radius: 10px; }
  .vw-rail-btn .rail-ico { font-size: 16px; }
  .vw-rail-btn .rail-lbl { font-size: 9.5px; }
}

/* 「タップで／コメント」（annotation.js が指で使う端末にだけ作る）。授業ページでは右端の列の下の段に置くが、
   ビューアにはその段の決まり（float-rail.css）が無く、右上の列の「保存」の上に重なっていた（iPad 縦で実測）。右下に、列と同じ四角で置く */
html.expl-v2 .ann-tap-fab {
  top: auto !important;
  right: calc(6px + env(safe-area-inset-right, 0px)) !important;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  width: 48px !important;
  min-height: 48px !important;
  height: 48px !important;
  padding: 2px 0 !important;
  border-width: 1px !important;
  border-radius: 12px !important;
  font-size: 9.5px !important;
  gap: 0 !important;
}
html.expl-v2 .ann-tap-fab .ann-tap-fab-icon { font-size: 16px; }

/* 題のまわり：右上の横並びのボタンが無くなったので、上の余白を詰める */
html.expl-v2 .viewer-page-header { padding-top: 26px; margin-bottom: 18px; }
@media (max-width: 759px) {
  html.expl-v2 .viewer-page-header { padding-top: 60px; margin-bottom: 8px; }
}

/* 題（h1）は、授業ページの題（④ 万有引力）と同じ形：左右に細い線を引いた中央の見出し。題の行の右端に小さい QR。
   2026-10-13，先生の指示「QRコードは授業コンテンツページと同じように問題タイトルの右側に表示させて，
   授業コンテンツページと同じようなデザイン（④ 万有引力のタイトルと同じデザイン）にして」。
   決まりは /css/lesson-v2.css の「11.」と同じ：
     ・字はグラデーション（水色 → 紫）のまま、字の下線は引かない。線は header の ::before／::after（h1 の中には何も入れない）
     ・header を 5 列の格子にする（空き｜線｜題｜線｜空き）。パンくず・ヒントの札は列をまたいで 1 行ずつ
     ・QR（.vw-title-qr。viewer-stage.js が今までの「▣ QR」のボタンから作る）は題の行の右端。QR のあるあいだは、左右の線を同じ長さだけ短くする
     ・幅 560px 未満では QR を出さない（題の横に場所が無いし、その端末でもう開いている）
   字の大きさも授業ページにそろえた（本文 18px の 2.4 倍＝43.2px。767px 以下は 1.85 倍） */
html.expl-v2 .viewer-page-header {
  display: grid;
  grid-template-columns: 0 minmax(0, 1fr) auto minmax(0, 1fr) 0;
  align-items: center;
}
html.expl-v2 .viewer-page-header > * { grid-column: 1 / -1; }
html.expl-v2 .viewer-page-header > h1 {
  grid-column: 3;
  grid-row: 2;
  margin: 14px 0 6px;
  padding-bottom: 0;
  border-bottom: 0;
  border-image: none;
  font-size: 2.4em;
}
html.expl-v2 .viewer-page-header::before,
html.expl-v2 .viewer-page-header::after {
  content: "";
  grid-row: 2;
  height: 2px;
  border-radius: 2px;
}
html.expl-v2 .viewer-page-header::before {
  grid-column: 2;
  margin-right: 22px;
  background: linear-gradient(90deg, rgba(14, 165, 233, 0), #0ea5e9);
}
html.expl-v2 .viewer-page-header::after {
  grid-column: 4;
  margin-left: 22px;
  background: linear-gradient(90deg, #8b5cf6, rgba(139, 92, 246, 0));
}
html.expl-v2 .viewer-page-header > .vw-title-qr {
  grid-column: 4;
  grid-row: 2;
  justify-self: end;
}
html.expl-v2 .viewer-page-header:has(> .vw-title-qr:not([hidden]))::before { margin-left: 78px; }
html.expl-v2 .viewer-page-header:has(> .vw-title-qr:not([hidden]))::after { margin-right: 78px; }
@media (max-width: 767px) {
  html.expl-v2 .viewer-page-header > h1 { font-size: 1.85em; margin: 8px 0 4px; }
  html.expl-v2 .viewer-page-header::before { margin-right: 12px; }
  html.expl-v2 .viewer-page-header::after { margin-left: 12px; }
}

/* 題の右の小さい QR（授業ページの .page-qr と同じ形）。押すと今までの QR の窓（shared-ui.js の initQRModal）が開く */
.vw-title-qr {
  position: relative;
  z-index: 1;
  display: inline-block;
  width: 60px;
  height: 60px;
  margin: 0;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.vw-title-qr[hidden] { display: none; }
.vw-title-qr:hover,
.vw-title-qr:focus-visible {
  transform: scale(1.06);
  border-color: #0ea5e9;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25);
  outline: none;
}
.vw-title-qr__img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.vw-title-qr__txt { display: block; line-height: 1.2; font-size: 13px; font-weight: 700; color: #0369a1; }
.embed-mode .vw-title-qr { display: none !important; }
@media (max-width: 559px) {
  .vw-title-qr { display: none !important; }
  html.expl-v2 .viewer-page-header:has(> .vw-title-qr)::before { margin-left: 0; }
  html.expl-v2 .viewer-page-header:has(> .vw-title-qr)::after { margin-right: 0; }
}
@media print { .vw-title-qr { display: none !important; } }

/* ヒントの入口（題の下の札）。対応するヒントがあるときだけ viewer.js が出す（style.display）。
   題（h1 は inline-block）の横ではなく、次の行のまん中に置く（flex＝塊。幅は中身に合わせる） */
.vw-hint-chip {
  width: max-content;
  max-width: 100%;
  box-sizing: border-box;
  align-items: center;
  gap: 6px;
  margin: 10px auto 0;
  padding: 6px 14px;
  border: 1.5px solid rgba(245, 158, 11, 0.55);
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e !important;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none !important;
  line-height: 1.3;
  transition: background 0.15s;
}
.vw-hint-chip:not([style*="none"]) { display: flex; }
.vw-hint-chip small { color: #b45309; font-weight: 600; font-size: 0.86em; opacity: 0.85; }
.vw-hint-chip small::before { content: "（"; }
.vw-hint-chip small::after { content: "）"; }
.vw-hint-chip:hover { background: #fef3c7; }

/* カードの下の送り（「次へ：(2) …」）。読み終えた所に置く */
.vw-card-nav {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 26px 0 4px;
  padding-top: 16px;
  border-top: 1px dashed #cbd5e1;
}
.vw-card-nav__pos { justify-self: center; color: #94a3b8; font-size: 0.84rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.vw-card-nav__prev {
  width: 44px; height: 44px;
  border: 1px solid #cbd5e1; border-radius: 50%;
  background: #fff; color: #475569; cursor: pointer; font-size: 0.9rem;
}
.vw-card-nav__next {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; max-width: min(460px, 62vw);
  padding: 8px 18px 8px 20px;
  border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff; cursor: pointer; font-family: inherit;
  box-shadow: 0 3px 12px rgba(79, 70, 229, 0.28);
  transition: box-shadow 0.15s;
}
.vw-card-nav__next:hover { box-shadow: 0 5px 16px rgba(79, 70, 229, 0.38); }
.vw-card-nav__k { font-size: 0.78rem; font-weight: 800; opacity: 0.85; white-space: nowrap; flex: 0 0 auto; }
.vw-card-nav__t { font-size: 0.98rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.vw-card-nav__end { color: #94a3b8; font-size: 0.84rem; font-weight: 700; }
@media print { .vw-card-nav { display: none !important; } }

/* ── 図のまわり（作り直した解説）── 題は図の下、その右に ⛶ 拡大・🔍 図鑑（同じ大きさの小さな札）。
   組むのは viewer-stage.js の SimChrome */
.vw-fig-cap {
  display: block;
  margin: 6px 0 0;
  text-align: center;
  line-height: 1.5;
}
.vw-fig-cap .ann-sim-label {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #64748b;
  font-size: 12.5px;
  font-weight: 700;
}
.vw-fig-tools { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: 1px; white-space: nowrap; }
.vw-fig-tool {
  display: inline-flex; align-items: center; gap: 3px;
  height: 20px; padding: 0 7px;
  border: 1px solid rgba(14, 165, 233, 0.4); border-radius: 6px;
  background: #fff; color: #0369a1 !important;
  font-family: inherit; font-size: 11px; font-weight: 700; line-height: 1;
  text-decoration: none !important; cursor: pointer;
  position: relative;
}
.vw-fig-tool:hover { background: #e0f2fe; }
/* 指の端末では、見た目はそのまま押せる範囲だけ広げる（授業ページの ⛶・🔍 と同じ） */
@media (pointer: coarse) {
  .vw-fig-tool::after { content: ""; position: absolute; left: -3px; right: -3px; top: -11px; bottom: -11px; }
}

/* ⛶ 拡大：図の包みを画面いっぱいに。全画面の API が使えない端末（iPhone の Safari）では fixed で敷く */
.vw-fig.vw-fig--fs {
  position: fixed !important;
  inset: 0;
  z-index: 2147483000;
  margin: 0 !important;
  padding: 56px 20px 20px;
  box-sizing: border-box;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.vw-fig:fullscreen { background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 20px 20px; box-sizing: border-box; overflow: auto; }
.vw-fig:-webkit-full-screen { background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 20px 20px; box-sizing: border-box; overflow: auto; }
.vw-fig-close {
  display: none;
  position: absolute; top: 10px; right: 14px;
  height: 36px; padding: 0 14px;
  border: 1px solid #cbd5e1; border-radius: 999px;
  background: #fff; color: #334155; font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
}
.vw-fig.vw-fig--fs > .vw-fig-close,
.vw-fig:fullscreen > .vw-fig-close,
.vw-fig:-webkit-full-screen > .vw-fig-close { display: inline-flex; align-items: center; }
.vw-fig.vw-fig--fs .vw-fig-tools,
.vw-fig:fullscreen .vw-fig-tools { display: none; }
/* 敷いているあいだは、包みを閉じこめる先祖の「閉じこめ」を外す（contain / backdrop-filter は fixed の基準になる） */
html.vw-fig-fs-host .viewer-container,
html.vw-fig-fs-host .explanation-area,
html.vw-fig-fs-host .card {
  contain: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  content-visibility: visible !important;
  transform: none !important;
}
html.vw-fig-fs-host .card .fig-steps > .fig-steps__fig { position: static !important; }

/* ================================================================
   収録モード（🎬 収録）—— 解説動画を画面収録する形
   ・上に細い帯 1 本（題・設問・段階表示・ペン／レーザー／操作・全画面・終了）。ほかの操作部品は出さない
   ・本文は 16:9 の画面に合わせて広く・字を一回り大きく。図は右の列で画面に付いてくる
   ・段階表示：→ ／ スペース ／ PageDown（プレゼンのリモコン）で 1 段ずつ出す。← ／ PageUp で戻す
   ================================================================ */
body.rec-mode { --vw-bar-h: 56px; }
body.rec-mode .vw-rail,
body.rec-mode .viewer-page-header,
body.rec-mode .site-footer,
body.rec-mode .back-to-top,
body.rec-mode .reading-progress,
body.rec-mode .card-reaction-footer,
body.rec-mode .ad-slot,
body.rec-mode .gate-band,
body.rec-mode .vw-fig-tools,
body.rec-mode .gallery-link-wrap,
body.rec-mode .vw-card-nav,
body.rec-mode .ann-tap-fab,
body.rec-mode .ann-panel,
body.rec-mode .ann-popup,
body.rec-mode .card-tabs { display: none !important; }
/* 収録（と解説動画）では、コメントの印（コメントの付いた図の題・式の橙の枠，文字の地色）を映さない（2026-10-12） */
body.rec-mode .ann-block-highlight { outline: none !important; box-shadow: none !important; }
body.rec-mode .ann-highlight { background: none !important; border-bottom-color: transparent !important; text-decoration: none !important; }

.vw-recbar { display: none; }
body.rec-mode .vw-recbar {
  display: flex;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 600;
  align-items: center;
  gap: 10px;
  height: var(--vw-bar-h);
  padding: 0 14px 0 16px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}
.vw-recbar__title {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 24vw;
  font-weight: 900;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.vw-recbar__tabs { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px; }
.vw-recbar__tabs::-webkit-scrollbar { display: none; }
.vw-recbar__tab {
  flex: 0 0 auto;
  height: 36px; padding: 0 14px;
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #fff; color: #475569;
  font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.vw-recbar__tab.is-on { color: #fff; border-color: transparent; background: linear-gradient(135deg, #0ea5e9, #6366f1); box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28); }
.vw-recbar__tools { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.vw-recbar__seg { display: inline-flex; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; background: #fff; }
.vw-recbar__btn {
  height: 36px; min-width: 36px; padding: 0 11px;
  border: 1px solid #e2e8f0; border-radius: 10px;
  background: #fff; color: #334155;
  font-family: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.vw-recbar__seg .vw-recbar__btn { border: 0; border-right: 1px solid #e2e8f0; border-radius: 0; }
.vw-recbar__seg .vw-recbar__btn:last-child { border-right: 0; }
.vw-recbar__btn.is-on { background: #eef2ff; color: #3730a3; box-shadow: inset 0 -3px 0 #6366f1; }
.vw-recbar__btn--exit { color: #be123c; border-color: rgba(225, 29, 72, 0.35); }
.vw-recbar__count { color: #64748b; font-size: 0.82rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
/* 幅が 1400px に満たない画面（iPad 横 1180 など）では、題を出さず道具は絵だけにして、設問のタブに幅を回す（名前は title で出る） */
@media (max-width: 1400px) {
  .vw-recbar__title { display: none; }
  .vw-recbar__btn .lbl { display: none; }
  .vw-recbar__btn { padding: 0 9px; }
}

/* 本文：16:9 の画面に合わせて広く・字を一回り大きく（1920×1080 で本文 20px） */
body.rec-mode { padding-top: var(--vw-bar-h); background: #f8fafc; }
body.rec-mode .viewer-container { contain: none; }
body.rec-mode .explanation-area { --card-width: min(1560px, calc(100vw - 40px)); max-width: var(--card-width); padding-top: 16px; }
body.rec-mode .explanation-area .card { max-width: none; font-size: clamp(17px, 1.05vw, 21px); padding: 24px 40px 30px; margin-bottom: 40vh; }
html.expl-v2 body.rec-mode .explanation-area .card .fig-steps { --ev-fig-col: min(600px, 40%); }
/* 収録モードでは図を付いてこさせない。手書きの線は錨（段落・図）の位置から置くが、付いてくる図はスクロールで
   錨と線の位置関係が変わる（授業ページで「線のあるカードは付いてこさせない」としたのと同じ理由）。1080p ならたいてい段と図が 1 画面に入る */
html.expl-v2 body.rec-mode .explanation-area .card .fig-steps > .fig-steps__fig { position: static; }

/* 段階表示：まだ出していない段は、場所を空けたまま見えなくする（行が動くと視線が飛ぶ・手書きの錨もずれない） */
body.rec-mode.rec-step .rec-hid { visibility: hidden !important; }
body.rec-mode.rec-step .rec-now { position: relative; }
body.rec-mode.rec-step .rec-now::after {
  content: "";
  position: absolute;
  left: -14px; top: 6px; bottom: 6px;
  width: 4px; border-radius: 2px;
  background: linear-gradient(180deg, #0ea5e9, #6366f1);
  pointer-events: none;
}
body.rec-mode.rec-step ol.step-list > li.rec-now::after { left: -12px; }
/* 出すときの動き（表示アニメーション）は viewer-stage.js の tweenIn が 1 コマずつ組む（CSS のアニメーションは使わない。
   解説動画をコマ送りで撮ると、実時間で進む CSS のアニメーションは音とずれるため） */
}

/* 段階表示の「次へ・戻る」（右下。指・ペンでも押せる。プレゼンのリモコンは PageDown／PageUp） */
.vw-rec-next { display: none; }
body.rec-mode.rec-step .vw-rec-next {
  display: flex;
  position: fixed;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 650;
  gap: 8px;
}
.vw-rec-next button {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(255, 255, 255, 0.92); color: #4f46e5;
  font-size: 1.05rem; font-weight: 900; cursor: pointer;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  opacity: 0.5; transition: opacity 0.2s;
}
.vw-rec-next button:hover, .vw-rec-next button:focus-visible { opacity: 1; }

/* レーザー（pointer.js）は収録モードの「🔴 レーザー」のときだけ。本文の上にどこでも出せる */
body.rec-mode #pointer-canvas.pointer-canvas-inline { z-index: 640; }

/* 書き込み（/js/ink.js）は収録モードのときだけ。道具箱は帯の下から */
body:not(.rec-mode) .ink-toolbar,
body:not(.rec-mode) .ink-layer-doc { display: none !important; }
body.rec-mode .ink-toolbar { top: calc(var(--vw-bar-h) + 10px) !important; }
body.rec-mode.rec-tool-laser .ink-toolbar,
body.rec-mode.rec-tool-hand .ink-toolbar { opacity: 0.35; }

/* ================================================================
   解説動画の撮影（?rec=1&video=1。tools/video/page-render.mjs が開く）
   先生の指示「このページを使って解説動画を作って，人工音声を入れてそれに連動して画面を操作して」
   ・帯は題・設問・流れの札（状況整理／考え方／解き方／補足）だけ。道具・◀ ▶・書き込みは出さない
   ・本文は左，図は右に固定して縦のまん中（文を送っても図はいつも見えている）。1920×1080 で組む
   ================================================================ */
body.rec-video .vw-recbar__tools,
body.rec-video .vw-rec-next,
body.rec-video .ink-toolbar { display: none !important; }
body.rec-video .vw-recbar__tabs { pointer-events: none; }
body.rec-video .vw-recbar { padding-right: 24px; }
body.rec-video .vw-recbar__title { display: block !important; max-width: 30vw; font-size: 1.1rem; }
.vw-recbar__chapter { display: none; }
body.rec-video .vw-recbar__chapter {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  font-weight: 900;
  font-size: 1.02rem;
  letter-spacing: 0.08em;
  line-height: 36px;
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.3);
}
body.rec-video .vw-recbar__chapter.is-on { display: inline-block; }
body.rec-video .viewer-container,
body.rec-video .explanation-area { contain: none !important; }
/* 解説動画の版面（2026-10-12 に改めた。先生の指示「図版と文章で真ん中で区切られているが，文中の右側に図版やシムを入れるなどして
   授業コンテンツページと同じようなデザインにして」）。カードは 1 枚で画面の幅いっぱい，本文は左の 6 割，図はカードの中の右（4 割弱）。
   図は画面に固定する（答え・つまずき・Point を話すあいだも図を指すため）が，自分の板・影は持たず，カードの地にそのまま乗る。
   カードの下は画面の下まで伸ばす（固定した図がカードの外にはみ出して見えないように） */
html.expl-v2 body.rec-video { --vid-area-w: calc(100vw - 80px); --vid-fig-w: 760px; --vid-pad-x: 44px; }
html.expl-v2 body.rec-video .explanation-area {
  --card-width: var(--vid-area-w);
  max-width: var(--vid-area-w);
  margin: 0 auto;
}
html.expl-v2 body.rec-video .explanation-area .card {
  font-size: 23px;                       /* 動画では文を短くした形に差し替えるので（台本の slide），字を大きく */
  padding: 26px calc(var(--vid-fig-w) + var(--vid-pad-x) + 40px) 50vh var(--vid-pad-x);
  margin-bottom: 0;
  background: #fff;                      /* 図（白地）とカードの地をそろえる（半透明の地だと図の四角が浮いて見える） */
  contain: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  content-visibility: visible;
}
/* 右に固定するのは，カードの本筋の図（カード直下の図と段の組）だけ。折りたたみ（別解）の中の図は，本文の中にふつうに組む */
html.expl-v2 body.rec-video .card > .fig-steps { display: block; }
html.expl-v2 body.rec-video .card > .fig-steps > .fig-steps__fig {
  position: fixed !important;
  top: calc(var(--vw-bar-h) + 40px);
  right: calc((100vw - var(--vid-area-w)) / 2 + var(--vid-pad-x));
  width: var(--vid-fig-w);
  padding: 0;
  box-sizing: border-box;
  background: transparent;
  z-index: 5;
}
/* いま読んでいる所の印（2026-10-12 に枠から改めた。先生の指示「枠囲みではなくアンダーラインで左から右へと引っ張るようなアニメにして」
   「読み上げている箇所の文字や図はその時だけ太字や大きいサイズ色分けなどして強調して，説明が終わったら元に戻して」）。
   文字は濃い藍で太く（字の幅は変えない＝行が動かない）。下線は viewer-stage.js が体の上に重ねて，左から右へ伸ばす。
   CSS の transition は使わない（コマ送りで撮るため。動きはすべて JS） */
body.rec-video .vid-hl,
body.rec-video .vid-hl * { color: #1e3a8a !important; }
body.rec-video .vid-hl { -webkit-text-stroke: 0.45px currentColor; }
body.rec-video .vid-hl mjx-container { -webkit-text-stroke: 0.35px currentColor; }
.vid-uline {
  position: absolute;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #fb923c, #f97316);
  pointer-events: none;
  z-index: 6;
}
/* 動画で外した部品（台本の slide の hide）・あとで出す部品（slide の later。"show" で出す。場所は取っておく） */
.vid-gone { display: none !important; }
.vid-later { visibility: hidden !important; }

/* 大きく見せる（viewer-stage.js の stage。解説動画だけ）。2026-10-13，先生の指示「スマートフォンで見ると文字や図が小さくて見にくい」
   「説明するときだけ文字や図を大きく画面に大きく表示し，説明が終わったら順次今の形式で表示させ」。
   いま話している部品は左の空きいっぱいに浮かせ（translate・scale は JS が 1 コマずつ），ほかは薄く（--vid-dim も JS が動かす）。
   図を大きくするときは，右の空きいっぱいに白い板ごと（下の本文を隠す） */
body.rec-video.vid-spotting .vid-dim { opacity: var(--vid-dim, 1) !important; }
body.rec-video.vid-spotting .vid-dim.vid-dim-off { opacity: 1 !important; }      /* 代入するもと（飛ぶあいだは濃く） */
body.rec-video .vid-spot { position: relative; z-index: 4; border-radius: 14px; box-shadow: 0 14px 40px rgba(15, 23, 42, 0.14); }
body.rec-video .vid-spot.vid-spot--plain { background: #fff; border-radius: 10px; box-shadow: 0 0 0 16px #fff, 0 18px 46px rgba(15, 23, 42, 0.13); }
html.expl-v2 body.rec-video .card > .fig-steps > .fig-steps__fig.vid-fig-big {
  background: #fff; border-radius: 18px; z-index: 6;
  box-shadow: 0 0 0 14px #fff, 0 22px 64px rgba(15, 23, 42, 0.18);
}

/* 代入の色（台本の slide の数式で \class{sub-b}{…} のように付ける）。読んでいる所の印（.vid-hl の濃い藍）より強くする。
   色はショート動画と同じ約束：青＝代入する式・緑＝約分で消えるもの・橙＝0 になるもの・赤＝注意 */
.sub-b, .sub-b *, body.rec-video .sub-b, body.rec-video .sub-b * { color: #0284c7 !important; }
.sub-g, .sub-g *, body.rec-video .sub-g, body.rec-video .sub-g * { color: #059669 !important; }
.sub-o, .sub-o *, body.rec-video .sub-o, body.rec-video .sub-o * { color: #d97706 !important; }
.sub-r, .sub-r *, body.rec-video .sub-r, body.rec-video .sub-r * { color: #dc2626 !important; }
/* シムの色にそろえるとき（175 (5)：台が動いた距離 L＝茶・地面に対する小物体の水平移動＝青緑） */
.sub-c, .sub-c *, body.rec-video .sub-c, body.rec-video .sub-c * { color: #b45309 !important; }
.sub-t, .sub-t *, body.rec-video .sub-t, body.rec-video .sub-t * { color: #0f766e !important; }
.vid-src, .vid-src *, body.rec-video .vid-src, body.rec-video .vid-src * { color: var(--vid-src, #0284c7) !important; }

/* 代入の写し（viewer-stage.js の substFly）。代入するもとから，代入される文字の上へ飛ぶ */
.vid-subst {
  position: absolute; z-index: 60; pointer-events: none; white-space: nowrap;
  padding: 1px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.22);
}
.vid-subst mjx-container { margin: 0 !important; }

/* 流れが変わるときの帯（viewer-stage.js の chapterBand。解説動画だけ） */
/* 流れの札：画面のまん中に，幅いっぱいの帯。字は大きく，折り返さない（viewer-stage.js の chapterBand） */
.vid-band {
  position: fixed; left: 0; right: 0; top: 50%; margin-top: -110px; height: 220px; z-index: 70; pointer-events: none;
  display: flex; align-items: center; justify-content: center; box-sizing: border-box; overflow: hidden;
  background: linear-gradient(100deg, rgba(14, 165, 233, 0.95), rgba(99, 102, 241, 0.95) 55%, rgba(139, 92, 246, 0.93));
  box-shadow: 0 20px 60px rgba(79, 70, 229, 0.32);
}
.vid-band::before, .vid-band::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px; background: rgba(255, 255, 255, 0.55);
}
.vid-band::before { top: 18px; }
.vid-band::after { bottom: 18px; }
.vid-band__tx {
  color: #fff; font-size: 120px; font-weight: 900; line-height: 1; letter-spacing: 0.14em; padding-left: 0.14em;
  white-space: nowrap; text-shadow: 0 6px 22px rgba(30, 27, 75, 0.38); transform-origin: 50% 50%;
}

@media print {
  .vw-rail, .vw-recbar, .vw-rec-next, .vw-hint-chip { display: none !important; }
}

/* ================================================================
   小問ごとの解説動画（viewer.js の addCardVideos）。2026-10-12，先生の指示
   「Youtube には大問ごとに 1 つの動画でアップする予定，web ページには小問ごとに振り分けて動画をページ内にそれぞれ組み込んで」。
   押すと 16:9 の枠が開き，大問の動画のうち，その小問の区間だけを再生する。
   2026-10-13 に置き場所を改めた（先生の指示「🎬この小問の解説動画のボタンはカードの右上に表示して（タイトルの右端）、
   ボタンをおしたらYoutube動画はカードの中央揃えで表示させて」）：
     ボタン（.vw-video--btn）は題（h3）の直前にあり，右に浮かせて題の 1 行目の右端に並べる。題の字はボタンをよけて折れる。
     見た目の高さは 32px（題の行より低く，題の下線にかからない）。指の端末では押せる範囲だけ 44px に広げる
     枠（.vw-video__frame）は題のすぐ後ろ。カードの中央に，幅 720px まで
   ================================================================ */
.vw-video--btn {
  float: right;
  position: relative;
  z-index: 1;
  margin: 1px 0 4px 16px;
}
.vw-video__btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px; border-radius: 999px; box-sizing: border-box;
  border: 1px solid #c7d2fe; background: #eef2ff; color: #3730a3;
  font-family: inherit; font-size: 0.84rem; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 4px rgba(79, 70, 229, 0.12);
}
.vw-video__btn:hover, .vw-video__btn:focus-visible { background: #e0e7ff; }
.vw-video__btn[aria-expanded="true"] { background: #e0e7ff; box-shadow: inset 0 0 0 1px #a5b4fc; }
.vw-video__ico { font-size: 1.05em; }
.vw-video__len { font-weight: 600; color: #4f46e5; opacity: 0.8; font-variant-numeric: tabular-nums; }
.vw-video__frame {
  width: 100%; max-width: 720px; margin: 0 auto 22px;
  aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #0f172a;
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.16);
}
.vw-video__frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.vw-video__frame[hidden] { display: none; }
@media (pointer: coarse) {
  .vw-video__btn::after { content: ""; position: absolute; left: -4px; right: -4px; top: -6px; bottom: -6px; }
}
/* 狭い画面（スマホ）では「この小問の」を外して短く（題の字の幅を残す） */
@media (max-width: 559px) {
  .vw-video--btn { margin: -2px 0 4px 10px; }
  .vw-video__btn { height: 30px; padding: 0 10px; gap: 5px; font-size: 0.8rem; }
  .vw-video__lbl-pre { display: none; }
}
/* 収録・解説動画の撮影・印刷では出さない */
body.rec-mode .vw-video, body.rec-video .vw-video { display: none !important; }
@media print { .vw-video { display: none !important; } }

/* ================================================================
   一般公開用の表示（?share=1。YouTube の概要欄の短い URL /v/<鍵> から。viewer.html の頭で html.share-mode を付ける）。
   2026-10-12，先生の指示「まだ webアプリの全体は完成していないので該当の解説ページのみ見える仕様で一般公開したい」。
   その解説だけを出し，サイトのほかの所へつながる部品は出さない：パンくず（問題解説のメニューへのリンク）・下の帯（サイトへのリンク）・
   ヒント（未完成。教員の画面だけ）・図鑑・コメント・保存・印刷・確認中の知らせの「メニューへ」。QR・⛶ 拡大・小問ごとの解説動画は残す
   （印刷は同じ日，先生の指示「印刷ボタン不要」で外した）
   ================================================================ */
html.share-mode #prob-breadcrumb,
html.share-mode .site-footer,
html.share-mode .skip-link,
html.share-mode #btn-to-hint,
html.share-mode .vw-hint-chip,
html.share-mode .hint-link-banner,
html.share-mode #btn-bookmark,
html.share-mode #btn-annotation-panel,
html.share-mode #btn-print,
html.share-mode .vw-fig-tool--gallery,
html.share-mode .gallery-link-wrap,
html.share-mode .gate-notice__btn,
html.share-mode .ad-slot { display: none !important; }

/* ================================================================
   教員の画面だけ：YouTube に上げるときの題と説明文（js/yt-meta-panel.js。2026-10-12，先生の指示
   「Youtube のタイトル説明文を教員の WEB アプリ解説ページで確認できる仕様にして」）
   ================================================================ */
.ytm-overlay {
  position: fixed; inset: 0; z-index: 30000;
  background: rgba(15, 23, 42, 0.42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; overflow-y: auto;
}
.ytm-panel {
  background: #fff; border-radius: 14px; width: 100%; max-width: 720px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28); overflow: hidden;
}
.ytm-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: #0f172a; color: #fff; font-weight: 700; font-size: 16px;
}
.ytm-x { border: 0; background: transparent; color: #fff; font-size: 18px; cursor: pointer; min-width: 40px; min-height: 40px; }
.ytm-body { padding: 14px 18px 16px; font-size: 15px; line-height: 1.7; color: #1e293b; }
.ytm-state { border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.ytm-state--pub { background: #dcfce7; color: #14532d; }
.ytm-state--wait { background: #fef3c7; color: #78350f; }
.ytm-state--none { background: #f1f5f9; color: #475569; }
.ytm-state a { color: inherit; font-weight: 700; margin-left: 6px; }
.ytm-label { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 700; font-size: 13px; color: #475569; }
.ytm-copy {
  border: 1px solid #cbd5e1; background: #f8fafc; border-radius: 8px; padding: 3px 10px;
  font-size: 13px; cursor: pointer; min-height: 32px;
}
.ytm-copy:hover { background: #e0f2fe; border-color: #7dd3fc; }
.ytm-title, .ytm-cur { margin-top: 4px; padding: 8px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid #e2e8f0; font-weight: 600; }
.ytm-cur { font-weight: 400; color: #475569; }
.ytm-desc {
  box-sizing: border-box;
  width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 8px; border: 1px solid #e2e8f0;
  background: #f8fafc; font: 14px/1.6 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif; resize: vertical;
}
.ytm-note { margin-top: 8px; font-size: 13px; color: #64748b; }
.ytm-foot { margin-top: 12px; font-size: 14px; }
.ytm-foot a { color: #0369a1; font-weight: 700; }
/* 公開した動画の URL の置き場（同じ日。「Youtube 動画公開した後の URL の置き場も分かりやすくして」） */
.ytm-url { margin: 4px 0 6px; padding: 10px 12px; border: 2px dashed #7dd3fc; border-radius: 10px; background: #f0f9ff; }
.ytm-url .ytm-label { margin-top: 0; color: #0369a1; font-size: 14px; }
.ytm-url-now { margin-top: 4px; font-size: 14px; }
.ytm-url-now a { color: #0369a1; font-weight: 700; word-break: break-all; }
.ytm-url-row { display: flex; gap: 8px; margin-top: 6px; }
.ytm-url-in { flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px; background: #fff; }
.ytm-url-btn { min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: #0284c7; color: #fff; font-weight: 700; cursor: pointer; }
.ytm-url-btn:disabled { opacity: 0.55; cursor: default; }
.ytm-url-msg { margin-top: 6px; font-size: 14px; font-weight: 700; }
.ytm-url-msg--ok { color: #15803d; }
.ytm-url-msg--ng { color: #c2410c; }

/* ================================================================
   縦の収録（ショート動画。1080×1920）。2026-10-14、先生の指示
     「やはり解説ページから仕上げる方針に変える、解説ページを踏まえてショート動画も作る方針にして、
       フォントのサイズやデザイン、シムの質も見直したいのでリードαの応用問題の動画を参考に作るようにしたい」
     → 版面は、応用問題の解説動画（横）と同じ作り（解説ページをそのまま撮る）。**縦のときだけ上下に積む**：
        上＝図（画面の 42%）・下＝本文（大きい字）。印は viewer-stage.js の markPortrait が付ける。
   横（1920×1080）の組みは、この下の規則では一切変えない。 */
html.expl-v2 body.rec-video.rec-portrait {
  --vid-area-w: calc(100vw - 24px);
  --vid-pad-x: 30px;
  --vid-fig-h: 42vh;                 /* viewer-stage.js の figBoxP と同じ値 */
  --vid-fig-top: calc(var(--vw-bar-h) + 16px);
}
html.expl-v2 body.rec-video.rec-portrait .explanation-area .card {
  /* 図のぶん（帯＋16＋図＋題の行 44＋間 22）を上に空け、本文はその下から。字はスマホで読める大きさに */
  font-size: 32px;
  line-height: 1.75;
  padding: calc(var(--vid-fig-top) + var(--vid-fig-h) + 66px) var(--vid-pad-x) 46vh var(--vid-pad-x);
}
html.expl-v2 body.rec-video.rec-portrait .card > .fig-steps > .fig-steps__fig {
  top: var(--vid-fig-top);
  left: 50%;
  right: auto;
  margin-left: calc(min(1000px, 100vw - 48px) / -2);     /* transform は JS（stage）が使うので、margin で中央に */
  width: min(1000px, calc(100vw - 48px));
}
/* 題の帯：縦では題を 2 行まで出し、タブは出さない（幅が足りない） */
body.rec-video.rec-portrait .vw-recbar__tabs { display: none !important; }
body.rec-video.rec-portrait .vw-recbar__title { max-width: 62vw; font-size: 1.35rem; }
body.rec-video.rec-portrait .vw-recbar__chapter { font-size: 1.2rem; }
/* 流れの帯（章）は、縦では字を小さめに（横の 120px だと 1080 幅に入らない） */
body.rec-portrait .vid-band { height: 260px; margin-top: -130px; }
body.rec-portrait .vid-band__tx { font-size: 92px; }
/* 段の印（いま話している段の左の棒）は、字が大きいぶん太く */
body.rec-mode.rec-portrait.rec-step .rec-now::after { left: -18px; width: 6px; }
