/* ==========================================
   RESET & BASE
   ========================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Dark-mode palette */
    --bg-page:        #1a1d23;
    --bg-container:   #21252e;
    --bg-card:        #272b35;
    --bg-header:      #1e2330;

    --accent-green:   #3dd68c;
    --accent-blue:    #5b9cf6;
    --accent-amber:   #f0a500;

    --border-main:    #3a3f4e;
    --border-accent:  #3dd68c;

    --text-primary:   #e8eaf0;
    --text-secondary: #a0a8bc;
    --text-heading:   #ffffff;
    --text-on-dark:   #e8eaf0;

    --h2-bg:          #1e2330;
    --h4-bg:          #2e3547;

    --tooltip-bg:     #1a1d23;
    --tooltip-border: #3dd68c;

    --dropdown-sum:   #2a2f3d;
    --dropdown-ans:   #242837;

    --nav-width:      280px;
    --nav-bg:         #181b22;
    --nav-border:     #2e3547;

    --shadow-soft:    0 4px 20px rgba(0,0,0,0.4);
    --shadow-glow:    0 0 16px rgba(61,214,140,0.15);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.7;
    color: var(--text-primary);
    padding: 30px 16px;
    min-height: 100vh;
}

/* ── HAND-DRAWN BACKGROUND ──
   Previously body had `background-attachment: fixed`, which forces the
   browser to repaint the ENTIRE window on every scroll tick instead of
   just the newly-revealed strip — a long-documented cause of janky,
   low-framerate scrolling (worse the taller the page). Moving the same
   tiled image onto its own fixed, negative-z-index pseudo-element gets
   the "locked in place while scrolling" look via compositing instead,
   so it's smooth. No visual change, no HTML/JS change required. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url('some_background.png'); /* Paths to your Inkscape file */
    background-repeat: repeat;                     /* Tiles the 200x200px square infinitely */
    background-color: var(--bg-page);
}

/* ==========================================
   HAMBURGER SIDEBAR NAV
   ========================================== */

/* Overlay backdrop */
#nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 900;
    backdrop-filter: blur(2px);
}

#nav-overlay.open {
    display: block;
}

/* Sidebar panel */
#side-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--nav-width);
    height: 100%;
    background: var(--nav-bg);
    border-right: 2px solid var(--nav-border);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 0 0 40px 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}

#side-nav.open {
    transform: translateX(0);
}

.nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--nav-border);
    background: var(--bg-header);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-header span {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-green);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.nav-close-btn:hover {
    color: var(--accent-green);
    background: rgba(61,214,140,0.1);
}

#side-nav ul {
    list-style: none;
    padding: 12px 0;
}

#side-nav ul li a {
    display: block;
    padding: 9px 22px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.93rem;
    border-left: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

#side-nav ul li a:hover {
    color: var(--accent-green);
    border-left-color: var(--accent-green);
    background: rgba(61,214,140,0.07);
}

#side-nav ul li.nav-section-title {
    padding: 14px 22px 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Hamburger button */
#hamburger-btn {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 850;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#hamburger-btn:hover {
    border-color: var(--accent-green);
    box-shadow: var(--shadow-glow);
}

#hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--accent-green);
    border-radius: 2px;
    transition: transform 0.2s;
}

/* ==========================================
   MAIN CONTAINER
   ========================================== */

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
	min-width: 0;
    
    /* ── ADDED FOR YOUR INNER TEXTURE ── */
    background-image: url('container_background.png'); /* Paths to your container texture */
    background-repeat: repeat;                   /* Tiles the pattern inside the box */
    background-color: var(--bg-container);        /* Kept your charcoal fill color safely underneath */
    /* ────────────────────────────────── */

    padding: 40px 40px 50px;
    border-radius: 12px;
    border: 2px solid var(--border-main);
    box-shadow: var(--shadow-soft);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 14px;
    border: 1.5px solid var(--accent-blue);
    border-radius: 6px;
    margin-bottom: 28px;
    margin-left: 48px; /* clear hamburger */
    transition: background 0.2s, color 0.2s;
}

.back-btn:hover {
    background: var(--accent-blue);
    color: #fff;
}

/* ==========================================
   INDEX PAGE CARDS
   ========================================== */

.image {
    width: 250px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto 24px auto;
    border-radius: 8px;
}

.notes-card {
    list-style-type: none;
    padding: 0;
    margin: 24px auto;
    width: 100%;
    max-width: 900px; /* Optional: limits the combined row width so it stays crisp */
    
    /* Flex grid setups */
    display: flex;
    flex-wrap: wrap;
    justify-content: center; 
    gap: 24px; /* Space between rows and columns */
}

.note-item-wrapper {
    display: flex;
    gap: 0px; 
    position: relative;
    margin-bottom: 0px;
    
    /* Force exactly 2 items per row (accounting for the 24px gap) */
    flex: 1 1 calc(50% - 12px); 
    min-width: 320px; /* Prevents columns from becoming impossibly narrow */
    max-width: 440px; /* Keeps the cards perfectly proportioned */
}

.main-note-link {
    flex: 1;
    display: block;
    background-color: var(--accent-green);
    color: #111;
    font-size: 1.5rem;
    padding: 18px;
    border-radius: 8px;
    border: 3px solid #2ab870;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
}

.main-note-link:hover {
    background-color: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(91,156,246,0.3);
}

.notes-dropdown summary {
    background-color: var(--bg-header);
    border: 3px solid var(--border-main);
    border-radius: 8px;
    width: 58px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    list-style: none;
    transition: all 0.2s ease;
}

.notes-dropdown summary::-webkit-details-marker { display: none; }

.notes-dropdown summary .arrow {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-green);
    transition: transform 0.2s ease;
}

.notes-dropdown summary:hover {
    background-color: var(--bg-card);
    border-color: var(--accent-green);
}

.notes-dropdown[open] summary .arrow {
    transform: rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-card);
    padding: 16px 20px;
    border: 1.5px solid var(--border-main);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-soft);
    z-index: 10;
    margin-top: 2px;
}

.dropdown-content ul {
    padding-left: 16px;
    margin: 0;
    color: var(--text-secondary);
}

.dropdown-content li {
    margin-bottom: 8px;
}

.dropdown-content li a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.dropdown-content li a:hover {
    text-decoration: underline;
}

/* ==========================================
   NOTES CONTENT TYPOGRAPHY
   ========================================== */

.notes-content {
    margin-top: 10px;
}

.notes-content h1 {
    font-size: 2.4rem;
    color: var(--text-heading);
    text-align: center;
    border-bottom: 3px solid var(--accent-green);
    padding-bottom: 14px;
    margin-bottom: 28px;
    letter-spacing: -0.02em;
}

.notes-content h2 {
    font-size: 1.65rem;
    color: var(--text-heading);
    margin-top: 40px;
    margin-bottom: 18px;
    background: var(--h2-bg);
    border: 2px solid var(--border-accent);
    border-radius: 6px;
    text-align: center;
    padding: 10px 20px;
    letter-spacing: 0.01em;
}

.notes-content h3 {
    font-size: 1.25rem;
    color: var(--accent-green);
    margin-top: 32px;
    margin-bottom: 12px;
    text-align: center;
    text-decoration: underline;
    text-decoration-color: rgba(61,214,140,0.4);
    text-underline-offset: 4px;
}

.notes-content h4 {
    font-size: 1.5rem;
    color: var(--text-heading);
    background-color: var(--h4-bg);
    display: table;
    padding: 10px 22px;
    border: 2px solid var(--border-main);
    border-radius: 6px;
    margin: 12px auto 16px auto;
    text-align: center;
    border-left: 4px solid var(--accent-amber);
}

.notes-content p,
.notes-content .notes-p {
    font-size: 1.1rem;
    line-height: 1.85;
    color: var(--text-primary);
    margin-bottom: 18px;
}

.notes-content ul {
    padding-left: 42px;
    margin-left: 4px;
    margin-bottom: 22px;
}

.notes-content ol {
    padding-left: 42px;
    margin-bottom: 22px;
}

.notes-content li {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.notes-content strong {
    color: #f0f2f8;
    font-weight: 700;
}

.notes-content a {
    color: var(--accent-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.notes-content a:hover {
    color: var(--accent-green);
}

.notes-content u {
    text-decoration-color: var(--accent-amber);
    text-underline-offset: 3px;
}

/* ==========================================
   HIGHLIGHTED TERMS
   ========================================== */

.notes-content mark {
    background-color: rgba(240,165,0,0.22);
    color: var(--accent-amber);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    border-bottom: 1.5px solid var(--accent-amber);
}

/* ==========================================
   TOOLTIP HOVER DEFINITIONS
   ========================================== */

.tooltip-target {
    position: relative;
    cursor: help;
}

.tooltip-box {
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    width: 460px;
    background: var(--tooltip-bg);
    border: 2px solid var(--tooltip-border);
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tooltip-target:hover .tooltip-box {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.tooltip-title {
    display: block;
    color: var(--accent-green);
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-main);
    padding-bottom: 6px;
}

.tooltip-text {
    display: block;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 400;
    text-align: left;
    line-height: 1.6;
}

.notes-content .tooltip-text ul {
    margin: 8px 0 0 0;
    padding-left: 18px;
    list-style-type: disc;
    display: block;
    margin-bottom: 0;
}

.notes-content .tooltip-text li {
    font-size: 0.95rem !important;
    line-height: 1.5;
    margin-bottom: 5px;
    color: var(--text-primary) !important;
    text-align: left;
    display: list-item;
}

.notes-content .tooltip-text li:last-child {
    margin-bottom: 0;
}

/* ==========================================
   QUESTION DROPDOWNS
   ========================================== */

.question-dropdown {
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 10px;
    margin: 22px 0;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s;
}

.question-dropdown:hover {
    border-color: var(--accent-blue);
}

.question-dropdown summary {
    padding: 13px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background-color: var(--dropdown-sum);
    list-style: none;
    transition: background 0.2s;
    border-left: 4px solid var(--accent-blue);
}

.question-dropdown summary::-webkit-details-marker { display: none; }

.question-dropdown summary strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.question-dropdown .dropdown-arrow {
    font-size: 1rem;
    color: var(--accent-green);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.question-dropdown summary:hover {
    background-color: #30364a;
}

.question-dropdown[open] summary .dropdown-arrow {
    transform: rotate(180deg);
}

.question-answer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-main);
    background-color: var(--dropdown-ans);
}

.question-answer p {
    font-size: 1.1rem;
    color: var(--text-primary) !important;
    margin-bottom: 14px;
    line-height: 1.8;
}

.question-answer p:last-child { margin-bottom: 0; }
.question-answer p:first-child { margin-top: 0 !important; }

.question-answer ol,
.question-answer ul {
    padding-left: 28px;
    margin-bottom: 14px;
}

.question-answer li {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.7;
}



/* ==========================================
   IMAGES
   ========================================== */

.notes_image {
    width: 600px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px auto 24px auto;
    border-radius: 8px;
    border: 1.5px solid var(--border-main);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}

/* ==========================================
   VIDEO CONTAINERS
   ========================================== */

.video-container {
    display: block;
    position: relative;
    margin: 24px auto;
    text-align: center;
    max-width: 640px;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: #000;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    border: 3px solid var(--border-main);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    transform-origin: top left;
}

/* New Placeholder Elements */
.video-placeholder {
    position: relative;
    cursor: pointer;
    display: block;
    width: 100%;
    border: 3px solid var(--border-main);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.video-thumbnail {
    width: 100%;
    height: auto;
    display: block;
}

/* Play Button Overlay matching your theme styles */
.play-button-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4); /* Subtle dimming over the thumbnail image */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.play-button-overlay span {
    background: var(--bg-card);
    color: var(--accent-green);
    border: 2px solid var(--border-main);
    font-size: 1.6rem;
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding-left: 5px; /* Centers the triangle icon optically */
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Hover effects matching your link and dropdown aesthetic */
.video-placeholder:hover {
    border-color: var(--accent-green);
    box-shadow: var(--shadow-glow);
}

.video-placeholder:hover .play-button-overlay {
    background-color: rgba(0, 0, 0, 0.2); /* Brightens the image slightly on hover */
}

.video-placeholder:hover .play-button-overlay span {
    color: #fff;
    background: var(--accent-green);
    border-color: var(--accent-green);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(61,214,140,0.4);
}

/* ==========================================
   COPYRIGHT BANNER
   ========================================== */

.copyright-banner {
    margin-top: 50px;
    padding: 20px 24px;
    background: var(--bg-header);
    border: 1.5px solid var(--border-main);
    border-radius: 8px;
    border-top: 3px solid var(--accent-green);
    text-align: center;
}

.copyright-banner p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.6;
}

.copyright-banner p:last-child { margin-bottom: 0; }

.copyright-banner strong {
    color: var(--text-primary);
}

/* ==========================================
   SCROLL-TO-TOP BUTTON
   ========================================== */

#scroll-top-btn {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 800;
    background: var(--accent-green);
    color: #111;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(61,214,140,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.2s;
}

#scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

#scroll-top-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(61,214,140,0.5);
}

/* ==========================================
   RESPONSIVE
   ========================================== */

@media (max-width: 768px) {
    body { padding: 16px 8px; }

    .container {
        padding: 24px 16px 36px;
        border-radius: 8px;
    }

    .back-btn {
        margin-left: 54px;
        font-size: 0.82rem;
        padding: 5px 10px;
    }

    .notes-content h1 { font-size: 1.8rem; }
    .notes-content h2 { font-size: 1.35rem; padding: 8px 14px; }
    .notes-content h3 { font-size: 1.1rem; }
    .notes-content h4 { font-size: 1.2rem; }

    .notes-content p,
    .notes-content .notes-p,
    .notes-content li { font-size: 1rem; }

    /* New Mobile Tooltip Rule: Hide the floating box completely */
  .tooltip-box {
      display: none !important;
  }

    .note-item-wrapper {
        width: 90%;
    }

/* ==========================================
       MATHJAX MOBILE OPTIMIZATION
       ========================================== */

    /* Normal inline equations (Default state) */
    mjx-container:not([display="true"]) {
        display: inline-block;
        vertical-align: middle;
    }

    /* Only applied by JavaScript when the math is actually too wide */
    mjx-container.scrollable-inline-math {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Display equations (Always handled as blocks) */
    mjx-container[display="true"] {
        display: block;
        text-align: center;
        margin: 1em 0;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* H4 Tags */
    .notes-content h4 {
        overflow-x: auto;
        max-width: 100%;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 480px) {
    .notes-content h1 { font-size: 1.5rem; }
    .notes-content h2 { font-size: 1.15rem; }
}




















/* Style for the interactive word */
.tap-word {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s;
}

.tap-word:hover {
  color: var(--accent-green);
}

/* Fullscreen dark overlay */
#popup-overlay {
  position: fixed;
  inset: 0; /* This replaces top, bottom, left, right, width, and height! */
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

/* The popup box */
#custom-popup {
  background-color: var(--bg-card);
  color: var(--text-primary);
  width: 85%;
  max-width: 450px;
  box-sizing: border-box;
  padding: 30px 20px 20px 20px;
  border-radius: 12px;
  border: 2px solid var(--border-accent); /* green accent, like your h2 */
  position: relative;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  max-height: 80vh;
  overflow-y: auto;
}

/* Popup heading */
#custom-popup h2 {
  font-size: 1.25rem;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-main);
}

/* Popup body text */
#popup-text {
  font-size: 1rem;
  color: var(--text-primary);
  line-height: 1.7;
}

/* X close button — matches your .nav-close-btn pattern */
#close-popup {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 26px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

#close-popup:hover {
  color: var(--accent-green);
  background: rgba(61, 214, 140, 0.1);
}

/* Helper class */
.hidden {
  display: none !important;
}



/* ── PAGINATION SYSTEM ── */

/* Hidden by default, shown only when active */
.note-page {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.note-page.active {
    display: block;
}

/* Container for the Next/Prev buttons */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-main);
}

/* Button style matching your .back-btn aesthetic */
.page-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    color: var(--accent-green);
    border: 1.5px solid var(--accent-green);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.page-nav-btn:hover {
    background: var(--accent-green);
    color: #111;
}

/* Disable button when on first/last page */
.page-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}


/* MCQ Load Button State */
h3.mcq-load-btn {
    background-color: var(--bg-card);
    border: 2px dashed var(--accent-green);
    border-radius: 8px;
    padding: 12px 24px;
    display: block;
    max-width: 400px;
    margin: 32px auto 12px auto;
    cursor: pointer;
    text-decoration: none !important; /* Temporarily removes native h3 underline */
    box-shadow: var(--shadow-soft);
    transition: all 0.2s ease;

    /* 📱 FIX 3: Force Mobile Touch Optimization */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

h3.mcq-load-btn:hover {
    border-style: solid;
    background-color: rgba(61, 214, 140, 0.05);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* Base geometry for your master dropdown chevrons */
.video-master-arrow, .notes-master-arrow {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--accent-green);  /* Clean theme-colored lines */
    border-bottom: 2px solid var(--accent-green);
    transform: rotate(45deg);                     /* Rotates square to point downward initially */
    transition: transform 0.25s ease;             /* Smooth flip animation */
    margin-right: 4px;                            /* Perfect spacing against container edge */
}

/* Rotates the new minimalist geometric arrows cleanly when opened */
details.notes-master-dropdown[open] .notes-master-arrow,
details.video-master-dropdown[open] .video-master-arrow {
    transform: rotate(-135deg) !important;
}

/* Hides default native layout summary layout markers in Webkit/Safari browsers */
details.notes-master-dropdown summary::-webkit-details-marker,
details.video-master-dropdown summary::-webkit-details-marker {
    display: none;
}

/* ==========================================
   INTEGRATED PERIODIC TABLE (STATIC)
   ========================================== */

.periodic-table-section {
    margin: 40px 0;
    padding: 24px;
    background-color: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    width: 100%;
}

.periodic-table-container {
    width: 100%;
}

.table-scroll-wrapper {
    width: 100%;
    overflow: visible; /* Eliminates nested container-level scrollbars */
}

/* Grid definition: 
   - 19 columns: 1 (for period numbers) + 18 groups (1fr each)
   - 11 rows: 1 header row, 7 period rows, 1 spacer row, 2 f-block rows
*/
.periodic-table-grid {
    display: grid !important;
    /* The magic fix: minmax(0, 1fr) forces columns to shrink instead of overflowing */
    grid-template-columns: 30px repeat(18, minmax(0, 1fr)) !important;
    grid-template-rows: 25px repeat(7, 70px) 15px repeat(2, 70px) !important;
    gap: 4px;
    width: 100%;
    max-width: 100%;
}

/* Coordinate Header Labels */
.group-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    user-select: none;
    border-bottom: 1px solid rgba(160, 168, 188, 0.15);
    padding-bottom: 4px;
}

.period-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    user-select: none;
    border-right: 1px solid rgba(160, 168, 188, 0.15);
    padding-right: 4px;
}

.series-label {
    font-size: 0.62rem;
    white-space: nowrap;
}

/* Element Cell Stylings (Clean, Solid, and Non-interactive) */
.element-cell {
    background-color: var(--bg-container);
    border: 1px solid var(--border-main);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 4px;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Disables all mouse highlights/clicks cleanly */
    /* These two lines allow the cell to squish without breaking the layout */
    overflow: hidden; 
    min-width: 0;
}

.element-cell .elem-num {
    font-size: 0.6rem;
    color: var(--text-secondary);
    line-height: 1;
    font-weight: 600;
    align-self: center;
}

.element-cell .elem-sym {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1;
    margin: 1px 0;
}

.element-cell .elem-name {
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.element-cell .elem-mass {
    font-size: 0.55rem;
    color: var(--text-secondary);
    line-height: 1;
    opacity: 0.85;
}

/* Left Indicator Color Strips */
.element-cell.nonmetal { border-left: 3px solid var(--accent-blue); }
.element-cell.noble-gas { border-left: 3px solid #b388ff; }
.element-cell.alkali { border-left: 3px solid var(--accent-amber); }
.element-cell.alkaline-earth { border-left: 3px solid #ffe082; }
.element-cell.metalloid { border-left: 3px solid var(--accent-green); }
.element-cell.halogen { border-left: 3px solid #80deea; }
.element-cell.transition-metal { border-left: 3px solid #90caf9; }
.element-cell.post-transition { border-left: 3px solid #a5d6a7; }
.element-cell.lanthanide { border-left: 3px solid #f48fb1; }
.element-cell.actinide { border-left: 3px solid #ffab91; }

/* Clean standard non-interactive cells */
.element-cell.static-cell {
    cursor: default !important;
    pointer-events: none; /* Disables hover states and clicks completely */
    transition: none !important;
    transform: none !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 4px;
    box-sizing: border-box;
}

/* ── Mobile: scroll instead of squish ──
   Below 700px, `minmax(0, 1fr)` was cramming all 18 columns down to
   roughly 12px each while rows stayed a fixed 70px tall — unreadable
   slivers. Below this breakpoint, columns get a fixed, legible width
   instead and the wrapper scrolls horizontally — the standard pattern
   for wide reference tables on small screens. Nothing above 700px
   changes. */
@media (max-width: 700px) {
    .periodic-table-section {
        padding: 12px 8px;
    }

    .periodic-table-container::before {
        content: "Scroll to see all 18 groups →";
        display: block;
        font-size: 0.7rem;
        color: var(--text-secondary);
        text-align: right;
        margin-bottom: 6px;
    }

    .table-scroll-wrapper {
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 10px; /* keeps the scrollbar clear of the last row */
    }

    .periodic-table-grid {
        grid-template-columns: 30px repeat(18, 46px) !important;
        grid-template-rows: 22px repeat(7, 56px) 12px repeat(2, 56px) !important;
        gap: 3px;
        width: max-content !important;
        max-width: none !important;
    }
}