* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.page {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: none; /* 默认隐藏所有页面 */
}

.page.active {
    display: flex; /* 显示激活的页面 */
}

/* 登录页面 */
#loginPage {
    background: linear-gradient(135deg, #1a237e, #4a148c);
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.login-container h1 {
    color: #1a237e;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #666;
    margin-bottom: 2rem;
}

/* 主场景 */
#mainPage {
    display: flex;
    flex-direction: column;
    background: url('assets/tree-background.jpeg') no-repeat center center;
    background-size: cover;
}

/* 对话框 */
.chat-container {
    position: absolute;
    right: 2rem;
    top: 2rem;
    width: 360px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.messages {
    height: 400px;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 1rem;
}

.message {
    margin-bottom: 1rem;
    padding: 0.8rem;
    border-radius: 0.8rem;
    max-width: 80%;
    word-break: break-word;
}

.user-message {
    background: #e3f2fd;
    margin-left: auto;
}

.ai-message {
    background: #f3e5f5;
    margin-right: auto;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.buttons {
    display: flex;
    gap: 0.5rem;
}

/* 心愿框 */
.wish-container {
    position: fixed;
    right: 2rem;
    bottom: 2rem;
    width: 360px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.2rem;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.wish-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.wish-textarea {
    width: 100%;
    height: 120px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.8rem;
    resize: none;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.wish-textarea:focus {
    outline: none;
    border-color: #4a148c;
    box-shadow: 0 0 0 2px rgba(74, 20, 140, 0.1);
}

.reminder-type {
    display: flex;
    gap: 1rem;
}

.reminder-type .type-btn {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.8rem;
    background: none;
    color: #666;
    transition: all 0.3s ease;
}

.reminder-type .type-btn.active {
    background: #4a148c;
    color: white;
    border-color: #4a148c;
}

.reminder-settings {
    display: flex;
    gap: 1rem;
}

.date-input,
.time-input,
.select-input {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.8rem;
    font-size: 1rem;
    background: white;
    flex: 1;
    color: #333;
}

.select-input {
    cursor: pointer;
}

.select-input option {
    color: #333;
    background: white;
}

.wish-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 0.8rem;
    background: #4a148c;
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wish-btn:hover {
    background: #6a1b9a;
    transform: translateY(-2px);
}

/* 输入框通用样式 */
input {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    font-size: 1rem;
    width: 100%;
}

input:focus {
    outline: none;
    border-color: #1a237e;
}

/* 按钮样式 */
button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

.primary-btn {
    background: #1a237e;
    color: white;
}

.bottle-btn {
    background: #0277bd;
    color: white;
}

.wish-btn {
    background: #4a148c;
    color: white;
}

/* 漂流瓶样式和动画 */
.bottle {
    position: absolute;
    width: 40px;
    height: 60px;
    background: url('assets/bottle.png') no-repeat center center;
    background-size: contain;
    z-index: 10;
    transition: transform 0.3s ease;
    transform-origin: center bottom;
}

@keyframes float {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    40% {
        /* 随机抛物线高度 */
        transform: translate(var(--throw-x), var(--throw-y)) rotate(var(--rotate-mid)) scale(0.95);
        opacity: 0.95;
    }
    70% {
        /* 落水 */
        transform: translate(var(--land-x), var(--land-y)) rotate(var(--rotate-end)) scale(0.9);
        opacity: 0.8;
    }
    100% {
        /* 沉入水中 */
        transform: translate(var(--sink-x), var(--sink-y)) rotate(var(--rotate-final)) scale(0.7);
        opacity: 0;
    }
}

.floating {
    animation: float 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* 确保漂流瓶容器样式正确 */
.bottle-container {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 360px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    z-index: 100;
}

.hidden {
    display: none !important;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .chat-container,
    .wish-container {
        width: calc(100% - 2rem);
        right: 1rem;
    }
    
    .chat-container {
        top: 1rem;
        height: calc(70vh - 2rem);
    }
    
    .messages {
        height: calc(100% - 100px);
    }
    
    .wish-container {
        bottom: 1rem;
    }
}

/* 修改功能按钮区位置 */
.function-buttons {
    position: absolute;
    left: 50%;
    top: 100px;
    transform: translate(-50%, 0);
    display: flex;
    gap: 2rem;
}

/* 统一功能按钮样式 */
.function-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 1rem;
    padding: 1.5rem;
    width: 160px;
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.function-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    background: #4a148c;
}

.function-btn:hover .btn-title,
.function-btn:hover .btn-desc {
    color: white;
}

.btn-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
}

.btn-desc {
    font-size: 0.9rem;
    color: #666;
}

/* 按钮激活状态 */
.function-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-btn {
    border: 2px solid #1a237e;
}

.bottle-btn {
    border: 2px solid #0277bd;
}

.wish-btn {
    border: 2px solid #4a148c;
}

/* 对话框、漂流瓶框、心愿框通用样式 */
.chat-container,
.bottle-container,
.wish-container {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 360px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.close-btn:hover {
    color: #000;
}

/* 漂流瓶特殊样式 */
textarea#bottleInput {
    width: 100%;
    height: 150px;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    resize: none;
    margin-bottom: 1rem;
    color: #333;
}

#bottleInput::placeholder {
    color: #888;
}

.throw-btn {
    width: 100%;
    background: #0277bd;
    color: white;
}

/* 修改河水区域样式 */
.river-area {
    position: absolute;
    left: 1050px;
    top: 600px;
    width: 200px;  /* 1250 - 1050 = 200px */
    height: 50px;  /* 650 - 600 = 50px */
    background: rgba(0, 119, 190, 0.05);  /* 降低透明度从0.2到0.05 */
    border-top: 1px solid rgba(255, 255, 255, 0.1);  /* 降低波纹效果的可见度 */
    pointer-events: none;  /* 让鼠标事件穿透这个区域 */
}

/* 消息回复区样式 */
.message-box {
    position: fixed;
    right: 2rem;
    top: 2rem;
    width: 320px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.message-box .box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.message-box .box-header h2 {
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
    margin: 0;
}

.message-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4CAF50;
    margin-right: 0.8rem;
    transition: all 0.3s ease;
}

/* 闪烁动画 */
@keyframes blink {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.message-indicator.new-message {
    animation: blink 1.5s infinite;
    background: #f44336;
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.5);
}

.message-content {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* 自定义滚动条 */
.message-content::-webkit-scrollbar {
    width: 4px;
}

.message-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.message-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.bottle-message {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 1.2rem;
    margin-bottom: 1rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    color: #444;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.bottle-message:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bottle-message .content {
    line-height: 1.5;
    margin-bottom: 0.8rem;
}

.bottle-message .time {
    color: #888;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
}

.bottle-message .time::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    background: #888;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #666;
    padding: 0.2rem;
    line-height: 1;
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: #333;
    transform: rotate(90deg);
}

/* 说话界面样式 */
.speak-container {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    width: 360px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.input-type-switch {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.type-btn {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 0.8rem;
    background: none;
    color: #666;
    transition: all 0.3s ease;
}

.type-btn.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
}

.type-btn:hover {
    transform: translateY(-2px);
}

/* 文字输入区域 */
.text-input-area textarea {
    width: 100%;
    height: 150px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.8rem;
    resize: none;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.text-input-area textarea:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.1);
}

/* 语音输入区域 */
.voice-input-area {
    text-align: center;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    z-index: 999;
    pointer-events: none; /* 防止区域响应点击 */
}

.voice-input-area * {
    pointer-events: auto; /* 允许子元素响应点击 */
}

.voice-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.voice-waves {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(26, 35, 126, 0.1);
    margin: 0 auto 1.5rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-waves i {
    font-size: 2rem;
    color: #1a237e;
    transform: rotate(-45deg);
}

.voice-waves.recording {
    background: rgba(26, 35, 126, 0.15);
}

@keyframes wave {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

.voice-waves.recording::before,
.voice-waves.recording::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    border: 2px solid #1a237e;
    animation: wave 2s infinite;
}

.voice-waves.recording::after {
    animation-delay: 1s;
}

.voice-text {
    color: #666;
    font-size: 1rem;
    margin-top: 1rem;
}

.record-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #1a237e;
    color: white;
    font-size: 2rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3);
    position: relative;
    z-index: 1000;
    pointer-events: auto;
}

.record-btn:active {
    transform: scale(0.92);
    background: #0d1642;
    box-shadow: 0 2px 6px rgba(26, 35, 126, 0.2);
}

.record-btn i {
    transform: rotate(-45deg);
}

/* 修改纸条的初始位置和动画 */
.paper {
    position: absolute;
    right: 2rem;  /* 与说话界面对齐 */
    top: 50%;     /* 与说话界面居中对齐 */
    width: 60px;
    height: 60px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    transform-origin: center;
    z-index: 100;
}

/* 移除标尺样式 */
.ruler-vertical,
.ruler-horizontal {
    display: none;
}

/* 修改树洞区域，移除虚框 */
.tree-hole {
    position: absolute;
    left: 350px;
    top: 200px;
    width: 100px;
    height: 300px;
}

/* 扔进树洞的动画 */
@keyframes throwToHole {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    40% {
        /* 抛物线最高点 */
        transform: translate(-100px, -50px) scale(0.9) rotate(-45deg);
        opacity: 0.9;
    }
    70% {
        /* 落入树洞中心点附近 */
        transform: translate(var(--target-x), var(--target-y)) scale(0.7) rotate(-90deg);
        opacity: 0.8;
    }
    100% {
        /* 完全消失 */
        transform: translate(var(--target-x), var(--target-y)) scale(0.5) rotate(-90deg);
        opacity: 0;
    }
}

.throwing {
    animation: throwToHole 1s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* 修改心愿输入框文字样式 */
#wishInput {
    color: #333;  /* 输入的文字颜色 */
}

#wishInput::placeholder {
    color: #888;  /* 占位符文字颜色 */
}

/* AI 消息样式 */
.bottle-message.ai-message {
    background: linear-gradient(135deg, #fff5f7 0%, #ffe4e9 100%);
    border-left: 4px solid #ff8fab;
    position: relative;
    padding: 1.5rem;
}

.message-header {
    font-size: 0.9rem;
    color: #ff8fab;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.message-header i {
    font-size: 1.2rem;
}

.ai-message .message-header {
    color: #ff6b8b;
}

.ai-message .message-header i {
    color: #ff6b8b;
}

.ai-message .message-header i.fa-robot {
    display: none;
}

.ai-message .message-header::before {
    content: '🌸';
    font-size: 1.2rem;
}

.ai-message .content {
    color: #444;
    line-height: 1.6;
    font-size: 0.95rem;
}

.ai-message::after {
    content: '✨';
    position: absolute;
    right: 1rem;
    bottom: 0.8rem;
    font-size: 1rem;
    opacity: 0.6;
}

.ai-message .message-header i {
    color: #ff6b8b;
}

.ai-message .message-header i.fa-robot {
    display: none;
}

.ai-message .message-header::before {
    content: '🌸';
    font-size: 1.2rem;
}

.ai-message .content {
    color: #444;
    line-height: 1.6;
    font-size: 0.95rem;
}

.ai-message::after {
    content: '✨';
    position: absolute;
    right: 1rem;
    bottom: 0.8rem;
    font-size: 1rem;
    opacity: 0.6;
}

/* 等待消息样式 */
.loading-message {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin: 20px auto;
    max-width: 300px;
}

.writing-animation {
    position: relative;
    margin: 20px auto;
    font-size: 24px;
    color: #6c5ce7;
}

.writing-animation .fa-feather-alt {
    animation: writing 2s infinite;
    transform-origin: bottom left;
}

.ink-drops {
    position: absolute;
    right: -20px;
    top: 0;
}

.ink-drops span {
    display: inline-block;
    width: 4px;
    height: 4px;
    background: #6c5ce7;
    border-radius: 50%;
    margin: 0 2px;
    opacity: 0;
    animation: drop 1.5s infinite;
}

.ink-drops span:nth-child(2) {
    animation-delay: 0.2s;
}

.ink-drops span:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-message p {
    color: #2d3436;
    font-size: 16px;
    margin: 15px 0;
    font-weight: 500;
}

.loading-dots {
    margin-top: 10px;
}

.loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #6c5ce7;
    border-radius: 50%;
    margin: 0 3px;
    opacity: 0.4;
    animation: dots 1.4s infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes writing {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

@keyframes drop {
    0% { transform: translateY(0); opacity: 0; }
    50% { transform: translateY(10px); opacity: 1; }
    100% { transform: translateY(20px); opacity: 0; }
}

@keyframes dots {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}
