/* ========== 自定义字体 ========== */
@font-face {
    font-family: 'FuShengKaiTi';
    src: url('../fonts/fusheng.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'FuShengKaiTi', 'KaiTi', 'Georgia', cursive;
    height: 100vh;
    overflow: hidden;
    color: white;
    background: transparent;
    position: relative;
}

/* ========== 视频背景层 ========== */
.video-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#bgVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.1s ease, opacity 0.5s ease;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

/* ========== 主容器 ========== */
.container {
    position: relative;
    z-index: auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

/* ========== 毛玻璃卡片 ========== */
.writing-zone {
    position: relative;
    width: 100%;
    max-width: 700px;
    max-height: 70vh;
    margin: 0 auto;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 30px 28px;
    overflow-y: auto;
}

.writing-zone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 24px;
    z-index: -1;
}

/* ========== 标语 ========== */
.slogan {
    text-align: center;
    font-family: 'FuShengKaiTi', 'KaiTi', cursive;
    margin-bottom: 20px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    animation: fadeIn 1s ease;
}

.slogan-line1 {
    font-size: 28px;
    color: rgba(255, 255, 255, 0.8);
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.slogan-line2 {
    font-size: 24px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 2px;
}

/* ========== 输入框 ========== */
.input-wrapper {
    margin-bottom: 24px;
}

.glass-input {
    font-family: 'FuShengKaiTi', 'KaiTi', cursive;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    border: none;
    border-radius: 32px;
    padding: 20px 24px;
    color: white;
    font-size: 18px;
    line-height: 1.5;
    min-height: 120px;
    outline: none;
    transition: all 0.3s ease;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.12);
}

.glass-input[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.4);
}

/* ========== 聊天区 ========== */
.chat-history {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
}

.ai-message, .user-message {
    display: flex;
    align-items: flex-start;
    animation: messageFadeIn 0.4s ease-out;
    margin-bottom: 22px;
    max-width: 85%;
}

.ai-message {
    flex-direction: row;
}

.user-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

.bubble {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.8;
    word-break: break-word;
    position: relative;
}

.ai-message .bubble {
    background: rgba(255, 255, 255, 0.8);
    color: #1e2b26;
    border-radius: 20px 20px 20px 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.user-message .bubble {
    background: #c8e6d9;
    color: #1a3b2e;
    border-radius: 20px 20px 6px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* ========== 底部工具栏 ========== */
.toolbar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    position: relative;
    z-index: 30;
}

.tool-btn {
    font-family: 'FuShengKaiTi', 'KaiTi', cursive;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 40px;
    padding: 10px 16px;
    font-size: 16px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.tool-btn.primary {
    background: rgba(212, 163, 115, 0.8);
}

.tool-btn.primary:hover {
    background: rgba(212, 163, 115, 1);
}

/* ========== 番茄钟 ========== */
.timer-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: none;
    border-radius: 40px;
    padding: 6px 16px 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'FuShengKaiTi', 'KaiTi', cursive;
}

.timer-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.timer-btn span {
    font-size: 14px;
    font-weight: 500;
    color: white;
    min-width: 45px;
}

.timer-ring {
    width: 32px;
    height: 32px;
    transform: rotate(-90deg);
}

.ring-progress {
    transition: stroke-dashoffset 1s linear;
}

/* ========== 控制面板 ========== */
.control-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 20px;
    width: 240px;
    z-index: 100;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-panel.hidden {
    transform: translateY(-50%) translateX(120%);
    opacity: 0;
    pointer-events: none;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.close-panel {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
}

.control-item {
    margin-bottom: 16px;
}

.control-item label {
    display: block;
    font-size: 12px;
    margin-bottom: 8px;
    opacity: 0.7;
}

.control-item input {
    width: 100%;
    cursor: pointer;
    accent-color: #d4a373;
}

/* ========== 陪伴状态卡片（左侧） ========== */
.mode-cards {
    position: fixed;
    left: 24px;
    top: 30%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 15;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'FuShengKaiTi', 'KaiTi', cursive;
    user-select: none;
}

.mode-card:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

.mode-card.active {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.mode-card.active .mode-text {
    color: rgba(255, 255, 255, 1);
    font-weight: 500;
}

.mode-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.mode-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.75);
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 163, 115, 0.5); }
    50%      { box-shadow: 0 0 0 30px rgba(212, 163, 115, 0); }
}

.pulse-glow {
    animation: pulse 0.8s ease-in-out 2;
}

/* ========== 卡片呼吸动画 ========== */
@keyframes cardBreathe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }
    50% {
        transform: scale(1.005);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }
}

.writing-zone.breathing {
    animation: cardBreathe 6s ease-in-out infinite;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 163, 115, 0.5);
    border-radius: 4px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .writing-zone {
        padding: 20px 16px;
    }

    .glass-input {
        font-size: 16px;
        padding: 16px 20px;
        min-height: 100px;
    }

    .tool-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    .control-panel {
        width: 200px;
        right: 10px;
    }

    .mode-cards {
        left: 10px;
        top: auto;
        bottom: 20px;
        transform: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .mode-card {
        padding: 8px 12px;
        border-radius: 12px;
    }

    .mode-icon {
        font-size: 14px;
    }

    .mode-text {
        font-size: 12px;
    }
}
