/* v9.0.2-1 */
/* ============================================================
   PHOTO UPLOAD v8.4.3-9 (NEW - CLEAN CSS)
   - Viết mới hoàn toàn, KHÔNG tham khảo CSS cũ
   - Bám theo template trong photo-upload-v8.4.3-4-1.js
   - Theme chính: teal -> sky, màu theo đúng chức năng
   - Fix vấn đề cuộn/che trường: dialog flex, body scroll, footer cố định trong dialog,
     có padding-bottom + safe-area để không che input cuối.
   Created: 2026-02-23
============================================================ */

/* ──────────────────────────────────────────────────────────
  1) TOKENS / VARIABLES
────────────────────────────────────────────────────────── */
.pu-overlay,
.pu-root {
  /* Brand (teal -> sky) */
  --pu-primary: #0f766e;       /* teal dark */
  --pu-primary-2: #0ea5e9;     /* sky */
  --pu-primary-soft: rgba(15,118,110,.10);
  --pu-primary-soft-2: rgba(14,165,233,.10);

  /* Functional colors */
  --pu-sky: #0ea5e9;
  --pu-sky-soft: rgba(14,165,233,.12);
  --pu-teal: #0d9488;
  --pu-teal-soft: rgba(13,148,136,.12);
  --pu-amber: #d97706;
  --pu-amber-soft: rgba(217,119,6,.16);
  --pu-red: #dc2626;
  --pu-red-soft: rgba(220,38,38,.12);
  --pu-violet: #7c3aed;
  --pu-violet-soft: rgba(124,58,237,.14);
  --pu-green: #16a34a;
  --pu-green-soft: rgba(22,163,74,.12);

  /* Surface */
  --pu-bg: #f8fafc;
  --pu-surface: #ffffff;
  --pu-surface-2: #f1f5f9;
  --pu-border: #e2e8f0;
  --pu-border-2: #cbd5e1;

  /* Text */
  --pu-text: #0f172a;
  --pu-text-sub: #475569;
  --pu-text-mute: #94a3b8;

  /* Radius & shadow */
  --pu-r-sm: 8px;
  --pu-r: 12px;
  --pu-r-lg: 18px;
  --pu-shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --pu-shadow: 0 10px 30px rgba(2,6,23,.18);

  /* Layout */
  --pu-dialog-w: 560px;
  --pu-footer-h: 64px; /* dùng để chừa chỗ cuộn (ước lượng an toàn) */

  /* Motion */
  --pu-trans: 0.18s ease;

  /* Safe-area */
  --pu-safe-b: env(safe-area-inset-bottom, 0px);
}

.pu-hidden { display: none !important; }

/* ──────────────────────────────────────────────────────────
  2) OVERLAY + DIALOG (FIX SCROLL)
────────────────────────────────────────────────────────── */
.pu-overlay {
  position: fixed;
  inset: 0;
  z-index: 10150;
  background: rgba(15,23,42,.62);
  backdrop-filter: blur(4px);

  display: flex;
  align-items: center;
  justify-content: center;

  /* Overlay được phép cuộn nếu màn hình quá thấp */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;

  padding: 18px 12px calc(18px + var(--pu-safe-b));

  opacity: 0;
  pointer-events: none;
  transition: opacity var(--pu-trans);
}

.pu-overlay.pu-show {
  opacity: 1;
  pointer-events: auto;
}

/* Dialog: luôn là flex column để footer không đè body */
.pu-dialog {
  width: 100%;
  max-width: var(--pu-dialog-w);

  /* Quan trọng: max-height theo dvh để đúng trên mobile */
  max-height: calc(100dvh - 36px - var(--pu-safe-b));

  background: var(--pu-surface);
  border-radius: var(--pu-r-lg);
  box-shadow: var(--pu-shadow);

  display: flex;
  flex-direction: column;

  overflow: hidden;

  transform: translateY(16px) scale(.985);
  transition: transform var(--pu-trans);
}

.pu-overlay.pu-show .pu-dialog {
  transform: translateY(0) scale(1);
}

/* ──────────────────────────────────────────────────────────
  3) HEADER
────────────────────────────────────────────────────────── */
.pu-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 14px 16px 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--pu-primary), var(--pu-primary-2));
}

.pu-header-icon {
  width: 34px;
  height: 34px;
  border-radius: 99px;
  background: rgba(255,255,255,.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}

.pu-header-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.pu-ja {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2px;
}

.pu-vi {
  font-size: 10px;
  font-weight: 700;
  opacity: .86;
  font-style: italic;
}

.pu-header-device-badge {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 900;
}

.pu-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 99px;
  background: rgba(255,255,255,.14);
  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  transition: background var(--pu-trans), transform var(--pu-trans);
}

.pu-close-btn:hover {
  background: rgba(255,255,255,.24);
  transform: translateY(-1px);
}

/* ──────────────────────────────────────────────────────────
  4) BODY (SCROLL AREA)
────────────────────────────────────────────────────────── */
.pu-body {
  flex: 1;
  min-height: 0;              /* cực quan trọng để overflow hoạt động trong flex */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  background: var(--pu-surface);
  padding: 12px 12px 10px;

  /* Chừa chỗ để footer không che các trường cuối */
  padding-bottom: calc(12px + var(--pu-footer-h) + var(--pu-safe-b));
  scroll-padding-bottom: calc(12px + var(--pu-footer-h) + var(--pu-safe-b));
  overscroll-behavior: contain;
}

/* Scrollbar (nhẹ) */
.pu-body::-webkit-scrollbar { width: 6px; }
.pu-body::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.65);
  border-radius: 99px;
}

/* ──────────────────────────────────────────────────────────
  5) SECTION (GROUP)
────────────────────────────────────────────────────────── */
.pu-section {
  background: var(--pu-bg);
  border: 1px solid var(--pu-border);
  border-radius: var(--pu-r);
  overflow: hidden;
}

.pu-section + .pu-section { margin-top: 10px; }

.pu-section-header {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  background: var(--pu-surface-2);

  border-bottom: 1px solid var(--pu-border);
  cursor: pointer;
  user-select: none;
}

.pu-section-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.pu-section-device .pu-section-icon { color: var(--pu-teal); }
.pu-section-photo  .pu-section-icon { color: var(--pu-sky); }
.pu-section-setting .pu-section-icon { color: var(--pu-violet); }

.pu-section-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.pu-section-title .pu-ja { color: var(--pu-text); font-size: 12px; }
.pu-section-title .pu-vi { color: var(--pu-text-mute); font-size: 10px; opacity: 1; }

.pu-section-chevron {
  color: var(--pu-text-mute);
  font-size: 12px;
  transition: transform var(--pu-trans);
}

.pu-section.pu-collapsed .pu-section-chevron { transform: rotate(-90deg); }
.pu-section.pu-collapsed .pu-section-body { display: none; }

.pu-section-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ──────────────────────────────────────────────────────────
  6) INLINE FIELD + GRID
────────────────────────────────────────────────────────── */
.pu-field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.pu-il-label {
  min-width: 56px;
  flex-shrink: 0;
  color: var(--pu-text-sub);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.1;
}

.pu-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

@media (max-width: 520px) {
  .pu-fields-grid { grid-template-columns: 1fr; }
  .pu-il-label { min-width: 52px; }
}

/* ──────────────────────────────────────────────────────────
  7) INPUT / TEXTAREA / SELECT
────────────────────────────────────────────────────────── */
.pu-input,
.pu-textarea,
.pu-device-search-input,
.pu-email-chip-input {
  width: 100%;
  border: 1.5px solid var(--pu-border);
  border-radius: var(--pu-r);
  background: var(--pu-surface);
  color: var(--pu-text);
  outline: none;

  transition: border-color var(--pu-trans), box-shadow var(--pu-trans), background var(--pu-trans);
}

.pu-input,
.pu-device-search-input {
  height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.pu-textarea {
  min-height: 72px;
  padding: 10px 12px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}

.pu-input:focus,
.pu-textarea:focus,
.pu-device-search-input:focus,
.pu-email-chips-wrap:focus-within {
  border-color: var(--pu-teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.16);
}

.pu-input[readonly] {
  background: var(--pu-surface-2);
  color: var(--pu-text-sub);
  cursor: default;
}

/* Auto-linked visual (JS có add class pu-input-auto) */
.pu-input-auto {
  background: rgba(13,148,136,.10) !important;
  border-color: rgba(13,148,136,.45) !important;
  color: var(--pu-teal) !important;
  font-weight: 800 !important;
}

/* Error visual (JS có add class pu-error) */
.pu-input.pu-error,
.pu-textarea.pu-error {
  border-color: var(--pu-red) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.14) !important;
}

.pu-field-error {
  margin-top: 4px;
  color: var(--pu-red);
  font-size: 11px;
  font-weight: 800;
  display: none;
}

.pu-field-error.pu-show { display: block; }

/* ──────────────────────────────────────────────────────────
  8) SMALL BADGES (auto/manual)
────────────────────────────────────────────────────────── */
.pu-ibadge {
  width: 20px;
  height: 20px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 9px;
  box-shadow: var(--pu-shadow-sm);
}

.pu-ibadge-auto { background: var(--pu-teal); color: #fff; }
.pu-ibadge-manual { background: var(--pu-amber); color: #fff; }

/* ──────────────────────────────────────────────────────────
  9) DEVICE SEARCH DROPDOWN
────────────────────────────────────────────────────────── */
.pu-device-search-wrap { position: relative; }
.pu-device-search-wrap > i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pu-text-mute);
  font-size: 12px;
  pointer-events: none;
}

.pu-device-search-input {
  padding-left: 32px;
}

.pu-device-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;

  background: var(--pu-surface);
  border: 1.5px solid var(--pu-border-2);
  border-radius: var(--pu-r);
  box-shadow: var(--pu-shadow-sm);
  z-index: 200;

  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pu-device-dropdown::-webkit-scrollbar { width: 6px; }
.pu-device-dropdown::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,.65);
  border-radius: 99px;
}

.pu-device-option {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--pu-border);
  transition: background var(--pu-trans);
}

.pu-device-option:last-child { border-bottom: none; }
.pu-device-option:hover { background: rgba(13,148,136,.10); }

.pu-opt-code { font-weight: 900; font-size: 12px; color: var(--pu-text); }
.pu-opt-name { font-size: 10px; color: var(--pu-text-sub); margin-top: 2px; }
.pu-opt-type {
  display: inline-block;
  margin-top: 4px;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pu-surface-2);
  color: var(--pu-text-sub);
}

/* Quick name */
.pu-quick-name-btn {
  height: 34px;
  width: fit-content;
  padding: 0 12px;
  border-radius: var(--pu-r);

  border: 1.5px dashed rgba(217, 119, 6, 0.178);
  background: var(--pu-amber-soft);
  color: var(--pu-amber);

  font-size: 12px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  transition: all var(--pu-trans);
}

.pu-quick-name-btn:hover {
  background: var(--pu-amber);
  color: #fff;
  border-color: var(--pu-amber);
}

/* Nút Nhập nhanh đặt cạnh ô tìm kiếm, nhìn nhẹ hơn ô tìm kiếm */
.pu-quick-name-btn.pu-quick-inline{
  height: 38px;
  border: 1.5px solid var(--pu-border);
  background: var(--pu-surface);
  color: var(--pu-text-sub);
}

.pu-quick-name-btn.pu-quick-inline:hover{
  background: var(--pu-surface-2);
  border-color: var(--pu-border-2);
  color: var(--pu-text);
}

/* ──────────────────────────────────────────────────────────
  10) PHOTO ACTIONS + DROPZONE + PREVIEW GRID
────────────────────────────────────────────────────────── */
.pu-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pu-photo-action-btn {
  flex: 1;
  min-width: 120px;
  height: 42px;

  border-radius: var(--pu-r);
  border: 1.5px solid var(--pu-border);
  background: var(--pu-surface);
  color: var(--pu-text-sub);

  font-size: 12px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  transition: all var(--pu-trans);
}

.pu-photo-action-btn:hover {
  border-color: rgba(13,148,136,.75);
  background: rgba(13,148,136,.10);
  color: var(--pu-teal);
}

.pu-photo-action-btn.pu-btn-camera {
  border-color: transparent;
  background: var(--pu-sky-soft);
  color: var(--pu-sky);
}

.pu-photo-action-btn.pu-btn-camera:hover {
  background: var(--pu-sky);
  color: #fff;
}

.pu-dropzone {
  border: 2px dashed var(--pu-border-2);
  border-radius: var(--pu-r);
  background: var(--pu-surface);
  color: var(--pu-text-mute);

  padding: 18px 12px;
  text-align: center;
  cursor: pointer;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;

  transition: all var(--pu-trans);
}

.pu-dropzone i { font-size: 22px; }
.pu-dz-ja { font-size: 12px; font-weight: 900; color: var(--pu-text-sub); }
.pu-dz-vi { font-size: 10px; font-weight: 700; font-style: italic; }

.pu-dropzone:hover,
.pu-dropzone.pu-drag-over {
  border-color: rgba(13,148,136,.85);
  background: rgba(13,148,136,.10);
  color: var(--pu-teal);
}

.pu-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

@media (max-width: 480px) {
  .pu-preview-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 6px; }
}

.pu-preview-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--pu-r-sm);
  overflow: hidden;

  border: 1.5px solid var(--pu-border);
  background: var(--pu-bg);

  cursor: pointer;
  transition: transform var(--pu-trans), border-color var(--pu-trans);
}

.pu-preview-item:hover {
  border-color: rgba(13,148,136,.85);
  transform: translateY(-1px);
}

.pu-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Thumb star */
.pu-preview-thumb-star {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 99px;
  background: var(--pu-teal);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
}

/* Edit/Delete buttons (JS tạo trong grid) */
.pu-preview-edit-btn,
.pu-preview-del {
  position: absolute;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 99px;
  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  transition: transform var(--pu-trans), opacity var(--pu-trans);
  opacity: 0;
}

.pu-preview-edit-btn {
  right: 6px;
  bottom: 6px;
  background: rgba(14,165,233,.88); /* edit = sky */
}

.pu-preview-del {
  right: 6px;
  top: 6px;
  background: rgba(220,38,38,.88);  /* delete = red */
}

.pu-preview-item:hover .pu-preview-edit-btn,
.pu-preview-item:hover .pu-preview-del {
  opacity: 1;
}

.pu-preview-edit-btn:hover,
.pu-preview-del:hover {
  transform: scale(1.06);
}

/* Touch device: luôn hiện để dễ bấm */
@media (hover: none) and (pointer: coarse) {
  .pu-preview-edit-btn,
  .pu-preview-del {
    opacity: 1;
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .pu-preview-thumb-star {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }
}

/* ──────────────────────────────────────────────────────────
  11) RESIZE MODES + THUMB ROW
────────────────────────────────────────────────────────── */
.pu-field-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
  margin-bottom: 2px;
}

.pu-field-label .pu-ja { color: var(--pu-text); font-size: 12px; }
.pu-field-label .pu-vi { color: var(--pu-text-mute); font-size: 10px; opacity: 1; }

.pu-resize-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pu-resize-mode-btn {
  flex: 1;
  min-width: 92px;
  height: 36px;

  border: 1.5px solid var(--pu-border);
  border-radius: var(--pu-r);
  background: var(--pu-surface);
  color: var(--pu-text-sub);

  font-size: 11px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  transition: all var(--pu-trans);
}

.pu-resize-mode-btn:hover {
  border-color: rgba(124,58,237,.75);
  background: var(--pu-violet-soft);
  color: var(--pu-violet);
}

.pu-resize-mode-btn.pu-active {
  border-color: var(--pu-violet);
  background: var(--pu-violet);
  color: #fff;
}

.pu-thumb-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  border-radius: var(--pu-r);

  background: rgba(13,148,136,.10);
  border: 1.5px solid rgba(13,148,136,.55);
  cursor: pointer;
}

.pu-thumb-toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--pu-teal);
  cursor: pointer;
  flex-shrink: 0;
}

.pu-thumb-toggle-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.pu-thumb-toggle-text .pu-ja { font-size: 12px; font-weight: 900; color: var(--pu-teal); }
.pu-thumb-toggle-text .pu-vi { font-size: 10px; color: var(--pu-text-sub); font-style: italic; }

.pu-thumb-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;

  font-size: 11px;
  color: var(--pu-text-mute);
  padding: 0 4px 2px;
}

.pu-thumb-note i { color: var(--pu-teal); margin-top: 2px; }

/* ──────────────────────────────────────────────────────────
  12) EMAIL CHIPS (CC)
────────────────────────────────────────────────────────── */
.pu-email-chips-wrap {
  min-height: 42px;
  border: 1.5px solid var(--pu-border);
  border-radius: var(--pu-r);
  padding: 6px 8px;

  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;

  background: var(--pu-surface);
  cursor: text;
  transition: border-color var(--pu-trans), box-shadow var(--pu-trans);
}

.pu-email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  padding: 4px 10px;
  border-radius: 999px;

  background: var(--pu-sky-soft);
  color: var(--pu-sky);

  font-size: 12px;
  font-weight: 900;
}

.pu-email-chip button {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--pu-sky);
  opacity: .75;
  transition: opacity var(--pu-trans);
  display: inline-flex;
  align-items: center;
}

.pu-email-chip button:hover { opacity: 1; }

.pu-email-chip-input {
  border: none !important;
  box-shadow: none !important;
  outline: none !important;

  height: 26px;
  min-width: 140px;

  background: transparent !important;
  padding: 0 2px;
  font-size: 13px;
  color: var(--pu-text);
}

/* ──────────────────────────────────────────────────────────
  13) PROGRESS + SEND RESULT
────────────────────────────────────────────────────────── */
.pu-progress-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pu-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;

  font-size: 11px;
  font-weight: 900;
  color: var(--pu-text-sub);
}

.pu-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--pu-border);
  border-radius: 99px;
  overflow: hidden;
}

.pu-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pu-teal), var(--pu-sky));
  border-radius: 99px;
  transition: width .35s ease;
}

.pu-send-result {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--pu-r);
  font-size: 12px;
  font-weight: 900;

  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--pu-border);
  background: var(--pu-surface);
  color: var(--pu-text-sub);
}

.pu-send-result.pu-success {
  border-color: rgba(22,163,74,.6);
  background: var(--pu-green-soft);
  color: var(--pu-green);
}

.pu-send-result.pu-error {
  border-color: rgba(220,38,38,.6);
  background: var(--pu-red-soft);
  color: var(--pu-red);
}

/* ──────────────────────────────────────────────────────────
  14) FOOTER (ACTIONS)
────────────────────────────────────────────────────────── */
.pu-footer {
  flex-shrink: 0;

  display: flex;
  gap: 8px;
  align-items: center;

  padding: 12px 12px calc(12px + var(--pu-safe-b));
  background: var(--pu-surface);
  border-top: 1px solid var(--pu-border);
}

.pu-send-btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: var(--pu-r);

  background: linear-gradient(135deg, var(--pu-primary), var(--pu-primary-2));
  color: #fff;

  font-size: 14px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  transition: transform var(--pu-trans), filter var(--pu-trans), opacity var(--pu-trans);
}

.pu-send-btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.pu-send-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.pu-spinner {
  width: 16px;
  height: 16px;
  border-radius: 99px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  display: none;
  animation: pu-spin .75s linear infinite;
}

@keyframes pu-spin { to { transform: rotate(360deg); } }

.pu-send-btn.pu-sending .pu-spinner { display: inline-block; }
.pu-send-btn.pu-sending .pu-send-icon { display: none; }

.pu-save-only-btn,
.pu-cancel-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--pu-r);
  cursor: pointer;
  white-space: nowrap;

  font-size: 12px;
  font-weight: 900;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  transition: all var(--pu-trans);
}

.pu-save-only-btn {
  border: 1.5px solid rgba(13,148,136,.45);
  background: rgba(13,148,136,.10);
  color: var(--pu-teal);
}

.pu-save-only-btn:hover {
  border-color: rgba(13,148,136,.75);
  background: rgba(13,148,136,.16);
}

.pu-cancel-btn {
  border: 1.5px solid var(--pu-border);
  background: var(--pu-surface);
  color: var(--pu-text-sub);
}

.pu-cancel-btn:hover { background: var(--pu-surface-2); }

/* ──────────────────────────────────────────────────────────
  15) EDITOR OVERLAY (FULLSCREEN)
────────────────────────────────────────────────────────── */
.pu-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: #000;

  display: flex;
  flex-direction: column;

  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}

.pu-editor-overlay.pu-show {
  opacity: 1;
  visibility: visible;
}

.pu-editor-header {
  flex-shrink: 0;

  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.pu-editor-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.pu-editor-title .pu-ja { color: #fff; font-size: 13px; }
.pu-editor-title .pu-vi { color: rgba(255,255,255,.55); font-size: 10px; opacity: 1; }

.pu-editor-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pu-editor-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--pu-r-sm);

  border: 1px solid rgba(255,255,255,.22);
  background: transparent;
  color: rgba(255,255,255,.92);

  font-size: 11px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  transition: background var(--pu-trans);
}

.pu-editor-btn:hover { background: rgba(255,255,255,.10); }

.pu-editor-btn.pu-editor-apply {
  border-color: rgba(13,148,136,.85);
  background: rgba(13,148,136,.92);
}

.pu-editor-btn.pu-editor-apply:hover { background: rgba(13,148,136,.98); }

.pu-editor-btn.pu-editor-cancel-edit {
  border-color: rgba(220,38,38,.55);
  color: rgba(255,180,180,.95);
}

.pu-editor-btn.pu-editor-cancel-edit:hover { background: rgba(220,38,38,.18); }

.pu-editor-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #111;

  display: flex;
  align-items: center;
  justify-content: center;
}

.pu-editor-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Crop overlay */
.pu-crop-overlay { position: absolute; inset: 0; pointer-events: none; }
.pu-crop-mask { position: absolute; background: rgba(0,0,0,.55); }
.pu-crop-mask.top { top: 0; left: 0; right: 0; }
.pu-crop-mask.bottom { bottom: 0; left: 0; right: 0; }
.pu-crop-mask.left { top: 0; bottom: 0; left: 0; }
.pu-crop-mask.right { top: 0; bottom: 0; right: 0; }

.pu-crop-box {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4);
  pointer-events: auto;
}

.pu-crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid var(--pu-sky);
  border-radius: 2px;
}

.pu-crop-handle.nw { top: -7px; left: -7px; cursor: nw-resize; }
.pu-crop-handle.ne { top: -7px; right: -7px; cursor: ne-resize; }
.pu-crop-handle.sw { bottom: -7px; left: -7px; cursor: sw-resize; }
.pu-crop-handle.se { bottom: -7px; right: -7px; cursor: se-resize; }
.pu-crop-handle.n { top: -7px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.pu-crop-handle.s { bottom: -7px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.pu-crop-handle.w { left: -7px; top: 50%; transform: translateY(-50%); cursor: w-resize; }
.pu-crop-handle.e { right: -7px; top: 50%; transform: translateY(-50%); cursor: e-resize; }

/* Editor toolbar */
.pu-editor-toolbar {
  flex-shrink: 0;
  background: rgba(255,255,255,.04);
  border-top: 1px solid rgba(255,255,255,.10);
  padding-bottom: var(--pu-safe-b);
}

.pu-editor-tabs {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.pu-editor-tab {
  flex: 1;
  height: 42px;
  border: none;
  background: transparent;

  color: rgba(255,255,255,.55);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  border-bottom: 2px solid transparent;
  transition: all var(--pu-trans);
}

.pu-editor-tab:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); }
.pu-editor-tab.pu-active {
  color: var(--pu-sky);
  border-bottom-color: var(--pu-sky);
  background: rgba(14,165,233,.10);
}

.pu-editor-panel {
  display: none;
  padding: 12px 14px;
}

.pu-editor-panel.pu-active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pu-rotate-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pu-rotate-value {
  min-width: 54px;
  text-align: center;
  color: #fff;
  font-weight: 900;
}

.pu-rotate-slider {
  flex: 1;
  height: 4px;
  appearance: none;
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  outline: none;
}

.pu-rotate-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--pu-sky);
  box-shadow: 0 0 0 3px rgba(14,165,233,.25);
  cursor: grab;
}

.pu-rotate-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pu-rotate-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--pu-r-sm);
  border: 1px solid rgba(255,255,255,.22);
  background: transparent;
  color: rgba(255,255,255,.90);

  font-size: 11px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pu-rotate-btn:hover { background: rgba(255,255,255,.10); }
.pu-rotate-btn.pu-reset { border-color: rgba(217,119,6,.6); color: rgba(255,210,160,.95); }

.pu-flip-actions { display: flex; gap: 10px; }
.pu-flip-btn {
  flex: 1;
  height: 40px;

  border-radius: var(--pu-r);
  border: 1px solid rgba(255,255,255,.22);
  background: transparent;
  color: rgba(255,255,255,.88);

  font-size: 12px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  transition: all var(--pu-trans);
}

.pu-flip-btn:hover {
  border-color: rgba(14,165,233,.65);
  background: rgba(14,165,233,.14);
  color: var(--pu-sky);
}

.pu-flip-btn.pu-active {
  border-color: var(--pu-sky);
  background: var(--pu-sky);
  color: #fff;
}

.pu-crop-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pu-crop-info {
  flex: 1;
  text-align: center;
  color: rgba(255,255,255,.55);
  font-size: 11px;
  font-weight: 900;
}

.pu-crop-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--pu-r-sm);

  border: 1px solid rgba(255,255,255,.22);
  background: transparent;
  color: rgba(255,255,255,.90);

  font-size: 11px;
  font-weight: 900;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  transition: all var(--pu-trans);
}

.pu-crop-btn:hover { background: rgba(255,255,255,.10); }
.pu-crop-btn.pu-crop-apply {
  border-color: rgba(13,148,136,.85);
  background: rgba(13,148,136,.92);
}
.pu-crop-btn.pu-crop-apply:hover { background: rgba(13,148,136,.98); }
.pu-crop-btn.pu-crop-reset { border-color: rgba(217,119,6,.55); color: rgba(255,210,160,.95); }

/* ──────────────────────────────────────────────────────────
  16) CAMERA OVERLAY (FULLSCREEN)
────────────────────────────────────────────────────────── */
.pu-camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 10200;
  background: #000;

  display: flex;
  flex-direction: column;

  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}

.pu-camera-overlay.pu-show {
  opacity: 1;
  visibility: visible;
}

.pu-camera-video-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;

  display: flex;
  align-items: center;
  justify-content: center;
}

.pu-camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pu-camera-guide {
  position: absolute;
  inset: 10%;
  border: 2px solid rgba(255,255,255,.30);
  border-radius: var(--pu-r);
  pointer-events: none;
}

.pu-camera-toolbar {
  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;

  padding: 14px 18px calc(14px + var(--pu-safe-b));
  background: rgba(0,0,0,.72);
}

.pu-camera-shutter {
  width: 64px;
  height: 64px;
  border-radius: 99px;
  border: 4px solid rgba(255,255,255,.55);
  background: #fff;
  cursor: pointer;

  box-shadow: 0 0 0 6px rgba(255,255,255,.22);
  transition: transform var(--pu-trans), box-shadow var(--pu-trans);
}

.pu-camera-shutter:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 8px rgba(255,255,255,.28);
}

.pu-camera-side-btn {
  width: 48px;
  height: 48px;
  border-radius: 99px;
  border: 2px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.10);
  color: #fff;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  transition: background var(--pu-trans);
}

.pu-camera-side-btn:hover { background: rgba(255,255,255,.18); }

/* ──────────────────────────────────────────────────────────
  17) RESPONSIVE TUNING (MOBILE)
────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .pu-overlay {
    align-items: flex-end;
    padding: 10px 10px calc(10px + var(--pu-safe-b));
  }

  .pu-dialog {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: calc(100dvh - 12px - var(--pu-safe-b));
  }

  /* Tránh iOS tự zoom input làm cảm giác “mất cuộn” */
  .pu-input,
  .pu-device-search-input,
  .pu-textarea,
  .pu-email-chip-input {
    font-size: 16px;
  }

  .pu-photo-action-btn { min-width: 96px; height: 40px; font-size: 12px; }
  .pu-footer { gap: 6px; }
  .pu-save-only-btn, .pu-cancel-btn { padding: 0 12px; }
}

/* ──────────────────────────────────────────────────────────
  18) (OPTIONAL) ACCESSIBILITY
────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pu-overlay,
  .pu-dialog,
  .pu-close-btn,
  .pu-photo-action-btn,
  .pu-preview-item,
  .pu-send-btn,
  .pu-device-option {
    transition: none !important;
  }
}

/* Highlight ô 検索 */
#puDeviceSearch{
  background: #FFF7DB;
  border: 2px solid rgba(245,158,11,.55);
  font-weight: 900;
}

#puDeviceSearch:focus{
  background: #fff;
  border-color: var(--pu-amber);
  box-shadow: 0 0 0 3px rgba(217,119,6,.18);
}

