/* mail-jp.net — giao diện người dùng */
:root {
  --bg: #f4f5fb;
  --bg-2: #eef0fa;
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #ffffff;
  --surface-2: #f7f8fc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e4e7f1;
  --line-2: #d6dbea;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: rgba(99, 102, 241, .1);
  --accent: #ec4899;
  --ok: #10b981;
  --danger: #ef4444;
  /* chữ đỏ / chữ tím trên nền sáng: đậm hơn để đạt độ tương phản WCAG AA (≥ 4.5:1) */
  --danger-text: #dc2626;
  --primary-strong: #4f46e5;
  --warn: #f59e0b;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 52%, #ec4899 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --shadow: 0 12px 32px -14px rgba(30, 27, 75, .25), 0 2px 6px -2px rgba(15, 23, 42, .06);
  --shadow-lg: 0 30px 60px -24px rgba(30, 27, 75, .35), 0 8px 20px -10px rgba(15, 23, 42, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0d17;
  --bg-2: #10132a;
  --surface: rgba(20, 23, 40, .82);
  --surface-solid: #151829;
  --surface-2: #1b1f36;
  --text: #e7e9f5;
  --text-2: #c4c8de;
  --muted: #8a90ad;
  --line: #262a45;
  --line-2: #323758;
  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-soft: rgba(129, 140, 248, .14);
  --danger-text: #f87171;
  --primary-strong: #a5b4fc;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 14px 34px -14px rgba(0, 0, 0, .6), 0 2px 6px -2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 30px 70px -24px rgba(0, 0, 0, .75);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d17;
    --bg-2: #10132a;
    --surface: rgba(20, 23, 40, .82);
    --surface-solid: #151829;
    --surface-2: #1b1f36;
    --text: #e7e9f5;
    --text-2: #c4c8de;
    --muted: #8a90ad;
    --line: #262a45;
    --line-2: #323758;
    --primary: #818cf8;
    --primary-2: #a78bfa;
    --primary-soft: rgba(129, 140, 248, .14);
    --danger-text: #f87171;
    --primary-strong: #a5b4fc;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 14px 34px -14px rgba(0, 0, 0, .6), 0 2px 6px -2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 30px 70px -24px rgba(0, 0, 0, .75);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.theme-anim, html.theme-anim * { transition: background-color .4s var(--ease), border-color .4s var(--ease), color .3s var(--ease) !important; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  font: 15px/1.55 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }
svg { flex: none; }
::selection { background: rgba(139, 92, 246, .25); }

/* ---------- nền ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: radial-gradient(1200px 600px at 50% -10%, var(--bg-2), var(--bg)); }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; will-change: transform; animation: drift 26s ease-in-out infinite alternate; }
.b1 { width: 520px; height: 520px; background: #a5b4fc; top: -180px; left: -120px; }
.b2 { width: 460px; height: 460px; background: #f9a8d4; top: -120px; right: -140px; animation-delay: -7s; opacity: .45; }
.b3 { width: 420px; height: 420px; background: #c4b5fd; bottom: -220px; left: 35%; animation-delay: -14s; opacity: .35; }
:root[data-theme="dark"] .blob { opacity: .22; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .blob { opacity: .22; } }
@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(60px, 40px, 0); } }

/* ---------- thanh trên ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(14px, 4vw, 36px); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); background: color-mix(in srgb, var(--bg) 70%, transparent); border-bottom: 1px solid transparent; transition: border-color .3s; }
body.in-inbox .topbar { border-bottom-color: var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 750; font-size: 19px; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; filter: drop-shadow(0 6px 12px rgba(99, 102, 241, .35)); transition: transform .5s var(--spring); }
.brand:hover .logo { transform: rotate(-8deg) scale(1.06); }
.brand-accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tld { color: var(--muted); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* Nút công cụ: luôn có chữ ghi rõ chức năng, biểu tượng chỉ để minh hoạ. */
.tool-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text-2); cursor: pointer; font-size: 13.5px; font-weight: 650; white-space: nowrap; transition: transform .15s var(--ease), background .2s, color .2s, border-color .2s, box-shadow .2s; }
.tool-btn:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); box-shadow: 0 4px 14px -6px rgba(99, 102, 241, .45); }
.tool-btn:active { transform: scale(.96); }
.tool-btn svg { flex: none; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn.danger { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.tool-btn.danger:hover { color: #fff; background: #dc2626; border-color: #dc2626; box-shadow: 0 4px 14px -6px rgba(239, 68, 68, .55); }
#theme-btn .i-moon { display: none; }
:root[data-theme="dark"] #theme-btn .i-sun { display: none; }
:root[data-theme="dark"] #theme-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) #theme-btn .i-moon { display: block; }
}
#theme-btn svg { transition: transform .5s var(--spring); }
#theme-btn:hover svg { transform: rotate(25deg); }

.toggle .i-off { display: none; }
.toggle[aria-pressed="false"] .i-on { display: none; }
.toggle[aria-pressed="false"] .i-off { display: block; }
.toggle[aria-pressed="false"] { color: var(--muted); }
.toggle[aria-pressed="true"] { color: var(--primary-strong); background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); }

.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; font-weight: 650; font-size: 13px; color: var(--text-2); transition: border-color .2s, color .2s; }
.chip-btn:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.chip-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.lang-code { display: none; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 8px); min-width: 160px; padding: 6px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: pop .22s var(--spring); transform-origin: top right; z-index: 40; }
.menu-list button { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 9px; background: none; cursor: pointer; font-size: 14px; }
.menu-list button:hover { background: var(--primary-soft); }
.menu-list button.active { color: var(--primary); font-weight: 650; }
@keyframes pop { from { opacity: 0; transform: scale(.92) translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- nút ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; font-weight: 650; font-size: 14px; white-space: nowrap; transition: transform .15s var(--ease), box-shadow .25s var(--ease), background .2s, border-color .2s, color .2s, opacity .2s; }
.btn:active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 3px; }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { color: #fff; background: var(--grad); background-size: 160% 160%; background-position: 0% 50%; box-shadow: 0 10px 24px -10px rgba(99, 102, 241, .75), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn-primary:hover { background-position: 100% 50%; box-shadow: 0 16px 30px -12px rgba(139, 92, 246, .8), inset 0 1px 0 rgba(255, 255, 255, .25); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .85; cursor: progress; transform: none; }
.btn-lg { height: 54px; font-size: 16px; border-radius: 15px; padding: 0 24px; width: 100%; }
.btn-ghost { background: var(--surface-solid); border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); color: var(--primary); }
.btn-danger { color: #fff; background: linear-gradient(135deg, #e11d48, #dc2626); box-shadow: 0 10px 22px -10px rgba(239, 68, 68, .7); }
.btn-danger:hover { box-shadow: 0 14px 26px -10px rgba(239, 68, 68, .8); transform: translateY(-1px); }
.btn-arrow { transition: transform .3s var(--spring); }
.btn-primary:hover .btn-arrow { transform: translateX(4px); }
.btn .spinner { display: none; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-arrow { display: none; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }
.reader-loading .spinner { width: 28px; height: 28px; border-color: var(--primary-soft); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { border: 0; background: none; padding: 4px 6px; border-radius: 8px; color: var(--primary); cursor: pointer; font-size: 13px; font-weight: 600; }
.link-btn:hover { background: var(--primary-soft); }
.link-btn.danger { color: var(--danger-text); }
.link-btn.danger:hover { background: rgba(239, 68, 68, .1); }

/* ---------- khung trang ---------- */
main { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 clamp(14px, 3vw, 32px); }
/* fill "backwards" (không phải "both"): hết hiệu ứng thì bỏ transform, nếu không
   khung hộp thư thành khối chứa của phần tử position:fixed và màn hình đọc thư trên
   điện thoại bị neo theo khung đó thay vì phủ kín màn hình. */
.view.enter { animation: viewIn .5s var(--ease) backwards; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- trang chủ ---------- */
.view-home { padding: clamp(28px, 7vh, 72px) 0 40px; }
.hero { max-width: 620px; margin: 0 auto; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Tiêu đề: MAIL-JP.NET & FLASHMAIL.PRO, từng dòng hiện lần lượt (chỉ animate
   opacity/transform để mượt; fill "backwards" để hết hiệu ứng là bỏ lớp GPU). */
.brand-hero { display: flex; flex-direction: column; align-items: center; margin: 0 0 16px; font-size: clamp(34px, 7.4vw, 62px); font-weight: 850; line-height: 1.04; letter-spacing: -.025em; text-transform: uppercase; }
.bh-line { display: inline-block; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0 .04em; animation: heroIn .9s var(--ease) backwards; }
/* "MAIL - JP.NET": giãn hai bên dấu gạch cho dễ đọc; chữ thật vẫn là mail-jp.net */
.bh-dash { margin: 0 .2em; font-weight: 500; }
.bh-amp { display: block; margin: .06em 0 .02em; font: italic 400 .62em/1 Georgia, "Times New Roman", serif; color: var(--muted); text-transform: none; animation: ampIn .9s .12s var(--ease) backwards; }
.bh-line ~ .bh-line { animation-delay: .2s; }
.hero-tagline { display: inline-flex; align-items: center; gap: 14px; margin: 0 auto 30px; font-size: clamp(14px, 2.3vw, 17px); font-weight: 600; letter-spacing: .1em; color: var(--text-2); animation: heroIn .9s .32s var(--ease) backwards; }
.hero-tagline::before, .hero-tagline::after { content: ""; width: 28px; height: 1px; background: currentColor; opacity: .35; }
@keyframes heroIn { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }
@keyframes ampIn { from { opacity: 0; transform: scale(.6) rotate(-12deg); } to { opacity: 1; transform: none; } }

.access-card { position: relative; text-align: left; padding: 24px; border-radius: 24px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: rise .8s .4s var(--ease) backwards; }
.access-card::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: linear-gradient(135deg, rgba(99, 102, 241, .5), transparent 40%, transparent 60%, rgba(236, 72, 153, .45)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 22px, 0) scale(.98); } to { opacity: 1; transform: none; } }
.field-label { display: block; margin: 0 0 8px 2px; font-size: 13px; font-weight: 650; color: var(--text-2); }
.addr-field { display: flex; align-items: center; gap: 4px; height: 58px; padding: 0 14px; border-radius: 15px; background: var(--surface-solid); border: 1.5px solid var(--line-2); transition: border-color .2s, box-shadow .25s; }
.addr-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.addr-icon { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s; }
.addr-field:focus-within .addr-icon { stroke: var(--primary); }
.addr-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; padding: 0 6px; font: 600 17px var(--font); color: var(--text); }
/* địa chỉ sai: viền đỏ (kèm dòng báo "Email sai" bên dưới) */
.addr-field.invalid, .addr-field.invalid:focus-within { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, .12); }
.addr-field.invalid .addr-icon { stroke: var(--danger); }
.addr-field input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); font-weight: 500; }
.form-error { min-height: 0; margin: 0; color: var(--danger-text); font-size: 13.5px; font-weight: 550; overflow: hidden; max-height: 0; transition: max-height .3s var(--ease), margin .3s var(--ease); }
.form-error.show { max-height: 80px; margin: 10px 2px 0; }
.captcha-wrap { display: flex; justify-content: center; margin-top: 16px; min-height: 78px; border-radius: 12px; transition: box-shadow .2s; }
.captcha-wrap.invalid { box-shadow: 0 0 0 2px rgba(239, 68, 68, .5); }
.access-card .btn-lg { margin-top: 16px; }
.captcha-terms { margin: 8px 2px 0; font-size: 11.5px; color: var(--muted); }
.grecaptcha-badge { visibility: hidden !important; }
.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }

.recent { margin-top: 22px; text-align: left; animation: rise .7s .5s var(--ease) backwards; }
.recent-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 10px; font-size: 13px; font-weight: 650; color: var(--muted); }
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip { display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; animation: chipIn .4s calc(var(--i, 0) * 50ms) var(--spring) both; transition: transform .2s var(--ease), border-color .2s, opacity .2s; }
.recent-chip:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.recent-chip.leaving { opacity: 0; transform: scale(.85); }
@keyframes chipIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
.recent-open { display: inline-flex; align-items: center; gap: 7px; padding: 7px 6px 7px 12px; border: 0; background: none; cursor: pointer; font-size: 13.5px; font-weight: 550; color: var(--text-2); }
.recent-open svg { width: 15px; height: 15px; fill: none; stroke: var(--primary); stroke-width: 1.8; }
.recent-ok { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.recent-x { display: grid; place-items: center; width: 28px; height: 28px; margin-right: 3px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.recent-x:hover { background: rgba(239, 68, 68, .1); color: var(--danger-text); }
.recent-x svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; }

.features { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; max-width: 720px; margin: clamp(40px, 8vh, 80px) auto 0; }
.feature { padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .3s var(--ease), box-shadow .3s var(--ease); animation: rise .8s var(--ease) backwards; }
.feature:nth-child(1) { animation-delay: .55s; } .feature:nth-child(2) { animation-delay: .65s; }
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature h3 { margin: 14px 0 6px; font-size: 16px; letter-spacing: -.01em; }
.feature p { margin: 0; color: var(--muted); font-size: 14px; }
.f-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: #fff; }
.f-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.f1 { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 10px 20px -10px #f97316; }
.f2 { background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 10px 20px -10px #8b5cf6; }
.feature:hover .f-icon svg { animation: wiggle .6s var(--spring); }
@keyframes wiggle { 0% { transform: rotate(0); } 30% { transform: rotate(-12deg) scale(1.1); } 60% { transform: rotate(8deg); } 100% { transform: none; } }

/* ---------- hộp thư ---------- */
.view-inbox { padding: 20px 0 24px; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.addr-box { display: flex; align-items: center; gap: 14px; min-width: 0; }
.addr-avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px; background: var(--grad); color: #fff; box-shadow: 0 10px 22px -10px rgba(139, 92, 246, .9); flex: none; }
.addr-avatar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.addr-info { min-width: 0; }
.addr-caption { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.addr-line { display: flex; align-items: center; gap: 8px; }
.addr-text { font-size: clamp(16px, 2.4vw, 21px); font-weight: 750; letter-spacing: -.01em; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-btn { flex: none; height: 34px; padding: 0 11px; }
.copy-btn .i-check { display: none; color: var(--ok); }
.copy-btn.copied { border-color: var(--ok); color: var(--ok); }
.copy-btn.copied .i-copy { display: none; }
.copy-btn.copied .i-check { display: block; animation: pop .35s var(--spring); stroke: var(--ok); stroke-width: 2.6; }
.inbox-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 38px; padding: 0 12px; border-radius: 11px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.live i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live[data-state="live"] { color: color-mix(in srgb, var(--ok) 80%, var(--text)); }
.live[data-state="live"] i { background: var(--ok); }
.live[data-state="live"] i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); animation: ring 1.8s ease-out infinite; }
.live[data-state="offline"] { color: var(--warn); }
.live[data-state="offline"] i { background: var(--warn); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }
@keyframes ring { 0% { transform: scale(.4); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
#refresh-btn.spin svg { animation: spin .7s var(--ease); }
/* Đăng xuất: nền đỏ để dễ thấy */
.logout-btn { height: 38px; padding: 0 15px; font-size: 13.5px; }

.mail-app { display: grid; grid-template-columns: minmax(300px, 390px) 1fr; gap: 16px; height: calc(100dvh - 210px); min-height: 480px; }
.list-pane, .reader { display: flex; flex-direction: column; min-height: 0; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.pane-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.list-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.mail-list { list-style: none; margin: 0; padding: 6px; }
.mail-item { position: relative; display: flex; gap: 12px; padding: 12px; border-radius: 14px; cursor: pointer; outline: 0; transition: background .2s, transform .2s var(--ease), box-shadow .2s; }
.mail-item + .mail-item { margin-top: 2px; }
.mail-item:hover { background: var(--surface-2); }
.mail-item:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.mail-item.selected { background: var(--primary-soft); }
.mail-item.selected::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--grad); }
.mail-list.stagger .mail-item { animation: itemIn .45s calc(var(--i, 0) * 45ms) var(--ease) both; }
@keyframes itemIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mail-item.fresh { animation: freshIn .7s var(--spring) both, freshGlow 2.4s .2s ease-out both; }
@keyframes freshIn { from { opacity: 0; transform: translateY(-18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes freshGlow { 0% { background: rgba(139, 92, 246, .22); box-shadow: 0 0 0 2px rgba(139, 92, 246, .35); } 100% { background: transparent; box-shadow: none; } }
.mail-item.removing { overflow: hidden; animation: removeOut .28s var(--ease) forwards; }
@keyframes removeOut { to { opacity: 0; height: 0; padding-top: 0; padding-bottom: 0; margin: 0; transform: translateX(-30px); } }
.avatar { --h: 250; display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; font-weight: 750; font-size: 16px; color: hsl(var(--h) 70% 38%); background: hsl(var(--h) 85% 92%); }
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 85% 80%); background: hsl(var(--h) 40% 22%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 85% 80%); background: hsl(var(--h) 40% 22%); } }
.mi-body { flex: 1; min-width: 0; }
.mi-top { display: flex; align-items: baseline; gap: 8px; }
.mi-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--text-2); }
.mi-time { flex: none; font-size: 12px; color: var(--muted); }
.mi-subject { display: flex; align-items: center; gap: 5px; margin-top: 1px; font-size: 14px; color: var(--text-2); }
.mi-subject span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-clip { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; }
.mi-snippet { margin-top: 2px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.unread .mi-from, .mail-item.unread .mi-subject { color: var(--text); font-weight: 750; }
.mail-item.unread .mi-time { color: var(--primary); font-weight: 700; }
.mail-item.unread::after { content: ""; position: absolute; right: 12px; bottom: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 3px var(--primary-soft); }

.skeleton { pointer-events: none; }
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.avatar.sk { color: transparent; }
.sk-line { height: 11px; border-radius: 6px; margin: 5px 0 9px; }
.w40 { width: 40%; } .w60 { width: 60%; } .w80 { width: 85%; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; animation: viewIn .5s var(--ease) both; }
.empty-art svg { width: 150px; height: 125px; }
.empty-art .float { animation: float 3.2s ease-in-out infinite; }
.empty-art .shadow { fill: var(--line); animation: shadowPulse 3.2s ease-in-out infinite; transform-origin: 60px 92px; }
.empty-art .sparkles circle { fill: #f9a8d4; animation: twinkle 2.4s ease-in-out infinite; }
.empty-art .sparkles circle:nth-child(2) { fill: #a5b4fc; animation-delay: .8s; }
.empty-art .sparkles circle:nth-child(3) { fill: #fcd34d; animation-delay: 1.6s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes shadowPulse { 0%, 100% { transform: scaleX(1); opacity: .9; } 50% { transform: scaleX(.8); opacity: .5; } }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.1); } }
.empty h3 { margin: 10px 0 4px; font-size: 17px; }
.empty p { margin: 0; color: var(--muted); font-size: 14px; max-width: 260px; }
.waiting-dots { display: flex; gap: 6px; margin-top: 18px; }
.waiting-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); opacity: .3; animation: dots 1.4s ease-in-out infinite; }
.waiting-dots i:nth-child(2) { animation-delay: .2s; } .waiting-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-5px); } }

/* ---------- đọc thư ---------- */
.reader { position: relative; }
.reader-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.reader-placeholder svg { width: 54px; height: 54px; fill: none; stroke: currentColor; stroke-width: 1.4; opacity: .55; stroke-linecap: round; stroke-linejoin: round; }
.reader-placeholder p { margin: 0; font-weight: 550; }
.reader-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.reader-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.reader-toolbar .spacer { flex: 1; }
.back-btn { display: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 12px; white-space: nowrap; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s; }
.seg button.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.reader-scroll { flex: 1; overflow-y: auto; padding: 22px 24px 28px; overscroll-behavior: contain; }
.reader-scroll.enter { animation: readerIn .4s var(--ease) both; }
@keyframes readerIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.subject { margin: 0 0 16px; font-size: clamp(19px, 2.4vw, 24px); line-height: 1.3; letter-spacing: -.02em; overflow-wrap: anywhere; }
.meta { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px dashed var(--line-2); }
.meta-main { flex: 1; min-width: 0; }
.meta-from { overflow-wrap: anywhere; font-size: 14.5px; }
.meta-to { font-size: 13px; overflow-wrap: anywhere; }
.meta-date { flex: none; font-size: 13px; align-self: flex-start; }
.muted { color: var(--muted); }
.attachments { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.att { display: inline-flex; align-items: center; gap: 10px; max-width: 280px; padding: 9px 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface-solid); cursor: pointer; text-align: left; transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.att:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow); }
.att.busy { opacity: .6; cursor: progress; }
.att-icon { width: 22px; height: 22px; fill: none; stroke: var(--primary); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.att-dl { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--spring), stroke .2s; }
.att:hover .att-dl { stroke: var(--primary); transform: translateY(2px); }
.att-text { display: flex; flex-direction: column; min-width: 0; }
.att-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-text small { color: var(--muted); font-size: 12px; }
.body-card { margin-top: 18px; border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
#r-frame { display: block; width: 100%; height: 120px; border: 0; background: #fff; }
.text-body { margin: 0; padding: 18px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.65 var(--font); color: #1f2937; background: #fff; }
.text-body a { color: #4f46e5; }
.expire-note { margin: 14px 2px 0; font-size: 12.5px; color: var(--muted); }
.reader-loading { position: absolute; inset: 52px 0 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface-solid) 60%, transparent); animation: viewIn .2s both; }

/* ---------- toast ---------- */
/* góc phải dưới, ngay trên nút hỗ trợ — ở trên sẽ che nút Đăng xuất */
.toasts { position: fixed; bottom: 96px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 28px)); pointer-events: none; }
.toast { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 16px; border-radius: 16px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); overflow: hidden; pointer-events: auto; animation: toastIn .55s var(--spring) both; }
.toast.clickable { cursor: pointer; }
.toast.clickable:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.toast.leaving { animation: toastOut .32s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(60px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(60px) scale(.95); } }
.toast-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; flex: none; color: #fff; background: var(--primary); }
.toast-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.toast-mail .toast-icon { background: var(--grad); box-shadow: 0 8px 18px -8px rgba(139, 92, 246, .9); }
.toast-mail .toast-icon svg { animation: bell 1s .2s ease-in-out 2; transform-origin: 50% 10%; }
@keyframes bell { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(16deg); } 30% { transform: rotate(-14deg); } 45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); } }
.toast-success .toast-icon { background: var(--ok); }
.toast-error .toast-icon { background: var(--danger); }
.toast-info .toast-icon { background: var(--primary); }
.toast-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.toast-text strong { font-size: 14.5px; }
.toast-text span { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-text small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast-close { display: grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; flex: none; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--grad); transform-origin: left; animation: bar linear forwards; }
.toast-success .toast-bar { background: var(--ok); }
.toast-error .toast-bar { background: var(--danger); }
@keyframes bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity .22s; }
.modal-card { position: relative; width: min(400px, 100%); padding: 26px 24px 20px; border-radius: 22px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); text-align: center; opacity: 0; transform: translateY(14px) scale(.96); transition: opacity .22s, transform .3s var(--spring); }
.modal.open .modal-backdrop { opacity: 1; }
.modal.open .modal-card { opacity: 1; transform: none; }
.modal-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; background: rgba(239, 68, 68, .12); color: var(--danger); }
.modal-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* ---------- chân trang ---------- */
.footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 18px 16px 22px; font-size: 13px; color: var(--muted); }
body.in-inbox .footer { padding-top: 0; }

/* ---------- hộp thư trên máy tính ---------- */
/* Khung thư lấp phần còn lại của màn hình, dù đầu hộp thư một hàng hay xuống hai hàng
   (không trừ cứng một chiều cao cố định). Màn hình thấp: khung giữ tối thiểu 360px và
   trang cuộn như thường. */
@media (min-width: 901px) {
  body.in-inbox { height: 100vh; height: 100dvh; }
  body.in-inbox main { display: flex; flex-direction: column; }
  body.in-inbox .view-inbox { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  /* contain: size — chiều cao khung lấy theo chỗ trống, không bị nội dung thư dài kéo giãn */
  body.in-inbox .mail-app { flex: 1; height: auto; min-height: 360px; contain: size; }
  /* chừa chỗ dưới cùng cho nút hỗ trợ, để nút không che khung đọc thư và thanh cuộn */
  body.has-support.in-inbox .view-inbox { padding-bottom: 72px; }
}

/* ---------- màn hình nhỏ ---------- */
@media (max-width: 900px) {
  /* chừa chỗ cho nút hỗ trợ ở góc phải dưới, để nút không che dòng chữ chân trang */
  body.has-support .footer { padding-bottom: 92px; }
  .features { grid-template-columns: 1fr; max-width: 520px; }
  .mail-app { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .list-pane { min-height: 60vh; }
  .list-scroll { overflow: visible; }
  .reader { position: fixed; inset: 0; z-index: 60; border-radius: 0; border: 0; transform: translateX(100%); transition: transform .38s var(--ease); visibility: hidden; background: var(--surface-solid); backdrop-filter: none; }
  .mail-app.reading .reader { transform: none; visibility: visible; }
  body.reading { overflow: hidden; }
  .reader-placeholder { display: none !important; }
  .back-btn { display: inline-flex; }
  .reader-toolbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .reader-scroll { padding: 18px 16px 96px; }
  .inbox-head { padding: 12px; }
  /* Hàng 1: trạng thái + Làm mới; hàng 2: âm thanh, thông báo (và Đăng xuất nếu đủ chỗ). */
  .inbox-actions { width: 100%; }
  .inbox-actions .live { flex: 1 1 55%; }
  .inbox-actions .live > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inbox-actions .tool-btn, .inbox-actions .logout-btn { flex: 1 1 auto; }
  .inbox-actions #refresh-btn { flex: 0 0 auto; }
  /* chừa chỗ cho nút hỗ trợ ở góc phải dưới */
  .toasts { bottom: 92px; right: 14px; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(40px) scale(.95); } to { opacity: 1; transform: none; } }
  @keyframes toastOut { to { opacity: 0; transform: translateY(40px); } }
}
@media (max-width: 520px) {
  .brand-tld { display: none; }
  .access-card { padding: 18px 14px; border-radius: 20px; }
  .addr-field { height: 54px; padding: 0 10px 0 12px; }
  /* 16px: nhỏ hơn thì Safari trên iPhone tự phóng to trang khi chạm vào ô nhập.
     Chữ gợi ý (liệt kê các domain) nhỏ hơn và bỏ biểu tượng để hiện đủ trên điện thoại. */
  .addr-field input { font-size: 16px; padding: 0 4px; }
  .addr-field input::placeholder { font-size: 14px; }
  .addr-icon { display: none; }
  /* Địa chỉ email riêng một dòng (không bị nút Sao chép cắt mất), nút Sao chép xuống dưới. */
  .addr-avatar { display: none; }
  .addr-line { flex-wrap: wrap; row-gap: 8px; }
  .addr-text { flex: 1 1 100%; }
  .hero-tagline { gap: 10px; letter-spacing: .06em; }
  .hero-tagline::before, .hero-tagline::after { width: 16px; }
  .captcha-wrap { transform: scale(.92); transform-origin: center; }
  .meta-date { display: none; }
}
@media (max-width: 640px) {
  /* Điện thoại: hai nút bật/tắt chia đôi một hàng, Đăng xuất riêng một hàng, to và đỏ. */
  .inbox-actions #sound-btn, .inbox-actions #notify-btn { flex: 1 1 40%; }
  .inbox-actions .logout-btn { flex: 1 1 100%; height: 46px; font-size: 15px; border-radius: 13px; }
  .logout-btn svg { width: 19px; height: 19px; }
}
@media (max-width: 420px) {
  .lang-name { display: none; }
  .lang-code { display: inline; }
}

@media (max-width: 400px) {
  .reader-toolbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .reader-toolbar .tool-btn { padding: 0 10px; gap: 5px; }
  .seg button { padding: 5px 9px; }
}

@media (max-width: 360px) {
  .topbar { gap: 8px; }
  .brand { font-size: 17px; gap: 8px; }
  .chip-btn { padding: 0 9px; gap: 5px; }
  .addr-field { padding: 0 8px; }
  .addr-field input { padding: 0 2px; }
  .addr-field input::placeholder { font-size: 13px; }
  .reader-toolbar { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .reader-toolbar .tool-btn { padding: 0 8px; }
  .seg button { padding: 5px 7px; }
  .inbox-actions .tool-btn { padding: 6px 8px; gap: 5px; font-size: 12.5px; height: auto; min-height: 40px; white-space: normal; line-height: 1.2; }
}

/* ---------- nút hỗ trợ Zalo (góc phải dưới) ---------- */
.zalo-container { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 90; }
.zalo-container a { position: relative; display: flex; align-items: center; gap: 10px; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.zalo-label { padding: 7px 13px; border-radius: 999px; background: #0068ff; color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 8px 20px -8px rgba(0, 104, 255, .75); }
.zalo-icon { position: relative; z-index: 2; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; background: #0068ff; box-shadow: 0 10px 24px -8px rgba(0, 104, 255, .75); transition: transform .25s var(--spring); }
.zalo-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.zalo-icon svg { width: 26px; height: 26px; fill: #fff; }
.zalo-container a:hover .zalo-icon { transform: scale(1.08); }
.zalo-container a:focus-visible { outline: none; }
.zalo-container a:focus-visible .zalo-icon { outline: 3px solid var(--primary); outline-offset: 3px; }
/* hai vòng sóng quanh biểu tượng (tâm trùng tâm biểu tượng 56px ở mép phải) */
.cmoz-alo-circle, .cmoz-alo-circle-fill { position: absolute; z-index: 1; border-radius: 50%; pointer-events: none; }
.cmoz-alo-circle { width: 80px; height: 80px; right: -12px; top: calc(50% - 40px); border: 2px solid #0068ff; }
.cmoz-alo-circle-fill { width: 68px; height: 68px; right: -6px; top: calc(50% - 34px); background: rgba(0, 104, 255, .3); }
.animated_zalo { animation-duration: 1.2s; animation-fill-mode: both; }
.animated_zalo.infinite { animation-iteration-count: infinite; }
.zoomIn_zalo { animation-name: zoomIn_zalo; }
.pulse_zalo { animation-name: pulse_zalo; }
@keyframes zoomIn_zalo { from { opacity: 0; transform: scale(.5); } 40% { opacity: .8; } to { opacity: 0; transform: scale(1); } }
@keyframes pulse_zalo { from, to { transform: scale(1); } 50% { transform: scale(1.1); } }
@media print { .zalo-container { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
