
/* 첫 번째 블록 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f2eef9;
  color: #252038;
  font: 15px system-ui, sans-serif;
}

main {
  max-width: 740px;
  margin: auto;
  background: #faf8fe;
  min-height: 100dvh;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  padding: 16px 20px;
  border-bottom: 1px solid #e7dff4;
}

h1, h2, p {
  margin: 0 0 10px;
}

small, time {
  color: #625775;
}

nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  background: #ede6f8;
  color: #3d285c;
}

button[aria-current=true],
button.primary {
  background: #59368c;
  color: white;
}

button:disabled {
  opacity: .55;
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid #8a54c5;
  outline-offset: 2px;
}

section {
  padding: 20px;
}

.entry {
  padding: 56px 24px;
  max-width: 460px;
  margin: auto;
}

label, input {
  display: block;
}

input {
  padding: 12px;
  margin: 8px 0 14px;
  width: 100%;
  border: 1px solid #8875a4;
  border-radius: 12px;
}

.date {
  text-align: center;
  font-size: 14px;
  color: #625775;
  margin: 16px 0;
  scroll-margin-top: var(--offset, 160px);
}

.line {
  display: flex;
  align-items: end;
  gap: 8px;
  margin: 12px 0;
}

.mine {
  justify-content: flex-end;
}

.bubble {
  background: white;
  border: 1px solid #e8def5;
  border-radius: 5px 16px 16px;
  padding: 10px 13px;
  max-width: min(78%, 420px);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mine .bubble {
  background: #e8d8ff;
  border-radius: 16px 5px 16px 16px;
}

.photo {
  padding: 0;
  background: none;
  overflow: hidden;
}

.photo img {
  display: block;
  max-width: 100%;
  max-height: 260px;
}

.month {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
}

.calendar button {
  padding: 9px 0;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.gallery button {
  padding: 0;
  overflow: hidden;
}

.gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

dialog {
  border: 0;
  border-radius: 18px;
  width: min(92vw, 650px);
  color: inherit;
}

dialog::backdrop {
  background: #201530bb;
}

dialog img {
  width: 100%;
  max-height: 70dvh;
  object-fit: contain;
  display: block;
  margin: 12px 0;
}

[hidden] {
  display: none !important;
}

/* 두 번째 블록 */
body, main {
  background: #c7cde5;
  color: #11131a;
}

main {
  max-width: 740px;
}

header {
  background: #c7cde5;
  border-color: #b7bed6;
  text-align: center;
  padding: 12px 16px 8px;
  position: sticky;
}

header h1 {
  font-size: 16px;
  margin: 0;
}

#status {
  font-size: 11px;
  color: #414654;
}

nav {
  justify-content: center;
  margin: 4px 0;
  gap: 4px;
}

nav button {
  background: transparent;
  padding: 4px 7px;
  font-size: 11px;
  color: #333a50;
}

nav button[aria-current=true] {
  background: #7a85b1;
  color: white;
}

.entry .primary {
  background: #596690;
}

#chat {
  padding: 12px 19px 20px;
}

.line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 19px 0 0;
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  max-width: 86%;
}

.mine .stack {
  align-items: flex-end;
}

.line .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #232735;
}

.meta time {
  color: inherit;
  font-size: 11px;
}

.avatar {
  width: 33px;
  height: 33px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #3c4552;
  color: white;
  font-size: 12px;
  flex: none;
}

.bubble,
.mine .bubble {
  padding: 10px 14px;
  border: 0;
  border-radius: 23px;
  max-width: 100%;
  line-height: 1.45;
}

.mine .bubble {
  background: #727da9;
  color: white;
}

.date {
  font-size: 11px;
  font-weight: 500;
  background: #d5daee;
  border-radius: 99px;
  width: fit-content;
  padding: 4px 14px;
  margin: 28px auto;
  color: #252836;
}

.verified {
  font-size: 10px;
  background: #252b35;
  border-radius: 50%;
  color: white;
  width: 14px;
  height: 14px;
  text-align: center;
}

/* 세 번째 블록 */
body, main, header {
  background: #cbd1e7;
}

header {
  min-height: 63px;
  padding: 8px 105px 8px 60px;
}

header h1 {
  font-size: 17px;
}

.profile,
.quick button {
  background: transparent;
  color: #232735;
}

.profile {
  padding: 2px 8px;
  font-weight: 750;
}

.quick {
  position: absolute;
  right: 10px;
  top: 15px;
  display: flex;
}

.quick button {
  font-size: 12px;
  padding: 7px;
}

.back {
  top: 19px;
}

.menu-actions {
  display: grid;
  gap: 8px;
}

.calendar button.has::after {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #51447f;
  display: block;
  margin: 3px auto 0;
}

.calendar button {
  min-height: 42px;
}

.return,
.result {
  display: block;
  margin: 10px 0;
}

.result {
  text-align: left;
  width: 100%;
}

dialog h2 {
  margin-top: 12px;
}

#chat {
  padding-bottom: 32px;
}

.bubble,
.mine .bubble {
  white-space: pre-wrap;
}

.mine .bubble {
  background: #525e89;
}

.date {
  background: #dee3f4;
}

/* 프로필 바텀 시트 스타일 추가 */
dialog.sheet {
  margin: auto auto 0;
  width: min(100%, 740px);
  max-width: 100%;
  border-radius: 24px 24px 0 0;
  background: #f4f5f7;
  padding: 12px 20px 32px;
  color: #191c24;
  border: 0;
}

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.52);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 99px;
  background: #d1d5db;
  margin: 0 auto 24px;
}

.sheet-profile {
  text-align: center;
  margin-bottom: 28px;
}

.sheet-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #3c4552;
  color: #fff;
  font-size: 32px;
  font-weight: 600;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  overflow: hidden;
}

.sheet-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sheet-profile h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 6px;
  color: #11131a;
}


.sheet-section {
  margin-bottom: 22px;
}

.sheet-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #555b6b;
  margin-bottom: 10px;
  padding: 0 2px;
}

.link-btn {
  background: none;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: #2f7cf6;
  border-radius: 0;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.recent-grid button {
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e5ec;
  aspect-ratio: 1;
}

.recent-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sheet-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 18px;
  font-size: 13px;
  color: #7b8190;
  background: #fff;
  border-radius: 14px;
  margin: 0;
}

.sheet-card {
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
}

.sheet-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: transparent;
  border-radius: 0;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: #191c24;
}

.sheet-item + .sheet-item {
  border-top: 1px solid #f1f2f5;
}

.sheet-item:active {
  background: #f8f9fa;
}

.sheet-item svg {
  width: 22px;
  height: 22px;
  flex: none;
  color: #333846;
}

.sheet-item.danger,
.sheet-item.danger svg {
  color: #e05252;
}

.gallery-days{display:grid;gap:16px}
.gallery-day{padding:14px;border-radius:16px;background:#ffffffa8}
.gallery-day h3{margin:0 0 10px;font-size:14px}
.gallery-day .gallery{grid-template-columns:repeat(auto-fill,minmax(104px,1fr))}

.bubble.reply-bubble {
  padding: 12px 16px;
  border-radius: 20px;
}

.reply-label {
  color: #3d3d3d;
  font-size: 0.82em;
  font-weight: 700;
}

.reply-quote {
  margin-top: 2px;
  color: #666;
  font-size: 0.82em;
}

.reply-body {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 8px;
}

.reply-body span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.reply-arrow {
  flex: none;
}

.message-item{display:flex;align-items:center;gap:5px;max-width:100%;border-radius:18px}.mine .message-item{flex-direction:row-reverse}.capture-selected{outline:2px solid #5548a1;background:#ffffff67}.message-item.capture-selected{cursor:pointer}#capture-bar:not([hidden]){display:flex;position:sticky;top:var(--offset,86px);z-index:4;gap:8px;align-items:center;flex-wrap:wrap;background:#fff;padding:10px 16px;border-bottom:1px solid #c7c3df}#hearts{padding:16px}.heart-row{display:flex;align-items:center;gap:8px}.heart-row .result{flex:1}.heart-row>button:last-child{color:#a32f62}


#chat .bubble,#results .result,#hearts .result{font-size:var(--chat-text-size,15px)}
img.avatar,.sheet-avatar img{object-fit:cover;display:block;padding:0}
.sheet-avatar{overflow:hidden}
.text-setting{gap:10px;cursor:default}
.text-setting label,.text-setting output{flex:none}
.text-setting input{flex:1;min-width:0;width:100%;padding:0}
#results .result span{display:block;overflow-wrap:anywhere}
.result-time{font-size:.8em;opacity:.8}
.result-quote{margin:5px 0;padding-left:8px;border-left:2px solid currentColor;font-size:.88em}
.result-text{margin-top:4px;white-space:pre-wrap}

/* 바텀 시트: 손잡이 주변까지 터치 가능 */
.sheet-drag-zone {
  display: grid;
  place-items: center;
  min-height: 44px;
  margin: -12px -20px 4px;
  touch-action: none;
  user-select: none;
  cursor: grab;
}

.sheet-drag-zone .sheet-handle {
  margin: 0;
}

dialog.sheet {
  transform: translateY(var(--sheet-y, 0px));
  transition: transform 180ms ease-out;
}

dialog.sheet.is-dragging {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  dialog.sheet {
    transition: none;
  }
}

/* 최신 채팅으로 이동: 모바일 하단 안전 영역 반영 */
.latest-fab:not([hidden]) {
  position: fixed;
  z-index: 5;
  right: max(16px, env(safe-area-inset-right, 0px),
             calc((100vw - 740px) / 2 + 16px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  background: #fff;
  color: #3d476b;
  font-size: 24px;
  box-shadow: 0 3px 12px rgb(0 0 0 / 18%);
}

#chat {
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* 하트가 설정됐을 때만 말풍선 오른쪽 아래에 표시 */
.message-item .bubble {
  position: relative;
  touch-action: manipulation;
}

.heart-badge:not([hidden]) {
  position: absolute;
  right: 4px;
  bottom: -5px;
  z-index: 1;
  padding: 1px 4px;
  border-radius: 999px;
  background: #fff;
  color: #bb2262;
  font-size: 11px;
  line-height: 1.2;
  pointer-events: none;
}

 
 /* Mobile refresh */
 #app > header { position: sticky; inset-block-start: 0; z-index: 4; min-height: 64px; padding: 8px 96px; display: grid; grid-template-columns: minmax(0,1fr); align-content: center; text-align: center; background: #f5f6fc; border-bottom: 1px solid #dee2ef; }
 #app > header h1 { margin: 0; }
 #app > header #status { margin: 0; }
 #app > header .quick { top: 50%; transform: translateY(-50%); gap: 0; }
 #app > header .quick-left { left: 6px; right: auto; }
 #app > header .quick-right { right: 6px; }
 .quick button:not([hidden]), .panel-back { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; color: #343d59; background: transparent; }
 .quick button[aria-current=true] { background: #e6eaf7; }
 .quick svg { width: 21px; height: 21px; }
 .panel-back { font-size: 21px; flex: 0 0 44px; }
 .panel-top { display: flex; align-items: center; gap: 8px; min-height: 52px; margin-bottom: 12px; }
 #photos, #dates, #hearts, #search { padding: 8px 12px 28px; min-height: calc(100dvh - 64px); background: #f7f8fc; }
 #search .panel-top input { flex: 1; width: 0; min-width: 0; min-height: 44px; margin: 0; border: 1px solid #dde2ef; border-radius: 14px; padding: 0 12px; background: #fff; }
 #photos .photo-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; }
 #photos .photo-grid > p { grid-column: 1 / -1; }
 #photos .photo-grid .photo, #recent-photos .photo { width: 100%; aspect-ratio: 1; border-radius: 6px; }
 #photos .photo-grid img, #recent-photos img { width: 100%; height: 100%; max-height: none; object-fit: cover; }
 #app .photo { display: block; border: 0; padding: 0; box-shadow: none; background: transparent; }
 #chat .bubble.photo-only { padding: 0; border: 0; box-shadow: none; background: transparent; }
 #app .photo:focus-visible, #app button:focus-visible, #query:focus-visible { outline: 2px solid #5d5f9b; outline-offset: 2px; }
 #results .result, #hearts .result { background: #fff; border: 1px solid #e2e6f0; border-radius: 14px; }
 .quick button, .panel-back, .latest-fab, #app .photo, #app .result { transition: transform .16s ease-out, background-color .18s ease-out; }
 .quick button:active, .panel-back:active, .latest-fab:active, #app .photo:active, #app .result:active { transform: scale(.97); }
 @media (prefers-reduced-motion: no-preference) {
   #app > section:not([hidden]):not(#chat) { animation: panel-in .20s ease-out both; }
   @keyframes panel-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
 }
 @media (prefers-reduced-motion: reduce) {
   .quick button, .panel-back, .latest-fab, #app .photo, #app .result { transition: none; }
 }

 /* 입장 화면 */
.entry {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
}

.entry-title {
  margin: 0;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 14px;
  text-align: center;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: .02em;
  color: #232735;
  border-bottom: 1px solid #b7bed6;
}

.entry-year {
  display: inline-block;
  margin-right: 8px;
  padding: 2px 9px;
  border-radius: 99px;
  background: #525e89;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  vertical-align: 1px;
}

.entry-chat {
  flex: 1;
  padding: 28px 19px 0;
}

.entry .avatar {
  width: 40px;
  height: 40px;
}

.entry-composer {
  position: sticky;
  bottom: 0;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  background: #f5f6fc;
  border-top: 1px solid #dee2ef;
}

.entry-composer label {
  margin: 0 4px 8px;
  font-size: 12px;
  color: #5a6280;
}

.composer-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 18px;
  background: #fff;
  border: 1px solid #dde2ef;
  border-radius: 26px;
  transition: border-color .18s ease-out, box-shadow .18s ease-out;
}

.composer-field:focus-within {
  border-color: #525e89;
  box-shadow: 0 0 0 3px rgb(82 94 137 / 18%);
}

.composer-field input {
  flex: 1;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 16px; /* iOS 확대 방지 */
}

.composer-field input:focus-visible {
  outline: none;
}

.composer-field .primary {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: #525e89;
  color: #fff;
  transition: opacity .18s ease-out, transform .16s ease-out;
}

.composer-field .primary svg {
  width: 20px;
  height: 20px;
}

.composer-field .primary:active {
  transform: scale(.93);
}

/* 입력 전에는 전송 버튼을 흐리게 */
.composer-field:has(input:placeholder-shown) .primary {
  opacity: .45;
}

@media (prefers-reduced-motion: no-preference) {
  .entry-line {
    animation: entry-in .5s .15s ease-out both;
  }
  .entry-composer {
    animation: entry-in .5s .45s ease-out both;
  }
  @keyframes entry-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
  }
}
/* 1) 말풍선 크기 축소 (글자 크기는 그대로) */
.stack { max-width: 78%; }
#chat .bubble,
.entry .bubble {
  padding: 7px 11px;
  border-radius: 17px;
  line-height: 1.35;
}
#chat .bubble.reply-bubble {
  padding: 9px 12px;
  border-radius: 17px;
}
.reply-body { margin-top: 5px; }

/* 2) 아티스트 프로필 사진 중앙 정렬 */
:root { --avatar-focus: 50% 50%; } /* 얼굴 위치 조절: 예) 50% 30% */
img.avatar,
.sheet-avatar img {
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: var(--avatar-focus);
}

/* 3) 입장 안내 팝업 */
dialog.guide {
  width: min(92vw, 420px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  border-radius: 22px;
  background: #f7f8fc;
  color: #191c24;
}
.guide-body { padding: 24px 22px 20px; }
.guide-body h2 { margin: 0 0 4px; font-size: 19px; font-weight: 750; }
.guide-lead { margin: 0 0 16px; font-size: 10px; color: #5a6280; }
.guide-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.guide-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: #fff;
  border-radius: 14px;
}
.guide-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e6eaf7;
  color: #3d476b;
  font-size: 17px;
}
.guide-ic svg { width: 19px; height: 19px; }
.guide-list strong { display: block; font-size: 14px; }
.guide-desc { font-size: 12.5px; line-height: 1.4; color: #5a6280; }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guide-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #3d476b; cursor: pointer; }
.guide-check input {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: #525e89;
}
.guide-actions .primary { padding: 10px 22px; border-radius: 99px; background: #525e89; }

