:root {
  --bg: #eef3ec;            /* ごく淡い若草（本人の指定）。黒板の緑とボタンの緑に合わせる */
  --panel: #fffefb;
  --ink: #24211d;
  --muted: #6f6a62;
  --line: #e2ded6;
  --accent: #3d6b5e;
  --now: #e6eeea;            /* いま観ている場面の行 */
  --shadow: 0 2px 14px rgba(60, 52, 40, .07);
}
/* 科目ごとの色（app.py の COURSE_THEME）。臨床心理査定学実習Iは青（本人の指定）。講義IIIと教員の一覧は緑のまま */
body.theme-blue {
  --bg: #ecf1f7;
  --accent: #3a5a86;
  --now: #e3eaf4;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* flex などの指定に負けて隠れないのを防ぐ */
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.75; font-size: 15px;
}
a { color: inherit; }
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar .home { font-weight: 600; text-decoration: none; letter-spacing: .04em; }
.bar .tools { display: flex; gap: 8px; }
@media (hover: none) { .bar .drop { display: none; } }   /* スマホ・タブレットには窓が無い */
.bar .out {                              /* ボタンに見えるように（小さな文字のリンクだと気づかれなかった） */
  color: var(--ink); text-decoration: none; font-size: 13px;
  padding: 7px 14px; border: 1px solid var(--muted); border-radius: 8px; background: #fff;
}
.bar .out:hover { background: #f1eee7; }
main { max-width: 1040px; margin: 0 auto; padding: 22px 18px 60px; }
main > h1, .head-row h1 { font-size: 17px; margin: 0 0 14px; font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px; box-shadow: var(--shadow);
}
.narrow { max-width: 380px; margin: 8vh auto; }
.card h1 { font-size: 20px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #9b3d33; font-size: 13px; }

input[type=password] {
  width: 100%; padding: 11px 12px; font-size: 16px; margin: 14px 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
button {
  font: inherit; padding: 10px 18px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.card button { width: 100%; background: var(--accent); color: #fff; border-color: transparent; }

.list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.thumb { flex: 0 0 148px; border-radius: 8px; overflow: hidden; line-height: 0; }
.thumb img { width: 148px; height: 84px; object-fit: cover; }
.thumb.blank { width: 148px; height: 84px; background: #ece8e0; border-radius: 8px; }
.meta { min-width: 0; }
.ttl { font-weight: 600; text-decoration: none; }
.ttl.plain { color: var(--muted); }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.watch { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.watch.solo { grid-template-columns: minmax(0, 860px); justify-content: center; }   /* 学生：文字起こしの枠なしで1列 */
.player video {
  /* 縦向きで撮られた動画が画面を埋め尽くさないように高さを抑える */
  width: auto; max-width: 100%; max-height: 68vh; display: block;
  border-radius: 12px; background: #000; box-shadow: var(--shadow);
}
/* 字幕：帯を敷かず，白い角ゴにぼかした縁をつける（映画字幕の作法）。
   黒板の上でも白い壁や教卓の上でも読めるよう，縁は3段に重ねる */
.player video::cue {
  font: 600 1.22em/1.5 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: #fff;
  background: transparent;
  text-shadow: 0 0 2px rgba(0, 0, 0, .95), 0 0 4px rgba(0, 0, 0, .8), 0 1px 8px rgba(0, 0, 0, .6);
}
/* スマホ：短く分けた字幕に差し替えたうえで，字を約1.5倍に（縦持ちだと約12pxで小さい） */
@media (max-width: 600px) {
  .phone-subs .player video::cue { font-size: 1.85em; }
}
.player h1.top { font-size: 19px; margin: 0 0 2px; }
.player .sub { margin: 0 0 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; }
.switch { display: inline-flex; }
.switch button { border-radius: 0; }
.switch button:first-child { border-radius: 8px 0 0 8px; }
.switch button:last-child { border-radius: 0 8px 8px 0; }
.switch button + button { border-left: none; }
.switch button.on { background: var(--accent); color: #fff; border-color: transparent; }

.keep { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.keep button { font-size: 13px; padding: 7px 14px; }
.keep button.on { background: var(--accent); color: #fff; border-color: transparent; }

.transcript {
  /* 位置の基準にする。これが無いと，今の行を追う自動送りが
     ページ全体からの距離で計算されてずれる */
  position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 8px 14px 14px; max-height: 72vh; overflow-y: auto;
  box-shadow: var(--shadow);
}
.transcript ol { list-style: none; margin: 8px 0 0; padding: 0; }
.follow {
  position: sticky; bottom: 6px; left: 50%; font-size: 12px; padding: 6px 12px;
  box-shadow: var(--shadow); background: var(--panel);
}
.transcript li {
  display: flex; gap: 10px; padding: 6px 8px; border-radius: 7px; cursor: pointer;
}
.transcript li:hover { background: #f1eee7; }
.transcript li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.transcript li.now { background: var(--now); }
.transcript .t { color: var(--muted); font-size: 12px; padding-top: 4px; flex: 0 0 44px; font-variant-numeric: tabular-nums; }

.chapters { margin-top: 18px; }
.chapters h2 { font-size: 14px; margin: 0 0 6px; font-weight: 600; }
.chapters ol { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line, #e3ded4); }
.chapters button {
  display: flex; gap: 12px; width: 100%; text-align: left; border: none; border-radius: 0;
  border-bottom: 1px solid var(--line, #e3ded4); background: transparent; padding: 9px 6px;
}
.chapters button:hover { background: #f1eee7; }
.chapters button.now { background: var(--now); }
.chapters .t { color: var(--muted); font-size: 13px; flex: 0 0 56px; font-variant-numeric: tabular-nums; }
.chap-edit { margin-top: 16px; }
.chap-edit summary { cursor: pointer; font-size: 13px; }
.chap-edit textarea {
  display: block; width: 100%; margin: 8px 0; padding: 8px 10px; font: inherit; font-size: 14px;
  border: 1px solid var(--muted); border-radius: 8px; background: #fff;
}
.chap-edit button { font-size: 13px; padding: 7px 14px; }

.head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.back { margin: 0 0 8px; }
.back a, .head-row a { color: var(--accent); }
.toc { margin-top: 22px; }
.toc h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
.toc-item { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.toc-item h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.toc-item h3 a { text-decoration: none; }
.toc-item ol { list-style: none; margin: 0; padding: 0; }
.toc-item li a { display: flex; gap: 12px; padding: 6px 4px; text-decoration: none; border-top: 1px solid var(--line); }
.toc-item li a:hover { background: #f1eee7; }
.toc-item .t { color: var(--muted); font-size: 13px; flex: 0 0 56px; font-variant-numeric: tabular-nums; }

.comment { margin-top: 18px; }
.comment label { font-weight: 600; font-size: 14px; }
.comment p { margin: 4px 0 6px; }
.comment textarea {
  display: block; width: 100%; padding: 8px 10px; font: inherit; font-size: 15px;
  border: 1px solid var(--muted); border-radius: 8px; background: #fff;
}
.comment-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.comment-row button { font-size: 14px; padding: 8px 18px; }
.comment-row button[type=submit], .comment-row button.primary { background: var(--accent); color: #fff; border-color: transparent; }
.comment-confirm { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.comment-confirm p { margin: 0 0 8px; }
.confirm-body { white-space: pre-wrap; line-height: 1.7; }
.comments { list-style: none; margin: 0; padding: 0; }
.comments li { border-top: 1px solid var(--line); padding: 10px 2px; }
.comments .meta { margin: 0 0 4px; }
.comments .body { margin: 0; white-space: pre-wrap; line-height: 1.7; }

@media (max-width: 780px) {
  .watch { grid-template-columns: 1fr; }
  .keep { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.keep button { font-size: 13px; padding: 7px 14px; }
.keep button.on { background: var(--accent); color: #fff; border-color: transparent; }

.transcript { max-height: 48vh; }
  .thumb, .thumb img, .thumb.blank { flex-basis: 108px; width: 108px; height: 61px; }
}
