:root {
  --bg: #f4f7fa;
  --card: #ffffff;
  --ink: #1f2d38;
  --muted: #5f7180;
  --line: #dde5ec;
  --brand: #263744;
  --accent: #ffb300;
  --accent-ink: #263238;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141c22;
    --card: #1d2830;
    --ink: #e8eef2;
    --muted: #9aabb8;
    --line: #2c3a44;
    --brand: #0f171c;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.hero { background: var(--brand); color: #fff; padding: 28px 0 22px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 700; }
.hero p { margin: 8px 0 18px; color: #c9d6df; max-width: 640px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input, .filters select {
  font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid #3b5160;
  background: #fff; color: #1f2d38;
}
.filters input { flex: 1 1 280px; min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chips button {
  font: inherit; font-size: 14px; border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer;
  background: #37505f; color: #dfe8ee;
}
.chips button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.count { color: var(--muted); font-size: 14px; margin: 18px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; color: inherit; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.12); outline: none; }
.thumb { aspect-ratio: 16 / 9; background: #e3edf5; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.meta { display: flex; gap: 8px; font-size: 12px; }
.subject { padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.grades { color: var(--muted); padding: 2px 0; }
.card h3 { font-size: 17px; margin: 2px 0 0; line-height: 1.35; }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.open { margin-top: 6px; font-weight: 600; font-size: 14px; color: #e08e00; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.foot { color: var(--muted); font-size: 13px; padding: 32px 16px; text-align: center; }

/* nút, tiêu đề mục */
.btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 20px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.06); }
.section-title { font-size: 20px; margin: 28px 0 14px; display: flex; align-items: center; gap: 10px; }
.section-title small { font-size: 13px; font-weight: 400; color: var(--muted); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.more { color: #e08e00; font-weight: 600; text-decoration: none; white-space: nowrap; }
.more:hover { text-decoration: underline; }

/* ô môn học ở trang chủ */
.subjects { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.subject-tile {
  --c: #607d8b; --soft: #eceff1;
  display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto auto; column-gap: 14px; row-gap: 2px;
  padding: 18px; border-radius: 16px; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--c);
  transition: transform .15s ease, box-shadow .15s ease;
}
.subject-tile:hover, .subject-tile:focus-visible { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.12); outline: none; }
.subject-tile .icon {
  grid-row: 1 / 4; width: 56px; height: 56px; border-radius: 14px; background: var(--soft);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.subject-tile .name { font-size: 19px; font-weight: 700; color: var(--c); }
.subject-tile .blurb { font-size: 13px; color: var(--muted); }
.subject-tile .n { font-size: 13px; font-weight: 600; margin-top: 4px; color: var(--c); }

/* trang thư viện */
.hero.compact { padding: 16px 0 18px; }
.brand.small { font-size: 16px; gap: 8px; color: #fff; text-decoration: none; opacity: .9; }
.brand.small:hover { opacity: 1; }
.hero h1 { font-size: 26px; margin: 10px 0 14px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button {
  --c: var(--accent);
  font: inherit; font-size: 15px; border: 2px solid transparent; border-radius: 12px; padding: 8px 14px; cursor: pointer;
  background: #37505f; color: #e4ecf1; display: inline-flex; align-items: center; gap: 8px;
}
.tabs button small { background: rgba(255,255,255,.16); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.tabs button:hover:not(.active) { background: #446373; }
.tabs button.active { background: #fff; color: var(--ink); border-color: var(--c); font-weight: 600; }
.tabs button.active small { background: var(--c); color: #fff; }
.subject-section .section-title .dot {
  width: 36px; height: 36px; border-radius: 10px; background: var(--soft);
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px;
}
.subject-section .section-title .t { color: var(--c); }
.subject-section + .subject-section { border-top: 1px solid var(--line); margin-top: 28px; }
.placeholder {
  border: 2px dashed var(--line); border-radius: 14px; padding: 26px; text-align: center; color: var(--muted);
}
@media (prefers-color-scheme: dark) {
  .tabs button.active { background: var(--card); color: var(--ink); }
}
