:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --text: #1f1e1c;
  --muted: #6b6862;
  --line: #e4e1da;
  --accent: #c2410c;
  --accent-soft: #fdf1ea;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

a { color: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }

.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.site-title { font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav { display: flex; gap: 18px; font-size: 14px; }
.site-nav a { color: var(--text); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }
.site-nav .muted { color: var(--muted); }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 32px; }

/* 目次 */
.intro { padding: 40px 0 8px; }
.intro h1 { font-size: 28px; margin: 0 0 12px; }
.intro p { margin: 0 0 6px; color: var(--muted); max-width: 46em; }

.filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.filter a {
  padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--text); text-decoration: none; font-size: 14px;
}
.filter a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress { margin-left: auto; color: var(--muted); font-size: 14px; }

.chapter { margin-top: 28px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chapter h2 { font-size: 20px; margin: 0; }
.chapter h2 a { color: var(--text); text-decoration: none; display: flex; align-items: baseline; gap: 10px; }
.chapter h2 a:hover { color: var(--accent); }
.chapter-meta { display: flex; gap: 6px; }
.chapter-no { color: var(--accent); font-size: 15px; font-weight: 700; }
.chapter-lead { margin: 4px 0 12px; color: var(--muted); font-size: 14px; }

.item-rows { display: flex; flex-direction: column; }
.item-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 8px;
  border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.item-row:hover { background: #f7f6f3; }
.item-no { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 2ch; }
.item-title { font-weight: 500; }
.item-time { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; font-weight: 500; }
.badge.star { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.badge.ready { color: var(--text); }
.badge.watched { color: var(--text); background: #efede8; }
h1 .badge { font-size: 13px; vertical-align: middle; }

/* 動画ページ */
.crumbs { font-size: 14px; color: var(--muted); padding: 20px 0 8px; }
.crumbs a { color: var(--muted); }

.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }

.video h1 { font-size: 24px; line-height: 1.5; margin: 0 0 16px; }
.video-no { color: var(--accent); margin-right: 12px; font-variant-numeric: tabular-nums; }
.video > .chapter-lead { margin: 12px 0 0; }

.item { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 8px; }
.item h2 { font-size: 19px; line-height: 1.5; margin: 0 0 10px; }
.play-row { margin: 0 0 12px; }
.play-from {
  font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 0; background: var(--accent); color: #fff;
}

.player { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--surface); border: 1px dashed #cfcac0;
}
.player.placeholder div { display: flex; flex-direction: column; gap: 4px; padding: 16px; }
.player.placeholder span { color: var(--muted); font-size: 14px; }

.watch-row { margin-top: 10px; display: flex; justify-content: flex-end; }
.watch-toggle {
  font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.watch-toggle.on { background: #efede8; }

.points { margin: 0; padding-left: 1.3em; }
.points li { margin-bottom: 6px; }

.table-wrap { margin: 24px 0 0; }
.table-wrap figcaption { font-weight: 700; margin-bottom: 8px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.6; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { background: #f2f0eb; white-space: nowrap; }
tbody th { font-weight: 600; min-width: 8em; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }

.note { margin-top: 20px; padding: 12px 16px; border-radius: var(--radius); background: #f2f0eb; color: var(--muted); font-size: 14px; }

.desktop { margin-top: 20px; padding: 16px 20px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; }
.desktop h3 { margin: 0 0 4px; font-size: 15px; color: var(--accent); }
.desktop p { margin: 0; }

.links { margin-top: 20px; }
.button { display: inline-block; padding: 8px 16px; border-radius: 8px; background: var(--accent); color: #fff; text-decoration: none; font-size: 14px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; }
.pager a {
  display: flex; flex-direction: column; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.5;
}
.pager a span { color: var(--muted); font-size: 12px; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; }

.side { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.side h2 { font-size: 14px; margin: 0 0 8px; }
.side ol { list-style: none; margin: 0; padding: 0; }
.side li a { display: flex; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.5; }
.side li a span { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.side li a em { font-style: normal; flex: 1; }
.side li a time { color: var(--muted); font-variant-numeric: tabular-nums; }
.side li a:hover { background: #f2f0eb; }

/* ログイン */
.login { max-width: 360px; margin: 80px auto; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 20px; margin: 0; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.login button { font: inherit; padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
.login .error { color: #b91c1c; }

@media (max-width: 860px) {
  .video-layout { grid-template-columns: 1fr; }
  .side { position: static; }
}
@media (max-width: 560px) {
  .site-header { padding: 12px 16px; }
  .intro h1 { font-size: 23px; }
  .progress { margin-left: 0; width: 100%; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}
