/* app.css — kiểu dáng chung + các trang ngoài màn hình làm bài */
:root {
  --ink: #1a1f2b;
  --muted: #5d6676;
  --line: #d8dce4;
  --line-soft: #e8ebf0;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --accent: #1f3a8a;
  --accent-hover: #182f73;
  --accent-soft: #e8edfb;
  --gold: #fbbf24;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #18794e;
  --warn-ink: #8a5a00;
  --warn-soft: #fff6dc;
  --radius: 10px;
  --ui-font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --read-font: Cambria, "Noto Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ui-font); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 12px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; }
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.logo-mark { display: inline-flex; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font: 12px var(--ui-font); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; color: var(--muted); background: #fafbfc; }

/* --- Nút --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; font-weight: 600; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn-sm { padding: 6px 14px; font-size: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { background: #f0f2f6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #971c12; }
.btn-icon { padding: 7px; border-radius: 8px; color: var(--muted); border: none; background: transparent; display: inline-flex; }
.btn-icon:hover { background: #eceff4; color: var(--danger); }
.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.input-num { width: 84px; }

/* --- Khung trang --- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.topnav {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 12px 32px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; }
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
  border: none; background: transparent; color: var(--muted); font-weight: 600;
}
.nav-btn:hover { background: #eef0f4; color: var(--ink); }
.nav-btn.active { background: var(--accent-soft); color: var(--accent); }
.page-body { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 32px 40px; }
.page-foot { padding: 14px 32px 20px; text-align: center; font-size: 12px; color: var(--muted); }

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; margin-bottom: 28px;
}
.hero p { margin: 0; }
.block { margin-bottom: 30px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 26px; }
.path {
  font-family: Consolas, "Cascadia Mono", monospace; font-size: 13.5px; background: #f1f3f7; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 9px 12px; word-break: break-all;
}

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.card-title { font-weight: 700; font-size: 16.5px; line-height: 1.3; }
.card-sub { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #eef0f4; color: #3b4353; }
.chip-rw { background: #e8edfb; color: #1f3a8a; }
.chip-math { background: #fdf1d3; color: #7a4d00; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); }
.row-score { font-weight: 600; color: var(--accent); white-space: nowrap; }
.rows + .small { margin-top: 8px; }
.empty { background: var(--surface); border: 1px dashed #b9c0cc; border-radius: 14px; padding: 30px; text-align: center; }
.empty p { margin: 0 0 4px; }
.fatal { padding: 40px; }

/* --- Hộp thoại --- */
.overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(18, 24, 38, .45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; max-height: calc(100vh - 48px);
  display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(10, 20, 50, .3);
}
.modal-wide { max-width: 640px; }
.modal-title { margin: 0; padding: 22px 26px 4px; font-size: 19px; }
.modal-body { padding: 10px 26px 6px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 26px 22px; flex-wrap: wrap; }
/* Hộp cỡ cố định (nhập đề): thân cuộn bên trong, hàng nút không xê dịch theo độ dài nội dung */
.modal-fixed { height: min(620px, calc(100vh - 48px)); }
.modal-fixed .modal-body { flex: 1 1 auto; min-height: 0; }
.modal-fixed .modal-foot { border-top: 1px solid var(--line, #e3e6ec); padding-top: 14px; }
.modal.modal-batch { max-width: 960px; height: min(720px, calc(100vh - 48px)); }
.warn-box ul { max-height: 180px; overflow: auto; }

/* Nhập nhiều file đề một lượt */
.input-sm { padding: 4px 8px; font-size: 13.5px; }
.imp-opts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px; margin: 4px 0 12px; }
.imp-opt { display: flex; flex-direction: column; gap: 4px; }
.imp-opt .input { min-width: 220px; }
.imp-check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; padding-bottom: 8px; }
.imp-table { font-size: 14px; }
.imp-table td { padding: 7px 10px; }
.imp-table .imp-file { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-table .warn-box { margin-top: 4px; font-size: 13px; }
.imp-err { color: var(--danger); margin-top: 3px; }
.imp-bar { height: 8px; border-radius: 99px; background: #e6e9f0; overflow: hidden; margin: 6px 0 4px; }
.imp-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }
.drop-veil { position: fixed; inset: 0; z-index: 1900; background: rgba(18, 24, 38, .35); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-veil[hidden] { display: none; }
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 48px; background: #fff; border-radius: 16px;
  border: 2px dashed var(--accent); color: var(--accent); box-shadow: 0 24px 60px rgba(10, 20, 50, .3); text-align: center;
}
.drop-card strong { font-size: 17px; color: var(--ink); }
.msg-list { margin: 0 0 10px; padding-left: 20px; }
.msg-list li { margin-bottom: 4px; }
.msg-list.err li::marker { color: var(--danger); }
.msg-list.warn { color: var(--warn-ink); }
.note.warn, .warn-box { background: var(--warn-soft); color: var(--warn-ink); border-radius: 8px; padding: 10px 14px; }
.warn-box summary { cursor: pointer; font-weight: 600; }
.warn-box ul { margin-top: 8px; }
.simple-table { border-collapse: collapse; width: 100%; margin: 6px 0 14px; }
.simple-table th, .simple-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.simple-table th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }

.start-options { display: flex; flex-direction: column; gap: 14px; }
.opt-group-title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.opt { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; cursor: pointer; }
.opt:hover { background: #f7f8fb; }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.opt input { margin-top: 4px; accent-color: var(--accent); }
.opt-text { display: flex; flex-direction: column; }
.opt-label { font-weight: 600; }
.opt-detail { font-size: 13px; color: var(--muted); }

/* --- Thông báo nhanh --- */
#toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; max-width: 560px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); transition: opacity .25s, transform .25s;
}
.toast-success { background: #14613f; }
.toast-error { background: #9c1f15; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* --- Chữ trong đề (dùng chung) --- */
.rich p { margin: 0 0 .8em; }
.rich p:last-child { margin-bottom: 0; }
.rich .blank { display: inline-block; width: 4.2em; border-bottom: 1.5px solid currentColor; vertical-align: baseline; margin: 0 .15em; }
.rich u { text-underline-offset: 3px; }
.rt-table { border-collapse: collapse; margin: .4em 0 1em; font-family: var(--ui-font); font-size: .92em; }
.rt-table th, .rt-table td { border: 1px solid #9aa3b2; padding: 6px 12px; text-align: center; }
.rt-table th { background: #f1f3f7; font-weight: 600; }
.katex { font-size: 1.08em; }

/* --- Nhãn trạng thái, thanh tỉ lệ --- */
.tag { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: #eef0f4; color: #3b4353; }
.tag-ok { background: #e3f4ea; color: #14613f; }
.tag-bad { background: var(--danger-soft); color: var(--danger); }
.tag-skip { background: #eef0f4; color: #5d6676; }
.tag-lg { font-size: 15px; padding: 5px 16px; }
td .tag + .tag, td > .tag-bad { margin-left: 8px; }
.bar { display: inline-block; width: 120px; height: 8px; border-radius: 999px; background: #e6e9ef; overflow: hidden; vertical-align: middle; }
.bar-fill { display: block; height: 100%; border-radius: 999px; }
.bar-fill.good { background: #2e9e6b; }
.bar-fill.mid { background: #e0a100; }
.bar-fill.low { background: #d1493e; }
.bar.time { width: 70px; height: 6px; margin-left: 8px; }
.bar.time .bar-fill { background: #8b97b5; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.note { border-radius: 8px; padding: 10px 14px; }

/* --- Trang kết quả --- */
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.results-head p { margin: 0; }
.score-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 14px; }
.score-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; border-top: 5px solid #8b97b5; }
.score-card.total { border-top-color: var(--accent); background: #f3f6ff; }
.score-card.rw { border-top-color: #4b6be0; }
.score-card.math { border-top-color: var(--gold); }
.score-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.score-value { font-size: 44px; font-weight: 700; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; }
.score-range { font-size: 13px; color: var(--muted); }
.score-raw { margin-top: 8px; font-weight: 600; }
.score-notes { margin-top: 4px; font-size: 12.5px; color: var(--warn-ink); }
.estimate-note { background: var(--warn-soft); color: #5c4200; font-size: 14px; margin-bottom: 24px; }
.skill-block + .skill-block { margin-top: 22px; }
.skill-block h3 { margin: 0 0 4px; font-size: 15.5px; }
.skill-table td:first-child { width: 46%; }
.domain-row td { font-weight: 700; background: #f7f8fb; }
.skill-row td:first-child { padding-left: 30px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.filter-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 14px; font-size: 14px; font-weight: 600; color: var(--muted); }
.filter-chip:hover:not(:disabled) { background: #f0f2f6; }
.filter-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.q-table td { vertical-align: middle; }
.q-row { cursor: pointer; }
.q-row:hover td, .q-row:focus-visible td { background: #f3f6ff; }
.q-row .flag { margin-left: 6px; vertical-align: middle; }
.q-row .flag svg { fill: var(--danger); stroke: var(--danger); }
.row-go { color: var(--accent); font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.time-cell { display: inline-flex; align-items: center; font-variant-numeric: tabular-nums; }
#questions { scroll-margin-top: 76px; }
.row-score { text-align: right; }
.row-est { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.more-history { margin-top: 10px; }
.backup-table { margin-top: 16px; }

/* --- Kho câu hỏi --- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: none; background: none; padding: 10px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.filter { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.filter .input { font-size: 14px; max-width: 220px; min-width: 130px; }
.filter.wide { flex: 1; min-width: 200px; }
.filter-break { flex-basis: 100%; height: 0; margin-top: -10px; } /* xuống hàng, không thêm khoảng trống */
.filter.wide .input { max-width: none; width: 100%; }
.bank-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bank-table { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.bank-table th:first-child, .bank-table td:first-child { padding-left: 18px; }
.bank-src { font-size: 12px; color: var(--muted); max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.bank-preview { color: #2c3443; font-size: 14px; line-height: 1.45; max-width: 380px; }
.mini { color: var(--muted); margin-left: 6px; vertical-align: middle; }
.row-icons { text-align: right; }
.row-icons .flag svg { fill: var(--danger); stroke: var(--danger); }
.row-icons .btn-icon.edit:hover { color: var(--accent); }
.mistake-progress { font-size: 12px; color: var(--warn-ink); margin-top: 3px; }
.tag-warn { background: var(--warn-soft); color: var(--warn-ink); }
/* Ôn câu sai theo lịch: thẻ "Hôm nay cần ôn" ở Trang chủ, dòng giải thích + nút ôn ở tab Sổ câu sai */
.review-card { display: flex; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid #8b97b5; border-radius: 14px; padding: 14px 22px; margin-bottom: 28px; }
.review-card.due { border-left-color: var(--accent); background: #f3f6ff; }
.review-count { font-size: 30px; font-weight: 700; line-height: 1; min-width: 34px; text-align: center; color: #8b97b5; }
.review-card.due .review-count { color: var(--accent); }
.review-main { flex: 1; min-width: 0; }
.review-title { font-weight: 700; font-size: 17px; }
.review-intro { display: flex; align-items: flex-start; gap: 18px; margin-bottom: 14px; }
.review-intro p { flex: 1; margin: 0; }
.review-intro .btn { white-space: nowrap; }
.bank-table th { white-space: nowrap; } /* thêm 2 cột Bậc/Hạn ôn thì tiêu đề cột không bị xuống dòng */
.weak-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.weak-card { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid #d1493e; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.weak-pct { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--danger); }
.weak-name { font-weight: 600; line-height: 1.3; }
.weak-card .btn { margin-top: 8px; }
.stats-table td:first-child { width: 38%; }
/* Thống kê → Lý do sai: biểu đồ cột ngang (một màu vì chỉ so độ lớn), bấm một dòng để mở danh sách */
.reason-filters { display: flex; flex-wrap: wrap; gap: 4px 28px; }
.reason-chart { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 12px; max-width: 760px; }
.reason-row { display: grid; grid-template-columns: 170px minmax(80px, 1fr) 92px; align-items: center; gap: 14px; padding: 7px 10px; border: none; border-radius: 8px; background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.reason-row:hover, .reason-row:focus-visible { background: #f3f6ff; }
.reason-row.on { background: var(--accent-soft); }
.reason-name { font-weight: 600; }
.reason-track { display: block; height: 12px; }
.reason-fill { display: block; height: 100%; min-width: 4px; border-radius: 0 4px 4px 0; background: #3b5bdb; }
.reason-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.reason-val strong { color: var(--ink); }
.reason-unsorted { border: 1px dashed var(--line); border-radius: 8px; background: var(--warn-soft); color: #5c4200; padding: 8px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.reason-unsorted:hover, .reason-unsorted.on { border-style: solid; border-color: #d9b45a; }
.reason-detail { margin-top: 18px; }
.reason-detail h3 { margin: 0 0 2px; font-size: 15.5px; }
.reason-select { font-size: 13.5px; padding: 4px 6px; }
.reason-note-text { margin-top: 3px; max-width: 220px; }

/* --- Form thêm/sửa câu, trang sửa đề --- */
.qf-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.page-body:has(.qf-layout) { max-width: 1320px; }
.qf-form { display: flex; flex-direction: column; gap: 14px; }
.qf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.qf-grid.three { grid-template-columns: 1.4fr 1.2fr .8fr; }
.qf-field { display: flex; flex-direction: column; gap: 4px; }
.qf-label { font-size: 13px; font-weight: 600; color: #3b4353; }
.qf-hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.qf-field .input, .qf-choice .input { width: 100%; }
.qf-text { resize: vertical; line-height: 1.5; font-family: var(--ui-font); }
.qf-choice { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.qf-choice input[type="radio"] { width: 18px; height: 18px; accent-color: #18794e; flex: none; }
.qf-choice .letter { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #1a1f2b; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.qf-image { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.qf-drop { width: 100%; border: 2px dashed #b4bac6; border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; background: #fafbfd; }
.qf-thumb { max-width: 100%; max-height: 220px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qf-actions { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.qf-preview { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; }
.qf-preview-body .passage { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.qf-preview-body .passage, .qf-preview-body .q-prompt, .qf-preview-body .choice-text { font-family: var(--read-font); font-size: 16px; line-height: 1.55; }
.qf-preview-body .q-prompt { margin-bottom: 14px; }
.qf-preview-body .q-figure { display: block; max-width: 100%; max-height: 300px; margin: 0 auto 14px; }
.qf-preview-body .choices { display: flex; flex-direction: column; gap: 8px; }
.qf-preview-body .choice { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid #4a5263; border-radius: 10px; min-height: 44px; }
.qf-preview-body .choice.correct { border-color: #18794e; box-shadow: inset 0 0 0 2px #18794e; background: #effaf3; }
.qf-preview-body .letter { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #1a1f2b; display: flex; align-items: center; justify-content: center; font-family: var(--ui-font); font-weight: 700; font-size: 13px; }
.qf-preview-body .choice.correct .letter { background: #18794e; border-color: #18794e; color: #fff; }
.qf-preview-body .spr-line { display: flex; justify-content: space-between; padding: 8px 14px; border-radius: 10px; border: 1.5px solid #18794e; background: #effaf3; }
.qf-preview-body .explain { margin-top: 18px; padding: 12px 14px; background: #f6f7fb; border-left: 4px solid var(--accent); border-radius: 8px; }
.qf-preview-body .explain h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; color: var(--accent); }
.ed-title { flex: 1; min-width: 240px; font-size: 16px; font-weight: 600; }
.ed-mod-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.ed-mod-head h2 { margin: 0; }
.ed-time { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.ed-table td { vertical-align: middle; }
.ed-num { width: 36px; font-weight: 700; color: var(--muted); }
.ed-note { margin-top: 8px; }
.ed-table + .btn { margin-top: 6px; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.bank-preview .mini { margin-left: 0; }
.bank-table td { padding-top: 10px; padding-bottom: 10px; }
.empty .btn { margin-top: 12px; }
/* Khi có hộp thoại đang mở, thông báo nhanh chuyển lên đầu màn hình để không che hàng nút của hộp thoại. */
body:has(.overlay) #toasts { bottom: auto; top: 14px; }

/* Trang chủ có thêm nút "Tạo đề cá nhân hoá": giữ ba nút trên một hàng, phần chữ bên trái tự xuống dòng */
.hero .btn-row { flex: none; }

/* --- Đề cá nhân hoá: hộp thoại tạo đề (views/custom-test.js) --- */
.custom-form { display: flex; flex-direction: column; gap: 12px; }
.custom-form > p { margin: 0; }
.custom-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.custom-sections .opt { margin-bottom: 0; }
.opt.disabled { opacity: .55; cursor: not-allowed; }
.opt.disabled:hover { background: transparent; }
.custom-row { display: flex; align-items: flex-end; gap: 28px; flex-wrap: wrap; }
.custom-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.custom-min { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
.custom-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.custom-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.custom-preview { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; background: #f7f8fb; min-height: 92px; }
.custom-preview p { margin: 6px 0 0; }
.custom-summary { font-weight: 700; font-size: 16px; }
.custom-detail { margin-top: 8px; }
.custom-detail summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.custom-table { margin: 6px 0 4px; font-size: 14px; }
.custom-table th, .custom-table td { padding: 5px 10px; }

/* --- Trang Tiến bộ (views/progress.js) --- */
.progress-page .block { margin-bottom: 26px; }
.h-sub { font-size: 14px; font-weight: 400; margin-left: 6px; }
.prog-note { margin: 10px 0 0; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: 13.5px; }
.link-btn:hover { text-decoration: underline; }
/* Ngày thi + mục tiêu */
.goal-card { display: flex; align-items: center; gap: 26px; background: #f3f6ff; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 14px; padding: 18px 24px; margin-bottom: 28px; }
.goal-count { min-width: 150px; }
.goal-num { font-size: 48px; font-weight: 700; line-height: 1.05; color: var(--accent); }
.goal-count.none .goal-num { color: #8b97b5; }
.goal-unit { font-size: 13.5px; color: var(--muted); }
.goal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.goal-line { font-weight: 600; }
.goal-form { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 10px; }
.goal-form .input[type="date"] { width: 170px; }
/* Ô số liệu */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.tile-label { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 700; line-height: 1.15; }
.tile-skill { display: block; font-size: 16px; line-height: 1.3; }
.tile-skill .chip { vertical-align: 1px; }
.tile-empty { font-size: 16px; color: var(--muted); }
.tile-sub { font-size: 13px; color: var(--muted); }
/* Chuỗi ngày + lịch học */
.streak-panel { display: flex; gap: 32px; align-items: flex-start; flex-wrap: wrap; }
.streak-tiles { display: flex; flex-direction: column; gap: 12px; width: 250px; }
.heat-wrap { flex: 1; min-width: 400px; }
.heat { display: grid; grid-auto-rows: 26px; gap: 5px; align-items: center; }
.heat-month { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; align-self: end; }
.heat-wd { font-size: 11px; color: var(--muted); }
.heat-cell { display: block; width: 26px; height: 26px; border-radius: 5px; background: #eef0f4; }
.heat-cell.l1 { background: #d6e0fd; }
.heat-cell.l2 { background: #9db1f5; }
.heat-cell.l3 { background: #5b7be8; }
.heat-cell.l4 { background: #1f3a8a; }
.heat-cell.future { background: transparent; box-shadow: inset 0 0 0 1px var(--line-soft); }
.heat-cell.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.heat .heat-cell:not(.future):hover, .heat .heat-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; }
.heat-legend .heat-cell { width: 14px; height: 14px; border-radius: 3px; }
.heat-note { margin-left: 12px; }
/* Biểu đồ */
.chart-panel { padding: 18px 22px; }
.chart-title { margin: 6px 0 2px; font-size: 14.5px; }
.chart-title + .prog-svg { margin-bottom: 10px; }
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin: 2px 0 2px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 16px; height: 2px; border-radius: 2px; }
.prog-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--ui-font); }
.prog-svg .grid { stroke: var(--line-soft); stroke-width: 1; }
.prog-svg .axis { stroke: var(--line); stroke-width: 1; }
.prog-svg .tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.prog-svg .tick-now { fill: var(--ink); font-weight: 600; }
.prog-svg .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.prog-svg .series-dot { stroke: var(--surface); stroke-width: 2; }
.prog-svg .end-label { font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.prog-svg .target-line { stroke: var(--warn-ink); stroke-width: 1.5; stroke-dasharray: 6 4; }
.prog-svg .target-label { font-size: 12px; font-weight: 600; fill: var(--warn-ink); }
.prog-svg .hit { outline: none; cursor: default; }
.prog-svg .hit-area { fill: transparent; }
.prog-svg .xline { stroke: var(--ink); stroke-width: 1; opacity: 0; }
.prog-svg .hit:hover .xline, .prog-svg .hit:focus-visible .xline { opacity: .35; }
.prog-svg .hit:hover .hit-area, .prog-svg .hit:focus-visible .hit-area { fill: rgba(31, 58, 138, .05); }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.chart-table .simple-table { font-size: 14px; }
.prog-tip { position: fixed; z-index: 1500; pointer-events: none; background: #1d2433; color: #e6e9f0; font-size: 13px; line-height: 1.4; padding: 8px 12px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); max-width: 320px; }
.prog-tip strong { display: block; color: #fff; font-size: 14px; }

/* --- Trang chủ gọn + thư mục đề (views/home.js) --- */
.hero-compact { padding: 14px 22px; margin-bottom: 18px; }
.hero-compact h1 { font-size: 21px; margin: 0; }
.quick-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 26px; }
.quick-row .review-card { margin-bottom: 0; }
.folder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.folder-card {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 10px 14px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.folder-card:hover, .folder-card:focus-visible { border-color: var(--accent); box-shadow: 0 2px 10px rgba(31, 58, 138, .1); outline: none; }
.folder-ico { display: flex; color: var(--accent); }
.folder-card.none .folder-ico { color: #8b97b5; }
.folder-main { flex: 1; min-width: 0; }
.folder-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-acts { display: flex; opacity: .5; transition: opacity .12s; }
.folder-card:hover .folder-acts, .folder-card:focus-within .folder-acts { opacity: 1; }
.btn-icon.plain:hover { color: var(--accent); }

.folder-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.folder-head h1 { margin: 0; font-size: 22px; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.folder-head h1 .ico { color: var(--accent); display: flex; }
.folder-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.folder-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 13.5px; color: var(--muted);
}
.folder-chip:hover { color: var(--ink); border-color: #b9c0cc; }
.folder-chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; cursor: default; }
.folder-strip.dragging .folder-chip:not(.on) { border-style: dashed; border-color: var(--accent); color: var(--ink); }
.folder-chip.over { background: var(--accent); border-color: var(--accent); color: #fff !important; }
.folder-chip .ico { display: flex; pointer-events: none; }
.strip-hint { margin-left: 6px; }
.folder-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px; margin-bottom: 16px;
}
#folder-search { width: 190px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; background: var(--surface); padding: 6px 14px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--accent-soft); color: var(--accent); }
.pick-all { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-head .pick { margin-top: 5px; flex: none; }
.card-score { font-size: 13.5px; }
.card[draggable="true"], .test-table tr[draggable="true"] { cursor: grab; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.test-table { margin: 0; }
.test-table th, .test-table td { padding-left: 8px; padding-right: 8px; }
.test-table th { white-space: nowrap; }
.test-table td { vertical-align: middle; }
.test-table tbody tr:last-child td { border-bottom: none; }
.test-table th:first-child, .test-table td:first-child { padding-left: 16px; padding-right: 4px; }
.test-name { font-weight: 600; min-width: 140px; }
.test-acts { display: flex; align-items: center; gap: 4px; }
.test-acts .btn-sm { padding: 5px 11px; }
.test-acts .btn-icon { padding: 5px; }
.move-list .opt-text { flex: 1; }
.move-list .opt-text .input { margin-top: 6px; }

/* --- Phân tích tốc độ: nhãn "Chậm", biểu đồ nhịp độ (trang kết quả), bảng tốc độ (Kho câu hỏi → Thống kê) --- */
.tag-slow { margin-left: 8px; }
.pace-summary { margin: 4px 0 10px; }
.pace-story { margin: 6px 0 4px; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-line.pace-key { background: var(--ink); }
.legend-line.plan-key { background: none; border-top: 2px dashed var(--muted); height: 0; }
.pace-svg .pace-line { stroke: var(--ink); stroke-width: 1.5; }
.pace-svg .pace-label { font-size: 12px; font-weight: 600; fill: var(--ink); }
.pace-svg .slow-line { stroke: #b4501f; stroke-width: 1.2; stroke-dasharray: 5 4; }
.pace-svg .slow-label { font-size: 12px; fill: #b4501f; }
.pace-svg .plan-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 4; }
.pace-svg .plan-label { font-size: 12.5px; fill: var(--muted); }
.pace-svg .behind-zone { fill: rgba(235, 104, 52, .09); }
.pace-svg .hit.pick { cursor: pointer; }
.pace-table { margin-bottom: 18px; }
.pace-over { color: var(--danger); font-weight: 600; }
.pace-warn { color: var(--warn-ink); }
.pace-under { color: var(--ok); }
#pace-stats h3 { margin: 16px 0 6px; font-size: 15.5px; }

/* --- Sổ từ vựng: nút nổi khi bôi đen, trang Từ vựng, flashcard --- */
.vocab-pop { position: fixed; z-index: 900; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: none; border-radius: 999px; background: var(--accent); color: #fff; font: 600 14px var(--ui-font); box-shadow: 0 8px 22px rgba(10, 20, 50, .28); white-space: nowrap; user-select: none; }
.vocab-pop:hover { background: var(--accent-hover); }
.vocab-dialog { max-width: 560px; width: 100%; }
.vw-contexts { display: flex; flex-direction: column; gap: 6px; max-height: 190px; overflow: auto; }
.vw-context { display: flex; align-items: flex-start; gap: 8px; background: #f7f8fa; border: 1px solid var(--line-soft); border-radius: 8px; padding: 8px 10px; }
.vw-sentence { flex: 1; min-width: 0; font-family: var(--read-font); font-size: 15px; line-height: 1.5; }
.vw-context.dropped .vw-sentence { text-decoration: line-through; opacity: .5; }
.vw-context.dropped .btn-icon { color: var(--danger); }
.vc-hit { color: var(--accent); }
.vocab .review-card { margin-bottom: 18px; }
.vocab .review-main .link-btn { margin-top: 3px; text-align: left; }
.vocab .filters { align-items: flex-end; }
.vocab-status { margin: 0; flex-basis: 100%; }
.vocab-table { width: 100%; }
.vc-word { font-weight: 700; font-size: 15.5px; max-width: 200px; overflow-wrap: anywhere; }
.vc-meaning { max-width: 260px; font-size: 14px; }
.vc-src { max-width: 360px; white-space: nowrap; margin-top: 2px; }
.fc-card { max-width: 680px; min-height: 290px; margin: 6px auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 30px rgba(10, 20, 50, .08); padding: 22px 34px 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.fc-card:not(.flipped) { cursor: pointer; }
.fc-side { align-self: flex-start; text-transform: uppercase; letter-spacing: .5px; font-size: 12px; font-weight: 600; }
.fc-word { font-size: 32px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.fc-sentence { font-family: var(--read-font); font-size: 18px; line-height: 1.6; color: #2c3443; }
.fc-hint { margin-top: auto; font-size: 14px; }
.fc-back { width: 100%; margin-top: 8px; padding-top: 16px; border-top: 1px dashed #b9c0cc; }
.fc-meaning { font-size: 21px; font-weight: 600; color: var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; }
.fc-note { margin-top: 8px; font-size: 15px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.fc-actions { display: flex; justify-content: center; gap: 14px; margin: 20px 0 8px; }
.fc-actions .btn { min-width: 150px; justify-content: center; gap: 10px; padding-top: 10px; padding-bottom: 10px; }
.fc-actions .btn-primary kbd { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .4); color: #fff; }
.fc-no { border-color: #e2b4ae; color: var(--danger); }
.fc-no:hover { background: var(--danger-soft); }
.fc-level, .fc-last { text-align: center; margin: 0 0 4px; }
.fc-last { min-height: 22px; font-size: 14px; }
.fc-done { max-width: 680px; margin: 6px auto 14px; text-align: center; }
.fc-done .btn-row { justify-content: center; margin-top: 14px; }
@media (max-width: 1240px) { .topnav { gap: 12px; padding-left: 20px; padding-right: 20px; } .nav-btn { padding-left: 10px; padding-right: 10px; } }

/* --- Ảnh nền (Cài đặt → Giao diện; js/background.js, src/main/background.js) ---
   #bg-layer là lớp cố định nằm SAU mọi thứ (z-index -1), chỉ hiện khi body có lớp .has-bg.
   Khi có ảnh nền: thẻ/bảng (mọi chỗ dùng --surface) trong mờ theo --card-alpha (sàn 0,7), nội dung trang nằm trên
   một tấm nền cùng độ đặc nên chữ ngoài thẻ (tiêu đề, dòng chú thích) vẫn dễ đọc; hộp thoại luôn đặc.
   Màn hình làm bài / xem lại / luyện từng câu (.exam) vẫn nền trắng đặc trừ khi bật công tắc (.bg-exam).
   Trang in: print.css ẩn mọi thứ ngoài #print-root nên không bao giờ có ảnh nền. */
#bg-layer { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: #dfe3ea; }
#bg-img {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); user-select: none;
  filter: blur(var(--bg-blur, 0px)) brightness(var(--bg-bright, 1));
}
/* Phủ kín: ảnh rộng hơn khung theo độ mờ để mép ảnh bị làm mờ không lộ viền nhạt */
#bg-img.fit-cover { width: calc(100% + 4 * var(--bg-blur, 0px)); height: calc(100% + 4 * var(--bg-blur, 0px)); max-width: none; object-fit: cover; }
/* Căn giữa: giữ cỡ thật, chỉ thu nhỏ khi ảnh lớn hơn cửa sổ */
#bg-img.fit-center { max-width: 100%; max-height: 100%; }
#bg-veil { position: absolute; inset: 0; background: var(--bg-veil, transparent); }

body.has-bg { --surface: rgba(255, 255, 255, var(--card-alpha, .85)); }
body.has-bg .page-body {
  width: calc(100% - 40px); margin: 20px auto; border-radius: 18px;
  background: rgba(245, 246, 248, var(--card-alpha, .85)); box-shadow: 0 12px 40px rgba(10, 20, 50, .16);
}
body.has-bg .topnav { background: rgba(255, 255, 255, .9); backdrop-filter: blur(14px); border-bottom-color: rgba(216, 220, 228, .6); }
body.has-bg .page-foot { width: fit-content; margin: 0 auto 18px; padding: 6px 16px; border-radius: 999px; background: rgba(255, 255, 255, .9); }
body.has-bg .modal { background: #fff; }
body.bg-exam .exam:not(.is-break):not(.is-done) { background: rgba(255, 255, 255, calc(.5 + var(--card-alpha, .85) / 2)); }
body.bg-exam .ex-body.review { background: transparent; }

/* Cài đặt → Giao diện */
.bg-head { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.bg-thumb { width: 192px; height: 108px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #eef0f4; flex: none; }
.bg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 32px; margin-bottom: 14px; }
.bg-ctl { display: grid; grid-template-columns: 140px minmax(0, 1fr) 52px; align-items: center; gap: 10px; min-height: 34px; }
.bg-ctl .seg { justify-self: start; grid-column: span 2; }
.bg-label { font-weight: 600; font-size: 14px; }
.bg-range { width: 100%; accent-color: var(--accent); }
.bg-val { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.bg-check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; }
@media (max-width: 1100px) { .bg-grid { grid-template-columns: 1fr; } }

/* --- Form câu hỏi: nhiều ảnh mỗi câu, câu trước / câu sau (đợt 3 phiên 2–4) --- */
.qf-img-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.qf-img-item { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.qf-img-item .qf-thumb { max-width: 220px; max-height: 150px; }
.qf-thumb.missing { width: 120px; height: 80px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.qf-img-tools { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.input-sm { padding: 4px 8px; font-size: 13.5px; }
.qf-nav { align-items: center; }
.qf-preview-body .rt-img { max-width: 100%; max-height: 260px; }

/* --- Bài thi ghép (đợt 3 phiên 1) --- */
.cmp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cmp-head h2 { margin: 0; }
.cmp-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.cmp-slot { border: 1.5px dashed #b4bac6; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: #fafbfd; }
.cmp-slot.filled { border-style: solid; border-color: var(--line); background: var(--surface, #fff); }
.cmp-slot-name { display: flex; align-items: baseline; gap: 8px; }
.cmp-pick-title { font-weight: 600; }
.cmp-slot .tag { margin-left: 6px; }
.cmp-filter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cmp-filter .input { flex: 1; min-width: 200px; }
.cmp-list { display: flex; flex-direction: column; gap: 4px; }
.cmp-cand { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px 10px; cursor: pointer; font: inherit; }
.cmp-cand:hover, .cmp-cand:focus-visible { border-color: var(--accent, #2a78d6); }
.cmp-cand.on { border-color: var(--accent, #2a78d6); background: #eef4fc; }
.cmp-cand-title { font-weight: 600; flex: 1; min-width: 0; }
.card-sub.used-in { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head .tag { margin-left: auto; flex-shrink: 0; }

/* --- Sửa đề cho đề dài (đợt 3 phiên 4) --- */
.ed-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ed-tools .input[type="search"] { flex: 1; min-width: 240px; }
.ed-bulk { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f1f5fb; }
.ed-bulk .input { width: auto; min-width: 140px; }
.ed-pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.ed-source { margin: 0; padding-left: 18px; }
.ed-flags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.ed-table tr.hit td { background: #fff8db; }
.ed-mod-tag { font-size: 12px; white-space: nowrap; }
.ed-num .small { white-space: nowrap; }

/* --- Đồng bộ đám mây (js/sync-ui.js): biểu tượng trên thanh menu, màn đăng nhập, mục ở Cài đặt --- */
.sync-chip {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  margin-left: 6px; border: none; border-radius: 8px; background: transparent; color: var(--muted);
}
.sync-chip:hover { background: #eef0f4; color: var(--ink); }
.sync-dot { position: absolute; right: 5px; bottom: 7px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); background: var(--ok); }
.sync-chip.sync-busy .sync-dot { background: var(--accent); animation: sync-pulse 1s ease-in-out infinite; }
.sync-chip.sync-off .sync-dot { background: #9aa3b2; }
.sync-chip.sync-bad .sync-dot { background: var(--danger); }
.sync-chip.sync-bad { color: var(--danger); }
@keyframes sync-pulse { 50% { opacity: .3; } }
.sync-state { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.sync-state.sync-ok { color: var(--ok); }
.sync-state.sync-bad { color: var(--danger); }
.sync-state.sync-off, .sync-state.sync-busy { color: var(--muted); }
.sync-state .muted { font-weight: 400; }
.sync-refresh {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 9000; display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 10px; background: #1d2430; color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px);
}
.sync-refresh .btn-icon { color: #c9cfdb; }
.sync-refresh .btn-icon:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(20, 30, 60, .08); }
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.gate-card h1 { font-size: 22px; }
.gate-foot { max-width: 420px; margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.login-form { display: grid; gap: 6px; margin-top: 8px; }
.login-form label { font-weight: 600; font-size: 14px; margin-top: 6px; }
.login-form .input { width: 100%; padding: 10px 12px; }
.login-form .btn-row { margin-top: 12px; }
.login-error { color: var(--danger); margin: 6px 0 0; }
.gate-progress { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.gate-progress p { margin: 0; }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spinner-turn .8s linear infinite; }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
.sub-h { font-size: 15px; margin: 20px 0 6px; }
.check-row { display: flex; align-items: center; gap: 8px; }
#sync-panel { scroll-margin-top: 84px; }
