*{box-sizing:border-box}
:root{
  --bg:#eef3f8;--card:#fff;--ink:#102039;--muted:#667085;--line:#d8e2ec;
  --brand:#0f766e;--brand2:#14b8a6;--blue:#2563eb;--warn:#f59e0b;--danger:#c2413a;
  --shadow:0 14px 34px rgba(15,23,42,.08);--radius:18px;
}
html,body{margin:0;min-height:100%;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;color:var(--ink);background:var(--bg)}
button,input,textarea,select{font:inherit}button{cursor:pointer}[hidden]{display:none!important}
.app-shell{min-height:100vh}
.topbar{height:72px;padding:0 18px;background:#fff;border-bottom:1px solid var(--line);display:grid;grid-template-columns:auto 1fr auto;gap:20px;align-items:center;position:sticky;top:0;z-index:20}
.brand{display:flex;gap:10px;align-items:center}.brand-mark{width:42px;height:42px;border-radius:13px;background:linear-gradient(135deg,var(--brand),var(--brand2));display:grid;place-items:center;color:#fff;font-size:23px;box-shadow:0 9px 22px rgba(15,118,110,.2)}.brand strong,.brand small{display:block}.brand small{font-size:10px;color:var(--muted);margin-top:2px}
.top-center{justify-self:center;display:flex;gap:8px;align-items:center;color:#475467;font-size:13px}.top-center strong{color:var(--ink)}
.top-actions{display:flex;gap:8px;align-items:center}.clock-now{font-size:20px;font-weight:900;letter-spacing:.04em}.icon-btn{width:38px;height:38px;border:1px solid var(--line);border-radius:10px;background:#fff;font-size:18px}
.main-layout{display:grid;grid-template-columns:250px minmax(560px,1fr) 245px;gap:12px;padding:12px;height:calc(100vh - 72px)}
.left-rail,.right-rail{display:flex;flex-direction:column;gap:10px;min-height:0;overflow:auto}
.rail-card{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:13px;box-shadow:var(--shadow)}.rail-card.compact{padding-bottom:11px}.rail-title{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;font-size:11px}.rail-title>b{font-size:11px;letter-spacing:.04em}.rail-title span{color:var(--muted)}
.activity-list{display:flex;flex-direction:column;gap:6px;max-height:300px;overflow:auto;margin-bottom:10px}.activity-item{border:1px solid var(--line);border-radius:11px;padding:9px;background:#fff;text-align:left}.activity-item.active{border-color:#7dd3c7;background:#ecfdf8}.activity-item.done{opacity:.55}.activity-item strong,.activity-item span{display:block}.activity-item strong{font-size:11px}.activity-item span{font-size:9px;color:var(--muted);margin-top:2px}
.btn{border:0;border-radius:10px;padding:9px 12px;font-weight:800;font-size:11px}.btn.primary{background:var(--brand);color:#fff}.btn.secondary{background:#eaf0f6;color:#24344d}.btn.ghost{background:#fff;border:1px solid var(--line);color:#475467}.btn.warning{background:#fff7e6;color:#9a5a00;border:1px solid #fbd38d}.btn.danger{color:var(--danger)}.btn.full{width:100%}.btn.large{font-size:14px;padding:12px 17px}
.quick-grid{display:grid;grid-template-columns:1fr 1fr;gap:7px}.quick-btn{border:1px solid var(--line);background:#fff;border-radius:11px;min-height:58px;font-size:20px}.quick-btn span{display:block;font-size:9px;color:#475467;margin-top:3px;font-weight:700}.quick-btn:hover{border-color:#7dd3c7;background:#f0fdf9}
.sound-row{display:flex;gap:6px}.sound-btn,.sound-toggle{border:1px solid var(--line);background:#fff;border-radius:9px;width:34px;height:34px}.sound-toggle.active{background:#ecfdf8;border-color:#7dd3c7}
.stage-panel{background:#fff;border:1px solid var(--line);border-radius:20px;box-shadow:var(--shadow);overflow:hidden;display:flex;flex-direction:column;min-width:0}
.stage-toolbar{height:52px;display:flex;justify-content:space-between;align-items:center;padding:0 10px;border-bottom:1px solid var(--line);background:#fbfcfe;gap:10px}.stage-tabs{display:flex;gap:4px;overflow:auto}.stage-tab{border:0;background:transparent;border-radius:8px;padding:7px 9px;color:#667085;font-size:10px;font-weight:800}.stage-tab.active{background:#e9f9f6;color:var(--brand)}.stage-actions{display:flex;gap:6px}
.stage{flex:1;min-height:0;position:relative;overflow:auto;background:radial-gradient(circle at 50% 20%,#fff,#f9fbfd)}.stage-view{display:none;min-height:100%;padding:34px;align-items:center;justify-content:center;flex-direction:column}.stage-view.active{display:flex}
.activity-kicker,.random-kicker,.qr-kicker{font-size:12px;letter-spacing:.16em;font-weight:900;color:var(--brand)}#activityTitle{font-size:clamp(36px,5vw,68px);line-height:1.05;text-align:center;margin:14px 0 18px;letter-spacing:-.035em}.activity-body{max-width:980px;text-align:center;font-size:clamp(22px,2.6vw,38px);line-height:1.5;white-space:pre-line}.activity-timer-mini{margin-top:28px;padding:12px 20px;border-radius:999px;background:#eefbf9;color:var(--brand);font-size:24px}.activity-timer-mini strong{margin-left:8px}
.timer-label{font-size:14px;font-weight:900;letter-spacing:.15em;color:var(--brand)}.timer-display{font-variant-numeric:tabular-nums;font-size:clamp(86px,13vw,180px);font-weight:950;line-height:1;margin:20px 0;letter-spacing:-.05em}.timer-progress{width:min(760px,85%);height:14px;background:#e8eef4;border-radius:999px;overflow:hidden}.timer-progress span{display:block;height:100%;width:100%;background:linear-gradient(90deg,var(--brand),#22c55e);transition:width .25s}.timer-presets{display:flex;gap:8px;margin-top:24px}.timer-presets button{border:1px solid var(--line);background:#fff;border-radius:999px;padding:8px 14px;font-size:11px;font-weight:800}.timer-controls{display:flex;gap:12px;margin-top:22px}.circle-action{width:66px;height:66px;border-radius:50%;border:1px solid var(--line);background:#fff;font-weight:900}.circle-action.primary{background:var(--brand);color:#fff;border-color:var(--brand);font-size:22px}
.random-name{font-size:clamp(58px,8vw,120px);font-weight:950;text-align:center;line-height:1.05;margin:18px 0;letter-spacing:-.035em}.random-meta{color:var(--muted);font-size:14px}.random-actions{display:flex;gap:10px;align-items:center;margin-top:28px;flex-wrap:wrap;justify-content:center}
.groups-toolbar{width:100%;display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}.groups-toolbar b,.groups-toolbar span{display:block}.groups-toolbar span{font-size:10px;color:var(--muted);margin-top:2px}.group-count{display:flex;gap:5px}.group-count button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:7px 9px;font-size:10px;font-weight:800}.group-count button.active{background:#e9f9f6;border-color:#83d4cb;color:var(--brand)}
.groups-grid{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:10px;align-content:start}.group-card{border:1px solid var(--line);border-radius:14px;background:#fff;overflow:hidden}.group-card h3{margin:0;padding:10px 12px;background:#f7fafc;font-size:13px}.group-members{padding:8px 12px}.group-members div{font-size:11px;padding:4px 0;border-bottom:1px dashed #edf0f3}.group-members div:last-child{border-bottom:0}
.score-heading{width:100%;display:flex;justify-content:space-between;align-items:center;margin-bottom:22px}.score-heading b,.score-heading span{display:block}.score-heading span{font-size:10px;color:var(--muted);margin-top:2px}.score-grid{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.score-card{border:1px solid var(--line);border-radius:16px;text-align:center;padding:16px;background:#fff}.score-card.winner{border-color:#f5c768;box-shadow:0 0 0 3px rgba(245,199,104,.18)}.score-card h3{margin:0;font-size:14px}.score-value{font-size:56px;font-weight:950;margin:10px 0}.score-controls{display:flex;gap:6px;justify-content:center}.score-controls button{border:0;border-radius:9px;padding:8px 12px;font-weight:900}.score-controls .plus{background:#eafaf6;color:var(--brand)}.score-controls .minus{background:#fff0f0;color:#b42318}
.qr-layout{display:flex;gap:38px;align-items:center}.qr-code{width:300px;height:300px;display:grid;place-items:center;background:#fff;border:12px solid #fff;box-shadow:0 12px 30px rgba(15,23,42,.1)}.qr-code img,.qr-code canvas{max-width:100%;max-height:100%}.qr-info{max-width:430px}.qr-info h2{font-size:42px;line-height:1.1;margin:10px 0}.qr-link{font-size:13px;color:var(--muted);word-break:break-all}
.stage-footer{min-height:42px;border-top:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;padding:8px 12px;font-size:9px;color:#8491a3}.shortcut-hint{display:flex;gap:9px;align-items:center;flex-wrap:wrap}kbd{border:1px solid #ccd5df;border-radius:5px;padding:2px 5px;background:#fff;color:#344054;box-shadow:0 1px 0 #ccd5df}
.mini-timer{text-align:center}.mini-timer strong{font-size:38px;font-variant-numeric:tabular-nums}.mini-timer div{display:flex;gap:6px;justify-content:center;margin-top:6px}.mini-timer button{border:1px solid var(--line);background:#fff;border-radius:8px;width:34px;height:30px}.mini-scores{display:flex;flex-direction:column;gap:6px}.mini-score-row{display:grid;grid-template-columns:1fr auto auto auto;gap:5px;align-items:center}.mini-score-row span{font-size:10px}.mini-score-row b{font-size:14px}.mini-score-row button{width:26px;height:26px;border:1px solid var(--line);background:#fff;border-radius:7px;font-size:10px}.mini-random-btn{width:100%;border:0;background:#eafaf6;color:var(--brand);border-radius:10px;padding:10px;font-size:11px;font-weight:900}.mini-last-student{text-align:center;margin-top:8px;font-weight:800;font-size:12px}.qr-mini-row{display:flex;gap:5px}.qr-mini-row input{min-width:0;width:100%;border:1px solid var(--line);border-radius:8px;padding:7px;font-size:10px}.qr-mini-row button{border:0;border-radius:8px;background:var(--brand);color:#fff;font-size:9px;font-weight:800;padding:0 8px}
.focus-overlay{position:fixed;inset:0;background:#08111f;color:#fff;z-index:100;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}.focus-icon{font-size:110px}.focus-text{font-size:clamp(54px,8vw,125px);font-weight:950;letter-spacing:-.04em}.focus-sub{font-size:14px;color:#9fb0c6;margin-top:16px}
dialog{border:0;border-radius:22px;padding:0;box-shadow:0 35px 90px rgba(15,23,42,.28);max-width:none}dialog::backdrop{background:rgba(15,23,42,.56)}.setup-dialog{width:min(1180px,94vw);max-height:90vh;overflow:auto;background:#fff}.dialog-head{display:flex;justify-content:space-between;align-items:flex-start;padding:22px 24px 14px;border-bottom:1px solid var(--line)}.eyebrow{font-size:10px;letter-spacing:.14em;color:var(--brand);font-weight:900}.dialog-head h2{font-size:25px;margin:5px 0}.dialog-close{border:0;background:#f2f4f7;border-radius:50%;width:34px;height:34px;font-size:22px}.setup-grid{display:grid;grid-template-columns:1.05fr 1.25fr .85fr;gap:18px;padding:18px 24px}.setup-grid h3{font-size:13px;margin:0 0 10px}.setup-grid h3.mt{margin-top:20px}.form-grid.two{display:grid;grid-template-columns:1fr 1fr;gap:8px}.setup-grid label{display:block;font-size:10px;font-weight:800;margin-bottom:8px}.setup-grid input,.setup-grid textarea,.setup-grid select{width:100%;border:1px solid #cfd8e3;border-radius:9px;padding:8px 9px;outline:none}.block-label textarea{margin-top:5px;resize:vertical;line-height:1.4}.remember-row{display:flex!important;gap:7px;align-items:center;font-weight:500!important;color:#475467}.remember-row input{width:auto}.preset-row{display:grid;grid-template-columns:1fr auto auto;gap:6px}.preset-row button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:0 8px;font-size:9px}.activity-editor{display:flex;flex-direction:column;gap:7px;max-height:405px;overflow:auto}.activity-edit-row{display:grid;grid-template-columns:1fr 72px 34px;gap:6px;align-items:start;border:1px solid var(--line);border-radius:10px;padding:8px;background:#fafcfe}.activity-edit-row .activity-edit-main{display:grid;gap:5px}.activity-edit-row input,.activity-edit-row textarea{font-size:10px;padding:7px}.activity-edit-row textarea{resize:vertical}.activity-edit-row .minutes{font-size:10px}.activity-edit-row .remove-activity{border:0;background:#fff1f0;color:#b42318;border-radius:8px;height:30px}.dialog-footer{display:flex;justify-content:flex-end;gap:8px;padding:14px 24px 20px;border-top:1px solid var(--line)}
.toast{position:fixed;right:18px;bottom:18px;background:#172033;color:#fff;border-radius:11px;padding:11px 14px;box-shadow:var(--shadow);font-size:11px;opacity:0;transform:translateY(8px);transition:.2s;pointer-events:none;z-index:200;max-width:380px}.toast.show{opacity:1;transform:translateY(0)}
body.presentation .left-rail,body.presentation .right-rail,body.presentation .stage-toolbar,body.presentation .topbar,body.presentation .stage-footer{display:none!important}body.presentation .main-layout{display:block;height:100vh;padding:0}body.presentation .stage-panel{height:100vh;border:0;border-radius:0}body.presentation .stage-view{padding:6vh 6vw}
.timer-warning .timer-display{color:#c2413a}.timer-warning .timer-progress span{background:linear-gradient(90deg,#f59e0b,#ef4444)}
@media(max-width:1200px){.main-layout{grid-template-columns:220px 1fr}.right-rail{display:none}.groups-grid,.score-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:820px){.topbar{grid-template-columns:auto auto}.top-center{display:none}.main-layout{display:block;height:auto;padding:8px}.left-rail{display:grid;grid-template-columns:1fr 1fr;margin-bottom:8px}.stage-panel{height:760px}.groups-grid,.score-grid{grid-template-columns:1fr 1fr}.setup-grid{grid-template-columns:1fr}.qr-layout{flex-direction:column}.qr-info{text-align:center}.stage-toolbar{overflow:auto}.stage-actions{display:none}}
@media(max-width:560px){.left-rail{display:block}.rail-card{margin-bottom:8px}.groups-grid,.score-grid{grid-template-columns:1fr}.stage-panel{height:720px}.stage-view{padding:20px}.qr-code{width:240px;height:240px}}

/* ===== V1.1 PROJECTOR-FIRST TYPOGRAPHY ===== */
body{font-size:16px}
.topbar{height:78px}
.brand strong{font-size:17px}
.brand small{font-size:12px}
.top-center{font-size:16px}
.clock-now{font-size:24px}
.icon-btn{width:42px;height:42px;font-size:20px}

.main-layout{height:calc(100vh - 78px);grid-template-columns:275px minmax(620px,1fr) 270px}
.rail-card{padding:15px}
.rail-title{font-size:13px}
.rail-title>b{font-size:13px}
.activity-item{padding:11px}
.activity-item strong{font-size:14px}
.activity-item span{font-size:11px}
.btn{font-size:13px;padding:10px 14px}
.quick-btn{min-height:68px;font-size:23px}
.quick-btn span{font-size:11px}
.sound-btn,.sound-toggle{width:38px;height:38px;font-size:16px}
.stage-toolbar{height:58px}
.stage-tab{font-size:12px;padding:9px 11px}
.activity-kicker,.random-kicker,.qr-kicker{font-size:15px}
.activity-body{font-size:clamp(26px,2.9vw,42px)}
.groups-toolbar b{font-size:17px}
.groups-toolbar span{font-size:12px}
.group-count button{font-size:12px;padding:8px 11px}
.group-card h3{font-size:16px;padding:12px 14px}
.group-members{padding:10px 14px}
.group-members div{font-size:14px;padding:6px 0}
.score-heading b{font-size:17px}
.score-heading span{font-size:12px}
.score-card h3{font-size:16px}
.score-value{font-size:64px}
.score-controls button{font-size:14px;padding:9px 14px}
.stage-footer{font-size:11px;min-height:46px}
.mini-timer strong{font-size:46px}
.mini-score-row span{font-size:12px}
.mini-score-row b{font-size:17px}
.mini-score-row button{width:30px;height:30px;font-size:12px}
.mini-random-btn{font-size:13px;padding:11px}
.mini-last-student{font-size:15px}
.qr-mini-row input{font-size:12px;padding:8px}
.qr-mini-row button{font-size:11px}
.setup-grid label{font-size:12px}
.setup-grid input,.setup-grid textarea,.setup-grid select{font-size:13px}
.activity-edit-row input,.activity-edit-row textarea,.activity-edit-row .minutes{font-size:12px}
.shortcut-hint{font-size:11px}

.student-import{
  margin:10px 0 12px;
  padding:11px;
  border:1px dashed #aab8c6;
  border-radius:12px;
  background:#f8fafc;
}
.student-import-head{display:flex;justify-content:space-between;gap:8px;align-items:center;margin-bottom:8px}
.student-import-head b{font-size:12px}
.student-import-head span{font-size:10px;color:var(--muted)}
.student-import-btn{display:block!important;margin:0!important}
.student-import-btn input{display:none}
.student-import-btn span{
  display:block;
  text-align:center;
  background:#eafaf6;
  color:var(--brand);
  border:1px solid #a8ddd6;
  border-radius:9px;
  padding:9px;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}
.student-import-info{font-size:10px;line-height:1.45;color:var(--muted);margin-top:7px}

@media(max-width:1200px){
  .main-layout{grid-template-columns:240px 1fr}
}

/* ===== V1.2: AUTO FONT + ACTIVITY TIME UX ===== */
:root{--display-scale:1}

.font-controls{
  display:flex;align-items:center;gap:3px;
  padding:3px;border:1px solid var(--line);border-radius:10px;background:#fff;
}
.font-controls button{
  border:0;background:transparent;border-radius:7px;
  min-width:34px;height:30px;padding:0 8px;
  font-size:11px;font-weight:900;color:#475467;
}
.font-controls button:hover,.font-controls button.active{background:#e9f9f6;color:var(--brand)}

#activityTitle{
  font-size:clamp(30px,calc(4.2vw * var(--display-scale)),62px);
}
.activity-body{
  font-size:clamp(20px,calc(2.35vw * var(--display-scale)),36px);
}
.random-name{
  font-size:clamp(38px,calc(6vw * var(--display-scale)),92px);
  max-width:96%;
  overflow-wrap:anywhere;
}
.timer-display{
  font-size:clamp(72px,calc(11vw * var(--display-scale)),156px);
}
.qr-info h2{
  font-size:clamp(28px,calc(3.2vw * var(--display-scale)),44px);
}

.activity-item-wrap{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:6px;
  align-items:stretch;
}
.activity-main-btn{
  border:1px solid var(--line);
  border-radius:11px;
  padding:10px;
  background:#fff;
  text-align:left;
  min-width:0;
}
.activity-main-btn.active{border-color:#7dd3c7;background:#ecfdf8}
.activity-main-btn.done{opacity:.6}
.activity-main-btn strong,.activity-main-btn span{display:block}
.activity-main-btn strong{font-size:14px;line-height:1.25}
.activity-main-btn span{font-size:11px;color:var(--muted);margin-top:3px}

.activity-side{
  display:flex;
  flex-direction:column;
  gap:4px;
  width:58px;
}
.activity-minute-input{
  width:58px;
  min-width:0;
  border:1px solid var(--line);
  border-radius:8px;
  padding:5px 3px;
  text-align:center;
  font-size:11px;
  font-weight:800;
  background:#fff;
}
.activity-start-btn{
  flex:1;
  border:0;
  border-radius:8px;
  background:#eafaf6;
  color:var(--brand);
  font-size:10px;
  font-weight:900;
  min-height:30px;
}
.activity-start-btn:hover{background:#d6f5ed}

.activity-running .activity-main-btn{
  box-shadow:0 0 0 2px rgba(15,118,110,.18);
}

.activity-timer-mini{
  font-size:clamp(18px,calc(1.8vw * var(--display-scale)),28px);
}

@media(max-width:820px){
  .font-controls{display:flex}
  .stage-actions{gap:5px}
}

/* ===== V1.3 SOUND + VIETNAMESE SPEECH ===== */
.sound-settings{
  display:grid;
  gap:8px;
  margin-top:10px;
  padding-top:9px;
  border-top:1px solid var(--line);
}
.sound-settings label{
  font-size:10px;
  font-weight:800;
  color:#475467;
}
.sound-settings select{
  width:100%;
  margin-top:4px;
  border:1px solid var(--line);
  border-radius:8px;
  padding:6px 7px;
  background:#fff;
  font-size:10px;
}
.sound-settings input[type="range"]{width:100%;margin-top:5px}
.loop-sound.active-loop{
  background:#fff7e6;
  border-color:#f5b94c;
  box-shadow:0 0 0 2px rgba(245,185,76,.17);
}

.speech-btn{
  background:#eef6ff;
  color:#175cd3;
  border:1px solid #b2ccff;
}
.speech-controls{
  display:flex;
  align-items:end;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
  margin-top:14px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#f8fafc;
}
.speech-controls label{
  min-width:145px;
  font-size:10px;
  font-weight:800;
  color:#475467;
}
.speech-controls select{
  display:block;
  width:100%;
  margin-top:4px;
  border:1px solid var(--line);
  border-radius:8px;
  background:#fff;
  padding:7px;
  font-size:11px;
}
.speech-controls input[type="range"]{
  display:block;
  width:150px;
  margin-top:6px;
}
.voice-info{
  max-width:240px;
  font-size:9px;
  line-height:1.4;
  color:var(--muted);
  align-self:center;
}

/* ===== V1.4 LOCAL AUDIO + VOICE FALLBACK ===== */
.speech-controls{align-items:end}
.speech-controls label{min-width:155px}
.speech-controls .btn{align-self:end}
.voice-info{flex-basis:100%;max-width:none;text-align:center}

/* ===== V1.5 independent sound selectors ===== */
.sound-settings{grid-template-columns:1fr}
.sound-settings label{font-size:10px}
.sound-settings select{font-size:10px}
.voice-warning{
  color:#b54708;
  background:#fffaeb;
  border:1px solid #fedf89;
  border-radius:8px;
  padding:6px 8px;
}

/* ===== V1.6 dynamic audio library ===== */
.audio-library-note{
  font-size:9px;
  line-height:1.45;
  color:var(--muted);
  padding:7px 8px;
  border-radius:8px;
  background:#f8fafc;
  border:1px solid var(--line);
}
.audio-library-note code{font-size:9px}
.audio-library-note button{
  display:block;
  margin-top:6px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--brand);
  border-radius:7px;
  padding:5px 8px;
  font-size:9px;
  font-weight:800;
}

/* ===== V1.7 robust audio scanner + TTS API ===== */
.tts-api-ok{color:#067647;background:#ecfdf3;border:1px solid #abefc6;border-radius:8px;padding:6px 8px}
.tts-api-warn{color:#b54708;background:#fffaeb;border:1px solid #fedf89;border-radius:8px;padding:6px 8px}

/* ===== V1.8 audio diagnostics ===== */
.audio-library-note button{display:inline-block;margin-right:5px}
.audio-diag-box{
  margin-top:7px;
  padding:7px 8px;
  border-radius:7px;
  border:1px solid #d0d5dd;
  background:#fff;
  color:#344054;
  font-size:9px;
  line-height:1.5;
  white-space:pre-wrap;
  word-break:break-word;
}
.audio-diag-box.error{background:#fef3f2;border-color:#fecdca;color:#b42318}
.audio-diag-box.ok{background:#ecfdf3;border-color:#abefc6;color:#067647}

/* ===== V2.6 CLEAN: optional local Vietnamese voice only ===== */
.speech-controls{
  grid-template-columns:minmax(180px,1fr) minmax(180px,1fr) auto;
  gap:10px;
  align-items:end;
}
.speech-controls label{min-width:0}
.voice-info{
  grid-column:1 / -1;
  flex-basis:auto;
}
.voice-info.voice-unavailable{
  color:#667085;
  background:#f8fafc;
  border:1px solid #e4e7ec;
  border-radius:8px;
  padding:7px 9px;
}
.speech-controls.is-unavailable select,
.speech-controls.is-unavailable input,
.speech-controls.is-unavailable button{
  opacity:.55;
}
@media(max-width:900px){
  .speech-controls{grid-template-columns:1fr 1fr}
  .speech-controls .btn{width:100%}
}

/* ===== V2.7 saved classes + reset ===== */
.saved-class-row{
  display:grid;
  grid-template-columns:minmax(180px,1fr) auto auto;
  gap:8px;
  align-items:center;
  margin-top:8px;
}
.saved-class-row select,
.saved-class-row button{min-height:42px}
.saved-class-help{
  margin-top:6px;
  font-size:11px;
  color:var(--muted);
}
.dialog-footer-spacer{flex:1}
@media(max-width:760px){
  .saved-class-row{grid-template-columns:1fr}
  .dialog-footer{flex-wrap:wrap}
  .dialog-footer-spacer{display:none}
  .dialog-footer .btn{flex:1 1 140px}
}

/* ===== V2.8 teacher workflow enhancements ===== */
.top-text-btn{
  border:1px solid var(--line);background:#fff;color:var(--brand);font-weight:800;
  border-radius:10px;padding:8px 10px;white-space:nowrap
}
.offline-status{font-size:14px;color:#f79009}
.offline-status.ready{color:#12b76a}
.offline-status.offline{color:#667085}
.timer-stage.timer-critical .timer-display,
.stage-view.timer-critical .timer-display{color:#d92d20;animation:timerPulse .7s infinite alternate}
.timer-stage.timer-warning .timer-display,
.stage-view.timer-warning .timer-display{color:#b54708}
@keyframes timerPulse{from{transform:scale(1)}to{transform:scale(1.035)}}
.random-progress-row{
  display:flex;justify-content:center;gap:20px;flex-wrap:wrap;margin-top:12px;
  color:var(--muted);font-size:13px
}
.random-progress-row strong{color:var(--brand)}
.random-history-wrap{margin:12px auto 0;max-width:760px}
.random-history-title{font-size:11px;font-weight:900;color:var(--muted);text-transform:uppercase;margin-bottom:6px}
.random-history{display:flex;gap:6px;flex-wrap:wrap;justify-content:center}
.random-history span{
  background:#f2f4f7;border:1px solid #e4e7ec;border-radius:999px;padding:5px 9px;font-size:11px
}
.random-actions kbd{font-size:9px;margin-left:4px}
.mini-absent-names{font-size:10px;color:var(--muted);margin-top:7px;line-height:1.4}
.class-transfer-row{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap}
.import-json-btn{cursor:pointer}
.import-json-btn input{display:none}
.attendance-dialog{width:min(760px,92vw);max-height:86vh;padding:0}
#attendanceDialog{border:none;border-radius:18px;padding:0;box-shadow:0 24px 70px rgba(16,24,40,.28)}
#attendanceDialog::backdrop{background:rgba(15,23,42,.48)}
.attendance-dialog .dialog-head{padding:18px 20px 12px}
.attendance-dialog .dialog-head p{margin:4px 0 0;color:var(--muted);font-size:12px}
.attendance-tools{display:flex;gap:8px;padding:0 20px 12px}
.attendance-tools input{flex:1;min-height:42px}
.attendance-list{
  padding:0 20px 18px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
  gap:7px;max-height:55vh;overflow:auto
}
.attendance-row{
  display:flex;align-items:center;gap:9px;border:1px solid var(--line);
  border-radius:10px;padding:9px 10px;background:#fff;cursor:pointer
}
.attendance-row.absent{background:#fff6f5;border-color:#fecdca}
.attendance-row input{width:18px;height:18px}
.attendance-row strong{font-size:12px}
.attendance-row small{margin-left:auto;color:#b42318;font-weight:800}
@media(max-width:700px){
  .attendance-list{grid-template-columns:1fr}
  .top-text-btn{padding:7px 8px;font-size:11px}
}


/* ===== V2.9: attendance visibility + Chrome voice rescan ===== */
.top-center{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  min-width:0;
}
.top-center-main{
  display:flex;
  align-items:center;
  gap:6px;
  min-width:0;
}
.header-attendance-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 9px;
  border:1px solid #d0d5dd;
  border-radius:999px;
  background:#fff;
  color:#344054;
  font-size:10px;
  line-height:1.2;
  font-weight:800;
  cursor:pointer;
}
.header-attendance-btn:hover{
  background:#f9fafb;
  border-color:#98a2b3;
}
.header-attendance-label{
  color:var(--brand);
}
.header-absent-badge{
  min-width:19px;
  height:19px;
  padding:0 5px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#d92d20;
  color:white;
  font-size:10px;
  font-weight:900;
}
.header-absent-badge[hidden]{display:none!important}
.voice-info.voice-ok{color:#067647}
.voice-info.voice-warning{color:#b54708}
#rescanVoicesBtn[disabled]{opacity:.62;cursor:wait}
@media(max-width:900px){
  .header-attendance-label{display:none}
  .header-attendance-btn{padding:4px 7px}
}


/* ===== V2.10: Bootstrap confirm modal ===== */
.toantin-confirm-modal{
  --bs-modal-width: 520px;
  z-index: 20050;
}
.toantin-confirm-modal + .modal-backdrop,
.modal-backdrop{
  z-index: 20040;
}
.toantin-confirm-modal .modal-content{
  border:0;
  border-radius:22px;
  overflow:hidden;
  box-shadow:0 28px 90px rgba(15,23,42,.28);
  background:#fff;
}
.toantin-confirm-modal .modal-body{
  padding:26px 26px 18px;
}
.toantin-confirm-head{
  display:flex;
  align-items:flex-start;
  gap:16px;
}
.toantin-confirm-icon{
  flex:0 0 52px;
  width:52px;
  height:52px;
  border-radius:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#eef4ff;
  color:#3538cd;
  font-size:25px;
  font-weight:900;
}
.toantin-confirm-icon.is-danger{
  background:#fef3f2;
  color:#d92d20;
}
.toantin-confirm-icon.is-warning{
  background:#fffaeb;
  color:#b54708;
}
.toantin-confirm-copy{
  min-width:0;
  flex:1;
}
.toantin-confirm-modal .modal-title{
  margin:1px 0 8px;
  color:#101828;
  font-size:20px;
  line-height:1.3;
  font-weight:900;
}
.toantin-confirm-message{
  color:#475467;
  font-size:14px;
  line-height:1.65;
  white-space:pre-line;
}
.toantin-confirm-modal .modal-footer{
  border-top:1px solid #eaecf0;
  background:#f9fafb;
  padding:14px 20px 16px;
  gap:10px;
}
.toantin-confirm-modal .modal-footer .btn{
  min-width:116px;
  min-height:42px;
  border-radius:12px;
  font-weight:800;
}
.toantin-confirm-modal .modal-footer .btn-light{
  border:1px solid #d0d5dd;
  background:#fff;
  color:#344054;
}
.toantin-confirm-modal .modal-footer .btn-primary{
  background:#5146a5;
  border-color:#5146a5;
}
.toantin-confirm-modal .modal-footer .btn-danger{
  background:#d92d20;
  border-color:#d92d20;
}
.toantin-confirm-modal .modal-footer .btn-warning{
  color:#fff;
  background:#b54708;
  border-color:#b54708;
}
@media(max-width:600px){
  .toantin-confirm-modal{
    --bs-modal-margin: 14px;
  }
  .toantin-confirm-modal .modal-body{
    padding:22px 18px 16px;
  }
  .toantin-confirm-head{
    gap:12px;
  }
  .toantin-confirm-icon{
    flex-basis:46px;
    width:46px;
    height:46px;
    border-radius:14px;
    font-size:22px;
  }
  .toantin-confirm-modal .modal-title{
    font-size:18px;
  }
  .toantin-confirm-modal .modal-footer{
    display:grid;
    grid-template-columns:1fr 1fr;
  }
  .toantin-confirm-modal .modal-footer .btn{
    width:100%;
    min-width:0;
  }
}

/* ===== V2.13: Help modal ===== */
.help-top-btn{border-color:#c7d7fe;background:#eef4ff;color:#3538cd}
.help-top-btn:hover{background:#e0eaff}



.help-eyebrow{font-size:10px;font-weight:900;letter-spacing:.08em;color:#6172f3;margin-bottom:4px}


.help-quick,.help-section{border:1px solid #eaecf0;border-radius:16px;padding:16px;margin-bottom:14px}
.help-quick{background:#f8f9ff;border-color:#d9e0ff}
.help-section-title{font-weight:900;color:#101828;margin-bottom:10px;font-size:14px}
.help-steps{display:grid;gap:8px}
.help-steps div{background:#fff;border-radius:10px;padding:9px 11px;border:1px solid #eaecf0;font-size:13px}
.help-methods{display:grid;gap:8px}
.help-methods>div{font-size:13px;line-height:1.5}
.help-badge{display:inline-block;min-width:58px;text-align:center;margin-right:7px;padding:3px 7px;border-radius:999px;background:#eef4ff;color:#3538cd;font-size:10px;font-weight:900}
.help-tip{margin-top:10px;padding:9px 11px;border-radius:10px;background:#ecfdf3;color:#067647;font-size:12px}
.help-feature-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.help-feature-grid article{border:1px solid #eaecf0;border-radius:12px;padding:11px;background:#fff}
.help-feature-grid article b{display:block;color:#344054;margin-bottom:4px;font-size:12px}
.help-feature-grid article span{display:block;color:#667085;font-size:11px;line-height:1.5}
.help-note{background:#fffcf5;border-color:#fedf89}
.help-note p{margin:4px 0;font-size:12px;color:#475467}


@media(max-width:760px){
  .help-feature-grid{grid-template-columns:1fr}
  .help-top-btn{font-size:0}
  .help-top-btn::after{content:"❓";font-size:14px}

}




/* ===== V2.15: Native help dialog - không dùng Bootstrap focus trap ===== */
.toantin-help-dialog{
  border:0;
  padding:0;
  width:min(920px,94vw);
  max-width:920px;
  max-height:88vh;
  border-radius:22px;
  background:#fff;
  box-shadow:0 30px 90px rgba(15,23,42,.30);
  overflow:hidden;
}
.toantin-help-dialog::backdrop{
  background:rgba(15,23,42,.56);
  backdrop-filter:blur(2px);
}
.help-dialog-shell{
  display:flex;
  flex-direction:column;
  max-height:88vh;
  background:#fff;
}
.help-dialog-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:20px 22px;
  border-bottom:1px solid #eaecf0;
  background:linear-gradient(135deg,#f8f9ff,#eef4ff);
}
.help-dialog-header h2{
  margin:2px 0 0;
  font-size:22px;
  line-height:1.25;
  font-weight:900;
  color:#101828;
}
.help-close-btn{
  flex:0 0 36px;
  width:36px;
  height:36px;
  border:0;
  border-radius:50%;
  background:#fff;
  color:#475467;
  font-size:24px;
  line-height:1;
  box-shadow:0 1px 3px rgba(16,24,40,.10);
}
.help-close-btn:hover{background:#f2f4f7}
.help-dialog-body{
  overflow:auto;
  padding:20px 22px 8px;
  overscroll-behavior:contain;
}
.help-dialog-footer{
  display:flex;
  justify-content:flex-end;
  padding:12px 20px 16px;
  border-top:1px solid #eaecf0;
  background:#f9fafb;
}
.help-dialog-footer .btn{
  min-width:120px;
  border-radius:11px;
  font-weight:800;
}
@media(max-width:760px){
  .toantin-help-dialog{width:96vw;max-height:92vh}
  .help-dialog-shell{max-height:92vh}
  .help-dialog-body{padding:14px}
}


/* ===== V2.16: logo + favicon branding ===== */
.brand{min-width:0}
.brand-mark-logo{
  width:54px;
  height:54px;
  padding:0;
  border-radius:16px;
  background:#fff;
  overflow:hidden;
  box-shadow:0 10px 24px rgba(15,23,42,.14);
  border:1px solid rgba(15,23,42,.06);
}
.brand-mark-logo img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.brand small{letter-spacing:.01em}
@media(max-width:760px){
  .brand-mark-logo{width:44px;height:44px;border-radius:13px}
}


/* ===== V2.17: Setup help button + prominent attendance ===== */
.setup-dialog-head{
  position:relative;
  display:grid !important;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:16px;
}
.setup-head-title{
  justify-self:start;
  min-width:0;
}
.setup-dialog-head .dialog-close{
  justify-self:end;
}
.setup-help-btn{
  justify-self:center;
  align-self:center;
  border:1px solid #99a8ff;
  background:linear-gradient(135deg,#eef4ff,#e8f7ff);
  color:#3448c5;
  border-radius:999px;
  padding:10px 16px;
  min-height:42px;
  font-size:12px;
  font-weight:900;
  box-shadow:0 6px 18px rgba(81,70,165,.12);
  cursor:pointer;
  white-space:nowrap;
}
.setup-help-btn:hover{
  background:linear-gradient(135deg,#e3ebff,#dff4ff);
  border-color:#7f8fff;
  transform:translateY(-1px);
}
.setup-help-btn:focus-visible{
  outline:3px solid rgba(81,70,165,.22);
  outline-offset:2px;
}

/* Điểm danh ở giữa header: nổi bật nhưng không lòe loẹt */
.header-attendance-btn{
  border:1px solid #14b8a6 !important;
  background:linear-gradient(135deg,#ecfdf8,#e8f8ff) !important;
  color:#0f5f5a !important;
  box-shadow:0 4px 14px rgba(15,118,110,.12);
}
.header-attendance-btn:hover{
  background:linear-gradient(135deg,#dffaf2,#dff4ff) !important;
  border-color:#0f9f91 !important;
}
.header-attendance-label{
  color:#0f766e !important;
  font-weight:950 !important;
  letter-spacing:.01em;
}
#headerAttendanceText{
  color:#174b55;
  font-weight:850;
}
.header-attendance-btn:has(.header-absent-badge:not([hidden])){
  border-color:#f04438 !important;
  background:linear-gradient(135deg,#fff1f0,#fff8f0) !important;
}
.header-attendance-btn:has(.header-absent-badge:not([hidden])) .header-attendance-label,
.header-attendance-btn:has(.header-absent-badge:not([hidden])) #headerAttendanceText{
  color:#b42318 !important;
}

@media(max-width:900px){
  .setup-dialog-head{
    grid-template-columns:1fr auto;
  }
  .setup-help-btn{
    grid-column:1 / -1;
    grid-row:2;
    justify-self:center;
    margin-top:4px;
  }
}
