/* 線上輸入法（/typingnote/type/ 入口頁與 boshiamy/、cangjie5/、dayi/、array30/、custom/ 五頁共用，
   change add-website-multi-ime-pages design D3）。原本是線上嘸蝦米輸入法頁的樣式。共用 token 在 /styles.css；
   查碼頁的 promo／attribution 兩塊樣式在 zi.css，這一頁不載入 zi.css，原樣複製為 tp- 前綴。

   版面主角是「輸入區」：工具列、文字框、組字列、語音列接成一個整體。組字列做成深色的
   顯示窗，字碼一個字根一顆鍵帽——嘸蝦米是拆字根打鍵，這一列就是鍵盤上看得見的那一刻。
   組字列與語音列一直在、高度固定，組字或聽寫時下面的內容不會被推動。 */

/* 瀏覽器預設的 [hidden]{display:none} 會被本頁與共用的 display 規則蓋過，限定在本頁強制生效 */
body.tp [hidden] { display: none !important; }

.tp {
    --strip-bg: var(--deep);
    --strip-ink: #f3f0fd;
    --strip-soft: #b9b2dc;
    --strip-key: #2e2459;
    --strip-key-edge: #0d0920;
    --strip-hl: #c4b5fd;
}

.tp-main { max-width: 860px; padding-top: 32px; padding-bottom: 48px; }
.tp-title { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; line-height: 1.35; margin: 0 0 10px; color: var(--ink); }
.tp-lede { color: var(--ink-soft); line-height: 1.8; margin: 0 0 18px; }

.tp-note {
    margin: 0 0 12px; padding: 10px 14px; font-size: .92rem; line-height: 1.7; color: var(--ink);
    background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
}

/* ── 輸入區 ── */
.tp-instrument {
    border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden;
    background: var(--surface); box-shadow: var(--shadow);
}
.tp-instrument:focus-within { border-color: var(--accent); box-shadow: var(--shadow-lift); }

/* 工具列 */
.tp-bar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.tp-bar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tp-pill {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; 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: .95rem; font-weight: 700; cursor: pointer;
}
.tp-pill:hover { border-color: var(--accent); }
.tp-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-press); }
.tp-pill-strong { background: var(--accent); border-color: var(--accent); color: #fff; }
.tp-pill-strong:hover { background: var(--accent-press); border-color: var(--accent-press); }
.tp-pill-small { min-height: 30px; min-width: 0; padding: 3px 12px; font-size: .85rem; }
.tp-pill-mic::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tp-pill-mic[aria-pressed="true"]::before { background: #e11d48; animation: tp-pulse 1.2s ease-in-out infinite; }
.tp-flash { font-size: .85rem; font-weight: 700; color: var(--accent); }

/* 文字框 */
.tp-editor {
    display: block; width: 100%; min-height: 168px; margin: 0; padding: 16px 18px; resize: vertical;
    border: 0; outline: none; background: var(--surface); color: var(--ink);
    font: inherit; font-size: 1.2rem; line-height: 1.85;
}
.tp-editor::placeholder { color: var(--muted); }

/* 組字列：深色顯示窗，固定高度（字碼＋候選、提示）；打開連續輸入時上面多一列整句。
   高度只在切換連續輸入開關時變，打字中不變 */
.tp-strip {
    display: grid; grid-template-rows: 48px 24px; row-gap: 2px;
    padding: 8px 16px 10px; background: var(--strip-bg); color: var(--strip-ink);
}
.tp-strip.has-sentence-row { grid-template-rows: 30px 48px 24px; }
.tp-strip-sentence { grid-row: 1; }
.tp-strip-main { grid-row: 1; }
.tp-strip-foot { grid-row: 2; }
.tp-strip.has-sentence-row .tp-strip-main { grid-row: 2; }
.tp-strip.has-sentence-row .tp-strip-foot { grid-row: 3; }
.tp-strip-sentence { display: flex; gap: 2px 8px; align-items: flex-end; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; }
.tp-strip-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tp-strip-foot { display: flex; align-items: center; gap: 12px; min-width: 0; overflow: hidden; white-space: nowrap; font-size: .85rem; color: var(--strip-soft); }

/* 字碼：一個字根一顆鍵帽 */
.tp-keys { display: inline-flex; flex: none; gap: 4px; }
.tp-keys:empty { display: none; }
.tp-key {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 30px; padding: 0 6px;
    border-radius: 6px; background: var(--strip-key); box-shadow: inset 0 -3px 0 var(--strip-key-edge);
    font-family: var(--font-mono); font-size: .95rem; font-weight: 700; letter-spacing: .02em; color: var(--strip-ink);
}
.tp-key-space { min-width: 14px; padding: 0; background: transparent; box-shadow: none; }
.tp-key-label { background: var(--strip-hl); color: var(--deep); box-shadow: none; font-family: var(--font-cjk); }
.tp-keys.tp-code-invalid .tp-key { background: #7f1d1d; box-shadow: inset 0 -3px 0 #450a0a; }

/* 候選：一列排開，太多就橫向捲，不換行（高度固定） */
.tp-items { display: flex; flex: 1 1 auto; gap: 2px; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--strip-key) transparent; }
.tp-items:empty { display: none; }
.tp-cand {
    display: inline-flex; flex: none; align-items: baseline; gap: 3px; padding: 4px 8px; cursor: pointer;
    border: 0; border-radius: 8px; background: transparent; color: var(--strip-ink);
    font-family: var(--font-cjk); font-size: 1.35rem; line-height: 1.3;
}
.tp-cand:first-child { background: rgba(196, 181, 253, .16); }
.tp-cand:hover, .tp-cand:focus-visible { background: var(--strip-key); outline: none; }
.tp-cand-empty { cursor: default; background: transparent !important; }
.tp-cand-empty .tp-cand-label { opacity: .45; }
.tp-cand-label { font-family: var(--font-mono); font-size: .7rem; color: var(--strip-soft); }
.tp-paging { flex: none; font-family: var(--font-mono); font-size: .78rem; color: var(--strip-soft); }
.tp-paging:empty { display: none; }

/* 沒在組字：顯示按鍵說明 */
.tp-idle { display: none; font-size: .9rem; color: var(--strip-soft); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-strip.is-idle .tp-idle { display: block; }

/* 連續輸入的整句：每個字上面小字標上碼 */
.tp-cell { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; }
.tp-cell-top { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .04em; color: var(--strip-hl); }
.tp-cell-ch { font-size: 1.1rem; color: var(--strip-ink); }

/* 提示列：引擎提示（快打、查詢選字後的打法）與送出後的規則碼 */
.tp-hint { overflow: hidden; text-overflow: ellipsis; color: var(--strip-ink); }
.tp-rulehint { overflow: hidden; text-overflow: ellipsis; }
.tp-rulehint a { color: inherit; text-decoration: none; }
.tp-rulehint a:hover .tp-rule-code, .tp-rulehint a:focus-visible .tp-rule-code { text-decoration: underline; }
.tp-rule-code { font-family: var(--font-mono); font-weight: 700; letter-spacing: .06em; color: var(--strip-hl); margin: 0 2px 0 6px; }
.tp-rule-tag { font-size: .72rem; color: var(--strip-soft); margin-right: 4px; }

/* 語音列：一直在，一行高 */
.tp-voice {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px;
    border-top: 1px solid var(--line); background: var(--surface); font-size: .9rem;
}
.tp-voice-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.tp-voice.is-listening .tp-voice-dot { background: #e11d48; animation: tp-pulse 1.2s ease-in-out infinite; }
.tp-voice-interim { flex: 1 1 auto; min-width: 0; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-voice-interim:empty::before { content: attr(data-idle); color: var(--muted); font-size: .82rem; }
.tp-voice-note { flex: none; font-weight: 700; color: #b91c1c; }
.tp-voice-note:empty { display: none; }
.tp-linkbtn { flex: none; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* 麥克風設定說明 */
.tp-mic-help {
    margin: 12px 0 0; padding: 14px 16px; font-size: .9rem; line-height: 1.75; color: var(--ink);
    background: var(--accent-soft); border-radius: var(--radius-sm);
}
.tp-mic-help p { margin: 0 0 6px; }
.tp-mic-url { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tp-mic-url code { padding: 4px 10px; border-radius: 6px; background: var(--surface); font-family: var(--font-mono); font-size: .88rem; color: var(--ink); word-break: break-all; }
.tp-mic-more { color: var(--ink-soft); font-size: .82rem; }

/* 資料狀態：輸入區下方一行小字，失敗時出現「重試」 */
.tp-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 10px 2px 0; font-size: .8rem; color: var(--muted); }
.tp-status-row { display: flex; gap: 6px; align-items: baseline; }
.tp-status-label { font-weight: 700; color: var(--ink-soft); }
.tp-status-text-failed { color: #b91c1c; font-weight: 700; }

/* 選項區 */
.tp-options {
    display: flex; flex-direction: column; gap: 10px; margin: 24px 0 8px; padding: 16px 20px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.tp-opt-switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); cursor: pointer; }
.tp-opt-switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.tp-opt-note { font-size: .82rem; font-weight: 400; color: var(--muted); }
.tp-opt-locked { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .92rem; color: var(--muted); }
.tp-opt-locked label { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.tp-pro { font-size: .8rem; }
.tp-app-hint { margin: 0; font-size: .9rem; color: var(--ink-soft); }

/* promo 與 attribution：查碼頁（zi.css）同款，原樣複製 */
.tp-promo { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; justify-content: space-between; padding: 18px 20px; margin: 8px 0 20px; border-radius: var(--radius); background: var(--accent-soft); }
.tp-promo p { margin: 0; flex: 1 1 260px; line-height: 1.7; color: var(--ink); }
.tp-attribution { font-size: .82rem; line-height: 1.75; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 16px; }
.tp-attribution p { margin: 0 0 8px; }
.tp-attribution a { text-decoration: underline; text-underline-offset: 3px; }

/* ── 輸入法切換列（五頁頁首）：一排像鍵帽列的分頁，目前這頁是按下去的那顆 ── */
.tp-imes { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.tp-imes a {
    display: inline-flex; align-items: center; min-height: 34px; padding: 4px 14px; border-radius: 8px;
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
    font-size: .92rem; font-weight: 700; text-decoration: none; box-shadow: inset 0 -2px 0 var(--line);
}
.tp-imes a:hover { border-color: var(--accent); color: var(--ink); }
.tp-imes a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-imes a[aria-current="page"] {
    background: var(--strip-bg); border-color: var(--strip-bg); color: var(--strip-ink);
    box-shadow: inset 0 -3px 0 var(--strip-key-edge);
}

/* ── 選項：字形、打法的分段按鈕 ── */
.tp-opt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tp-opt-label { min-width: 2.5em; font-weight: 700; color: var(--ink); }
.tp-seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); overflow: hidden; }
.tp-seg-btn {
    min-width: 48px; min-height: 36px; padding: 4px 14px; border: 0; border-left: 1px solid var(--line);
    background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem; font-weight: 700; cursor: pointer;
}
.tp-seg-btn:first-child { border-left: 0; }
.tp-seg-btn:hover { background: var(--surface-2); }
.tp-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tp-seg-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ── 自建輸入法：目前的碼表、清單、選檔 ── */
.tp-custom { margin: 0 0 16px; }
.tp-custom-current {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 12px 16px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.tp-custom-label { font-size: .85rem; color: var(--muted); }
.tp-custom-name { font-size: 1.05rem; color: var(--ink); }
.tp-custom-source { font-size: .85rem; color: var(--ink-soft); }
.tp-custom-source a { text-decoration: underline; text-underline-offset: 3px; }
.tp-custom-current .tp-pill { margin-left: auto; }
.tp-custom-picker { margin-top: 10px; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); }
.tp-custom-title { margin: 0 0 4px; font-size: 1.05rem; color: var(--ink); }
.tp-custom-note { margin: 0; font-size: .85rem; line-height: 1.7; color: var(--ink-soft); }
.tp-table-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin: 12px 0; padding: 0; list-style: none; }
.tp-table {
    display: flex; flex-direction: column; gap: 4px; width: 100%; height: 100%; padding: 10px 12px; text-align: left; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: inherit;
}
.tp-table:hover { border-color: var(--accent); }
.tp-table:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-table[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tp-table-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.tp-table-name { font-weight: 800; }
.tp-table-verified { padding: 0 6px; border-radius: 4px; background: var(--strip-bg); color: var(--strip-ink); font-size: .72rem; font-weight: 700; }
.tp-table-size { margin-left: auto; font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
.tp-table-desc { font-size: .85rem; line-height: 1.6; color: var(--ink-soft); }
.tp-custom-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tp-file-btn { position: relative; overflow: hidden; }
.tp-file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tp-file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-custom-msg { margin: 10px 0 0; font-size: .9rem; font-weight: 700; color: var(--accent-press); }
.tp-custom-msg.tp-custom-msg-error { color: #b91c1c; }

/* ── 入口頁：每張卡上方是一小段組字列，畫同一個「米」在這個輸入法的打法 ── */
.tp-gate-lead { margin: 8px 0 10px; font-weight: 700; color: var(--ink); }
.tp-gate-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 0 0 24px; padding: 0; list-style: none; }
.tp-gate-card {
    display: flex; flex-direction: column; height: 100%; overflow: hidden; text-decoration: none; color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.tp-gate-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-lift); }
.tp-gate-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.tp-gate-strip { display: flex; align-items: center; gap: 4px; min-height: 58px; padding: 12px 16px; background: var(--strip-bg); color: var(--strip-ink); }
.tp-gate-strip .tp-key { font-family: var(--font-cjk); }
.tp-gate-arrow { margin: 0 6px; color: var(--strip-soft); }
.tp-gate-char { font-family: var(--font-cjk); font-size: 1.5rem; line-height: 1; color: var(--strip-hl); }
.tp-gate-body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; }
.tp-gate-name { font-size: 1.15rem; font-weight: 800; }
.tp-gate-desc { font-size: .9rem; line-height: 1.7; color: var(--ink-soft); }
.tp-gate-source { margin-top: auto; font-size: .78rem; color: var(--muted); }
.tp-gate-card-custom { border-style: dashed; }
.tp-gate-note { font-size: .88rem; line-height: 1.75; color: var(--ink-soft); }
.tp-gate-note a { text-decoration: underline; text-underline-offset: 3px; }

@keyframes tp-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
    .tp-pill-mic[aria-pressed="true"]::before, .tp-voice.is-listening .tp-voice-dot { animation: none; }
    .tp-gate-card { transition: none; }
    .tp-gate-card:hover { transform: none; }
}

@media (max-width: 520px) {
    .tp-strip { padding: 8px 12px 10px; }
    .tp-editor { padding: 14px; font-size: 1.1rem; }
    .tp-voice { flex-wrap: wrap; align-items: flex-start; }
    .tp-voice-dot { margin-top: 7px; }
    /* 手機寬度：暫時結果與待機說明固定兩行高（隱私說明不能被截掉），按鈕換到下一行 */
    .tp-voice-interim {
        flex: 1 1 calc(100% - 18px); height: 2.9em; line-height: 1.45; white-space: normal;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    }
    .tp-voice-interim:empty::before { font-size: .8rem; }
    .tp-linkbtn { margin-left: 18px; }
}
