/* 排盘 · 移动端方块工具 + 历史记录 */
:root {
    --ph-page: #f7f3e9;
    --ph-card: #fffefb;
    --ph-ink: #2a2418;
    --ph-muted: #8a8074;
    --ph-line: rgba(120, 108, 92, 0.16);
    --ph-gold: #e8b86a;
}

.ph-body {
    min-height: 100vh;
    margin: 0;
    font-family: 'Microsoft YaHei', 'PingFang SC', system-ui, sans-serif;
    color: var(--ph-ink);
    background: var(--ph-page);
    padding-bottom: calc(4.6rem + env(safe-area-inset-bottom));
}

@media (min-width: 992px) {
    .ph-body {
        display: none;
    }
}

.ph-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
    align-items: center;
    padding: 0.55rem 0.75rem;
    padding-top: calc(0.55rem + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--ph-page) 90%, white 10%);
    border-bottom: 1px solid var(--ph-line);
    backdrop-filter: blur(8px);
}

.ph-topbar .hd-menu-toggle {
    width: 2.35rem;
    height: 2.35rem;
}

.ph-title {
    margin: 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.ph-topbar-spacer {
    width: 2.35rem;
}

.ph-main {
    max-width: 520px;
    margin: 0 auto;
    padding: 0.85rem 0.85rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.ph-card {
    background: var(--ph-card);
    border-radius: 18px;
    border: 1px solid var(--ph-line);
    box-shadow: 0 8px 28px rgba(42, 30, 18, 0.06);
    padding: 1rem 0.85rem 1rem;
}

.ph-sec-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0 0 0.85rem;
}

.ph-sec-head__bar {
    width: 3px;
    height: 1em;
    border-radius: 2px;
    background: linear-gradient(180deg, #f0c878, #d4923a);
    flex: 0 0 auto;
}

.ph-sec-head__title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

/* ── 4 列方块网格 ── */
.ph-tool-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem 0.45rem;
}

.ph-tool-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    text-decoration: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ph-tool-tile__ico {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1;
    max-width: 4.35rem;
    border-radius: 1.05rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ph-tool-tile__ico img,
.ph-tool-tile__ico svg {
    display: block;
    width: 52%;
    height: 52%;
    max-width: 1.85rem;
    max-height: 1.85rem;
    object-fit: contain;
}

.ph-tool-tile__ico--bazi {
    background: linear-gradient(160deg, #fff4df, #f3d7a4);
}

.ph-tool-tile__ico--ziwei {
    background: linear-gradient(160deg, #efe6ff, #d8c6f5);
}

.ph-tool-tile__ico--qimen {
    background: linear-gradient(160deg, #ffe8d6, #f5c49a);
}

.ph-tool-tile__ico--liuren {
    background: linear-gradient(160deg, #e3f6ea, #b8e0c6);
}

.ph-tool-tile__ico--qizheng {
    background: linear-gradient(160deg, #e4efff, #b9cff5);
}

.ph-tool-tile__ico--kezhan {
    background: linear-gradient(160deg, #f5efe1, #e2d0b0);
}

.ph-tool-tile__ico--liuyao {
    background: linear-gradient(160deg, #ffe6e2, #f5bfb6);
}

.ph-tool-tile__ico--zeji {
    background: linear-gradient(160deg, #e2f7f4, #b5e4dc);
}

.ph-tool-tile:active:not(:disabled) .ph-tool-tile__ico {
    transform: scale(0.96);
}

.ph-tool-tile__label {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    color: #3a2f1f;
}

.ph-tool-tile--soon {
    opacity: 0.72;
    cursor: not-allowed;
}

.ph-tool-tile__badge {
    position: absolute;
    top: -0.15rem;
    right: 0.05rem;
    z-index: 1;
    padding: 0.08rem 0.28rem;
    border-radius: 999px;
    font-size: 0.55rem;
    font-weight: 700;
    color: #8a5a22;
    background: rgba(255, 248, 230, 0.96);
    border: 1px solid rgba(196, 146, 62, 0.45);
    line-height: 1.2;
    pointer-events: none;
}

/* ── 历史记录 ── */
.ph-history-hint {
    margin: -0.35rem 0 0.7rem;
    font-size: 0.72rem;
    color: var(--ph-muted);
    line-height: 1.4;
}

.ph-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ph-history-empty {
    margin: 0.25rem 0 0;
    padding: 0.9rem 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--ph-muted);
    background: rgba(247, 243, 233, 0.7);
    border-radius: 12px;
    border: 1px dashed rgba(120, 108, 92, 0.22);
}

.ph-history-item {
    position: relative;
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.8rem 0.7rem;
    border-radius: 14px;
    border: 1px solid rgba(120, 108, 92, 0.12);
    background: #faf6ee;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.ph-history-item:active {
    background: rgba(232, 184, 106, 0.16);
}

.ph-history-item__status {
    position: absolute;
    top: 0.45rem;
    right: 0.5rem;
    padding: 0.12rem 0.4rem;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
}

.ph-history-item__status--saved {
    color: #2f7a4a;
    background: rgba(90, 170, 120, 0.16);
    border: 1px solid rgba(90, 170, 120, 0.35);
}

.ph-history-item__status--unsaved {
    color: #9a6a22;
    background: rgba(232, 184, 106, 0.22);
    border: 1px solid rgba(196, 146, 62, 0.4);
}

.ph-history-item__tool {
    margin: 0 3.6rem 0.2rem 0;
    font-size: 0.78rem;
    font-weight: 800;
    color: #5a4a32;
}

.ph-history-item__title {
    margin: 0 3.6rem 0.2rem 0;
    font-size: 0.92rem;
    font-weight: 700;
}

.ph-history-item__summary {
    margin: 0;
    font-size: 0.78rem;
    color: var(--ph-muted);
    line-height: 1.35;
    word-break: break-all;
}

.ph-history-item__time {
    margin: 0.35rem 0 0;
    font-size: 0.68rem;
    color: #a39888;
}

.ph-notice-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgba(24, 18, 10, 0.42);
}

.ph-notice-backdrop[hidden] {
    display: none !important;
}

.ph-notice {
    width: min(20rem, 100%);
    background: #fffefb;
    border-radius: 16px;
    padding: 1.15rem 1rem 1rem;
    border: 1px solid var(--ph-line);
    box-shadow: 0 16px 40px rgba(42, 30, 18, 0.18);
}

.ph-notice__title {
    margin: 0 0 0.55rem;
    font-size: 1rem;
    font-weight: 800;
}

.ph-notice__body {
    margin: 0 0 1rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #5a4e40;
}

.ph-notice__ok {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    color: #3a2f1f;
    background: linear-gradient(180deg, #f4d49a, #e8b86a);
}

.ph-compliance {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 0.85rem 0.5rem;
}
