:root {
  /* seedoes light palette — warm off-white canvas, editorial minimalism */
  --bg: #EEEDE8;
  --panel: #FFFFFF;
  --panel-2: #F5F5F2;
  --text: #444444;
  --text-strong: #1A1A1A;
  --muted: #888888;
  --accent: #1A1A1A;            /* Brand: pure ink accent */
  --accent-hover: #000000;
  --accent-fg: #FFFFFF;         /* Text on dark-accent surfaces */
  --accent-soft: rgba(26, 26, 26, 0.08);
  --accent-2: #2C7A5E;          /* Muted forest for success */
  --warn: #B89642;              /* Muted ochre */
  --error: #B45A57;             /* Muted brick */
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.18);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.25);

  /* seedoes-specific tokens */
  --seedoes-canvas: #EEEDE8;
  --seedoes-ink: #1A1A1A;
  --seedoes-muted: #888888;
  --seedoes-sidebar-w: 72px;
  --seedoes-header-h: 64px;
  --seedoes-content-max: 1280px;
  --seedoes-radius: 4px;
  --seedoes-radius-lg: 12px;
  /* Neumorphism：spread 10 + 大 blur 保持柔化；高光/陰影 opacity 加強 */
  --neu-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    -4px -4px 22px 10px rgba(255, 255, 255, 0.55),
     8px  8px 34px 10px rgba(140, 143, 146, 0.45);
  --neu-shadow-focus:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    -2px -2px 14px 6px rgba(255, 255, 255, 0.42),
     5px  5px 22px 6px rgba(140, 143, 146, 0.38);
}

/* Dark theme override — activated by html[data-theme="dark"]. Keeps the
   same variable names so no other CSS needs a duplicate. Chosen for
   comfortable long-viewing (not pure black), preserving the "有品"
   minimalist warmth in dark. */
html[data-theme="dark"] {
  --bg: #141414;
  --panel: #1E1E1E;
  --panel-2: #262626;
  --text: #C8C6C4;              /* light warm grey text */
  --text-strong: #F0EDEA;       /* near-white for headings */
  --muted: #7A7876;
  --accent: #B8B4B0;            /* light accent on dark surfaces */
  --accent-hover: #E5E1DD;
  --accent-fg: #1E1E1E;         /* text on light-accent (inverted) */
  --accent-soft: rgba(255,255,255,0.06);
  --accent-2: #8FAB8B;          /* olive brightened for dark */
  --warn: #D4B26E;
  --error: #D68A87;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.6);
  /* 深色模式：暗底 + 微白高光 + 深黑陰影，比較內斂避免發光感 */
  --neu-shadow:
    -4px -4px 10px rgba(255, 255, 255, 0.03),
     6px  6px 14px rgba(0, 0, 0, 0.55);
  --neu-shadow-focus:
    -3px -3px  8px rgba(255, 255, 255, 0.025),
     4px  4px 10px rgba(0, 0, 0, 0.45);
}
/* Dark theme — modal backdrop needs a different blur tint. The default
   uses a light overlay which reads wrong on dark. */
html[data-theme="dark"] .modal-backdrop {
  background: rgba(20, 20, 20, 0.85);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Noto Sans TC", "PingFang TC", "PingFang", "Microsoft JhengHei",
               -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Override the OS-default blue for native form controls (checkbox tick,
     radio dot, focus ring) with the brand dark grey. */
  accent-color: var(--text-strong);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--text-strong); }
/* Kill the global input:focus ring/outline on checkboxes & radios — they
   look ugly as a dark halo around the box. The accent-color tint already
   shows the checked state clearly. */
input[type="checkbox"]:focus,
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus,
input[type="radio"]:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
}

/* Custom checkbox style for the search axis row — replaces the default
   black system frame with a soft light-grey box that fills dark when
   checked. Keeps native click semantics. */
.axes input.axis-cb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 14px;
  height: 14px;
  border: none !important;
  border-radius: 3px;
  background: #fff !important;
  cursor: pointer;
  position: relative;
  margin: 0 4px 0 0;
  padding: 0 !important;
  vertical-align: middle;
  transition: background 0.12s;
}
.axes input.axis-cb:checked {
  background: var(--text-strong) !important;
}
/* Dark theme: white boxes on dark bg look harsh. Use dark grey instead;
   filled state stays light so the check symbol still reads clearly. */
html[data-theme="dark"] .axes input.axis-cb {
  background: #3A3A3A !important;
}
html[data-theme="dark"] .axes input.axis-cb:checked {
  background: var(--text-strong) !important;   /* light fill */
}
html[data-theme="dark"] .axes input.axis-cb:checked::after {
  border-color: var(--bg) !important;   /* dark check on light fill */
}
.axes input.axis-cb:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

h1, h2, h3 { letter-spacing: 0.02em; font-weight: 400; }
h2 { font-size: 18px; font-weight: 400; margin: 18px 0 12px; color: var(--text-strong); }
h3 { font-size: 12px; font-weight: 500; color: var(--muted);
     letter-spacing: 0.1em; margin: 22px 0 10px; }

a { color: var(--accent-2); }

/* UPHiN topbar — centered logo, hamburger on right */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 28px 12px;
  background: var(--bg);
}
.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand svg { display: block; width: 84px; height: auto; color: var(--text-strong); }
/* Left cluster of the topbar: health line on top, scan status under it.
   Positioning lives on the wrapper so the two stay stacked no matter how
   long the health string gets. */
.topbar-left {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.health {
  font-size: 11px;
  color: var(--muted);
}
.scan-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
/* Stale = nothing has scanned for a while (or a folder was never scanned).
   Amber rather than red: it's informational, not an error. */
.scan-status.stale #scan-status-text { color: var(--warn); }
.scan-status.scanning #scan-status-text { color: var(--accent-2); }
.scan-status button {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.scan-status button:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--text-strong);
}
.scan-status button:disabled { opacity: 0.45; cursor: default; }
.hamburger {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
  transition: background 0.15s;
}
.hamburger:hover { background: var(--accent-soft); border-color: transparent; }
/* Hamburger never animates / shifts on press — override every interaction
   state from the generic button rules. */
.hamburger,
.hamburger:hover,
.hamburger:active,
.hamburger:focus,
.hamburger:focus-visible {
  transform: none !important;
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.hamburger svg {
  width: 22px;
  height: 14px;
  color: var(--text-strong);
}

/* Tree-row icons：實心 SVG 在 12px 太重，opacity 收斂讓它變柔和 */
.tree-icon svg {
  width: 12px;
  height: 10px;
  color: var(--muted);
  opacity: 0.55;
  vertical-align: middle;
}
/* Folder has pending or error videos → 加深提示，但同樣保留透明度 */
.tree-icon.has-pending svg {
  color: var(--text-strong);
  opacity: 0.75;
}
.tree-icon-btn svg { width: 12px; height: 12px; }
.tree-icon-btn.danger svg { width: 11px; height: 12px; }

/* Underline tabs, centered */
.tabs {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 0 28px 4px;
  background: var(--bg);
}

/* ====== 專案頁：左清單 + 右內容 ====== */
.projects-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  /* width:100% 保證整區無論內容多寡都撐滿 <main>，右邊 1fr 才會穩定 */
  width: 100%;
  min-height: calc(100vh - 200px);
}
.projects-sidebar {
  border-right: 1px solid var(--border);
  padding-right: 20px;
  min-width: 0;
}
.projects-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 12px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.05em;
}
.projects-sidebar-head button {
  background: transparent;
  border: none;
  color: var(--text-strong);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
}
.projects-sidebar-head button:hover { background: var(--accent-soft); }
.projects-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.project-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
.project-row:hover { background: var(--accent-soft); }
.project-row.selected {
  background: var(--accent-soft);
  color: var(--text-strong);
  font-weight: 600;
}
.project-row .count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.projects-sidebar-empty {
  padding: 16px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.projects-main {
  min-width: 0; /* let grid contents shrink so the frame grid doesn't overflow */
}
.projects-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.projects-empty p { margin: 6px 0; }

.projects-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  gap: 20px;
}
.projects-detail-name {
  font-size: 18px;
  font-weight: 300;
  color: var(--text-strong);
}
.projects-detail-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.projects-detail-actions button { font-size: 12px; }

/* 專案內的截圖 grid：跟搜尋卡類似但更緊湊，每張右上有 ✕ 移除 */
.projects-frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.project-frame-card {
  position: relative;
  /* box-shadow + 微微上移的 hover；捲動時 body.is-scrolling 一起關掉 */
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
  contain: layout paint;
}
.project-frame-card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
body.is-scrolling .project-frame-card { pointer-events: none; }
body.is-scrolling .project-frame-card:hover {
  box-shadow: none;
  transform: none;
}
.project-frame-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
}
.project-frame-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.project-frame-time {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 10px;
  padding: 1px 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 2px;
}
.project-frame-remove,
.project-frame-download {
  position: absolute;
  top: 5px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s;
}
.project-frame-remove { right: 5px; }
.project-frame-download { right: 37px; }
.project-frame-card:hover .project-frame-remove,
.project-frame-card:hover .project-frame-download { opacity: 1; }
.project-frame-remove:hover { background: var(--error, #B45A57); }
.project-frame-download:hover { background: var(--accent, #3b82f6); }
.project-frame-body {
  padding: 10px 12px 14px;
}
.project-frame-title {
  font-size: 12px;
  color: var(--text-strong);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.project-frame-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.projects-frames-empty {
  grid-column: 1 / -1;
  /* 讓空狀態的文字排版跟有截圖時的 grid 對齊：左對齊、無外距 */
  padding: 4px 0;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ====== Modal 開關的淡入 + 微微放大過場 ======
   只套用在 #ui-modal 上（其他 modal 例如 player-modal、frames-modal 用直接
   顯示，不套動畫，避免全透明看不見造成點擊被擋）。 */
#ui-modal {
  opacity: 0;
  transition: opacity 0.22s ease-out;
}
#ui-modal.showing { opacity: 1; }
#ui-modal .modal-card {
  transform: scale(0.94);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
#ui-modal.showing .modal-card { transform: scale(1); }

/* ====== 分鏡 tab：使用專案 chip（brief 下方左側，小圓角矩形） ====== */
.sb-project-bar {
  display: flex;
  justify-content: flex-start;
  padding: 10px 0 0;
}
.sb-project-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--panel);
  border: none;
  border-radius: 6px;
  color: var(--text-strong);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.sb-project-chip:hover { background: var(--panel-2); }
.sb-project-chip-label { color: var(--muted); }
/* caret 隱藏（保留 DOM 以防後續要恢復） */
.sb-project-chip-caret { display: none; }

/* ====== 通用 UI Modal（取代 alert / prompt / confirm） ====== */
.ui-modal-card {
  width: min(380px, 92vw) !important;
  max-width: min(380px, 92vw);
  padding: 0;
  overflow: hidden;
}
.ui-modal-body {
  padding: 20px 22px 8px;
}
.ui-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 10px;
}
.ui-modal-message {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 4px;
  white-space: pre-wrap;
}
.ui-modal-input {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--bg);
  /* 與 atp-search 一致：小圓角矩形 + 細邊，聚焦才變深 */
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text-strong);
  transition: border-color 0.15s, background 0.15s;
}
/* hidden 屬性要顯式蓋 display: block，否則 alert 模式仍會看到輸入框 */
.ui-modal-input[hidden] { display: none !important; }
.ui-modal-input:focus {
  border-color: var(--border-strong);
  background: var(--panel);
}
.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px;
}
.ui-modal-actions button {
  padding: 8px 18px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.ui-modal-actions button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.ui-modal-actions button.ghost:hover {
  color: var(--text-strong);
  border-color: var(--border-strong);
}
.ui-modal-actions button.primary {
  background: transparent;
  color: var(--text-strong);
  border-color: transparent;
  font-weight: 600;
}
.ui-modal-actions button.primary:hover {
  background: var(--accent-soft);
  border-color: transparent;
}
.ui-modal-card[data-mode="alert"] .ui-modal-actions button.ghost { display: none; }

/* ====== 加到專案 Picker — 錨定在圖片旁的浮動彈窗 ====== */
.atp-popover {
  position: fixed;
  width: 300px;
  max-height: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 13px;
  /* 淡入 + 微微放大過場 */
  opacity: 0;
  transform: scale(0.96);
  transform-origin: top right;
  transition: opacity 0.2s ease-out, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.atp-popover.showing {
  opacity: 1;
  transform: scale(1);
}
/* HTML hidden 屬性需要顯式蓋掉上面的 display: flex，否則 X 沒作用 */
.atp-popover[hidden] { display: none !important; }
.atp-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 8px 4px;
}
.atp-title {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 13px;
}
.atp-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.atp-close:hover { color: var(--text-strong); }
.atp-search-row {
  padding: 0 12px 8px;
}
.atp-search-row input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--bg);
  /* 拿掉深色框、改小圓角矩形 —— 符合 UPHiN 主搜尋 bar 的節奏 */
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text-strong);
  transition: border-color 0.15s, background 0.15s;
}
.atp-search-row input:focus {
  border-color: var(--border-strong);
  background: var(--panel);
}
.atp-list {
  flex: 1;
  overflow-y: auto;
  /* 左右內距對齊搜尋 bar 與新增專案按鈕，讓三個 bar 齊寬 */
  padding: 4px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.atp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-strong);
  transition: background 0.12s;
}
.atp-row:hover { background: var(--accent-soft); }
.atp-row.current { background: var(--accent-soft); }
.atp-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.atp-row .meta {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.atp-row.in-project .meta {
  color: var(--accent-2);
  font-weight: 500;
}
.atp-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.atp-new-row {
  padding: 8px 12px 12px;
  border-top: 1px solid var(--border);
}
.atp-new-row button {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-strong);
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.atp-new-row button:hover { background: var(--accent-soft); }

/* Search card：加到專案按鈕（跟下載按鈕並排） */
.search-card-addproj {
  position: absolute;
  top: 6px;
  right: 40px;   /* 下載按鈕在 right:6，這顆在它左邊 */
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  cursor: pointer;
  padding: 0;
}
.search-card:hover .search-card-addproj { opacity: 1; }
.search-card-addproj:hover { background: var(--accent, #3b82f6); }
.tab {
  position: relative;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 10px 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-strong); }
/* 完全不顯示 focus 框：active 底線已經足夠當狀態指示 */
.tab:focus,
.tab:focus-visible { outline: none; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  height: 1px;
  background: var(--text-strong);
}

/* Hamburger drawer (slides in from right) */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease-out;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  /* 3/4 螢幕寬（使用者偏好），floor 480px 確保窄螢幕仍好讀 */
  width: max(480px, 75vw);
  max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 1060;
  transform: translateX(100%);
  /* 從 0.22s 慢到 0.45s + cubic-bezier 讓出場更絲滑 */
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.drawer.open { transform: translateX(0); }
/* 關閉鈕定位到抽屜的右上角 — 因為 drawer 貼齊 viewport 右邊，
   right/top 座標會跟 header 的 hamburger 視覺上對齊。
   hamburger 在 topbar 中垂直置中，實測 top ≈ 34px 對齊最準。 */
/* 定位到抽屜的右上角，樣式沿用 .uph-iconbtn（跟搜尋 bar 的 X 一致） */
.drawer-close {
  position: absolute;
  top: 34px;
  right: 24px;
  z-index: 1;
}
/* body 上邊留給 X 的空間；下方保留原來的透氣 */
.drawer-body { padding: 72px 32px 40px; }

/* 只針對外層 <body > main>，避免影響巢狀的 <main class="projects-main"> */
body > main {
  padding: 24px 28px 56px;
  max-width: 1240px;
  margin: 0 auto;
}
/* 內層專案主欄：撐滿 grid 的 1fr，讓標題位置在空/滿都一致 */
.projects-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.panel { display: none; }
.panel.active { display: block; }

h2 { margin-top: 0; }

.hint { color: var(--muted); font-size: 12px; }

input, textarea, select {
  font-family: inherit;
  font-size: 13px;
  background: var(--panel);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.55;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  /* User preference: no focus indicator beyond the cursor itself. Border
     stays the same as resting state, no halo shadow, no dark line. */
  border-color: var(--border);
  box-shadow: none;
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  background: var(--panel);
  color: var(--text-strong);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.06s;
  letter-spacing: 0.04em;
}
button:hover {
  background: var(--accent-soft);
  border-color: var(--text-strong);
}
button:active { transform: translateY(1px); }
button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
/* Ghost: minimal, no border */
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
button.ghost:hover {
  color: var(--text-strong);
  border-color: transparent;
  background: var(--accent-soft);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
  flex-wrap: wrap;
}

.row > label { color: var(--muted); font-size: 12px; }

#folder-path { flex: 1; min-width: 280px; }

/* Folder-add bar uses the same shell as the search bar (.uph-search). The
   add-folder-plus glyph sits inside on the right, matching the search
   page's X / 🔍 / 🖼 icon row in size + spacing. */
.uph-folder-add { margin: 32px auto 12px; }
.add-folder-plus {
  font-size: 22px !important;
  font-weight: 300;
  line-height: 1;
  /* override .uph-iconbtn color so the + reads as muted-then-strong */
  color: var(--muted);
}
.add-folder-plus:hover {
  color: var(--text-strong) !important;
}

/* Compact folder summary (replaces old card grid) */
.folder-summary { margin-top: 12px; }
.folder-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 10px 0;
  transition: border-color 0.15s, background 0.15s;
}
.folder-row:hover { border-color: var(--border-strong); }
.folder-info { min-width: 0; flex: 1; }
.folder-row-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  word-break: break-all;
}
.folder-row-path {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-all;
}
.folder-row-stats {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.folder-row-stats .stat-ok { color: var(--accent-2); }
.folder-row-stats .stat-pending { color: var(--warn); }
.folder-row-stats .stat-running { color: var(--accent); }
.folder-row-stats .stat-error { color: var(--error); }
.folder-row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Work queue — UPHiN minimal line + progress bar */
.wq-title { display: none; }   /* mockup hides the heading */
#work-queue {
  background: transparent;
  border: none;
  padding: 0;
  margin: 18px 0 14px;
}
.wq-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text);
}
.wq-line-stats { color: var(--text-strong); }
.wq-line-actions { display: flex; gap: 6px; }
.wq-line-actions button {
  font-size: 11px;
  padding: 4px 10px;
}
.wq-progress {
  height: 2px;
  margin-top: 6px;
  background: rgba(0,0,0,0.12);
  border-radius: 1px;
  overflow: hidden;
}
.wq-progress-fill {
  height: 100%;
  background: #FFFFFF;
  transition: width 0.25s ease;
}
.stat-error { color: var(--error); }

/* DAM per-row tag button */
.dam-meta-actions {
  margin-top: 6px;
}
.dam-meta-actions button {
  font-size: 11px;
  padding: 4px 10px;
}
.dam-meta-actions button:disabled { opacity: 0.6; cursor: not-allowed; }

/* Clickable video name in DAM rows */
.dam-name-clickable {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: color 0.12s, border-color 0.12s;
}
.dam-name-clickable:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Frames-detail modal */
.frames-modal-card { width: min(960px, 92vw); max-height: 92vh; }
#frames-modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.frame-detail-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.frame-detail-row:last-child { border-bottom: none; }
.frame-detail-thumb {
  position: relative;
  width: 200px;
  height: 113px;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}
.frame-detail-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame-detail-thumb:hover { border-color: var(--accent); }
.frame-detail-time {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
}
/* 下載按鈕：hover 縮圖才浮出，不干擾主要的縮圖點擊 */
.frame-detail-download {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  text-decoration: none;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  cursor: pointer;
}
.frame-detail-thumb:hover .frame-detail-download { opacity: 1; }
.frame-detail-download:hover { background: var(--accent, #3b82f6); }
.frame-detail-tags {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.tag-line {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  align-items: baseline;
}
.tag-key {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  padding-right: 4px;
  border-right: 1px solid var(--border);
}
.tag-val {
  color: var(--text);
  word-break: break-word;
  line-height: 1.5;
}

.folder-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.folder-path {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 400;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  color: var(--muted);
  letter-spacing: 0.04em;
}
.badge.done { background: rgba(89,87,87,0.10); color: var(--text); }
.badge.pending { background: rgba(184,150,66,0.14); color: var(--warn); }
.badge.tagging { background: var(--accent-soft); color: var(--text-strong); }
.badge.error { background: rgba(180,90,87,0.14); color: var(--error); }

/* DAM (Digital Asset Management) browser */
.dam-title { margin: 32px 0 8px; }
.dam-browser {
  --dam-tree-width: 260px;
  display: grid;
  grid-template-columns: var(--dam-tree-width) 5px 1fr;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
  min-height: 320px;
  margin-bottom: 28px;
}
@media (max-width: 760px) {
  .dam-browser {
    grid-template-columns: 1fr;
  }
  .dam-resizer { display: none; }
}

/* Draggable splitter between tree and grid */
.dam-resizer {
  position: relative;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  user-select: none;
}
.dam-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: var(--border);
}
.dam-resizer:hover { background: rgba(255,255,255,0.06); }
.dam-resizer:hover::after { background: var(--muted); }
.dam-resizer.active {
  background: rgba(255,255,255,0.10);
}
.dam-resizer.active::after { background: var(--accent); }
.dam-resizing,
.dam-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.dam-tree {
  border-right: 1px solid var(--border);
  padding: 8px 6px;
  overflow: auto;
  height: calc(100vh - 120px);
  min-height: 640px;
}
/* 樹頂部工具列（統一的「重新掃描全部」按鈕）*/
.dam-tree-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 2px 6px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
/* 掃描進行中：按鈕變半透明 + 圖示自轉 + 游標變等待 */
.tree-icon-btn.is-loading {
  opacity: 0.5;
  cursor: wait;
}
.tree-icon-btn.is-loading svg {
  animation: uphin-spin 1s linear infinite;
}
@keyframes uphin-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}
.dam-tree-root,
.dam-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree-node { display: block; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  padding-left: calc(6px + var(--depth, 0) * 14px);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}
.tree-row:hover { background: var(--panel-2); }
.tree-row.selected {
  background: var(--accent-soft);
  color: var(--text);
}
.tree-row.tree-branch { color: var(--muted); font-weight: 500; }
.tree-row.tree-leaf { color: var(--text); }

/* Per-folder action icons in tree (rescan / retag / delete) */
.tree-actions {
  display: inline-flex;
  gap: 2px;
  margin-left: 6px;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.tree-row:hover .tree-actions,
.tree-row.selected .tree-actions { opacity: 1; }
.tree-icon-btn {
  background: transparent;
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  border-radius: 4px;
}
.tree-icon-btn:hover {
  background: var(--panel);
  color: var(--text);
}
.tree-icon-btn.danger:hover {
  color: var(--error);
}
.tree-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tree-caret {
  display: inline-block;
  width: 12px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}
.tree-icon { font-size: 12px; }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.tree-count { color: var(--muted); font-size: 11px; margin-left: 4px; }

.dam-grid {
  overflow: auto;
  /* Match dam-tree so the two panes stay aligned. */
  height: calc(100vh - 120px);
  min-height: 640px;
  padding: 0;
}
.dam-grid-head {
  position: sticky;
  top: 0;
  background: var(--panel);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
/* 右上角的檔名搜尋框（絕對定位、不擠標題） */
.dam-folder-filter {
  position: absolute;
  top: 12px;
  right: 16px;
  width: min(280px, 40%);
}
.dam-folder-filter input {
  width: 100%;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--text-strong);
  transition: border-color 0.15s, background 0.15s;
}
.dam-folder-filter input:focus {
  border-color: var(--border-strong);
  background: var(--panel);
}
.dam-grid-head { position: sticky; }
.dam-grid-head { padding-right: 320px; }
.dam-folder-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.dam-folder-chip {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.08);
  padding: 4px 12px;
  border-radius: 999px;
}
.dam-folder-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  word-break: break-all;
}
.dam-folder-stats {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dam-folder-stats .stat-ok { color: var(--accent-2); }
.dam-folder-stats .stat-pending { color: var(--warn); }
.dam-folder-stats .stat-running { color: var(--accent); }
/* 全庫搜尋模式：每張卡片頂部顯示所在資料夾 */
.dam-folder-crumb {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 4px;
  opacity: 0.8;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dam-folder-stats .stat-error { color: var(--error); }

.dam-rows { padding: 4px 12px 12px; }
.dam-video-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  padding: 6px 4px;   /* was 10px, tighter to fit more per screen */
  border-bottom: 1px solid var(--border);
}
.dam-video-row:last-child { border-bottom: none; }
.dam-meta { font-size: 12px; min-width: 0; }
.dam-name {
  font-weight: 600;
  color: var(--text);
  /* Single-line title; hover for full filename via the title attribute. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.dam-meta-line { color: var(--muted); font-size: 11px; margin-top: 2px; }

.dam-summary {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  background: var(--panel-2);
  border-left: 2px solid var(--accent);
  padding: 6px 8px;
  border-radius: 0 4px 4px 0;
  /* truncated 20-char form is short enough to fit one line; if long
     descriptions slip through we still cap height */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dam-summary-clickable {
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.dam-summary-clickable:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--accent-hover);
}

.frame-summary-block {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 6px;
}
.frame-summary-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.frame-summary-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.dam-thumbs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 2px 0 8px;   /* was 4px 0 12px, tighter */
  align-items: center;
  min-height: 48px;      /* was 60px */
  /* Force the chunky scrollbar to render on macOS Chrome (which would
     otherwise auto-hide). */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--panel-2);
}
.dam-thumbs::-webkit-scrollbar {
  height: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.dam-thumbs::-webkit-scrollbar-track {
  background: var(--panel-2);
  border-radius: 5px;
  margin: 0 4px;
}
.dam-thumbs::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 5px;
  min-width: 40px;
  border: 2px solid var(--panel-2);
}
.dam-thumbs::-webkit-scrollbar-thumb:hover {
  background: var(--accent-2);
}
.dam-thumbs::-webkit-scrollbar-thumb:active {
  background: var(--accent-2);
}
.dam-thumbs-loading,
.dam-thumbs > .hint { font-size: 11px; color: var(--muted); }

.dam-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 80px;        /* was 96px, ~16% smaller */
  height: 45px;       /* was 54px, keeps 16:9 */
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: #000;
  transition: transform 0.15s ease, z-index 0.01s;
}
.dam-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.dam-thumb:hover {
  transform: scale(1.8);
  z-index: 10;
  border-color: var(--accent);
}
.dam-thumb-time {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  padding: 1px 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
.dam-thumb:hover .dam-thumb-time { opacity: 1; }

.jobs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 4px;
}
.jobs-header h3 { margin: 0; }
.jobs-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.jobs-toggle input { margin: 0; }

#jobs .job {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 12px;
  transition: padding 0.18s, background 0.18s;
}
#jobs .job.collapsed {
  padding: 4px 12px;
  background: transparent;
  border-color: var(--border);
}
.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.job-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.job-summary span:first-child { color: var(--accent-2); font-weight: 700; }
.job-summary span:nth-child(2) { flex: 1; }
.job-expand-btn,
.job-collapse-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 4px;
}
.job-expand-btn:hover,
.job-collapse-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}
/* Stop running job — small grey ghost button next to the 執行中 badge. */
.job-stop-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 2px 10px;
  font-size: 11px;
  border-radius: 4px;
  margin-left: 8px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.job-stop-btn:hover {
  background: var(--border);
  color: var(--text-strong);
  border-color: var(--muted);
}
.job-stop-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar > div {
  height: 100%;
  background: var(--accent);
  width: 0%;
}

/* UPHiN big search bar (Phase 3) */
.uph-search {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: none;
  border-radius: 14px;
  padding: 10px 10px 10px 20px;
  margin: 28px auto 16px;
  max-width: 1240px;
  /* 陰影拿掉，維持乾淨的搜尋 bar；分鏡輸入框保留 neumorphism */
}
.uph-search:focus-within {
  /* Intentionally empty */
}
/* Drag-and-drop feedback — when an image is dragged over the search bar,
   highlight it so the user knows the drop zone is active. Class added by
   the drop-handler in app.js and removed on drop / dragleave. */
.uph-search.dragging-image {
  outline: 2px dashed var(--text-strong);
  outline-offset: 2px;
  background: var(--accent-soft);
  transition: background 0.1s;
}
.uph-search.dragging-image::before {
  content: "放開以進行以圖搜圖";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-strong);
  background: var(--panel);
  padding: 2px 10px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  pointer-events: none;
  white-space: nowrap;
}
/* .uph-search needs relative positioning so the ::before badge anchors */
.uph-search { position: relative; }
.uph-search-input {
  flex: 1;
  border: none !important;
  background: transparent !important;
  outline: none;
  font-size: 15px;
  padding: 8px 0 !important;
  color: var(--text-strong);
  /* Kill the global input:focus halo so the bar stays clean on type */
  box-shadow: none !important;
}
.uph-search-input:focus { box-shadow: none !important; outline: none !important; }
.uph-search-input::placeholder { color: var(--muted); }
.uph-search-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.uph-iconbtn {
  width: 34px;
  height: 34px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.uph-iconbtn:hover {
  color: var(--text-strong);
  background: var(--accent-soft) !important;
}
.uph-iconbtn svg { width: 18px; height: 18px; }
.uph-divider {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 4px;
}

/* Pasted/uploaded image preview inside the search bar — small thumbnail
   left of the input text so user knows the image is "loaded". */
.search-preview {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-right: 10px;
  border-radius: 4px;
  overflow: visible;
}
.search-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  border: 1px solid var(--border);
}
.search-preview-clear {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--text-strong);
  color: #fff;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-preview-clear:hover { background: #000; }

/* Search history dropdown — shown when search input is focused + empty */
.search-history-dd {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  z-index: 20;
  overflow: hidden;
}
.search-history-item {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-history-item:last-child { border-bottom: none; }
.search-history-item:hover {
  background: var(--panel-2);
  color: var(--text-strong);
}

.uph-axes {
  justify-content: flex-start;
  margin: 8px auto 6px;
  max-width: 1240px;
  border: none;
  font-size: 11px;
}
.axes-label { color: var(--muted); margin-right: 6px; }

/* Search results — 4-column card grid */
.search-card {
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  /* box-shadow + transform 一起做 hover lift；捲動時 body.is-scrolling
     會把兩個效果都關掉，避免 momentum scroll 跨卡片閃爍。 */
  transition: box-shadow 0.15s, transform 0.15s;
  /* `contain: layout paint` 隔離每張卡的 layout/paint，捲動更順 */
  contain: layout paint;
}
.search-card:hover {
  box-shadow: var(--shadow-card);
  transform: translateY(-2px);
}
/* Momentum-scroll flicker fix：捲動中 100ms 內關 hover + pointer-events */
body.is-scrolling .search-card {
  pointer-events: none;
}
body.is-scrolling .search-card:hover {
  box-shadow: none;
  transform: none;
}
.search-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--panel-2);
  overflow: hidden;
  /* Promote to its own GPU compositing layer — keeps the painted image
     stable during fast scroll so the browser doesn't have to repaint it
     on every frame. Big win for the flicker problem. */
  transform: translateZ(0);
  will-change: transform;
}
.search-card-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.search-card-time {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
}
/* 下載按鈕：hover 卡片才浮出，不干擾原本點卡片開播放器 */
.search-card-download {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  cursor: pointer;
}
.search-card:hover .search-card-download { opacity: 1; }
.search-card-download:hover { background: var(--accent, #3b82f6); }
.search-card-body {
  padding: 10px 12px 14px;
}
.search-card-title {
  font-size: 12px;
  color: var(--text-strong);
  font-weight: 400;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-card-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.uph-results-grid {
  display: grid;
  gap: 18px;
  margin-top: 20px;
  /* Default sizing (matches [data-size="m"]) so no-JS / initial render
     doesn't visibly reflow. */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
/* Size variants — controlled by the S/M/L/XL toggle in search-summary.
   Each min value determines the smallest card width; auto-fill packs
   as many columns as viewport allows.
   XS ≈ dense scan (many small thumbs); XL ≈ inspect mode (few big). */
.uph-results-grid[data-size="xs"] { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.uph-results-grid[data-size="s"]  { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.uph-results-grid[data-size="m"]  { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.uph-results-grid[data-size="l"]  { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.uph-results-grid[data-size="xl"] { grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); }

/* Size toggle sits at the right of the summary line. */
.size-toggle {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.size-toggle button {
  background: transparent;
  border: none;
  padding: 3px 10px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  border-radius: 0;
}
.size-toggle button:hover {
  background: var(--accent-soft);
  color: var(--text-strong);
}
.size-toggle button.active {
  background: var(--text-strong);
  color: var(--accent-fg);
}
.search-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.axes {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 14px;
}
.axes label { display: flex; gap: 4px; align-items: center; }
/* `display: flex` above overrides the HTML5 hidden attribute (which maps
   to display: none). Restore the semantic so `<div class="axes" hidden>`
   actually hides. */
.axes[hidden] { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.frame-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
}
.frame-card img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #000;
}
.frame-card .meta { padding: 8px 10px; }
.frame-card .meta .vid { font-weight: 600; word-break: break-all; }
.frame-card .meta .tags {
  color: var(--muted);
  margin-top: 4px;
  font-size: 11px;
}
.frame-card .score {
  color: var(--accent-2);
  font-size: 11px;
}
.literal-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
  font-weight: 500;
}

.search-summary {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 6px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 4px;
}
.pagination .page-indicator {
  color: var(--muted);
  font-size: 12px;
  min-width: 110px;
  text-align: center;
}
.pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.output {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 22px;
  white-space: pre-wrap;
  font-family: "PingFang TC", "Noto Sans TC", inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  min-height: 80px;
  margin-top: 6px;
}

/* UPHiN textfield with inline action icon */
.uph-textfield {
  position: relative;
  margin-top: 18px;
}
.uph-textfield textarea {
  width: 100%;
  /* 關掉右下角的拖曳把手（那個小黑三角） */
  resize: none;
  padding: 14px 44px 14px 18px !important;
  font-size: 13px;
  background: var(--panel);
  border: none !important;
  border-radius: 14px;
  outline: none;
}
.uph-textfield textarea:focus {
  outline: none !important;
}
.uph-iconbtn-inline {
  /* 容器 wrapper (.uph-textfield > div) 已用 flex 排列，這裡不再絕對定位，
     否則多顆會互相疊在同一個 top/right 位置。 */
  position: static;
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: none !important;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
}
.uph-iconbtn-inline:hover {
  color: var(--text-strong);
  background: var(--accent-soft) !important;
}
.uph-iconbtn-inline svg { width: 16px; height: 16px; }

.uph-result-wrap {
  position: relative;
  margin-top: 20px;
}
.uph-download-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
}

/* Storyboard grid (Phase 5) */
.storyboard-overall {
  font-size: 12px;
  color: var(--text);
  margin: 18px 0 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-left: 2px solid var(--text-strong);
  border-radius: 0 4px 4px 0;
}
.storyboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
@media (min-width: 1100px) {
  .storyboard-grid { grid-template-columns: repeat(4, 1fr); }
}
.storyboard-card {
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.storyboard-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.storyboard-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--panel-2);
  overflow: hidden;
}
.storyboard-card-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.storyboard-card-noref {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
/* Cut number + duration sit in a thin bar between the thumb and the body
   text (not overlaid on the image any more). Left = 01, right = 3s. */
.storyboard-card-numbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px 0;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.storyboard-card-num {
  color: var(--text-strong);
  font-weight: 500;
}
.storyboard-card-dur {
  color: var(--muted);
}
.storyboard-card-body {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text);
  line-height: 1.5;
}
.storyboard-card-scene {
  font-weight: 500;
  color: var(--text-strong);
  font-size: 12px;
}
.storyboard-card-visual {
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.storyboard-card-meta { color: var(--muted); font-size: 11px; }
.storyboard-card-meta .hint { margin-right: 4px; }

/* "換圖" floating button on shot card */
.storyboard-card-swap {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  border: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.storyboard-card-thumb:hover .storyboard-card-swap { opacity: 1; }
.storyboard-card-swap:hover { background: rgba(0,0,0,0.85); }
/* On no-ref cards, always show the button (no image to obscure) */
.storyboard-card-noref + .storyboard-card-swap { opacity: 1; }

/* Candidates strip under the main thumb (top 5 from per-shot search) */
.storyboard-card-cands {
  display: flex;
  gap: 3px;
  padding: 4px 4px 0;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}
.storyboard-card-cands img {
  width: 48px;
  height: 27px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.7;
  border: 1px solid transparent;
  transition: opacity 0.1s, border-color 0.1s;
}
.storyboard-card-cands img:hover { opacity: 1; }
.storyboard-card-cands img.is-active {
  opacity: 1;
  border-color: var(--accent, #4a90e2);
}

/* Shot picker modal */
.shot-picker-card {
  width: min(90vw, 1100px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.shot-picker-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.shot-picker-search {
  display: flex;
  gap: 8px;
}
.shot-picker-search input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
}
/* Picker-specific focus override is no longer needed — the global
   input:focus rule above already keeps border-color as --border. */
.shot-picker-status { min-height: 16px; }

/* --- Relink modal (Phase B) --- */
.relink-modal-card {
  width: min(90vw, 1100px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.relink-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
#relink-summary { padding: 6px 2px; }
#relink-list { display: flex; flex-direction: column; gap: 8px; }
.relink-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  background: var(--panel-2);
  border-radius: 4px;
  font-size: 12px;
}
.relink-row input[type="checkbox"] { margin-top: 3px; }
.relink-row-name {
  font-weight: 500;
  color: var(--text-strong);
  word-break: break-all;
}
.relink-row-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  word-break: break-all;
}
.relink-row-path.old { text-decoration: line-through; opacity: 0.7; }
.relink-row-path.new { color: var(--text); }
.relink-row-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 6px;
}
/* Perceptual match — a judgement call, not a certainty. Amber so it reads
   differently from the byte-exact matches sitting next to it. */
.relink-row-badge.warn {
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
}
.relink-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 8px 0 4px;
  letter-spacing: 0.04em;
}

/* --- Missing files modal --- */
.missing-modal-card {
  width: min(88vw, 900px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.missing-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
#missing-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  background: var(--panel-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}
.missing-row {
  padding: 3px 4px;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.missing-row:last-child { border-bottom: none; }
.missing-row .name {
  color: var(--text-strong);
  font-family: "PingFang TC", "Noto Sans TC", inherit;
  font-size: 12px;
  font-weight: 500;
}
.missing-row .path {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
#missing-relink-result {
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  font-size: 12px;
}
/* Drag-target visual feedback on the path input */
#missing-relink-path.drag-target {
  border-color: var(--text-strong) !important;
  background: var(--accent-soft) !important;
}
.missing-relink-match {
  padding: 6px;
  border-bottom: 1px solid var(--border);
}
.missing-relink-match:last-child { border-bottom: none; }
.missing-relink-match .name {
  color: var(--text-strong);
  font-weight: 500;
  font-size: 12px;
}
.missing-relink-match .old {
  color: var(--muted);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-decoration: line-through;
}
.missing-relink-match .new {
  color: var(--accent-2);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- Duplicate management modal (Phase C) --- */
.dup-modal-card {
  width: min(92vw, 1200px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.dup-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
#dup-list { display: flex; flex-direction: column; gap: 18px; }
.dup-cluster {
  background: var(--panel-2);
  border-radius: 6px;
  padding: 12px 14px;
}
.dup-cluster-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.dup-cluster-header b { color: var(--text-strong); }
.dup-cluster-videos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.dup-video {
  position: relative;
  background: var(--panel);
  border-radius: 4px;
  padding: 10px;
  border: 2px solid transparent;
  transition: border-color 0.12s;
  font-size: 11px;
}
.dup-video.is-keep {
  border-color: var(--accent-2);
  background: rgba(110,142,106,0.06);
}
.dup-video.is-delete {
  border-color: var(--error);
  background: rgba(180,90,87,0.05);
  opacity: 0.9;
}
.dup-video-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.dup-video-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.dup-video-name {
  font-weight: 500;
  color: var(--text-strong);
  word-break: break-all;
  margin-bottom: 3px;
}
.dup-video-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 4px;
}
.dup-video-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
}
.dup-video-meta span { margin-right: 6px; }
.dup-video-actions {
  display: flex;
  gap: 4px;
  font-size: 11px;
}
.dup-video-actions button {
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.dup-video-actions button.active-keep {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}
.dup-video-actions button.active-delete {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.dup-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 4px;
}
.dup-badge.warn {
  background: rgba(184,150,66,0.14);
  color: var(--warn);
}
.shot-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  /* Use shorthand `gap` for max browser compatibility; column-gap and
     row-gap split sometimes behaves differently inside a flex parent.
     16px = roughly 1 thumb-line of white space between rows. */
  gap: 18px;
  overflow-y: auto;
  flex: 1;
  padding: 10px 4px 14px;
}
.shot-picker-tile {
  /* Use the classic "padding-bottom 56.25%" trick instead of aspect-ratio.
     With many tiles inside a height-constrained grid container, browsers
     can collapse aspect-ratio-based rows to a tiny height. padding-bottom
     reserves the height unconditionally so every tile is true 16:9. */
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  background: var(--panel-2);
  cursor: pointer;
  overflow: hidden;
  border-radius: 4px;
  border: 2px solid transparent;
  transition: border-color 0.1s, transform 0.1s;
}
.shot-picker-tile:hover {
  border-color: var(--accent, #4a90e2);
  transform: scale(1.02);
}
.shot-picker-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.shot-picker-tile-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  color: #fff;
  font-size: 10px;
  padding: 12px 6px 4px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shot-picker-tile-score {
  /* Hidden by user preference —排序仍然依百分比由高到低，但不顯示數字。
     Remove this rule to bring the badge back. */
  display: none;
}

details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
}
details > summary {
  cursor: pointer;
  outline: none;
}

code { color: var(--accent-2); font-size: 12px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: 90%;
}
.toast.show { opacity: 1; }
.toast.error { border-color: var(--error); color: var(--error); }
.toast.ok { border-color: var(--accent-2); color: var(--accent-2); }
.toast.warn { border-color: var(--warn); color: var(--warn); }

/* The "this file is already in the library twice" offer. Sits above the
   missing-file list because it's the actionable answer, not a footnote. */
.missing-merge-banner {
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 12px;
}

/* Settings → background scan scope. Capped height because a library can
   have dozens of registered folders and this shouldn't push the rest of
   the settings page off screen. */
.scan-scope-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 4px;
}
.scan-scope-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-width: 0;
}
.scan-scope-list .scope-path {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Frame card click affordance */
.frame-card { cursor: pointer; transition: transform 0.12s, border-color 0.12s; }
.frame-card:hover { transform: translateY(-2px); border-color: var(--accent); }

/* Video player modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(219, 220, 220, 0.85);
  backdrop-filter: blur(6px);
}
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(960px, 92vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; font-size: 14px; }
.modal-sub { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-all; }
.modal-x {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  font-weight: 400;
}
.modal-x:hover { color: var(--text); }
.modal-body {
  padding: 14px 18px;
  overflow: auto;
}
.modal-body video {
  width: 100%;
  max-height: 65vh;
  background: #000;
  border-radius: 4px;
  display: block;
}
/* Player modal — image branch. `contain` preserves the true aspect ratio
   so photos aren't cropped when the user opens the detail modal. Max
   height caps at 65vh so we don't push the modal off-screen for tall
   verticals. Black background around the letterbox reads as intentional
   (like a photo viewer / lightbox). */
.modal-body img#player-image {
  display: block;
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
}
/* HTML5 `hidden` attribute normally maps to display: none, but the
   .modal-body video / img rules above use display: block which wins by
   specificity. Restore the hidden semantics explicitly so the JS
   branch-swap (video vs image) actually hides one at a time. */
.modal-body video[hidden],
.modal-body img#player-image[hidden] {
  display: none !important;
}
.player-frame-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-left: 2px solid var(--text-strong);
  border-radius: 0 4px 4px 0;
}
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 16px;
}
/* Footer buttons in modal should look like text links (per mockup) */
.modal-foot button.ghost {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  font-size: 12px;
}
.modal-foot button.ghost:hover {
  color: var(--text-strong);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Error details modal */
.error-modal-card { width: min(640px, 92vw); max-height: 80vh; }
.err-section { margin-bottom: 18px; }
.err-section:last-child { margin-bottom: 0; }
.err-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.err-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  word-break: break-all;
  margin-bottom: 8px;
}
.err-row-actions {
  display: flex;
  gap: 8px;
}
.err-row-actions button {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
}
.err-row-actions button:hover {
  background: var(--border);
}
.err-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
}
.err-foot {
  justify-content: space-between !important;
}
.err-foot-right {
  display: flex;
  gap: 12px;
}
.err-foot button.danger {
  color: #b00020;
  background: transparent;
  border: 1px solid #e6c4ca;
}
.err-foot button.danger:hover {
  background: rgba(176,0,32,0.06);
  border-color: #b00020;
}

/* 全域 button.danger：危險/破壞性動作的按鈕（純紅字、無框） */
button.danger {
  color: var(--error, #b00020);
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
}
button.danger:hover {
  background: rgba(176, 0, 32, 0.06);
}
.err-foot button.primary {
  background: var(--text-strong);
  color: #fff;
  border: 1px solid var(--text-strong);
}
.err-foot button.primary:hover {
  background: var(--text);
}

/* Storyboard toolbar — appears above the shot grid once cards rendered */
.storyboard-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 6px 0 12px;
}
/* 顯式蓋掉 display:flex，讓 hidden 屬性真的生效 */
.storyboard-toolbar[hidden] { display: none !important; }

/* Storyboard history tabs — one row of 1..5 slots + [+] to make new.
   Each slot shows its letter (A/B/C/D/E) and hover-title with brief preview.
   Active slot has a dark underline. Storage: sessionStorage → clears when
   the browser is closed. */
.storyboard-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0 8px;
  margin: 14px 0 12px;
}
.storyboard-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.12s, color 0.12s;
}
.storyboard-tab:hover {
  background: var(--accent-soft);
  color: var(--text-strong);
}
.storyboard-tab.active {
  color: var(--text-strong);
  background: var(--panel);
  border-color: var(--border);
  border-bottom-color: var(--panel);
  margin-bottom: -1px;
}
.storyboard-tab-letter {
  font-weight: 500;
  font-size: 13px;
}
.storyboard-tab-time {
  font-size: 10px;
  color: var(--muted);
}
.storyboard-tab-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.12s, color 0.12s;
}
.storyboard-tab-close:hover {
  opacity: 1;
  color: var(--error);
}
.storyboard-tab-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 6px 12px;
  font-style: italic;
}
.storyboard-tabs-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

/* ===========================================================
   PRINT — used when the user clicks 下載 PDF → browser print
   Hides everything except the storyboard so the saved PDF is
   a clean, A4-friendly shot deck (title + cards, no nav).
   =========================================================== */
@media print {
  /* Use white background and ink-dark text instead of palette */
  body {
    background: #fff !important;
    color: #000 !important;
  }
  /* Hide everything we don't want printed */
  header.topbar,
  .tabs,
  #health,
  .drawer,
  .drawer-backdrop,
  .toast,
  #work-queue,
  .jobs-header,
  #jobs,
  .dam-browser,
  .uph-textfield,
  #storyboard-toolbar,
  /* hide all panels except storyboard's section */
  #tab-search,
  #tab-library,
  #tab-reorg,
  #tab-settings {
    display: none !important;
  }
  /* Make sure the storyboard tab is visible even if it wasn't .active */
  #tab-script {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  /* Tighter card layout suitable for A4 portrait — 2 columns */
  .storyboard-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  .storyboard-overall {
    color: #000 !important;
    font-size: 13px !important;
    margin: 0 0 14px !important;
    border: none !important;
    padding: 0 !important;
  }
  .storyboard-card {
    break-inside: avoid;
    page-break-inside: avoid;
    background: #fff !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }
  .storyboard-card-thumb img { max-width: 100% !important; height: auto !important; }
  /* Show full text (no line-clamp truncation in PDF) */
  .storyboard-card-visual {
    display: block !important;
    -webkit-line-clamp: unset !important;
    overflow: visible !important;
  }
  /* Print page setup */
  @page { size: A4; margin: 12mm; }
}

/* Clickable error badge — looks slightly interactive */
.badge.badge-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-style: dotted;
  text-decoration-color: rgba(176,0,32,0.4);
}
.badge.badge-clickable:hover {
  filter: brightness(0.92);
}

/* =========================================================
 * 對話式素材助理 · Phase 1
 * 側邊面板 + 浮動按鈕 · Claude Desktop 灰調
 * ========================================================= */

/* 浮動按鈕（收起狀態）*/
#assistant-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 12px;
  background: var(--panel, #1a1c22);
  color: var(--text, #e6e8ee);
  border: 1px solid var(--border, #2a2d38);
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
#assistant-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  background: #22252d;
}
#assistant-toggle .assistant-toggle-icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #d6412c;
  color: white;
  border-radius: 6px;
  font-size: 11px;
}
#assistant-toggle .assistant-toggle-icon::before { content: "💬"; font-size: 12px; }
#assistant-toggle .assistant-toggle-label { font-weight: 500; }
#assistant-toggle .assistant-toggle-kbd {
  color: var(--muted, #8a92a3);
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  font-family: -apple-system, monospace;
}

/* 開啟狀態：隱藏浮動按鈕 */
#assistant-toggle.hidden { display: none; }

/* 側邊面板 */
#assistant-panel {
  position: fixed;
  top: 0; right: 0;
  width: 560px;
  transition: width 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
              transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  height: 100vh;
  z-index: 199;
  background: var(--panel, #14161c);
  border-left: 1px solid var(--border, #2a2d38);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
}
#assistant-panel[aria-hidden="false"] { transform: translateX(0); }

/* 面板 header */
.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #2a2d38);
  flex-shrink: 0;
}
.assistant-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
  color: var(--text, #e6e8ee);
  letter-spacing: 0.3px;
}
.assistant-dot {
  width: 8px; height: 8px;
  background: #d6412c;
  border-radius: 50%;
  animation: assistant-pulse 2s ease-in-out infinite;
}
@keyframes assistant-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.assistant-header-actions { display: flex; gap: 4px; }
.assistant-icon-btn {
  width: 28px; height: 28px;
  background: transparent; border: none;
  color: var(--muted, #8a92a3);
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.assistant-icon-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text, #e6e8ee);
}

/* 訊息區 */
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.assistant-empty {
  color: var(--muted, #8a92a3);
  font-size: 13px;
  padding: 40px 8px;
  text-align: center;
  line-height: 1.7;
}
.assistant-empty h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text, #e6e8ee);
  font-weight: 500;
}
.assistant-empty .hint-list {
  margin-top: 20px;
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
}
.assistant-empty .hint-pill {
  background: transparent;
  border: 1px solid var(--border, #2a2d38);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted, #8a92a3);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.assistant-empty .hint-pill:hover {
  color: var(--text, #e6e8ee);
  border-color: #d6412c;
}

.assistant-msg {
  display: flex; flex-direction: column;
  gap: 4px;
  animation: assistant-msg-in 0.25s ease-out;
}
@keyframes assistant-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.assistant-msg .role-tag {
  font-size: 10px;
  color: var(--muted, #8a92a3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.assistant-msg.user .role-tag { color: var(--muted, #8a92a3); }
.assistant-msg.assistant .role-tag { color: #d6412c; }
.assistant-msg .msg-body {
  color: var(--text, #e6e8ee);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.assistant-msg.user .msg-body {
  background: rgba(255,255,255,0.04);
  padding: 10px 14px;
  border-radius: 12px;
}

/* Tool 使用 badges */
.assistant-msg .tools-used {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-top: 4px;
}
.assistant-msg .tool-badge {
  background: rgba(214, 65, 44, 0.12);
  color: #d6412c;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: -apple-system, monospace;
}

/* Status（thinking / calling tool） */
.assistant-status {
  padding: 10px 18px;
  color: var(--muted, #8a92a3);
  font-size: 12px;
  font-style: italic;
  border-top: 1px solid var(--border, #2a2d38);
  animation: assistant-status-fade 0.3s;
}
@keyframes assistant-status-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 輸入區 */
.assistant-form {
  border-top: 1px solid var(--border, #2a2d38);
  padding: 12px 14px 16px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#assistant-input {
  flex: 1;
  background: rgba(0,0,0,0.2);
  color: var(--text, #e6e8ee);
  border: 1px solid var(--border, #2a2d38);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 160px;
  transition: border-color 0.15s;
}
#assistant-input:focus {
  border-color: #d6412c;
}
#assistant-input::placeholder {
  color: rgba(138, 146, 163, 0.6);
}
#assistant-send {
  width: 36px; height: 36px;
  border: none;
  background: #d6412c;
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
#assistant-send:hover:not(:disabled) { background: #b83221; }
#assistant-send:disabled {
  background: rgba(214, 65, 44, 0.3);
  cursor: not-allowed;
}

/* =========================================================
 * 助理按鈕：升級到 tabs nav（顯眼的常駐位置）
 * ========================================================= */
.tabs {
  display: flex;
  align-items: center;
}
.tab-assistant {
  margin-left: auto !important;   /* 貼齊右邊 */
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  padding: 8px 14px !important;
  background: #d6412c !important;
  color: white !important;
  border: none !important;
  border-radius: 999px !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(214, 65, 44, 0.25);
}
.tab-assistant:hover {
  background: #b83221 !important;
  transform: translateY(-1px);
}
.tab-assistant.active,
.tab-assistant:focus {
  background: #b83221 !important;
  outline: none;
}
.tab-assistant .tab-assistant-dot {
  width: 6px; height: 6px;
  background: white;
  border-radius: 50%;
  animation: assistant-pulse 2s ease-in-out infinite;
  opacity: 0.9;
}
.tab-assistant .tab-assistant-kbd {
  font-size: 10px;
  background: rgba(255,255,255,0.18);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: -apple-system, monospace;
  color: rgba(255,255,255,0.9);
}

/* =========================================================
 * 助理入口：搬到搜尋 bar 下方、灰色 subtle 樣式
 * ========================================================= */
.assistant-quick {
  display: flex;
  justify-content: center;
  padding: 14px 0 4px;
}
.assistant-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--panel);
  color: var(--text-strong, var(--text));
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.assistant-quick-btn:hover {
  color: #ffffff;
  border-color: #000000;
  background: #000000;
}
.assistant-quick-btn:hover .aq-dot {
  background: #ffffff;
  opacity: 1;
}
.assistant-quick-btn:hover .aq-icon {
  opacity: 1;
}
.assistant-quick-btn .aq-dot {
  width: 6px; height: 6px;
  background: #ffffff;
  border-radius: 50%;
  animation: assistant-pulse 2.5s ease-in-out infinite;
  opacity: 0.75;
}

.assistant-quick-btn .aq-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  color: currentColor;
  opacity: 0.85;
}
.assistant-quick-btn .aq-icon svg { width: 14px; height: 14px; }


/* 助理 header 累計統計 */
.assistant-stats {
  font-size: 10px;
  color: var(--muted, #8a92a3);
  margin-left: 8px;
  font-family: -apple-system, monospace;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

/* 對話中的 video 卡片（可點擊、開 frames modal） */
.assistant-video-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.av-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(214, 65, 44, 0.08);
  color: var(--text, #e6e8ee);
  border: 1px solid rgba(214, 65, 44, 0.25);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  max-width: 100%;
}
.av-card:hover {
  background: rgba(214, 65, 44, 0.15);
  border-color: #d6412c;
}
.av-card .av-id {
  background: #d6412c;
  color: white;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 10px;
  font-weight: 600;
}
.av-card .av-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.av-card-loading .av-name {
  color: var(--muted, #8a92a3);
  font-style: italic;
}

/* 助理訊息 body：段落 + 內嵌影片卡片 */
.assistant-msg .msg-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assistant-msg .msg-paragraph {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text, #e6e8ee);
  font-size: 13.5px;
  line-height: 1.65;
}
.assistant-msg .assistant-video-cards.inline {
  margin-top: -2px;
  margin-bottom: 4px;
  padding-left: 4px;
  border-left: 2px solid rgba(214, 65, 44, 0.25);
  padding-left: 10px;
}
.assistant-msg .msg-cards-label {
  color: var(--muted, #8a92a3);
  font-size: 11px;
  margin-top: 8px;
  font-style: italic;
}


/* 助理面板展開態 */
#assistant-panel.expanded { width: 720px; }
@media (min-width: 1400px) {
  #assistant-panel.expanded { width: 900px; }
}

/* ========================================================
 * 搜尋模式 toggle · 畫面 / 影片
 * 位置：搜尋 bar 下方、置中（取代原助理入口）
 * ======================================================== */
.search-mode-wrap {
  display: flex;
  justify-content: center;
  padding: 14px 0 4px;
}
.search-mode-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.05);
  padding: 3px;
  border-radius: 999px;
  gap: 0;
  position: relative;
  overflow: hidden;
}
:root:not(.dark) .search-mode-toggle {
  background: #EDECE9;
}
/* 滑動的白色 pill 指示器（絕對定位、跟著 mode class 走） */
.search-mode-toggle::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  background: var(--panel, #FFFFFF);
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08),
              0 1px 2px rgba(0,0,0,0.04);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.search-mode-toggle.mode-video::before {
  transform: translateX(100%);
}
.smt-btn {
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  padding: 7px 22px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted, #8a92a3);
  cursor: pointer;
  transition: color 0.2s;
  min-width: 68px;
}
.smt-btn:hover:not(.active) { color: var(--text, #e6e8ee); }
.smt-btn.active {
  color: var(--text-strong, #1a1c22);
  font-weight: 500;
}

/* ========================================================
 * 影片模式：video card (大縮圖 + summary + hover scrub)
 * ======================================================== */
.video-result-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}
.video-result-grid[data-size="s"] {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.video-result-grid[data-size="m"],
.video-result-grid:not([data-size]) {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.video-result-grid[data-size="l"] {
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 20px;
}
/* S 尺寸：卡片內文字略縮、summary 收成 2 行 */
.video-result-grid[data-size="s"] .vc-name { font-size: 12px; }
.video-result-grid[data-size="s"] .vc-summary { -webkit-line-clamp: 2; font-size: 11px; }
.video-result-grid[data-size="s"] .vc-meta { padding: 8px 10px 10px; }
/* L 尺寸：卡片內文字略放、summary 展 4 行 */
.video-result-grid[data-size="l"] .vc-name { font-size: 14px; }
.video-result-grid[data-size="l"] .vc-summary { -webkit-line-clamp: 4; font-size: 13px; }
.video-result-grid[data-size="l"] .vc-meta { padding: 12px 14px 14px; }
.video-card {
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  contain: layout paint;
}
.video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
body.is-scrolling .video-card { pointer-events: none; }
body.is-scrolling .video-card:hover { box-shadow: none; transform: none; }
.vc-thumb {
  aspect-ratio: 16/9;
  background: var(--panel-2);
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform;
}
.vc-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.1s;
}
.vc-thumb .vc-scrub-dots {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 3px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.video-card:hover .vc-scrub-dots { opacity: 0.9; }
.vc-scrub-dots .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transition: background 0.1s, transform 0.1s;
}
.vc-scrub-dots .dot.active {
  background: #FFFFFF;
  transform: scale(1.4);
}
/* .vc-count-badge 已拿掉（改用全片縮圖 scrub、不再顯示命中數）*/

.vc-meta {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 5px;
}
.vc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.vc-summary {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.vc-footline {
  font-size: 10.5px;
  color: var(--muted);
  display: flex; gap: 8px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.vc-relevance {
  padding: 1px 8px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.3px;
}
.vc-relevance.s-precise  { background: rgba(74, 155, 79, 0.18); color: #4a9b4f; }
.vc-relevance.s-relevant { background: rgba(232, 166, 63, 0.18); color: #b8892e; }
.vc-relevance.s-edge     { background: rgba(139, 139, 139, 0.18); color: #6f6f6f; }
.vc-relevance.s-loose    { background: rgba(180, 180, 175, 0.15); color: #8a8a85; }

/* 影片模式分頁控制 */
.video-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 30px 0 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #E5E5E5);
}
.pg-btn {
  width: 40px; height: 36px;
  background: var(--panel);
  border: 1px solid var(--border, #DFDEDA);
  color: var(--text-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.15s;
  font-family: inherit;
}
.pg-btn:hover:not(:disabled) {
  background: #D6412C;
  border-color: #D6412C;
  color: #FFF;
  transform: translateY(-1px);
}
.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pg-info {
  font-size: 13px;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 50px;
  text-align: center;
}
.pg-count {
  color: var(--muted);
  font-size: 11px;
  margin-left: 10px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================
 * seedoes v1 · 新版介面 · 覆蓋層
 * ========================================================= */

/* 隱藏舊的 header topbar + tabs · 用新的 sidebar 導航 */
body.seedoes-mode .topbar,
body.seedoes-mode > nav.tabs {
  display: none !important;
}

/* --- Header 新版 --- */
.seedoes-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--seedoes-header-h);
  padding: 0 32px;
  background: var(--seedoes-canvas);
  border-bottom: 0.5px solid var(--border);
}
/* Logo 對齊 sidebar 中線（sidebar 寬 72、icon 中心約 36px） */
.seedoes-brand {
  margin-left: 4px;
}
.seedoes-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--seedoes-ink);
  cursor: pointer;
}
.seedoes-brand-mark {
  width: 24px;
  height: 24px;
  display: block;
  color: var(--seedoes-ink);
}
.seedoes-brand-lockup {
  height: 22px;
  width: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.seedoes-brand-text {
  font-size: 18px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--seedoes-ink);
}
.seedoes-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: 999px;
  color: var(--seedoes-ink);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.seedoes-user:hover {
  background: var(--panel);
}

/* --- Sidebar 左側垂直 nav --- */
.seedoes-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--seedoes-sidebar-w);
  padding: calc(var(--seedoes-header-h) + 20px) 0 20px;
  background: var(--seedoes-canvas);
  border-right: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 90;
}
.seedoes-nav-btn {
  position: relative;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seedoes-nav-btn:hover {
  background: var(--accent-soft);
  color: var(--seedoes-ink);
}
.seedoes-nav-btn.active {
  background: var(--seedoes-ink);
  color: var(--panel);
}
.seedoes-nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.5;
}
/* Tooltip 顯示名稱 */
.seedoes-nav-btn::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  background: var(--seedoes-ink);
  color: var(--panel);
  font-size: 11px;
  letter-spacing: 0.06em;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  white-space: nowrap;
  z-index: 200;
}
.seedoes-nav-btn:hover::after {
  opacity: 1;
}

/* --- 主內容區 · 讓 sidebar --- */
body.seedoes-mode main {
  margin-left: var(--seedoes-sidebar-w);
  padding: 32px 32px 48px;
  max-width: none;
}
body.seedoes-mode main > section.panel {
  max-width: var(--seedoes-content-max);
  margin: 0 auto;
}

/* --- Home 頁 · 置中 hero --- */
.seedoes-home {
  min-height: calc(100vh - var(--seedoes-header-h) - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px 20px;
}
.seedoes-home-title {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 400;
  color: var(--seedoes-ink);
  letter-spacing: -0.01em;
  margin: 0;
}
.seedoes-home-title .home-mark {
  width: 26px;
  height: 26px;
  color: var(--seedoes-ink);
}
.seedoes-home-input-wrap {
  width: 100%;
  max-width: 720px;
  padding: 20px 20px 12px;
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--seedoes-radius);
  transition: border-color 0.15s;
}
.seedoes-home-input-wrap:focus-within {
  border-color: var(--seedoes-ink);
}
.seedoes-home-input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--seedoes-ink);
  font-family: inherit;
}
.seedoes-home-input::placeholder {
  color: var(--muted);
}
.seedoes-home-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}
.seedoes-home-plus,
.seedoes-home-submit {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--seedoes-ink);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.seedoes-home-submit {
  margin-left: auto;
}
.seedoes-home-submit svg,
.seedoes-home-plus svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}

/* --- Search-mode toggle · 已存在的樣式再調 · 位置移到 home input 內 --- */
.seedoes-home-controls .search-mode-toggle {
  transform: scale(0.85);
  transform-origin: left center;
}

/* =========================================================
 * seedoes v1 · Home Hero（搜尋首頁置中大 input）
 * ========================================================= */
.seedoes-hero {
  min-height: calc(100vh - var(--seedoes-header-h) - 200px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px 20px;
  transition: min-height 0.3s, padding 0.3s;
}
.seedoes-hero.hidden { display: none; }

/* 有結果時 · Hero 收合 · 只留 input 在頂端 */
.seedoes-hero.has-results {
  min-height: auto;
  padding: 8px 20px 24px;
  gap: 0;
}
.seedoes-hero.has-results .seedoes-hero-title {
  display: none;
}
.seedoes-hero.has-results .seedoes-hero-input-wrap {
  padding: 14px 20px 10px;
  max-width: 900px;
}
.seedoes-hero.has-results .seedoes-hero-input {
  font-size: 14px;
}
.seedoes-hero.has-results .seedoes-hero-controls {
  margin-top: 10px;
}

.seedoes-hero-title {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-size: 32px;
  font-weight: 400;
  color: var(--seedoes-ink);
  letter-spacing: -0.01em;
  margin: 0;
}
.seedoes-hero-title .hero-mark {
  width: 28px;
  height: 28px;
  color: var(--seedoes-ink);
}

.seedoes-hero-input-wrap {
  width: 100%;
  max-width: 720px;
  padding: 22px 24px 16px;
  background: transparent;
  border: 1.5px solid var(--seedoes-ink);
  border-radius: var(--seedoes-radius);
  transition: box-shadow 0.15s;
}
.seedoes-hero-input-wrap:focus-within {
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}
.seedoes-hero-input {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--seedoes-ink);
  font-family: inherit;
  line-height: 1.4;
}
.seedoes-hero-input::placeholder {
  color: var(--muted);
}

.seedoes-hero-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.seedoes-hero-plus {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--seedoes-ink);
  cursor: pointer;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  padding: 0;
  transition: opacity 0.15s;
}
.seedoes-hero-plus:hover { opacity: 0.6; }

.seedoes-hero-submit {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--seedoes-ink);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.seedoes-hero-submit:hover { transform: translateX(2px); }

/* Hero 內的 STILL/MOTION pill toggle · 黑底 pill · 白字 · 選中反白 */
.seedoes-hero-modes {
  display: inline-flex;
  padding: 3px;
  background: var(--seedoes-ink);
  border-radius: 999px;
}
.hero-mode-btn {
  padding: 4px 14px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
}
.hero-mode-btn.active {
  background: var(--panel);
  color: var(--seedoes-ink);
}

/* 隱藏舊的畫面/影片 toggle（seedoes 模式已用 hero STILL/MOTION 取代）*/
body.seedoes-mode .search-mode-wrap {
  display: none !important;
}

/* Hero 搜尋歷史 · Home 狀態顯示 */
.seedoes-hero-history {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.hero-history-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.hero-history-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
}
.hero-history-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 14px;
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: 999px;
  color: var(--seedoes-ink);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  max-width: 240px;
}
.hero-history-chip:hover {
  background: var(--panel);
  border-color: var(--seedoes-ink);
}
.hero-history-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.hero-history-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.hero-history-chip-x:hover {
  color: var(--seedoes-ink);
  background: var(--accent-soft);
}

/* has-results 時隱藏歷史 */
.seedoes-hero.has-results .seedoes-hero-history {
  display: none;
}

/* 隱藏舊的畫面/影片 toggle（sedoes 模式已用 hero STILL/MOTION 取代）*/
body.seedoes-mode .search-mode-wrap {
  display: none !important;
}

/* =========================================================
 * seedoes v1 · Search 結果卡片微調（配 canvas 色）
 * ========================================================= */
body.seedoes-mode .search-card,
body.seedoes-mode .video-card {
  border-radius: var(--seedoes-radius);
  background: var(--panel);
  border: 0.5px solid var(--border);
}
body.seedoes-mode .search-card:hover,
body.seedoes-mode .video-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
body.seedoes-mode .search-card-thumb,
body.seedoes-mode .vc-thumb {
  background: var(--panel-2);
}

/* =========================================================
 * seedoes v1 · Pop-up modal 樣式（兩種版式）
 * ========================================================= */
.seedoes-popup {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  min-width: 360px;
  max-width: 520px;
  padding: 14px 20px 16px;
  background: var(--seedoes-canvas);
  border: 0.5px solid var(--seedoes-ink);
  border-radius: var(--seedoes-radius);
  color: var(--seedoes-ink);
  z-index: 2000;
  animation: seedoes-popup-in 0.25s ease;
}
@keyframes seedoes-popup-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.seedoes-popup-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--seedoes-ink);
}
.seedoes-popup-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--warn);
}
.seedoes-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}
.seedoes-popup-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0.5px solid var(--border-strong);
  border-radius: 50%;
  color: var(--seedoes-ink);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  transition: background 0.15s;
}
.seedoes-popup-btn:hover {
  background: var(--accent-soft);
}
.seedoes-popup-btn.warn {
  border-color: var(--warn);
  color: var(--warn);
}
