/* MAD Mail UI kit styles (2026-10-06): tokens, toasts, notification center,
 * loading system. Shared by index.html and connect.html. Light first;
 * dark = the same components re-tokened under html[data-theme="dark"]. ASCII only. */
:root {
  --app-bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;
  --hairline: #e6e8ed;
  --hairline-strong: #d5d9e0;
  --text: #14161b;
  --text-2: #565c69;
  --text-3: #8a909c;
  --accent-ink: #0a6fbd;
  --ring: rgba(29, 161, 242, 0.28);
  --brand-soft: #fdecef;
  --sel-bg: #ebf4ff;
  --sel-bar: #1da1f2;
  --hover-bg: #f3f5f8;
  --mark-bg: #fff1a8;
  --mark-fg: inherit;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --bad: #c8102e;
  --bad-soft: #fdecef;
  --info: #0a6fbd;
  --info-soft: #e8f3fd;
  --skel-base: #eceef2;
  --skel-shine: rgba(255, 255, 255, 0.85);
  --skel-tint: rgba(200, 16, 46, 0.06);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-pop: 0 18px 40px -12px rgba(16, 24, 40, 0.22), 0 6px 12px -6px rgba(16, 24, 40, 0.10);
  --row-h: 84px;
  --topbar-h: 58px;
  --subbar-h: 50px;
  --pane-list: 380px;
  --splitter-w: 9px;
  --r-lg: 14px;
  --r-md: 10px;
}
html[data-theme="dark"] {
  --app-bg: #0b0c0f;
  --surface: #121419;
  --surface-2: #171a20;
  --surface-3: #1d2027;
  --hairline: #23262e;
  --hairline-strong: #30343d;
  --text: #f1f2f4;
  --text-2: #a7adb9;
  --text-3: #858b97; /* B11 2026-11-17: was #767c88 (4.39:1 on --surface); now >= 4.5:1 on surface, surface-2 and surface-3 */
  --accent-ink: #5cb8f5;
  --ring: rgba(92, 184, 245, 0.32);
  --brand-soft: #2a1016;
  --sel-bg: #10233a;
  --sel-bar: #5cb8f5;
  --hover-bg: #181b21;
  --mark-bg: #5a4700;
  --mark-fg: #fff7d6;
  --ok: #4ade80;
  --ok-soft: #0f2a1a;
  --warn: #f5b04b;
  --warn-soft: #2d2010;
  --bad: #ff6b7d;
  --bad-soft: #2a1016;
  --info: #5cb8f5;
  --info-soft: #0f2233;
  --skel-base: #1b1e24;
  --skel-shine: rgba(255, 255, 255, 0.06);
  --skel-tint: rgba(255, 69, 0, 0.06);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 18px 40px -12px rgba(0, 0, 0, 0.7), 0 6px 12px -6px rgba(0, 0, 0, 0.5);
}
/* The hidden attribute must win over component display rules. */
[hidden] { display: none !important; }
.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; }
/* ---------- toasts ---------- */
.mm-toasts { position: fixed; z-index: 400; right: 20px; bottom: calc(20px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; width: min(400px, calc(100vw - 24px)); }
.mm-toast-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mm-toast { pointer-events: auto; position: relative; display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 14px 12px 16px 14px; background: var(--surface); color: var(--text); border: 1px solid var(--hairline); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden; opacity: 0; transform: translateY(10px) scale(0.98); transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,.9,.3,1.2); }
.mm-toast.is-in { opacity: 1; transform: none; }
.mm-toast.is-out { opacity: 0; transform: translateX(16px); transition: opacity 160ms ease, transform 200ms ease; }
.mm-toast-ic { width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mm-toast-ic svg, .mm-np-ic svg, .mm-state-art svg, .mm-toast-x svg, .mm-np-close svg, .mm-np-empty-ic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mm-toast-success .mm-toast-ic { background: var(--ok-soft); color: var(--ok); }
.mm-toast-error .mm-toast-ic { background: var(--bad-soft); color: var(--bad); }
.mm-toast-warning .mm-toast-ic { background: var(--warn-soft); color: var(--warn); }
.mm-toast-info .mm-toast-ic { background: var(--info-soft); color: var(--info); }
.mm-toast-error { border-color: color-mix(in srgb, var(--bad) 35%, var(--hairline)); }
.mm-toast-body { flex: 1; min-width: 0; padding-top: 1px; }
.mm-toast-title { font-weight: 650; font-size: 14px; line-height: 1.3; }
.mm-toast-msg { font-size: 13px; color: var(--text-2); margin-top: 2px; line-height: 1.4; overflow-wrap: anywhere; }
.mm-toast-act { font-size: 13px; font-weight: 700; color: var(--accent-ink); padding: 6px 8px; border-radius: 8px; flex-shrink: 0; }
.mm-toast-act:hover { background: var(--hover-bg); }
.mm-toast-x { width: 28px; height: 28px; border-radius: 8px; color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mm-toast-x:hover { background: var(--hover-bg); color: var(--text); }
.mm-toast-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; transform-origin: left center; background: currentColor; opacity: 0.35; }
.mm-toast-success .mm-toast-bar { color: var(--ok); }
.mm-toast-error .mm-toast-bar { color: var(--bad); }
.mm-toast-warning .mm-toast-bar { color: var(--warn); }
.mm-toast-info .mm-toast-bar { color: var(--info); }
@media (max-width: 1023px) {
  .mm-toasts { left: 12px; right: 12px; width: auto; align-items: stretch; bottom: calc(68px + var(--safe-bottom)); }
}

/* ---------- notification center ---------- */
.mm-np { position: absolute; top: calc(100% + 6px); right: 8px; width: min(400px, calc(100vw - 16px)); max-height: min(72vh, 620px); display: none; flex-direction: column; background: var(--surface); border: 1px solid var(--hairline); border-radius: 16px; box-shadow: var(--shadow-pop); z-index: 150; overflow: hidden; }
.mm-np.show { display: flex; animation: mm-pop 140ms ease-out; }
.mm-np-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--hairline); }
.mm-np-head h3 { margin: 0; font: 700 15px/1.2 var(--font-display); }
.mm-np-tabs { display: flex; gap: 2px; margin-left: auto; background: var(--surface-3); padding: 3px; border-radius: 9px; }
.mm-np-tabs button { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 7px; color: var(--text-2); }
.mm-np-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.mm-np-close { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); }
.mm-np-list { overflow-y: auto; flex: 1; padding: 6px; }
.mm-np-item { display: flex; gap: 12px; padding: 10px; border-radius: 10px; }
.mm-np-item:hover { background: var(--hover-bg); }
.mm-np-item.is-unread { background: var(--surface-2); }
.mm-np-item.is-unread .mm-np-title::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--color-fire); margin-left: 8px; vertical-align: middle; }
.mm-np-ic { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mm-np-success .mm-np-ic { background: var(--ok-soft); color: var(--ok); }
.mm-np-error .mm-np-ic { background: var(--bad-soft); color: var(--bad); }
.mm-np-warning .mm-np-ic { background: var(--warn-soft); color: var(--warn); }
.mm-np-info .mm-np-ic { background: var(--info-soft); color: var(--info); }
.mm-np-text { min-width: 0; }
.mm-np-title { font-size: 13.5px; font-weight: 600; }
.mm-np-msg { font-size: 12.5px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.mm-np-time { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.mm-np-foot { display: flex; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--hairline); }
.mm-np-link { font-size: 12.5px; font-weight: 600; color: var(--accent-ink); padding: 6px 8px; border-radius: 8px; }
.mm-np-link:hover { background: var(--hover-bg); }
.mm-np-empty { text-align: center; padding: 36px 16px; color: var(--text-2); font-size: 14px; }
.mm-np-empty-ic { display: inline-flex; width: 44px; height: 44px; border-radius: 14px; align-items: center; justify-content: center; background: var(--ok-soft); color: var(--ok); margin-bottom: 10px; }
.mm-np-empty-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
@media (max-width: 639px) {
  .mm-np { position: fixed; top: calc(var(--topbar-h) + var(--safe-top) + 4px); left: 8px; right: 8px; width: auto; }
}

/* ---------- loading system ---------- */
.mm-skel { display: block; background: var(--skel-base); border-radius: 6px; position: relative; overflow: hidden; }
.mm-skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent 0%, var(--skel-tint) 35%, var(--skel-shine) 50%, var(--skel-tint) 65%, transparent 100%); animation: mm-shimmer 1.35s ease-in-out infinite; }
.mm-skel-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 44px; column-gap: 12px; align-items: start; min-height: var(--row-h); padding: 12px 16px 12px 18px; border-bottom: 1px solid var(--hairline); }
html[data-density="compact"] .mm-skel-row { padding-top: 8px; padding-bottom: 8px; grid-template-columns: 28px minmax(0, 1fr) 44px; }
.mm-skel-av { width: 36px; height: 36px; border-radius: 50%; }
html[data-density="compact"] .mm-skel-row .mm-skel-av { width: 28px; height: 28px; }
.mm-skel-av.lg { width: 40px; height: 40px; }
.mm-skel-lines { display: flex; flex-direction: column; gap: 9px; padding-top: 3px; min-width: 0; }
.mm-skel-line { height: 10px; }
.mm-skel-faint { opacity: 0.6; }
.mm-skel-date { height: 10px; width: 40px; margin-top: 5px; }
.mm-skel-reader { padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.mm-skel-h1 { height: 20px; width: 62%; border-radius: 8px; }
.mm-skel-from { display: flex; gap: 12px; align-items: center; }
.mm-skel-from .mm-skel-lines { flex: 1; }
.mm-skel-actions { display: flex; gap: 8px; }
.mm-skel-btn { width: 84px; height: 34px; border-radius: 10px; }
.mm-skel-body { display: flex; flex-direction: column; gap: 11px; }
.mm-skel-gap { height: 6px; background: transparent; }
.mm-skel-gap::after { display: none; }
.mm-spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; vertical-align: -2px; flex-shrink: 0; }
.mm-progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 6; opacity: 0; pointer-events: none; overflow: hidden; transition: opacity 200ms; }
.mm-progress.is-on { opacity: 1; }
.mm-progress-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--color-primary), var(--color-fire)); border-radius: 0 3px 3px 0; transition: width 280ms ease; }
.mm-progress.is-indet .mm-progress-fill { width: 34%; animation: mm-indet 1.1s ease-in-out infinite; }
.mm-progress.is-done .mm-progress-fill { background: var(--ok); }
.mm-progress.is-error .mm-progress-fill { background: var(--bad); }
.mm-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 24px; color: var(--text-2); }
.mm-state-art { width: 56px; height: 56px; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-3); margin-bottom: 6px; }
.mm-state-art svg { width: 26px; height: 26px; }
.mm-state-error .mm-state-art { background: var(--bad-soft); color: var(--bad); }
.mm-state-title { font: 600 16px/1.3 var(--font-display); color: var(--text); }
.mm-state-msg { font-size: 13.5px; max-width: 360px; }
.mm-state .btn { margin-top: 10px; }
/* ---------- livelier loading (2026-10-23 g27): staggered rows, brand-tinted
   avatar pulse, one-row EN/ES ticker (same height as the row it replaces, so no
   layout shift), streaming search progress. Off under prefers-reduced-motion. */
.mm-skel-row { animation: mm-rise 320ms ease both; animation-delay: calc(var(--mm-i, 0) * 70ms); }
.mm-skel-row .mm-skel::after { animation-delay: calc(var(--mm-i, 0) * 90ms); }
.mm-skel-row .mm-skel-av, .mm-skel-from .mm-skel-av { background: linear-gradient(135deg, var(--brand-soft) 0%, var(--skel-base) 72%); animation: mm-avpulse 1.6s ease-in-out infinite; animation-delay: calc(var(--mm-i, 0) * 90ms); }
.mm-tick { display: block; min-width: 0; max-width: 100%; font: 500 13px/16px var(--font, inherit); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity 180ms ease, transform 180ms ease; }
.mm-tick::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; background: var(--color-fire, #ff4500); animation: mm-dot 1.2s ease-in-out infinite; }
.mm-tick.is-out { opacity: 0; transform: translateY(-3px); }
.mm-tick-h1 { height: 20px; font-size: 14px; line-height: 20px; }
.mm-skel-tick-row .mm-skel-lines { gap: 10px; padding-top: 1px; }
.mm-results-head { position: relative; }
/* Two lines in every state (query, then status) so the head keeps its height
   when the live ticker turns into the final count. */
#msg-list > .mm-results-head .mm-rh-q { flex: 1 1 100%; max-width: 100%; }
#msg-list > .mm-results-head .mm-rh-meta { flex: 1 1 100%; margin-left: 0; min-height: 18px; line-height: 18px; }
.mm-results-head .mm-rh-live { display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.mm-results-head .mm-rh-live .mm-tick { display: inline-block; max-width: 230px; font-size: 12.5px; color: var(--text-2); }
.mm-results-head .mm-rh-count { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mm-rh-prog { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; overflow: hidden; pointer-events: none; }
.mm-rh-prog > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--color-primary, #c8102e), var(--color-fire, #ff4500)); border-radius: 0 2px 2px 0; transition: width 280ms ease; }
.mm-rh-hint { color: var(--text-3); }
@keyframes mm-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes mm-avpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes mm-dot { 0%, 100% { opacity: 0.35; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1); } }
@media (max-width: 639px) {
  .mm-results-head .mm-rh-live .mm-tick { max-width: 170px; }
}
@media (prefers-reduced-motion: reduce) {
  .mm-skel-row, .mm-skel-row .mm-skel-av, .mm-skel-from .mm-skel-av { animation: none; }
  .mm-tick, .mm-tick.is-out { transition: none; opacity: 1; transform: none; }
  .mm-tick::before { animation: none; opacity: 0.8; }
  .mm-rh-prog > span { transition: none; }
}
@keyframes mm-shimmer { to { transform: translateX(100%); } }
@keyframes mm-indet { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }
@keyframes mm-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .mm-skel::after { animation: none; display: none; }
  .mm-spin { animation: none; border-right-color: currentColor; opacity: 0.55; }
  .mm-progress.is-indet .mm-progress-fill { animation: none; width: 100%; opacity: 0.45; }
  .mm-toast, .mm-toast.is-in, .mm-toast.is-out { transition: opacity 120ms linear; transform: none; }
  .mm-search-pop.show, .mm-np.show { animation: none; }
  .pane-folders, .pane-reader { transition: none; }
}

.mm-hl { background: var(--mark-bg); color: var(--mark-fg); border-radius: 3px; padding: 0 1px; }

/* ---------- MVP 2026-11-17 (queue B): session-expired overlay (B08) and offline banner (B09) ---------- */
.mm-session-ov { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(11, 12, 15, 0.55); }
.mm-session-card { width: min(400px, 100%); background: var(--surface); color: var(--text); border: 1px solid var(--hairline); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 22px 20px 20px; text-align: center; }
.mm-session-card h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.3; }
.mm-session-card p { margin: 0 0 16px; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.mm-session-go { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 160px; padding: 0 18px; border-radius: 10px; font-weight: 700; text-decoration: none; }
.mm-offline { padding: 8px 16px; background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--warn); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.mm-offline.hidden { display: none; }

/* ---------- MVP 2026-11-17 (queue B11): focus rings and 44 px touch targets on the addon controls ---------- */
.mm-toast-x:focus-visible, .mm-toast-act:focus-visible, .mm-np-close:focus-visible, .mm-np-tabs button:focus-visible,
.mm-np-link:focus-visible, .mm-np-item:focus-visible, .mm-session-go:focus-visible, .mm-load-more:focus-visible,
.mm-acct-fix:focus-visible, .mm-wrong-acct a:focus-visible, .mm-wrong-acct button:focus-visible, .mm-storage-x:focus-visible, .mm-storage-mail:focus-visible {
  outline: 2px solid var(--accent-ink, #0a6fbd); outline-offset: 2px;
}
@media (pointer: coarse), (max-width: 767px) {
  .mm-toast-x, .mm-toast-act, .mm-np-close, .mm-np-tabs button, .mm-np-link, .mm-session-go, .mm-load-more { min-height: 44px; min-width: 44px; }
  .mm-toast-x, .mm-np-close { width: 44px; height: 44px; }
  .mm-toast-act, .mm-np-link { display: inline-flex; align-items: center; justify-content: center; }
}
