.person-profile-link > span { min-width: 0; display: grid; gap: 5px; }
.person-profile-link strong { font: inherit; }
.person-profile-link small { font-size: var(--text-12); line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
#modal[data-view="person-profile"] { width: 520px; max-width: calc(100vw - 20px); height: min(860px, calc(var(--dialog-height, 100dvh) - 24px)); max-height: calc(var(--dialog-height, 100dvh) - 24px); overflow: hidden; container: person-dialog / size; }
#modal[data-view="person-profile"] #modal-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#modal[data-view="person-profile"] .modal-header { flex: none; align-items: center; gap: 10px; padding: 17px 20px; }
#modal[data-view="person-profile"] .modal-header h2 { font-size: var(--text-20); }
#modal[data-view="person-profile"] .modal-header p { font-size: var(--text-12); line-height: 1.5; margin-top: 5px; }
#modal[data-view="person-profile"] .modal-header .icon-button { width: 44px; height: 44px; }
.person-profile { display: flex; flex: 1; min-height: 0; padding: 0 20px 16px; overflow: hidden; }
#person-profile-form { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.person-fields { flex: 1; min-height: 72px; overflow-y: auto; overscroll-behavior: contain; scroll-padding: 10px; -webkit-overflow-scrolling: touch; }
.person-section { border-bottom: 1px solid var(--line); }
.person-section > summary { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 0; list-style: none; cursor: pointer; }
.person-section > summary::-webkit-details-marker { display: none; }
.person-section-heading { display: grid; gap: 3px; flex: 1; min-width: 0; }
.person-section-heading > span { font-size: var(--text-14); line-height: 1.45; font-weight: 500; }
.person-section-heading small { color: var(--muted); font-size: var(--text-12); line-height: 1.45; overflow-wrap: anywhere; }
.person-section[open] .person-section-heading small { display: none; }
.person-section-arrow { display: flex; color: var(--muted); flex: 0 0 18px; }
.person-section-arrow svg { width: 18px; height: 18px; }
.person-section[open] .person-section-arrow { transform: rotate(90deg); }
.person-section-content { padding: 0 0 14px; }
.person-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.person-metric { display: grid; gap: 8px; min-width: 0; font-size: var(--text-13); }
.person-input-unit { position: relative; min-width: 0; }
.person-input-unit .form-input { padding-right: 38px; min-width: 0; }
.person-input-unit > span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: var(--text-13); color: var(--muted); pointer-events: none; }
.person-profile .form-input { font-size: var(--text-16); min-height: 48px; }
.person-profile input[aria-invalid="true"] { border-color: var(--danger); }
.person-help { font-size: var(--text-12); line-height: 1.55; color: var(--muted); margin: 8px 0 0; }
.person-section-content > .person-help:first-child { margin-top: 0; }
.person-weight-goals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin-top: 11px; }
.person-weight-goals button { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--paper); color: var(--ink); min-height: 48px; font: inherit; font-size: var(--text-12); line-height: 1.5; padding: 9px 7px; }
.person-weight-goals button[aria-pressed="true"] { border-color: var(--accent); background: var(--tint); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.person-training-goals { display: grid; gap: 6px; margin-top: 10px; }
.person-goal { display: flex; align-items: center; position: relative; gap: 10px; min-height: 48px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; font-size: var(--text-13); line-height: 1.45; }
.person-goal input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.person-goal-icon { color: var(--muted); display: flex; flex: 0 0 18px; }
.person-goal-icon svg { width: 18px; height: 18px; }
.person-goal-check { display: flex; align-items: center; justify-content: center; margin-left: auto; width: 19px; height: 19px; flex: 0 0 19px; border: 1px solid var(--line); border-radius: var(--radius-s); color: transparent; }
.person-goal-check svg { width: 14px; height: 14px; }
.person-goal:not(.is-locked):has(input:checked) { border-color: var(--accent); background: var(--tint); }
.person-goal:not(.is-locked) input:checked ~ .person-goal-icon { color: var(--accent); }
.person-goal input:checked ~ .person-goal-check { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.person-goal:has(input:focus-visible), .person-weight-goals button:focus-visible, .person-section > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.person-goal.is-locked { color: var(--muted); background: var(--surface); cursor: default; min-height: 40px; opacity: .65; }
.person-goal-status { margin-left: auto; font-size: var(--text-10); flex-shrink: 0; }
.person-companion { flex: none; margin-top: 14px; }
.person-speech { position: relative; padding: 13px 15px; border-radius: var(--radius-l); background: var(--tint); }
.person-speech::after { content: ''; position: absolute; left: 28px; bottom: -7px; width: 14px; height: 14px; transform: rotate(45deg); background: var(--tint); }
.person-combination { position: relative; font-size: var(--text-13); line-height: 1.6; color: var(--ink); margin: 0; }
/* Empty until the avatar artwork is supplied. Keep its space inside the dialog. */
.person-avatar-space { height: 118px; display: flex; align-items: flex-end; justify-content: center; }
.person-avatar-space > img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.person-error { flex: none; color: var(--danger); font-size: var(--text-12); line-height: 1.5; margin: 8px 0 0; }
.person-footer { display: flex; flex: none; align-items: center; gap: 12px; padding-top: 10px; }
.person-footer .button { flex: 1; min-height: 48px; font-size: var(--text-14); }
.person-footer .text-button { min-height: 44px; padding: 8px 0; color: var(--muted); font-size: var(--text-12); }
@container person-dialog (max-height: 650px) {
  .person-avatar-space { height: 72px; }
  .person-companion { margin-top: 10px; }
  .person-speech { padding: 10px 12px; }
  .person-combination { font-size: var(--text-12); line-height: 1.5; max-height: 126px; overflow-y: auto; }
}
@container person-dialog (max-height: 440px) {
  .person-companion { display: none; }
}
@media (max-width: 360px) {
  .person-profile { padding-left: 16px; padding-right: 16px; }
  .person-metrics { gap: 10px; }
  .person-input-unit input::placeholder { font-size: var(--text-12); }
  .person-weight-goals { gap: 5px; }
  .person-weight-goals button { font-size: var(--text-11); }
  .person-goal { gap: 8px; padding-left: 8px; padding-right: 8px; font-size: var(--text-12); }
}

@media (max-width: 700px), (max-width: 1200px) and (max-height: 600px) {
  #modal[data-view="person-profile"] { width: 100%; max-width: none; height: var(--dialog-height, 100dvh); max-height: none; border-radius: 0; }
  #modal[data-view="person-profile"] .person-profile,
  #modal[data-view="person-profile"] #person-profile-form { display: block; min-height: 0; }
  #modal.modal-page[data-view="person-profile"] .modal-body.person-profile { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  #modal[data-view="person-profile"] .person-fields { min-height: 0; overflow: visible; }
  #modal[data-view="person-profile"] .person-combination { max-height: none; overflow: visible; }
}
