/* =========================================
   1. 全局基础样式 (Global Basics)
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f4f8;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* =========================================
   2. 头部样式 (Header)
   ========================================= */
header {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #4a6fa5;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1em;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
}

.language-selector select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9em;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-appearance: none;
}

/* =========================================
   3. 功能网格与按钮 (Grid & Buttons)
   ========================================= */
.function-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.function-btn {
    background-color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 25px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.function-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    background-color: #f8f9fa;
}

.function-btn h3 {
    color: #4a6fa5;
    font-size: 1.3em;
    margin-bottom: 10px;
}

.function-btn p {
    color: #666;
    font-size: 0.95em;
}

/* =========================================
   4. 功能详情容器 (Detail View)
   ========================================= */
.function-detail {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
}

.function-detail.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.detail-header h2 {
    color: #4a6fa5;
    font-size: 2em;
}

.back-btn {
    background-color: #4a6fa5;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.detail-content {
    font-size: 1.1em;
}

.detail-content h3 {
    color: #4a6fa5;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.detail-content p {
    margin-bottom: 15px;
    color: #555;
}

/* =========================================
   5. 表单控件 (Inputs & Actions)
   ========================================= */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

.input-group input,
.input-group textarea,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    -webkit-appearance: none;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.input-group textarea {
    resize: vertical;
    min-height: 120px;
}

.action-btn {
    background-color: #4a6fa5;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.action-btn:hover {
    background-color: #3a5a82;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background-color: #6c757d;
}

.action-btn.secondary:hover {
    background-color: #5a6268;
}

/* =========================================
   6. 结果显示与排版 (Results & Typography)
   ========================================= */
.result {
    background-color: #e8f4f8;
    border-left: 4px solid #4a6fa5;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    animation: fadeIn 0.5s ease;
}

.result h4 {
    color: #4a6fa5;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.result ul, .result ol {
    list-style-position: inside;
    padding-left: 20px;
    margin-left: 0;
}

.result li {
    margin-bottom: 8px;
    color: #555;
    line-height: 1.6;
}

/* 强制 Markdown 粗体样式 */
.result strong, .result b {
    font-weight: 800 !important;
    color: #000 !important;
}

/* 加载动画 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #4a6fa5;
    font-weight: 600;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4a6fa5;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

/* =========================================
   7. 模块专属样式 (Specific Modules)
   ========================================= */

/* --- 任务启动助手 (Task Starter) --- */
.progress-container {
    width: 100%;
    height: 12px;
    background-color: #e9ecef;
    border-radius: 6px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid #dee2e6;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4a6fa5, #6a8fb5);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.task-item:hover {
    border-color: #4a6fa5;
}

.task-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
    z-index: 2;
    accent-color: #4a6fa5;
}

.task-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.task-step-title {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 4px;
    color: #333;
    transition: color 0.3s;
}

.task-step-detail {
    color: #666;
    font-size: 0.9em;
    line-height: 1.4;
    transition: color 0.3s;
}

/* 完成任务的样式 */
.task-item.completed {
    background-color: #f1f3f5;
    border-color: #e9ecef;
    opacity: 0.8;
}

.task-item.completed .task-step-title {
    text-decoration: line-through;
    color: #adb5bd;
}

.task-item.completed .task-step-detail {
    color: #ced4da;
}

/* 撒花动画 */
.task-item.completed::before {
    content: '✨';
    position: absolute;
    left: 18px;
    top: 10px;
    font-size: 2em;
    pointer-events: none;
    animation: burst 0.6s ease-out forwards;
    z-index: 1;
}

.task-item.completed::after {
    content: '🎉';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5em;
    pointer-events: none;
    animation: burst 0.8s ease-out 0.1s forwards;
}

/* --- 时间感知 (Time Perception) --- */
.game-area {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    text-align: center;
}

.timer-visualizer {
    width: 50px;
    height: 50px;
    margin: 20px auto;
    background-color: #4a6fa5;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

/* --- 情绪急救 (Emotion Rescue) --- */
.carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.carousel-container {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 20px 5px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    scroll-behavior: smooth;
}

.carousel-container::-webkit-scrollbar {
    display: none;
}

.emotion-card {
    flex: 0 0 85%;
    max-width: 300px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    scroll-snap-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 200px;
}

.emotion-card:hover {
    transform: translateY(-5px);
    border-color: #4a6fa5;
}

.emotion-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.emotion-title {
    font-weight: bold;
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #4a6fa5;
}

.carousel-btn {
    background: rgba(255,255,255,0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 2;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a6fa5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: all 0.2s;
    flex-shrink: 0;
}

.carousel-btn:hover {
    background: #4a6fa5;
    color: white;
}

/* --- 记忆便签 (Memory Helper) --- */
.memory-notes {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.note {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.5s ease;
}

.note-content {
    margin-bottom: 10px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.note-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #ffeeba;
    padding-top: 10px;
    margin-top: auto;
}

.note-timestamp {
    font-size: 0.8em;
    color: #666;
}

.note-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    margin-left: 10px;
    padding: 5px;
    border-radius: 4px;
}

.note-actions .edit-note { color: #007bff; }
.note-actions .save-note { color: #28a745; font-weight: bold; }
.note-actions .delete-note { color: #dc3545; }

.note-content .note-edit-area {
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 8px;
    font-family: inherit;
    font-size: 1em;
    min-height: 80px;
}

/* --- 社交指南 (Social Guide) --- */
.social-tips-list {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #ffeeba;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.social-tips-list h5 {
    color: #856404;
    margin-bottom: 10px;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.social-tips-list ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.social-tips-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.95em;
}

.social-tips-list li::before {
    content: '💡';
    position: absolute;
    left: 0;
    top: 0;
    font-size: 0.8em;
}

.chat-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    font-size: 1em;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.chat-you {
    align-self: flex-end;
    background-color: #4a6fa5;
    color: white;
    border-bottom-right-radius: 2px;
    margin-left: 20%;
}

.chat-you::before {
    content: '我 (Me)';
    display: block;
    font-size: 0.75em;
    opacity: 0.8;
    margin-bottom: 4px;
    text-align: right;
    font-weight: bold;
}

.chat-other {
    align-self: flex-start;
    background-color: #e9ecef;
    color: #333;
    border-bottom-left-radius: 2px;
    margin-right: 20%;
}

.chat-other::before {
    content: '对方 (Other)';
    display: block;
    font-size: 0.75em;
    color: #666;
    margin-bottom: 4px;
    font-weight: bold;
}

.chat-tip {
    align-self: center;
    background-color: #fff3cd;
    color: #856404;
    font-size: 0.9em;
    padding: 8px 12px;
    border-radius: 20px;
    margin: 10px 0;
    border: 1px solid #ffeeba;
    text-align: center;
    font-style: italic;
}

/* --- 白噪音 (Focus Sound) --- */
.sound-player {
    text-align: center;
    padding: 30px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.sound-select-container {
    margin-bottom: 20px;
}

.sound-select-container select {
    padding: 10px;
    font-size: 1em;
    border-radius: 8px;
    border: 2px solid #e9ecef;
    width: 100%;
    max-width: 250px;
    text-align: center;
}

.sound-visualizer {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 20px;
}

.bar {
    width: 6px;
    background-color: #4a6fa5;
    border-radius: 3px;
    animation: equalize 1s infinite alternate;
}

.bar:nth-child(even) { animation-duration: 0.8s; }
.bar:nth-child(3n) { animation-duration: 1.2s; }

.play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: #4a6fa5;
    color: white;
    font-size: 2em;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(74, 111, 165, 0.4);
}

.play-btn.playing {
    background: #dc3545;
    animation: pulse 2s infinite;
}

/* --- 冲动拦截器 (Impulse Blocker) --- */
.impulse-calc {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e9ecef;
    text-align: center;
}

.life-cost {
    font-size: 2.5em;
    font-weight: 800;
    color: #dc3545;
    margin: 15px 0;
}

.life-cost span {
    font-size: 0.4em;
    color: #666;
    font-weight: normal;
}

.cool-down-timer {
    font-size: 1.5em;
    margin: 20px 0;
    color: #4a6fa5;
    font-family: monospace;
}

.timer-display {
    font-size: 3.5em;
    font-weight: bold;
    color: #4a6fa5;
    text-align: center;
    margin: 20px 0;
}

/* --- 动画定义 (Animations) --- */
@keyframes equalize { 0% { height: 10px; } 100% { height: 50px; } }
@keyframes burst { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.5); opacity: 1; } 100% { transform: scale(2); opacity: 0; } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 0% { transform: scale(0.9); opacity: 0.7; } 50% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.9); opacity: 0.7; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Safari 兼容性前缀 */
@-webkit-keyframes burst { 0% { -webkit-transform: scale(0); opacity: 0; } 50% { -webkit-transform: scale(1.5); opacity: 1; } 100% { -webkit-transform: scale(2); opacity: 0; } }
@-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } }
@-webkit-keyframes pulse { 0% { -webkit-transform: scale(0.9); opacity: 0.7; } 50% { -webkit-transform: scale(1); opacity: 1; } 100% { -webkit-transform: scale(0.9); opacity: 0.7; } }
@-webkit-keyframes fadeIn { from { opacity: 0; -webkit-transform: translateY(10px); } to { opacity: 1; -webkit-transform: translateY(0); } }

/* --- 响应式设计 (Responsive) --- */
@media (max-width: 768px) {
    header div {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .container {
        padding: 15px;
    }
    header h1 {
        font-size: 2em;
    }
    .function-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .detail-header h2 {
        margin-bottom: 15px;
    }
    .timer-display {
        font-size: 2.5em;
    }
}