/* ========== Tokens ========== */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1b1f2e;
  --muted: #646b80;
  --border: #e2e5ee;
  --primary: #4353e0;
  --primary-600: #3442c4;
  --primary-soft: #e8eafc;
  --accent: #ff8a3d;
  --danger: #d63c4a;
  --danger-soft: #fdecee;
  --success: #1f9d63;
  --success-soft: #e4f6ed;
  --warning: #c27c0e;
  --warning-soft: #fdf3e1;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131b; --surface: #191c27; --surface-2: #222634; --text: #e8eaf2; --muted: #9aa1b5;
    --border: #2c3142; --primary: #7381ff; --primary-600: #8b97ff; --primary-soft: #262b4a;
    --danger: #ff6b78; --danger-soft: #3a1f25; --success: #4fd197; --success-soft: #173326;
    --warning: #f0b252; --warning-soft: #3a2d15;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11131b; --surface: #191c27; --surface-2: #222634; --text: #e8eaf2; --muted: #9aa1b5;
  --border: #2c3142; --primary: #7381ff; --primary-600: #8b97ff; --primary-soft: #262b4a;
  --danger: #ff6b78; --danger-soft: #3a1f25; --success: #4fd197; --success-soft: #173326;
  --warning: #f0b252; --warning-soft: #3a2d15;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; font-size: 15px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ========== Buttons & forms ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: background .15s, transform .05s; text-decoration: none !important; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-icon { padding: 7px; width: 36px; height: 36px; }
.btn:disabled { opacity: .6; cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
.input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 70px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

/* ========== Landing ========== */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 24px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none !important; }
.logo-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.nav-links { display: flex; gap: 22px; margin-left: auto; }
.nav-links a { color: var(--muted); font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-cta { display: flex; gap: 8px; }
@media (max-width: 760px) { .nav-links { display: none; } .nav-cta { margin-left: auto; } .nav-cta .btn-ghost { display: none; } }

.hero { padding: 72px 0 56px; }
.hero .container { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
.badge { display: inline-block; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 13px; padding: 5px 12px; border-radius: 99px; margin-bottom: 16px; }
.hero h1 { font-size: clamp(32px, 5vw, 50px); letter-spacing: -.02em; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero-lead { font-size: 18px; color: var(--muted); max-width: 520px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 26px 0 16px; }
.hero-note { font-size: 14px; color: var(--muted); }
@media (max-width: 900px) { .hero .container { grid-template-columns: 1fr; } .hero { padding-top: 40px; } }

.mock { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 16px; }
.mock-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 700; }
.mock-dots { display: flex; gap: 6px; }
.mock-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mock-grid { display: grid; grid-template-columns: 38px repeat(5, 1fr); grid-auto-rows: 34px; gap: 4px; font-size: 11px; }
.mock-grid .d { text-align: center; color: var(--muted); font-weight: 600; align-self: center; }
.mock-grid .t { color: var(--muted); align-self: start; }
.mock-grid .c { border-radius: 7px; padding: 4px 6px; color: #fff; font-weight: 600; overflow: hidden; line-height: 1.25; }

.section { padding: 64px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { text-align: center; max-width: 620px; margin: 0 auto 40px; }
.section-title h2 { font-size: clamp(26px, 3.4vw, 34px); }
.section-title p { color: var(--muted); font-size: 17px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.feature-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.card h3 { font-size: 18px; }
.card p { color: var(--muted); margin: 0; }
.audience ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.audience li { margin-bottom: 6px; }
.steps { counter-reset: step; }
.step { position: relative; padding-top: 52px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: grid; place-items: center; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 10px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 10px 0 0; color: var(--muted); }
.cta-band { background: var(--primary); color: #fff; border-radius: 20px; padding: 44px 24px; text-align: center; }
.cta-band h2 { font-size: clamp(24px, 3vw, 32px); }
.cta-band p { opacity: .85; }
.cta-band .btn { background: #fff; color: #3442c4; }
.site-footer { padding: 28px 0; color: var(--muted); font-size: 14px; border-top: 1px solid var(--border); }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* ========== Auth pages ========== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.auth-card .logo { justify-content: center; margin-bottom: 18px; }
.auth-card h1 { font-size: 23px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }
.auth-card .btn-primary { width: 100%; margin-top: 4px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { text-align: center; padding: 8px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg input:checked + label { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg input:focus-visible + label { outline: 2px solid var(--primary); }

/* ========== App shell ========== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .logo { padding: 4px 8px 18px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; cursor: pointer; border: 0; background: none; font: inherit; text-align: left; width: 100%; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item svg { width: 20px; height: 20px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.user-chip .name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { font-size: 12px; color: var(--muted); }
.main { padding: 26px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 1024px) and (min-width: 761px) {
  .app { grid-template-columns: 210px 1fr; }
  .main { padding: 22px 20px 60px; }
}

/* ========== Dashboard ========== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 2px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.panel h2 { font-size: 17px; display: flex; justify-content: space-between; align-items: center; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.lesson { display: flex; gap: 14px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 10px; align-items: center; }
.lesson .bar { width: 5px; align-self: stretch; border-radius: 4px; flex: none; }
.lesson .time { font-weight: 700; font-size: 14px; min-width: 92px; }
.lesson .info { flex: 1; min-width: 0; }
.lesson .title { font-weight: 700; }
.lesson .meta { font-size: 13px; color: var(--muted); }
.lesson.now { border-color: var(--primary); background: var(--primary-soft); }
@media (max-width: 520px) {
  .lesson { display: grid; grid-template-columns: 5px 1fr auto; column-gap: 12px; row-gap: 2px; }
  .lesson .bar { grid-row: span 2; }
  .lesson .time { min-width: 0; grid-column: 2; font-size: 13px; color: var(--muted); }
  .lesson .info { grid-column: 2; }
  .lesson .pill { grid-column: 3; grid-row: 1; }
}
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill-now { background: var(--primary); color: #fff; }
.pill-thi { background: var(--danger-soft); color: var(--danger); }
.pill-kiem_tra { background: var(--warning-soft); color: var(--warning); }
.pill-bai_tap { background: var(--primary-soft); color: var(--primary); }
.pill-late { background: var(--danger); color: #fff; }

/* ========== Timetable ========== */
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-label { font-weight: 700; min-width: 190px; text-align: center; }
.tt-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tt { --hour: 64px; display: grid; grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); min-width: 840px; }
.tt-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 6px; text-align: center; font-weight: 700; font-size: 14px; z-index: 2; }
.tt-head small { display: block; font-weight: 500; color: var(--muted); }
.tt-head.today { color: var(--primary); }
.tt-head.today small { color: var(--primary); }
.tt-times { position: relative; border-right: 1px solid var(--border); }
.tt-times span { position: absolute; right: 8px; font-size: 12px; color: var(--muted); transform: translateY(-50%); }
.tt-col { position: relative; border-right: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px var(--hour)); cursor: copy; }
.tt-col:last-child { border-right: 0; }
.tt-col.today { background-color: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.tt-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.tt-now::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.tt-entry {
  position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 6px 8px; color: #fff;
  font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  border: 0; text-align: left; font-family: inherit;
}
.tt-entry:hover { filter: brightness(1.06); z-index: 4; }
.tt-entry b { display: block; font-size: 13px; }
.tt-entry .sm { opacity: .9; }

/* ========== Lists (subjects, tasks) ========== */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.subject-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; border-top: 5px solid var(--c, var(--primary)); }
.subject-card h3 { font-size: 17px; margin-bottom: 4px; }
.subject-card .meta { font-size: 14px; color: var(--muted); margin-bottom: 2px; }
.subject-card .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.task input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; cursor: pointer; }
.task .info { flex: 1; min-width: 0; }
.task .title { font-weight: 600; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ========== Modal & toast ========== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 30, .45); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 12px 20px; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; padding: 6px 20px 20px; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors label { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; position: relative; }
.colors input { position: absolute; opacity: 0; }
.colors input:checked + span { position: absolute; inset: -4px; border: 2px solid var(--text); border-radius: 50%; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 500; z-index: 200; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* ========== Print (in thời khóa biểu) ========== */
@media print {
  .sidebar, .page-head .actions, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .tt-scroll { overflow: visible; border: 0; }
  .tt { min-width: 0; }
  .tt-entry { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================================
   Bổ sung: học kỳ, nghỉ/học bù, điểm danh, điểm số, lớp học, giờ rảnh,
   cài đặt, ngoại tuyến, xem theo ngày trên điện thoại
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.code-big { font-size: 15px; font-weight: 700; letter-spacing: .06em; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row a { font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
.input.input-sm { padding: 6px 10px; font-size: 14px; width: auto; }
select.input.semester-select { width: calc(100% - 8px); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Sidebar dài: danh sách cuộn được */
.sidebar { overflow: hidden; }
.nav-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; flex: 1; margin-top: 6px; }
.semester-select { margin: 0 4px 6px; width: calc(100% - 8px); font-weight: 600; }
.sidebar-foot { margin-top: 8px; }
.sidebar-foot .nav-item { padding: 8px 12px; font-size: 14px; }

.offline-bar { background: var(--warning-soft); color: var(--warning); text-align: center; font-weight: 600; font-size: 14px; padding: 8px 16px; position: sticky; top: 0; z-index: 60; }

/* Hiện/ẩn theo kích thước màn hình */
.mobile-only { display: none; }
@media (max-width: 760px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
}

/* Xem theo ngày trên điện thoại */
.day-tabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px; }
.day-tabs button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); padding: 7px 0; border-radius: 9px; cursor: pointer; }
.day-tabs button small { display: block; font-size: 16px; font-weight: 700; color: var(--text); }
.day-tabs button.today small { color: var(--primary); }
.day-tabs button.active { background: var(--primary); color: #fff; }
.day-tabs button.active small { color: #fff; }
.day-list { touch-action: pan-y; min-height: 120px; }

/* Buổi học dạng danh sách (bấm được) */
button.lesson { width: 100%; background: var(--surface); font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.lesson:hover { border-color: var(--primary); }
.lesson .info { display: flex; flex-direction: column; }
.lesson .tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.lesson.cancelled { opacity: .6; }
.lesson.cancelled .title { text-decoration: line-through; }
@media (max-width: 520px) { .lesson .tags { grid-column: 3; grid-row: 1 / span 2; align-self: center; } }

.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,.28); color: inherit; line-height: 1.5; }
.lesson .tag { background: var(--surface-2); color: var(--muted); }
.tag-cancel { background: #fff !important; color: var(--danger) !important; }
.tag-absent { background: var(--danger) !important; color: #fff !important; }
.tag-excused { background: var(--warning-soft) !important; color: var(--warning) !important; }
.tag-late { outline: 1px solid currentColor; }
.lesson .tag-late { color: var(--warning) !important; }

.tt-col.clickable { cursor: copy; }
.tt-col:not(.clickable) { cursor: default; }
.tt-entry { display: block; }
.tt-entry .tags { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 2px; }
.tt-entry.cancelled { opacity: .5; background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.tt-entry.cancelled b { text-decoration: line-through; }
.tt-entry.makeup { outline: 2px dashed #fff; outline-offset: -4px; }
div.tt-entry { cursor: default; }

/* Bảng thao tác một buổi học */
.sheet-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sheet-color { height: 5px; border-radius: 99px; margin: -4px 0 12px; }
.sheet-info { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 14px; }
.sheet-label { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions .btn { justify-content: flex-start; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 99px; cursor: pointer; }
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-absent.active { background: var(--danger); border-color: var(--danger); }
.chip-excused.active { background: var(--warning); border-color: var(--warning); }
.chip-present.active { background: var(--success); border-color: var(--success); }

.modal-wide { max-width: 760px; }

/* Bảng */
.table-wrap { overflow-x: auto; }
.panel-flush { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.panel-flush .table td:first-child { min-width: 150px; }
.table .row-error td { background: var(--danger-soft); }

/* Điểm số */
.grade-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.grade-chip { font-size: 12px; background: var(--surface-2); border-radius: 7px; padding: 2px 8px; white-space: nowrap; }
.grade-chip small { color: var(--muted); }
.grade-chip.empty b { color: var(--muted); font-weight: 500; }
.grade-letter { display: inline-block; min-width: 30px; text-align: center; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }
.g-A { background: var(--success-soft); color: var(--success); }
.g-Bp, .g-B { background: var(--primary-soft); color: var(--primary); }
.g-Cp, .g-C { background: var(--warning-soft); color: var(--warning); }
.g-Dp, .g-D, .g-F { background: var(--danger-soft); color: var(--danger); }
.grade-row { display: grid; grid-template-columns: 1fr 90px 80px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.grade-row-head { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.grade-result { margin-top: 14px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.grade-result:empty { display: none; }
@media (max-width: 520px) { .grade-row { grid-template-columns: 1fr 70px 64px 36px; gap: 6px; } }

/* Chuyên cần */
.att-mini { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.att-mini span { white-space: nowrap; }
.bar-track { flex: 1; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 99px; }
.bar-fill.ok { background: var(--success); }
.bar-fill.warn { background: var(--warning); }
.bar-fill.bad { background: var(--danger); }
.lvl-ok { color: var(--success); }
.lvl-warn { color: var(--warning); }
.lvl-bad { color: var(--danger); }

/* Danh sách & form gọn */
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-row:last-of-type { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.copy-field { display: flex; gap: 8px; margin-bottom: 10px; }
.copy-field .input { min-width: 0; }

/* Giờ rảnh chung */
.free-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .free-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .free-grid { grid-template-columns: 1fr; } }
.free-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.free-head { font-weight: 700; margin-bottom: 8px; }
.free-head small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.free-track { position: relative; height: 8px; border-radius: 99px; background: var(--danger-soft); margin-bottom: 10px; overflow: hidden; }
.free-track span { position: absolute; top: 0; bottom: 0; background: var(--success); }
.free-slot { font-weight: 600; font-size: 14px; color: var(--success); padding: 3px 0; }

/* Cài đặt */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .settings-grid { grid-template-columns: 1fr; } }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; position: relative; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 42px; height: 24px; border-radius: 99px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.seg-3 { grid-template-columns: repeat(3, 1fr); }
.howto { margin: 8px 0 12px; font-size: 14px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.howto ol { padding-left: 20px; margin: 8px 0 0; color: var(--muted); }
.howto li { margin-bottom: 6px; }

.share-main { padding-top: 26px; padding-bottom: 50px; }
.page-head h1 + .muted { margin-top: 2px; }

@media print {
  .mobile-only, .offline-bar { display: none !important; }
  .desktop-only { display: block !important; }
}

/* =====================================================================
   Điều hướng mới: tab con, thẻ "Tiếp theo", giao diện điện thoại
   (thanh trên, thanh dưới, nút thêm nhanh, bảng trượt, bảng -> thẻ)
   ===================================================================== */
.topbar, .bottom-nav, .fab { display: none; }

/* Tab con trong một nhóm (Lịch, Học tập) */
.subtabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 18px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { padding: 7px 16px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; text-decoration: none; }
.subtabs a:hover { color: var(--text); }
.subtabs a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Thẻ buổi học tiếp theo */
.next-card {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; font: inherit; cursor: pointer;
  border: 0; border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: 0 6px 20px color-mix(in srgb, var(--c) 35%, transparent);
}
.next-label { font-size: 13px; font-weight: 600; opacity: .9; }
.next-title { font-size: 21px; font-weight: 800; }
.next-meta { font-size: 14px; opacity: .92; }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--primary); }

/* Danh sách trong bảng trượt (tài khoản, học kỳ, thao tác) */
.sheet-list { display: flex; flex-direction: column; gap: 4px; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; font: inherit; color: var(--text); font-weight: 600; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; min-height: 48px; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.active { background: var(--primary-soft); color: var(--primary); }
.sheet-item small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.sheet-ico { width: 24px; text-align: center; flex: none; }

/* Lưới thêm nhanh */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-item { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 16px 6px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; text-align: center; }
.quick-item:hover { border-color: var(--primary); }
.quick-ico { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.quick-ico svg { width: 22px; height: 22px; }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

@media (max-width: 760px) {
  body { -webkit-tap-highlight-color: transparent; }
  .sidebar { display: none; }
  .app { grid-template-columns: 1fr; min-height: auto; }
  .offline-bar { position: static; }

  /* Thanh trên */
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    min-height: 56px; padding: env(safe-area-inset-top) 12px 0 16px;
    background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-title { flex: 1; min-width: 0; font-weight: 800; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sem-chip { flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 11px; border-radius: 99px; cursor: pointer; }
  .avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
  .avatar-btn .avatar { width: 34px; height: 34px; font-size: 14px; }

  /* Thanh dưới */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav button { border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 8px; min-height: 60px; cursor: pointer; }
  .bottom-nav .ico { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 99px; transition: background .15s; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav button.active { color: var(--primary); }
  .bottom-nav button.active .ico { background: var(--primary-soft); }

  /* Nút thêm nhanh */
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; z-index: 41;
    bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px; border: 0;
    background: var(--primary); color: #fff; cursor: pointer; box-shadow: 0 8px 22px color-mix(in srgb, var(--primary) 45%, transparent);
  }
  .fab.hidden { display: none; }

  .main { padding: 14px 16px calc(150px + env(safe-area-inset-bottom)); }
  .subtabs { display: flex; margin-bottom: 14px; }
  .subtabs.hidden { display: none; }
  .subtabs a { flex: 1 1 auto; text-align: center; padding: 8px 10px; }
  .toast { bottom: calc(146px + env(safe-area-inset-bottom)); }

  /* Đầu trang gọn: tiêu đề đã nằm trên thanh trên, nút thêm chuyển vào nút "+", nút phụ vào "⋯" */
  .page-head { margin-bottom: 12px; gap: 8px; }
  .page-head h1:not(.greeting) { display: none; }
  .page-head h1.greeting { font-size: 21px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn-primary, [data-more] { display: none !important; }
  .page-head .actions:not(:has(> :not(.btn-primary):not([data-more]):not(.desktop-only))) { display: none; }
  .week-nav { flex: 1; justify-content: space-between; }
  .week-label { min-width: 0; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; }

  /* Thống kê một hàng */
  .stats, .stats-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .stat { padding: 10px 8px; text-align: center; border-radius: 12px; }
  .stat .label { font-size: 11px; line-height: 1.25; }
  .stat .value { font-size: 19px; }
  .stat .value .pill { display: block; width: fit-content; margin: 2px auto 0; font-size: 10px; padding: 1px 6px; }
  .two-col { gap: 14px; }
  .panel { padding: 14px; }

  /* Hộp thoại -> bảng trượt từ dưới lên */
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal {
    max-width: none; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0;
    animation: sheet-up .22s ease-out; transition: transform .2s; padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-wide { max-width: none; }
  .modal-head { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-top: 24px; touch-action: none; }
  .modal-head::before { content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 40px; height: 5px; border-radius: 99px; background: var(--border); }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding-top: 12px; padding-bottom: 14px; }
  .modal-foot .right .btn { min-width: 88px; }
  .input, select.input { min-height: 44px; font-size: 16px; } /* 16px: iOS không tự phóng to khi nhập */
  .btn { min-height: 40px; }

  /* Bảng -> thẻ */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 10px; padding: 14px; border-bottom: 1px solid var(--border); }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { display: block; padding: 0; border: 0; text-align: left !important; min-width: 0 !important; white-space: normal !important; }
  .table-cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .table-cards td:first-child { grid-column: 1 / -1; font-size: 15px; display: block; }
  .table-cards td[data-full] { grid-column: 1 / -1; order: 10; }
  .table-cards td[data-full]:last-child { order: 11; }
  .table-cards td[data-span="3"] { grid-column: span 3; }
  .table-cards td[data-full]:last-child:not([data-label]) .btn { width: 100%; }
  .table-cards .muted.small { font-size: 12px; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .modal { animation: none; transition: none; }
}
@media print {
  .topbar, .bottom-nav, .fab, .subtabs { display: none !important; }
}

/* =====================================================================
   Tài khoản: ghi nhớ đăng nhập, Google, ảnh đại diện, hồ sơ, khung tiết, mục tiêu
   ===================================================================== */
.check { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0 16px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.oauth { margin-bottom: 4px; }
.btn-google { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-google:hover { background: var(--surface-2); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.verify-bar { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; background: var(--primary-soft); color: var(--text); font-size: 14px; padding: 6px 16px; }
.pill-ok { background: var(--success-soft); color: var(--success); margin-left: 6px; }
.pill-kiem_tra { margin-left: 6px; }
.sub-title { font-size: 14px; font-weight: 700; margin: 18px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sub-form { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin: 4px 0 10px; }
img.avatar { object-fit: cover; display: block; }
.avatar { flex: none; }
.avatar-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.member { display: flex; align-items: center; gap: 10px; min-width: 0; }
.settings-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.period-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.period-row .input { min-width: 0; padding-left: 8px; padding-right: 8px; }
.period-no { font-weight: 600; font-size: 14px; color: var(--muted); }
.quick-periods { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; font-size: 14px; color: var(--text); }
.quick-periods label { display: flex; align-items: center; gap: 6px; }
.quick-periods input[type=number] { width: 70px; }
.goal-panel h2 { gap: 10px; }
.goal-grid { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.goal-big { font-size: 30px; font-weight: 800; line-height: 1.1; }
.goal-panel { margin-bottom: 18px; }
@media (max-width: 760px) {
  .verify-bar { justify-content: space-between; font-size: 13px; }
  .period-row { grid-template-columns: 50px minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 6px; }
  .goal-grid { gap: 14px; }
}

/* =====================================================================
   Thời khóa biểu: đầu trang gọn, chú thích lọc môn, hàng hạn bài tập, trục theo tiết,
   kéo thả, xem nhanh, chọn tuần, popover/menu
   ===================================================================== */
.week-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.week-head .spacer { flex: 1; }
.week-pick { display: flex; flex-direction: column; align-items: center; line-height: 1.2; border: 0; background: none; font: inherit; color: var(--text); padding: 4px 12px; border-radius: var(--radius-sm); cursor: pointer; min-width: 200px; }
.week-pick:hover, .week-pick[aria-expanded="true"] { background: var(--surface-2); }
.week-pick b { font-size: 16px; }
.week-pick small { color: var(--muted); font-size: 12px; font-weight: 500; }

.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.legend-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; cursor: pointer; user-select: none; }
.legend-chip:hover { border-color: var(--primary); }
.legend-chip.off { color: var(--muted); background: transparent; text-decoration: line-through; }
.legend-chip.off .dot { opacity: .3; }
.legend-all { color: var(--primary); border-style: dashed; }
.week-tip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 6px 10px; margin: 0 0 12px; }
.week-foot { margin: 8px 0 0; }

/* Popover & menu */
.popover { position: absolute; z-index: 120; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; min-width: 200px; }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 8px; border: 0; background: none; font: inherit; font-size: 14px; color: var(--text); text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-check { width: 16px; color: var(--primary); font-weight: 800; }

/* Chọn tuần */
.week-picker { padding: 4px; width: 300px; }
.wp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.wp-row { display: grid; grid-template-columns: 38px repeat(7, 1fr); align-items: center; width: 100%; border: 0; background: none; font: inherit; font-size: 13px; color: var(--text); padding: 5px 0; border-radius: 8px; cursor: pointer; text-align: center; }
button.wp-row:hover { background: var(--surface-2); }
.wp-row.sel { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.wp-row .out { color: var(--muted); opacity: .55; }
.wp-row .today { color: #fff; background: var(--primary); border-radius: 99px; width: 24px; height: 24px; line-height: 24px; margin: 0 auto; font-weight: 700; }
.wp-wk { font-size: 11px; color: var(--muted); font-weight: 600; }
.wp-days { cursor: default; font-weight: 600; color: var(--muted); font-size: 12px; }
.wp-foot { display: flex; justify-content: center; margin-top: 4px; }

/* Hàng hạn bài tập / thi */
.tt { user-select: none; }
.tt-allday-label { display: flex; align-items: center; justify-content: flex-end; padding: 6px 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.tt-allday { display: flex; flex-direction: column; gap: 3px; padding: 5px 4px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 34px; min-width: 0; }
.tt-allday:last-child { border-right: 0; }
.tt-task { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; border: 0; border-left: 3px solid var(--primary); background: var(--primary-soft); color: var(--text); font: inherit; font-size: 12px; font-weight: 600; padding: 3px 6px; border-radius: 6px; cursor: pointer; text-align: left; }
.tt-task-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tt-task small { color: var(--muted); font-weight: 500; flex: none; }
.tt-task.t-thi { background: var(--danger-soft); border-left-color: var(--danger); }
.tt-task.t-kiem_tra { background: var(--warning-soft); border-left-color: var(--warning); }
.tt-task.done { opacity: .55; text-decoration: line-through; }
.tt-task:hover { filter: brightness(.97); }
.day-tasks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.day-tasks .tt-task { font-size: 14px; padding: 8px 10px; }

/* Trục theo tiết */
.tt-times.by-period .p-label { transform: none; right: 6px; left: 4px; text-align: right; line-height: 1.15; font-size: 11px; }
.tt-times.by-period .p-label b { display: block; color: var(--text); font-size: 11px; }
.tt-band { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--primary) 4%, transparent); pointer-events: none; }
.tt-session { position: absolute; left: 0; right: 0; border-top: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent); pointer-events: none; }

/* Kéo thả / đổi độ dài / kéo chọn */
.tt-entry.editable { cursor: grab; }
.tt-entry.dragging { cursor: grabbing; z-index: 6; opacity: .9; box-shadow: 0 10px 24px rgba(0,0,0,.28); transition: none; }
.tt-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.tt-resize::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 3px; margin-left: -11px; border-radius: 99px; background: rgba(255,255,255,.55); opacity: 0; transition: opacity .15s; }
.tt-entry.editable:hover .tt-resize::after { opacity: 1; }
.tt-select { position: absolute; left: 4px; right: 4px; z-index: 5; border-radius: 8px; background: color-mix(in srgb, var(--primary) 22%, transparent); border: 2px dashed var(--primary); color: var(--primary); font-size: 12px; font-weight: 700; padding: 4px 6px; pointer-events: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* Xem nhanh */
.tt-tip { position: absolute; z-index: 130; max-width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.2); padding: 12px 14px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; pointer-events: none; }
.tt-tip b { color: var(--text); font-size: 15px; margin-bottom: 2px; }
.tt-tip-bar { height: 4px; border-radius: 99px; margin-bottom: 6px; }
.tt-tip-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 12px; }

@media (max-width: 760px) {
  .week-head .week-nav { flex: 1; }
  .week-head .btn-primary { display: none; }
  .week-pick { flex: 1; min-width: 0; }
  .legend { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
  .legend::-webkit-scrollbar { display: none; }
  .legend-chip { flex: none; }
}
@media print {
  .week-head, .legend, .week-tip, .week-foot { display: none !important; }
}

/* =====================================================================
   Quản trị: thanh "đang xem thay", thông báo hệ thống, trang /admin, biểu đồ
   ===================================================================== */
.imp-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; background: var(--danger); color: #fff; font-size: 14px; padding: 8px 16px; position: sticky; top: 0; z-index: 70; }
.imp-bar .btn { background: #fff; color: var(--danger); }
.ann-bar { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 16px; font-size: 14px; font-weight: 500; background: var(--primary-soft); color: var(--text); }
.ann-bar a { font-weight: 700; }
.ann-warning { background: var(--warning-soft); }
.ann-success { background: var(--success-soft); }

.admin-tabs { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pager span { margin-right: auto; }
.row-link { cursor: pointer; }
.row-link:hover td, .row-link:focus-visible td { background: var(--surface-2); }
.user-table td:first-child { min-width: 260px; }
.back-link { display: inline-block; margin-bottom: 12px; font-weight: 600; }
.user-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.user-hero h1 { font-size: 22px; margin: 0 0 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.info-list { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.facts > div { display: flex; flex-direction: column; gap: 2px; }
.facts b { font-size: 20px; }
.facts.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 8px; }
.facts.compact b { font-size: 17px; }
.action-grid { display: flex; flex-direction: column; gap: 8px; }
.action-grid .btn { justify-content: flex-start; }
.danger-zone { margin-top: 18px; padding: 14px; border: 1px solid var(--danger-soft); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger-soft) 40%, transparent); }
.danger-zone p { margin: 4px 0 10px; }
.log-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.ann-item { margin-bottom: 12px; padding: 0; overflow: hidden; }
.ann-item .ann-bar { justify-content: flex-start; }
.ann-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; }
.ann-meta .spacer { flex: 1; }

/* Ô số liệu (KPI) */
.kpi .stat .value { font-size: 28px; }
.value-sub { font-size: 16px; font-weight: 600; }
.delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }

/* Biểu đồ: dữ liệu dùng màu --primary, chữ dùng màu chữ, lưới mảnh và chìm */
.charts { margin-bottom: 0; }
.chart-box { position: relative; color: var(--primary); }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .area { fill: currentColor; fill-opacity: .1; }
.chart .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end, .chart .hover-dot { fill: currentColor; stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 700; font-family: var(--font); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hit { cursor: crosshair; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; padding: 4px 10px; font-size: 13px; white-space: nowrap; color: var(--text); }
.chart-table { margin-top: 8px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.chart-table .table-wrap { max-height: 220px; overflow-y: auto; margin-top: 6px; }

@media (max-width: 1000px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .admin-body .main { padding-bottom: 40px; }
  .admin-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tabs a { flex: none; padding: 8px 14px; border-radius: 99px; font-weight: 600; font-size: 14px; color: var(--muted); background: var(--surface-2); text-decoration: none; }
  .admin-tabs a.active { background: var(--primary); color: #fff; }
  .admin-body .page-head h1 { display: block !important; }
  .admin-body .page-head .actions .btn-primary { display: inline-flex !important; }
  .info-list { grid-template-columns: 1fr; gap: 2px; }
  .info-list dd { margin-bottom: 8px; }
  .user-table td:first-child { min-width: 0; }
  .filters input[type=search] { min-width: 0; flex-basis: 100%; }
}

/* =====================================================================
   Blog công khai + trình soạn bài trong quản trị
   ===================================================================== */
.blog-main { padding-top: 36px; padding-bottom: 60px; }
.blog-head { margin-bottom: 26px; }
.blog-head h1 { font-size: clamp(28px, 4vw, 38px); margin-bottom: 6px; }
.blog-search { margin: 16px 0 12px; max-width: 420px; }
.blog-cats { display: flex; gap: 8px; flex-wrap: wrap; }
.blog-cats a { padding: 6px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; }
.blog-cats a span { color: var(--muted); font-weight: 500; }
.blog-cats a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.blog-cats a.active span { color: rgba(255,255,255,.8); }
.blog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 900px) { .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .blog-grid { grid-template-columns: 1fr; } }
.blog-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.blog-cover img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.blog-card-body { padding: 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.blog-card h2 { font-size: 18px; margin: 0; line-height: 1.35; }
.blog-card h2 a { color: var(--text); }
.blog-card p { color: var(--muted); margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.blog-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.blog-meta { color: var(--muted); font-size: 13px; margin-top: auto; }
.blog-pager { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.blog-article { max-width: 760px; margin: 0 auto; }
.blog-article h1 { font-size: clamp(28px, 4.2vw, 40px); letter-spacing: -.01em; margin-bottom: 10px; }
.blog-article header .blog-meta { margin-bottom: 22px; }
.blog-hero { width: 100%; border-radius: var(--radius); margin-bottom: 28px; aspect-ratio: 1200 / 630; object-fit: cover; }
.prose { font-size: var(--prose-size, 18px); line-height: 1.75; overflow-wrap: anywhere; }
.prose h2 { font-size: 1.42em; line-height: 1.3; margin: 2em 0 .6em; }
.prose h3 { font-size: 1.14em; line-height: 1.35; margin: 1.5em 0 .5em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 18px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin-bottom: 6px; }
.prose img { border-radius: 10px; margin: 8px auto; height: auto; }
.prose blockquote { border-left: 4px solid var(--primary); padding: 4px 18px; color: var(--muted); background: var(--surface); border-radius: 0 8px 8px 0; }
.prose pre { background: var(--surface-2); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 14px; }
.prose table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.prose iframe { width: 100%; aspect-ratio: 16/9; height: auto; border: 0; border-radius: 10px; }
.blog-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.blog-cta { max-width: 760px; margin: 36px auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--primary-soft); border-radius: var(--radius); padding: 20px 22px; }
.blog-cta p { margin: 4px 0 0; }
.blog-related { margin-top: 40px; }
.blog-related h2 { font-size: 22px; margin-bottom: 16px; }

.posts-layout { grid-template-columns: 1fr 300px; align-items: start; }
@media (max-width: 1000px) { .posts-layout { grid-template-columns: 1fr; } }
.editor-cols { grid-template-columns: 1fr 340px; align-items: start; }
@media (max-width: 1100px) { .editor-cols { grid-template-columns: 1fr; } }
.content-input { min-height: 420px; font-size: 13px; line-height: 1.5; }
.preview { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 18px; margin-top: 10px; }
.preview-banner { margin-bottom: 18px; }

/* Danh sách bài: trạng thái, chọn nhiều, sắp xếp theo cột */
.filters select { max-width: 100%; min-width: 0; }
.status-tabs { width: fit-content; max-width: 100%; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.status-tabs button { white-space: nowrap; }
.status-tabs .muted { font-weight: 500; margin-left: 2px; }
.row-alert { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-alert .btn { flex: none; }
.bulk-bar { position: sticky; top: 8px; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--primary); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.bulk-bar b { margin-right: 4px; font-size: 14px; }
.th-sort { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.th-sort:hover { color: var(--text); }
th.num .th-sort { flex-direction: row-reverse; }
.table th .row-check { margin-right: 10px; vertical-align: middle; }
.row-check { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex: none; }
.post-cell { display: flex; align-items: flex-start; gap: 10px; }
.post-cell .row-check { margin-top: 2px; }
.post-cell-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-menu { flex: none; margin: -4px -6px -4px 0; width: 32px; height: 32px; color: var(--muted); }
.pill-warn { background: var(--warning-soft); color: var(--warning); cursor: help; }
.post-table td:nth-child(3) .pill { margin-left: 0; }

/* Chuyên mục: kéo thả đổi thứ tự */
.cat-row { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 6px 8px; }
.cat-main { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.cat-actions { grid-column: 2; display: flex; gap: 4px; flex-wrap: wrap; }
.cat-row:not([draggable]) .cat-main { grid-column: 1 / -1; }
.cat-actions .btn-icon { width: 30px; height: 30px; padding: 0; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 18px; line-height: 1; user-select: none; }
.cat-row.dragging { opacity: .45; }
@media (max-width: 760px) { .drag-handle { display: none; } }

/* Trình soạn bài: chuyển hướng, kiểm tra SEO */
.redirects { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.redirect-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.redirect-row code { overflow-wrap: anywhere; }
.seo-check { list-style: none; padding: 0; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.seo-check li { display: flex; gap: 8px; align-items: baseline; }
.seo-check li span { flex: none; width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 800; }
.seo-check .ok span { background: var(--success-soft); color: var(--success); }
.seo-check .warn span { background: var(--warning-soft); color: var(--warning); }
.rev-title { font-size: 20px; margin: 0 0 6px; }
.fb-sum { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.fb-bar { height: 6px; border-radius: 99px; background: var(--danger-soft); overflow: hidden; margin: 8px 0 10px; }
.fb-bar span { display: block; height: 100%; background: var(--success); }
.fb-notes { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.fb-notes li { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); overflow-wrap: anywhere; }

/* Thống kê & kiểm tra SEO */
.top-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.top-list li { padding-left: 4px; }
.top-list li::marker { color: var(--muted); }
.top-list a { display: inline; }
.top-list b { float: right; margin-left: 10px; }
.audit-sec { margin-top: 18px; }
.audit-sec h2 { margin-bottom: 4px; }
.audit-sec > .muted.small { margin: 0 0 12px; }
.ok-line { color: var(--success); font-weight: 600; margin: 0; }
code.break { overflow-wrap: anywhere; font-size: 12px; }

/* =====================================================================
   Mẫu & xuất ảnh thời khóa biểu
   ===================================================================== */
.poster-page { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.poster-controls { position: sticky; top: 12px; }
.poster-controls .check { margin: 0 0 8px; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-opt { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.theme-opt input { position: absolute; opacity: 0; }
.theme-opt.on { border-color: var(--primary); background: var(--primary-soft); }
.theme-opt:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-sw { display: flex; height: 26px; border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.theme-sw i { flex: 1; }
.poster-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.poster-toolbar .spacer { flex: 1; }
.poster-stage-wrap { position: relative; overflow: hidden; border-radius: 12px; background: repeating-conic-gradient(var(--surface-2) 0 25%, transparent 0 50%) 0 0 / 20px 20px; }
.poster-stage { transform-origin: top left; box-shadow: 0 10px 30px rgba(0,0,0,.18); position: absolute; top: 0; left: 0; }
.poster-loading { padding: 40px; text-align: center; }
#posterPrint { position: fixed; left: -100000px; top: 0; }
.poster-preview { min-width: 0; }
.poster-stage-wrap { width: 100%; }
@media (max-width: 900px) {
  .poster-page { grid-template-columns: minmax(0, 1fr); }
  .poster-controls { position: static; order: 2; }
  .poster-preview { order: 1; }
}

/* ---------- Khung poster (kích thước cố định theo khổ, dùng chung mọi mẫu) ---------- */
.poster { position: relative; overflow: hidden; box-sizing: border-box; display: flex; flex-direction: column; gap: calc(var(--pad) * .45);
  padding: var(--pad); font-family: var(--pfont); line-height: 1.2; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.poster *, .poster *::before, .poster *::after { box-sizing: border-box; }
.sz-a4l { --fs: 14px; --title: 44px; --pad: 30px; }
.sz-a4p { --fs: 14px; --title: 46px; --pad: 32px; }
.sz-phone { --fs: 12.5px; --title: 38px; --pad: 20px; padding-top: 175px; }   /* chừa chỗ cho đồng hồ màn hình khóa */
.sz-square { --fs: 11px; --title: 28px; --pad: 18px; }
.pt-head { text-align: center; position: relative; z-index: 1; }
.pt-title { font-size: var(--title); margin: 0; line-height: 1.1; font-weight: 700; }
.pt-sub { font-size: calc(var(--fs) * 1.15); margin-top: 6px; opacity: .85; }
.pt-week { font-size: calc(var(--fs) * .95); margin-top: 4px; opacity: .7; }
.pt-body { flex: 1; min-height: 0; display: flex; position: relative; z-index: 1; }
.pt-foot { text-align: center; font-size: calc(var(--fs) * .85); opacity: .55; letter-spacing: .04em; position: relative; z-index: 1; }
.pt-sticker { position: absolute; z-index: 0; font-size: calc(var(--title) * .9); line-height: 1; pointer-events: none; }
.pt-sticker.s0 { top: calc(var(--pad) * .4); left: calc(var(--pad) * .5); transform: rotate(-18deg); }
.pt-sticker.s1 { top: calc(var(--pad) * .4); right: calc(var(--pad) * .5); transform: rotate(12deg); }
.pt-sticker.s2 { bottom: calc(var(--pad) * .3); left: calc(var(--pad) * .5); transform: rotate(-8deg); }
.pt-sticker.s3 { bottom: calc(var(--pad) * .3); right: calc(var(--pad) * .5); transform: rotate(10deg); }
.pt-sticker.s4, .pt-sticker.s5 { font-size: calc(var(--title) * .6); }
.pt-sticker.s4 { top: calc(var(--pad) + var(--title) * .1); left: 26%; }
.pt-sticker.s5 { top: calc(var(--pad) + var(--title) * .1); right: 26%; }
.sz-phone .pt-sticker.s0, .sz-phone .pt-sticker.s1 { top: 120px; }
.sz-phone .pt-sticker.s4, .sz-phone .pt-sticker.s5 { top: 186px; left: auto; right: auto; }
.sz-phone .pt-sticker.s4 { left: 8%; }
.sz-phone .pt-sticker.s5 { right: 8%; }

/* Bảng tiết */
.pt-table { width: 100%; height: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 4px; font-size: var(--fs); }
.pt-table th { font-weight: 700; }
.pt-corner { width: 70px; font-size: calc(var(--fs) * .9); }
.sz-phone .pt-corner, .sz-square .pt-corner { width: 52px; }
.pt-day { padding: 6px 2px; text-align: center; font-size: calc(var(--fs) * 1.05); white-space: nowrap; overflow: hidden; }
.pt-sec { width: 26px; padding: 0; }
.pt-sec span { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; letter-spacing: .12em; text-transform: uppercase; font-size: calc(var(--fs) * .85); }
.pt-period { text-align: center; font-size: calc(var(--fs) * 1.05); }
.pt-period small { display: block; font-weight: 400; font-size: calc(var(--fs) * .72); opacity: .7; }
.pt-cell { position: relative; padding: 0; }
.pt-cell .pt-lesson { position: absolute; inset: 1px; }
.pt-cell:not(.has) .pt-lesson { position: static; margin-bottom: 3px; padding: 3px 5px; }
.pt-lesson { padding: 4px 6px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.pt-name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.pt-emoji { margin-right: 3px; }
.pt-meta { display: block; font-size: .82em; opacity: .8; margin-top: 2px; overflow-wrap: anywhere; }

/* Thẻ theo ngày */
.pt-cards { display: grid; gap: calc(var(--pad) * .5); width: 100%; grid-auto-rows: 1fr; }
.sz-a4l .pt-cards { grid-template-columns: repeat(3, 1fr); }
.sz-a4l .pt-cards.n7 { grid-template-columns: repeat(4, 1fr); }
.sz-a4p .pt-cards, .sz-phone .pt-cards { grid-template-columns: repeat(2, 1fr); }
.sz-square .pt-cards { grid-template-columns: repeat(3, 1fr); }
.pt-card { display: flex; flex-direction: column; gap: 5px; padding: 10px; overflow: hidden; min-height: 0; font-size: var(--fs); }
.pt-card-head { text-align: center; font-weight: 700; font-size: calc(var(--fs) * 1.3); margin-bottom: 2px; }
.pt-item { display: flex; gap: 6px; align-items: baseline; padding: 5px 7px; }
.pt-time { font-weight: 700; font-size: .85em; white-space: nowrap; opacity: .85; }
.pt-item-body { min-width: 0; }
.pt-item .pt-name { display: inline; }
.pt-item .pt-meta { display: inline; margin-left: 4px; }
.pt-empty { flex: 1; display: grid; place-items: center; opacity: .5; }

/* ---------- Mẫu: Vẽ tay ---------- */
.t-vetay { background-color: #fffdf5; color: #2b2b2b;
  background-image: linear-gradient(#efe8d4 1px, transparent 1px), linear-gradient(90deg, #efe8d4 1px, transparent 1px); background-size: 22px 22px; }
.t-vetay .pt-title { text-decoration: underline wavy #f06292; text-decoration-thickness: 3px; text-underline-offset: 10px; letter-spacing: .03em; }
.t-vetay .pt-sub { margin-top: 18px; }
.t-vetay .pt-day { background: var(--tint); border: 2px dashed #333; border-radius: 12px 16px 10px 14px; }
.t-vetay .pt-lesson { border: 2px dashed rgba(0,0,0,.5); border-radius: 12px 7px 13px 8px; }
.t-vetay .pt-cell:not(.has) { border: 1.5px dashed rgba(0,0,0,.12); border-radius: 10px; }
.t-vetay .pt-card { background: var(--tint); border: 2.5px dashed #333; border-radius: 18px 12px 20px 10px; transform: rotate(var(--tilt)); }
.t-vetay .pt-item { border: 1.5px dashed rgba(0,0,0,.4); border-radius: 10px 6px 11px 7px; }

/* ---------- Mẫu: Pastel ---------- */
.t-pastel { background: linear-gradient(160deg, #fff3f8 0%, #f1f6ff 55%, #f6efff 100%); color: #4a3b52; }
.t-pastel .pt-title { color: #e2558a; }
.t-pastel .pt-sub { color: #8a6f96; opacity: 1; }
.t-pastel .pt-day { background: var(--tint); border-radius: 999px; color: #5b4566; }
.t-pastel .pt-lesson { border-radius: 14px; border-left: 4px solid var(--edge); box-shadow: 0 2px 6px rgba(120, 80, 140, .12); }
.t-pastel .pt-cell:not(.has) { background: rgba(255,255,255,.55); border-radius: 14px; }
.t-pastel .pt-card { background: rgba(255,255,255,.85); border-radius: 22px; box-shadow: 0 6px 18px rgba(120, 80, 140, .12); }
.t-pastel .pt-card-head { background: var(--tint); border-radius: 999px; padding: 4px; color: #5b4566; }
.t-pastel .pt-item { border-radius: 12px; border-left: 4px solid var(--edge); }

/* ---------- Mẫu: Bảng phấn ---------- */
.t-bangphan { color: #f4f1e8; border: 16px solid #9a6a3a; box-shadow: inset 0 0 0 3px #6e4a26;
  background: radial-gradient(circle at 18% 12%, rgba(255,255,255,.07), transparent 45%), radial-gradient(circle at 85% 88%, rgba(255,255,255,.06), transparent 45%), #2f4b3c; }
.t-bangphan .pt-title { color: #fffef6; text-shadow: 0 0 1px rgba(255,255,255,.6), 1px 1px 0 rgba(255,255,255,.15); border-bottom: 3px dashed rgba(255,255,255,.45); display: inline-block; padding-bottom: 4px; }
.t-bangphan .pt-day { color: #ffe28a; border-bottom: 2px solid rgba(255,255,255,.55); }
.t-bangphan .pt-sec span, .t-bangphan .pt-period { color: #cfe9d6; }
.t-bangphan .pt-lesson { border: 2px solid rgba(255,255,255,.35); border-radius: 6px; background: rgba(255,255,255,.04); }
.t-bangphan .pt-cell:not(.has) { border: 1px dashed rgba(255,255,255,.14); border-radius: 6px; }
.t-bangphan .pt-meta { color: #e8e4d8; }
.t-bangphan .pt-card { border: 2px solid rgba(255,255,255,.45); border-radius: 8px; }
.t-bangphan .pt-card-head { color: #ffe28a; }
.t-bangphan .pt-item { border-bottom: 1px dashed rgba(255,255,255,.25); }
.t-bangphan .pt-sticker { color: rgba(255,255,255,.28); }
.t-bangphan.sz-phone { border-width: 12px; }

/* ---------- Mẫu: Tối giản (in ấn) ---------- */
.t-toigian { background: #fff; color: #111; }
.t-toigian .pt-title { font-weight: 800; letter-spacing: -.01em; }
.t-toigian .pt-table { border-collapse: collapse; border-spacing: 0; }
.t-toigian .pt-table th, .t-toigian .pt-table td { border: 1px solid #222; }
.t-toigian .pt-day, .t-toigian .pt-corner { background: #f1f1f1; }
.t-toigian .pt-lesson { inset: 0; }
.t-toigian .pt-name::before { content: ''; display: inline-block; width: .6em; height: .6em; margin-right: 4px; background: var(--dot, #111); vertical-align: middle; }
.t-toigian .pt-emoji { display: none; }
.t-toigian .pt-card { border: 1.5px solid #111; }
.t-toigian .pt-card-head { border-bottom: 1.5px solid #111; padding-bottom: 4px; }
.t-toigian .pt-item { border-bottom: 1px solid #ddd; padding-left: 0; }

/* In / PDF: chỉ in poster, đúng khổ A4 */
@media print {
  body.print-poster > *:not(#posterPrint) { display: none !important; }
  body.print-poster #posterPrint { position: static; left: 0; }
  body.print-poster { background: #fff; }
}

.pw-row { display: flex; gap: 8px; align-items: stretch; }
.pw-row .input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }

/* Bài blog: mục lục, khối công cụ, neo tiêu đề */
.prose h2, .prose h3 { scroll-margin-top: 84px; }
.toc { margin: 0 0 22px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.toc b { display: block; margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; display: grid; gap: 3px; font-size: 15px; }
.toc a { color: var(--text); }
.toc a:hover { color: var(--primary); }
.blog-tools { margin: 26px 0 0; padding: 16px 18px; border-radius: var(--radius); background: var(--primary-soft); }
.blog-tools b { display: block; margin-bottom: 10px; }
.blog-tools div { display: flex; flex-wrap: wrap; gap: 8px; }
.blog-tools a { padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; }
.blog-tools a:hover { border-color: var(--primary); color: var(--primary); }

/* =====================================================================
   Trang bài viết: 2 cột + mục lục dính, tiến độ đọc, tóm tắt, hỏi đáp, chia sẻ, đánh giá
   ===================================================================== */
.blog-article [hidden], .read-tools[hidden], .share-btn[hidden] { display: none !important; }
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--primary); transform: scaleX(0); transform-origin: 0 50%; }
.article-layout { max-width: 720px; margin: 0 auto; }
.article-layout.has-side { max-width: none; display: grid; grid-template-columns: minmax(0, 720px) 240px; gap: 56px; justify-content: center; }
.article-layout .blog-article { max-width: none; margin: 0; min-width: 0; }
.side-sticky { position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto; padding-top: 36px; display: flex; flex-direction: column; gap: 22px; scrollbar-width: thin; }
.toc-side { margin: 0; padding: 0 0 0 16px; border: 0; border-left: 2px solid var(--border); border-radius: 0; background: none; }
.toc-side b { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.toc-side ol { list-style: none; padding: 0; gap: 0; font-size: 14px; }
.toc-side a { display: block; padding: 5px 0 5px 14px; margin-left: -18px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.4; text-decoration: none; }
.toc-side a:hover { color: var(--text); }
.toc-side a.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.side-share { display: flex; flex-direction: column; gap: 8px; padding-left: 18px; }
.toc-inline { display: none; }
@media (max-width: 1080px) {
  .article-layout.has-side { display: block; max-width: 720px; margin: 0 auto; }
  .article-side { display: none; }
  .toc-inline { display: block; padding: 0; overflow: hidden; }
  .toc-inline summary { cursor: pointer; padding: 13px 16px; font-weight: 700; }
  .toc-inline nav { padding: 0 16px 14px; }
  .toc-inline a.active { color: var(--primary); font-weight: 600; }
}

.cat-pill { display: inline-block; padding: 4px 12px; margin-bottom: 14px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700; text-decoration: none; }
.article-head h1 { font-size: clamp(28px, 4.4vw, 42px); line-height: 1.2; letter-spacing: -.015em; margin: 0 0 14px; }
.article-lede { font-size: 19px; line-height: 1.6; color: var(--muted); margin: 0 0 20px; }
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 14px 0; margin-bottom: 26px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.byline { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.byline img { border-radius: 8px; }
.updated-pill { padding: 2px 10px; border-radius: 99px; background: var(--success-soft); color: var(--success); font-size: 13px; font-weight: 600; }
.hero-ph, .blog-cover-ph { display: flex; align-items: flex-end; color: #fff; font-weight: 800; text-decoration: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.hero-ph { aspect-ratio: auto; height: 132px; padding: 18px 24px; font-size: clamp(18px, 2.6vw, 24px); }
@media (max-width: 600px) { .hero-ph { height: 88px; padding: 14px 18px; } }
.blog-cover-ph { aspect-ratio: 16 / 9; padding: 14px 16px; font-size: 16px; }
.blog-cover-ph:hover { color: #fff; }
.ph-0 { background: linear-gradient(135deg, #4353e0, #8b5cf6); }
.ph-1 { background: linear-gradient(135deg, #d63c6e, #f2793a); }
.ph-2 { background: linear-gradient(135deg, #0b8a78, #1b8fd1); }
.ph-3 { background: linear-gradient(135deg, #b4400e, #d99a0b); }
.ph-4 { background: linear-gradient(135deg, #3c4a63, #5b5fe0); }

.prose a { text-underline-offset: 3px; }
.anchor-btn { margin-left: 6px; padding: 0 6px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: .8em; cursor: pointer; opacity: 0; transition: opacity .15s; vertical-align: middle; }
.anchor-btn:hover { color: var(--primary); background: var(--primary-soft); }
.prose h2:hover .anchor-btn, .prose h3:hover .anchor-btn, .anchor-btn:focus-visible { opacity: 1; }
@media (hover: none) { .anchor-btn { opacity: .45; } }
.summary-box { margin: 0 0 30px; padding: 2px 22px 4px; border-left: 4px solid var(--primary); border-radius: 0 var(--radius) var(--radius) 0; background: var(--primary-soft); }
.summary-box h2 { margin: 18px 0 8px; font-size: 1.05em; text-transform: uppercase; letter-spacing: .04em; color: var(--primary); }
.summary-box ul, .summary-box ol { margin-bottom: 16px; }
.faq-box .faq-item { margin: 0 0 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.faq-item summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; cursor: pointer; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; flex: none; color: var(--primary); font-size: 24px; font-weight: 500; line-height: 1; transition: transform .2s; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary h3 { margin: 0; font-size: 1em; }
.faq-item[open] summary { border-bottom: 1px solid var(--border); }
.faq-a { padding: 14px 18px 0; }
.mid-cta { display: flex; align-items: center; gap: 14px; margin: 32px 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); font-size: 15px; line-height: 1.5; }
.mid-cta-icon { flex: none; font-size: 28px; }
.mid-cta p { margin: 2px 0 0; color: var(--muted); }
.mid-cta .btn { flex: none; margin-left: auto; text-decoration: none; }
@media (max-width: 600px) { .mid-cta { flex-wrap: wrap; } .mid-cta .btn { width: 100%; justify-content: center; } }

.tag-link { padding: 5px 12px; border-radius: 99px; background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; }
.tag-link:hover { background: var(--primary-soft); color: var(--primary); }
.feedback { margin: 34px 0 0; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.feedback-q { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.feedback-btns { display: flex; gap: 8px; }
.feedback-note { display: flex; flex-direction: column; gap: 8px; }
.feedback-note label { font-size: 14px; font-weight: 600; }
.feedback-note .btn { align-self: flex-start; }
.feedback-thanks { margin: 0; color: var(--success); font-weight: 600; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 0; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 14px; }
.share { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.share-btn:hover { border-color: var(--primary); color: var(--primary); }
.share-icons .share-btn { padding: 9px; }
.share-icons .share-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.author-box { display: flex; align-items: flex-start; gap: 16px; margin: 28px 0 0; padding: 20px; border-radius: var(--radius); background: var(--surface-2); }
.author-box img { flex: none; border-radius: 12px; }
.author-box p { margin: 4px 0 6px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.author-box a { font-size: 14px; font-weight: 600; }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0 0; }
.post-nav-item { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.post-nav-item:hover { border-color: var(--primary); }
.post-nav-item b { line-height: 1.4; }
.post-nav-item.next { text-align: right; }
@media (max-width: 600px) { .post-nav { grid-template-columns: 1fr; } .post-nav-item.next { text-align: left; } }

.article-after { max-width: 1016px; margin: 44px auto 0; }
.article-after .blog-cta { max-width: none; }
.blog-tools .tool-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.blog-tools .tool-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px; font-weight: 400; }
.blog-tools .tool-card > span { font-size: 22px; }
.blog-tools .tool-card small { color: var(--muted); font-size: 13px; line-height: 1.5; }
@media (max-width: 760px) { .blog-tools .tool-cards { grid-template-columns: 1fr; } }
.read-tools { position: fixed; right: 18px; bottom: 18px; z-index: 25; display: flex; flex-direction: column; gap: 6px; }
.read-tools button { width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow); }
.read-tools button:hover { border-color: var(--primary); color: var(--primary); }
@media (max-width: 600px) { .read-tools { right: 12px; bottom: 12px; } .read-tools button { width: 40px; height: 40px; } }
@media print { .read-progress, .read-tools, .article-side, .share-row, .feedback, .mid-cta, .article-after, .toc-inline { display: none !important; } }

/* Ô tên đăng nhập có tiền tố @ */
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--muted); font-weight: 600; }
.input-prefix .input { border-top-left-radius: 0; border-bottom-left-radius: 0; min-width: 0; }
.field-hint { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.field-hint.ok { color: var(--success); }
.field-hint.bad { color: var(--danger); }

/* ========== Đồng bộ lịch: nút một chạm, mã QR, trạng thái ========== */
.sync-status { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--text); font-size: 14px; margin-bottom: 14px; }
.sync-status.ok { background: var(--success-soft); }
.sync-status.ok b { color: var(--success); }
.sync-status > div > div + div { margin-top: 4px; }
.sync-status .btn { flex: none; }
.sync-main { display: flex; gap: 18px; align-items: stretch; margin-bottom: 12px; }
.cal-btns { flex: 1; display: grid; gap: 8px; align-content: start; min-width: 0; }
.cal-btn { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none !important; transition: border-color .15s, transform .1s, box-shadow .15s; }
.cal-btn:hover { border-color: var(--primary); box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--primary) 50%, transparent); }
.cal-btn:active { transform: translateY(1px); }
.cal-btn b { display: block; font-size: 15px; }
.cal-btn small { color: var(--muted); font-size: 12.5px; }
.cal-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.cal-btn.primary small { color: rgba(255, 255, 255, .85); }
.cal-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); font-size: 20px; }
.cal-btn.primary .cal-ico { background: rgba(255, 255, 255, .18); }
.sync-qr { flex: 0 0 170px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: 12.5px; color: var(--muted); }
.qr-box { width: 150px; height: 150px; padding: 6px; border-radius: 12px; background: #fff; border: 1px solid var(--border); }
.qr-box svg { width: 100%; height: 100%; display: block; }
.sync-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 10px; font-size: 14px; }
.sync-opts > b { width: 100%; }
.sync-opts .check { margin: 0; }
.sync-remind { display: flex; align-items: center; gap: 8px; }
.sync-remind .input { width: auto; padding: 6px 10px; }
.panel.flash { animation: panelFlash 1.6s ease-out; }
@keyframes panelFlash { 0%, 40% { box-shadow: 0 0 0 3px var(--primary); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 600px) { .sync-main { flex-direction: column; } .sync-qr { display: none; } .sync-status { flex-direction: column; align-items: flex-start; } }

/* Gợi ý "Đưa lịch học lên điện thoại" */
.sync-hint { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); background: linear-gradient(135deg, var(--primary-soft), var(--surface)); }
.sync-hint-ico { font-size: 28px; flex: none; }
.sync-hint-txt { flex: 1; min-width: 0; }
.sync-hint-txt b { display: block; }
.sync-hint-txt small { color: var(--muted); }
.sync-hint .btn-icon { flex: none; }
@media (max-width: 520px) { .sync-hint { flex-wrap: wrap; } .sync-hint .btn-primary { flex: 1; } }

/* Trang /cal/:token/them (mở từ mã QR) */
.caladd-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.caladd { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.caladd h1 { font-size: 22px; margin: 4px 0 0; }
.caladd p { margin: 0; }
.caladd .cal-btns { width: 100%; text-align: left; }

/* ========== Trang công cụ công khai: /mau-thoi-khoa-bieu, /tinh-gpa ========== */
.tool-main { padding-top: 18px; padding-bottom: 48px; }
.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.tool-hero { max-width: 760px; margin-bottom: 22px; }
.tool-hero .kicker { display: inline-block; font-family: 'Patrick Hand', 'Mali', cursive; font-size: 20px; color: var(--accent); transform: rotate(-2deg); }
.tool-hero h1 { font-size: clamp(28px, 4.4vw, 42px); letter-spacing: -.02em; font-weight: 800; margin: 4px 0 10px; }
.tool-hero .lead { font-size: 17px; color: var(--muted); margin: 0; }
.tool-loading { padding: 40px; text-align: center; }
.tool-sec { margin-top: 44px; max-width: 900px; }
.tool-sec h2 { font-size: clamp(21px, 2.6vw, 26px); letter-spacing: -.01em; }
.tool-sec p { color: var(--muted); }
.tool-steps { padding-left: 22px; color: var(--muted); display: grid; gap: 10px; }
.tool-steps b { color: var(--text); }
.tool-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.tool-cards > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.tool-cards p { margin: 6px 0 0; font-size: 14px; }
.tool-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-size: 15px; }
.tool-table th, .tool-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.tool-table thead th { background: var(--surface-2); font-size: 13.5px; color: var(--muted); }
.tool-table tr:last-child td { border-bottom: 0; }
.tool-cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-top: 44px; padding: 28px; border-radius: 20px; color: #fff; background: linear-gradient(135deg, #4353e0, #7b4fe0 60%, #e0457b 130%); }
.tool-cta h2 { color: #fff; margin: 0 0 6px; font-size: 22px; }
.tool-cta p { margin: 0; opacity: .92; color: #fff; max-width: 560px; }
.tool-cta .btn-white { background: #fff; color: #3442c4; }
.tool-faq { max-width: 820px; }
.tool-more { margin-top: 30px; }
.tool-after { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--text); font-size: 14.5px; }

/* Trình nhập thời khóa biểu */
.tkb-editor { margin-bottom: 18px; }
.tkb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0; }
.tkb-row .spacer { flex: 1; }
.tkb-type { width: 260px; max-width: 100%; }
.tkb-inline { margin: 0; }
.tkb-h { font-size: 17px; margin: 18px 0 10px; }
.tkb-h small { font-weight: 500; font-size: 13px; color: var(--muted); margin-left: 6px; }
.tkb-h3 { font-size: 19px; margin-top: 8px; }
.tkb-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tkb-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 2px solid color-mix(in srgb, var(--c, var(--muted)) 45%, transparent); background: color-mix(in srgb, var(--c, var(--muted)) 12%, var(--surface)); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.tkb-chip.on { border-color: var(--c, var(--text)); background: var(--c, var(--text)); color: #fff; box-shadow: 0 4px 12px -4px var(--c, #000); }
.tkb-chip.eraser { --c: #94a3b8; }
.tkb-add { display: flex; gap: 8px; margin-top: 10px; max-width: 520px; }
.tkb-add .input { flex: 1; min-width: 0; }
.tkb-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.tkb-edit .input { width: 200px; flex: 1 1 160px; }
.tkb-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.tkb-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.tkb-color.on { box-shadow: 0 0 0 2px var(--text); }
.tkb-grid-wrap { overflow-x: auto; }
.tkb-grid { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 360px; table-layout: fixed; }
.tkb-grid th { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.tkb-grid thead th:first-child, .tkb-grid tbody th { width: 46px; }
.tkb-grid tbody th { text-align: center; font-size: 13px; color: var(--text); }
.tkb-grid tbody th small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.tkb-noon th, .tkb-noon td { border-top: 2px dashed var(--border); padding-top: 6px; }
.tkb-cell { width: 100%; height: 40px; border-radius: 8px; border: 1px dashed var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 12px; font-weight: 700; line-height: 1.15; padding: 2px 4px; cursor: pointer; overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tkb-cell:hover { border-color: var(--primary); }
.tkb-cell.has { border: 0; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: color-mix(in srgb, var(--c) 70%, var(--text)); }
.tkb-actions { margin-top: 12px; }

/* Công cụ GPA */
.gpa-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.gpa-tabs button { padding: 10px 16px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.gpa-tabs button[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.gpa-rows { display: grid; gap: 8px; }
.gpa-row { display: grid; grid-template-columns: minmax(0, 2fr) 90px 150px minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.gpa-row.parts { grid-template-columns: minmax(0, 2fr) 110px 190px 36px; }
.gpa-head { font-size: 13px; color: var(--muted); font-weight: 600; }
.gpa-out { font-size: 14px; color: var(--muted); }
.gpa-out b { color: var(--text); font-size: 15px; }
.gpa-out.bad { color: var(--danger); font-size: 12.5px; }
.gpa-result { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.gpa-big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.gpa-big span { color: var(--muted); font-weight: 600; }
.gpa-big b { font-size: 44px; font-weight: 800; letter-spacing: -.02em; color: var(--primary); font-variant-numeric: tabular-nums; }
.gpa-big em { font-style: normal; font-weight: 700; padding: 4px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.gpa-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.gpa-facts > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.gpa-facts span { display: block; font-size: 12.5px; color: var(--muted); }
.gpa-facts b { font-size: 20px; }
.gpa-need-title { margin: 0 0 10px; }
.gpa-need { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gpa-need > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.gpa-need b { font-size: 18px; }
.gpa-need span { font-weight: 700; color: var(--primary); }
.gpa-need small { color: var(--muted); font-size: 12px; }
.gpa-need .free span { color: var(--success); }
.gpa-need .off { opacity: .55; }
.gpa-need .off span { color: var(--muted); }
@media (max-width: 640px) {
  .gpa-row { grid-template-columns: minmax(0, 1fr) 64px 92px 36px; }
  .gpa-row .gpa-out { grid-column: 1 / -1; margin-top: -4px; order: 5; }
  .gpa-row .gpa-out:empty { display: none; }
  .gpa-head span:nth-child(4) { display: none; }
  .gpa-row.parts { grid-template-columns: minmax(0, 1fr) 70px 92px 36px; }
  .gpa-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-cta { padding: 22px; }
}
.foot-links-inline { display: flex; flex-wrap: wrap; gap: 4px 0; justify-content: flex-end; }
.tool-hero .btn { margin: 6px 8px 6px 0; }

/* =====================================================================
   Tạo lịch nhanh: hoàn tác, chế độ tô, bắt đầu nhanh, mẫu, gõ nhanh, chụp ảnh
   ===================================================================== */
.toast-action { display: flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast-action button { border: 0; background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); font: inherit; font-weight: 700; padding: 5px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
/* Đang mở hộp thoại: đưa thông báo lên trên để không che nút của hộp thoại */
body:has(#modalRoot .modal-backdrop) .toast { top: 16px; bottom: auto; }
.toast-action button:hover { background: color-mix(in srgb, var(--bg) 30%, transparent); }

/* Chế độ tô */
.paint-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--primary); border-radius: var(--radius-sm); background: var(--primary-soft); }
.paint-bar .muted { flex: 1 1 240px; }
.legend-chip.on { border-color: var(--primary); background: var(--primary); color: #fff; }
.legend-chip.on .dot { box-shadow: 0 0 0 2px #fff; }
.painting .tt-col.clickable { cursor: crosshair; }
.painting .tt-entry { cursor: cell; }
.painting .tt-entry .tt-resize { display: none; }
.tt-paint { border-style: solid; }
.tt-entry.copying { outline: 2px dashed #fff; outline-offset: -4px; }
.tt-entry.copying::after { content: "+ Nhân bản"; position: absolute; right: 6px; top: 4px; font-size: 11px; font-weight: 800; background: rgba(0, 0, 0, .35); padding: 1px 6px; border-radius: 6px; }

/* Bắt đầu nhanh (tuần trống, trang Hôm nay) */
.start-panel { margin: 16px 0; padding: 20px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.start-panel h3 { margin: 0 0 4px; font-size: 18px; }
.start-panel > p { margin: 0 0 16px; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.start-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; cursor: pointer; }
.start-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.start-card > span { font-size: 26px; }
.start-card small { color: var(--muted); font-size: 12px; line-height: 1.4; }

/* Chọn thứ (nhiều thứ) */
.day-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.day-toggle label { position: relative; }
.day-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.day-toggle span { display: grid; place-items: center; min-width: 44px; height: 38px; padding: 0 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 700; cursor: pointer; user-select: none; }
.day-toggle input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.day-toggle input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.field > .label { font-weight: 600; font-size: 14px; }

/* Trình hướng dẫn tạo từ mẫu */
.wiz-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.wiz-steps span { padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.wiz-steps span.on { background: var(--primary); color: #fff; }
.wiz-steps span.done { background: var(--primary-soft); color: var(--primary); }
.wiz-back { margin-bottom: 8px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.level-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.level-card:hover, .level-card.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.level-ico { font-size: 26px; }
.level-card small { color: var(--muted); font-size: 13px; line-height: 1.45; }
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.radio-row:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-row input { margin-top: 3px; accent-color: var(--primary); }
.radio-row span { display: flex; flex-direction: column; gap: 2px; }
.radio-row small { color: var(--muted); font-size: 13px; }
.period-gen { margin: 4px 0 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.period-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; }
.period-chips span { padding: 3px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.subject-picks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pick { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); font-size: 14px; cursor: pointer; }
.pick:has(input:checked), .pick.on { border-color: var(--primary); background: var(--primary-soft); }
.pick input { accent-color: var(--primary); margin: 0; }
.pick small { color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0 2px; }
.add-subject { display: flex; gap: 8px; margin-bottom: 6px; }
.add-subject .input { flex: 1; max-width: 320px; }
.mini-grid { max-height: 52vh; overflow: auto; }
.mini-grid td, .mini-grid th { padding: 4px; vertical-align: top; }
.mini-cell { display: block; padding: 5px 7px; border-radius: 7px; background: color-mix(in srgb, var(--c) 16%, transparent); border-left: 3px solid var(--c); font-size: 12px; font-weight: 600; line-height: 1.3; }
.mini-cell small { display: block; color: var(--muted); font-weight: 500; }

/* Nhập: cách khác, gõ nhanh, ảnh */
.import-alt { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.quick-text { font-size: 15px; line-height: 1.6; }
.preview-sum { margin: 10px 0 6px; }
.photo-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; margin-bottom: 12px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; text-align: center; }
.photo-drop:hover { border-color: var(--primary); }
.photo-drop > span { font-size: 30px; }
.photo-drop small { color: var(--muted); }
.photo-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-thumb { display: block; max-width: 100%; max-height: 220px; margin: 0 auto 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.loading-line { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.keys td { padding: 6px 10px; }
kbd { display: inline-block; padding: 2px 8px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); font: 600 13px/1.4 ui-monospace, Consolas, monospace; white-space: nowrap; }
@media print { .paint-bar, .start-panel { display: none !important; } }

/* Trang pháp lý */
.legal { max-width: 760px; margin: 0 auto; padding: 8px 0 48px; }
.legal h1 { font-size: 2rem; margin: 8px 0 4px; }
.legal .prose { --prose-size: 17px; margin-top: 20px; }
.legal .prose table { width: 100%; border-collapse: collapse; font-size: .92em; }
.legal .prose th, .legal .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb); vertical-align: top; }
