/* === Tokens === */
:root {
  --sp-primary: #2563eb;
  --sp-primary-hover: #1d4ed8;
  --sp-success: #16a34a;
  --sp-error: #dc2626;
  --sp-gray-50: #f9fafb;
  --sp-gray-100: #f3f4f6;
  --sp-gray-200: #e5e7eb;
  --sp-gray-400: #9ca3af;
  --sp-gray-600: #4b5563;
  --sp-gray-900: #111827;
  --sp-radius: 8px;
  --sp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sp-font-reading: Georgia, "Times New Roman", serif;
  --sp-max-w: 760px;
}

/* === Base === */
.sp-wrap {
  max-width: var(--sp-max-w);
  margin: 0 auto;
  padding: 0 16px;
  font-family: var(--sp-font);
  color: var(--sp-gray-900);
  line-height: 1.5;
}

.sp-test-user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  min-height: 1.5rem;
}

/* === Portal breadcrumbs === */
.sp-portal-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25em;
  margin: 0 0 10px;
  font-size: 0.9375rem;
  color: var(--sp-gray-600);
  line-height: 1.4;
}
.sp-breadcrumb-link {
  color: var(--sp-gray-600);
  text-decoration: none;
}
.sp-breadcrumb-link:hover {
  color: var(--sp-primary);
  text-decoration: underline;
}
.sp-breadcrumb-sep {
  color: var(--sp-gray-400);
  user-select: none;
}
.sp-breadcrumb-current {
  color: var(--sp-gray-900);
}
.sp-previous-attempt {
  font-size: 0.875rem;
  color: var(--sp-gray-600);
}
.sp-last-attempt-link {
  font-size: 0.875rem;
}
.sp-test-user-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sp-gray-700, #374151);
  white-space: nowrap;
  text-decoration: none;
}
.sp-test-user-name:hover {
  color: var(--sp-primary);
  text-decoration: underline;
}
.sp-test-user-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  margin: -6px -4px -6px 0;
  border-radius: 6px;
  color: var(--sp-gray-600);
  text-decoration: none;
}
.sp-test-user-logout:hover {
  color: var(--sp-primary);
  background: var(--sp-gray-100);
}

/* === Cards === */
.sp-card {
  border: 1px solid var(--sp-gray-200);
  border-radius: var(--sp-radius);
  padding: 24px;
  background: #fff;
  transition: border-color 0.15s;
}
.sp-card:hover { border-color: var(--sp-primary); }

/* === Subject × grade summary table === */
.sp-subject-grade-table-wrap {
  margin: 16px 0 12px;
  overflow-x: auto;
}
.sp-subject-grade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
.sp-subject-grade-table th,
.sp-subject-grade-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--sp-gray-200, #e5e7eb);
}
.sp-subject-grade-table th {
  font-weight: 600;
  color: var(--sp-gray-700, #374151);
  background: var(--sp-gray-50, #f9fafb);
}
.sp-subject-grade-table-note {
  margin: 0 0 24px;
  font-size: 0.875rem;
  color: var(--sp-gray-600);
}

/* === Subject Picker === */
.sp-subjects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.sp-subject-card { text-align: center; }
.sp-subject-card h3 { margin: 0 0 8px; font-size: 1.125rem; }
.sp-subject-card h3 a {
  color: var(--sp-gray-900);
  text-decoration: none;
}
.sp-subject-card h3 a:hover { color: var(--sp-primary); }
.sp-subject-card p { margin: 0; color: var(--sp-gray-600); font-size: 0.875rem; }

/* === Buttons === */
.sp-btn {
  display: inline-block;
  padding: 12px 24px;
  background: var(--sp-primary);
  color: #fff;
  text-decoration: none;
  border-radius: var(--sp-radius);
  border: none;
  font-size: 1rem;
  font-family: var(--sp-font);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  line-height: 1;
}
.sp-btn:hover { background: var(--sp-primary-hover); }
.sp-btn:focus-visible {
  outline: 3px solid var(--sp-primary);
  outline-offset: 2px;
}

/* === Links === */
.sp-link {
  color: var(--sp-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sp-link:hover { color: var(--sp-primary-hover); }
.sp-link:focus-visible {
  outline: 3px solid var(--sp-primary);
  outline-offset: 2px;
}

/* === Status Badges === */
.sp-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sp-badge-mastered  { background: #dcfce7; color: var(--sp-success); }
.sp-badge-completed { background: #fef3c7; color: #92400e; }
.sp-badge-pending   { background: var(--sp-gray-100); color: var(--sp-gray-400); }

/* === Reading Passage (collapsible) === */
.sp-passage-details {
  margin-bottom: 24px;
  border: 1px solid #fde68a;
  border-radius: var(--sp-radius);
  background: #fffbeb;
}
.sp-passage-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--sp-gray-700);
  cursor: pointer;
  user-select: none;
}
.sp-passage-summary::-webkit-details-marker {
  display: none;
}
.sp-passage-summary::marker {
  content: "";
}
.sp-passage-summary::after {
  content: "Hide";
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sp-gray-500);
}
.sp-passage-details:not([open]) .sp-passage-summary::after {
  content: "Show";
}
.sp-passage-body {
  padding: 0 16px 16px;
}
.sp-passage-details:not([open]) .sp-passage-body {
  display: none;
}
.sp-passage-details .sp-font-controls {
  margin-bottom: 12px;
}
.sp-passage {
  background: #fefce8;
  padding: 24px;
  border-left: 4px solid #ca8a04;
  border-radius: 0 var(--sp-radius) var(--sp-radius) 0;
  margin-bottom: 0;
  font-family: var(--sp-font-reading);
  line-height: 1.75;
}
.sp-passage p { margin: 0 0 16px; }
.sp-passage p:last-child { margin-bottom: 0; }

/* Passage font sizes */
.sp-font-small  { font-size: 1.25rem; line-height: 1.75; }
.sp-font-medium { font-size: 1.5rem; line-height: 1.85; }
.sp-font-large  { font-size: 1.75rem; line-height: 1.9; }

/* Font size controls */
.sp-font-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.875rem;
  color: var(--sp-gray-600);
}
.sp-font-btn {
  border: 1px solid var(--sp-gray-200);
  background: #fff;
  border-radius: var(--sp-radius);
  cursor: pointer;
  color: var(--sp-gray-600);
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sp-font-reading);
  transition: border-color 0.15s, background 0.15s;
}
.sp-font-btn[data-size="small"]  { font-size: 0.75rem; }
.sp-font-btn[data-size="medium"] { font-size: 1rem; }
.sp-font-btn[data-size="large"]  { font-size: 1.25rem; }
.sp-font-btn:hover { border-color: var(--sp-primary); }
.sp-font-btn-active {
  border-color: var(--sp-primary);
  background: var(--sp-primary);
  color: #fff;
}
.sp-font-btn:focus-visible {
  outline: 3px solid var(--sp-primary);
  outline-offset: 2px;
}

/* === Questions === */
.sp-question {
  margin: 16px 0;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--sp-gray-200);
  border-radius: var(--sp-radius);
}
.sp-question:nth-child(even) {
  background: var(--sp-gray-50);
}
.sp-question-text {
  margin: 0 0 12px;
  line-height: 1.6;
  font-weight: 600;
}
.sp-question-skipped {
  background: var(--sp-gray-50);
  border-style: dashed;
  border-color: var(--sp-gray-300);
}
.sp-question-skipped-note {
  margin: 0;
  color: var(--sp-gray-600);
  font-size: 0.875rem;
}

/* === Radio Options (44px tap target) === */
.sp-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: var(--sp-radius);
  cursor: pointer;
  min-height: 44px;
  transition: background 0.1s;
}
.sp-option:hover { background: var(--sp-gray-50); }
.sp-option input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--sp-primary);
}
.sp-option input[type="radio"]:focus-visible {
  outline: 3px solid var(--sp-primary);
  outline-offset: 2px;
}

/* === Results === */
.sp-result-item {
  padding: 12px 16px;
  margin: 8px 0;
  border-radius: var(--sp-radius);
}
.sp-result-correct {
  border-left: 4px solid var(--sp-success);
  background: #f0fdf4;
}
.sp-result-incorrect {
  border-left: 4px solid var(--sp-error);
  background: #fef2f2;
}
.sp-explanation {
  color: var(--sp-gray-600);
  font-style: italic;
  margin-top: 8px;
  font-size: 0.9375rem;
}

/* === Score Summary === */
.sp-score {
  background: var(--sp-gray-50);
  padding: 24px;
  border-radius: var(--sp-radius);
  margin: 24px 0;
  text-align: center;
}
.sp-score-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--sp-gray-900);
}

/* === Sticky Timer Bar === */
.sp-timer {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--sp-gray-200);
  z-index: 100;
  font-size: 0.875rem;
  color: var(--sp-gray-600);
  min-height: 44px;
}

/* === Test List === */
.sp-test-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sp-test-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sp-gray-100);
  min-height: 44px;
}
.sp-test-list li:last-child { border-bottom: none; }

/* === Login Gate === */
.sp-login {
  text-align: center;
  padding: 32px;
  background: var(--sp-gray-50);
  border-radius: var(--sp-radius);
}

/* === Login Card === */
.sp-login-card {
  max-width: 420px;
  margin: 32px auto;
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%);
  border: 1px solid #e0e7ff;
  padding: 0;
  overflow: hidden;
}

/* === Tabs === */
.sp-tabs {
  display: flex;
  border-bottom: 2px solid #e0e7ff;
}
.sp-tab {
  flex: 1;
  padding: 14px 16px;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--sp-font);
  color: var(--sp-gray-400);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.sp-tab:hover { color: var(--sp-gray-600); }
.sp-tab-active {
  color: var(--sp-primary);
  border-bottom-color: var(--sp-primary);
}

/* === Tab Panels === */
.sp-tab-panel {
  padding: 24px;
}

/* === Login Form === */
.sp-login-form {
  display: flex;
  flex-direction: column;
}
.sp-login-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}
.sp-login-form label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sp-gray-600);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sp-login-form input[type="email"],
.sp-login-form input[type="password"],
.sp-login-form input[type="text"] {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 0;
  border: 1px solid #d1d5f0;
  border-radius: var(--sp-radius);
  font-size: 1rem;
  font-family: var(--sp-font);
  box-sizing: border-box;
  background: #fff;
}
.sp-login-form input:focus {
  outline: none;
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.sp-login-error {
  background: #fef2f2;
  color: var(--sp-error);
  padding: 10px 12px;
  border-radius: var(--sp-radius);
  font-size: 0.875rem;
  margin-bottom: 14px;
}
.sp-btn-secondary {
  background: #7c3aed;
}
.sp-btn-secondary:hover {
  background: #6d28d9;
}

.sp-login-submit {
  width: 100%;
  margin-top: 4px;
}

/* === Portal wide layout (welcome, dashboard, tests) === */
.sp-wrap.sp-wrap-portal-wide,
.sp-wrap.sp-wrap-dashboard {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* Widen theme wrappers (welcome shortcode page + CPT templates) */
body.sp-portal-wide-page .site-main,
body.sp-portal-wide-page .content-area {
  max-width: 1200px;
  width: 100%;
}
body.sp-portal-wide-page .entry-content,
body.sp-portal-wide-page .wp-block-post-content {
  max-width: none;
  width: 100%;
}

/* Fallback when :has() is supported */
.entry-content:has(.sp-wrap-portal-wide),
.entry-content:has(.sp-wrap-dashboard) {
  max-width: none;
  width: 100%;
}
.site-main:has(.sp-wrap-portal-wide),
.site-main:has(.sp-wrap-dashboard) {
  max-width: 1200px;
  width: 100%;
}
.sp-dashboard-content .sp-dashboard-table,
.sp-dashboard-content .sp-dashboard-table th,
.sp-dashboard-content .sp-dashboard-table td,
.sp-dashboard-content .sp-dashboard-filter {
  font-size: 15px;
}
.sp-dashboard-note {
  color: var(--sp-gray-600);
  font-size: 0.875rem;
  margin: 0 0 16px;
}
.sp-dashboard-card-summary {
  margin: 4px 0 0;
  color: var(--sp-gray-600);
  font-size: 0.875rem;
}
.sp-dashboard-empty {
  color: var(--sp-gray-400);
  padding: 12px 0;
  margin: 0;
}

.sp-dashboard-section-h4 {
  margin: 14px 0 8px;
  font-size: 0.9375rem;
  color: var(--sp-gray-700);
}

.sp-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.sp-dashboard-identity {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}
.sp-dashboard-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  border: 2px solid var(--sp-gray-200);
  background: var(--sp-gray-100);
}
.sp-dashboard-identity-text {
  min-width: 0;
}
.sp-dashboard-welcome {
  margin: 0;
}
.sp-dashboard-nav {
  margin: 8px 0 0;
  font-size: 1.0625rem;
}
.sp-dashboard-nav-link {
  white-space: nowrap;
  font-size: 1.0625rem;
  font-weight: 500;
}
.sp-dashboard-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.sp-logout-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sp-logout-icon {
  width: 1.125em;
  height: 1.125em;
  flex-shrink: 0;
}

/* === Dashboard Cards (expandable) === */
.sp-dashboard-card {
  margin-bottom: 12px;
}
.sp-dashboard-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.sp-dashboard-card > summary::-webkit-details-marker {
  display: none;
}
.sp-dashboard-card > summary::marker {
  content: "";
}
.sp-dashboard-card-info { flex: 1; }
.sp-expand-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--sp-gray-200);
  border-radius: var(--sp-radius);
  background: #fff;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--sp-gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}
.sp-expand-btn::before {
  content: "+";
}
.sp-dashboard-card[open] > summary .sp-expand-btn::before {
  content: "\2212";
}
.sp-dashboard-card[open] > summary .sp-expand-btn {
  background: var(--sp-primary);
  color: #fff;
  border-color: var(--sp-primary);
}
.sp-dashboard-card > summary:hover .sp-expand-btn {
  background: var(--sp-gray-50);
}
.sp-dashboard-card[open] > summary:hover .sp-expand-btn {
  background: var(--sp-primary-hover);
  border-color: var(--sp-primary-hover);
}
.sp-dashboard-card-body {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--sp-gray-100);
}

/* === History Table === */
.sp-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.sp-history-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--sp-gray-600);
  border-bottom: 2px solid var(--sp-gray-200);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sp-history-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--sp-gray-100);
  vertical-align: middle;
}
.sp-history-table tr:last-child td {
  border-bottom: none;
}
.sp-history-table tr:nth-child(even) td {
  background: var(--sp-gray-50);
}
.sp-table-filters th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--sp-gray-200);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}
.sp-dashboard-filter {
  display: block;
  width: 100%;
  min-width: 72px;
  padding: 6px 8px;
  font-size: 0.8125rem;
  border: 1px solid var(--sp-gray-200);
  border-radius: 4px;
  font-family: var(--sp-font);
  box-sizing: border-box;
  background: #fff;
}
.sp-dashboard-filter:focus {
  outline: none;
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}
.sp-dashboard-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Dashboard rows: full-width title, compact meta below */
.sp-dashboard-table .sp-dashboard-test-row > td {
  padding: 0;
  vertical-align: top;
}
.sp-dashboard-test-cell {
  border-bottom: 1px solid var(--sp-gray-100);
}
.sp-dashboard-test-row:last-child .sp-dashboard-test-cell {
  border-bottom: none;
}
.sp-dashboard-test-row:nth-child(even) .sp-dashboard-test-cell {
  background: var(--sp-gray-50);
}
.sp-dashboard-test-title {
  display: block;
  padding: 12px 12px 8px;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.sp-dashboard-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  padding: 0 12px 12px;
}
@media (min-width: 640px) {
  .sp-dashboard-meta {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
.sp-dashboard-meta-cell {
  min-width: 0;
}
.sp-dashboard-meta-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sp-gray-500);
  margin-bottom: 2px;
}
.sp-dashboard-meta-value {
  display: block;
  line-height: 1.3;
}
.sp-dashboard-meta-actions .sp-dashboard-meta-value {
  white-space: nowrap;
}

/* === Test list filter (archive + taxonomy) === */
.sp-test-filter {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--sp-radius);
  padding: 16px 20px 20px;
  margin: 0 0 24px;
}
.sp-test-filter-legend {
  margin: 0 0 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sp-primary);
}
.sp-test-filter-title-row {
  margin-bottom: 14px;
}
.sp-test-filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px 16px;
  align-items: end;
}
@media (min-width: 640px) {
  .sp-test-filter-grid {
    grid-template-columns: 1fr 1fr 1.3fr;
  }
}
.sp-test-filter-label { display: block; margin: 0; min-width: 0; }
.sp-test-filter-key {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sp-gray-600);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.sp-test-filter-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9375rem;
  border: 1px solid var(--sp-gray-200);
  border-radius: 6px;
  font-family: var(--sp-font);
  background: #fff;
  box-sizing: border-box;
}
.sp-test-filter-hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--sp-gray-600);
  line-height: 1.45;
  max-width: 52rem;
}
.sp-test-filter-hint code {
  font-size: 0.7rem;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 3px;
  word-break: break-word;
}
.sp-test-filter-frozen {
  padding: 4px 0 8px;
  border: 1px dashed var(--sp-gray-200);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}
.sp-test-filter-subject-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sp-gray-900);
  display: block;
  margin-top: 2px;
}
.sp-test-filter-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 16px 0 0;
  flex-wrap: wrap;
}
.sp-test-filter-apply { margin: 0; }
.sp-test-list-heading,
.sp-test-archive-subjects-h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--sp-gray-900);
}
.sp-test-archive-subjects-h2 {
  margin-top: 32px;
  padding-top: 8px;
  border-top: 1px solid var(--sp-gray-200);
}
.sp-test-list-archive .sp-test-list-date {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--sp-gray-400);
  margin-left: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.sp-test-list .sp-test-list-date {
  font-size: 0.75rem;
  color: var(--sp-gray-400);
  margin-left: 0.5rem;
  font-variant-numeric: tabular-nums;
}
.sp-test-list-meta {
  color: var(--sp-gray-600);
  font-size: 0.875rem;
}
.sp-test-list-empty { color: var(--sp-gray-600); margin: 0 0 8px; }
nav.pagination { margin: 1rem 0; }
nav.pagination a,
nav.pagination span { margin-right: 0.5rem; }

/* === Split view: questions + protected PDF (25/75 desktop) === */
.sp-wrap.sp-wrap-portal-wide.sp-wrap-split,
.sp-wrap.sp-wrap-dashboard.sp-wrap-split {
  max-width: 100%;
  width: 100%;
}
.sp-split-ref-toggle {
  margin: 0 0 12px;
  display: none;
}
.sp-split-root {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: min(80vh, calc(100vh - 10rem));
  min-height: 420px;
  max-height: calc(100vh - 8rem);
  border: 1px solid var(--sp-gray-200);
  border-radius: var(--sp-radius);
  background: #fff;
  overflow: hidden;
}
.sp-split-root.sp-split-desktop {
  flex-direction: row;
  align-items: stretch;
}
.sp-split-pane {
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
}
.sp-split-root.sp-split-desktop .sp-split-pane {
  height: 100%;
  max-height: 100%;
}
.sp-split-pane-left {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sp-split-questions-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.sp-split-pane-right {
  background: var(--sp-gray-50);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sp-split-ref-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.sp-pdf-frame {
  display: block;
  border: 0;
  width: 100%;
  height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  background: #fff;
}
/* PDF.js viewer (iframe document at /sp-reference/{id}/view/) */
.sp-pdf-viewer-body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sp-gray-100, #f3f4f6);
}
.sp-pdf-viewer-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.sp-pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 8px 10px;
  background: #fff;
  border-bottom: 1px solid var(--sp-gray-200);
  font-family: var(--sp-font, system-ui, sans-serif);
}
.sp-pdf-zoom {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.sp-pdf-zoom-btn,
.sp-pdf-print-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--sp-gray-200);
  border-radius: 6px;
  background: #fff;
  color: var(--sp-gray-700, #374151);
  cursor: pointer;
  font-family: inherit;
}
.sp-pdf-zoom-btn:hover,
.sp-pdf-print-btn:hover {
  border-color: var(--sp-primary);
  color: var(--sp-primary);
}
.sp-pdf-zoom-btn.sp-pdf-zoom-active {
  background: var(--sp-primary);
  border-color: var(--sp-primary);
  color: #fff;
}
.sp-pdf-print-btn {
  flex-shrink: 0;
}
.sp-pdf-pages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: block;
  -webkit-overflow-scrolling: touch;
}
.sp-pdf-page {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 auto 16px;
  width: max-content;
  max-width: none;
}
.sp-pdf-page:last-child {
  margin-bottom: 0;
}
.sp-pdf-page-canvas {
  display: block;
  width: auto;
  max-width: none;
  height: auto;
}
.sp-pdf-viewer-error {
  padding: 24px;
  color: var(--sp-gray-700, #374151);
  font-family: var(--sp-font, system-ui, sans-serif);
  font-size: 0.875rem;
}
@media print {
  .sp-pdf-toolbar {
    display: none !important;
  }
  .sp-pdf-viewer-body {
    background: #fff;
  }
  .sp-pdf-pages {
    overflow: visible;
    padding: 0;
  }
  .sp-pdf-page {
    box-shadow: none;
    border-radius: 0;
    page-break-after: always;
    break-after: page;
  }
  .sp-pdf-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}
.sp-timer.sp-timer-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  flex-shrink: 0;
  background: #fff;
  padding: 12px 16px 8px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--sp-gray-100);
}
.gutter {
  background: var(--sp-gray-100);
  background-repeat: no-repeat;
  background-position: 50%;
  flex-shrink: 0;
}
.gutter.gutter-horizontal {
  cursor: col-resize;
}
@media (max-width: 768px) {
  .sp-split-ref-toggle {
    display: inline-block;
  }
  .sp-split-root {
    height: auto;
    max-height: none;
    min-height: 0;
  }
  .sp-split-root:not(.sp-split-ref-open) .sp-split-pane-right {
    display: none;
  }
  .sp-split-root.sp-split-ref-open .sp-split-pane-right {
    display: flex;
    min-height: 55vh;
    border-top: 1px solid var(--sp-gray-200);
  }
  .sp-split-root.sp-split-ref-open .gutter {
    display: none;
  }
  .sp-split-root.sp-split-ref-open {
    height: min(85vh, calc(100vh - 8rem));
    max-height: calc(100vh - 8rem);
  }
}
@media (min-width: 769px) {
  .sp-split-pane-right {
    display: flex !important;
  }
}

/* === Reading article panel (top of quiz, passage-style) === */
.sp-reading-article-details {
  margin-bottom: 24px;
}
.sp-reading-article-primary {
  padding: 16px;
  margin-bottom: 16px;
  border: 2px solid #ca8a04;
  border-radius: var(--sp-radius);
  background: #fffbeb;
}
.sp-reading-lead {
  margin: 0 0 14px;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--sp-gray-900);
}
.sp-reading-link-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid #fde68a;
  border-radius: var(--sp-radius);
  background: #fff;
  margin-bottom: 0;
  font-size: 1.0625rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.sp-reading-favicon {
  flex-shrink: 0;
  border-radius: 4px;
  width: 40px;
  height: 40px;
}
.sp-reading-link-body {
  flex: 1;
  min-width: 0;
}
.sp-reading-link-title {
  display: block;
  font-weight: 700;
  color: var(--sp-primary);
  text-decoration: none;
  line-height: 1.35;
  margin-bottom: 8px;
  font-size: 1.25rem;
}
.sp-reading-link-title:hover {
  color: var(--sp-primary-hover);
  text-decoration: underline;
}
.sp-reading-link-url {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--sp-gray-600);
  word-break: break-all;
  line-height: 1.45;
}
.sp-reading-copy-btn {
  flex-shrink: 0;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 1rem;
}
.sp-reading-copy-btn.is-copied {
  background: var(--sp-success);
}
.sp-reading-teaser {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid #fde68a;
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--sp-gray-800, #1f2937);
  font-family: var(--sp-font-reading);
}
.sp-reading-howto {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--sp-gray-600);
}
.sp-reading-howto-title {
  margin: 0 0 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sp-gray-500, #6b7280);
}
.sp-reading-instructions {
  margin: 0 0 12px;
  padding-left: 1.25rem;
}
.sp-reading-instructions > li {
  margin-bottom: 6px;
}
.sp-reading-instructions > li:last-child {
  margin-bottom: 0;
}
.sp-reading-help-images {
  width: 100%;
  max-width: 640px;
  border-collapse: collapse;
  border-spacing: 0;
}
.sp-reading-help-images td {
  width: 50%;
  vertical-align: top;
  padding: 0 8px 0 0;
  border: none;
}
.sp-reading-help-images td:last-child {
  padding: 0 0 0 8px;
}
.sp-reading-help-images img {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 6px;
  opacity: 0.92;
}
.sp-reading-help-images-reader img {
  width: 60%;
  max-width: 168px;
}
.sp-reading-missing {
  color: var(--sp-gray-600);
  margin: 0;
}

/* === Mobile === */
@media (max-width: 600px) {
  .sp-subjects { grid-template-columns: 1fr; }
  .sp-passage { padding: 16px; }
  .sp-reading-help-images,
  .sp-reading-help-images tbody,
  .sp-reading-help-images tr,
  .sp-reading-help-images td {
    display: block;
    width: 100%;
    max-width: none;
  }
  .sp-reading-help-images td {
    padding: 0 0 12px;
  }
  .sp-reading-help-images td:last-child {
    padding-bottom: 0;
  }
  .sp-reading-help-images img {
    max-width: 100%;
  }
  .sp-reading-link-card {
    flex-wrap: wrap;
  }
  .sp-question { padding: 12px; }
  .sp-score { padding: 16px; }
  .sp-card { padding: 16px; }
  .sp-timer { padding: 8px 12px; }
  .sp-wrap.sp-wrap-portal-wide,
  .sp-wrap.sp-wrap-dashboard {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  .sp-login-card { margin: 16px auto; }
}

/* === Activity heatmap (GitHub-style) === */
.sp-archive-dashboard-header {
  margin-bottom: 20px;
}
.sp-archive-dashboard-header h1 {
  margin: 0;
}
  margin-bottom: 24px;
  padding: 16px 20px;
}
.sp-activity-heatmap-header {
  margin-bottom: 12px;
}
.sp-activity-heatmap-title {
  margin: 0 0 4px;
  font-size: 1.125rem;
}
.sp-activity-heatmap-summary {
  margin: 0;
  color: var(--sp-gray-600, #4b5563);
  font-size: 0.875rem;
}
.sp-activity-heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.sp-activity-heatmap-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 3px;
  margin-left: 32px;
  margin-bottom: 4px;
  min-width: max-content;
}
.sp-activity-heatmap-month {
  font-size: 0.6875rem;
  color: var(--sp-gray-600, #4b5563);
  line-height: 1;
  white-space: nowrap;
}
.sp-activity-heatmap-month-empty {
  visibility: hidden;
}
.sp-activity-heatmap-body {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.sp-activity-heatmap-day-labels {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  gap: 3px;
  font-size: 0.6875rem;
  color: var(--sp-gray-600, #4b5563);
  line-height: 13px;
  padding-top: 0;
}
.sp-activity-heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 13px;
  gap: 3px;
  min-width: max-content;
}
.sp-activity-heatmap-week {
  display: grid;
  grid-template-rows: repeat(7, 13px);
  gap: 3px;
}
.sp-activity-cell {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  display: block;
  box-sizing: border-box;
}
.sp-activity-cell-hidden {
  visibility: hidden;
}
.sp-activity-level-0 { background: #ebedf0; }
.sp-activity-level-1 { background: #9be9a8; }
.sp-activity-level-2 { background: #40c463; }
.sp-activity-level-3 { background: #30a14e; }
.sp-activity-level-4 { background: #216e39; }
.sp-activity-heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  justify-content: flex-end;
}
.sp-activity-heatmap-legend-label {
  font-size: 0.6875rem;
  color: var(--sp-gray-600, #4b5563);
  margin: 0 4px;
}

/* Portal parent (student roster for sutambe) */
.sp-parent-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 20px;
  padding: 0;
}
.sp-parent-nav-link {
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--sp-gray-700, #374151);
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--sp-gray-100, #f3f4f6);
}
.sp-parent-nav-link:hover {
  background: var(--sp-gray-200, #e5e7eb);
  color: var(--sp-primary, #2563eb);
}
.sp-parent-nav-link-active {
  background: var(--sp-primary, #2563eb);
  color: #fff;
}
.sp-parent-nav-link-active:hover {
  color: #fff;
  background: var(--sp-primary-dark, #1d4ed8);
}
.sp-parent-nav-link-active {
  cursor: default;
}
.sp-parent-nav-sep,
.sp-parent-nav-current {
  font-size: 0.9375rem;
  color: var(--sp-gray-600, #4b5563);
}
.sp-parent-signed-in {
  font-size: 0.9375rem;
  color: var(--sp-gray-600, #4b5563);
  margin: 0;
}
.sp-parent-roster-title {
  margin: 0 0 16px;
  font-size: 1.125rem;
}
.sp-parent-student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.sp-parent-student-card {
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-size: 0.9375rem;
}
.sp-parent-student-card-link {
  display: block;
  padding: 16px;
  text-decoration: none;
  color: inherit;
}
.sp-parent-student-card-link:hover .sp-parent-view-link {
  color: var(--sp-primary, #2563eb);
}
.sp-parent-student-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.sp-parent-student-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.sp-parent-student-name {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}
.sp-parent-student-grade {
  margin: 4px 0 0;
  font-size: 0.9375rem;
  color: var(--sp-gray-600, #4b5563);
}
.sp-parent-student-stats {
  margin: 0 0 10px;
  font-size: 0.9375rem;
  color: var(--sp-gray-700, #374151);
}
.sp-parent-subject-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}
.sp-parent-subject-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--sp-gray-100, #f3f4f6);
}
.sp-parent-subject-list li:first-child {
  border-top: none;
}
.sp-parent-subject-label {
  font-weight: 500;
}
.sp-parent-subject-counts {
  color: var(--sp-gray-600, #4b5563);
  white-space: nowrap;
}
.sp-parent-view-link {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--sp-gray-700, #374151);
}
.sp-parent-ai-tool {
  margin-top: 20px;
}
.sp-parent-ai-tool-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.sp-parent-ai-tool-link:hover .sp-parent-ai-tool-title {
  color: var(--sp-primary);
}
.sp-parent-ai-tool-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--sp-gray-900, #111827);
}
.sp-parent-ai-tool-summary {
  margin: 10px 0 0;
  font-size: 0.9375rem;
  color: var(--sp-gray-600, #4b5563);
}
.sp-parent-student-empty,
.sp-parent-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--sp-gray-600, #4b5563);
}

/* AI Engine chatbot auth wall */
.sp-ai-chatbot-auth-wall {
  max-width: 480px;
  margin: 0 auto;
}
.sp-ai-chatbot-auth-card {
  text-align: center;
}
.sp-ai-chatbot-auth-message {
  margin: 0 0 16px;
  font-size: 1rem;
  color: var(--sp-gray-700, #374151);
}
.sp-ai-chatbot-auth-actions {
  margin: 0;
}
.sp-ai-chatbot-wrap {
  margin-top: 0;
}

/* AI Quiz Generator — tall embedded chat, no sender name labels */
.sp-ai-chatbot-page .entry-content {
  max-width: none;
}
.sp-ai-chatbot-wrap .mwai-chatbot-container,
.sp-ai-chatbot-wrap .mwai-chatbot,
.sp-ai-chatbot-wrap #mwai-chatbot-default {
  --mwai-width: 100%;
  --mwai-maxHeight: min(78vh, 780px);
}
.sp-ai-chatbot-wrap .mwai-body {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 720px);
}
.sp-ai-chatbot-wrap .mwai-conversation {
  flex: 1 1 auto;
  min-height: min(56vh, 560px);
  max-height: min(68vh, 680px);
}
.sp-ai-chatbot-wrap .mwai-reply .mwai-name {
  display: none;
}
