/* Shared Worksheet Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    max-width: 210mm;
    margin: 0 auto;
    padding: 15mm;
    background: white;
    color: #333;
}

.header {
    text-align: center;
    border-bottom: 3px solid;
    padding: 40px 10px 10px 10px;
    margin-bottom: 20px;
    position: relative;
}

.header::before {
    font-size: 32px;
    position: absolute;
    top: 10px;
    left: 10px;
}

.spec-ref {
    position: absolute;
    top: 15px;
    right: 10px;
    font-size: 9pt;
    text-align: right;
    font-style: italic;
    line-height: 1.3;
}

h1 {
    margin: 0;
    font-size: 24pt;
}

.subtitle {
    font-style: italic;
    margin-top: 5px;
}

h2 {
    padding: 8px 12px;
    border-left: 4px solid;
    font-size: 14pt;
    margin-top: 25px;
}

.question {
    margin: 15px 0;
    page-break-inside: avoid;
}

.question-number {
    font-weight: bold;
    margin-bottom: 8px;
}

.answer-space {
    border: 2px solid;
    min-height: 30px;
    margin-top: 8px;
    padding: 10px;
}

.answer-space.large {
    min-height: 60px;
}

.small-answer {
    border-bottom: 1px solid #333;
    display: inline-block;
    min-width: 150px;
    margin: 0 5px;
}

.definition-box {
    border-left: 4px solid;
    padding: 12px;
    margin: 15px 0;
    font-size: 10pt;
}

.definition-box strong {
    font-weight: bold;
}

.marks {
    font-weight: bold;
    float: right;
}

.venn-space,
.diagram-box,
.grid-space {
    border: 2px dashed;
    min-height: 140px;
    margin-top: 8px;
    padding: 10px;
}

.grid-space {
    background: 
        repeating-linear-gradient(0deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 20px),
        repeating-linear-gradient(90deg, currentColor 0px, currentColor 1px, transparent 1px, transparent 20px);
    background-size: 20px 20px;
}

.instruction {
    font-style: italic;
    font-size: 10pt;
    margin-top: 5px;
}

.info-box {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 11pt;
}

.info-item {
    border-bottom: 1px solid;
    padding-bottom: 2px;
}

.notation {
    font-family: 'Times New Roman', serif;
    font-size: 12pt;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border: 2px solid;
}

th, td {
    border: 1px solid;
    padding: 10px;
    text-align: left;
}

th {
    font-weight: bold;
}

.mark-scheme {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 3px dashed;
}

.total-marks {
    text-align: right;
    margin-top: 30px;
    font-weight: bold;
}

@media print {
    body {
        padding: 10mm;
        margin: 0;
    }
    
    /* Prevent breaks inside these elements */
    .question {
        page-break-inside: avoid;
    }
    
    .definition-box {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    table {
        page-break-inside: avoid;
    }
    
    /* Keep section headers with following content */
    h2 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    /* Keep question numbers with their content */
    .question-number {
        page-break-after: avoid;
    }
    
    /* Prefer breaks before sections */
    h2.maths-section,
    h2.biology-section,
    h2.chemistry-section,
    h2.physics-section {
        page-break-before: auto;
    }
    
    /* Mark scheme on new page */
    .mark-scheme {
        page-break-before: always;
    }
    
    /* Avoid orphans and widows */
    p {
        orphans: 3;
        widows: 3;
    }
}
