* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f5f7;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    position: relative;
}

.page {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}

.page.active {
    display: flex;
}

/* ============ 欢迎页 ============ */
.welcome-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    min-height: 100vh;
}

.welcome-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.welcome-container h1 {
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 700;
}

.welcome-subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 40px;
}

.welcome-desc {
    margin-bottom: 40px;
    font-size: 15px;
    opacity: 0.85;
    line-height: 1.8;
}

.welcome-desc p {
    margin-bottom: 8px;
}

.btn-primary {
    background: #fff;
    color: #667eea;
    border: none;
    padding: 14px 40px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.welcome-tip {
    margin-top: 20px;
    font-size: 14px;
    opacity: 0.8;
}

.welcome-tip a {
    color: #fff;
    text-decoration: underline;
}

/* ============ 通用头部 ============ */
.timeline-header, .stage-header, .chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 100;
}

.timeline-header h2, .stage-header h2, .chat-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-back {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #333;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-reset {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-voice {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.btn-toggle-voice:hover {
    background: #f0f0f0;
}

.btn-toggle-voice.active {
    background: #e3f2fd;
    color: #1565c0;
}

/* ============ 时间轴页 ============ */
.timeline-intro {
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
    background: #f9f9fb;
}

.timeline-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.timeline-node {
    display: flex;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.timeline-node:hover {
    transform: translateX(5px);
}

.timeline-node-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 15px;
    min-width: 50px;
}

.timeline-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 2;
}

.timeline-line {
    width: 2px;
    flex: 1;
    background: #e0e0e0;
    margin-top: 5px;
    min-height: 20px;
}

.timeline-node:last-child .timeline-line {
    display: none;
}

.timeline-node-right {
    flex: 1;
    background: #f9f9fb;
    border-radius: 12px;
    padding: 15px;
    border-left: 4px solid;
}

.timeline-node-age {
    font-size: 12px;
    color: #999;
    margin-bottom: 4px;
}

.timeline-node-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-node-question {
    font-size: 13px;
    color: #666;
}

.timeline-footer {
    padding: 20px;
    text-align: center;
    font-size: 14px;
    color: #666;
    border-top: 1px solid #eee;
}

.timeline-footer a {
    color: #667eea;
    text-decoration: none;
}

/* ============ 阶段详情页 ============ */
.stage-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.stage-hero {
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    color: #fff;
}

.stage-hero-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.stage-hero h3 {
    font-size: 22px;
    margin-bottom: 5px;
}

.stage-hero-age {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 15px;
}

.stage-hero-question {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
}

.stage-hero-summary {
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.7;
}

.stage-section {
    margin-bottom: 25px;
}

.stage-section h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-left: 10px;
    border-left: 3px solid #667eea;
}

.stage-section ul {
    list-style: none;
    padding: 0;
}

.stage-section li {
    padding: 8px 0;
    font-size: 14px;
    color: #444;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.6;
}

.stage-section li:last-child {
    border-bottom: none;
}

.path-item {
    background: #f9f9fb;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.path-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
    color: #333;
}

.path-pros {
    font-size: 13px;
    color: #2e7d32;
    margin-bottom: 4px;
}

.path-cons {
    font-size: 13px;
    color: #c62828;
}

.stage-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #fff;
}

.stage-footer .btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

/* ============ 对话页 ============ */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f5f5f7;
}

.message {
    margin-bottom: 15px;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.assistant .message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-bubble p {
    margin-bottom: 8px;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble ul, .message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 4px;
}

.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    margin: 0 2px;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-area {
    display: flex;
    align-items: flex-end;
    padding: 10px 15px;
    background: #fff;
    border-top: 1px solid #eee;
    gap: 10px;
}

.input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 50px 10px 15px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.3s;
}

#chat-input:focus {
    border-color: #667eea;
}

.btn-voice {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s;
    /* 防止长按选中文本/弹出菜单 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-voice:hover {
    background: #f0f0f0;
}

.btn-voice.recording {
    background: #ff4444;
    animation: pulse 1s infinite;
}

.btn-voice:active {
    transform: scale(0.95);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255,68,68,0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255,68,68,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,68,68,0); }
}

.btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-send:hover {
    opacity: 0.9;
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-status {
    padding: 12px 20px;
    background: #e3f2fd;
    border-top: 1px solid #bbdefb;
    font-size: 14px;
    color: #1565c0;
}

.voice-status-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.voice-recording {
    font-weight: 600;
    white-space: nowrap;
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    flex: 1;
}

.voice-wave span {
    width: 3px;
    background: #1565c0;
    border-radius: 2px;
    animation: wave 1s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; height: 8px; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; height: 16px; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; height: 24px; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; height: 16px; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; height: 8px; }

@keyframes wave {
    0%, 100% { transform: scaleY(0.5); }
    50% { transform: scaleY(1.2); }
}

.voice-result {
    font-size: 13px;
    color: #666;
    word-break: break-all;
}

/* 语音消息播放器 */
.audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f5f5f7;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.audio-player:hover {
    background: #ebebef;
}

.audio-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    overflow: hidden;
}

.audio-progress-bar {
    height: 100%;
    background: #667eea;
    width: 0%;
    transition: width 0.1s;
}

.audio-duration {
    font-size: 12px;
    color: #999;
    flex-shrink: 0;
}

/* ============ 快捷操作 ============ */
.chat-quick-actions {
    padding: 8px 15px;
    background: #fff;
    border-top: 1px solid #eee;
}

.btn-quick {
    width: 100%;
    background: #f0f0ff;
    color: #667eea;
    border: 1px dashed #667eea;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-quick:hover {
    background: #e8e8ff;
}

/* ============ 弹窗 ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.modal-tip {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    line-height: 1.6;
}

.modal-tip-small {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
}

#resume-text {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

#resume-text:focus {
    border-color: #667eea;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #eee;
}

.btn-cancel {
    flex: 1;
    background: #f5f5f5;
    color: #666;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
}

.btn-submit {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* ============ 响应式 ============ */
@media (max-width: 480px) {
    .welcome-container h1 {
        font-size: 24px;
    }
    
    .welcome-icon {
        font-size: 60px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 14px;
    }
}
