/* Portal UI v13: shared member-page frame and compact survey navigation.
   The accepted navigation and existing content styles remain in style.css.
   Public HP, billing actions, survey persistence and email transport are unchanged. */

@media (min-width: 821px) {
  .nav-more > .nav-grouped-menu {
    display: block;
    box-sizing: border-box;
    width: 370px;
    min-width: 0;
    max-width: calc(100vw - 32px);
    max-height: min(640px, calc(100vh - 210px));
    max-height: min(640px, calc(100dvh - 210px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 12px 12px;
  }
  .nav-more:not([open]) > .nav-grouped-menu { display: none; }
  .nav-grouped-menu__header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
    padding: 2px 4px;
    background: var(--surface);
  }
  .nav-grouped-menu__header > p {
    margin: 0;
    color: var(--heading);
    font-size: .98rem;
    font-weight: 800;
  }
  .nav-grouped-menu__close {
    display: grid;
    place-items: center;
    width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--heading);
    font-size: 1.6rem;
    line-height: 1;
    box-shadow: none;
    cursor: pointer;
  }
  .nav-grouped-menu__close:hover { background: var(--chip); }
  .nav-grouped-menu .nav-mobile-group { margin: 0 0 10px; padding: 0; min-width: 0; }
  .nav-grouped-menu .nav-mobile-group:last-child { margin-bottom: 0; }
  .nav-grouped-menu .nav-mobile-group__title {
    margin: 0;
    padding: 2px 6px 4px;
    color: var(--ink-muted);
    font-size: .71rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: .03em;
  }
  .nav-grouped-menu .nav-mobile-group__links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 4px;
  }
  .nav-grouped-menu .nav-menu-item {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    height: auto;
    margin: 0;
    padding: 8px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: var(--heading);
    font-size: .875rem;
    font-weight: 700;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    text-decoration: none;
  }
  .nav-grouped-menu .nav-menu-item:hover { background: var(--chip); color: var(--heading); }
  .nav-grouped-menu .nav-menu-item[aria-current="page"] { background: var(--chip); box-shadow: inset 3px 0 0 var(--primary); }
  .nav-grouped-menu .nav-menu-item:focus-visible,
  .nav-grouped-menu__close:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  .nav-grouped-menu .nav-menu-form {
    display: block;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
}

/* One shared, plain heading. Page-specific tables and cards are not reset. */
.portal-unified-page .portal-content-page {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 0 28px;
}
.portal-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.portal-page-header--wrap { flex-wrap: wrap; }
.portal-page-header > .portal-page-heading {
  min-width: 0;
  margin: 0;
  padding: 0;
  color: var(--heading);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.portal-page-header > a { flex: 0 1 auto; margin: 0; }
.portal-page-help {
  display: block;
  margin: 10px 0 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.portal-page-help > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 2px;
  color: var(--heading);
  font-size: .84rem;
  font-weight: 750;
  line-height: 1.5;
}
.portal-page-help > summary::-webkit-details-marker { display: none; }
.portal-page-help > summary::before { content: "？ "; font-weight: 900; }
.portal-page-help > summary::after { content: "⌄"; margin-left: 5px; }
.portal-page-help[open] > summary::after { content: "⌃"; }
.portal-page-help > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-page-help__body {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-muted);
  font-size: .84rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.portal-page-help__body p { margin: 0 0 6px; }
.portal-page-help__body p:last-child { margin-bottom: 0; }
.portal-unified-page .portal-mypage-content > .mypage-intro { margin-top: 0; }
.portal-unified-page .survey-page > .survey-section:first-of-type { margin-top: 0; }
.portal-unified-page .video-page > .video-page-tools { margin-top: 0; }
.portal-unified-page .portal-page-add { display: inline-flex; }

/* Read-only member directory: same fields and ordering as the original table. */
.portal-member-directory { display: grid; gap: 10px; }
.portal-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 2.2fr);
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.portal-member-row__name {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.portal-member-label, .portal-member-row__facts dt { color: var(--ink-muted); font-size: .75rem; font-weight: 700; }
.portal-member-row__name strong { color: var(--heading); font-size: .95rem; }
.portal-member-row__facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; margin: 0; }
.portal-member-row__facts > div { min-width: 0; padding: 12px 14px; border-left: 1px solid var(--border); }
.portal-member-row__facts dd { margin: 4px 0 0; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }

@media (max-width: 820px) {
  .portal-unified-page .portal-content-page {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 18px 14px 28px;
    background: var(--surface);
  }
  .portal-page-header { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
  .portal-page-header > .portal-page-heading { font-size: 1.28rem; line-height: 1.25; }
  .portal-page-header > a {
    min-height: 34px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: .82rem;
    line-height: 1.4;
    box-shadow: none;
  }
  .portal-page-help { margin: 10px 0 14px; }
  .portal-page-help > summary { padding: 9px 0; font-size: .8rem; }
  .portal-page-help__body { font-size: .82rem; }
  .portal-unified-page .video-page-tools .portal-page-add { margin-left: auto; }
  .portal-unified-page .organization-picker-actions { width: 100%; }
  .portal-member-row { grid-template-columns: minmax(0, 1fr); }
  .portal-member-row__name { padding: 10px 12px; flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 10px; }
  .portal-member-row__facts > div { padding: 9px 10px; }
  .portal-member-row__facts > div:first-child { border-left: 0; }
  .portal-member-row__facts dd { font-size: .84rem; }
}

/* Keep the longer permissions label together at meaningful word boundaries. */
.nav-permissions-label > span { display: inline-block; white-space: nowrap; }
@media (max-width: 820px) {
  .portal-mypage-content > .mypage-section { padding: 12px; }
  .portal-mypage-content .portal-attendance-table { border: 0; background: transparent; box-shadow: none; }
  .portal-attendance-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .portal-attendance-table tbody { display: grid; gap: 10px; }
  .portal-attendance-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
  .portal-attendance-table tbody td { display: block; min-width: 0; padding: 9px 10px; border: 0; background: transparent; font-size: .84rem; line-height: 1.5; overflow-wrap: anywhere; }
  .portal-attendance-table tbody td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--ink-muted); font-size: .74rem; font-weight: 700; }
  .portal-attendance-table tbody td .badge { white-space: nowrap; }
}


/* Survey UI: bounded invitation excerpts, saved recipients and named results. */
.survey-card.survey-card--compact { align-items: center; gap: 16px; padding: 16px 18px; }
.survey-card--compact .survey-card__copy { flex: 1 1 0; min-width: 0; }
.survey-card--compact .survey-card__title,
.survey-card--compact .survey-card__excerpt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}
.survey-card--compact .survey-card__title { margin: 8px 0 6px; line-height: 1.4; max-height: 2.8em; }
.survey-card--compact .survey-card__excerpt { margin: 6px 0; font-size: .9rem; line-height: 1.6; max-height: 3.2em; white-space: normal; }
.survey-card--compact .survey-card__deadline { margin: 7px 0 0; font-size: .82rem; }
.survey-card--compact > .survey-card__answer { flex: 0 0 auto; white-space: nowrap; margin: 0; }
/* V13.1: native disclosure keeps the default excerpt compact. Full text is
   escaped by the template and remains inside the initially closed details.
   These selectors affect invitation cards only, not dashboard rows or forms. */
.survey-card--compact .survey-card__description {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.survey-card--compact .survey-card__description-summary {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  cursor: pointer;
  font-weight: 400;
  color: var(--ink);
}
.survey-card--compact .survey-card__description-summary::-webkit-details-marker { display: none; }
.survey-card--compact .survey-card__description-summary::marker { content: ""; }
.survey-card--compact .survey-card__description-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 2px 0;
  box-sizing: border-box;
  color: var(--primary-strong);
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.5;
}
.survey-card--compact .survey-card__description-summary:hover .survey-card__description-toggle { text-decoration: underline; }
.survey-card--compact .survey-card__description-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.survey-card--compact .survey-card__description:not([open]) .survey-card__close-label,
.survey-card--compact .survey-card__description[open] .survey-card__read-label,
.survey-card--compact .survey-card__description[open] .survey-card__excerpt { display: none; }
.survey-card--compact .survey-card__description[open] .survey-card__description-chevron { transform: rotate(180deg); }
.survey-card--compact .survey-card__description:not([open]) > .survey-card__full-description { display: none; }
.survey-card--compact .survey-card__full-description {
  margin: 6px 0;
  padding: 0;
  max-height: none;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--ink);
}
.survey-card.survey-card--compact:has(.survey-card__description[open]) { align-items: flex-start; }
@media (max-width: 640px) {
  .survey-card--compact .survey-card__full-description { font-size: .84rem; }
}

.mypage-pending-surveys .mypage-section-head { flex-wrap: wrap; gap: 8px; }

.survey-count { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--chip); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.survey-roster { margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.survey-roster > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px; min-height: 44px; box-sizing: border-box; font-size: .93rem; font-weight: 750; cursor: pointer; list-style: none; }
.survey-roster > summary::-webkit-details-marker { display: none; }
.survey-roster > summary::after { content: "⌄"; margin-left: auto; }
.survey-roster[open] > summary::after { content: "⌃"; }
.survey-roster__hint { font-size: .76rem; color: var(--ink-muted); font-weight: 400; }
.survey-roster__body { padding: 0 14px 12px; }
.survey-roster__list { margin: 0; padding: 0; list-style: none; max-height: 290px; overflow-y: auto; overscroll-behavior: contain; }
.survey-roster__list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; min-height: 42px; box-sizing: border-box; border-top: 1px solid var(--border); }
.survey-roster__name { min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.survey-roster__name > small { display: block; margin-top: 3px; }
.survey-response-status { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); font-size: .77rem; white-space: nowrap; }
.survey-response-status.is-answered { font-weight: 700; background: var(--chip); color: var(--heading); }
.survey-target-caption, .survey-roster__note { font-size: .86rem; line-height: 1.6; overflow-wrap: anywhere; }
.survey-target-warning { padding: 10px 12px; border-left: 3px solid var(--primary); background: var(--surface-2); font-size: .85rem; }
.survey-target-form .survey-target-options[hidden] { display: none; }
.survey-target-form input[type="checkbox"], .survey-target-form input[type="radio"] { flex: 0 0 auto; }
.survey-results-page .survey-page__heading { flex-wrap: wrap; gap: 14px; }
.survey-results-page .survey-page__heading > div:first-child { flex: 1 1 320px; min-width: 0; }
.survey-results-page .survey-page__heading h2 { overflow-wrap: anywhere; }
.survey-results-page .survey-actions { flex-wrap: wrap; gap: 8px; }
.survey-named-results { margin: 20px 0; }
.survey-named-results > h3, .survey-aggregate-heading { margin: 16px 0 8px; }
.survey-person-response { margin: 8px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); overflow: hidden; }
.survey-person-response > summary { padding: 12px 14px; min-height: 44px; box-sizing: border-box; font-weight: 750; cursor: pointer; overflow-wrap: anywhere; }
.survey-person-response > dl { margin: 0; padding: 0 14px 12px; }
.survey-person-response > dl > div { padding: 12px 0; border-top: 1px solid var(--border); }
.survey-person-response dt { font-weight: 700; font-size: .87rem; overflow-wrap: anywhere; }
.survey-person-response dd { margin: 7px 0 0; font-size: .9rem; line-height: 1.65; overflow-wrap: anywhere; }
.survey-person-response dd ul { margin: 0; padding-left: 1.3em; }
.survey-roster > summary:focus-visible, .survey-person-response > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (max-width: 640px) {
  .survey-card.survey-card--compact { display: block; padding: 12px; }
  .survey-card--compact > .survey-card__answer { display: inline-flex; min-height: 36px; margin-top: 8px; padding: 5px 12px; font-size: .84rem; }
  .survey-card--compact .survey-card__title { font-size: .94rem; }
  .survey-card--compact .survey-card__excerpt { font-size: .84rem; }
  .survey-roster > summary { padding: 10px 12px; font-size: .84rem; }
  .survey-roster__hint { display: none; }
  .survey-roster__body { padding: 0 12px 10px; }
  .survey-roster__list > li { gap: 8px; }
  .survey-roster__name { font-size: .84rem; }
  .survey-results-page .survey-page__heading { padding: 14px; }
  .survey-results-page .survey-page__heading h2 { font-size: 1.15rem; }
  .survey-results-page .survey-actions { display: flex; }
  .survey-results-page .survey-actions .btn { font-size: .78rem; padding: 7px 10px; }
  .survey-results-page .survey-result { padding: 14px; }
  .survey-results-page .survey-result h3 { font-size: .95rem; }
  .survey-results-page .survey-result li { overflow-wrap: anywhere; }
}

/* V13: TOP/home is the sizing reference. Keep the existing outer 1180px/ad grid
   and 1040px main (including 16px side padding); remove inner page width limits.
   This applies only to the signed-in organization shell, never the public HP. */
.portal-member-layout { --portal-main-max: 1040px; --portal-page-gutter: 14px; }
.portal-member-layout > .portal-main {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--portal-main-max);
  min-width: 0;
  padding-inline: 16px;
  margin-inline: auto;
}
.portal-member-layout .portal-main-inner > :is(.portal-content-page, .survey-page, .page-section--narrow, .form-card, .page) {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-inline: 0;
  padding-inline: 0;
}
@media (max-width: 820px) {
  .portal-member-layout > .portal-main { padding-inline: 0; }
  .portal-member-layout .portal-main-inner > :is(.portal-content-page, .survey-page, .page-section--narrow, .form-card, .page) {
    padding-inline: var(--portal-page-gutter);
  }
}

/* Dashboard rows deliberately have no description or nested invitation cards. */
.portal-mypage-content > .mypage-section.mypage-pending-surveys { padding: 14px 18px; }
.mypage-pending-surveys .mypage-section-head { margin: 0 0 6px; }
.mypage-pending-surveys #pending-surveys-heading { margin: 0; font-size: 1.02rem; line-height: 1.4; }
.mypage-pending-surveys .mypage-section-head > a { font-size: .8rem; }
.mypage-survey-links { list-style: none; margin: 0; padding: 0; }
.mypage-survey-links > .mypage-survey-link-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 48px; margin: 0; padding: 8px 0;
  border: 0; border-top: 1px solid var(--border); background: transparent;
}
.mypage-survey-link-copy { flex: 1 1 0; min-width: 0; }
.mypage-survey-title {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: .9rem; line-height: 1.5; font-weight: 700; color: var(--heading);
}
.mypage-survey-deadline { display: block; margin-top: 2px; font-size: .75rem; color: var(--ink-muted); }
.mypage-survey-action {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; min-height: 44px; padding: 4px 8px; font-size: .84rem;
  white-space: nowrap; font-weight: 750; color: var(--primary-strong);
}
.mypage-survey-title:focus-visible, .mypage-survey-action:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 640px) {
  .portal-mypage-content > .mypage-section.mypage-pending-surveys { padding: 12px; }
  .mypage-pending-surveys #pending-surveys-heading { font-size: .95rem; }
  .mypage-survey-links > .mypage-survey-link-row { gap: 8px; }
  .mypage-survey-title { font-size: .85rem; }
  .mypage-survey-action { padding-inline: 4px; font-size: .8rem; }
}

/* Only optional authoring fields collapse. The anonymity setting, question,
   answer-type selector and choices stay visible. Fields remain enabled. */
.survey-form > .survey-optional-field {
  margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); min-width: 0;
}
.survey-optional-field > summary {
  padding: 10px 12px; min-height: 44px; cursor: pointer;
  font-size: .9rem; font-weight: 750; overflow-wrap: anywhere;
}
.survey-optional-field > summary small { margin-left: 8px; color: var(--ink-muted); font-size: .75rem; font-weight: 400; }
.survey-optional-field > .survey-optional-field__body { margin: 0; padding: 0 12px 12px; }
.survey-optional-field__body > label { display: block; font-size: .84rem; }
.survey-optional-field > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
