/* Values extracted from the approved Library hub in styles.css (mobile hub block).
   Do not restyle the hub/results/source CTA or the Like or Pass card here. */
:root {
  --mobile-page-padding: 16px;
  --mobile-section-gap: 24px;
  --mobile-title-size: 32px;
  --mobile-section-title-size: 28px;
  --mobile-body-size: 16px;
  --mobile-meta-size: 13px;
  --mobile-control-height: 56px;
  --mobile-account-size: 52px;
  --mobile-card-radius: 24px;
  --mobile-input-radius: 28px;
  --mobile-pill-radius: 999px;
  --mobile-border: 1.5px solid rgba(15, 17, 21, 0.08);
  --mobile-surface: #fafafa;
}

/* Photo hydration is presentation only, including on desktop. Keep geometry stable. */
.brandbook-body :is(.profile-avatar, .header-user-avatar, .mini-avatar, .feed-avatar, .feed-comment-avatar, .reference-owner-avatar, .avatar).has-photo,
.brandbook-body :is(.profile-avatar, .header-user-avatar, .mini-avatar, .feed-avatar, .feed-comment-avatar, .reference-owner-avatar, .avatar).avatar-loading {
  background: #f4f4f5;
}
.brandbook-body .avatar-loading img { opacity: 0; }
.brandbook-body .has-photo img { object-fit: cover; }

.reference-photo-picker {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: var(--mobile-border);
  border-radius: var(--mobile-card-radius);
  background: var(--mobile-surface);
}
.reference-photo-picker input[type="file"] { display: none; }
.reference-photo-picker .reference-image-preview:not([hidden]) { display: grid; gap: 8px; }
.reference-photo-picker .reference-image-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  border-radius: 16px;
  object-fit: contain;
}
.reference-photo-picker :is(small, [role="status"]) { font-size: 13px; color: var(--text-soft); }
.reference-photo-picker [role="status"]:empty { display: none; }
.reference-photo-picker button { min-height: 44px; }
.reference-photo-picker button:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.reference-form-mobile-title { display: none; }

.feed-ref-block.has-reference-image { position: relative; overflow: hidden; }
.feed-reference-image { display: block; width: 100%; height: 220px; object-fit: cover; border-radius: 16px; }
.feed-ref-block.has-reference-image { grid-template-columns: minmax(0, 1fr); }
.messages-placeholder { max-width: 600px; margin: 24px auto; padding: 24px; }
.messages-placeholder > svg { width: 56px; height: 56px; fill: none; stroke: var(--primary); stroke-width: 1.5; }

@media (max-width: 768px) {
  .brandbook-body:is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page, [data-auth-page]) {
    background: #fff;
    font-size: var(--mobile-body-size);
  }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header {
    min-height: calc(84px + env(safe-area-inset-top, 0px));
    height: auto;
    padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
    gap: 12px;
    grid-template-areas: none;
    background: #fff;
  }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header--title { grid-template-columns: 44px minmax(0, 1fr) 52px; }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header > strong {
    font-size: var(--mobile-title-size);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header-icon { width: 44px; min-height: 44px; }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-account { width: 52px; height: 52px; max-width: 52px; }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header > * { grid-area: auto; }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-account :is(.auth-trigger, .header-user-profile) {
    display: flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; min-height: 52px; padding: 0;
    border: var(--mobile-border); border-radius: 50%; background: #fff; overflow: hidden;
  }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-account .header-user-avatar { width: 100%; height: 100%; border-radius: 50%; }
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-account .auth-trigger::before {
    content: ""; display: block; width: 20px; height: 20px; flex: 0 0 20px; background: currentColor;
    --profile-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21v-2a8 8 0 0 1 16 0v2'/%3E%3C/svg%3E");
    -webkit-mask: var(--profile-icon) center / contain no-repeat;
    mask: var(--profile-icon) center / contain no-repeat;
  }
  .brandbook-body :is(.profile-avatar, .header-user-avatar, .mini-avatar, .feed-avatar, .feed-comment-avatar, .reference-owner-avatar, .avatar):not(.has-photo) { background: #f4f4f5; color: var(--text-soft); }

  /* The existing form remains a single owner/admin workflow on all devices. */
  .library-page #addReferenceDialog {
    width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh;
    margin: 0; padding: 0; border: 0; border-radius: 0; background: #fff;
  }
  .library-page #addReferenceForm {
    min-width: 0; padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    background: #fff; gap: var(--mobile-section-gap);
  }
  .library-page #addReferenceForm .dialog-head {
    display: flex; position: sticky; top: 0; z-index: 2; gap: 12px; align-items: center;
    min-height: 84px; padding: calc(16px + env(safe-area-inset-top, 0px)) 0 16px; background: #fff;
  }
  .library-page #addReferenceForm .dialog-head > div { min-width: 0; flex: 1; }
  .library-page #addReferenceForm .dialog-head :is(.eyebrow, .reference-form-desktop-title) { display: none; }
  .library-page #addReferenceForm .reference-form-mobile-title { display: block; font-size: var(--mobile-title-size); line-height: 1.05; letter-spacing: -0.03em; }
  .library-page #closeAddReference { order: -1; flex: 0 0 44px; min-height: 44px; height: 44px; width: 44px; padding: 0; font-size: 0; border: var(--mobile-border); border-radius: 50%; }
  .library-page #closeAddReference::before { content: "\2190"; font-size: 24px; }
  .library-page #addReferenceForm .dialog-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .library-page #addReferenceForm .search-field { gap: 8px; min-width: 0; }
  .library-page #addReferenceForm .search-field > span { position: static; width: auto; height: auto; overflow: visible; clip: auto; font-size: 16px; font-weight: 700; text-transform: none; letter-spacing: 0; }
  .library-page #addReferenceForm .search-field::before { content: none; }
  .library-page #addReferenceForm :is(input:not([type="radio"]):not([type="file"]), select, textarea),
  .brandbook-body:is(.profile-page, .feed-page, .community-page, [data-auth-page]) :is(input:not([type="radio"]):not([type="file"]):not([type="checkbox"]), select, textarea) {
    max-width: 100%; min-width: 0; min-height: var(--mobile-control-height);
    padding: 16px 18px; border: var(--mobile-border); border-radius: var(--mobile-input-radius);
    background: var(--mobile-surface); color: var(--text); font-size: 16px; line-height: 1.4;
  }
  .library-page #addReferenceForm textarea { min-height: 120px; resize: vertical; }
  .library-page #addReferenceForm .button-row { position: static; gap: 12px; background: none; }
  .library-page #addReferenceForm .button { min-height: 52px; border-radius: var(--mobile-pill-radius); font-size: 16px; }
  .library-page #saveReferenceButton { width: 100%; min-height: 54px; order: -1; background: var(--brand-gradient); color: #fff; font-weight: 800; }
  .library-page #addReferenceForm > .button-row { flex-direction: column; }
  .library-page .reference-drafts-panel { padding: 16px; border: var(--mobile-border); border-radius: var(--mobile-card-radius); background: #fff; }
  .library-page .reference-target-field { padding: 16px; border: var(--mobile-border); border-radius: var(--mobile-card-radius); }
  .library-page .reference-target-option { min-width: 0; }
  .library-page .reference-target-option small { font-size: 13px; }

  .feed-page .feed-mobile-tabs { gap: 12px; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
  .feed-page .feed-mobile-tabs a { min-height: 44px; display: inline-flex; align-items: center; padding: 8px 20px; border-radius: 999px; font-size: 16px; }
  .feed-page .feed-card { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); gap: 12px; }
  .feed-page .feed-user { gap: 12px; }
  .feed-page :is(.feed-avatar, .feed-comment-avatar) { width: 44px; height: 44px; flex-basis: 44px; }
  .feed-page :is(.feed-meta-line, .feed-meta-line strong, .feed-post-text) { font-size: 16px; line-height: 1.4; }
  .feed-page :is(.feed-user .meta, .feed-ref-copy p, .feed-ref-copy .meta) { font-size: 13px; line-height: 1.4; }
  .feed-page .feed-card-top .tag { font-size: 11px; padding: 4px 8px; }
  .feed-page .feed-ref-block { padding: 18px; border-radius: 24px; min-height: 200px; gap: 12px; }
  .feed-page .feed-ref-copy h3 { font-size: 18px; line-height: 1.2; }
  .feed-page .feed-action-button { min-height: 44px; font-size: 13px; }
  .feed-page .has-reference-image .feed-reference-image { position: absolute; inset: 0; height: 100%; border-radius: inherit; }
  .feed-page .has-reference-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .8)); pointer-events: none; }
  .feed-page .has-reference-image :is(.feed-ref-copy, .feed-open-button) { position: relative; z-index: 1; }

  .profile-page .profile-shell { gap: 24px; }
  .profile-page .profile-shell > .profile-card:first-child { padding: 0 16px 16px; column-gap: 12px; }
  .profile-page .profile-mobile-cover { width: calc(100% + 32px); margin-inline: -16px; }
  .profile-page .profile-meta { gap: 8px; margin-top: 12px; }
  .profile-page .profile-meta h3 { font-size: 28px; line-height: 1.1; font-weight: 800; }
  .profile-page .profile-meta .meta { font-size: 13px; }
  .profile-page .profile-meta .card-description { display: block; overflow: visible; font-size: 16px; line-height: 1.45; max-width: 100%; }
  .profile-page :is(.profile-mobile-edit-toggle, .profile-follow-toggle, .profile-mobile-member-panel .profile-bio-edit-toggle) { min-height: 44px; padding: 8px 16px; font-size: 16px; border-radius: 999px; }
  .profile-page .profile-follow-toggle { position: static; margin-block: 12px; }
  .profile-page .profile-social-stats { margin-top: 24px; }
  .profile-page :is(.profile-follow-button, .profile-stats article) strong { font-size: 18px; }
  .profile-page :is(.profile-follow-button, .profile-stats article) .meta { font-size: 13px; }
  .profile-page .profile-shell > .profile-card:last-child { padding-inline: 16px; }
  .profile-page .profile-mobile-tabs { min-height: 44px; gap: 24px; }
  .profile-page .profile-mobile-tabs a { font-size: 16px; padding-block: 12px; }
  .profile-page .activity-list { gap: 12px; margin-inline: -16px !important; padding: 16px; }
  .profile-page .activity-item { flex-basis: 160px; min-height: 168px; border-radius: 24px; padding: 18px; }
  .profile-page .activity-item h4 { font-size: 18px; line-height: 20px; }
  .profile-page .activity-item :is(p, .meta, .eyebrow) { font-size: 13px; line-height: 18px; }
  .profile-page .profile-mobile-member-panel { padding: 16px; border-radius: 24px; background: #fafafa; }
  .profile-page .profile-mobile-member-panel .button { min-height: 44px; font-size: 16px; }

  .brandbook-body[data-auth-page] > .page-shell { width: 100%; max-width: 100%; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
  .brandbook-body[data-auth-page] .site-header { min-height: 84px; margin: 0; padding: 16px 0; border: 0; flex-wrap: nowrap; }
  .brandbook-body[data-auth-page] .brand-logo { width: 128px; height: 52px; object-fit: contain; }
  .brandbook-body[data-auth-page] .main-grid { margin: 0; gap: 0; }
  .brandbook-body[data-auth-page] :is(.auth-page-shell, .auth-page-card) { width: 100%; max-width: 100%; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
  .brandbook-body[data-auth-page] .auth-page-copy { gap: 12px; padding: 24px 0; }
  .brandbook-body[data-auth-page] .auth-page-copy > .brandbook-label { display: none; }
  .brandbook-body[data-auth-page] .auth-page-copy h1 { font-size: 32px; line-height: 1.05; letter-spacing: -0.03em; font-weight: 800; }
  .brandbook-body[data-auth-page] .auth-page-copy p { font-size: 13px; line-height: 1.45; }
  .brandbook-body[data-auth-page] .auth-form { gap: 20px; }
  .brandbook-body[data-auth-page] .search-field > span { font-size: 16px; text-transform: none; letter-spacing: 0; }
  .brandbook-body[data-auth-page] .password-field input { padding-right: 56px; }
  .brandbook-body[data-auth-page] .button { min-height: 52px; font-size: 16px; border-radius: 999px; }
  .brandbook-body[data-auth-page] .auth-form-actions .button-primary { width: 100%; background: var(--brand-gradient); }
  .brandbook-body[data-auth-page] .auth-page-links { gap: 16px; margin-top: 24px; flex-wrap: wrap; }
  .brandbook-body[data-auth-page] .text-button { min-height: 44px; font-size: 16px; }
  .brandbook-body[data-auth-page] .auth-confirmation-panel { padding: 24px 16px; border-radius: 24px; }
  .brandbook-body[data-auth-page] .site-footer { margin-top: 24px; }
  .messages-page > .page-shell { padding: 0; width: 100%; max-width: 100%; }
  .messages-page .messages-placeholder { margin: 0; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
  .messages-page .messages-placeholder h1 { font-size: 28px; }
  .messages-page .messages-placeholder p { font-size: 16px; }
  .quiz-page :is(.quiz-option, .quiz-question-text) { font-size: 16px; line-height: 1.4; }
  .quiz-page .quiz-option { min-height: 56px; border-radius: 28px; }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 768px),
       (orientation: landscape) and (max-height: 500px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  :is(.feed-page, .profile-page, .quiz-page, .community-page, .messages-page) .mobile-app-header { display: none; }
  .library-page #addReferenceForm .dialog-head { position: static; min-height: 44px; padding-block: 8px; }
}
