/* Shared mobile reading frame. Desktop page layouts retain their existing styles. */
#wa-mobile-frame,
#wa-mobile-context,
#wa-mobile-panel {
  display: none;
}

@media (max-width: 820px) {
  body[data-mobile-frame] {
    --wa-mobile-night: #111416;
    --wa-mobile-paper: #f3f0e8;
    --wa-mobile-ink: #202423;
    --wa-mobile-gold: #b49a64;
    --wa-mobile-gold-light: #d2bf95;
    --wa-mobile-muted: #aaa99f;
    --wa-mobile-line: #3b3c34;
    --wa-mobile-bottom-height: 64px;
    --wa-mobile-body-size: 16px;
    --wa-mobile-secondary-size: 14px;
    --wa-mobile-caption-size: 12px;
    --pad: max(18px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    padding-bottom: calc(var(--wa-mobile-bottom-height) + env(safe-area-inset-bottom, 0px) + 12px);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
  }

  body[data-mobile-frame] .header {
    position: sticky;
    top: 0;
    z-index: 80;
    transform: none !important;
    visibility: visible;
    pointer-events: auto;
    padding-top: env(safe-area-inset-top, 0px);
  }

  body[data-mobile-frame] .header-inner {
    height: 68px;
    min-height: 68px;
    gap: 12px;
  }

  body[data-mobile-frame] .brand {
    gap: 9px;
    min-width: 0;
  }

  body[data-mobile-frame] .brand-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }

  body[data-mobile-frame] .brand-name {
    font-size: 17px;
    white-space: nowrap;
  }

  body[data-mobile-frame] .header-end {
    gap: 12px;
  }

  body[data-mobile-frame="detail"] .header .asset-language {
    display: none;
  }

  body[data-mobile-frame] .menu-toggle,
  body[data-mobile-frame] .asset-language-trigger {
    min-height: 44px;
    font-size: 14px;
  }

  body[data-mobile-frame] .menu-toggle {
    min-width: 52px;
    padding-inline: 8px;
  }

  body[data-mobile-frame] main :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), select, textarea) {
    font-size: 16px;
    min-height: 44px;
  }

  body[data-mobile-frame] main button {
    min-height: 44px;
  }

  body[data-mobile-frame] main p {
    font-size: var(--wa-mobile-body-size);
    line-height: 1.8;
  }

  body[data-mobile-frame] main p:is([class*="note"], [class*="meta"], [class*="caption"], [class*="source"], [class*="status"]) {
    font-size: var(--wa-mobile-secondary-size);
  }

  body[data-mobile-frame] main p:is(.mono, .eyebrow, [class*="eyebrow"], [class*="kicker"], [class$="-en"]) {
    font-size: var(--wa-mobile-caption-size);
    line-height: 1.7;
  }

  body[data-mobile-frame] main :is(section, h2, h3)[id] {
    scroll-margin-top: calc(88px + env(safe-area-inset-top, 0px));
  }

  body[data-mobile-frame] main :is(.hero-description, .wa-lead, .ar-intro, .pa-intro),
  body[data-mobile-frame] main .dz-hero-copy > p:not(.eyebrow),
  body[data-mobile-frame] main .section-head > p {
    font-size: 16px;
    line-height: 1.85;
  }

  /* The shared panel owns mobile chapters and tools; keep their source data in place. */
  body[data-mobile-frame] #wa-page-tools,
  body[data-mobile-frame] nav:is(.gov-subnav, .local-nav, .subnav, .ra-anchor, .project-subnav, .ah-subnav, .pa-anchor-nav, .ar-anchor-nav, .nd-anchor-nav, .dz-anchor-nav, .ai-local-nav, .union-subnav, .post-subnav, .capital-subnav, .research-subnav, .ba-reading-nav) {
    display: none !important;
  }

  body[data-mobile-frame] #wa-mobile-frame {
    display: block;
    color: var(--wa-mobile-ink);
    font: inherit;
  }

  body[data-mobile-frame] #wa-mobile-context {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 54px;
    padding: 7px max(18px, env(safe-area-inset-right, 0px)) 7px max(18px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid #d6d0c2;
    background: var(--wa-mobile-paper);
    color: var(--wa-mobile-ink);
  }

  #wa-mobile-context .wa-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding-right: 5px;
    flex-shrink: 0;
    color: #786136;
    font-size: 14px;
    line-height: 1.6;
    text-decoration: none;
  }

  #wa-mobile-context .wa-mobile-back svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  #wa-mobile-context [data-mobile-short-title] {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.7;
    color: #66685e;
  }

  #wa-mobile-frame .wa-mobile-bottom {
    position: fixed;
    z-index: 85;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0 max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px));
    border-top: 1px solid #454136;
    background: var(--wa-mobile-night);
    color: #b7b7ac;
  }

  body[data-mobile-frame="detail"] #wa-mobile-frame .wa-mobile-bottom {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #wa-mobile-frame .wa-mobile-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    min-height: var(--wa-mobile-bottom-height);
    padding: 9px 3px 8px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  body[data-mobile-frame="detail"] #wa-mobile-frame .wa-mobile-tab {
    font-size: 13px;
  }

  #wa-mobile-frame .wa-mobile-tab svg {
    display: block;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #wa-mobile-frame .wa-mobile-tab:is([aria-current="page"], [aria-expanded="true"], .is-current) {
    color: var(--wa-mobile-gold-light);
    background: #b49a640d;
  }

  #wa-mobile-frame .wa-mobile-tab[aria-current="page"]::before,
  #wa-mobile-frame .wa-mobile-tab.is-current::before {
    content: "";
    position: absolute;
    top: 0;
    right: 25%;
    left: 25%;
    height: 2px;
    background: var(--wa-mobile-gold);
  }

  body.wa-mobile-panel-open #wa-mobile-frame .wa-mobile-bottom,
  body.wa-mobile-keyboard-open #wa-mobile-frame .wa-mobile-bottom {
    display: none;
  }

  body[data-mobile-frame] #wa-mobile-panel.wa-mobile-dialog[open] {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-top: 2px solid var(--wa-mobile-gold);
    border-radius: 0;
    background: var(--wa-mobile-night);
    color: #ebe9e3;
    font: inherit;
    text-align: left;
    box-sizing: border-box;
  }

  #wa-mobile-panel::backdrop {
    background: #080a0be6;
  }

  #wa-mobile-panel .wa-mobile-dialog-head {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 70px;
    padding: max(12px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 12px max(18px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid var(--wa-mobile-line);
  }

  #wa-mobile-panel .wa-mobile-dialog-head :is(h2, h3) {
    margin: 0;
    color: var(--wa-mobile-gold-light);
    font-size: 22px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: .01em;
  }

  #wa-mobile-panel .wa-mobile-dialog-head > div {
    min-width: 0;
  }

  #wa-mobile-panel .wa-mobile-eyebrow {
    display: block;
    margin-bottom: 4px;
    color: #aaa99f;
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: .14em;
  }

  #wa-mobile-panel .wa-mobile-dialog-head button {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #57503f;
    background: transparent;
    color: var(--wa-mobile-gold-light);
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    cursor: pointer;
  }

  #wa-mobile-panel .wa-mobile-dialog-head button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #wa-mobile-panel .wa-mobile-panel-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: #786136 #171a1c;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  #wa-mobile-panel section[data-mobile-pane] {
    min-width: 0;
    max-width: 100%;
  }

  #wa-mobile-panel section[data-mobile-pane][hidden] {
    display: none !important;
  }

  /* Move the established menu into the shared dialog without changing its IDs. */
  #wa-mobile-panel #mobile-nav {
    position: static;
    display: block !important;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: none !important;
    margin: 0;
    padding: 0;
    overflow: visible !important;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #ebe9e3;
  }

  #wa-mobile-panel #mobile-nav[hidden],
  #wa-mobile-panel #mobile-nav [hidden] {
    display: none !important;
  }

  #wa-mobile-panel #mobile-nav [data-integrated-mobile] {
    display: block !important;
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--wa-mobile-line);
  }

  #wa-mobile-panel #mobile-nav > a,
  #wa-mobile-panel #mobile-nav :is(.mobile-section-parent, .mobile-research-parent) > a {
    display: flex;
    flex: 1;
    align-items: center;
    min-width: 0;
    min-height: 56px;
    padding: 14px 0;
    border: 0;
    color: #ebe9e3;
    font-size: 16px;
    line-height: 1.7;
    white-space: normal;
    text-decoration: none;
  }

  #wa-mobile-panel #mobile-nav > a {
    border-bottom: 1px solid var(--wa-mobile-line);
  }

  #wa-mobile-panel #mobile-nav :is(.mobile-section-parent, .mobile-research-parent) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }

  #wa-mobile-panel #mobile-nav :is(.mobile-section-toggle, .mobile-research-toggle) {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid #4c473a;
    background: transparent;
    color: var(--wa-mobile-gold-light);
    font: inherit;
    font-size: 17px;
    line-height: 1;
  }

  #wa-mobile-panel #mobile-nav .nav-chevron {
    font-size: 14px;
  }

  #wa-mobile-panel #mobile-nav [id^="mobile-"][id$="-submenu"] {
    display: block;
    grid-column: auto;
    margin: 0 0 18px;
    padding: 4px 14px;
    border: 1px solid #3d3a31;
    background: #191c1d;
  }

  #wa-mobile-panel #mobile-nav [id^="mobile-"][id$="-submenu"] a {
    display: block;
    min-height: 48px;
    padding: 15px 0;
    border: 0;
    border-bottom: 1px solid #3b3c34;
    color: #e0dfd6;
    font-size: 15px;
    line-height: 1.75;
    text-decoration: none;
  }

  #wa-mobile-panel #mobile-nav [id^="mobile-"][id$="-submenu"] a:last-child {
    border-bottom: 0;
  }

  #wa-mobile-panel #mobile-nav strong {
    display: block;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.75;
  }

  #wa-mobile-panel #mobile-nav a > span,
  #wa-mobile-panel #mobile-nav .capital-menu-overview > span {
    display: block;
    margin-top: 6px;
    color: #acaca1;
    font-size: 13px;
    line-height: 1.75;
  }

  #wa-mobile-panel #mobile-nav :is(.research-menu-group, .capital-menu-group, .post-project-group) {
    margin-block: 16px;
    padding: 0;
    min-width: 0;
  }

  #wa-mobile-panel #mobile-nav :is(.research-menu-group, .capital-menu-group) h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.7;
    color: var(--wa-mobile-gold-light);
  }

  #wa-mobile-panel #mobile-nav .research-menu-group h3 a {
    color: var(--wa-mobile-gold-light);
    border: 0;
    padding: 8px 0;
  }

  #wa-mobile-panel #mobile-nav :is(.research-menu-en, .capital-menu-en) {
    margin: 4px 0 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #3b3c34;
    color: #a2a394;
    font-size: 11px !important;
    line-height: 1.7;
    letter-spacing: .04em;
  }

  #wa-mobile-panel #mobile-nav .post-view-links {
    display: block;
  }

  #wa-mobile-panel #mobile-nav :is(a[aria-current="page"], a.is-active),
  #wa-mobile-panel #mobile-nav :is(a[aria-current="page"], a.is-active) strong {
    color: var(--wa-mobile-gold-light);
  }

  #wa-mobile-panel .wa-mobile-languages {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--wa-mobile-line);
  }

  #wa-mobile-panel .wa-mobile-languages :is(h2, h3, p) {
    margin: 0 0 14px;
    color: #afafa3;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.8;
  }

  #wa-mobile-panel .wa-mobile-languages :is(button, .wa-mobile-language-current) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--wa-mobile-line);
    background: transparent;
    color: #e2e1d8;
    font: inherit;
    font-size: 15px;
    line-height: 1.65;
    text-align: left;
    box-sizing: border-box;
  }

  #wa-mobile-panel .wa-mobile-languages button:disabled {
    color: #a9aa9e;
    cursor: default;
    opacity: 1;
  }

  #wa-mobile-panel .wa-mobile-languages :is(.wa-mobile-language-current, [aria-current="true"], [data-language="zh"]) {
    color: var(--wa-mobile-gold-light);
    background: #b49a6410;
  }

  #wa-mobile-panel .wa-mobile-languages :is(button, .wa-mobile-language-current) > span:last-child {
    color: #aa9a77;
    font-size: 13px;
  }

  #wa-mobile-panel :is(.wa-mobile-chapter-link, .wa-mobile-related-link) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 58px;
    padding: 16px 0;
    border-bottom: 1px solid var(--wa-mobile-line);
    color: #ebe9e3;
    font-size: 16px;
    line-height: 1.75;
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel ol[data-mobile-chapters] {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  #wa-mobile-panel ol[data-mobile-chapters] > li {
    min-width: 0;
  }

  #wa-mobile-panel .wa-mobile-chapter-link {
    align-items: flex-start;
    justify-content: flex-start;
    gap: 16px;
  }

  #wa-mobile-panel .wa-mobile-chapter-link > span:first-child {
    flex: 0 0 2ch;
    color: var(--wa-mobile-gold-light);
    font-size: 13px;
    line-height: 2.15;
    white-space: nowrap;
  }

  #wa-mobile-panel .wa-mobile-chapter-link > span:last-child {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel .wa-mobile-related-link {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 7px;
    min-width: 0;
  }

  #wa-mobile-panel .wa-mobile-related-link > strong {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
    font-weight: 400;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel .wa-mobile-related-link > strong > span {
    flex-shrink: 0;
    color: var(--wa-mobile-gold-light);
  }

  #wa-mobile-panel .wa-mobile-related-link > span {
    min-width: 0;
    color: #adada0;
    font-size: 14px;
    line-height: 1.8;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel .wa-mobile-note {
    margin: 0 0 20px;
    color: #afafa3;
    font-size: 14px;
    line-height: 1.9;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel .wa-mobile-share-title {
    margin: 10px 0 22px;
    color: #ebe9e3;
    font-size: 21px;
    font-weight: 400;
    line-height: 1.7;
    overflow-wrap: anywhere;
  }

  #wa-mobile-panel .wa-mobile-share-link {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 48px;
    padding: 12px 13px;
    border: 1px solid #625640;
    border-radius: 0;
    background: #1b1e1f;
    color: #e7dfcc;
    font: inherit;
    font-size: 16px;
    line-height: 1.8;
    overflow-wrap: anywhere;
    box-sizing: border-box;
  }

  #wa-mobile-panel textarea.wa-mobile-share-link {
    min-height: 104px;
    resize: vertical;
  }

  #wa-mobile-panel .wa-mobile-share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
  }

  #wa-mobile-panel .wa-mobile-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 44px;
    min-height: 48px;
    padding: 12px 17px;
    border: 1px solid #b49a64;
    border-radius: 0;
    background: transparent;
    color: var(--wa-mobile-gold-light);
    font: inherit;
    font-size: 15px;
    line-height: 1.6;
    text-decoration: none;
    cursor: pointer;
  }

  #wa-mobile-panel .wa-mobile-action:disabled {
    border-color: #565443;
    color: #989a8e;
    cursor: default;
  }

  #wa-mobile-panel .wa-mobile-status {
    min-height: 26px;
    margin: 16px 0 0;
    color: var(--wa-mobile-gold-light);
    font-size: 14px;
    line-height: 1.85;
    overflow-wrap: anywhere;
  }

  #wa-mobile-frame :is(a, button):focus-visible,
  #wa-mobile-context a:focus-visible,
  #wa-mobile-panel :is(a, button, input, textarea):focus-visible {
    outline: 2px solid var(--wa-mobile-gold-light);
    outline-offset: 3px;
  }

  @media (hover: hover) {
    #wa-mobile-frame .wa-mobile-tab:hover,
    #wa-mobile-panel :is(.wa-mobile-chapter-link, .wa-mobile-related-link):hover {
      color: var(--wa-mobile-gold-light);
      background: #b49a640a;
    }
  }
}

@media (max-width: 360px) {
  body[data-mobile-frame] {
    --pad: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  }

  body[data-mobile-frame] .header-inner,
  body[data-mobile-frame] .header-end {
    gap: 8px;
  }

  body[data-mobile-frame] .brand {
    gap: 7px;
  }

  body[data-mobile-frame] .brand-mark {
    width: 28px;
    height: 28px;
  }

  body[data-mobile-frame] .brand-name {
    font-size: 16px;
  }

  body[data-mobile-frame] .asset-language-trigger {
    gap: 4px;
    font-size: 13px;
  }

  #wa-mobile-frame .wa-mobile-tab {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #wa-mobile-frame *,
  #wa-mobile-panel *,
  #wa-mobile-context * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  #wa-mobile-frame,
  #wa-mobile-context,
  #wa-mobile-panel {
    display: none !important;
  }

  body[data-mobile-frame] {
    padding-bottom: 0;
  }
}
