body {
  background: var(--cream);
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------page layout-------------------- */
.p-body {
  font-family: var(--general-font), serif;
  display: flex;
  flex: 1;
  align-items: flex-start;
}

/* ------------------sidebar-------------------- */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  padding: 32px 24px;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  background-color: var(--warm-white);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background-color: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 2px;
}

.filter-group {
  .filter-group-title {
    font-family: var(--header-font), serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.04em;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .filter-clear {
    font-family: var(--accent-font), serif;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted-light);
    cursor: pointer;
    letter-spacing: 0;
    transition: color 0.2s;
  }
  .filter-clear:hover {
    color: var(--red);
  }
  .filter-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .filter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    user-select: none;
  }
  .filter-label:hover {
    background: var(--cream);
    color: var(--ink);
  }

  .filter-label input[type="checkbox"] {
    display: none;
  }
  .cb-box {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    background: white;
  }
  .cb-box::after {
    content: "";
    width: 8px;
    height: 5px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translateY(-1px);
    opacity: 0;
    transition: opacity 0.15s;
  }
  .filter-label input:checked ~ .cb-box {
    background-color: var(--red);
    border-color: var(--red);
  }
  .filter-label input:checked ~ .cb-box::after {
    opacity: 1;
  }
  .filter-label input:checked ~ span {
    color: var(--ink);
    font-weight: 600;
  }

  .filter-count {
    margin-left: auto;
    font-family: var(--accent-font), serif;
    font-size: 11px;
    color: var(--muted-light);
    background-color: var(--cream);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 500;
  }
}

.filter-toggle-bar {
  padding: 12px 5%;
  border-bottom: 1px solid var(--border);
  background-color: var(--warm-white);
  cursor: pointer;
  font-family: var(--general-font), serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: none;
}
.filter-toggle-bar svg {
  width: 16px;
  height: 16px;
  stroke: var(--muted);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 36px 40px 60px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-left {
  .page-title {
    font-family: var(--header-font), serif;
    font-size: 30px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.2;
  }
  .page-count {
    font-family: var(--accent-font), serif;
    font-size: 13px;
    color: var(--muted);
    font-weight: 400;
    margin-top: 4px;
  }

  .page-count strong {
    color: var(--ink);
    font-weight: 700;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  .search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 14px;
    flex: 1;
    min-width: 180px;
    transition: border-color 0.2s;
  }
  .search-box:focus-within {
    border-color: var(--red);
  }
  .search-box svg {
    width: 15px;
    height: 15px;
    stroke: var(--muted-light);
    flex-shrink: 0;
  }
  .search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    font-family: var(--accent-font), serif;
    color: var(--ink);
    width: 100%;
  }
  .search-box input::placeholder {
    color: var(--muted-light);
  }

  .sort-select {
    appearance: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 32px 8px 12px;
    font-family: var(--accent-font), serif;
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7268' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    outline: none;
    transition: border-color 0.2s;
  }
  .sort-select:focus {
    border-color: var(--red);
  }
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red-pale);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.filter-chip:hover {
  background: #f9d8d4;
}
.filter-chip span {
  font-size: 14px;
  line-height: 1;
}

.clear-all {
  font-size: 12px;
  color: var(--muted-light);
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}
.clear-all:hover {
  color: var(--red);
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  min-height: 28px;
}
.active-filters-label {
  font-family: var(--accent-font), serif;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.course-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 0.25s,
    box-shadow 0.25s,
    border-color 0.25s;
  animation: cardIn 0.4s ease both;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 0 rgba(15, 13, 14, 0.1);
  border-color: var(--border-strong);
}

.course-card-accent {
  height: 4px;
  background: var(--red);
  transition: height 0.2s;
}
.course-card:hover .course-card-accent {
  height: 5px;
}

/* Color variants */
.acc-blue {
  background: #4a90c8;
}
.acc-green {
  background: #3a9e6a;
}
.acc-amber {
  background: #c9922a;
}
.acc-teal {
  background: #2a9e9e;
}
.acc-red {
  background: var(--red);
}
.acc-purple {
  background: #7a5ccf;
}

.course-card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.course-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.tag-type {
  background: var(--red-pale);
  color: var(--red);
}
.tag-level {
  background: #eef4fb;
  color: #2a5e8a;
}
.tag-season {
  background: #fdf4e3;
  color: #8a5a10;
}

.course-name {
  font-family: var(--general-font), serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.course-dates {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--accent-font), serif;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.course-dates svg {
  width: 13px;
  height: 13px;
  stroke: var(--muted-light);
  flex-shrink: 0;
}

.course-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
  font-weight: 300;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-divider {
  height: 1px;
  background: var(--border);
  margin: 0 -20px;
  width: calc(100% + 40px);
}

.course-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}
.course-slots {
  font-family: var(--accent-font), serif;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.course-slots svg {
  width: 13px;
  height: 13px;
  stroke: var(--muted-light);
}
.slots-count {
  color: var(--ink);
  font-weight: 600;
}

.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "Noto Sans Thai", sans-serif;
}
.btn-contact:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
}

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty-icon {
  font-size: 48px;
  opacity: 0.3;
}
.empty-title {
  font-family: "Noto Serif Thai", serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
}
.empty-sub {
  font-size: 14px;
  color: var(--muted-light);
  max-width: 280px;
  line-height: 1.7;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 190px;
  }
  .courses-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .main {
    padding: 28px 28px 60px;
  }
}

@media (max-width: 640px) {
  nav {
    padding: 0 5%;
  }
  .nav-links,
  .nav-desktop-cta {
    display: none;
  }

  .nav-hamburger {
    display: flex;
  }

  .nav-logo-text {
    font-size: 13px;
  }

  .mobile-menu-tab > button.btn-red {
    color: white;
  }

  .filter-toggle-bar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba (0, 0, 0, 0);
    height: auto;
    width: 280px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 79;
    opacity: 0;
    transition: opacity 0.3s;
  }
  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  .main {
    padding: 20px 5% 48px;
  }
  .courses-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .page-title {
    font-size: 24px;
  }
  .course-slots {
    align-items: flex-start;
    width: 100%;
  }
  .course-footer {
    flex-direction: column;
    gap: 14px;
  }
  .course-footer > a {
    width: 100%;
    justify-content: center;
  }
}
@media (max-width: 520px) {
  .toolbar {
    align-items: stretch;
  }
  .search-box {
    min-width: unset;
  }
  footer {
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    text-align: center;
  }
  footer > div:nth-child(2) {
    display: none;
  }
  .footer-logo {
    justify-content: center;
  }
  .footer-socials {
    justify-content: center;
  }
}
