:root {
  --help-backdrop: rgba(2, 6, 23, 0.68);
  --help-surface: var(--surface, #ffffff);
  --help-surface-soft: var(--surface-alt, #f8fafc);
  --help-text: var(--text, #0f172a);
  --help-muted: var(--text-muted, #475569);
  --help-border: var(--border, #dbe4f0);
  --help-primary: var(--primary, #4f46e5);
  --help-primary-contrast: #ffffff;
  --help-shadow: 0 30px 90px rgba(2, 6, 23, 0.38);
  --help-radius: var(--radius, 24px);
  --help-radius-sm: var(--radius-sm, 14px);
}

html[data-theme="dark"],
.analytics-page,
body:has(.teacher-topbar) {
  --help-surface: var(--surface, #0f172a);
  --help-surface-soft: var(--surface-alt, #172033);
  --help-text: var(--text, #f8fafc);
  --help-muted: var(--text-muted, #cbd5e1);
  --help-border: var(--border, rgba(148, 163, 184, 0.28));
  --help-primary: var(--primary, #818cf8);
}

.student-page:not(.student-gradebook) {
  --help-surface: rgba(13, 19, 46, 0.96);
  --help-surface-soft: rgba(255, 255, 255, 0.08);
  --help-text: var(--text-bright, #ffffff);
  --help-muted: var(--muted, #bfd0f8);
  --help-border: var(--glass-border, rgba(255, 255, 255, 0.22));
  --help-primary: var(--primary, #4de0c1);
  --help-shadow: var(--shadow, 0 24px 70px rgba(0, 0, 0, 0.42));
}

.student-page.student-gradebook,
.parent-gradebook {
  --help-surface: var(--sgb-surface, #ffffff);
  --help-surface-soft: var(--sgb-surface-soft, #f8fafc);
  --help-text: var(--sgb-text, #0f172a);
  --help-muted: var(--sgb-muted, #475569);
  --help-border: var(--sgb-border, #dbe4f0);
  --help-primary: var(--sgb-brand, #2563eb);
  --help-shadow: var(--sgb-shadow, 0 18px 45px rgba(15, 23, 42, 0.16));
  --help-radius: var(--sgb-radius, 24px);
}

.help-center-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.help-center-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--help-border);
  border-radius: 999px;
  padding: 9px 15px;
  background: var(--help-surface-soft);
  color: var(--help-text);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  line-height: 1.4;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.help-center-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
}

.help-center-button:focus-visible,
.help-center-close:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--help-primary) 42%, transparent);
  outline-offset: 3px;
}

.analytics-page .topbar > .help-center-actions,
.teacher-user-actions .help-center-button,
.topbar .help-center-button {
  margin-inline-start: auto;
}

.student-header .help-center-actions,
.student-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.student-page:not(.student-gradebook) .help-center-button {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(5, 9, 26, 0.28);
  backdrop-filter: blur(12px);
}

.student-gradebook .sgb-actions .help-center-button,
.parent-gradebook .sgb-actions .help-center-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 14px;
  padding: 11px 18px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  box-shadow: none;
}

.parent-gradebook .parent-topline .sgb-actions .help-center-button,
.parent-gradebook .parent-topline .sgb-actions #parent-logout {
  flex: 0 0 auto;
}

.help-center-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--help-backdrop);
  backdrop-filter: blur(10px);
}

.help-center-overlay.is-open {
  display: flex;
}

.help-center-dialog {
  width: min(880px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--help-border);
  border-radius: calc(var(--help-radius) + 2px);
  background: var(--help-surface);
  color: var(--help-text);
  box-shadow: var(--help-shadow);
  direction: rtl;
}

.help-center-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--help-border);
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--help-primary) 18%, transparent), transparent 40%),
    var(--help-surface-soft);
}

.help-center-kicker {
  margin: 0 0 4px;
  color: var(--help-muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.help-center-title {
  margin: 0;
  color: var(--help-text);
  font-size: clamp(1.2rem, 2.5vw, 1.45rem);
  line-height: 1.55;
}

.help-center-close {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--help-border);
  border-radius: var(--help-radius-sm);
  background: var(--help-surface);
  color: var(--help-text);
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
}

.help-center-body {
  overflow: auto;
  padding: 22px 24px 26px;
  scrollbar-gutter: stable;
}

.help-center-section {
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--help-border);
  border-radius: var(--help-radius-sm);
  background: var(--help-surface-soft);
}

.help-center-section:last-child {
  margin-bottom: 0;
}

.help-center-section h3 {
  margin: 0 0 10px;
  color: var(--help-primary);
  font-size: 1.03rem;
  font-weight: 1000;
  line-height: 1.6;
}

.help-center-section p,
.help-center-section li {
  color: var(--help-text);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 2;
}

.help-center-section p {
  margin: 0;
}

.help-center-section ul,
.help-center-section ol {
  margin: 0;
  padding-inline-start: 24px;
}

.help-center-section li {
  margin-bottom: 6px;
}

@media (max-width: 768px) {
  .student-header .help-center-actions,
  .student-header-actions,
  .parent-gradebook .parent-topline .sgb-actions {
    width: 100%;
    justify-content: stretch;
  }

  .student-header .help-center-button,
  .student-header-actions .help-center-button,
  .student-header-actions > button,
  .parent-gradebook .parent-topline .sgb-actions .help-center-button,
  .parent-gradebook .parent-topline .sgb-actions #parent-logout {
    flex: 1 1 140px;
  }
}

@media (max-width: 640px) {
  .help-center-overlay {
    align-items: flex-end;
    padding: 10px;
  }

  .help-center-dialog {
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
  }

  .help-center-header,
  .help-center-body {
    padding: 18px;
  }

  .help-center-section {
    padding: 14px;
  }
}
