/* ============================================================
   PDF 工具箱（工具 → PDF 工具箱，2026-10-03）
   左：工具選單　中：工作區（縮圖格、單頁編輯）　右：選項面板＋輸出結果
   ≤1180px 工具選單變成上方橫向捲動；≤860px 單欄（選單 → 面板 → 工作區）
   ============================================================ */
.pt-page {
    padding: var(--space-lg) 0 var(--space-3xl);
    --pt-ok: #3fb37f; --pt-bad: #e0556a; --pt-paper: #ffffff;
    --pt-sel: var(--color-accent);
}
[data-theme="light"] .pt-page { --pt-ok: #23865a; --pt-bad: #c43a52; }
.pt-page .container { max-width: 1520px; }
.pt-page svg { flex: none; }
.pt-muted { color: var(--color-text-muted); }

/* ── 標題列（2026-10-03 精簡成一行：返回、標題、一句話說明、右邊隱私小膠囊） ── */
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; margin-bottom: 14px; position: relative; }
.pt-head-main { min-width: 0; flex: 1 1 420px; display: flex; align-items: baseline; gap: 12px; }
.pt-back { align-self: center; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--color-border);
    color: var(--color-text-secondary); flex: none; transition: color var(--transition-fast), border-color var(--transition-fast); }
.pt-back:hover { color: var(--color-accent); border-color: var(--color-accent); }
.pt-back svg { width: 15px; height: 15px; }
.pt-head h1 { font-size: 1.5rem; line-height: 1.2; white-space: nowrap; }
.pt-head p { min-width: 0; font-size: 0.84rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pt-privacy { flex: none; position: relative; font-size: 0.8rem; z-index: 20; }
.pt-privacy summary { display: flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer; color: var(--pt-ok); font-weight: 600; list-style: none; border-radius: 999px;
    background: color-mix(in srgb, var(--pt-ok) 10%, transparent); border: 1px solid color-mix(in srgb, var(--pt-ok) 35%, transparent); }
.pt-privacy summary::-webkit-details-marker { display: none; }
.pt-privacy summary::after { content: ''; width: 6px; height: 6px; margin: 0 2px 3px 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform var(--transition-fast); }
.pt-privacy[open] summary::after { transform: rotate(-135deg); margin-bottom: -3px; }
.pt-privacy summary svg { width: 16px; height: 16px; }
.pt-privacy-body { position: absolute; right: 0; top: calc(100% + 8px); width: min(420px, calc(100vw - 32px)); padding: 14px 16px; border-radius: var(--radius-lg);
    background: var(--dropdown-bg, var(--color-surface)); border: 1px solid color-mix(in srgb, var(--pt-ok) 35%, var(--color-border)); box-shadow: var(--shadow-lg);
    color: var(--color-text-secondary); line-height: 1.7; display: flex; flex-direction: column; gap: 6px; }

/* ── 三欄 ── */
.pt-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.pt-nav {
    position: sticky; top: calc(var(--navbar-height) + 12px); max-height: calc(100vh - var(--navbar-height) - 24px); overflow: auto;
    display: flex; flex-direction: column; gap: 2px; padding: 8px; scrollbar-width: thin;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
}
/* 工具搜尋（按 / 聚焦、Enter 開第一個） */
.pt-nav-search { position: sticky; top: -8px; z-index: 1; display: flex; align-items: center; gap: 6px; margin: -8px -8px 4px; padding: 8px 10px; background: var(--color-surface);
    border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); }
.pt-nav-search svg { width: 14px; height: 14px; }
.pt-nav-search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--color-text); font: inherit; font-size: 0.82rem; padding: 4px 0; }
.pt-nav-search input:focus { outline: none; }
.pt-nav-search:focus-within { color: var(--color-accent); }
.pt-nav-search kbd { font: inherit; font-size: 0.66rem; padding: 0 5px; border-radius: 4px; border: 1px solid var(--color-border); color: var(--color-text-muted); }
.pt-nav-search:focus-within kbd { display: none; }
.pt-nav-empty { font-size: 0.76rem; color: var(--color-text-muted); padding: 10px 8px; }
.pt-tool[hidden], .pt-tool-group[hidden] { display: none; }
.pt-tool-group { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; color: var(--color-text-muted); padding: 10px 8px 4px; text-transform: uppercase; }
.pt-tool-group:first-child { padding-top: 2px; }
.pt-tool {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border-radius: 9px; border: 0; background: transparent;
    color: var(--color-text-secondary); font: inherit; font-size: 0.84rem; text-align: left; cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.pt-tool svg { width: 17px; height: 17px; opacity: 0.85; }
.pt-tool:hover { background: var(--color-surface-elevated); color: var(--color-text); }
.pt-tool.is-active { background: var(--color-accent-soft); color: var(--color-accent); font-weight: 600; }
.pt-tool.is-active svg { opacity: 1; }
.pt-tool:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }

.pt-work { min-width: 0; }

/* 桌機＝固定高度的 App 殼（2026-10-03）：整頁剛好一個畫面高，三欄各自捲動；
   選項面板的主要按鈕因此永遠在畫面內（sticky 在 .pt-side 底部） */
@media (min-width: 1181px) {
    .pt-page { height: calc(100dvh - var(--navbar-height)); min-height: 560px; padding-bottom: 14px; display: flex; flex-direction: column; }
    .pt-page > .container { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
    .pt-layout { flex: 1; min-height: 0; align-items: stretch; }
    .pt-nav, .pt-side { position: static; max-height: none; height: 100%; }
    .pt-work { height: 100%; overflow: auto; scrollbar-width: thin; padding-right: 2px; overscroll-behavior: contain; }
    .pt-work .pt-bar { top: 0; }
    .pt-drop { height: 100%; }
    .pt-side { overscroll-behavior: contain; }
}
.pt-side {
    position: sticky; top: calc(var(--navbar-height) + 12px); max-height: calc(100vh - var(--navbar-height) - 24px); overflow: auto; scrollbar-width: thin;
    display: flex; flex-direction: column; gap: 12px; min-width: 0;
}

/* ── 面板 ── */
.pt-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
/* 選項面板：主要按鈕固定在面板底部，選項再長也不用捲到底才按得到 */
.pt-panel > .pt-actions { position: sticky; bottom: 0; z-index: 2; margin: 4px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--color-border);
    background: color-mix(in srgb, var(--color-surface) 92%, transparent); backdrop-filter: blur(8px); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.pt-panel > .pt-actions .pt-btn-primary { flex: 1 1 auto; }
.pt-panel h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.pt-panel h2 svg { width: 20px; height: 20px; color: var(--color-accent); }
.pt-panel h3 { font-size: 0.86rem; margin-bottom: 8px; }
.pt-desc { font-size: 0.8rem; color: var(--color-text-secondary); line-height: 1.65; }
.pt-hint { font-size: 0.74rem; color: var(--color-text-muted); line-height: 1.6; }
.pt-warn { font-size: 0.78rem; color: var(--pt-bad); line-height: 1.6; }
.pt-sub { border-top: 1px solid var(--color-border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.pt-sub h3 { margin-bottom: 0; }
.pt-sub-first { border-top: 0; padding-top: 0; }
.pt-more { border: 1px solid var(--color-border); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.pt-more[open] { padding-bottom: 12px; }
.pt-more summary { cursor: pointer; font-size: 0.82rem; color: var(--color-text-secondary); }
.pt-more[open] summary { margin-bottom: 6px; }

.pt-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pt-field > label, .pt-label { font-size: 0.76rem; color: var(--color-text-secondary); display: flex; align-items: center; gap: 6px; }
.pt-field output { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--color-text); }
.pt-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pt-inline { display: flex; gap: 8px; align-items: center; }
.pt-inline .pt-input { flex: 1; min-width: 0; }

.pt-input {
    width: 100%; min-height: 36px; padding: 6px 10px; border-radius: 9px;
    background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text);
    font-family: var(--font-primary); font-size: 0.85rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.pt-input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.pt-input.is-bad { border-color: var(--pt-bad); }
select.pt-input { padding-right: 6px; }
textarea.pt-input { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; line-height: 1.5; }
.pt-input-xs { width: 62px; min-height: 28px; padding: 2px 6px; display: inline-block; text-align: center; }
.pt-input-suffix { display: flex; align-items: center; gap: 6px; }
.pt-input-suffix span { font-size: 0.8rem; color: var(--color-text-muted); }
.pt-color { width: 44px; height: 36px; padding: 2px; border-radius: 9px; border: 1px solid var(--color-border); background: var(--color-bg); cursor: pointer; flex: none; }
.pt-panel input[type="range"] { width: 100%; accent-color: var(--color-accent); }

.pt-check { display: flex; align-items: flex-start; gap: 8px; font-size: 0.8rem; color: var(--color-text); line-height: 1.5; cursor: pointer; }
.pt-check input { margin-top: 3px; accent-color: var(--color-accent); width: 15px; height: 15px; flex: none; }

/* 分段選擇（radio） */
.pt-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 10px; align-self: flex-start; max-width: 100%; }
.pt-seg label { position: relative; cursor: pointer; }
.pt-seg input { position: absolute; opacity: 0; pointer-events: none; }
.pt-seg label > span { display: block; padding: 5px 10px; border-radius: 7px; font-size: 0.78rem; color: var(--color-text-secondary); white-space: nowrap; transition: background var(--transition-fast), color var(--transition-fast); }
.pt-seg label:hover > span { color: var(--color-text); }
.pt-seg input:checked + span { background: var(--color-accent); color: var(--color-accent-text); font-weight: 600; }
.pt-seg input:focus-visible + span { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.pt-seg-wrap { display: flex; }

.pt-radio-list { display: flex; flex-direction: column; gap: 4px; }
.pt-radio-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; font-size: 0.8rem; cursor: pointer; min-height: 36px; }
.pt-radio-list label:hover { background: var(--color-surface-elevated); }
.pt-radio-list label > input { accent-color: var(--color-accent); flex: none; }
.pt-radio-list label > span { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pt-radio-cards label { align-items: flex-start; border: 1px solid var(--color-border); padding: 8px 10px; }
.pt-radio-cards label > input { margin-top: 3px; }
.pt-radio-cards label > span { flex-direction: column; align-items: flex-start; gap: 2px; }
.pt-radio-cards label:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); }
.pt-radio-cards strong { font-size: 0.84rem; }
.pt-radio-cards small { font-size: 0.74rem; color: var(--color-text-secondary); line-height: 1.5; }

.pt-pos9 { display: grid; grid-template-columns: repeat(3, 26px); gap: 4px; padding: 6px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 10px; align-self: flex-start; }
.pt-pos9 button { width: 26px; height: 20px; border-radius: 4px; border: 1px solid var(--color-border); background: var(--color-surface); cursor: pointer; }
.pt-pos9 button.on { background: var(--color-accent); border-color: var(--color-accent); }

/* ── 按鈕 ── */
.pt-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 10px;
    border: 1px solid var(--color-border); background: var(--color-surface-elevated); color: var(--color-text);
    font: inherit; font-size: 0.84rem; font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}
.pt-btn svg { width: 16px; height: 16px; }
.pt-btn:hover:not(:disabled) { border-color: var(--color-accent); }
.pt-btn:active:not(:disabled) { transform: translateY(1px); }
.pt-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pt-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.pt-btn-primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-text); font-weight: 600; }
.pt-btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.pt-btn-ghost { background: transparent; }
.pt-btn-sm { min-height: 30px; padding: 4px 10px; font-size: 0.78rem; border-radius: 8px; }
.pt-btn-sm svg { width: 14px; height: 14px; }
.pt-btn.pt-danger, .pt-icon-btn.pt-danger { color: var(--pt-bad); }
.pt-btn.pt-danger:hover:not(:disabled) { border-color: var(--pt-bad); }
.pt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-actions .pt-btn-primary { flex: 1 1 auto; }
.pt-actions-top { margin-top: -2px; }
.pt-btn-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-btn-col { display: flex; flex-direction: column; gap: 6px; }
.pt-btn-col .pt-btn { justify-content: flex-start; }

.pt-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent;
    background: transparent; color: var(--color-text-secondary); cursor: pointer; transition: background var(--transition-fast), color var(--transition-fast);
}
.pt-icon-btn svg { width: 17px; height: 17px; }
.pt-icon-btn:hover:not(:disabled) { background: var(--color-surface-elevated); color: var(--color-text); }
.pt-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.pt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--color-border); background: transparent;
    color: var(--color-text-secondary); font: inherit; font-size: 0.76rem; cursor: pointer; }
.pt-chip svg { width: 13px; height: 13px; }
.pt-chip:hover { border-color: var(--color-accent); color: var(--color-text); }

/* ── 空狀態（拖放區） ── */
.pt-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
    min-height: 420px; padding: 40px 20px; border: 2px dashed color-mix(in srgb, var(--color-accent) 45%, var(--color-border)); border-radius: var(--radius-xl);
    background: var(--color-surface); cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast);
}
.pt-drop:hover, .pt-drop:focus-visible { border-color: var(--color-accent); background: var(--color-accent-soft); outline: none; }
.pt-drop > svg { width: 52px; height: 52px; color: var(--color-accent); margin-bottom: 4px; }
.pt-drop strong { font-size: 1.15rem; }
.pt-drop > span { font-size: 0.86rem; color: var(--color-text-secondary); }
.pt-drop small { font-size: 0.74rem; color: var(--color-text-muted); max-width: 420px; line-height: 1.6; }
.pt-drop.pt-pulse { animation: pt-pulse 0.7s ease; }
@keyframes pt-pulse { 0%, 100% { transform: none; } 30% { transform: scale(1.015); border-color: var(--color-accent); } }
.pt-drop-lock { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 5px 12px; border-radius: 999px; color: var(--pt-ok) !important;
    background: color-mix(in srgb, var(--pt-ok) 12%, transparent); font-size: 0.78rem !important; font-weight: 600; }
.pt-drop-lock svg { width: 15px; height: 15px; }

.pt-dropzone { position: fixed; inset: 0; z-index: 3000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    background: color-mix(in srgb, var(--color-bg) 82%, transparent); backdrop-filter: blur(4px); color: var(--color-accent); font-size: 1.3rem; font-weight: 700;
    border: 3px dashed var(--color-accent); pointer-events: none; }
.pt-dropzone svg { width: 64px; height: 64px; }

/* ── 檔案列 ── */
.pt-ws { display: flex; flex-direction: column; gap: 10px; }
.pt-files { display: flex; flex-wrap: wrap; gap: 6px; }
.pt-file {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 4px 4px 6px; border-radius: 10px;
    background: var(--color-surface); border: 1px solid var(--color-border); font-size: 0.78rem;
}
.pt-file-tag { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px;
    background: var(--c); color: #fff; font-weight: 700; font-size: 0.72rem; cursor: pointer; border: 0; }
.pt-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; cursor: pointer; }
.pt-file-meta { color: var(--color-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pt-file-lock { color: var(--color-accent); display: inline-flex; }
.pt-file-lock svg { width: 13px; height: 13px; }
.pt-file .pt-icon-btn { width: 24px; height: 24px; }
.pt-file .pt-icon-btn svg { width: 13px; height: 13px; }

/* ── 工具列 ── */
.pt-bar { display: flex; align-items: center; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 6px 10px; padding: 6px 8px; background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); position: sticky; top: calc(var(--navbar-height) + 8px); z-index: 5; backdrop-filter: blur(10px); }
.pt-bar-group { display: flex; align-items: center; gap: 2px; }
.pt-bar-group + .pt-bar-group { padding-left: 8px; border-left: 1px solid var(--color-border); }
.pt-bar-spacer { flex: 1; }
.pt-bar::-webkit-scrollbar { display: none; }
.pt-bar > * { flex: none; }
@media (max-width: 1360px) { .pt-bar-label { display: none; } }
@media (max-width: 1180px) { .pt-bar { flex-wrap: wrap; overflow: visible; } }
.pt-count { font-size: 0.76rem; color: var(--color-text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pt-zoom { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-muted); }
.pt-zoom svg { width: 14px; height: 14px; }
.pt-zoom input { width: 84px; accent-color: var(--color-accent); }

/* ── 縮圖格 ── */
.pt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--thumb), 1fr)); gap: 14px 12px; padding: 4px 2px 8px; }
.pt-card {
    position: relative; display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 6px; border-radius: 12px; cursor: pointer;
    background: var(--color-surface); border: 1px solid var(--color-border); user-select: none; -webkit-user-select: none; touch-action: manipulation;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.pt-card:hover { border-color: color-mix(in srgb, var(--color-accent) 50%, var(--color-border)); }
.pt-card.is-sel { border-color: var(--pt-sel); box-shadow: 0 0 0 2px var(--pt-sel); }
.pt-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1.3; border-radius: 6px; overflow: hidden;
    background: color-mix(in srgb, var(--color-text) 5%, transparent); }
.pt-thumb canvas { max-width: 100%; max-height: 100%; background: var(--pt-paper); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.pt-thumb canvas.is-loading { background: linear-gradient(110deg, #eee 30%, #f8f8f8 50%, #eee 70%); background-size: 200% 100%; animation: pt-shimmer 1.2s linear infinite; }
@keyframes pt-shimmer { to { background-position: -200% 0; } }
.pt-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 0.72rem; min-height: 18px; }
.pt-num { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-text); }
.pt-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pt-tag i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.pt-badge { position: absolute; top: 12px; left: 12px; padding: 1px 6px; border-radius: 6px; font-size: 0.66rem; font-weight: 700; background: rgba(0, 0, 0, 0.62); color: #fff; pointer-events: none; }
.pt-check-dot { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85); background: rgba(0, 0, 0, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity var(--transition-fast); pointer-events: none; }
.pt-card:hover .pt-check-dot, .pt-grid.has-sel .pt-check-dot { opacity: 1; }
.pt-card.is-sel .pt-check-dot { opacity: 1; background: var(--pt-sel); border-color: #fff; }
.pt-card.is-sel .pt-check-dot::after { content: ''; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.pt-card-acts { position: absolute; left: 50%; bottom: 32px; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; border-radius: 9px;
    background: color-mix(in srgb, var(--color-bg) 88%, transparent); border: 1px solid var(--color-border); opacity: 0; transition: opacity var(--transition-fast); }
.pt-card:hover .pt-card-acts, .pt-card:focus-within .pt-card-acts { opacity: 1; }
.pt-card-acts .pt-icon-btn { width: 26px; height: 26px; }
.pt-card-acts .pt-icon-btn svg { width: 14px; height: 14px; }
@media (hover: none) { .pt-card-acts { opacity: 1; bottom: 30px; } .pt-check-dot { opacity: 1; } }
.pt-card.sortable-ghost { opacity: 0.35; }
.pt-card.sortable-chosen { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); transform: scale(1.02); }
.pt-card.sortable-drag { opacity: 0.95; }

/* 拆分：每一份的起點 */
.pt-card[data-part] { border-top: 3px solid var(--pc); }
.pt-card.is-cut::before { content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px; border-radius: 2px; background: var(--pc); }
.pt-part { position: absolute; top: -10px; left: 8px; padding: 0 7px; border-radius: 6px; background: var(--pc); color: #fff; font-size: 0.66rem; font-weight: 700; line-height: 18px; pointer-events: none; }
.pt-cut { position: absolute; left: -17px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%; padding: 0; display: none;
    align-items: center; justify-content: center; background: var(--color-surface-elevated); border: 1px solid var(--color-border); color: var(--color-text-muted); cursor: pointer; z-index: 2; }
.pt-cut svg { width: 12px; height: 12px; }
.pt-cut:hover { color: var(--color-accent); border-color: var(--color-accent); }
.pt-grid.cut-mode .pt-cut { display: flex; }
.pt-grid.cut-mode .pt-card:first-child .pt-cut { display: none; }
.pt-card.is-cut .pt-cut { background: var(--pc, var(--color-accent)); color: #fff; border-color: transparent; }
.pt-grid.cut-mode { gap: 14px 22px; padding-left: 14px; }
.pt-grid-hint { font-size: 0.72rem; color: var(--color-text-muted); text-align: center; padding: 4px 0 8px; }

/* ── 單頁編輯 ── */
.pt-stage { display: flex; flex-direction: column; gap: 8px; }
.pt-stage-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.82rem; color: var(--color-text-secondary); }
.pt-stage-hint { margin-left: auto; font-size: 0.74rem; color: var(--color-text-muted); }
.pt-stage-view { display: flex; justify-content: center; padding: 16px; background: color-mix(in srgb, var(--color-text) 5%, transparent); border-radius: var(--radius-lg); overflow: auto; }
.pt-stage-page { position: relative; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); background: var(--pt-paper); line-height: 0; touch-action: none; }
.pt-stage-page canvas { display: block; }
.pt-stage-layer { position: absolute; inset: 0; }

.pt-crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(10, 8, 20, 0.5); outline: 2px solid var(--color-accent); cursor: move; }
.pt-stage-page.is-crop { overflow: hidden; }
.pt-h { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; background: #fff; border: 2px solid var(--color-accent); border-radius: 4px; touch-action: none; }
.pt-h[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; } .pt-h[data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
.pt-h[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; } .pt-h[data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.pt-h[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; } .pt-h[data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.pt-h[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; } .pt-h[data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }

.pt-ov { position: absolute; outline: 1.5px dashed var(--color-accent); cursor: move; touch-action: none; }
.pt-ov img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.pt-ov .pt-h { left: 100%; top: 100%; cursor: nwse-resize; }
.pt-ov-acts { position: absolute; right: -2px; top: -30px; display: flex; gap: 2px; line-height: normal; }
.pt-ov-acts button { height: 24px; min-width: 24px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--color-border); background: var(--color-surface-elevated);
    color: var(--color-text); font: inherit; font-size: 0.7rem; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.pt-ov-acts button svg { width: 12px; height: 12px; }
.pt-ov-acts button:hover { border-color: var(--color-accent); }

/* ── 簽名、印章庫 ── */
.pt-stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pt-stamp { position: relative; height: 64px; border-radius: 9px; border: 1px solid var(--color-border); background: #fff; cursor: pointer; padding: 6px; display: flex; align-items: center; justify-content: center; }
.pt-stamp img { max-width: 100%; max-height: 100%; }
.pt-stamp:hover { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }
.pt-stamp .pt-stamp-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--color-border);
    background: var(--color-surface-elevated); color: var(--color-text-secondary); display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.pt-stamp .pt-stamp-x svg { width: 11px; height: 11px; }

/* ── 頁碼列 ── */
.pt-num-rows { display: flex; flex-direction: column; gap: 6px; }
.pt-num-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) 30px; gap: 6px; align-items: center; }

/* ── 拆分預覽、資訊列表 ── */
.pt-plan { font-size: 0.78rem; color: var(--color-text-secondary); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 10px; padding: 8px 10px; max-height: 210px; overflow: auto; }
.pt-plan:empty { display: none; }
.pt-plan strong { color: var(--color-text); }
.pt-plan ol { margin: 6px 0 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }
.pt-plan li { display: flex; gap: 8px; align-items: baseline; }
.pt-plan li i { width: 8px; height: 8px; border-radius: 2px; background: var(--pc); flex: none; transform: translateY(-1px); }
.pt-plan li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-plan li em { margin-left: auto; font-style: normal; color: var(--color-text-muted); white-space: nowrap; }
.pt-plan.is-error { color: var(--pt-bad); border-color: var(--pt-bad); }

.pt-info-list, .pt-lock-list { display: flex; flex-direction: column; gap: 8px; }
.pt-info { border: 1px solid var(--color-border); border-radius: 10px; padding: 10px 12px; font-size: 0.76rem; }
.pt-info-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.82rem; margin-bottom: 6px; min-width: 0; }
.pt-info-head span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-info dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; margin: 0; }
.pt-info dt { color: var(--color-text-muted); }
.pt-info dd { margin: 0; overflow-wrap: anywhere; }
.pt-lock { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 10px; }
.pt-lock .pt-lock-state { margin-left: auto; font-size: 0.74rem; white-space: nowrap; }
.pt-lock .is-ok { color: var(--pt-ok); }

.pt-textout { display: flex; flex-direction: column; gap: 8px; }

/* ── 輸出結果 ── */
.pt-results { background: var(--color-surface); border: 1px solid color-mix(in srgb, var(--pt-ok) 45%, var(--color-border)); border-radius: var(--radius-lg); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.pt-results-head { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 600; color: var(--pt-ok); }
.pt-results-head svg { width: 17px; height: 17px; }
.pt-results-head .pt-icon-btn { margin-left: auto; width: 26px; height: 26px; color: var(--color-text-muted); }
.pt-results-note { font-size: 0.76rem; color: var(--color-text-secondary); line-height: 1.6; }
.pt-results-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.pt-result { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; padding: 4px 0; border-bottom: 1px solid var(--color-border-subtle); min-width: 0; }
.pt-result:last-child { border-bottom: 0; }
.pt-result-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt-result-size { color: var(--color-text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-result a { color: var(--color-accent); white-space: nowrap; }
.pt-results .pt-actions .pt-btn { flex: 1 1 auto; }

/* ── 進度 ── */
.pt-busy { position: fixed; inset: 0; z-index: 2500; display: flex; align-items: center; justify-content: center; background: rgba(6, 5, 15, 0.45); backdrop-filter: blur(2px); }
.pt-busy-card { width: min(360px, calc(100% - 32px)); padding: 22px 20px 16px; border-radius: var(--radius-lg); background: var(--color-surface-elevated); border: 1px solid var(--color-border);
    display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
[data-theme="light"] .pt-busy-card { background: var(--color-surface); }
.pt-busy.is-paused { visibility: hidden; }
.pt-spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--color-accent-soft); border-top-color: var(--color-accent); animation: pt-spin 0.8s linear infinite; }
@keyframes pt-spin { to { transform: rotate(360deg); } }
.pt-busy-text { font-size: 0.86rem; text-align: center; overflow-wrap: anywhere; }
.pt-progress { width: 100%; height: 6px; border-radius: 3px; background: var(--color-bg); overflow: hidden; }
.pt-progress-bar { height: 100%; width: 0; background: var(--color-accent); transition: width 0.15s; }

/* ── 對話框 ── */
/* 全站 reset（* { margin: 0 }）會把 <dialog> 預設的 margin: auto 清掉，彈窗就跑到左上角：這裡明確置中 */
.pt-dialog { position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100dvh - 32px); overflow: auto;
    border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface-elevated); color: var(--color-text);
    padding: 20px; width: min(420px, calc(100% - 32px)); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5); }
.pt-confirm-msg { font-size: 0.86rem; color: var(--color-text-secondary); line-height: 1.7; overflow-wrap: anywhere; }
.pt-btn-primary.is-danger { background: var(--pt-bad); border-color: var(--pt-bad); color: #fff; }
[data-theme="light"] .pt-dialog { background: var(--color-surface); }
.pt-dialog::backdrop, .pt-preview::backdrop { background: rgba(0, 0, 0, 0.55); }
.pt-dialog h3 { display: flex; align-items: center; gap: 8px; font-size: 1.02rem; margin-bottom: 10px; }
.pt-dialog h3 svg { width: 18px; height: 18px; color: var(--color-accent); }
.pt-dialog form { display: flex; flex-direction: column; gap: 10px; }
.pt-dialog-file { font-size: 0.8rem; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.pt-dialog-buttons { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pt-dialog-wide { width: min(720px, calc(100% - 24px)); }
.pt-sig-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.pt-sig-head h3 { margin: 0; }
.pt-sig-tools { display: flex; align-items: center; gap: 8px; }
.pt-sig-tools input { width: 90px; accent-color: var(--color-accent); }
.pt-swatch { width: 24px; height: 24px; border-radius: 50%; background: var(--c); border: 2px solid transparent; box-shadow: 0 0 0 1px var(--color-border); cursor: pointer; padding: 0; }
.pt-swatch.on { border-color: var(--color-surface-elevated); box-shadow: 0 0 0 2px var(--color-accent); }
.pt-sig-pad { position: relative; height: 240px; border-radius: 10px; background: #fff; overflow: hidden; touch-action: none; }
.pt-sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.pt-sig-line { position: absolute; left: 8%; right: 8%; bottom: 28%; border-bottom: 1.5px dashed #c9c4d6; pointer-events: none; }

.pt-preview { border: 0; padding: 0; margin: 0; inset: 0; background: transparent; width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; color: #fff; }
.pt-preview[open] { display: flex; flex-direction: column; }
.pt-preview-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: rgba(12, 10, 26, 0.85); font-size: 0.86rem; }
.pt-preview-bar .pt-icon-btn { color: #ddd; }
.pt-preview-bar .pt-icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.pt-preview-body { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 18px; }
.pt-preview-body canvas { box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6); background: #fff; }

/* ── 全螢幕工具模式（≥861px，2026-10-04）──
   整頁不捲動：高度＝視窗－導覽列，頁尾藏起來；只有工具選單、縮圖格（工作區）、選項面板各自捲。
   手機（≤860px）空間不夠排成一屏，維持一般整頁捲動。 */
@media (min-width: 861px) {
    body.pt-app-mode { height: 100dvh; overflow: hidden; }
    body.pt-app-mode .site-footer { display: none; }
    body.pt-app-mode main { animation: none; }
    .pt-app-mode .pt-page { height: calc(100dvh - var(--navbar-height)); padding: 12px 0; display: flex; flex-direction: column; }
    .pt-app-mode .pt-page > .container { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; }
    .pt-app-mode .pt-head { flex: none; margin-bottom: 10px; align-items: center; }
    .pt-app-mode .pt-head h1 { font-size: 1.4rem; }
    .pt-app-mode .pt-head p { font-size: 0.8rem; margin-top: 0; }
    .pt-app-mode .pt-back { display: none; }
    .pt-app-mode .pt-privacy { position: relative; z-index: 6; }
    .pt-app-mode .pt-privacy[open] .pt-privacy-body { position: absolute; right: 0; top: 100%; width: min(420px, 90vw); margin-top: 6px; padding-top: 12px;
        background: var(--color-surface-elevated); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4); }
    [data-theme="light"] .pt-app-mode .pt-privacy[open] .pt-privacy-body { background: var(--color-surface); }
    .pt-app-mode .pt-layout { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
    .pt-app-mode .pt-nav, .pt-app-mode .pt-side { position: static; max-height: none; height: 100%; overflow: auto; }
    .pt-app-mode .pt-work { height: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-gutter: stable; padding-right: 6px; }
    .pt-app-mode .pt-drop { height: 100%; min-height: 0; }
    .pt-app-mode .pt-bar { top: 0; }
    .pt-app-mode .pt-side { overscroll-behavior: contain; padding-bottom: 4px; }
    .pt-app-mode .pt-nav { overscroll-behavior: contain; }
}
@media (min-width: 861px) and (max-width: 1180px) {
    /* 工具選單變成上方一排：版面改成兩列（選單／內容） */
    .pt-app-mode .pt-layout { grid-template-rows: auto minmax(0, 1fr); }
    .pt-app-mode .pt-nav { height: auto; overflow-x: auto; overflow-y: hidden; }
}

/* ── 響應式 ── */
@media (max-width: 1180px) {
    .pt-layout { grid-template-columns: minmax(0, 1fr) 330px; }
    .pt-nav { grid-column: 1 / -1; position: static; max-height: none; flex-direction: row; overflow-x: auto; padding: 6px; gap: 4px; scrollbar-width: none; }
    .pt-nav::-webkit-scrollbar { display: none; }
    .pt-tool-group { display: none; }
    .pt-tool { width: auto; flex: none; white-space: nowrap; padding: 7px 11px; }
    .pt-nav-search { position: sticky; left: -6px; top: auto; margin: 0; flex: none; width: 150px; border-bottom: 0; border-right: 1px solid var(--color-border); padding: 4px 10px; }
    .pt-nav-search kbd, .pt-nav-empty { display: none; }
}
@media (max-width: 860px) {
    .pt-layout { grid-template-columns: minmax(0, 1fr); }
    .pt-side { position: static; max-height: none; overflow: visible; order: 1; }
    .pt-work { order: 2; }
    .pt-head h1 { font-size: 1.5rem; }
    .pt-privacy { flex-basis: 100%; }
    .pt-drop { min-height: 260px; }
    .pt-bar { top: calc(var(--navbar-height) + 4px); }
    .pt-zoom { display: none; }
    .pt-grid { gap: 10px 8px; }
    .pt-grid.cut-mode { gap: 10px 20px; }
    .pt-file-name { max-width: 140px; }
}
@media (max-width: 480px) {
    .pt-grid2 { grid-template-columns: 1fr; }
    .pt-bar-group + .pt-bar-group { padding-left: 4px; }
    .pt-panel { padding: 14px 12px; }
    .pt-stage-view { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .pt-spinner, .pt-thumb canvas.is-loading { animation: none; }
}

/* 壓縮預覽大小（2026-10-03） */
.pt-cmp-est { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--color-border); background: var(--color-surface-elevated); font-size: 0.82rem; color: var(--color-text-secondary); }
.pt-cmp-est[hidden] { display: none; }
.pt-cmp-est b { color: var(--color-text); font-variant-numeric: tabular-nums; }
.pt-cmp-arrow { color: var(--color-text-muted); }
.pt-cmp-pct { margin-left: auto; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pt-cmp-pct.is-good { color: #4fc37a; background: rgba(80, 200, 120, 0.12); }
.pt-cmp-pct.is-bad { color: var(--color-text-muted); background: var(--color-surface); }
