/* ============================================================
   v3 · 一屏布局 / 居中对话框 / 防双击放大
   ============================================================ */

/* 关掉双击放大（iOS Safari 对 user-scalable 的限制兜底） */
html,
body,
button,
a,
input,
textarea,
select,
label,
div,
span,
p,
section,
article,
header,
footer,
nav,
li {
    touch-action: manipulation;
}

/* 整页高度铺满，内部自己管理滚动 */
.page-home,
.page-judgment,
.rec-page {
    height: 100%;
    min-height: 0;
}

.page-home {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 9px 12px calc(8px + var(--safe-bottom));
}

/* 九宫盘面：填满剩余高度，正方形自适应；页面永远不需要上下滚动 */
.board-wrap {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-wrap .chart-board {
    height: 100%;
    width: auto;
    aspect-ratio: 1 / 1;
    max-width: 100%;
    min-height: 0;
}

.page-home .chart-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.page-judgment .jd-board-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ---------------- 记录页：整页不滚，列表内部滚动 ---------------- */

.rec-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px calc(8px + var(--safe-bottom));
    overflow: hidden;
}

.rec-page > .rec-head {
    flex: 0 0 auto;
    align-items: center;
}

.rec-page .rec-head-title {
    font-size: 19px;
}

.rec-page > .rec-stat {
    flex: 0 0 auto;
    padding: 8px 12px;
    gap: 6px;
}

.rec-page .rec-stat-value {
    font-size: 21px;
}

.rec-page .rec-mini {
    font-size: 9.5px;
    padding: 2px 7px;
}

.rec-page > .rec-chips {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.rec-page > .rec-chips::-webkit-scrollbar {
    display: none;
}

.rec-page > .rec-cat-tools,
.rec-page > .rec-list-head,
.rec-page > .rec-foot-note {
    flex: 0 0 auto;
}

.rec-page > .rec-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1px 2px 4px;
}

.rec-page > .rec-empty {
    flex: 1 1 auto;
}

.rec-page .rec-row {
    padding: 9px 11px;
    gap: 6px;
}

.rec-page .rec-row-actions .rec-act {
    height: 30px;
}

.rec-page .rec-list-head {
    padding: 0 2px;
}

.rec-page .rec-foot-note {
    padding: 0 2px;
    font-size: 9px;
}


/* ---------------- 宫位摘要条 ---------------- */

.palace-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 7px 9px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: linear-gradient(180deg, #FFFDF8, #FBF6EC);
    text-align: left;
}

.palace-strip:active {
    background: var(--paper-mid);
}

.palace-strip-name {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ink);
    white-space: nowrap;
}

.palace-strip-name em {
    margin-left: 5px;
    font-style: normal;
    font-size: 10px;
    font-weight: 400;
    color: var(--ink-faint);
}

.palace-strip-tags {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.palace-tag {
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9px;
    letter-spacing: 0.06em;
}

.palace-tag-dong {
    color: var(--accent);
    background: rgba(156, 43, 43, 0.08);
}

.palace-tag-wang {
    color: var(--gold-deep);
    background: rgba(233, 218, 185, 0.55);
}

.palace-tag-ming {
    color: #8a6420;
    background: rgba(231, 196, 106, 0.28);
}

.palace-strip-hint {
    margin-left: auto;
    flex: 0 0 auto;
    font-size: 10.5px;
    color: var(--ink-faint);
    white-space: nowrap;
}

/* ---------------- 命盘一行摘要 ---------------- */

.calendar-line {
    display: flex;
    flex-wrap: wrap;
    gap: 1px 10px;
    padding: 0 3px;
    font-size: 10px;
    line-height: 1.55;
    color: var(--ink-faint);
}

.calendar-line b {
    font-weight: 500;
    color: var(--ink-soft);
}

/* ---------------- 断局页 ---------------- */

.page-judgment {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 12px calc(8px + var(--safe-bottom));
}

.jd-head-compact {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.jd-title-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.jd-head-compact .jd-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
}

.jd-mode {
    font-size: 10px;
    color: var(--ink-faint);
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jd-head-compact .jd-save {
    margin-left: auto;
    height: 38px;
    padding: 0 16px;
    letter-spacing: 0.08em;
}

.jd-top {
    flex: 0 0 auto;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.pillars-compact .pillar {
    padding: 4px 0 5px;
    gap: 0;
}

.pillars-compact .pillar-label {
    margin-bottom: 0;
}

.pillars-compact .pillar-gan,
.pillars-compact .pillar-zhi {
    font-size: 17px;
    line-height: 1.16;
}

.jd-meta {
    padding: 0;
    border-bottom: 0;
    margin: 0;
}

.jd-board-card {
    flex: 0 0 auto;
    padding: 8px;
}

.jd-write-strip {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #FFFDF8, #FBF6EC);
    text-align: left;
}

.jd-write-strip:active {
    background: var(--paper-mid);
}

.jd-write-label {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.04em;
}

.jd-write-summary {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------- 断局编辑器（对话框内） ---------------- */

.jd-editor {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.jd-editor-label {
    font-size: 10.5px;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    margin-top: 2px;
}

.jd-editor .jd-textarea {
    min-height: 96px;
    resize: none;
}

.jd-editor .jd-feedback {
    min-height: 64px;
}

/* ---------------- 居中对话框（Dlg / RecSheet） ---------------- */

.dlg-mask {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(43, 39, 33, 0.46);
}

.dlg {
    position: fixed;
    left: 50%;
    /* 在「安全区以内」的可视区域里居中：不会钻到刘海/状态栏下面，底部按钮也不会被 Home 条挡住 */
    top: calc(var(--vv-top, 0px) + var(--safe-top, 0px)
            + (var(--vv-height, 100dvh) - var(--safe-top, 0px) - var(--safe-bottom, 0px)) / 2);
    transform: translate(-50%, -50%);
    z-index: 81;
    width: min(430px, calc(100vw - 26px));
    max-height: calc(var(--vv-height, 100dvh) - var(--safe-top, 0px) - var(--safe-bottom, 0px) - 16px);
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 18px 52px rgba(43, 39, 33, 0.3);
    padding: 12px 14px calc(11px + var(--safe-bottom) * 0.35);
}

.dlg-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line-soft);
}

.dlg-heading {
    flex: 1 1 auto;
    min-width: 0;
}

.dlg-title {
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.35;
    color: var(--ink);
}

.dlg-sub {
    margin-top: 3px;
    font-size: 10.5px;
    line-height: 1.55;
    color: var(--ink-faint);
}

.dlg-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--paper-mid);
    color: var(--ink-faint);
    font-size: 13px;
    line-height: 1;
}

.dlg-close:active {
    background: var(--paper-deep);
}

.dlg-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px 2px 6px;
}

.dlg-foot {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

.dlg-foot .rec-sheet-act,
.dlg-act {
    width: 100%;
    height: 46px;
}

/* 对话框里的局信息面板去掉卡片外壳 */
.dlg-body .pi-card {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

@keyframes dlg-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes dlg-in {
    from {
        opacity: 0.65;
        transform: translate(-50%, -50%) scale(0.965);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ---------------- 浏览器模式安装引导条 ---------------- */

.install-hint {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: linear-gradient(180deg, #FBF3E2, #F6EBD5);
    border-bottom: 1px solid rgba(176, 138, 62, 0.28);
    color: var(--ink-soft);
}

.install-hint-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--gold-deep);
}

.install-hint-icon svg {
    width: 18px;
    height: 18px;
}

.install-hint-text {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 10.5px;
    line-height: 1.55;
    letter-spacing: 0.02em;
}

.install-hint-close {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--ink-faint);
    font-size: 11px;
    background: rgba(255, 253, 248, 0.7);
}

.install-hint-close:active {
    background: var(--paper-mid);
}


/* ============================================================
   起局页（只做起局选择：极简、一屏、无转场动画）
   ============================================================ */

.page-setup {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 12px 14px calc(10px + var(--safe-bottom));
    overflow: hidden;
}

.setup-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 15px calc(14px + var(--safe-bottom) * 0.2);
}

.setup-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setup-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.16em;
    color: var(--ink-faint);
}

.setup-time {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: linear-gradient(180deg, #FFFDF8, #FBF5EA);
    text-align: left;
    position: relative;
}

.setup-time:active {
    background: var(--paper-mid);
}

.setup-time-main {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.setup-time-main b {
    margin-left: 8px;
    font-size: 25px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.setup-time-sub {
    font-size: 10.5px;
    color: var(--ink-faint);
    letter-spacing: 0.03em;
}

.setup-time .ctl-chev {
    position: absolute;
    right: 11px;
    top: 50%;
    margin-top: -7px;
}

.setup-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.setup-chip {
    flex: 1 1 0;
    min-width: 92px;
    height: 40px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink-soft);
    font-size: 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.setup-chip:active {
    background: var(--paper-mid);
}

.setup-chip.on {
    color: var(--gold-deep);
    border-color: rgba(176, 138, 62, 0.5);
    background: rgba(233, 218, 185, 0.28);
    font-weight: 600;
}

.setup-start {
    margin-top: 4px;
    height: 52px;
    border-radius: 10px;
    font-size: 16px;
    letter-spacing: 0.32em;
    text-indent: 0.32em;
}

.setup-hint {
    margin: 0;
    text-align: center;
    font-size: 10px;
    line-height: 1.5;
    color: var(--ink-faint);
    letter-spacing: 0.02em;
}
.setup-foot {
    margin: auto 0 2px;
    padding-top: 14px;
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--ink-faint);
}