.custom-qcm-app {
    --qcm-ink: #ffffff;
    --qcm-muted: #cccccc;
    --qcm-surface: #2d2d2d;
    --qcm-soft: #202020;
    --qcm-border: #555555;
    --qcm-accent: #ffeb3b;
    --qcm-accent-dark: #e3cf00;
    --qcm-warning: #ffcc00;
    box-sizing: border-box;
    width: min(100%, 920px);
    margin: 24px auto;
    padding: clamp(18px, 4vw, 38px);
    color: var(--qcm-ink);
    background: var(--qcm-surface);
    border: 1px solid #3b3b3b;
    border-top: 5px solid var(--qcm-accent);
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.custom-qcm-app *,
.custom-qcm-app *::before,
.custom-qcm-app *::after {
    box-sizing: border-box;
}

.custom-qcm-app [hidden] {
    display: none !important;
}

.custom-qcm-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--qcm-border);
}

.custom-qcm-header h1,
.custom-qcm-intro h2,
.custom-qcm-success h2 {
    margin: 0;
    color: var(--qcm-ink);
    letter-spacing: 0;
}

.custom-qcm-header h1 {
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1;
}

.custom-qcm-kicker {
    margin: 0 0 6px;
    color: var(--qcm-accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.custom-qcm-version {
    display: block;
    margin-top: 7px;
    color: var(--qcm-muted);
    font-size: 11px;
    font-weight: 650;
}

.custom-qcm-access-code,
.custom-qcm-timer {
    min-width: 150px;
    margin-left: auto;
    padding: 10px 14px;
    background: var(--qcm-soft);
    border: 1px solid var(--qcm-border);
    border-radius: 6px;
    text-align: right;
}

.custom-qcm-timer {
    margin-left: 0;
}

.custom-qcm-access-code span,
.custom-qcm-timer span {
    display: block;
    color: var(--qcm-muted);
    font-size: 12px;
}

.custom-qcm-access-code strong,
.custom-qcm-timer strong {
    display: block;
    margin-top: 2px;
    color: var(--qcm-accent);
    font-size: 21px;
    letter-spacing: 0.05em;
}

.custom-qcm-identity {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.custom-qcm-field-wide {
    width: 100%;
}

.custom-qcm-field label {
    display: block;
    margin-bottom: 7px;
    color: var(--qcm-ink);
    font-size: 14px;
    font-weight: 700;
}

.custom-qcm-field input,
.custom-qcm-field select,
.custom-qcm-question textarea {
    display: block;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 11px 13px;
    color: #171717;
    background: #fff;
    border: 1px solid #9e9e9e;
    border-radius: 5px;
    font: inherit;
}

.custom-qcm-question textarea {
    min-height: 140px;
    resize: vertical;
}

.custom-qcm-field input:focus,
.custom-qcm-field select:focus,
.custom-qcm-question textarea:focus {
    outline: 3px solid rgba(255, 235, 59, 0.24);
    border-color: var(--qcm-accent);
}

.custom-qcm-waiting,
.custom-qcm-notice,
.custom-qcm-error {
    margin: 20px 0 0;
    padding: 12px 14px;
    border-radius: 5px;
    font-weight: 650;
}

.custom-qcm-waiting {
    color: var(--qcm-accent);
    background: #1d1d1d;
    border: 1px solid #646000;
}

.custom-qcm-waiting.is-approved {
    color: #e8ffef;
    background: #173423;
    border-color: #3e7953;
}

.custom-qcm-error {
    color: #842029;
    background: #f8d7da;
    border: 1px solid #e5a5ab;
}

.custom-qcm-intro {
    padding: clamp(18px, 4vw, 30px);
    background: var(--qcm-soft);
    border: 1px solid var(--qcm-border);
    border-radius: 6px;
}

.custom-qcm-intro h2 {
    color: var(--qcm-accent);
}

.custom-qcm-intro p {
    margin: 14px 0 0;
    color: var(--qcm-muted);
    font-size: 0.95em;
    line-height: 1.6;
}

.custom-qcm-intro strong {
    color: #fff;
}

.custom-qcm-start-wait {
    margin: 22px 0 0;
    padding: 12px 14px;
    color: var(--qcm-accent);
    background: #171717;
    border: 1px solid #646000;
    border-radius: 5px;
    font-weight: 700;
}

.custom-qcm-penalty-example {
    text-align: center;
}

@keyframes custom-qcm-penalty-blink {
    0%, 100% { background: #dc3545; color: #fff; }
    50% { background: #080808; color: #fff; }
}

.custom-qcm-penalty-demo {
    display: inline-block;
    padding: 6px 9px;
    border: 2px solid #dc3545;
    border-radius: 5px;
    animation: custom-qcm-penalty-blink 0.8s infinite;
    font-weight: 700;
}

.custom-qcm-intro .custom-qcm-cheating-warning {
    color: var(--qcm-warning);
}

.custom-qcm-intro ul {
    margin: 18px 0 24px;
    padding-left: 21px;
}

.custom-qcm-intro li + li {
    margin-top: 9px;
}

.custom-qcm-progress {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 5px 12px;
    color: #151515;
    background: var(--qcm-accent);
    border-radius: 4px;
    font-size: 14px;
    font-weight: 750;
}

.custom-qcm-question {
    min-width: 0;
    margin: 24px 0 0;
    padding: 0;
    border: 0;
}

.custom-qcm-question legend {
    width: 100%;
    margin: 0 0 14px;
    padding: 0;
    color: var(--qcm-ink);
    font-size: clamp(19px, 3vw, 26px);
    font-weight: 750;
    line-height: 1.3;
}

.custom-qcm-question-image {
    display: flex;
    width: 100%;
    min-height: 120px;
    max-height: 390px;
    align-items: center;
    justify-content: center;
    margin: 0 0 16px;
    padding: 14px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--qcm-border);
    border-radius: 6px;
}

.custom-qcm-question-image img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: contain;
}

.custom-qcm-question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.custom-qcm-penalty,
.custom-qcm-multiple {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 750;
}

.custom-qcm-penalty {
    color: #fff;
    background: #a61d2a;
}

.custom-qcm-multiple {
    color: #171717;
    background: var(--qcm-accent);
}

.custom-qcm-options {
    display: grid;
    gap: 10px;
}

.custom-qcm-option {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
    gap: 11px;
    min-height: 52px;
    margin: 0;
    padding: 13px 15px;
    color: var(--qcm-ink);
    background: #242424;
    border: 1px solid var(--qcm-border);
    border-radius: 5px;
    cursor: pointer;
}

.custom-qcm-option:hover {
    border-color: var(--qcm-accent);
    background: #353535;
}

.custom-qcm-option:has(input:checked) {
    border-color: var(--qcm-accent);
    background: #3b3922;
    box-shadow: inset 4px 0 0 var(--qcm-accent);
}

.custom-qcm-option input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    accent-color: var(--qcm-accent);
}

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

.custom-qcm-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    color: #171717 !important;
    background: var(--qcm-accent);
    border: 1px solid var(--qcm-accent);
    border-radius: 5px;
    font: inherit;
    font-weight: 750;
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
}

.custom-qcm-button:hover,
.custom-qcm-button:focus-visible {
    background: var(--qcm-accent-dark);
    border-color: var(--qcm-accent-dark);
}

.custom-qcm-button-secondary {
    color: #171717 !important;
    background: var(--qcm-accent);
}

.custom-qcm-success {
    text-align: center;
}

.custom-qcm-final-score {
    margin: 22px auto;
    color: var(--qcm-accent);
    font-size: 42px;
    font-weight: 800;
}

.custom-qcm-final-score span {
    color: var(--qcm-muted);
    font-size: 24px;
}

.custom-qcm-final-score small {
    display: block;
    margin-top: 4px;
    color: var(--qcm-muted);
    font-size: 15px;
}

.custom-qcm-save-state,
.custom-qcm-resume-link {
    margin: 10px 0 0;
    color: var(--qcm-muted);
    font-size: 13px;
}

.custom-qcm-save-state {
    display: inline-block;
    margin-left: 10px;
}

.custom-qcm-resume-link a {
    color: var(--qcm-accent);
    font-weight: 700;
}

.custom-qcm-resume-form {
    display: grid;
    grid-template-columns: minmax(180px, 320px) auto;
    align-items: end;
    gap: 12px;
    margin-top: 22px;
}

.custom-qcm-student-bar {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1px;
    margin: -8px 0 22px;
    overflow: hidden;
    background: var(--qcm-border);
    border: 1px solid var(--qcm-border);
    border-radius: 6px;
}

.custom-qcm-student-bar > span {
    min-width: 0;
    padding: 10px 13px;
    background: #242424;
}

.custom-qcm-student-bar small,
.custom-qcm-student-bar strong {
    display: block;
}

.custom-qcm-student-bar small {
    color: var(--qcm-muted);
    font-size: 11px;
}

.custom-qcm-student-bar strong {
    overflow: hidden;
    margin-top: 2px;
    color: #fff;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-qcm-fullscreen-button {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #171717;
    background: var(--qcm-accent);
    border: 1px solid var(--qcm-accent);
    border-radius: 5px;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.custom-qcm-fullscreen-button:hover,
.custom-qcm-fullscreen-button:focus-visible {
    background: #fff36a;
    outline: 3px solid rgba(255, 235, 59, 0.24);
}

.custom-qcm-app:fullscreen,
.custom-qcm-app.is-pseudo-fullscreen {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    overflow: auto;
    border: 0;
    border-radius: 0;
}

.custom-qcm-app.is-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 999999;
}

body.custom-qcm-no-scroll {
    overflow: hidden;
}

@media (max-width: 680px) {
    .custom-qcm-app {
        margin: 12px auto;
        padding: 17px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .custom-qcm-header {
        display: grid;
        grid-template-columns: 1fr 1fr 44px;
    }

    .custom-qcm-header > div:first-child {
        grid-column: 1 / -1;
    }

    .custom-qcm-access-code,
    .custom-qcm-timer {
        min-width: 0;
        margin: 0;
        text-align: left;
    }

    .custom-qcm-access-code strong,
    .custom-qcm-timer strong {
        font-size: 18px;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .custom-qcm-student-bar {
        grid-template-columns: 1fr;
    }

    .custom-qcm-student-bar strong {
        white-space: normal;
    }

    .custom-qcm-identity {
        grid-template-columns: 1fr;
        gap: 13px;
    }

    .custom-qcm-actions,
    .custom-qcm-button {
        width: 100%;
    }

    .custom-qcm-save-state {
        display: block;
        margin-left: 0;
    }

    .custom-qcm-resume-form {
        grid-template-columns: 1fr;
    }
}
