/* --- 基础和背景设置 --- */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
}

body {
    background: linear-gradient(135deg, #ffdde1 0%, #ee9ca7 100%);
    min-height: 100vh;
    box-sizing: border-box;
    padding: 5vh 0; 
}

#sakura-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.container {
    position: relative;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px) saturate(1.5);
    -webkit-backdrop-filter: blur(12px) saturate(1.5);
    padding: 40px 50px;
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(100, 50, 50, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    animation: fadeIn 1.5s ease-in-out;
    width: 580px;
    max-width: 90%;
    box-sizing: border-box;
    margin: 0 auto; 
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.main-title {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 3.2rem;
    font-weight: normal;
    margin-bottom: 15px;
    color: #d6336c;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
    user-select: none;
}

.description {
    font-size: 1.1rem;
    margin-bottom: 30px;
    color: #5d5d5d;
}

.name-input {
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    margin-bottom: 20px;
    border-radius: 30px;
    border: 2px solid rgba(214, 51, 108, 0.4);
    background-color: rgba(255, 255, 255, 0.7);
    color: #d6336c;
    font-size: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}
.name-input:focus {
    outline: none;
    border-color: #d6336c;
    box-shadow: 0 0 15px rgba(214, 51, 108, 0.5);
}

.button-group {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 15px;
    align-items: center;
}

.generate-button {
    padding: 15px 40px;
    border: none;
    border-radius: 30px;
    background: linear-gradient(45deg, #f06595, #d6336c);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(214, 51, 108, 0.45);
    width: 100%;
    max-width: 300px;
}
.generate-button:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 25px rgba(214, 51, 108, 0.6);
}
.generate-button:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 10px rgba(214, 51, 108, 0.4);
}
.generate-button:disabled { 
    cursor: not-allowed; 
    background: #c5869a; 
}
.generate-button.loading { 
    animation: pulse 1.5s infinite; 
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.history-button {
    padding: 8px 18px;
    font-size: 0.9rem;
    color: #d6336c;
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid #d6336c;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}
.history-button:hover {
    background-color: #d6336c;
    color: white;
}

#card-container, #history-container {
    margin-top: 40px;
    text-align: left;
}

.card {
    background: rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #444;
    line-height: 1.7;
}
.card h3 {
    margin-top: 0;
    color: #c8507f;
    text-align: center;
    font-size: 1.5rem;
    border-bottom: 2px solid rgba(214, 51, 108, 0.2);
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.card p strong { color: #c8507f; }

.error-card {
    background-color: rgba(255, 224, 224, 0.7);
    border: 1px solid rgba(214, 51, 108, 0.5);
    color: #a32953;
    text-align: center;
}

#character-image-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid rgba(214, 51, 108, 0.2);
}
.character-image {
    width: 100%;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* --- [新增] 图片加载和错误状态的样式 --- */
.image-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    min-height: 200px;
}

.image-loader {
    border: 4px solid rgba(214, 51, 108, 0.2);
    border-left-color: #d6336c;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.image-loader-text {
    margin-top: 15px;
    color: #5d5d5d;
    font-size: 0.9rem;
}

.image-error {
    text-align: center;
    padding: 20px;
    background-color: rgba(255, 224, 224, 0.5);
    border-radius: 8px;
    color: #a32953;
}
.image-error .text-xs {
    font-size: 0.75rem;
    margin-top: 8px;
    opacity: 0.8;
}

.image-title {
    text-align: center;
    font-weight: bold;
    color: #c8507f;
    margin-bottom: 10px;
}

.image-placeholder-text {
    text-align: center;
    color: #888;
    padding: 40px 20px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* --- [新增结束] --- */


.history-list {
    list-style: none;
    padding: 0;
}
.history-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.25);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
}
.history-list-item .history-time {
    color: #555;
    flex-shrink: 0;
}
.history-list-item .history-name {
    color: #333;
    font-weight: 500;
    margin: 0 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.view-details-btn {
    padding: 5px 12px;
    font-size: 0.85rem;
    color: #d6336c;
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid #d6336c;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.view-details-btn:hover {
    background-color: #d6336c;
    color: white;
}

.site-footer {
    width: 100%;
    padding: 20px 0 10px 0;
    text-align: center;
    font-size: 0.9rem;
    color: #5d5d5d;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

.site-footer p {
    margin: 0;
}


@media (max-width: 600px) {
    body {
        padding: 20px 0; 
    }
    .container { 
        padding: 30px 20px; 
        width: 90%;
    }
    .main-title { 
        font-size: 2.2rem;
    }
    .description { font-size: 1rem; }
    .history-list-item {
        flex-wrap: wrap;
        align-items: center;
        row-gap: 8px;
    }
    .history-list-item .history-time {
        width: 100%;
        text-align: left;
    }
    .history-list-item .history-name {
        margin-left: 0;
        margin-right: auto;
    }
    .site-footer {
        font-size: 0.8rem;
    }
}
