:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #68748a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #dbe3ef;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  padding: 24px 16px;
  background: #101827;
  color: #fff;
}

.brand {
  margin-bottom: 28px;
  font-size: 22px;
  font-weight: 800;
}

.nav {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.nav:hover,
.nav.active {
  background: #243149;
  color: #fff;
}

.content {
  width: calc(100% - 220px);
  margin-left: 220px;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 28px;
}

.topbar p,
.section-title p,
.muted {
  color: var(--muted);
}

.toast {
  min-width: 180px;
  align-self: flex-start;
  padding: 10px 14px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.toast.show {
  opacity: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-title {
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.grid.two {
  grid-template-columns: minmax(360px, 1fr) minmax(300px, 0.9fr);
}

.card {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.callout {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.narrow {
  max-width: 720px;
}

.hint {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 400;
}

.form-card {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

button {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

button.secondary {
  background: #e2e8f0;
  color: #1e293b;
}

button.danger {
  background: var(--danger);
}

button.success {
  background: var(--success);
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.filters {
  margin-bottom: 14px;
}

.filters label {
  min-width: 180px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #475569;
  white-space: nowrap;
}

td .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 180px;
}

td .row-actions button {
  padding: 7px 9px;
  font-size: 12px;
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
}

.tag.published {
  background: #dcfce7;
  color: #166534;
}

.tag.draft {
  background: #fef3c7;
  color: #92400e;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.mini-list {
  display: grid;
  gap: 10px;
}

.mini-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

pre {
  overflow-x: auto;
  padding: 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
}

.scan-result {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 12px;
  margin-bottom: 0;
}

.course-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.course-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
  overflow: hidden;
}

.course-head {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
}

.course-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.course-toggle:hover {
  background: transparent;
}

.course-arrow {
  color: #64748b;
  font-size: 12px;
  width: 16px;
}

.course-main {
  display: grid;
  gap: 4px;
  flex: 1;
}

.course-name {
  font-size: 18px;
}

.course-meta {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

.course-actions {
  flex-wrap: wrap;
}

.course-children {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
  background: #fff;
}

.course-children[hidden] {
  display: none !important;
}

.lesson-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 42px;
  border-bottom: 1px solid #eef2f7;
}

.lesson-row:last-child {
  border-bottom: 0;
}

.lesson-main {
  flex: 1;
  min-width: 0;
}

.lesson-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.lesson-meta {
  color: #64748b;
  font-size: 12px;
}

.lesson-rename {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 13px;
}

@media (max-width: 900px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
  }

  .content {
    width: 100%;
    margin-left: 0;
    padding: 18px;
  }

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