/* Tantangan Belajar Tubita — mobile-first, mode terang & gelap. */

:root {
  --bg: #f4f2ec;
  --kartu: #ffffff;
  --kartu-2: #f8f7f3;
  --teks: #1b1c1a;
  --redup: #66675f;
  --garis: #e2dfd6;
  --aksen: #1d6b55;
  --aksen-tekan: #155342;
  --aksen-teks: #ffffff;
  --aksen-lembut: #e1efe9;
  --bahaya: #b23c1c;
  --bahaya-lembut: #fbe8e1;
  --peringatan: #8a5a00;
  --peringatan-lembut: #fdf1d6;
  --sorot: #fff6dd;
  --emas: #c69214;
  --perak: #8c959c;
  --perunggu: #b06c3f;
  --bayang: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 14px rgb(0 0 0 / 0.04);
  --radius: 14px;
  --radius-kecil: 10px;
  --menu-tinggi: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="terang"]) {
    --bg: #111413;
    --kartu: #1a1e1c;
    --kartu-2: #212624;
    --teks: #ecebe6;
    --redup: #a3a59c;
    --garis: #2e3431;
    --aksen: #4fbf98;
    --aksen-tekan: #6fd0ad;
    --aksen-teks: #0c1f18;
    --aksen-lembut: #1d3029;
    --bahaya: #f08466;
    --bahaya-lembut: #3a221b;
    --peringatan: #f0c060;
    --peringatan-lembut: #352a12;
    --sorot: #2b2818;
    --bayang: 0 1px 2px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}
:root[data-tema="gelap"] {
  --bg: #111413;
  --kartu: #1a1e1c;
  --kartu-2: #212624;
  --teks: #ecebe6;
  --redup: #a3a59c;
  --garis: #2e3431;
  --aksen: #4fbf98;
  --aksen-tekan: #6fd0ad;
  --aksen-teks: #0c1f18;
  --aksen-lembut: #1d3029;
  --bahaya: #f08466;
  --bahaya-lembut: #3a221b;
  --peringatan: #f0c060;
  --peringatan-lembut: #352a12;
  --sorot: #2b2818;
  --bayang: 0 1px 2px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--teks);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.ada-menu { padding-bottom: calc(var(--menu-tinggi) + env(safe-area-inset-bottom)); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: inherit; }
small { font-size: .82em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
:focus-visible { outline: 3px solid var(--aksen); outline-offset: 2px; border-radius: 4px; }
/* Tautan #anker tidak tertutup header yang menempel di atas */
[id] { scroll-margin-top: 84px; }

.redup { color: var(--redup); }
.kecil { font-size: .875rem; }
.tengah { text-align: center; }
.tersembunyi {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.ikon { width: 20px; height: 20px; flex: none; }

/* ---------- kepala & menu ---------- */
/* Sengaja tanpa backdrop-filter: properti itu menjadikan header "containing block"
   sehingga menu position:fixed di dalamnya ikut menempel ke header, bukan ke layar. */
.atas {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--garis);
}
.atas-isi {
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.merek { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; margin-right: auto; }
.merek-tanda {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--aksen); color: var(--aksen-teks);
}
.merek-teks { line-height: 1.1; }
.merek-teks small { display: block; font-weight: 500; color: var(--redup); font-size: .75rem; }

.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--kartu); border-top: 1px solid var(--garis);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.menu a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 48px; justify-content: center; padding: 4px;
  text-decoration: none; color: var(--redup); font-size: .75rem; font-weight: 600; border-radius: 10px;
}
.menu a[aria-current="page"] { color: var(--aksen); background: var(--aksen-lembut); }
.menu .ikon { width: 22px; height: 22px; }

@media (min-width: 760px) {
  body.ada-menu { padding-bottom: 0; }
  .menu {
    position: static; border: 0; background: none; padding: 0; gap: 4px;
  }
  .menu a { flex: none; flex-direction: row; gap: 6px; min-height: 40px; padding: 0 12px; font-size: .9rem; }
  .menu .ikon { width: 18px; height: 18px; }
}

.tombol-ikon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 12px; border: 1px solid var(--garis); background: var(--kartu); color: var(--teks);
  cursor: pointer; text-decoration: none;
}
.tombol-ikon:hover { border-color: var(--redup); }
.tombol-ikon.mati { opacity: .35; cursor: default; }

/* ---------- isi ---------- */
.isi { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.isi > * { margin: 0; }

.kartu {
  background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--bayang);
}
.kartu.sorot { background: var(--sorot); }
.kartu-kepala { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.kartu-kepala h2, .kartu-kepala p { margin: 0; }
.judul-bagian { font-size: 1.05rem; margin: 8px 0 10px; }
.label-kecil { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--redup); margin: 0; }
.sub { margin-top: 16px; font-size: .9rem; color: var(--redup); }

.pesan { padding: 12px 14px; border-radius: var(--radius-kecil); font-weight: 600; margin: 0; }
.pesan.ok { background: var(--aksen-lembut); color: var(--aksen); }
.pesan.galat { background: var(--bahaya-lembut); color: var(--bahaya); }

.kosong { color: var(--redup); padding: 16px; text-align: center; border: 1px dashed var(--garis); border-radius: var(--radius); }

.sapa h1 { margin: 0 0 6px; }
.sapa p { margin: 0; }
.chip, .lencana {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--kartu-2); border: 1px solid var(--garis);
  white-space: nowrap; flex: none;
}
.chip { background: var(--aksen-lembut); color: var(--aksen); border-color: transparent; }
.lencana .ikon { width: 14px; height: 14px; }
.lencana.ok { background: var(--aksen-lembut); color: var(--aksen); border-color: transparent; }
.lencana.tolak { background: var(--bahaya-lembut); color: var(--bahaya); border-color: transparent; }
.lencana.hari-ini { background: var(--aksen); color: var(--aksen-teks); border-color: transparent; }

/* ---------- tombol ---------- */
.tombol, .tombol-garis {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.tombol { background: var(--aksen); color: var(--aksen-teks); }
.tombol:hover { background: var(--aksen-tekan); }
.tombol:disabled { opacity: .55; cursor: progress; }
.tombol.bahaya { background: var(--bahaya); color: #fff; }
.tombol-garis { background: transparent; color: var(--teks); border-color: var(--garis); }
.tombol-garis:hover { border-color: var(--redup); }
.lebar { width: 100%; }
.tombol-kecil {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px;
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--kartu-2); color: var(--teks); border: 1px solid var(--garis);
}
.tombol-kecil.bahaya { color: var(--bahaya); }
.tombol-teks {
  background: none; border: 0; padding: 6px 0; font: inherit; cursor: pointer; color: var(--redup);
  text-decoration: underline; text-underline-offset: 3px; min-height: 36px;
}
.tombol-teks.bahaya { color: var(--bahaya); }
.tautan { color: var(--aksen); font-weight: 600; text-underline-offset: 3px; }
.kembali { display: inline-flex; align-items: center; gap: 4px; color: var(--redup); text-decoration: none; font-weight: 600; }
.kembali .ikon { width: 18px; height: 18px; }
.baris-tombol { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }

/* ---------- minggu ini ---------- */
.hari7 { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hari7 li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hari7-titik {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px dashed var(--garis); color: var(--aksen-teks);
}
.hari7-titik .ikon { width: 18px; height: 18px; }
.hari7 .aktif .hari7-titik { background: var(--aksen); border: 2px solid var(--aksen); }
.hari7 .kini .hari7-titik { border-style: solid; border-color: var(--aksen); }
.hari7 .kini .hari7-nama { color: var(--aksen); font-weight: 700; }
.hari7 .nanti { opacity: .45; }
.hari7-nama { font-size: .78rem; color: var(--redup); font-weight: 600; }

.progres-teks { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.bar { height: 10px; border-radius: 999px; background: var(--kartu-2); border: 1px solid var(--garis); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--aksen); border-radius: inherit; transition: width .4s ease; }

.statistik { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.statistik div { background: var(--kartu-2); border-radius: var(--radius-kecil); padding: 10px; }
.statistik dt { font-size: .75rem; color: var(--redup); font-weight: 600; }
.statistik dd { margin: 2px 0 0; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.statistik dd small { font-size: .75rem; font-weight: 600; color: var(--redup); }

/* ---------- kartu hari ini ---------- */
.dua-kartu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot { display: flex; flex-direction: column; gap: 6px; padding: 14px; }
.slot h3, .slot p { margin: 0; }
.slot .tombol { margin-top: auto; min-height: 42px; }
.slot-kepala { display: flex; justify-content: space-between; align-items: center; }
.slot-ikon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--aksen-lembut); color: var(--aksen);
}
.poin-lencana { font-weight: 800; color: var(--aksen); font-size: 1.1rem; }
.slot-valid { border-color: color-mix(in srgb, var(--aksen) 40%, var(--garis)); }
.status-ok { display: flex; align-items: center; gap: 6px; color: var(--aksen); font-weight: 700; margin-top: auto !important; }
.status-tolak { color: var(--bahaya); font-weight: 600; font-size: .85rem; margin-top: auto !important; }

/* ---------- daftar setoran ---------- */
.daftar-setoran { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.kartu .daftar-setoran .setoran { background: var(--kartu-2); }
.setoran {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start;
  background: var(--kartu); border: 1px solid var(--garis); border-radius: var(--radius); padding: 10px;
}
.setoran p { margin: 0; }
.thumb { display: block; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--kartu-2); border: 1px solid var(--garis); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.setoran-isi { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.setoran-judul { font-weight: 700; overflow-wrap: anywhere; }
.pelajaran { font-style: italic; font-size: .9rem; overflow-wrap: anywhere; }
.setoran-kanan { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.poin { font-weight: 800; color: var(--aksen); font-size: 1.05rem; }
.setoran.ditolak .setoran-judul { text-decoration: line-through; color: var(--redup); }
.setoran.ditolak .thumb { opacity: .5; }

/* ---------- aturan ---------- */
.aturan summary { font-weight: 700; cursor: pointer; min-height: 28px; }
.aturan ul { margin: 12px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- formulir ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-sempit { max-width: 440px; width: 100%; margin: 12px auto 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, .label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.kolom { display: flex; flex-direction: column; gap: 4px; }
input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), textarea, select {
  width: 100%; font: inherit; color: var(--teks); background: var(--kartu);
  border: 1px solid var(--garis); border-radius: 12px; padding: 11px 13px; min-height: 46px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, textarea:focus { outline: 2px solid var(--aksen); outline-offset: 0; border-color: var(--aksen); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bahaya); }
.petunjuk { color: var(--redup); }
.petunjuk.peringatan { color: var(--peringatan); background: var(--peringatan-lembut); padding: 8px 10px; border-radius: 10px; font-size: .9rem; margin: 8px 0 0; }
.galat-kolom { color: var(--bahaya); font-size: .875rem; font-weight: 600; margin: 4px 0 0; }
.galat-kolom:empty { display: none; }

.opsi-grup { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.opsi-grup.kolom-1 { grid-template-columns: 1fr; }
.opsi { position: relative; display: block; cursor: pointer; }
.opsi input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opsi span {
  display: flex; flex-direction: column; justify-content: center; min-height: 52px; padding: 8px 12px;
  border: 1px solid var(--garis); border-radius: 12px; background: var(--kartu); font-weight: 700; line-height: 1.2;
}
.opsi-grup.kolom-1 .opsi span { flex-direction: row; justify-content: flex-start; min-height: 46px; }
.opsi small { color: var(--redup); font-weight: 600; }
.opsi input:checked + span { border-color: var(--aksen); background: var(--aksen-lembut); color: var(--aksen); box-shadow: inset 0 0 0 1px var(--aksen); }
.opsi input:checked + span small { color: var(--aksen); }
.opsi input:focus-visible + span { outline: 3px solid var(--aksen); outline-offset: 2px; }
.opsi input:disabled + span { opacity: .45; cursor: not-allowed; }

.unggah {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: 64px;
  border: 2px dashed var(--garis); border-radius: 12px; background: var(--kartu-2); cursor: pointer; padding: 10px;
  text-align: center; font-weight: 600; color: var(--redup);
}
.unggah input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.unggah:focus-within { border-color: var(--aksen); }
.pratinjau img { max-height: 240px; width: auto; border-radius: 10px; border: 1px solid var(--garis); margin-top: 8px; }

/* ---------- leaderboard ---------- */
.pengumuman { background: linear-gradient(160deg, var(--sorot), var(--kartu) 70%); }
.podium, .podium-divisi, .daftar-individu, .daftar-divisi, .daftar-peserta { list-style: none; padding: 0; margin: 0; }
.podium { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.podium li, .daftar-individu li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; }
.podium li { background: var(--kartu); border: 1px solid var(--garis); border-radius: 12px; padding: 8px 12px; }
.podium-divisi { display: flex; flex-direction: column; gap: 6px; }
.podium-divisi li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; }
.nomor {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  font-weight: 800; font-size: .9rem; background: var(--kartu-2); color: var(--redup); font-variant-numeric: tabular-nums;
}
.medali-1 { background: var(--emas); color: #fff; }
.medali-2 { background: var(--perak); color: #fff; }
.medali-3 { background: var(--perunggu); color: #fff; }
.nama { display: flex; flex-direction: column; min-width: 0; }
.nama strong { overflow-wrap: anywhere; }
.poin-besar { font-weight: 800; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.poin-besar small { font-size: .75rem; color: var(--redup); font-weight: 600; }
.target-ok { color: var(--aksen); font-weight: 700; }

.saklar { display: grid; grid-template-columns: 1fr 1fr; background: var(--kartu-2); border: 1px solid var(--garis); border-radius: 12px; padding: 4px; gap: 4px; }
.saklar a { display: grid; place-items: center; min-height: 40px; border-radius: 9px; text-decoration: none; font-weight: 700; color: var(--redup); }
.saklar a[aria-current="true"] { background: var(--kartu); color: var(--teks); box-shadow: var(--bayang); }

.pilih-minggu { display: flex; align-items: center; gap: 12px; }
.pilih-minggu-teks { flex: 1; display: flex; flex-direction: column; align-items: center; }

.daftar-divisi { display: flex; flex-direction: column; gap: 14px; }
.daftar-divisi li { display: flex; flex-direction: column; gap: 6px; }
.daftar-divisi li.saya { background: var(--sorot); margin: -6px -8px; padding: 6px 8px; border-radius: 10px; }
.daftar-divisi p { margin: 0; }
.baris-atas { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.skor { font-weight: 800; font-variant-numeric: tabular-nums; }
.skor small { font-weight: 600; color: var(--redup); }

.daftar-individu { display: flex; flex-direction: column; }
.daftar-individu li { padding: 10px 6px; border-bottom: 1px solid var(--garis); }
.daftar-individu li:last-child { border-bottom: 0; }
.daftar-individu li.saya { background: var(--sorot); border-radius: 10px; border-bottom-color: transparent; }
.pemisah { text-align: center; color: var(--redup); margin: 4px 0 !important; }
#individu .tombol-garis { margin-top: 12px; }

/* ---------- admin ---------- */
.grid-divisi { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grid-divisi { grid-template-columns: repeat(3, 1fr); } }
.daftar-peserta li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--garis); flex-wrap: wrap; }
.daftar-peserta li:last-child { border-bottom: 0; }
.daftar-peserta .nama { flex: 1 1 200px; }
.daftar-peserta .nama strong { display: inline; margin-right: 6px; }
.aksi { display: flex; gap: 8px; }
.bahaya-kartu { border-color: color-mix(in srgb, var(--bahaya) 45%, var(--garis)); }
.sandi-sementara { font-size: 1.6rem; font-weight: 800; letter-spacing: .06em; background: var(--kartu-2); border-radius: 12px; padding: 14px; text-align: center; user-select: all; }

/* ---------- lightbox ---------- */
.lightbox { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; }
.lightbox::backdrop { background: rgb(0 0 0 / 0.85); }
.lightbox[open] { display: grid; place-items: center; }
.lightbox img { max-width: min(96vw, 1280px); max-height: 88vh; border-radius: 8px; object-fit: contain; }
.lightbox form { position: fixed; top: 12px; right: 12px; }
.lightbox-tutup {
  width: 48px; height: 48px; border-radius: 50%; border: 0; font-size: 2rem; line-height: 1;
  background: rgb(255 255 255 / 0.15); color: #fff; cursor: pointer;
}

@media (min-width: 760px) {
  .isi { padding-top: 28px; gap: 20px; }
  .kartu { padding: 20px; }
  h1 { font-size: 1.9rem; }
}
@media (max-width: 360px) {
  .dua-kartu { grid-template-columns: 1fr; }
  .statistik dd { font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) {
  .bar > span { transition: none; }
}
