:root {
  --ink: #1E2A5E;
  --ink-soft: #4A5585;
  --ink-faint: #8A93B8;
  --paper: #F3F6FC;
  --grid: #DFE6F6;
  --white: #FFFFFF;
  --line: #CBD4EC;
  --sun: #FFC83D;
  --sun-soft: #FFF3CF;
  --math: #2F6BFF;
  --math-soft: #E4ECFF;
  --eng: #EF4E6E;
  --eng-soft: #FFE5EA;
  --ps: #7A4DE0;
  --ps-soft: #EEE7FF;
  --ok: #138A5C;
  --ok-soft: #DDF5EA;
  --warn: #B86E00;
  --warn-soft: #FFF0D6;
  --bad: #C92F2F;
  --bad-soft: #FDE3E3;
  --radius: 14px;
  --head: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Lexend", "Segoe UI", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  padding-bottom: var(--safe-bottom);
}
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.15; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .8em; }
a { color: var(--math); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .88rem; }
.small { font-size: .88rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding: calc(10px + var(--safe-top)) 18px 0;
}
.topbar-inner { max-width: 1120px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 1.35rem; font-weight: 800; }
.brand-icon {
  width: 40px; height: 40px; background: #fff; border-radius: 12px; padding: 3px; object-fit: contain; flex: none;
}
.login-logo { display: block; width: 100%; max-width: 260px; height: auto; margin: -6px auto 6px; }
.who { font-size: .85rem; opacity: .85; text-align: right; }
.who b { display: block; font-size: .95rem; opacity: 1; }
.nav { display: flex; gap: 4px; overflow-x: auto; margin-top: 10px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #fff; opacity: .78; text-decoration: none; padding: 9px 14px 11px;
  border-radius: 10px 10px 0 0; white-space: nowrap; font-size: .92rem;
}
.nav a:hover { opacity: 1; }
.nav a.on { background: var(--paper); color: var(--ink); opacity: 1; font-weight: 600; }

main { max-width: 1120px; margin: 0 auto; padding: 22px 18px 60px; }

/* ---------- Panels & buttons ---------- */
.panel {
  background: var(--white); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 18px;
}
.panel.flat { background: transparent; border: none; padding: 0; }
.panel h3 { margin-bottom: .6em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--ink); color: #fff; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2; min-height: 44px;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.sun { background: var(--sun); border-color: var(--ink); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: .88rem; border-radius: 10px; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; min-height: 54px; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: none; color: var(--math); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- Forms ---------- */
label.f { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
label.f > span.hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: .82rem; }
.inp, select.inp, textarea.inp {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-weight: 400;
}
.inp:focus { border-color: var(--math); outline: none; box-shadow: 0 0 0 3px var(--math-soft); }
textarea.inp { min-height: 110px; resize: vertical; font-family: var(--body); }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; min-height: 180px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: #fff; cursor: pointer; font-weight: 500;
}
.check input { width: 18px; height: 18px; }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--paper); }

/* ---------- Chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.chip.matematika { background: var(--math-soft); color: var(--math); }
.chip.english { background: var(--eng-soft); color: #B8243F; }
.chip.public_speaking { background: var(--ps-soft); color: var(--ps); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.plain { background: var(--paper); color: var(--ink-soft); }

/* ---------- Student: subject stickers (the signature element) ---------- */
.hello { margin: 4px 0 18px; }
.hello h1 { font-size: 2.3rem; margin-bottom: 2px; }
.stickers { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin: 8px 0 26px; }
.sticker {
  position: relative; border: 2.5px solid var(--ink); border-radius: 20px; padding: 18px 18px 16px;
  box-shadow: 6px 6px 0 var(--ink); color: var(--ink); text-decoration: none; display: block;
  transition: transform .12s, box-shadow .12s;
}
.sticker:hover { transform: translate(-2px,-2px); box-shadow: 8px 8px 0 var(--ink); }
.sticker:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.sticker.matematika { background: var(--math-soft); }
.sticker.english { background: var(--eng-soft); }
.sticker.public_speaking { background: var(--ps-soft); }
.sticker .emoji { font-size: 2.4rem; line-height: 1; }
.sticker h2 { margin: 8px 0 2px; font-size: 1.6rem; }
.sticker .lv { font-weight: 600; font-size: .9rem; }
.sticker .done {
  position: absolute; top: -12px; right: 14px; background: var(--sun); border: 2px solid var(--ink);
  border-radius: 99px; padding: 2px 10px; font-size: .8rem; font-weight: 700; transform: rotate(4deg);
}

.stat { padding: 14px 16px; }
.stat .n { font-family: var(--head); font-size: 2rem; font-weight: 800; line-height: 1; }
.stat .l { color: var(--ink-soft); font-size: .88rem; }

.list-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--grid); }
.list-item:last-child { border-bottom: none; }
.empty { padding: 22px; text-align: center; color: var(--ink-soft); border: 2px dashed var(--line); border-radius: var(--radius); background: rgba(255,255,255,.6); }

/* ---------- Activity player ---------- */
.player { max-width: 720px; margin: 0 auto; }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.progress { height: 12px; background: var(--white); border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--sun); transition: width .3s; }
.qcard { background: #fff; border: 2.5px solid var(--ink); border-radius: 20px; padding: 24px; box-shadow: 5px 5px 0 var(--ink); }
.qtext { font-family: var(--head); font-size: 1.7rem; font-weight: 700; margin-bottom: 18px; line-height: 1.25; white-space: pre-line; }
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; background: #fff;
  cursor: pointer; font-size: 1.05rem; font-weight: 500; min-height: 52px;
}
.opt:hover { border-color: var(--ink); }
.opt.right { background: var(--ok-soft); border-color: var(--ok); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); }
.answer-inp { font-size: 1.5rem; padding: 12px 14px; text-align: center; font-weight: 600; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.passage { background: var(--sun-soft); border: 2px solid var(--ink); border-radius: 16px; padding: 18px; margin-bottom: 16px; font-size: 1.05rem; line-height: 1.75; max-height: 40vh; overflow-y: auto; }
.speak-btn { font-size: 1.4rem; }
.bigmic {
  width: 120px; height: 120px; border-radius: 50%; border: 3px solid var(--ink); background: var(--eng);
  color: #fff; font-size: 2.8rem; cursor: pointer; box-shadow: 5px 5px 0 var(--ink); display: grid; place-items: center; margin: 10px auto;
}
.bigmic.rec { background: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .bigmic.rec { animation: none; } .sticker { transition: none; } }
.transcript { min-height: 52px; padding: 12px; border-radius: 12px; background: var(--paper); font-size: 1.05rem; }
.word-ok { color: var(--ok); font-weight: 600; }
.word-miss { color: var(--bad); text-decoration: underline wavy; }

/* match game */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 10px; align-content: start; }
.tile { padding: 14px 10px; border: 2px solid var(--ink); border-radius: 14px; background: #fff; cursor: pointer; font-weight: 600; font-size: 1rem; min-height: 54px; }
.tile.sel { background: var(--sun); }
.tile.gone { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); cursor: default; opacity: .7; }
.tile.shake { animation: shake .35s; background: var(--bad-soft); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* public speaking meters */
.meters { display: grid; gap: 14px; }
.vol { position: relative; height: 34px; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden;
  background: linear-gradient(90deg, #E9ECF5 0 35%, var(--ok-soft) 35% 85%, var(--bad-soft) 85% 100%); }
.vol > div { position: absolute; inset: 0 auto 0 0; background: var(--ps); width: 0; transition: width .08s; opacity: .85; }
.vol-labels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-soft); }
canvas.pitch { width: 100%; height: 90px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; display: block; }
.timer { font-family: var(--head); font-size: 2.6rem; font-weight: 800; text-align: center; }
.metric { border: 2px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.metric .mv { font-family: var(--head); font-size: 1.6rem; font-weight: 800; }
.bar { height: 8px; background: var(--grid); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar > div { height: 100%; background: var(--ps); }
.scorebig { font-family: var(--head); font-size: 4.5rem; font-weight: 800; line-height: 1; }

/* ---------- Modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(30,42,94,.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: calc(30px + var(--safe-top)) 14px 30px; overflow-y: auto; }
.modal { background: #fff; border: 2.5px solid var(--ink); border-radius: 20px; padding: 22px; width: 100%; max-width: 560px; box-shadow: 6px 6px 0 var(--ink); }
.modal.wide { max-width: 820px; }
.toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 80; max-width: 90vw; font-weight: 500; }
.toast.err { background: var(--bad); }
.stars { display: flex; gap: 6px; font-size: 2.1rem; }
.stars button { background: none; border: none; cursor: pointer; padding: 0 2px; filter: grayscale(1); opacity: .45; }
.stars button.on { filter: none; opacity: 1; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 400px; background: #fff; border: 2.5px solid var(--ink); border-radius: 24px; padding: 28px; box-shadow: 8px 8px 0 var(--ink); }
.login .brand { color: var(--ink); font-size: 1.6rem; margin-bottom: 4px; }

/* ---------- Charts ---------- */
.chart svg { width: 100%; height: auto; display: block; }

/* ---------- Report (print) ---------- */
.report { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 860px; margin: 0 auto; }
.report-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.report section { margin-bottom: 22px; break-inside: avoid; }
.report .subj-title { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--grid); padding-bottom: 6px; margin-bottom: 10px; }
.quote { border-left: 4px solid var(--sun); padding: 4px 12px; margin: 8px 0; font-style: italic; }
.print-note { white-space: pre-wrap; }


/* ---------- Papan peringkat ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 10px 0 14px; }
.pod { flex: 1; max-width: 140px; text-align: center; }
.pod-medal { font-size: 2rem; line-height: 1; }
.pod-name { font-weight: 600; font-size: .9rem; margin: 4px 0 2px; overflow-wrap: anywhere; }
.pod-val { font-family: var(--head); font-size: 1.5rem; font-weight: 800; }
.pod-block { border: 2px solid var(--ink); border-bottom: none; border-radius: 12px 12px 0 0; font-family: var(--head); font-weight: 800; font-size: 1.4rem; display: grid; place-items: center; }
.pod1 .pod-block { height: 86px; background: var(--sun); }
.pod2 .pod-block { height: 62px; background: #E5E9F2; }
.pod3 .pod-block { height: 46px; background: #F3D9C4; }
.pod.me .pod-name { color: var(--math); }
.lb-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 6px; border-bottom: 1px solid var(--grid); }
.lb-row.me { background: var(--sun-soft); border-radius: 10px; }
.lb-rank { font-family: var(--head); font-weight: 800; color: var(--ink-soft); text-align: center; }
.lb-val { font-family: var(--head); font-size: 1.2rem; }

/* ---------- Program harian ---------- */
.days { display: flex; gap: 8px; flex-wrap: wrap; }
.day {
  width: 62px; min-height: 66px; border: 2px solid var(--ink); border-radius: 14px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink); font-family: var(--head); font-weight: 800; font-size: 1.15rem; line-height: 1.05;
}
.day small { font-family: var(--body); font-weight: 500; font-size: .68rem; color: var(--ink-soft); }
.day.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.day.today { background: var(--sun); box-shadow: 3px 3px 0 var(--ink); }
.day.late { background: var(--warn-soft); }
.day.locked { opacity: .5; border-style: dashed; }
a.day:hover { transform: translate(-1px,-1px); }
.days.sm { gap: 4px; }
.days.sm .day { width: 30px; min-height: 30px; border-radius: 8px; font-size: .78rem; border-width: 1.5px; box-shadow: none; }
.days.sm .day small { display: none; }
.plan { padding: 14px 0; border-bottom: 1px solid var(--grid); }
.plan:last-child { border-bottom: none; }
.opts.pics { grid-template-columns: repeat(2, 1fr); }
.opts.pics .opt { font-size: 3.2rem; text-align: center; min-height: 96px; }
.emoji-big { font-size: 6rem; line-height: 1.1; }
.build-area { min-height: 62px; border: 2px dashed var(--line); border-radius: 14px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; background: var(--paper); align-items: center; }
.wtile { padding: 10px 14px; border: 2px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 600; cursor: pointer; font-size: 1.05rem; }
.build-area .wtile { background: var(--sun-soft); }
.stage-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.stage { padding: 4px 12px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-size: .85rem; }
.stage.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.stage.now { background: var(--sun); border-color: var(--ink); font-weight: 600; }
details.topics { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
details.topics summary { cursor: pointer; font-weight: 600; }
details.topics .checks { margin-top: 8px; }
.subpanel { border-left: 4px solid var(--line); padding-left: 14px; margin: 14px 0; }
.subpanel.matematika { border-color: var(--math); }
.subpanel.english { border-color: var(--eng); }
.subpanel.public_speaking { border-color: var(--ps); }

@media print {
  body { background: #fff; }
  .topbar, .no-print, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border: none; padding: 0; max-width: none; }
  textarea.inp { border: none; padding: 0; resize: none; min-height: 0; }
}

@media (max-width: 640px) {
  h1 { font-size: 1.6rem; }
  .hello h1 { font-size: 1.9rem; }
  .qtext { font-size: 1.4rem; }
  .qcard { padding: 18px; }
  main { padding: 16px 14px 60px; }
  .who { display: none; }
}
