/* ---------- Popup thông báo + viền màu chạy ---------- */
  @property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
  @keyframes tspin { to { --ang: 360deg; } }
  @keyframes tin { from { opacity: 0; transform: translateY(18px) scale(0.9); } to { opacity: 1; transform: none; } }
  @keyframes tout { to { opacity: 0; transform: translateY(14px) scale(0.94); } }
  @keyframes tshake { 0%, 100% { translate: 0; } 20% { translate: -7px; } 40% { translate: 6px; } 60% { translate: -4px; } 80% { translate: 3px; } }
  @keyframes tpop { from { transform: scale(0.2) rotate(-90deg); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes tdraw { to { stroke-dashoffset: 0; } }
  @keyframes tcount { to { transform: scaleX(0); } }
  @keyframes trun { to { transform: scaleX(0.03); } }
  @keyframes tpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

  /* Các thông báo chữ cũ vẫn được cập nhật cho trình đọc màn hình nhưng không hiện ra nữa */
  .status { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; min-height: 0; }

  #toasts { position: fixed; z-index: 9999; bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
  .toast {
    --c1: #e11d2e; --c2: #ff9f1c; --c3: #ff2d95;
    pointer-events: auto; position: relative; overflow: hidden;
    width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box;
    display: grid; grid-template-columns: auto 1fr auto auto; align-items: start; gap: 12px;
    padding: 14px 10px 17px 14px; border: 2px solid transparent; border-radius: 16px;
    color: var(--ink); font-size: 14px; line-height: 1.45;
    background: linear-gradient(var(--surface), var(--surface)) padding-box,
                conic-gradient(from var(--ang), var(--c1), var(--c2), var(--c3), var(--c1)) border-box;
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45), 0 0 26px color-mix(in srgb, var(--c1) 38%, transparent);
    animation: tin 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
  }
  .toast.ok { --c1: #22c55e; --c2: #2dd4bf; --c3: #a3e635; }
  .toast.err { --c1: #ff3b30; --c2: #ff9f1c; --c3: #e11d2e; animation: tin 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) both, tshake 0.5s 0.1s both; }
  .toast.run, .toast.info { --c1: #3b82f6; --c2: #06b6d4; --c3: #8b5cf6; }
  .toast.warn { --c1: #f59e0b; --c2: #fbbf24; --c3: #ef4444; }
  .toast.save { --c1: #10b981; --c2: #a3e635; --c3: #14b8a6; }
  .toast.danger { --c1: #ff3b30; --c2: #ff9f1c; --c3: #e11d2e; }
  .toast.ask { width: 100%; }
  .toast.out { animation: tout 0.3s ease-in forwards; }
  .ti { width: 26px; height: 26px; display: grid; place-items: center; margin-top: 1px; }
  .ti svg { width: 26px; height: 26px; animation: tpop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
  .ti .sp { width: 22px; height: 22px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--c1) 25%, transparent); border-top-color: var(--c1); }
  .ti .dr { stroke-dasharray: 24; stroke-dashoffset: 24; animation: tdraw 0.5s 0.12s ease forwards; }
  .tk { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--c1); }
  .tm { font-weight: 500; overflow-wrap: anywhere; max-height: 9.5em; overflow: auto; }
  .tt { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); padding-top: 3px; }
  .toast:not(.run) .tt { display: none; }
  #toasts .tx { all: unset; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 8px; border-radius: 8px; }
  #toasts .tx:hover { color: var(--ink); background: var(--raise); }
  .tbar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; transform-origin: left; background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3)); }
  /* Thanh màu = thời gian còn lại: đầy lúc đầu rồi co dần về 0 (đang xử lý: theo thời gian ước tính --est) */

  /* Dòng chữ trắng nằm dưới, tràn qua cả cột đồng hồ và nút đóng */
  #toasts .toast:not(.ask) { grid-template-areas: "ti tk tt tx" "ti tm tm tm"; row-gap: 3px; }
  #toasts .toast:not(.ask) .tb { display: contents; }
  #toasts .toast:not(.ask) .ti { grid-area: ti; }
  #toasts .toast:not(.ask) .tk { grid-area: tk; align-self: center; }
  #toasts .toast:not(.ask) .tt { grid-area: tt; align-self: center; padding-top: 0; }
  #toasts .toast:not(.ask) .tx { grid-area: tx; align-self: center; }
  #toasts .toast:not(.ask) .tm { grid-area: tm; padding-right: 6px; }

  @media (prefers-reduced-motion: reduce) {
    /* Chỉ bỏ hiệu ứng trượt vào và rung; viền chạy, vòng quay, thanh đếm do JS điều khiển nên vẫn chạy */
    .toast, .toast.err { animation: none; }
    .toast.out { animation: tout 0.3s ease-in forwards; }
  }