:root {
    --primary: #5b7fff;
    --secondary: #99b8ff;
    --text: #333;
    --bg: #f5f7fa;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 卡片布局 */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

/* 聊天界面 */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 80vh;
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: rgb(255, 255, 255);
    border-radius: 8px;
    margin-bottom: 20px;
}

.message {
    display: flex;
    margin-bottom: 15px;
}

.message .avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: rgb(255, 255, 255);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

.message .content {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 70%;
}

.message.ai .content {
    background: #f1f1f1;
}

.message.user {
    justify-content: flex-end;
}

.message.user .content {
    background: var(--primary);
    color: rgb(0, 0, 0);
}

.input-area {
    display: flex;
    gap: 10px;
}

#user-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 16px;
}

.btn {
    padding: 15px 30px;  
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;    
    transition: all 0.2s;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: #4a6fe6;
    transform: translateY(-2px);
}

.btn.secondary {
    background: #f0f0f0;
    color: #333;
}

.btn.secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 4px;
    color: white;
    z-index: 1000;
    animation: fadeInOut 3s ease-in-out;
}

.toast.success {
    background: #81e0ff;
}

.toast.error {
    background: #b7aff9;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

header {
    text-align: center;
    padding: 30px 0;
}

footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
    color: #666;
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 30px;  
    margin: 30px 0;
}

.training-container, .exam-container {
    text-align: center;
    padding: 40px 20px;
}

.training-container h2, .exam-container h2 {
    margin-bottom: 40px;
    font-size: 28px;
    color: var(--primary);
}

.action-buttons.vertical {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 350px;
    margin: 0 auto;
}

.btn.large {
    padding: 18px 36px;
    font-size: 20px;
}

.btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn.secondary.active {
    background: #b2d2ff;
    color: #333;
}

/* 新增表单样式 */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 30px;
    background: rgb(197, 210, 251);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.form-title {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
}

/* 客户端卡片样式 */
.client-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 81, 255, 0.1);
    transition: all 0.3s;
}

.client-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.client-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.delete-form {
    margin: 0;

}

/* 导出按钮样式 */
.btn-export {
    background: #d9e6ff; /* 浅蓝色 - 导出按钮 */
    color: #333;
    border: 1px solid #b8d0ff;
}

.btn-export:hover {
    background: #c5d9ff; /* 悬停时稍微加深 */
    transform: translateY(-2px);
}

/* 调整头部布局 */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px; /* 与对话框左侧对齐 */
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}
/* 结束对话按钮样式 - 使用浅蓝色 */
#end-session-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 14px;
    background: #d9e6ff; /* 浅蓝色 - 与导出按钮一致 */
    color: #333;
    border: 1px solid #b8d0ff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0; /* 移除可能的外边距 */
}

#end-session-btn:hover {
    background: #c5d9ff; /* 悬停时稍微加深 */
    transform: translateY(-1px);
}

#end-session-btn svg {
    width: 14px;
    height: 14px;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    color: var(--primary);
    margin: 0;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.report-section {
    margin-bottom: 25px;
}

.report-section h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 16px;
}

.report-section ul {
    padding-left: 20px;
    margin: 0;
}

.report-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eeeeee;
}

/* WAI评分样式 */
.wai-scores {
    margin-top: 15px;
    padding: 12px;
    background: #f0f8ff;
    border-radius: 8px;
    border-left: 4px solid #4a6fe6;
}

.wai-scores p {
    margin: 5px 0;
}

.wai-scores strong {
    color: #2c5282;
}

.wai-scores p:last-child {
    font-size: 16px;
    font-weight: bold;
    color: #4a6fe6;
    margin-top: 8px;
}

/* 报告弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-header .close {
    font-size: 28px;
    cursor: pointer;
    color: #666;
}

.modal-header .close:hover {
    color: #333;
}

.report-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
}

.report-section h4 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
}

.report-section ul {
    padding-left: 20px;
}

.report-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: #4a6fe6;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn:hover {
    opacity: 0.9;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Mobile chat layout
   Keep one frontend and reshape only the conversation surface on small screens. */
@media (max-width: 640px) {
    html,
    body {
        height: 100%;
        overflow-x: hidden;
    }

    body {
        background: #eef2f8;
    }

    body > header {
        display: none !important;
    }

    main {
        padding: 0 !important;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    footer {
        display: none !important;
    }

    .container.chat-container {
        width: 100% !important;
        max-width: none !important;
        height: 100dvh !important;
        min-height: 0;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        background: #eef2f8;
        overflow: hidden;
    }

    .chat-header {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 8px !important;
        align-items: stretch !important;
        margin: 0 !important;
        min-height: 86px;
        padding: calc(7px + env(safe-area-inset-top)) 10px 8px !important;
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid #dfe6f4;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
        flex-shrink: 0;
    }

    .chat-header h2 {
        min-width: 0;
        margin: 0 !important;
        font-size: 17px !important;
        line-height: 1.15 !important;
        color: #172554;
        display: block !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-header h2 small {
        display: block;
        font-size: 11px !important;
        color: #64748b;
        font-weight: 500;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-top: 2px;
    }

    .session-badge {
        margin-left: 0 !important;
        font-size: 10px !important;
        padding: 2px 7px !important;
    }

    .header-buttons,
    .exam-indicators {
        width: 100%;
        min-width: 0;
        display: grid !important;
        grid-template-columns: minmax(112px, 0.86fr) minmax(0, 1.14fr);
        gap: 5px !important;
        align-items: center !important;
        justify-content: stretch;
        overflow-x: visible;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        padding-bottom: 1px;
    }

    .header-buttons::-webkit-scrollbar,
    .exam-indicators::-webkit-scrollbar {
        display: none;
    }

    .header-buttons .btn,
    .header-buttons a,
    #history-btn,
    #end-session-btn,
    #export-btn,
    #emergency-end-btn,
    .btn-back {
        flex: 0 0 auto !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        font-size: 0 !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        transform: none !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    .chat-header #end-session-btn,
    .chat-header .btn-back {
        width: auto !important;
        min-width: 0 !important;
        height: 32px !important;
        padding: 0 9px !important;
        border-radius: 12px !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        gap: 0 !important;
        letter-spacing: 0 !important;
        box-shadow: none !important;
    }

    .chat-header #end-session-btn {
        flex: none !important;
        background: #5b7fff !important;
        color: #fff !important;
        border-color: #5b7fff !important;
    }

    .chat-header #end-session-btn svg {
        display: none !important;
    }

    .chat-header .btn-back {
        flex: none !important;
        display: inline-flex !important;
        background: #f8fafc !important;
        color: #334155 !important;
        border: 1px solid #d8e0ef !important;
    }

    .chat-header .btn-back::before {
        content: "";
        width: 7px;
        height: 7px;
        margin-right: 5px;
        border-left: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        flex: 0 0 auto;
    }

    .header-buttons svg {
        width: 16px !important;
        height: 16px !important;
        margin: 0 !important;
        flex: 0 0 auto;
    }

    #counselor-badge,
    #history-btn,
    #export-btn {
        display: none !important;
    }

    #counselor-badge {
        flex: 0 0 auto !important;
        display: inline-flex !important;
        align-items: center;
        max-width: 170px;
        min-height: 30px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 5px 9px !important;
        margin-left: 0 !important;
        border-radius: 999px !important;
        background: #f8fafc;
    }

    .exam-indicators {
        grid-column: 1 / -1;
        order: 2;
        justify-content: stretch;
        overflow-x: hidden;
    }

    .exam-timer,
    .exam-turn-counter {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        justify-content: space-between;
        gap: 6px;
        padding: 6px 9px !important;
        border-radius: 999px !important;
        font-size: 12px !important;
    }

    .timer-label,
    .turn-label {
        font-size: 11px !important;
    }

    .timer-value,
    .turn-value {
        font-size: 12px !important;
    }

    .chat-box {
        flex: 1 1 auto !important;
        min-height: 0;
        margin: 0 !important;
        padding: 14px 12px 14px !important;
        border-radius: 0 !important;
        background: #eef2f8 !important;
        scroll-padding-bottom: 12px;
    }

    .message {
        gap: 7px;
        margin-bottom: 11px !important;
        align-items: flex-end;
    }

    .message .avatar {
        width: 28px !important;
        height: 28px !important;
        margin-right: 0 !important;
        font-size: 11px !important;
        box-shadow: 0 2px 8px rgba(91, 127, 255, 0.22);
    }

    .message .content {
        max-width: min(82vw, 560px) !important;
        padding: 9px 12px !important;
        border-radius: 16px !important;
        font-size: 15px !important;
        line-height: 1.55 !important;
        word-break: break-word;
        overflow-wrap: anywhere;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    }

    .message.ai .content {
        background: #fff !important;
        color: #1f2937;
        border-bottom-left-radius: 5px !important;
    }

    .message.user {
        justify-content: flex-end !important;
    }

    .message.user .avatar {
        order: 2;
        margin-left: 0;
    }

    .message.user .content {
        background: #cddcff !important;
        color: #111827 !important;
        border-bottom-right-radius: 5px !important;
    }

    .input-area {
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        z-index: 20;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 7px !important;
        align-items: end !important;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom)) !important;
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid #dfe6f4;
        box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.07);
    }

    #user-input {
        min-width: 0;
        width: 100%;
        height: 42px;
        padding: 9px 13px !important;
        border-radius: 999px !important;
        font-size: 16px !important;
        background: #f8fafc;
        border-color: #cbd5e1 !important;
    }

    #send-btn,
    .voice-btn {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0 !important;
    }

    #send-btn {
        background: #5b7fff !important;
        color: #fff !important;
    }

    #send-btn span,
    .voice-btn .voice-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .voice-icon {
        font-size: 18px;
        line-height: 1;
    }

    .voice-panel {
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 9px 12px calc(9px + env(safe-area-inset-bottom)) !important;
        border-radius: 0 !important;
        border-width: 1px 0 0 !important;
        gap: 8px !important;
    }

    .voice-wave {
        height: 30px !important;
    }

    .voice-wave span {
        width: 4px !important;
    }

    .voice-status {
        min-width: 108px !important;
        font-size: 12px !important;
    }

    .history-panel {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 72dvh !important;
        border-radius: 18px 18px 0 0 !important;
        z-index: 900 !important;
        box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.2) !important;
    }

    .history-panel-header {
        padding: 14px 16px !important;
    }

    .history-panel-body {
        padding: 8px 10px calc(14px + env(safe-area-inset-bottom)) !important;
    }

    .history-session-card {
        padding: 11px 12px !important;
        background: #f8fafc;
        margin-bottom: 8px !important;
    }

    .modal {
        align-items: stretch !important;
        justify-content: stretch !important;
        padding: 0 !important;
    }

    .modal-content,
    .modal-report {
        width: 100% !important;
        max-width: none !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .modal-report .modal-header,
    .modal-header {
        padding: 12px 14px !important;
    }

    .modal-report .modal-body,
    .modal-body {
        padding: 14px !important;
    }

    .modal-report .modal-footer,
    .modal-footer {
        flex-direction: column !important;
        gap: 8px !important;
        padding: 10px 14px calc(10px + env(safe-area-inset-bottom)) !important;
    }

    .modal-footer .btn,
    .modal-footer a {
        width: 100% !important;
        min-height: 40px;
    }

    .score-ring-wrap,
    .dialogue-row,
    .wai-grid {
        display: block !important;
    }

    .score-ring-wrap {
        padding: 14px !important;
    }

    .score-ring {
        margin: 0 auto 10px;
    }

    .wai-dim,
    .dialogue-box {
        margin-bottom: 10px;
    }

    .wai-total-strip,
    .skill-row {
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .wai-total-label,
    .skill-label {
        width: auto !important;
        min-width: 76px;
    }

    .toast {
        left: 10px !important;
        right: 10px !important;
        bottom: calc(70px + env(safe-area-inset-bottom)) !important;
        width: auto !important;
        transform: none !important;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .container.chat-container {
        height: 100dvh !important;
    }

    .header-buttons .btn,
    .header-buttons a,
    #history-btn,
    #end-session-btn,
    #export-btn,
    #emergency-end-btn,
    .btn-back {
        padding: 7px 9px !important;
        font-size: 11px !important;
    }

    .message .content {
        max-width: 84vw !important;
        font-size: 14px !important;
    }
}

@media (max-width: 640px) {
    .chat-header #counselor-badge,
    .chat-header #history-btn,
    .chat-header #export-btn {
        display: none !important;
    }
}
