/* 會議庫單頁（explorer.js）——顏色、陰影沿用 app.css 的變數 */

.shell:has(.home) { max-width: 960px; }
.home .card + .card { margin-top: 16px; }

/* ── 上傳區：「放到」哪裡＋名稱、標籤 ── */
#new-job .file-to { display: block; }
.up-to { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 14px; }
.up-to-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--ink-2); }
.up-to-label svg { color: var(--accent); }
.up-path { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.up-path button {
  border: 0; background: none; padding: 3px 7px; border-radius: 8px; color: var(--accent);
  font: inherit; font-weight: 700; cursor: pointer;
}
.up-path button:hover { background: var(--accent-soft); }
.up-path b { padding: 3px 9px; border-radius: 8px; background: var(--surface); color: var(--accent); overflow-wrap: anywhere; box-shadow: 0 1px 3px rgba(40, 80, 130, .1); }
.up-note { color: var(--ink-3); font-size: 13px; }
.crumb-sep { color: var(--ink-3); }
.up-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.up-meta #nj-title { flex: 1; min-width: 160px; }

/* ── 會議庫：最上面一排（會議庫、搜尋、新增），下面是整棵樹 ── */
.lib { padding: 14px; }
.lib-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.lib-root {
  display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px 0 10px;
  border: 2px solid transparent; border-radius: 14px; background: none; color: var(--ink); font: inherit; font-size: 16px; cursor: pointer;
}
.lib-root .fold { width: 30px; height: 25px; }
.lib-root:hover { background: var(--surface-2); }
.lib-root.cur { background: var(--accent-soft); color: var(--accent); }
.lib-head .search-box { min-width: 200px; }
.lib-head .btn { height: 48px; }
.lib-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.lib-trash {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--ink-3); font: inherit; font-size: 13px; cursor: pointer;
}
.lib-trash:hover { background: var(--surface-2); color: var(--ink-2); }
.ex-empty { text-align: center; color: var(--ink-3); padding: 36px 16px; }
.ex-empty p { margin: 10px 0 0; }

/* ── 樹：一列一個東西，最前面是類型圖示，子層往右縮 ── */
.xlist { display: flex; flex-direction: column; gap: 1px; }
.xrow {
  position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 42px;
  padding: 4px 44px 4px calc(4px + var(--d, 0) * 24px); border-radius: 11px; color: var(--ink); cursor: pointer; user-select: none;
}
.xrow:hover { background: var(--surface-2); }
.xrow.cur { background: var(--accent-soft); }
.xrow.cur .tile-name { color: var(--accent); }
.xrow.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.xrow.dragging { opacity: .4; }
.xrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.xrow.flash { animation: xflash 1.8s ease-out; }
@keyframes xflash { 0%, 35% { background: color-mix(in srgb, var(--accent) 24%, transparent); } }
.xr-caret {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px;
  background: none; color: var(--ink-3); cursor: pointer; transition: transform .15s;
}
button.xr-caret:hover { background: var(--line); color: var(--ink); }
.xr-caret.open { transform: rotate(90deg); }
.xr-ico { position: relative; flex: none; width: 30px; height: 28px; display: grid; place-items: center; }
.xr-ico .fold { width: 30px; height: 25px; }
.ficon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.xr-text { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 14px; }
.xrow .tile-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xr-sub { flex: none; max-width: 48%; font-size: 12.5px; color: var(--ink-3); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-st { color: var(--accent); font-weight: 800; }
.tile-st.bad { color: var(--bad); }
.tile-more {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-3); cursor: pointer; opacity: 0; transition: opacity .12s;
}
.xrow:hover .tile-more, .xrow:focus-within .tile-more, .xrow.cur .tile-more, .xrow.sel .tile-more { opacity: 1; }
.tile-more:hover { background: var(--surface); color: var(--ink); }
@media (pointer: coarse) { .tile-more { opacity: 1; } }
.tile-edit {
  flex: 1; min-width: 0; max-width: 460px; padding: 3px 8px; border: 2px solid var(--accent); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 14px; outline: none;
}
/* 會議右下角的小徽章（錄影／錄音／YouTube）、處理中的小點 */
.fold-badge {
  position: absolute; right: -4px; bottom: -3px; width: 15px; height: 15px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(30, 60, 100, .2);
}
.fold-badge svg { width: 10px; height: 10px; }
.tile-dot {
  position: absolute; right: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); animation: pulse 1.6s infinite;
}
.xrow-empty { font-size: 13px; color: var(--ink-3); padding: 7px 0 7px calc(40px + var(--d, 0) * 24px); }
.xrow-empty.bad { color: var(--bad); }

/* 會議展開後最上面的狀態：處理進度、失敗原因 */
.xnote {
  display: grid; gap: 8px; margin: 2px 10px 4px calc(40px + var(--d, 0) * 24px); padding: 10px 12px;
  border-radius: 12px; background: var(--surface-2); font-size: 13.5px;
}
.xn-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.xn-line b { flex: 1; min-width: 0; font-weight: 700; }
.xnote .bar { height: 6px; margin: 0; }
.xn-warn { color: var(--ink-2); }
.xn-bad { color: var(--bad); font-weight: 700; }
.xn-muted { color: var(--ink-3); }

/* 拖曳目標 */
.drop-over { outline: 2.5px dashed var(--accent) !important; outline-offset: -2px; background: var(--accent-soft) !important; }

/* 加檔案的上傳進度（貼在畫面下緣） */
.ex-up {
  position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); margin-top: 16px; padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.ex-up .bar { height: 6px; margin: 0; }

/* 右鍵選單 */
.ctx {
  position: fixed; z-index: 60; min-width: 196px; padding: 6px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lift);
}
.ctx button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.ctx button:hover { background: var(--surface-2); }
.ctx button.danger { color: var(--bad); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* 搜尋結果：點了在樹上展開到那場 */
.search-list { display: grid; gap: 8px; }
.search-hit {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.search-hit:hover { border-color: var(--accent-2); }
.search-hit .fold { width: 40px; height: 32px; flex: none; }
.search-hit > span { display: flex; flex-direction: column; min-width: 0; }
.search-hit .snippet { font-size: 13px; color: var(--ink-2); }

/* 「移動到…」 */
.pick { max-height: 55vh; overflow: auto; padding: 6px; border: 1.5px solid var(--line); border-radius: 12px; }
.pick-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px 8px calc(10px + var(--d, 0) * 20px);
  border: 0; border-radius: 9px; background: none; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.pick-row:hover { background: var(--surface-2); }
.pick-row.on { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.pick-row .faint { margin-left: auto; font-size: 12px; font-weight: 400; }
.pick-row:disabled { color: var(--ink-3); cursor: default; background: none; }

/* 字幕、總結的檢視視窗 */
dialog.modal.viewer { width: min(880px, calc(100vw - 32px)); }
.viewer-body { margin-top: 8px; }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ficon { filter: brightness(.9) saturate(1.1); } }

/* 手機：縮排少一點，說明文字改到名稱下面 */
@media (max-width: 560px) {
  .lib { padding: 10px; }
  .lib-head .search-box { order: 3; flex-basis: 100%; }
  .lib-head .btn { margin-left: auto; }
  .xrow { padding-left: calc(2px + var(--d, 0) * 14px); padding-right: 40px; }
  .xr-text { flex-direction: column; align-items: stretch; gap: 0; }
  .xr-sub { max-width: 100%; text-align: left; }
  .xrow-empty { padding-left: calc(34px + var(--d, 0) * 14px); }
  .xnote { margin-left: calc(34px + var(--d, 0) * 14px); margin-right: 4px; }
}
.viewer-issues { margin-bottom: 14px; }
.viewer-issues ul { margin: 6px 0 0 20px; padding: 0; font-weight: 500; }

/* 逐字稿上方的「說話者」：說話者1 → 真名 */
.speakers { margin: 8px 0 12px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.spk-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 14px; }
.spk-head svg { color: var(--accent); }
.spk-head .faint { font-size: 12.5px; }
.spk-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 12px; margin-top: 10px; }
.spk { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.spk .input { min-height: 40px; height: 40px !important; padding: 6px 12px; border-radius: 11px; }
.spk select.input { font-size: 13px; }
.spk .input:disabled { opacity: .45; }
.spk b { font-size: 14px; word-break: break-word; }
.spk-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; }
.spk-foot .faint { font-size: 12.5px; margin-right: auto; }

/* ── 檢視切換（樹狀／資料夾／標籤） ── */
.lib-head .search-box { flex: 1; }
.view-seg { flex: none; }
.view-seg button { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; }
.it.dragging { opacity: .4; }
.it:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.xtile:hover .tile-more, .xtile:focus-within .tile-more, .xtile.sel .tile-more,
.xchip:hover .tile-more, .xchip:focus-within .tile-more, .xchip.sel .tile-more { opacity: 1; }

/* ── 資料夾檢視：路徑＋格子 ── */
.drv-path { display: flex; align-items: center; gap: 6px; min-height: 36px; margin: 0 0 12px; font-size: 14px; }
.drv-up {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center; padding: 0;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.drv-up svg { transform: rotate(180deg); }
.drv-up:hover { border-color: var(--accent-2); color: var(--accent); }
.drv-path .up-path button { border: 0; background: none; padding: 3px 7px; border-radius: 8px; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.drv-path .up-path button:hover { background: var(--accent-soft); }
.drv-path .up-path b { padding: 3px 9px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); overflow-wrap: anywhere; }
.drv-note { margin: 0 0 12px; }
.drv-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.xtile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  padding: 18px 10px 12px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface);
  text-align: center; cursor: pointer; user-select: none; transition: border-color .12s, box-shadow .12s;
}
.xtile:hover { border-color: var(--accent-2); box-shadow: 0 4px 14px rgba(40, 80, 130, .08); }
.xtile.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.xt-ico { position: relative; width: 68px; height: 64px; display: grid; place-items: center; margin-bottom: 6px; }
.xt-ico .fold { width: 68px; height: 56px; }
.xt-ico .ficon { width: 52px; height: 52px; border-radius: 15px; }
.xt-ico .ficon svg { width: 26px; height: 26px; }
.xt-ico .fold-badge { right: -2px; bottom: -2px; width: 22px; height: 22px; }
.xt-ico .fold-badge svg { width: 13px; height: 13px; }
.xt-ico.thumb { width: 100%; height: 64px; }
.xt-thumb { width: 100%; height: 64px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.xtile .tile-name {
  max-width: 100%; font-weight: 700; font-size: 14.5px; line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.xt-sub { max-width: 100%; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xtile .tile-more { top: 8px; right: 6px; transform: none; }
.xtile .tile-edit { width: 100%; text-align: center; }

/* ── 標籤檢視：會議、資料夾裡的檔案排成標籤 ── */
.xchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 10px 10px calc(40px + var(--d, 0) * 24px); }
.xchip {
  position: relative; display: inline-flex; align-items: center; gap: 9px; min-width: 0; max-width: 100%;
  padding: 7px 40px 7px 8px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
  cursor: pointer; user-select: none; transition: border-color .12s;
}
.xchip:hover { border-color: var(--accent-2); }
.xchip.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.xc-ico { flex: none; display: grid; }
.xc-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.xchip .tile-name { max-width: 240px; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xc-sub { max-width: 240px; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xchip .tile-more { right: 5px; width: 28px; height: 28px; }
.xchip .tile-edit { max-width: 220px; }

@media (max-width: 760px) {
  .drv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .view-seg button span { display: none; }
  .view-seg button { padding: 0 10px; }
}
@media (max-width: 560px) {
  .drv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lib-head .view-seg { order: 2; }
  .xchips { margin-left: calc(34px + var(--d, 0) * 14px); margin-right: 4px; }
  .xchip .tile-name, .xc-sub { max-width: 60vw; }
}

/* 換圖示 */
.icon-pick { display: grid; gap: 16px; }
.ip-label { font-size: 13px; font-weight: 800; color: var(--ink-2); margin-bottom: 8px; }
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.ip-btn {
  position: relative; height: 54px; display: grid; place-items: center; padding: 0;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer;
}
.ip-btn:hover { border-color: var(--accent-2); }
.ip-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.ip-btn .fold { width: 36px; height: 30px; }
.ip-btn .ficon { width: 34px; height: 34px; border-radius: 10px; }
.ip-btn .ficon svg { width: 20px; height: 20px; }

/* ── 手機（用手指點）：列高一點，「⋯」、展開箭頭、切換鈕都放大到手指點得準 ── */
@media (pointer: coarse) {
  .xrow { min-height: 48px; padding-right: 50px; }
  .xr-caret { width: 30px; height: 40px; }
  .tile-more { width: 44px; height: 44px; right: 2px; }
  .xchip { min-height: 48px; padding-right: 46px; }
  .xchip .tile-more { width: 42px; height: 42px; right: 1px; }
  .xtile .tile-more { width: 40px; height: 40px; top: 2px; right: 2px; }
  .view-seg button { min-width: 44px; height: 44px; justify-content: center; }
  .drv-up { width: 44px; height: 44px; }
  .drv-path .up-path button { min-height: 40px; }
  .lib-trash { min-height: 44px; padding: 8px 12px; }
  .pick-row { min-height: 48px; }
  .ctx button { min-height: 46px; font-size: 15px; }
  .search-hit { min-height: 56px; }
  .ip-btn { height: 56px; }
  .spk .input { height: 44px !important; min-height: 44px; }
  .tile-edit { font-size: 16px; min-height: 40px; }
}
/* 手機：最上面兩排就好——「會議庫」＋新增、檢視切換＋搜尋 */
@media (max-width: 560px) {
  .lib-head { gap: 8px; }
  .lib-head .lib-root { order: 1; }
  .lib-head .btn { order: 2; margin-left: auto; }
  .lib-head .view-seg { order: 3; }
  .lib-head .search-box { order: 4; flex: 1 1 0; min-width: 0; }
  .spk-list { grid-template-columns: 1fr; }
  .spk-foot { flex-wrap: wrap; }
  .spk-foot .btn { width: 100%; }
}

/* 手機的選單：從畫面下方滑出，滿版、選項大顆 */
.ctx-back { position: fixed; inset: 0; z-index: 59; background: rgba(20, 35, 55, .35); }
.ctx.sheet {
  left: 0; right: 0; top: auto; bottom: 0; min-width: 0; max-height: 82vh; overflow: auto;
  padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); border-width: 1.5px 0 0; border-radius: 22px 22px 0 0;
  animation: sheet-up .18s ease-out;
}
@supports (height: 100dvh) { .ctx.sheet { max-height: 82dvh; } }
.ctx.sheet button { min-height: 50px; padding: 10px 14px; border-radius: 12px; font-size: 15.5px; }
.ctx.sheet button svg { flex: none; color: var(--ink-3); }
.ctx.sheet button.danger svg { color: var(--bad); }
.ctx.sheet .ctx-cancel {
  position: sticky; bottom: 0; justify-content: center; margin-top: 6px; background: var(--surface-2); font-weight: 700;
  box-shadow: 0 -8px 12px var(--surface);
}
.ctx-grip { width: 40px; height: 5px; margin: 4px auto 4px; border-radius: 3px; background: var(--line); }
.ctx-title { padding: 8px 14px 6px; font-size: 13.5px; font-weight: 800; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes sheet-up { from { transform: translateY(30px); opacity: .5; } }
/* 展開箭頭：看起來一樣小，手指可以點的範圍往外撐大（不影響版面） */
@media (pointer: coarse) {
  button.xr-caret { position: relative; }
  button.xr-caret::before { content: ""; position: absolute; inset: -8px -6px; }
}
/* 手機：名稱太長就折成兩行，不要截成「客戶會議錄音 …」——字幕、總結、整理稿的差別在最後面 */
@media (max-width: 560px) {
  .xrow .tile-name, .xchip .tile-name {
    white-space: normal; overflow-wrap: anywhere; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  .xrow { padding-top: 6px; padding-bottom: 6px; }
}
/* 很窄的手機（iPhone SE 那種）：搜尋框自己一排 */
@media (max-width: 380px) {
  .lib-head .search-box { flex-basis: 100%; }
}
