body {
    font-family: 'Arial', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #000;
    margin: 0;
    padding: 0;
}

.page-watermark {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 10px;
    color: #000;
    font-weight: bold;
    pointer-events: none;
    user-select: none;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    border: 2px solid #000;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

header h1 {
    color: #000;
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: bold;
    text-transform: uppercase;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

#subjectInput, #gradeInput {
    padding: 8px 12px;
    border: 2px solid #000;
    font-size: 14px;
    min-width: 200px;
    font-family: 'Arial', sans-serif;
}

#subjectInput:focus, #gradeInput:focus {
    outline: 2px solid #000;
}

#pageCountSelect {
    padding: 8px 12px;
    border: 2px solid #000;
    font-size: 14px;
    min-width: 120px;
    font-family: 'Arial', sans-serif;
    background: white;
}

#pageCountSelect:focus {
    outline: 2px solid #000;
}

button {
    padding: 8px 16px;
    background: #000;
    color: white;
    border: 2px solid #000;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Arial', sans-serif;
    text-transform: uppercase;
}

button:hover {
    background: #333;
}

button:disabled {
    background: #ccc;
    border-color: #999;
    cursor: not-allowed;
}

.screen {
    background: white;
    border: 2px solid #000;
    padding: 40px;
    box-shadow: none;
    position: relative;
}

.setup-content {
    text-align: center;
}

.setup-content h2 {
    color: #000;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
}

.setup-content p {
    color: #000;
    margin-bottom: 30px;
    font-size: 16px;
}

.features {
    text-align: left;
    max-width: 500px;
    margin: 0 auto;
}

.features h3 {
    color: #000;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
}

.features ul {
    list-style: none;
}

.features li {
    padding: 8px 0;
    color: #000;
    font-size: 14px;
}

.features li:before {
    content: "• ";
    color: #000;
    font-weight: bold;
}

.test-header {
    border-bottom: 2px solid #000;
    padding-bottom: 20px;
    margin-bottom: 30px;
    text-align: center;
}

#testTitle {
    color: #000;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.exam-info {
    font-size: 14px;
    margin-bottom: 10px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    font-size: 14px;
}

.page-controls {
    display: flex;
    gap: 10px;
}

.test-content {
    min-height: 600px;
}

.question {
    margin-bottom: 40px;
    padding: 0;
    border: none;
    background: transparent;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.question-number {
    font-weight: bold;
    color: #000;
    font-size: 16px;
}

.question-marks {
    background: transparent;
    color: #000;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid #000;
    padding: 2px 8px;
}

.question-text {
    font-size: 16px;
    line-height: 1.5;
    color: #000;
    margin-bottom: 20px;
    font-weight: 500;
}

.options-container {
    margin: 15px 0;
    padding-left: 20px;
}

.options-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 15px;
    color: #000;
}

.options-container input[type="radio"] {
    margin-right: 10px;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #000;
    background: white;
    cursor: pointer;
    position: relative;
}

.options-container input[type="radio"]:checked {
    background: #000;
}

.options-container input[type="radio"]:checked::after {
    content: '✓';
    color: white;
    position: absolute;
    top: -2px;
    left: 2px;
    font-size: 12px;
    font-weight: bold;
}

.answer-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.answer-input label {
    font-weight: bold;
    color: #000;
    font-size: 14px;
}

.answer-input input[type="text"],
.answer-input textarea {
    padding: 8px 12px;
    border: 2px solid #000;
    font-size: 14px;
    font-family: 'Arial', sans-serif;
    background: transparent;
}

.answer-input input:focus,
.answer-input textarea:focus {
    outline: 2px solid #000;
}

.answer-input textarea {
    min-height: 120px;
    resize: none;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        #000 27px,
        #000 28px
    );
    background-size: 100% 28px;
    line-height: 28px;
    padding: 14px 12px 14px 12px;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    border: 2px solid #000;
    background-color: white;
    overflow: hidden;
}

.answer-input textarea:focus {
    outline: 2px solid #000;
    background-image: repeating-linear-gradient(
        transparent,
        transparent 27px,
        #000 27px,
        #000 28px
    );
}

.test-actions {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #000;
}

.results-content {
    text-align: left;
}

.results-content h2 {
    color: #000;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
}

.score-summary {
    background: #f0f0f0;
    padding: 20px;
    border: 2px solid #000;
    margin-bottom: 20px;
}

.score-summary p {
    font-size: 16px;
    margin-bottom: 10px;
    color: #000;
    font-weight: bold;
}

.score-summary span {
    font-weight: bold;
    color: #000;
}

#resultsDetails {
    margin-bottom: 20px;
}

.result-item {
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid #000;
    background: white;
}

.result-item.correct {
    background: #f0fff0;
    border-color: #006600;
}

.result-item.incorrect {
    background: #fff0f0;
    border-color: #cc0000;
}

.result-question {
    font-weight: bold;
    color: #000;
    margin-bottom: 8px;
    font-size: 14px;
}

.result-answer {
    color: #000;
    margin-bottom: 5px;
    font-size: 13px;
}

.result-correct {
    color: #006600;
    font-weight: bold;
    font-size: 13px;
}

.result-incorrect {
    color: #cc0000;
    font-weight: bold;
    font-size: 13px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 16px;
    font-family: 'Arial', sans-serif;
}

.exam-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #000;
    padding-bottom: 20px;
}

.exam-title {
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.exam-details {
    font-size: 14px;
    margin-bottom: 5px;
}

.total-marks {
    font-weight: bold;
    font-size: 16px;
    margin-top: 10px;
}

.instructions {
    background: #f9f9f9;
    border: 2px solid #000;
    padding: 15px;
    margin-bottom: 30px;
    font-size: 14px;
}

.instructions h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
}

.instructions ul {
    margin: 0;
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 5px;
}

.mark-scheme-answer {
    background: #f0f8ff;
    padding: 10px;
    border: 1px solid #000;
    margin: 10px 0;
    font-weight: bold;
}

.mark-scheme-options {
    background: #f9f9f9;
    padding: 10px;
    border: 1px solid #000;
    margin: 10px 0;
}

.marking-notes {
    background: #fff9e6;
    padding: 10px;
    border: 1px solid #000;
    margin: 10px 0;
    font-style: italic;
}

.results-actions {
    text-align: center;
    margin: 20px 0;
}

.results-actions button {
    margin: 0 10px;
    padding: 8px 16px;
    border: 2px solid #000;
    background: white;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    cursor: pointer;
}

.results-actions button:hover {
    background: #f0f0f0;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border: 2px solid #000;
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    overflow-y: auto;
}

.modal-header {
    background: #000;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-family: 'Arial', sans-serif;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 2px solid #000;
    text-align: right;
}

.modal-footer button {
    margin-left: 10px;
    padding: 8px 16px;
    border: 2px solid #000;
    background: white;
    color: #000;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer button:hover {
    background: #f0f0f0;
}

.modal-footer button:first-child {
    background: #000;
    color: white;
}

.modal-footer button:first-child:hover {
    background: #333;
}

.edit-question-item, .edit-mark-item {
    border: 1px solid #000;
    padding: 15px;
    margin-bottom: 15px;
}

.edit-question-item h4, .edit-mark-item h4 {
    margin: 0 0 10px 0;
    font-family: 'Arial', sans-serif;
}

.edit-question-item textarea, .edit-mark-item input {
    width: 100%;
    padding: 8px;
    border: 1px solid #000;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    resize: vertical;
}

.edit-question-item textarea {
    min-height: 60px;
}

.edit-mark-item .marks-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.edit-mark-item .marks-input label {
    font-weight: bold;
    min-width: 80px;
}

.drawing-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 2px solid #000;
    background: #f5f5f5;
    flex-wrap: wrap;
    gap: 15px;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn {
    padding: 8px 12px;
    border: 2px solid #000;
    background: white;
    color: #000;
    font-family: 'Arial', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #f0f0f0;
}

.tool-btn.active {
    background: #000;
    color: white;
}

.tool-group label {
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    font-weight: bold;
}

#colorPicker {
    width: 40px;
    height: 30px;
    border: 2px solid #000;
    cursor: pointer;
}

#sizePicker {
    width: 80px;
}

#sizeValue {
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    min-width: 20px;
}

.canvas-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: white;
}

#drawingCanvas {
    border: 2px solid #000;
    cursor: crosshair;
    background: white;
}

.drawing-image {
    max-width: 100%;
    height: auto;
    border: 1px solid #000;
    margin-top: 10px;
    cursor: pointer;
}

.drawing-image:hover {
    border-color: #666;
}

.ai-helper-btn {
    margin-top: 10px;
    margin-right: 10px;
    padding: 5px 10px;
    border: 1px solid #000;
    background: white;
    color: #000;
    cursor: pointer;
    font-family: 'Arial', sans-serif;
    font-size: 12px;
    transition: all 0.2s;
}

.ai-helper-btn:hover {
    background: #f0f0f0;
}

.ai-helper-display {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #000;
    background: #f9f9f9;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
}

.ai-helper-controls {
    text-align: center;
    margin: 20px 0;
}

.ai-helper-controls button {
    margin: 0 5px;
    padding: 8px 16px;
    border: 2px solid #000;
    background: white;
    color: #000;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-helper-controls button:hover {
    background: #f0f0f0;
}

.ai-helper-controls button:first-child {
    background: #000;
    color: white;
}

.ai-helper-controls button:first-child:hover {
    background: #333;
}

.ai-assistant {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    height: 450px;
    background: white;
    border: 2px solid #000;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-family: 'Arial', sans-serif;
    transition: all 0.3s ease;
}

.ai-assistant.minimized {
    height: 50px;
}

.ai-assistant-header {
    background: #000;
    color: white;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
}

.ai-assistant-icon {
    font-size: 18px;
    margin-right: 8px;
}

.ai-assistant-title {
    font-weight: bold;
    font-size: 14px;
    flex: 1;
}

.ai-assistant-minimize {
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background 0.2s;
}

.ai-assistant-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-assistant-body {
    height: calc(100% - 50px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-assistant.minimized .ai-assistant-body {
    display: none;
}

.ai-assistant-chat {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #fafafa;
}

.ai-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.ai-message.user {
    align-items: flex-end;
}

.ai-message.ai {
    align-items: flex-start;
}

.ai-message-content {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}

.ai-message.ai .ai-message-content {
    background: #000;
    color: white;
    border-bottom-left-radius: 4px;
}

.ai-message.user .ai-message-content {
    background: #e3f2fd;
    color: #000;
    border-bottom-right-radius: 4px;
    border: 1px solid #2196f3;
}

.ai-welcome-message .ai-message-content {
    background: #f0f8ff;
    color: #000;
    border: 1px solid #000;
    border-bottom-left-radius: 4px;
}

.ai-assistant-input {
    padding: 12px 15px;
    border-top: 1px solid #000;
    display: flex;
    gap: 8px;
    background: white;
}

.ai-assistant-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #000;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Arial', sans-serif;
}

.ai-assistant-input input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.ai-assistant-input button {
    padding: 8px 12px;
    background: #000;
    color: white;
    border: 1px solid #000;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    transition: background 0.2s;
}

.ai-assistant-input button:hover {
    background: #333;
}

.ai-assistant-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

@media print {
    .drawing-btn {
        display: none !important;
    }
    
    .ai-helper-btn {
        display: none !important;
    }
    
    .ai-helper-display {
        display: none !important;
    }
    
    .ai-assistant {
        display: none !important;
    }
    
    body {
        background: white;
        margin: 0;
        padding: 0;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
    
    header {
        display: none;
    }
    
    .screen {
        border: none;
        padding: 0;
        box-shadow: none;
        page-break-after: always;
    }
    
    .test-actions,
    .pagination {
        display: none !important;
    }
    
    .exam-header {
        border-bottom: 2px solid #000;
        padding-bottom: 20px;
        margin-bottom: 20px;
    }
    
    .instructions {
        border: 2px solid #000;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .question {
        page-break-inside: avoid;
        margin-bottom: 30px;
    }
    
    .answer-input input,
    .answer-input textarea,
    .options-container input {
        border: 1px solid #000;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .question-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        page-break-inside: avoid;
    }
    
    .question-number {
        font-weight: bold;
        color: #000;
        font-size: 16px;
        flex: 0 0 auto;
    }
    
    .question-marks {
        background: transparent;
        color: #000;
        padding: 2px 8px;
        font-size: 14px;
        font-weight: bold;
        border: 2px solid #000;
        flex: 0 0 auto;
        margin-left: 20px;
    }
    
    .mark-scheme-answer,
    .mark-scheme-options,
    .marking-notes {
        margin-bottom: 15px;
        page-break-inside: avoid;
    }
    
    .mark-scheme-answer strong,
    .mark-scheme-options strong,
    .marking-notes strong {
        color: #000;
        font-weight: bold;
    }
    
    .page-watermark {
        position: absolute;
        bottom: 5px;
        right: 5px;
        font-size: 10px;
        color: #000;
        font-weight: bold;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .question-number {
        font-weight: bold;
    }
    
    .question-marks {
        border: 1px solid #000;
        padding: 2px 6px;
        font-weight: bold;
    }
    
    .mark-scheme-answer,
    .mark-scheme-options,
    .marking-notes {
        border: 1px solid #000;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .page-watermark {
        position: absolute;
        bottom: 5px;
        right: 5px;
        font-size: 10px;
        color: #000;
        font-weight: bold;
        pointer-events: none;
        user-select: none;
    }
    
    @page {
        margin: 0.5in;
        size: A4;
    }
    
    @page :header {
        display: none;
    }
    
    @page :footer {
        display: none;
    }
}
