:root {
  --scale: 1;
  --font: 'Times New Roman', Times, serif;
  --page-bg: #fff; --title: #ff2a00; --subtitle: #ff8c1a;
  --header-bg: #007bff; --header-text: #fff;
  --row-bg: #f7f7f7; --row-alt-bg: #fff; --text: #111; --border: #c8c8c8;
  --day-bg: #eef5ff; --red: #e00000; --today-bg: #fff4c2; --notice-bg: #fde9e7;
}
* { box-sizing: border-box; }
html {
  /* cỡ chữ gốc co giãn theo màn hình: ~21px ở 1920x1080, ~42px ở 4K, tối thiểu 14px */
  font-size: calc(max(14px, min(1.1vw, 2vh)) * var(--scale));
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--page-bg); color: var(--text);
  font-family: var(--font); overflow: hidden;
}
body.hide-cursor, body.hide-cursor * { cursor: none !important; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* --------- tiêu đề --------- */
.top { position: relative; padding: .7em 1em .55em; text-align: center; flex: none; }
.top h1 {
  margin: 0; color: var(--title); font-size: 1.3em; font-weight: 700; letter-spacing: .01em;
  text-shadow: 1px 1px 1px rgba(0,0,0,.35); text-transform: none; line-height: 1.25;
}
.top h2 { margin: .3em 0 0; color: var(--subtitle); font-size: 1.1em; font-weight: 700; }
.clock {
  position: absolute; right: 1em; top: 50%; transform: translateY(-50%);
  text-align: right; font-weight: 700; color: var(--header-bg); line-height: 1.15;
}
.clock .t { font-size: 1.35em; font-variant-numeric: tabular-nums; }
.clock .d { font-size: .75em; color: var(--text); opacity: .75; }
.no-clock .clock { display: none; }

/* --------- bảng --------- */
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.thead-wrap { flex: none; }
.thead-wrap th {
  background: var(--header-bg); color: var(--header-text); text-align: left;
  padding: .55em .5em; font-size: 1em; font-weight: 700;
  border: 1px solid rgba(255,255,255,.35); text-shadow: 0 1px 1px rgba(0,0,0,.25);
}
.thead-wrap th.c-day, .thead-wrap th.c-session { text-align: center; }
.viewport { flex: 1; position: relative; overflow: hidden; }
.viewport.manual { overflow-y: auto; }
.track { will-change: transform; }
.track.paging { transition: transform .9s ease-in-out; }
.grid td {
  border: 1px solid var(--border); padding: .45em .5em; vertical-align: middle;
  font-size: 1em; line-height: 1.3; background: var(--row-bg); overflow-wrap: anywhere;
}
.grid tr.alt td { background: var(--row-alt-bg); }
.grid td.c-day { text-align: center; font-weight: 700; background: var(--day-bg); }
.grid td.c-day .dl { display: block; }
.sticky-on td.c-day, .sticky-on td.c-session { vertical-align: top; padding-top: 0; padding-bottom: 0; }
.stk { will-change: transform; }
.track.paging .stk { transition: transform .9s ease-in-out; }
.grid td.c-day .dd { display: block; font-weight: 400; font-size: .9em; margin-top: .15em; }
.grid td.c-session { text-align: center; font-style: italic; }
.grid td.c-day, .grid td.c-session, .grid td.c-time { overflow-wrap: normal; word-break: keep-all; padding-left: .2em; padding-right: .2em; }
.grid td.c-time { text-align: center; font-weight: 700; white-space: nowrap; }
.grid td.c-content { text-align: left; }
.grid td .ln { display: block; }
.grid td.red, .grid td.red * { color: var(--red); }
.grid tr.notice td.c-content { text-align: center; font-weight: 700; background: var(--notice-bg); }
.grid tr.today td { background: var(--today-bg); }
.grid td.c-day.today { background: var(--today-bg); box-shadow: inset .3em 0 0 var(--header-bg); }
.badge-today {
  display: inline-block; margin-top: .35em; padding: .1em .5em; border-radius: 1em;
  background: var(--header-bg); color: var(--header-text); font-size: .7em; font-weight: 700;
}
.grid tr.day-start td { border-top: 2px solid #7a7a7a; }

/* --------- ghi chú --------- */
.notes { padding: .8em 1.2em 1.2em; font-size: .95em; line-height: 1.45; text-align: justify; }
.notes p { margin: .25em 0; }
.notes .red { color: var(--red); }
.notes-title {
  margin: 0 0 .4em; padding: .35em .6em; background: var(--header-bg); color: var(--header-text);
  font-weight: 700; font-size: 1em;
}
.spacer { height: 1.5em; }
.empty { position: fixed; inset: 0; display: grid; place-items: center; font-size: 1.4em; color: #666; }
.empty[hidden] { display: none; }

/* --------- màn hẹp: dạng thẻ --------- */
.cards { padding: .5em .75em 2em; }
.cards .day { margin: 0 0 1em; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--row-alt-bg); }
.cards .day > h3 {
  margin: 0; padding: .55em .8em; background: var(--header-bg); color: var(--header-text);
  font-size: 1.05em; display: flex; justify-content: space-between; align-items: center; gap: .5em;
}
.cards .day.today > h3 { box-shadow: inset 0 -4px 0 #ffd43b; }
.cards .sess { padding: .3em .8em .1em; font-style: italic; font-weight: 700; color: var(--subtitle); }
.cards .item { padding: .5em .8em .6em; border-top: 1px solid var(--border); background: var(--row-bg); }
.cards .item.red .main, .cards .item .red { color: var(--red); }
.cards .item .main b { margin-right: .3em; }
.cards .item .meta { margin-top: .3em; font-size: .9em; color: #444; display: grid; gap: .15em; }
.cards .item .meta span i { font-style: normal; font-weight: 700; color: #333; }
.cards .item.notice { text-align: center; font-weight: 700; background: var(--notice-bg); }
.cards .empty-sess { padding: .3em .8em .6em; color: #888; font-size: .9em; }
body.mobile { overflow: auto; }
body.mobile #app { height: auto; min-height: 100vh; }
body.mobile .viewport { overflow: visible; }
body.mobile .thead-wrap { display: none; }
/* màn dọc (TV xoay đứng): chữ theo chiều ngang */
@media (orientation: portrait) and (min-width: 761px) {
  html { font-size: calc(max(14px, min(1.6vw, 1.3vh)) * var(--scale)); }
  .grid td.c-day .dd { font-size: .8em; }
}
/* tiêu đề dài / màn dọc / điện thoại: đồng hồ xuống dưới tiêu đề */
@media (orientation: portrait), (max-width: 1100px) {
  .top { padding-right: 1em; }
  .clock { position: static; transform: none; display: flex; justify-content: center; gap: .6em; align-items: baseline; margin-top: .3em; }
}
@media (max-width: 760px) {
  html { font-size: calc(16px * var(--scale)); }
  .top { padding: .6em .8em .5em; text-align: left; }
  .top h1 { font-size: 1.1em; }
  .top h2 { font-size: .95em; }
  .clock { position: static; transform: none; text-align: left; display: flex; gap: .6em; align-items: baseline; margin-top: .35em; }
  .clock .t { font-size: 1.05em; }
  .clock .d { font-size: .85em; }
}
