:root{color-scheme:light dark;
--ff:"Atkinson Hyperlegible",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
--bg:#ffffff;--text:#000000;--muted:rgba(0,0,0,.7);
--topbar-bg:rgba(255,255,255,.92);
--card-bg:#ffffff;--card2-bg:#fafafa;
--border:rgba(0,0,0,.10);--border2:rgba(0,0,0,.14);
--shadow:0 10px 30px rgba(0,0,0,.10);
--btn-ghost-bg:rgba(0,0,0,.04);
--btn-ghost-border:rgba(0,0,0,.10);
--opt-bg:#ffffff;--opt-border:rgba(0,0,0,.14);
--surface-tint:rgba(76,125,255,.10);
--accent:#4c7dff;}
html[data-theme="dark"]{
--bg:#0b1020;--text:#e8ecff;--muted:rgba(232,236,255,.85);
--topbar-bg:rgba(11,16,32,.95);
--card-bg:rgba(255,255,255,.06);--card2-bg:rgba(255,255,255,.04);
--border:rgba(255,255,255,.12);--border2:rgba(255,255,255,.10);
--shadow:0 10px 30px rgba(0,0,0,.25);
--btn-ghost-bg:rgba(255,255,255,.04);
--btn-ghost-border:rgba(255,255,255,.10);
--opt-bg:rgba(0,0,0,.25);--opt-border:rgba(255,255,255,.10);
--surface-tint:rgba(76,125,255,.18);
}
*{box-sizing:border-box}html,body{margin:0;padding:0;font-family:var(--ff);background:var(--bg);color:var(--text);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizeLegibility}
a{color:inherit}
.topbar{position:sticky;top:0;z-index:10;background:var(--topbar-bg);backdrop-filter:blur(8px);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:12px 16px}
.brand{display:flex;gap:12px;align-items:center}
.logo{width:42px;height:42px;border-radius:12px;background:var(--btn-ghost-bg);display:grid;place-items:center;font-size:22px}
.title{font-weight:800}
.sub{opacity:.8;font-size:13px;margin-top:2px}
.container{max-width:1024px;margin:18px auto;padding:0 14px 40px}
.card{background:var(--card-bg);border:1px solid var(--opt-border);border-radius:18px;padding:16px;margin-top:14px;box-shadow:var(--shadow)}
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
@media(max-width:900px){.grid{grid-template-columns:1fr}}
.mode{background:var(--card2-bg);border:1px solid var(--border2);border-radius:16px;padding:14px}
.mode h3{margin:4px 0 6px}
.mode p{margin:0 0 10px;opacity:.85;line-height:1.35}
.row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.controls{display:flex;flex-wrap:wrap;gap:10px;align-items:end;margin-top:10px}
label{display:flex;flex-direction:column;gap:6px;font-size:13px;opacity:.95}
select,input{background:var(--card-bg);color:var(--text);border:1px solid var(--border2);border-radius:12px;padding:10px 12px;outline:none}
input::placeholder{opacity:.6}
button{border:0;border-radius:12px;padding:10px 12px;color:var(--text);cursor:pointer}
.primary{background:#4c7dff}
.ghost{background:var(--btn-ghost-bg)}
.primary:hover{filter:brightness(1.08)}
.ghost:hover{filter:brightness(1.1)}
.hidden{display:none}
.qcard{background:var(--opt-bg);border:1px solid var(--opt-border);border-radius:16px;padding:14px;margin-top:12px}
.qhead{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.qtitle{font-weight:700;line-height:1.35}
.meta{opacity:.75;font-size:12px}
.options{display:grid;gap:8px;margin-top:12px}
.opt{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border-radius:14px;border:1px solid var(--opt-border);background:rgba(255,255,255,.05);cursor:pointer}
.opt:hover{filter:brightness(1.06)}
.badge{width:26px;height:26px;border-radius:8px;border:1px solid rgba(255,255,255,.16);display:grid;place-items:center;flex:0 0 26px;opacity:.9}
.opt.correct{border-color:rgba(116, 255, 194,.55);background:rgba(116, 255, 194,.10)}
.opt.wrong{border-color:rgba(255, 112, 112,.55);background:rgba(255, 112, 112,.10)}
.opt.chosen{border-color:rgba(255,255,255,.55);background:rgba(255,255,255,.10)}
.note{margin-top:10px;opacity:.85;font-size:13px;line-height:1.35}
.actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px;align-items:center}
.timer{margin-left:auto;font-weight:700;opacity:.9}
.kpi{display:flex;gap:10px;flex-wrap:wrap;margin-top:8px}
.pill{padding:6px 10px;border-radius:999px;border:1px solid var(--border);background:rgba(255,255,255,.05);font-size:12px;opacity:.9}
.footer{opacity:.7;font-size:12px;margin-top:18px;text-align:center}

.inline{flex-direction:row;align-items:center;gap:10px}
.inline span{opacity:.95}

.examLayout{display:grid;grid-template-columns:1fr 280px;gap:12px;margin-top:12px}
@media(max-width:900px){.examLayout{grid-template-columns:1fr}.examRight{order:-1}}
.examLeft,.examRight{background:rgba(255,255,255,.03);border:1px solid var(--border2);border-radius:16px;padding:12px}
.palette{display:grid;grid-template-columns:repeat(6,1fr);gap:8px}
.pbtn{padding:10px 0;border-radius:12px;background:var(--card-bg);border:1px solid var(--opt-border)}
.pbtn:hover{filter:brightness(1.08)}
.pbtn.active{outline:2px solid rgba(76,125,255,.9)}
.pbtn.done{background:rgba(76,125,255,.18);border-color:rgba(76,125,255,.28)}
.pbtn.ok{background:rgba(116,255,194,.16);border-color:rgba(116,255,194,.35)}
.pbtn.bad{background:rgba(255,112,112,.16);border-color:rgba(255,112,112,.35)}

#progressCard{margin-top:12px}
#progressCard .row{display:flex;justify-content:space-between;gap:10px;align-items:center;flex-wrap:wrap}
#progressCard .label{font-weight:700}
#progressCard .bar{height:12px;border-radius:999px;background:var(--btn-ghost-bg);overflow:hidden;margin-top:10px;border:1px solid var(--opt-border)}
#progressCard .barFill{height:100%;background:rgba(76,125,255,.85)}


/* ====== Badge: đáp án đã chọn (Lựa chọn 3: viền màu, nền trắng) ====== */
.opt.chosen .badge{
  background:#fff;
  color:#2196f3;
  border:2px solid #2196f3;
  border-radius:50%;
  font-weight:700;
}

/* Khi nộp bài: badge đổi màu theo đúng/sai */
.opt.correct .badge{
  background:#fff;
  color:rgba(116, 255, 194, .95);
  border:2px solid rgba(116, 255, 194, .75);
  border-radius:50%;
  font-weight:800;
}
.opt.wrong .badge{
  background:#fff;
  color:rgba(255, 112, 112, .95);
  border:2px solid rgba(255, 112, 112, .75);
  border-radius:50%;
  font-weight:800;
}

/* Animate nhấn xuống (click) */
.badge{transition: transform .12s ease, background-color .12s ease, border-color .12s ease, color .12s ease;}
.opt.pressed .badge{transform: scale(.9);}


/* Theme application */
html,body{background:var(--bg);color:var(--text)}
a{color:inherit}
.sub, .muted{color:var(--muted)}
.topbar{background:var(--topbar-bg)}
.card{background:var(--card-bg);border:1px solid var(--border);box-shadow:var(--shadow)}
.mode, .examLeft, .examRight{background:var(--card2-bg);border:1px solid var(--border2)}
button.ghost{background:var(--btn-ghost-bg);border:1px solid var(--btn-ghost-border)}
/* Form readability in light mode */
select,input,textarea{
  background:var(--card-bg);
  color:var(--text);
  border:1px solid var(--border2);
}
select:focus,input:focus,textarea:focus{outline:2px solid var(--surface-tint)}
/* Mobile optimizations */
@media(max-width:520px){
  .topbar{padding:10px 12px}
  .brand{gap:10px}
  .logo{width:38px;height:38px;border-radius:12px;font-size:20px}
  .title{font-size:15px}
  .sub{font-size:12px}
  .right{display:flex;gap:8px}
  button{min-height:44px}
  .ghost{padding:10px 12px}
  .controls{gap:8px}
  .container{margin:12px auto;padding:0 10px 26px}
  .card{padding:12px}
  .grid{gap:10px}
  .examLayout{gap:10px}
  .palette{grid-template-columns:repeat(5,1fr)}
  .pbtn{padding:12px 0}
  .opt{padding:12px}
  .opt .badge{width:28px;height:28px;min-width:28px}
}
@media(max-width:380px){
  .palette{grid-template-columns:repeat(4,1fr)}
  #btnTheme{max-width:120px}
}


/* ===== Custom menu (admin-managed links) ===== */
.menuWrap{ position:relative; display:inline-flex; align-items:center; }
.menuDropdown{
  position:absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: 320px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(0,0,0,.12));
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.18);
  padding: 8px;
  display:none;
  z-index: 50;
}
.menuDropdown.open{ display:block; }
.menuDropdown a{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration:none;
  color: inherit;
  font-weight: 600;
}
.menuDropdown a:hover{
  background: rgba(0,0,0,.06);
}
[data-theme="dark"] .menuDropdown a:hover{
  background: rgba(255,255,255,.08);
}
.menuDropdown .hint{
  padding: 6px 10px 10px;
  font-size: 12px;
  opacity:.75;
}

/* Mobile: menu full width dropdown */
@media (max-width: 520px){
  .menuDropdown{
    right: -6px;
    left: -6px;
    min-width: auto;
    max-width: none;
  }
}
