/* Sổ Lớp — nền chung: token, chữ, nút, lớp phủ */
:root {
  --paper: #F4EEE3;      /* tường kem của lớp học */
  --sheet: #FFFCF6;      /* trang sổ */
  --sheet-2: #ECE4D5;    /* gỗ nhạt */
  --ink: #1D2232;        /* mực xanh đen */
  --ink-2: #545A69;
  --ink-3: #6A6D74;
  --accent: #23407D;     /* xanh mực — màu nhấn duy nhất */
  --accent-2: #1A3266;
  --accent-ink: #FFFFFF;
  --accent-soft: #E2E7F1;
  --sun: #E3A83B;        /* nắng trên logo — chỉ để trang trí */
  --margin: #B9473A;     /* lề đỏ vở ô li */
  --leaf: #3E7A57;
  --hair: rgba(29, 34, 50, .08);
  --shadow: 0 1px 2px rgba(29, 34, 50, .05), 0 12px 32px -18px rgba(29, 34, 50, .28);
  --f-d: 'Fraunces', 'Times New Roman', serif;
  --f-b: 'Be Vietnam Pro', system-ui, sans-serif;
  --e: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --r: 14px;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #13151B;
  --sheet: #1B1E26;
  --sheet-2: #252934;
  --ink: #F2EDE3;
  --ink-2: #AEB2BD;
  --ink-3: #9599A4;
  --accent: #93AAE6;
  --accent-2: #B1C3F0;
  --accent-ink: #0F1628;
  --accent-soft: #232D45;
  --sun: #E8B65A;
  --margin: #E2806F;
  --leaf: #7CC39A;
  --hair: rgba(242, 237, 227, .08);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.6 var(--f-b); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 16px; top: -60px; z-index: 999; background: var(--accent); color: var(--accent-ink); padding: 12px 18px; border-radius: 10px; text-decoration: none; font-weight: 600; transition: top .2s var(--e); }
.skip:focus { top: 16px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 11px; background: var(--sheet-2); color: var(--ink); font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; transition: transform .18s var(--e), background .2s, color .2s, box-shadow .2s; white-space: nowrap; }
.btn:hover { background: color-mix(in srgb, var(--sheet-2) 80%, var(--ink) 8%); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--sheet-2); }
.btn.danger { background: var(--margin); color: #fff; }
.btn.lg { min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 13px; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.icon { width: 44px; padding: 0; }

/* avatar chữ cái */
.av { --h: 210; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 600 15px/1 var(--f-b); color: hsl(var(--h) 38% 26%); background: hsl(var(--h) 46% 88%); letter-spacing: .02em; }
[data-theme="dark"] .av { color: hsl(var(--h) 50% 88%); background: hsl(var(--h) 22% 28%); }
.av.lg { width: 72px; height: 72px; font-size: 24px; }
.av.xl { width: 96px; height: 96px; font-size: 32px; font-family: var(--f-d); }
.av.sm { width: 36px; height: 36px; font-size: 13px; }

/* lớp phủ: modal, drawer, toast, palette */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(18, 20, 28, .42); opacity: 0; transition: opacity .3s var(--e); }
.scrim.in { opacity: 1; }
.modal { position: fixed; z-index: 81; left: 50%; top: 50%; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; background: var(--sheet); border-radius: 18px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .5); transform: translate(-50%, -46%) scale(.97); opacity: 0; transition: transform .38s var(--spring), opacity .25s var(--e); }
.modal.in { transform: translate(-50%, -50%); opacity: 1; }
.modal-h { padding: 28px 32px 8px; }
.modal-h h2 { font: 600 26px/1.2 var(--f-d); }
.modal-h p { color: var(--ink-2); margin-top: 6px; }
.modal-b { padding: 16px 32px 8px; display: grid; gap: 18px; }
.modal-f { padding: 16px 32px 28px; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.drawer { position: fixed; z-index: 81; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--sheet); overflow: auto; transform: translateX(104%); transition: transform .45s var(--e); box-shadow: -30px 0 80px -40px rgba(0, 0, 0, .45); }
.drawer.in { transform: none; }
.x-btn { position: absolute; right: 16px; top: 16px; z-index: 3; width: 44px; height: 44px; border-radius: 50%; border: 0; background: color-mix(in srgb, var(--sheet) 88%, transparent); cursor: pointer; display: grid; place-items: center; }
.x-btn:hover { background: var(--sheet-2); }
.toasts { position: fixed; z-index: 120; left: 50%; bottom: 28px; transform: translateX(-50%); display: grid; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: calc(100vw - 32px); padding: 14px 18px; border-radius: 14px; background: var(--ink); color: var(--paper); font-weight: 500; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .5); animation: toastIn .45s var(--spring) both; }
.toast .ic { color: var(--sun); }
.toast button { margin-left: auto; background: none; border: 0; color: var(--sun); font-weight: 600; cursor: pointer; min-height: 32px; }
.toast.out { animation: toastOut .3s var(--e) both; }
@keyframes toastIn { from { transform: translateY(18px) scale(.96); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

/* form */
.fld { display: grid; gap: 8px; }
.fld > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.fld input, .fld select, .fld textarea { width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid transparent; border-radius: 11px; background: var(--paper); transition: border-color .2s, background .2s; }
.fld textarea { padding: 12px 14px; min-height: 96px; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 0; border-color: var(--accent); background: var(--sheet); }
.fld.err input, .fld.err select { border-color: var(--margin); }
.fld .msg { font-size: 13px; color: var(--margin); min-height: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--sheet-2); }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: none; font-weight: 600; font-size: 14px; color: var(--ink-2); cursor: pointer; transition: background .2s, color .2s; }
.seg button[aria-pressed="true"] { background: var(--sheet); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ảnh có vệt sáng khi đang tải */
.skel { position: relative; overflow: hidden; background: var(--sheet-2); border-radius: 12px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); animation: shine 1.2s infinite; }
[data-theme="dark"] .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes shine { to { transform: translateX(100%); } }

/* chú thích concept */
.concept { font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.concept a { color: var(--ink-2); }

/* giảm chuyển động */
html.calm { scroll-behavior: auto !important; }
.calm *, .calm *::before, .calm *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
