/* 選圖／上傳面板 (picker.js; same layout as the hub's hub-web/picker.css, part118). Colours are the page's own tokens
   (style.css, light and dark): --bg panel, --surface tiles and pills, --accent selection, --line borders, --muted secondary text. */
dialog.bp{--bp-sel:var(--accent);--bp-onsel:var(--inverse);--bp-bad:#b3261e;--bp-pull:0px;
  border:1px solid var(--line);padding:0;margin:auto;width:min(640px,calc(100vw - 32px));max-width:none;height:min(660px,calc(100dvh - 48px));max-height:none;
  border-radius:24px;background:var(--bg);color:var(--ink);box-shadow:0 12px 40px #0000002e;overflow:hidden;font-size:15px;line-height:1.45;position:fixed}
:root[data-theme=dark] dialog.bp{--bp-bad:#ffb4ab}
dialog.bp[open]{display:flex;flex-direction:column;animation:bp-in .2s var(--ease-out,ease) backwards}
dialog.bp::backdrop{background:#0007}
dialog.bp:focus,dialog.bp:focus-visible{outline:none}
dialog.bp[open]::backdrop{animation:bp-fade .18s ease both}
dialog.bp *{box-sizing:border-box}
@keyframes bp-in{from{transform:translateY(10px)}to{transform:none}}
@keyframes bp-up{from{transform:translateY(48px)}to{transform:none}}
@keyframes bp-fade{from{opacity:0}to{opacity:1}}
.bp .bp-ic{width:20px;height:20px;flex:none}
.bp .bp-nb{white-space:nowrap}
.bp .bp-q{overflow-wrap:anywhere}
.bp-grab{display:none}

/* top: search pill + ✕ */
.bp-top{display:flex;align-items:center;gap:8px;padding:16px 16px 10px}
.bp-search{flex:1;min-width:0;display:flex;align-items:center;gap:10px;height:46px;padding:0 16px;border-radius:999px;background:var(--surface);color:var(--muted);cursor:text;transition:box-shadow .15s}
.bp-search:focus-within{box-shadow:0 0 0 2px var(--muted)}
.bp-search input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font:inherit;font-size:16px;outline:none!important;padding:0;height:100%}
.bp-search input::placeholder{color:var(--muted);opacity:1}
.bp-search input::-webkit-search-cancel-button{cursor:pointer}
.bp .bp-x{flex:none;width:44px;height:44px;border-radius:50%}
.bp .bp-x:hover{background:var(--hover)}

/* tabs: the page's own segmented control, full width */
.bp .bp-tabs{display:flex;width:auto;margin:0 16px 10px;justify-content:stretch}
.bp .bp-tabs button{flex:1;min-width:0;white-space:nowrap;padding:8px 6px}

.bp-body{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0 16px 12px;position:relative}
.bp-pane{min-height:100%}

/* photos: square tiles, 3 px apart, ~112 px minimum */
.bp-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(112px,1fr));gap:3px}
.bp-tile{position:relative;aspect-ratio:1/1;border:0;padding:0;margin:0;background:var(--surface);overflow:hidden;cursor:pointer;border-radius:6px;color:var(--ink);font:inherit;display:block;width:100%;min-width:0;
  transition:transform .1s;-webkit-tap-highlight-color:transparent}
.bp-tile:not(.bp-sk):active{transform:scale(.97)}
.bp-tile:focus-visible{outline:3px solid var(--bp-sel);outline-offset:-3px}
.bp-th{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:inset .12s,opacity .15s}
.bp-th img{width:100%;height:100%;object-fit:cover;display:block;opacity:0;transition:opacity .18s ease}
.bp-th.ready img{opacity:1}
.bp-th.now img{transition:none}
.bp-sk-th,.bp-sk{background:linear-gradient(100deg,var(--surface) 30%,var(--line) 50%,var(--surface) 70%) 0 0/300% 100%;animation:bp-shimmer 1.3s linear infinite}
.bp-sk{cursor:default}
.bp-sk-th>.bp-th-file{visibility:hidden}
@keyframes bp-shimmer{from{background-position:100% 0}to{background-position:0 0}}
.bp-th-file{display:flex;flex-direction:column;align-items:center;gap:4px;color:var(--muted)}
.bp-th-file .bp-ic{width:30px;height:30px}
.bp-ext{font-size:11.5px;font-weight:700;letter-spacing:.04em}
.bp-th-s .bp-th-file .bp-ic{width:22px;height:22px}
.bp-vid{position:absolute;left:6px;bottom:6px;display:inline-flex;align-items:center;gap:2px;padding:1px 7px 1px 3px;border-radius:999px;background:#0000008c;color:#fff;font-size:11.5px;font-variant-numeric:tabular-nums}
.bp-vid .bp-ic{width:14px;height:14px;fill:currentColor;stroke:none}
/* the circle: white-edged hollow ring (Telegram), the number when chosen */
.bp-badge{position:absolute;top:6px;right:6px;width:24px;height:24px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;
  font-size:13px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--bp-onsel);background:#0000002e;box-shadow:inset 0 0 0 2px #fff,0 1px 3px #0000004d;pointer-events:none}
.bp-tile.on .bp-badge{background:var(--bp-sel);box-shadow:0 0 0 2px #fff,0 1px 4px #0000004d}
.bp-tile.on .bp-badge:empty::after{content:"";width:6px;height:11px;border:solid var(--bp-onsel);border-width:0 2.4px 2.4px 0;transform:translateY(-1px) rotate(45deg)}
.bp-tile.on::after{content:"";position:absolute;inset:0;border:3px solid var(--bp-sel);border-radius:inherit;pointer-events:none}
.bp-tile.on .bp-th{inset:7px;border-radius:3px}
.bp-tile.off .bp-badge,.bp-tile.full .bp-badge{opacity:.45}
.bp-act .bp-badge,.bp-sk .bp-badge,.bp-tile.off .bp-badge,.bp-tile.off .bp-vid{display:none}
.bp-why:empty{display:none}
.bp-tile .bp-why{position:absolute;left:0;right:0;bottom:0;padding:18px 4px 7px;background:linear-gradient(transparent,#000000b8);color:#fff;font-size:12.5px;line-height:1.3;text-align:center;pointer-events:none;white-space:nowrap}
.bp-tile.off .bp-th{opacity:.42}
.bp-tile.off,.bp-row.off{cursor:not-allowed}
.bp-tile.full .bp-th{opacity:.6}
.bp-shake{animation:bp-shake .28s ease}
@keyframes bp-shake{25%{transform:translateX(-3px)}75%{transform:translateX(3px)}}
.bp-act{background:var(--surface);color:var(--ink)}
.bp-act:hover{background:var(--hover)}
.bp-act-in{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:7px;padding:6px;text-align:center}
.bp-act .bp-ic{width:28px;height:28px}
.bp-act-t{font-size:14px;font-weight:600;line-height:1.25;white-space:nowrap}

/* files / recent: rows */
.bp-rows{display:flex;flex-direction:column;gap:2px}
.bp-row{display:grid;grid-template-columns:44px minmax(0,1fr) 26px;align-items:center;gap:12px;width:100%;min-height:60px;padding:8px 10px;border:0;border-radius:14px;background:transparent;color:var(--ink);
  text-align:left;font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
.bp-row:not(.bp-sk-row):hover{background:var(--hover)}
.bp-row:not(.bp-sk-row):active{transform:scale(.99)}
.bp-row.on{background:var(--surface)}
.bp-row:focus-visible{outline:2px solid var(--bp-sel);outline-offset:-2px}
.bp-th-s{position:relative;inset:auto;width:44px;height:44px;border-radius:10px;background:var(--surface)}
.bp-row-t{display:flex;flex-direction:column;min-width:0;gap:1px}
.bp-name{display:flex;min-width:0;font-size:var(--tx-row,14.5px);font-weight:600;white-space:nowrap}
.bp-stem{min-width:0;overflow:hidden;text-overflow:ellipsis}
.bp-tail{flex:none}
.bp-meta{font-size:12.5px;color:var(--muted);font-variant-numeric:tabular-nums}
.bp-bad{color:var(--bp-bad)}
.bp-row.off .bp-th-s,.bp-row.off .bp-name{opacity:.55}
.bp-row .bp-badge{position:static;box-shadow:inset 0 0 0 2px var(--line);background:transparent}
.bp-row.on .bp-badge{background:var(--bp-sel);box-shadow:none}
.bp-row.on .bp-badge:empty::after{content:"";width:6px;height:11px;border:solid var(--bp-onsel);border-width:0 2.4px 2.4px 0;transform:translateY(-1px) rotate(45deg)}
.bp-row.off .bp-badge,.bp-row.full .bp-badge{opacity:.4}
.bp-sk-row{cursor:default}
.bp-sk-lines{height:14px;width:62%;border-radius:7px;background:linear-gradient(100deg,var(--surface) 30%,var(--line) 50%,var(--surface) 70%) 0 0/300% 100%;animation:bp-shimmer 1.3s linear infinite}

/* 〔瀏覽檔案〕〔管家的檔案庫〕: one grouped card like the settings rows */
.bp-browse-group{border:1px solid var(--line);border-radius:var(--radius-group,14px);overflow:hidden;margin:2px 0 6px}
.bp-browse{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:14px;width:100%;min-height:64px;padding:10px 16px;border:0;border-top:1px solid var(--line);
  background:var(--bg);color:var(--ink);font:inherit;text-align:left;cursor:pointer}
.bp-browse:first-child{border-top:0}
.bp-browse:hover{background:var(--hover)}
.bp-browse:active{background:var(--hover)}
.bp-browse:focus-visible{outline:2px solid var(--bp-sel);outline-offset:-2px}
.bp-browse-ic{width:36px;height:36px;border-radius:10px;background:var(--surface);display:grid;place-items:center}
.bp-browse-ic .bp-ic{width:20px;height:20px}
.bp-browse-t{display:flex;flex-direction:column;gap:2px;min-width:0}
.bp-browse-h{font-size:15.5px;font-weight:600}
.bp-browse-s{font-size:12.5px;color:var(--muted)}
.bp-label{font-size:var(--tx-label,12.5px);font-weight:600;color:var(--muted);margin:14px 4px 4px}

/* empty / no match */
.bp-nomatch{display:flex;flex-direction:column;align-items:center;gap:12px;padding:44px 12px 24px;text-align:center}
.bp-empty{display:block;color:var(--muted);font-size:14.5px;text-align:center;line-height:1.6}
.bp-fine{font-size:13.5px;padding:16px 8px 4px}
.bp-left{text-align:left;padding:8px 0}
.bp .bp-pill{width:auto;margin:0;min-height:40px;padding:6px 18px;border-radius:999px;text-align:center;font-weight:600}

/* footer: 已選／hint + main button */
.bp-foot{flex:none;display:flex;align-items:center;gap:12px;border-top:1px solid var(--line);padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px))}
.bp-sum{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.bp-count{font-weight:700;font-size:15.5px}
.bp-bad-line{color:var(--bp-bad)}
.bp-hint{color:var(--ink);font-size:14px}
.bp-extra{color:var(--muted);font-size:12.5px}
.bp .bp-go{flex:none;position:relative;min-height:46px;padding:0 24px;white-space:nowrap;font-size:15px}
.bp .bp-go:disabled{opacity:.35}
.bp .bp-go.busy{cursor:progress;opacity:1}
.bp .bp-spin{position:absolute;left:7px;top:50%;margin-top:-6px;width:12px;height:12px}
.bp-locked .bp-top,.bp-locked .bp-tabs,.bp-locked .bp-body,.bp-locked .bp-grab{pointer-events:none}
.bp-locked .bp-x,.bp-locked .bp-tabs,.bp-locked .bp-body{opacity:.55;transition:opacity .15s}

/* drop zone */
.bp-drop{position:absolute;inset:8px;z-index:5;display:flex;align-items:center;justify-content:center;border:2px dashed var(--muted);border-radius:18px;
  background:color-mix(in srgb,var(--surface) 92%,transparent);color:var(--ink);font-size:18px;font-weight:700;pointer-events:none}

/* phone width: a bottom sheet with a handle, 3 columns */
@media (max-width:600px){
  dialog.bp{width:100vw;height:88dvh;margin:auto 0 0;border:0;border-radius:22px 22px 0 0;transform:translateY(var(--bp-pull))}
  dialog.bp[open]{animation-name:bp-up;animation-duration:.24s}
  dialog.bp.bp-pulling{transition:none}
  .bp-grab{display:flex;flex:none;justify-content:center;padding:8px 0 2px;cursor:grab;touch-action:none}
  .bp-grab::before{content:"";width:40px;height:4px;border-radius:2px;background:var(--line)}
  .bp-top{padding:6px 12px 8px}
  .bp .bp-tabs{margin:0 12px 8px}
  .bp-body{padding:0 2px 10px}
  .bp-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .bp-tile{border-radius:0}
  .bp-rows,.bp-browse-group,.bp-empty,.bp-nomatch,.bp-label{margin-left:10px;margin-right:10px}
  .bp-foot{padding-left:14px;padding-right:14px}
}
@media (prefers-reduced-motion:reduce){dialog.bp[open],dialog.bp[open]::backdrop,.bp-th img,.bp-sk,.bp-sk-th,.bp-sk-lines,.bp-shake{animation:none;transition:none}}
