/* 基础重置与全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    min-height: 100vh;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* 标题区 */
.header {
    text-align: center;
    padding: 30px 0;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header h1 {
    font-size: 2.8rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.2rem;
    color: #a8dadc;
    opacity: 0.9;
}

/* 主内容区布局 */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    margin-bottom: 40px;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* 左侧控制区 */
.control-section {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.input-group h2, .input-box h3 {
    color: #4ecdc4;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-box {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.input-box:last-child {
    border-bottom: none;
}

label {
    display: block;
    margin-bottom: 10px;
    color: #a8dadc;
    font-weight: 500;
}

/* 输入框样式 */
.input-with-button {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

#emotion-input {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    transition: all 0.3s;
}

#emotion-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px #4ecdc4;
}

/* 按钮通用样式 */
button {
    cursor: pointer;
    transition: all 0.3s;
}

.generate-btn, .emotion-btn, .element-btn, .action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
}

.generate-btn {
    background: linear-gradient(45deg, #ff6b6b, #ff8e53);
    color: white;
    min-width: 100px;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.4);
}

/* 情绪按钮组 */
.emotion-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 768px) {
    .emotion-buttons {
        grid-template-columns: 1fr;
    }
}

.emotion-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.emotion-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* 元素按钮 */
.element-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.element-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
    padding: 10px 15px;
}

.element-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* 滑块样式 */
.slider-container {
    margin-bottom: 25px;
    position: relative;
}

.slider-container label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.value-display {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: none;
    position: relative;
    z-index: 2;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4ecdc4;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

.slider-track {
    position: absolute;
    top: 25px;
    left: 0;
    height: 8px;
    border-radius: 4px;
    pointer-events: none;
}

#hue-track {
    background: linear-gradient(to right, 
        #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    width: 100%;
}

#saturation-track {
    background: linear-gradient(to right, 
        hsl(180, 0%, 50%), hsl(180, 100%, 50%));
    width: 80%;
}

#lightness-track {
    background: linear-gradient(to right, 
        #000, #888, #fff);
    width: 60%;
}

/* 右侧可视化区 */
.visualization-section {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* 场景容器 */
.scene-container {
    width: 100%;
    height: 400px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    background: linear-gradient(to bottom, 
        rgba(0,0,0,0.3), 
        rgba(0,0,0,0.1));
    margin-bottom: 20px;
}

#p5-canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.scene-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* 当前情绪显示 */
.current-emotion, .color-scheme, .story-narrative, .timeline-control {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#current-emotion-text {
    font-size: 1.4rem;
    color: #ffd166;
    font-weight: 600;
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

/* 色彩方案 */
.color-palette {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.color-box {
    flex: 1;
    height: 60px;
    border-radius: 10px;
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
    background: linear-gradient(45deg, #3498db, #2ecc71);
}

.color-box:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.color-box::after {
    content: "点击复制";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.color-box:hover::after {
    opacity: 1;
}

.color-codes {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#hex-codes {
    font-family: 'Courier New', monospace;
    color: #a8dadc;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    display: inline-block;
}

/* 诗意描述 */
.poem-display {
    text-align: center;
    padding: 15px;
    font-style: italic;
    color: #ffd166;
    font-size: 1.1rem;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 3px solid currentColor;
    transition: all 0.5s;
    margin-top: 15px;
}

/* 时间轴控制 */
.timeline-slider {
    margin-top: 15px;
}

.timeline-marks {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #a8dadc;
    font-size: 0.9rem;
}

#timeline-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: linear-gradient(to right, 
        #3498db, #2ecc71, #f1c40f, #e74c3c, #9b59b6);
    border-radius: 3px;
    outline: none;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* ========== 情绪日记墙样式 ========== */
.diary-wall {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 25px;
    margin-top: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.diary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.diary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.diary-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.diary-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.diary-card-color {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #3498db, #2ecc71);
}

.diary-card-info h4 {
    color: white;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.diary-card-info p {
    color: #a8dadc;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* 日记卡片删除按钮 */
.diary-card-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s;
    z-index: 10;
}

.diary-card:hover .diary-card-delete {
    opacity: 1;
}

.diary-card-delete:hover {
    background: rgba(192, 57, 43, 1);
    transform: scale(1.1);
}

.diary-card-delete i {
    font-size: 0.8rem;
}

/* 清空日记按钮 */
.clear-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.clear-btn:hover {
    background: linear-gradient(45deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

/* ========== 删除确认对话框 ========== */
.delete-confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.delete-confirm-dialog.show {
    opacity: 1;
    visibility: visible;
}

.delete-confirm-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.delete-confirm-content h3 {
    color: #ffd166;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.delete-confirm-content p {
    color: #a8dadc;
    margin-bottom: 25px;
    line-height: 1.5;
}

.delete-confirm-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.delete-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.confirm-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
}

.confirm-btn:hover {
    background: linear-gradient(45deg, #c0392b, #a93226);
    transform: translateY(-2px);
}

/* 底部操作栏 */
.footer {
    text-align: center;
    padding: 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    margin-top: 30px;
}

.footer p {
    color: #a8dadc;
    margin-bottom: 20px;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 20px;
}

@media (max-width: 768px) {
    .actions {
        flex-direction: column;
    }
}

.action-btn {
    background: linear-gradient(45deg, #4776E6, #8E54E9);
    color: white;
    padding: 15px 30px;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(142, 84, 233, 0.4);
}

/* 场景动画关键帧 */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes drift {
    0% { transform: translateX(-100px); opacity: 0; }
    10% { opacity: 0.8; }
    90% { opacity: 0.8; }
    100% { transform: translateX(calc(100vw + 100px)); opacity: 0; }
}

@keyframes wave {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes fall {
    0% { transform: translateY(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(calc(100vh + 20px)); opacity: 0; }
}

@keyframes flicker {
    0% { transform: scaleY(1); opacity: 0.8; }
    100% { transform: scaleY(1.1); opacity: 1; }
}

@keyframes sway {
    0%, 100% { transform: translateX(-50%) rotate(-5deg); }
    50% { transform: translateX(-50%) rotate(5deg); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-20px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}