:root {
    --primary: #2c3e50; /* 墨蓝 */
    --accent: #c0392b;  /* 朱红 */
    --gold: #d4af37;    /* 金色 */
    --bg-color: #fdfbf7; /* 米白纸张色 */
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-light: #666666;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --radius: 16px;
}

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

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Serif SC', serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    padding: 15px;
    line-height: 1.6;
    background-image: radial-gradient(#e0e0e0 1px, transparent 1px);
    background-size: 20px 20px; /* 点阵背景增加质感 */
}

.container {
    max-width: 600px; /* 限制最大宽度，模拟手机 App 感觉 */
    margin: 0 auto;
}

/* 头部 */
.header {
    text-align: center;
    padding: 30px 0;
}

.header h1 {
    font-size: 1.8rem;
    color: var(--primary);
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.header .subtitle {
    font-size: 0.9rem;
    color: var(--text-light);
    font-family: sans-serif;
}

/* 卡片通用样式 */
.card, .result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.02);
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 8px;
    font-weight: 500;
}

input[type="text"],
input[type="date"],
input[type="time"],
select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    background: #fcfcfc;
    transition: all 0.3s;
    font-family: sans-serif;
}

input:focus, select:focus {
    border-color: var(--primary);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* 按钮 */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: var(--gold);
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(44, 62, 80, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--text-light);
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* 结果区域样式优化 */
.card-title {
    font-size: 1.1rem;
    color: var(--primary);
    border-left: 4px solid var(--accent);
    padding-left: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

/* 四柱八字 Grid */
.bazi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.pillar-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px 5px;
    text-align: center;
    border: 1px solid #eee;
}

.pillar-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 10px;
    font-family: sans-serif;
}

.gan-zhi {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-family: 'Kaiti SC', 'STKaiti', 'KaiTi', serif; /* 楷体更有韵味 */
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-main);
}

.gan {
    color: var(--accent); /* 天干用朱红 */
}

.zhi {
    color: var(--primary); /* 地支用墨蓝 */
}

/* 五行方位布局 - 五行生克五角星布局 */
.wuxing-grid {
    display: block;
    width: 320px;
    height: 320px;
    position: relative;
    margin: 30px auto;
    /* 背景绘制五角星连线（相克）和外圈连线（相生） */
    background-image: url("data:image/svg+xml,%3Csvg width='320' height='320' viewBox='0 0 320 320' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cmarker id='arrow' markerWidth='10' markerHeight='10' refX='9' refY='3' orient='auto' markerUnits='strokeWidth'%3E%3Cpath d='M0,0 L0,6 L9,3 z' fill='%23ddd' /%3E%3C/marker%3E%3C/defs%3E%3C!-- 外圈圆形 (相生) --%3E%3Ccircle cx='160' cy='160' r='110' fill='none' stroke='%23eee' stroke-width='1' stroke-dasharray='5,5' /%3E%3C!-- 内部五角星 (相克) --%3E%3Cpath d='M160,40 L274,123 L230,255 L90,255 L46,123 Z' fill='none' stroke='%23eee' stroke-width='1' /%3E%3Cpath d='M160,40 L230,255 L46,123 L274,123 L90,255 Z' fill='none' stroke='%23e0e0e0' stroke-width='1' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

.wuxing-item {
    position: absolute;
    width: 60px;
    height: 80px;
    /* 居中定位修正 */
    left: 50%;
    top: 50%;
    margin-left: -30px;
    margin-top: -40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 2;
}

/* 
   五行位置计算 (半径 R=120px)
   中心点 (0,0)
   火 (Top): 0度 -> (0, -120)
   土 (Right): 72度 -> (114, -37)
   金 (Bottom Right): 144度 -> (70, 97)
   水 (Bottom Left): 216度 -> (-70, 97)
   木 (Left): 288度 -> (-114, -37)
*/

/* 火 - 上 */
.wuxing-item.fire { 
    transform: translate(0px, -120px);
}

/* 土 - 右上 */
.wuxing-item.earth { 
    transform: translate(114px, -37px);
}

/* 金 - 右下 */
.wuxing-item.metal { 
    transform: translate(70px, 97px);
}

/* 水 - 左下 */
.wuxing-item.water { 
    transform: translate(-70px, 97px);
}

/* 木 - 左上 */
.wuxing-item.wood { 
    transform: translate(-114px, -37px);
}

.element-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 4px solid #fff;
    font-family: 'Kaiti SC', 'STKaiti', serif;
    position: relative;
    box-sizing: border-box;
    flex-shrink: 0;
}

.element-count {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 700;
    background: rgba(255,255,255,0.9);
    padding: 2px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    white-space: nowrap;
}

/* 颜色定义 - 线性渐变 (符合截图的扁平圆形风格) */
.wuxing-item.metal .element-icon { 
    /* 金 - 黄色 */
    background: linear-gradient(180deg, #FDD835 0%, #F9A825 100%); 
    color: #fff; 
    border-color: #fff; 
}
.wuxing-item.wood .element-icon { 
    /* 木 - 绿色 */
    background: linear-gradient(180deg, #81C784 0%, #388E3C 100%); 
}
.wuxing-item.water .element-icon { 
    /* 水 - 蓝色 */
    background: linear-gradient(180deg, #64B5F6 0%, #1976D2 100%); 
}
.wuxing-item.fire .element-icon { 
    /* 火 - 红色 */
    background: linear-gradient(180deg, #E57373 0%, #D32F2F 100%); 
}
.wuxing-item.earth .element-icon { 
    /* 土 - 棕色 */
    background: linear-gradient(180deg, #8D6E63 0%, #4E342E 100%); 
    color: #fff; 
}


/* 十神分析列表 */
.shishen-list {
    list-style: none;
}

.shishen-list li {
    position: relative;
    padding: 10px 0 10px 20px;
    border-bottom: 1px dashed #eee;
    font-size: 0.95rem;
    color: #444;
}

.shishen-list li::before {
    content: "•";
    color: var(--accent);
    font-size: 1.5rem;
    position: absolute;
    left: 0;
    top: 5px;
    line-height: 1;
}

.shishen-list li:last-child {
    border-bottom: none;
}

/* 加载动画优化 */
.loading {
    text-align: center;
    padding: 50px 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* 太极动画 - SVG 矢量版 */
.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 30px;
    animation: spin 2s linear infinite;
    /* 使用 box-shadow 代替 filter，避免旋转时的边缘锯齿 */
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-radius: 50%; /* 确保阴影是圆形的 */
    
    /* 移除旧的 CSS 绘图属性 */
    background: none;
    border: none;
    
    /* 硬件加速 */
    will-change: transform;
}

/* 移除旧的伪元素绘图，防止干扰 */
.spinner::before,
.spinner::after,
.spinner .dot {
    display: none;
}

/* ... existing code ... */

.step.active::before {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.1);
}

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

/* 进度文字 */
.loading p {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.loading .wait-time {
    font-size: 0.9rem;
    color: #888;
    font-weight: 400;
    margin-bottom: 30px;
}

/* 进度步骤条 */
.progress-steps {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 280px;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 9px;
    left: 10px;
    right: 10px;
    height: 2px;
    background: #eee;
    z-index: 0;
}

.step {
    position: relative;
    z-index: 1;
    background: transparent;
    padding: 0;
    color: #ccc;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 0;
    width: 60px;
}

.step::before {
    content: '';
    width: 16px;
    height: 16px;
    background: #fff;
    border: 2px solid #eee;
    border-radius: 50%;
    transition: all 0.3s;
    margin-bottom: 5px;
}

.step.active {
    color: var(--primary);
    font-weight: bold;
    border: none;
}

.step.active::before {
    border-color: var(--primary);
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(44, 62, 80, 0.1);
}

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

/* 隐藏元素 */
.hidden {
    display: none !important;
}

/* 错误提示 */
.error {
    background: #fff2f0;
    border: 1px solid #ffccc7;
    color: #ff4d4f;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* 五行分析内容样式 */
.analysis-content {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.8;
    text-align: justify;
}

.analysis-content p {
    margin-bottom: 10px;
}


/* 首页菜单样式 */
.home-container {
    max-width: 800px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.menu-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.02);
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.12);
}

.menu-card .icon-wrapper {
    width: 60px;
    height: 60px;
    background: var(--bg-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 1.5rem;
    color: var(--primary);
    transition: background 0.3s ease, color 0.3s ease;
}

.menu-card:hover .icon-wrapper {
    background: var(--primary);
    color: #fff;
}

.menu-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.menu-card p {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* 禁用状态 */
.menu-card.disabled {
    opacity: 0.8;
    cursor: not-allowed;
    background: #f9f9f9;
}

.menu-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow);
}

.menu-card.disabled .icon-wrapper {
    background: #eee;
    color: #aaa;
}

.tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #eee;
    color: #999;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
}

/* =========================================
   移动端适配与布局优化
   ========================================= */

/* 布局容器优化 */
.main-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 表单网格布局 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.full-width {
    grid-column: 1 / -1;
}

/* 移动端响应式样式 */
@media (max-width: 768px) {
    body {
        padding: 10px;
        background-size: 10px 10px; /* 减小背景点阵尺寸 */
    }

    .container {
        width: 100%;
        padding: 0;
    }

    .header {
        padding: 20px 0;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 20px 15px; /* 减小卡片内边距 */
        border-radius: 12px;
        margin-bottom: 15px;
    }

    /* 首页菜单移动端优化 - 改为列表式卡片 */
    .menu-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .menu-card {
        display: flex;
        align-items: center;
        text-align: left;
        padding: 15px;
        min-height: 80px;
    }
    
    .menu-card .icon-wrapper {
        margin: 0 15px 0 0;
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
        flex-shrink: 0;
    }
    
    .menu-card h3 {
        margin-bottom: 4px;
        font-size: 1.1rem;
    }
    
    .menu-card p {
        font-size: 0.85rem;
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .tag {
        top: 50%;
        transform: translateY(-50%);
        right: 15px;
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* 八字排盘结果适配 */
    .bazi-grid {
        gap: 5px;
    }
    
    .pillar-item {
        padding: 10px 2px;
    }
    
    .pillar-label {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }
    
    .gan-zhi {
        font-size: 1.3rem;
    }

    /* 五行图适配 - 缩小以适应窄屏 */
    .wuxing-grid {
        transform: scale(0.85);
        margin: 0 auto 20px;
        transform-origin: center top;
        /* 修正高度占用，因为 scale 不会改变布局占据的空间 */
        height: 280px; 
        width: 100%;
        max-width: 320px;
        background-position: center top;
    }
    
    /* 按钮优化 */
    .btn-primary {
        padding: 12px;
        font-size: 1rem;
    }
}

/* 超小屏幕适配 (如 iPhone SE) */
@media (max-width: 375px) {
    .wuxing-grid {
        transform: scale(0.75);
        height: 250px;
    }
    
    .gan-zhi {
        font-size: 1.1rem;
    }
    
    .pillar-item {
        padding: 8px 0;
    }
}

/* =========================================
   面相分析页面样式
   ========================================= */

.upload-area {
    width: 100%;
    min-height: 300px;
    border: 2px dashed #e0e0e0;
    border-radius: var(--radius);
    background: #fcfcfc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary);
    background: #f8f9fa;
}

.upload-placeholder {
    text-align: center;
    color: var(--text-light);
}

.plus-icon {
    width: 80px;
    height: 80px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
    margin: 0 auto 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.3s ease;
}

.upload-area:hover .plus-icon {
    transform: scale(1.1);
    color: var(--accent);
}

.upload-placeholder p {
    font-size: 1.1rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.upload-placeholder small {
    font-size: 0.85rem;
    color: #999;
}

.preview-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.btn-icon-overlay {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: none;
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-icon-overlay:hover {
    transform: scale(1.1);
    background: #fff;
}

/* 结果内容样式 */
.analysis-content h3 {
    color: var(--primary);
    margin: 20px 0 10px;
    font-size: 1.2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.analysis-content p {
    margin-bottom: 15px;
    line-height: 1.8;
    color: #444;
}

.analysis-content ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.analysis-content li {
    margin-bottom: 8px;
    color: #555;
}

/* 紫微斗数样式 */
.ziwei-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
}

.palace-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #eee;
}

.palace-item h4 {
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 1rem;
    border-bottom: 1px dashed #ddd;
    padding-bottom: 5px;
}

.palace-item p {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
}

.ziwei-main-star {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-main);
}

.analysis-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-main);
}


/* =========================================
   进度条加载动画
   ========================================= */
.progress-container {
    width: 100%;
    max-width: 300px;
    height: 12px;
    background-color: #f0f0f0;
    border-radius: 6px;
    margin: 0 auto 20px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
}

/* 进度条光效动画 */
.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-image: linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 20px 20px;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

.loading-text {
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 10px;
}
