body.listening-test-mode {
    overflow: hidden;
    height: 100vh;
    background: #f4f6f8;
}

body.listening-test-mode .listening-test-wrap {
    height: 100vh;
    overflow: hidden;
    padding: 0 !important;
    max-width: none !important;
}

body.listening-test-mode .wrap-content,
body.listening-test-mode .wrap-home {
    padding: 0 !important;
    max-width: none !important;
}

.listening-test-page {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f4f6f8;
    font-family: Inter, Arial, sans-serif;
    overflow: hidden;
}

.listening-start-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}

.listening-start-overlay.is-hidden {
    display: none !important;
    pointer-events: none;
    visibility: hidden;
}

/* Bootstrap modals — outside overflow:hidden wrapper, ensure correct stacking */
body.listening-test-mode .modal-backdrop {
    z-index: 10040 !important;
}

body.listening-test-mode .modal {
    z-index: 10050 !important;
}

.listening-start-btn {
    background: #fff;
    border: none;
    border-radius: 8px;
    padding: 18px 28px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
}

.listening-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: #1f2937;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.listening-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.listening-header__logo {
    height: 28px;
}

.listening-header__timer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
}

.listening-header__timer-icon {
    font-size: 32px;
    line-height: 1;
    color: #fbbf24;
    flex-shrink: 0;
}

.listening-header__timer-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.listening-header__timer-val {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.listening-header__timer-text {
    font-size: 12px;
    opacity: 0.85;
}

.listening-header__controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.listening-audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.listening-audio-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #dbe1e8;
    flex-shrink: 0;
}

.listening-audio-bar__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.listening-audio-bar__icon {
    font-size: 22px;
    color: #2563eb;
}

.listening-audio-bar__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.25;
}

.listening-audio-bar__text strong {
    font-size: 14px;
    color: #111827;
}

.listening-audio-bar__status {
    font-size: 12px;
    color: #6b7280;
}

.listening-audio-bar__player-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

.listening-audio-bar__player-wrap audio {
    width: min(100%, 420px);
    height: 36px;
}

.listening-audio-bar__player-wrap.is-locked audio {
    pointer-events: none;
    opacity: 0.75;
}

.listening-audio-bar__player-wrap input[type="range"] {
    width: 90px;
    flex-shrink: 0;
}

.listening-audio-controls input[type="range"] {
    width: 90px;
}

.listening-header__submit {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
}

.listening-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.listening-questions-wrap {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    padding: 20px;
    padding-bottom: 8px;
}

.listening-questions-wrap::-webkit-scrollbar {
    width: 10px;
}

.listening-questions-wrap::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 5px;
}

.listening-questions-wrap::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 5px;
}

.listening-questions-wrap::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.test-panel {
    display: none;
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
}

.test-panel.is-active {
    display: block;
}

.test-panel__header {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 16px;
    padding-bottom: 8px;
}

.test-panel__title {
    margin: 0;
    font-size: 22px;
}

.test-panel__question-title {
    margin: 0 0 12px;
    font-size: 16px;
}

.test-panel__question-sm-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.test-panel__answer-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: flex-start;
}

.test-panel__answer-option {
    font-weight: 700;
    min-width: 20px;
}

.test-panel__input-answer,
.iot-lr-question.iot-question__fill-blank,
.iot-lr-question.iot-dropdown {
    display: inline-block;
    min-width: 120px;
    max-width: 220px;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
}

.test-panel__iotquestion {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.test-panel__question-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #2563eb;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.test-panel table {
    width: 100%;
    border-collapse: collapse;
}

.test-panel table td,
.test-panel table th {
    border: 1px solid #d1d5db;
    padding: 8px;
}

/* Footer zone: Prev/Next + question palette */
#listening-test-app .listening-footer-zone {
    flex-shrink: 0;
    background: #eef6fc;
    border-top: 2px solid #5ba4d9;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

#listening-test-app .listening-footer-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 10px;
    min-height: 52px;
}

#listening-test-app .listening-part-nav {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

#listening-test-app .listening-part-nav__btn {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    min-width: 72px;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

#listening-test-app .listening-part-nav__btn:not(:disabled):hover {
    border-color: #5ba4d9;
    color: #1d4ed8;
}

#listening-test-app .listening-part-nav__btn:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
}

#listening-test-app .listening-palette {
    flex: 1;
    min-width: 0;
    background: transparent;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

#listening-test-app .listening-palette::-webkit-scrollbar {
    height: 8px;
}

#listening-test-app .listening-palette::-webkit-scrollbar-track {
    background: #dbeafe;
    border-radius: 4px;
}

#listening-test-app .listening-palette::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 4px;
}

#listening-test-app .question-palette {
    min-width: max-content;
}

#listening-test-app .question-palette__list-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 2px;
    min-width: max-content;
}

#listening-test-app .question-palette__part {
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #d6e4da;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

#listening-test-app .question-palette__part.is-active {
    border-color: #37854d;
    box-shadow: 0 0 0 1px rgba(55, 133, 77, 0.15);
}

#listening-test-app .question-palette__part-header {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

#listening-test-app .question-palette__part-title {
    font-size: 14px;
    font-weight: 700;
    color: #294563;
    line-height: 1;
}

#listening-test-app .question-palette__part.is-active .question-palette__part-title {
    color: #1d6eb8;
}

#listening-test-app .question-palette__part-title span {
    margin-left: 0;
}

#listening-test-app .question-palette__items-group {
    display: none;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 3px;
}

#listening-test-app .question-palette__part.is-active .question-palette__items-group {
    display: inline-flex;
}

#listening-test-app .question-palette__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    min-width: 26px;
    border: 1px solid #eaecef;
    border-radius: 5px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    color: #282828;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

#listening-test-app .question-palette__item:hover {
    border-color: #5ba4d9;
    color: #1d4ed8;
}

#listening-test-app .question-palette__item.is-selected {
    border-color: #37854d;
    box-shadow: 0 0 0 1px #37854d;
    font-weight: 700;
}

#listening-test-app .question-palette__item.is-answered {
    background: #d6e4da;
    border-color: #b8d4c0;
    color: #37854d;
    font-weight: 600;
}

@media (max-width: 768px) {
    .listening-header {
        flex-wrap: wrap;
    }

    .listening-header__brand,
    .listening-header__controls {
        min-width: auto;
    }
}

/* Admin answer-key preview */
body.listening-answer-preview-mode {
    padding-top: 52px;
}

body.listening-answer-preview-mode .listening-test-wrap {
    height: calc(100vh - 52px);
}

.listening-admin-preview-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.listening-admin-preview-bar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    flex-wrap: wrap;
}

.listening-admin-preview-bar__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    flex-wrap: wrap;
}

.listening-admin-preview-bar__sep {
    opacity: 0.5;
}

.listening-admin-preview-bar__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.listening-preview-mode-label {
    font-size: 14px;
    font-weight: 600;
    color: #15803d;
}

.listening-correct-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
    vertical-align: middle;
    white-space: nowrap;
}

.listening-correct-badge small {
    font-weight: 500;
    opacity: 0.85;
}

.listening-frozen-answer {
    background: #f0fdf4 !important;
    border-color: #86efac !important;
    color: #14532d !important;
    cursor: default;
}

.listening-correct-choice {
    background: #f0fdf4;
    border-radius: 6px;
    outline: 2px solid #86efac;
    outline-offset: 1px;
}

.listening-correct-choice label {
    font-weight: 600;
    color: #166534;
}
