/* shared sidebar — edit once, applies to all chapter pages */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(15, 15, 20, 0.1);
  border-radius: 3px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  margin-bottom: 8px;
}
.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  display: block;
}
.brand-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.top-nav {
  display: flex;
  flex-direction: column;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.top-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-soft);
  font-weight: 600;
  border-bottom: none;
  transition: background 120ms ease;
  text-decoration: none;
}
.top-nav-item:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-bottom: none;
}
.top-nav-item .ico {
  font-size: 15px;
  opacity: 0.85;
}
.top-nav-item.active {
  color: var(--accent-strong);
  background: var(--accent-bg);
}
/* 전체 자료 저장 — 작은 라벨 + HTML/PDF 2분할 버튼 */
.dl-caption {
  margin: 8px 0 5px;
  padding: 0 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.dl-row {
  display: flex;
  gap: 6px;
}
.dl-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.dl-btn .ico {
  font-size: 12.5px;
  opacity: 0.85;
}
.dl-btn:hover {
  border-color: rgba(124, 58, 237, 0.28);
  background: var(--accent-bg);
  color: var(--accent-strong);
}
.dl-btn:disabled {
  cursor: progress;
  opacity: 0.72;
}

.ch-nav {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 0 12px 24px;
}

/* 모듈 그룹핑(선택) — 챕터가 많을 때 nav를 모듈 단위로 묶는다.
   주: 학생용엔 시간 표시 금지이므로 .mod-label에 소요시간(.mod-time)은 두지 않는다. */
.mod-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mod-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 12px 4px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent-strong);
  line-height: 1.35;
}
.mod-group:first-child .mod-label {
  border-top: none;
  padding-top: 2px;
}
.mod-label .soon {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}
.ch-block {
  display: flex;
  flex-direction: column;
}
.ch-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 12px 6px;
  border-bottom: none;
  color: var(--text);
  font-weight: 800;
  font-size: 13.5px;
  text-decoration: none;
}
.ch-head:hover {
  border-bottom: none;
  color: var(--accent-strong);
}
.ch-head .ch-num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  min-width: 22px;
}
.ch-head .ch-name {
  line-height: 1.4;
}
.ch-block.current .ch-head .ch-num,
.ch-block.current .ch-head .ch-name {
  color: var(--accent-strong);
}
/* 현재 보고 있는 챕터 — 또렷한 알약 하이라이트 */
.ch-block.active .ch-head {
  background: var(--accent-bg);
  border-radius: 8px;
}
.ch-block.active .ch-head .ch-num,
.ch-block.active .ch-head .ch-name {
  color: var(--accent-strong);
}
.ch-block.active .ch-head .ch-name {
  font-weight: 800;
}
.ch-block.upcoming .ch-head {
  opacity: 0.4;
}
.ch-block.upcoming .ch-head .ch-name::after {
  content: " · 준비 중";
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.sub {
  list-style: none;
  padding: 0;
  margin: 6px 0 0 22px;
  border-left: 1px solid var(--border);
}
.sub li {
  margin: 0;
}
.sub a {
  display: block;
  padding: 7px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  font-weight: 500;
  border-left: 2px solid transparent;
  margin-left: -1px;
  border-bottom: none;
  transition: all 120ms ease;
  text-decoration: none;
}
.sub a:hover {
  color: var(--text);
  background: var(--bg-soft);
  border-bottom: none;
}
.sub a.active {
  color: var(--accent-strong);
  font-weight: 700;
  border-left-color: var(--accent-strong);
  background: var(--accent-bg);
}

.view-toggle {
  margin: 16px 16px 8px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}
body.student-view .view-toggle {
  display: none;
}
.view-toggle code {
  color: var(--accent-strong);
  background: var(--accent-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.view-toggle a {
  color: var(--text);
  font-weight: 700;
  border-bottom: none;
  text-decoration: none;
}
.open-student-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(124, 58, 237, 0.2);
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease;
}
.open-student-btn:hover {
  background: rgba(124, 58, 237, 0.15);
}

/* site-search — 사이드바 상단 교안 전체 검색.
   결과 패널은 사이드바 위에 겹쳐 뜬다(사이드바 자체를 밀지 않기 위해). */
.site-search {
  position: relative;
  padding: 0 12px 12px;
}
.sr-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 34px 8px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-soft, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 130ms ease, background-color 130ms ease;
}
.sr-input::placeholder { color: var(--text-muted); }
.sr-input:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
}
.sr-input::-webkit-search-cancel-button { cursor: pointer; }
.sr-hint {
  position: absolute;
  top: 8px;
  right: 22px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}
.sr-input:focus ~ .sr-hint { display: none; }

.sr-panel {
  display: none;
  position: absolute;
  top: calc(100% - 6px);
  left: 12px;
  right: 12px;
  z-index: 60;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 15, 20, 0.14);
}
.sr-panel.open { display: block; }
.sr-count,
.sr-empty {
  padding: 6px 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.sr-page { margin-top: 4px; }
.sr-page-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 8px 2px;
}
.sr-mod {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-strong);
  white-space: nowrap;
}
.sr-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sr-hit {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-soft);
}
.sr-hit:hover,
.sr-hit.active { background: var(--accent-bg); color: var(--text); }
.sr-hit mark {
  background: #fde68a;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* 공개 전 회차 — 링크 없이 안내만 */
.ch-locked { margin: 4px 0 8px; padding: 10px 12px; border: 1px dashed var(--border, #ddd); border-radius: 10px; font-size: 13px; color: var(--text-muted, #888); }
