/* ReMind — Workflow v2 styles. Một renderer duy nhất (.wf-shell) cho admin
 * soạn / xem thử / member / cổng / trang /w. Tokens khai báo trên .wf-shell;
 * dark theo [data-theme="dark"] (app theo theme, /w theo prefers-color-scheme).
 * ============================================================ */

.wf-viewer { position: absolute; inset: 0; }

/* Token workflow = biến theme của app (themes.css). Fallback giữ giá trị cũ để
   lỡ thiếu themes.css vẫn chạy. Dark/vintage/modern đến từ themes.css, KHÔNG
   override cứng ở đây nữa. */
.wf-shell, .wf-sheet, .wf-lightbox {
  --wf-bg: var(--bg, #F6F7F9);
  --wf-dot: var(--grid, #DCE0E6);
  --wf-surface: var(--panel, #FFFFFF);
  --wf-surface-2: var(--panel-2, #F1F3F6);
  --wf-ink: var(--text, #16191F);
  --wf-muted: var(--text-muted, #6B7280);
  --wf-line: var(--border, #E3E6EB);
  --wf-edge: var(--edge, #C4CAD4);
  --wf-accent: var(--accent, #2F6FEB);
  --wf-accent-soft: var(--accent-soft, rgba(47,111,235,.14));
  --wf-done: var(--success, #16A34A);
  --wf-root-bg: var(--text, #16191F);
  --wf-root-ink: var(--panel, #FFFFFF);
  --wf-danger: var(--danger, #DC4B3E);
  --wf-radius: var(--node-radius, 12px);
  --wf-shadow-1: var(--node-shadow, 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08));
  --wf-shadow-2: var(--node-shadow-hover, 0 8px 24px rgba(16,24,40,.12));
  --wf-panel-w: 420px;
  --wf-on-accent: #ffffff; /* chữ trên nút nền accent — đọc được ở modern/vintage */
}
[data-theme="dark"] .wf-shell, [data-theme="dark"] .wf-sheet, [data-theme="dark"] .wf-lightbox {
  --wf-on-accent: var(--bg, #0a0d18); /* dark: accent sáng → chữ tối cho tương phản ≥4.5 */
}
.wf-shell {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--wf-bg); color: var(--wf-ink);
  font-family: var(--font-ui, 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
}

/* ---- Canvas ---- */
.wf-canvas-wrap {
  position: absolute; inset: 0; overflow: hidden; touch-action: none;
  background-color: var(--wf-bg);
  background-image: radial-gradient(var(--wf-dot) 1px, transparent 1px);
  background-size: 22px 22px; background-position: 0 0; cursor: grab;
}
.wf-canvas-wrap.wf-grabbing { cursor: grabbing; }
/* Nền canvas theo map.style.background (giống #canvas-wrap của app). Vị trí +
   kích thước hoa văn do JS cập nhật theo pan/zoom. */
.wf-canvas-wrap[data-bg="dots"] { background-image: radial-gradient(circle, var(--wf-dot) 1px, transparent 1px); }
.wf-canvas-wrap[data-bg="grid"] { background-image: linear-gradient(var(--wf-dot) 1px, transparent 1px), linear-gradient(90deg, var(--wf-dot) 1px, transparent 1px); }
.wf-canvas-wrap[data-bg="lines"] { background-image: linear-gradient(transparent 27px, var(--wf-dot) 27px, var(--wf-dot) 28px, transparent 28px); }
.wf-canvas-wrap[data-bg="blank"] { background-image: none; }
[data-theme="vintage"] .wf-canvas-wrap[data-bg="lines"]::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 96px; width: 1px;
  background: rgba(168,80,60,.25); pointer-events: none; z-index: 0;
}
.wf-cards { font-family: var(--font-node, 'Inter', sans-serif); }
/* Giấy sần cho vintage (giống app) */
.wf-canvas-wrap::before, .wf-panel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain-pattern, none); opacity: .6;
}
[data-theme="dark"] .wf-canvas-wrap::before, [data-theme="dark"] .wf-panel::before { display: none; }
.wf-panel > * { position: relative; z-index: 1; }
.wf-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.wf-edges { position: absolute; overflow: visible; pointer-events: none; }
.wf-cards { position: absolute; top: 0; left: 0; }

/* ---- Edges ---- */
.wf-edge-main { fill: none; stroke: var(--wf-edge); stroke-width: 2; }
.wf-edge-sub { fill: none; stroke: var(--wf-edge); stroke-width: 1.5; }
.wf-edge-done { stroke: var(--wf-done); stroke-width: 2; }
.wf-edge-next { stroke: var(--wf-accent); stroke-width: 2; stroke-dasharray: 6 6; animation: wf-dash 1.2s linear infinite; }
@keyframes wf-dash { to { stroke-dashoffset: -24; } }

/* ---- Cards ---- */
.wf-card {
  position: absolute; box-sizing: border-box; overflow: visible;
  background: var(--wf-surface); border: 1px solid var(--wf-line);
  border-radius: var(--wf-radius); box-shadow: var(--wf-shadow-1);
  padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer;
  transition: transform .14s ease, border-color .16s, box-shadow .16s;
}
.wf-card:hover { transform: translateY(-2px); box-shadow: var(--wf-shadow-2); z-index: 5; }
.wf-card:focus-visible { outline: none; border-color: var(--wf-accent); box-shadow: 0 0 0 4px var(--wf-accent-soft); }
.wf-card.wf-current { border-color: var(--wf-accent); border-width: 1.5px; box-shadow: 0 0 0 4px var(--wf-accent-soft), var(--wf-shadow-1); z-index: 6; }
.wf-card.wf-has-bar::before,
.wf-card.wf-viewed::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: var(--wf-radius) 0 0 var(--wf-radius);
}
.wf-card.wf-has-bar::before { background: var(--wf-bar); }
.wf-card.wf-viewed::before { background: var(--wf-done); }
.wf-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.wf-card-label { font: 600 11px/16px 'Inter', sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--wf-lab, var(--wf-muted)); }
.wf-card.wf-current .wf-card-label { color: var(--wf-accent); }
.wf-card.wf-viewed .wf-card-label { color: var(--wf-done); }
.wf-card-title {
  font: 600 14px/20px 'Inter', sans-serif; color: var(--wf-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.wf-vthumb.wf-card-thumb { flex: none; width: 56px; height: 42px; }

/* Root card */
.wf-card.wf-root {
  background: var(--wf-root-bg); color: var(--wf-root-ink); border: none;
  border-radius: 14px; flex-direction: column; align-items: flex-start;
  justify-content: center; gap: 3px; box-shadow: var(--wf-shadow-2);
}
.wf-card.wf-root:hover { transform: translateY(-2px); }
.wf-root-label { font: 700 11px/16px 'Inter', sans-serif; letter-spacing: .08em; opacity: .68; }
.wf-root-title { font: 700 16px/22px 'Inter', sans-serif; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wf-root-sub { font: 500 12px/16px 'Inter', sans-serif; opacity: .68; }

/* Ghost + Empty */
.wf-card.wf-ghost {
  border: 1.5px dashed var(--wf-edge); background: transparent; box-shadow: none;
  color: var(--wf-muted); justify-content: center; gap: 6px; font: 600 13px 'Inter', sans-serif;
}
.wf-card.wf-ghost:hover { border-color: var(--wf-accent); color: var(--wf-accent); transform: none; box-shadow: none; }
.wf-ghost-plus { font-size: 18px; line-height: 1; }
.wf-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.wf-empty[hidden] { display: none; }
.wf-empty-in { text-align: center; color: var(--wf-muted); pointer-events: auto; font-size: 15px; }
.wf-empty-add { margin-top: 12px; border: 1px solid var(--wf-accent); background: var(--wf-accent); color: var(--wf-on-accent); border-radius: 8px; padding: 9px 18px; cursor: pointer; font: 600 14px 'Inter', sans-serif; }

/* Edit-mode card controls */
.wf-card-controls { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .12s; }
.wf-edit .wf-card:hover .wf-card-controls,
.wf-edit .wf-card.wf-selected .wf-card-controls { opacity: 1; }
.wf-card-btn { pointer-events: none; }
.wf-edit .wf-card:hover .wf-card-btn,
.wf-edit .wf-card.wf-selected .wf-card-btn { pointer-events: auto; }
.wf-card-btn {
  position: absolute; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--wf-line); background: var(--wf-surface); color: var(--wf-ink);
  cursor: pointer; font-size: 14px; line-height: 1; box-shadow: var(--wf-shadow-1);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.wf-card-btn:hover { border-color: var(--wf-accent); color: var(--wf-accent); }
.wf-add-right { right: -12px; top: 50%; transform: translateY(-50%); }
.wf-add-below { bottom: -12px; left: 50%; transform: translateX(-50%); }
.wf-more { top: -10px; right: -10px; }
.wf-dragging { z-index: 1000 !important; box-shadow: var(--wf-shadow-2); opacity: .95; transition: none; }
.wf-dropline { position: absolute; background: var(--wf-accent); border-radius: 2px; z-index: 900; pointer-events: none; }

.wf-cardmenu {
  position: fixed; z-index: 100001; background: var(--wf-surface);
  border: 1px solid var(--wf-line); border-radius: 10px; box-shadow: var(--wf-shadow-2);
  padding: 6px; min-width: 190px; display: flex; flex-direction: column; gap: 2px;
}
.wf-cardmenu button { text-align: left; padding: 7px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--wf-ink); font: 500 13px 'Inter', sans-serif; }
.wf-cardmenu button:hover { background: var(--wf-surface-2); }
.wf-cardmenu .wf-danger { color: var(--wf-danger); }
.wf-cardmenu-colors { display: flex; gap: 6px; padding: 6px 8px; }
.wf-colordot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--wf-surface); box-shadow: 0 0 0 1px var(--wf-line); cursor: pointer; padding: 0; }
.wf-colordot:hover { box-shadow: 0 0 0 2px var(--wf-accent); }

/* ---- Overlays on canvas ---- */
.wf-preview-banner {
  position: absolute; top: 0; left: 0; right: 0; height: 36px; z-index: 25;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--wf-accent); color: var(--wf-on-accent); font: 600 13px 'Inter', sans-serif;
}
.wf-preview-exit { border: 0; background: rgba(255,255,255,.22); color: #fff; border-radius: 6px; padding: 3px 10px; cursor: pointer; font: inherit; }
.wf-preview-exit:hover { background: rgba(255,255,255,.34); }
.wf-kbd { border: 1px solid rgba(255,255,255,.5); border-radius: 4px; padding: 0 5px; font-size: 11px; }

.wf-numbanner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 35;
  max-width: min(680px, 92%); display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--wf-surface); border: 1px solid var(--wf-line);
  border-left: 3px solid var(--wf-accent); border-radius: 10px; box-shadow: var(--wf-shadow-2);
  font: 500 13px 'Inter', sans-serif; color: var(--wf-ink);
}
.wf-numbanner[hidden] { display: none; }
.wf-numbanner-err { border-left-color: var(--wf-danger); }
.wf-numbanner-txt { flex: 1; min-width: 0; }
.wf-numbanner-sub { display: block; font-size: 12px; color: var(--wf-muted); margin-top: 2px; }
.wf-numbanner-err .wf-numbanner-txt { color: var(--wf-ink); }
.wf-numbanner-fix { border: 1px solid var(--wf-accent); background: var(--wf-accent); color: var(--wf-on-accent); border-radius: 7px; padding: 5px 10px; cursor: pointer; font: 600 12px 'Inter', sans-serif; white-space: nowrap; }
.wf-numbanner-fix:hover { filter: brightness(1.06); }
.wf-numbanner-skip { border: 1px solid var(--wf-line); background: var(--wf-surface); color: var(--wf-muted); border-radius: 7px; padding: 5px 10px; cursor: pointer; font: 600 12px 'Inter', sans-serif; white-space: nowrap; }
.wf-numbanner-skip:hover { background: var(--wf-surface-2); }
.wf-untitled { color: var(--wf-muted); font-style: italic; }

.wf-toast {
  position: absolute; left: 50%; top: 80px; transform: translateX(-50%) translateY(-8px);
  background: var(--wf-ink); color: var(--wf-bg); padding: 8px 16px; border-radius: 20px;
  font: 600 13px 'Inter', sans-serif; opacity: 0; transition: opacity .2s, transform .2s;
  z-index: 40; box-shadow: var(--wf-shadow-2); pointer-events: none; max-width: 80%; text-align: center;
}
.wf-toast.wf-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }

.wf-zoomctl {
  position: absolute; left: 16px; bottom: 16px; z-index: 30; display: flex; align-items: center; gap: 2px;
  background: var(--wf-surface); border: 1px solid var(--wf-line); border-radius: 10px; padding: 3px; box-shadow: var(--wf-shadow-1);
}
.wf-z { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; color: var(--wf-ink); font-size: 16px; line-height: 1; }
.wf-z:hover { background: var(--wf-surface-2); }
.wf-zlabel { font: 600 12px 'Inter', sans-serif; color: var(--wf-muted); min-width: 40px; text-align: center; }

.wf-floatnav {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 6px; background: var(--wf-surface);
  border: 1px solid var(--wf-line); border-radius: 22px; padding: 4px 8px; box-shadow: var(--wf-shadow-2);
}
.wf-floatnav[hidden] { display: none; }
.wf-floatcount { font: 600 13px 'Inter', sans-serif; color: var(--wf-ink); min-width: 90px; text-align: center; }

.wf-reopen {
  position: absolute; right: 16px; bottom: 16px; z-index: 30; height: 44px; min-width: 44px; padding: 0 14px;
  border-radius: 22px; border: 1px solid var(--wf-line); background: var(--wf-surface); color: var(--wf-ink);
  box-shadow: var(--wf-shadow-2); cursor: pointer; display: flex; align-items: center; gap: 6px; font: 600 13px 'Inter', sans-serif;
}
.wf-reopen[hidden] { display: none; }
.wf-reopen-ic { font-size: 16px; }

.wf-nav-btn { border: 1px solid var(--wf-line); background: var(--wf-surface); color: var(--wf-ink); border-radius: 8px; padding: 8px 12px; cursor: pointer; font: 600 13px 'Inter', sans-serif; }
.wf-nav-btn:hover:not(:disabled) { background: var(--wf-surface-2); }
.wf-nav-btn:disabled { opacity: .45; cursor: default; }
.wf-floatnav .wf-nav-btn { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 16px; }

/* ---- Panel (desktop overlay) ---- */
.wf-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--wf-panel-w); z-index: 20;
  background: var(--wf-surface); border-left: 1px solid var(--wf-line);
  box-shadow: -4px 0 16px rgba(16,24,40,.06); display: flex; flex-direction: column;
  transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
.wf-shell.wf-collapsed .wf-panel { transform: translateX(100%); }
.wf-panel-resizer { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 2; }
.wf-panel-resizer.wf-rz-active { background: var(--wf-accent-soft); }
.wf-sheet-grip { display: none; }

.wf-panel-head { flex: 0 0 auto; padding: 16px 18px 12px; border-bottom: 1px solid var(--wf-line); position: relative; }
.wf-panel-titlerow { display: flex; align-items: center; gap: 8px; }
.wf-panel-maptitle { flex: 1; min-width: 0; font: 600 13px 'Inter', sans-serif; color: var(--wf-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-panel-collapse { flex: none; border: 0; background: transparent; color: var(--wf-muted); font-size: 18px; cursor: pointer; width: 28px; height: 28px; border-radius: 6px; }
.wf-panel-collapse:hover { background: var(--wf-surface-2); }
.wf-progress { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.wf-progress[hidden] { display: none; }
.wf-progress-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--wf-surface-2); overflow: hidden; }
.wf-progress-bar i { display: block; height: 100%; background: var(--wf-done); width: 0; transition: width .3s ease; }
.wf-progress-txt { font: 500 12px 'Inter', sans-serif; color: var(--wf-muted); white-space: nowrap; }
.wf-save { margin-top: 8px; font: 500 12px 'Inter', sans-serif; }
.wf-save[hidden] { display: none; }
.wf-save.wf-saving { color: var(--wf-muted); }
.wf-save.wf-saved { color: var(--wf-done); transition: opacity 1s; }
.wf-save.wf-saved.wf-fade { opacity: 0; }
.wf-save.wf-error { color: var(--wf-danger); cursor: pointer; text-decoration: underline; }
.wf-legacy-link { margin-top: 10px; border: 0; background: transparent; color: var(--wf-accent); cursor: pointer; font: 500 12px 'Inter', sans-serif; text-decoration: underline; padding: 0; display: block; }

.wf-panel-body { flex: 1; overflow-y: auto; padding: 18px; }
.wf-panel-foot { flex: 0 0 auto; display: flex; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--wf-line); }
.wf-panel-foot .wf-nav-prev { flex: 1; text-align: center; }
.wf-panel-foot .wf-nav-next { flex: 1.5; text-align: center; background: var(--wf-accent); border-color: var(--wf-accent); color: var(--wf-on-accent); }
.wf-panel-foot .wf-nav-next:hover:not(:disabled) { filter: brightness(1.06); }
.wf-nav-next.wf-nav-done { background: var(--wf-done); border-color: var(--wf-done); }

/* ---- Panel body content ---- */
.wf-body-label { font: 600 11px/16px 'Inter', sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--wf-muted); margin-bottom: 6px; }
.wf-body-title { font: 700 22px/30px 'Inter', sans-serif; color: var(--wf-ink); margin: 0 0 14px; overflow-wrap: anywhere; }
.wf-body-empty { color: var(--wf-muted); font-style: italic; font-size: 14px; }
.wf-body-in-r { animation: wf-in-r .18s cubic-bezier(.2,.8,.2,1); }
.wf-body-in-l { animation: wf-in-l .18s cubic-bezier(.2,.8,.2,1); }
@keyframes wf-in-r { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes wf-in-l { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

.wf-video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; margin: 0 0 14px; }
.wf-video-frame video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.wf-video-expand { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 8px; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 15px; }
.wf-video-expand:hover { background: rgba(0,0,0,.75); }

.wf-toc { margin-top: 14px; border-top: 1px solid var(--wf-line); padding-top: 12px; }
.wf-toc-label, .wf-next-label { font: 600 11px 'Inter', sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--wf-muted); margin-bottom: 8px; }
.wf-next { margin-top: 16px; }
.wf-toc-item, .wf-next-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--wf-line); background: var(--wf-surface); border-radius: 10px; padding: 9px 12px; margin-bottom: 6px; cursor: pointer; color: var(--wf-ink); font: 500 14px 'Inter', sans-serif; }
.wf-toc-item:hover, .wf-next-item:hover { background: var(--wf-surface-2); border-color: var(--wf-edge); }
.wf-toc-mark, .wf-next-num { flex: none; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 6px; background: var(--wf-surface-2); color: var(--wf-muted); display: flex; align-items: center; justify-content: center; font: 600 11px 'Inter', sans-serif; }
.wf-toc-item.wf-done .wf-toc-mark { background: var(--wf-done); color: #fff; }
.wf-toc-txt, .wf-next-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-next-arrow { color: var(--wf-muted); }

/* ---- Edit body ---- */
.wf-edit-title { width: 100%; box-sizing: border-box; min-height: 40px; /* 1 dòng = 30 + padding 8 + viền 2: không bao giờ bẹp dù autoGrow đo ra 0 */ border: 1px solid transparent; background: transparent; font: 700 22px/30px 'Inter', sans-serif; color: var(--wf-ink); resize: none; padding: 4px 6px; border-radius: 8px; margin: 0 0 12px; outline: none; overflow: hidden; }
.wf-edit-title:hover { border-color: var(--wf-line); }
.wf-edit-title:focus { border-color: var(--wf-accent); background: var(--wf-surface); }
.wf-vzone { margin-bottom: 14px; }
.wf-vzone-acts { display: flex; gap: 8px; margin-top: 8px; }
.wf-vbtn { border: 1px solid var(--wf-line); background: var(--wf-surface); color: var(--wf-ink); border-radius: 8px; padding: 6px 12px; cursor: pointer; font: 600 12px 'Inter', sans-serif; }
.wf-vbtn:hover { background: var(--wf-surface-2); }
.wf-vbtn.wf-danger { color: var(--wf-danger); }
.wf-dropzone { border: 1.5px dashed var(--wf-edge); border-radius: 12px; padding: 20px; text-align: center; color: var(--wf-muted); min-height: 120px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; }
.wf-dropzone.wf-dz-over { border-color: var(--wf-accent); background: var(--wf-accent-soft); }
.wf-dz-txt { margin-bottom: 10px; font: 500 14px 'Inter', sans-serif; }
.wf-dz-row { display: flex; gap: 8px; justify-content: center; }
.wf-dz-link { display: flex; gap: 6px; margin-top: 10px; }
.wf-dz-link[hidden] { display: none; }
.wf-dz-input { flex: 1; border: 1px solid var(--wf-line); border-radius: 8px; padding: 7px 10px; background: var(--wf-surface); color: var(--wf-ink); }
.wf-dz-status { margin-top: 8px; font: 500 12px 'Inter', sans-serif; color: var(--wf-danger); }
.wf-dz-row .wf-rec-btn { color: var(--wf-danger); border-color: var(--wf-danger); }
/* Ghi màn hình — panel đang ghi / đang tải lên */
.wf-rec-live { border: 1.5px solid var(--wf-edge); border-radius: 12px; padding: 16px; text-align: center; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.wf-rec-head { display: flex; align-items: center; gap: 8px; }
.wf-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--wf-danger); animation: wf-rec-pulse 1.2s infinite; }
@keyframes wf-rec-pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.wf-rec-info { font: 600 14px 'Inter', sans-serif; color: var(--wf-ink); font-variant-numeric: tabular-nums; }
.wf-rec-hint { font: 500 12px 'Inter', sans-serif; color: var(--wf-muted); }
.wf-rec-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wf-rec-acts[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .wf-rec-dot { animation: none; } }
/* Màn cắt đầu/đuôi sau khi ghi (M4) */
.wf-trim-panel { align-items: stretch; text-align: left; }
.wf-trim-panel .wf-video-frame { margin: 0; width: 100%; }
.wf-trim-title { font: 700 12px 'Inter', sans-serif; color: var(--wf-muted); text-transform: uppercase; letter-spacing: .04em; }
.wf-trim-bar { position: relative; height: 34px; margin: 4px 9px; touch-action: none; user-select: none;
  background: var(--wf-surface-2); border: 1px solid var(--wf-line); border-radius: 6px; }
.wf-trim-range { position: absolute; top: 0; bottom: 0; background: var(--wf-edge); opacity: .35; }
.wf-trim-mark { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--wf-muted); opacity: .45; pointer-events: none; }
.wf-trim-h { position: absolute; top: -4px; bottom: -4px; width: 16px; margin-left: -8px; border-radius: 5px; cursor: ew-resize;
  background: var(--wf-ink); border: 2px solid var(--wf-surface); box-sizing: border-box; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.wf-trim-h:focus-visible { outline: 2px solid var(--wf-edge); outline-offset: 2px; }
.wf-trim-locked .wf-trim-h { opacity: .45; cursor: default; }
.wf-trim-label { font: 600 13px 'Inter', sans-serif; color: var(--wf-ink); font-variant-numeric: tabular-nums; text-align: center; }
.wf-trim-panel .wf-trim-done { align-self: center; }
.wf-mdedit { border: 1px solid var(--wf-line); border-radius: 12px; overflow: hidden; }
.wf-mdtabs { display: flex; border-bottom: 1px solid var(--wf-line); }
.wf-mdtab { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; font: 600 13px 'Inter', sans-serif; color: var(--wf-muted); }
.wf-mdtab.wf-active { color: var(--wf-ink); box-shadow: inset 0 -2px 0 var(--wf-accent); }
.wf-mdtool { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--wf-line); flex-wrap: wrap; }
.wf-mdtool button { border: 0; background: transparent; min-width: 30px; height: 28px; border-radius: 6px; cursor: pointer; color: var(--wf-ink); font: 500 13px 'Inter', sans-serif; }
.wf-mdtool button:hover { background: var(--wf-surface-2); }
.wf-mdpop { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 8px; border-bottom: 1px solid var(--wf-line); background: var(--wf-surface-2); }
.wf-mdpop[hidden] { display: none; }
.wf-mdpop-or { font: 500 12px 'Inter', sans-serif; color: var(--wf-muted); }
.wf-mdpop .wf-dz-input { flex: 1; min-width: 140px; }
.wf-mdarea { width: 100%; box-sizing: border-box; border: 0; padding: 12px 14px; background: var(--wf-surface); color: var(--wf-ink); font: 400 14px/22px 'Inter', sans-serif; resize: none; outline: none; min-height: 120px; }
.wf-mdpreview { padding: 12px 14px; min-height: 120px; }

/* ---- Markdown (dùng chung viewer + editor) ---- */
.wf-md { font-size: 15px; line-height: 26px; color: var(--wf-ink); max-width: 68ch; }
.wf-md-h { margin: 18px 0 8px; line-height: 1.3; }
.wf-md h1.wf-md-h { font-size: 20px; } .wf-md h2.wf-md-h { font-size: 18px; }
.wf-md h3.wf-md-h { font-size: 16px; } .wf-md h4.wf-md-h { font-size: 14px; }
.wf-md-p { margin: 0 0 12px; }
.wf-md-list { margin: 0 0 12px; padding-left: 22px; }
.wf-md-list li { margin: 3px 0; }
.wf-md-quote { margin: 0 0 12px; padding: 6px 14px; border-left: 3px solid var(--wf-accent); background: var(--wf-surface-2); color: var(--wf-muted); border-radius: 0 6px 6px 0; }
.wf-md-pre { margin: 0 0 12px; padding: 12px 14px; background: #1b1f27; color: #e8ecf3; border-radius: 8px; overflow-x: auto; }
.wf-md-pre code { color: #e8ecf3; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
.wf-md code { background: var(--wf-surface-2); padding: 1px 5px; border-radius: 4px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
.wf-md a { color: var(--wf-accent); text-decoration: underline; }
.wf-md-img { max-width: 100%; border-radius: 10px; margin: 8px 0; display: block; cursor: zoom-in; }
.wf-md-hr { border: none; border-top: 1px solid var(--wf-line); margin: 16px 0; }

/* ---- Mobile bottom sheet (<768px) ---- */
.wf-shell.wf-mobile .wf-panel {
  top: auto; left: 0; right: 0; bottom: 0; width: auto !important; height: 112px;
  border-left: 0; border-top: 1px solid var(--wf-line); border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(16,24,40,.16); transform: none !important;
  transition: height .26s cubic-bezier(.2,.9,.3,1);
}
.wf-shell.wf-mobile .wf-panel.wf-sheet { }
.wf-shell.wf-mobile .wf-panel-resizer { display: none; }
.wf-shell.wf-mobile .wf-panel-collapse { display: none; }
.wf-shell.wf-mobile .wf-sheet-grip { display: flex; justify-content: center; padding: 8px 0 2px; cursor: grab; touch-action: none; }
.wf-sheet-grip span { width: 36px; height: 4px; border-radius: 2px; background: var(--wf-edge); }
.wf-shell.wf-mobile .wf-panel-head { touch-action: none; }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .wf-edge-next { animation: none !important; }
  .wf-card, .wf-panel, .wf-body-in-l, .wf-body-in-r, .wf-toast, .wf-progress-bar i { transition: none !important; animation: none !important; }
}

/* ============================================================
 * Video thumbnail (poster) — dùng chung editor + viewer + /w.
 * ============================================================ */
.wf-vthumb {
  position: relative; display: block; width: 100%; height: 46px;
  border: 0; padding: 0; margin: 0; border-radius: 8px; cursor: pointer;
  background: #14181f center / cover no-repeat; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.wf-vthumb.wf-vthumb-has { background-color: #000; }
.wf-vthumb .wf-vthumb-play {
  position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 11px; transition: background .15s, transform .1s;
}
.wf-vthumb:hover .wf-vthumb-play { background: var(--wf-accent, #2f6feb); transform: scale(1.08); }
.wf-vthumb:focus-visible { outline: 2px solid var(--wf-accent, #2f6feb); outline-offset: 2px; }
.node-vthumb { height: 44px; margin-top: 4px; }  /* editor node (legacy mind-map) */

.wf-lightbox {
  position: fixed; inset: 0; z-index: 100000; background: rgba(10,10,14,.86);
  display: flex; align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; animation: wf-lb-in .14s ease;
}
@keyframes wf-lb-in { from { opacity: 0; } to { opacity: 1; } }
.wf-lightbox-inner { position: relative; width: min(92vw, 1100px); max-height: 88vh; display: flex; }
.wf-lightbox-video { width: 100%; max-height: 88vh; border-radius: 10px; background: #000; box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: wf-lb-vid .14s ease; }
@keyframes wf-lb-vid { from { transform: scale(.98); } to { transform: scale(1); } }
.wf-lightbox-inner:fullscreen { width: 100vw; max-height: 100vh; align-items: center; justify-content: center; background: #000; }
.wf-lightbox-inner:fullscreen .wf-lightbox-video { max-height: 100vh; border-radius: 0; }
.wf-lightbox-btn { position: absolute; top: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; background: #fff; color: #1a1a1a; font-size: 15px; box-shadow: 0 3px 10px rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; }
.wf-lightbox-close { right: 10px; }
.wf-lightbox-full { right: 54px; }
.wf-lightbox-btn:hover { background: var(--wf-accent, #2f6feb); color: #fff; }
@media (prefers-reduced-motion: reduce) { .wf-lightbox, .wf-lightbox-video { animation: none !important; } }

/* ============================================================
 * Nhúng trong app: overlay + menu Workflow + modal Chia sẻ/Tiến độ
 * ============================================================ */
.wf-overlay { position: absolute; inset: 0; z-index: 60; background: var(--wf-bg, #F6F7F9); }
[data-theme="dark"] .wf-overlay { background: #0E1117; }
.wf-overlay[hidden] { display: none; }
.wf-overlay-mount { position: absolute; inset: 0; }

#wfMenu .wf-disabled { opacity: .45; cursor: default; pointer-events: none; }

/* Ẩn công cụ mind-map khi map workflow bị khoá / đang mount surface */
body.wf-view-locked #selToolbar,
body.wf-view-locked #fab,
body.wf-surface-on #selToolbar,
body.wf-surface-on #fab { display: none !important; }

/* Surface workflow đang hiện → ẩn nút topbar chỉ dành cho canvas mind map.
   Giữ: tên map, Saved, Undo, Redo, Export, Workflow ▾, theme, avatar. */
body.wf-surface-on #searchBtn,
body.wf-surface-on #focusBtn,
body.wf-surface-on #presentBtn,
body.wf-surface-on #fitBtn,
body.wf-surface-on #toolHand,
body.wf-surface-on #toolSelect,
body.wf-surface-on #minimapBtn,
body.wf-surface-on #zoomOut,
body.wf-surface-on #zoomLabel,
body.wf-surface-on #zoomIn,
body.wf-surface-on #minimap { display: none !important; }

/* Khung Style khi map là workflow: Preset + Layout mờ, kèm chú thích. */
.form-row.wf-style-dim { opacity: .45; pointer-events: none; }
.wf-style-hint { margin: -6px 2px 12px; font-style: italic; opacity: .8; }

/* Banner "đang sửa dạng mind map" (legacy editor) */
.wf-legacy-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 45;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: #fff; border: 1px solid #e3e6eb; border-radius: 10px; box-shadow: 0 6px 20px rgba(16,24,40,.12);
  font: 500 13px 'Inter', sans-serif; color: #16191f;
}
[data-theme="dark"] .wf-legacy-banner { background: #161B24; border-color: #2A3140; color: #E8ECF3; }
.wf-legacy-banner button { border: 1px solid #2F6FEB; background: #2F6FEB; color: #fff; border-radius: 7px; padding: 5px 10px; cursor: pointer; font: 600 12px 'Inter', sans-serif; }
.wf-legacy-banner[hidden] { display: none; }

/* Modal Chia sẻ + Tiến độ (render trong #modal của app) */
.wf-share-label { font-weight: 700; font-size: 13px; margin: 4px 0 8px; color: #16191f; }
.wf-share-sep { height: 1px; background: #e3e6eb; margin: 16px 0; }
.wf-share-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.wf-share-row input { flex: 1 1 auto; min-width: 0; padding: 7px 9px; border: 1px solid #d8dce3; border-radius: 8px; font-size: 12px; font-family: 'JetBrains Mono', monospace; }
.wf-team-box { margin-bottom: 4px; }
.wf-team-row { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.wf-team-status { font-size: 13px; color: #6b7280; }
.wf-team-status.on { color: #16a34a; font-weight: 600; }
.wf-prog-list { display: flex; flex-direction: column; gap: 8px; }
.wf-prog-item { }
.wf-prog-head { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 12px; border: 1px solid #e3e6eb; border-radius: 10px; background: #fafbfc; cursor: pointer; font-family: inherit; }
.wf-prog-head:hover { background: #f1f3f6; }
.wf-prog-name { font-weight: 700; font-size: 13px; color: #16191f; text-align: left; }
.wf-prog-src { font-size: 10px; padding: 1px 6px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.wf-prog-src.team { background: #dcedff; color: #1d5fd6; }
.wf-prog-src.public { background: #eceff3; color: #6b7280; }
.wf-prog-pct { font-size: 12px; color: #6b7280; }
.wf-prog-bar { grid-column: 1 / -1; height: 6px; background: #eceff3; border-radius: 999px; overflow: hidden; }
.wf-prog-bar i { display: block; height: 100%; background: #16a34a; }
.wf-prog-detail { padding: 8px 4px 2px; }
.wf-prog-step { font-size: 12.5px; color: #6b7280; padding: 3px 6px; }
.wf-prog-step.ok { color: #16191f; }
.wf-prog-step span { display: inline-block; width: 16px; color: #16a34a; }

/* Hộp thiết lập ghi: bong bóng webcam (M6) */
.wf-cam-setup { align-items: stretch; text-align: left; }
.wf-cam-switch, .wf-cam-mirror { font: 600 12px 'Inter', sans-serif; color: var(--wf-ink); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.wf-cam-opts { display: flex; flex-direction: column; gap: 8px; }
.wf-cam-opts[hidden] { display: none; }
.wf-cam-stage { position: relative; width: 100%; max-width: 288px; aspect-ratio: 16 / 9; background: var(--wf-surface-2); border: 1px solid var(--wf-line); border-radius: 8px; overflow: hidden; }
.wf-cam-bubble { position: absolute; border-radius: 50%; overflow: hidden; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); background: #000; }
.wf-cam-bubble video { width: 100%; height: 100%; object-fit: cover; display: block; }
.wf-cam-row { display: flex; align-items: center; gap: 6px; font: 600 12px 'Inter', sans-serif; color: var(--wf-muted); flex-wrap: wrap; }
.wf-cam-row > span { min-width: 28px; }
.wf-cam-row .wf-vbtn { padding: 4px 10px; }
.wf-cam-row .wf-vbtn.wf-on { background: var(--wf-ink); color: var(--wf-surface); border-color: var(--wf-ink); }
.wf-cam-row .wf-cam-mirror { margin-left: auto; }
.wf-cam-msg { font: 500 12px 'Inter', sans-serif; color: var(--wf-danger); }
.wf-cam-msg:empty { display: none; }

/* Dải nhắc: đang có bản ghi ở bước khác (phiên ghi sống ở tầng mount) */
.wf-rec-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; padding: 8px 10px; border: 1.5px solid var(--wf-danger); border-radius: 10px; font: 600 12px 'Inter', sans-serif; color: var(--wf-danger); }
.wf-rec-banner-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-rec-banner .wf-vbtn { flex: none; }
.wf-rec-session { display: block; }

/* ===== media/image ===== */
/* Vùng media của bước (editor): video và/hoặc ảnh + ô thả; thả vào bất kỳ chỗ nào của hộp đều được. */
.wf-vzone.wf-dz-over { outline: 2px dashed var(--wf-accent); outline-offset: 4px; border-radius: 12px; }
.wf-vzone.wf-dz-over .wf-dropzone { border-color: var(--wf-accent); background: var(--wf-accent-soft); }
.wf-vzone-item + .wf-vzone-item, .wf-vzone-item + .wf-dropzone { margin-top: 12px; }
.wf-vzone-item .wf-video-frame { margin-bottom: 0; }
.wf-img-frame { position: relative; border-radius: 12px; overflow: hidden; background: var(--wf-surface-2); border: 1px solid var(--wf-line); text-align: center; line-height: 0; cursor: zoom-in; }
.wf-img-frame img { display: block; max-width: 100%; max-height: 240px; margin: 0 auto; object-fit: contain; }
.wf-img-frame:focus-visible { outline: 2px solid var(--wf-accent); outline-offset: 2px; }
.wf-img-frame.wf-img-broken { cursor: default; padding: 26px 12px; line-height: 1.4; color: var(--wf-muted); font: 500 13px 'Inter', sans-serif; }
.wf-dropzone:focus-visible { outline: 2px solid var(--wf-accent); outline-offset: 2px; }
.wf-dropzone.wf-dz-compact { min-height: 0; padding: 10px 12px; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.wf-dropzone.wf-dz-compact .wf-dz-txt { margin: 0; font-size: 13px; }
.wf-dropzone.wf-dz-compact .wf-dz-link { flex: 1 1 100%; margin-top: 0; }
.wf-dz-row { flex-wrap: wrap; }
.wf-dz-status[hidden] { display: none; }
.wf-dz-status.wf-dz-busy { color: var(--wf-muted); }

/* Ảnh trong panel xem (editor preview + viewer + /w) */
.wf-panel-img { margin: 0 0 14px; border-radius: 12px; cursor: zoom-in; }
.wf-panel-img img { display: block; width: auto; max-width: 100%; height: auto; max-height: 70vh; object-fit: contain; margin: 0; border-radius: 12px; }
.wf-panel-img:focus-visible { outline: 2px solid var(--wf-accent); outline-offset: 2px; }
.wf-panel-img.wf-panel-img-broken { cursor: default; padding: 22px 14px; text-align: center; color: var(--wf-muted); background: var(--wf-surface-2); font: 500 13px 'Inter', sans-serif; }

/* Thumbnail ảnh trên card (bước chỉ có ảnh) — kích thước lấy từ .wf-vthumb.wf-card-thumb */
.wf-imgthumb { background-color: var(--wf-surface-2); }
.wf-imgthumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wf-imgthumb:hover { outline: 2px solid var(--wf-accent); outline-offset: -2px; }
.wf-imgthumb.wf-imgthumb-broken::after { content: '🖼'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; opacity: .45; }

/* Lightbox ảnh (dùng chung khung .wf-lightbox với video) */
.wf-lightbox-imgwrap .wf-lightbox-inner { width: auto; max-width: 92vw; justify-content: center; }
.wf-lightbox-img { display: block; width: auto; height: auto; max-width: 100%; max-height: 88vh; min-width: 0; object-fit: contain; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: wf-lb-vid .14s ease; }
.wf-lightbox-imgwrap .wf-lightbox-inner:fullscreen { width: 100vw; max-width: none; }
.wf-lightbox-inner:fullscreen .wf-lightbox-img { max-width: 100vw; max-height: 100vh; border-radius: 0; box-shadow: none; }
.wf-lightbox-err { align-self: center; padding: 40px 56px; border-radius: 12px; background: rgba(255,255,255,.08); color: #fff; font: 600 15px 'Inter', sans-serif; }
@media (prefers-reduced-motion: reduce) { .wf-lightbox-img { animation: none !important; } }
