/* HUG LMS. One stylesheet for every page; colors follow the Radix teal/slate scales the
   React UI used. Thai needs a taller line height than Latin text. */
:root {
  --font: 'IBM Plex Sans Thai', -apple-system, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  --g1: #fcfcfd; --g2: #f9f9fb; --g3: #f0f0f3; --g4: #e8e8ec; --g5: #e0e1e6; --g6: #d9d9e0;
  --g9: #8b8d98; --g10: #80838d; --g11: #60646c; --g12: #1c2024;
  --a2: #f3fbf9; --a3: #e0f8f3; --a5: #b8eae0; --a7: #83cdc1; --a8: #53b9ab; --a9: #12a594; --a10: #0d9b8a; --a11: #008573;
  --red2: #fff7f7; --red5: #ffcdce; --red9: #e5484d; --red11: #ce2c31; --red3: #feebec;
  --green2: #f4fbf6; --green3: #e6f6eb; --green5: #c4e8d1; --green9: #30a46c; --green11: #218358;
  --orange3: #fff1e7; --orange5: #ffd19a; --orange11: #cc4e00;
  --blue3: #e6f4fe; --blue11: #0d74ce;
  --radius: 10px;
  --bottom-nav: 64px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); line-height: 1.6; color: var(--g12); background: var(--g1); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3, h4, h5 { margin: 0 0 .25em; line-height: 1.35; }
.h2 { font-size: 26px; font-weight: 700; }
.h3 { font-size: 22px; font-weight: 700; }
.h4 { font-size: 18px; font-weight: 700; }
.h5 { font-size: 16px; font-weight: 700; }
.small { font-size: 14px; } .xsmall { font-size: 12px; }
.muted { color: var(--g11); } .strong { font-weight: 600; }
.red-text { color: var(--red11); } .green-text { color: var(--green11); } .orange-text { color: var(--orange11); } .teal-text { color: var(--a11); }
.center { text-align: center; } .end { text-align: right; }
.pre-line { white-space: pre-line; }
.mb { margin-bottom: 16px; } .mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mt-lg { margin-top: 32px; }
.row { display: flex; } .wrap { flex-wrap: wrap; } .gap { gap: 12px; } .gap-sm { gap: 6px; }
.row.between { justify-content: space-between; } .row.end { justify-content: flex-end; } .center-y { align-items: center; }
.grow { flex: 1; min-width: 180px; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack-sm { display: flex; flex-direction: column; gap: 6px; }
.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-1 { -webkit-line-clamp: 1; } .clamp-2 { -webkit-line-clamp: 2; }
[hidden] { display: none !important; }

/* ---- Controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border: 1px solid transparent; border-radius: 8px;
  background: var(--a9); color: white; font: inherit; font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--a10); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible { outline: 2px solid var(--a8); outline-offset: 1px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.lg { min-height: 44px; padding: 8px 18px; font-size: 16px; }
.btn.sm { min-height: 28px; padding: 2px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.soft { background: var(--a3); color: var(--a11); } .btn.soft:hover { background: var(--a5); }
.btn.soft.gray { background: var(--g3); color: var(--g12); } .btn.soft.gray:hover { background: var(--g4); }
.btn.soft.red { background: var(--red3); color: var(--red11); } .btn.soft.red:hover { background: var(--red5); }
.btn.outline { background: white; color: var(--g12); border-color: var(--g6); } .btn.outline:hover { background: var(--g2); }
.btn.outline.red, .btn.outline.red:hover { color: var(--red11); border-color: var(--red5); background: white; }
.btn.outline.red:hover { background: var(--red3); }
.btn.red { background: var(--red9); } .btn.red:hover { background: var(--red11); }
.btn.ghost { background: transparent; color: var(--a11); } .btn.ghost:hover { background: var(--a3); }
.btn.ghost.red { color: var(--red11); } .btn.ghost.red:hover { background: var(--red3); }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--g11); font-size: 16px; cursor: pointer; list-style: none; }
.icon-btn:hover { background: var(--g3); } .icon-btn[disabled] { opacity: .3; }
.input, .select { min-height: 36px; padding: 6px 10px; border: 1px solid var(--g6); border-radius: 8px; background: white; font: inherit; font-size: 15px; color: inherit; }
.input.lg { min-height: 44px; font-size: 16px; } .input.sm { min-height: 30px; font-size: 13px; }
.input.block { width: 100%; }
textarea.input { resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field small { font-weight: 400; }
.input-wrap { position: relative; display: block; } .input-wrap .input { width: 100%; padding-right: 64px; }
.link-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--a11); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 8px; }
.link { color: var(--a11); font-weight: 600; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--g3); max-width: 100%; overflow-x: auto; }
.segmented > * { padding: 4px 12px; border: 0; border-radius: 7px; background: transparent; font: inherit; font-size: 14px; color: var(--g11); text-decoration: none; cursor: pointer; white-space: nowrap; }
.segmented > [aria-selected="true"] { background: white; color: var(--g12); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.segmented.sm > * { padding: 2px 10px; font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--g3); color: var(--g11); }
.badge.lg { font-size: 13px; padding: 3px 10px; }
.badge.green { background: var(--green3); color: var(--green11); } .badge.red { background: var(--red3); color: var(--red11); }
.badge.blue { background: var(--blue3); color: var(--blue11); } .badge.orange { background: var(--orange3); color: var(--orange11); }
.badge.teal, .badge.soft { background: var(--a3); color: var(--a11); }
.badge-x { border: 0; background: none; cursor: pointer; font-size: 15px; line-height: 1; color: inherit; padding: 0 0 0 4px; }
.callout { padding: 10px 14px; border-radius: 8px; background: var(--a2); color: var(--g12); border: 1px solid var(--a5); font-size: 14px; }
.callout.red { background: var(--red2); border-color: var(--red5); color: var(--red11); }
.callout.green { background: var(--green2); border-color: var(--green5); color: var(--green11); }
.callout.orange { background: var(--orange3); border-color: var(--orange5); color: var(--orange11); }
.callout.gray { background: var(--g2); border-color: var(--g4); }
.card { background: white; border: 1px solid var(--g4); border-radius: 14px; padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.tint-green { background: var(--green3); border-color: var(--green5); }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--a3); color: var(--a11); font-weight: 600; font-size: 14px; flex: none; }
.avatar.xl { width: 64px; height: 64px; font-size: 24px; }
.bar { display: inline-block; flex: 1; max-width: 160px; height: 6px; border-radius: 3px; background: var(--g4); overflow: hidden; }
.bar.wide { display: block; max-width: none; margin: 6px 0; }
.bar > span { display: block; height: 100%; background: var(--a9); transition: width .4s ease; }
.empty { padding: 24px 0; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table-wrap.scroll { max-height: 440px; overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--g12); padding: 10px 12px; border-bottom: 1px solid var(--g5); background: var(--g2); position: sticky; top: 0; z-index: 1; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--g3); vertical-align: middle; }
.table.sm th, .table.sm td { padding: 7px 10px; }
.table tbody tr:hover { background: var(--g2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a { color: var(--g12); } .table a:hover { color: var(--a11); }
.kv { display: grid; grid-template-columns: auto 1fr; margin: 0 0 16px; font-size: 14px; }
.kv dt { color: var(--g11); padding: 8px 0; border-bottom: 1px solid var(--g3); }
.kv dd { margin: 0; padding: 8px 0; text-align: right; border-bottom: 1px solid var(--g3); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--g3); font-size: 14px; }

/* ---- Shell ---- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 24px; height: 60px; padding: 0 20px; background: white; border-bottom: 1px solid var(--g4); }
.logo img { display: block; height: 44px; width: auto; }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; color: var(--g11); text-decoration: none; font-size: 15px; white-space: nowrap; }
.topnav-link svg { width: 18px; height: 18px; }
.topnav-link:hover { background: var(--g3); color: var(--g12); }
.topnav-link.active { background: var(--a3); color: var(--a11); font-weight: 600; }
.usermenu { position: relative; margin-left: auto; }
.usermenu > summary, .dropdown > summary { list-style: none; cursor: pointer; }
.usermenu > summary::-webkit-details-marker, .dropdown > summary::-webkit-details-marker { display: none; }
.usermenu > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 4px 4px 12px; border: 1px solid var(--g5); border-radius: 999px; font-size: 14px; }
.usermenu > summary:hover { background: var(--g3); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 200px; padding: 6px; background: white; border: 1px solid var(--g4); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.12); }
.menu a, .menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--g12); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--a9); color: white; }
.menu hr { border: 0; border-top: 1px solid var(--g4); margin: 4px 0; }
.menu .menu-danger { color: var(--red11); } .menu .menu-danger:hover { background: var(--red9); color: white; }
.menu-nav { display: none; }
.dropdown { position: relative; }
.main { max-width: 1200px; margin: 0 auto; padding: 16px 20px 32px; }
.bottomnav { display: none; }
.page.narrow { max-width: 560px; margin: 0 auto; }
.page.medium { max-width: 820px; margin: 0 auto; }
.back { display: inline-block; margin-bottom: 12px; color: var(--a11); text-decoration: none; font-size: 15px; }

/* ---- Login / register ---- */
.auth-page { display: flex; min-height: 100vh; background: var(--g2); }
.auth-hero { flex: 1.2; background: #f36f25; overflow: hidden; }
.auth-hero video { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; padding: 32px 28px; background: white; border-radius: 16px; box-shadow: 0 8px 30px rgba(15,23,42,.08); }
.auth-logo { height: 48px; width: auto; align-self: flex-start; margin-left: -12px; }

/* ---- Learner home ---- */
.my-lessons { max-width: 880px; margin: 0 auto; }
.summary { display: flex; align-items: center; gap: 16px; }
.ring { --pct: 0%; flex: none; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--a9) var(--pct), var(--g4) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: white; display: grid; place-items: center; font-weight: 700; font-size: 18px; color: var(--a11); }
.resume { display: flex; gap: 14px; margin-top: 12px; padding: 14px; background: var(--a2); border: 1px solid var(--a5); border-radius: 14px; text-decoration: none; }
.resume-cover { flex: none; width: 112px; aspect-ratio: 16/9; border-radius: 10px; object-fit: cover; background: linear-gradient(135deg, var(--a10), var(--a8)); color: white; display: grid; place-items: center; font-size: 1.5rem; }
.resume-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.filters { margin: 20px 0 8px; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li + li { border-top: 1px solid var(--g3); }
.lesson-row { display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 12px 14px; text-decoration: none; }
.lesson-row:hover, .lesson-row:focus-visible { background: var(--g2); }
.lesson-cover { position: relative; flex: none; width: 88px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: rgba(255,255,255,.9); background: linear-gradient(135deg, #1f4e79, #3a7bbf); }
.lesson-cover.done { background: linear-gradient(135deg, var(--green9), #5bb98b); }
.lesson-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lesson-cover img + .lesson-badge { position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: rgba(0,0,0,.55); }
.lesson-cover.done img + .lesson-badge { background: var(--green9); }
.lesson-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lesson-name { font-weight: 500; }

/* ---- Lesson ---- */
.lesson-page { max-width: 1100px; margin: 0 auto; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.lesson-title { margin-top: 16px; }
.player video { display: block; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 12px; }
.player.placeholder, .player-error { display: grid; place-items: center; width: 100%; aspect-ratio: 16/9; background: var(--g3); color: var(--g11); border-radius: 12px; }
.action-bar { position: sticky; top: 76px; }
.next-action { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: white; border: 1px solid var(--g4); border-radius: 14px; }
.next-action.done { background: var(--green2); border-color: var(--green5); }
.next-action.warn { background: var(--red2); border-color: var(--red5); }
.next-action .btn { width: 100%; }

/* ---- Exam ---- */
.exam-page { max-width: 880px; margin: 0 auto; }
.questions { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.question-text { font-size: 17px; font-weight: 500; margin: 4px 0 12px; }
.question.missing .question-text { color: var(--red11); }
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--g5); border-radius: 10px; cursor: pointer; }
.choice:hover { border-color: var(--a8); background: var(--g2); }
.choice input { width: 18px; height: 18px; accent-color: var(--a9); flex: none; }
.choice:has(input:checked) { border: 2px solid var(--a9); background: var(--a2); }
.exam-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.exam-foot > span { margin-right: auto; }
.exam-dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.exam-dot { width: 34px; height: 34px; padding: 0; border-radius: 50%; font: inherit; font-size: 13px; background: white; color: var(--g11); border: 1px solid var(--g6); cursor: pointer; }
.exam-dot.answered { background: var(--a3); border-color: var(--a7); color: var(--a11); }
.exam-dot.current { outline: 2px solid var(--a9); outline-offset: 1px; }
.exam-dot.missing { border-color: var(--red9); color: var(--red11); }
.big-score { font-size: 40px; font-weight: 700; margin: 16px 0; }

/* ---- Admin ---- */
.lesson-cell { display: flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; }
.lesson-cell:hover .strong { color: var(--a11); text-decoration: underline; }
.thumb { flex: none; width: 80px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--g3); }
.thumb.placeholder { display: grid; place-items: center; color: white; background: linear-gradient(135deg, #1f4e79, #3a7bbf); }
.cover-preview { width: 240px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.cover-preview.empty { display: grid; place-items: center; background: var(--g3); }
.checklist { list-style: none; padding: 0; margin: 0 0 12px; }
.checklist .ok { color: var(--green11); } .checklist .ok::before { content: '✓ '; }
.checklist .warn { color: var(--orange11); } .checklist .warn::before { content: '! '; }
.exam-list > li { margin-bottom: 12px; } .exam-list ol { margin: 4px 0; }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--g5); border-radius: 8px; padding: 6px 10px; }
.pick-list.tall { max-height: 380px; }
.pick-list label { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.pick-list .group-label { font-size: 12px; color: var(--g11); margin-top: 6px; }
.suggestion, .pick-row { padding: 6px 8px; border-radius: 8px; background: var(--g2); }
.emp { min-width: 0; }
.people { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.group-list { width: 260px; display: flex; flex-direction: column; gap: 4px; }
.group-item { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: var(--g3); text-decoration: none; font-size: 14px; }
.group-item.active { background: var(--a9); color: white; }
.secret { padding: 12px 16px; border-radius: 8px; background: var(--g3); font: 600 22px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .1em; }
.progress { font-size: 13px; }

/* ---- Dialogs, toast, tooltip ---- */
.dialog { width: min(440px, calc(100vw - 32px)); padding: 20px; border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgba(15,23,42,.25); }
.dialog.wide { width: min(620px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15,23,42,.4); }
.dialog-title { font-size: 18px; }
.dialog-input { width: 100%; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; padding: 10px 16px; border-radius: 10px; background: var(--g12); color: white; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast.error { background: var(--red11); }
.tooltip { position: absolute; z-index: 80; padding: 8px 10px; border-radius: 8px; background: var(--g12); color: white; font-size: 12px; white-space: nowrap; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.15); transform: translate(-50%, calc(-100% - 8px)); }
.tooltip div:first-child { font-weight: 600; font-size: 13px; } .tooltip div + div { opacity: .8; }

/* ---- Dashboard ---- */
.dashboard { --mark: var(--a10); --mark-soft: var(--a3); }
.dashboard .card { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.hero { display: grid; grid-template-columns: minmax(240px, 1fr) 2fr; gap: 24px; align-items: center; }
.hero-value { font-size: 52px; font-weight: 600; line-height: 1.1; }
.hero-value span { font-size: 18px; font-weight: 500; color: var(--g11); }
.meter { margin-top: 10px; height: 10px; border-radius: 5px; background: var(--mark-soft); overflow: hidden; }
.meter > div { height: 100%; border-radius: 5px; background: var(--mark); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { display: block; padding: 12px; border-radius: 10px; background: var(--g2); text-decoration: none; }
.stat.link:hover { background: var(--g3); }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart { position: relative; }
.columns { position: relative; display: flex; height: 180px; }
.grid-lines { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.grid-lines > div { position: relative; border-top: 1px solid var(--g3); height: 0; }
.grid-lines span { position: absolute; left: 0; top: -16px; font-size: 11px; color: var(--g10); }
.columns-plot { position: relative; flex: 1; display: flex; align-items: flex-end; gap: 2px; padding-left: 32px; }
.column-slot { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.column-slot:hover, .column-slot:focus-visible { background: var(--g2); }
.column { width: 100%; max-width: 24px; min-height: 2px; background: var(--mark); border-radius: 4px 4px 0 0; }
.cap-label { position: absolute; left: 0; right: 0; margin-bottom: 4px; text-align: center; font-size: 12px; font-weight: 600; }
.columns-axis { display: flex; gap: 2px; padding-left: 32px; margin-top: 6px; }
.columns-axis span { flex: 1; text-align: center; font-size: 11px; color: var(--g10); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 240px) 1fr; align-items: center; gap: 12px; padding: 4px 0; border-radius: 6px; outline: none; }
.bar-row:hover, .bar-row:focus-visible { background: var(--g2); }
.bar-label { font-size: 13px; color: var(--g11); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 18px; padding-right: 40px; }
.bar-area { position: relative; height: 100%; }
.hbar { height: 100%; min-width: 2px; background: var(--mark); border-radius: 0 4px 4px 0; }
.goal-line { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px solid var(--g12); margin-left: -1px; }
.bar-value { position: absolute; top: 50%; transform: translateY(-50%); margin-left: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.bars-legend { margin-top: 8px; font-size: 12px; color: var(--g11); display: flex; align-items: center; gap: 6px; }
.goal-key { display: inline-block; height: 14px; border-left: 2px solid var(--g12); }
.inline-track { display: inline-block; width: 120px; height: 8px; border-radius: 4px; background: var(--mark-soft); overflow: hidden; }
.inline-track > span { display: block; height: 100%; background: var(--mark); border-radius: 4px; }

/* Admin menu has eight items: drop the icons and tighten before it needs scrolling. */
@media (max-width: 1500px) {
  .topbar { gap: 12px; }
  .topnav-link { padding: 8px 6px; font-size: 14px; }
  .topnav-link svg { display: none; }
}

@media (max-width: 900px) {
  .hero, .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: minmax(90px, 40%) 1fr; }
}

/* ---- Phones ---- */
@media (max-width: 767px) {
  .topbar { height: 56px; padding: 0 12px; gap: 12px; }
  .logo img { height: 36px; }
  .topnav, .usermenu-name { display: none; }
  .usermenu > summary { padding: 4px; border: 0; }
  .menu-nav { display: block; }
  .main { padding: 12px; }
  .has-bottom-nav .main { padding-bottom: calc(var(--bottom-nav) + 24px + env(safe-area-inset-bottom)); }
  .bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; height: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: white; border-top: 1px solid var(--g4); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--g10); text-decoration: none; font-size: 12px; }
  .bottomnav a.active { color: var(--a11); font-weight: 600; }
  .hide-sm { display: none; }
  .auth-hero { display: none; }
  .auth-panel { align-items: flex-start; padding: 24px 16px; }
  .auth-card { padding: 24px 20px; box-shadow: none; border: 1px solid var(--g4); }
  .filters .segmented { width: 100%; }
  .filters .segmented > * { flex: 1; }
  .lesson-cover { width: 72px; }
  .lesson-layout { grid-template-columns: 1fr; gap: 12px; }
  .lesson-page { padding-bottom: 96px; }
  .action-bar { position: fixed; top: auto; left: 0; right: 0; bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); z-index: 40; padding: 8px 12px; background: rgba(255,255,255,.96); border-top: 1px solid var(--g4); backdrop-filter: blur(6px); }
  .next-action { flex-direction: row; align-items: center; padding: 0; border: 0; background: transparent; }
  .next-action.done, .next-action.warn { padding: 8px 12px; }
  .next-action-text { flex: 1; min-width: 0; }
  .next-action .btn { width: auto; flex: none; }
  /* Exam: one question per screen (exam.js), navigation fixed above the bottom bar */
  .exam-page.paged .question:not(.current) { display: none; }
  .exam-page.paged .exam-foot { position: fixed; left: 0; right: 0; bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); z-index: 40; padding: 10px 12px; background: rgba(255,255,255,.96); border-top: 1px solid var(--g4); }
  .exam-page.paged { padding-bottom: 88px; }
  .thumb { width: 56px; }
  .group-list { width: 100%; }
}
