:root {
  --primary: #0d665e;
  --primary-strong: #084b45;
  --primary-soft: #dff3ef;
  --accent: #c65316;
  --surface: #ffffff;
  --surface-subtle: #f4f8f6;
  --background: #edf4f1;
  --text: #17302c;
  --text-muted: #62736f;
  --border: #d3dfda;
  --success: #19704c;
  --warning: #8a5b10;
  --danger: #b42318;
  --shadow-sm: 0 4px 16px rgba(17, 56, 47, 0.08);
  --shadow-lg: 0 24px 80px rgba(7, 31, 26, 0.18);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--background); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -8%, rgba(13, 102, 94, 0.11), transparent 34rem),
    linear-gradient(180deg, #f7faf8 0%, var(--background) 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}
button, input, select { font: inherit; }
button, a, input, select { touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 1000;
  padding: 10px 14px; color: white; background: var(--primary-strong); border-radius: 10px;
}
.skip-link:focus { top: 16px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.login-shell { width: min(100%, 780px); }
.brand-lockup, .compact-brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--primary-strong);
  font-weight: 800; letter-spacing: -0.02em; text-decoration: none;
}
.brand-lockup { margin: 0 0 24px 16px; font-size: 20px; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; color: var(--primary); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-mark.small { width: 34px; height: 34px; }

.login-card {
  position: relative; overflow: hidden; padding: clamp(28px, 6vw, 58px);
  background: rgba(255,255,255,0.94); border: 1px solid rgba(211,223,218,0.9);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.login-card::after {
  content: ""; position: absolute; width: 260px; height: 260px; right: -120px; top: -130px;
  border: 42px solid rgba(13,102,94,0.07); border-radius: 50%; pointer-events: none;
}
.section-label {
  display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px;
  color: var(--primary-strong); background: var(--primary-soft); border-radius: 999px;
  font-size: 13px; font-weight: 750; letter-spacing: 0.03em;
}
.section-label.light { color: #d9fbf5; background: rgba(255,255,255,0.13); }
.login-card h1 { margin: 18px 0 14px; font-size: clamp(32px, 7vw, 52px); line-height: 1.16; letter-spacing: -0.04em; }
.login-copy { max-width: 590px; margin: 0 0 30px; color: var(--text-muted); font-size: 17px; }
form label { display: block; margin-bottom: 8px; font-weight: 700; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
input[type="text"], input:not([type]), input[type="password"] {
  width: 100%; min-height: 52px; padding: 0 16px; color: var(--text);
  background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color 180ms ease, box-shadow 180ms ease;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(13,102,94,0.24); outline-offset: 2px;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(13,102,94,0.1); }
.primary-button {
  min-height: 52px; min-width: 128px; padding: 0 22px; border: 0; border-radius: var(--radius-sm);
  color: white; background: var(--primary); font-weight: 750; box-shadow: 0 8px 18px rgba(13,102,94,0.2);
  transition: background 180ms ease, transform 180ms ease;
}
.primary-button:hover { background: var(--primary-strong); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: 0.55; }
.form-error { min-height: 25px; margin: 8px 0 0; color: var(--danger); font-size: 14px; }
.demo-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 14px; }
.text-button { min-height: 44px; padding: 6px 10px; border: 0; color: var(--primary); background: transparent; font-weight: 750; }
.privacy-note { margin: 18px 12px 0; color: var(--text-muted); text-align: center; font-size: 13px; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  min-height: 72px; padding: 10px max(20px, calc((100vw - 1120px) / 2));
  background: rgba(247,250,248,0.92); border-bottom: 1px solid rgba(211,223,218,0.9); backdrop-filter: blur(16px);
}
.compact-brand { font-size: 18px; }
.user-menu { display: flex; align-items: center; gap: 12px; text-align: right; }
.user-menu strong, .user-menu span { display: block; }
.user-menu strong { font-size: 14px; }
.user-menu span { max-width: 220px; color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button, .control-button {
  display: inline-grid; place-items: center; width: 46px; height: 46px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; color: var(--text); background: var(--surface);
}
.icon-button svg, .control-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.inverse { color: white; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.22); }

.main-content { width: min(1120px, calc(100% - 32px)); margin: 34px auto 80px; }
.overview-card {
  display: grid; grid-template-columns: 1fr 250px; gap: 28px; align-items: end;
  padding: clamp(26px, 5vw, 48px); color: white;
  background: linear-gradient(135deg, #0a4d47 0%, #0d665e 62%, #137c70 100%);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.overview-card h1 { max-width: 720px; margin: 16px 0 10px; font-size: clamp(30px, 5vw, 48px); line-height: 1.2; letter-spacing: -0.04em; }
.overview-card p { max-width: 690px; margin: 0; color: rgba(255,255,255,0.8); }
.overall-progress { padding: 20px; border: 1px solid rgba(255,255,255,0.18); border-radius: var(--radius-md); background: rgba(255,255,255,0.09); }
.overall-progress strong { display: block; font-size: 30px; font-variant-numeric: tabular-nums; }
.overall-progress span { display: block; margin-bottom: 13px; color: rgba(255,255,255,0.75); font-size: 13px; }
.progress-track { height: 8px; overflow: hidden; background: rgba(255,255,255,0.18); border-radius: 999px; }
.progress-track > span { display: block; width: 0; height: 100%; background: #7ce2d2; border-radius: inherit; transition: width 240ms ease; }
.progress-track.dark { background: rgba(255,255,255,0.12); }

.course-section { margin-top: 44px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 18px; }
.section-heading h2 { margin: 10px 0 0; font-size: clamp(26px, 4vw, 36px); line-height: 1.2; letter-spacing: -0.03em; }
.section-heading p { margin: 0; color: var(--text-muted); }
.course-list { display: grid; gap: 14px; }
.course-card {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 18px; align-items: center;
  min-height: 122px; padding: 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-sm); transition: border-color 180ms ease, transform 180ms ease;
}
.course-card:not(.locked):hover { transform: translateY(-2px); border-color: #9bbab2; }
.course-card.locked { opacity: 0.67; background: #f1f4f3; box-shadow: none; }
.course-number { display: grid; place-items: center; width: 54px; height: 54px; color: var(--primary); background: var(--primary-soft); border-radius: 16px; font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.course-number svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.course-card.completed .course-number { color: white; background: var(--success); }
.course-copy h3 { margin: 0 0 5px; font-size: 18px; line-height: 1.35; }
.course-copy p { margin: 0; color: var(--text-muted); font-size: 14px; }
.course-meta { display: flex; align-items: center; gap: 12px; margin-top: 11px; }
.mini-progress { width: 150px; height: 6px; overflow: hidden; background: #e2ebe7; border-radius: 999px; }
.mini-progress span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.progress-text { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.course-action {
  min-width: 116px; min-height: 48px; padding: 0 18px; border: 1px solid var(--primary); border-radius: var(--radius-sm);
  color: var(--primary); background: white; font-weight: 750;
}
.course-action svg { width: 17px; height: 17px; margin-right: 5px; fill: none; stroke: currentColor; stroke-width: 1.8; vertical-align: -3px; }
.course-action:hover { color: white; background: var(--primary); }
.course-action:disabled { cursor: not-allowed; color: #7f8d89; background: #e6ebe9; border-color: #d0d9d5; }
.course-card.completed .course-action { color: var(--success); border-color: #92c8ae; background: #effaf4; }

.player-sheet { position: fixed; inset: 0; z-index: 100; overflow: auto; padding: 24px; background: rgba(4, 20, 17, 0.76); backdrop-filter: blur(10px); }
.player-panel { width: min(1080px, 100%); margin: 0 auto; overflow: hidden; color: white; background: #0b1513; border: 1px solid rgba(255,255,255,0.12); border-radius: 24px; box-shadow: 0 30px 100px rgba(0,0,0,0.45); }
.player-header { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding: 22px 24px; }
.player-header h2 { margin: 10px 0 0; font-size: clamp(20px, 4vw, 30px); line-height: 1.3; }
.video-stage { position: relative; aspect-ratio: 16 / 9; background: black; overflow: hidden; }
.video-stage video { display: block; width: 100%; height: 100%; object-fit: contain; background: black; }
.center-play { position: absolute; inset: 50% auto auto 50%; display: grid; place-items: center; width: 78px; height: 78px; padding: 0; color: white; background: rgba(13,102,94,0.92); border: 1px solid rgba(255,255,255,0.42); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 12px 30px rgba(0,0,0,0.35); }
.center-play svg { width: 34px; height: 34px; fill: currentColor; stroke: none; }
.video-controls { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 24px 18px 14px; background: linear-gradient(transparent, rgba(0,0,0,0.86)); }
.control-button { width: 44px; height: 44px; color: white; background: transparent; border-color: transparent; }
.control-button:hover { background: rgba(255,255,255,0.12); }
.pause-icon { display: none; }
.playing .play-icon { display: none; }.playing .pause-icon { display: block; }
.timeline-control { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
input[type="range"] { width: 100%; min-height: 44px; accent-color: #69d7c5; cursor: pointer; }
#timeLabel { min-width: 94px; color: rgba(255,255,255,0.82); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.rate-control select { min-width: 74px; min-height: 44px; padding: 0 9px; color: white; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); border-radius: 10px; }
.rate-control option { color: var(--text); background: white; }
.player-progress-card { display: grid; gap: 10px; padding: 20px 24px 24px; }
.player-progress-card > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.player-progress-card span { color: rgba(255,255,255,0.68); }
.player-progress-card strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.player-progress-card p { margin: 0; color: rgba(255,255,255,0.68); font-size: 14px; }

.toast { position: fixed; z-index: 200; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 520px); padding: 13px 16px; color: white; background: #17302c; border-radius: 12px; box-shadow: var(--shadow-lg); transform: translateX(-50%); text-align: center; }

.admin-page { width: min(1180px, calc(100% - 32px)); margin: 28px auto 72px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-header h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); }
.admin-login, .admin-panel { padding: 24px; background: white; border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.admin-login { max-width: 560px; margin: 80px auto; }
.admin-login h1 { margin: 0 0 8px; }.admin-login p { color: var(--text-muted); }
.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.secondary-button { min-height: 46px; padding: 0 16px; color: var(--primary); background: white; border: 1px solid var(--primary); border-radius: 11px; font-weight: 700; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.summary-card { padding: 20px; background: white; border: 1px solid var(--border); border-radius: var(--radius-md); }
.summary-card strong { display: block; font-size: 30px; color: var(--primary); }
.summary-card span { color: var(--text-muted); font-size: 14px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 14px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--primary-strong); background: #edf6f3; }
tr:last-child td { border-bottom: 0; }
.status-pill { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; }
.status-pill.done { color: var(--success); background: #e8f7ef; }.status-pill.pending { color: var(--warning); background: #fff5dc; }
.invite-panel { margin-bottom: 18px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2 { margin: 8px 0 0; font-size: 24px; }.panel-heading p { margin: 0; color: var(--text-muted); }
.invite-form { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(240px, 1fr) auto; gap: 12px; align-items: end; }
.invite-form label { margin-bottom: 6px; font-size: 14px; }
.form-message { min-height: 24px; margin: 10px 0; color: var(--primary); font-size: 14px; }
.invite-list { display: grid; gap: 8px; }
.invite-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 12px; }
.invite-row strong, .invite-row span { display: block; }.invite-row span { color: var(--text-muted); font-size: 13px; }
.code-chip { min-height: 44px; padding: 0 12px; color: var(--primary-strong); background: white; border: 1px dashed #81aaa0; border-radius: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.invite-toggle { min-width: 70px; min-height: 44px; color: var(--success); background: #e8f7ef; border: 1px solid #a9d7bf; border-radius: 10px; font-weight: 700; }
.invite-toggle.active { color: var(--danger); background: #fff1ef; border-color: #efbbb5; }

@media (max-width: 760px) {
  .login-view { padding: 18px 12px; align-items: start; }
  .brand-lockup { margin: 8px 0 16px 10px; }
  .login-card { padding: 28px 20px; border-radius: 22px; }
  .input-row { grid-template-columns: 1fr; }
  .primary-button { width: 100%; }
  .topbar { min-height: 64px; padding: 8px 14px; }
  .compact-brand span:last-child { display: none; }
  .user-menu span { max-width: 150px; }
  .main-content { width: min(100% - 20px, 680px); margin-top: 16px; }
  .overview-card { grid-template-columns: 1fr; padding: 24px 20px; border-radius: 22px; }
  .overall-progress { padding: 16px; }
  .section-heading { align-items: start; flex-direction: column; }
  .section-heading p { font-size: 14px; }
  .course-card { grid-template-columns: 48px 1fr; gap: 12px; padding: 16px; }
  .course-number { width: 46px; height: 46px; border-radius: 14px; }
  .course-action { grid-column: 1 / -1; width: 100%; }
  .mini-progress { width: min(45vw, 150px); }
  .player-sheet { padding: 0; background: #0b1513; }
  .player-panel { min-height: 100dvh; border: 0; border-radius: 0; }
  .player-header { padding: max(14px, env(safe-area-inset-top)) 14px 14px; }
  .video-controls { grid-template-columns: auto 1fr auto; gap: 6px; padding: 24px 8px 8px; }
  .timeline-control { grid-template-columns: 1fr; gap: 0; }
  #timeLabel { display: none; }
  #fullscreenButton { display: none; }
  .player-progress-card { padding: 18px 16px max(24px, env(safe-area-inset-bottom)); }
  .summary-grid { grid-template-columns: 1fr; }
  .admin-header { align-items: start; flex-direction: column; }
  .panel-heading { align-items: start; flex-direction: column; }
  .invite-form, .invite-row { grid-template-columns: 1fr; }
  .code-chip, .invite-toggle { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
