.imessage-project {
  padding-block: 2rem 4rem;
}

.imessage-intro {
  max-width: 38rem;
  margin-block-end: 2rem;
}

.imessage-intro h1,
.imessage-intro p {
  margin-block: 0;
}

.imessage-intro h1 {
  margin-block-end: 0.5rem;
}

.eyebrow {
  margin-block-end: 0.5rem !important;
  color: #777;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.imessage-workspace {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) minmax(18rem, 26rem) minmax(13rem, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.imessage-preview-panel {
  display: grid;
  grid-column: 2;
  grid-row: 1;
  grid-template-rows: auto auto;
  min-height: 35rem;
  background: #f4f5f7;
}

body > main:has(.imessage-project) {
  width: min(100%, 1200px);
}

.phone-stage {
  display: grid;
  width: 100%;
  min-height: 40rem;
  place-items: center;
  padding: 2rem 1rem;
  box-sizing: border-box;
  --phone-scale: 0.65;
}

.phone {
  display: flex;
  width: 393px;
  height: 852px;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #111;
  position: relative;
  box-shadow: none;
  zoom: var(--phone-scale);
  transition: width 180ms ease, height 180ms ease, zoom 180ms ease;
}

.phone-call-actions {
  position: absolute;
  top: 62px;
  right: 16px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.phone-call-actions button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 5px 20px 6px rgb(0 0 0 / 5.5%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  color: #111;
  font: inherit;
}

.phone-call-actions svg {
  display: block;
  width: 25px;
  height: 16.6667px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.conversation-meta {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  margin: 0 auto 1rem;
  color: #8c8c92;
  font-size: 0.7rem;
  line-height: 1.2;
}

.conversation-meta strong {
  color: #111;
  font-size: 0.85rem;
  font-weight: 700;
}

.conversation-meta time { margin-top: 0.45rem; }

.encrypted-label { display: inline-flex; align-items: center; gap: 0.2rem; }
.encrypted-label svg { width: 0.7rem; height: 0.7rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.4; }

.phone[data-phone="iphone-mini"] { width: 375px; height: 812px; }
.phone[data-phone="android"] { width: 412px; height: 915px; border-radius: 22px; }
.phone[data-phone="compact"] { width: 360px; height: 780px; border-radius: 18px; }

.phone-status,
.phone-contact,
.compose-bar {
  flex: 0 0 auto;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0.8rem 0.35rem;
  font-size: 0.65rem;
  font-weight: 600;
}

.phone-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3.1rem;
  padding: 0.35rem 0.75rem 0.55rem;
  border-bottom: 1px solid #e5e5e5;
  font-size: 0.75rem;
}

.avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: #d8d8dc;
  color: #fff;
  font-weight: 600;
}

.avatar-small { width: 1.5rem; height: 1.5rem; font-size: 0.7rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.conversation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  justify-content: end;
  gap: 0.25rem;
  overflow: hidden;
  padding: 0.75rem;
  font-size: 0.72rem;
}

.message-ui-bubble-row {
  max-width: 78%;
  overflow-wrap: anywhere;
}

.message-ui-bubble-row.incoming { align-self: flex-start; }
.message-ui-bubble-row.outgoing { align-self: flex-end; }
.message-ui-bubble {
  padding: 0.42rem 0.62rem;
  border-radius: 0.85rem;
  line-height: 1.25;
}
.message-ui-bubble.incoming { background: #e9e9eb; color: #171717; }
.message-ui-bubble.outgoing { background: #0a7cff; color: #fff; }
.message-time { margin-block-start: 0.2rem; color: #8c8c92; font-size: 0.55rem; text-align: center; }

.compose-bar {
  width: 100%;
  box-sizing: border-box;
  border-top: 0;
  color: inherit;
  font-size: inherit;
}

.phone .compose-bar textarea {
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  font-size: 17px !important;
  line-height: 20px !important;
}

.phone .compose-bar textarea::placeholder {
  color: #9b9ba1 !important;
  opacity: 1;
}

.fake-input { flex: 1; padding: 0.35rem 0.55rem; border: 1px solid #d2d2d7; border-radius: 1rem; color: #999; }

.imessage-controls {
  display: contents;
}

.imessage-primary-controls {
  display: contents;
}

.imessage-primary-left,
.imessage-primary-right {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #e5e5e7;
  background: transparent;
}

.imessage-primary-left { grid-column: 1; grid-row: 1; }
.imessage-primary-right { grid-column: 3; grid-row: 1; }

.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.control-group { display: grid; gap: 0.35rem; }
.control-group label { color: #777; font-size: 0.8rem; }
.control-label { color: #777; font-size: 0.8rem; }
.contact-sheet { grid-column: 1 / -1; grid-row: 4; border-block: 1px solid #e5e5e7; }
.contact-sheet h2 { margin: 0; padding-block: 0.75rem; font-size: 1rem; font-weight: 500; }
.contact-sheet-content { display: grid; gap: 0.85rem; padding-block: 0.25rem 1rem; }
.toggle-control { display: inline-flex; align-items: center; gap: 0.45rem; color: #666; font-size: 0.8rem; }

.profile-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.profile-choice,
.profile-add {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.4rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid #d4d4d8;
  border-radius: 999px;
  background: #fff;
  color: #222;
  font: inherit;
  cursor: pointer;
}
.profile-control { gap: 0.45rem; }
.profile-picker { align-items: center; }
.profile-choice { min-height: 2.6rem; border-color: transparent; border-radius: 1.4rem; background: #f2f2f7; }
.profile-choice.is-selected { border-color: #1683f5; background: #fff; }
.profile-choice-avatar { width: 2rem; height: 2rem; font-size: 0.85rem; }
.profile-choice.is-selected { border-color: #1683f5; box-shadow: 0 0 0 1px #1683f5; }
.profile-choice-avatar { display: grid; width: 1.45rem; height: 1.45rem; place-items: center; border-radius: 50%; background: #d8d8dc; font-size: 0.75rem; font-weight: 600; }
.profile-check { position: relative; display: inline-flex; width: 1rem; height: 1rem; align-items: center; justify-content: center; visibility: hidden; color: #1683f5; font-size: 1rem; font-weight: 700; line-height: 1; text-align: center; }
.profile-choice.is-selected .profile-check { visibility: visible; }
.profile-choice.is-selected:hover .profile-check { color: transparent; }
.profile-choice.is-selected:hover .profile-check::after { content: '×'; position: absolute; inset: 0; display: grid; place-items: center; color: #1683f5; }
.profile-add { width: 2.4rem; justify-content: center; padding: 0; font-size: 1.1rem; }
.control-group input,
.control-group select,
.message-row textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.7rem;
  border: 1px solid #d4d4d8;
  border-radius: 0.4rem;
  background: #fff;
  color: #222;
  font: inherit;
}

.message-editor { display: grid; gap: 0.75rem; }
.message-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.5rem; align-items: start; }
.message-row select:nth-of-type(n + 2), .message-edited { grid-column: 3; }
.message-meta { grid-column: 3; display: flex; align-items: center; gap: 0.45rem; }
.message-meta select { grid-column: auto; }
.message-edited { display: inline-flex; align-items: center; gap: 0.25rem; color: #777; font-size: 0.75rem; white-space: nowrap; }
.message-row textarea { min-height: 3rem; resize: vertical; }
.message-row select { padding: 0.55rem 0.3rem; border: 1px solid #d4d4d8; border-radius: 0.4rem; background: #fff; color: #222; font: inherit; }

.add-message,
.save-image,
.clear-messages {
  padding: 0.65rem 0.8rem;
  border: 0;
  border-radius: 0.4rem;
  background: #f4f5f7;
  color: #111;
  font: inherit;
  cursor: pointer;
}

.add-message:hover,
.save-image:hover,
.clear-messages:hover { background: #e3e5e9; }
.imessage-action-box {
  display: flex;
  gap: 0.6rem;
  width: calc(100% - 2rem);
  box-sizing: border-box;
  justify-self: center;
  padding: 0.75rem 1rem 1rem;
  background: #f4f5f7;
}
.imessage-action-box > button { flex: 1; padding: 0.5rem 0.7rem; font-size: 0.8rem; }
.save-image { background: #1683f5; color: #fff; }
.save-image:hover { background: #0d70d6; }
.imessage-action-box .clear-messages { background: #e5e7eb; color: #222; }
.imessage-action-box .clear-messages:hover { background: #d7d9dd; }
.hint { grid-column: 1 / -1; grid-row: 3; margin: 0; color: #777; font-size: 0.75rem; }

.advanced-controls {
  grid-column: 1 / -1;
  grid-row: 2;
  border-block: 1px solid #e5e5e7;
}

.advanced-controls summary {
  padding-block: 0.75rem;
  color: #555;
  cursor: pointer;
  font-size: 0.85rem;
}

.advanced-controls-content {
  display: grid;
  gap: 0.75rem;
  padding-block: 0.25rem 1rem;
}

.advanced-message-actions {
  display: flex;
  gap: 0.6rem;
}

.phone-display-settings {
  display: grid;
  gap: 0.45rem;
}

@media (max-width: 47.99rem) {
  .imessage-project { padding-block-start: 1.25rem; }
  .imessage-workspace { grid-template-columns: 1fr; gap: 1.5rem; }
  body > main:has(.imessage-project) { width: min(100%, var(--site-max-width, 640px)); }
  .imessage-preview-panel { grid-column: 1; grid-row: 1; min-height: 31rem; }
  .imessage-primary-left { grid-column: 1; grid-row: 2; }
  .imessage-primary-right { grid-column: 1; grid-row: 3; }
  .advanced-controls { grid-column: 1; grid-row: 4; }
  .hint { grid-column: 1; grid-row: 5; }
  .contact-sheet { grid-column: 1; grid-row: 6; }
  .phone-stage { min-height: 40rem; }
}
