#media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 50000;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
  pointer-events: auto;
}

#media-lightbox[hidden] {
  display: none;
}

.media-lightbox-body {
  display: grid;
  place-items: center;
  max-width: 100%;
  max-height: 100%;
}

#media-lightbox img,
#media-lightbox video {
  display: block;
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.chat-link {
  color: #9fd2ff;
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

#link-preview {
  position: fixed;
  left: 5vw;
  top: 5vh;
  width: 90vw;
  height: 90vh;
  z-index: 50010;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 14px;
  background: rgba(8, 12, 18, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.58);
  pointer-events: auto;
}

#link-preview[hidden] {
  display: none;
}

.link-preview-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(15, 21, 30, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.link-preview-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(245, 247, 251, 0.76);
  font: 700 12px/1.2 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
}

.link-preview-open,
.link-preview-proxy,
.link-preview-close {
  height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(245, 247, 251, 0.86);
  font: 850 12px/28px 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.link-preview-proxy.active {
  border: 1px solid rgba(255, 209, 102, 0.44);
  background: rgba(255, 209, 102, 0.16);
  color: #ffe38c;
}

.link-preview-close {
  width: 28px;
  padding: 0;
}

.link-preview-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28px;
  height: 28px;
  cursor: nwse-resize;
  z-index: 3;
  touch-action: none;
}

.link-preview-resize::before {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 13px;
  height: 13px;
  border-right: 2px solid rgba(255,255,255,0.38);
  border-bottom: 2px solid rgba(255,255,255,0.38);
  border-radius: 0 0 4px 0;
}

#link-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.link-preview-status {
  position: absolute;
  inset: 45px 0 0 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 210, 102, 0.08), transparent 42%),
    rgba(7, 12, 18, 0.82);
  pointer-events: auto;
}

.link-preview-status[hidden] {
  display: none;
}

.link-preview-status-card {
  max-width: min(680px, 90%);
  padding: 22px 24px;
  border-radius: 14px;
  border: 1px solid rgba(255, 218, 112, 0.24);
  background: rgba(12, 18, 26, 0.94);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48), 0 0 36px rgba(255, 218, 112, 0.08);
  color: rgba(245, 247, 251, 0.9);
}

.link-preview-status-text {
  font: 750 15px/1.55 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
}

.link-preview-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.link-preview-status-actions button,
.link-preview-status-actions a {
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(245, 247, 251, 0.88);
  font: 850 12px/32px 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.link-preview-status-actions .primary {
  border-color: rgba(255, 218, 112, 0.5);
  background: rgba(255, 218, 112, 0.18);
  color: #ffe38c;
}

.emoji-picker {
  position: fixed;
  z-index: 50020;
  width: min(560px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 24px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(9, 13, 18, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
}

.emoji-picker[hidden] {
  display: none;
}

.emoji-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: rgba(245, 247, 251, 0.78);
  font: 850 12px/1 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.emoji-picker-head:active {
  cursor: grabbing;
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  grid-auto-rows: 86px;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.emoji-picker-section {
  grid-column: 1 / -1;
  margin: 5px 1px -2px;
  color: rgba(245, 247, 251, 0.72);
  font: 900 11px/1 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.emoji-picker-item {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(245, 247, 251, 0.92);
  font: 900 24px/1 'Pretendard', 'Noto Sans KR', 'Segoe UI Emoji', system-ui, sans-serif;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
}

.emoji-picker-item.sticker {
  border-color: rgba(99, 179, 255, 0.2);
}

.emoji-picker-item.premium-emoji {
  border-color: rgba(255, 116, 214, 0.25);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 116, 214, 0.2), transparent 48%),
    rgba(255, 255, 255, 0.07);
}

.emoji-picker-item.no-preview {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(255, 255, 255, 0.06);
}

.emoji-picker-fallback {
  max-width: calc(100% - 8px);
  padding: 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(245, 247, 251, 0.92);
  font: 900 13px/1.12 'Pretendard', 'Noto Sans KR', 'Segoe UI Emoji', system-ui, sans-serif;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.48);
}

.emoji-picker-item.premium-emoji .emoji-picker-fallback {
  color: #ffd6f4;
  font-size: 24px;
}

.emoji-picker-custom-preview,
.emoji-picker-custom-preview .chat-custom-emoji-media,
.emoji-picker-custom-preview.lottie-sticker {
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  margin: 0;
  font-size: 46px;
  vertical-align: baseline;
}

.emoji-picker-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 999px;
  padding: 2px 5px;
  background: rgba(4, 7, 10, 0.72);
  color: rgba(245, 247, 251, 0.86);
  font: 850 8px/1 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  text-transform: uppercase;
  pointer-events: none;
}

.emoji-picker-item.premium-emoji .emoji-picker-badge {
  color: #ffd2f4;
  background: rgba(112, 22, 82, 0.72);
}

.emoji-picker-item:hover {
  border-color: rgba(255, 218, 112, 0.46);
  background: rgba(255, 218, 112, 0.14);
}

.emoji-picker-item.disabled {
  cursor: not-allowed;
  opacity: 0.46;
  filter: grayscale(0.45);
}

.emoji-picker-item.disabled:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.07);
}

.emoji-picker-item.loading-preview {
  border-color: rgba(255, 218, 112, 0.36);
}

.emoji-picker-item.loading-preview::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 8px;
  border: 2px solid rgba(255, 218, 112, 0.16);
  border-top-color: rgba(255, 218, 112, 0.72);
  animation: emoji-preview-spin 0.85s linear infinite;
  pointer-events: none;
}

.emoji-picker-item.preview-ready {
  border-color: rgba(91, 226, 142, 0.38);
}

.emoji-picker-item.preview-failed {
  border-color: rgba(255, 103, 103, 0.26);
}

@keyframes emoji-preview-spin {
  to { transform: rotate(360deg); }
}

.emoji-picker-item img,
.emoji-picker-item video {
  display: block;
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  object-fit: contain;
  border-radius: 7px;
}

.chat-custom-emoji {
  display: inline-grid;
  width: 1.35em;
  height: 1.35em;
  margin: -0.18em 0.04em -0.25em;
  place-items: center;
  vertical-align: -0.22em;
}

.chat-custom-emoji-media,
.chat-custom-emoji .lottie-sticker,
.chat-custom-emoji.lottie-sticker {
  display: block;
  width: 1.35em;
  height: 1.35em;
  object-fit: contain;
  pointer-events: none;
}

.chat-custom-emoji.custom-emoji-loading::before {
  content: "";
  width: 0.9em;
  height: 0.9em;
  border-radius: 999px;
  border: 0.14em solid rgba(255, 210, 244, 0.22);
  border-top-color: rgba(255, 210, 244, 0.9);
  animation: emoji-preview-spin 0.85s linear infinite;
}

.chat-custom-emoji.custom-emoji-failed {
  opacity: 0.78;
}

.emoji-picker-empty {
  grid-column: 1 / -1;
  padding: 14px;
  color: rgba(245, 247, 251, 0.58);
  font: 750 13px/1.45 'Pretendard', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  text-align: center;
}
