[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: #f7f9fa;
    color: #1c1d1f;
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 32px auto;
    padding: 0 16px;
}

.card {
    background: #fff;
    border: 1px solid #d1d7dc;
    border-radius: 8px;
    padding: 24px 32px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

h1 {
    margin-top: 0;
    font-size: 1.6rem;
}

h2 {
    font-size: 1.15rem;
    margin: 16px 0 8px;
}

h3 {
    font-size: 1rem;
    margin: 16px 0 8px;
}

label[for="topic-select"] {
    font-weight: 600;
}

select {
    font: inherit;
    padding: 8px;
    border: 1px solid #6a6f73;
    border-radius: 4px;
    background: #fff;
}

#topic-select {
    display: block;
    width: 100%;
    margin-top: 8px;
}

button {
    font: inherit;
    font-weight: 600;
    padding: 10px 20px;
    border: 1px solid #1c1d1f;
    border-radius: 4px;
    background: #fff;
    color: #1c1d1f;
    cursor: pointer;
}

button:hover:not(:disabled) {
    background: #f2f3f5;
}

button.primary {
    background: #a435f0;
    border-color: #a435f0;
    color: #fff;
}

button.primary:hover:not(:disabled) {
    background: #8710d8;
}

button:disabled {
    opacity: 0.4;
    cursor: default;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

#previous-button,
#exams-button {
    margin-right: auto;
}

/* Exam list */

.exam-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.exam-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 16px;
    border: 1px solid #d1d7dc;
    text-align: left;
}

.exam-card:hover:not(:disabled) {
    border-color: #a435f0;
}

.exam-title {
    font-weight: 600;
}

.exam-meta {
    color: #6a6f73;
    font-weight: normal;
    font-size: 0.9rem;
}

.error {
    color: #b32d0f;
}

.hint {
    color: #6a6f73;
    font-style: italic;
}

/* Question header */

.question-header {
    display: flex;
    justify-content: space-between;
    color: #6a6f73;
    font-size: 0.9rem;
}

.progress-bar {
    height: 6px;
    margin: 8px 0 16px;
    border-radius: 3px;
    background: #d1d7dc;
    overflow: hidden;
}

#progress-fill {
    width: 0;
    height: 100%;
    background: #a435f0;
    transition: width 0.2s;
}

/* Markdown content */

.markdown pre {
    padding: 12px;
    border: 1px solid #d1d7dc;
    border-radius: 4px;
    background: #f3f4f6;
    overflow-x: auto;
    font-size: 0.85rem;
}

code {
    font-family: Consolas, "Courier New", monospace;
}

:not(pre) > code {
    padding: 1px 4px;
    border-radius: 3px;
    background: #f3f4f6;
    font-size: 0.9em;
}

/* Single and multiple choice */

.options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.option {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    border: 1px solid #d1d7dc;
    border-radius: 4px;
    cursor: pointer;
}

.option:hover {
    background: #f7f9fa;
}

.option input {
    margin-top: 5px;
}

/* Yes / No */

.yesno {
    width: 100%;
    margin: 16px 0;
    border-collapse: collapse;
}

.yesno th,
.yesno td {
    padding: 10px 12px;
    border: 1px solid #d1d7dc;
    text-align: left;
}

.yesno th {
    background: #f7f9fa;
}

.yesno th.choice,
.yesno td.choice {
    width: 70px;
    text-align: center;
}

/* Tables in question text and explanations */

.markdown table {
    margin: 12px 0;
    border-collapse: collapse;
}

.markdown th,
.markdown td {
    padding: 8px 12px;
    border: 1px solid #d1d7dc;
    text-align: left;
    vertical-align: top;
}

.markdown th {
    background: #f7f9fa;
}

/* Matching / dropdowns */

.matching {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.matching-row {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid #d1d7dc;
    border-radius: 4px;
}

.matching-row select {
    width: 100%;
}

.correct-answer {
    grid-column: 1 / -1;
    font-weight: 600;
    color: #1e6055;
}

/* Validation */

.option.correct,
.matching-row.correct,
.feedback.correct {
    border-color: #1e6055;
    background: #e7f6ef;
}

.option.incorrect,
.matching-row.incorrect,
.feedback.incorrect {
    border-color: #b32d0f;
    background: #fcebe8;
}

/* Table cells share collapsed borders with their neighbours, so use an inset frame instead */
.yesno td.correct {
    background: #e7f6ef;
    box-shadow: inset 0 0 0 1px #1e6055;
}

.yesno td.incorrect {
    background: #fcebe8;
    box-shadow: inset 0 0 0 1px #b32d0f;
}

.feedback {
    margin: 16px 0;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: 4px;
    font-weight: 600;
}

.feedback.correct {
    color: #1e6055;
}

.feedback.incorrect {
    color: #b32d0f;
}

.feedback.neutral {
    border-color: #c4a000;
    background: #fff8e1;
}

#explanation {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid #d1d7dc;
}

/* Summary */

.score {
    font-size: 2rem;
    font-weight: 700;
    margin: 8px 0;
}
