/* =========================================================
   ClassHub — design system
   ========================================================= */
:root {
  --primary: #9E1B22;
  --accent: #C9A227;

  --primary-600: color-mix(in srgb, var(--primary) 82%, black);
  --primary-700: color-mix(in srgb, var(--primary) 65%, black);
  --primary-50: color-mix(in srgb, var(--primary) 6%, white);
  --primary-100: color-mix(in srgb, var(--primary) 12%, white);
  --primary-200: color-mix(in srgb, var(--primary) 24%, white);
  --primary-glow: color-mix(in srgb, var(--primary) 22%, transparent);
  --accent-50: color-mix(in srgb, var(--accent) 12%, white);
  --accent-600: color-mix(in srgb, var(--accent) 75%, black);

  --bg: #f7f7f9;
  --bg-soft: #f1f2f5;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #5d6068;
  --faint: #9a9ca5;
  --border: #e4e6eb;
  --border-strong: #d2d5dc;

  --success: #15803d;
  --success-50: #ecfdf3;
  --warning: #b45309;
  --warning-50: #fff7e6;
  --danger: #c52a2a;
  --danger-50: #fff0f0;
  --info: #1d5fc9;
  --info-50: #eef4ff;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 1px 2px rgba(16, 18, 27, .04), 0 2px 8px rgba(16, 18, 27, .04);
  --shadow-md: 0 8px 28px color-mix(in srgb, var(--primary) 9%, transparent), 0 2px 6px rgba(16, 18, 27, .04);
  --shadow-lg: 0 24px 60px color-mix(in srgb, var(--primary) 14%, transparent), 0 6px 16px rgba(16, 18, 27, .06);
  --shadow-glow: 0 6px 22px var(--primary-glow);

  --font-th: 'Noto Sans Thai', system-ui, sans-serif;
  --font-en: 'Outfit', 'Noto Sans Thai', system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .25, 1);
  --nav-h: 76px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-th);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--primary-100); }
:focus-visible { outline: 3px solid var(--primary-200); outline-offset: 2px; border-radius: 6px; }
.en { font-family: var(--font-en); }

#app { flex: 1; display: flex; flex-direction: column; }
main { flex: 1; }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 860px; }

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: .35;
}
.nav-inner { height: 100%; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); flex-shrink: 0; }
.brand:hover { color: var(--text); }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(140deg, var(--primary), var(--primary-700));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-en); font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow-glow);
  position: relative; overflow: hidden;
}
.brand-mark::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); right: -5px; bottom: -5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--font-en); font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-text small { font-size: 12px; color: var(--muted); }

.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-links a {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 500; font-size: 15px;
  transition: background .2s, color .2s;
  position: relative;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--text); }
.nav-links a.active { color: var(--primary); background: var(--primary-50); }
.nav-links a.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: -18px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--primary);
}
.nav-actions { display: flex; align-items: center; gap: 10px; }
.nav .nav-toggle { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 14px 5px 5px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; transition: border-color .2s, box-shadow .2s;
}
.user-chip:hover { border-color: var(--primary-200); box-shadow: var(--shadow-sm); }
.user-chip .avatar { width: 34px; height: 34px; font-size: 14px; }
.user-chip span { font-size: 14px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; line-height: 1; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0;
}

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 220px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: 60;
  animation: pop .18s var(--ease);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--text); font-size: 14px; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg-soft); }
.dropdown-menu i { width: 18px; color: var(--muted); }
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--card); --btn-fg: var(--text); --btn-bd: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 20px; border-radius: 12px;
  background: var(--btn-bg); color: var(--btn-fg); border: 1.5px solid var(--btn-bd);
  font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, color .2s;
  white-space: nowrap; user-select: none; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); color: var(--btn-fg); }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: #fff; --btn-bd: var(--primary); box-shadow: var(--shadow-glow); }
.btn-primary:hover { --btn-bg: var(--primary-600); --btn-bd: var(--primary-600); box-shadow: 0 10px 28px var(--primary-glow); }
.btn-accent { --btn-bg: var(--accent); --btn-fg: #2a2000; --btn-bd: var(--accent); }
.btn-outline { --btn-bg: transparent; --btn-fg: var(--primary); --btn-bd: var(--primary); }
.btn-outline:hover { --btn-bg: var(--primary-50); }
.btn-soft { --btn-bg: var(--primary-50); --btn-fg: var(--primary); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--primary-100); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--muted); --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--bg-soft); --btn-fg: var(--text); }
.btn-light { --btn-bg: #fff; --btn-fg: var(--text); --btn-bd: var(--border); }
.btn-light:hover { --btn-bd: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: var(--success); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger-soft { --btn-bg: var(--danger-50); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-sm { padding: 7px 13px; font-size: 13.5px; border-radius: 10px; gap: 7px; }
.btn-lg { padding: 15px 28px; font-size: 16.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 40px; height: 40px; border-radius: 12px; }
.btn-icon.btn-sm { width: 34px; height: 34px; border-radius: 10px; }
.btn .spin { animation: spin 1s linear infinite; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5;
  background: var(--bg-soft); color: var(--muted); white-space: nowrap;
}
.badge-primary { background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-100); }
.badge-accent { background: var(--accent-50); color: var(--accent-600); }
.badge-success { background: var(--success-50); color: var(--success); }
.badge-warning { background: var(--warning-50); color: var(--warning); }
.badge-danger { background: var(--danger-50); color: var(--danger); }
.badge-info { background: var(--info-50); color: var(--info); }
.badge-dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 15px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all .2s;
}
.chip:hover { border-color: var(--primary-200); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 28px; }
.card-pad-sm { padding: 20px; }
.card-hover { transition: transform .3s var(--ease), box-shadow .3s, border-color .3s; }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-100); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.card-head h3 i { color: var(--primary); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-sm { padding: 40px 0; }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 44px; }
.section-head h2 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 700; display: inline-flex; align-items: center; gap: 14px; }
.section-head h2 i { color: var(--primary); font-size: .85em; }
.section-head p { color: var(--muted); margin-top: 10px; font-size: 16.5px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--primary);
  padding: 6px 14px; border-radius: 999px; background: var(--primary-50); border: 1px solid var(--primary-100);
}

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Hero ---------- */
.hero { padding: 40px 0 24px; }
.hero-card {
  position: relative; overflow: hidden;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(900px 400px at 100% 0%, var(--primary-100), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, var(--accent-50), transparent 60%),
    var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 64px 56px;
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center;
}
.hero-card::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--primary) 14%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent 30%, #000 75%);
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 75%);
  pointer-events: none;
}
.hero-copy { position: relative; }
.hero h1 { font-size: clamp(32px, 4.6vw, 52px); font-weight: 700; margin: 22px 0 18px; line-height: 1.22; }
.hero h1 .hl {
  color: var(--primary); display: inline-block; position: relative;
}
.hero h1 .hl::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: .08em; height: .22em;
  background: var(--accent); opacity: .35; border-radius: 4px; z-index: -1;
  transform-origin: left; animation: grow 1s .4s var(--ease) both;
}
.hero-lead { color: var(--muted); font-size: 17.5px; max-width: 560px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 32px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 36px; color: var(--muted); font-size: 14.5px; }
.hero-meta span { display: flex; align-items: center; gap: 8px; }
.hero-meta i { color: var(--primary); }

.hero-visual { position: relative; min-height: 400px; }
.float-card {
  position: absolute; background: var(--card); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 18px;
  animation: float 6s ease-in-out infinite;
}
.fc-slide { left: 4%; top: 0; width: 74%; padding: 0; overflow: hidden; animation-delay: -1s; }
.fc-slide .fc-screen {
  aspect-ratio: 16/10; background: linear-gradient(140deg, var(--primary), var(--primary-700));
  color: #fff; padding: 24px; display: flex; flex-direction: column; justify-content: flex-end; position: relative; overflow: hidden;
}
.fc-slide .fc-screen::before {
  content: ''; position: absolute; width: 180px; height: 180px; border-radius: 50%;
  border: 28px solid rgba(255,255,255,.08); right: -40px; top: -50px;
}
.fc-slide .fc-screen b { font-size: 20px; }
.fc-slide .fc-screen small { opacity: .8; }
.fc-slide .fc-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; color: var(--muted); }
.fc-slide .fc-bar .progress { flex: 1; }
.fc-score { right: 0; top: 46%; width: 210px; animation-delay: -3s; display: flex; align-items: center; gap: 14px; }
.fc-score b { font-size: 15px; display: block; }
.fc-score small { color: var(--muted); font-size: 12.5px; }
.fc-file { left: 0; bottom: 0; width: 250px; animation-delay: -4.5s; display: flex; align-items: center; gap: 12px; }
.fc-file .fc-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--success-50); color: var(--success); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.fc-file b { font-size: 14px; display: block; }
.fc-file small { color: var(--success); font-size: 12.5px; font-weight: 600; }

/* ---------- Feature tiles ---------- */
.feature {
  padding: 30px 26px; text-align: left; cursor: pointer; position: relative; overflow: hidden;
  display: block; color: var(--text);
}
.feature:hover { color: var(--text); }
.feature-ico {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 24px;
  background: var(--primary-50); color: var(--primary); margin-bottom: 20px;
  transition: transform .4s var(--ease), background .3s, color .3s;
}
.feature:hover .feature-ico { transform: rotate(-8deg) scale(1.08); background: var(--primary); color: #fff; }
.feature h3 { font-size: 19px; margin-bottom: 8px; }
.feature p { color: var(--muted); font-size: 15px; }
.feature .arrow { position: absolute; right: 24px; top: 30px; color: var(--faint); transition: transform .3s var(--ease), color .3s; }
.feature:hover .arrow { transform: translateX(4px); color: var(--primary); }

/* ---------- Timeline (lessons on home) ---------- */
.timeline { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 22px; overflow-x: auto; padding: 8px 4px 24px; scroll-snap-type: x mandatory; }
/* connector from each dot to the next one (works however far the strip scrolls) */
.tl-item:not(:last-child)::after {
  content: ''; position: absolute; top: 36px; left: 50%; width: calc(100% + 22px); height: 4px; border-radius: 4px;
  background: var(--primary-100);
}
.tl-item.done:not(:last-child)::after { background: linear-gradient(90deg, var(--accent), var(--accent-50)); }
.tl-item { position: relative; text-align: center; scroll-snap-align: start; color: var(--text); }
.tl-item:hover { color: var(--text); }
.tl-dot {
  width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px; position: relative; z-index: 1;
  background: var(--card); color: var(--primary); border: 4px solid var(--primary-100);
  box-shadow: var(--shadow-md); transition: transform .35s var(--ease);
}
.tl-item:hover .tl-dot { transform: translateY(-4px) scale(1.05); }
.tl-item.done .tl-dot { background: var(--accent); color: #fff; border-color: var(--accent-50); }
.tl-item.current .tl-dot { background: var(--primary); color: #fff; border-color: var(--primary-100); box-shadow: 0 0 0 8px var(--primary-50), var(--shadow-glow); }
.tl-card { padding: 22px 18px; height: calc(100% - 94px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.tl-card .tl-unit { font-family: var(--font-en); font-weight: 600; font-size: 13px; color: var(--primary); background: var(--primary-50); padding: 3px 12px; border-radius: 999px; }
.tl-card h4 { font-size: 17px; }
.tl-card p { font-size: 14px; color: var(--muted); flex: 1; }

/* ---------- Page header (inner pages) ---------- */
.page-head { padding: 40px 0 28px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs i { font-size: 10px; opacity: .6; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 36px); font-weight: 700; }
.page-head p { color: var(--muted); margin-top: 6px; }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

.lesson-hero {
  border-radius: var(--radius-xl); padding: 36px 40px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(130deg, var(--primary), var(--primary-700));
  box-shadow: var(--shadow-lg);
}
.lesson-hero::before { content: ''; position: absolute; width: 340px; height: 340px; border-radius: 50%; border: 50px solid rgba(255,255,255,.06); right: -80px; top: -120px; }
.lesson-hero::after { content: ''; position: absolute; width: 140px; height: 140px; border-radius: 50%; background: var(--accent); opacity: .25; right: 140px; bottom: -70px; filter: blur(4px); }
.lesson-hero .crumbs, .lesson-hero .crumbs a { color: rgba(255,255,255,.75); }
.lesson-hero .crumbs a:hover { color: #fff; }
.lesson-hero h1 { font-size: clamp(24px, 3.2vw, 34px); position: relative; }
.lesson-hero p { opacity: .85; margin-top: 8px; position: relative; max-width: 720px; }
.lesson-hero .badge { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.22); }
.lesson-hero-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; position: relative; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; padding: 6px; background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-sm); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 18px; border-radius: 13px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap; transition: all .25s var(--ease);
  position: relative;
}
.tab:hover { color: var(--text); background: var(--bg-soft); }
.tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-glow); }
.tab .tab-check { width: 20px; height: 20px; border-radius: 50%; background: var(--success); color: #fff; font-size: 10px; display: grid; place-items: center; }
.tab.active .tab-check { background: #fff; color: var(--success); }
.tab-count { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--muted); }
.tab.active .tab-count { background: rgba(255,255,255,.2); color: #fff; }

/* ---------- Lesson cards ---------- */
.unit-block { margin-bottom: 44px; }
.unit-title { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.unit-title .unit-num {
  font-family: var(--font-en); font-weight: 700; width: 48px; height: 48px; border-radius: 15px;
  background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 20px; box-shadow: var(--shadow-glow);
}
.unit-title h2 { font-size: 22px; }
.unit-title small { color: var(--muted); font-size: 14px; display: block; font-weight: 400; }

.lesson-card { display: flex; flex-direction: column; overflow: hidden; color: var(--text); }
.lesson-card:hover { color: var(--text); }
.lesson-cover {
  height: 128px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  display: flex; align-items: flex-end; padding: 18px 22px; color: #fff;
}
.lesson-cover::before { content: ''; position: absolute; width: 170px; height: 170px; border-radius: 50%; border: 26px solid rgba(255,255,255,.09); right: -40px; top: -60px; transition: transform .6s var(--ease); }
.lesson-card:hover .lesson-cover::before { transform: scale(1.15) rotate(20deg); }
.lesson-cover .lc-ico { position: absolute; right: 22px; bottom: 16px; font-size: 40px; opacity: .9; transition: transform .5s var(--ease); }
.lesson-card:hover .lc-ico { transform: translateY(-4px) rotate(-6deg); }
.lesson-cover .lc-no { font-family: var(--font-en); font-weight: 600; font-size: 13px; background: rgba(255,255,255,.18); padding: 3px 11px; border-radius: 999px; }
.lesson-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.lesson-body h3 { font-size: 18px; }
.lesson-body p { color: var(--muted); font-size: 14.5px; flex: 1; }
.lesson-parts { display: flex; gap: 8px; flex-wrap: wrap; }
.part {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 8px; background: var(--bg-soft); color: var(--muted);
}
.part.done { background: var(--success-50); color: var(--success); }
.lesson-foot { display: flex; align-items: center; gap: 12px; padding-top: 6px; }
.lesson-foot .progress { flex: 1; }
.lesson-foot small { font-family: var(--font-en); font-weight: 600; color: var(--muted); font-size: 13px; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--primary)); transition: width .6s var(--ease); }
.progress.success > span { background: var(--success); }
.progress-lg { height: 12px; }

.ring { display: block; }
.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring-wrap .ring-label b { font-family: var(--font-en); font-weight: 700; display: block; }
.ring-wrap .ring-label small { font-size: 12px; color: var(--muted); display: block; }
.ring circle.ring-fg { transition: stroke-dashoffset 1.2s var(--ease); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.label { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 12px 15px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-size: 15.5px; transition: border-color .2s, box-shadow .2s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%235d6068' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 42px; }
.help { font-size: 13px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.input-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 44px; height: 26px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--primary-200); outline-offset: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; background: var(--bg-soft); padding: 12px 16px; white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 13px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--primary-50); }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-family: var(--font-en); font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }

/* ---------- Stats ---------- */
.stat { padding: 22px; display: flex; align-items: center; gap: 16px; }
.stat-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 21px; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.stat-ico.success { background: var(--success-50); color: var(--success); }
.stat-ico.accent { background: var(--accent-50); color: var(--accent-600); }
.stat-ico.info { background: var(--info-50); color: var(--info); }
.stat-ico.warning { background: var(--warning-50); color: var(--warning); }
.stat-value { font-family: var(--font-en); font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty-ico { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 26px; display: grid; place-items: center; font-size: 34px; background: var(--primary-50); color: var(--primary); }
.empty h3 { color: var(--text); font-size: 19px; margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--bg-soft) 25%, #e9ebef 50%, var(--bg-soft) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 12px; }
.loader { display: grid; place-items: center; padding: 80px 0; color: var(--primary); font-size: 28px; }

/* ---------- Modal & drawer ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(18, 16, 24, .45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px; animation: fade .2s ease;
}
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--radius-lg); box-shadow: 0 30px 80px rgba(0,0,0,.25);
  animation: pop .28s var(--ease);
}
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1080px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 26px 0; }
.modal-head h3 { font-size: 19px; }
.modal-body { padding: 18px 26px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 26px 22px; flex-wrap: wrap; }
.modal-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 28px; margin: 0 auto 14px; background: var(--primary-50); color: var(--primary); }
.modal-ico.danger { background: var(--danger-50); color: var(--danger); }
.modal-ico.success { background: var(--success-50); color: var(--success); }

.drawer-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(18,16,24,.4); animation: fade .2s ease; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 101; width: min(640px, 100%);
  background: var(--card); box-shadow: -20px 0 60px rgba(0,0,0,.18); display: flex; flex-direction: column;
  animation: slideIn .32s var(--ease);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 440px; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-radius: 14px;
  background: #1f1d24; color: #fff; box-shadow: 0 14px 40px rgba(0,0,0,.25); font-size: 14.5px;
  animation: toastIn .35s var(--ease); pointer-events: auto; max-width: 100%;
}
.toast i { font-size: 17px; }
.toast.success i { color: #4ade80; }
.toast.error i { color: #f87171; }
.toast.warning i { color: #fbbf24; }
.toast.info i { color: #93c5fd; }
.toast.out { animation: toastOut .3s var(--ease) forwards; }

/* ---------- Slides ---------- */
.deck { background: #111014; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); position: relative; }
.deck:fullscreen { border-radius: 0; display: flex; flex-direction: column; justify-content: center; }
.deck-stage { position: relative; aspect-ratio: 16/9; overflow: hidden; background: #fff; touch-action: pan-y; }
.deck:fullscreen .deck-stage { aspect-ratio: auto; flex: 1; }
.slide {
  position: absolute; inset: 0; padding: 6% 7%; display: flex; flex-direction: column; justify-content: center;
  opacity: 0; transform: translateX(40px); transition: opacity .45s var(--ease), transform .45s var(--ease);
  pointer-events: none; font-size: clamp(14px, 1.9vw, 24px);
  container-type: size;
}
.slide.active { opacity: 1; transform: none; pointer-events: auto; }
/* Tall content on small screens: keep the top visible and let the slide scroll instead of clipping both ends */
.slide { justify-content: safe center; overflow-y: auto; scrollbar-width: thin; }
.slide-title, .slide-quote, .slide-image, .slide-video { overflow: hidden; }
/* iPhone fallback for fullscreen (no element Fullscreen API) */
.deck.pseudo-fs {
  position: fixed; inset: 0; z-index: 150; border-radius: 0; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.deck.pseudo-fs .deck-stage { aspect-ratio: auto; flex: 1; }
.slide.prev { transform: translateX(-40px); }
.slide h2 { font-size: 2.1em; font-weight: 700; margin-bottom: .55em; color: var(--text); }
.slide h2::after { content: ''; display: block; width: 2.4em; height: .16em; border-radius: 4px; background: var(--accent); margin-top: .35em; }
.slide ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: .55em; }
.slide li { display: flex; gap: .7em; align-items: flex-start; opacity: 0; transform: translateY(12px); transition: all .45s var(--ease); }
.slide.active li { opacity: 1; transform: none; }
.slide li::before { content: ''; width: .5em; height: .5em; border-radius: 50%; background: var(--primary); margin-top: .55em; flex-shrink: 0; box-shadow: 0 0 0 .2em var(--primary-100); }
.slide-title { background: linear-gradient(135deg, var(--primary), var(--primary-700)); color: #fff; text-align: left; }
.slide-title::before { content: ''; position: absolute; width: 50%; aspect-ratio: 1; border-radius: 50%; border: 3em solid rgba(255,255,255,.07); right: -12%; top: -30%; }
.slide-title::after { content: ''; position: absolute; width: 18%; aspect-ratio: 1; border-radius: 50%; background: var(--accent); opacity: .35; right: 18%; bottom: -8%; }
.slide-title h2 { color: #fff; font-size: 2.7em; position: relative; z-index: 1; }
.slide-title h2::after { background: var(--accent); }
.slide-title p { font-size: 1.15em; opacity: .85; position: relative; z-index: 1; }
.slide-title .slide-kicker { font-family: var(--font-en); font-size: .8em; letter-spacing: .12em; text-transform: uppercase; opacity: .7; margin-bottom: .6em; position: relative; z-index: 1; }
.slide-quote { background: var(--primary-50); text-align: center; align-items: center; }
.slide-quote blockquote { margin: 0; font-size: 1.6em; font-weight: 600; line-height: 1.45; max-width: 85%; position: relative; }
.slide-quote blockquote::before { content: '\201C'; font-family: Georgia, serif; font-size: 3em; color: var(--primary); opacity: .3; position: absolute; left: -.5em; top: -.55em; }
.slide-quote cite { margin-top: 1em; color: var(--muted); font-style: normal; }
.slide-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 5%; align-items: center; }
.slide-split .slide-img { border-radius: .8em; overflow: hidden; box-shadow: var(--shadow-lg); aspect-ratio: 4/3; background: var(--bg-soft); display: grid; place-items: center; }
.slide-split .slide-img img { width: 100%; height: 100%; object-fit: cover; }
.slide-split .slide-img .slide-emoji { font-size: 5em; }
.slide-image { padding: 0; }
.slide-image img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.slide-image .caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 1em 1.4em; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; }
.slide-video { padding: 0; background: #000; }
.slide-video iframe { width: 100%; height: 100%; border: 0; }
.slide p.slide-text { color: var(--muted); font-size: 1.05em; }
.slide-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 1em; }
.slide-cards > div { background: var(--bg-soft); border-radius: .7em; padding: 1em; border-top: .25em solid var(--primary); opacity: 0; transform: translateY(14px); transition: all .5s var(--ease); }
.slide.active .slide-cards > div { opacity: 1; transform: none; }
.slide-cards b { display: block; font-size: 1.05em; margin-bottom: .3em; }
.slide-cards span { color: var(--muted); font-size: .85em; }
.slide-cards .sc-ico { font-size: 1.6em; margin-bottom: .3em; display: block; }

.deck-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #19171d; color: #fff; }
.deck-bar .btn-icon { --btn-bg: rgba(255,255,255,.08); --btn-fg: #fff; --btn-bd: transparent; width: 38px; height: 38px; }
.deck-bar .btn-icon:hover { --btn-bg: rgba(255,255,255,.16); }
.deck-count { font-family: var(--font-en); font-size: 14px; opacity: .8; min-width: 64px; text-align: center; }
.deck-progress { flex: 1; height: 5px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; cursor: pointer; }
.deck-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #fff); transition: width .4s var(--ease); }
.deck-thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 14px 2px 4px; scrollbar-width: thin; }
.thumb {
  flex-shrink: 0; width: 132px; aspect-ratio: 16/9; border-radius: 10px; border: 2px solid var(--border);
  background: var(--card); padding: 8px 10px; cursor: pointer; text-align: left; overflow: hidden;
  font-size: 11px; line-height: 1.35; color: var(--muted); transition: border-color .2s, transform .2s;
  display: flex; flex-direction: column; justify-content: space-between;
}
.thumb:hover { transform: translateY(-2px); }
.thumb.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.thumb b { color: var(--text); font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb small { font-family: var(--font-en); font-weight: 600; color: var(--primary); }
/* Slides, mode "pages": page images, image thumbnails, clips/links under the stage */
.deck-img { -webkit-user-drag: none; user-select: none; display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.deck-img[hidden], .deck-img-miss[hidden], .thumb-img[hidden] { display: none; }
.deck-img-miss { position: absolute; inset: 0; display: grid; place-items: center; padding: 1em; text-align: center; background: var(--bg-soft); color: var(--muted); font-size: 15px; }
.deck-thumbs.pages { display: flex; touch-action: pan-x; -webkit-overflow-scrolling: touch; } /* stays visible on phones (the text deck hides it) */
.thumb.pg { position: relative; padding: 0; background: var(--bg-soft); }
.thumb-img { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.thumb .thumb-no { position: absolute; left: 6px; bottom: 5px; padding: 1px 7px; border-radius: 6px; background: rgba(17, 16, 20, .78); color: #fff; font-size: 11px; line-height: 1.5; }
.thumb-play { position: absolute; right: 6px; top: 6px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 8px; }
.page-extras { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.page-extras:empty { display: none; }
.page-clip { position: relative; width: 100%; max-width: 720px; aspect-ratio: 16/9; border-radius: var(--radius-lg); overflow: hidden; background: #000; box-shadow: var(--shadow-lg); }
.page-clip iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.page-links { display: flex; flex-wrap: wrap; gap: 8px; }
.page-links .btn { max-width: 100%; }
.page-link-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.embed-frame { position: relative; aspect-ratio: 16/9; border-radius: var(--radius-lg); overflow: hidden; background: #111; box-shadow: var(--shadow-lg); }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-frame.tall { aspect-ratio: 3/4; max-height: 82vh; }

/* ---------- Quiz ---------- */
.quiz-wrap { max-width: 820px; margin: 0 auto; }
.quiz-intro { text-align: center; padding: 44px 32px; }
.quiz-intro .big-ico { width: 92px; height: 92px; border-radius: 28px; margin: 0 auto 20px; display: grid; place-items: center; font-size: 38px; background: linear-gradient(140deg, var(--primary), var(--primary-700)); color: #fff; box-shadow: var(--shadow-glow); animation: float 5s ease-in-out infinite; }
.quiz-intro h2 { font-size: 26px; margin-bottom: 8px; }
.quiz-facts { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin: 26px 0 30px; }
.quiz-fact { min-width: 120px; padding: 14px 18px; border-radius: 16px; background: var(--bg-soft); }
.quiz-fact b { display: block; font-family: var(--font-en); font-size: 24px; color: var(--primary); }
.quiz-fact small { color: var(--muted); font-size: 13px; }

.quiz-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.quiz-top .progress { flex: 1; }
.quiz-top .q-count { font-family: var(--font-en); font-weight: 600; color: var(--muted); font-size: 14px; white-space: nowrap; }
.timer { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--border); font-family: var(--font-en); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.timer.low { border-color: var(--danger); color: var(--danger); background: var(--danger-50); animation: pulse 1s ease-in-out infinite; }

.q-card { padding: 34px; animation: qIn .4s var(--ease); }
.q-card.out { animation: qOut .25s var(--ease) forwards; }
.q-label { font-family: var(--font-en); font-weight: 600; font-size: 13px; color: var(--primary); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 10px; }
.q-text { font-size: 21px; font-weight: 600; line-height: 1.5; margin-bottom: 24px; }
.q-img { border-radius: 16px; margin-bottom: 22px; max-height: 320px; object-fit: contain; background: var(--bg-soft); width: 100%; }
.choices { display: grid; gap: 12px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px 18px; border-radius: 16px; border: 2px solid var(--border); background: var(--card);
  cursor: pointer; font-size: 16.5px; transition: border-color .2s, background .2s, transform .15s var(--ease), box-shadow .2s;
}
.choice:hover { border-color: var(--primary-200); background: var(--primary-50); transform: translateX(3px); }
.choice .key {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-soft); font-family: var(--font-en); font-weight: 700; color: var(--muted); transition: all .2s;
}
.choice.selected { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 4px var(--primary-50); }
.choice.selected .key { background: var(--primary); color: #fff; transform: scale(1.06); }
.choice.correct { border-color: var(--success); background: var(--success-50); }
.choice.correct .key { background: var(--success); color: #fff; }
.choice.wrong { border-color: var(--danger); background: var(--danger-50); animation: shake .4s; }
.choice.wrong .key { background: var(--danger); color: #fff; }
.choice[disabled] { cursor: default; transform: none; }
.choice .mark { margin-left: auto; font-size: 18px; }
.choice.correct .mark { color: var(--success); }
.choice.wrong .mark { color: var(--danger); }
.tf-choices { grid-template-columns: 1fr 1fr; }
.tf-choices .choice { flex-direction: column; justify-content: center; padding: 26px 18px; font-weight: 600; font-size: 18px; }
.tf-choices .choice .key { width: 56px; height: 56px; font-size: 24px; border-radius: 18px; }
.explain { margin-top: 18px; padding: 16px 18px; border-radius: 14px; background: var(--info-50); color: #1e3a6e; font-size: 15px; display: flex; gap: 12px; animation: fadeUp .35s var(--ease); }
.explain i { color: var(--info); margin-top: 4px; }
.q-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; }
.q-dots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.q-dot { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card); font-family: var(--font-en); font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; transition: all .2s; }
.q-dot:hover { border-color: var(--primary-200); }
.q-dot.answered { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary); }
.q-dot.current { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.08); }
.q-dot.correct { background: var(--success); border-color: var(--success); color: #fff; }
.q-dot.wrong { background: var(--danger); border-color: var(--danger); color: #fff; }

.result { text-align: center; padding: 44px 32px; }
.result h2 { font-size: 28px; margin: 18px 0 6px; }
.result .result-msg { color: var(--muted); font-size: 16.5px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px auto; max-width: 520px; }
.result-stats div { padding: 16px; border-radius: 16px; background: var(--bg-soft); }
.result-stats b { display: block; font-family: var(--font-en); font-size: 26px; }
.result-stats small { color: var(--muted); font-size: 13px; }
.review-item { padding: 20px 22px; border-radius: 18px; border: 1.5px solid var(--border); background: var(--card); margin-bottom: 14px; }
.review-item.ok { border-left: 5px solid var(--success); }
.review-item.no { border-left: 5px solid var(--danger); }
.review-item h4 { font-size: 16px; margin-bottom: 10px; display: flex; gap: 10px; }
.review-ans { font-size: 14.5px; display: flex; flex-direction: column; gap: 4px; }
.review-ans .you-wrong { color: var(--danger); }
.review-ans .is-right { color: var(--success); font-weight: 600; }

/* ---------- Worksheet ---------- */
.ws-head { display: flex; align-items: center; gap: 16px; padding: 22px 26px; }
.ws-head .ws-ico { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 22px; background: var(--accent-50); color: var(--accent-600); flex-shrink: 0; }
.ws-head h2 { font-size: 20px; }
.ws-head p { color: var(--muted); font-size: 14.5px; }
.ws-progress { position: sticky; top: calc(var(--nav-h) + 12px); z-index: 5; display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin: 18px 0; }
.ws-progress .progress { flex: 1; }
.ws-progress small { font-weight: 600; color: var(--muted); white-space: nowrap; font-size: 13.5px; }
.ws-item { padding: 26px; margin-bottom: 16px; transition: border-color .25s, box-shadow .25s; }
.ws-item:focus-within { border-color: var(--primary-200); box-shadow: var(--shadow-md); }
.ws-item.answered .ws-num { background: var(--success); color: #fff; }
.ws-q { display: flex; gap: 14px; margin-bottom: 16px; }
.ws-num { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-50); color: var(--primary); font-family: var(--font-en); font-weight: 700; font-size: 14px; transition: all .3s; }
.ws-q-text { font-weight: 600; font-size: 16.5px; padding-top: 4px; }
.ws-q-text small { display: block; color: var(--muted); font-weight: 400; font-size: 13.5px; margin-top: 2px; }
.ws-points { margin-left: auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; padding-top: 6px; }
.ws-body { padding-left: 48px; }
.charcount { text-align: right; font-size: 12.5px; color: var(--faint); margin-top: 4px; font-family: var(--font-en); }
.opt-list { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px; border: 1.5px solid var(--border);
  cursor: pointer; transition: all .2s; background: var(--card);
}
.opt:hover { border-color: var(--primary-200); background: var(--primary-50); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; transition: all .2s; color: transparent; font-size: 11px; }
.opt.checkbox .tick { border-radius: 7px; }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.opt:has(input:checked) .tick { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt:has(input:focus-visible) { outline: 3px solid var(--primary-200); outline-offset: 2px; }
.fill-text { font-size: 17px; line-height: 2.4; }
.fill-text input { display: inline-block; width: auto; min-width: 120px; max-width: 220px; padding: 4px 10px; margin: 0 4px; border: 0; border-bottom: 2px dashed var(--primary-200); border-radius: 6px 6px 0 0; background: var(--primary-50); font: inherit; font-size: 16px; color: var(--primary-700); text-align: center; transition: all .2s; }
.fill-text input:focus { outline: 0; border-bottom-style: solid; border-bottom-color: var(--primary); background: var(--primary-100); }
.match-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-bottom: 10px; }
.match-left { padding: 12px 16px; border-radius: 12px; background: var(--bg-soft); font-weight: 500; }
.match-row > i { color: var(--faint); }
.sortable-list { display: grid; gap: 10px; }
.sort-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 14px; border: 1.5px solid var(--border); background: var(--card); cursor: grab; user-select: none; transition: box-shadow .2s, border-color .2s; }
.sort-item:active { cursor: grabbing; }
.sort-item .grip { color: var(--faint); }
.sort-item .pos { width: 28px; height: 28px; border-radius: 9px; background: var(--primary-50); color: var(--primary); font-family: var(--font-en); font-weight: 700; display: grid; place-items: center; font-size: 13px; flex-shrink: 0; }
.sort-item .sort-btns { margin-left: auto; display: flex; gap: 4px; }
.sort-ghost { opacity: .4; }
.sort-chosen { border-color: var(--primary); box-shadow: var(--shadow-md); }
.scale { display: flex; gap: 10px; flex-wrap: wrap; }
.scale label { flex: 1; min-width: 56px; cursor: pointer; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 14px; border: 1.5px solid var(--border); font-family: var(--font-en); font-weight: 700; font-size: 18px; transition: all .2s; }
.scale span small { font-family: var(--font-th); font-weight: 400; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.3; }
.scale label:hover span { border-color: var(--primary-200); }
.scale input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.scale input:checked + span small { color: rgba(255,255,255,.85); }
.ws-done { display: flex; gap: 16px; align-items: center; padding: 20px 24px; border-radius: 18px; background: var(--success-50); border: 1px solid color-mix(in srgb, var(--success) 25%, white); margin-bottom: 18px; }
.ws-done > i { font-size: 28px; color: var(--success); }
.feedback-box { padding: 16px 18px; border-radius: 14px; background: var(--accent-50); border-left: 4px solid var(--accent); margin-top: 10px; font-size: 15px; }
.feedback-box b { display: block; margin-bottom: 4px; color: var(--accent-600); }

/* ---------- Assignment / upload ---------- */
.dropzone {
  border: 2.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 44px 24px; text-align: center;
  background: var(--bg-soft); cursor: pointer; transition: all .25s var(--ease); position: relative;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone.drag { transform: scale(1.01); }
.dropzone .dz-ico { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 14px; display: grid; place-items: center; font-size: 30px; background: var(--card); color: var(--primary); box-shadow: var(--shadow-md); transition: transform .3s var(--ease); }
.dropzone:hover .dz-ico, .dropzone.drag .dz-ico { transform: translateY(-6px); }
.dropzone b { font-size: 17px; display: block; }
.dropzone small { color: var(--muted); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { display: grid; gap: 10px; margin-top: 16px; }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--card); animation: fadeUp .3s var(--ease); }
.file-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--primary-50); color: var(--primary); flex-shrink: 0; overflow: hidden; }
.file-ico img { width: 100%; height: 100%; object-fit: cover; }
.file-meta { flex: 1; min-width: 0; }
.file-meta b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta small { color: var(--muted); font-size: 12.5px; }
.file-meta .progress { margin-top: 6px; height: 6px; }
.seg { display: inline-flex; padding: 4px; border-radius: 14px; background: var(--bg-soft); gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.seg button { padding: 9px 16px; border-radius: 11px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; transition: all .2s; }
.seg button.active { background: var(--card); color: var(--primary); box-shadow: var(--shadow-sm); }
.history-item { display: flex; gap: 14px; padding: 16px 0; border-top: 1px solid var(--border); }
.history-item:first-child { border-top: 0; }
.due { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding: 7px 14px; border-radius: 12px; background: var(--warning-50); color: var(--warning); font-weight: 600; }
.due.late { background: var(--danger-50); color: var(--danger); }
.due.ok { background: var(--success-50); color: var(--success); }

/* ---------- Login ---------- */
.auth-wrap { min-height: calc(100vh - var(--nav-h)); display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 980px; display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; }
.auth-side {
  padding: 44px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--primary), var(--primary-700));
  display: flex; flex-direction: column; justify-content: space-between; gap: 30px;
}
.auth-side::before { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; border: 44px solid rgba(255,255,255,.07); right: -110px; bottom: -90px; }
.auth-side h2 { font-size: 28px; position: relative; }
.auth-side p { opacity: .85; position: relative; }
.auth-points { display: grid; gap: 14px; position: relative; }
.auth-points div { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.auth-points i { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,.14); display: grid; place-items: center; }
.auth-form { padding: 44px; }
.auth-form h3 { font-size: 24px; margin-bottom: 6px; }
.auth-form > p { color: var(--muted); margin-bottom: 26px; }

/* ---------- Me / profile ---------- */
.profile-card { display: flex; align-items: center; gap: 20px; padding: 28px; }
.profile-card .avatar { width: 72px; height: 72px; font-size: 28px; }
.profile-card h2 { font-size: 22px; }
.profile-card p { color: var(--muted); }
.work-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--border); transition: background .15s; color: var(--text); }
.work-row:first-child { border-top: 0; }
.work-row:hover { background: var(--primary-50); color: var(--text); }
.work-ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.work-ico.quiz { background: var(--info-50); color: var(--info); }
.work-ico.worksheet { background: var(--accent-50); color: var(--accent-600); }
.work-ico.assignment { background: var(--success-50); color: var(--success); }
.work-main { flex: 1; min-width: 0; }
.work-main b { display: block; font-size: 15px; }
.work-main small { color: var(--muted); font-size: 13px; }
.work-score { text-align: right; font-family: var(--font-en); }
.work-score b { font-size: 18px; display: block; }
.work-score small { color: var(--muted); font-size: 12px; font-family: var(--font-th); }

/* ---------- Teacher ---------- */
.t-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; padding: 32px 0 60px; align-items: start; }
.t-side { position: sticky; top: calc(var(--nav-h) + 24px); padding: 14px; }
.t-side a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--muted); font-weight: 500; font-size: 15px; transition: all .2s; }
.t-side a:hover { background: var(--bg-soft); color: var(--text); }
.t-side a.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-glow); }
.t-side a i { width: 20px; text-align: center; }
.t-side .t-side-label { font-size: 12px; font-weight: 600; color: var(--faint); padding: 14px 14px 6px; text-transform: uppercase; letter-spacing: .06em; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.answer-block { padding: 16px 18px; border-radius: 14px; background: var(--bg-soft); margin-bottom: 12px; }
.answer-block h5 { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 600; }
.answer-block div { white-space: pre-wrap; word-break: break-word; }
.editor-item { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; background: var(--card); position: relative; }
.editor-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.editor-item-head .ws-num { width: 30px; height: 30px; font-size: 13px; }
.editor-item-head .grow { flex: 1; }
.choice-edit { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.choice-edit input[type=radio], .choice-edit input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--success); flex-shrink: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.gradebook th, .gradebook td { text-align: center; }
.gradebook th:first-child, .gradebook td:first-child, .gradebook th:nth-child(2), .gradebook td:nth-child(2) { text-align: left; }
.cell-score { font-family: var(--font-en); font-weight: 600; }
.cell-none { color: var(--faint); }

/* ---------- Footer ---------- */
.footer { margin-top: 40px; background: #17151b; color: rgba(255,255,255,.7); padding: 48px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 40px; }
.footer .brand { color: #fff; }
.footer .brand-text small { color: rgba(255,255,255,.55); }
.footer h4 { color: #fff; font-size: 15px; margin-bottom: 14px; }
.footer a { color: rgba(255,255,255,.7); display: block; padding: 4px 0; font-size: 14.5px; }
.footer a:hover { color: #fff; }
.footer p { font-size: 14.5px; margin-top: 14px; max-width: 360px; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); margin-top: 36px; padding-top: 20px; font-size: 13.5px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.demo-banner {
  background: linear-gradient(90deg, var(--accent-50), #fff8e5); color: #6b5300; font-size: 13.5px; text-align: center; padding: 8px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, white);
}
.demo-banner a { color: #6b5300; font-weight: 600; text-decoration: underline; }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }
.xsmall { font-size: 12.5px; }
.bold { font-weight: 600; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; }
.gap-sm { gap: 8px; }
.gap-lg { gap: 20px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

[data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
[data-reveal].in { opacity: 1; transform: none; }
.view-enter { animation: fadeUp .45s var(--ease); }

/* ---------- Keyframes ---------- */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }
@keyframes slideIn { from { transform: translateX(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes pulse { 50% { transform: scale(1.04); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes qIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes qOut { to { opacity: 0; transform: translateX(-30px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-card { grid-template-columns: 1fr; padding: 48px 36px; }
  .hero-visual { min-height: 360px; max-width: 520px; width: 100%; margin: 0 auto; }
  .t-layout { grid-template-columns: 1fr; }
  .t-side { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .t-side .t-side-label { display: none; }
  .t-side a { white-space: nowrap; }
}
@media (max-width: 900px) {
  .nav-links { display: none; position: absolute; left: 0; right: 0; top: var(--nav-h); background: #fff; flex-direction: column; align-items: stretch; padding: 12px 16px 18px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg); gap: 2px; }
  .nav.open .nav-links { display: flex; animation: fadeUp .25s var(--ease); }
  .nav-links a { padding: 12px 14px; }
  .nav-links a.active::after { display: none; }
  .nav .nav-toggle { display: inline-flex; }
  .nav-actions { margin-left: auto; }
  .nav-inner { gap: 10px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-card { grid-template-columns: 1fr; }
  .auth-side { padding: 32px; }
  .auth-side .auth-points { display: none; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .slide-split { grid-template-columns: 1fr; }
  .slide-split .slide-img { display: none; }
}
@media (max-width: 640px) {
  :root { --nav-h: 66px; }
  body { font-size: 15.5px; }
  .container { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid { gap: 16px; }
  .section { padding: 48px 0; }
  .hero { padding: 16px 0; }
  .hero-card { padding: 36px 22px; border-radius: var(--radius-lg); gap: 28px; }
  .hero-actions { gap: 10px; }
  .hero-actions .btn-lg { flex: 1 1 140px; padding: 14px 18px; font-size: 15.5px; }
  .hero-meta { gap: 10px 18px; margin-top: 26px; }
  .hero-visual { min-height: 290px; }
  .fc-slide { width: 88%; left: 0; }
  .fc-score { width: auto; padding: 12px 14px; top: 44%; gap: 10px; }
  .fc-score small { display: none; }
  .fc-file { width: auto; max-width: 86%; padding: 12px 14px; }
  .brand-text small { display: none; }
  .user-chip span, .user-chip small { display: none; }
  .user-chip { padding: 4px; }
  .card-pad { padding: 22px; }
  .lesson-hero { padding: 28px 22px; border-radius: var(--radius-lg); }
  .tab { padding: 11px 14px; font-size: 14px; flex: none; }
  .q-card { padding: 22px; }
  .q-text { font-size: 18px; }
  .choice { padding: 13px 14px; font-size: 15.5px; }
  .ws-item { padding: 20px; }
  .ws-body { padding-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }
  .match-row { grid-template-columns: 1fr; gap: 6px; }
  .match-row > i { transform: rotate(90deg); justify-self: center; }
  .result-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .result-stats b { font-size: 20px; }
  .auth-form { padding: 28px 22px; }
  .modal-head, .modal-body, .modal-foot { padding-left: 20px; padding-right: 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .slide { font-size: 12px; padding: 5% 6%; }
  .deck-stage { aspect-ratio: 4 / 3; } /* more height for text on phones */
  .slide-cards { grid-auto-flow: row; grid-template-columns: 1fr 1fr; gap: .6em; }
  .deck-thumbs { display: none; }
  .work-row { padding: 14px 16px; gap: 12px; }
  .toast-stack { bottom: 16px; }
  .ws-done { flex-wrap: wrap; }
  .ws-done > .btn { width: 100%; }
}
