:root {
  --bg: #ebe4d8;
  --paper: #f7f3ec;
  --ink: #1c1916;
  --muted: #6f675d;
  --line: rgba(28, 25, 22, 0.12);
  --anh: #0f6b52;
  --anh-soft: #e4f3ec;
  --toan: #b4532a;
  --toan-soft: #fde8dc;
  --gt: #2a3d86;
  --gt-soft: #e6e9f6;
  --ct: #5c5346;
  --ct-soft: #efe8dc;
  --shadow: 0 16px 40px rgba(60, 42, 20, 0.08);
  --font: "Be Vietnam Pro", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(255, 255, 255, 0.7), transparent 50%),
    var(--bg);
  min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }
code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92em;
}

.wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}
.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(36px, 5vw, 56px);
  letter-spacing: -0.03em;
  line-height: 0.95;
}
.range {
  margin: 0;
  color: var(--muted);
  text-align: right;
  font-size: 14px;
}

.hero {
  background: var(--ink);
  color: #f6f1e8;
  border-radius: 18px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  box-shadow: var(--shadow);
}
.hero .when { margin: 0; color: #c9c0b3; font-size: 13px; font-weight: 600; }
.hero h2 {
  margin: 4px 0 0;
  font-family: var(--display);
  font-weight: 560;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.hero .left strong {
  display: block;
  margin-top: 8px;
  color: #f0c9a0;
  font-size: 15px;
}
.hero-list { display: grid; gap: 8px; align-content: center; }
.hero-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
}
.dot { width: 10px; height: 10px; border-radius: 99px; }
.dot.anh { background: #7dcead; }
.dot.toan { background: #f0a37a; }
.dot.gt { background: #a9b6ee; }
.dot.ct { background: #d9cbb6; }
.hero-item b { display: block; font-size: 14px; }
.hero-item span { color: #c9c0b3; font-size: 13px; }
.hero-item em { font-style: normal; color: #f6f1e8; font-size: 13px; font-weight: 600; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 16px 0 10px;
  flex-wrap: wrap;
}
.filters, .views { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button, .views button, .weekbar > button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
}
.filters button[aria-pressed="true"] { color: white; border-color: transparent; }
.filters button[data-subject="all"][aria-pressed="true"] { background: var(--ink); }
.filters button[data-subject="anh"][aria-pressed="true"] { background: var(--anh); }
.filters button[data-subject="toan"][aria-pressed="true"] { background: var(--toan); }
.filters button[data-subject="gt"][aria-pressed="true"] { background: var(--gt); }
.filters button[data-subject="ct"][aria-pressed="true"] { background: var(--ct); }
.views button[aria-pressed="true"] { background: var(--ink); color: white; border-color: var(--ink); }
.filters button:focus-visible, .views button:focus-visible, .weekbar button:focus-visible, .textbtn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.weekbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.weekbar > button { width: 40px; height: 40px; padding: 0; }
.weeklabel { text-align: center; }
.weeklabel strong { display: block; font-size: 15px; }
.textbtn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.weekbar.is-hidden { display: none; }

.sheet {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}
.sheet-head, .trow {
  display: grid;
  grid-template-columns: 64px minmax(1152px, 1fr);
}
.gutter {
  position: sticky;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--paper);
  border-right: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.gutter b { font-size: 16px; letter-spacing: 0; }
.trow.is-today .gutter { background: white; color: var(--ink); }
.trow { border-top: 1px solid var(--line); }
.trow.is-today { background: white; }
.scale { position: relative; }
.bands {
  display: grid;
  grid-template-columns: 1fr 1fr;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.bands span { padding: 8px 10px; }
.bands span:first-child { background: #f3ecdf; }
.bands span:last-child {
  background: #e7efe9;
  border-left: 2px solid rgba(28, 25, 22, 0.28);
}
.hours {
  display: grid;
  grid-template-columns: repeat(24, minmax(48px, 1fr));
  border-top: 1px solid var(--line);
}
.hours span {
  padding: 4px 0 6px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border-left: 1px solid var(--line);
}
.hours span:nth-child(13) { border-left: 2px solid rgba(28, 25, 22, 0.28); }
.track {
  position: relative;
  background-color: #f7f3ec;
  background-image: repeating-linear-gradient(to right, rgba(28, 25, 22, 0.08) 0 1px, transparent 1px calc(100% / 24));
}
.trow.is-today .track { background-color: white; }
.track::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(28, 25, 22, 0.28);
  pointer-events: none;
}
.block {
  position: absolute;
  z-index: 1;
  height: 40px;
  overflow: hidden;
  border-radius: 8px;
  padding: 4px 6px;
}
.block b, .block span { display: block; white-space: nowrap; }
.block b { font-size: 12px; }
.block span { color: var(--muted); font-size: 11px; }
.block.free {
  z-index: 0;
  background: repeating-linear-gradient(-45deg, transparent, transparent 5px, rgba(28, 25, 22, 0.035) 5px, rgba(28, 25, 22, 0.035) 6px);
  color: #8a8176;
}
.block.anh { background: var(--anh-soft); }
.block.toan { background: var(--toan-soft); }
.block.gt { background: var(--gt-soft); }
.block.ct { background: var(--ct-soft); }
.block.is-past { opacity: 0.48; }
.block.anh b { color: var(--anh); }
.block.toan b { color: var(--toan); }
.block.gt b { color: var(--gt); }
.block.ct b { color: var(--ct); }

.agenda { display: none; }

.months { display: grid; gap: 18px; }
.month h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 6px;
}
.row.anh { border-left-color: var(--anh); }
.row.toan { border-left-color: var(--toan); }
.row.gt { border-left-color: var(--gt); }
.row.ct { border-left-color: var(--ct); }
.row.is-past { opacity: 0.5; }
.row time { display: grid; line-height: 1.1; }
.row time b { font-size: 20px; }
.row time span { color: var(--muted); font-size: 12px; font-weight: 600; }
.row h3 { margin: 0; font-size: 15px; }
.row p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.pill {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
  background: #efe7da;
  color: var(--ink);
  white-space: nowrap;
}
.pill.soon { background: #f3d7b0; }
.pill.live { background: #d7efdf; color: #0f6b52; }
.pill.done { background: transparent; color: var(--muted); }

.foot { color: var(--muted); font-size: 13px; margin: 22px 0 0; }

@media (max-width: 720px) {
  .wrap { width: min(1180px, calc(100% - 20px)); }
  .top { display: block; }
  .range { text-align: left; margin-top: 8px; }
  .hero { grid-template-columns: 1fr; padding: 14px; }
  .hero h2 { font-size: 24px; }
  .toolbar { align-items: stretch; }
  .views { width: 100%; }
  .views button { flex: 1; }
  .row { grid-template-columns: 64px 1fr; }
  .pill { grid-column: 2; justify-self: start; }

  .sheet {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .sheet-head, .track { display: none; }
  .trow {
    display: block;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    overflow: hidden;
  }
  .gutter {
    position: static;
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .agenda { display: block; padding: 10px 10px 12px; }
  .strip {
    position: relative;
    height: 16px;
    margin-bottom: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: #f3ecdf linear-gradient(to right, #f3ecdf 50%, #e7efe9 50%);
  }
  .strip::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(28, 25, 22, 0.35);
  }
  .strip i { position: absolute; top: 0; bottom: 0; }
  .strip i.anh { background: var(--anh); }
  .strip i.toan { background: var(--toan); }
  .strip i.gt { background: var(--gt); }
  .strip i.ct { background: var(--ct); }
  .half { margin-top: 8px; }
  .half h3 {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .slot {
    display: grid;
    grid-template-columns: 108px 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
    padding: 8px;
    border-radius: 10px;
  }
  .slot time { font-size: 12px; font-weight: 700; }
  .slot b { display: block; font-size: 14px; }
  .slot span { color: var(--muted); font-size: 12px; }
  .slot.free { background: transparent; color: #8a8176; border: 1px dashed var(--line); }
  .slot.anh { background: var(--anh-soft); }
  .slot.toan { background: var(--toan-soft); }
  .slot.gt { background: var(--gt-soft); }
  .slot.ct { background: var(--ct-soft); }
  .slot.is-past { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}

@media print {
  body { background: white; }
  .toolbar, .weekbar, .foot, .hero { display: none; }
  .sheet { overflow: visible; }
  .trow { break-inside: avoid; }
}
