* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #3b82f6 100%);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo { text-align: center; margin-bottom: 32px; }

.logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  color: #fff;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto 16px;
}

.logo-icon.small {
  width: 36px; height: 36px;
  font-size: 14px;
  border-radius: 8px;
  margin: 0;
}

.login-logo h1 { font-size: 22px; margin-bottom: 8px; }
.login-logo p { color: var(--text-secondary); font-size: 14px; }

.form-group { margin-bottom: 16px; }

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-text { font-size: 18px; font-weight: 600; }

.sidebar-nav { flex: 1; padding: 12px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  color: #94a3b8;
  transition: all 0.2s;
  font-size: 14px;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.nav-item.active { background: var(--primary); color: #fff; }

.nav-icon { display: flex; align-items: center; }
.nav-icon svg { width: 20px; height: 20px; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}

.user-name { font-size: 14px; font-weight: 500; }
.user-role { font-size: 12px; color: #94a3b8; }

.btn-logout {
  width: 100%;
  padding: 6px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-logout:hover { background: rgba(255,255,255,0.15); color: #e2e8f0; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px 32px;
  max-width: 1000px;
}

.page-title { font-size: 24px; font-weight: 600; margin-bottom: 24px; }

.section { margin-bottom: 32px; }
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Content Cards ===== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.content-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.content-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.content-card h4 { font-size: 15px; margin: 10px 0 8px; }

.content-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.content-type-badge.video { background: #dbeafe; color: #2563eb; }
.content-type-badge.audio { background: #dcfce7; color: #16a34a; }
.content-type-badge.book { background: #fef3c7; color: #d97706; }
.content-type-badge.tips { background: #fce7f3; color: #db2777; }
.content-type-badge.offline { background: #e0e7ff; color: #4f46e5; }

/* ===== Progress Bar ===== */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-bar.small { height: 4px; }

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-text { font-size: 12px; color: var(--text-secondary); }

/* ===== Tip Card ===== */
.tip-card {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 20px;
}

.tip-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tip-badge { background: #f59e0b; color: #fff; padding: 2px 10px; border-radius: 12px; font-size: 12px; }
.tip-date { font-size: 13px; color: #92400e; }
.tip-card h4 { margin-bottom: 8px; }
.tip-card p { color: #78350f; font-size: 14px; }

/* ===== Point Items ===== */
.point-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.point-info { display: flex; flex-direction: column; }
.point-action { font-size: 14px; }
.point-date { font-size: 12px; color: var(--text-muted); }
.point-value { color: var(--success); font-weight: 600; }

/* ===== Filter Bar ===== */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }

.filter-btn {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Content List ===== */
.content-list { display: flex; flex-direction: column; gap: 12px; }

.content-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.content-item:hover { box-shadow: var(--shadow-md); }

.content-item-left { display: flex; gap: 16px; flex: 1; }

.content-type-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.content-type-icon.video { background: #dbeafe; color: #2563eb; }
.content-type-icon.audio { background: #dcfce7; color: #16a34a; }
.content-type-icon.book { background: #fef3c7; color: #d97706; }
.content-type-icon.tips { background: #fce7f3; color: #db2777; }

.content-info h4 { font-size: 15px; margin-bottom: 4px; }
.content-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.content-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tag.difficulty { background: var(--primary-light); color: var(--primary); }

.completed-badge {
  padding: 4px 12px;
  background: #dcfce7;
  color: var(--success);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

.start-badge {
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

.progress-mini { display: flex; align-items: center; gap: 8px; }
.progress-mini span { font-size: 12px; color: var(--text-secondary); }

/* ===== Detail Page ===== */
.btn-back {
  padding: 6px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 20px;
  color: var(--text-secondary);
}

.btn-back:hover { border-color: var(--primary); color: var(--primary); }

.detail-header { margin-bottom: 24px; }
.detail-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 12px;
}
.detail-badge.video { background: #dbeafe; color: #2563eb; }
.detail-badge.audio { background: #dcfce7; color: #16a34a; }
.detail-badge.book { background: #fef3c7; color: #d97706; }
.detail-badge.tips { background: #fce7f3; color: #db2777; }

.detail-header h2 { font-size: 24px; margin-bottom: 8px; }
.detail-desc { color: var(--text-secondary); margin-bottom: 12px; }
.detail-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); }

.player-section { margin: 24px 0; }

.book-section { margin: 24px 0; }
.book-info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.book-info-card h3 { margin-bottom: 12px; }

.action-section { margin: 24px 0; }

.completed-notice {
  padding: 16px;
  background: #dcfce7;
  color: var(--success);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 500;
  margin: 24px 0;
}

/* ===== Insight Section ===== */
.insight-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 24px 0;
}

.insight-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

.insight-section textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  resize: vertical;
  font-family: inherit;
}

.insight-section textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.insight-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

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

.insights-list { margin-top: 24px; }
.insight-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.insight-author { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.insight-item p { font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.insight-date { font-size: 12px; color: var(--text-muted); }

/* ===== Points Page ===== */
.points-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.points-total, .points-month {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}

.points-total { border-left: 4px solid var(--primary); }
.points-month { border-left: 4px solid var(--success); }

.points-big { font-size: 48px; font-weight: 700; }
.points-total .points-big { color: var(--primary); }
.points-month .points-big { color: var(--success); }
.points-label { color: var(--text-secondary); }

.rules-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.rules-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.rules-table tr:last-child td { border-bottom: none; }
.rules-table td:last-child { color: var(--success); font-weight: 500; text-align: right; }

/* ===== Leaderboard ===== */
.leaderboard-filter { display: flex; gap: 8px; margin-bottom: 20px; }

.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.leaderboard-item.top3 { border-color: #f59e0b; background: #fffbeb; }
.leaderboard-item.me { border-color: var(--primary); background: var(--primary-light); }

.rank-badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: var(--bg);
  color: var(--text-secondary);
}

.rank-badge.rank-1 { background: #fef3c7; color: #d97706; }
.rank-badge.rank-2 { background: #f1f5f9; color: #64748b; }
.rank-badge.rank-3 { background: #fff7ed; color: #c2410c; }

.leader-info { flex: 1; }
.leader-name { font-weight: 500; }
.leader-dept { font-size: 12px; color: var(--text-muted); }
.leader-points { font-weight: 600; color: var(--primary); }

/* ===== Insights Page ===== */
.insight-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.insight-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.insight-author-name { font-weight: 500; }
.insight-book { color: var(--primary); font-size: 13px; }
.insight-date { color: var(--text-muted); font-size: 13px; margin-left: auto; }

/* ===== Questions ===== */
.question-form {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

.question-form input, .question-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
  font-family: inherit;
}

.question-form input:focus, .question-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.question-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

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

.status-badge {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.status-badge.pending { background: #fef3c7; color: #d97706; }
.status-badge.answered { background: #dcfce7; color: var(--success); }

.question-footer {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.question-answer {
  margin-top: 12px;
  padding: 12px;
  background: var(--primary-light);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ===== Admin ===== */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 24px; }

.admin-tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.admin-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.admin-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.admin-section h3 { margin-bottom: 16px; }

.admin-form {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-form input, .admin-form select, .admin-form textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.admin-form textarea { width: 100%; margin-bottom: 12px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.admin-table th {
  background: var(--bg);
  font-weight: 500;
  color: var(--text-secondary);
}

/* ===== Buttons ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-full { width: 100%; }

.btn-sm { padding: 4px 12px; font-size: 13px; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ===== Empty Text ===== */
.empty-text {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 14px;
}

/* ===== Reading Stats ===== */
.reading-stats {
  display: flex;
  gap: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-top: 16px;
}

.reading-stat { display: flex; flex-direction: column; align-items: center; }
.reading-stat-value { font-size: 20px; font-weight: 600; color: var(--primary); }
.reading-stat-label { font-size: 12px; color: var(--text-secondary); }

/* ===== Reader Overlay ===== */
.reader-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #faf9f7;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-reader-close {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-reader-close:hover { border-color: var(--primary); color: var(--primary); }

.reader-title {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 16px;
}

.reader-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.timer-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.reader-progress-bar {
  height: 3px;
  background: var(--border);
  flex-shrink: 0;
}

.reader-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
}

.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px 80px;
}

.reader-content {
  max-width: 720px;
  margin: 0 auto;
  background: var(--card);
  padding: 48px 56px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.reader-end {
  max-width: 720px;
  margin: 24px auto 0;
  text-align: center;
  color: var(--text-muted);
}

.reader-end p { margin-bottom: 16px; }

/* ===== Markdown Body ===== */
.markdown-body {
  font-size: 16px;
  line-height: 1.9;
  color: #2d3748;
}

.markdown-body h1 { font-size: 26px; margin: 32px 0 16px; padding-bottom: 12px; border-bottom: 2px solid var(--border); }
.markdown-body h2 { font-size: 22px; margin: 28px 0 14px; }
.markdown-body h3 { font-size: 18px; margin: 24px 0 12px; color: var(--primary); }
.markdown-body h4 { font-size: 16px; margin: 20px 0 10px; }
.markdown-body p { margin: 14px 0; }
.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 8px 16px;
  margin: 16px 0;
  background: var(--primary-light);
  color: var(--text-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-body img { max-width: 100%; border-radius: var(--radius); margin: 16px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 24px; margin: 14px 0; }
.markdown-body li { margin: 6px 0; }
.markdown-body strong { color: #1a202c; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 12px; font-size: 14px; }
.markdown-body th { background: var(--bg); }
.markdown-body code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 14px; }

@media (max-width: 768px) {
  .reader-content { padding: 24px 20px; }
  .markdown-body { font-size: 15px; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .logo-text, .sidebar .nav-item span:not(.nav-icon), .sidebar .user-detail { display: none; }
  .sidebar .user-info { justify-content: center; }
  .main-content { margin-left: 64px; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .points-summary { grid-template-columns: 1fr; }
  .admin-form { flex-direction: column; }
}

/* ===== Duration / Group Tags ===== */
.duration-hint {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 8px;
  background: #dcfce7;
  color: #16a34a;
  text-align: center;
}
.duration-hint.not-met {
  background: #fef3c7;
  color: #d97706;
}
.required-tag {
  background: #fef3c7 !important;
  color: #d97706 !important;
  font-weight: 600;
}
