.fxm-ios-legal-sheet { display: none; }

@media (max-width: 767.98px) {
  html:has(.fxm-ios-legal-sheet[open]) { overflow: hidden; }
  .fxm-ios-legal-sheet[open] {
    position: fixed;
    inset: auto max(0px, env(safe-area-inset-right)) 0 max(0px, env(safe-area-inset-left));
    display: block;
    width: auto;
    max-width: none;
    height: min(93dvh, var(--fxm-ios-visible-height, 100dvh));
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--fxm-ios-ink);
    background: var(--fxm-ios-page);
    border: 0;
    border-radius: 28px 28px 0 0;
  }
  .fxm-ios-legal-sheet::backdrop { background: rgba(0, 0, 0, .2); }
  .fxm-ios-legal-sheet__frame { display: flex; flex-direction: column; height: 100%; }
  .fxm-ios-legal-sheet__frame > header {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 6px 16px 2px 12px;
    background: transparent;
    border-bottom: 0;
  }
  .fxm-ios-legal-sheet__lang {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--fxm-ios-accent);
  }
  .fxm-ios-legal-sheet__lang > span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--fxm-ios-card);
  }
  .fxm-ios-legal-sheet__close {
    min-height: 44px;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--fxm-ios-accent);
    font: var(--fxm-ios-weight-semibold, 600) var(--fxm-ios-type-card-title, 18px)/1.25 var(--fxm-ios-font);
  }
  .fxm-ios-legal-sheet__frame > header h2 {
    margin: 0;
    text-align: center;
    font-size: var(--fxm-ios-type-title);
    font-weight: var(--fxm-ios-weight-semibold, 600);
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fxm-ios-legal-sheet__scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 20px 20px calc(28px + env(safe-area-inset-bottom, 0px));
    overflow-wrap: anywhere;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.45) transparent;
  }
  .fxm-ios-legal-sheet__scroll::-webkit-scrollbar { width: 3px; height: 3px; }
  .fxm-ios-legal-sheet__scroll::-webkit-scrollbar-track { background: transparent; }
  .fxm-ios-legal-sheet__scroll::-webkit-scrollbar-thumb { background: rgba(156, 163, 175, 0.45); border-radius: 999px; }
  .fxm-ios-legal-sheet [data-fxm-ios-legal-document] {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
  .fxm-ios-legal-sheet .fxm-ios-legal-heading {
    margin: 0;
    font-size: var(--fxm-ios-type-section-title, 22px);
    font-weight: var(--fxm-ios-weight-semibold, 600);
    line-height: 1.3;
    color: var(--fxm-ios-ink);
  }
  .fxm-ios-legal-sheet .fxm-ios-legal-metadata,
  .fxm-ios-legal-sheet .fxm-legal-html {
    margin: 0;
    padding: 0;
    color: var(--fxm-ios-ink);
    background: transparent;
    border: 0;
    border-radius: 0;
  }
  .fxm-ios-legal-sheet .fxm-ios-legal-metadata { display: grid; gap: 6px; font-size: var(--fxm-ios-type-caption, 14px); }
  .fxm-ios-legal-sheet .fxm-ios-legal-metadata > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 8px;
    color: var(--fxm-ios-secondary);
  }
  .fxm-ios-legal-sheet .fxm-ios-legal-metadata dd { margin: 0; color: var(--fxm-ios-secondary); }
  .fxm-ios-legal-sheet .fxm-ios-legal-fallback { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--fxm-ios-secondary); font-size: var(--fxm-ios-type-body, 16px); line-height: 1.5; }
  .fxm-ios-legal-sheet .fxm-ios-legal-fallback svg { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px; }
  .fxm-ios-legal-sheet .fxm-legal-html { overflow: visible; font-size: var(--fxm-ios-type-body, 16px); line-height: 1.52; }
  .fxm-ios-legal-sheet .fxm-legal-html img { display: none !important; }
  .fxm-ios-legal-sheet .fxm-legal-html > * + * { margin-block-start: 12px; }
  .fxm-ios-legal-sheet .fxm-legal-html h1 { font-size: 30px; font-weight: var(--fxm-ios-weight-bold, 700); line-height: 1.25; }
  .fxm-ios-legal-sheet .fxm-legal-html h2 { font-size: 26px; font-weight: var(--fxm-ios-weight-semibold, 600); line-height: 1.3; }
  .fxm-ios-legal-sheet .fxm-legal-html h3 { font-size: 22px; font-weight: var(--fxm-ios-weight-semibold, 600); line-height: 1.35; }
  .fxm-ios-legal-sheet .fxm-legal-html h4 { font-size: 20px; font-weight: var(--fxm-ios-weight-semibold, 600); line-height: 1.35; }
  .fxm-ios-legal-sheet .fxm-legal-html :is(h5, h6) { font-size: var(--fxm-ios-type-card-title, 18px); font-weight: var(--fxm-ios-weight-semibold, 600); line-height: 1.4; }
  .fxm-ios-legal-sheet .fxm-legal-html ul { list-style: disc; padding-inline-start: 22px; }
  .fxm-ios-legal-sheet .fxm-legal-html ol { list-style: decimal; padding-inline-start: 22px; }
  .fxm-ios-legal-sheet .fxm-legal-html a { color: var(--fxm-ios-accent); text-decoration: underline; }
  .fxm-ios-legal-sheet [data-fxm-ios-legal-error]:not([hidden]) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 240px;
    text-align: center;
    color: var(--fxm-ios-secondary);
  }
  .fxm-ios-legal-sheet [data-fxm-ios-legal-retry] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 20px;
    border: 1px solid var(--fxm-ios-border);
    border-radius: 999px;
    background: var(--fxm-ios-card);
    color: var(--fxm-ios-accent);
    font: var(--fxm-ios-weight-semibold, 600) var(--fxm-ios-type-body, 16px)/1.2 var(--fxm-ios-font);
  }
  .fxm-ios-legal-sheet__lang-dialog { display: none; }
  .fxm-ios-legal-sheet__lang-dialog[open] { position: fixed; inset: auto 0 0; display: block; width: 100%; max-width: 520px; margin: auto auto 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px)); border: 0; border-radius: 24px 24px 0 0; background: var(--fxm-ios-card); color: var(--fxm-ios-ink); box-shadow: 0 -12px 48px rgba(0, 0, 0, .14); }
  .fxm-ios-legal-sheet__lang-dialog::backdrop { background: rgba(0, 0, 0, .2); }
  .fxm-ios-legal-sheet__lang-dialog::before { content: ''; display: block; width: 36px; height: 4px; margin: 10px auto 8px; border-radius: 999px; background: #d1d5db; }
  .fxm-ios-legal-sheet__lang-dialog > header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 44px; padding: 4px 0; margin-bottom: 4px; }
  .fxm-ios-legal-sheet__lang-dialog > header h2 { margin: 0; text-align: center; font: var(--fxm-ios-weight-semibold, 600) 18px/1.25 var(--fxm-ios-font); }
  .fxm-ios-legal-sheet__lang-dialog > header button { min-height: 40px; height: 40px; padding: 8px 12px; border: 0; border-radius: 999px; background: transparent; color: #5f3fbf; font: 600 18px/1.2 var(--fxm-ios-font); cursor: pointer; }
  .fxm-ios-legal-sheet__wheel-viewport { position: relative; height: 228px; padding: 0 4px; }
  .fxm-ios-legal-sheet__wheel-viewport::before { content: ''; position: absolute; inset: 92px 4px auto; height: 44px; border-radius: 9px; background: color-mix(in srgb, var(--fxm-ios-ink) 5.5%, transparent); pointer-events: none; }
  .fxm-ios-legal-sheet__wheel { position: relative; z-index: 1; display: flex; flex-direction: column; height: 228px; padding: 92px 0; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; }
  .fxm-ios-legal-sheet__wheel::-webkit-scrollbar { display: none; }
  .fxm-ios-legal-sheet__wheel > button { flex: 0 0 44px; height: 44px; border: 0; background: transparent; color: var(--fxm-ios-ink); font: 400 20px/44px var(--fxm-ios-font); scroll-snap-align: center; opacity: .28; transition: opacity .12s ease; }
  .fxm-ios-legal-sheet__wheel > button[data-wheel-dist="0"] { opacity: 1; font-weight: 500; }
  .fxm-ios-legal-sheet__wheel > button[data-wheel-dist="1"] { opacity: .5; }
  .fxm-ios-legal-sheet__wheel > button[data-wheel-dist="2"] { opacity: .28; }
  .fxm-ios-legal-sheet__wheel > button[data-wheel-dist="3"] { opacity: .14; }
  :is(html.dark, [data-theme="dark"], body.dark) .fxm-ios-legal-sheet__lang-dialog::before { background: #4b5563; }
  :is(html.dark, [data-theme="dark"], body.dark) .fxm-ios-legal-sheet__lang-dialog > header button { color: #a78bfa; }
}

@media (max-width: 767.98px) and (prefers-color-scheme: dark) {
  .fxm-ios-legal-sheet__lang-dialog::before { background: #4b5563; }
  .fxm-ios-legal-sheet__lang-dialog > header button { color: #a78bfa; }
}
