    :root {
      --primary: #FF6B6B;
      --secondary: #4ECDC4;
      --dark: #2C3E50;
      --light: #F5F5F5;
      --accent1: #FF9F43;
      --accent2: #6A5ACD;
      --accent3: #2ECC71;
      --gray: #DDDDDD;
      --white: #FFFFFF;
      --blue-bg: #e6f2ff;
    }
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
    body {
      background-color: var(--light);
      color: var(--dark);
    }
    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0px 15px;
      min-height: 60px;
      background-color: white;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
      flex-wrap: wrap;
    }
    .logo a {
      font-size: 24px;
      font-weight: bold;
      color: var(--primary);
      text-decoration: none;
    }
    .logo img {
      height: 40px;
      width: auto;
      display: block;
    }

    .nav-tabs {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      justify-content: center;
    }
    .nav-tab {
      padding: 10px 20px;
      background-color: transparent;
      border-radius: 6px;
      cursor: pointer;
      text-decoration: none;
      font-weight: 500;
      font-size: 15px;
      color: #6C757D;
      border: 1.5px solid transparent;
      transition: all 0.2s ease;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
        text-decoration: none;
        transition: background 0.2s;
    }
    .nav-tab:hover,
    .nav-tab.active {
      color: #CB00A3;
      border-color: #F0D6EA;
    }

    .user-actions {
        display: flex;
        gap: 12px;
        align-items: center;
    }

    .profile-btn,
    .logout-btn {
        padding: 10px 20px;
        font-size: 14px;
        font-weight: 500;
        border-radius: 6px;
        cursor: pointer;
        text-decoration: none;
        transition: all 0.2s ease;
        border: 1.5px solid;
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    }

    .profile-btn {
        background-color: transparent;
        color: #CB00A3;
        border-color: #CB00A3;
    }

    .profile-btn:hover {
        background-color: #CB00A3;
        color: white;
    }

    .logout-btn {
        background-color: #CB00A3;
        color: white;
        border-color: #CB00A3;
    }

    .logout-btn:hover {
        background-color: #A30082;
    }

    /* Responsive adjustments */
    @media (max-width: 768px) {
        .header {
            padding: 0 16px;
            height: auto;
            min-height: 72px;
            flex-direction: column;
            gap: 12px;
            padding: 12px;
        }
    }

    @media (max-width: 480px) {
        .nav-tabs {
            width: 100%;
            justify-content: space-between;
        }
        
        .nav-tab {
            padding: 8px 12px;
            font-size: 14px;
        }
        
        .user-actions {
            width: 100%;
            justify-content: center;
        }
    } 

    .statscontainer {
      display: grid;
      grid-template-columns: 1fr;
      gap: 20px;
      padding: 20px;
    }    
    .container {
      display: grid;
      grid-template-columns: 1fr;
      gap: 20px;
      padding: 20px;
    }

    /* CRITICAL: Safari/iPad grid fix */
    .container > div {
        min-width: 0;
    }

    /* Desktop only */
    @media (min-width: 1025px) {
        .container {
            grid-template-columns: 2.8fr 1fr;
        }
    }

    /* iPad & Tablet */
    @media (min-width: 768px) and (max-width: 1024px) {
        .container {
            grid-template-columns: 1fr;
        }
    }

    /* ================= SECTIONS ================= */

    .section {
      background: white;
      padding: 20px;
      border-radius: 10px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.05);
      margin-bottom: 20px;
      max-width: 100%;
      overflow: hidden;
    }
    .section-title {
      font-size: 20px;
      margin-bottom: 15px;
      text-align: center;
      color: var(--dark);
    }
    .tasks-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 15px;
    }
    .task-card {
      background: #FFF5E6;
      padding: 15px;
      border-radius: 8px;
      border-left: 4px solid var(--accent1);
    }
    .task-card h4 {
      margin-bottom: 8px;
      font-size: 14px;
    }
    .task-card p {
      font-size: 12px;
      color: #666;
    }
    .user-wall {
      text-align: center;
      padding: 20px;
      background: #F9F9F9;
      border-radius: 10px;
    }
    .avatar-container {
      width: 80px;
      height: 80px;
      border-radius: 50%;
      overflow: hidden;
      background: #f0f0f0;
      margin: 0 auto 10px auto;   /* centers horizontally */
    }

    .user-avatar {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
    .user-name {
      font-size: 20px;
      font-weight: bold;
      margin: 5px 0;
    }
    .user-nickname {
      color: #888;
      font-size: 14px;
    }
    .stats-row {
      display: flex;
      justify-content: space-around;
      margin: 15px 0;
      flex-wrap: wrap;
      gap: 10px;
    }
    .stat-item {
      text-align: center;
      font-size: 14px;
      min-width: 80px;
    }
    .stat-value {
      font-size: 18px;
      font-weight: bold;
    }
    .generate-btn {
      width: 100%;
      padding: 10px;
      background-color: var(--primary);
      color: white;
      border: none;
      border-radius: 20px;
      cursor: pointer;
      margin-top: 15px;
    }
    .subject-section {
      padding: 15px;
      border-radius: 10px;
      margin-bottom: 15px;
      position: relative;
      overflow: hidden;
    }
    .subject-header {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
      gap: 6px;
    }
    .feedback-container {
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
    }
    @media (max-width: 480px) {
      .subject-header {
        gap: 4px;
      }
      .feedback-container {
        width: 100%;
        order: 3;
        flex-wrap: wrap;
        gap: 4px;
      }
      .feedback-container label {
        font-size: 13px !important;
        margin-right: 4px !important;
      }
      .feedback-container .feedback-select {
        max-width: 100% !important;
        width: 100%;
        font-size: 13px !important;
      }
    }
    .subject-title {
      font-size: 20px;
      font-weight: bold;
    }
    .score-box {
      background: white;
      padding: 10px;
      border-radius: 8px;
      text-align: center;
    }
    .progress-dots {
      display: flex;
      gap: 5px;
      margin: 10px 0;
      align-items: center;
    }
    .dot {
      width: 15px;
      height: 15px;
      border-radius: 50%;
      background: #ccc;
    }
    .dot.active {
      background: var(--primary);
    }
    .dot.completed {
      background: var(--accent3);
    }
    .chart-carousel {
      display: flex;
      overflow-x: auto;
      gap: 20px;
      padding: 10px 0;
      margin: 15px 0;
    }
    .chart-card {
      min-width: 260px;
      max-width: 300px;
      flex-shrink: 0;
      background: white;
      border-radius: 12px;
      padding: 15px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    .chart-container {
      height: 200px;
      width: 100%;
    }
    .carousel-nav {
      display: flex;
      justify-content: center;
      gap: 8px;
      margin-top: 10px;
    }
    .carousel-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background: #ccc;
      cursor: pointer;
    }
    .carousel-dot.active {
      background: var(--primary);
    }
    .chart-title {
      text-align: center;
      font-size: 14px;
      margin-bottom: 10px;
      font-weight: bold;
    }
    .wall-feed {
      overflow-y: auto;
      overflow-x: hidden;
      max-height: 840px;
    }
    .wall-post {
      background: rgba(245, 245, 245, 0.7);
      border-radius: 12px;
      padding: 14px;
      margin-bottom: 16px;
      border: 1px solid rgba(220, 220, 220, 0.6);
      box-shadow: 0 2px 6px rgba(0,0,0,0.05);
      word-break: break-word;
      overflow-wrap: break-word;
    }
    .reaction {
      position: relative;
      cursor: pointer;
      transition: transform 0.1s ease, opacity 0.1s ease;
    }
    .reaction:active {
      transform: scale(0.95);
      opacity: 0.8;
    }
    .reaction-tooltip {
      position: absolute;
      bottom: 40%;
      left: 200%;
      transform: translateX(-50%);
      background: black;
      color: white;
      padding: 6px 12px;
      border-radius: 6px;
      font-size: 12px;
      white-space: nowrap;
      min-width: 100px;
      text-align: center;
      z-index: 100;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s;
    }
    .reaction:hover .reaction-tooltip {
      opacity: 1;
    }
    /* Footer */
    .footer {
        background: var(--dark);
        color: white;
        padding: 24px 0;
        text-align: center;
    }

    .footer-links {
        display: flex;
        justify-content: center;
        gap: 24px;
        margin-bottom: 16px;
        flex-wrap: wrap;
    }

    .footer-links a {
        color: #CBD5E0;
        text-decoration: none;
        font-size: 15px;
        transition: color 0.2s;
    }

    .footer-links a:hover {
        color: white;
        text-decoration: underline;
    }

    .footer p {
        font-size: 14px;
        color: #A0AEC0;
    }

    /* ===== BODY & LAYOUT ===== */
    body {
      display: flex;
      flex-direction: column;
      min-height: 100vh;
      background-color: var(--light);
      color: var(--dark);
      margin: 0;
      padding: 0;
    }

    .container {
      flex: 1;
      display: grid;
      grid-template-columns: 1fr;
      gap: 20px;
      padding: 20px;
      overflow-y: auto;
    }

    /* Critical: Safari/iPad fix */
    .container > div {
      min-width: 0;
    }

    /* Desktop */
    @media (min-width: 1025px) {
      .container {
        grid-template-columns: 2.8fr 1fr;
      }
    }

    /* iPad/Tablet */
    @media (min-width: 768px) and (max-width: 1024px) {
      .container {
        grid-template-columns: 1fr;
      }
    }
 
/* ===== LEGAL PAGES CONTAINER ===== */
.legal-container {
  max-width: 800px;
  margin: 40px auto; /* Centers the container */
  padding: 0 20px;
}

.legal-card {
  background: white;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  text-align: center;
}

.legal-card h1 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 32px;
}

.legal-card .last-updated {
  color: #7f8c8d;
  font-style: italic;
  margin-bottom: 30px;
}

.legal-content {
  text-align: left;
  line-height: 1.8;
  color: #34495e;
  font-size: 16px;
}

/* ── Stylus Scratchpad (shared across math/nvr/verbal quiz & heroes) ── */
.sp-panel {
  flex: 0 0 360px;
  position: sticky;
  top: 20px;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 14px rgba(0,0,0,0.08);
  padding: 12px 12px 8px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Narrower scratchpad on medium laptop screens so the question panel gets more room */
@media (min-width: 901px) and (max-width: 1100px) {
  .sp-panel {
    flex: 0 0 200px !important;
    min-width: 180px;
  }
}
@media (min-width: 1101px) and (max-width: 1350px) {
  .sp-panel {
    flex: 0 0 260px !important;
  }
}
.sp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.sp-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.sp-clear {
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.sp-clear:hover { background: #FECACA; }
.sp-fix {
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #EFF6FF;
  color: #2563EB;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.sp-fix:hover { background: #DBEAFE; }
.sp-hint {
  font-size: 0.72rem;
  font-style: italic;
  color: #bbb;
  text-align: center;
  margin: 0 0 6px;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}
.sp-canvas {
  flex: 1;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  cursor: none;
  touch-action: none;
  -ms-touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #fff;
  display: block;
  box-sizing: border-box;
}
/* Mobile toggle button — hidden on desktop */
.sp-toggle { display: none; }

@media (max-width: 900px) {
  .sp-panel {
    display: none;
    position: static;
    height: 300px;
    flex: none;
    margin-bottom: 14px;
    top: auto;
  }
  .sp-panel.open { display: flex; flex-direction: column; }
  .sp-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    background: #F5F3FF;
    color: #7C3AED;
    border: 1.5px solid #C4B5FD;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 12px;
    touch-action: manipulation;
    box-sizing: border-box;
  }
  .sp-toggle:active { background: #EDE9FE; }
}
@media (max-width: 600px) {
  .sp-panel { height: 240px; }
}