/* Birdies mobile components. The desktop layout is intentionally unchanged.
   The shared mobile tokens are declared by the shell stylesheet. */
@media (max-width: 1023px) {
  #content {
    min-width: 0;
    line-height: 1.55;
  }

  #content :where(.grid, .ns-grid, .ff-grid, .ff-two-person, .fp-members,
    .fp-step-grid, .fp-field-grid, .fp-totals, .ns-form-grid) {
    gap: var(--mobile-space-4, 16px);
    min-width: 0;
  }

  #content :where(.grid) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-block: var(--mobile-space-6, 24px);
  }

  #content :where(.card, .ns-card, .fp-member, .fp-step-card, .fp-figure) {
    min-width: 0;
    padding: var(--mobile-space-5, 20px);
    border-radius: var(--mobile-radius-card, 20px);
  }

  #content :where(.ns-hero, .ns-guide, .ff-hero, .ff-panel, .fp-intro, .fp-panel) {
    min-width: 0;
    padding: var(--mobile-space-5, 20px);
    border-radius: var(--mobile-radius-card, 20px);
    margin-block: var(--mobile-space-5, 20px);
  }

  #content > form,
  #content > details > form {
    min-width: 0;
    padding: var(--mobile-space-5, 20px);
    border-radius: var(--mobile-radius-card, 20px);
  }

  #content :where(h1, h2, h3, h4, p, li, label, summary, a, .tag,
    .ns-tag, .fp-pill, .ff-badge, .brain-status, .stat, .ff-number,
    .ns-balance, .brain-report, .review-row, .fp-review-row, .ff-review,
    .ns-review, .readable-record, .record-item) {
    overflow-wrap: anywhere;
    min-width: 0;
  }

  #content :where(h1) {
    font-size: clamp(30px, 5vw, 40px);
    line-height: 1.15;
    letter-spacing: -.8px;
    margin-block: var(--mobile-space-5, 20px) var(--mobile-space-4, 16px);
  }

  #content :where(h2) {
    font-size: clamp(25px, 4vw, 32px);
    line-height: 1.22;
  }

  #content :where(h3) {
    line-height: 1.3;
    letter-spacing: -.3px;
  }

  #content :where(p) {
    line-height: 1.6;
  }

  #content :where(.hint, .ns-muted, .ns-field-help, .fp-help, .ff-subtle) {
    font-size: 14px;
    line-height: 1.55;
    color: var(--mobile-muted, #536b7b);
  }

  #content :where(button, input, select, textarea) {
    max-width: 100%;
    min-width: 0;
    font: inherit;
    font-size: 16px;
    border-radius: var(--mobile-radius-control, 12px);
  }

  #content :where(button) {
    min-height: var(--mobile-control, 48px);
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.4;
    padding: var(--mobile-space-3, 12px) var(--mobile-space-4, 16px);
    touch-action: manipulation;
  }

  #content :where(input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea) {
    width: 100%;
    min-height: var(--mobile-control, 48px);
    padding: var(--mobile-space-3, 12px);
    margin-block: var(--mobile-space-2, 8px) 0;
  }

  #content :where(input[type=date], input[type=datetime-local]) {
    min-inline-size: 0;
  }

  #content :where(textarea) {
    min-height: 120px;
    resize: vertical;
  }

  #content :where(input[type=checkbox], input[type=radio]) {
    width: 24px;
    height: 24px;
    min-height: 24px;
    flex: 0 0 24px;
    margin: 2px 0 0;
  }

  #content :where(label) {
    font-size: 15px;
    line-height: 1.5;
    color: var(--mobile-muted, #536b7b);
  }

  #content :where(form > label, .fp label, .ns-guide label, .ff-panel label) {
    margin-block: var(--mobile-space-5, 20px);
  }

  #content :where(label:has(> input[type=checkbox]), label:has(> input[type=radio]), .check) {
    display: flex;
    align-items: flex-start;
    gap: var(--mobile-space-3, 12px);
    min-height: var(--mobile-control, 48px);
  }

  #content :where(.fp-review-toggle, .fp-inventory-choice) {
    padding: var(--mobile-space-4, 16px);
    border-radius: var(--mobile-radius-control, 12px);
  }

  #content :where(.fp-review-toggle > span, .fp-inventory-choice > span) {
    min-width: 0;
    flex: 1;
  }

  #content :where(details) {
    min-width: 0;
    margin-block: var(--mobile-space-4, 16px);
  }

  #content :where(summary) {
    min-height: var(--mobile-control, 48px);
    padding-block: var(--mobile-space-3, 12px);
    line-height: 1.5;
    cursor: pointer;
    touch-action: manipulation;
  }

  #content :where(details[open] > summary) {
    margin-bottom: var(--mobile-space-2, 8px);
  }

  #content :where(.ns-tags, .fp-pills, .ff-badges) {
    gap: var(--mobile-space-2, 8px);
    align-items: flex-start;
    margin-block: var(--mobile-space-4, 16px) var(--mobile-space-5, 20px);
  }

  #content :where(.tag, .ns-tag, .fp-pill, .ff-badge, .brain-status) {
    max-width: 100%;
    white-space: normal;
    font-size: 13px;
    line-height: 1.45;
    letter-spacing: 0;
    padding: 7px var(--mobile-space-3, 12px);
  }

  #content :where(.ns-card > .ns-step-number, .fp-eyebrow, .ns-eyebrow, .ff-eyebrow) {
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: .08em;
    color: var(--mobile-muted, #536b7b);
  }

  #content :where(.eyebrow, .ns-step-number, .fp-label, .ns-editor-title,
    .survey-top, .fp-review-row span, .ns-review span, .ff-review span,
    .fp-figure > span:first-child) {
    color: var(--mobile-muted, #536b7b);
  }

  #content :where(.ns-card > .ns-step-number) {
    margin-bottom: var(--mobile-space-2, 8px);
  }

  #content :where(.ns-card > .ns-tag, .ns-card > .brain-status) {
    margin-bottom: var(--mobile-space-4, 16px);
  }

  #content :where(.fp-entry) {
    padding: var(--mobile-space-4, 16px);
    margin-block: var(--mobile-space-5, 20px);
    border-radius: 16px;
    min-width: 0;
  }

  #content :where(.fp-entry legend) {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.5;
    padding-inline: var(--mobile-space-1, 4px);
    overflow-wrap: anywhere;
  }

  #content :where(.fp-source, .ns-extra, .ff-explanation) {
    padding: var(--mobile-space-3, 12px);
    margin-block: var(--mobile-space-4, 16px);
    border-radius: 14px;
  }

  #content :where(.fp-source > summary, .ns-extra > summary, .ff-explanation > summary) {
    margin-block: -4px;
  }

  #content :where(.fp-entry-top) {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--mobile-space-2, 8px);
    margin-bottom: var(--mobile-space-3, 12px);
  }

  #content :where(.fp-entry-top > span) {
    flex: 1 1 110px;
  }

  #content :where(.fp-entry-top > button) {
    font-size: 14px;
  }

  #content :where(.fp-callout, .fp-empty, .fp-saved, .fp-error,
    .ns-callout, .ns-saved, .ns-saved-record, .ns-error, .ns-preview,
    .ff-empty, .ff-lesson, .ff-success, .ff-pending, .chapter-note, .empty) {
    padding: var(--mobile-space-4, 16px);
    margin-block: var(--mobile-space-4, 16px);
    border-radius: 16px;
    min-width: 0;
  }

  #content :where(.actions, .ns-actions, .fp-actions, .ff-actions, .survey-actions) {
    gap: var(--mobile-space-3, 12px);
    align-items: stretch;
    margin-block: var(--mobile-space-6, 24px) var(--mobile-space-2, 8px);
  }

  #content :where(.ns-inline-links) {
    gap: var(--mobile-space-2, 8px) var(--mobile-space-4, 16px);
  }

  #content :where(.ns-inline-links a, .ns-source-link) {
    display: inline-flex;
    align-items: center;
    min-height: var(--mobile-control, 48px);
    max-width: 100%;
    line-height: 1.5;
  }

  #content :where(.brain-prompt, pre) {
    max-width: 100%;
    padding: var(--mobile-space-3, 12px);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  #content :where(.table-wrap) {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    margin-block: var(--mobile-space-5, 20px);
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  #content :where(.table-wrap table) {
    width: 100%;
    min-width: 440px;
    font-size: 14px;
  }

  #content :where(.table-wrap th, .table-wrap td) {
    padding: var(--mobile-space-3, 12px) var(--mobile-space-4, 16px);
    vertical-align: top;
  }

  #content :where(.table-wrap th) {
    background: #eef3f7;
    color: var(--mobile-muted, #536b7b);
  }

  #content :where(.survey-top, .ff-stage-heading) {
    flex-wrap: wrap;
    gap: var(--mobile-space-2, 8px) var(--mobile-space-4, 16px);
  }

  #content :where(.survey-parts) {
    gap: var(--mobile-space-2, 8px);
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-block: var(--mobile-space-1, 4px);
  }

  #content :where(.survey-parts button, .ff-chapters button) {
    min-width: var(--mobile-control, 48px);
    min-height: var(--mobile-control, 48px);
    flex: 0 0 48px;
    padding: 0;
    font-size: 14px;
  }

  #content :where(.survey-review) {
    max-height: none;
    padding: var(--mobile-space-3, 12px) var(--mobile-space-4, 16px);
  }

  #confirmation {
    width: min(700px, calc(100% - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: var(--mobile-space-5, 20px);
    border-radius: var(--mobile-radius-card, 20px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-padding-block: var(--mobile-space-5, 20px);
  }

  #confirmation :where(h2) {
    font-size: 26px;
    line-height: 1.2;
    margin-block: 0 var(--mobile-space-4, 16px);
  }

  #confirmation :where(p, h3, strong, span, li, a) {
    overflow-wrap: anywhere;
    min-width: 0;
  }

  #confirmation .friendly-preview {
    max-height: none;
    overflow: visible;
    padding: var(--mobile-space-4, 16px);
    margin-block: var(--mobile-space-4, 16px);
  }

  #confirmation > .actions {
    position: sticky;
    bottom: calc(-1 * var(--mobile-space-5, 20px));
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--mobile-space-3, 12px);
    padding-block: var(--mobile-space-4, 16px) var(--mobile-space-5, 20px);
    margin-bottom: calc(-1 * var(--mobile-space-5, 20px));
    background: #fff;
    border-top: 1px solid var(--line);
  }

  #confirmation > .actions button {
    min-width: 0;
    min-height: var(--mobile-control, 48px);
    font-size: 16px;
    line-height: 1.4;
    white-space: normal;
    padding: var(--mobile-space-3, 12px);
    border-radius: var(--mobile-radius-control, 12px);
    touch-action: manipulation;
  }
}

@media (max-width: 800px) {
  #content:is(.ns, .fp, .ff) {
    padding-bottom: 0;
  }

  #content :where(.brain-team) {
    padding-bottom: 0;
  }

  #content :where(.ff-tabs) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--mobile-space-2, 8px);
    margin-block: var(--mobile-space-4, 16px);
  }

  #content :where(.ff-tabs button) {
    padding: var(--mobile-space-3, 12px) var(--mobile-space-2, 8px);
    font-size: 14px;
  }
}

@media (max-width: 640px) {
  #content :where(.grid, .ns-grid, .ns-options, .ns-form-grid, .ff-grid,
    .ff-two-person, .ff-choices, .ff-mission-list, .survey-choices,
    .fp-members, .fp-step-grid, .fp-field-grid, .fp-totals) {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--mobile-space-3, 12px);
  }

  #content :where(.card, .ns-card, .fp-member, .fp-step-card, .fp-figure,
    .ns-hero, .ns-guide, .ff-hero, .ff-panel, .fp-intro, .fp-panel) {
    padding: var(--mobile-space-4, 16px);
  }

  #content > form,
  #content > details > form {
    padding: var(--mobile-space-4, 16px);
  }

  #content :where(.fp-entry) {
    padding: var(--mobile-space-3, 12px);
  }

  #content :where(.fp-field-grid, .ns-form-grid) {
    row-gap: 0;
  }

  #content :where(.ns-heading-row) {
    gap: var(--mobile-space-3, 12px);
    align-items: flex-start;
  }

  #content :where(.ns-heading-row > :not(img)) {
    min-width: 0;
    flex: 1;
  }

  #content :where(.ns-birds) {
    width: 48px;
    height: 44px;
    flex: 0 0 48px;
  }

  #content :where(.ff-guide) {
    width: 64px;
    height: 56px;
    float: none;
    display: block;
    margin-bottom: var(--mobile-space-3, 12px);
  }

  #content :where(h1) {
    font-size: 30px;
  }

  #content :where(h2, .ns-guide h2, .ff-panel h2, .fp-panel h2) {
    font-size: 26px;
  }

  #content :where(.ns-card h3, .fp-member h3, .fp-step-card h3) {
    font-size: 23px;
  }

  #content :where(.stat, .ff-number, .ns-balance, .fp-figure strong) {
    font-size: 27px;
    line-height: 1.3;
  }

  #content :where(.ff-tabs) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #content :where(.ns-options button, .ff-choice, .survey-choices .choice) {
    min-height: 64px;
    padding: var(--mobile-space-4, 16px);
    padding-right: 38px;
    text-align: left;
  }

  #content :where(.ff-choice[aria-pressed=true], .survey-choices .choice.selected,
    .ns-options button[aria-pressed=true]) {
    padding: 15px;
    padding-right: 37px;
  }

  #content :where(.survey-intro, .survey-explanation) {
    font-size: 16px;
    margin-block: var(--mobile-space-4, 16px) var(--mobile-space-6, 24px);
  }

  #content:is(.survey) {
    margin-block: var(--mobile-space-5, 20px);
  }

  #content :where(.actions, .ns-actions, .fp-actions, .ff-actions, .survey-actions) {
    flex-direction: column;
    align-items: stretch;
  }

  #content :where(.actions > button, .ns-actions > button, .fp-actions > button,
    .ff-actions > button, .survey-actions > button) {
    width: 100%;
    flex: 0 1 auto;
    margin-left: 0;
    margin-right: 0;
  }

  #content :where(.card > button, .fp-saved > button, .fp-member > button,
    .ns-guide > button, .ff-panel > button, form > button[type=submit]) {
    width: 100%;
  }

  #content :where(.card > button + button, .ns-guide > button + button,
    .ff-panel > button + button) {
    margin-top: var(--mobile-space-3, 12px);
  }

  #confirmation {
    width: calc(100% - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: var(--mobile-space-4, 16px);
  }

  #confirmation .friendly-preview {
    padding: var(--mobile-space-3, 12px);
  }

  #confirmation > .actions {
    bottom: calc(-1 * var(--mobile-space-4, 16px));
    margin-bottom: calc(-1 * var(--mobile-space-4, 16px));
    padding-bottom: var(--mobile-space-4, 16px);
  }
}

@media (max-width: 359px) {
  #content :where(h1) {
    font-size: 28px;
  }

  #content :where(h2, .ns-guide h2, .ff-panel h2, .fp-panel h2) {
    font-size: 24px;
  }

  #content :where(.ns-hero .ns-heading-row) {
    flex-direction: column;
  }

  #confirmation > .actions {
    grid-template-columns: 1fr;
  }
}

@media (hover: none) and (max-width: 1023px) {
  #content :where(.choice:hover, .ff-choice:hover) {
    transform: none;
  }
}
