/* サンホーク 理論学習 ― 画面のデザイン（ライト／ダーク対応） */
:root {
  --bg: #eef1f6;
  --bg-2: #e4e9f2;
  --card: #ffffff;
  --card-2: #f6f8fb;
  --text: #16203a;
  --text-2: #4b5674;
  --muted: #8a93a8;
  --line: #e3e7ef;
  --brand: #1b2a4a;
  --brand-2: #2d4a8a;
  --brand-3: #4f73d9;
  --brand-grad: linear-gradient(135deg, #1b2a4a 0%, #2d4a8a 60%, #4f73d9 100%);
  --gold: #d9b24a;
  --ok: #1f9d55;
  --ok-bg: #e3f6eb;
  --mid: #c47d0a;
  --mid-bg: #fff2d6;
  --none: #a4acbf;
  --none-bg: #eef1f6;
  --danger: #d03b3b;
  --shadow: 0 1px 2px rgba(22,32,58,.05), 0 8px 24px -12px rgba(22,32,58,.18);
  --shadow-lg: 0 20px 50px -20px rgba(22,32,58,.35);
  --r: 18px;
  --r-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420; --bg-2: #141b2b; --card: #182033; --card-2: #1f293f;
    --text: #e9edf6; --text-2: #b7c0d6; --muted: #7f8aa6; --line: #27304a;
    --brand-grad: linear-gradient(135deg, #223562 0%, #2f4f93 60%, #4f73d9 100%);
    --ok-bg: #153a27; --mid-bg: #3d2d0e; --none-bg: #202a40; --none: #6c7691;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 24px 60px -24px rgba(0,0,0,.8);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Segoe UI", sans-serif;
  font-size: 15.5px; line-height: 1.55; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { background-image: radial-gradient(1200px 500px at 50% -200px, rgba(79,115,217,.14), transparent 70%); background-attachment: fixed; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 48px 16px; }
.small { font-size: 12.5px; }
.right { text-align: right; }

/* ヘッダー */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: rgba(27,42,74,.92); color: #fff;
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); }
.top .brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.top .brand img { width: 30px; height: 30px; border-radius: 9px; background: #fff; }
.top .title { font-weight: 700; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.top .sub { font-size: 11.5px; opacity: .75; display: block; }
.top button { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; padding: 6px 13px; cursor: pointer; transition: background .15s; }
.top button:hover { background: rgba(255,255,255,.22); }
.top button.icon { border: none; background: transparent; font-size: 24px; line-height: 1; padding: 0 8px 0 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #1b2a4a; font-weight: 800; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.badge-off { background: var(--gold); color: #1b2a4a; font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }

.wrap { max-width: 820px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-bottom)); }
.wrap.wide { max-width: none; }

.card { background: var(--card); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h2 { font-size: 16px; margin: 0 0 10px; letter-spacing: .01em; }
.card h3 { font-size: 14.5px; margin: 0; }

/* ヒーロー（全体の進み） */
.hero { background: var(--brand-grad); color: #fff; border: none; border-radius: 22px; padding: 18px 20px; display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero .ring { flex: none; width: 84px; height: 84px; position: relative; }
.hero .ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.hero .ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 19px; }
.hero .h-body { flex: 1; min-width: 0; z-index: 1; }
.hero .h-title { font-size: 12.5px; opacity: .8; letter-spacing: .06em; text-transform: uppercase; }
.hero .h-main { font-size: 22px; font-weight: 800; margin: 2px 0 2px; }
.hero .h-main b { font-size: 30px; }
.hero .h-sub { font-size: 12.5px; opacity: .85; }
.hero .h-cta { margin-top: 10px; display: inline-flex; align-items: center; gap: 8px; background: #fff; color: var(--brand); border: none; border-radius: 999px; padding: 8px 14px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 18px -8px rgba(0,0,0,.5); transition: transform .12s; }
.hero .h-cta:hover { transform: translateY(-1px); }

/* コース切替 */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 999px; padding: 4px; margin: 2px 0 14px; gap: 2px; }
.seg button { border: none; background: transparent; border-radius: 999px; padding: 7px 16px; cursor: pointer; color: var(--text-2); font-weight: 600; transition: all .15s; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.seg button .lock { font-size: 11px; margin-left: 4px; opacity: .7; }

/* 進捗バー */
.bar { height: 8px; background: var(--none-bg); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand-3)); border-radius: 999px; transition: width .35s ease; }
.bar.done > i { background: var(--ok); }
.hero .bar { background: rgba(255,255,255,.22); }
.hero .bar > i { background: #fff; }

/* 章 */
.chapter { margin-bottom: 14px; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.chapter .head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; cursor: pointer; user-select: none; }
.chapter .head:hover { background: var(--card-2); }
.chapter .cnum { width: 34px; height: 34px; border-radius: 11px; background: var(--brand-grad); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; font-size: 15px; }
.chapter .ctext { flex: 1; min-width: 0; }
.chapter .cname { font-weight: 700; font-size: 15.5px; }
.chapter .cmeta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.chapter .cmeta .bar { width: 90px; height: 5px; }
.chapter .chev { color: var(--muted); transition: transform .2s; font-size: 12px; }
.chapter.closed .chev { transform: rotate(-90deg); }
.chapter .body { border-top: 1px solid var(--line); }
.chapter.closed .body { display: none; }
.chapter .mat { display: flex; align-items: center; gap: 8px; padding: 9px 16px; font-size: 13px; border-top: 1px dashed var(--line); background: var(--card-2); }
.chapter .mat a { font-weight: 600; }

.vrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.vrow:last-child { border-bottom: none; }
.vrow:hover { background: var(--card-2); }
.vrow .thumb { flex: none; width: 96px; height: 54px; border-radius: 9px; background: var(--none-bg) center/cover no-repeat; position: relative; overflow: hidden; }
.vrow .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vrow .thumb .no { position: absolute; left: 5px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.vrow .thumb .dur { position: absolute; right: 5px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 6px; }
.vrow .thumb .done { position: absolute; inset: 0; background: rgba(31,157,85,.55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800; }
.vrow .thumb .pbar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.35); }
.vrow .thumb .pbar i { display: block; height: 100%; background: var(--gold); }
.vrow .t { flex: 1; min-width: 0; }
.vrow .t .name { font-size: 15px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vrow .t .sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 3px; flex-wrap: wrap; }
.st { flex: none; font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.st.none { background: var(--none-bg); color: var(--none); }
.st.mid { background: var(--mid-bg); color: var(--mid); }
.st.done { background: var(--ok-bg); color: var(--ok); }
.dl { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text-2); font-size: 15px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; }
.dl:hover { border-color: var(--brand-3); color: var(--brand-3); }
.dl.saved { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.dl.busy { color: var(--brand-3); border-color: var(--brand-3); font-size: 10px; font-weight: 700; }

/* プレーヤー */
.ptop { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.ptop .back { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; box-shadow: var(--shadow); }
.ptop .crumb { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player { background: #000; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-lg); display: flex; justify-content: center; }
.player video { width: 100%; max-height: 72vh; background: #000; display: block; }
.ptitle { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 6px; }
.ptitle h2 { margin: 0; font-size: 19px; flex: 1; line-height: 1.35; }
.pinfo { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13.5px; color: var(--text-2); }
.pinfo .bar { flex: 1; min-width: 120px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 9px 16px; cursor: pointer; box-shadow: var(--shadow); transition: transform .12s, background .15s; font-weight: 600; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--brand-grad); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.block { width: 100%; border-radius: 14px; padding: 12px; }
.next { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px; border-radius: var(--r); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: pointer; }
.next:hover { background: var(--card-2); }
.next .thumb { width: 96px; height: 54px; border-radius: 9px; background: var(--none-bg) center/cover; flex: none; }
.next .t { flex: 1; min-width: 0; }
.next .t .lbl { font-size: 11.5px; color: var(--muted); letter-spacing: .06em; }
.next .t .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* フォーム */
.login { max-width: 400px; margin: 36px auto; }
.logo { text-align: center; margin-bottom: 16px; }
.logo img { width: 76px; height: 76px; border-radius: 20px; box-shadow: var(--shadow); background: #fff; }
.logo h1 { font-size: 21px; margin: 10px 0 0; color: var(--text); letter-spacing: .02em; }
.logo p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
label.f { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text-2); font-weight: 600; }
label.f input, label.f select, label.f textarea { display: block; width: 100%; margin-top: 5px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); color: var(--text); font-weight: 400; transition: border .15s, box-shadow .15s; }
label.f input:focus, label.f select:focus, label.f textarea:focus { outline: none; border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(79,115,217,.18); background: var(--card); }
.err { color: var(--danger); font-size: 13.5px; margin: 6px 0; min-height: 1.2em; }
.note { background: var(--mid-bg); border: 1px solid rgba(196,125,10,.25); border-radius: 12px; padding: 10px 13px; font-size: 13.5px; margin: 10px 0; color: var(--text); }

/* 管理画面 */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.tabs button { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 15px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tablewrap { overflow: auto; max-height: 72vh; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); }
table.mx { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.mx th, table.mx td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 5px 7px; white-space: nowrap; text-align: center; }
table.mx thead th { position: sticky; top: 0; background: var(--card-2); z-index: 2; font-weight: 700; }
table.mx thead tr:nth-child(2) th { top: 31px; }
table.mx th.name, table.mx td.name { position: sticky; left: 0; background: var(--card); text-align: left; z-index: 3; min-width: 130px; cursor: pointer; }
table.mx thead th.name { z-index: 4; background: var(--card-2); }
table.mx td.name:hover { color: var(--brand-3); }
table.mx td.c0 { background: var(--none-bg); color: var(--none); }
table.mx td.c1 { background: #fff4d6; color: #7a4d00; }
table.mx td.c2 { background: #ffe3a3; color: #5e3a00; }
table.mx td.c3 { background: #c9ecd5; color: #1f6b3b; font-weight: 800; }
@media (prefers-color-scheme: dark) { table.mx td.c1 { background: #3b2d0f; color: #f3c56b; } table.mx td.c2 { background: #52400f; color: #ffd27a; } table.mx td.c3 { background: #173f2a; color: #7ad39c; } }
table.mx td.sum { background: var(--card-2); font-weight: 700; }
table.plain { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 8px 9px; text-align: left; vertical-align: top; }
table.plain th { background: var(--card-2); font-weight: 700; position: sticky; top: 0; }
.chip { display: inline-block; font-size: 11px; border-radius: 999px; padding: 1px 8px; background: var(--none-bg); color: var(--text-2); margin-left: 5px; font-weight: 600; }
.chip.admin { background: #e5e9ff; color: #3b4ab8; }
.chip.off { background: #fde2e2; color: var(--danger); }
.chip.lock { background: var(--mid-bg); color: var(--mid); }
@media (prefers-color-scheme: dark) { .chip.admin { background: #27306b; color: #aeb8ff; } .chip.off { background: #4a1f1f; color: #ff9b9b; } }
.actions button { font-size: 12px; padding: 4px 10px; margin: 2px; box-shadow: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px 10px; align-items: end; }

/* モーダル */
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,30,.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 700px) { .modal-bg { align-items: center; } }
.modal { background: var(--card); border-radius: 22px 22px 0 0; width: 100%; max-width: 860px; max-height: 92vh; overflow: auto; padding: 18px; box-shadow: var(--shadow-lg); animation: up .2s ease; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .modal { border-radius: 22px; } }
.modal h2 { margin: 0 0 10px; font-size: 17px; }
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-list .btn { text-align: left; border-radius: 14px; padding: 12px 16px; box-shadow: none; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(10px); background: #1b2131; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90vw; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
