/* ============================================================================
 * 檔案名稱：meihua.css
 * 相對路徑：assets/css/meihua.css
 * 所屬系統：金玲巧語 - 梅花易數排盤頁
 * ============================================================================
 *
 * 建立時間：2026-04-25
 * 重寫時間：2026-04-25（用戶指出爻線山寨、版面歪、不美觀）
 * 重寫原因：
 *   1. 爻線改用 div + CSS 畫（陽=粗實線、陰=兩段中間留白）
 *   2. 整體風格對齊八字盤 master-* 系列（金邊、米白底、暗紅標題）
 *   3. 前台公開頁（無 sidebar），表單區套 form-decoration-frame、結果區套 result-decoration-frame
 *   4. RWD：手機/平板/桌機自適應
 *
 * ============================================================================ */

/* === 起卦工具列（內嵌於八字盤的 form-decoration-frame 內） === */
.meihua-cast-bar {
    padding: 8px 0;
}

.cast-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #d4a85b;
    margin-bottom: 18px;
}
.cast-tab {
    padding: 10px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #5d4a1f;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
    font-family: 'Noto Serif TC', serif;
}
.cast-tab:hover { color: #8b3a3a; }
.cast-tab.active {
    color: #8b3a3a;
    border-bottom-color: #8b3a3a;
    font-weight: 700;
}

.cast-tip {
    font-size: 12px;
    color: #8a7a5a;
    margin: 6px 0 0 4px;
    font-style: italic;
}

.meihua-save-btn {
    margin-left: 12px;
    background: linear-gradient(135deg, #8b3a3a 0%, #6b2828 100%) !important;
}

.meihua-cta-link {
    color: #8b3a3a;
    text-decoration: underline;
    font-weight: 500;
}

/* flex helpers（在八字盤已定義就重複保險） */
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* === 結果區外框（仿八字 form-decoration-frame） === */
.meihua-result-section {
    margin: 30px auto;
    max-width: 1200px;
    padding: 0 16px;
}
.result-decoration-frame {
    background: #fdf8ee;
    border: 2px solid #d4a85b;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 4px 20px rgba(139,58,58,.08);
    position: relative;
}
.result-decoration-frame::before,
.result-decoration-frame::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid #8b3a3a;
}
.result-decoration-frame::before { top: -2px; left: -2px;  border-right: none; border-bottom: none; }
.result-decoration-frame::after  { bottom: -2px; right: -2px; border-left: none;  border-top: none; }

.panel-empty,
.panel-loading,
.panel-error {
    padding: 80px 20px;
    text-align: center;
    color: #8a7a5a;
}
.panel-empty-icon { font-size: 56px; opacity: .35; margin-bottom: 12px; }
.panel-empty-text { font-size: 18px; color: #5d4a1f; margin-bottom: 6px; font-family: 'Noto Serif TC', serif; }
.panel-empty-hint { font-size: 13px; color: #aa9970; }
.panel-error      { color: #c0392b; font-size: 15px; }

/* === 摘要 === */
.meihua-summary {
    text-align: center;
    border-bottom: 1px dashed #d4a85b;
    padding-bottom: 16px;
    margin-bottom: 22px;
}
.summary-main {
    font-size: 22px;
    font-family: 'Noto Serif TC', serif;
    color: #5d4a1f;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.summary-label  { font-size: 13px; color: #8a7a5a; }
.summary-gua    { font-size: 26px; font-weight: 700; color: #8b3a3a; letter-spacing: 2px; }
.summary-yao    { font-size: 18px; color: #c0392b; font-weight: 600; }
.summary-arrow  { color: #d4a85b; font-size: 18px; }
.summary-meta   { font-size: 13px; color: #6b5a30; }

.summary-shiyou {
    margin-top: 14px;
    background: #fff8e8;
    border-left: 4px solid #d4a85b;
    padding: 10px 16px;
    color: #5d4a1f;
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    text-align: left;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
.summary-shiyou .kw {
    font-weight: 700;
    color: #8b3a3a;
    margin-right: 8px;
}
.summary-saved {
    color: #2d8659;
    font-size: 13px;
    margin-top: 8px;
}
.summary-master-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 14px;
    background: linear-gradient(135deg, #8b3a3a 0%, #6b2828 100%);
    color: #fff;
    font-size: 13px;
    border-radius: 16px;
    letter-spacing: 1px;
}

/* === 主六爻表 === */
.panel-table-wrap {
    overflow-x: auto;
    margin-bottom: 24px;
    border: 1px solid #d4a85b;
    border-radius: 8px;
    background: #fffdf8;
}
.panel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    color: #2c2416;
    min-width: 720px;
}
.panel-table th,
.panel-table td {
    border: 1px solid #e5d5b5;
    padding: 10px 6px;
    text-align: center;
    vertical-align: middle;
    line-height: 1.5;
}
.panel-table thead th {
    background: linear-gradient(180deg, #f5e9c8 0%, #ecd9a6 100%);
    font-weight: 600;
    color: #5d4a1f;
    font-size: 13px;
    font-family: 'Noto Serif TC', serif;
    padding: 12px 6px;
}
.panel-table thead th small {
    display: block;
    font-size: 10px;
    color: #8a7a5a;
    font-weight: 400;
    margin-top: 2px;
}
.panel-table tbody tr.changing {
    background: #fff5e0;
}
.panel-table .shi-ying {
    font-weight: 700;
    color: #8b3a3a;
    font-family: 'Noto Serif TC', serif;
    font-size: 16px;
}

.panel-table .th-yao,
.panel-table .td-yao { width: 130px; }

/* === 爻象（核心：div + CSS 畫） === */
.yao-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 24px;
}
.yao-line {
    display: inline-block;
    height: 8px;
    background: #1a1a1a;
    border-radius: 2px;
}
.yao-line.yao-yang {
    width: 90px;
}
.yao-line.yao-yin {
    width: 90px;
    background: transparent;
    display: inline-flex;
    align-items: center;
}
.yao-line.yao-yin .yin-half {
    flex: 1;
    height: 8px;
    background: #1a1a1a;
    border-radius: 2px;
}
.yao-line.yao-yin .yin-gap {
    width: 14px;
}
.yao-mark {
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}
.yao-mark.mark-o { color: #2d8659; }
.yao-mark.mark-x { color: #c0392b; }

/* === 納甲格 === */
.najia-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    line-height: 1.2;
    position: relative;
}
.najia-cell.bian   { color: #8a5a2a; }
.najia-cell.fushen { color: #5a5a5a; opacity: .85; }
.ng-gan { font-size: 13px; color: #6b5a30; font-weight: 600; }
.ng-zhi { font-size: 16px; color: #2c2416; font-weight: 700; }
.ng-wx  {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 8px;
    margin-top: 1px;
}
.ng-wx.wx-jin  { background: #e8e0c8; color: #8a7a3e; }
.ng-wx.wx-mu   { background: #d4ead4; color: #2d6633; }
.ng-wx.wx-shui { background: #d0dceb; color: #1d4070; }
.ng-wx.wx-huo  { background: #f2d4d4; color: #a02828; }
.ng-wx.wx-tu   { background: #ead8be; color: #8a5a28; }
.kong-tag {
    margin-top: 2px;
    background: #d3d3d3;
    color: #555;
    border-radius: 3px;
    padding: 0 5px;
    font-size: 10px;
}

/* 六獸顏色（仿 NCC 圖配色） */
.liushou {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
}
.liushou-青龍 { background: #2d8659; }
.liushou-朱雀 { background: #c0392b; }
.liushou-勾陳 { background: #b8762e; }
.liushou-騰蛇 { background: #7a3e8c; }
.liushou-白虎 { background: #6a6a6a; }
.liushou-玄武 { background: #1d4070; }

/* === 體用 === */
.panel-tiyong {
    margin-bottom: 24px;
    overflow-x: auto;
}
.panel-tiyong .ty-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    border: 1px solid #d4a85b;
    background: #fffdf8;
    border-radius: 8px;
    overflow: hidden;
    min-width: 460px;
}
.panel-tiyong .ty-cell {
    padding: 14px 8px;
    text-align: center;
    background: #fdf8ee;
    border-right: 1px dashed #e5d5b5;
}
.panel-tiyong .ty-cell:last-child { border-right: none; }
.panel-tiyong .ty-cell.ty-ti {
    background: linear-gradient(180deg, #fff3d9 0%, #ffe9bd 100%);
}
.ty-label  { font-size: 12px; color: #8a7a5a; margin-bottom: 6px; }
.ty-gua    { font-size: 22px; font-weight: 700; color: #2c2416; font-family: 'Noto Serif TC', serif; }
.ty-wuxing {
    font-size: 12px;
    margin-top: 4px;
    display: inline-block;
    padding: 1px 8px;
    border-radius: 8px;
}
.ty-wuxing.wx-jin  { background: #e8e0c8; color: #8a7a3e; }
.ty-wuxing.wx-mu   { background: #d4ead4; color: #2d6633; }
.ty-wuxing.wx-shui { background: #d0dceb; color: #1d4070; }
.ty-wuxing.wx-huo  { background: #f2d4d4; color: #a02828; }
.ty-wuxing.wx-tu   { background: #ead8be; color: #8a5a28; }
.ty-symbol {
    font-size: 24px;
    font-weight: 700;
    margin-top: 6px;
    line-height: 1;
}
.ty-symbol-text {
    font-size: 18px;
    font-weight: 700;
    margin-top: 6px;
    color: #8b3a3a;
}
.ty-symbol.sym-sheng  { color: #2d8659; }
.ty-symbol.sym-ke     { color: #c0392b; }
.ty-symbol.sym-kechu  { color: #b8762e; }
.ty-symbol.sym-bihe   { color: #1d4070; }

/* === 神煞 === */
.section-title {
    font-size: 16px;
    color: #5d4a1f;
    border-left: 4px solid #8b3a3a;
    padding-left: 10px;
    margin: 0 0 12px 0;
    font-family: 'Noto Serif TC', serif;
    font-weight: 600;
}
.shensha-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 24px;
}
.shensha-cell {
    border: 1px solid #e5d5b5;
    border-radius: 8px;
    padding: 8px 12px;
    background: #fffdf8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}
.ss-label { color: #8a7a5a; font-size: 12px; }
.ss-value { color: #2c2416; font-weight: 700; }

/* === 八字注入 === */
.panel-bazi-snapshot {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #d4a85b;
}
.bazi-pillars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    text-align: center;
    margin-bottom: 8px;
}
.bp-cell {
    background: linear-gradient(180deg, #fffdf8 0%, #f5e9c8 100%);
    border: 1px solid #d4a85b;
    border-radius: 8px;
    padding: 12px;
}
.bp-label { display: block; color: #8a7a5a; font-size: 12px; margin-bottom: 4px; }
.bp-cell strong { font-size: 24px; color: #2c2416; font-family: 'Noto Serif TC', serif; letter-spacing: 1px; }
.bazi-meta { font-size: 13px; color: #6b5a30; text-align: center; }

/* === 卦辭參考 === */
.panel-hexagram-texts {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #d4a85b;
}
.hex-text-block {
    background: #fffdf8;
    border: 1px solid #d4a85b;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 0;
    overflow: hidden;
}
.hex-text-block summary {
    cursor: pointer;
    padding: 12px 16px;
    background: linear-gradient(180deg, #f5e9c8 0%, #ecd9a6 100%);
    font-family: 'Noto Serif TC', serif;
    color: #5d4a1f;
    list-style: none;
    user-select: none;
}
.hex-text-block summary::-webkit-details-marker { display: none; }
.hex-text-block summary::before {
    content: '▸ ';
    color: #8b3a3a;
    font-weight: 700;
}
.hex-text-block[open] summary::before { content: '▾ '; }
.hex-text-block summary .ht-label {
    font-size: 13px;
    color: #8a7a5a;
    margin-right: 10px;
}
.hex-text-block summary strong {
    font-size: 17px;
    color: #8b3a3a;
    letter-spacing: 1px;
}
.hex-text-block .ht-body {
    padding: 14px 18px 18px;
    color: #2c2416;
    font-family: 'Noto Serif TC', serif;
    line-height: 1.9;
    font-size: 15px;
}
.hex-text-block .ht-body p { margin: 0 0 8px 0; }
.hex-text-block .ht-kw {
    display: inline-block;
    background: #8b3a3a;
    color: #fff;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 8px;
    margin-right: 8px;
    vertical-align: middle;
    font-family: 'Noto Sans TC', sans-serif;
    letter-spacing: 1px;
}
.hex-text-block .ht-yao {
    color: #5d4a1f;
    padding-left: 16px;
    text-indent: -16px;
}
.hex-text-block .ht-tuan,
.hex-text-block .ht-xiang {
    margin-top: 12px;
    color: #6b5a30;
    font-size: 14px;
}
.hex-text-block .ht-empty {
    padding: 16px;
    color: #aa9970;
    font-style: italic;
}

/* === 存盤區（盤面下方） === */
.panel-save-section {
    margin-top: 20px;
    padding: 16px 18px;
    background: linear-gradient(180deg, #fff8e8 0%, #fff3d9 100%);
    border: 2px solid #d4a85b;
    border-radius: 10px;
}
.panel-save-section .save-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-top: 10px;
    flex-wrap: wrap;
}
.panel-save-section input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #d4a85b;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #2c2416;
}
.panel-save-section input:focus {
    outline: none;
    border-color: #8b3a3a;
    box-shadow: 0 0 0 3px rgba(139,58,58,.15);
}
.panel-save-section .meihua-save-btn {
    margin-left: 0;
    flex-shrink: 0;
}
.save-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #8a7a5a;
}
.save-flash {
    margin-top: 16px;
    padding: 12px 16px;
    background: #d4ead4;
    color: #2d6633;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
}

/* === 老師批算 === */
.panel-master-note {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #d4a85b;
}
.master-note-body {
    background: #fffdf8;
    border: 1px solid #d4a85b;
    border-radius: 8px;
    padding: 16px 20px;
    color: #2c2416;
    font-size: 15px;
    line-height: 1.9;
    font-family: 'Noto Serif TC', serif;
    white-space: pre-wrap;
}

/* === 登入提示彈窗 === */
.meihua-login-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.meihua-login-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
}
.meihua-login-modal .modal-card {
    position: relative;
    background: #fdf8ee;
    border: 2px solid #d4a85b;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
}
.meihua-login-modal .modal-card h3 {
    margin: 0 0 12px 0;
    color: #8b3a3a;
    font-family: 'Noto Serif TC', serif;
}
.meihua-login-modal .modal-card p {
    color: #5d4a1f;
    line-height: 1.7;
    margin-bottom: 20px;
}
.meihua-login-modal .modal-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}
.mc-btn {
    padding: 8px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #d4a85b;
    background: #fff;
    color: #5d4a1f;
}
.mc-btn-primary {
    background: linear-gradient(135deg, #8b3a3a 0%, #6b2828 100%);
    border-color: #8b3a3a;
    color: #fff;
}
.mc-btn-ghost { background: #fff; }

/* === RWD === */
@media (max-width: 768px) {
    .cast-tabs { gap: 4px; overflow-x: auto; }
    .cast-tab { padding: 8px 16px; font-size: 14px; white-space: nowrap; }

    .summary-main { font-size: 18px; gap: 6px; }
    .summary-gua { font-size: 22px; }
    .summary-yao { font-size: 16px; }

    .panel-table { font-size: 12px; min-width: 580px; }
    .panel-table th,
    .panel-table td { padding: 6px 3px; }
    .ng-zhi { font-size: 14px; }

    .yao-line.yao-yang,
    .yao-line.yao-yin { width: 70px; }

    .panel-tiyong .ty-row { grid-template-columns: repeat(3, 1fr); }
    .ty-gua { font-size: 18px; }

    .bazi-pillars { grid-template-columns: repeat(2, 1fr); }
    .bp-cell strong { font-size: 18px; }
}

@media (max-width: 480px) {
    .result-decoration-frame { padding: 14px; }
    .panel-table thead th small { display: none; }
    .liushou { padding: 1px 5px; font-size: 11px; }

    .yao-line.yao-yang,
    .yao-line.yao-yin { width: 56px; }
}

/* ============================================================ */
/*  我的梅花盤 — 列表頁（金邊風格與前台對齊）                    */
/* ============================================================ */
.meihua-records-page .meihua-list-frame {
    background: #fdf8ee;
    border: 2px solid #d4a85b;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 4px 20px rgba(139,58,58,.08);
    position: relative;
    margin: 8px 0;
}
.meihua-records-page .meihua-list-frame::before,
.meihua-records-page .meihua-list-frame::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid #8b3a3a;
}
.meihua-records-page .meihua-list-frame::before { top: -2px; left: -2px;  border-right: none; border-bottom: none; }
.meihua-records-page .meihua-list-frame::after  { bottom: -2px; right: -2px; border-left: none;  border-top: none; }

.meihua-records-page .meihua-list-header {
    text-align: center;
    border-bottom: 1px dashed #d4a85b;
    padding-bottom: 18px;
    margin-bottom: 20px;
}
.meihua-records-page .meihua-list-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 28px;
    color: #8b3a3a;
    letter-spacing: 2px;
    margin: 0 0 8px 0;
    font-weight: 700;
}
.meihua-records-page .meihua-list-subtitle {
    font-size: 13px;
    color: #6b5a30;
    margin: 0 0 14px 0;
}
.meihua-records-page .meihua-list-actions { margin-top: 10px; }
.meihua-records-page .meihua-list-actions .master-submit-btn {
    display: inline-flex;
    text-decoration: none;
}

/* 卡片網格 */
.meihua-records-page .records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.meihua-records-page .record-card {
    background: linear-gradient(180deg, #fffdf8 0%, #fdf8ee 100%);
    border: 1.5px solid #d4a85b;
    border-radius: 10px;
    padding: 16px;
    position: relative;
    cursor: pointer;
    transition: box-shadow .25s, transform .25s, border-color .25s;
}
.meihua-records-page .record-card:hover {
    box-shadow: 0 8px 24px rgba(139,58,58,.18);
    transform: translateY(-3px);
    border-color: #8b3a3a;
}
.meihua-records-page .rc-tags {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
    align-items: center;
}
.meihua-records-page .rc-method {
    font-size: 11px;
    color: #8a7a5a;
    background: #fff;
    border: 1px solid #d4a85b;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 1px;
}
.meihua-records-page .rc-title {
    font-family: 'Noto Serif TC', serif;
    font-size: 22px;
    color: #2c2416;
    margin-bottom: 8px;
    margin-right: 130px;
    letter-spacing: 1px;
}
.meihua-records-page .rc-title .arrow { color: #d4a85b; margin: 0 8px; font-size: 18px; }
.meihua-records-page .rc-title strong { color: #8b3a3a; font-weight: 700; }
.meihua-records-page .rc-meta {
    font-size: 12px;
    color: #6b5a30;
    margin-bottom: 10px;
    line-height: 1.6;
}
.meihua-records-page .rc-shi-you {
    background: #fff8e8;
    border-left: 3px solid #d4a85b;
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    color: #5d4a1f;
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 44px;
}
.meihua-records-page .rc-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    border-top: 1px dashed #e5d5b5;
    padding-top: 10px;
}
.meihua-records-page .rc-btn {
    padding: 5px 12px;
    font-size: 12px;
    border: 1px solid #d4a85b;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    color: #5d4a1f;
    transition: all .2s;
}
.meihua-records-page .rc-btn:hover { border-color: #8b3a3a; color: #8b3a3a; background: #fff8e8; }
.meihua-records-page .rc-btn.danger:hover { border-color: #c0392b; color: #c0392b; background: #fdedec; }

.meihua-records-page .empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #8a7a5a;
}
.meihua-records-page .empty-state-icon { font-size: 56px; opacity: .35; margin-bottom: 12px; }

/* RWD */
@media (max-width: 768px) {
    .meihua-records-page .meihua-list-frame { padding: 18px; }
    .meihua-records-page .meihua-list-title { font-size: 22px; }
    .meihua-records-page .records-grid { grid-template-columns: 1fr; }
    .meihua-records-page .rc-title { font-size: 18px; margin-right: 110px; }
}

/* ============== 列表頁卡片標籤（前台/後台共用） ============== */
.rc-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
}
.rc-tag.tag-free   { background: #e0eef5; color: #1d4070; }
.rc-tag.tag-master { background: linear-gradient(135deg,#8b3a3a,#6b2828); color: #fff; }
