:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --primary: #3730a3;
  --primary-hover: #312e81;
  --primary-soft: #eef2ff;
  --accent: #0284c7;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.07);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image: radial-gradient(#dbe2f0 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 18px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

.amber-text {
  color: #fbbf24 !important;
}

code {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.88em;
  color: #1e293b;
}

/* Toast */
.toast-box {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-badge {
  background: linear-gradient(135deg, #312e81, #4f46e5);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 0.92rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.93rem;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.nav-count, .nav-pill {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-chip, .status-chip, .admin-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-chip:hover, .status-chip:hover, .admin-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.dot.verified {
  background: var(--emerald);
}

/* Announcement */
.announcement-bar {
  background: linear-gradient(90deg, #eef2ff 0%, #f0f9ff 100%);
  border-bottom: 1px solid #c7d2fe;
}

.announcement-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 0.86rem;
  color: #1e1b4b;
}

.announcement-tag {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.announcement-text {
  margin: 0;
}

/* Main Shell */
.main-shell {
  padding-top: 20px;
  padding-bottom: 56px;
  min-height: calc(100vh - 140px);
}

/* Forum Hero Strip */
.forum-hero-strip {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #0f172a 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
}

.fh-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.fh-title-row h1 {
  margin: 0;
  font-size: 1.42rem;
}

.live-pill {
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(125, 211, 252, 0.4);
  color: #bae6fd;
  padding: 2px 9px;
  border-radius: 999px;
}

.fh-desc {
  margin: 0 0 12px;
  font-size: 0.89rem;
  color: #cbd5e1;
  max-width: 740px;
}

.fh-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shortcut-chip {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.shortcut-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.fh-stats-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.stat-mini {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 13px;
  text-align: center;
  min-width: 74px;
}

.stat-mini.clickable {
  cursor: pointer;
}

.stat-mini.clickable:hover {
  background: rgba(255, 255, 255, 0.16);
}

.stat-num {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-lbl {
  font-size: 0.72rem;
  color: #cbd5e1;
}

.btn-post-cta {
  background: #38bdf8 !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  padding: 12px 18px !important;
  border-radius: 11px !important;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.btn-post-cta:hover {
  background: #7dd3fc !important;
}

/* Moodle Deadlines Strip */
.deadlines-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.dl-strip-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.dl-strip-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dl-chip {
  font-size: 0.78rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--text-secondary);
}

.dl-chip strong {
  color: var(--text);
}

.handouts-section-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Forum Filter Card */
.forum-filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.filter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-filter-row {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.course-pills, .type-pills, .sort-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-secondary);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

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

.sub-pill {
  border: 1px solid transparent;
  background: #f1f5f9;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.sub-pill.active {
  background: #1e293b;
  color: #fff;
}

.sort-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--text);
  background: #f1f5f9;
}

.sort-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #c7d2fe;
}

.search-box input {
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 0.85rem;
  min-width: 240px;
}

/* Handouts Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #0f172a 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 26px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #93c5fd;
  margin-bottom: 8px;
}

.hero-copy h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
}

.hero-copy p {
  margin: 0;
  color: #cbd5e1;
  font-size: 0.93rem;
}

.hero-quick-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.quick-jump-card {
  text-align: left;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-jump-card:hover {
  background: rgba(255, 255, 255, 0.16);
}

.qj-tag {
  font-size: 0.72rem;
  color: #7dd3fc;
  font-weight: 700;
}

/* Handouts Grid */
.handouts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.handout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.hc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.course-code-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
}

.version-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid #a7f3d0;
}

.hc-title {
  margin: 8px 0 4px;
  font-size: 1.1rem;
}

.hc-sub {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.hc-changelog {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.hc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.79rem;
  color: var(--muted);
}

.realname-bar-card {
  background: var(--surface);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.rnb-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rnb-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.rnb-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 420px;
}

.rnb-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.rnb-form input:focus,
.dl-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(55, 48, 163, 0.14);
}

.rnb-saved {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rnb-badge {
  background: var(--emerald-soft);
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.dl-modal-card {
  max-width: 440px;
  padding: 24px 26px;
}

.dl-file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.dl-pdf-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

.dl-file-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dl-file-meta strong {
  font-size: 0.95rem;
  color: var(--text);
}

.dl-name-input {
  padding: 11px 14px !important;
  font-size: 0.98rem !important;
  border-radius: 10px !important;
}

.dl-submit-btn {
  width: 100%;
  padding: 11px 16px;
  font-size: 0.95rem;
  border-radius: 10px;
  margin-top: 2px;
}

.dl-privacy-note {
  margin: 2px 0 0;
  font-size: 0.77rem;
  color: var(--muted);
  text-align: center;
}

.roster-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.roster-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.roster-controls select,
.roster-controls input {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
  background: #fff;
}

.roster-table-wrap {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.roster-table {
  margin-top: 0;
}

.roster-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.hc-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hc-actions .btn {
  flex: 1;
}

.history-wrap {
  margin-top: 22px;
}

.history-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.history-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: 8px;
  font-size: 0.86rem;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

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

.btn-emerald {
  background: var(--emerald-soft);
  border-color: #a7f3d0;
  color: var(--emerald);
}

.btn-danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 4px;
}

.btn-link.danger {
  color: var(--danger);
}

/* Forum Layout */
.qa-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.25fr);
  gap: 18px;
  align-items: start;
}

.qa-layout.wide-detail {
  grid-template-columns: 1fr;
}

.qa-layout.wide-detail .posts-list-col {
  display: none;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.load-more-wrap {
  margin-top: 12px;
  text-align: center;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.post-card:hover {
  border-color: #818cf8;
}

.post-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(55, 48, 163, 0.14);
}

.post-card.pinned {
  background: linear-gradient(180deg, #fffdf5 0%, #ffffff 65%);
  border-color: #fde68a;
}

.pc-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.badge {
  font-size: 0.71rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
}

.badge-pin {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #fde68a;
}

.badge-solved {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.badge-unsolved {
  background: #fff1f2;
  color: #e11d48;
}

.badge-course {
  background: #eef2ff;
  color: #3730a3;
}

.badge-type {
  background: #f1f5f9;
  color: #475569;
}

.badge-official {
  background: linear-gradient(90deg, #312e81, #4f46e5);
  color: #fff;
}

.badge-op {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-mine {
  background: #fae8ff;
  color: #86198f;
}

.pc-title {
  margin: 0 0 5px;
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.38;
}

.pc-excerpt {
  margin: 0 0 9px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.76rem;
  color: var(--muted);
}

/* Post Detail Pane */
.post-detail-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 98px);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.qa-layout.wide-detail .post-detail-pane {
  position: static;
  max-height: none;
}

.detail-top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.mobile-back-btn {
  display: none;
}

.empty-detail {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.detail-title {
  margin: 8px 0 10px;
  font-size: 1.25rem;
  line-height: 1.36;
}

.detail-author-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.81rem;
  color: var(--muted);
}

.detail-toolbar-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rich-content {
  font-size: 0.94rem;
  line-height: 1.68;
  color: #1e293b;
  overflow-wrap: anywhere;
}

.rich-content p {
  margin: 0 0 10px;
}

.rich-content h3, .rich-content h4 {
  margin: 12px 0 6px;
  font-size: 1.02rem;
}

.rich-content ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.rich-content blockquote {
  margin: 8px 0;
  padding: 6px 12px;
  border-left: 3px solid #818cf8;
  background: #f8fafc;
  color: var(--text-secondary);
  border-radius: 0 6px 6px 0;
}

.rich-content pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.84rem;
}

.rich-content pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.post-attached-img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 8px 0;
  cursor: zoom-in;
  background: #f8fafc;
}

.detail-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* Comments */
.comments-section {
  margin-top: 20px;
}

.comments-section h4 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.comment-item {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 11px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.comment-item.official-reply {
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
  border-color: #a5b4fc;
}

.comment-item.accepted-reply {
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 100%);
  border: 1.5px solid #34d399;
}

.accepted-banner {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--emerald);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reply-quote-pill {
  background: #eef2ff;
  border-left: 3px solid var(--primary);
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.79rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.comment-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.reply-form {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.replying-to-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.81rem;
  font-weight: 600;
}

/* Tools Section */
.tools-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.tools-header h2, .admin-header h2 {
  margin: 0 0 4px;
  font-size: 1.32rem;
}

.tools-header p, .admin-header p {
  margin: 0;
}

.tool-switcher {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tool-tab {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tool-tab.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.tool-course {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
}

.tool-tab strong {
  font-size: 0.9rem;
  color: var(--text);
}

.tool-mount {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.tool-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tool-grid-2 {
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.tool-grid-equal {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.tool-panel {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-width: 0;
}

.tool-panel h3, .tool-panel h4 {
  margin: 0 0 10px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-btn {
  font-size: 0.76rem;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi-val {
  font-size: 1.06rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.svg-chart-wrap {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  overflow-x: auto;
}

.svg-chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.load-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.eq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 10px;
}

.eq-table th, .eq-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}

.eq-table th {
  background: var(--surface-alt);
  font-weight: 600;
}

/* Forms & Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-login-card {
  max-width: 480px;
  margin-top: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 0;
}

.stack-form input[type="text"],
.stack-form input[type="number"],
.stack-form input[type="password"],
.stack-form select,
.stack-form textarea,
.inline-auth-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

.form-row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.inline-auth-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-auth-form input {
  flex: 1;
}

.form-error {
  color: var(--danger);
  font-size: 0.84rem;
  margin: 2px 0 0;
}

.form-msg {
  color: var(--emerald);
  font-size: 0.85rem;
  margin: 2px 0 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.toolbar-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.formula-chip {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.77rem;
  cursor: pointer;
}

.formula-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.live-preview-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}

.preview-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.preview-body {
  min-height: 36px;
}

.upload-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-btn {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  padding: 6px 12px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary) !important;
  cursor: pointer;
  font-size: 0.81rem !important;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  cursor: pointer;
}

/* Modals & Lightbox */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-sm {
  max-width: 430px;
}

.modal-lg {
  max-width: 760px;
}

.modal-pdf {
  max-width: 1120px;
  height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
}

.pdf-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-frame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.icon-close {
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.lightbox-inner {
  position: relative;
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.lightbox-inner img {
  max-width: 94vw;
  max-height: 84vh;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.lightbox-close {
  border: none;
  background: #fff;
  color: #0f172a;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

/* Passcode Gate */
.gate-card {
  max-width: 480px;
  margin: 48px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.gate-icon {
  font-size: 2.4rem;
}

.gate-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.gate-form input {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

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

.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  padding: 16px 0;
  font-size: 0.82rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

/* Responsive Mobile Experience */
@media (max-width: 960px) {
  .forum-hero-strip {
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }
  .fh-stats-panel {
    justify-content: space-between;
  }
  .hero-banner {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .handouts-grid {
    grid-template-columns: 1fr;
  }
  .qa-layout {
    grid-template-columns: 1fr;
  }
  .post-detail-pane {
    position: static;
    max-height: none;
  }
  /* Mobile focused single-pane navigation when reading a thread */
  .qa-layout.mobile-reading .posts-list-col {
    display: none;
  }
  .qa-layout:not(.mobile-reading) .post-detail-pane {
    display: none;
  }
  .mobile-back-btn {
    display: inline-flex;
  }
  .hide-on-mobile {
    display: none !important;
  }
  .tool-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tool-grid-2,
  .tool-grid-equal {
    grid-template-columns: minmax(0, 1fr);
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .brand-sub {
    display: none;
  }
  .main-nav {
    order: 3;
    width: 100%;
    justify-content: space-around;
  }
  .nav-tab {
    flex: 1;
    justify-content: center;
    padding: 8px;
  }
  .tool-switcher {
    grid-template-columns: 1fr;
  }
  .form-row-2, .form-row-3 {
    grid-template-columns: 1fr;
  }
  .search-box, .search-box input {
    width: 100%;
  }
  .btn-post-cta {
    width: 100%;
  }
  .eq-table {
    display: block;
    overflow-x: auto;
    font-size: 0.78rem;
  }
  .eq-table th, .eq-table td {
    padding: 5px 6px;
  }
}
