:root {
    --blue: #004f9e;
    --bg: #f7f7f7;
    --border: #ccc;
    --text: #111;
    --muted: #666;
    --ok: #dff5df;
    --warn: #fff3cd;
    --fail: #ffdede;
}

body {
    font-family: Arial, sans-serif;
    max-width: 1200px;
    margin: 0 auto 60px;
    background: var(--bg);
    color: var(--text);
}

.header {
    width: 100%;
    box-sizing: border-box;
    background: white;
    padding: 28px 36px;
    border: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 2.2fr;
    gap: 34px;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 34px;
    min-height: 220px;
}

.logo {
    width: 100%;
    max-height: 170px;
    object-fit: contain;
    justify-self: start;
}

.train {
    width: 100%;
    max-height: 170px;
    object-fit: contain;
    align-self: start;
    justify-self: center;
    transform: translateY(-60%) scale(1.75);

    transform-origin: center top;
}

.content {
    background: white;
    border: 1px solid var(--border);
    padding: 24px;
    box-sizing: border-box;
}

.card,
.box,
.summary,
.question,
.answer {
    background: white;
    border: 1px solid var(--border);
    padding: 16px;
    margin: 18px 0;
}

.question,
.answer {
    border-left: 6px solid var(--blue);
}

.inactive {
    opacity: 0.45;
}

h1,
h2,
h3 {
    color: var(--blue);
}

a {
    color: var(--blue);
}

.mc-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
}

.mc-option input[type="checkbox"],
.mc-option input[type="radio"] {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.mc-option label {
    margin: 0;
    font-weight: normal;
}

a.menu-link {
    display: block;
    padding: 14px 16px;
    margin: 10px 0;
    background: #eee;
    text-decoration: none;
    color: #000;
    border-left: 6px solid var(--blue);
    transition: background 0.2s ease;
}

a.menu-link:hover {
    background: #e0e0e0;
}

.logout {
    border-left-color: #999 !important;
}

input,
textarea,
select,
button {
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
}

input,
select,
textarea {
    width: 100%;
    padding: 8px;
    margin: 4px 0 12px;
}

textarea {
    min-height: 85px;
}

button {
    padding: 9px 14px;
    cursor: pointer;
}

label {
    font-weight: bold;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.chapter {
    color: var(--blue);
    font-weight: bold;
    margin-bottom: 8px;
}

.meta,
.hint,
.small,
.save-status {
    color: var(--muted);
    font-size: 13px;
}

.message,
.ok {
    background: #e4ffe4;
    border: 1px solid #7ccf7c;
    padding: 10px;
    margin: 12px 0;
}

.error {
    background: #ffe4e4;
    border: 1px solid #cf7c7c;
    padding: 10px;
    margin: 12px 0;
}

.fail {
    background: var(--fail);
}

.open {
    background: var(--warn);
}

.neutral {
    background: #eee;
}

.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 13px;
    margin: 2px 0;
}

.answer-box,
.options {
    background: #f5f5f5;
    padding: 10px;
    border: 1px solid #ddd;
    min-height: 24px;
}

.solution-box,
.solution {
    background: #eef6ff;
    padding: 10px;
    border: 1px solid #bdd7ee;
}

.correct {
    background: #e1ffe1;
}

.metric {
    background: #f2f2f2;
    padding: 14px;
    border-left: 6px solid var(--blue);
}

.metric strong {
    display: block;
    font-size: 26px;
}

.question-image-wrap {
    margin: 14px 0 18px;
}

.question-image,
.preview-image {
    width: auto;
    height: auto;
    object-fit: contain;
    background: white;
    border: 1px solid var(--border);
    padding: 6px;
    max-width: 100%;
    margin: 10px 0;
}

.clickable-image {
    cursor: zoom-in;
}

.image-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0,0,0,0.88);
    justify-content: center;
    align-items: center;
    padding: 30px;
    box-sizing: border-box;
}

.image-overlay img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    background: white;
    padding: 10px;
    border-radius: 8px;
}

.save-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.submitbox {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid var(--border);
    padding: 16px;
    text-align: right;
}

.finish-btn {
    font-size: 16px;
    padding: 14px 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th,
td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #eee;
}

@media print {
    .no-print {
        display: none;
    }

    body {
        background: white;
        max-width: none;
        margin: 0;
    }

    .question {
        break-inside: avoid;
    }
}
@media (max-width: 1024px) {

    html,
    body {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    .header,
    .grid,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .header {
        width: 100%;
        min-height: auto;
        padding: 16px;
        margin-top: 0;
        margin-bottom: 16px;
    }

    .content,
    .question,
    .card,
    .box,
    .summary,
    .answer,
    .submitbox {
        width: 100%;
        max-width: 100%;
    }

    .content {
        padding: 12px;
        border-left: 0;
        border-right: 0;
    }

    .question,
    .card,
    .box,
    .summary,
    .answer {
        padding: 12px;
        margin-left: 0;
        margin-right: 0;
    }

    .train {
        width: 100%;
        max-height: 120px;
        object-fit: contain;
        transform: translateY(-120%) scale(2);
    }

    .logo {
        max-height: 110px;
    }

    .topbar {
        display: block;
    }

    .save-row {
        display: block;
    }

    .save-row button {
        width: 100%;
        margin-bottom: 8px;
    }

    .save-status {
        display: block;
        width: 100%;
    }

    .submitbox {
        position: static;
        text-align: center;
        padding: 12px;
    }

    .finish-btn {
        width: 100%;
        white-space: normal;
    }

    img,
    table,
    textarea,
    input,
    select,
    button {
        max-width: 100%;
    }

    textarea,
    input,
    select {
        width: 100%;
    }

    a.menu-link {
        padding: 12px;
    }
}