/* Use the iOS system body size on the sign-in, Documents and Transactions screens.
   Their existing rem type sizes then follow the user's Larger Text setting. */
@supports (font: -apple-system-body) and (-webkit-touch-callout: none) {
  html:has(#auth-view:not(.hidden), #section-documents:not(.hidden), #section-transactions:not(.hidden)) {
    font: -apple-system-body;
  }
  body:has(#auth-view:not(.hidden), #section-documents:not(.hidden)),
  #section-transactions .transaction-activity-list {
    /* Preserve the existing 15px body text at iOS's standard 17px system size. */
    font-size: calc(15rem / 17);
  }

  /* Family does not set a system size on the root. Scale its native disclosure locally. */
  #section-family div.support-privacy {
    font: -apple-system-body;
  }
  #section-family .support-privacy details {
    font-size: calc(15em / 17);
  }
  #section-family .support-privacy h2 {
    font-size: calc(1.15em * 17 / 15);
  }

  @media (max-width: 800px) {
    .auth-shell,
    .main-content:has(#section-documents:not(.hidden), #section-transactions:not(.hidden)) { overflow-wrap: anywhere; }
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    /* Display headings still grow, with room for words at narrow widths. */
    .auth-intro h1 { font-size: min(2.3rem, .65rem + 6.4vw); }
    .auth-intro > p:not(.eyebrow) { font-size: min(1.1rem, .6rem + 1.9vw); }
    .auth-form h2 { font-size: min(1.8rem, .75rem + 4.25vw); }
    .main-content:has(#section-documents:not(.hidden)) .topbar h1 {
      font-size: min(1.7rem, .65rem + 4vw);
    }
    #app-view:has(#section-documents:not(.hidden)) .month-picker input {
      font-size: min(1rem, .5rem + 2vw);
      max-width: 100%;
    }
    #app-view:has(#section-documents:not(.hidden)) .navigation-close { flex-shrink: 0; }
    #app-view:has(#section-documents:not(.hidden)) .nav-link span {
      flex: 0 0 1.1em;
      font-size: 1em;
    }
    .auth-tabs { flex-wrap: wrap; }
    .auth-form,
    .documents-panel,
    .documents-add-actions { min-width: 0; }
    .documents-search { display: flex; flex-wrap: wrap; }
    .documents-search > label:nth-child(-n+2) { flex: 1 1 100%; }
    .documents-search > .check-label { flex: 1 1 max-content; }
    .documents-search > label > input::placeholder,
    .documents-search > label > select {
      font-size: min(1rem, .5rem + 2vw);
    }
    .auth-form .button,
    .documents-add-actions .button,
    .documents-search .button { max-width: 100%; white-space: normal; }
  }
}

/* Focused layout refinements for the 2026-11-10 product UX review. */
#section-overview > .plan-panel { margin-bottom: 24px; }
#section-overview > .two-col { margin-bottom: 24px; }
.connection-freshness-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  overflow-wrap: anywhere;
}
.connection-freshness-row > * { min-width: 0; max-width: 100%; }
.connection-freshness-row > small { margin-top: 0; }
#section-overview > .account-snapshot #overview-account-total { display: block; }
#section-overview > .account-snapshot #overview-account-total + small { display: block; margin-top: 8px; }

#section-categories > .two-col + .muted { margin: 16px 0 0; }

#section-income > .two-col > .panel:first-child,
#section-accounts > .two-col > .panel:first-child,
#section-bills > .two-col > .panel:first-child,
#section-categories > .two-col > .panel:first-child,
#section-goals > .two-col > .panel:first-child,
#section-net-worth > .two-col > .panel:first-child { align-self: start; }

.bank-activity-search { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.bank-activity-search input { flex: 1 1 220px; min-width: 0; }
.bank-activity-search button { flex: 0 0 auto; }
.bank-activity-search small { flex: 1 0 100%; margin: 0; line-height: 1.45; }
.bank-connection { container-type: inline-size; }
@container (max-width: 560px) {
  .bank-account-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; }
  .bank-account-row select { grid-column: 1 / -1; }
}

.documents-fields textarea { font: inherit; font-size: max(16px, 1rem); line-height: 1.5; padding: 12px 13px; color: var(--text); background: var(--input); border: 1px solid var(--control-border); border-radius: 8px; }
.documents-fields textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }

#join-form { display: grid; gap: 16px; }
.family-members-panel td:last-child > .text-button + .text-button { margin-left: 12px; }
.family-members-panel .text-button,
.family-members-panel .danger { min-height: 44px; padding: 10px 8px; white-space: normal; text-align: left; }
.family-confirmation-actions { gap: 12px; }
.support-privacy { margin-block-start: 1rem; overflow-wrap: anywhere; }
nav.support-privacy { display: flex; flex-wrap: wrap; column-gap: 1rem; }
.support-privacy a, .support-privacy summary { color: var(--action); }
.support-privacy a { display: inline-flex; align-items: center; min-block-size: 44px; }
.support-privacy summary { min-block-size: 44px; padding-block: 0.65rem; cursor: pointer; }
.support-privacy h2 { margin-block: 1rem 0.25rem; font-size: 1.15rem; }

/* Navigation controls are injected only after the authenticated shell starts. */
.navigation-close[hidden],
.navigation-backdrop[hidden] { display: none !important; }
.navigation-close { display: block; min-height: 44px; width: 100%; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--control-border); border-radius: 8px; background: var(--sidebar-active); color: var(--text); font: inherit; font-weight: 700; text-align: left; }
.navigation-close:focus-visible,
.navigation-backdrop:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.navigation-backdrop { position: fixed; inset: 0; z-index: 3; width: 100vw; height: 100vh; height: 100dvh; padding: 0; border: 0; border-radius: 0; background: rgb(16 24 32 / 58%); }
.navigation-close:not([hidden]),
.navigation-backdrop:not([hidden]) { display: block; }

/* Keep the injected goal form styling ready for its later native disclosure wrapper. */
.entry-disclosure { min-width: 0; align-self: start; padding: 0; }
.entry-disclosure > summary { display: flex; min-height: 44px; align-items: center; gap: 12px; padding: 18px 22px; cursor: pointer; }
.entry-disclosure > summary { justify-content: space-between; list-style: none; }
.entry-disclosure > summary::-webkit-details-marker { display: none; }
.entry-disclosure > summary::after { content: '+'; display: grid; flex: 0 0 24px; width: 24px; height: 24px; place-items: center; border: 1px solid var(--control-border); border-radius: 50%; color: var(--action); font: 700 1rem/1 system-ui, sans-serif; }
.entry-disclosure[open] > summary::after { content: '−'; }
.entry-disclosure > summary h3 { margin: 0; }
.entry-disclosure[open] > summary { margin-bottom: 0; }
.entry-disclosure > form { display: grid; min-width: 0; gap: 16px; padding: 16px 22px 22px; }

.category-row > div:last-child > .text-button,
.category-row > div:last-child > .delete-button,
.document-actions > button,
.goal-plan-card .goal-action { min-height: 44px; padding: 10px 8px; white-space: normal; }
.document-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.document-status-badge:not(.is-expired):not(.is-review-due) { background: var(--selection); color: var(--text); }
.family-members-guidance { margin: 0 0 18px; line-height: 1.55; }
.family-coverage-panel { margin-top: 22px; }
.family-coverage-status p { margin: 12px 0; }
.family-coverage-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 12px 0; }
.family-coverage-details dt { font-weight: 600; }
.family-coverage-details dd { margin: 0; overflow-wrap: anywhere; }
.family-coverage-refresh { min-height: 44px; text-align: left; }

@media (max-width: 600px) {
  .bank-activity-search { align-items: stretch; gap: 8px; }
  .bank-activity-search input { flex-basis: 100%; }
  .bank-activity-search button { min-height: 44px; }
  .family-members-panel td:last-child { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .family-members-panel td:last-child > .text-button + .text-button { margin-left: 0; }
  .transaction-row .delete-button,
  .document-actions .text-button,
  .category-row .text-button,
  .budget-history-category .text-button { min-height: 44px; padding: 10px 8px; white-space: normal; }
  .banks-actions .button,
  .bank-actions .button,
  .family-confirmation-actions .button { min-height: 44px; white-space: normal; }
}

@media (max-width: 800px) {
  .sidebar { z-index: 4; width: min(280px, 84vw); max-width: calc(100vw - 24px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
}

/* Document status cues use the active light/dark appearance palette. */
.document-status-summary { margin-bottom: 16px; }
.document-status-summary h3 { margin: 0 0 8px; }
.document-summary-message { margin: 0; color: var(--muted-text); line-height: 1.5; }
.document-status-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.document-status-badge.is-expired { background: var(--danger-bg); color: var(--danger); }
.document-status-badge.is-review-due { background: var(--warning-bg); color: var(--warning); }
