.speechace-recorder {
    max-width: 800px;
    margin: 20px auto;
    padding: 25px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.speaking-task-header {
    margin-bottom: 18px;
}

.speaking-task-header h3 {
    margin: 8px 0;
    color: #243b48;
    font-size: 22px;
    line-height: 1.3;
}

.speaking-task-header p {
    margin: 0;
    color: #3b6571;
}

.task-type-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #e8f4f6;
    color: #1962a2;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

.speaking-asset {
    margin: 18px 0;
}

.speaking-asset img {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #f8f9fa;
}

.speaking-asset audio,
.recorded-audio {
    width: 100%;
    margin: 12px 0;
}

.scenario-text,
.visible-reference-text {
    margin: 18px 0;
    padding: 16px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #f8f9fa;
    color: #243b48;
    line-height: 1.6;
}

.recorder-controls {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
    align-items: center;
}

.record-btn, .score-btn {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.record-btn {
    background: #b0542d;
    color: white;
}

.record-btn:hover {
    background: #9d4b28;
}

.record-btn.recording {
    background: #df542d;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.score-btn {
    background: #1962a2;
    color: white;
}

.score-btn:hover {
    background: #3b6571;
}

.score-btn:disabled {
    background: #688ca2;
    cursor: not-allowed;
}

.recorder-feedback {
    margin-top: 20px;
}

.recorder-message {
    color: #3b6571;
}

.recorder-error {
    color: #b0542d;
    font-weight: 600;
}

.speechace-score-report {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.score-report-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.score-report-header h4 {
    margin: 8px 0 0;
    color: #243b48;
    font-size: 20px;
}

.result-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e9ecef;
    color: #243b48;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.result-status-success {
    background: rgba(59, 101, 113, 0.14);
    color: #3b6571;
}

.result-status-partial,
.result-status-requires_upgrade,
.result-status-low_confidence {
    background: rgba(176, 84, 45, 0.12);
    color: #b0542d;
}

.result-note {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-left: 4px solid #b0542d;
    background: #fff;
    color: #3b6571;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.score-item {
    background: white;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    text-align: center;
}

.score-label {
    font-size: 14px;
    font-weight: 600;
    color: #3b6571;
    margin-bottom: 8px;
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    color: #1962a2;
    margin-bottom: 5px;
}

.score-scale {
    font-size: 12px;
    color: #688ca2;
    margin-bottom: 10px;
}

.score-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, #1cc2cc 0%, #1962a2 68%, #b0542d 100%);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.fallback-panel,
.feedback-block {
    background: white;
    padding: 18px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-top: 16px;
}

.fallback-panel h4,
.feedback-block h4 {
    margin: 0 0 10px;
    color: #3b6571;
    font-size: 16px;
}

.fallback-panel p,
.feedback-block p {
    margin: 0;
    color: #243b48;
    line-height: 1.6;
}

.feedback-block ul {
    margin: 0;
    padding-left: 20px;
    color: #243b48;
    line-height: 1.7;
}

.word-analysis {
    background: white;
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    margin-top: 20px;
}

.word-analysis h4 {
    margin-bottom: 15px;
    color: #3b6571;
    font-size: 16px;
    font-weight: 600;
}

.word-text {
    font-size: 16px;
    line-height: 1.8;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.word-correct {
    color: #3b6571 !important;
    background: rgba(59, 101, 113, 0.15) !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    margin: 0 2px !important;
    display: inline-block !important;
}

.word-incorrect {
    color: #df542d !important;
    background: rgba(223, 84, 45, 0.15) !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    margin: 0 2px !important;
    border-bottom: 2px solid #df542d !important;
    display: inline-block !important;
}

.word-missing {
    color: #b0542d !important;
    background: rgba(176, 84, 45, 0.1) !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    margin: 0 2px !important;
    text-decoration: line-through !important;
    opacity: 0.7 !important;
    display: inline-block !important;
}

.reference-text {
    display: none !important;
}

.speaking-flow-status {
    margin: 16px 0 8px;
    color: #3b6571;
    font-weight: 700;
}

.speaking-countdowns {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    color: #314b57;
}

.speaking-answer {
    margin: 18px 0;
}

.speechace-recorder .speaking-answer .answer-btn {
    padding: 10px 18px;
    border: 2px solid #1962a2 !important;
    border-radius: 8px;
    background: #fff !important;
    color: #1962a2 !important;
    font-weight: 700;
    cursor: pointer;
    opacity: 1 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.speechace-recorder .speaking-answer .answer-btn:hover,
.speechace-recorder .speaking-answer .answer-btn:focus-visible {
    background: #eef6fb !important;
    border-color: #174f7d !important;
    color: #174f7d !important;
}

.speechace-recorder .speaking-answer .answer-text {
    margin-top: 12px;
    padding: 16px;
    border: 1px solid #dfe7ee;
    border-left: 4px solid #1962a2;
    border-radius: 6px;
    background: #f8f9fa;
    color: #243b48;
}

.word-feedback-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.word-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    padding: 6px 9px;
    border-radius: 7px;
    font-weight: 650;
}

.word-chip small {
    font-size: 11px;
    opacity: .75;
}

.word-good {
    color: #176b49;
    background: #e6f6ee;
}

.word-review {
    color: #8a5a00;
    background: #fff4cf;
}

.word-poor {
    color: #a33131;
    background: #fde7e7;
}

.speaking-attempt-history {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #dfe7ee;
}

.attempt-history-heading,
.attempt-history-meta,
.attempt-history-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.attempt-history-heading h4 {
    margin: 0;
}

.attempt-history-heading span,
.attempt-history-meta span,
.attempt-history-scores,
.speaking-history-login-note {
    color: #596773;
    font-size: 13px;
}

.attempt-history-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.attempt-history-item {
    padding: 14px;
    border: 1px solid #dfe7ee;
    border-radius: 10px;
    background: #fff;
}

.attempt-history-item.is-kept {
    border-color: #c9834e;
    background: #fffaf6;
}

.attempt-history-item audio {
    width: 100%;
    margin: 10px 0;
}

.attempt-keep-btn {
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid #9b5728;
    border-radius: 7px;
    background: #fff;
    color: #9b5728;
    font-weight: 700;
    cursor: pointer;
}

.attempt-history-item.is-kept .attempt-keep-btn {
    background: #9b5728;
    color: #fff;
}

.attempt-history-message {
    margin: 0;
    padding: 9px 11px;
    border-radius: 7px;
    background: #eef6ff;
    color: #174f7d;
    font-size: 13px;
}

.attempt-history-error {
    color: #a33131;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1962a2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 640px) {
    .speechace-recorder {
        padding: 18px;
    }

    .recorder-controls,
    .score-report-header {
        flex-direction: column;
        align-items: stretch;
    }

    .record-btn,
    .score-btn {
        width: 100%;
    }

    .attempt-history-heading,
    .attempt-history-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
