/* ── リセット＆ベース ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #1c1d1f;
  --surface:      #2d2f31;
  --surface2:     #3e4143;
  --text:         #f7f9fa;
  --text-sub:     #9da0a4;
  --accent:       #a78bfa;
  --accent-h:     #8b5cf6;
  --border:       #3e4143;
  --active-bg:    #3a3b3d;
  --danger:       #ef4444;
  --success:      #10b981;
  --info:         #3b82f6;
  --header-h:     56px;
  --sidebar-w:    340px;
  --radius:       8px;
}

html { font-size: 16px; }
body {
  font-family: 'Inter', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
img { max-width: 100%; }

/* ── 共通パーツ ──────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(239,68,68,.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(16,185,129,.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.alert-info    { background: rgba(59,130,246,.15); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-primary.w-full { width: 100%; }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text);
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); cursor: pointer; transition: all .2s;
}
.btn-outline:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid rgba(239,68,68,.4);
  padding: 6px 12px; font-size: 13px; border-radius: 6px;
  cursor: pointer; transition: all .2s;
}
.btn-danger:hover { background: rgba(239,68,68,.15); }

.btn-logout {
  font-size: 13px; color: var(--text-sub);
  border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 6px;
  transition: all .2s;
}
.btn-logout:hover { color: var(--text); border-color: var(--text-sub); }

.btn-text {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 0;
  text-decoration: underline;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 14px; font-weight: 500; color: var(--text); }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  width: 100%;
  transition: border-color .2s;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-input-sm {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px;
  border-radius: 6px; font-size: 13px; width: 100%;
}

.otp-input { letter-spacing: .3em; font-size: 24px; text-align: center; font-weight: 700; }

.text-muted { color: var(--text-sub); font-size: 14px; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── ヘッダー ─────────────────────────────────────── */
.site-header, .lesson-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.header-inner, .lesson-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 24px; max-width: 100%;
}
.header-logo, .lesson-header-back { font-size: 18px; font-weight: 700; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user { font-size: 13px; color: var(--text-sub); }

.lesson-header-back { display: flex; align-items: center; gap: 6px; color: var(--text-sub); transition: color .2s; }
.lesson-header-back:hover { color: var(--text); }
.back-arrow { font-size: 18px; }
.back-label { font-size: 14px; }
.lesson-header-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 40%;
}
.lesson-header-right { display: flex; align-items: center; gap: 12px; }

/* ── フッター ─────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
}
.footer-inner { text-align: center; font-size: 13px; color: var(--text-sub); }

/* ── ログインページ ───────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
}
.login-logo {
  font-size: 28px; font-weight: 700; text-align: center;
  margin-bottom: 24px; letter-spacing: .05em;
  background: linear-gradient(135deg, #a78bfa, #7dd3fc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.login-sub { font-size: 14px; color: var(--text-sub); margin-bottom: 24px; line-height: 1.6; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.resend-form { margin-top: 16px; text-align: center; }

/* ── コース一覧ページ ────────────────────────────── */
.course-index-page { padding-top: var(--header-h); }

.course-hero {
  background: linear-gradient(135deg, #1a1040 0%, #1c1d1f 60%);
  border-bottom: 1px solid var(--border);
  padding: 60px 24px;
}
.course-hero.has-image {
  background-size: cover;
  background-position: center;
  position: relative;
}
.course-hero.has-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26,16,64,0.82) 0%, rgba(28,29,31,0.72) 100%);
}
.course-hero.has-image .course-hero-inner { position: relative; z-index: 1; }
.course-hero-inner { max-width: 800px; margin: 0 auto; }
.course-category { font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; }
.course-hero-title { font-size: 32px; font-weight: 700; margin-bottom: 12px; line-height: 1.3; }
.course-hero-desc { font-size: 16px; color: var(--text-sub); margin-bottom: 20px; }
.course-meta { display: flex; gap: 20px; font-size: 14px; color: var(--text-sub); margin-bottom: 28px; }
.btn-start {
  display: inline-flex; align-items: center;
  background: var(--accent); color: #fff;
  padding: 14px 28px; border-radius: var(--radius);
  font-size: 16px; font-weight: 600;
  transition: background .2s;
}
.btn-start:hover { background: var(--accent-h); color: #fff; }

.course-content-wrap { padding: 40px 24px 80px; }
.course-content-inner { max-width: 800px; margin: 0 auto; }
.section-list-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.section-block { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.section-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  cursor: pointer; user-select: none;
  transition: background .15s;
}
.section-block-header:hover { background: var(--surface2); }
.section-block-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.section-chevron { font-size: 12px; transition: transform .2s; display: inline-block; }
.section-block-count { font-size: 13px; color: var(--text-sub); }
.section-block-lessons { background: var(--bg); }
.section-block-lessons.collapsed { display: none; }

.lesson-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--text); transition: background .15s;
}
.lesson-row:hover { background: var(--active-bg); }
.lesson-row-icon { color: var(--accent); font-size: 12px; flex-shrink: 0; }
.lesson-row-label { flex: 1; font-size: 14px; line-height: 1.4; }
.lesson-row-day { font-size: 12px; color: var(--text-sub); display: block; }
.lesson-row-count { font-size: 12px; color: var(--text-sub); flex-shrink: 0; }

/* ── レッスンページ（Udemy風）────────────────────── */
.lesson-page { padding-top: var(--header-h); }

.lesson-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.lesson-main {
  flex: 7;
  min-width: 0;
  padding-bottom: 60px;
}

.video-block {
  background: var(--bg);
  padding: 0 32px 40px;
  border-bottom: 1px solid var(--border);
}
.video-block:last-of-type { border-bottom: none; }
.video-inline-download {
  padding: 16px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.video-label {
  padding: 20px 32px;
  font-size: 20px; font-weight: 700; color: var(--text);
  text-align: center;
  background: linear-gradient(135deg, #1a1040 0%, #2d1f5e 50%, #1c1d1f 100%);
  border-radius: 6px;
  letter-spacing: .02em;
  margin-bottom: 10px;
}
.video-wrapper {
  position: relative;
  padding-top: calc(56.25% * 0.82);
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin: 0 9%;
}
.video-wrapper iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: none;
}
.no-video { padding: 40px; text-align: center; color: var(--text-sub); }

/* タブ */
.lesson-tabs { padding: 0 24px 24px; }
.tab-nav {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none; border: none;
  color: var(--text-sub); font-size: 14px; font-weight: 500;
  padding: 12px 20px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .2s; margin-bottom: -1px;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-btn:hover { color: var(--text); }

.tab-content { animation: fadeIn .15s ease; }
.tab-lesson-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.tab-lesson-desc { font-size: 14px; color: var(--text-sub); margin-bottom: 16px; }

.lesson-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px; line-height: 1.8;
  color: var(--text-sub);
  margin-top: 16px;
}

.download-list { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.download-item { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 10px 18px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  transition: all .2s;
}
.btn-download:hover { background: var(--surface2); color: var(--text); }
.btn-download-empty { opacity: .5; cursor: not-allowed; }
.download-expire { font-size: 12px; color: var(--text-sub); }

.ref-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.ref-list a { font-size: 14px; color: var(--accent); }
.ref-list a:hover { text-decoration: underline; }

/* 前へ/次へ */
.lesson-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  font-size: 14px; font-weight: 500; transition: all .2s;
}
.nav-btn:hover { background: var(--surface2); color: var(--text); }

/* サイドバー */
.lesson-sidebar {
  flex: 3;
  min-width: 260px;
  max-width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
  overflow-y: auto;
}
.sidebar-header {
  padding: 16px 18px;
  font-size: 14px; font-weight: 700;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.sidebar-sections { }
.sidebar-section { border-bottom: 1px solid var(--border); }
.sidebar-section-title {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none;
  transition: background .15s;
}
.sidebar-section-title:hover { background: var(--surface2); }
.sidebar-chevron { font-size: 10px; transition: transform .2s; display: inline-block; flex-shrink: 0; }
.sidebar-section-title span:nth-child(2) { flex: 1; }
.sidebar-section-count {
  font-size: 11px; color: var(--text-sub);
  background: var(--bg);
  padding: 2px 8px; border-radius: 10px;
  flex-shrink: 0;
}
.sidebar-lessons { }
.sidebar-lessons.collapsed { display: none; }
.sidebar-section:not(.open) .sidebar-chevron { transform: rotate(-90deg); }
.sidebar-section:not(.open) .sidebar-lessons { display: none; }

.sidebar-lesson {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px 10px 24px;
  font-size: 13px; color: var(--text-sub);
  transition: all .15s;
  border-top: 1px solid var(--border);
}
.sidebar-lesson:hover { background: var(--active-bg); color: var(--text); }
.sidebar-lesson.active {
  background: rgba(167,139,250,.12);
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding-left: 21px;
}
.sidebar-lesson-icon { font-size: 11px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.sidebar-lesson.active .sidebar-lesson-icon { color: var(--accent); }
.sidebar-lesson-text { line-height: 1.5; }
.sidebar-lesson-day { font-size: 11px; color: var(--text-sub); display: block; }
.sidebar-dl-badge {
  display: inline-block; margin-top: 4px;
  font-size: 10px; font-weight: 700;
  background: var(--accent); color: #fff;
  padding: 2px 7px; border-radius: 4px;
  letter-spacing: .04em;
}
.sidebar-lesson.active .sidebar-lesson-day { color: var(--accent); opacity: .8; }

/* ── 管理ページ ──────────────────────────────────── */
.manage-page { padding-top: var(--header-h); }
.manage-main { padding: 40px 24px 80px; }
.manage-inner { max-width: 900px; margin: 0 auto; }
.manage-login-wrap { max-width: 400px; margin: 60px auto 0; }
.manage-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; }
.manage-login-form { display: flex; flex-direction: column; gap: 12px; }
.manage-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.manage-section-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.manage-add-form { display: flex; flex-direction: column; gap: 16px; }
.manage-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.checkbox-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; cursor: pointer;
}
.checkbox-group-sm { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.checkbox-label-sm {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; cursor: pointer;
}

.user-list { display: flex; flex-direction: column; gap: 12px; }
.user-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; gap: 16px; flex-wrap: wrap;
}
.user-card-info { flex: 1; min-width: 200px; }
.user-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.user-email { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; }
.user-courses { display: flex; flex-wrap: wrap; gap: 6px; }
.course-badge {
  font-size: 12px; background: rgba(167,139,250,.15);
  color: var(--accent); border: 1px solid rgba(167,139,250,.3);
  padding: 2px 10px; border-radius: 10px;
}
.user-card-actions {
  display: flex; flex-direction: column; gap: 8px;
  align-items: flex-start; min-width: 220px;
}
.inline-form { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.password-form { flex-direction: row; align-items: center; gap: 8px; }
.password-form .form-input-sm { flex: 1; }

/* ── アニメーション ───────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── レスポンシブ ─────────────────────────────────── */
@media (max-width: 900px) {
  .lesson-layout { flex-direction: column; }
  .lesson-sidebar {
    width: 100%; height: auto;
    position: static;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .lesson-header-title { display: none; }
}
@media (max-width: 600px) {
  .course-hero { padding: 40px 16px; }
  .course-hero-title { font-size: 24px; }
  .manage-form-row { grid-template-columns: 1fr; }
  .user-card { flex-direction: column; }
  .user-card-actions { width: 100%; }
  .login-card { padding: 28px 20px; }
}
