.speaking-header nav,
.speaking-page {
    max-width: 1100px;
    margin: 0 auto;
}

.speaking-page {
    padding: 1.5rem 1.25rem 4rem;
}

.speaking-back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.speaking-intro,
.speaking-review {
    padding: clamp(1.25rem, 3vw, 2.5rem);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 30px rgb(0 0 0 / 8%);
}

.speaking-runner {
    position: fixed;
    z-index: 1000;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    width: 92vw;
    max-width: 1050px;
    min-height: 80vh;
    max-height: 94vh;
    overflow-y: auto;
    padding: clamp(1.25rem, 3vw, 2.5rem);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 0 0 100vmax rgb(20 34 44 / 55%), 0 12px 48px rgb(0 0 0 / 24%);
}

.speaking-intro h1 {
    margin: 0.8rem 0 0.5rem;
}

.speaking-status {
    margin-top: 1rem;
    color: var(--accent-color);
}

.speaking-status-error {
    font-weight: 600;
}

.speaking-status-loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.speaking-status-loading::before {
    width: 0.9rem;
    height: 0.9rem;
    flex: 0 0 auto;
    border: 2px solid #dce4e9;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    content: "";
    animation: speaking-spin 0.8s linear infinite;
}

.speaking-equipment-check {
    position: fixed;
    z-index: 1001;
    inset: 50% auto auto 50%;
    box-sizing: border-box;
    width: min(92vw, 680px);
    max-height: 92vh;
    overflow-y: auto;
    padding: clamp(1.25rem, 3vw, 2rem);
    transform: translate(-50%, -50%);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 0 0 100vmax rgb(20 34 44 / 55%), 0 12px 48px rgb(0 0 0 / 24%);
}

.speaking-equipment-check[hidden] {
    display: none;
}

.speaking-mic-meter {
    height: 1rem;
    overflow: hidden;
    margin: 1rem 0;
    border-radius: 999px;
    background: #e5ebef;
}

.speaking-mic-meter > div {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: #25834a;
    transition: width 80ms linear;
}

.speaking-equipment-prompt {
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--primary-color);
    background: #f6f9fb;
    font-weight: 600;
}

.speaking-equipment-message {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: #fff4dc;
    color: #684700;
}

.speaking-equipment-message.is-active {
    background: #e8f5eb;
    color: #185d32;
}

.speaking-equipment-check audio {
    display: block;
    width: 100%;
    margin-top: 1rem;
}

.speaking-equipment-check .btn.is-recording:disabled {
    background: #c62828;
    border-color: #c62828;
    color: #fff;
    opacity: 1;
    cursor: not-allowed;
    animation: speaking-record-pulse 1s ease-in-out infinite;
}

.speaking-equipment-check .btn.speaking-record-again {
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    text-decoration: underline;
}

.speaking-equipment-check .btn.is-verified:not(:disabled) {
    background: #1b8a3f;
    border-color: #1b8a3f;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.9rem 1.6rem;
    box-shadow: 0 4px 14px rgba(27, 138, 63, 0.45);
}

@keyframes speaking-record-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.6); }
    50% { box-shadow: 0 0 0 10px rgba(198, 40, 40, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .speaking-equipment-check .btn.is-recording:disabled { animation: none; }
}

.speaking-status[hidden],
.speaking-runner[hidden],
.speaking-review[hidden],
.speaking-recording[hidden] {
    display: none;
}

.speaking-review {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 1000;
    width: min(680px, 100vw);
    max-height: 100vh;
    overflow-y: auto;
    border-radius: 14px 0 0 14px;
    box-shadow: -12px 0 40px rgb(0 0 0 / 18%);
}

.speaking-review-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.speaking-runner-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    border-bottom: 1px solid #dce4e9;
    padding-bottom: 1rem;
}

.speaking-kicker {
    color: var(--primary-color);
    font-weight: 700;
    margin: 0;
}

.speaking-timer-block {
    display: grid;
    text-align: right;
    gap: 0.25rem;
}

.speaking-timer-block strong {
    color: var(--primary-color);
    font-size: 2rem;
    font-variant-numeric: tabular-nums;
}

.speaking-stage {
    padding: 0.75rem 0;
    min-width: 0;
}

.speaking-stage > * {
    min-width: 0;
}

.speaking-question {
    font-size: 1.3rem;
    font-weight: 600;
}

.speaking-progress-pill {
    display: inline-block;
    margin: 0 0 1rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}

.speaking-stage-enter {
    animation: speaking-stage-enter 0.35s ease-out;
}

@keyframes speaking-stage-enter {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .speaking-stage-enter {
        animation: none;
    }
}

.speaking-image,
.speaking-image-pair img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    margin: 0.5rem auto;
    object-fit: cover;
    border-radius: 8px;
}

/* Part 2 is the only single image appended directly to the stage. */
.speaking-stage > .speaking-image {
    max-height: 300px;
    margin: 0.75rem auto;
}

.speaking-image-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    width: 100%;
}

.speaking-image-pair figure {
    margin: 0;
}

.speaking-image-pair img {
    width: 100%;
    height: clamp(120px, 22vw, 200px);
    object-fit: cover;
}

.speaking-image-pair figcaption {
    text-align: center;
    font-weight: 600;
}

.speaking-notepad {
    display: grid;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.speaking-part4-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: start;
    gap: clamp(1rem, 3vw, 2rem);
}

.speaking-part4-photo,
.speaking-part4-content {
    min-width: 0;
}

.speaking-part4-layout .speaking-image {
    width: 100%;
    max-height: 200px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.speaking-part4-layout--no-image {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
}

.speaking-part4-layout--no-image .speaking-part4-content {
    width: 100%;
    max-width: 720px;
}

.speaking-part4-content {
    padding: clamp(1rem, 2vw, 1.5rem);
    border: 1px solid #dce4e9;
    border-radius: 10px;
    background: #f8fafb;
}

.speaking-prompt-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding-left: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.55;
}

.speaking-notepad {
    margin-top: 1.5rem;
}

.speaking-notepad textarea {
    box-sizing: border-box;
}

.speaking-audio-status {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 1.5rem;
    margin-top: 0.5rem;
    color: #344b5a;
    font-weight: 600;
}

.speaking-audio-status.is-listening::before {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    background: var(--accent-color);
    content: "";
    animation: speaking-listening-pulse 1s ease-in-out infinite;
}

.speaking-audio-status.is-started {
    color: var(--primary-color);
}

.speaking-audio-status.is-error {
    color: var(--accent-color);
}

.speaking-audio-status[hidden] {
    display: none;
}

.speaking-recording {
    justify-content: center;
}

.speaking-actions {
    justify-content: space-between;
}

.speaking-notepad textarea {
    width: 100%;
    min-height: 130px;
    padding: 0.75rem;
    border: 1px solid #aebcc5;
    border-radius: 8px;
    font: inherit;
    resize: vertical;
}

.speaking-recording {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: #f2f7fa;
}

.speaking-wave {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.speaking-wave i {
    display: block;
    width: 4px;
    height: 7px;
    border-radius: 4px;
    background: var(--primary-color);
}

.speaking-wave.is-active i {
    animation: speaking-wave 0.65s ease-in-out infinite alternate;
}

.speaking-wave.is-active i:nth-child(2n) {
    animation-delay: 0.2s;
}

.speaking-wave.is-active i:nth-child(3n) {
    animation-delay: 0.35s;
}

.speaking-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.speaking-review-item {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #dce4e9;
    border-radius: 10px;
}

.speaking-evaluation-loading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.8rem;
    min-height: 12rem;
    color: #344b5a;
    font-weight: 600;
}

.speaking-evaluation-message {
    line-height: 1.5;
}

.speaking-evaluation-skeleton {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.speaking-skeleton-card {
    display: block;
    height: 5rem;
    border-radius: 10px;
    background: linear-gradient(100deg, #edf1f3 25%, #f8fafb 45%, #edf1f3 65%);
    background-size: 250% 100%;
    animation: speaking-skeleton-shimmer 1.4s ease-in-out infinite;
}

.speaking-evaluation-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid #dce4e9;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: speaking-spin 0.8s linear infinite;
    flex: 0 0 auto;
}

.speaking-performance-card {
    padding: 1.25rem;
    border-radius: 12px;
    background: #f2f7fa;
}

.speaking-performance-heading {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.speaking-cefr-badge,
.speaking-part-band {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font-weight: 700;
}

.speaking-score {
    font-size: 1.25rem;
    font-weight: 700;
}

.speaking-criteria-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.speaking-criterion-card,
.speaking-diagnostic,
.speaking-priority-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid #dce4e9;
    border-radius: 10px;
    background: #fff;
}

.speaking-criterion-card h4,
.speaking-diagnostic h4 {
    margin-top: 0;
}

.speaking-score-line {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.speaking-score-track {
    height: 0.65rem;
    overflow: hidden;
    margin: 0.5rem 0;
    border-radius: 999px;
    background: #e5ebef;
}

.speaking-score-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary-color);
}

.speaking-diagnostic {
    margin-top: 1rem;
}

.speaking-diagnostic-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem;
}

.speaking-transcript {
    white-space: pre-wrap;
}

.speaking-part-audio {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.speaking-part-audio audio {
    max-width: 100%;
}

.speaking-model-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.speaking-model-tabs button[aria-selected="true"] {
    background: var(--primary-color);
    color: #fff;
}

.speaking-model-tab-panel {
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--primary-color);
    background: #f6f9fb;
    white-space: pre-wrap;
}

.speaking-upgrade-table-wrap {
    overflow-x: auto;
}

.speaking-upgrade-table {
    width: 100%;
    border-collapse: collapse;
}

.speaking-upgrade-table th,
.speaking-upgrade-table td {
    padding: 0.65rem;
    border: 1px solid #dce4e9;
    text-align: left;
    vertical-align: top;
}

.speaking-priorities {
    display: grid;
    gap: 0.75rem;
    padding-left: 1.25rem;
}

@keyframes speaking-spin {
    to { transform: rotate(360deg); }
}

@keyframes speaking-skeleton-shimmer {
    to { background-position-x: -250%; }
}

.speaking-model-answer {
    padding-left: 0.75rem;
    border-left: 3px solid var(--primary-color);
}

.speaking-model-answer strong {
    color: var(--primary-color);
}

@keyframes speaking-wave {
    to { height: 22px; }
}

@keyframes speaking-listening-pulse {
    50% { opacity: 0.35; }
}

@media (max-width: 640px) {
    .speaking-runner {
        min-height: 90vh;
        max-height: 96vh;
        padding: 1rem;
    }

    .speaking-review-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .speaking-evaluation-skeleton {
        grid-template-columns: 1fr;
    }

    .speaking-runner-header {
        align-items: flex-start;
    }

    .speaking-image-pair {
        grid-template-columns: 1fr;
    }

    .speaking-image-pair img {
        height: auto;
        max-height: 200px;
    }

    .speaking-part4-layout {
        grid-template-columns: 1fr;
    }

    .speaking-actions > button {
        flex: 1 1 100%;
    }
}

/* Full mock: no practice chrome, no review drawer, just the exam and a hand-off screen. */
.speaking-full-mock .speaking-header,
.speaking-full-mock .speaking-back-link,
.speaking-full-mock .speaking-review {
    display: none !important;
}

.speaking-full-mock .speaking-intro > :not(.speaking-status):not(#speakingStart.speaking-retry) {
    display: none;
}

.speaking-full-mock .speaking-intro:not(:has(.speaking-status:not([hidden]))):not(:has(.speaking-retry)) {
    display: none;
}

.speaking-recording-indicator {
    color: #c62828;
    font-weight: 800;
    letter-spacing: 0.04em;
    animation: speaking-record-blink 1.2s ease-in-out infinite;
}

@keyframes speaking-record-blink {
    50% { opacity: 0.55; }
}

.speaking-complete {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    background: var(--bg-color, #fff);
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
}

.speaking-complete[hidden] {
    display: none;
}

.speaking-complete .speaking-evaluation-spinner {
    width: 3rem;
    height: 3rem;
    border-width: 4px;
}

@media (max-width: 768px) {
    .speaking-notepad textarea,
    .speaking-notepad input,
    .speaking-notepad #speakingNotes,
    input,
    textarea {
        font-size: max(16px, 1rem);
    }

    #speakingEquipmentRecord,
    #speakingFinishStep,
    #speakingStart,
    #speakingEquipmentProceed,
    #speakingSkipAudio,
    .speaking-actions .btn,
    .speaking-actions > button {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .speaking-recording-indicator {
        animation: none;
    }
}
