:root {
  color: #162033;
  --bg: #f0f5ff;
  --card: #ffffff;
  --line: #dbe5f9;
  --accent: #1f5ce9;
  --accent-soft: #d7e4ff;
  --text-muted: #5d6c86;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at 12% 2%, #e9f0ff 0, transparent 28%),
    radial-gradient(circle at 90% 20%, #f1e8ff 0, transparent 34%),
    var(--bg);
  color: #132040;
}

.shell {
  max-width: 1280px;
  margin: 32px auto 60px;
  padding: 0 18px;
}

.lecture-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: flex;
  max-height: calc(100vh - 24px);
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 12px 24px rgba(17, 39, 89, 0.08);
}

.sidebar h2 {
  margin: 0 0 10px;
  border-radius: 10px;
  background: linear-gradient(135deg, #142b61, #28519a);
  color: #ffffff;
  padding: 10px 11px;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  box-shadow: 0 6px 14px rgba(20, 43, 97, 0.2);
}

.course-home-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.course-home-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.course-home-link:focus-visible {
  border-radius: 5px;
  outline: 3px solid #ffb74d;
  outline-offset: 3px;
}

.course-materials {
  margin-bottom: 12px;
}

.course-materials h3 {
  margin: 0 0 6px;
  color: #26395f;
  font-size: 0.84rem;
}

.material-links {
  display: grid;
  gap: 6px;
}

.material-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #b8c8f0;
  border-radius: 8px;
  background: #f7f9ff;
  color: #16307a;
  padding: 7px 8px;
  font-size: 0.81rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}

.material-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.material-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.material-meta {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
}

.global-search {
  position: relative;
  margin-bottom: 12px;
  border: 2px solid #f0a23b;
  border-radius: 12px;
  background: linear-gradient(145deg, #ffead0, #fff7e9);
  padding: 10px;
  box-shadow: 0 7px 16px rgba(194, 84, 0, 0.16);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.global-search:focus-within {
  border-color: #d97706;
  box-shadow:
    0 0 0 3px rgba(245, 158, 11, 0.2),
    0 9px 20px rgba(194, 84, 0, 0.2);
}

.global-search label {
  display: block;
  margin: 0 0 7px;
  color: #8a3d00;
  font-size: 0.9rem;
  font-weight: 800;
}

#global-search-input {
  width: 100%;
  border: 2px solid #e0a052;
  border-radius: 8px;
  background-color: #ffffff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b45309' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E");
  background-position: 10px center;
  background-repeat: no-repeat;
  color: #132040;
  padding: 10px 10px 10px 36px;
  font: inherit;
  font-size: 0.9rem;
  box-shadow: 0 2px 7px rgba(194, 84, 0, 0.1);
}

#global-search-input:hover {
  border-color: #d97706;
}

#global-search-input:focus {
  border-color: #d97706;
  outline: 3px solid #ffdfb5;
  outline-offset: 1px;
}

.global-search-status {
  min-height: 1.1rem;
  margin: 6px 1px 0;
  color: #43577c;
  font-size: 0.76rem;
  line-height: 1.35;
}

.global-search-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  width: min(430px, calc(100vw - 36px));
  max-height: min(65vh, 560px);
  overflow-y: auto;
  border: 1px solid #9eb2e2;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(17, 39, 89, 0.2);
}

.global-search-results[hidden] {
  display: none;
}

.global-search-result {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  padding: 10px 12px;
  text-align: left;
}

.global-search-result:first-child {
  border-radius: 9px 9px 0 0;
}

.global-search-result:last-child {
  border-bottom: 0;
  border-radius: 0 0 9px 9px;
}

.global-search-result:only-child {
  border-radius: 9px;
}

.global-search-result:hover,
.global-search-result:focus-visible {
  background: #edf4ff;
  outline: none;
}

.global-search-result-title {
  display: block;
  color: #142b61;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
}

.global-search-result-summary {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  color: #334767;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.global-search-result-meta {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.lecture-nav {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  scrollbar-gutter: stable;
}

.lecture-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid #b8c8f0;
  background: #edf2ff;
  color: #16307a;
  border-radius: 8px;
  padding: 8px 9px;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
}

.lecture-item:hover {
  background: var(--accent-soft);
}

.lecture-item.active {
  background: #e8edff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #d7e4ff inset;
}

.lesson-workspace {
  min-width: 0;
}

.lesson-workspace h1 {
  margin: 0 0 6px;
}

.header {
  margin-bottom: 14px;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
}

.header p {
  margin: 0;
  color: var(--text-muted);
}

.status {
  padding: 10px 14px;
  border-radius: 10px;
  min-height: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: #f8fbff;
}

.status[hidden] {
  display: none;
}

.status.error {
  color: #a0182a;
  border-color: #facfd6;
  background: #fff4f6;
}

.sync-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr);
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 24px rgba(17, 39, 89, 0.08);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.slide-card {
  position: relative;
}

#slide-image {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fd;
  min-height: 320px;
  object-fit: contain;
}

#slide-caption {
  min-height: 1.2rem;
  margin: 10px 0 0;
  border: 1px solid #b9caee;
  border-left: 4px solid #28519a;
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fbff, #eef4ff);
  padding: 11px 12px 12px;
  color: #243657;
  box-shadow: 0 5px 14px rgba(20, 43, 97, 0.08);
}

#slide-caption.empty {
  border-left-color: #91a0bb;
  color: var(--text-muted);
}

.slide-note-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.slide-note-kicker,
.slide-note-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.slide-note-kicker {
  background: #142b61;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.slide-note-chip {
  border: 1px solid #c7d4ef;
  background: #ffffff;
  color: #40547a;
}

.slide-note-topic {
  margin: 0;
  color: #142b61;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.4;
}

.slide-note-summary {
  margin: 5px 0 0;
  color: #334767;
  font-size: 0.88rem;
  line-height: 1.55;
}

.slide-note-takeaway {
  margin: 8px 0 0;
  border-radius: 7px;
  background: #fff3df;
  padding: 7px 9px;
  color: #69431a;
  font-size: 0.85rem;
  line-height: 1.5;
}

.slide-note-takeaway-label {
  color: #9a4f08;
}

.media-card video {
  width: 100%;
  border-radius: 8px;
  background: #111;
}

.control-row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 1px solid #b8c8f0;
  background: #edf2ff;
  color: #16307a;
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-soft);
}

label {
  display: inline-block;
  margin-top: 12px;
  margin-bottom: 6px;
  color: var(--text-muted);
}

#time-slider {
  width: 100%;
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--text-muted);
}

.timeline-card {
  margin-top: 14px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.lecture-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.lecture-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.marker {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  background: #fbfdff;
  font-size: 0.95rem;
}

.marker:hover {
  background: #f0f6ff;
}

.marker.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #d7e4ff inset;
}

.marker-time {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 4px;
  white-space: nowrap;
}

.marker-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-weight: 600;
}

.marker-desc {
  color: #1b2f5a;
  font-size: 0.87rem;
  margin-top: 4px;
}

.footerbar {
  margin-top: 14px;
  border: 1px solid #29487f;
  border-radius: 14px;
  background: linear-gradient(135deg, #142b61, #203f7a);
  color: #edf4ff;
  padding: 14px 20px;
  text-align: center;
  box-shadow: 0 12px 24px rgba(17, 39, 89, 0.14);
}

.footerbar p {
  max-width: 1080px;
  margin: 0 auto;
  font-size: 0.88rem;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .lecture-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    top: auto;
    max-height: min(62vh, 520px);
  }

  .global-search-results {
    width: 100%;
  }

  .timeline {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

@media (max-width: 700px) {
  .shell {
    margin-top: 16px;
    padding: 0 10px;
  }

  .sync-layout {
    grid-template-columns: 1fr;
  }

  .header-row {
    align-items: center;
    flex-direction: column;
    gap: 8px;
  }

  .timeline {
    grid-template-columns: 1fr;
  }

  #slide-image {
    min-height: 180px;
  }

  .footerbar {
    padding: 12px 14px;
  }

  .footerbar p {
    font-size: 0.82rem;
  }
}
