/* Student Platform — Physics Learning Workspace
   Warm scholarly aesthetic. Purposeful visual structure.
   Instrument Serif (display) + Satoshi (body). Amber accent. */

/* ============== FOUNDATION ============== */
body.student-platform-page {
  display: flex;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.875rem;
  line-height: 1.55;
}

body.student-platform-page ::-webkit-scrollbar { width: 5px; }
body.student-platform-page ::-webkit-scrollbar-track { background: transparent; }
body.student-platform-page ::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
body.student-platform-page ::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

/* ============== SIDEBAR ============== */
.sp-sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 56px;
  display: flex; flex-direction: column;
  background: #1c1917;
  border-right: 1px solid rgba(255,255,255,0.05);
  z-index: 100;
  overflow-y: auto; overflow-x: hidden;
}
.sp-sidebar::-webkit-scrollbar { width: 0; }

.sp-brand { padding: 16px 0 12px; display: flex; align-items: center; justify-content: center; }
.sp-brand-logo { width: 26px; height: 26px; flex-shrink: 0; }
.sp-brand-logo svg { width: 100%; height: 100%; color: #faf5eb; }
.sp-brand-name { display: none; }

.sp-nav { flex: 1; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }

.sp-nav-link {
  display: flex; align-items: center; justify-content: center;
  padding: 10px; border-radius: 10px;
  color: #78716c; text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
  position: relative;
}
.sp-nav-link span { display: none; }
.sp-nav-link:hover { color: #d6d3d1; background: rgba(255,255,255,0.06); }
.sp-nav-link.is-active { color: #faf5eb; background: rgba(251,191,36,0.08); }
.sp-nav-link.is-active::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 0 3px 3px 0; background: #fbbf24;
}
.sp-nav-link svg, .sp-nav-link i { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.5; transition: opacity 150ms ease; }
.sp-nav-link:hover svg, .sp-nav-link:hover i { opacity: 0.8; }
.sp-nav-link.is-active svg, .sp-nav-link.is-active i { opacity: 1; color: #fbbf24; }

.sp-nav-link::after {
  content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 4px 10px; border-radius: 6px; background: #292524; color: #e7e5e4;
  font-size: 0.6875rem; font-weight: 500; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 120ms ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.sp-nav-link:hover::after { opacity: 1; }

.sp-sidebar-stats { display: none; }
.sp-stat-value, .sp-stat-label, .sp-stat { display: none; }

.sp-sidebar-footer {
  padding: 8px 6px 12px; border-top: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}

.sp-sidebar-action {
  display: flex; align-items: center; justify-content: center;
  padding: 9px; border-radius: 10px; background: transparent;
  color: #78716c; border: none; cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
  position: relative;
}
.sp-sidebar-action span { display: none; }
.sp-sidebar-action:hover { color: #d6d3d1; background: rgba(255,255,255,0.06); }
.sp-sidebar-action svg, .sp-sidebar-action i { width: 16px; height: 16px; opacity: 0.5; }
.sp-sidebar-action:hover svg, .sp-sidebar-action:hover i { opacity: 0.8; }
.sp-sidebar-action::after {
  content: attr(data-tooltip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  padding: 4px 10px; border-radius: 6px; background: #292524; color: #e7e5e4;
  font-size: 0.6875rem; font-weight: 500; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity 120ms ease;
}
.sp-sidebar-action:hover::after { opacity: 1; }

.sp-user-card { display: flex; align-items: center; justify-content: center; padding: 6px; margin-top: 2px; }
.sp-user-info { display: none; }
.sp-avatar {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #1c1917; display: grid; place-items: center;
  font-weight: 700; font-size: 0.6875rem; flex-shrink: 0;
}
.sp-collapse-btn { display: none; }

/* ============== CONTENT ============== */
.sp-content {
  margin-left: 56px; flex: 1;
  overflow-y: auto; min-height: 100dvh;
  display: flex; flex-direction: column;
}

.sp-status-bar {
  position: sticky; top: 0; z-index: 50;
  padding: 5px 40px; font-size: 0.75rem; color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface); min-height: 28px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.sp-status-bar.is-error { background: var(--color-error-highlight); color: var(--color-error); border-bottom-color: transparent; }
.sp-status-bar.is-success { background: var(--color-success-highlight); color: var(--color-success); border-bottom-color: transparent; }

/* ============== PAGE SHELL ============== */
.sp-page { display: none; }
.sp-page.is-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sp-page-immersive { padding: 0; }

/* ============== PAGE HEADER ============== */
.sp-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 36px 44px 28px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-2);
}

.sp-head-text { min-width: 0; }

.sp-display {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 400; line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin: 0;
}

.sp-lead {
  margin: 6px 0 0;
  color: var(--color-text-muted);
  font-size: 0.875rem; line-height: 1.6;
  max-width: 48ch;
}

.sp-head-controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* ============== SHARED COMPONENTS ============== */

/* Search field */
.sp-search-field {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-surface);
  transition: border-color 180ms ease, box-shadow 180ms ease;
  min-width: 180px;
}
.sp-search-field:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(196,122,26,0.08); }
.sp-search-field svg { width: 14px; height: 14px; color: var(--color-text-faint); flex-shrink: 0; }
.sp-search-field input {
  border: none; background: transparent; color: var(--color-text);
  font-size: 0.8125rem; font-family: var(--font-body); width: 100%; outline: none;
}
.sp-search-field input::placeholder { color: var(--color-text-faint); }
.sp-search-field-grow { flex: 1; }

/* Toolbar row */
.sp-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-divider);
}

/* Section label (small caps group header) */
.sp-section-label {
  font-size: 0.6875rem; font-weight: 600; color: var(--color-text-faint);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 0;
}
.sp-section-label-mt { margin-top: 20px; }

/* Section title (large serif heading) */
.sp-section-title {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 400;
  letter-spacing: -0.02em; color: var(--color-text);
  margin: 0;
}

/* Overline text */
.sp-overline {
  font-size: 0.6875rem; font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Selects */
.sp-select {
  padding: 7px 12px; border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-surface); color: var(--color-text);
  font-size: 0.8125rem; font-family: var(--font-body);
  transition: border-color 180ms ease;
}
.sp-select:focus { outline: none; border-color: var(--color-primary); }

/* Forms */
.sp-form { display: grid; gap: 16px; }
.sp-field { display: grid; gap: 5px; }
.sp-field-label { font-size: 0.8125rem; font-weight: 600; color: var(--color-text); }

.sp-input, .sp-textarea {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-surface); color: var(--color-text);
  font-size: 0.875rem; font-family: var(--font-body);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.sp-input:focus, .sp-textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(196,122,26,0.08); }
.sp-input::placeholder, .sp-textarea::placeholder { color: var(--color-text-faint); }
.sp-textarea { resize: vertical; }

/* Buttons */
.sp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 0.8125rem; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; border: none;
  transition: background 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
  white-space: nowrap;
}
.sp-btn:disabled { opacity: 0.4; cursor: default; }

.sp-btn-primary { background: var(--color-text); color: var(--color-surface-2); }
.sp-btn-primary:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

.sp-btn-secondary { background: var(--color-surface-2); border: 1px solid var(--color-border); color: var(--color-text); }
.sp-btn-secondary:hover { background: var(--color-surface-offset); border-color: var(--color-text-faint); }

.sp-btn-accent { background: var(--color-primary); color: var(--color-text-inverse); }
.sp-btn-accent:hover { box-shadow: 0 2px 10px rgba(196,122,26,0.25); }

.sp-btn-small { padding: 5px 10px; font-size: 0.75rem; border-radius: 6px; }
.sp-btn-ghost { background: transparent; color: var(--color-text-muted); padding: 5px 8px; }
.sp-btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* Lists (dynamically populated) */
.sp-list { display: grid; gap: 2px; }

.sp-list-item {
  padding: 10px 12px; border-radius: 8px;
  background: transparent; display: grid; gap: 3px;
  transition: background 150ms ease; cursor: pointer;
}
.sp-list-item:hover { background: var(--color-surface-offset); }
.sp-list-item.is-selected { background: var(--color-primary-subtle); }

.sp-list-item-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.sp-list-item h3, .sp-list-item h4 { margin: 0; font-size: 0.8125rem; font-weight: 600; line-height: 1.35; color: var(--color-text); }
.sp-list-item p { color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.5; margin: 0; }
.sp-list-meta { font-size: 0.6875rem; color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
.sp-list-actions { display: flex; flex-wrap: wrap; gap: 4px; }

/* Badges */
.sp-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 9999px;
  background: var(--color-surface-offset);
  font-size: 0.6875rem; font-weight: 600; color: var(--color-text-muted);
  letter-spacing: 0.02em;
}
.sp-badge-amber { background: rgba(251,191,36,0.12); color: var(--color-primary); }
.sp-badge-green { background: rgba(5,150,105,0.1); color: #059669; }
.sp-badge-red { background: rgba(225,29,72,0.1); color: #dc2626; }

/* Pills */
.sp-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-pill {
  padding: 3px 10px; border-radius: 9999px;
  border: 1px solid var(--color-divider); background: var(--color-surface);
  font-size: 0.75rem; font-weight: 600; color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Messages */
.sp-messages { display: grid; gap: 6px; }
.sp-message {
  padding: 10px 14px; border-radius: 10px;
  background: var(--color-surface); border: 1px solid var(--color-divider);
  display: grid; gap: 3px;
}
.sp-message p { color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.6; margin: 0; }
.sp-message-user { background: var(--color-text); border-color: var(--color-text); }
.sp-message-user p, .sp-message-user .sp-list-meta { color: rgba(255,255,255,0.8); }

/* Empty */
.sp-empty {
  padding: 48px 16px; text-align: center;
  color: var(--color-text-faint); font-size: 0.875rem; line-height: 1.6;
}

/* Related list */
.sp-related-list { padding-left: 16px; display: grid; gap: 4px; }
.sp-related-list li { font-size: 0.8125rem; line-height: 1.5; color: var(--color-text-muted); }
.sp-related-list li strong { color: var(--color-text); }

.hidden { display: none !important; }

/* ============== GRAPH ============== */
.sp-map-stage {
  position: relative; min-height: 300px;
  border-radius: 12px; border: 1px solid var(--color-divider);
  background: var(--color-surface-2); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.sp-map-stage svg { width: 100%; height: 100%; display: block; }

.sp-graph-edge { stroke: var(--color-divider); stroke-width: 1; }
.sp-graph-edge.is-highlight { stroke: var(--color-primary); stroke-width: 1.5; opacity: 1; }
.sp-graph-node { cursor: pointer; }
.sp-graph-node:hover circle { filter: brightness(1.1); }
.sp-graph-node circle { stroke-width: 2; stroke: var(--color-surface-2); transition: filter 150ms ease; }
.sp-graph-node.is-selected circle { stroke: var(--color-text); stroke-width: 3; }
.sp-graph-node text { fill: var(--color-text-muted); font-family: var(--font-body); font-size: 9px; font-weight: 500; pointer-events: none; text-anchor: middle; }

.sp-graph-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 8px 0 0; }
.sp-graph-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.6875rem; color: var(--color-text-faint); }
.sp-graph-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Legacy map nodes */
.sp-map-center { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; border: 1px dashed var(--color-border); color: var(--color-text-faint); font-size: 0.625rem; letter-spacing: 0.05em; text-transform: uppercase; }
.sp-map-link { position: absolute; left: var(--from-x); top: var(--from-y); width: var(--distance); height: 1px; transform-origin: left center; transform: rotate(var(--angle)); background: var(--color-divider); }
.sp-map-node { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%,-50%); max-width: 140px; padding: 7px 11px; border: 1px solid var(--color-divider); border-radius: 8px; background: var(--color-surface-2); color: var(--color-text); font-size: 0.8125rem; font-weight: 600; cursor: pointer; transition: border-color 180ms ease, box-shadow 180ms ease; }
.sp-map-node:hover { border-color: var(--color-text-faint); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.sp-map-node.is-focus { background: var(--color-text); border-color: var(--color-text); color: var(--color-text-inverse); }
.sp-map-node.is-strong { border-color: #059669; }
.sp-map-node.is-gap { border-color: #dc2626; }

/* Problem library items (JS-created) */
.sp-library-card,
.sp-problem-library-item {
  padding: 16px 18px; border-radius: 12px;
  border: 1px solid var(--color-divider);
  background: var(--color-surface-2); cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  display: grid; gap: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.sp-library-card:hover,
.sp-problem-library-item:hover {
  border-color: var(--color-primary);
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}

/* ============== OVERLAYS ============== */
.sp-overlay {
  position: fixed; inset: 0; z-index: 250;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 24px;
  background: rgba(20,20,20,0.45);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.sp-drawer-card {
  width: min(480px, 100%); max-height: calc(100dvh - 48px);
  border-radius: 16px; border: 1px solid var(--color-divider);
  background: var(--color-surface-2); box-shadow: 0 20px 56px rgba(0,0,0,0.18);
  display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
}
.sp-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--color-divider);
}
.sp-modal-title {
  margin: 0; font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 400; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--color-text);
}
.sp-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-text-muted); cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease;
}
.sp-icon-btn:hover { border-color: var(--color-text-faint); color: var(--color-text); }
.sp-icon-btn svg, .sp-icon-btn i { width: 15px; height: 15px; }
.sp-thread-drawer-card #theory-thread-list { overflow: auto; padding: 12px 22px 22px; }

/* ============== SKELETON ============== */
.sp-skeleton {
  background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-divider) 50%, var(--color-surface-offset) 75%);
  background-size: 200% 100%; animation: sp-shimmer 1.5s ease-in-out infinite; border-radius: 6px;
}
@keyframes sp-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ======================================================================
   PAGE: SKILLS
   Full-width graph card on top, three info cards below.
   ====================================================================== */
.sp-skills-stage {
  display: flex; flex-direction: column; gap: 18px;
  flex: 1; min-height: 0;
  padding: 24px 44px 36px;
}

.sp-skills-graph-card {
  flex: 1; min-height: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-skills-graph-card .sp-map-stage {
  flex: 1; min-height: 320px;
  border-radius: 10px;
}

.sp-skills-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.85fr) minmax(0, 0.85fr);
  gap: 14px;
  min-height: 0;
}

.sp-skills-focus-card,
.sp-skills-strength-card,
.sp-skills-gaps-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  max-height: 280px;
  overflow-y: auto;
}

.sp-skills-focus-card .sp-focus-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 400;
  line-height: 1.1; letter-spacing: -0.02em;
  color: var(--color-text); margin: 0;
}
.sp-skills-focus-card .sp-focus-summary {
  margin: 0; color: var(--color-text-muted);
  font-size: 0.8125rem; line-height: 1.6;
}

/* ======================================================================
   PAGE: PROBLEMS
   Library above, activity below.
   ====================================================================== */
.sp-problems-body {
  display: flex; flex-direction: column; gap: 0;
  flex: 1; min-height: 0;
  padding: 24px 44px 36px;
}

.sp-problems-library {
  display: flex; flex-direction: column; gap: 16px;
  flex: 1; min-height: 0;
}

.sp-problem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  overflow-y: auto; padding-right: 4px;
  flex: 1;
  align-content: start;
}

.sp-problems-activity {
  padding-top: 24px; margin-top: 24px;
  border-top: 1px solid var(--color-divider);
}

.sp-activity-tabs { display: flex; gap: 2px; margin-bottom: 14px; }

.sp-tab,
[data-problem-view] {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border: none; border-radius: 8px;
  background: transparent; color: var(--color-text-muted);
  font-size: 0.8125rem; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; transition: background 150ms ease, color 150ms ease;
}
.sp-tab span,
[data-problem-view] span { font-weight: 500; font-size: 0.75rem; color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
.sp-tab:hover,
[data-problem-view]:hover { background: var(--color-surface-offset); color: var(--color-text); }
.sp-tab.is-active,
[data-problem-view].is-active { background: var(--color-text); color: var(--color-surface-2); }
.sp-tab.is-active span,
[data-problem-view].is-active span { color: rgba(255,255,255,0.6); }

.sp-activity-body { max-height: 340px; overflow-y: auto; padding-right: 4px; }

/* Compat aliases */
.sp-problems-tab {}
.sp-problems-activity-list {}

/* ======================================================================
   PAGE: THEORY
   Three cards side by side: nav | reader | notes
   ====================================================================== */
.sp-theory-stage {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: 14px;
  flex: 1; min-height: 0;
  padding: 24px 44px 36px;
}

.sp-theory-nav-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-theory-nav-divider { height: 1px; background: var(--color-divider); margin: 6px 0; }

.sp-theory-reader-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-reader-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}

.sp-doc-body {
  flex: 1;
  padding: 24px 28px;
  border-radius: 10px;
  border: 1px solid var(--color-divider);
  background: var(--color-surface);
  color: var(--color-text);
  line-height: 1.8;
  overflow-y: auto;
  font-size: 0.9375rem;
}
.sp-doc-body h1, .sp-doc-body h2, .sp-doc-body h3 { font-family: var(--font-display); margin-top: 1.6em; margin-bottom: 0.5em; }
.sp-doc-body h1:first-child, .sp-doc-body h2:first-child, .sp-doc-body h3:first-child { margin-top: 0; }
.sp-doc-body code { font-size: 0.8125rem; padding: 2px 5px; border-radius: 4px; background: var(--color-surface-offset); }
.sp-doc-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.sp-theory-notes-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-notes-head { display: flex; flex-direction: column; gap: 6px; }
.sp-notes-thread-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 400;
  line-height: 1.15; color: var(--color-text);
  margin: 0; letter-spacing: -0.01em;
}
.sp-notes-meta { margin: 0; color: var(--color-text-faint); font-size: 0.8125rem; line-height: 1.5; }
.sp-notes-messages { flex: 1; overflow-y: auto; }

.sp-note-form {
  display: grid; gap: 8px;
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--color-divider);
}

/* ======================================================================
   PAGE: PROFILE
   Hero card on top, two-column cards below.
   ====================================================================== */
.sp-page-profile {
  padding: 0;
  overflow-y: auto;
}

.sp-profile-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 44px 64px;
  display: flex; flex-direction: column; gap: 18px;
}

/* Hero card */
.sp-profile-hero-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 16px;
  padding: 28px 32px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-profile-hero-inner {
  display: flex; align-items: center; gap: 20px;
  min-width: 0;
}

.sp-profile-avatar-xl {
  width: 72px; height: 72px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #1c1917; font-size: 1.3rem; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(217,119,6,0.22);
}

.sp-profile-hero-text { min-width: 0; }
.sp-profile-hero-text .sp-display { font-size: 1.7rem; margin-bottom: 2px; }
.sp-profile-hero-text .sp-lead { font-size: 0.8125rem; margin-top: 4px; max-width: 40ch; }
.sp-profile-handle { color: var(--color-text-faint); font-size: 0.8125rem; margin-top: 4px; }

.sp-profile-hero-stats {
  display: flex; gap: 28px; flex-shrink: 0;
}

.sp-profile-stat { text-align: center; }

.sp-profile-stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 400;
  color: var(--color-text);
  letter-spacing: -0.03em; line-height: 1;
}

.sp-profile-stat-label {
  display: block; margin-top: 4px;
  font-size: 0.6875rem; font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Two-column body */
.sp-profile-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 18px;
  min-height: 0;
}

.sp-profile-details-card,
.sp-profile-goals-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: 14px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.sp-goal-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 8px; }
.sp-goal-col { display: flex; flex-direction: column; gap: 8px; }

/* Compat: old stat elements (JS sets textContent on the new IDs) */
.sp-profile-stat-card { display: contents; }
.sp-profile-stat-value { display: none; }
.sp-profile-hero-meta { display: none; }

/* ======================================================================
   PROBLEM DETAIL (iframe page)
   ====================================================================== */
.sp-problem-frame-wrap { position: relative; min-height: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--color-divider); background: var(--color-surface); }
.sp-problem-frame { width: 100%; height: 100%; border: none; display: block; background: transparent; }
.sp-problem-frame-page { width: 100%; height: 100%; }
.sp-page-problem-detail { width: 100%; padding: 0 !important; }
.sp-problem-detail-stage { display: block; width: 100%; height: 100%; min-height: 0; }
.sp-problem-detail-frame-wrap { height: 100%; min-height: 0; border-radius: 0; border: none; background: transparent; }
.sp-problem-detail-empty { height: 100%; display: grid; place-items: center; gap: 12px; padding: 36px; text-align: center; color: var(--color-text-muted); }
.sp-problem-detail-empty h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem,3vw,2.2rem); line-height: 1.05; color: var(--color-text); }
.sp-problem-detail-empty p { margin: 0; max-width: 42ch; line-height: 1.7; }

/* ======================================================================
   ENTRANCE ANIMATIONS
   ====================================================================== */
@keyframes sp-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sp-page.is-active .sp-head { animation: sp-fadeIn 400ms cubic-bezier(0.16,1,0.3,1) both; }
.sp-page.is-active .sp-skills-stage,
.sp-page.is-active .sp-problems-body,
.sp-page.is-active .sp-theory-stage,
.sp-page.is-active .sp-profile-page {
  animation: sp-fadeIn 400ms cubic-bezier(0.16,1,0.3,1) 60ms both;
}

@media (prefers-reduced-motion: reduce) {
  .sp-page.is-active .sp-head,
  .sp-page.is-active .sp-skills-stage,
  .sp-page.is-active .sp-problems-body,
  .sp-page.is-active .sp-theory-stage,
  .sp-page.is-active .sp-profile-page { animation: none; }
}

/* ======================================================================
   COMPAT: OLD CLASS NAMES (used by student.html SPA + JS)
   ====================================================================== */
.sp-card {
  background: var(--color-surface-2); border: 1px solid var(--color-divider);
  border-radius: 12px; padding: 22px;
  display: grid; align-content: start; gap: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.sp-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp-card-title { font-size: 0.6875rem; font-weight: 600; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.sp-card-accent { border-top: 2px solid var(--color-primary); }
.sp-workspace-panel { min-height: 0; }
.sp-panel-subtitle { margin: 2px 0 0; color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.55; }
.sp-focus-title { margin: 0; font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; line-height: 1.1; letter-spacing: -0.02em; color: var(--color-text); }
.sp-focus-summary { margin: 0; color: var(--color-text-muted); font-size: 0.8125rem; line-height: 1.6; }
.sp-divider { height: 1px; background: var(--color-divider); }
.sp-page-label { display: none; }
.sp-page-title { font-family: var(--font-display); font-size: clamp(1.8rem,3vw,2.5rem); font-weight: 400; line-height: 1.05; letter-spacing: -0.03em; color: var(--color-text); margin: 0; }
.sp-page-desc { margin: 6px 0 0; color: var(--color-text-muted); font-size: 0.875rem; line-height: 1.6; max-width: 48ch; }
.sp-select-wrap { display: inline-flex; align-items: center; gap: 8px; }
.sp-select-wrap .sp-field-label { white-space: nowrap; font-size: 0.8125rem; }
.sp-section-divider { margin: 28px 0 12px; font-size: 0.6875rem; font-weight: 600; color: var(--color-text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.sp-card-heading { margin: 4px 0 0; font-family: var(--font-display); font-size: clamp(1.2rem,2vw,1.5rem); font-weight: 400; line-height: 1.05; letter-spacing: -0.03em; color: var(--color-text); }

/* Grids (used by student.html SPA) */
.sp-grid { display: grid; gap: 16px; }
.sp-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-grid-2-wide { grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); }
.sp-grid-aside { grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.25fr); }
.sp-mt { margin-top: 16px; }
.sp-page-header { margin-bottom: 32px; }
.sp-page-controls { display: flex; align-items: center; gap: 12px; margin-top: 16px; }

/* Old search (SPA) */
.sp-search { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface); min-width: 200px; transition: border-color 180ms ease, box-shadow 180ms ease; }
.sp-search:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(196,122,26,0.08); }
.sp-search-icon { width: 14px; height: 14px; color: var(--color-text-faint); flex-shrink: 0; }
.sp-search-input { border: none; background: transparent; color: var(--color-text); font-size: 0.8125rem; font-family: var(--font-body); width: 100%; outline: none; }
.sp-search-input::placeholder { color: var(--color-text-faint); }

/* ======================================================================
   RESPONSIVE
   ====================================================================== */
@media (max-width: 1200px) {
  .sp-skills-bottom { grid-template-columns: 1fr 1fr; }
  .sp-skills-focus-card { grid-column: 1 / -1; }

  .sp-theory-stage { grid-template-columns: 200px minmax(0, 1fr); }
  .sp-theory-notes-card { grid-column: 1 / -1; }

  .sp-profile-body { grid-template-columns: 1fr; }
  .sp-profile-hero-card { flex-direction: column; align-items: stretch; text-align: center; }
  .sp-profile-hero-inner { flex-direction: column; align-items: center; }
  .sp-profile-hero-stats { justify-content: center; }
}

@media (max-width: 1024px) {
  .sp-sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; height: auto; flex-direction: row;
    border-right: none; border-top: 1px solid rgba(255,255,255,0.06);
    z-index: 200;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    background: rgba(28,25,23,0.95);
  }
  .sp-brand, .sp-sidebar-footer, .sp-collapse-btn { display: none; }
  .sp-nav { flex-direction: row; padding: 6px 8px; gap: 2px; justify-content: center; }
  .sp-nav-link { padding: 8px 18px; min-width: 64px; }
  .sp-nav-link::after { display: none; }
  .sp-nav-link.is-active::before { display: none; }
  .sp-content { margin-left: 0; padding-bottom: 72px; }

  .sp-head { padding: 24px 24px 20px; }
  .sp-skills-stage { padding: 20px 24px 32px; }
  .sp-problems-body { padding: 20px 24px 32px; }
  .sp-profile-page { padding: 24px 24px 48px; }
  .sp-profile-hero-card { padding: 22px 24px; }
  .sp-profile-hero-stats { flex-wrap: wrap; gap: 16px; }

  .sp-theory-stage { grid-template-columns: 1fr; }
  .sp-theory-nav-card { max-height: 200px; }
  .sp-skills-bottom { grid-template-columns: 1fr; }

  .sp-goal-columns { grid-template-columns: 1fr; }
  .sp-profile-hero-stats { gap: 16px; }

  .sp-overlay { padding: 18px 14px 84px; align-items: end; }
  .sp-drawer-card { max-height: min(82dvh, 900px); border-radius: 14px 14px 0 0; width: 100%; }

  /* SPA compat */
  .sp-grid-2, .sp-grid-2-wide, .sp-grid-aside { grid-template-columns: 1fr; }
  .sp-page:not(.sp-page-immersive):not(.sp-page-profile) { padding: 24px 24px 40px; }
}

@media (max-width: 640px) {
  .sp-head { flex-direction: column; align-items: stretch; gap: 12px; padding: 18px 18px 16px; }
  .sp-head-controls { flex-wrap: wrap; }
  .sp-display { font-size: 1.6rem; }

  .sp-skills-stage { padding: 16px 18px 28px; }
  .sp-skills-graph .sp-map-stage { min-height: 280px; }
  .sp-inspect-lists { grid-template-columns: 1fr; }

  .sp-problems-body { padding: 16px 18px 28px; }
  .sp-problem-grid { grid-template-columns: 1fr; }

  .sp-profile-page { padding: 18px 16px 40px; }
  .sp-profile-hero-card { padding: 20px; }
  .sp-profile-hero-text .sp-display { font-size: 1.4rem; }
  .sp-profile-hero-stats { gap: 12px; }
  .sp-profile-stat-num { font-size: 1.2rem; }

  .sp-page-title { font-size: 1.5rem; }
  .sp-map-stage { min-height: 280px; }
}
