/* ============================================================
   行知学长 · 积木创意园 �� 基础样式
   ============================================================ */

/* ── Reset & Variables ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #27ae60;
  --primary-dark: #1e8449;
  --primary-light: #eafaf1;
  --accent: #f39c12;
  --accent-light: #fef9e7;
  --blue: #2b8fde;
  --blue-light: #e8f4fd;
  --red: #e74c3c;
  --red-light: #fdecea;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.10);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Top Navigation ──────────────────────────────────────── */
.top-nav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
}
.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-weight: 700;
  font-size: 18px;
  color: var(--primary-dark);
  text-decoration: none;
}
.nav-brand:hover { opacity: .85; }
.brand-icon { font-size: 22px; }
.brand-sub { font-size: 13px; color: var(--gray-500); font-weight: 400; }
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-user { font-size: 14px; color: var(--gray-700); }
.nav-uid {
  display: inline-block;
  font-size: 11px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  letter-spacing: 1px;
}
.nav-role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}
.nav-role-badge.student { background: var(--blue-light); color: var(--blue); }
.nav-role-badge.teacher { background: var(--primary-light); color: var(--primary-dark); }
.nav-link {
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all .15s;
}
.nav-link:hover { background: var(--gray-100); }
.nav-signup {
  background: var(--primary);
  color: #fff !important;
}
.nav-signup:hover { background: var(--primary-dark); }
.nav-logout { color: var(--gray-500); }
.nav-logout:hover { color: var(--red); }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  min-height: calc(100vh - 56px - 50px);  /* nav + footer */
}
.site-footer {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--gray-500);
  border-top: 1px solid var(--gray-200);
}

/* ── Auth Pages (Login / Register) ────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px - 50px);
  padding: 24px;
  background: linear-gradient(135deg, #e8f5e9 0%, #e3f2fd 50%, #fff3e0 100%);
}
.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; font-size: 48px; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--gray-800); }
.auth-subtitle { text-align: center; font-size: 14px; color: var(--gray-500); margin: 4px 0 24px; }

.auth-form .form-group { margin-bottom: 18px; }
.auth-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-hint { font-weight: 400; color: var(--gray-400); font-size: 12px; }
.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color .2s;
  outline: none;
}
.auth-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.form-error {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.reg-bonus {
  text-align: center;
  padding: 10px;
  background: var(--accent-light);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--gray-500);
}

/* ── Role Selector ──────────────────────────────────────── */
.role-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.role-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.role-option input[type="radio"] { display: none; }
.role-option:hover { border-color: var(--primary); background: var(--primary-light); }
.role-option.selected {
  border-color: var(--primary-dark);
  background: var(--primary-light);
}
.role-icon { font-size: 28px; }
.role-label { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.role-desc { font-size: 11px; color: var(--gray-500); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }

/* ── Home Page ────────────────────────────────────────────── */
.home-page { max-width: 1000px; margin: 0 auto; padding: 32px 24px; }

/* 5 层背景色块（参照平台首页 section 风格，每层不同色区分） */
.home-layer {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.home-layer .home-section + .home-section {
  margin-top: 28px;
}
.layer-2 { background: linear-gradient(135deg, #fff7e6, #fff3e0); }  /* 行动引导 */
.layer-3 { background: linear-gradient(135deg, #e8f0fe, #eef4f8); }  /* 功能工具 */
.layer-4 { background: linear-gradient(135deg, #f3e8ff, #f7f0ff); }  /* 成果展示 */
.layer-5 { background: linear-gradient(135deg, #e0f7fa, #e8f4f5); }  /* 成长档案 */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--primary-light), var(--blue-light));
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 28px;
}
.teacher-banner { background: linear-gradient(135deg, var(--primary-light), #e8f0fe); }
.welcome-text h1 { font-size: 22px; color: var(--gray-800); margin-bottom: 4px; }
.welcome-text p { font-size: 14px; color: var(--gray-600); }
.stars-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow);
}
.stars-icon { font-size: 20px; }
.stars-count { font-size: 28px; font-weight: 700; color: var(--accent); }
.stars-label { font-size: 12px; color: var(--gray-500); }

.quick-actions { margin-bottom: 28px; }
.quick-actions h2,
.home-section h2,
.home-top-left h2,
.home-top-right h2 {
  font-size: 17px;
  color: var(--gray-800);
  margin-bottom: 14px;
  padding-left: 4px;
}

.home-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}
.home-top-left {
  display: flex;
  flex-direction: column;
}
.home-top-left .action-grid {
  grid-template-columns: 1fr 1fr;
}
.home-top-left .action-hero {
  flex: 1;
}
.home-top-right {
  display: flex;
  flex-direction: column;
}
.home-top-right #tasksSection {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 16px;
  min-height: 220px;
  /* 任务多时框内上下滚动，不再撑长整页布局 */
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;                    /* Firefox */
  scrollbar-color: #c8d6c8 transparent;
}
.home-top-right #tasksSection::-webkit-scrollbar { width: 6px; }
.home-top-right #tasksSection::-webkit-scrollbar-thumb {
  background: #c8d6c8;
  border-radius: 6px;
}
.home-top-right #tasksSection::-webkit-scrollbar-track { background: transparent; }
.home-top-right #tasksSection .task-card:last-child { margin-bottom: 0; }
.home-top-third {
  display: flex;
  flex-direction: column;
}
.home-top-third #rankingSection {
  flex: 1;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 8px;
  min-height: 220px;
}
.home-top-third .ranking-list {
  border: none;
  border-radius: 0;
}
.home-top-third .ranking-row {
  padding: 4px 10px;
  gap: 8px;
}
.home-top-third .ranking-num {
  font-size: 14px;
  width: 24px;
}
.home-top-third .ranking-name,
.home-top-third .ranking-stars {
  font-size: 13px;
}
.home-top-third .ranking-my-row {
  padding: 4px 10px;
  gap: 8px;
}
.peer-task-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #e8f5e9, #e3f2fd);
  border: 1px solid var(--primary);
  border-radius: 12px;
  padding: 14px 16px;
  text-decoration: none;
  margin-top: 16px;
  transition: all .2s;
}
.peer-task-entry:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: #219a52;
}
.peer-task-entry .pte-icon { font-size: 26px; }
.peer-task-entry .pte-body { flex: 1; min-width: 0; }
.peer-task-entry .pte-title { display: block; font-size: 15px; font-weight: 600; color: var(--gray-800); }
.peer-task-entry .pte-desc { display: block; font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.peer-task-entry .pte-arrow { font-size: 22px; color: var(--primary); }
.home-top-right .placeholder-card {
  border: none;
  padding: 32px 16px;
}
.home-top-right .skeleton-block {
  border: none;
}
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* 学习工具区固定 5 列（2026-09-26 定案：一行五个，窄屏回落） */
.tool-grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .tool-grid-5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .tool-grid-5 { grid-template-columns: 1fr 1fr; } }
.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 16px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  text-decoration: none;
  color: var(--gray-800);
  transition: all .2s;
  text-align: center;
}
.action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.action-card.action-hero {
  grid-column: 1 / -1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #e8f5e9, #e3f2fd);
  border: 2px solid var(--primary);
  text-align: center;
}
.action-card.action-hero .action-icon { font-size: 40px; flex-shrink: 0; }
.action-card.action-hero .action-label { font-size: 18px; white-space: nowrap; }
.action-card.action-hero .action-desc { font-size: 14px; }
.hero-stats { font-size: 13px; color: #666; }
.hero-progress {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 6px;
  overflow: hidden;
}
.hero-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #27ae60, #2ecc71);
  border-radius: 6px;
  transition: width .4s ease;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
@media (min-width: 641px) {
  .action-card.action-hero { grid-column: span 2; }
}
.action-icon { font-size: 36px; }
.action-label { font-size: 15px; font-weight: 600; }
.action-desc { font-size: 12px; color: var(--gray-500); }

.placeholder-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--gray-500);
  font-size: 14px;
}

/* ── Error Pages ──────────────────────────────────────────── */
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px - 50px);
  padding: 24px;
}
.error-card {
  text-align: center;
  padding: 48px;
}
.error-code {
  font-size: 80px;
  font-weight: 800;
  color: var(--gray-200);
  line-height: 1;
  margin-bottom: 8px;
}
.error-card h1 { font-size: 20px; color: var(--gray-700); margin-bottom: 8px; }
.error-card p { color: var(--gray-500); margin-bottom: 24px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .welcome-banner { flex-direction: column; text-align: center; gap: 16px; }
  .action-grid { grid-template-columns: 1fr 1fr; }
  .brand-sub { display: none; }
  .home-top-row { grid-template-columns: 1fr; }
  .home-top-left .action-grid { grid-template-columns: 1fr 1fr; }
  .home-top-right #tasksSection { min-height: 160px; max-height: 280px; }
}

/* ── Skeleton / Placeholder ─────────────────────────────── */
.skeleton-block {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}
.placeholder-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Progress Card ──────────────────────────────────────── */
.progress-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
}
.progress-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.progress-emoji { font-size: 32px; }
.progress-status { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.progress-bar-wrap {
  position: relative;
  height: 28px;
  background: var(--gray-100);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #2ecc71);
  border-radius: 14px;
  transition: width .6s ease;
  min-width: 28px;
}
.progress-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
}
.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  text-align: center;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 12px; color: var(--gray-500); }

/* ── Task Cards ──────────────────────────────────────────── */
.task-group { margin-bottom: 14px; }
.task-group-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 8px;
  padding-left: 4px;
}
.task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}
.task-card:hover { box-shadow: var(--shadow); }
.task-pending { border-left: 3px solid var(--accent); }
.task-done { border-left: 3px solid var(--primary); opacity: .75; }
.task-info { display: flex; flex-direction: column; gap: 3px; }
.task-title { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.task-meta { font-size: 12px; color: var(--gray-500); }
.task-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.task-badge.pending { background: var(--accent-light); color: var(--accent); }
.task-badge.done { background: var(--primary-light); color: var(--primary-dark); }

/* ── Works Grid ──────────────────────────────────────────── */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.works-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .15s;
}
.works-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.works-preview {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.works-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.works-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 6px;
}
.works-share-badge {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 8px;
}
.works-date { font-size: 11px; color: var(--gray-500); }

/* ── Rankings ────────────────────────────────────────────── */
.ranking-list {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
.ranking-row:hover { background: var(--gray-50); }
.ranking-row:last-child { border-bottom: none; }
.ranking-row.ranking-me { background: var(--accent-light); }
.ranking-num {
  font-size: 16px;
  font-weight: 700;
  width: 32px;
  text-align: center;
  color: var(--gray-600);
  flex-shrink: 0;
}
.ranking-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--gray-800); }
.ranking-stars { font-size: 14px; color: var(--accent); font-weight: 600; }
.ranking-total { font-size: 12px; color: var(--gray-400); flex-shrink: 0; }
.ranking-my-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent-light);
  border-top: 2px solid var(--accent);
  font-weight: 600;
}
.ranking-my-inline {
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  justify-content: center;
}

/* ── Level Map Page ─────────────────────────────────────── */
.map-page { max-width: 960px; margin: 0 auto; padding: 24px; }

.map-header {
  position: relative;
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 0;
  margin-bottom: 20px;
}
.map-back {
  font-size: 13px;
  color: var(--gray-500);
  text-decoration: none;
  margin-bottom: 4px;
  display: inline-block;
}
.map-back:hover { color: var(--primary); }
.map-title-area h1 {
  font-size: 22px;
  color: var(--gray-800);
  margin: 0;
}
.map-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}
.map-legend {
  display: flex;
  gap: 18px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray-600);
}
.legend-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid;
}
.legend-dot.completed { background: #27ae60; border-color: #1e8449; }
.legend-dot.current   { background: #f39c12; border-color: #e67e22; }
.legend-dot.available { background: #fff; border-color: #27ae60; }
.legend-dot.locked    { background: #e9ecef; border-color: #adb5bd; }
.legend-star { font-size: 14px; }

.map-loading, .map-error {
  text-align: center;
  padding: 60px 24px;
  font-size: 16px;
  color: var(--gray-500);
}

.map-chapter {
  border: 2px solid;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 8px;
  overflow: hidden;
}
.chapter-banner {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px dashed;
  border-color: inherit;
}
.chapter-title {
  font-size: 22px;
  font-weight: 700;
}
.chapter-meta {
  font-size: 13px;
  opacity: .7;
}

.chapter-levels { }

.level-row {
  margin-bottom: 2px;
}

.level-path {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  padding: 8px 0;
}

.level-node-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
  gap: 4px;
}

.level-node {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--node-fill);
  border: 3px solid var(--node-stroke);
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
  transition: all .3s;
  cursor: default;
  position: relative;
}
.level-node.current {
  width: 52px; height: 52px;
  box-shadow: 0 0 0 6px rgba(243,156,18,.2), 0 0 20px rgba(243,156,18,.3);
}
.level-node.completed { cursor: pointer; }
.level-node.completed:hover { transform: scale(1.12); }
.level-node.available { cursor: pointer; }
.level-node.available:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  transform: scale(1.08);
}
.level-node.locked { cursor: not-allowed; }

.node-icon {
  font-size: 16px;
  line-height: 1;
}
.level-node.current .node-icon { font-size: 24px; }

.node-pulse {
  animation: nodePulse 2s ease-in-out infinite;
}
@keyframes nodePulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(243,156,18,.2); }
  50%      { box-shadow: 0 0 0 12px rgba(243,156,18,.08); }
}

.node-label {
  font-size: 10px;
  color: var(--gray-500);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.node-label.completed { color: var(--primary-dark); }
.node-label.current { color: var(--accent); font-weight: 700; }

.node-stars {
  font-size: 10px;
  margin-top: -2px;
}

.node-connector {
  display: block;
  width: 20px;
  height: 3px;
  border-radius: 2px;
  margin-top: 20px;
  flex-shrink: 0;
}
.node-connector.completed { background: #27ae60; }
.node-connector.active { background: linear-gradient(90deg, #27ae60, #f39c12); }
.node-connector.locked { background: #dee2e6; }

/* ── Challenge Area within Map ──────────────────────────── */
.challenge-area {
  margin-top: 14px;
}
.challenge-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}
.challenge-divider-line {
  flex: 1;
  height: 1px;
}
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.challenge-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
}
.challenge-node:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.challenge-node.locked {
  opacity: .55;
  cursor: not-allowed;
  background: var(--gray-50);
}
.challenge-node.locked:hover { border-color: var(--gray-200); box-shadow: none; }
.challenge-icon { font-size: 24px; flex-shrink: 0; }
.challenge-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.challenge-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.challenge-node.locked .challenge-title { color: var(--gray-500); font-weight: 400; }
.challenge-reward {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.challenge-state {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.challenge-node.locked .challenge-state { color: var(--gray-400); }

/* ── Chapter Transition ────────────────────────────────── */
.chapter-transition {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
}
.transition-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gray-300), transparent);
}
.transition-text {
  font-size: 12px;
  color: var(--gray-400);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Admin Pages ────────────────────────────────────────── */
.admin-page {
  display: flex;
  min-height: calc(100vh - 56px);
}
.admin-sidebar {
  width: 200px;
  background: var(--gray-50);
  border-right: 1px solid var(--gray-200);
  padding: 24px 16px;
  flex-shrink: 0;
}
.admin-sidebar h2 {
  font-size: 15px;
  color: var(--gray-800);
  margin: 0 0 16px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.admin-sidebar a {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--gray-600);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}
.admin-sidebar a:hover { background: var(--gray-100); color: var(--gray-800); }
.admin-sidebar a.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.admin-sidebar hr {
  margin: 16px 0;
  border: none;
  border-top: 1px solid var(--gray-200);
}
.admin-sidebar .sidebar-group {
  font-size: 11px; font-weight:600; color: var(--gray-400);
  text-transform: uppercase; letter-spacing:0.5px;
  padding: 12px 8px 4px 8px;
  pointer-events: none;
}
.admin-sidebar .sidebar-sub {
  padding-left: 20px; font-size:12px;
}
.admin-main {
  flex: 1;
  padding: 24px 32px;
  overflow-x: auto;
}
.admin-main h1 {
  font-size: 20px;
  color: var(--gray-800);
  margin: 0 0 4px 0;
}
.admin-hint {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 20px;
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; color: var(--primary-dark); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--gray-50); }
.admin-table .loading { text-align: center; padding: 32px; color: var(--gray-400); }
.inactive-row td { opacity: .45; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.on { background: #d4edda; color: #155724; }
.status-badge.off { background: #f8d7da; color: #721c24; }

.action-btns { white-space: nowrap; }
.action-btns .btn-sm {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid var(--gray-300);
  background: #fff;
  cursor: pointer;
  margin-right: 2px;
}
.action-btns .btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.action-btns .btn-toggle { color: var(--accent); border-color: #f39c12; }
.action-btns .btn-danger { color: #e74c3c; border-color: #f5c6cb; }
.action-btns .btn-danger:hover { background: #fce4e4; }

/* modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
}
.modal-box h3 { margin: 0 0 16px 0; font-size: 16px; }
.modal-box label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--gray-600); }
.modal-box .input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-sizing: border-box;
}
.modal-box .input:focus { border-color: var(--primary); outline: none; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
