/* スマホでの受験を前提にしたレイアウト。
   タップ対象は最低 44px、文字は 16px 以上（iOS が勝手に拡大しないように）。 */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #63707f;
  --line: #d8dee6;
  --accent: #1c6fb8;
  --accent-ink: #ffffff;
  --ok: #1a7f4b;
  --ok-bg: #e6f4ec;
  --ng: #b3261e;
  --ng-bg: #fdeceb;
  --warn-bg: #fff5e0;
  --warn-line: #e0b055;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 14px 96px;
}

header.bar {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header.bar .inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
header.bar a { color: var(--accent-ink); }
header.bar .brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;      /* 狭い画面で講座名から先に詰まるように */
  flex: 1 1 auto;
}
header.bar .site { font-weight: 700; text-decoration: none; white-space: nowrap; }
/* アプリ名のうしろに出す「いまどこにいるか」 */
header.bar .ctx {
  font-size: 0.85rem;
  opacity: 0.9;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
header.bar .ctx::before { content: "｜"; opacity: 0.55; margin-right: 2px; }
/* 講座名は、その講座の回の一覧へ戻る入口にしてある */
header.bar a.ctx { text-decoration: none; }
header.bar a.ctx:hover, header.bar a.ctx:focus { text-decoration: underline; }
header.bar .who { font-size: 0.85rem; opacity: 0.9; }
/* 本番か練習かを示すバッジ。帯（sticky なのでスクロールしても消えない）と、
   提出ボタンの下で同じものを使う */
.mode {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.mode.prac { background: var(--warn-bg); color: var(--ink); }
.mode.honban { background: var(--ng-bg); color: var(--ng); }
header.bar .mode { margin-left: 4px; flex: 0 0 auto; }
h1 .mode { margin-left: 8px; vertical-align: 0.22em; }

h1 { font-size: 1.3rem; margin: 20px 0 6px; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; }
p.lead { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin: 0 0 14px;
}

.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card .meta { color: var(--muted); font-size: 0.85rem; }

/* --- ボタン --- */
.btn {
  display: inline-block;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.btn.wide { display: block; width: 100%; }
.btn.sub {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}
/* 本番は赤、練習は黄。解答画面の〔本番モード〕〔練習モード〕と同じ対応にして、
   色を見ただけでどちらのボタンか分かるようにする */
.btn.honban { background: var(--ng); color: #fff; }
.btn.prac { background: var(--warn-line); color: var(--ink); }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 0.9rem; }
/* 押せないボタンは色も抜いて灰色に寄せる。赤や黄のまま薄くしただけだと、
   押せるものとの差が分かりにくいため */
.btn[disabled] { opacity: 0.5; filter: grayscale(0.85); cursor: not-allowed; }

/* 学籍番号ログインと Google ログインの区切り */
.orline {
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* --- 入力 --- */
label.field { display: block; margin: 14px 0 0; font-weight: 700; }
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 0; line-height: 1.6; resize: vertical; }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* 設問ごとの取引一覧（補助簿・伝票）。紙の問題と同じ（1）（2）…で並べる */
.qlines {
  margin: 0 0 8px;
  padding-left: 1.9em;
  font-size: 0.95rem;
}
.qlines li { margin-bottom: 2px; }
/* 紙の問題と同じ（1）（2）…にそろえる */
.qlines li::marker { color: var(--muted); content: "（" counter(list-item) "）"; }

/* --- テスト公開中の断り書き（ログイン画面の下）。
       .notice は教員側の赤い注意書きなので、別の名前にしてある --- */
.trialnote {
  margin: 24px 0 0;
  padding: 12px 14px;
  border: 2px solid var(--warn-line);
  border-radius: 10px;
  background: var(--warn-bg);
}
.trialnote b { display: block; margin-bottom: 4px; }
.trialnote p { margin: 0; font-size: 0.9rem; }

/* --- 公開ページ（プライバシーポリシー・利用規約）の本文 --- */
.doc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 18px 18px;
  margin-top: 14px;
}
.doc h2 { font-size: 1rem; margin: 22px 0 4px; }
.doc p, .doc ul { margin: 0 0 8px; font-size: 0.95rem; }
.doc ul { padding-left: 1.2em; }

/* --- 設問 --- */
.q { margin-bottom: 16px; }
.q .qhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.q .qlabel { font-weight: 700; }
.q .qpoints { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.q .qtext { margin: 0 0 6px; }
.q .qnote {
  background: var(--warn-bg);
  border-left: 3px solid var(--warn-line);
  padding: 6px 10px;
  margin: 8px 0;
  font-size: 0.9rem;
}

/* 仕訳の入力欄。紙の答案と同じく、左が借方・右が貸方。 */
.journal {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.jhead {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #eef2f6;
  border-bottom: 1px solid var(--line);
}
.jhead span {
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.jhead span + span { border-left: 1px solid var(--line); }

.jrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.jrow + .jrow { border-top: 1px dashed var(--line); }

.side {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
}
.side + .side { border-left: 1px solid var(--line); }
.side .sidelabel { display: none; }   /* 見出し行があるので不要 */
.side select, .side input { margin-top: 0; }

/* 採点結果に出す、読むだけの仕訳 */
.journal.read { margin-top: 4px; }
.journal.read .side { min-height: 40px; }
.journal.read .amt { text-align: right; }
.journal.read .blank { color: var(--muted); }

/* 画面が狭いときは、借方の下に貸方を置く */
@media (max-width: 620px) {
  .jhead { display: none; }
  .jrow { grid-template-columns: 1fr; }
  .side {
    grid-template-columns: 2.9rem minmax(0, 1.15fr) minmax(0, 1fr);
  }
  /* 図は横スクロールにせず画面幅に収める。ただの縮小だと文字が読めなくなるので、
     図の中の文字と線だけを太らせる（SVG は viewBox 基準なので、これで
     縮小されたあとの見かけの大きさがもとに戻る） */
  .figbox .fig-title { font-size: 30px; }
  .figbox .fig-side { font-size: 24px; }
  .figbox .fig-num { font-size: 34px; }
  .figbox .fig-box { stroke-width: 3.5; }
  .figbox .fig-rule { stroke-width: 3; }

  .side + .side { border-left: 0; border-top: 1px dotted var(--line); }
  .side .sidelabel {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
  }
}

.numrow { display: flex; align-items: center; gap: 8px; }
.numrow input { flex: 1; text-align: right; }
.numrow .unit { color: var(--muted); white-space: nowrap; }

/* 選択肢 */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label {
  flex: 1 1 auto;
  min-width: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}
.choices input { position: absolute; opacity: 0; }
.choices input:checked + span { font-weight: 700; }
.choices label:has(input:checked) {
  border-color: var(--accent);
  background: #e8f1fa;
}

/* 語群 */
.wordbank {
  background: #eef2f6;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.wordbank b { display: block; margin-bottom: 4px; }

/* --- 結果 --- */
.verdict {
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}
.verdict.pass { background: var(--ok-bg); border: 2px solid var(--ok); }
.verdict.fail { background: var(--ng-bg); border: 2px solid var(--ng); }
.verdict .big { font-size: 2rem; font-weight: 700; display: block; }
.verdict.pass .big { color: var(--ok); }
.verdict.fail .big { color: var(--ng); }
/* 練習は合否を出さないので、合格・不合格とは別の色にする */
.verdict.practice { background: #eef3f8; border: 2px solid var(--accent); }
.verdict.practice .big { color: var(--accent); }
.verdict .score { font-size: 1.1rem; }
/* 提出日時は得点のすぐ下に置く（ページ末尾だと目に入らない） */
.verdict .when {
  display: block;
  margin: 6px 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.q.correct { border-left: 4px solid var(--ok); }
.q.wrong { border-left: 4px solid var(--ng); }
.tag { font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
/* 受講者へのメッセージ。教員が入れた改行をそのまま出す */
.meta.msg { white-space: pre-line; }

/* 講座の一覧に出す「自分のこれまで」。数字を大きく出して、
   何回やったかが目に入るようにする（練習は0回でも出す） */
.mystat { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.mystat .stat {
  flex: 1 1 160px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
.mystat .lbl { display: block; font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.mystat b { display: block; font-size: 1.3rem; line-height: 1.35; }
.mystat b a { color: inherit; }
.mystat .sub { display: block; font-size: 0.78rem; color: var(--muted); }
.mystat .stat.ok { background: var(--ok-bg); border-color: var(--ok); }
.mystat .stat.ok .lbl { color: var(--ok); }
.mystat .stat.ng { background: var(--ng-bg); border-color: var(--ng); }
.mystat .stat.ng .lbl { color: var(--ng); }
.mystat .stat.prac b { color: var(--accent); }
.mystat .stat.yet b { color: var(--muted); }

/* 講座の一覧の見出し。回を10件ぶんスクロールしても講座名が消えないように、
   帯のすぐ下へ貼り付ける（左右は .wrap の余白ぶん外へ広げて背景を敷く） */
.pagehead {
  position: sticky;
  top: var(--barh, 52px);
  z-index: 4;
  background: var(--bg);
  margin: 0 -14px;
  padding: 8px 14px 6px;
  box-shadow: 0 8px 10px -10px rgba(0, 0, 0, 0.45);
}
.pagehead h1 { margin-top: 0; }
.pagehead .lead { margin-bottom: 0; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.ng { background: var(--ng-bg); color: var(--ng); }
/* 止まっている状態。間違いではないので赤にはせず、灰色で控えめに出す */
.tag.off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
/* 講座設定のカードの見出しに、いまの受付状態を札で添える */
.cardhead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.cardhead h3 { margin: 0; }
.answerbox { font-size: 0.95rem; margin-top: 8px; }
.answerbox dt { color: var(--muted); font-size: 0.82rem; margin-top: 6px; }
.answerbox dd { margin: 2px 0 0; }
/* 間違えたときは「あなたの解答」と「正解」が続けて並ぶ。文字だけだと
   どちらを覚えればよいのか分かりにくいので、塗り分けて見分けられるようにする */
.answerbox dt.ans-ok, .answerbox dt.ans-ng { font-weight: 700; }
.answerbox dt.ans-ok { color: var(--ok); }
.answerbox dt.ans-ng { color: var(--ng); }
.answerbox dd.ans-ok, .answerbox dd.ans-ng {
  padding: 8px 10px;
  border-radius: 8px;
  border-left: 3px solid transparent;
}
.answerbox dd.ans-ok { background: var(--ok-bg); border-left-color: var(--ok); }
.answerbox dd.ans-ng { background: var(--ng-bg); border-left-color: var(--ng); }
.explain {
  background: #eef2f6;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* --- T字勘定（総勘定元帳） --- */
table.taccount { min-width: 34rem; }
table.taccount thead tr:first-child th { text-align: center; }
/* 4列目から貸方。境目に縦罫を入れて左右を分ける */
table.taccount th:nth-child(4),
table.taccount td:nth-child(4) { border-left: 2px solid var(--line); }
table.taccount thead tr:first-child th:nth-child(2) { border-left: 2px solid var(--line); }
table.taccount td { padding: 5px 8px; }
table.taccount td.blank { background: transparent; }
table.taccount input, table.taccount select { min-height: 38px; margin-top: 0; }
table.taccount input.date { min-width: 4.5rem; }
table.taccount td:nth-child(2) select,
table.taccount td:nth-child(5) select { min-width: 7.5rem; }
table.taccount input.amount { min-width: 6rem; text-align: right; }

/* --- 表形式の設問（試算表・精算表・仕訳帳） --- */
table.gridq { min-width: 100%; }
table.gridq th {
  white-space: normal;
  min-width: 5.5rem;
  text-align: center;
  line-height: 1.4;
}
table.gridq td { padding: 5px 8px; }
table.gridq td.given { background: #eef2f6; text-align: right; }
table.gridq td.given:first-child { text-align: left; }
/* 日付や摘要のように数字でない欄は左そろえ（補助簿・伝票） */
table.gridq td.given.txt { text-align: left; }
/* 表の中の勘定科目のプルダウン */
table.gridq select { min-height: 38px; min-width: 7rem; margin-top: 0; }
table.gridq input {
  min-height: 38px;
  min-width: 5.5rem;
  margin-top: 0;
  text-align: right;
}
/* --- 埋め込んだ図（SVG） --- */
.figbox svg {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 0 auto;
}
.fig-box { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.fig-inner { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 6 4; }
.fig-rule { stroke: var(--ink); stroke-width: 2; }
.fig-title {
  fill: var(--ink); font-size: 20px; font-weight: 700; text-anchor: middle;
}
.fig-side { fill: var(--muted); font-size: 14px; text-anchor: middle; }
.fig-num {
  fill: var(--accent); font-size: 24px; font-weight: 700; text-anchor: middle;
}
.fig-arrow { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.fig-arrowhead { fill: var(--accent); stroke: none; }

/* 財務諸表の図（貸借対照表・損益計算書の箱組み） */
/* 列が多くて横スクロールになる表は、左の何列かを貼り付けたままにする。
   精算表は勘定科目と試算表の3列が流れると、どの行を書いているのか見失うため。
   貼り付ける列は下の背景色が要る（透けると下の欄が透けて見える）ので、
   テンプレート側では「記入済み（text）の列」だけを freeze_columns に指定すること。
   border-collapse: collapse のままだと貼り付けた列の罫線が消えるので separate に替える。 */
table.gridq.freeze1, table.gridq.freeze2, table.gridq.freeze3 {
  border-collapse: separate;
  border-spacing: 0;
}
table.gridq[class*="freeze"] th:nth-child(1),
table.gridq[class*="freeze"] td:nth-child(1) {
  position: sticky; left: 0; z-index: 2;
  width: 9.5rem; min-width: 9.5rem;
}
table.gridq.freeze2 th:nth-child(2), table.gridq.freeze2 td:nth-child(2),
table.gridq.freeze3 th:nth-child(2), table.gridq.freeze3 td:nth-child(2) {
  position: sticky; left: 9.5rem; z-index: 2;
  width: 6.5rem; min-width: 6.5rem;
}
table.gridq.freeze3 th:nth-child(3), table.gridq.freeze3 td:nth-child(3) {
  position: sticky; left: 16rem; z-index: 2;
  width: 6.5rem; min-width: 6.5rem;
}
/* 貼り付けた列の右端に境目を出す。罫線ではなく影にするのは、
   横に動かしても消えないようにするため */
table.gridq.freeze1 th:nth-child(1), table.gridq.freeze1 td:nth-child(1),
table.gridq.freeze2 th:nth-child(2), table.gridq.freeze2 td:nth-child(2),
table.gridq.freeze3 th:nth-child(3), table.gridq.freeze3 td:nth-child(3) {
  box-shadow: 2px 0 3px -1px rgba(0, 0, 0, 0.18);
}

/* 採点済みの表。左端に○×の列が増えるので、貼り付けるのは○×と勘定科目の2列だけ */
table.gridq.freezeread { border-collapse: separate; border-spacing: 0; }
/* ○×の列だけは元の色が付いていないので、貼り付けるために下地を敷く
   （透けたままだと、横に動かしたとき数字が透けて見える） */
table.gridq.freezeread th:nth-child(1), table.gridq.freezeread td:nth-child(1) {
  position: sticky; left: 0; z-index: 2;
  background: var(--card);
}
table.gridq.freezeread th:nth-child(2), table.gridq.freezeread td:nth-child(2) {
  position: sticky; left: 3.2rem; z-index: 2;
  width: 9.5rem; min-width: 9.5rem;
  box-shadow: 2px 0 3px -1px rgba(0, 0, 0, 0.18);
}

table.gridq.diagram { min-width: 22rem; }
table.gridq.diagram th { text-align: center; }
table.gridq.diagram td.given {
  text-align: center;
  padding: 22px 10px;
  width: 50%;
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 1.05rem;
}

table.gridq td.mark, table.gridq th.mark {
  min-width: 3.2rem;
  width: 3.2rem;
  text-align: center;
  font-weight: 700;
}
table.gridq td.mark .pts {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
}
table.gridq tr.rowng td.mark { color: var(--ng); }
table.gridq td.cellng { background: var(--ng-bg); }
table.gridq .want {
  display: block;
  color: var(--ok);
  font-weight: 700;
  font-size: 0.82rem;
}

/* --- 表（教員画面） --- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
th { background: #eef2f6; font-size: 0.82rem; }
td.num, th.num { text-align: right; }
tr.fail td { background: #fdf6f6; }
/* 名簿にいて答案の無い学生。目立たせすぎず、見落とさない濃さにする */
tr.absent td { background: #f4f6f8; color: var(--muted); }
/* 同じ端末から2人以上が出した行。不合格の色より優先させたいので後ろに置く */
tr.shared td { background: var(--warn-bg); }

/* 端末ID（先頭6文字）。数字と英字を見分けやすい等幅で出す */
.dev {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--muted);
}
.dev.warn {
  color: var(--ink);
  font-weight: 700;
  background: #fff;
  border: 1px solid var(--warn-line);
  border-radius: 4px;
  padding: 1px 5px;
}

.flash {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 14px 0;
}
.notice {
  background: var(--ng-bg);
  border: 1px solid var(--ng);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 14px 0;
  font-size: 0.9rem;
}

.submitbar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(244, 246, 248, 0));
  padding: 14px 0 18px;
}

/* --- 資料を上に貼り付け、解答欄だけをスクロールさせる（第4回） --- */
.stickyhead {
  position: sticky;
  top: var(--barh, 52px);
  z-index: 6;
  background: var(--bg);
  padding-top: 10px;
  max-height: 46vh;
  overflow: auto;
  box-shadow: 0 8px 12px -10px rgba(0, 0, 0, 0.5);
}
/* 貼り付けた資料は画面を占領しすぎないよう、行間を詰めて表示する */
.stickyhead .card { padding: 10px 12px; margin-bottom: 8px; }
.stickyhead .card h3 { margin: 0 0 4px; font-size: 0.92rem; }
.stickyhead table.gridq td,
.stickyhead table.gridq th,
.stickyhead table.taccount td,
.stickyhead table.taccount th { padding: 3px 8px; }

/* 解答欄を下に貼り付ける回では、ページ末尾の余白を詰める */
body:has(.stickyfoot) .wrap { padding-bottom: 12px; }

/* --- 逆に解答欄を下に貼り付け、資料をスクロールさせる（第5回） --- */
.stickyfoot {
  position: sticky;
  bottom: 0;
  z-index: 6;
  background: var(--bg);
  box-shadow: 0 -8px 12px -10px rgba(0, 0, 0, 0.5);
}
.stickyfoot .sf-body {
  max-height: 52vh;
  overflow: auto;
  padding-top: 10px;
}
/* 貼り付けた解答欄も、資料が見える高さを残すために詰めて表示する */
.stickyfoot .sf-body .card { margin-bottom: 8px; padding: 10px 12px; }
.stickyfoot table.gridq td,
.stickyfoot table.gridq th { padding: 3px 8px; }
.stickyfoot .qnote { margin: 4px 0; padding: 4px 8px; }
.stickyfoot .submitbar { position: static; padding: 6px 0 12px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > * { margin-top: 0; }
.spacer { flex: 1; }
.pill { background: #eef2f6; border-radius: 999px; padding: 2px 10px; font-size: 0.82rem; color: var(--muted); }
a { color: var(--accent); }
/* 講座の設定画面の「設定を保存」。回が10件並ぶので、下に貼り付けて
   どこまでスクロールしても押せるようにする */
.savebar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: 16px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.08);
}
/* 貼り付けたバーに複数のボタンを並べるとき（採点結果の画面） */
.savebar .row { justify-content: center; }

footer { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 20px 0; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b21;
    --card: #1e252d;
    --ink: #e8edf2;
    --muted: #9aa7b4;
    --line: #333d47;
    --accent: #4f9fe0;
    --accent-ink: #0d1319;
    --ok: #5fd39b;
    --ok-bg: #16321f;
    --ng: #f08a80;
    --ng-bg: #3a1c1a;
    --warn-bg: #33291a;
    --warn-line: #a8802f;
  }
  input[type="text"], input[type="password"], input[type="number"], select,
  .btn.sub, .choices label { background: #131920; color: var(--ink); }
  .choices label:has(input:checked) { background: #1d3550; }
  .wordbank, .explain, th, .jhead,
  table.gridq td.given { background: #232c35; }
  table.taccount input, table.taccount select,
  table.gridq input { background: #131920; color: var(--ink); }
  tr.fail td { background: #2a1e1e; }
  tr.absent td { background: #1b222a; }
}

/* --- MotoLab のトップページ（templates/portal.html だけが使う） --- */
body.portal { background: var(--bg); }
.phead {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 34px 16px 30px;
  text-align: center;
}
.phead .logo {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.phead .sub { margin: 6px 0 0; font-size: 0.9rem; opacity: 0.9; }
.plead { color: var(--muted); margin: 22px 0 18px; text-align: center; }

.pcard {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 14px;
  color: inherit;
  text-decoration: none;
}
a.pcard:hover { border-color: var(--accent); background: #fbfdff; }
.pcard h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pcard p { margin: 0; font-size: 0.95rem; }
.pcard .pmeta { margin-top: 8px; color: var(--muted); font-size: 0.85rem; }
.pcard .parrow { color: var(--accent); font-weight: 700; }
/* まだ中身が無いもの。押せないことが見て分かる濃さにする */
.pcard.soon { border-left-color: var(--line); color: var(--muted); }
.pcard .ptag {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.pfoot {
  margin: 34px 0 24px;
  padding: 0 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}
.pfoot p { margin: 6px 0; }
