/* Reload LMS — mobile first, no inline styles (strict CSP). */
:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1f1e; --muted: #6b6f6c; --line: #e4e1d9;
  --brand: #14322e; --brand-2: #1f4a44; --accent: #c8a46a; --ok: #1f7a4d; --warn: #b7791f; --bad: #b42318;
  --okbg: #e7f4ec; --warnbg: #fdf3e1; --badbg: #fdecea;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --c-teal: #2a7a72; --c-amber: #b7791f; --c-rose: #b4485c; --c-indigo: #4c55a8; --c-emerald: #2f8a57; --c-slate: #4a5563;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.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; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; display: flex; align-items: center; gap: 12px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; color: #fff; text-decoration: none; }
.topbar .brand img { width: 30px; height: 30px; }
.topbar nav { margin-left: auto; display: none; gap: 4px; }
.topbar nav a { color: #e6efe9; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: .92rem; }
.topbar nav a.on { background: rgba(255,255,255,.14); color: #fff; }
main { max-width: 960px; margin: 0 auto; padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: .74rem; color: var(--muted); text-decoration: none; }
.bottomnav a .ico { display: block; font-size: 1.25rem; line-height: 1.4; }
.bottomnav a.on { color: var(--brand); font-weight: 600; }
@media (min-width: 760px) {
  .topbar nav { display: flex; } .bottomnav { display: none; }
  main { padding-bottom: 40px; padding-top: 24px; }
}

/* cards & bits */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid var(--line); }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid.four { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 14px 16px; } .stat b { display: block; font-size: 1.5rem; } .stat span { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef0ee; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--okbg); color: var(--ok); } .badge.warn { background: var(--warnbg); color: var(--warn); }
.badge.bad { background: var(--badbg); color: var(--bad); } .badge.brand { background: var(--brand); color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: .88rem; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.bar { height: 8px; border-radius: 999px; background: #eceae4; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 999px; width: 0; transition: width .3s; }
.bar.in > i { background: var(--warn); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f3f2ee; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f1c6c1; }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
label.f { display: block; font-size: .85rem; font-weight: 600; color: #3b3f3c; margin-bottom: 4px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid #d6d3ca; border-radius: 10px; background: #fff; padding: 10px 12px; min-height: 42px; }
textarea.input { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88rem; }
.input:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.err { color: var(--bad); font-size: .88rem; min-height: 1.2em; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(160deg, #14322e 0%, #1f4a44 55%, #2b5a52 100%); }
.login { width: 100%; max-width: 380px; }
.login .logo { display: block; width: 84px; height: 84px; margin: 0 auto 8px; }
.login h1 { color: #fff; text-align: center; margin-bottom: 4px; }
.login .sub { color: #cfe0da; text-align: center; margin: 0 0 20px; font-size: .92rem; }
.pin { letter-spacing: .5em; text-align: center; font-size: 1.4rem; }

/* course cards */
.ccard { display: flex; flex-direction: column; overflow: hidden; padding: 0; text-decoration: none; color: inherit; }
.ccard .cover { height: 84px; padding: 14px 16px; color: #fff; display: flex; align-items: flex-end; justify-content: space-between; }
.ccard .cover .cat { font-size: .78rem; opacity: .9; text-transform: uppercase; letter-spacing: .06em; }
.ccard .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ccard h3 { margin: 0; }
.ccard .desc { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cover-teal { background: linear-gradient(135deg, var(--c-teal), #1c5751); }
.cover-amber { background: linear-gradient(135deg, var(--c-amber), #8c5a12); }
.cover-rose { background: linear-gradient(135deg, var(--c-rose), #8b3446); }
.cover-indigo { background: linear-gradient(135deg, var(--c-indigo), #363d82); }
.cover-emerald { background: linear-gradient(135deg, var(--c-emerald), #1f6440); }
.cover-slate { background: linear-gradient(135deg, var(--c-slate), #2f3742); }
.hero { border-radius: var(--radius); color: #fff; padding: 20px; margin-bottom: 16px; }
.hero h1 { margin: 4px 0 6px; }
.hero p { margin: 0; opacity: .92; }
.back { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); text-decoration: none; font-size: .9rem; margin-bottom: 10px; }

/* lesson list */
.llist { list-style: none; margin: 0; padding: 0; }
.llist li + li { border-top: 1px solid var(--line); }
.llist a, .llist .item { display: flex; gap: 12px; align-items: center; padding: 12px 4px; text-decoration: none; color: inherit; }
.llist .num { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: #eceae4; font-weight: 700; font-size: .85rem; flex: none; }
.llist .num.done { background: var(--ok); color: #fff; }
.llist .num.lock { background: #f1efe9; color: #a3a69f; }

/* lesson content */
.prose { font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.2em; }
.prose blockquote { margin: 1em 0; padding: 10px 14px; border-left: 4px solid var(--accent); background: #faf6ee; border-radius: 0 8px 8px 0; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose code { background: #f1efe9; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.video { position: relative; width: 100%; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; margin-bottom: 16px; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.attach { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px dashed #cfcabd; border-radius: 12px; background: #fcfbf8; }
.attach img { max-width: 100%; }
.lesson-foot { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--bg); padding: 12px 0; margin-top: 16px; }
@media (min-width: 760px) { .lesson-foot { bottom: 0; } }

/* quiz */
.q { padding: 16px; }
.q .qn { font-size: .8rem; color: var(--muted); font-weight: 600; }
.q .qt { font-weight: 600; margin: 4px 0 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin-top: 8px; background: #fff; }
.opt input { margin-top: 3px; accent-color: var(--brand); }
.opt.on { border-color: var(--brand-2); background: #eef5f3; }
.result { text-align: center; padding: 24px 16px; }
.result .score { font-size: 3rem; font-weight: 800; line-height: 1; }
.result.pass .score { color: var(--ok); } .result.fail .score { color: var(--bad); }
.rv { border-left: 4px solid var(--ok); } .rv.bad { border-left-color: var(--bad); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th, table.t td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th { background: #faf9f6; font-weight: 600; color: #4a4e4b; position: sticky; top: 0; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.wrap { white-space: normal; min-width: 160px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #d8d5cc; vertical-align: middle; }
.dot.completed { background: var(--ok); } .dot.in_progress { background: var(--warn); }

/* admin */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; font-size: .92rem; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.editor-item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.editor-item:first-child { border-top: 0; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.opt-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--ok); flex: none; }
.pinbox { font-family: ui-monospace, Menlo, monospace; font-size: 1.6rem; letter-spacing: .3em; font-weight: 700; text-align: center;
  padding: 12px; background: #f6f4ef; border-radius: 10px; margin: 10px 0; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 18, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 680px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; padding: 24px; } }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 60;
  background: #1d1f1e; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }

/* spacing + link cards */
main > * + * { margin-top: 12px; }
main > h2 { margin-top: 20px; }
a.card { text-decoration: none; color: inherit; display: block; }
a.card.spread { display: flex; }
a.card.ccard { display: flex; }
textarea.input.plain { font-family: inherit; font-size: .95rem; min-height: 90px; }

/* requests, deadlines, NIK chips */
.tabcount { margin-left: 6px; font-size: .68rem; padding: 1px 6px; }
.bad-text { color: var(--bad); font-weight: 600; }
.dot.overdue { background: var(--bad); }
.chip .chip-x { border: 0; background: transparent; margin-left: 6px; cursor: pointer; color: var(--muted); padding: 0; }
.chip.on .chip-x { color: #fff; }

/* profile + avatars */
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: #e6e2d8; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--brand); font-size: .8rem; vertical-align: middle; }
.avatar.lg { width: 76px; height: 76px; font-size: 1.6rem; }
.avatar.ph { text-transform: uppercase; }
.profile { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.profile h2 { margin: 0 0 2px; }
.profile-grid > div { padding: 8px 0; border-top: 1px solid var(--line); }
a.who { display: inline-flex; align-items: center; gap: 8px; }
.hero-me { position: relative; }
.hero-photo { position: absolute; right: 18px; top: 18px; border: 3px solid rgba(255,255,255,.7); }
.hero-me h1, .hero-me .small, .hero-me p { padding-right: 90px; }
.grid.two.profile-grid { grid-template-columns: 1fr 1fr; column-gap: 16px; }
table.t td .row { flex-wrap: nowrap; }
