#person-content:has(.family-profile, .family-profile-state) {
  padding: 0;
}

.family-profile {
  --profile-rule: #c3d8de;
  display: grid;
  grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "stage heading"
    "stage details";
  align-items: start;
  gap: clamp(18px, 3vw, 36px) clamp(24px, 4.9vw, 68px);
  padding: clamp(8px, 1.5vw, 16px) clamp(16px, 2.5vw, 28px) 24px;
}

.family-profile-heading {
  grid-area: heading;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  min-width: 0;
}

.family-profile-heading h1 {
  flex: 1 1 auto;
  min-width: 0;
  font: 700 clamp(1.9rem, 4.5vw, 3.85rem)/.99 var(--sans);
  letter-spacing: -.055em;
  overflow-wrap: anywhere;
}

.family-profile-heading .button {
  flex: none;
}

.family-profile-stage {
  grid-area: stage;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #b2cbd2;
}

.family-profile-details {
  grid-area: details;
  display: grid;
  gap: clamp(20px, 3vw, 32px);
  min-width: 0;
}

.family-profile-group h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--profile-rule);
  font: 700 clamp(1.1rem, 2.4vw, 1.42rem)/1.2 var(--sans);
  letter-spacing: -.025em;
}

.family-profile-list {
  display: grid;
  margin: 0;
}

.family-profile-list-shirt {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 16px;
}

.family-profile-entry {
  min-width: 0;
  padding-block: 10px;
}

.family-profile-list-gift .family-profile-entry {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 8px 16px;
}

.family-profile-list-gift .family-profile-entry + .family-profile-entry {
  border-top: 1px solid var(--profile-rule);
}

.family-profile-list dt {
  padding-top: .11em;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 700;
  line-height: 1.35;
}

.family-profile-list dd {
  min-width: 0;
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.family-profile-list-shirt dd {
  margin-top: 3px;
  font-size: 1.125rem;
  font-weight: 700;
}

.family-profile-empty, .family-profile-state {
  color: var(--muted);
}

.family-profile-empty {
  padding-block: 13px;
  border-top: 1px solid var(--profile-rule);
}

.family-profile-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 16px clamp(16px, 2.5vw, 28px);
}

body[data-screen="focus"] #person {
  position: fixed;
  z-index: 2;
  inset: 0 0 0 auto;
  width: 44%;
  margin: 0;
  border-left: 1px solid #a8c0cb;
  background: linear-gradient(160deg, #f9fcfcf2, #eaf3f6fa);
  box-shadow: -12px 0 35px #27465b20;
}

body[data-screen="focus"] #person-content {
  height: 100%;
}

body[data-screen="focus"] :is(.family-profile, .family-profile-state) {
  max-width: none;
  height: 100%;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(74px, 11vh, 108px) clamp(20px, 3.25vw, 56px) max(30px, env(safe-area-inset-bottom));
}

body[data-screen="focus"] .family-profile {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "heading" "details";
  row-gap: clamp(21px, 3.25vw, 34px);
}

body[data-screen="focus"] .family-profile:focus-visible {
  outline-offset: -5px;
}

body[data-screen="focus"] .family-profile-heading h1 {
  font-size: clamp(1.9rem, 3.9vw, 3.7rem);
}

body[data-screen="focus"] .family-profile-state {
  align-content: start;
}

@media (max-width: 670px) {
  .family-profile {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "heading" "stage" "details";
    max-width: 460px;
    margin-inline: auto;
    padding-inline: 16px;
  }

  .family-profile-stage {
    width: min(100%, 400px);
    justify-self: center;
  }
}

@media (max-width: 900px) {
  body[data-screen="focus"] .family-profile-list-gift .family-profile-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }
}

@media (max-width: 719px) {
  body[data-screen="focus"] #person {
    inset: 46% 0 0;
    width: auto;
    border-top: 1px solid #a8c0cb;
    border-left: 0;
    box-shadow: 0 -9px 25px #27465b22;
  }

  body[data-screen="focus"] :is(.family-profile, .family-profile-state) {
    padding: 14px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }

  body[data-screen="focus"] .family-profile-details {
    row-gap: 14px;
  }
}

@media (max-width: 390px) {
  .family-profile-list-shirt {
    column-gap: 9px;
  }

  .family-profile-list-gift .family-profile-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  body[data-screen="focus"] #person {
    --profile-enter: 22px 0;
    animation: show-in-plaza 300ms 100ms cubic-bezier(.18, .74, .28, 1) both;
  }

  @media (max-width: 719px) {
    body[data-screen="focus"] #person {
      --profile-enter: 0 20px;
    }
  }

  @keyframes show-in-plaza {
    from { opacity: 0; translate: var(--profile-enter); }
    to { opacity: 1; translate: 0 0; }
  }
}

.character-chat {
  grid-area: details;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.chat-label {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 650;
}
.chat-content {
  min-height: 0;
  max-height: min(42svh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat-starters { display: grid; gap: 6px; margin-top: 10px; }
.chat-starters .button { justify-content: flex-start; text-align: left; }
.chat-transcript {
  margin: 0;
  padding: 0;
  list-style: none;
}
.chat-message {
  padding: 9px 12px;
  border-left: 2px solid var(--accent);
  background: #ffffffa8;
  overflow-wrap: anywhere;
}
.chat-message + .chat-message { margin-top: 7px; }
.chat-message-user {
  border-color: #a9c1c9;
  background: #e0ecee;
}
.chat-speaker {
  display: block;
  margin-bottom: 2px;
  font-size: .78rem;
  font-weight: 700;
}
.chat-message p { white-space: pre-wrap; }
.chat-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: .14em;
}
.chat-status { color: var(--muted); font-size: .875rem; }
.chat-status:empty { position: absolute; }
.chat-status-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.chat-pending-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 1em;
  vertical-align: middle;
  color: var(--accent);
}
.chat-pending-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
@media (prefers-reduced-motion: no-preference) {
  .chat-pending-dots span { animation: chat-dot-pulse 1.15s ease-in-out infinite; }
  .chat-pending-dots span:nth-child(2) { animation-delay: .15s; }
  .chat-pending-dots span:nth-child(3) { animation-delay: .3s; }

  @keyframes chat-dot-pulse {
    0%, 65%, 100% { opacity: .45; translate: 0 0; }
    30% { opacity: 1; translate: 0 -3px; }
  }
}
.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
body[data-screen="focus"] .family-profile:has(.character-chat:not([hidden])) {
  grid-template: "details" minmax(0, 1fr) / minmax(0, 1fr);
}
body[data-screen="focus"] .character-chat {
  align-self: stretch;
  min-height: 0;
  gap: 0;
  grid-template-rows: minmax(0, 1fr) auto auto;
}
body[data-screen="focus"] .chat-content { max-height: none; }
body[data-screen="focus"] .chat-content .family-profile-heading { margin-bottom: clamp(14px, 3vw, 24px); }
body[data-screen="focus"] .chat-status:not(:empty) { margin-top: 6px; }
body[data-screen="focus"] .chat-composer { margin-top: 10px; }
@media (max-width: 719px) {
  body[data-screen="focus"] #person:has(.character-chat:not([hidden])) {
    inset-block-start: min(46%, max(54px, calc(100% - 21rem)));
  }
  .chat-content .family-profile-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
  }
  .chat-content .family-profile-heading h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chat-content .family-profile-heading .button { gap: 4px; padding-inline: 10px; }
}
.chat-input {
  min-width: 0;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #a8c0cb;
  border-radius: 3px;
}
.profile-personality {
  padding: 15px 0 3px;
  border-top: 1px solid var(--line);
}

.preference-items {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-inline-start: 1.15em;
  white-space: normal;
}
.preference-items-colors, .preference-items-hobbies {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  padding: 0;
  list-style: none;
}
.preference-items-colors li, .preference-items-hobbies li {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.preference-swatch {
  align-self: center;
  flex: none;
  width: 13px;
  height: 13px;
  background: var(--preference-color);
  border: 1px solid #26414859;
  border-radius: 2px;
}
.profile-format-note { color: var(--muted); font-size: .875rem; }

.profile-title-block { flex: 1 1 auto; min-width: 0; }
.profile-contact { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.profile-contact button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 3px;
  color: #20616c; background: none; border: 0; font: 650 .9rem/1.25 var(--sans); cursor: pointer;
}
.profile-contact button:hover:not([aria-disabled="true"]) { text-decoration: underline; }
.profile-contact button[aria-disabled="true"] { color: var(--muted); cursor: default; }
.profile-contact .ui-icon { width: 17px; height: 17px; flex: none; }
.profile-contact [role="status"] { font-size: .83rem; color: var(--muted); }

.family-profile-list-gift .family-profile-entry:has(.wishlist-gifts) { grid-template-columns: minmax(0, 1fr); }
.wishlist-gifts { list-style: none; padding: 0; margin: 0; white-space: normal; }
.wishlist-gifts a {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center;
  gap: 12px; padding: 8px 2px; color: #184e57; font-size: .92rem; line-height: 1.35;
}
.wishlist-gifts li + li { border-top: 1px solid var(--profile-rule); }
.wishlist-gifts a:hover > span:nth-child(2) { text-decoration: underline; }
.wishlist-thumb { display: grid; place-items: center; width: 52px; height: 52px; background: #fff; border: 1px solid #d3dfe3; }
.wishlist-thumb img { width: 100%; height: 100%; object-fit: contain; }
.wishlist-thumb:empty::before { content: "✧"; color: #739197; font-size: 1.4rem; }
.wishlist-more > summary { cursor: pointer; padding: 8px 2px; color: #20616c; font-weight: 650; font-size: .88rem; }
