/* Lịch học: phone and tablet first. Same colour family as the exam pages (web/style.css), softer shapes. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2330;
  --muted: #5b6577;
  --border: #d5dae3;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --accent-soft: #e6effc;
  --accent-soft-text: #17468e;
  --ok: #17693a;
  --ok-soft: #e3f3e8;
  --warn: #8a5200;
  --warn-soft: #fbf0dc;
  --error: #b3261e;
  --error-soft: #fcebea;
  --radius: 14px;
  --radius-small: 10px;
  --tabbar-height: 64px;
  /* Subject colours: pale fill + dark text in light mode, the reverse in dark mode. */
  --subj-blue-bg: #e6f1fb; --subj-blue-fg: #0c447c;
  --subj-aqua-bg: #e1f5ee; --subj-aqua-fg: #085041;
  --subj-green-bg: #eaf3de; --subj-green-fg: #27500a;
  --subj-yellow-bg: #faeeda; --subj-yellow-fg: #633806;
  --subj-orange-bg: #faece7; --subj-orange-fg: #712b13;
  --subj-red-bg: #fcebeb; --subj-red-fg: #791f1f;
  --subj-magenta-bg: #fbeaf0; --subj-magenta-fg: #72243e;
  --subj-violet-bg: #eeedfe; --subj-violet-fg: #3c3489;
  --subj-gray-bg: #f1efe8; --subj-gray-fg: #444441;
  --subj-lime-bg: #f1f7d6; --subj-lime-fg: #44570a;
  --subj-sky-bg: #e2f5fb; --subj-sky-fg: #0b5a73;
  --subj-plum-bg: #f6eafb; --subj-plum-fg: #5f1f7c;
  --subj-lotus-bg: #fce8f6; --subj-lotus-fg: #7c1a62;
  --subj-brown-bg: #e9dccf; --subj-brown-fg: #4a3020;
  --subj-slate-bg: #e1e8f2; --subj-slate-fg: #283a55;
  color-scheme: light;
}
/* Dark colours: <html data-theme="dark">, set by lichhoc-theme.js from the family's Giao diện, or from the
   device itself when that is "Theo máy". */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --surface: #1d2129;
  --surface-2: #262b35;
  --text: #e8ebf0;
  --muted: #a3acbb;
  --border: #363d4a;
  --accent: #7fb0ff;
  --accent-text: #0b1526;
  --accent-soft: #1d3150;
  --accent-soft-text: #bcd6ff;
  --ok: #7bd69b;
  --ok-soft: #1c3526;
  --warn: #f0b861;
  --warn-soft: #3a2c14;
  --error: #ff8a80;
  --error-soft: #3d1f1d;
  --subj-blue-bg: #0c447c; --subj-blue-fg: #b5d4f4;
  --subj-aqua-bg: #085041; --subj-aqua-fg: #9fe1cb;
  --subj-green-bg: #27500a; --subj-green-fg: #c0dd97;
  --subj-yellow-bg: #633806; --subj-yellow-fg: #fac775;
  --subj-orange-bg: #712b13; --subj-orange-fg: #f5c4b3;
  --subj-red-bg: #791f1f; --subj-red-fg: #f7c1c1;
  --subj-magenta-bg: #72243e; --subj-magenta-fg: #f4c0d1;
  --subj-violet-bg: #3c3489; --subj-violet-fg: #cecbf6;
  --subj-gray-bg: #444441; --subj-gray-fg: #d3d1c7;
  --subj-lime-bg: #44570a; --subj-lime-fg: #d5e89a;
  --subj-sky-bg: #0b5a73; --subj-sky-fg: #a6e3f3;
  --subj-plum-bg: #5f1f7c; --subj-plum-fg: #e3c3f2;
  --subj-lotus-bg: #7c1a62; --subj-lotus-fg: #f5c0e4;
  --subj-brown-bg: #553a26; --subj-brown-fg: #e6cdb6;
  --subj-slate-bg: #2f3e54; --subj-slate-fg: #c6d2e2;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.15rem; margin-bottom: 12px; }
h3 { font-size: 1rem; }
p { margin: 0; }
code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Buttons and fields: big enough for a thumb (44 px). */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-small);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: none; }
/* "small" means less padding and text, never a smaller target: every control stays 44 px tall. */
button.small { padding: 4px 10px; font-size: 0.9rem; }
button.icon { min-width: 44px; padding: 4px; font-size: 1.05rem; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--accent); }
button.wide { width: 100%; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type="text"], input[type="password"], input[type="time"], input[type="date"], input[type="number"], select, textarea {
  display: block; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-small);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
.field-error { color: var(--error); font-size: 0.9rem; min-height: 1.4em; margin-top: 6px; }

/* Cards and chips. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; white-space: nowrap; line-height: 1.6;
  background: var(--surface-2); color: var(--muted);
}
/* Each subject colour names its pair of tokens; chips, buttons and bars then paint with --subj-bg / --subj-fg. */
[data-color="blue"] { --subj-bg: var(--subj-blue-bg); --subj-fg: var(--subj-blue-fg); }
[data-color="aqua"] { --subj-bg: var(--subj-aqua-bg); --subj-fg: var(--subj-aqua-fg); }
[data-color="green"] { --subj-bg: var(--subj-green-bg); --subj-fg: var(--subj-green-fg); }
[data-color="yellow"] { --subj-bg: var(--subj-yellow-bg); --subj-fg: var(--subj-yellow-fg); }
[data-color="orange"] { --subj-bg: var(--subj-orange-bg); --subj-fg: var(--subj-orange-fg); }
[data-color="red"] { --subj-bg: var(--subj-red-bg); --subj-fg: var(--subj-red-fg); }
[data-color="magenta"] { --subj-bg: var(--subj-magenta-bg); --subj-fg: var(--subj-magenta-fg); }
[data-color="violet"] { --subj-bg: var(--subj-violet-bg); --subj-fg: var(--subj-violet-fg); }
[data-color="gray"] { --subj-bg: var(--subj-gray-bg); --subj-fg: var(--subj-gray-fg); }
[data-color="lime"] { --subj-bg: var(--subj-lime-bg); --subj-fg: var(--subj-lime-fg); }
[data-color="sky"] { --subj-bg: var(--subj-sky-bg); --subj-fg: var(--subj-sky-fg); }
[data-color="plum"] { --subj-bg: var(--subj-plum-bg); --subj-fg: var(--subj-plum-fg); }
[data-color="lotus"] { --subj-bg: var(--subj-lotus-bg); --subj-fg: var(--subj-lotus-fg); }
[data-color="brown"] { --subj-bg: var(--subj-brown-bg); --subj-fg: var(--subj-brown-fg); }
[data-color="slate"] { --subj-bg: var(--subj-slate-bg); --subj-fg: var(--subj-slate-fg); }
.chip[data-color] { background: var(--subj-bg); color: var(--subj-fg); }

/* Login and other whole-page messages. */
.center-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; padding: 24px; }
.login-card h1 { margin-bottom: 6px; }
.login-card p + p { margin-top: 10px; }
.login-card button { margin-top: 4px; }

/* The app: a header, the screen, and a tab bar at the bottom of the phone. */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 999px; color: var(--muted); text-decoration: none;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
main { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(var(--tabbar-height) + 24px + env(safe-area-inset-bottom)); }
.placeholder { text-align: center; padding: 40px 16px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; border-radius: var(--radius-small);
  color: var(--muted); text-decoration: none; font-size: 0.75rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.2; }
/* On a wide screen the tabs sit under the header, as one rounded group like on the exam pages. */
@media (min-width: 900px) {
  :root { --tabbar-height: 0px; }
  .tabbar {
    position: static; max-width: 760px; margin: 0 auto 8px; padding: 4px;
    border: 1px solid var(--border); border-radius: 999px; justify-content: center; gap: 4px;
  }
  .tabbar a { flex-direction: row; gap: 6px; max-width: none; flex: none; padding: 8px 16px; border-radius: 999px; font-size: 0.9rem; }
  .tabbar a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }
}

/* Above the ✎ Ghi bài button, which sits at the same height on the right. */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-height) + 80px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: var(--radius-small);
  background: var(--text); color: var(--bg); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.toast-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hoàn tác: still a 44 px target, without making the toast taller. */
#toast .toast-action {
  flex: none; margin: -10px -8px -10px 0; padding: 4px 8px; border: 0; background: none; color: inherit;
  font-weight: 700; text-decoration: underline;
}
#toast.error { background: var(--error); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }
[data-theme="dark"] #toast.error, [data-theme="dark"] #toast.ok { color: #10131a; }
@media (prefers-reduced-motion: no-preference) { #toast { transition: opacity 0.2s; } }

/* ----- shared pieces of the screens ----- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.row.center, .center { justify-content: center; text-align: center; }
.grow { flex: 1; min-width: 0; }
.block { display: block; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
h4 { margin: 12px 0 4px; font-size: 0.95rem; color: var(--muted); }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok, .badge[data-tone="ok"] { background: var(--ok-soft); color: var(--ok); }
.badge[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.badge[data-tone="error"] { background: var(--error-soft); color: var(--error); }
.badge[data-tone="accent"] { background: var(--accent-soft); color: var(--accent-soft-text); }
.ok-text { color: var(--ok); font-weight: 600; }
.tone-warn { border-color: var(--warn); background: var(--warn-soft); }
.tone-warn p + button { margin-top: 10px; }
button.danger { color: var(--error); border-color: var(--error); }
button.add, a.add { color: var(--accent); margin-top: 8px; }
a.button { text-decoration: none; }
a.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; margin-top: 10px; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.list-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 4px;
  border: 0; border-top: 1px solid var(--border); border-radius: 0; background: none; text-align: left; justify-content: flex-start;
}
.list-row.static { cursor: default; }
.card-head + .list-row, h4 + .list-row { border-top: 0; }
.field label { margin-top: 10px; }
details.card > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details.card[open] > summary { margin-bottom: 8px; }

/* Dialogs: a sheet from the bottom on a phone, a centred box on a wider screen. */
dialog.sheet {
  width: min(520px, 100%); max-width: 100%; max-height: 88vh; margin: auto auto 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface); color: var(--text);
}
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: var(--radius); } }
dialog.sheet::backdrop { background: rgba(10, 14, 20, 0.45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.sheet-actions .danger { margin-right: auto; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.option { flex-direction: column; align-items: flex-start; text-align: left; }
.option[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: 1px; }
.option[data-color] { border-color: transparent; }
.radio-group { border: 0; padding: 0; margin: 12px 0 0; }
.radio-group legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 0; font-weight: 400; }
.radio input { width: 20px; height: 20px; }

/* Buttons and bars that carry a subject colour. */
[data-color]:is(button, .bar) { background: var(--subj-bg); color: var(--subj-fg); }

/* ----- TKB ----- */
.day-chips { display: flex; gap: 6px; margin-bottom: 12px; }
.day-chips button { flex: 1; min-width: 0; padding: 8px 0; border-radius: 999px; font-weight: 600; }
.day-chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
/* A period on a phone: its number and time (tap: change the time), then its subject (tap: change the subject). */
.period-line { display: flex; align-items: stretch; gap: 8px; border-top: 1px solid var(--border); }
.card-head + .period-line { border-top: 0; }
.period-label {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0;
  padding: 4px 6px; border: 0; background: none; color: var(--muted); font-size: 0.85rem; text-align: left;
}
.period-line .period-label { flex: none; width: 92px; }
.period-subject { flex: 1; justify-content: flex-start; border: 0; border-radius: 0; background: none; }
.grid-row .period-label { min-height: 44px; padding: 4px 8px; border-radius: 8px; color: var(--text); font-weight: 600; }
.grid-row .period-label:hover { background: var(--surface-2); }
.period-label .time { font-size: 0.78rem; font-weight: 400; color: var(--muted); }
.grid-label { padding: 0 8px; }
.sheet-hint { margin: 0 0 10px; }
.week-grid { padding: 12px; }
.grid-row { display: grid; grid-template-columns: 96px repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 4px; }
/* "Sáng", "Chiều", "Tối" over their rows, so the left column only has to say which period and when. */
.grid-session {
  margin: 14px 0 2px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-soft-text);
}
.grid-row.session-start { margin-top: 12px; }
.grid-head { margin-top: 0; }
.grid-day { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 600; font-size: 0.9rem; }
.grid-day .badge { font-size: 0.68rem; padding: 0 4px; }
.grid-label { align-self: center; color: var(--muted); font-size: 0.85rem; }
.cell { min-height: 44px; padding: 2px; border-radius: 8px; background: var(--surface-2); border-color: transparent; }
.dim { opacity: 0.5; }
.cell .chip { padding: 2px 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* The evening row of the grid: one small button per item, and a "+" (the whole cell when it is empty). */
.evening-cell { display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.evening-item {
  display: flex; flex-direction: column; align-items: center; gap: 0; min-height: 0; padding: 2px; width: 100%;
  border: 0; border-radius: 6px; background: none; font-size: 0.8rem;
}
.evening-item .chip { font-size: 0.75rem; }
/* An evening's note is a badge like a subject's, but may wrap: at most two lines (the whole note is in the
   edit form), so a pill shape would look odd on two lines. */
.chip.evening-note {
  max-width: 100%; white-space: normal; line-height: 1.3; padding: 2px 8px; border-radius: 10px;
  overflow-wrap: anywhere; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.evening-item .evening-note { text-align: center; }
.evening-item .chip + .chip { margin-top: 2px; }
.evening-add { min-height: 24px; padding: 0; border: 0; background: none; color: var(--accent); font-size: 1rem; }
.evening-add.empty { flex: 1; min-height: 40px; color: var(--muted); }
/* The whole week on a phone (Cả tuần): seven narrow columns that fit the screen without scrolling sideways.
   Period numbers only (their times are in Theo ngày), a green dot for a free morning, small names on up to
   two lines (three for an evening's note). */
.tkb-view { margin-bottom: 12px; }
.week-grid.compact { padding: 8px 6px; overflow-x: auto; }
.compact .grid-row { grid-template-columns: 20px repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 3px; }
.compact .grid-session { margin: 10px 0 2px; font-size: 0.72rem; }
.compact .grid-day { font-size: 0.8rem; }
.compact .grid-day .badge { width: 7px; height: 7px; padding: 0; border-radius: 50%; font-size: 0; background: var(--ok); }
.compact .period-label { align-items: center; min-height: 40px; padding: 0; font-size: 0.8rem; }
.compact .period-label .time { display: none; }
.compact .cell { min-height: 40px; padding: 1px; }
.compact .cell .chip, .compact .evening-item .chip {
  max-width: 100%; padding: 2px 3px; border-radius: 6px; font-size: 0.62rem; line-height: 1.2; text-align: center;
  white-space: normal; overflow-wrap: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.compact .chip.evening-note { -webkit-line-clamp: 3; }
.compact .evening-item { padding: 1px; font-size: 0.62rem; }

/* ----- Cài đặt ----- */
/* One subject: colour and name on the first line; on a phone the short name and the buttons wrap below. */
.subject-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--border); }
.subject-row input { min-height: 44px; min-width: 0; }
.subject-row input:not(.short) { flex: 1 1 180px; }
.subject-row input.short { width: 96px; flex: none; }
.subject-row .swatch { flex: none; min-width: 64px; min-height: 36px; border-radius: 999px; }
.subject-row.archived input, .subject-row.archived .swatch { opacity: 0.5; }
.card .row { margin-top: 10px; }

/* ----- Bài tập ----- */
.chip-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-picker .chip { min-height: 36px; padding: 4px 12px; border: 2px solid transparent; font-size: 0.9rem; }
.chip-picker .chip[aria-pressed="true"] { border-color: currentColor; }
.segmented { display: flex; border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden; }
.segmented button { flex: 1; border: 0; border-radius: 0; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.due-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.quick-add .primary { margin-top: 8px; }
.task-row { display: flex; align-items: stretch; gap: 8px; border-top: 1px solid var(--border); }
.card-head + .task-row, summary + .task-row, summary + .swipe-row > .task-row { border-top: 0; }
.task-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: 0; border-radius: 0; background: none; text-align: left; padding: 8px 0;
}
.task-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.task-title { overflow-wrap: anywhere; }
.tick {
  flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 4px 0; align-self: center;
  border: 2px solid var(--muted); border-radius: 8px; background: none; color: var(--accent-text); font-weight: 700;
}
.tick[aria-pressed="true"], .done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
/* In the homework list the tick is a 44 px target drawn as a 30 px box. */
.task-row .tick, .task-row .tick[aria-pressed="true"] { position: relative; z-index: 0; border: 0; background: none; color: #fff; }
.task-row .tick::before {
  content: ""; position: absolute; inset: 7px; z-index: -1; border: 2px solid var(--muted); border-radius: 8px;
}
.task-row .tick[aria-pressed="true"]::before { background: var(--ok); border-color: var(--ok); }
.done .task-title { text-decoration: line-through; color: var(--muted); }
/* Bài tập: swipe a row left to show Sửa / Xóa (lichhoc-swipe-row.js). Until then the row covers the buttons,
   so it takes the card's own background (warm on "Quá hạn"). Up and down still scroll the page. */
.swipe-row { position: relative; overflow: hidden; background: inherit; touch-action: pan-y; }
.swipe-content { position: relative; z-index: 1; background: inherit; }
.swipe-actions { position: absolute; top: 1px; right: 0; bottom: 0; display: flex; }
.swipe-actions button { min-width: 76px; border: 0; border-radius: 0; font-weight: 600; }
.swipe-actions .swipe-accent { background: var(--accent); color: var(--accent-text); }
.swipe-actions .swipe-danger { background: var(--error); color: var(--surface); }
@media (prefers-reduced-motion: no-preference) {
  .swipe-content { transition: transform 0.2s ease; }
  .swiping .swipe-content { transition: none; }
}

/* ----- Kế hoạch ----- */
.plan-head h3 { text-align: center; }
.plan-head input[type="date"] { width: auto; display: inline-block; }
.plan-head .row.center { margin-top: 8px; }
.suggestion { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.card-head + .suggestion { border-top: 0; }
.suggestion .badge { flex: none; min-width: 72px; text-align: center; }
.suggestion > button { flex: none; min-width: 44px; font-size: 1.2rem; }
.card .wide { margin-top: 12px; }
/* A task: what to study and why, the order tools beside it. */
.plan-task { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.card-head + .plan-task { border-top: 0; }
.plan-task .task-tools { display: flex; align-items: center; flex: none; }
.plan-task .task-tools button { min-width: 40px; }

/* ----- Hôm nay ----- */
.parent-note {
  margin-bottom: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-soft-text);
}
.parent-note p { font-size: 1.05rem; margin-top: 2px; }
button.parent-note { display: block; width: 100%; border: 0; text-align: left; font: inherit; }
.note-add { margin: 0 0 8px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 8px; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.cheer { color: var(--ok); font-weight: 600; margin: 4px 0 8px; }
.today-task { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); }
.today-task:first-child { border-top: 0; }
.tick-row {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; justify-content: flex-start;
  min-height: 56px; padding: 8px 0; border: 0; border-radius: 0; background: none; text-align: left;
}
.tick-row .tick { width: 30px; height: 30px; min-height: 30px; margin: 0; display: inline-flex; align-items: center; justify-content: center; }
.tick-row .task-title { font-size: 1.02rem; margin-top: 2px; }
.lesson-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ----- Tuần ----- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface-2); border-radius: var(--radius-small); padding: 10px; display: flex; flex-direction: column; }
.stat b { font-size: 1.3rem; }
.week-day { padding: 8px 0; border-top: 1px solid var(--border); }
.card-head + .week-day { border-top: 0; }
.small-bar { height: 6px; margin: 6px 0 0; }
.subject-bar { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; }
.subject-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.subject-bar .track { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.subject-bar .bar { display: block; height: 100%; border-radius: 999px; }
.subject-bar .bar[data-color] { background: currentColor; }  /* the subject's strong colour, readable in both themes */

/* Thông báo (Cài đặt). The notification cards sit in a box of their own, so space them like cards. */
#screen-caidat .screen-body > div:not(.card) > .card { margin-top: 12px; }
fieldset.checks { border: 0; margin: 12px 0 0; padding: 0; }
fieldset.checks legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-weight: 400; }
label.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
/* A tick inside a form (Lichhoc.form): its label may wrap and carry a hint, so the box sits by the first line. */
label.check-field { align-items: flex-start; margin-top: 14px; }
label.check-field input { margin: 1px 0 0; }
ol.steps { margin: 8px 0; padding-left: 22px; }
ol.steps li { margin: 4px 0; }
.device-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.device-row .badge { margin-left: 6px; }
#screen-caidat .screen-body > div:not(.card) + .card { margin-top: 12px; }
.plan-head h3 .small { font-weight: 400; }

/* Ghi nhanh: the floating button on every screen, and its preview list. The page leaves room under the
   content so the button never hides the last control. */
/* A family showing one tab only has no tab bar: nothing to keep room for at the bottom, and Cài đặt shows
   a way back to that tab. */
.back-link { margin-bottom: 12px; }
#app.no-tabbar { --tabbar-height: 0px; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-height) + 16px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 6px; padding: 12px 18px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}
.fab .icon { width: 20px; height: 20px; }
main { padding-bottom: calc(var(--tabbar-height) + 88px + env(safe-area-inset-bottom)); }
.quick-items { margin-top: 4px; }
.quick-item { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); }
.quick-item-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 8px 4px; border: 0; background: none; text-align: left;
}

/* Pull to refresh (Home Screen app): a pill that slides down from the top while pulling. */
#pull-refresh {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; z-index: 30; transform: translate(-50%, -48px);
  opacity: 0; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; pointer-events: none;
  background: var(--surface); color: var(--muted); font-size: 0.9rem; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
#pull-refresh:empty { display: none; }
