/* CBT PyKelas - gaya bersama halaman mahasiswa dan admin. Tanpa font/skrip luar. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #141a24;
  --muted: #566070;
  --line: #dde2ea;
  --brand: #1f4fd6;
  --brand-hover: #173fb0;
  --brand-soft: #e6edfd;
  --on-brand: #ffffff;
  --ok: #17803d;
  --ok-soft: #e2f4e8;
  --warn: #a15c07;
  --warn-soft: #fdf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --code-bg: #101827;
  --code-ink: #e6edf7;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 4px 16px rgb(16 24 40 / .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b;
    --surface: #161d28;
    --surface-2: #1d2634;
    --ink: #e8edf5;
    --muted: #9aa6b8;
    --line: #2a3446;
    --brand: #6f97ff;
    --brand-hover: #8fadff;
    --brand-soft: #1b2a52;
    --on-brand: #0b1220;
    --ok: #55c982;
    --ok-soft: #12301f;
    --warn: #f0b250;
    --warn-soft: #3a2a0c;
    --bad: #ff8a80;
    --bad-soft: #3d1815;
    --code-bg: #0a0f18;
    --code-ink: #e6edf7;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace; }
a { color: var(--brand); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.wrap { width: min(100% - 32px, 1120px); margin-inline: auto; }
.wrap-sempit { width: min(100% - 32px, 520px); margin-inline: auto; }
.kartu { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.muted { color: var(--muted); }
.kecil { font-size: .875rem; }

/* ---------- tombol & isian ---------- */
.tombol {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; padding: 10px 16px; min-height: 44px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tombol:hover { background: var(--surface-2); }
.tombol:disabled { opacity: .5; cursor: not-allowed; }
.tombol.utama { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.tombol.utama:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
.tombol.bahaya { color: var(--bad); border-color: var(--bad); }
.tombol.bahaya:hover { background: var(--bad-soft); }
.tombol.kecil { min-height: 34px; padding: 4px 10px; font-size: .875rem; }
.tombol.penuh { width: 100%; }

label.isian { display: block; margin-bottom: 14px; font-weight: 600; font-size: .95rem; }
label.isian > span.bantu { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; margin-top: 6px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; min-height: 140px; }

.pesan { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; font-size: .95rem; border: 1px solid transparent; }
.pesan.galat { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.pesan.info { background: var(--brand-soft); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }
.pesan.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.pesan.waspada { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

.lencana { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.lencana.ok { background: var(--ok-soft); color: var(--ok); }
.lencana.warn { background: var(--warn-soft); color: var(--warn); }
.lencana.bad { background: var(--bad-soft); color: var(--bad); }
.titik { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- halaman masuk ---------- */
.masuk { min-height: 100dvh; display: grid; place-items: center; padding: 24px 0; }
.merek { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.merek img { width: 52px; height: 52px; object-fit: contain; }
.merek .kecil { margin: 0; }
.merek h1 { margin: 0; font-size: 1.3rem; }
.aturan { margin: 0 0 18px; padding-left: 1.2em; color: var(--muted); font-size: .92rem; }
.aturan li { margin-bottom: 4px; }
.centang { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; font-size: .92rem; }
.centang input { margin-top: 4px; width: 20px; height: 20px; flex: none; accent-color: var(--brand); }

/* ---------- layar ujian ---------- */
.bilah {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 var(--line);
}
.bilah .wrap { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; padding-block: 6px; }
.bilah .siapa { flex: 1 1 160px; min-width: 0; }
.bilah .siapa strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bilah .kemajuan { flex: 0 0 auto; font-size: .9rem; color: var(--muted); }
.waktu {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.35rem; padding: 4px 14px; border-radius: 10px;
  background: var(--surface-2); min-width: 108px; text-align: center; font-family: ui-monospace, Consolas, monospace;
}
.waktu.menipis { background: var(--warn-soft); color: var(--warn); }
.waktu.kritis { background: var(--bad-soft); color: var(--bad); animation: denyut 1s ease-in-out infinite; }
@keyframes denyut { 50% { opacity: .65; } }
.status-simpan { font-size: .8rem; color: var(--muted); min-width: 88px; }
.status-simpan.gagal { color: var(--bad); font-weight: 700; }

.ujian { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; padding: 20px 0 80px; }
@media (max-width: 860px) { .ujian { grid-template-columns: 1fr; } }

.soal-kartu { padding: 24px; user-select: none; -webkit-user-select: none; }
.soal-no { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-weight: 700; }
.soal-tanya { font-size: 1.1rem; font-weight: 600; margin-bottom: 14px; white-space: pre-wrap; }
.kode {
  background: var(--code-bg); color: var(--code-ink); border-radius: 10px; padding: 14px 16px; margin: 0 0 18px;
  overflow-x: auto; font-size: .95rem; line-height: 1.55; tab-size: 4;
}
.opsi { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.opsi legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.pilihan {
  display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; min-height: 52px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
}
.pilihan:hover { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); }
.pilihan input { position: absolute; opacity: 0; pointer-events: none; }
.pilihan .huruf {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: var(--surface-2); color: var(--muted);
}
.pilihan .teks { padding-top: 3px; white-space: pre-wrap; word-break: break-word; }
.pilihan .teks.mono { font-family: ui-monospace, Consolas, monospace; font-size: .95rem; padding-top: 4px; }
.pilihan:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pilihan:has(input:checked) .huruf { background: var(--brand); color: var(--on-brand); }
.pilihan:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }

.kelompok-esai { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.editor {
  width: 100%; margin: 0; min-height: 260px; resize: vertical; user-select: text; -webkit-user-select: text;
  font-family: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace; font-size: .95rem; line-height: 1.5; tab-size: 4; white-space: pre; overflow: auto;
  background: var(--code-bg); color: var(--code-ink); border-color: var(--line);
}
.petak button.esai { border-style: dashed; }
.petak button.esai.terjawab { border-style: solid; }
.navigasi { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.navigasi .rapat { margin-left: auto; }
.ragu { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; user-select: none; }
.ragu input { width: 18px; height: 18px; accent-color: var(--warn); }

.peta { position: sticky; top: 76px; padding: 16px; }
@media (max-width: 860px) { .peta { position: static; } }
.peta h2 { font-size: 1rem; }
.petak { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.petak button {
  appearance: none; font: inherit; font-weight: 700; font-size: .9rem; min-height: 40px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); position: relative;
}
.petak button.terjawab { background: var(--brand-soft); border-color: var(--brand); }
.petak button.ragu-tanda::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.petak button[aria-current=true] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin-bottom: 14px; }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); margin-right: 5px; vertical-align: -1px; }

.selubung { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.selubung-isi { width: min(100%, 460px); text-align: center; }
.cap-air { position: fixed; inset: 0; z-index: 40; pointer-events: none; opacity: .09; background-repeat: repeat; }
.lencana.peringatan { background: var(--warn-soft); color: var(--warn); }
.lencana.bahaya { background: var(--bad-soft); color: var(--bad); }
.peringatan-tab {
  position: fixed; inset: auto 16px 16px 16px; z-index: 30; max-width: 520px; margin-inline: auto;
}

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 24px; width: min(92vw, 460px); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(8 12 20 / .55); }
dialog .aksi { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---------- hasil ---------- */
.hasil-skor { text-align: center; padding: 8px 0 20px; }
.hasil-skor .angka { font-size: 4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hasil-skor .angka small { font-size: 1.2rem; color: var(--muted); font-weight: 600; }
.batang-materi { display: grid; grid-template-columns: 90px 1fr 52px; gap: 10px; align-items: center; margin: 8px 0; font-size: .92rem; }
.batang { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.batang > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.batang > i.rendah { background: var(--warn); }

/* ---------- admin ---------- */
.admin-atas { background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-atas .wrap { display: flex; align-items: center; gap: 14px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.admin-atas img { width: 36px; height: 36px; object-fit: contain; }
.admin-atas h1 { font-size: 1.1rem; margin: 0; }
.admin-atas .kanan { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tab { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0 18px; overflow-x: auto; }
.tab button {
  appearance: none; background: none; border: 0; font: inherit; font-weight: 700; color: var(--muted); padding: 12px 16px;
  cursor: pointer; border-bottom: 3px solid transparent; min-height: 44px; white-space: nowrap;
}
.tab button[aria-selected=true] { color: var(--brand); border-bottom-color: var(--brand); }
.grid-ubin { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ubin { padding: 16px; }
.ubin .nilai { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ubin .label { color: var(--muted); font-size: .85rem; }
.dua-kolom { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 18px; }
.baris-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.baris-form > label.isian { flex: 1 1 140px; margin-bottom: 0; }

.tabel-bungkus { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.angka, th.angka { text-align: right; font-variant-numeric: tabular-nums; }
td.nama { white-space: normal; min-width: 160px; }
.peta-panas td.sel { text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; padding: 8px 6px; min-width: 52px; }
.alat { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.alat input[type=search], .alat select { width: auto; margin: 0; min-width: 150px; }
.alat .rapat { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.kuat { font-weight: 700; }
.lembar { margin-bottom: 16px; padding: 16px; }
.lembar header { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.lembar pre.kode { margin: 0 0 12px; max-height: 340px; overflow: auto; white-space: pre; }
.lembar .rubrik { display: grid; gap: 8px; margin-bottom: 10px; }
.lembar .aspek { display: grid; grid-template-columns: 1fr 86px; gap: 10px; align-items: center; font-size: .92rem; }
.lembar .aspek select { margin: 0; min-height: 36px; padding: 4px 8px; }
.lembar .baris-simpan { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lembar .baris-simpan input[type=text] { flex: 1 1 200px; margin: 0; min-height: 38px; }
.lembar.dinilai { border-left: 4px solid var(--ok); }
details.butir { border-bottom: 1px solid var(--line); }
details.butir summary { cursor: pointer; padding: 10px 12px; display: flex; gap: 12px; align-items: center; }
details.butir[open] { background: var(--surface-2); }
.dist { display: grid; gap: 6px; padding: 8px 12px 16px 44px; }
.dist .baris { display: grid; grid-template-columns: 24px minmax(120px, 1fr) 70px; gap: 10px; align-items: center; font-size: .88rem; }
.dist .benar { color: var(--ok); font-weight: 700; }

@media (prefers-reduced-motion: reduce) { .waktu.kritis { animation: none; } }
@media print { body { display: none !important; } }
