/* ===== CBT Pro — Design tokens & komponen (gaya shadcn/ui) ===== */
:root{
  --background:0 0% 100%;--foreground:224 40% 12%;
  --muted:220 25% 96%;--muted-foreground:220 10% 42%;
  --border:220 20% 90%;--input:220 20% 86%;
  --primary:226 70% 48%;--primary-foreground:0 0% 100%;
  --accent:226 80% 96%;
  --destructive:0 75% 52%;--success:152 62% 33%;--warning:36 95% 48%;
  --radius:.65rem;
}
*{-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{font-family:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;background:hsl(var(--muted));color:hsl(var(--foreground));font-size:14.5px;line-height:1.5}
h1,h2,h3{letter-spacing:-.01em}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;height:2.4rem;padding:0 .95rem;border-radius:calc(var(--radius) - 2px);font-weight:500;font-size:.875rem;border:1px solid transparent;cursor:pointer;transition:all .15s;white-space:nowrap;user-select:none}
.btn:disabled{opacity:.5;pointer-events:none}
.btn svg{width:1rem;height:1rem;flex:none}
.btn-primary{background:hsl(var(--primary));color:#fff}.btn-primary:hover{filter:brightness(1.1)}
.btn-outline{background:#fff;border-color:hsl(var(--input));color:hsl(var(--foreground))}.btn-outline:hover{background:hsl(var(--muted))}
.btn-ghost{background:transparent;color:hsl(var(--foreground))}.btn-ghost:hover{background:hsl(var(--muted))}
.btn-destructive{background:hsl(var(--destructive));color:#fff}.btn-destructive:hover{filter:brightness(1.08)}
.btn-success{background:hsl(var(--success));color:#fff}.btn-success:hover{filter:brightness(1.1)}
.btn-warning{background:hsl(var(--warning));color:#fff}
.btn-soft{background:hsl(var(--accent));color:hsl(var(--primary))}.btn-soft:hover{filter:brightness(.97)}
.btn-sm{height:2rem;padding:0 .65rem;font-size:.8rem}
.btn-lg{height:2.9rem;padding:0 1.4rem;font-size:1rem}
.btn-icon{width:2.2rem;padding:0}.btn-icon.btn-sm{width:2rem}

/* Form */
.input{width:100%;min-height:2.4rem;border:1px solid hsl(var(--input));background:#fff;border-radius:calc(var(--radius) - 2px);padding:.45rem .7rem;font-size:.9rem;outline:none;transition:box-shadow .15s,border-color .15s;color:inherit}
.input:focus{border-color:hsl(var(--primary));box-shadow:0 0 0 3px hsl(var(--primary)/.15)}
textarea.input{resize:vertical}
.label{display:block;font-size:.8rem;font-weight:600;margin-bottom:.3rem;color:hsl(var(--foreground))}
.hint{font-size:.75rem;color:hsl(var(--muted-foreground))}
input[type=checkbox],input[type=radio]{accent-color:hsl(var(--primary));width:1rem;height:1rem}

/* Card, badge */
.card{background:#fff;border:1px solid hsl(var(--border));border-radius:var(--radius);box-shadow:0 1px 2px rgba(15,23,42,.04)}
.card-pad{padding:1.1rem}
.badge{display:inline-flex;align-items:center;gap:.25rem;padding:.12rem .55rem;border-radius:999px;font-size:.72rem;font-weight:600;border:1px solid transparent}
.badge-blue{background:#e0e9ff;color:#2748b8}.badge-green{background:#dcf5e6;color:#17703f}.badge-red{background:#fde4e4;color:#b42323}
.badge-amber{background:#fdf0d2;color:#966100}.badge-gray{background:#eceff4;color:#4a5568}.badge-violet{background:#ece4ff;color:#5b34b8}
.badge-pink{background:#fde3f1;color:#a3256f}.badge-orange{background:#ffe9d5;color:#a24a08}.badge-emerald{background:#d6f5ea;color:#0d6b49}.badge-slate{background:#e6ebf1;color:#3c4a5d}

/* Table */
.tbl-wrap{overflow:auto;border:1px solid hsl(var(--border));border-radius:var(--radius);background:#fff}
.tbl{width:100%;border-collapse:collapse;font-size:.85rem}
.tbl th{position:sticky;top:0;background:hsl(var(--muted));text-align:left;font-weight:600;padding:.6rem .75rem;border-bottom:1px solid hsl(var(--border));white-space:nowrap;font-size:.78rem;color:hsl(var(--muted-foreground));text-transform:uppercase;letter-spacing:.03em}
.tbl td{padding:.55rem .75rem;border-bottom:1px solid hsl(var(--border));vertical-align:middle}
.tbl tr:hover td{background:hsl(var(--muted)/.5)}

/* Tabs */
.tabs{display:flex;gap:.25rem;padding:.25rem;background:hsl(var(--muted));border-radius:var(--radius);width:fit-content;max-width:100%;overflow:auto}
.tab{padding:.4rem .9rem;border-radius:calc(var(--radius) - 2px);font-weight:500;font-size:.85rem;cursor:pointer;color:hsl(var(--muted-foreground));white-space:nowrap;border:0;background:transparent}
.tab.active{background:#fff;color:hsl(var(--foreground));box-shadow:0 1px 3px rgba(0,0,0,.1)}

/* Sidebar */
.nav-link{display:flex;align-items:center;gap:.7rem;padding:.6rem .85rem;border-radius:calc(var(--radius) - 2px);font-weight:500;color:#cbd5e6;font-size:.9rem;transition:all .15s}
.nav-link:hover{background:rgba(255,255,255,.08);color:#fff}
.nav-link.active{background:hsl(var(--primary));color:#fff;box-shadow:0 4px 12px hsl(var(--primary)/.4)}
.nav-link svg{width:1.1rem;height:1.1rem}

/* Sidebar admin: responsif tanpa bergantung pada utilitas Tailwind */
#sidebar{position:fixed;top:0;left:0;z-index:40;height:100vh;width:16rem;flex-shrink:0;display:flex;flex-direction:column;transform:translateX(-100%);transition:transform .25s}
#sidebar.open{transform:none}
#side-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.5);z-index:30;display:none}
#side-backdrop.open{display:block}
@media (min-width:1024px){
  #sidebar{position:sticky;transform:none}
  #side-backdrop,#side-backdrop.open{display:none}
}

/* Stat tiles */
.stat{display:flex;align-items:center;gap:.9rem;padding:1rem 1.1rem}
.stat-ico{width:2.8rem;height:2.8rem;border-radius:.8rem;display:grid;place-items:center;flex:none}
.stat-ico svg{width:1.4rem;height:1.4rem}

/* Soal card */
.q-card{display:flex;flex-direction:column;gap:.6rem;padding:1rem;transition:box-shadow .15s,transform .15s;position:relative}
.q-card:hover{box-shadow:0 8px 24px rgba(15,23,42,.1);transform:translateY(-2px)}
.q-card.selected{outline:2px solid hsl(var(--primary))}
.chip{display:inline-flex;align-items:center;padding:.18rem .65rem;border-radius:999px;border:1px solid hsl(var(--input));background:#fff;font-size:.78rem;cursor:pointer;font-weight:500;user-select:none}
.chip:hover{background:hsl(var(--muted))}
.chip.on{background:hsl(var(--primary));border-color:hsl(var(--primary));color:#fff}
/* Baris tag: lipat default 2 baris */
.tag-collapsed{max-height:4rem;overflow:hidden}
/* Daftar soal bernomor (tampilan list) */
.q-list{display:flex;flex-direction:column;gap:.5rem}
.q-row{flex-direction:row;align-items:flex-start;gap:.75rem;padding:.7rem .9rem}
.q-num{min-width:2rem;height:2rem;border-radius:.6rem;background:#eef2ff;color:#2148c0;font-weight:800;display:grid;place-items:center;font-size:.85rem;flex:none}
.q-prev{max-height:3.4rem;overflow:hidden;position:relative;-webkit-mask-image:linear-gradient(#000 70%,transparent);mask-image:linear-gradient(#000 70%,transparent)}

/* Question content */
.q-html{overflow-wrap:anywhere}
.q-html img{max-width:100%;height:auto;border-radius:6px}
.q-html p{margin:.35rem 0}
.q-html table{border-collapse:collapse;max-width:100%}
.q-html td,.q-html th{border:1px solid #cbd5e1;padding:.25rem .5rem}
.q-html audio,.q-html video,.q-html iframe{max-width:100%}
.q-html ul{list-style:disc;padding-left:1.4rem}.q-html ol{list-style:decimal;padding-left:1.4rem}

/* Editor option rows */
.opt-row{display:flex;gap:.6rem;align-items:flex-start;margin-bottom:.6rem}
.opt-row .letter{width:2rem;height:2rem;border-radius:999px;background:hsl(var(--muted));display:grid;place-items:center;font-weight:700;font-size:.85rem;flex:none;margin-top:.2rem}
.opt-row.key .letter{background:hsl(var(--success));color:#fff}
.mf{flex:1;min-width:0}
.mf-tools{display:flex;gap:.25rem;margin-top:.2rem}
.mf-tools button{font-size:.72rem;padding:.1rem .45rem;border:1px solid hsl(var(--input));background:#fff;border-radius:6px;cursor:pointer;color:hsl(var(--muted-foreground))}
.mf-tools button:hover{background:hsl(var(--accent));color:hsl(var(--primary))}
.mf-prev{font-size:.85rem;padding:.3rem .5rem;margin-top:.25rem;background:hsl(var(--muted)/.6);border-radius:6px;display:none}
.mf-prev.on{display:block}

/* ===== Test engine ===== */
.opt{display:flex;gap:.8rem;align-items:flex-start;width:100%;text-align:left;padding:.8rem .9rem;border:2px solid hsl(var(--border));border-radius:.8rem;background:#fff;cursor:pointer;transition:all .12s;font-size:inherit}
.opt:hover{border-color:hsl(var(--primary)/.5);background:hsl(var(--accent)/.5)}
.opt.sel{border-color:hsl(var(--primary));background:hsl(var(--accent))}
.opt-letter{flex:none;width:2rem;height:2rem;border-radius:999px;background:hsl(var(--muted));display:grid;place-items:center;font-weight:700;font-size:.9rem}
.opt.sel .opt-letter{background:hsl(var(--primary));color:#fff}
.opt.chk .opt-letter{border-radius:.5rem}
.opt-text{flex:1;min-width:0;padding-top:.15rem}
.bs-table{width:100%;border-collapse:separate;border-spacing:0 .5rem}
.bs-table td{background:#fff;border-top:2px solid hsl(var(--border));border-bottom:2px solid hsl(var(--border));padding:.7rem}
.bs-table td:first-child{border-left:2px solid hsl(var(--border));border-radius:.7rem 0 0 .7rem}
.bs-table td:last-child{border-right:2px solid hsl(var(--border));border-radius:0 .7rem .7rem 0}
.bs-btn{min-width:5rem;padding:.5rem .8rem;border:2px solid hsl(var(--input));border-radius:.6rem;background:#fff;font-weight:600;cursor:pointer;font-size:.85rem}
.bs-btn.sel{background:hsl(var(--primary));border-color:hsl(var(--primary));color:#fff}
.urut-item{display:flex;align-items:center;gap:.6rem;padding:.6rem .7rem;background:#fff;border:2px solid hsl(var(--border));border-radius:.7rem;margin-bottom:.5rem}
.urut-item .no{width:1.8rem;height:1.8rem;border-radius:999px;background:hsl(var(--primary));color:#fff;display:grid;place-items:center;font-weight:700;font-size:.8rem;flex:none}
.urut-item .grip{cursor:grab;color:#94a3b8;touch-action:none}
.pal-btn{aspect-ratio:1;border-radius:.6rem;border:2px solid hsl(var(--input));background:#fff;font-weight:700;font-size:.85rem;cursor:pointer;position:relative;display:grid;place-items:center}
.pal-btn.done{background:hsl(var(--success));border-color:hsl(var(--success));color:#fff}
.pal-btn.ragu{background:hsl(var(--warning));border-color:hsl(var(--warning));color:#fff}
.pal-btn.cur{box-shadow:0 0 0 3px hsl(var(--primary)/.55);border-color:hsl(var(--primary))}
.exam-protect,.exam-protect *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.exam-protect input,.exam-protect textarea{-webkit-user-select:text;user-select:text}
.drawer-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.5);z-index:40;opacity:0;pointer-events:none;transition:opacity .2s}
.drawer-backdrop.open{opacity:1;pointer-events:auto}
.drawer{position:fixed;left:0;right:0;bottom:0;max-height:78vh;background:#fff;z-index:41;border-radius:1.2rem 1.2rem 0 0;transform:translateY(105%);transition:transform .25s;overflow:auto;padding:1rem}
.drawer.open{transform:none}
.timer{font-variant-numeric:tabular-nums;font-weight:700}
.timer.low{color:hsl(var(--destructive));animation:pulse 1s infinite}
@keyframes pulse{50%{opacity:.55}}

/* SweetAlert tweak */
.swal2-popup{font-family:inherit;border-radius:1rem}
.swal-wide{width:min(46rem,94vw)!important}
.swal-form label{display:block;text-align:left;font-size:.8rem;font-weight:600;margin:.65rem 0 .25rem}
.swal-form .input{font-size:.9rem}
.swal2-html-container{overflow-x:hidden}

/* Peringatan pelanggaran (merah) */
.swal-danger{border-top:10px solid #dc2626;box-shadow:0 0 0 4px rgba(220,38,38,.25),0 20px 60px rgba(0,0,0,.4)!important;background:#fff}
.swal-danger-title{color:#b91c1c!important;font-weight:800!important;letter-spacing:.02em;font-size:1.4rem!important}
@media print{body.exam-protect *{display:none!important}}

.skeleton{background:linear-gradient(90deg,#e8ecf2 25%,#f3f5f9 50%,#e8ecf2 75%);background-size:200% 100%;animation:sk 1.2s infinite;border-radius:8px}
@keyframes sk{to{background-position:-200% 0}}
.fade-in{animation:fi .25s ease}
@keyframes fi{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

@media (max-width:640px){
  body{font-size:15px}
  .bs-btn{min-width:4rem;padding:.45rem .5rem}
}
