.magnet-exam-grid {
    display: grid;
    grid-template-columns:repeat(2, minmax(240px, 1fr));
    gap: 16px
}

.magnet-exam-grid label, .magnet-title-field, .magnet-question > label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-weight: 600
}

.magnet-exam-grid input:not([type=checkbox]), .magnet-exam-grid select, .magnet-title-field input, .magnet-question textarea, .magnet-question input[type=text], .magnet-question input[type=number] {
    width: 100%;
    max-width: none
}

.magnet-exam-grid .magnet-check {
    align-self: end;
    display: block
}

.magnet-exam-grid .magnet-start-message-field {
    grid-column: 1/-1
}

.magnet-question {
    background: #fff;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    padding: 18px;
    margin: 0 0 18px;
    box-shadow: 0 3px 16px rgba(20, 33, 61, .05)
}

.magnet-question header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px
}

.magnet-options {
    display: grid;
    grid-template-columns:1fr 1fr;
    gap: 10px;
    margin: 14px 0
}

.magnet-options label {
    display: flex;
    align-items: center;
    gap: 7px
}

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

.magnet-question-scores label {
    font-size: 12px
}

.magnet-question-image-field {
    background: #f7f9fc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    margin: 14px 0
}

.magnet-question-image-field label {
    display: flex;
    flex-direction: column;
    gap: 5px
}

.magnet-question-image-preview {
    display: block;
    max-width: 360px;
    max-height: 220px;
    object-fit: contain;
    border-radius: 10px;
    margin: 0 0 10px
}

.magnet-question-public-image {
    display: block;
    max-width: min(100%, 720px);
    max-height: 420px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 14px;
    margin: 18px auto;
    background: #f7f8fa
}

.magnet-builder-form {
    display: flex;
    flex-direction: column;
    gap: 18px
}

.magnet-title-field {
    margin-bottom: 16px
}

.magnet-table-wrap {
    overflow: auto
}

.magnet-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    background: #fff
}

.magnet-table-wrap th, .magnet-table-wrap td {
    padding: 12px;
    border-bottom: 1px solid #e6eaf0;
    text-align: right
}

.magnet-notice {
    background: #fff7df;
    border: 1px solid #f3d27b;
    padding: 12px 15px;
    border-radius: 10px;
    margin: 10px 0
}

.magnet-course-exams {
    background: #fff;
    border: 1px solid #e7eaf0;
    border-radius: 18px;
    padding: 20px;
    margin: 0 0 20px
}

.magnet-course-exams h3 {
    margin: 0 0 15px
}

.magnet-exam-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 15px 0;
    border-top: 1px solid #edf0f4
}

.magnet-exam-card > div {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.magnet-exam-card span, .magnet-exam-card small {
    color: #6b7280
}

.magnet-passed, .magnet-locked {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px
}

.magnet-passed {
    background: #e8f8ee !important;
    color: #168248 !important
}

.magnet-locked {
    background: #f3f4f6 !important
}

.magnet-exam-intro, .magnet-quiz, .magnet-result {
    position: relative;
    background: #fff;
    border: 1px solid #e6eaf0;
    border-radius: 22px;
    padding: 28px;
    overflow: hidden
}

.magnet-exam-intro ul {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0;
    list-style: none
}

.magnet-exam-intro li {
    background: #f4f7fb;
    border-radius: 999px;
    padding: 7px 13px
}

.magnet-progress {
    height: 8px;
    background: #edf1f5;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 25px
}

.magnet-progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #173f88, #f4a51c);
    transition: width .3s
}

.magnet-question-count {
    color: #657084;
    margin-bottom: 7px
}

.magnet-answer-list {
    display: grid;
    gap: 10px;
    margin: 22px 0
}

.magnet-answer-list label {
    cursor: pointer
}

.magnet-answer-list input {
    position: absolute;
    opacity: 0
}

.magnet-answer-list span {
    display: block;
    padding: 14px 17px;
    border: 1px solid #dce2ea;
    border-radius: 12px;
    transition: .2s
}

.magnet-answer-list input:checked + span {
    border-color: #173f88;
    background: #eef4ff;
    box-shadow: 0 0 0 2px rgba(23, 63, 136, .12)
}

.magnet-answer-list [data-unanswered] span {
    border-style: dashed;
    color: #667085
}

.magnet-timer {
    position: absolute;
    left: 25px;
    top: 48px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #eef4ff;
    color: #173f88
}

.magnet-timer b {
    font-size: 20px;
    line-height: 1
}

.magnet-timer small {
    font-size: 9px
}

.magnet-timer.is-low {
    background: #fff0f0;
    color: #d32929;
    animation: magnetPulse .7s infinite alternate
}

.magnet-result {
    text-align: center;
    min-height: 330px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px
}

.magnet-result .button {
    margin: 4px
}

.magnet-medal {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #2dcc70, #16854a);
    color: #fff;
    font-size: 50px;
    box-shadow: 0 14px 35px rgba(25, 155, 84, .25);
    animation: magnetPop .55s cubic-bezier(.2, .9, .3, 1.4)
}

.magnet-medal.failed {
    background: linear-gradient(145deg, #ff8a8a, #d33)
}

.magnet-result.is-passed h2 {
    color: #168248
}

.magnet-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none
}

.magnet-confetti i {
    position: absolute;
    width: 10px;
    height: 20px;
    background: #f4a51c;
    top: -30px;
    animation: magnetFall 2.3s ease-in infinite
}

.magnet-confetti i:nth-child(2) {
    left: 18%;
    background: #2dcc70;
    animation-delay: .2s
}

.magnet-confetti i:nth-child(3) {
    left: 35%;
    background: #ec4d8c;
    animation-delay: .6s
}

.magnet-confetti i:nth-child(4) {
    left: 58%;
    background: #2f75d8;
    animation-delay: .1s
}

.magnet-confetti i:nth-child(5) {
    left: 76%;
    background: #9b59b6;
    animation-delay: .8s
}

.magnet-confetti i:nth-child(6) {
    left: 91%;
    background: #ef4444;
    animation-delay: .4s
}

.magnet-certificate-button {
    background: #173f88 !important;
    color: #fff !important
}

.magnet-certificate-instructions {
    background: #eef5ff;
    border-radius: 10px;
    padding: 12px
}

.magnet-result #magnet-certificate-form {
    width: min(100%, 560px);
    display: grid;
    gap: 12px;
    text-align: right;
    background: #f8fafc;
    padding: 18px;
    border-radius: 15px
}

.magnet-result #magnet-certificate-form label {
    display: grid;
    gap: 5px
}

.magnet-result #magnet-certificate-form input {
    width: 100%
}

.magnet-certificate-issued {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px
}

.magnet-certificate-grid {
    display: grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 30px
}

.magnet-auto-certificate-card {
    display: grid;
    grid-template-columns:auto 1fr auto;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e4e8ef;
    border-radius: 16px;
    padding: 16px
}

.magnet-auto-certificate-card div:nth-child(2) {
    display: grid;
    gap: 5px
}

.magnet-auto-certificate-card small {
    color: #6b7280
}

.magnet-certificate-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #e7f8ed;
    color: #198a4c;
    font-size: 22px
}

.magnet-legacy-certificates {
    margin-top: 30px
}

.magnet-certificate-settings label {
    display: grid;
    gap: 6px;
    margin: 0 0 13px
}

.magnet-designer-layout {
    display: grid;
    grid-template-columns:320px minmax(500px, 1fr);
    gap: 22px;
    align-items: start
}

.magnet-designer-sidebar {
    background: #fff;
    border: 1px solid #dfe3e8;
    border-radius: 14px;
    padding: 18px
}

.magnet-media-row {
    display: flex;
    gap: 6px
}

.magnet-media-row input {
    min-width: 0
}

.magnet-field-controls {
    border-top: 1px solid #e5e7eb;
    margin-top: 16px;
    padding-top: 16px
}

.magnet-field-controls label {
    font-size: 12px
}

.magnet-certificate-canvas {
    position: relative;
    overflow: hidden;
    width: 100%;
    min-height: 520px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border: 1px solid #cbd5e1;
    box-shadow: 0 12px 35px rgba(15, 23, 42, .12)
}

.magnet-template-image {
    display: block;
    width: 100%;
    height: auto;
    min-height: 520px;
    object-fit: contain
}

.magnet-design-field {
    position: absolute;
    z-index: 2;
    cursor: move;
    min-height: 26px;
    padding: 5px;
    border: 1px dashed transparent;
    box-sizing: border-box;
    line-height: 1.4;
    user-select: none
}

.magnet-design-field:hover, .magnet-design-field.is-selected {
    border-color: #2563eb;
    background: rgba(219, 234, 254, .28)
}

.magnet-design-field img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: auto
}

.magnet-design-field.field-photo {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, .75);
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 13px
}

.magnet-settings-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px
}

.magnet-settings-actions .submit {
    margin: 0;
    padding: 0
}

@keyframes magnetFall {
    to {
        transform: translateY(420px) rotate(560deg)
    }
}

@keyframes magnetPop {
    from {
        transform: scale(.2);
        opacity: 0
    }
    to {
        transform: scale(1);
        opacity: 1
    }
}

@keyframes magnetPulse {
    to {
        transform: scale(1.08)
    }
}

@media (max-width: 900px) {
    .magnet-designer-layout {
        grid-template-columns:1fr
    }

    .magnet-certificate-canvas {
        min-height: 350px
    }

    .magnet-template-image {
        min-height: 350px
    }
}

@media (max-width: 700px) {
    .magnet-exam-grid, .magnet-options, .magnet-question-scores, .magnet-certificate-grid {
        grid-template-columns:1fr
    }

    .magnet-exam-card {
        align-items: flex-start;
        flex-direction: column
    }

    .magnet-timer {
        position: static;
        margin: 0 0 15px
    }

    .magnet-exam-intro, .magnet-quiz, .magnet-result {
        padding: 18px
    }

    .magnet-auto-certificate-card {
        grid-template-columns:auto 1fr
    }

    .magnet-auto-certificate-card .button {
        grid-column: 1/-1
    }
}

/* WordPress exam editor */
body.post-type-magnet_exam #poststuff {
    max-width: 1440px
}

body.post-type-magnet_exam #poststuff .postbox {
    border: 1px solid #dbe3ec;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 5px 22px rgba(15, 23, 42, .06)
}

body.post-type-magnet_exam #poststuff .postbox-header {
    min-height: 52px;
    padding: 0 8px;
    background: #f8fafc;
    border-bottom-color: #e2e8f0
}

body.post-type-magnet_exam #poststuff .postbox-header h2 {
    color: #173f88;
    font-size: 15px;
    font-weight: 700
}

body.post-type-magnet_exam #poststuff .inside {
    margin: 0;
    padding: 20px
}

body.post-type-magnet_exam #titlewrap #title,
body.post-type-magnet_exam .magnet-exam-grid input:not([type=checkbox]),
body.post-type-magnet_exam .magnet-exam-grid select,
body.post-type-magnet_exam .magnet-question textarea,
body.post-type-magnet_exam .magnet-question input[type=text],
body.post-type-magnet_exam .magnet-question input[type=number],
body.post-type-magnet_exam .magnet-question input[type=file] {
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #172033;
    box-shadow: none
}

body.post-type-magnet_exam .magnet-question textarea {
    min-height: 86px
}

body.post-type-magnet_exam #titlewrap #title:focus,
body.post-type-magnet_exam .magnet-exam-grid input:focus,
body.post-type-magnet_exam .magnet-exam-grid select:focus,
body.post-type-magnet_exam .magnet-question textarea:focus,
body.post-type-magnet_exam .magnet-question input:focus {
    border-color: #173f88;
    box-shadow: 0 0 0 3px rgba(23, 63, 136, .12);
    outline: 0
}

body.post-type-magnet_exam .magnet-exam-grid label,
body.post-type-magnet_exam .magnet-question > label {
    color: #263247
}

body.post-type-magnet_exam .magnet-exam-grid .magnet-check {
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #dbe3ec;
    border-radius: 9px;
    background: #f8fafc
}

body.post-type-magnet_exam .magnet-question {
    border-color: #dbe3ec;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .05)
}

body.post-type-magnet_exam .magnet-question header strong {
    color: #173f88;
    font-size: 15px
}

body.post-type-magnet_exam .magnet-options label {
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #f8fafc
}

body.post-type-magnet_exam #magnet-add-question {
    min-height: 40px;
    padding: 6px 18px;
    border-radius: 999px
}

body.post-type-magnet_exam .description {
    color: #64748b;
    line-height: 1.8
}

@media (max-width: 782px) {
    body.post-type-magnet_exam #poststuff .inside {
        padding: 14px
    }
}
