/* Mazuma colours: leaf green #A0CE4E, deep green, charcoal #242D2E */
:root {
  --bg: #f5f7f2; --card: #fff; --ink: #242d2e; --muted: #69727d; --line: #e3e8dd;
  --brand: #4f8f25; --brand-2: #a0ce4e; --brand-soft: #eff7e3; --brand-ink: #fff;
  --dark: #242d2e; --teal: #1b8fa0;
  --ok: #2f8a3c; --ok-bg: #e7f5e4; --bad: #c62828; --bad-bg: #fdecec; --warn: #9a6a00; --warn-bg: #fff4d6;
  --radius: 14px; --shadow: 0 1px 3px rgba(36, 45, 46, .08);
  --grad: linear-gradient(90deg, #a0ce4e, #4f8f25 60%, #1b8fa0);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --card: #1b211d; --ink: #e7ece4; --muted: #9ba59d; --line: #2c352e;
    --brand: #8cc443; --brand-2: #a0ce4e; --brand-soft: #22301b; --brand-ink: #0f160b; --dark: #e7ece4;
    --ok-bg: #173020; --bad-bg: #3a1717; --warn: #e3b341; --warn-bg: #3a2f12; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.55 'Sarabun', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
body.protect { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media print { body { display: none !important; } }
a { color: var(--brand); }
h1, h2, h3, .brandfont { font-family: 'Chakra Petch', 'Sarabun', sans-serif; font-weight: 600; line-height: 1.3; margin: 0 0 8px; }
h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 17px; }
small, .muted { color: var(--muted); }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 96px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.dark { background: var(--dark); border-color: var(--dark); color: var(--card); }
.btn.soft { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 18px; }
.btn.sm { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); min-height: 44px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.err { color: var(--bad); font-weight: 600; min-height: 1.5em; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--grad); border-radius: 99px; }

/* technician top bar + bottom nav */
.top { position: sticky; top: 0; z-index: 20; background: var(--card); border-top: 4px solid transparent; border-image: var(--grad) 1; border-bottom: 1px solid var(--line);
  padding: 8px 16px; display: flex; align-items: center; gap: 10px; }
.top .title { flex: 1; font-family: 'Chakra Petch', sans-serif; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--brand); }
.top .btn { min-height: 36px; padding: 4px 12px; }
.logo-word { font-family: 'Chakra Petch', sans-serif; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.bnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.bnav a { flex: 1; text-align: center; padding: 8px 4px 10px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.bnav a span { display: block; font-size: 22px; line-height: 1.2; }
.bnav a.on { color: var(--brand); }

/* login */
.login { max-width: 380px; margin: 8vh auto; padding: 16px; }
.logo { width: 72px; height: 72px; display: block; margin: 0 auto 12px; }

/* course list + hub */
.course { display: block; text-decoration: none; color: inherit; border-left: 6px solid var(--brand-2); }
.course:active { transform: scale(.99); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.opt { display: flex; gap: 14px; align-items: flex-start; }
.opt .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 26px; flex: none; background: var(--brand-soft); }
.opt.exam .ico { background: #e9ecec; }
.opt.rev .ico { background: #e3f3f5; }
.opt .status { font-size: 14px; color: var(--muted); }
.sec { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.sec:first-child { border-top: 0; }
.sec .dot { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--bg); border: 2px solid var(--line); }
.sec.done .dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.sec.now .dot { border-color: var(--brand); color: var(--brand); }
.sec .meta { font-size: 13px; color: var(--muted); }
details > summary { cursor: pointer; font-weight: 600; color: var(--brand); }

/* reader */
.reader { position: fixed; inset: 0; display: flex; flex-direction: column; background: #4a5150; }
.reader .head { background: var(--card); border-top: 4px solid transparent; border-image: var(--grad) 1; padding: 6px 10px; display: flex; align-items: center; gap: 8px; }
.reader .head .t { flex: 1; min-width: 0; }
.reader .head .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; color: var(--brand); }
.reader .head .t span { font-size: 13px; color: var(--muted); }
.reader .head .btn { min-height: 36px; padding: 2px 10px; }
.reader .stage { flex: 1; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; }
.reader .paper { position: relative; margin: 8px auto; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.reader canvas { display: block; width: 100%; height: auto; }
.wm { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.wm span { position: absolute; transform: rotate(-30deg); color: rgba(79, 143, 37, .14); font-weight: 700; font-size: 15px; white-space: nowrap; }
.reader .foot { background: var(--card); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); }
.reader .foot .btn { min-height: 52px; }
.reader .foot .stamp { flex: 1; font-size: 17px; }
.reader .prog { height: 4px; background: rgba(255,255,255,.25); }
.reader .prog i { display: block; height: 100%; background: var(--grad); }
.loading { color: #fff; text-align: center; padding: 40px; }
.stamped-mark { position: absolute; right: 10px; top: 10px; z-index: 2; background: var(--brand); color: #fff; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 13px; transform: rotate(6deg); box-shadow: 0 2px 6px rgba(0,0,0,.25); }

/* exam */
.timer { font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; font-family: 'Chakra Petch', sans-serif; }
.timer.low { color: var(--bad); }
.tbar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 14px; }
.tbar i { display: block; height: 100%; background: var(--grad); transition: width .25s linear; }
.tbar.low i { background: var(--bad); }
.q { font-size: 19px; font-weight: 700; margin: 6px 0 14px; }
.qimg { position: relative; margin: 0 0 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.qimg img { display: block; width: 100%; max-height: 46vh; object-fit: contain; background: #000; }
.choice { display: flex; gap: 10px; width: 100%; text-align: left; padding: 14px; margin-bottom: 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; align-items: flex-start; position: relative; }
.choice b.l { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); }
.choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.choice.right { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice:disabled { cursor: default; }
.pics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.pics .choice { flex-direction: column; padding: 6px; margin: 0; align-items: stretch; }
.pics .choice img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; display: block; background: #000; }
.pics .choice b.l { position: absolute; left: 10px; top: 10px; background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.pics .choice .zoom { position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-size: 15px; }
.pics .choice span.t { padding: 4px 2px 0; font-size: 14px; }
.verdict { font-size: 22px; font-weight: 700; text-align: center; padding: 10px; border-radius: 12px; margin-bottom: 12px; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.bad { background: var(--bad-bg); color: var(--bad); }
.explain { background: var(--warn-bg); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.score { font-size: 56px; font-weight: 700; text-align: center; line-height: 1.1; font-family: 'Chakra Petch', sans-serif; }
.qnum { font-size: 64px; font-weight: 700; text-align: center; color: var(--brand); line-height: 1; font-family: 'Chakra Petch', sans-serif; }
.lightbox { position: fixed; inset: 0; z-index: 600; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 12px; }
.lightbox img { max-width: 100%; max-height: 90vh; object-fit: contain; }

/* tables */
.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--brand-soft); z-index: 1; white-space: nowrap; font-weight: 700; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nw { white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.kpi b { display: block; font-size: 24px; font-family: 'Chakra Petch', sans-serif; }
.kpi span { color: var(--muted); font-size: 13px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; vertical-align: middle; border: 1px solid var(--line); }

/* admin layout: menu on the left */
.admin { display: flex; min-height: 100vh; }
.side { width: 250px; flex: none; background: var(--dark); color: #e7ece4; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; border-top: 4px solid transparent; border-image: var(--grad) 1; }
.side .brand { padding: 16px; font-size: 18px; }
.side .brand small { display: block; color: #9ba59d; font-family: 'Sarabun', sans-serif; font-weight: 400; font-size: 13px; }
.side nav { flex: 1; padding: 0 8px; }
.side .grp { color: #9ba59d; font-size: 12px; text-transform: uppercase; padding: 12px 10px 4px; letter-spacing: .03em; }
.side a { display: block; color: #e7ece4; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 600; font-size: 15px; }
.side a:hover { background: rgba(255,255,255,.06); }
.side a.on { background: var(--brand); color: #fff; }
.side a.course-link { font-weight: 600; }
.side a.course-link.open { background: rgba(160,206,78,.15); color: #c9e79a; }
.side .sub a { padding-left: 28px; font-weight: 500; }
.side .foot { padding: 8px; border-top: 1px solid rgba(255,255,255,.1); }
.main { flex: 1; min-width: 0; }
.main .wrap { max-width: 1280px; }
.mtop { display: none; }
@media (max-width: 899px) {
  .admin { display: block; }
  .side { position: fixed; z-index: 400; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; visibility: hidden; }
  .side.open { transform: none; visibility: visible; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .mtop { display: flex; position: sticky; top: 0; z-index: 50; background: var(--card); border-top: 4px solid transparent; border-image: var(--grad) 1; border-bottom: 1px solid var(--line); padding: 8px 12px; gap: 10px; align-items: center; }
}
.crumb { color: var(--muted); font-size: 14px; margin-bottom: 4px; }

/* question bank */
.qcard .choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.qcard .ch { border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 14px; display: flex; gap: 6px; align-items: flex-start; }
.qcard .ch b { white-space: nowrap; }
.qcard .ch img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 6px; display: block; }
.qcard .ch.pic { flex-direction: column; }
.qcard .ch.ans { border-color: var(--ok); background: var(--ok-bg); }
.qcard.off { opacity: .55; }
.qcard .qi { max-width: 260px; border-radius: 8px; display: block; margin: 6px 0; }
.edrow { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.edrow img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }

/* overlays */
#shield { position: fixed; inset: 0; z-index: 1000; background: #000; color: #777; display: none; place-items: center; text-align: center; font-size: 20px; }
body.shielded #shield { display: grid; }
body.shielded #app { visibility: hidden; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--dark); color: var(--card); padding: 10px 16px; border-radius: 10px; z-index: 900; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500; display: grid; place-items: center; padding: 16px; }
.modal > div { background: var(--card); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal.wide > div { max-width: 760px; }
.edrow { flex-wrap: wrap; }
.edrow.ans { border-color: var(--ok); background: var(--ok-bg); }
.edrow .pick { display: flex; gap: 6px; align-items: center; margin: 0; cursor: pointer; }
.edrow .pick input { width: 20px; min-height: 0; }
.edrow input.grow { flex: 1 1 200px; min-width: 0; }
.bnav[hidden] { display:none; }
@media (min-width:900px) {
 .admin .mtop { display:flex; align-items:center; gap:.8rem; padding:12px 20px; }
 .admin.collapsed .side { display:none; }
}
@media (prefers-color-scheme:light) {
 :root { --bg:#f4f8fc; --line:#e3e9f1; --ink:#1f2937; --brand:#176caf; --brand-soft:#d9eeff; --grad:linear-gradient(90deg,#2387e8,#36a852); }
}

:root {--brand:#1673bd;--brand-2:#36a852;--grad:linear-gradient(105deg,#2387e8,#36a852);--radius:16px;} .side .brand:before{content:'';display:block;width:54px;height:54px;background:url('/app-classroom.webp') center/contain no-repeat} .bnav a img{display:block;margin:auto} .card{box-shadow:0 6px 22px rgba(31,55,90,.08)}
.nav-icon { width:26px;height:26px;object-fit:contain;vertical-align:middle;margin-right:9px }
#listening audio { width:100% }
#listening fieldset { border:1px solid var(--line);border-radius:12px }
#listening fieldset .btn { margin:5px }
.side{background:var(--card);color:var(--ink);border-right:1px solid var(--line)}
.side a{color:var(--ink)} .side a.course-link.open,.side a:hover{background:var(--brand-soft);color:var(--brand)}
.side a.on{background:#176bb4;color:white} .side .grp,.side .brand small{color:var(--muted)}
.side-close{position:absolute;right:10px;top:10px}
@media(prefers-color-scheme:dark){:root:not([data-theme="light"]){--bg:#101b29;--card:#182739;--line:#34485d;--brand:#83caff;--brand-soft:#183b57;--ink:#eef6ff;--muted:#b1c3d4}}
.login{position:relative;max-width:480px;margin:clamp(24px,7vh,80px) auto;padding:0 20px 32px}
.login-landscape{height:128px;background:#d9eeff url('/nexus-campus.webp') center 54%/cover;border-radius:20px;margin-bottom:-32px}
.login .logo{position:relative;width:72px;height:72px;object-fit:contain;background:var(--card);padding:7px;border-radius:18px}
.admin-login{margin:20px 0}.admin-login summary{color:var(--muted);cursor:pointer;text-align:center}.admin-login form{margin-top:12px}
