* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  overflow-x: hidden;
}

body {
  padding: 8px;
  background: #fff;
  color: #111827;
  font-family: Arial, sans-serif;
}

.tb-course-widget {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 14px;
  overflow: hidden;
  border: 1px solid #dce7f3;
  border-radius: 14px;
  background: #f7faff;
}

.tb-course-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.tb-course-heading { min-width: 0; }

.tb-course-heading h2 {
  margin: 0 0 4px;
  color: #111827;
  font-size: 22px;
  line-height: 1.25;
}

.tb-course-heading p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.4;
}

.tb-course-controls {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.tb-course-select,
.tb-course-search {
  height: 38px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #111827;
  font-size: 13px;
  outline: none;
}

.tb-course-select { width: 180px; }
.tb-course-search { width: 190px; }

.tb-course-slider { position: relative; min-width: 0; }

.tb-course-track {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  padding: 2px 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-inline: contain;
}

.tb-course-track::-webkit-scrollbar { display: none; }

.tb-course-card {
  display: flex;
  flex: 0 0 180px;
  flex-direction: column;
  width: 180px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .08);
  scroll-snap-align: start;
}

.tb-course-card[hidden] { display: none; }

.tb-course-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e2e8f0;
}

.tb-course-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 9px;
}

.tb-course-label {
  display: inline-block;
  width: fit-content;
  margin-bottom: 7px;
  padding: 3px 8px;
  border-radius: 20px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
}

.tb-course-title {
  display: -webkit-box;
  min-height: 56px;
  margin: 0 0 8px;
  overflow: hidden;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tb-course-meta {
  margin-bottom: 10px;
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-course-button {
  display: block;
  width: 100%;
  margin-top: auto;
  padding: 8px;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.tb-course-button:hover { background: #1d4ed8; }

.tb-course-nav {
  position: absolute;
  top: 50%;
  z-index: 10;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  transform: translateY(-50%);
}

.tb-course-prev { left: -10px; }
.tb-course-next { right: -10px; }

.tb-course-message {
  padding: 22px 10px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
}

.tb-course-error { color: #b91c1c; }

@media (max-width: 700px) {
  body { padding: 0; }

  .tb-course-widget {
    max-width: 100%;
    padding: 9px;
    border-radius: 11px;
  }

  .tb-course-header {
    flex-direction: column;
    gap: 9px;
    margin-bottom: 9px;
  }

  .tb-course-heading,
  .tb-course-controls {
    width: 100%;
    min-width: 0;
  }

  .tb-course-heading h2 { font-size: 18px; line-height: 1.2; }
  .tb-course-heading p { font-size: 11px; line-height: 1.35; }

  .tb-course-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .tb-course-select,
  .tb-course-search {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 38px;
    font-size: 16px;
  }

  .tb-course-track {
    gap: 9px;
    padding: 2px 28px 7px 0;
    scroll-snap-type: x mandatory;
  }

  .tb-course-card {
    flex-basis: calc(100% - 30px);
    width: calc(100% - 30px);
    max-width: 310px;
  }

  .tb-course-title {
    min-height: 0;
    font-size: 13px;
  }

  .tb-course-body { padding: 8px; }
  .tb-course-nav { display: none; }
}

@media (min-width: 520px) and (max-width: 700px) {
  .tb-course-card {
    flex-basis: calc(50% - 5px);
    width: calc(50% - 5px);
    max-width: none;
  }
}
