/* 八字推理系统样式 */

:root {
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary-color: #06b6d4;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* 头部 */
.header {
    text-align: center;
    padding: 40px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* 区域通用样式 */
section {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #0891b2;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* 排盘卡片 */
.bazi-card {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 20px;
}

.bazi-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .label {
    color: var(--text-muted);
}

.bazi-main {
    text-align: center;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 20px;
}

.bazi-string {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 16px 0;
    letter-spacing: 4px;
}

.day-master {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.day-master-value {
    color: var(--secondary-color);
    font-weight: bold;
}

/* 四柱网格 */
.four-pillars {
    margin-top: 20px;
}

.pillars-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.pillar {
    background: var(--background);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.pillar-title {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.pillar-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
}

/* 额外信息 */
.extra-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: var(--background);
    border-radius: 4px;
}

.info-item .label {
    color: var(--text-muted);
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

/* AI 解读区域 */
.interpret-options {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.interpret-options select {
    padding: 10px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

/* 解读结果 */
.interpret-result {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 24px;
    margin-top: 20px;
}

.result-content h3 {
    margin-bottom: 16px;
    color: var(--primary-color);
}

.content-text {
    line-height: 1.8;
    white-space: pre-wrap;
}

/* 历史记录 */
.history-list {
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: var(--surface-light);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.history-item:hover {
    background: var(--primary-color);
    transform: translateX(4px);
}

.history-item .date {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-item .bazi {
    font-weight: bold;
    color: var(--text);
    margin-top: 4px;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.disclaimer {
    font-size: 0.9rem;
    margin-top: 8px;
    color: var(--warning);
}

/* 导航菜单样式 */
.navigation {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    justify-content: center;
}

.nav-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-btn:hover {
    background: var(--surface);
    transform: translateY(-2px);
}

.nav-link {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-link:hover {
    background: var(--surface);
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

/* 合盘容器样式 */
.hepan-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 20px;
}

.hepan-person {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 24px;
    border: 1px solid var(--border);
}

.hepan-person h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--text);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.hepan-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

/* 合盘结果样式 */
.hepan-result-content {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 24px;
    margin-top: 16px;
    border: 1px solid var(--border);
}

.hepan-result-content h4 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.hepan-compatibility {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.compatibility-item {
    background: var(--background);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.compatibility-title {
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 8px;
}

.compatibility-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin: 10px 0;
}

.compatibility-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* 响应式设计 - 小屏设备 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 20px 15px;
    }

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

    .subtitle {
        font-size: 1rem;
    }

    section {
        padding: 20px;
        margin-bottom: 20px;
    }

    .form-group input,
    .form-group select {
        padding: 14px 16px;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    .btn {
        padding: 14px 20px;
        font-size: 1rem;
        min-height: 48px; /* 确保触摸目标足够大 */
    }

    .pillars-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bazi-string {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .interpret-options {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .interpret-options select,
    .interpret-options button {
        width: 100%;
    }
    
    .hepan-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .navigation {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        flex: 1;
        min-width: 120px;
    }
    
    .hepan-actions {
        flex-direction: column;
    }

    .bazi-header {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .info-row {
        justify-content: flex-start;
        flex-direction: column;
    }

    .info-row .label {
        margin-bottom: 4px;
    }

    .bazi-main {
        padding: 16px;
    }

    .extra-info .info-grid {
        grid-template-columns: 1fr;
    }

    .dayun-header {
        flex-direction: column;
        gap: 8px;
    }

    .dayun-item {
        justify-content: space-between;
    }
}

/* 超小屏设备优化 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

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

    .header {
        padding: 15px 10px;
    }

    section {
        padding: 16px;
    }

    .form-group {
        margin-bottom: 16px;
    }

    .form-group input,
    .form-group select {
        padding: 12px 14px;
        font-size: 16px;
    }

    .btn {
        padding: 14px 18px;
        min-height: 48px;
    }

    .pillars-grid {
        grid-template-columns: 1fr;
    }

    .bazi-string {
        font-size: 1.3rem;
        letter-spacing: 1px;
    }

    .bazi-card {
        padding: 16px;
    }

    .nav-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-width: 100px;
    }

    .interpret-options {
        gap: 10px;
    }

    .interpret-options select {
        padding: 12px 14px;
    }

    .content-text {
        font-size: 0.95rem;
    }

    .bazi-header {
        gap: 10px;
    }

    .info-row {
        padding: 6px 0;
    }

    .dayun-item-card {
        padding: 10px 12px;
    }

    .dayun-detail {
        flex-direction: column;
        gap: 4px;
    }
}

/* 极小屏设备优化 */
@media (max-width: 375px) {
    .header h1 {
        font-size: 1.6rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .bazi-string {
        font-size: 1.2rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    .form-group input,
    .form-group select {
        padding: 12px 12px;
        font-size: 15px;
    }

    section h2 {
        font-size: 1.3rem;
    }

    .bazi-card {
        padding: 14px;
    }

    .nav-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-width: 80px;
    }
}

/* 工具类 */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

/* 四柱详细信息区域 */
.four-pillars-detail {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.four-pillars-detail h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--text);
}

.pillar-table-container {
    overflow-x: auto;
    margin-top: 16px;
}

.pillar-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.pillar-table th,
.pillar-table td {
    padding: 12px 8px;
    text-align: left;
    border: 1px solid var(--border);
}

.pillar-table th {
    background: var(--surface-light);
    font-weight: bold;
    color: var(--text);
    padding: 12px;
}

.label-column {
    width: 120px;
    background: var(--surface);
    color: var(--text);
}

.pillar-column {
    min-width: 120px;
    text-align: center;
}

.Label-cell {
    background: var(--surface);
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.pillar-cell {
    vertical-align: top;
    text-align: center;
    padding: 12px 8px;
}

.canggan-container,
.shensha-container {
    min-height: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start; /* 改为顶部对齐 */
}

.canggan-item {
    display: block;
    width: 100%;
    padding: 4px 8px;
    background: var(--surface);
    border-radius: 4px;
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 2px;
}

.shensha-item {
    display: block;
    width: 100%;
    padding: 2px 6px;
    background: var(--surface-light);
    border-radius: 3px;
    font-size: 0.75rem;
    text-align: center;
    margin-bottom: 2px;
}

/* 为特殊的神煞添加特殊样式 */
.shensha-kongwang {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important; /* 红色渐变表示空亡 */
    color: white !important;
    font-weight: bold;
}

.shensha-guiren {
    background: linear-gradient(135deg, #10b981, #059669) !important; /* 绿色渐变表示贵人 */
    color: white !important;
    font-weight: bold;
}

.shensha-taohua {
    background: linear-gradient(135deg, #ec4899, #db2777) !important; /* 粉色渐变表示桃花 */
    color: white !important;
    font-weight: bold;
}

.no-shensha, .no-canggan, .no-dayun {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
}

/* 添加行背景色区分 */
.pillar-table tbody tr:nth-child(odd):not(.label-row) {
    background-color: var(--surface);
}

.pillar-table tbody tr:nth-child(even):not(.label-row) {
    background-color: var(--background);
}

/* 为标签行添加特定类 */
.label-row {
    background-color: var(--surface) !important;
}

/* 大运信息区域 */
.dayun-info {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.dayun-info h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--text);
}

.dayun-header {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dayun-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dayun-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.dayun-value {
    color: var(--secondary-color);
    font-weight: bold;
}

.dayun-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dayun-item-card {
    background: var(--background);
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid var(--border);
}

.dayun-title {
    font-weight: bold;
    color: var(--primary-color);
    margin-right: 12px;
}

.dayun-value {
    color: var(--text);
}

.dayun-detail {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.dayun-detail span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 神煞区域 */
.shensha-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.shensha-section h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    color: var(--text);
}

.shensha-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shensha-item {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--surface-light);
    border-radius: 4px;
    font-size: 0.9rem;
}

/* 姓名测评部分 */
.name-score-section {
    background: var(--surface);
    margin-top: 20px;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.name-score-input {
    margin-bottom: 20px;
}

.name-score-input label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-weight: 500;
}

.name-score-input input {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.3s;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.name-score-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.score-display {
    text-align: center;
    margin: 20px 0;
}

.score-circle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    margin: 0 auto 15px;
}

.score-value {
    font-size: 32px;
    font-weight: bold;
    color: white;
}

.score-text {
    font-size: 14px;
    color: white;
}

.score-description {
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
    color: var(--text);
}

.name-score-result .result-content h3 {
    color: var(--text);
    margin-bottom: 16px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.name-score-result .content-text {
    line-height: 1.8;
    white-space: pre-wrap;
    color: var(--text);
}

/* 五行分析样式 */
.wuxing-analysis {
    background: var(--surface);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.wuxing-analysis h3 {
    margin-top: 0;
    color: var(--text);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.wuxing-scores {
    margin: 15px 0;
}

.wuxing-item {
    display: flex;
    align-items: center;
    margin: 8px 0;
    padding: 6px 0;
}

.wuxing-name {
    width: 40px;
    font-weight: bold;
    color: var(--text);
    margin-right: 10px;
}

.wuxing-bar-container {
    flex: 1;
    display: flex;
    align-items: center;
}

.wuxing-bar {
    height: 20px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    min-width: 0;
    transition: width 0.5s ease-in-out;
}

.wuxing-value {
    margin-left: 10px;
    min-width: 30px;
    text-align: right;
    font-weight: bold;
    color: var(--text);
}

.wuxing-strength {
    margin: 15px 0;
    padding: 10px;
    background-color: var(--surface-light);
    border-radius: 5px;
    border-left: 4px solid var(--primary-color);
}

.strength-value {
    font-weight: bold;
    color: var(--error);
}

.score-value {
    font-weight: bold;
    color: var(--success);
}

.wuxing-deficiency {
    margin: 10px 0;
    padding: 10px;
    background-color: var(--surface-light);
    border-radius: 5px;
    border-left: 4px solid var(--warning);
}

.deficiency-value {
    font-weight: bold;
    color: var(--warning);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .wuxing-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .wuxing-bar-container {
        width: 100%;
        margin-top: 5px;
    }
    
    .wuxing-name {
        margin-right: 0;
        margin-bottom: 5px;
    }
}

/* 新增：改进刑冲克害显示样式 */
.relations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.relation-card {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid var(--primary-color);
}

.relation-card.he-card {
    border-left-color: #2ecc71; /* 绿色表示合 */
}

.relation-card.chong-card {
    border-left-color: #e74c3c; /* 红色表示冲 */
}

.relation-card.ke-card {
    border-left-color: #f39c12; /* 橙色表示克 */
}

.relation-card.xing-card {
    border-left-color: #9b59b6; /* 紫色表示刑 */
}

.relation-card.hai-card {
    border-left-color: #e67e22; /* 橙红色表示害 */
}

.relation-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text);
    display: flex;
    align-items: center;
}

.relation-title i {
    margin-right: 8px;
}

.relation-items {
    list-style: none;
    padding: 0;
}

.relation-items li {
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.relation-items li:last-child {
    border-bottom: none;
}

.relation-item {
    display: flex;
    align-items: center;
}

.relation-item i {
    margin-right: 5px;
    color: var(--text-muted);
}

.tiangan-relation, .dizhi-relation {
    margin-bottom: 30px;
}

.relation-category {
    margin-bottom: 15px;
}

.relation-category-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 3px solid var(--primary-color);
}

.ai-interpret-btn {
    background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 15px;
    font-size: 14px;
    transition: transform 0.2s;
}

.ai-interpret-btn:hover {
    transform: scale(1.05);
}

.interpret-result {
    margin-top: 20px;
    padding: 15px;
    background: var(--surface-light);
    border-radius: 5px;
    border-left: 4px solid #1abc9c;
    display: none;
}

/* 合盘结果页面增强样式 */
.hepan-basic-analysis {
    margin-top: 20px;
}

.hepan-basic-analysis h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.hepan-basic-analysis h5 {
    margin: 15px 0 10px 0;
    color: var(--text);
    font-size: 1rem;
    border-left: 3px solid var(--primary-color);
    padding-left: 10px;
}

.hepan-basic-analysis ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

.hepan-basic-analysis li {
    margin-bottom: 5px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border);
}

.hepan-basic-analysis li:last-child {
    border-bottom: none;
}

.hepan-basic-analysis p {
    color: var(--text-muted);
    font-style: italic;
    margin: 10px 0;
}

.interpretation-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.interpretation-section h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.interpret-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.interpret-controls select {
    padding: 8px 12px;
    background: var(--surface-light);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.9rem;
}

.interpretation-result {
    background: var(--background);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border);
    margin-top: 15px;
}

.interpretation-content {
    line-height: 1.6;
    color: var(--text);
}

.parsed-interpretation {
    margin-top: 15px;
}

.parsed-interpretation > div {
    margin-bottom: 10px;
    padding: 10px;
    background: var(--surface);
    border-radius: 6px;
}

.parsed-interpretation h5 {
    color: var(--secondary-color);
    margin-bottom: 5px;
    font-size: 0.95rem;
}

/* 合盘关系表格样式 */
.relations-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
    background: var(--surface-light);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.relations-table th,
.relations-table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.relations-table th {
    background-color: var(--surface);
    font-weight: 600;
    color: var(--text);
}

.relations-table tr:last-child td {
    border-bottom: none;
}

.relations-table tr:nth-child(even) {
    background-color: var(--background);
}

.relations-table tr:hover {
    background-color: var(--surface);
}

.relation-he { color: #2ecc71; }
.relation-chong { color: #e74c3c; }
.relation-ke { color: #f39c12; }
.relation-xing { color: #9b59b6; }
.relation-hai { color: #e67e22; }

.relation-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 5px;
}

/* 五行相克表格 */
.wuxing-ke-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: var(--surface-light);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.wuxing-ke-table th,
.wuxing-ke-table td {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.wuxing-ke-table th {
    background-color: var(--surface);
    font-weight: 600;
    color: var(--text);
}

.wuxing-ke-table tr:last-child td {
    border-bottom: none;
}

.wuxing-ke-table .arrow-col {
    width: 60px;
    text-align: center;
    font-weight: bold;
    color: var(--error);
}

/* 关系卡片样式 */
.relation-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.relation-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    background: var(--surface-light);
    transition: box-shadow 0.2s;
}

.relation-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.relation-title {
    font-weight: 600;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

.relation-item {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}

.relation-item:last-child {
    border-bottom: none;
}

.relation-item i {
    margin-right: 8px;
    font-style: normal;
}

/* 合盘概览样式 */
.hepan-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.overview-card {
    background: var(--surface-light);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    text-align: center;
}

.overview-title {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.overview-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text);
}

/* 重复项统计样式 */
.duplicate-count {
    background: var(--surface);
    color: var(--secondary-color);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    margin-left: 5px;
    display: inline-block;
}

/* 响应式优化 */
@media (max-width: 768px) {
    .relations-table,
    .wuxing-ke-table {
        font-size: 12px;
    }
    
    .relations-table th,
    .relations-table td,
    .wuxing-ke-table th,
    .wuxing-ke-table td {
        padding: 8px;
    }
    
    .hepan-overview {
        grid-template-columns: 1fr;
    }
    
    .relation-cards {
        grid-template-columns: 1fr;
    }
    
    /* 针对四柱表格的额外优化 */
    .pillar-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
    }
    
    .pillar-table {
        min-width: 600px; /* 确保表格在小屏幕上可以横向滚动 */
    }
    
    /* 神煞列表在移动端居中对齐 */
    .shensha-list {
        justify-content: center;
    }
    
    /* 信息行在移动端垂直堆叠 */
    .info-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .info-row .label {
        margin-bottom: 4px;
    }
}

/* 针对iPhone X等375px宽度屏幕的优化 */
@media (max-width: 375px) and (min-width: 321px) {
    .header h1 {
        font-size: 1.4rem;
    }
    
    .bazi-string {
        font-size: 1.1rem;
        letter-spacing: 0.5px;
    }
    
    .container {
        padding: 8px;
    }
    
    section {
        padding: 14px;
    }
    
    .btn {
        padding: 12px 14px;
        font-size: 0.9rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .nav-btn {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-width: 70px;
    }
    
    .interpret-options {
        gap: 8px;
    }
    
    /* 针对四柱表格在iPhone X等375px屏幕上的优化 */
    .pillar-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -10px; /* 扩展到边缘 */
        padding: 0 10px;
        border: 1px solid var(--border);
        border-radius: 8px;
    }
    
    .pillar-table {
        min-width: 700px; /* 增加表格最小宽度以适应内容 */
        font-size: 0.7rem; /* 进一步缩小字体 */
        table-layout: auto; /* 让表格自动计算列宽 */
    }
    
    .pillar-table th,
    .pillar-table td {
        padding: 5px 3px; /* 减小内边距 */
        white-space: nowrap; /* 防止文字换行 */
    }
    
    .label-column {
        width: 90px; /* 减小标签列宽度 */
    }
    
    .pillar-column {
        min-width: 110px; /* 调整列宽以适应内容 */
    }
    
    /* 针对藏干、神煞等复杂内容的优化 */
    .canggan-container,
    .shensha-container {
        font-size: 0.6rem; /* 进一步减小字号以适应内容 */
        line-height: 1.1;
        min-height: auto; /* 重置最小高度 */
    }
    
    .canggan-item,
    .shensha-item {
        font-size: 0.6rem; /* 进一步减小字号 */
        padding: 1px 2px;
        margin: 0.5px 0;
        white-space: nowrap;
        overflow: visible; /* 不隐藏溢出内容 */
        max-width: none; /* 移除最大宽度限制 */
        display: block;
        text-align: center;
    }
    
    /* 特殊处理藏干和神煞较多的情况 */
    .canggan-container,
    .shensha-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px; /* 减小项目间距 */
    }
    
    /* 信息行在375px屏幕上垂直堆叠 */
    .info-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .info-row .label {
        margin-bottom: 2px;
    }
    
    /* 调整其他表格相关元素 */
    .pillar-table .label-cell {
        padding: 5px 3px;
        font-size: 0.65rem;
    }
    
    .pillar-table .pillar-cell {
        padding: 5px 3px;
        vertical-align: middle; /* 改为中间对齐 */
    }
}

/* iPhone SE及类似极小屏幕优化 */
@media (max-width: 320px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .bazi-string {
        font-size: 1rem;
        letter-spacing: 0.2px;
    }
    
    .container {
        padding: 6px;
    }
    
    section {
        padding: 12px;
    }
    
    .btn {
        padding: 11px 12px;
        font-size: 0.85rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 9px 10px;
        font-size: 13px;
    }
    
    .nav-btn {
        padding: 5px 6px;
        font-size: 0.7rem;
        min-width: 60px;
    }
    
    .interpret-options {
        gap: 6px;
    }
    
    /* 进一步优化表格 */
    .pillar-table {
        min-width: 550px;
        font-size: 0.75rem;
    }
    
    .pillar-table th,
    .pillar-table td {
        padding: 5px 3px;
    }
    
    .label-column {
        width: 80px;
    }
    
    .pillar-column {
        min-width: 90px;
    }
    
    .canggan-item,
    .shensha-item {
        font-size: 0.65rem;
        padding: 1px 2px;
    }
    
    /* 在极小屏幕上将表格转换为卡片布局 */
    .pillar-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -5px;
        padding: 5px;
    }
    
    /* 当屏幕非常小时，隐藏整个表格并用卡片替代 */
    .pillar-table {
        display: none; /* 在极小屏幕上隐藏原表格 */
    }
    
    /* 显示卡片式布局替代表格 */
    .pillar-cards-container {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    
    .pillar-card {
        background: var(--background);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px;
    }
    
    .pillar-card-header {
        font-weight: bold;
        color: var(--primary-color);
        text-align: center;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }
    
    .pillar-card-row {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border-bottom: 1px dashed var(--border);
    }
    
    .pillar-card-label {
        color: var(--text-muted);
        font-size: 0.65rem;
    }
    
    .pillar-card-value {
        font-size: 0.7rem;
        text-align: right;
    }
    
    .pillar-card-canggan,
    .pillar-card-shensha {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
        margin-top: 4px;
    }
    
    .pillar-card-canggan-item,
    .pillar-card-shensha-item {
        font-size: 0.6rem;
        padding: 1px 3px;
        background: var(--surface);
        border-radius: 3px;
    }
    
    .canggan-item,
    .shensha-item {
        font-size: 0.6rem;
        padding: 1px 2px;
    }
}

/* 触摸友好的交互效果优化 */
@media (hover: none) and (pointer: coarse) {
    /* 针对触摸设备的按钮交互优化 */
    .btn {
        -webkit-tap-highlight-color: transparent;
        tap-highlight-color: transparent;
        /* 使用transform代替box-shadow实现按压效果 */
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -khtml-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .btn:active {
        transform: translateY(-1px) scale(0.98);
    }
    
    .nav-btn:active {
        transform: translateY(-1px) scale(0.98);
    }
    
    .history-item:active {
        background: var(--primary-color);
        transform: translateX(2px);
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    :root {
        --border: #cbd5e1;
        --text: #0f172a;
        --text-muted: #475569;
        --background: #ffffff;
        --surface: #f1f5f9;
        --surface-light: #e2e8f0;
    }
    
    body {
        background: var(--background);
        color: var(--text);
    }
    
    section {
        background: var(--surface);
        border: 2px solid var(--border);
    }
    
    .bazi-card {
        background: var(--surface-light);
    }
    
    .btn-outline {
        border: 3px solid var(--primary-color);
    }
}

/* 减少动画偏好支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn,
    .nav-btn {
        transition: none;
    }
    
    .spinner {
        animation: none;
    }
    
    .history-item {
        transition: none;
    }
}
