/* 重置样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 新增样式 - 浅色版配色和排版优化 */
:root {
    --light-bg: #F5F7FA;
    --main-bg: #FFFFFF;
    --text-color: #333333;
    --secondary-text: #6B7280;
    --border-color: #E2E8F0;
    --primary-blue: #2563eb;
    --primary-blue-dark: #1e40af;
    --secondary-gray: #F1F5F9;
    --secondary-gray-dark: #cbd5e1;
    --user-message-bg: #2563eb;
    --ai-message-bg: #F0F4F8;
    --error-red: #dc2626;
    --success-green: #4ade80;
    --waveform-color: #2563eb;
}

body {
    margin: 0;
    padding: 0;
    background: var(--light-bg);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding-top: 60px;
}

/* 固定标签页布局 - 修改为居中 */
.tab-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: center; /* 添加居中 */
    background: var(--light-bg);
    border-bottom: 2px solid var(--border-color);
    padding: 8px 16px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 添加标签按钮容器 */
.tab-buttons-container {
    display: flex;
    max-width: 980px;
    width: 100%;
}

.tab-button {
    padding: 10px 16px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--secondary-text);
    font-weight: 600;
    transition: color 0.3s, border-bottom 0.3s;
    flex-shrink: 0;
}

.tab-button:hover:not(.active) {
    color: var(--primary-blue);
}

.tab-button.active {
    border-bottom: 2px solid var(--primary-blue);
    color: var(--primary-blue);
}

.tab-content {
    display: none;
    background: var(--main-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    flex: 1;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    margin-top: 8px;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

.card {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

label {
    display: block;
    margin-top: 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary-text);
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    background: var(--secondary-gray);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
}

#playback-count, #play-mixed-count, .speed-select {
    width: 70px;
}

button {
    padding: 10px 14px;
    margin: 6px 6px 6px 0;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.primary {
    background: var(--primary-blue);
    color: white;
}

.primary:hover {
    background: var(--primary-blue-dark);
}

.secondary {
    background: var(--secondary-gray);
    color: var(--text-color);
    border: 1px solid var(--secondary-gray-dark);
}

.secondary:hover {
    background: var(--secondary-gray-dark);
}

.status {
    margin-top: 16px;
    font-size: 14px;
    color: var(--secondary-text);
}

audio {
    margin-top: 16px;
    width: 100%;
}

#waveform, #assessment-waveform {
    width: 100%;
    height: 80px;
    background: var(--secondary-gray);
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid var(--border-color);
}

ul {
    margin-top: 12px;
    padding-left: 18px;
    list-style: none;
    padding-left: 0;
}

li {
    padding-left: 18px;
    position: relative;
}

li::before {
    content: "•";
    color: var(--secondary-text);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.history-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    background: var(--main-bg);
}

.history-item:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.history-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 14px;
}

.history-controls small {
    color: var(--secondary-text);
}

.toggle-btn {
    background: var(--secondary-gray);
    color: var(--text-color);
}

.play-controls {
    display: flex;
    align-items: center;
}

.play-controls span {
    margin-right: 10px;
    color: var(--secondary-text);
}

.speed-select {
    width: 80px;
}

.llm-response {
    display: block;
}

.history-day-container { 
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background: var(--main-bg);
}

.history-day-container h4 {
    margin: 0 0 10px 0;
    color: var(--primary-blue);
}

.assessment-container {
    margin-top: 20px;
    padding: 20px;
    background: var(--secondary-gray);
    border-radius: 8px;
}

.assessment-score {
    font-size: 28px;
    font-weight: bold;
    color: var(--success-green);
}

.error-list {
    margin-top: 10px;
}

.error-list li {
    color: var(--error-red);
    font-weight: bold;
}

.error-list li::before {
    color: var(--error-red);
}

.assessment-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.assessment-controls select {
    margin-left: 6px;
    width: auto;
}

.assessment-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    margin-top: 10px;
}

.assessment-buttons .left-group,
.assessment-buttons .right-group {
    display: flex;
    flex-wrap: wrap;
}

#play-assessment-rec, #play-assessment-tts, #play-mixed {
    white-space: nowrap;
}

/* 聊天窗口样式 - 类似APP的对话界面 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
    background: var(--main-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    flex: 1;
    width: 100%;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 220px);
    min-height: 200px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    position: relative;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

/* 确保聊天记录框有独立的滚动条，不会挤压下方内容 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100% - 60px);
    background: var(--main-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    flex: 1;
    width: 100%;
}

/* 优化输入区域布局，减少占用空间 */
.chat-input-area {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--main-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* 移动端聊天记录滚动条优化 */
@media (max-width: 600px) {
    .chat-messages {
        max-height: calc(100vh - 250px);
        min-height: 150px;
        padding: 16px;
        gap: 12px;
    }
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    line-height: 1.4;
    font-size: 15px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #1e40af 100%);
    color: white;
    border-bottom-right-radius: 6px;
    margin-left: 20%;
}

.ai-message {
    align-self: flex-start;
    background: white;
    color: var(--text-color);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border-color);
    margin-right: 20%;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.message-controls {
    display: flex;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: var(--secondary-text);
    opacity: 0.8;
}

.message-time {
    margin-right: 8px;
}

.chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: var(--main-bg);
    display: flex;
    flex-direction: column;
}

.input-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.playback-label {
    font-size: 12px;
    color: var(--secondary-text);
    white-space: nowrap;
    margin-right: 0;
}

#playback-speed, #playback-count {
    width: 60px;
    padding: 6px 8px;
    font-size: 12px;
}

.input-row {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 8px;
}

/* 输入框和发送按钮并排布局 */
.input-with-button {
    display: flex;
    width: 100%;
    gap: 8px;
    align-items: center;
}

#text-input {
    flex: 1;
    padding: 12px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--secondary-gray);
    color: var(--text-color);
    min-height: 44px;
}

.send-button {
    background: var(--primary-blue);
    color: white;
    border-radius: 24px;
    padding: 12px 20px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
    min-height: 44px;
    flex-shrink: 0;
}

.send-button:hover {
    background: var(--primary-blue-dark);
}

#send-text {
    background: var(--primary-blue);
    color: white;
    border-radius: 24px;
    padding: 12px 20px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
    min-height: 44px;
}

.hold-to-talk {
    background: var(--error-red);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    order: 2;
}

.hold-to-talk:active {
    background: #b91c1c;
}

#stop-playback {
    background: var(--secondary-gray);
    color: var(--text-color);
    border-radius: 24px;
    padding: 10px 16px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    order: 3;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hold-to-talk {
    background: var(--error-red);
    color: white;
    padding: 10px 16px;
    border-radius: 24px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    order: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.streaming-talk {
    background: #10b981 !important;
    color: white !important;
    padding: 10px 16px !important;
    border-radius: 24px !important;
    border: none !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    white-space: nowrap !important;
    order: 2 !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.waveform-container {
    margin-top: 8px;
    display: none;
}

.pronunciation-range-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 手机端适配 */
@media (max-width: 600px) {
    body {
        padding: 0;
    }
    
    .container {
        padding-top: 50px;
    }
    
    .tab-container {
        padding: 6px 8px;
        justify-content: flex-start; /* 移动端左对齐 */
    }
    
    .tab-buttons-container {
        max-width: 100%;
    }
    
    .tab-button {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .tab-content {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-top: 0;
    }

    .chat-container {
        height: calc(100% - 50px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    /* 移动端输入框和按钮布局优化 */
    .input-with-button {
        display: flex;
        flex-direction: row !important;
        gap: 8px;
        align-items: center;
        width: 100%;
    }
    
    .input-with-button #text-input {
        flex: 1;
        margin-bottom: 0;
        min-height: 40px;
    }
    
    .input-with-button .send-button {
        width: auto;
        min-width: 80px;
        margin-top: 0;
        height: 40px;
        flex-shrink: 0;
    }
    
    .input-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    /* 语音按钮行布局 */
    .voice-buttons-row {
        display: flex;
        gap: 4px;
        justify-content: space-between;
        margin-top: 8px;
        flex-wrap: nowrap;
        width: 100%;
    }
    
    .voice-buttons-row button {
        flex: 1;
        min-width: 0;
        font-size: 11px;
        padding: 6px 4px;
        margin: 0;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 18px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* 优化按钮文字显示 */
    .voice-buttons-row .hold-to-talk {
        font-size: 11px;
        padding: 6px 4px;
    }
    
    .voice-buttons-row .streaming-talk {
        font-size: 11px;
        padding: 6px 4px;
    }
    
    .voice-buttons-row #stop-playback {
        font-size: 11px;
        padding: 6px 4px;
    }
    
    /* 统一移动端按钮大小 */
    #stop-playback {
        background: var(--secondary-gray);
        color: var(--text-color);
        border-radius: 24px;
        padding: 10px 16px;
        border: none;
        cursor: pointer;
        white-space: nowrap;
        order: 3;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .hold-to-talk {
        background: var(--error-red);
        color: white;
        padding: 10px 16px;
        border-radius: 24px;
        border: none;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.2s;
        white-space: nowrap;
        order: 1;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .streaming-talk {
        background: #10b981 !important;
        color: white !important;
        padding: 10px 16px !important;
        border-radius: 24px !important;
        border: none !important;
        font-weight: bold !important;
        cursor: pointer !important;
        transition: background 0.2s !important;
        white-space: nowrap !important;
        order: 2 !important;
        height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* 播放控制优化 */
    .playback-controls {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        flex-wrap: wrap;
        margin-bottom: 4px;
    }
    
    .playback-controls .playback-label {
        font-size: 11px;
    }
    
    .playback-controls select {
        width: 55px;
        padding: 4px 6px;
        font-size: 11px;
    }
    
    /* 移动端聊天记录框优化 */
    .chat-messages {
        max-height: calc(100vh - 200px);
        min-height: 150px;
        padding: 12px;
        gap: 10px;
    }
    
    /* 移动端输入区域优化 */
    .chat-input-area {
        padding: 6px 8px;
    }
    
    /* 消息样式优化 */
    .message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .user-message {
        margin-left: 10%;
    }
    
    .ai-message {
        margin-right: 10%;
    }
}

/* 测试页面样式 */
.sentence-item {
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sentence-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.english-text {
    font-style: italic;
    color: var(--primary-blue);
    margin-top: 5px;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .sentence-item {
        padding: 10px;
    }
    
    #testing .input-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #testing .input-controls > div {
        margin-bottom: 10px;
    }
}

/* 流式语音识别样式 */
.streaming-talk {
    background: #10b981 !important;
    color: white !important;
    padding: 12px 20px !important;
    border-radius: 24px !important;
    border: none !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    white-space: nowrap !important;
    order: 2 !important;
}

.streaming-talk:hover {
    background: #059669 !important;
}

.streaming-talk:active {
    background: #047857 !important;
}

.streaming-result {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    font-size: 14px;
}

.streaming-partial {
    color: #0ea5e9;
    font-weight: 600;
    margin-bottom: 8px;
}

.streaming-partial span {
    color: #0369a1;
    font-style: italic;
}

.streaming-final {
    color: #059669;
    font-weight: 600;
}

.streaming-final span {
    color: #047857;
    font-weight: normal;
}