/* 打字與查碼 App 的共用外框（change add-website-type-lookup-pwa design D7–D10）。
   輸入法六頁、查碼頁（lookup.js 的 layout）、聲明頁與背景程式的「還沒存到」頁共用。
   色票與字型只用 /styles.css 的 token；鍵帽的四個顏色與打字頁組字列（type.css 的 --strip-*）相同。

   招牌只有一個：頁首的「打字｜查碼」做成深色底座上的兩顆實體鍵帽，選中的那顆是按下去的。
   其他新元素（安裝鍵、離線標示、頁底出處、廣告位）都安靜。 */

[hidden] { display: none !important; }

.app-tabs {
    --cap: #382c6c;
    --cap-hover: #43367d;
    --cap-down: #241a47;
    --cap-edge: #0d0920;
    --cap-ink: #f3f0fd;
    --cap-hl: #c4b5fd;
    padding: 18px 0 0;
}
.app-tabs-row {
    max-width: 860px;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px 16px;
}
.app-keys {
    grid-column: 2;
    display: inline-flex; gap: 6px; padding: 6px;
    background: var(--deep);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 12px 26px -16px rgba(24, 18, 48, .75);
}
.app-key {
    display: block; min-width: 112px; height: 48px; border-radius: 9px;
    background: var(--cap); color: var(--cap-ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), inset 0 -5px 0 var(--cap-edge);
    font-size: 1.02rem; font-weight: 700; letter-spacing: .14em; text-decoration: none;
    transition: transform 80ms ease-out, box-shadow 80ms ease-out, background-color .15s;
}
.app-key-cap { display: flex; align-items: center; justify-content: center; height: 100%; padding: 0 0 5px .14em; }
.app-key:hover { background: var(--cap-hover); color: var(--cap-ink); text-decoration: none; }
/* 選中＝按下去並亮起：沉 2px、底邊變薄、鍵帽變淡紫（與候選列的高亮同色），一眼看得出在哪一邊 */
.app-key[aria-current="true"], .app-key:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), inset 0 -2px 0 var(--cap-edge);
}
.app-key[aria-current="true"] { background: var(--cap-hl); color: var(--deep); }
.app-key[aria-current="true"] .app-key-cap { padding-bottom: 2px; }
.app-key:focus-visible { outline: 2px solid var(--cap-hl); outline-offset: 2px; }

.app-tools { grid-column: 3; justify-self: end; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.app-install {
    display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 14px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-pill);
    background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.app-install:hover { border-color: var(--accent); color: var(--accent-press); }
.app-install:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-ios-hint { margin: 0; font-size: .82rem; color: var(--ink-soft); }
.app-offline { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); }
.app-offline::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--muted); }

/* App 視窗：收掉網站導覽列，只留品牌字與鍵帽分頁，像 App 的上方工具列 */
@media (display-mode: standalone) {
    .site-header { padding: 10px 0; }
    .site-header .nav-links { display: none; }
    .app-tabs { padding-top: 14px; }
}

/* ── 頁底一行出處（design D10） ── */
.app-credit { max-width: 920px; margin: 0 auto 10px; font-size: .8rem; line-height: 1.8; color: var(--muted); }
.app-credit a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.app-credit a:hover { color: var(--ink); }
.app-credit a[href="/typingnote/notice/"] { white-space: nowrap; }

/* ── 頁尾廣告版位（design D9）：pwa.js 只在 ads-config.json 填了編號時打開 ── */
.ad-slot { margin: 28px 0 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.ad-slot-label { margin: 0 0 8px; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .2em; color: var(--muted); }
.ad-slot-box { min-height: 280px; }

/* ── 查碼首頁：下載全部查碼資料（design D5） ── */
.zi-offline {
    margin: 0 0 24px; padding: 16px 20px; border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: var(--surface);
}
.zi-offline h2 { margin: 0 0 4px; font-size: 1.05rem; }
.zi-offline p { margin: 0 0 10px; font-size: .92rem; line-height: 1.7; color: var(--ink-soft); }
.zi-offline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.zi-offline .btn { width: auto; padding: 9px 18px; font-size: .95rem; }
.zi-offline-status { font-size: .88rem; font-weight: 700; color: var(--ink); }
.zi-offline-status.is-error { color: #b91c1c; }
.zi-offline-bar { flex: 1 1 160px; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.zi-offline-bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s; }

/* ── 自家 Google Play 引導彈窗（design D8）：電腦置中卡片，手機從底部滑上來 ── */
.app-promo {
    width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); margin: auto; padding: 0;
    border: 0; border-radius: var(--radius); background: var(--surface); color: var(--ink);
    box-shadow: 0 30px 70px -20px rgba(24, 18, 48, .55); overflow: hidden;
}
.app-promo::backdrop { background: rgba(24, 18, 48, .55); }
.app-promo-media { position: relative; background: var(--deep); }
.app-promo-media img { display: block; width: 100%; height: auto; aspect-ratio: 1024 / 500; }
.app-promo-close {
    position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: rgba(13, 9, 32, .62); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.app-promo-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.app-promo-body { padding: 18px 20px 20px; }
.app-promo-text { margin: 0 0 16px; font-size: 1.12rem; font-weight: 700; line-height: 1.5; }
.app-promo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.app-promo-actions .btn { width: auto; }
.app-promo-done {
    padding: 8px 4px; border: 0; background: none; color: var(--ink-soft); font: inherit; font-size: .92rem;
    text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.app-promo-done:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
    .app-tabs { padding-top: 14px; }
    .app-tabs-row { grid-template-columns: 1fr; justify-items: center; }
    .app-keys { grid-column: 1; }
    .app-key { min-width: 0; width: 42vw; max-width: 150px; }
    .app-tools { grid-column: 1; justify-self: center; justify-content: center; text-align: center; }
    .app-tools:not(:has(> :not([hidden]))) { display: none; }

    .app-promo {
        width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92vh;
        border-radius: var(--radius) var(--radius) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .app-promo[open] { animation: app-sheet-up .22s ease-out; }
    .app-promo-actions .btn { flex: 1 1 100%; }
    .app-promo-actions { justify-content: center; }
}
@keyframes app-sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ── 「還沒存到這台裝置」頁（背景程式產生） ── */
.app-notstored { max-width: 620px; padding-top: 56px; padding-bottom: 72px; text-align: center; }
.app-notstored .app-notstored-mark {
    display: inline-block; margin: 0 0 18px; padding: 6px 14px 9px; border-radius: 8px;
    background: #2e2459; color: #c4b5fd; box-shadow: inset 0 -3px 0 #0d0920;
    font-size: .9rem; font-weight: 700; letter-spacing: .14em;
}
.app-notstored h1 { margin: 0 0 12px; font-size: clamp(1.4rem, 4vw, 1.8rem); line-height: 1.35; }
.app-notstored p { color: var(--ink-soft); line-height: 1.8; }
.app-notstored .btn { width: auto; }

@media (prefers-reduced-motion: reduce) {
    .app-key { transition: none; }
    .app-promo[open] { animation: none; }
    .zi-offline-bar span { transition: none; }
}
