/* Shared floating purchase entry: 中醫傷寒學園 */
.app-purchase-float [hidden] { display: none !important; }
.app-purchase-float {
    width: 282px;
    position: fixed;
    right: 24px;
    bottom: 78px;
    z-index: 155;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 9px 11px;
    align-items: center;
    padding: 13px 14px 13px;
    border: 1px solid #9e8d79;
    border-left: 3px solid #8e3f32;
    border-radius: 8px;
    background: rgba(251,248,241,.98);
    box-shadow: 0 12px 28px rgba(45,38,30,.15);
    font-family: "Noto Sans TC","PingFang TC","Microsoft JhengHei",sans-serif;
    color: #302c27;
}
.app-purchase-float.is-collapsed {
    width: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.app-purchase-close {
    width: 27px;
    height: 27px;
    position: absolute;
    right: 6px;
    top: 5px;
    border: 0;
    background: transparent;
    color: #82786c;
    font: 21px/1 Arial,sans-serif;
    cursor: pointer;
}
.app-purchase-close:hover { color: #2d2924; }
.app-purchase-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #4c4740;
    border-radius: 8px;
    color: #fff;
    background: #3b3935;
    font: 700 9px/1 Arial,sans-serif;
    letter-spacing: .08em;
}
.app-purchase-copy { min-width: 0; padding-right: 14px; }
.app-purchase-kicker {
    display: block;
    margin-bottom: 2px;
    color: #82776c;
    font-size: 11px;
    letter-spacing: .05em;
}
.app-purchase-copy strong {
    display: block;
    color: #2a2723;
    font-size: 16px;
    letter-spacing: .04em;
}
.app-purchase-copy p {
    margin: 5px 0 0;
    color: #655e55;
    font-size: 11.5px;
    line-height: 1.5;
}
.app-purchase-action {
    grid-column: 1 / -1;
    min-height: 36px;
    border: 1px solid #4c4740;
    border-radius: 3px;
    color: #fff;
    background: #383633;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .04em;
    cursor: pointer;
}
.app-purchase-action:hover { background: #232220; }

/* Expanded layout: keep the close control out of the grid flow. */
.app-purchase-icon { grid-column: 1; grid-row: 1; }
.app-purchase-copy { grid-column: 2; grid-row: 1; }
.app-purchase-action { grid-column: 1 / -1; grid-row: 2; }

/* Collapsed state: compact horizontal button instead of a tall capsule. */
.app-purchase-pill {
    width: 48px;
    height: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #9e8d79;
    border-radius: 50%;
    color: #322e29;
    background: rgba(251,248,241,.98);
    box-shadow: 0 8px 22px rgba(45,38,30,.16);
    cursor: pointer;
}
.app-purchase-pill:hover { border-color: #725f4d; background: #fffdf8; }
.app-purchase-float.is-collapsed .app-purchase-pill { grid-column: auto; grid-row: auto; }
.app-purchase-pill span {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    background: #3b3935;
    font: 700 9px/1 Arial,sans-serif;
    letter-spacing: .05em;
}

.app-purchase-details {
    width: 540px;
    position: absolute;
    right: calc(100% + 14px);
    bottom: 0;
    z-index: 2;
    padding: 20px;
    border: 1px solid #9e8d79;
    border-top: 4px solid #8e3f32;
    border-radius: 5px;
    background: rgba(253,251,246,.995);
    box-shadow: 0 18px 42px rgba(45,38,30,.2);
}
.app-purchase-details::after {
    content: "";
    position: absolute;
    right: -9px;
    bottom: 26px;
    width: 16px;
    height: 16px;
    border-top: 1px solid #9e8d79;
    border-right: 1px solid #9e8d79;
    background: #fdfbf6;
    transform: rotate(45deg);
}
.app-purchase-details-close {
    width: 30px;
    height: 30px;
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 2;
    border: 0;
    background: transparent;
    color: #776e63;
    font: 24px/1 Arial,sans-serif;
    cursor: pointer;
}
.app-purchase-details-heading { padding-right: 28px; margin-bottom: 16px; }
.app-purchase-details-heading > span {
    display: block;
    margin-bottom: 4px;
    color: #8e3f32;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
}
.app-purchase-details-heading > strong {
    display: block;
    color: #282521;
    font-size: 19px;
    line-height: 1.45;
    letter-spacing: .035em;
}
.app-purchase-details-heading > p {
    margin: 7px 0 0;
    color: #685f55;
    font-size: 12.5px;
    line-height: 1.65;
}
.app-store-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 14px;
}
.app-store-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid #d0c6b8;
    background: rgba(255,255,255,.78);
    text-align: center;
}
.app-store-platform {
    color: #8a8074;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.app-store-card h3 { margin: 3px 0 10px; color: #2e2a25; font-size: 16px; }
.app-store-qr {
    width: 132px;
    height: 132px;
    max-width: 100%;
    display: block;
    margin: 0 auto 10px;
    border: 1px solid #d5cec3;
    background: #fff;
    object-fit: contain;
}
.app-store-card p {
    min-height: 42px;
    margin: 0 0 11px;
    color: #6b6359;
    font-size: 11.5px;
    line-height: 1.55;
    text-align: left;
}
.app-store-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: 1px solid #48433d;
    border-radius: 3px;
    color: #fff;
    background: #383633;
    text-decoration: none;
    font-size: 11.5px;
    font-weight: 700;
}
.app-store-link:hover { background: #22211f; }
.app-purchase-sync-note {
    display: grid;
    gap: 3px;
    margin-top: 14px;
    padding: 11px 13px;
    border-left: 3px solid #8e3f32;
    background: rgba(246,242,234,.9);
}
.app-purchase-sync-note strong { color: #40382f; font-size: 12px; }
.app-purchase-sync-note span { color: #6b6258; font-size: 11.5px; line-height: 1.6; }

@media (max-width: 980px) and (min-width: 721px) {
    .app-purchase-details { width: 480px; }
    .app-store-qr { width: 112px; height: 112px; }
}
@media (max-width: 720px) {
    .app-purchase-float {
        width: calc(100% - 32px);
        max-width: 520px;
        right: 16px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        grid-template-columns: 46px minmax(0,1fr) 104px;
        grid-template-rows: auto;
        gap: 10px 12px;
        padding: 12px 13px;
        border-left-width: 3px;
        box-shadow: 0 10px 28px rgba(45,38,30,.2);
    }
    .app-purchase-icon {
        grid-column: 1;
        grid-row: 1;
        width: 46px;
        height: 46px;
        font-size: 10px;
    }
    .app-purchase-copy {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        padding-right: 0;
    }
    .app-purchase-copy strong { font-size: 15px; line-height: 1.35; }
    .app-purchase-kicker { font-size: 10px; }
    .app-purchase-copy p { margin-top: 3px; font-size: 11px; line-height: 1.45; }
    .app-purchase-action {
        grid-column: 3;
        grid-row: 1;
        width: 104px;
        min-height: 40px;
        padding: 7px 9px;
        white-space: normal;
        font-size: 11.5px;
        line-height: 1.35;
    }
    .app-purchase-close {
        right: -4px;
        top: -28px;
        width: 30px;
        height: 30px;
        border: 1px solid #b5aa9c;
        border-radius: 50%;
        background: rgba(250,247,240,.98);
        box-shadow: 0 4px 12px rgba(45,38,30,.12);
    }
    .app-purchase-float.is-collapsed {
        width: auto;
        right: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom));
    }
    .app-purchase-pill { width: 48px; height: 48px; min-height: 48px; padding: 0; }
    .app-purchase-details {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 110px - env(safe-area-inset-bottom));
        right: 0;
        bottom: calc(100% + 12px);
        overflow-y: auto;
        padding: 16px;
        border-top-width: 3px;
    }
    .app-purchase-details::after {
        right: 26px;
        bottom: -9px;
        border-top: 0;
        border-right: 1px solid #9e8d79;
        border-bottom: 1px solid #9e8d79;
    }
    .app-store-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
    .app-store-card { padding: 10px; }
    .app-store-qr { width: 104px; height: 104px; }
    .app-store-card p { min-height: 0; font-size: 10.5px; }
    .app-purchase-details-heading > strong { font-size: 17px; }
    .app-purchase-details-heading > p { font-size: 11.5px; }
}
@media (max-width: 430px) {
    .app-purchase-float:not(.is-collapsed) {
        grid-template-columns: 46px minmax(0,1fr);
        gap: 9px 11px;
        padding: 11px 12px 12px;
    }
    .app-purchase-icon { grid-column: 1; grid-row: 1; }
    .app-purchase-copy {
        grid-column: 2;
        grid-row: 1;
        padding-right: 26px;
    }
    .app-purchase-copy strong { font-size: 15px; }
    .app-purchase-copy p { font-size: 10.5px; }
    .app-purchase-action {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        min-height: 38px;
        white-space: nowrap;
        font-size: 11.5px;
    }
    .app-purchase-close {
        right: 5px;
        top: 5px;
        width: 26px;
        height: 26px;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    .app-purchase-details {
        left: 50%;
        right: auto;
        width: calc(100vw - 20px);
        transform: translateX(-50%);
    }
    .app-store-grid { grid-template-columns: 1fr; }
    .app-store-card {
        display: grid;
        grid-template-columns: 92px minmax(0,1fr);
        column-gap: 10px;
        text-align: left;
    }
    .app-store-platform,.app-store-card h3,.app-store-card p,.app-store-link { grid-column: 2; }
    .app-store-platform { align-self: end; }
    .app-store-card h3 { margin-bottom: 5px; }
    .app-store-qr { grid-column: 1; grid-row: 1 / span 4; width: 92px; height: 92px; margin: 0; }
    .app-store-link { min-height: 32px; }
}


/* 2026-08-27 mobile position hardening */
@media (max-width: 720px) {
    /* 收合狀態固定在右下角，避免受到其他版面規則影響而跑到中央。 */
    .app-purchase-float.is-collapsed {
        left: auto !important;
        right: max(14px, env(safe-area-inset-right)) !important;
        bottom: calc(14px + env(safe-area-inset-bottom)) !important;
        width: 48px !important;
        max-width: none !important;
        display: block !important;
        transform: none !important;
    }
    .app-purchase-float.is-collapsed .app-purchase-pill {
        display: inline-flex;
        margin: 0;
        position: static;
        transform: none !important;
    }

    /* 手機展開購買方式時，資訊面板改以 viewport 定位。
       上方預留固定 Header 空間，關閉鈕不會被 Header 蓋住。 */
    .app-purchase-details {
        position: fixed;
        left: 12px;
        right: 12px;
        top: calc(84px + env(safe-area-inset-top));
        bottom: calc(84px + env(safe-area-inset-bottom));
        width: auto;
        max-width: none;
        max-height: none;
        transform: none;
        overflow-y: auto;
        overscroll-behavior: contain;
        z-index: 210;
    }
    .app-purchase-details::after { display: none; }
    .app-purchase-details-close {
        position: sticky;
        float: right;
        top: 0;
        right: 0;
        margin: -4px -4px 0 8px;
        border: 1px solid #c5b9aa;
        border-radius: 50%;
        background: rgba(253,251,246,.98);
        box-shadow: 0 3px 10px rgba(45,38,30,.12);
    }
}

@media (max-width: 430px) {
    .app-purchase-details {
        left: 10px;
        right: 10px;
        top: calc(76px + env(safe-area-inset-top));
        bottom: calc(82px + env(safe-area-inset-bottom));
        width: auto;
        transform: none;
    }
}

/* Temporary pre-launch notice shown while the App purchase flow is still under test. */
.app-purchase-testing {
    width: 390px;
    padding: 28px 28px 24px;
    text-align: center;
}
.app-purchase-testing-icon {
    width: 52px;
    height: 52px;
    margin: 2px auto 12px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #fff;
    background: #3b3935;
    font: 700 10px/1 Arial,sans-serif;
    letter-spacing: .08em;
}
.app-purchase-testing-kicker {
    display: block;
    margin-bottom: 5px;
    color: #8e3f32;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
}
.app-purchase-testing > strong {
    display: block;
    color: #282521;
    font-size: 20px;
    line-height: 1.45;
    letter-spacing: .035em;
}
.app-purchase-testing > p {
    margin: 10px 0 0;
    color: #685f55;
    font-size: 13px;
    line-height: 1.8;
    text-align: left;
}
.app-purchase-testing-note {
    margin-top: 16px;
    padding-top: 13px;
    border-top: 1px solid #ddd4c8;
    color: #5f5145;
    font-size: 12.5px;
    font-weight: 700;
}

@media (max-width: 720px) {
    .app-purchase-testing {
        width: calc(100vw - 32px);
        max-width: 420px;
        padding: 25px 22px 21px;
    }
}
