:root {
    /* Premium Color Palette */
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;

    /* Semantic Colors */
    --fire-bg: #fef2f2;
    --fire-text: #ef4444;
    --fire-border: #fca5a5;

    --rare-bg: #f0fdfa;
    --rare-text: #0d9488;
    --rare-border: #5eead4;

    --draw-bg: #fdf4ff;
    --draw-text: #c026d3;
    --draw-border: #f0abfc;

    --calc-bg: #eff6ff;
    --calc-text: #2563eb;
    --calc-border: #bfdbfe;

    --theo-bg: #fffbeb;
    --theo-text: #d97706;
    --theo-border: #fcd34d;

    /* Shadow & Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 80px 15px 40px 15px; /* Added 80px top padding to clear the floating back button */
}

/* =========================================
   CONTAINER & HEADER
========================================= */
.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    background: var(--bg-card);
    padding: 30px 20px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 3px solid var(--primary);
}

/* Mini Header Nav (Last 6 Subjects) */
.header {
    display: contents; /* Allows children to render while ignoring the parent container */
}

.header h1 {
    display: none !important; /* Hide the duplicate "Most IMP Questions" text */
}

/* Make the inline back button float identically to the JS injected one */
.back-btn {
    position: fixed; 
    top: 20px; 
    left: 20px; 
    z-index: 1000;
    background: white; 
    padding: 10px 20px; 
    border-radius: 30px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); 
    text-decoration: none;
    color: var(--text-main); 
    font-weight: 600; 
    font-size: 0.9rem;
    border: 1px solid #eee;
    display: inline-block;
    width: auto;
    height: auto;
    transition: all 0.2s ease;
}

/* Append " Back" so it matches the text of the first 6 subjects */
.back-btn::after {
    content: " Back";
}

.back-btn:hover {
    background: var(--primary); /* This will be Blue */
    color: white;
}

/* Emulate deep blue header for last 6 subjects which have loose h1 tags */
.container > h1:not(header h1):not(.header h1) {
    background: var(--bg-card);
    padding: 25px 20px 10px 20px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
}

.container > p.subtitle {
    background: var(--bg-card);
    padding: 0 20px 25px 20px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin: 0 0 30px 0;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border-bottom: 3px solid var(--primary);
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 10px 0;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0 0 20px 0;
}

/* Stats Container (Flex Row) */
.stats-container, .stats-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.stat-pill, .stat-badge {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* =========================================
   MODULES & TOPICS
========================================= */
.module {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    overflow: hidden;
}

.module-header, .chapter-header {
    background: var(--primary);
    color: white;
    padding: 16px 20px;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

.topic-header, .topic-title, .topic-row {
    background: #f1f5f9;
    color: #334155;
    padding: 12px 20px;
    font-size: 1.05rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
    margin: 0;
}

/* =========================================
   BOXES (Strategy, Answer, Formula)
========================================= */
.strategy-box, .mini-tip, .highlight-note {
    background: #fff8f1;
    border-left: 4px solid #f59e0b;
    padding: 15px 20px;
    margin: 15px 20px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.95rem;
    color: #78350f;
}

.strategy-title {
    display: block;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    color: #b45309;
}

.answer-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
    font-size: 0.95rem;
    color: #334155;
}

.formula-box {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 10px 0;
    font-family: monospace;
    font-size: 0.95rem;
    color: #166534;
}

/* =========================================
   QA BLOCKS (For 1MH101 style)
========================================= */
.qa-block {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.qa-block:last-child {
    border-bottom: none;
}

.question-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 8px;
}

.q-text {
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.5;
}

/* =========================================
   TABLES (For 1SP201 style)
========================================= */
table {
    width: 100%;
    border-collapse: collapse;
}

tr {
    border-bottom: 1px solid var(--border);
}

tr:last-child {
    border-bottom: none;
}

td {
    padding: 16px 20px;
    vertical-align: top;
}

td.col-q { width: 65%; }
td.col-meta, td.col-ref { width: 25%; }
td.col-link { width: 10%; text-align: right; }

/* =========================================
   TAGS & BADGES
========================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 6px 4px 0;
    border: 1px solid transparent;
}

.b-fire, .b-high { background: var(--fire-bg); color: var(--fire-text); border-color: var(--fire-border); }
.b-rare { background: var(--rare-bg); color: var(--rare-text); border-color: var(--rare-border); }
.b-draw { background: var(--draw-bg); color: var(--draw-text); border-color: var(--draw-border); }
.b-calc, .b-long { background: var(--calc-bg); color: var(--calc-text); border-color: var(--calc-border); }
.b-theo, .b-theory { background: var(--theo-bg); color: var(--theo-text); border-color: var(--theo-border); }

/* Exam Tags */
.col-meta, .col-ref {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.exam-tag, .year-pill {
    display: inline-block;
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.exam-recent, .year-recent {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
    font-weight: 600;
}

/* =========================================
   LINKS & BUTTONS
========================================= */
.pdf-btn, a.pdf-link, .btn-course, .btn-exam {
    display: inline-block;
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-bottom: 4px;
}

.pdf-btn:hover, a.pdf-link:hover, .btn-course:hover, .btn-exam:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

/* Responsive */
@media (max-width: 600px) {
    .question-row { flex-direction: column; }
    td.col-meta, td.col-ref, td.col-link { display: block; width: 100%; text-align: left; padding-top: 0; }
    td.col-q { width: 100%; border-bottom: none; }
    tr { display: block; border-bottom: 2px solid var(--border); }
}