/* Minh Khanh Study Hub — giao diện ưu tiên điện thoại/iPad, 3 chủ đề theo cấp học. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #dbeafe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --base: 16px;
}

/* Tiểu học: màu tươi, chữ to, bo tròn nhiều */
.theme-primary {
  --bg: #fff8ec;
  --primary: #f97316;
  --primary-soft: #ffedd5;
  --radius: 22px;
  --base: 18px;
}
/* THCS */
.theme-secondary {
  --bg: #f1f5f9;
  --primary: #4f46e5;
  --primary-soft: #e0e7ff;
  --radius: 12px;
}
/* THPT */
.theme-high {
  --bg: #f8fafc;
  --primary: #0f766e;
  --primary-soft: #ccfbf1;
  --radius: 10px;
}
.theme-auth { --bg: #0f172a; --text: #e2e8f0; --muted: #94a3b8; --surface: #1e293b; --line: #334155; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { color: var(--primary); }
h1 { font-size: 1.5em; margin: .2em 0 .5em; line-height: 1.25; }
h2 { font-size: 1.15em; margin: 1.2em 0 .6em; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
h3 { font-size: 1.05em; margin: .4em 0; }
img, video, iframe { max-width: 100%; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; }
.narrow { max-width: 460px; }

/* Thanh trên cùng */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.brand { font-weight: 800; text-decoration: none; color: var(--text); font-size: 1.1em; white-space: nowrap; }
.nav { order: 3; width: 100%; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: .92em; }
.nav a.active, .nav a:hover { background: var(--primary-soft); color: var(--text); }
.me { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-name { font-weight: 600; font-size: .9em; display: none; }
.me form { margin: 0; }
@media (min-width: 900px) {
  .nav { order: 0; width: auto; flex: 1; margin: 0; }
  .me-name { display: inline; }
}

/* Thành phần chung */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
a.card { display: block; color: inherit; text-decoration: none; transition: transform .12s, border-color .12s; }
a.card:hover { transform: translateY(-2px); border-color: var(--primary); }
.card.empty { text-align: center; color: var(--muted); }
.card.note { background: var(--primary-soft); border-color: transparent; box-shadow: none; }
.card.danger { border-color: var(--bad-soft); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row form { margin: 0; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.page-head h1, .page-head h2 { margin-bottom: .3em; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid > .card { margin-bottom: 0; }
.muted { color: var(--muted); }
.tiny { font-size: .82em; }
.pre { white-space: pre-line; margin: .2em 0; }
.quote { background: var(--bg); border-radius: 10px; padding: 8px 12px; margin: 0; white-space: pre-line; }
.hidden { display: none !important; }
.plus { color: var(--ok); }
.minus { color: var(--bad); }
.danger-text { color: var(--bad) !important; }

.chip { display: inline-block; background: var(--primary-soft); color: var(--text); padding: 2px 10px; border-radius: 999px; font-size: .85em; font-weight: 600; }
.pill { display: inline-block; min-width: 1.4em; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .8em; text-align: center; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8em; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--line); color: var(--muted); }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 12px; font-weight: 600; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
.flash-bad { background: var(--bad-soft); color: var(--bad); }

/* Nút & ô nhập */
.btn, button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .88em; }
.btn.big { min-height: 56px; font-size: 1.1em; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .95em; }
label.inline, .inline { flex-direction: row; align-items: center; gap: 6px; display: inline-flex; font-weight: 500; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.w-num { width: 80px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .span2 { grid-column: span 2; } }
fieldset.picker { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
fieldset.picker legend { font-weight: 600; font-size: .95em; margin-bottom: 4px; }
.pick { cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span { display: inline-flex; width: 42px; height: 42px; align-items: center; justify-content: center; font-size: 22px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); }
.pick input:checked + span { border-color: var(--text); box-shadow: 0 0 0 2px var(--primary-soft); }
.pick input:focus-visible + span { outline: 2px solid var(--primary); }
.swatch { width: 42px; height: 42px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 600; }
.tabs a.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li.inactive { opacity: .55; }
.card.list { padding: 4px 16px; }

/* Hình đại diện */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; font-size: 22px; flex: none; color: #fff; }
.avatar.sm { width: 32px; height: 32px; font-size: 18px; }
.avatar.lg { width: 72px; height: 72px; font-size: 40px; }

/* Đăng nhập */
.auth { max-width: 720px; margin: 6vh auto 0; text-align: center; }
.auth.narrow { max-width: 460px; text-align: left; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 24px 0; }
.profile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px;
  background: var(--surface); border: 2px solid var(--line); border-radius: 18px; color: var(--text); cursor: pointer;
}
.profile:hover, .profile.selected { border-color: #38bdf8; transform: translateY(-2px); }
.profile-name { font-weight: 700; }
.profile-meta { font-size: .85em; color: var(--muted); }
.pinbox { max-width: 320px; margin: 0 auto; text-align: center; }
.pin-input { text-align: center; font-size: 1.6em; letter-spacing: .4em; background: var(--bg); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.keypad button { min-height: 60px; font-size: 1.4em; font-weight: 700; border-radius: 16px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; }
.keypad button:active { transform: scale(.96); }
.keypad .key-ok { background: #22c55e; color: #fff; border-color: #22c55e; }
.keypad .key-muted { color: var(--muted); }

/* Trang học sinh */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.hero h1 { margin: 0; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.star-total { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--text); background: #fef3c7; border-radius: 18px; padding: 8px 18px; }
.star-total span { font-size: 1.6em; line-height: 1; }
.star-total b { font-size: 1.6em; line-height: 1.1; }
.star-total small { color: var(--muted); }
.task h3 { margin: 10px 0 6px; }
.subjects { display: flex; flex-wrap: wrap; gap: 8px; }
.subject { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }
.kid { display: flex !important; gap: 14px; align-items: center; }
.kid-name { font-weight: 800; font-size: 1.1em; }
.kid-stats { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }

.video-wrap { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.media { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #000; border-radius: 10px; }
.upload-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.upload-btn {
  display: flex; align-items: center; justify-content: center; min-height: 64px; padding: 10px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; font-weight: 700; text-align: center;
}
.upload-btn:hover { border-color: var(--primary); }
.upload-btn.chosen { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.submission { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.submission:first-of-type { border-top: 0; padding-top: 0; }

/* ---------- Trắc nghiệm ---------- */
.quiz-cta { display: flex !important; align-items: center; gap: 14px; background: var(--primary-soft); border-color: transparent; }
.quiz-cta.done { background: var(--ok-soft); }
.quiz-icon { font-size: 2.2em; }
.progress { position: sticky; top: 56px; z-index: 5; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--primary); transition: width .2s; }
fieldset.question { border: 1px solid var(--line); margin: 0; min-width: 0; }
.question.answered { border-color: var(--primary); }
.question.right { border-left: 6px solid var(--ok); }
.question.wrong { border-left: 6px solid var(--bad); }
.q-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0; }
.q-num { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); align-items: center; justify-content: center; font-weight: 800; }
.q-prompt { font-size: 1.08em; font-weight: 600; margin: 10px 0; }
.choices { display: grid; gap: 8px; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice { flex-direction: row; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { flex: 1; display: block; padding: 12px 14px; min-height: 48px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.choice input:focus-visible + span { outline: 2px solid var(--primary); }
.num-answer { max-width: 220px; font-size: 1.2em; }
.opts { margin: 4px 0 8px; padding-left: 22px; }
.opts li.plus { font-weight: 700; }
details summary { cursor: pointer; color: var(--muted); margin-top: 6px; }

/* ---------- Quà ---------- */
.reward { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reward.locked { opacity: .65; }
.reward-icon { font-size: 2.6em; line-height: 1; }
.reward-icon.sm { font-size: 1.6em; }
.reward-cost { font-weight: 800; color: var(--warn); }

/* ---------- Thống kê ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--bg); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.stat b { font-size: 1.5em; }
.stat span { color: var(--muted); font-size: .85em; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; overflow-x: auto; }
.bar { flex: 1 0 14px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.bar span { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span.none { background: var(--line); }
.bar small { font-size: 10px; color: var(--muted); }
.meter-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; gap: 10px; align-items: center; margin: 6px 0; }
.meter { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; }
.meter .low { background: var(--bad); }
.meter .mid { background: #f59e0b; }
.meter .high { background: var(--ok); }
.meter-val { font-weight: 700; white-space: nowrap; }
.subject.active { border-color: var(--primary); background: var(--primary-soft); }
a.subject { text-decoration: none; color: var(--text); }

/* ---------- Tìm video ---------- */
.yt-results { display: grid; gap: 6px; }
.yt-item { display: flex; gap: 10px; align-items: center; text-align: left; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.yt-item:hover { border-color: var(--primary); }
.yt-item img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .85em; word-break: break-all; }

/* ---------- Nhiệm vụ cô giao ---------- */
.tasks li { align-items: center; }
.task-link { display: flex; gap: 10px; align-items: flex-start; text-decoration: none; color: var(--text); font-weight: 600; }
.task-check { font-size: 1.3em; line-height: 1.2; }
.list-head { background: var(--bg); border-radius: 8px; padding: 6px 10px !important; margin-top: 8px; }
dialog.task-popup { border: 0; border-radius: var(--radius); padding: 20px; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); background: var(--surface); color: var(--text); }
dialog.task-popup::backdrop { background: rgba(15, 23, 42, .55); }
.task-popup h2 { margin-top: 0; padding-right: 40px; }
.popup-close { position: absolute; top: 12px; right: 12px; }
.book-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.book-page { position: relative; display: block; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.book-page img { display: block; width: 100%; height: auto; }
.book-page .chip { position: absolute; left: 8px; bottom: 8px; background: rgba(255,255,255,.92); }
.thumbs-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 2px solid var(--primary); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.media-grid .media { max-height: 220px; }

/* ---------- Đọc sách ---------- */
.reader-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.reader-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-jump { margin: 0; }
.reader-stage { position: relative; display: flex; justify-content: center; align-items: flex-start; }
.reader-page { max-width: 100%; max-height: calc(100vh - 170px); width: auto; border-radius: 6px; box-shadow: var(--shadow); background: #fff; cursor: zoom-in; touch-action: pan-y pinch-zoom; }
.reader.zoomed .reader-page { max-height: none; width: 100%; cursor: zoom-out; }
.reader-nav { position: absolute; top: 40%; width: 48px; height: 72px; display: flex; align-items: center; justify-content: center; font-size: 40px; text-decoration: none; color: var(--text); background: rgba(255,255,255,.85); border-radius: 12px; box-shadow: var(--shadow); }
.reader-nav.prev { left: 0; }
.reader-nav.next { right: 0; }
.reader-nav.disabled { opacity: .2; pointer-events: none; }
.book-page img { aspect-ratio: auto 210 / 297; background: #f1f5f9; }
.reader-page { aspect-ratio: auto 210 / 297; }

/* ---------- Menu bên trái (máy tính, máy tính bảng ngang) / thanh cuộn ngang (điện thoại) ---------- */
.topbar-inner { max-width: none; flex-wrap: nowrap; }
.me-name { display: inline; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidenav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 53px; z-index: 9; }
.sidenav .nav { order: 0; width: auto; margin: 0; padding: 6px 12px; display: flex; gap: 4px; overflow-x: auto; flex-wrap: nowrap; }
.sidenav .nav a { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.nav-group { display: none; }
.nav .pill { margin-left: 4px; }
@media (max-width: 899px) {
  .has-sidenav .progress { top: 104px; }
}
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .sidenav { top: 53px; height: calc(100vh - 53px); overflow-y: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .sidenav .nav { flex-direction: column; overflow: visible; padding: 12px; gap: 2px; }
  .sidenav .nav a { border-radius: 10px; padding: 10px 12px; font-size: .95em; }
  .sidenav .nav a .nav-label { flex: 1; }
  .nav-group { display: block; margin: 14px 12px 4px; font-size: .72em; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .nav-group:first-child { margin-top: 2px; }
  .shell .container { margin: 0; max-width: 1100px; width: 100%; }
}
/* ---------- Đề cương ôn thi ---------- */
.thumb-file { display: flex; align-items: center; justify-content: center; height: 100%; padding: 4px; font-size: 11px; text-align: center; word-break: break-all; background: var(--bg); }
.guide-text { font-size: 1.08em; line-height: 1.75; background: var(--bg); border-radius: 10px; padding: 12px 14px; margin: 0; }
.theme-primary .guide-text { font-size: 1.15em; }
.guide-qs { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.guide-item h3 { margin: 0; }
details.reveal > summary { font-weight: 700; color: var(--primary); }
[hidden] { display: none !important; }

/* ---------- Đề thi thử ---------- */
.mock-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .mock-grid { grid-template-columns: minmax(0, 3fr) minmax(200px, 2fr); } }
.mock-page img { max-height: 520px; object-fit: contain; object-position: top; }
.w-auto { width: auto; min-height: 36px; padding: 4px 8px; }
.sticky-save { position: sticky; bottom: 8px; z-index: 5; box-shadow: 0 6px 24px rgba(15,23,42,.18); }
.timer { font-size: 1.1em; }
.timer.timer-low { background: var(--bad-soft); color: var(--bad); }
a.card.locked { opacity: .55; pointer-events: none; }
.locked-box { border: 2px dashed var(--warn); background: var(--warn-soft); }
.grade-box { display: grid; gap: 6px; }
.grade-box .choice span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.grade-box .w-num { min-height: 34px; padding: 4px 6px; }
.answer-mode { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; }
.key-grid { display: flex; flex-direction: column; gap: 0; padding: 4px 12px; }
.key-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.key-row > .tiny { grid-column: 2 / -1; }
.key-prompt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-choices { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.key-pick input { position: absolute; opacity: 0; }
.key-pick span { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border: 2px solid var(--line); border-radius: 10px; font-weight: 800; cursor: pointer; background: var(--surface); }
.key-pick input:checked + span { background: var(--ok); border-color: var(--ok); color: #fff; }
.key-pick input:focus-visible + span { outline: 2px solid var(--primary); }
.key-open { min-width: 220px; }
@media (max-width: 640px) { .key-row { grid-template-columns: 34px minmax(0, 1fr); } .key-choices { grid-column: 1 / -1; justify-content: flex-start; } }
.video-learn .video-wrap > div, .video-learn .video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.view-progress { position: static; height: 10px; }
.view-progress span { background: var(--ok); }

.thumb video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.thumb-video::after { content: "🎬"; position: absolute; left: 4px; bottom: 2px; font-size: 18px; }
.upload-btn.upload-main { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }

.advanced-box { border-top: 1px dashed var(--line); padding-top: 10px; }

/* Cài đặt: thẻ từng dịch vụ AI */
.settings-grid { align-items: start; }
.provider-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
.provider-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; background: var(--surface); }
.provider-card.ready { border-color: var(--ok, #2e9d5b); }
.provider-card summary { cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; list-style: none; }
.provider-card summary::-webkit-details-marker { display: none; }
.provider-card[open] summary { margin-bottom: 6px; }
.provider-fields { display: grid; gap: 8px; }
.provider-fields label { margin: 0; }

/* Đề thi thử: bài đọc, hình, phần nghe, chính tả, ảnh bài làm */
.passage-box { border-left: 4px solid var(--primary); }
.passage-text { font-size: 1.05rem; line-height: 1.7; }
.listen-box { background: var(--primary-soft); border-color: transparent; }
.listen-audio { width: 100%; }
.q-figure { display: block; margin: 8px 0; text-align: center; }
.q-figure img { max-width: 100%; max-height: 70vh; border-radius: 8px; border: 1px solid var(--line); }
.q-figure.small img { max-height: 180px; }
.q-figure.page .chip { display: inline-block; margin-top: 4px; }
.dictation-box { background: var(--primary-soft); border-radius: var(--radius); padding: 10px 12px; }
.answer-photos { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.answer-photos .upload-btn { align-self: flex-start; }
.q-media { border-top: 1px dashed var(--line); padding-top: 8px; }
.q-media summary { cursor: pointer; }
.semester-tabs { margin-bottom: 12px; }
.cam-box { display: flex; flex-direction: column; gap: 8px; }
.cam-box video { width: 100%; max-height: 60vh; background: #000; border-radius: var(--radius); transform: scaleX(-1); }
.cam-box .rec { color: #dc2626; font-weight: 700; }

/* Chuông thông báo */
.bell { position: relative; }
.bell summary { list-style: none; cursor: pointer; font-size: 1.35rem; line-height: 1; padding: 6px 8px; border-radius: 999px; position: relative; user-select: none; }
.bell summary::-webkit-details-marker { display: none; }
.bell summary:hover, .bell[open] summary { background: var(--primary-soft); }
.bell-badge { position: absolute; top: -2px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #dc2626; color: #fff; font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; }
.bell-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.18); z-index: 60; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.bell-empty { padding: 14px; margin: 0; }
.bell-all { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line); }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: .85rem; padding: 0; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li.unread { background: var(--primary-soft); }
.notif-list li.action { background: #fff7ed; border-left: 4px solid #f97316; }
.notif-link { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; color: inherit; text-decoration: none; flex: 1; }
.notif-link:hover { background: rgba(127,127,127,.08); }
.notif-icon { font-size: 1.25rem; line-height: 1.2; }
.notif-list li.unread .notif-link > span:last-child { font-weight: 600; }
.todo-list li { align-items: center; }
@media (max-width: 640px) {
  .bell-panel { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
}

/* Cài đặt AI: danh sách có thứ tự */
.ai-settings h3 { margin: 10px 0 0; }
@media (min-width: 900px) { .settings-grid.three { grid-template-columns: repeat(3, 1fr); } }
.provider-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.provider-list .provider-card { padding: 0; }
.provider-list details { padding: 8px 12px; }
.provider-list summary { display: flex; align-items: center; gap: 10px; }
.provider-list .grow { flex: 1; }
.order-no { width: 26px; height: 26px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.provider-card.ready .order-no { background: var(--primary); color: #fff; }
.order-btns { display: inline-flex; gap: 2px; }
.order-btns .btn { padding: 2px 8px; min-height: 0; }
.provider-list .provider-fields { margin-top: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.provider-card.moved { animation: moved .5s; }
@keyframes moved { from { background: var(--primary-soft); } to { background: var(--surface); } }

/* Thông báo nổi khi có thông báo mới */
.bell-badge[hidden] { display: none; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 80; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--primary); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.2); padding: 12px 14px; color: inherit; text-decoration: none; animation: toast-in .35s ease-out; }
.toast.action { border-left-color: #f97316; }
.toast .toast-icon { font-size: 1.6rem; line-height: 1; }
.toast b { display: block; margin-bottom: 2px; }
.toast .toast-close { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); margin-left: auto; }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.bell.ring summary { animation: ring .8s ease-in-out 2; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-18deg); } 40% { transform: rotate(14deg); } 60% { transform: rotate(-10deg); } 80% { transform: rotate(6deg); } }
