/* Contact Poster & Animated Obsidian Profile Sheet */
dialog.apple-profile-dialog {
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  overflow: visible;
}

dialog.apple-profile-dialog::backdrop {
  background: rgba(7, 6, 8, 0.8);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  animation: appleBackdropFade 240ms ease-out;
}

dialog.apple-profile-dialog > .dialog-inner {
  position: relative;
  max-height: min(88dvh, 820px);
  overflow: hidden;
  padding: 0;
  display: block;
  border-radius: 26px;
  background: #141115;
  border: 1px solid var(--line-strong);
  box-shadow:
    var(--sheen),
    0 32px 84px -18px rgba(0, 0, 0, 0.94),
    0 0 40px -18px rgba(236, 78, 48, 0.22);
  animation: appleSheetPop 380ms var(--ease-out);
  scrollbar-width: thin;
}

dialog.apple-profile-dialog #dialog-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

dialog.apple-profile-dialog .close {
  position: absolute;
  top: 9px;
  right: 12px;
  z-index: 25;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--raised);
  border: 1px solid var(--line-strong);
  color: var(--white);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  transition: transform 220ms var(--ease-spring), background-color 180ms ease, border-color 180ms ease;
}

dialog.apple-profile-dialog .close:hover {
  transform: rotate(90deg) scale(1.08);
  background: rgba(236, 78, 48, 0.24);
  border-color: rgba(236, 78, 48, 0.5);
}

@keyframes appleBackdropFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes appleSheetPop {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes appleAvatarPop {
  0% {
    transform: scale(0.65);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.profile-room.apple-profile-sheet {
  --room-line: var(--line);
  --room-panel: var(--surface);
  color: var(--white);
  display: grid;
  gap: 12px;
  width: min(500px, 100%);
  margin-inline: auto;
  min-width: 0;
}

.profile-room.apple-profile-sheet.is-modal {
  width: 100%;
  max-height: min(calc(88dvh - 2px), 818px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  margin: 0;
}

.profile-room .profile-editor-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 58px 10px 18px;
  border-bottom: 1px solid var(--room-line);
  background: #141115;
}

.profile-room .profile-editor-tools strong {
  font-family: var(--display);
  font-size: 0.96rem;
  letter-spacing: -0.02em;
}

.profile-room .profile-editor-tools select {
  max-width: 48%;
  min-width: 0;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 9px;
  font-size: 0.8rem;
}

.profile-room .profile-editor-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 14px 16px 24px;
  scroll-padding-block: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

/* Expanding Hero Visual at Top of Contact Card */
.profile-room .apple-hero-visual {
  isolation: isolate;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  min-height: 172px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--well);
  cursor: zoom-in;
  user-select: none;
  transition:
    min-height 440ms var(--ease-out),
    border-color 220ms ease,
    box-shadow 260ms ease;
}

.profile-room .apple-hero-visual:hover {
  border-color: rgba(236, 78, 48, 0.45);
}

.profile-room .apple-hero-visual.is-expanded {
  min-height: 336px;
  cursor: zoom-out;
}

.profile-room .room-cover-photo {
  position: absolute;
  z-index: -3;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%;
  transform: scale(1.03);
  transition: transform 500ms var(--ease-out);
}

.profile-room .apple-hero-visual:hover .room-cover-photo {
  transform: scale(1.07);
}

.profile-room .apple-hero-visual.is-expanded .room-cover-photo {
  transform: scale(1);
}

.profile-room .room-cover-shade {
  position: absolute;
  z-index: -2;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 9, 11, 0.46) 0%, rgba(9, 9, 11, 0.12) 40%, rgba(9, 9, 11, 0.94) 100%);
}

.profile-room .apple-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.profile-room .room-visibility,
.profile-room .apple-zoom-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 13, 16, 0.82);
  backdrop-filter: blur(10px);
  color: var(--white);
  font-size: 0.74rem;
  font-weight: 650;
}

.profile-room .apple-zoom-hint {
  cursor: zoom-in;
}

.profile-room .apple-zoom-hint[aria-expanded="true"] {
  cursor: zoom-out;
}

.profile-room .apple-photo-trigger {
  position: relative;
  z-index: 2;
}

.profile-room .apple-zoom-hint:focus-visible,
.profile-room .apple-photo-trigger:focus-visible {
  outline: 2px solid var(--iris-soft);
  outline-offset: 2px;
}

.profile-room .room-visibility[data-published="true"] {
  border-color: rgba(34, 229, 155, 0.45);
  color: var(--green-soft);
  background: rgba(10, 34, 25, 0.88);
}

.profile-room .room-visibility i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.profile-room .apple-hero-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
}

.profile-room .apple-avatar-ring {
  flex: none;
  padding: 2.5px;
  border-radius: 50%;
  background: var(--brand-grad);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62);
  animation: appleAvatarPop 460ms var(--ease-spring);
}

.profile-room .apple-avatar-ring .avatar {
  display: block;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #0e0d10;
  transition:
    width 380ms var(--ease-out),
    height 380ms var(--ease-out);
}

.profile-room .apple-hero-visual.is-expanded .apple-avatar-ring .avatar {
  width: 72px;
  height: 72px;
}

.profile-room .room-identity {
  min-width: 0;
  flex: 1;
}

.profile-room .room-identity h1 {
  color: var(--white);
  margin: 0;
  font-size: clamp(1.34rem, 2.2vw, 1.68rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}

.profile-room .room-location {
  margin: 3px 0 0;
  font-size: 0.81rem;
  color: rgba(245, 240, 230, 0.78);
}

.profile-room .apple-photo-trigger {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 999px;
  background: var(--white);
  color: #09090b;
  font-size: 0.8rem;
  font-weight: 750;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.profile-room .apple-photo-trigger:hover {
  transform: scale(1.04) translateY(-1px);
  background: #ffffff;
}

.profile-room .apple-photo-trigger .ic {
  width: 15px;
  height: 15px;
  color: var(--coral);
}

/* Compact Media Tile Strip (Prevents Vertical Button Bloat & Modal Clipping) */
.profile-room .apple-gallery-strip {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--room-line);
  background: var(--room-panel);
}

.profile-room .apple-gallery-strip .gallery-editor {
  padding: 0;
}

.profile-room .apple-gallery-strip .gallery-heading {
  margin-bottom: 2px;
}

.profile-room .apple-gallery-strip .gallery-heading h3 {
  font-size: 0.92rem;
  margin: 0;
}

.profile-room .apple-gallery-strip .gallery-help {
  font-size: 0.74rem;
  margin: 0 0 8px;
}

.profile-room .apple-gallery-strip .gallery-count {
  color: var(--iris-soft);
  background: rgba(207, 169, 114, 0.16);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.73rem;
  font-variant-numeric: tabular-nums;
}

.profile-room .apple-gallery-strip .gallery-list {
  margin: 0 0 8px;
}

.profile-room .apple-gallery-strip .gallery-list:empty {
  display: none;
}

.profile-room .apple-gallery-strip .gallery-list:empty + .gallery-button {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px dashed rgba(236, 78, 48, 0.45);
  color: var(--coral-soft);
  background: rgba(236, 78, 48, 0.08);
  font-weight: 700;
}

.profile-room .apple-gallery-strip .gallery-list:not(:empty) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.profile-room .apple-gallery-strip .gallery-item {
  position: relative;
  padding: 0;
  overflow: hidden;
  border-radius: 13px;
  aspect-ratio: 4 / 3.4;
  background: var(--well);
}

.profile-room .apple-gallery-strip .gallery-item img {
  width: 100%;
  height: 100%;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

.profile-room .apple-gallery-strip .gallery-caption {
  position: absolute;
  top: 6px;
  left: 6px;
  margin: 0;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(9, 9, 11, 0.82);
  backdrop-filter: blur(6px);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 700;
}

.profile-room .apple-gallery-strip .gallery-tools {
  position: absolute;
  inset: auto 4px 4px 4px;
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 3px;
}

.profile-room .apple-gallery-strip .gallery-tools .gallery-button {
  flex: 1 1 auto;
  min-height: 26px;
  padding: 2px 4px;
  border-radius: 7px;
  font-size: 0.68rem;
  background: rgba(15, 13, 16, 0.86);
  backdrop-filter: blur(6px);
  border-color: rgba(255, 255, 255, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inset Grouped Sections */
.profile-room .apple-group-card {
  display: grid;
  gap: 11px;
  padding: 15px;
  border-radius: 18px;
  border: 1px solid var(--room-line);
  background: var(--room-panel);
  min-width: 0;
}

.profile-room .apple-group-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.profile-room .room-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding-block: 4px;
  color: var(--white);
  font-size: 0.88rem;
  cursor: pointer;
}

.profile-room .room-toggle input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0.1em 0 0;
  accent-color: var(--coral);
}

.profile-room .room-toggle small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-room [data-activity-controls][hidden] {
  display: none;
}

.profile-room [data-activity-controls] .helper:empty {
  display: none;
}

.profile-room .voice-editor audio {
  max-width: 100%;
}

.profile-room .apple-field-block {
  display: grid;
  gap: 7px;
}

.profile-room .apple-field-label,
.profile-room .apple-bio-field span {
  font-size: 0.83rem;
  font-weight: 650;
  color: var(--white);
}

/* Segmented Intent Pills */
.profile-room .apple-intent-pills {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--well);
  border: 1px solid var(--line);
}

.profile-room .apple-intent-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 8px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, transform 220ms var(--ease-spring);
}

.profile-room .apple-intent-pill:hover:not(.active) {
  color: var(--white);
  background: rgba(255, 255, 255, 0.05);
}

.profile-room .apple-intent-pill.active {
  background: var(--white);
  color: #09090b;
  font-weight: 750;
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.16);
}

.profile-room .apple-intent-pill.active .ic {
  color: var(--coral);
}

.profile-room .apple-inline-pair {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.profile-room .profile-editor-scroll .field {
  color: var(--white);
  font-size: 0.82rem;
}

.profile-room .profile-editor-scroll :is(input:not([type="checkbox"]), select, textarea) {
  background: var(--well);
  border-color: var(--line-strong);
  color: var(--white);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.profile-room .profile-editor-scroll :is(input, select, textarea):focus-visible {
  outline-color: var(--iris-soft);
  border-color: var(--iris-soft);
}

/* Automatic Discord Activity Card */
.profile-room .apple-discord-card {
  border-color: rgba(207, 169, 114, 0.28);
  background: var(--surface);
}

.profile-room .apple-discord-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-room .apple-sync-btn {
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 0.79rem;
}

/* Sticky Save Footer */
.profile-room .apple-sheet-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--room-line);
  background: #141115;
}

.profile-room .profile-save-state,
.profile-room .apple-sheet-footer .form-error {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.profile-room .profile-save-state {
  color: var(--muted);
}

.profile-room .apple-sheet-footer:has(.form-error:not(:empty)) .profile-save-state {
  display: none;
}

.profile-room .apple-sym-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  height: 44px;
  padding: 0 22px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.profile-room .apple-save-btn {
  min-width: 116px;
  background: var(--brand-grad);
  color: #ffffff;
  border: 1px solid rgba(255, 212, 196, 0.38);
}

@media (max-width: 760px) {
  dialog.apple-profile-dialog > .dialog-inner {
    border-radius: 22px;
    max-height: 90dvh;
  }
  .profile-room.apple-profile-sheet.is-modal {
    max-height: calc(90dvh - 2px);
  }
  .profile-room .profile-editor-scroll {
    padding: 12px 12px 22px;
  }
  .profile-room .profile-editor-scroll :is(input:not([type="checkbox"]), select, textarea) {
    font-size: 1rem;
  }
  .profile-room .apple-hero-visual {
    min-height: 164px;
    padding: 13px;
  }
  .profile-room .apple-hero-visual.is-expanded {
    min-height: 284px;
  }
  .profile-room .apple-hero-bottom {
    flex-wrap: wrap;
  }
  .profile-room .apple-gallery-strip .gallery-list:not(:empty) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .profile-room .apple-hero-top {
    gap: 6px;
  }
  .profile-room .apple-hero-bottom {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px 10px;
  }
  .profile-room .apple-hero-bottom .apple-photo-trigger {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .profile-room .apple-intent-pills {
    display: flex;
    flex-wrap: wrap;
  }
  .profile-room .apple-inline-pair {
    grid-template-columns: minmax(64px, 0.55fr) minmax(0, 1fr);
  }
  .profile-room .field input {
    min-width: 0;
    width: 100%;
  }
}
