:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e3e6eb;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --done: #1a7f4b;
  --danger: #c0392b;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e7e9ee;
    --muted: #9aa3b2;
    --line: #2c323d;
    --accent: #4c8dff;
    --accent-text: #0b1220;
    --done: #3fb27f;
    --danger: #ff6b5e;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.topnav { display: flex; gap: 16px; align-items: center; font-size: 14px; }
.topnav a { color: var(--text); text-decoration: none; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }

.app { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.center { text-align: center; }
.muted { color: var(--muted); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }

/* カード・フォーム */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.narrow { max-width: 420px; margin: 24px auto; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; padding: 10px 12px; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 11px 16px; font-size: 15px; font-weight: 600; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-text);
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.auto { width: auto; }
.btn.done { background: var(--done); color: #fff; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.links { margin-top: 16px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.msg.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.msg.ok { background: color-mix(in srgb, var(--done) 12%, transparent); color: var(--done); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* コース一覧 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.course {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.course:hover { border-color: var(--accent); }
.thumb { aspect-ratio: 16 / 9; background: var(--line) center / cover no-repeat; }
.course .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.course .title { font-weight: 700; }
.course .desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--done); }
.count { font-size: 12px; color: var(--muted); }

/* レッスン画面 */
.lesson-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 72px; }
.side-head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.side-head .title { font-weight: 700; font-size: 15px; }
.side ol { list-style: none; margin: 0; padding: 0; max-height: 65vh; overflow-y: auto; }
.side li a {
  display: flex; gap: 10px; padding: 10px 16px; color: var(--text); text-decoration: none; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.side li a.current { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 600; }
.mark { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); margin-top: 2px; }
.mark.on { background: var(--done); border-color: var(--done); position: relative; }
.mark.on::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-main h1 { margin-top: 18px; }
.lesson-body { white-space: pre-wrap; word-break: break-word; margin: 0 0 20px; }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0 24px; }
.pager { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; }

@media (max-width: 800px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .side { position: static; order: 2; }
  .side ol { max-height: none; }
  .topnav { gap: 12px; font-size: 13px; }
  .card { padding: 20px 16px; }
}
