/* Medicoras design tokens: warm paper canvas, ink actions, one violet accent. */
:root {
  --ink: #0A1A3F;
  --ink-2: #13285C;
  --navy: var(--ink);
  --navy-2: var(--ink-2);
  --primary: #2563FF;
  --primary-2: #1A4FE0;
  --primary-50: #EDF2FF;
  --primary-100: #D9E4FF;
  --text: #0A1A3F;
  --slate: #4A5675;
  --muted: #8B95AE;
  --line: #E3E8F2;
  --line-2: #D5DCEA;
  --bg: #F2F5FB;
  --soft: #F7F9FD;
  --card: #FFFFFF;
  --green: #0F9D58;
  --green-50: #E7F7EE;
  --amber: #B25E00;
  --amber-2: #FFAD33;
  --amber-50: #FFF4E2;
  --red: #E03A3A;
  --red-2: #BF2424;
  --red-50: #FDEDED;
  --violet: #2563FF;
  --violet-50: #EDF2FF;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(10, 26, 63, .05);
  --shadow-lg: 0 16px 36px -14px rgba(10, 26, 63, .28);
  --ring: 0 0 0 4px rgba(37, 99, 255, .16);
  --hero: radial-gradient(700px 300px at 100% 0%, rgba(37, 99, 255, .45), transparent 65%), radial-gradient(500px 260px at 0% 100%, rgba(80, 140, 255, .22), transparent 70%), linear-gradient(135deg, #0A1A3F, #0E2456);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.015em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--primary-100); }
:focus-visible { outline: none; box-shadow: var(--ring); }
.ti { font-size: 18px; line-height: 1; vertical-align: -3px; }
.muted { color: var(--muted); }
.slate { color: var(--slate); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: #fff; color: var(--text); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.btn:hover { background: var(--soft); border-color: #C8D1E3; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.p { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.p:hover { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn.g { background: var(--green); border-color: var(--green); color: #fff; }
.btn.r { color: var(--red); }
.btn.r.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: var(--soft); }
.input, select.input, textarea.input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 96px; padding: 11px 14px; resize: vertical; }
.input:hover { border-color: #C8D1E3; }
.input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder { color: var(--muted); }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.search { position: relative; }
.search .ti { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.search .input { padding-left: 38px; }

/* ---------- Badges, avatars, progress ---------- */
.bg { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.bg::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.bg.g { background: var(--green-50); color: var(--green); }
.bg.a { background: var(--amber-50); color: var(--amber); }
.bg.r { background: var(--red-50); color: var(--red-2); }
.bg.u { background: #EDF1F8; color: var(--slate); }
.bg.v { background: var(--violet-50); color: var(--violet); }
.bg.b { background: var(--primary-50); color: var(--primary); }
.av { --h: 210; display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: hsl(var(--h) 60% 93%); color: hsl(var(--h) 45% 32%); font-size: 12px; font-weight: 700; }
.av.lg { width: 60px; height: 60px; font-size: 19px; }
.pb { height: 6px; border-radius: 99px; background: #E6EBF4; overflow: hidden; }
.pb span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .4s; }
.pb.g span { background: var(--green); }
.pb.a span { background: var(--amber-2); }

/* ---------- Cards, KPIs, lists, tables ---------- */
.cd { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cd-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cd-h h2 { font-size: 15px; font-weight: 700; }
.cd-h a { font-weight: 600; font-size: 13px; }
.cd-b { padding: 20px; }
.grid { display: grid; gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 18px; }
.kv { padding: 20px; display: grid; gap: 4px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.kv .k { display: flex; align-items: center; justify-content: space-between; color: var(--slate); font-size: 13px; font-weight: 600; }
.kv .k .ti { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--primary-50); color: var(--primary); }
.kv .k .ti.a { background: var(--amber-50); color: var(--amber); }
.kv .k .ti.g { background: var(--green-50); color: var(--green); }
.kv .k .ti.v { background: var(--violet-50); color: var(--violet); }
.kv .v { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; margin-top: 4px; }
.kv .s { font-size: 12px; color: var(--muted); }
.li { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); transition: background .15s; }
a.li:hover { background: var(--soft); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .d { font-size: 12px; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .ti { font-size: 22px; display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 10px; border-radius: 14px; background: #EDF1F8; color: var(--slate); }
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click, .tbl tr[data-href] { cursor: pointer; }
.tbl tr.click:hover td, .tbl tr[data-href]:hover td { background: var(--soft); }
.person { display: flex; align-items: center; gap: 12px; }
.person .n { font-weight: 600; }
.person .c { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1; min-width: 200px; }
.toolbar select.input { width: auto; }
.tabs { display: inline-flex; gap: 2px; flex-wrap: wrap; padding: 4px; border-radius: 12px; background: #E8EDF6; }
.tabs button { height: 32px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--slate); font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(10, 26, 63, .1); }
.tabs button em { font-style: normal; margin-left: 5px; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--slate); font-weight: 600; margin-bottom: 16px; transition: color .15s, gap .15s; }
.back:hover { color: var(--text); gap: 7px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 12px 14px; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 600; }

/* ---------- Brand mark ---------- */
.brand .ti { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--ink); color: #fff !important; font-size: 19px !important; box-shadow: inset 0 -2px 0 rgba(255, 255, 255, .08); }

/* ---------- Admin layout ---------- */
.admin { display: flex; min-height: 100vh; }
.sb { position: fixed; inset: 0 auto 0 0; width: 252px; background: var(--bg); border-right: 1px solid var(--line); color: var(--slate); display: flex; flex-direction: column; padding: 20px 14px; z-index: 30; }
.sb .brand { display: flex; align-items: center; gap: 11px; color: var(--text); font-weight: 800; font-size: 17px; letter-spacing: -.02em; padding: 0 8px 24px; }
.sb nav, .sb-foot { display: grid; gap: 2px; }
.sb a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 11px; color: var(--slate); font-weight: 600; transition: background .15s, color .15s; }
.sb a:hover { background: #E8EDF6; color: var(--text); }
.sb a.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(10, 26, 63, .08), 0 0 0 1px var(--line); }
.sb a.on .ti { color: var(--primary); }
.sb a em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.sb-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.sb-back { display: none; }
.main { flex: 1; min-width: 0; margin-left: 252px; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 72px; padding: 0 32px; background: rgba(242, 245, 251, .85); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.top h1 { font-size: 22px; font-weight: 800; letter-spacing: -.025em; }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top .menu { display: none; }
.who { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.top .who { margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--line-2); }
.content { padding: 4px 32px 40px; max-width: 1320px; }
.dash { grid-template-columns: 2fr 1fr; align-items: start; }

/* Chart */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--primary-100); transition: fill .15s; }
.chart .bar:hover { fill: var(--primary); }
.chart .bar.today { fill: var(--primary); }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart .val { fill: var(--slate); font-weight: 700; }
.chart .grid-l { stroke: var(--line); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 140px 44px; gap: 12px; align-items: center; padding: 11px 0; }
.hbar .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* Video library & thumbnails */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.vcard { overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .2s, transform .2s; }
.vcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.vcard .body { padding: 16px; display: grid; gap: 8px; flex: 1; }
.vcard .title { font-weight: 700; }
.vcard .meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.vcard .foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.thumb { --h: 214; position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; background: radial-gradient(120% 90% at 85% 10%, hsl(calc(var(--h) + 30) 75% 88%), transparent 60%), linear-gradient(140deg, hsl(var(--h) 65% 94%), hsl(calc(var(--h) + 20) 55% 84%)); color: hsl(var(--h) 45% 25%); }
.thumb::after { content: ''; position: absolute; width: 60%; aspect-ratio: 1; right: -18%; bottom: -40%; border-radius: 50%; border: 18px solid hsl(var(--h) 60% 97% / .55); }
.thumb .ti { position: relative; z-index: 1; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 6px 20px -6px hsl(var(--h) 50% 30% / .45); font-size: 22px; padding-left: 3px; transition: transform .2s; }
a:hover .thumb .ti, .vcard:hover .thumb .ti, .mv:hover .thumb .ti { transform: scale(1.08); }
.thumb .dur { position: absolute; z-index: 1; right: 10px; bottom: 10px; font-size: 11px; font-weight: 700; background: rgba(10, 26, 63, .78); color: #fff; padding: 3px 8px; border-radius: 99px; }
.thumb.sm { width: 96px; flex: none; border-radius: 10px; }
.thumb.sm::after { display: none; }
.thumb.sm .ti { width: 30px; height: 30px; font-size: 14px; padding-left: 2px; }
.thumb.sm .dur { display: none; }

/* Quiz builder & grading */
.qcard { padding: 20px; display: grid; gap: 12px; }
.qhead { display: flex; align-items: center; gap: 8px; }
.qhead .qn { display: inline-grid; place-items: center; min-width: 32px; height: 26px; padding: 0 8px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; transition: border-color .15s, background .15s; }
.opt.correct { border-color: #9ED9B9; background: var(--green-50); }
.opt.correct .ti { color: var(--green); }
.opt.wrong { border-color: #F2B2B2; background: var(--red-50); }
.opt.wrong .ti { color: var(--red); }
.answer { padding: 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; white-space: pre-wrap; }
.check-list { max-height: 260px; overflow: auto; border: 1px solid var(--line-2); border-radius: 12px; }
.check-list label { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check-list label:hover { background: var(--soft); }
.check-list label:last-child { border-bottom: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.steps span.on { background: var(--primary); }
.drop { display: block; cursor: pointer; border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--slate); background: var(--soft); transition: border-color .15s, background .15s; }
.drop:hover { border-color: var(--primary); background: var(--primary-50); }
.drop .ti { font-size: 30px; color: var(--primary); display: block; margin: 0 auto 8px; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(10, 26, 63, .45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: 20px; box-shadow: 0 30px 70px -20px rgba(10, 26, 63, .4); }
.modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { font-size: 17px; font-weight: 800; }
.modal .mb { padding: 22px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line); }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 500; box-shadow: 0 16px 40px -12px rgba(10, 26, 63, .5); animation: ls-pop .2s ease-out; }
.toast .ti { color: #6EE7A0; }
.toast.r .ti { color: #FF9C9C; }
.fatal { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 300; margin: 0; padding: 12px; background: var(--red-50); color: var(--red-2); border: 1px solid var(--red); border-radius: 10px; white-space: pre-wrap; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(600px 400px at 15% 10%, rgba(91, 76, 240, .10), transparent 70%),
  radial-gradient(500px 360px at 90% 95%, rgba(242, 163, 58, .10), transparent 70%),
  radial-gradient(circle at 1px 1px, rgba(10, 26, 63, .07) 1px, transparent 0) 0 0 / 22px 22px,
  var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px 30px; border-radius: 24px; box-shadow: var(--shadow-lg); }
.auth-card .brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--text); margin-bottom: 22px; }
.auth-card .brand + p, .auth-card > p:first-of-type { color: var(--slate); margin-bottom: 22px; }
.auth-card .btn.p { height: 44px; font-size: 14px; margin-top: 4px; }
.demo { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.notice { display: flex; gap: 10px; padding: 13px 14px; border-radius: 12px; background: var(--primary-50); color: var(--ink); font-size: 13px; }
.notice.a { background: var(--amber-50); color: var(--amber); }
.notice.r { background: var(--red-50); color: var(--red-2); }
.notice.g { background: var(--green-50); color: var(--green); }

/* ---------- Student portal ---------- */
.student { min-height: 100vh; padding-bottom: 72px; }
.st-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; height: 68px; padding: 0 32px; background: rgba(242, 245, 251, .85); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.st-top .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; color: var(--text); }
.st-top .who { margin-left: auto; }
.st-nav { display: flex; gap: 2px; position: absolute; left: 50%; transform: translateX(-50%); padding: 4px; border-radius: 13px; background: #E8EDF6; }
.st-nav a, .st-tabs a { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 10px; color: var(--slate); font-weight: 600; transition: background .15s, color .15s; }
.st-nav a:hover { color: var(--text); }
.st-nav a.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(10, 26, 63, .1); }
.st-nav a.on .ti { color: var(--primary); }
.st-tabs { display: none; }
.st-content { max-width: 1120px; margin: 0 auto; padding: 32px; }
.hello { margin-bottom: 24px; }
.hello h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.hello p { color: var(--slate); margin-top: 6px; font-size: 15px; }
.st-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.st-stats .kv .v { font-size: 28px; }
.mv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; margin-top: 16px; }
.mv { overflow: hidden; display: flex; flex-direction: column; color: inherit; transition: box-shadow .2s, transform .2s, border-color .2s; }
.mv:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-3px); color: inherit; }
.mv .body { padding: 16px 18px; display: grid; gap: 10px; flex: 1; }
.mv .title { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.mv .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.mv .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px 16px; }
.player { position: relative; aspect-ratio: 16 / 9; background: #06102A; border-radius: 20px; overflow: hidden; color: #fff; user-select: none; box-shadow: 0 12px 30px -18px rgba(10, 26, 63, .45); }
.player .screen { position: absolute; inset: 0; display: grid; place-items: center; }
.player .big-play { width: 72px; height: 72px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .15); color: #fff; cursor: pointer; display: grid; place-items: center; }
.player .big-play .ti { font-size: 34px; }
.player .wm { position: absolute; font-size: 12px; color: rgba(255, 255, 255, .35); pointer-events: none; transition: top 1s, left 1s; white-space: nowrap; }
.player .ctrl { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); display: grid; gap: 8px; }
.player .track { position: relative; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.player .track .watched { position: absolute; top: 0; bottom: 0; left: 0; background: rgba(110, 160, 255, .75); }
.player .track .pos { position: absolute; top: 0; bottom: 0; left: 0; background: #fff; }
.player .ctrl .row { justify-content: space-between; font-size: 12px; }
.player .ctrl button { background: none; border: 0; color: #fff; cursor: pointer; padding: 0; }
.player-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.lock { display: grid; place-items: center; text-align: center; gap: 8px; padding: 26px 20px; }
.lock .ti { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: #EDF1F8; color: var(--slate); font-size: 24px; margin-bottom: 4px; }
.lock b { font-size: 16px; letter-spacing: -.01em; }
.lock .btn { margin-top: 6px; }
.player .lock .ti { background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .7); }
.quiz-q { padding: 22px; display: grid; gap: 12px; }
.quiz-q .opt { cursor: pointer; }
.quiz-q .opt:hover { border-color: #BFD0FF; background: #F7F9FF; }
.quiz-q .opt:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 1px var(--primary); }
.score-ring { width: 132px; height: 132px; margin: 4px auto 0; display: block; }
.empty-page { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; color: var(--slate); }
.empty-page .ti { font-size: 40px; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .dash, .player-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sb { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .admin.sb-open .sb { transform: none; }
  .admin.sb-open .sb-back { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(10, 26, 63, .35); }
  .main { margin-left: 0; }
  .top { padding: 0 16px; height: 64px; }
  .top h1 { font-size: 19px; }
  .top .menu { display: inline-grid; }
  .top .who { border-left: 0; padding-left: 0; margin-left: 0; }
  .top .who span:last-child { display: none; }
  .content { padding: 4px 16px 24px; }
  .st-nav { display: none; }
  .st-top { padding: 0 16px; height: 60px; }
  .st-content { padding: 20px 16px; }
  .hello h1 { font-size: 24px; }
  .st-tabs { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 20; background: rgba(10, 26, 63, .94); backdrop-filter: blur(12px); border-radius: 20px; justify-content: space-around; padding: 6px; box-shadow: 0 16px 40px -12px rgba(10, 26, 63, .5); }
  .st-tabs a { flex: 1; justify-content: center; flex-direction: column; gap: 2px; font-size: 11px; padding: 7px 4px; color: rgba(255, 255, 255, .6); border-radius: 14px; }
  .st-tabs a .ti { font-size: 21px; }
  .st-tabs a.on { color: #fff; background: rgba(255, 255, 255, .12); }
  .student { padding-bottom: 96px; }
  .hbar { grid-template-columns: minmax(0, 1fr) 80px 40px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
}
@media (max-width: 520px) {
  .tabs { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs button, .tabs a { flex: none; }
  .st-stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .st-stats .kv { padding: 14px 12px; }
  .st-stats .kv .k { font-size: 12px; }
  .st-stats .kv .k .ti { display: none; }
  .st-stats .kv .v { font-size: 24px; }
  .top-r .btn span { display: none; }
  .top-r .btn { width: 38px; padding: 0; }
}
.row > .pb { flex: 1; min-width: 60px; }
.grow { flex: 1; min-width: 0; }
a.kv { color: inherit; }
a.kv:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); color: inherit; }
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpis .kv { padding: 14px; }
  .kpis .kv .v { font-size: 24px; }
  .kpis .kv .k .ti { width: 30px; height: 30px; font-size: 16px; }
  .cd-h, .li, .toolbar { padding-left: 16px; padding-right: 16px; }
  .tbl th, .tbl td { padding-left: 14px; padding-right: 14px; }
}

/* ---------- Server app additions ---------- */
.player video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.player .wm { z-index: 2; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, .55); text-shadow: 0 0 3px rgba(0, 0, 0, .7); }
/* Full screen covers the whole player, so the watermark stays on top of the video. */
.player:fullscreen, .player:-webkit-full-screen, .player.fs { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; }
.player.fs { position: fixed; inset: 0; z-index: 1000; }
.player:fullscreen .wm, .player:-webkit-full-screen .wm, .player.fs .wm { font-size: 16px; }
.player .ctrl { z-index: 2; gap: 4px; padding: 28px 14px 10px; transition: opacity .25s; }
.player.idle { cursor: none; }
.player.idle .ctrl { opacity: 0; pointer-events: none; }
.player .ctrl .row .row { gap: 14px; flex-wrap: nowrap; }
.player .ctrl button { font-size: 20px; display: grid; place-items: center; }
.player .ctrl input[type=range] { accent-color: #fff; margin: 0; cursor: pointer; }
.player .ctrl .seek { width: 100%; }
.player .ctrl .vol { width: 80px; }
@media (max-width: 600px) { .player .ctrl .vol { display: none; } }
.track.static { position: relative; height: 6px; border-radius: 99px; background: #E6EBF4; overflow: hidden; margin-top: 12px; }
.track.static .watched { position: absolute; top: 0; bottom: 0; background: var(--primary); }
.sb-link { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 12px; border-radius: 11px; border: 0; background: none; color: var(--slate); font-weight: 600; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
.sb-link:hover { background: #E8EDF6; color: var(--text); }
dialog.modal { padding: 0; border: 0; }
dialog.modal::backdrop { background: rgba(10, 26, 63, .45); backdrop-filter: blur(3px); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.field .err { color: var(--red-2); font-size: 12px; font-weight: 500; }
.red { color: var(--red); }
.green { color: var(--green); }
.amber { color: var(--amber-2); }
code { font-size: 12px; background: #EDF1F8; padding: 2px 7px; border-radius: 6px; }
.progress-upload { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-upload span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.tabs a { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 9px; color: var(--slate); font-weight: 600; }
.tabs a:hover { color: var(--text); }
.tabs a.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(10, 26, 63, .1); }
.tabs a em { font-style: normal; margin-left: 5px; font-size: 12px; color: var(--muted); }

.player .next-quiz { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; background: rgba(6, 16, 42, .9); backdrop-filter: blur(4px); color: #fff; padding: 16px; }
.player .next-quiz[hidden] { display: none; }
.player .next-quiz > .ti { font-size: 34px; color: #7FA6FF; }
.player .next-quiz b { font-size: 20px; letter-spacing: -.01em; }
.player .next-quiz .btn.p { background: #fff; border-color: #fff; color: var(--ink); }
.player .next-quiz .btn:not(.p) { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }

/* Confirmation dialog */
dialog.confirm { max-width: 420px; text-align: center; }
dialog.confirm .mb { display: grid; justify-items: center; gap: 10px; padding: 32px 26px 22px; }
dialog.confirm .c-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
dialog.confirm.danger .c-icon { background: var(--red-50); color: var(--red); }
dialog.confirm .c-icon .ti { font-size: 26px; }
dialog.confirm .c-title { font-size: 19px; font-weight: 800; }
dialog.confirm .c-msg { color: var(--slate); }
dialog.confirm .notice { width: 100%; text-align: left; }
dialog.confirm .mf { border-top: 0; padding: 0 26px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog.confirm .mf .btn { height: 44px; }
dialog.modal[open] { animation: ls-pop .18s ease-out; }
@keyframes ls-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

dialog.modal { width: calc(100% - 32px); }

/* ---------- Download-manager alerts (admin) ---------- */
#dl-alerts { display: grid; gap: 8px; }
#dl-alerts:has(.dl-alert) { margin-bottom: 18px; }
.dl-alert { align-items: center; flex-wrap: wrap; border: 1px solid #F6CFCF; }
.dl-alert .grow { flex: 1; min-width: 220px; }
.dl-alert form { margin: 0; }

/* ---------- Quiz result: correct / wrong counts ---------- */
.tally { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.tally > div { display: grid; justify-items: center; gap: 2px; min-width: 120px; padding: 14px 18px; border-radius: 16px; }
.tally .ti { font-size: 20px; }
.tally b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.tally span { font-size: 12px; font-weight: 600; }
.tally .g { background: var(--green-50); color: var(--green); }
.tally .r { background: var(--red-50); color: var(--red-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Navy & white theme ---------- */
/* Admin sidebar: deep navy panel. */
.sb { background: var(--hero); border-right: 0; color: rgba(255, 255, 255, .7); }
.sb .brand { color: #fff; }
.sb .brand .ti { background: #fff; color: var(--ink) !important; }
.sb a, .sb-link { color: rgba(255, 255, 255, .68); }
.sb a:hover, .sb-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sb a.on { background: #fff; color: var(--ink); box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5); }
.sb a.on .ti { color: var(--primary); }
.sb a em { background: var(--amber-2); color: var(--ink); }
.sb-foot { border-top-color: rgba(255, 255, 255, .1); }

/* Student header: navy bar with white segmented nav. */
.st-top { background: var(--ink); border-bottom: 0; color: #fff; }
.st-top .brand, .st-top .who { color: #fff; }
.st-top .brand .ti { background: #fff; color: var(--ink) !important; }
.st-nav { background: rgba(255, 255, 255, .08); }
.st-nav a { color: rgba(255, 255, 255, .7); }
.st-nav a:hover { color: #fff; }
.st-nav a.on { background: #fff; color: var(--ink); box-shadow: none; }
.st-top .av { box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); }
.st-tabs { background: rgba(10, 26, 63, .96) !important; }

/* Page heroes: the first heading block on a page becomes a navy banner. */
.st-content > .hello:first-child { position: relative; overflow: hidden; padding: 30px 32px; border-radius: 22px; background: var(--hero); color: #fff; box-shadow: var(--shadow-lg); }
.st-content > .hello:first-child p { color: rgba(255, 255, 255, .72); }
.st-content > .hello:first-child::after { content: ''; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255, 255, 255, .05); }

/* KPI: the first card is filled navy for emphasis. */
.kpis > .kv:first-child, .st-stats > .kv:first-child { background: var(--hero); border-color: transparent; color: #fff; }
.kpis > .kv:first-child .k, .st-stats > .kv:first-child .k { color: rgba(255, 255, 255, .75); }
.kpis > .kv:first-child .s { color: rgba(255, 255, 255, .55); }
.kpis > .kv:first-child .k .ti, .st-stats > .kv:first-child .k .ti { background: rgba(255, 255, 255, .12); color: #fff; }

/* Thumbnails: rich blue-family gradients with a glass play button. */
.thumb { background: radial-gradient(120% 90% at 85% 10%, hsl(calc(var(--h) + 25) 80% 55% / .55), transparent 60%), linear-gradient(140deg, hsl(var(--h) 60% 34%), #0A1A3F); color: #fff; }
.thumb::after { border-color: rgba(255, 255, 255, .07); }
.thumb .ti { background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(6px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }

/* Auth: navy canvas, white card. */
.auth { background: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .07) 1px, transparent 0) 0 0 / 24px 24px, var(--hero); }
.auth-card { border: 0; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6); }

/* ---------- Polish & responsive layout ---------- */
.top h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .who { display: none; }
.sb-me { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 8px; border-radius: 14px; background: rgba(255, 255, 255, .07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.sb-me .n { color: #fff; font-weight: 700; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-me .c { font-size: 11px; color: rgba(255, 255, 255, .5); }
.sb nav a { position: relative; }

/* KPI rows never leave a lonely card: 4 across on wide screens, 2 across otherwise. */
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Student video cards: status on the thumbnail, progress along its bottom edge. */
.mv-media { position: relative; }
.mv-chip { position: absolute; top: 12px; left: 12px; z-index: 2; }
.mv-chip .bg { background: rgba(255, 255, 255, .94); box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .4); }
.mv-bar { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; height: 4px; background: rgba(255, 255, 255, .18); }
.mv-bar span { display: block; height: 100%; background: linear-gradient(90deg, #5B8CFF, #8DB2FF); box-shadow: 0 0 12px rgba(91, 140, 255, .8); }
.mv-bar.g span { background: linear-gradient(90deg, #22C55E, #6EE7A0); box-shadow: 0 0 12px rgba(34, 197, 94, .7); }
.mv .body { gap: 6px; padding-bottom: 6px; }
.mv .foot { border-top: 0; padding-top: 8px; }
.mv .foot .btn .ti { font-size: 15px; transition: transform .2s; }
.mv:hover .foot .btn .ti { transform: translateX(3px); }

/* Gentle entrance for page content. */
@keyframes ls-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content > *, .st-content > *, .kpis > *, .st-stats > *, .mv-list > *, .vgrid > * { animation: ls-rise .45s cubic-bezier(.2, .7, .2, 1) both; }
.content > :nth-child(2), .st-content > :nth-child(2), .kpis > :nth-child(2), .st-stats > :nth-child(2), .mv-list > :nth-child(2), .vgrid > :nth-child(2) { animation-delay: .05s; }
.content > :nth-child(3), .st-content > :nth-child(3), .kpis > :nth-child(3), .st-stats > :nth-child(3), .mv-list > :nth-child(3), .vgrid > :nth-child(3) { animation-delay: .1s; }
.content > :nth-child(n+4), .st-content > :nth-child(n+4), .kpis > :nth-child(n+4), .mv-list > :nth-child(n+4), .vgrid > :nth-child(n+4) { animation-delay: .15s; }

/* Tablet: student keeps the top navigation; the bottom bar is for phones only. */
@media (min-width: 641px) and (max-width: 860px) {
  .st-nav { display: flex; }
  .st-tabs { display: none !important; }
  .student { padding-bottom: 24px; }
  .st-top .who > span:last-child { display: none; }
}
@media (max-width: 640px) {
  .st-tabs { max-width: 420px; margin: 0 auto; }
  .st-top .who > span:last-child { display: none; }
  .st-content > .hello:first-child { padding: 24px 22px; border-radius: 18px; }
  .mv-list { grid-template-columns: 1fr; }
}

/* Tables become stacked cards (labels come from the column headers, see app.js). */
@media (max-width: 900px) {
  .tbl-wrap { overflow: visible; }
  table.tbl, .tbl tbody { display: block; }
  .tbl thead { display: none; }
  .tbl tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; padding: 16px; border-bottom: 1px solid var(--line); transition: background .15s; }
  .tbl tr:last-child { border-bottom: 0; }
  .tbl td, .tbl tr:last-child td { display: block; min-width: 0 !important; padding: 0; border: 0; text-align: left !important; overflow-wrap: anywhere; }
  .tbl td::before { content: attr(data-label); display: block; margin-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  .tbl td:first-child, .tbl td:not([data-label]) { grid-column: 1 / -1; }
  .tbl td:first-child::before, .tbl td:not([data-label])::before { display: none; }
  .tbl tr[data-href]:hover, .tbl tr.click:hover { background: var(--soft); }
  .tbl tr[data-href]:hover td, .tbl tr.click:hover td { background: none; }
}
@media (max-width: 330px) {
  .tbl tr { grid-template-columns: 1fr; }
}

/* ---------- Sections: library bar, breadcrumbs, folder cards, video rows ---------- */
.lib-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 18px; }
.lib-bar .search { flex: 0 1 300px; margin-left: auto; }
.lib-used { font-size: 12px; white-space: nowrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; font-weight: 600; }
.crumbs > .ti { color: var(--muted); font-size: 15px; }
.crumbs a, .crumbs span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; color: var(--slate); }
.crumbs a:hover { background: var(--soft); color: var(--text); }
.crumbs .on { background: var(--primary-50); color: var(--primary); }
.sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 16px; }
.sec-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.sec-head p { margin-top: 2px; }
.sec-head form { margin: 0; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.fcard { display: flex; align-items: center; gap: 14px; padding: 16px; color: inherit; transition: box-shadow .2s, transform .2s, border-color .2s; }
.fcard:hover { color: inherit; border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.fcard .f-ico .ti { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--hero); color: #fff; font-size: 22px; box-shadow: 0 8px 18px -10px rgba(10, 26, 63, .6); }
.fcard.is-closed { opacity: .7; cursor: not-allowed; }
.fcard.is-closed:hover { border-color: var(--line); box-shadow: none; transform: none; }
.fcard.is-closed .f-ico .ti { background: var(--slate); box-shadow: none; }
.fcard .t { font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fcard .f-go { color: var(--muted); transition: transform .2s, color .2s; }
.fcard:hover .f-go { color: var(--primary); transform: translateX(3px); }
.vrow { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line); transition: background .15s; }
.vrow:last-child { border-bottom: 0; }
.vrow:hover { background: var(--soft); }
.vrow .t { display: block; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .t:hover { color: var(--primary); }
.vrow .d { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.vrow .d .ti { font-size: 14px; vertical-align: -2px; }
.vrow .thumb.sm { width: 104px; }
@media (max-width: 640px) {
  .lib-bar .search { flex-basis: 100%; margin-left: 0; }
  .lib-used { display: none; }
  .vrow { flex-wrap: wrap; padding: 12px 16px; }
  .vrow .thumb.sm { width: 84px; }
  .vrow > .grow { flex-basis: calc(100% - 100px); }
  .vrow > .bg { margin-left: 98px; }
  .vrow-act { margin-left: auto; }
  .sec-head h2 { font-size: 20px; }
}

/* Student section browsing */
.st-h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 12px; }
.st-crumbs { margin-bottom: 14px; }
.st-fgrid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.st-fgrid .fcard .pb { margin-top: 8px; height: 5px; }
.sec-hero h1 { font-size: 28px; }
.sec-hero-bar { position: relative; z-index: 1; height: 6px; margin-top: 16px; max-width: 420px; border-radius: 99px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.sec-hero-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6EA0FF, #A9C6FF); }
.st-content > .crumbs + .hello { position: relative; overflow: hidden; padding: 28px 30px; border-radius: 22px; background: var(--hero); color: #fff; box-shadow: var(--shadow-lg); }
.st-content > .crumbs + .hello p { color: rgba(255, 255, 255, .72); }
@media (max-width: 640px) {
  .st-crumbs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .st-crumbs a { flex: none; }
  .st-content > .crumbs + .hello { padding: 22px; }
  .sec-hero h1 { font-size: 22px; }
}
.sec-tree label { gap: 8px; }
.sec-tree label .ti { font-size: 16px; }

/* ---------- Theme toggle ---------- */
.theme-btn .ti { font-size: 19px; transition: transform .4s cubic-bezier(.4, 0, .2, 1); }
.theme-btn:hover .ti { transform: rotate(-20deg); }
.theme-btn .i-sun, :root[data-theme="dark"] .theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: inline-block; }
.st-top .who { gap: 12px; }
.st-top .theme-btn { width: 36px; height: 36px; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #fff; }
.st-top .theme-btn:hover { background: rgba(255, 255, 255, .16); }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; backdrop-filter: blur(8px); }
.auth-theme:hover { background: rgba(255, 255, 255, .18); }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }

/* ---------- Dark mode: midnight navy ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #E8EEFB;
  --slate: #A9B6D3;
  --muted: #7382A3;
  --line: #1B2846;
  --line-2: #26375C;
  --bg: #070E1F;
  --soft: #111D3A;
  --card: #0D1730;
  --primary: #5B8CFF;
  --primary-2: #82A8FF;
  --primary-50: rgba(91, 140, 255, .14);
  --primary-100: rgba(91, 140, 255, .32);
  --violet: #5B8CFF;
  --violet-50: rgba(91, 140, 255, .14);
  --green: #34D399;
  --green-50: rgba(52, 211, 153, .12);
  --amber: #FBBF24;
  --amber-2: #FBBF24;
  --amber-50: rgba(251, 191, 36, .12);
  --red: #F87171;
  --red-2: #FCA5A5;
  --red-50: rgba(248, 113, 113, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 44px -18px rgba(0, 0, 0, .75);
  --ring: 0 0 0 4px rgba(91, 140, 255, .25);
  --hero: radial-gradient(700px 300px at 100% 0%, rgba(91, 140, 255, .42), transparent 65%), radial-gradient(500px 260px at 0% 100%, rgba(120, 160, 255, .16), transparent 70%), linear-gradient(135deg, #10255C, #0A1838);
}
:root[data-theme="dark"] body { background: radial-gradient(1200px 600px at 100% -10%, rgba(91, 140, 255, .08), transparent 60%), var(--bg); background-attachment: fixed; }

/* Surfaces that were white */
:root[data-theme="dark"] .btn, :root[data-theme="dark"] .icon-btn, :root[data-theme="dark"] .input,
:root[data-theme="dark"] .opt, :root[data-theme="dark"] .modal, :root[data-theme="dark"] .auth-card { background: var(--card); }
:root[data-theme="dark"] .btn:hover, :root[data-theme="dark"] .icon-btn:hover { background: var(--soft); border-color: var(--line-2); }
:root[data-theme="dark"] .input:hover { border-color: #33476F; }
:root[data-theme="dark"] .btn.p { background: linear-gradient(180deg, #6A97FF, #4C7DF5); border-color: #5B8CFF; color: #fff; box-shadow: 0 6px 18px -8px rgba(91, 140, 255, .7); }
:root[data-theme="dark"] .btn.p:hover { background: linear-gradient(180deg, #7DA4FF, #5B8CFF); }
:root[data-theme="dark"] .cd { border-color: var(--line); }
:root[data-theme="dark"] .notice { color: var(--text); }
:root[data-theme="dark"] .bg.u, :root[data-theme="dark"] .empty .ti, :root[data-theme="dark"] .lock .ti, :root[data-theme="dark"] code { background: var(--soft); }
:root[data-theme="dark"] .pb, :root[data-theme="dark"] .track.static { background: var(--line); }
:root[data-theme="dark"] .av { background: hsl(var(--h) 45% 20%); color: hsl(var(--h) 80% 82%); }
:root[data-theme="dark"] .brand .ti { background: linear-gradient(135deg, #6A97FF, #3F6FE8); color: #fff !important; }

/* Tabs and segmented controls */
:root[data-theme="dark"] .tabs { background: var(--soft); }
:root[data-theme="dark"] .tabs button.on, :root[data-theme="dark"] .tabs a.on { background: var(--line-2); color: #fff; box-shadow: none; }

/* Headers and navigation */
:root[data-theme="dark"] .top { background: rgba(7, 14, 31, .78); }
:root[data-theme="dark"] .st-top { background: rgba(9, 18, 40, .88); border-bottom: 1px solid var(--line); backdrop-filter: saturate(1.4) blur(12px); }
:root[data-theme="dark"] .sb { background: linear-gradient(180deg, #0B1838, #070F24); border-right: 1px solid var(--line); }
:root[data-theme="dark"] .sb .brand .ti, :root[data-theme="dark"] .st-top .brand .ti { background: linear-gradient(135deg, #6A97FF, #3F6FE8); color: #fff !important; }
:root[data-theme="dark"] .sb a.on { background: rgba(91, 140, 255, .16); color: #fff; box-shadow: inset 0 0 0 1px rgba(91, 140, 255, .28); }
:root[data-theme="dark"] .sb a.on .ti { color: #8FB0FF; }
:root[data-theme="dark"] .st-nav a.on { background: rgba(91, 140, 255, .2); color: #fff; }
:root[data-theme="dark"] .st-nav a.on .ti { color: #8FB0FF; }
:root[data-theme="dark"] .st-tabs { background: rgba(13, 23, 48, .96) !important; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8), inset 0 0 0 1px var(--line); }
:root[data-theme="dark"] .crumbs .on { color: #8FB0FF; }

/* Content details */
:root[data-theme="dark"] .hello h1, :root[data-theme="dark"] .top h1, :root[data-theme="dark"] .sec-head h2 { color: #fff; }
:root[data-theme="dark"] .st-content > .hello:first-child, :root[data-theme="dark"] .st-content > .crumbs + .hello,
:root[data-theme="dark"] .kpis > .kv:first-child, :root[data-theme="dark"] .st-stats > .kv:first-child { box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(255, 255, 255, .06); }
:root[data-theme="dark"] .fcard .f-ico .ti { background: linear-gradient(135deg, #3F6FE8, #1B3A8F); box-shadow: 0 8px 18px -10px rgba(91, 140, 255, .6); }
:root[data-theme="dark"] .mv-chip .bg { background: rgba(9, 18, 40, .88); backdrop-filter: blur(6px); }
:root[data-theme="dark"] .opt.correct { border-color: rgba(52, 211, 153, .45); }
:root[data-theme="dark"] .opt.wrong { border-color: rgba(248, 113, 113, .45); }
:root[data-theme="dark"] .quiz-q .opt:hover { border-color: rgba(91, 140, 255, .5); background: var(--soft); }
:root[data-theme="dark"] .dl-alert { border-color: rgba(248, 113, 113, .3); }
:root[data-theme="dark"] .toast { background: #16244A; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8), inset 0 0 0 1px var(--line-2); }
:root[data-theme="dark"] .chart .val { fill: var(--slate); }
:root[data-theme="dark"] .player { box-shadow: 0 16px 40px -18px rgba(0, 0, 0, .9), 0 0 0 1px var(--line); }
:root[data-theme="dark"] dialog.modal::backdrop, :root[data-theme="dark"] .modal-back { background: rgba(2, 6, 16, .7); }
:root[data-theme="dark"] ::selection { background: rgba(91, 140, 255, .35); }
:root[data-theme="dark"] .auth { background: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .05) 1px, transparent 0) 0 0 / 24px 24px, radial-gradient(700px 400px at 85% 0%, rgba(91, 140, 255, .25), transparent 65%), #060C1C; }
:root[data-theme="dark"] .auth-card { box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .9), inset 0 0 0 1px var(--line); }

/* Password requirements */
.pw-rules { list-style: none; margin: -4px 0 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; border-radius: 12px; background: var(--soft); font-size: 12.5px; color: var(--slate); }
.pw-rules li { display: flex; align-items: center; gap: 7px; }
.pw-rules li::before { content: ''; flex: none; width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--line-2); transition: background .15s, border-color .15s; }
.pw-rules li.ok { color: var(--green); }
.pw-rules li.ok::before { border-color: var(--green); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat var(--green); }
@media (max-width: 420px) { .pw-rules { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .auth { padding-top: 72px; align-items: start; } }

/* Destructive and confirm buttons: soft red outline, solid red for the final confirm, in both themes. */
.btn.r:not(.solid) { border-color: rgba(217, 54, 54, .28); background: var(--card); }
.btn.r:not(.solid):hover { background: var(--red-50); border-color: var(--red); color: var(--red); }
.btn.r.solid { background: linear-gradient(180deg, #EF4444, #D93636); border-color: #D93636; color: #fff; box-shadow: 0 6px 16px -8px rgba(217, 54, 54, .7); }
.btn.r.solid:hover { background: linear-gradient(180deg, #F25555, #C92E2E); border-color: #C92E2E; color: #fff; }
.btn.g { background: linear-gradient(180deg, #16A35C, #12924A); border-color: #12924A; color: #fff; }
.btn.g:hover { background: linear-gradient(180deg, #1BB066, #0F8743); color: #fff; }
:root[data-theme="dark"] .btn.r:not(.solid) { border-color: rgba(248, 113, 113, .35); background: var(--card); color: var(--red); }
:root[data-theme="dark"] .btn.r:not(.solid):hover { background: var(--red-50); border-color: var(--red); }
:root[data-theme="dark"] .btn.r.solid { background: linear-gradient(180deg, #F25555, #DC3838); border-color: #F25555; color: #fff; box-shadow: 0 6px 18px -8px rgba(242, 85, 85, .7); }
:root[data-theme="dark"] .btn.r.solid:hover { background: linear-gradient(180deg, #F87171, #E04848); color: #fff; }
:root[data-theme="dark"] .btn.g { background: linear-gradient(180deg, #22C177, #15A05F); border-color: #22C177; color: #fff; }
:root[data-theme="dark"] .btn.g:hover { background: linear-gradient(180deg, #34D399, #1DB06A); color: #fff; }
:root[data-theme="dark"] dialog.confirm.danger .c-icon { background: rgba(248, 113, 113, .16); color: #FF8A8A; box-shadow: inset 0 0 0 1px rgba(248, 113, 113, .25); }
dialog.confirm.danger .c-icon { box-shadow: inset 0 0 0 1px rgba(217, 54, 54, .15); }

/* ---------- Dark mode contrast fixes (white text needs a deep enough color behind it) ---------- */
:root[data-theme="dark"] { --muted: #8794B4; }
:root[data-theme="dark"] .btn.p { background: linear-gradient(180deg, #3468F2, #2553D8); border-color: #3D70F5; box-shadow: 0 6px 18px -8px rgba(52, 104, 242, .75); }
:root[data-theme="dark"] .btn.p:hover { background: linear-gradient(180deg, #3366EE, #2A58DD); border-color: #4A7BF7; }
:root[data-theme="dark"] .brand .ti, :root[data-theme="dark"] .sb .brand .ti, :root[data-theme="dark"] .st-top .brand .ti { background: linear-gradient(135deg, #3468F2, #2148C2); }
:root[data-theme="dark"] .btn.r.solid { background: linear-gradient(180deg, #D43535, #BC2828); border-color: #E44949; box-shadow: 0 6px 18px -8px rgba(222, 59, 59, .75); }
:root[data-theme="dark"] .btn.r.solid:hover { background: linear-gradient(180deg, #D93939, #C42B2B); border-color: #EF5A5A; }
:root[data-theme="dark"] .btn.g { background: linear-gradient(180deg, #14965A, #0F7F4B); border-color: #1AA866; }
:root[data-theme="dark"] .btn.g:hover { background: linear-gradient(180deg, #18A463, #128A52); }
:root[data-theme="dark"] .tabs button.on em, :root[data-theme="dark"] .tabs a.on em { color: var(--slate); }
.kpis > .kv:first-child .s { color: rgba(255, 255, 255, .72); }
:root:not([data-theme="dark"]) { --muted: #6E7894; }
:root[data-theme="dark"] .btn.g { background: linear-gradient(180deg, #0F8450, #0B7044); border-color: #16A060; }
:root[data-theme="dark"] .btn.g:hover { background: linear-gradient(180deg, #118C55, #0C7848); }
:root:not([data-theme="dark"]) { --muted: #636D88; }

/* Show / hide password */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-eye { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.pw-eye:hover { background: var(--soft); color: var(--text); }
.pw-eye .ti { font-size: 19px; }
.pw-eye .i-hide, .pw-eye[aria-pressed="true"] .i-show { display: none; }
.pw-eye[aria-pressed="true"] .i-hide { display: inline-block; }
.pw-eye[aria-pressed="true"] { color: var(--primary); }
.pw-wrap .input::-ms-reveal { display: none; }

/* Back link at the top left of an auth card (change password) */
.auth-back { display: inline-flex; align-items: center; gap: 6px; margin: -12px 0 18px -6px; padding: 6px 12px 6px 8px; border-radius: 10px; color: var(--slate); font-weight: 600; font-size: 13.5px; transition: background .15s, color .15s; }
.auth-back:hover { background: var(--soft); color: var(--text); }
.auth-back .ti { font-size: 18px; transition: transform .2s; }
.auth-back:hover .ti { transform: translateX(-3px); }

/* The theme button on sign-in pages scrolls with the page instead of floating over the form. */
.auth { position: relative; }
.auth-theme { position: absolute; }

/* Error pages */
.err-page { text-align: center; padding: 8px 0 4px; }
.err-code { font-size: 64px; font-weight: 800; letter-spacing: -.04em; line-height: 1; background: linear-gradient(135deg, var(--primary), #6EA0FF); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 10px; }
.err-page h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }

/* ---------- Files in a section ---------- */
.f-type .ti { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; font-size: 24px; }
.f-type.pdf .ti { background: var(--red-50); color: var(--red); }
.f-type.docx .ti { background: var(--primary-50); color: var(--primary); }
.file-row .f-type .ti { width: 40px; height: 40px; border-radius: 12px; font-size: 21px; }
.st-content > h2.st-h2 + section.cd { margin-bottom: 18px; }
.f-type.image .ti { background: var(--green-50); color: var(--green); }
.f-type.powerpoint .ti { background: var(--amber-50); color: var(--amber); }
.f-type.word .ti { background: var(--primary-50); color: var(--primary); }
