body.custom-test-page {
    min-height: 100dvh;
    color: var(--handrive-text);
}

.custom-test-page .ui-toolbar-wrap {
    background: var(--handrive-surface-toolbar);
}

.custom-test-content {
    width: min(1300px, 100%);
    margin: 0 auto;
    padding: 18px 12px 24px;
    overflow: visible;
    box-sizing: border-box;
    container-name: custom-test-content;
    container-type: inline-size;
}

.custom-test-panel {
    min-width: 0;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 10px;
    background: var(--shared-card-bg, var(--handrive-surface-muted));
    padding: clamp(14px, 2.4vw, 24px);
    box-sizing: border-box;
}

.custom-test-panel.custom-test-picker {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.custom-test-panel[hidden],
.custom-test-page [hidden] {
    display: none;
}

.custom-test-panel-head,
.custom-test-question-head,
.custom-test-result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.custom-test-panel h2,
.custom-test-question-head h2,
.custom-test-result-head h2 {
    margin: 0;
    color: var(--handrive-text-stronger);
    font-size: clamp(18px, 2.2vw, 23px);
    font-weight: var(--site-weight-title-strong, 700);
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.custom-test-panel-head .custom-test-muted {
    margin: 6px 0 0;
}

.custom-test-picker .custom-test-panel-head {
    gap: clamp(8px, 1.5cqi, 20px);
}

.custom-test-picker .custom-test-eyebrow {
    margin-bottom: clamp(3px, 0.45cqi, 6px);
    font-size: clamp(10px, 1cqi, 13px);
}

.custom-test-picker .custom-test-panel-head h2 {
    font-size: clamp(20px, 3.1cqi, 34px);
    line-height: 1.25;
}

.custom-test-picker .custom-test-panel-head .custom-test-muted {
    margin-top: clamp(4px, 0.7cqi, 9px);
    font-size: clamp(12px, 1.25cqi, 16px);
}

.custom-test-eyebrow {
    margin: 0 0 5px;
    color: var(--handrive-text-faint);
    font-size: 12px;
    font-weight: var(--site-weight-label, 700);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.custom-test-muted {
    margin: 0;
    color: var(--handrive-text-muted);
    font-size: 14px;
    line-height: 1.55;
}

.custom-test-page .media-handrive-picker-modal {
    width: min(680px, 100%);
}

.custom-test-page .media-handrive-picker-list-wrap {
    min-width: 0;
}

.custom-test-upload-stage {
    flex: 0 0 auto;
    width: min(760px, 100%);
    min-height: clamp(132px, 25cqi, 190px);
    margin: clamp(12px, 1.6cqi, 20px) 0 0;
    padding: clamp(8px, 1.2cqi, 16px);
}

.custom-test-upload-stage .media-upload-empty {
    gap: clamp(4px, 0.55cqi, 8px);
    font-size: clamp(13px, 1.25cqi, 17px);
}

.custom-test-upload-stage .media-upload-mark {
    width: clamp(56px, 6.2cqi, 80px);
    height: clamp(56px, 6.2cqi, 80px);
}

.custom-test-upload-stage .media-upload-mark .site-upload-icon {
    width: clamp(28px, 3.2cqi, 42px);
    height: clamp(28px, 3.2cqi, 42px);
}

.custom-test-upload-stage .media-upload-empty small {
    font-size: clamp(11px, 1cqi, 14px);
}

.custom-test-upload-name {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--handrive-text-strong);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-test-upload-status {
    min-height: 0;
    margin: 4px 0 0;
    padding: 0;
    font-size: clamp(12px, 1.05cqi, 14px);
}

.custom-test-page .media-handrive-picker-list .handrive-item {
    min-width: 0;
}

.custom-test-page .media-handrive-picker-list .handrive-tree-browser-row {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
}

.custom-test-page .media-handrive-picker-list .custom-test-folder-row:disabled,
.custom-test-page .media-handrive-picker-list .custom-test-folder-row:disabled:hover,
.custom-test-page .media-handrive-picker-list .custom-test-file-row:disabled,
.custom-test-page .media-handrive-picker-list .custom-test-file-row:disabled:hover {
    background: transparent;
    color: var(--handrive-text-faint);
    cursor: not-allowed;
    opacity: 0.5;
    translate: none;
}

.custom-test-page .media-handrive-picker-footer > .media-handrive-picker-status {
    padding: 0;
}

.custom-test-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.custom-test-selection-copy {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.custom-test-selection-copy > div {
    min-width: 0;
}

.custom-test-selection-icon {
    display: inline-flex;
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--handrive-surface-muted);
    color: var(--handrive-text-muted);
}

.custom-test-selection-icon svg {
    width: 26px;
    height: 26px;
}

.custom-test-selection-copy .custom-test-muted {
    margin-top: 4px;
}

.custom-test-mode-picker {
    display: flex;
    flex: 1 1 360px;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
}

.custom-test-mode-picker legend {
    width: 100%;
    margin-bottom: 1px;
    padding: 0;
    color: var(--handrive-text-faint);
    font-size: 12px;
    font-weight: var(--site-weight-label, 700);
}

.custom-test-mode-option {
    display: flex;
    flex: 1 1 170px;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 7px;
    padding: 8px 9px;
    background: var(--shared-card-bg, var(--handrive-surface-muted));
    color: var(--handrive-text);
    cursor: pointer;
}

.custom-test-mode-option.is-selected {
    border-color: var(--ui-btn-primary-bg, var(--handrive-accent));
    background: var(--handrive-surface-toolbar);
}

.custom-test-mode-option input {
    flex: 0 0 auto;
    margin: 3px 0 0;
    accent-color: var(--handrive-accent, var(--ui-btn-primary-bg));
}

.custom-test-mode-option > span {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.custom-test-mode-option strong {
    color: var(--handrive-text-stronger);
    font-size: 13px;
    line-height: 1.35;
}

.custom-test-mode-option small {
    color: var(--handrive-text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.custom-test-selection-actions,
.custom-test-submit-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
}

.custom-test-status {
    margin: 12px 0;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--handrive-surface-muted);
    color: var(--handrive-text-muted);
    font-size: 14px;
}

.custom-test-status.is-error {
    border-color: color-mix(in srgb, #dc2626 45%, var(--handrive-border-soft));
    color: var(--handrive-text-stronger);
}

.custom-test-questions {
    margin-top: 14px;
}

.custom-test-question-head {
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--handrive-border-soft);
}

.custom-test-progress-label {
    flex: 0 0 auto;
    color: var(--handrive-text-faint);
    font-size: 13px;
    font-weight: var(--site-weight-label, 700);
}

.custom-test-question-list {
    display: grid;
    gap: 12px;
    padding: 14px 0;
}

.custom-test-practice-feedback {
    margin: 0 0 14px;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 7px;
    padding: 10px 12px;
    background: var(--handrive-surface-muted);
    color: var(--handrive-text);
    line-height: 1.55;
}

.custom-test-practice-feedback[data-status="correct"] {
    border-color: color-mix(in srgb, var(--btn-template-primary-bg, var(--handrive-accent)) 55%, var(--handrive-border-soft));
}

.custom-test-practice-feedback[data-status="incorrect"] {
    border-color: color-mix(in srgb, var(--btn-template-danger-bg, #dc2626) 55%, var(--handrive-border-soft));
}

.custom-test-practice-feedback strong {
    display: block;
    margin-bottom: 3px;
    color: var(--handrive-text-stronger);
}

.custom-test-question {
    min-width: 0;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 8px;
    padding: 14px;
    background: var(--handrive-surface-muted);
}

.custom-test-question legend {
    max-width: 100%;
    padding: 0 6px;
    color: var(--handrive-text-faint);
    font-size: 12px;
    font-weight: var(--site-weight-label, 700);
}

.custom-test-question-prompt {
    margin: 2px 0 12px;
    color: var(--handrive-text-stronger);
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: anywhere;
    white-space: normal;
    overflow-x: auto;
}

.custom-test-question-prompt.is-plain {
    white-space: pre-wrap;
}

.custom-test-question-prompt > :first-child {
    margin-top: 0;
}

.custom-test-question-prompt > :last-child {
    margin-bottom: 0;
}

.custom-test-question-prompt pre {
    max-width: 100%;
    margin: 10px 0;
    padding: 10px 12px;
    overflow: auto;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 7px;
    background: var(--handrive-surface-toolbar);
    color: var(--handrive-text);
    font: 0.9em/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    tab-size: 4;
    white-space: pre;
}

.custom-test-question-prompt pre code {
    font: inherit;
    white-space: inherit;
}

.custom-test-question-prompt table {
    width: max-content;
    max-width: 100%;
    margin: 10px 0;
    border-collapse: collapse;
    color: var(--handrive-text);
    font-size: 0.92em;
    line-height: 1.45;
}

.custom-test-question-prompt th,
.custom-test-question-prompt td {
    border: 1px solid var(--handrive-border-soft);
    padding: 6px 9px;
    text-align: left;
    vertical-align: top;
    white-space: pre-wrap;
}

.custom-test-question-prompt th {
    background: var(--handrive-surface-toolbar);
    font-weight: var(--site-weight-label, 700);
}

.custom-test-question-prompt img {
    display: block;
    width: auto;
    max-width: 100%;
    max-height: 70vh;
    height: auto;
    margin: 10px 0;
    object-fit: contain;
    border-radius: 4px;
}

.custom-test-question-options {
    display: grid;
    gap: 7px;
}

.custom-test-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 7px;
    padding: 10px 11px;
    background: var(--shared-card-bg, var(--handrive-surface-muted));
    color: var(--handrive-text);
    cursor: pointer;
    transition: var(--ui-btn-transition, 160ms ease);
}

.custom-test-option:hover,
.custom-test-option:focus-within {
    border-color: var(--ui-btn-hover-border, var(--handrive-border-soft));
    background: var(--ui-btn-hover-bg, var(--handrive-hover-soft));
}

.custom-test-option input {
    flex: 0 0 auto;
    margin: 3px 0 0;
    accent-color: var(--handrive-accent, var(--ui-btn-primary-bg));
}

.custom-test-option > span {
    min-width: 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.custom-test-answer-input {
    display: block;
    width: 100%;
    min-height: 96px;
    resize: vertical;
    box-sizing: border-box;
    border: 1px solid var(--handrive-border-soft);
    border-radius: 7px;
    padding: 10px 12px;
    background: var(--handrive-surface-muted-strong);
    color: var(--handrive-text);
    font: inherit;
    line-height: 1.55;
}

.custom-test-answer-input:focus-visible {
    outline: 2px solid var(--handrive-accent, var(--ui-btn-primary-bg));
    outline-offset: 1px;
}

.custom-test-submit-row {
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--handrive-border-soft);
    padding-top: 14px;
}

.custom-test-submit-row .custom-test-muted {
    max-width: 720px;
    font-size: 12px;
}

.custom-test-result {
    margin-top: 14px;
}

.custom-test-result-head {
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--handrive-border-soft);
}

.custom-test-score {
    flex: 0 0 auto;
    color: var(--handrive-text-stronger);
    font-size: clamp(24px, 4vw, 36px);
    line-height: 1;
}

.custom-test-result > .custom-test-muted {
    margin-top: 11px;
}

.custom-test-result-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
    padding-left: 28px;
}

.custom-test-result-list li {
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--handrive-surface-muted);
    color: var(--handrive-text-muted);
    line-height: 1.5;
}

.custom-test-result-list li[data-status="correct"] {
    box-shadow: inset 3px 0 var(--btn-template-primary-bg, currentColor);
}

.custom-test-result-list li[data-status="incorrect"] {
    box-shadow: inset 3px 0 var(--btn-template-danger-bg, currentColor);
}

.custom-test-result-list li[data-status="pending"] {
    box-shadow: inset 3px 0 var(--handrive-text-faint);
}

.custom-test-result-list strong {
    color: var(--handrive-text-stronger);
}

@media (max-width: 640px) {
    .custom-test-content {
        padding-top: 10px;
    }

    .custom-test-panel:not(.custom-test-picker) {
        padding: 13px;
    }

    .custom-test-folder-select {
        min-height: 28px;
        margin-right: 4px;
        padding: 3px 7px;
    }

    .custom-test-selection {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .custom-test-selection-actions {
        justify-content: stretch;
    }

    .custom-test-mode-picker {
        flex-basis: auto;
    }

    .custom-test-mode-option {
        flex-basis: 100%;
    }

    .custom-test-selection-actions .ui-btn {
        flex: 1 1 0;
    }

    .custom-test-submit-row {
        align-items: stretch;
        flex-direction: column;
    }

    .custom-test-submit-row .ui-btn {
        width: 100%;
    }
}
