/* Bring application and archive pages into the encyclopedia's visual family.
   Loaded last by app-consistency.mjs. No homepage, Atlas, tool, or encyclopedia changes.
   Screen-only so existing print/export layouts retain their own styles. */
@media screen {
  body:is(.history-page, .wallet-page, .community-page, .public-profile-page, .site-document-page, .research-page) {
    --app-bg: #0a0f15;
    --app-panel: #11171f;
    --app-ink: #eeeae2;
    --app-muted: #bcc2cb;
    --app-accent: #d4b079;
    --app-line: #303640;
    --app-sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    --app-mono: 'IBM Plex Mono', ui-monospace, monospace;
    --app-width: 1120px;
    --app-gutter: 32px;
    --site-space: var(--app-bg);
    --site-surface: var(--app-panel);
    --site-paper: var(--app-ink);
    --site-muted: var(--app-muted);
    --site-gold: var(--app-accent);
    --site-gold-soft: var(--app-accent);
    --site-hairline: var(--app-line);
    --site-hairline-soft: var(--app-line);
    --history-bg: var(--app-bg);
    --history-amber: var(--app-accent);
    --board-gold: var(--app-accent);
    --board-line: var(--app-line);
    color: var(--app-ink);
    background: radial-gradient(ellipse at 70% 0, #24303a26, transparent 650px), var(--app-bg);
    background-attachment: scroll;
    font-family: var(--app-sans);
  }

  body.community-page[data-leaderboard-design] {
    --record-bg: var(--app-bg);
    --record-text: var(--app-ink);
    --record-muted: var(--app-muted);
    --record-line: var(--app-line);
    --record-link: var(--app-accent);
    background: var(--app-bg);
  }

  /* Shared page frame; long-form paragraphs retain their reading measure. */

  body.community-page .community-wrap,
  body.community-page[data-leaderboard-design] .community-wrap,
  body.public-profile-page .public-profile-wrap,
  body.wallet-page > .wrap,
  body.site-document-page:is([data-content-visuals], .not-found-page) > .wrap {
    width: min(var(--app-width), calc(100% - 2 * var(--app-gutter)));
    max-width: var(--app-width);
    margin-inline: auto;
    padding: 0 0 48px;
  }
  body.site-document-page:is([data-content-visuals], .not-found-page) .methodology {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    overflow: visible;
  }
  body.site-document-page .methodology::before { content: none; }
  body.site-document-page .methodology > :is(p, ul, ol, dl) { max-width: 72ch; }
  body.site-document-page .foot { max-width: none; }

  /* Same wordmark, header baseline and link treatment across page families. */

  body:is(.community-page, .public-profile-page) .community-nav,
  body.site-document-page .document-topbar,
  body.wallet-page .wallet-library-topbar,
  body.wallet-page .wallet-masthead-bar,
  body.history-page .history-topbar {
    min-height: 76px;
    width: 100%;
    margin: 0;
    padding: 12px 0;
    gap: 12px 24px;
    border: 0;
    border-bottom: 1px solid var(--app-line);
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
  }
  body.history-page .history-topbar {
    width: min(var(--app-width), calc(100% - 2 * var(--app-gutter)));
    margin-inline: auto;
    background: var(--app-bg);
  }
  body.site-document-page .document-topbar { margin-bottom: 48px; }
  body.research-page .research-topbar { gap: 12px 24px; flex-wrap: wrap; }
  body.research-page .research-brand-group { min-width: 0; flex-wrap: wrap; }
  body.research-page .research-topbar nav { min-width: 0; max-width: 100%; }
  body.research-page .research-footer { flex-wrap: wrap; gap: 10px 16px; }
  body.wallet-library-page .wallet-library-topbar > div { justify-content: flex-start; }
  body:is(.community-page, .public-profile-page, .site-document-page, .wallet-page, .history-page) :is(.community-nav .community-brand, .methodology-brand .brand-link, .wallet-library-topbar .wallet-library-brand, .wallet-breadcrumb .brand-link, .history-brand) {
    font-family: var(--app-sans);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.4;
    text-transform: none;
    color: var(--app-ink);
  }
  body:is(.community-page, .public-profile-page, .site-document-page, .wallet-page, .history-page) :is(.community-nav-links, .document-topbar nav, .wallet-library-topbar > div, .wallet-global-nav, .history-topnav) {
    gap: 4px 18px;
    flex-wrap: wrap;
  }
  body:is(.community-page, .public-profile-page, .site-document-page, .wallet-page, .history-page) :is(.community-nav-links, .document-topbar nav, .wallet-library-topbar > div, .wallet-global-nav, .history-topnav) > a {
    min-height: 40px;
    align-items: center;
    font-family: var(--app-mono);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: .05em;
    line-height: 1.5;
    color: var(--app-muted);
    text-transform: uppercase;
  }
  body:is(.community-page, .public-profile-page, .site-document-page, .wallet-page, .history-page) nav a:hover { color: var(--app-accent); }

  /* Familiar title sizes, with the same restrained gold used by the tools. */

  body.history-page .masthead-title h1,
  body.community-page .community-hero h1,
  body.public-profile-page .public-profile-heading h1,
  body.site-document-page .methodology h1,
  body.wallet-library-page .wallet-library-hero h1 {
    max-width: 26ch;
    margin: 18px 0 24px;
    color: var(--app-ink);
    font-family: var(--app-sans);
    font-size: clamp(2rem, 4.2vw, 3.45rem);
    font-weight: 550;
    line-height: 1.12;
    letter-spacing: -.038em;
    text-wrap: balance;
    overflow-wrap: anywhere;
  }
  body.community-page .community-hero h1 em { color: inherit; font: inherit; }
  body.community-page :is(.community-board-head h2, .community-empty strong),
  body.public-profile-page .public-profile-cta h2 {
    font-family: var(--app-sans);
    font-size: clamp(1.25rem, 2.2vw, 1.65rem);
    line-height: 1.35;
    letter-spacing: -.025em;
  }
  body:is(.community-page, .public-profile-page) .eyebrow,
  body.history-page .publication-label {
    color: var(--app-accent);
    font-family: var(--app-mono);
    font-size: 11px;
    letter-spacing: .085em;
    line-height: 1.8;
  }

  /* Open up the address library and archive instead of nesting a second page. */
  body.wallet-library-page .wallet-library-masthead {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  body.wallet-library-page .wallet-library-masthead::before { content: none; }
  body.wallet-library-page .wallet-library-breadcrumb { padding: 0; }
  body.wallet-library-page .wallet-library-hero {
    padding: 24px 0 40px;
    gap: 40px;
    align-items: start;
  }
  body.wallet-library-page .wallet-library-hero h1 { margin-top: 14px; }
  body.wallet-library-page .wallet-library-dek { font-size: 17px; line-height: 1.75; }
  body.wallet-library-page .wallet-library-hero .wallet-editorial-meta { font-size: 12px; line-height: 1.85; margin-top: 20px; }
  body.wallet-page .wallet-story { padding-inline: 0; }
  body.wallet-page .wallet-masthead-bar { display: flex; flex-wrap: wrap; }
  body.wallet-page :is(.wallet-breadcrumb, .wallet-record-type) { border: 0; background: none; border-radius: 0; padding-inline: 0; }
  body.wallet-page .wallet-breadcrumb { flex-wrap: wrap; width: auto; }
  body.wallet-page .wallet-record-type { order: 3; flex-basis: 100%; margin: 0; }
  body.wallet-page .wallet-global-nav { margin-left: auto; }
  body.wallet-page .wallet-hero-intro { padding-left: 0; border-left: 0; background: none; }
  body.wallet-page .wallet-standfirst { font-size: 16px; line-height: 1.8; }
  body.wallet-page :is(.wallet-lineage-inspector, .wallet-address-capsule, .wallet-related-card) {
    background: var(--app-panel);
    border-color: var(--app-line);
    border-radius: 10px;
    box-shadow: none;
  }

  body.history-page .history-masthead {
    width: min(var(--app-width), calc(100% - 2 * var(--app-gutter)));
    padding: 48px 0 40px;
  }
  body.history-page .masthead-title { display: block; margin-top: 16px; }
  body.history-page .masthead-period { margin: 0; }
  body.history-page .masthead-title h1 { max-width: 26ch; }
  body.history-page :is(.masthead-introduction, .masthead-method, .masthead-actions, .history-masthead .research-byline) {
    max-width: none;
    margin-left: 0;
  }
  body.history-page .masthead-introduction { margin-top: 24px; gap: 40px; }
  body.history-page .masthead-deck { font-size: 20px; line-height: 1.65; color: var(--app-muted); }
  body.history-page .masthead-introduction p:last-child { font-size: 16px; line-height: 1.8; }
  body.history-page .history-masthead p.research-byline { margin-top: 24px; font-size: 12px; }
  body.research-page:not(.encyclopedia-page) .research-hero { padding-block: 36px 40px; }

  /* Reuse panel and control shapes; preserve data, status colors and hidden states. */
  body:is(.community-page, .public-profile-page) :is(.community-proof-note, .community-empty, .community-error, .public-profile-shell, .public-profile-cta) {
    border: 1px solid var(--app-line);
    border-radius: 10px;
    background: var(--app-panel);
    box-shadow: none;
    backdrop-filter: none;
  }
  body.community-page .community-hero { padding-block: 36px; }
  body:is(.community-page, .public-profile-page, .wallet-page) :is(button.primary, .button-link.primary, .wallet-library-actions a:first-child) {
    color: #17140f;
    background: var(--app-accent);
    border-color: var(--app-accent);
    border-radius: 6px;
    box-shadow: none;
    text-shadow: none;
  }
  body.wallet-library-page .wallet-library-actions a { border-radius: 6px; letter-spacing: .03em; }
  body:is(.community-page, .public-profile-page, .wallet-page, .history-page, .site-document-page) :is(a, button, input, select, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 4px;
  }
  body.site-document-page .document-contents a { display: flex; gap: 10px; }
  body.site-document-page .document-contents a::before { flex-shrink: 0; }

  @media (max-width: 760px) {
    body:is(.history-page, .wallet-page, .community-page, .public-profile-page, .site-document-page, .research-page) { --app-gutter: 20px; }
    body:is(.site-document-page, .wallet-page, .history-page, .community-page, .public-profile-page) :is(.document-topbar, .wallet-library-topbar, .history-topbar, .community-nav) { flex-wrap: wrap; }

    body.history-page .history-masthead { padding-block: 32px; }
    body.site-document-page .document-topbar { margin-bottom: 32px; }
    body.wallet-library-page .wallet-library-hero { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    body.wallet-page .wallet-global-nav { margin-left: 0; }
    body.history-page .masthead-introduction { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  }
  @media (max-width: 380px) {
    body:is(.history-page, .wallet-page, .community-page, .public-profile-page, .site-document-page, .research-page) { --app-gutter: 16px; }
  }
  @media (forced-colors: active) {
    body:is(.history-page, .wallet-page, .community-page, .public-profile-page, .site-document-page, .research-page) {
      --app-bg: Canvas;
      --app-panel: Canvas;
      --app-ink: CanvasText;
      --app-muted: CanvasText;
      --app-accent: LinkText;
      --app-line: CanvasText;
    }
  }
}
