.course-viewer-page {
  display: flex;
  flex-direction: column;
  padding-bottom: 100px;
}

/* Loading */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 32px;
  color: #1abc9c;
}

.loading-spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Header */
.viewer-header {
  padding: 16px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.back-btn {
  width: 40px;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
}

.edit-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

/* Hero */
.course-hero {
  margin-bottom: 16px;
}

.course-icon-wrap {
  width: 52px;
  height: 52px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text);
  margin-bottom: 10px;
}

.community-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.course-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 8px;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.course-description {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.5;
}

.course-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.meta-dot {
  color: var(--border);
}

/* Progress card */
.progress-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.progress-value {
  font-size: 13px;
  font-weight: 700;
  color: #1abc9c;
}

.progress-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

/* Enroll button */
.enroll-btn {
  width: 100%;
  background-color: var(--primary);
  color: var(--primary-fg);
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.enroll-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.enroll-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Restart button */
.restart-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
}

.restart-btn:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
}

/* Topics section */
.topics-section {
  padding: 20px 20px 0;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}

.empty-topics {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 32px 0;
}

.topic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  overflow: hidden;
}

.topic-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  user-select: none;
}

.topic-position {
  width: 28px;
  height: 28px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.topic-info {
  flex: 1;
  min-width: 0;
}

.topic-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}

.topic-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 4px;
  line-height: 1.4;
}

.resource-count {
  font-size: 11px;
  color: var(--text-muted);
}

.topic-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topic-position.done {
  background: rgba(26, 188, 156, 0.15);
  border-color: #1abc9c;
  color: #1abc9c;
}

.topic-done .topic-title {
  text-decoration: line-through;
  opacity: 0.6;
}

.mark-done-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.mark-done-btn:hover {
  border-color: #1abc9c;
  color: #1abc9c;
}

.expand-icon {
  font-size: 14px;
  color: var(--text-muted);
}

/* Resources */
.resources-list {
  border-top: 1px solid var(--border);
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.resource-item:last-child {
  border-bottom: none;
}

.resource-item:active {
  background: var(--card);
}

.resource-done {
  opacity: 0.6;
}

.resource-icon {
  width: 34px;
  height: 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}

.resource-icon.done {
  background: rgba(26, 188, 156, 0.15);
  border-color: #1abc9c;
  color: #1abc9c;
}

.resource-info {
  flex: 1;
  min-width: 0;
}

.resource-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-type {
  font-size: 11px;
  color: var(--text-muted);
}

.resource-open {
  color: #1abc9c;
  font-weight: 600;
}

.resource-text-content {
  padding: 12px 14px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mark-read-btn {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #1abc9c;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
