/* ==========================================================================
   六爻金钱摇卦与排盘系统 专属 UI 样式表 (tools/liu-yao/style.css)
   遵守 Liquid Glass 视觉规范及日夜双主题变量控制
   ========================================================================== */

/* 1. 布局与顶栏控制 */
@media (min-width: 992px) {
    .tool-container-standard {
        max-width: 1100px !important;
    }
}

.tool-instructions {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* 2. 起卦模式卡片与切换器 */
.cast-mode-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-tab-btn {
    background: var(--glass-bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-tab-btn.active {
    background: var(--primary-color);
    color: var(--bg-base);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.3);
}

/* 全局标准按钮样式定义 */
.btn-primary {
    width: 100%;
    padding: 12px 18px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.25);
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 6px 16px rgba(8, 145, 178, 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 摇卦区面板 */
.cast-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.cast-question-input {
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
}

/* 表单输入框与下拉菜单美化 */
.cast-question-input input,
.time-input-area input,
.manual-line-row select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg-hover);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.cast-question-input input:focus,
.time-input-area input:focus,
.manual-line-row select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 12px rgba(8, 145, 178, 0.3);
}

.cast-question-input input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.cast-workspace {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

/* 金币 3D 动画 */
.coins-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.coins-row {
    display: flex;
    gap: 16px;
}

.coin {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #daa520);
    border: 2px solid #b8860b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    transition: transform 0.3s ease;
    user-select: none;
}

.coin.flipping {
    animation: flipCoin 0.3s infinite linear;
}

@keyframes flipCoin {
    0% {
        transform: rotateY(0deg) scale(1.1);
    }
    100% {
        transform: rotateY(360deg) scale(1.1);
    }
}

.coin-yang {
    width: 24px;
    height: 4px;
    background-color: #fff;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.coin-yin {
    display: flex;
    width: 24px;
    justify-content: space-between;
}

.coin-yin::before,
.coin-yin::after {
    content: '';
    width: 10px;
    height: 4px;
    background-color: #fff;
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 卦象生成预览区 */
.lines-preview-area {
    width: 220px;
    min-height: 240px;
    border: 2px dashed var(--glass-border);
    border-radius: 12px;
    padding: 20px 14px;
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.05);
    position: relative;
}

.gua-line-bar {
    width: 160px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 4px;
    opacity: 0;
    transform: translateY(8px);
    animation: fadeInLine 0.4s forwards;
    position: relative;
}

.gua-line-bar.yin {
    background: linear-gradient(to right, var(--primary-color) 42%, transparent 42%, transparent 58%, var(--primary-color) 58%);
}

.gua-line-bar .line-mark {
    position: absolute;
    right: -32px;
    top: 0px;
    font-size: 18px;
    font-weight: bold;
    color: #ef4444;
}

@keyframes fadeInLine {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 手动选爻模式面板 */
.manual-input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.manual-line-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--glass-bg-hover);
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.manual-line-row label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.manual-line-row select {
    width: 140px;
    padding: 6px 10px;
    border-radius: 6px;
}

/* 日期选单与按时间起卦 */
.time-input-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

/* 3. 六爻排盘结果卡片 (全端横排控制) */
.pan-result-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border-radius: 16px;
    padding: 20px;
    margin-top: 24px;
    display: none;
}

.pan-header-info {
    text-align: center;
    border-bottom: 1px dashed var(--glass-border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.pan-question-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.pan-time-gz {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.pan-time-gz .gz-pillar {
    display: inline-block;
    margin: 0 6px;
    font-weight: 600;
}

.pan-time-gz .gz-pillar span {
    margin: 0 !important;
}

/* 本卦与变卦对照容器 (PC端横排，移动端竖排) */
.pan-gua-duizhao {
    display: flex;
    flex-direction: row;
    gap: 16px;
    width: 100%;
}

.gua-card-half {
    flex: 1 1 50%;
    min-width: 0; /* 允许文本自适应收缩 */
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 14px 10px;
    box-sizing: border-box;
    overflow-x: auto; /* 防止单元格溢出破坏隔壁卡片 */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.gua-card-title {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.gua-title-link {
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

.gua-title-link:hover {
    color: #0d9488;
}

.gua-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--glass-bg-hover);
    color: var(--text-secondary);
    font-weight: normal;
}

/* 六爻排盘数据表格 */
.yao-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.yao-table th:nth-child(1) { width: 14%; }
.yao-table th:nth-child(2) { width: 16%; }
.yao-table th:nth-child(3) { width: 18%; }
.yao-table th:nth-child(4) { width: 32%; }
.yao-table th:nth-child(5) { width: 20%; }

.yao-table th,
.yao-table td {
    padding: 8px 4px;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
    height: 40px;
    vertical-align: middle;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
}

.yao-table th {
    color: var(--text-secondary);
    font-weight: 600;
    background: var(--glass-bg-hover);
    height: 34px;
}

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

/* 爻象图像渲染单元格 (2列 Grid 保证多行画棒 100% 垂直绝对对齐) */
.yao-cell-grid {
    display: inline-grid;
    grid-template-columns: 76px 28px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    vertical-align: middle;
}

.yao-cell-grid .yao-extra {
    text-align: left;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
}

.gua-line-bar-mini {
    display: inline-block;
    width: 76px;
    height: 12px;
    vertical-align: middle;
    background: var(--primary-color);
    border-radius: 3px;
    box-shadow: 0 0 5px var(--mystic-glow);
    transition: all 0.3s ease;
}

.gua-line-bar-mini.yin {
    background: linear-gradient(to right, var(--primary-color) 42%, transparent 42%, transparent 58%, var(--primary-color) 58%);
    box-shadow: none;
    filter: drop-shadow(0 0 2px var(--mystic-glow));
}

.moving-row .gua-line-bar-mini.yang {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.moving-row .gua-line-bar-mini.yin {
    background: linear-gradient(to right, #ef4444 42%, transparent 42%, transparent 58%, #ef4444 58%);
    box-shadow: none;
    filter: drop-shadow(0 0 2px rgba(239, 68, 68, 0.4));
}

/* 伏神列显示格式 (保持单行，避免撑高整行导致左右不对称) */
.fushen-text {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.9;
    white-space: nowrap;
}

/* 世应标记 */
.badge-shi {
    color: #ef4444;
    font-weight: bold;
    margin-left: 2px;
}

.badge-ying {
    color: #3b82f6;
    font-weight: bold;
    margin-left: 2px;
}

/* 动爻高亮 */
.moving-row {
    background: rgba(239, 68, 68, 0.08);
}

.moving-row td {
    color: #ef4444;
    font-weight: 700;
}

.move-mark {
    display: inline-block;
    color: #ef4444;
    font-weight: bold;
    margin-left: 2px;
}

/* 4. 卦辞与爻辞释义区域 */
.gua-ci-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--glass-border);
}

.ci-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.ci-text {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    background: var(--glass-bg-hover);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* 5. 64卦 内部弹窗样式 (方案B) */
.overlay-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.gua-modal-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: var(--background-blur);
    -webkit-backdrop-filter: var(--background-blur);
    border-radius: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
    animation: modalSlideUp 0.3s ease-out;
}

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

.gua-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid var(--glass-border);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    color: var(--text-primary);
}

.gua-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-color);
}

.gua-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.8;
}

/* 移动端 (<= 768px 及 <= 480px) 竖排自适应展示 */
@media (max-width: 768px) {
    .tool-container-standard {
        padding: 16px 12px !important;
    }

    .cast-workspace {
        gap: 20px;
    }

    .pan-result-container {
        padding: 16px 12px;
    }

    .pan-gua-duizhao {
        flex-direction: column !important;
        gap: 16px;
    }

    .gua-card-half {
        flex: 1 1 100%;
        width: 100%;
        padding: 14px 12px;
        border-radius: 12px;
    }

    .gua-card-title {
        font-size: 16px;
        margin-bottom: 10px;
        padding-bottom: 6px;
        gap: 6px;
    }

    .yao-table th,
    .yao-table td {
        padding: 8px 4px;
        font-size: 13px;
        letter-spacing: normal;
        height: 36px;
    }

    .fushen-text {
        font-size: 11px;
        white-space: nowrap;
    }

    .gua-badge {
        font-size: 11px;
        padding: 2px 6px;
    }

    .yao-cell-grid {
        grid-template-columns: 60px 24px;
        gap: 4px;
    }

    .gua-line-bar-mini {
        width: 60px;
        height: 10px;
    }

    .lines-preview-area {
        width: 180px;
        min-height: 200px;
    }

    .gua-line-bar {
        width: 130px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .tool-container-standard {
        padding: 12px 8px !important;
    }

    .pan-result-container {
        padding: 14px 8px;
    }

    .pan-gua-duizhao {
        gap: 14px;
    }

    .gua-card-half {
        padding: 12px 8px;
    }

    .gua-card-title {
        font-size: 15px;
    }

    .coins-row {
        gap: 12px;
    }

    .coin {
        width: 46px;
        height: 46px;
        font-size: 19px;
    }

    .yao-table th,
    .yao-table td {
        padding: 6px 2px;
        font-size: 12.5px;
        letter-spacing: normal;
        height: 34px;
    }

    .pan-question-title {
        font-size: 16px;
    }

    .pan-time-gz {
        font-size: 12px;
    }

    .pan-time-gz .gz-pillar {
        margin: 0 4px;
    }

    .yao-cell-grid {
        grid-template-columns: 52px 22px;
        gap: 3px;
    }

    .gua-line-bar-mini {
        width: 52px;
        height: 9px;
    }

    .lines-preview-area {
        width: 140px;
        min-height: 170px;
    }

    .gua-line-bar {
        width: 100px;
        height: 14px;
    }
}

/* 6. 笔记区域标准样式 (与八字排盘完全对齐) */
.notes-section {
    margin-top: 32px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notes-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 4px;
}

.standard-notes-area {
    width: 100%;
    height: 180px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: all 0.3s var(--ease-liquid);
    box-sizing: border-box;
    font-family: inherit;
}

.standard-notes-area:focus {
    border-color: var(--primary-color);
    background: var(--glass-bg-hover);
    box-shadow: 0 0 0 4px var(--mystic-glow);
}

.notes-actions {
    width: 100%;
}

