/* H5 shell (< 768px): compact header, menu drawer, bottom tab bar, compact footer
   and cross-page guards. Loaded last on every page so it wins over page sheets;
   page-specific phone layouts live at the end of each page's own stylesheet.

   Desktop rule: every new or changed rule lives inside a max-width: 767.98px
   query. H5-only markup ships with an inline style="display:none" and is shown
   from here with display: ... !important. (Not [hidden]: Tailwind's layered
   [hidden]{display:none!important} outranks any unlayered !important.)

   H5 design spec (tokens in :root below; reuse them in page H5 blocks):
   - Type: 22 page title / 18 section title / 16 card title / 15 body /
     13.5 secondary / 12 caption (floor). Titles 700, labels 600, body 400.
     CJK labels never get letter-spacing or uppercase.
   - Space: 4-pt steps (4 8 12 16 20 24 32); page gutter 20.
   - Controls: input 52, primary button 50, secondary 48, compact 40,
     chips 32-36. Every tap area >= 44 including padding.
   - Radius: 10 small controls / 14 inputs & buttons / 20 cards / 24 sheets.
     Full pills only for chips and tags.
   - Colour: ink #1f2335 titles, text #3d4359 body, muted #62677d secondary
     (5.6:1 on white, 5.1:1 on the #f5f4fa surface), placeholder #a0a5b8.
     Primary #4f34d9 with soft #f3f0ff fills; focus = primary border + 3px
     primary ring.
   - Helper text that only repeats the title or placeholder is hidden on
     phones (it stays reachable through aria-describedby). */

.fxm-m-menu-btn,
.fxm-m-nav,
.fxm-tabbar { display: none; }

@media (max-width: 767.98px) {
  :root {
    --fxm-m-header: 60px;
    --fxm-m-tabbar: 58px;
    --fxm-m-gutter: 20px;
    --fxm-m-primary: #4f34d9;
    --fxm-m-primary-soft: #f3f0ff;
    --fxm-m-primary-line: rgba(79, 52, 217, .3);
    --fxm-m-primary-ring: rgba(79, 52, 217, .14);
    --fxm-m-grad-primary: linear-gradient(135deg, #6a52f6 0%, #4f34d9 100%);
    --fxm-m-grad-accent: linear-gradient(90deg, #6c54f7, #89dfd7);
    --fxm-m-ink: #1f2335;
    --fxm-m-text: #3d4359;
    --fxm-m-muted: #62677d;
    --fxm-m-placeholder: #a0a5b8;
    --fxm-m-line: #e5e3ee;
    --fxm-m-line-soft: #efedf6;
    --fxm-m-surface: #fff;
    --fxm-m-surface-2: #f5f4fa;
    --fxm-m-danger: #d0384f;
    --fxm-m-danger-soft: #fff5f7;
    --fxm-m-r-sm: 10px;
    --fxm-m-r-md: 14px;
    --fxm-m-r-lg: 20px;
    --fxm-m-r-xl: 24px;
    --fxm-m-h-control: 52px;
    --fxm-m-h-btn: 50px;
    --fxm-m-shadow-card: 0 10px 28px -14px rgba(79, 52, 217, .16);
    --fxm-m-shadow-btn: 0 10px 22px -12px rgba(79, 52, 217, .6);
  }

  /* Nothing may widen the layout viewport on phones (mobile browsers zoom out to fit).
     Use clip so body does not become a scroll container and break position: sticky. */
  body { overflow-x: hidden; overflow-x: clip; }
  .overflow-x-auto { max-width: 100%; }
  img, video, iframe { max-width: 100%; }

  /* ---------- header ---------- */
  .fxm-site-header .h-18 { height: var(--fxm-m-header); }
  .fxm-site-header > .relative { padding-inline: 16px; gap: 8px; }
  .fxm-site-header a[aria-label] > img { height: 28px; }
  .fxm-site-header .fxm-header-end { gap: 8px; }
  .fxm-site-header [data-fxm-lang-switcher] { display: none; }
  .fxm-site-header [data-fxm-ai-open] { width: 36px; height: 36px; }
  .fxm-site-header [data-fxm-auth-guest] { gap: 0; }
  .fxm-site-header [data-fxm-auth-guest] > a:first-child {
    display: inline-flex;
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
    color: var(--color-primary, #4f34d9);
    border-color: rgba(79, 52, 217, .18);
    box-shadow: none;
  }
  .fxm-site-header [data-fxm-auth-guest] > a:last-child { display: none; }
  .fxm-site-header [data-fxm-user-menu-trigger] { padding: 2px; }
  .fxm-site-header [data-fxm-user-menu-trigger] img { width: 32px; height: 32px; }
  .fxm-site-header [data-fxm-user-menu-trigger] > svg { display: none; }
  .fxm-site-header [data-fxm-lang-menu],
  .fxm-site-header [data-fxm-user-menu-dropdown] { top: calc(var(--fxm-m-header) + 4px); }

  .fxm-m-menu-btn {
    display: inline-flex;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid #e8e6f5;
    border-radius: 12px;
    background: #fff;
    color: #272e42;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 160ms ease, transform 160ms ease;
  }
  .fxm-m-menu-btn:active { transform: scale(.94); background: #f4f2ff; }

  /* ---------- drawer ---------- */
  .fxm-m-nav { display: block; position: fixed; inset: 0; z-index: 90; }
  .fxm-m-nav[hidden] { display: none; }
  .fxm-m-nav__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 22, 40, .42);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 240ms ease;
  }
  .fxm-m-nav__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    width: min(86vw, 360px);
    flex-direction: column;
    border-radius: 20px 0 0 20px;
    background: #fbfaff;
    box-shadow: -18px 0 48px -24px rgba(39, 46, 66, .35);
    transform: translateX(104%);
    transition: transform 280ms cubic-bezier(.2, .8, .2, 1);
  }
  .fxm-m-nav.is-open .fxm-m-nav__backdrop { opacity: 1; }
  .fxm-m-nav.is-open .fxm-m-nav__panel { transform: none; }
  .fxm-m-nav__top {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px + env(safe-area-inset-top)) 16px 12px 20px;
  }
  .fxm-m-nav__logo { height: 26px; width: auto; }
  .fxm-m-nav__x {
    display: inline-flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #f0eef9;
    color: #4b5068;
  }
  .fxm-m-nav__scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .fxm-m-account {
    margin-bottom: 14px;
    border: 1px solid #ebe7ff;
    border-radius: 16px;
    background:
      radial-gradient(120% 140% at 100% 0%, rgba(137, 223, 215, .22) 0%, transparent 46%),
      linear-gradient(135deg, #f1edff 0%, #ffffff 72%);
    padding: 16px;
  }
  .fxm-m-account__title { font-size: 16px; font-weight: 700; color: #272e42; letter-spacing: -.01em; }
  .fxm-m-account__desc { margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: #6b7088; }
  .fxm-m-account__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
  .fxm-m-btn {
    display: inline-flex;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
  }
  .fxm-m-btn.is-ghost { border: 1px solid rgba(79, 52, 217, .2); background: #fff; color: var(--color-primary, #4f34d9); }
  .fxm-m-btn.is-primary {
    background: linear-gradient(135deg, #6c54f7 0%, #5a40eb 100%);
    color: #fff;
    box-shadow: 0 10px 20px -12px rgba(79, 52, 217, .7);
  }
  .fxm-m-account__user { display: flex; align-items: center; gap: 12px; }
  .fxm-m-account__user[hidden] { display: none; }
  .fxm-m-account__user img { width: 44px; height: 44px; flex-shrink: 0; border-radius: 999px; object-fit: cover; border: 2px solid #fff; box-shadow: 0 4px 12px -6px rgba(39, 46, 66, .3); }
  .fxm-m-account__who { display: flex; min-width: 0; flex: 1; flex-direction: column; }
  .fxm-m-account__who strong { overflow: hidden; font-size: 15px; color: #272e42; text-overflow: ellipsis; white-space: nowrap; }
  .fxm-m-account__who small { overflow: hidden; font-size: 12px; color: #8a8fa6; text-overflow: ellipsis; white-space: nowrap; }
  .fxm-m-account__go { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--color-primary, #4f34d9); white-space: nowrap; }

  .fxm-m-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
    border-radius: 16px;
    background: #fff;
    padding: 12px 6px;
    box-shadow: 0 1px 0 #eeecf6, 0 6px 18px -14px rgba(39, 46, 66, .2);
  }
  .fxm-m-shortcuts a {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #3d4359;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
  }
  .fxm-m-shortcuts__icon {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: #f3f0ff;
    color: var(--color-primary, #4f34d9);
    transition: transform 160ms ease;
  }
  .fxm-m-shortcuts a:active .fxm-m-shortcuts__icon { transform: scale(.92); }

  .fxm-m-group { border-bottom: 1px solid #eeecf5; }
  .fxm-m-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    font-size: 15px;
    font-weight: 700;
    color: #272e42;
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .fxm-m-group summary::-webkit-details-marker { display: none; }
  .fxm-m-group summary svg { color: #a3a7ba; transition: transform 200ms ease; }
  .fxm-m-group[open] summary svg { transform: rotate(90deg); }
  .fxm-m-group__links { display: grid; gap: 2px; padding: 0 0 12px; }
  .fxm-m-group__links a {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    padding: 6px 8px;
    font-size: 14px;
    color: #3d4359;
    -webkit-tap-highlight-color: transparent;
  }
  .fxm-m-group__links a:active { background: #f1eefc; }
  .fxm-m-group__icon {
    display: inline-flex;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #f3f1fb;
    color: #5b5f78;
  }
  .fxm-m-group__links a.is-risk .fxm-m-group__icon { background: #fff1f2; color: #e11d48; }
  .fxm-m-group__links.is-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .fxm-m-group__links.is-grid a { gap: 8px; border: 1px solid #efedf6; background: #fff; padding: 6px 8px; font-size: 13px; }
  .fxm-m-group__links.is-grid .fxm-tool-nav-icon { width: 28px; height: 28px; flex-shrink: 0; }
  .fxm-m-group__links.is-grid span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .fxm-m-nav__section { padding: 16px 4px 4px; }
  .fxm-m-nav__label { margin-bottom: 10px; font-size: 12px; color: #8a8fa6; letter-spacing: .02em; }
  .fxm-m-langs { display: flex; flex-wrap: wrap; gap: 8px; }
  .fxm-m-langs a {
    display: inline-flex;
    height: 34px;
    align-items: center;
    gap: 6px;
    border: 1px solid #e8e6f2;
    border-radius: 999px;
    background: #fff;
    padding: 0 12px;
    font-size: 13px;
    color: #4b5068;
  }
  .fxm-m-langs a img { border-radius: 3px; }
  .fxm-m-langs a.is-active { border-color: rgba(79, 52, 217, .35); background: #f1edff; color: var(--color-primary, #4f34d9); font-weight: 600; }
  .fxm-m-nav__foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 18px; padding: 14px 4px 0; border-top: 1px solid #eeecf5; }
  .fxm-m-nav__foot a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; font-size: 13px; color: #6b7088; }

  html.fxm-m-locked, html.fxm-m-locked body { overflow: hidden; }

  /* ---------- bottom tab bar ---------- */
  body.fxm-has-tabbar { padding-bottom: calc(var(--fxm-m-tabbar) + env(safe-area-inset-bottom)); }
  body.fxm-has-tabbar [data-fxm-ai-floating] { display: none !important; }
  .fxm-tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 48;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--fxm-m-tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(226, 228, 240, .9);
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    backdrop-filter: blur(16px) saturate(1.4);
    box-shadow: 0 -10px 28px -22px rgba(39, 46, 66, .35);
  }
  .fxm-tabbar__item,
  .fxm-tabbar__ai {
    position: relative;
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #8b90a7;
    -webkit-tap-highlight-color: transparent;
  }
  .fxm-tabbar__item svg { transition: transform 180ms ease; }
  .fxm-tabbar__item:active svg { transform: scale(.88); }
  .fxm-tabbar__label {
    max-width: 100%;
    overflow: hidden;
    font-size: 10.5px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .fxm-tabbar__item.is-active { color: var(--color-primary, #4f34d9); }
  .fxm-tabbar__item.is-active svg { stroke-width: 2.3; }
  .fxm-tabbar__item.is-active .fxm-tabbar__label { font-weight: 700; }
  .fxm-tabbar__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 18px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, #6c54f7, #89dfd7);
  }
  .fxm-tabbar__ai { justify-content: flex-end; padding-bottom: 7px; }
  .fxm-tabbar__orb {
    position: absolute;
    top: -18px;
    display: flex;
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 4px solid #fff;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 10px 22px -10px rgba(79, 52, 217, .65);
    transition: transform 180ms ease;
  }
  .fxm-tabbar__orb img,
  .fxm-tabbar__orb svg { width: 100%; height: 100%; }
  .fxm-tabbar__ai:active .fxm-tabbar__orb { transform: scale(.92); }
  .fxm-tabbar__ai .fxm-tabbar__label { color: var(--color-primary, #4f34d9); font-weight: 600; }

  /* Footer layout is owned by fxm-footer.css at all viewport widths. */
}

@media (max-width: 767.98px) {
  /* The tab bar's centre orb is the AI entry on phones; one orb is enough. */
  body.fxm-has-tabbar .fxm-site-header .fxm-header-end > [data-fxm-ai-open] { display: none; }
}

/* ---------- bottom sheets: <details data-fxm-m-sheet> (filters) ----------
   Closed on load by fxm-mobile-nav.js; the summary is the trigger chip, the
   first non-summary child becomes the sheet and details::before the backdrop. */
@keyframes fxm-m-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fxm-m-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 767.98px) {
  /* Until the script has closed them, server-open sheets must not flash over the page. */
  html:not(.fxm-m-sheets-ready) details[data-fxm-m-sheet] > :not(summary),
  html:not(.fxm-m-sheets-ready) details[data-fxm-m-sheet]::before { display: none !important; }
  details[data-fxm-m-sheet][open]::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 94;
    background: rgba(20, 22, 40, .45);
    animation: fxm-m-fade 200ms ease;
  }
  details[data-fxm-m-sheet][open] > :not(summary) {
    position: fixed !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 95 !important;
    display: flex !important;
    flex-direction: column;
    max-height: min(84vh, 720px) !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 22px 16px 0 !important;
    background: linear-gradient(#dcdde8, #dcdde8) center 9px / 38px 4px no-repeat, #fff !important;
    box-shadow: 0 -20px 48px -20px rgba(20, 22, 40, .4);
    animation: fxm-m-sheet-up 280ms cubic-bezier(.2, .8, .2, 1);
  }
}

/* ---------- Dialogs become bottom sheets on phones (login, exposure report) ---------- */
@media (max-width: 767.98px) {
	.fxm-login-modal,
	.fxm-exposure-modal {
		width: 100vw;
		max-width: 100vw;
		margin: auto 0 0;
		border: 0;
		border-radius: 22px 22px 0 0;
		box-shadow: 0 -18px 50px -20px rgba(27, 23, 45, .35);
	}
	.fxm-login-modal[open],
	.fxm-exposure-modal[open] { animation: fxm-m-sheet-up .32s cubic-bezier(.2, .8, .2, 1); }
	.fxm-login-modal { max-height: calc(100dvh - 48px); }
	.fxm-login-modal__surface { padding: 26px 20px calc(20px + env(safe-area-inset-bottom)); }
	.fxm-login-modal__surface::before,
	.fxm-exposure-modal__header::before {
		position: absolute;
		top: 8px;
		left: 50%;
		width: 38px;
		height: 4px;
		border-radius: 4px;
		background: #dcd8ea;
		transform: translateX(-50%);
		content: "";
	}
	.fxm-login-modal__logo { width: 118px; margin-bottom: 18px; }
	.fxm-login-modal__header h2 { font-size: 24px; }
	.fxm-login-modal__watermark { top: -20px; right: -40px; width: 180px; height: 180px; opacity: .5; }
	.fxm-login-modal__close { top: 16px; right: 14px; background: #f5f3fa; }

	.fxm-exposure-modal { max-height: calc(100dvh - 32px); }
	.fxm-exposure-modal__form { max-height: calc(100dvh - 32px); }
	.fxm-exposure-modal__header { position: relative; padding-top: 24px; }
	.fxm-exposure-modal__footer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}
@media (max-width: 767.98px) and (prefers-reduced-motion: reduce) {
	.fxm-login-modal[open],
	.fxm-exposure-modal[open] { animation: none; }
}

/* ---------- Auth pages (login / register / forgot): app-style single column ---------- */
/* Layout: a compact brand header on the lavender canvas, then one white sheet
   that runs to the bottom of the screen (form, other sign-in, language row).
   Two H5-only hooks come from the templates: .fxm-auth-back (frame) and
   .fxm-auth-m-tabs (login). The frame's inline <style> prints after this
   sheet, so its selectors are matched here with .fxm-auth-shell in front. */
@media (max-width: 767.98px) {
	.fxm-auth-main { overflow-x: clip; padding: 0 !important; }
	.fxm-auth-shell .fxm-auth-canvas { align-items: stretch; }
	.fxm-auth-shell .fxm-auth-panel {
		display: flex;
		flex-direction: column;
		max-width: none !important;
		border: 0 !important;
		border-radius: 0 !important;
		box-shadow: none !important;
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) {
		display: flex;
		flex: 1 0 auto;
		flex-direction: column;
		overflow: visible;
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section { min-width: 0; }

	/* ----- back control (sits on the logo row) ----- */
	.fxm-auth-shell .fxm-auth-back {
		position: absolute;
		top: calc(14px + env(safe-area-inset-top));
		left: var(--fxm-m-gutter);
		z-index: 30;
		display: inline-flex !important;
		width: 40px;
		height: 40px;
		align-items: center;
		justify-content: center;
		border: 1px solid rgba(79, 52, 217, .12);
		border-radius: 999px;
		background: rgba(255, 255, 255, .86);
		color: var(--fxm-m-text);
		box-shadow: 0 6px 16px -10px rgba(39, 46, 66, .35);
		-webkit-backdrop-filter: blur(8px);
		backdrop-filter: blur(8px);
		-webkit-tap-highlight-color: transparent;
		transition: transform 160ms ease, background-color 160ms ease;
	}
	.fxm-auth-shell .fxm-auth-back::before { position: absolute; inset: -4px; content: ""; }
	.fxm-auth-shell .fxm-auth-back:active { transform: scale(.94); background: var(--fxm-m-primary-soft); }
	.fxm-auth-shell .fxm-auth-back:focus-visible { outline: 2px solid var(--fxm-m-primary); outline-offset: 2px; }

	/* ----- brand header ----- */
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type {
		flex: none;
		padding: calc(14px + env(safe-area-inset-top)) var(--fxm-m-gutter) 24px;
		border-bottom: 0;
		background: transparent;
		overflow: visible;
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type > .relative > span:first-child,
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type p + p,
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type .flex-wrap { display: none; }
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type .rounded-\[24px\] {
		display: flex;
		height: 40px;
		align-items: center;
		margin: 0 0 0 52px;
		padding: 0;
		border: 0;
		background: none;
		box-shadow: none;
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type img { height: 26px; }
	/* Regular weight on all three pages: the bold title belongs to the sheet
	   below (login/forgot already pin 400 via a layered !important utility). */
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type h2 {
		max-width: none;
		margin-top: 20px;
		font-family: var(--font-family-heading);
		font-size: 18px;
		font-weight: 400;
		line-height: 1.4;
		letter-spacing: -.01em;
		color: var(--fxm-m-ink);
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:first-of-type h2 + p {
		max-width: none;
		margin-top: 4px;
		font-size: 13px;
		line-height: 1.65;
		color: var(--fxm-m-muted);
	}

	/* ----- form sheet ----- */
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:last-of-type {
		flex: 1 0 auto;
		padding: 26px var(--fxm-m-gutter) 28px;
		border-radius: var(--fxm-m-r-xl) var(--fxm-m-r-xl) 0 0;
		background: var(--fxm-m-surface);
		box-shadow: 0 -10px 28px -22px rgba(79, 52, 217, .3);
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) > section:last-of-type > .flex:first-child { display: block; }
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) h1 {
		font-family: var(--font-family-heading);
		font-size: 22px;
		font-weight: 700 !important;
		line-height: 1.3;
		letter-spacing: -.02em;
		color: var(--fxm-m-ink);
	}
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) h1 + p {
		margin-top: 6px;
		font-size: 13.5px;
		line-height: 1.6;
		color: var(--fxm-m-muted);
	}
	[data-fxm-login-page] > section:last-of-type > .mt-6.rounded-\[22px\] { margin-top: 16px; border-radius: 12px; padding: 10px 12px; font-size: 13px; }

	/* Password / e-mail code: segmented control replaces the desktop pill. */
	[data-fxm-login-page] [data-action="login-toggle-method"] { display: none; }
	.fxm-auth-shell .fxm-auth-m-tabs {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 4px;
		margin-top: 20px;
		padding: 4px;
		border-radius: 12px;
		background: var(--fxm-m-surface-2);
	}
	.fxm-auth-shell .fxm-auth-m-tabs > button {
		height: 40px;
		min-width: 0;
		padding: 0 8px;
		border-radius: 9px;
		font-size: 14px;
		font-weight: 500;
		color: var(--fxm-m-muted);
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		-webkit-tap-highlight-color: transparent;
		transition: background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
	}
	.fxm-auth-shell .fxm-auth-m-tabs > button[aria-selected="true"] {
		background: var(--fxm-m-surface);
		color: var(--fxm-m-primary);
		font-weight: 600;
		box-shadow: 0 1px 2px rgba(31, 35, 53, .06), 0 4px 10px -6px rgba(79, 52, 217, .35);
	}
	.fxm-auth-shell .fxm-auth-m-tabs > button:focus-visible { outline: 2px solid var(--fxm-m-primary); outline-offset: 1px; }

	/* ----- form rhythm: one 18px gap, no utility margins ----- */
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form], [data-fxm-forgot-form]) {
		display: grid;
		gap: 18px;
		margin-top: 22px;
	}
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form], [data-fxm-forgot-form]) > * { margin-block: 0; }
	:is([data-fxm-login-page], [data-fxm-register-page], [data-fxm-forgot-page]) form :is(.grid > *, .flex > :not(.shrink-0)) { min-width: 0; }

	/* ----- fields ----- */
	.fxm-auth-shell :is(.fxm-auth-field, .fxm-phone-field) { gap: 8px; }
	.fxm-auth-shell :is(.fxm-auth-field__label, .fxm-phone-field__label-row label) {
		font-size: 13.5px;
		font-weight: 600 !important;
		line-height: 1.3;
		letter-spacing: 0;
		text-transform: none;
		color: var(--fxm-m-text);
	}
	.fxm-auth-shell .fxm-auth-field__control {
		height: var(--fxm-m-h-control);
		padding: 0 6px 0 14px;
		border: 1px solid var(--fxm-m-line);
		border-radius: var(--fxm-m-r-md);
		background: var(--fxm-m-surface);
		box-shadow: none;
		translate: none;
		transition: border-color 160ms ease, box-shadow 160ms ease;
	}
	.fxm-auth-shell .fxm-auth-field__control:focus-within {
		border-color: var(--fxm-m-primary);
		box-shadow: 0 0 0 3px var(--fxm-m-primary-ring);
		translate: none;
	}
	.fxm-auth-shell .fxm-auth-field__control:has([aria-invalid="true"]) { border-color: var(--fxm-m-danger); background: var(--fxm-m-danger-soft); }
	.fxm-auth-shell .fxm-auth-field__icon,
	.fxm-auth-shell .fxm-auth-field__control:focus-within .fxm-auth-field__icon {
		width: 20px;
		height: 20px;
		margin-right: 10px;
		border: 0;
		border-radius: 0;
		background: none;
		color: #9a9fb3;
	}
	.fxm-auth-shell .fxm-auth-field__control:focus-within .fxm-auth-field__icon { color: var(--fxm-m-primary); }
	/* 16px keeps iOS from zooming the page when a field takes focus. */
	.fxm-auth-shell :is(.fxm-auth-field__input, .fxm-phone-field__input) {
		height: 100%;
		min-width: 0;
		font-size: 16px;
		color: var(--fxm-m-ink);
	}
	.fxm-auth-shell :is(.fxm-auth-field__input, .fxm-phone-field__input)::placeholder { color: var(--fxm-m-placeholder); }
	.fxm-auth-shell .fxm-auth-field__trailing { margin-left: 8px; }
	.fxm-auth-shell [data-action$="send-code"] {
		height: 40px;
		min-width: 0;
		padding: 0 12px;
		border: 0;
		border-radius: var(--fxm-m-r-sm);
		background: var(--fxm-m-primary-soft);
		font-size: 13px;
		font-weight: 600;
		white-space: nowrap;
		translate: none;
	}
	.fxm-auth-shell [data-action$="toggle-password"] { width: 40px; height: 40px; border-radius: var(--fxm-m-r-sm); color: #9a9fb3; }
	.fxm-auth-shell .fxm-auth-field__desc { font-size: 12px; line-height: 1.55; color: var(--fxm-m-muted); }
	/* Login hints only restate the sheet subtitle and the placeholders
	   ("e-mail, username or phone"; "both fields are required"). Register and
	   reset keep theirs: those carry real rules (code length, password policy). */
	[data-fxm-login-page] .fxm-auth-field__desc { display: none; }
	.fxm-auth-shell .fxm-auth-field__error { font-size: 12.5px; color: var(--fxm-m-danger); }

	/* Phone number (register): one 52px row, flag + dial code | number. */
	.fxm-auth-shell .fxm-phone-field__frame {
		padding: 0;
		border: 1px solid var(--fxm-m-line);
		border-radius: var(--fxm-m-r-md);
		background: var(--fxm-m-surface);
		box-shadow: none;
		transition: border-color 160ms ease, box-shadow 160ms ease;
	}
	.fxm-auth-shell .fxm-phone-field__frame:focus-within { border-color: var(--fxm-m-primary); box-shadow: 0 0 0 3px var(--fxm-m-primary-ring); }
	.fxm-auth-shell .fxm-phone-field__control { height: calc(var(--fxm-m-h-control) - 2px); flex-direction: row; align-items: stretch; gap: 0; }
	.fxm-auth-shell .fxm-phone-field__trigger {
		width: auto;
		height: auto;
		flex: none;
		gap: 6px;
		padding: 0 10px 0 12px;
		border: 0;
		border-right: 1px solid var(--fxm-m-line-soft);
		border-radius: var(--fxm-m-r-md) 0 0 var(--fxm-m-r-md);
		background: var(--fxm-m-surface-2);
	}
	.fxm-auth-shell .fxm-phone-field__flag { width: 22px; height: 22px; border: 0; border-radius: 0; background: none; box-shadow: none; font-size: 18px; }
	.fxm-auth-shell :is(.fxm-phone-field__separator, .fxm-phone-field__name) { display: none; }
	.fxm-auth-shell .fxm-phone-field__dial { font-size: 15px; font-weight: 600; color: var(--fxm-m-ink); }
	.fxm-auth-shell .fxm-phone-field__input-shell { padding: 0 14px; border: 0; border-radius: 0 var(--fxm-m-r-md) var(--fxm-m-r-md) 0; background: transparent; box-shadow: none; }
	.fxm-auth-shell .fxm-phone-field__input-icon { display: none; }
	.fxm-auth-shell .fxm-phone-field__popover { padding-top: 6px; }
	.fxm-auth-shell .fxm-phone-field__panel { height: min(304px, 52vh); border-radius: var(--fxm-m-r-md); }
	.fxm-auth-shell .fxm-phone-field__option { min-height: 44px; }

	/* ----- remember device / forgot password ----- */
	.fxm-auth-shell [data-fxm-login-form] > div.flex {
		min-height: 44px;
		margin-block: -6px;
		gap: 12px;
		font-size: 14px;
		color: var(--fxm-m-text);
	}
	.fxm-auth-shell [data-fxm-login-form] > div.flex > label { min-height: 44px; gap: 8px; }
	.fxm-auth-shell [data-fxm-login-form] > div.flex > a { display: inline-flex; min-height: 44px; align-items: center; padding-left: 12px; font-weight: 600; color: var(--fxm-m-primary); }
	.fxm-auth-shell input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--fxm-m-primary); }

	/* Terms (register). */
	/* Padding grows the tap area to 44px; the negative margin keeps the visual rhythm. */
	.fxm-auth-shell [data-fxm-register-form] > label { gap: 10px; margin-block: -12px; padding-block: 12px; font-size: 13px; line-height: 1.6; color: var(--fxm-m-muted); }
	.fxm-auth-shell [data-fxm-register-form] > label input[type="checkbox"] { margin-top: 1px; }
	.fxm-auth-shell [data-fxm-register-form] > label a { font-weight: 600; color: var(--fxm-m-primary); }

	/* ----- actions ----- */
	.fxm-auth-shell :is([data-fxm-login-submit], [data-fxm-register-submit], [data-fxm-forgot-submit]) {
		height: var(--fxm-m-h-btn);
		border-radius: var(--fxm-m-r-md);
		background: var(--fxm-m-grad-primary);
		font-family: var(--font-family-heading);
		font-size: 16px;
		font-weight: 600;
		letter-spacing: .02em;
		box-shadow: var(--fxm-m-shadow-btn);
		translate: none;
		transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
	}
	.fxm-auth-shell :is([data-fxm-login-submit], [data-fxm-register-submit], [data-fxm-forgot-submit]):active:not(:disabled) { transform: scale(.985); box-shadow: 0 6px 14px -10px rgba(79, 52, 217, .6); }
	.fxm-auth-shell :is([data-fxm-login-submit], [data-fxm-register-submit], [data-fxm-forgot-submit]):disabled { box-shadow: none; }
	/* "Register now" under the primary action: soft secondary, not a second outline. */
	.fxm-auth-shell [data-fxm-login-form] > a {
		height: 48px;
		margin-top: -6px;
		border-color: transparent;
		border-radius: var(--fxm-m-r-md);
		background: var(--fxm-m-primary-soft);
		color: var(--fxm-m-primary);
		font-family: var(--font-family-heading);
		font-size: 15px;
		font-weight: 600;
		box-shadow: none;
		translate: none;
	}
	.fxm-auth-shell [data-fxm-login-form] > a:active { background: #e9e4ff; }
	.fxm-auth-shell :is([data-fxm-login-status], [data-fxm-register-status], [data-fxm-forgot-status]) {
		min-height: 0;
		font-size: 13px;
		line-height: 1.5;
		color: var(--fxm-m-muted);
	}
	/* Keep the live region rendered (so updates are announced) but take it out
	   of the grid while empty; otherwise its row still costs one 18px gap. */
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form], [data-fxm-forgot-form]) { position: relative; }
	.fxm-auth-shell :is([data-fxm-login-status], [data-fxm-register-status], [data-fxm-forgot-status]):empty { position: absolute; }

	/* ----- other sign-in methods ----- */
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form]) + div {
		margin: 24px 0 16px;
		gap: 12px;
		font-size: 12.5px;
		letter-spacing: 0;
		text-transform: none;
		color: var(--fxm-m-muted);
	}
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form]) + div > .h-px { background: var(--fxm-m-line-soft); }
	.fxm-auth-shell :is([data-fxm-login-form], [data-fxm-register-form]) + div + div {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		align-items: end;
		gap: 10px;
	}
	.fxm-auth-shell :is([data-fxm-google-signin-fallback], [data-fxm-apple-signin]) {
		height: 48px;
		gap: 8px;
		border-color: var(--fxm-m-line);
		border-radius: var(--fxm-m-r-md);
		background: var(--fxm-m-surface);
		color: var(--fxm-m-ink);
		font-size: 15px;
		font-weight: 500;
		box-shadow: none;
		translate: none;
	}
	.fxm-auth-shell :is([data-fxm-google-signin-fallback], [data-fxm-apple-signin]):active { background: var(--fxm-m-surface-2); }
	.fxm-auth-shell :is([data-fxm-google-signin-fallback], [data-fxm-apple-signin]) svg { width: 18px; height: 18px; }
	.fxm-auth-shell :is([data-fxm-google-signin-error], [data-fxm-apple-signin-error]) { border-radius: var(--fxm-m-r-sm); font-size: 12px; }

	/* From 640px the templates swap the bottom "Back to sign in" row for a pill
	   beside the title (sm: utilities). The phone layout keeps the bottom row. */
	.fxm-auth-shell :is([data-fxm-register-page], [data-fxm-forgot-page]) > section:last-of-type > .flex:first-child > a { display: none; }
	.fxm-auth-shell :is([data-fxm-register-form] + div + div + div, [data-fxm-forgot-form] + div) { display: flex; }

	/* "Already have an account? / Back to sign in" rows. */
	.fxm-auth-shell :is([data-fxm-register-form] + div + div + div, [data-fxm-forgot-form] + div) { margin-top: 18px; font-size: 14px; color: var(--fxm-m-muted); }
	.fxm-auth-shell :is([data-fxm-register-form] + div + div + div, [data-fxm-forgot-form] + div) > a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; color: var(--fxm-m-primary); }

	/* ----- language row: the sheet's footer ----- */
	.fxm-auth-shell .fxm-auth-lang-dock {
		gap: 8px;
		padding: 16px var(--fxm-m-gutter) calc(20px + env(safe-area-inset-bottom));
		border-top: 1px solid var(--fxm-m-line-soft);
		background: var(--fxm-m-surface);
	}
	.fxm-auth-shell .fxm-auth-lang-caption { flex-basis: 100%; margin-bottom: 2px; font-size: 12px; letter-spacing: 0; text-align: center; color: var(--fxm-m-muted); }
	.fxm-auth-shell .fxm-auth-lang-tag {
		height: 40px;
		gap: 6px;
		padding: 0 12px 0 10px;
		border-color: var(--fxm-m-line);
		background: var(--fxm-m-surface);
		box-shadow: none;
		font-size: 13px;
		color: var(--fxm-m-text);
		transform: none;
	}
	.fxm-auth-shell .fxm-auth-lang-tag.is-active { border-color: var(--fxm-m-primary-line); background: var(--fxm-m-primary-soft); color: var(--fxm-m-primary); }
	.fxm-auth-shell .fxm-auth-lang-code { display: none; }
	.fxm-auth-shell .fxm-auth-lang-flag { width: 18px; height: 13px; }
}
/* Large phones / landscape: keep a ~520px reading column centred on the sheet. */
@media (min-width: 600px) and (max-width: 767.98px) {
	.fxm-auth-shell { --fxm-m-gutter: max(20px, calc((100vw - 520px) / 2)); }
}
@media (max-width: 767.98px) and (prefers-reduced-motion: reduce) {
	.fxm-auth-shell :is(.fxm-auth-back, .fxm-auth-m-tabs > button, .fxm-auth-field__control, .fxm-phone-field__frame, [data-fxm-login-submit], [data-fxm-register-submit], [data-fxm-forgot-submit]) { transition: none; }
}
