:root {
  --bg: #eeecf4;
  --card: #ffffff;
  --text: #17171c;
  --muted: #6b7280;
  --border: #e7e5f0;

  --accent: #6f5cf0;
  --accent-dark: #5847c9;

  --yellow: #f6e35a;
  --yellow-dark: #e8cf2a;
  --coral: #fb6f5d;
  --blue: #4f8ef7;
  --green: #55c799;
  --purple: #a78bfa;

  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px circle at 8% -5%, rgba(251,111,93,0.14), transparent 55%),
    radial-gradient(500px circle at 100% 0%, rgba(246,227,90,0.18), transparent 50%),
    radial-gradient(700px circle at 50% 100%, rgba(79,142,247,0.10), transparent 50%);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-14px) scale(1.04); }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 3px;
  background: linear-gradient(90deg, var(--coral), var(--yellow), var(--green), var(--blue), var(--purple));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--coral), var(--purple));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 6px 14px rgba(111,92,240,0.35);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
}

#user-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(23,23,28,0.08); }
.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: var(--accent);
  color: white;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(111,92,240,0.30);
}

.btn.primary:hover { box-shadow: 0 14px 30px rgba(111,92,240,0.38); }

.btn.primary.large { padding: 13px 26px; font-size: 15px; border-radius: 12px; }

.btn.back { margin-bottom: 18px; background: transparent; border-color: transparent; padding-left: 4px; color: var(--muted); }
.btn.back:hover { color: var(--text); box-shadow: none; transform: translateX(-2px); }

/* ---------- Login ---------- */

.login-gate {
  min-height: calc(100vh - 62px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-gate[hidden] { display: none; }

.login-panel {
  display: flex;
  width: 100%;
  max-width: 880px;
  background: var(--card);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(23,23,28,0.14);
}

.login-visual {
  position: relative;
  flex: 1 1 42%;
  min-height: 400px;
  background: linear-gradient(135deg, var(--coral) 0%, var(--purple) 55%, var(--blue) 100%);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 24px;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(1px);
  opacity: 0.55;
  animation: floaty 7s ease-in-out infinite;
}
.orb-1 { width: 190px; height: 190px; background: var(--yellow); top: -50px; left: -50px; }
.orb-2 { width: 150px; height: 150px; background: var(--green); bottom: -40px; right: -30px; animation-delay: 1.2s; }
.orb-3 { width: 110px; height: 110px; background: #ffffff; bottom: 70px; left: 30px; opacity: 0.25; animation-delay: 2.4s; }

.visual-label {
  position: relative;
  color: rgba(255,255,255,0.92);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.login-card {
  flex: 1 1 58%;
  padding: 52px 46px;
  text-align: left;
}

.login-badge {
  display: inline-block;
  background: var(--bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  margin-bottom: 18px;
}

.login-card h1 { font-size: 36px; line-height: 1.2; margin: 0 0 14px; letter-spacing: -0.02em; font-weight: 800; }
.login-card p { color: var(--muted); margin: 0 0 26px; font-size: 15px; }

/* ---------- App shell ---------- */

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.dashboard-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
}

.dashboard-main { flex: 1 1 auto; min-width: 0; }

.dashboard-sidebar {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.side-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  animation: fadeInUp .4s ease both;
}

.side-panel.tint-coral {
  background: linear-gradient(160deg, rgba(251,111,93,0.16), rgba(251,111,93,0.05));
  border-color: rgba(251,111,93,0.30);
}

.side-panel.tint-green {
  background: linear-gradient(160deg, rgba(85,199,153,0.18), rgba(85,199,153,0.05));
  border-color: rgba(85,199,153,0.30);
}

.side-panel.tint-coral .side-event,
.side-panel.tint-green .side-event {
  border-top-color: rgba(23,23,28,0.08);
}

.side-panel.tint-coral .side-event-date { color: #c8402f; }
.side-panel.tint-green .side-event-date { color: #1f7a52; }

.side-panel h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}

.side-panel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.side-event {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.side-event:first-child { border-top: none; padding-top: 0; }

.side-event-date {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin-bottom: 3px;
}

.side-event-title { font-size: 13px; font-weight: 600; }
.side-event-note { font-size: 12px; color: var(--muted); margin-top: 1px; }

.side-empty { font-size: 13px; color: var(--muted); margin: 0; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; min-height: 16px; }

h1 { font-size: 32px; font-weight: 800; margin: 0 0 20px; letter-spacing: -0.025em; }

.hero { margin-bottom: 28px; }
.hero h1 { font-size: 36px; margin-bottom: 18px; }
.hero-eyebrow { font-size: 15px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
}
.stat-pill.accent { border-color: var(--green); background: #f2fbf7; }
.stat-num { font-size: 18px; font-weight: 800; }
.stat-pill.accent .stat-num { color: #1f7a52; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.view { animation: fadeInUp .35s ease both; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--accent));
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: box-shadow .18s ease, transform .18s ease;
  animation: fadeInUp .4s ease both;
}

.card:hover {
  box-shadow: 0 14px 32px rgba(23,23,28,0.10);
  transform: translateY(-3px);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--card-accent, var(--accent));
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.badge svg { display: block; }

.chip {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 9px;
  border-radius: 20px;
}
.chip.done { color: #1f7a52; background: #eaf8f1; }

.card h3 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.01em; }
.card h3.lg { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.card p { margin: 0; font-size: 13px; color: var(--muted); }
.card .count { margin-top: 12px; font-size: 12px; color: var(--card-accent, var(--accent)); font-weight: 700; }

.progress {
  margin-top: 12px;
  height: 6px;
  border-radius: 20px;
  background: var(--bg);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--card-accent, var(--accent));
}

.card.c0 { --card-accent: var(--coral); }
.card.c1 { --card-accent: var(--yellow-dark); }
.card.c2 { --card-accent: var(--green); }
.card.c3 { --card-accent: var(--blue); }
.card.c4 { --card-accent: var(--purple); }

.module-desc { color: var(--muted); margin-bottom: 20px; font-size: 15px; }

.embed-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #17171c;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(23,23,28,0.14);
}

.embed-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

.file-row { margin-top: 18px; }
.watched-row { margin-top: 18px; }

.btn.download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: linear-gradient(135deg, var(--blue), #2f6fe0);
  border-color: var(--blue);
  color: white;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(79,142,247,0.30);
}

.btn.watched {
  background: linear-gradient(135deg, var(--green), #2f9d6f);
  border-color: var(--green);
  color: white;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(85,199,153,0.28);
}

.btn.watched.done {
  background: #eef8f2;
  border-color: var(--green);
  color: #1f7a52;
  cursor: default;
  box-shadow: none;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}

.loading-state[hidden] { display: none; }

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.load-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  color: #8a241d;
  background: #fdecea;
  border: 1px solid #f5c2bd;
  padding: 24px 20px;
  border-radius: 12px;
}

.load-error[hidden] { display: none; }
.load-error p { margin: 0; }

/* ---------- Mobile ---------- */

@media (max-width: 960px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-sidebar { flex: none; width: 100%; flex-direction: row; flex-wrap: wrap; }
  .side-panel { flex: 1 1 260px; }
}

@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 15px; }
  .brand-text { display: none; }

  .login-panel { flex-direction: column; border-radius: 20px; }
  .login-visual { min-height: 120px; flex: none; align-items: center; justify-content: center; padding: 16px; }
  .visual-label { font-size: 17px; }
  .login-card { padding: 32px 24px; text-align: center; }
  .login-card h1 { font-size: 26px; }

  .app { padding: 24px 16px 70px; }
  h1 { font-size: 25px; }
  .hero h1 { font-size: 27px; }

  .grid { grid-template-columns: 1fr; }
  .stats-row { gap: 8px; }
  .stat-pill { flex: 1 1 auto; justify-content: center; padding: 10px 12px; }

  .card { padding: 18px; }

  .dashboard-sidebar { flex-direction: column; }
}

@media (max-width: 400px) {
  .stats-row { flex-direction: column; }
}
