/* =========================
   Global clamp for overlay
========================= */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  max-width: 100%;
}

/* =========================
   Overlay Root
========================= */

.char-overlay {
  position: fixed;
  inset: 0;
  left: 0;
  right: 0;

  width: 100%;
  max-width: 100%;

  z-index: 9999;
  overflow: hidden;
}

.char-overlay.hidden {
  display: none;
}

.char-overlay-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

/* =========================
   Sheet
========================= */

.char-sheet {
  position: absolute;
  left: 0;
  right: 0;

  top: 8vh;
  bottom: auto;

  margin: 0 auto;

  width: 100%;
  max-width: 390px;

  height: 88vh;

  background: linear-gradient(180deg, #111827, #020617);
  border-radius: 18px 18px 0 0;

  display: flex;
  flex-direction: column;

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;

  -ms-overflow-style: none;
  scrollbar-width: none;

  box-shadow: 0 -10px 30px rgba(0,0,0,0.45);
}

.char-sheet::-webkit-scrollbar {
  display: none;
}

/* =========================
   Header (Sticky)
========================= */

.char-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;

  background: linear-gradient(180deg, #0f172a, #0b1020);
  color: #fff;

  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);

  position: sticky;
  top: 0;
  z-index: 5;

  flex-shrink: 0;
  overflow-x: hidden;
}

.char-title {
  flex: 1;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.char-close {
  appearance: none;
  border: none;
  background: rgba(255,255,255,0.08);
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.char-close img {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.95;
  max-width: 100%;
}

/* =========================
   Hero
========================= */

.char-hero {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 4;
  min-height: 50vh;
  background: #020617;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.char-hero-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 3;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  overflow-x: hidden;
}

/* 좌측: 제작자 */
.char-hero-creator {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#charHeroCreatorAvatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
  display: block;
  max-width: 100%;
}

.char-hero-creator-name {
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* =========================
   Hero Stats (아이콘 + 숫자)
========================= */

.char-hero-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #e5e7eb;
}

.char-hero-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

/* 숫자: 굵기 500 */
.char-hero-stat span {
  font-size: 14px;
  font-weight: 500;
  -webkit-text-stroke: 0.4px #e5e7eb;
  text-shadow:
    0 0 0.5px #e5e7eb,
    0 0 0.5px #e5e7eb;
}

/* 기본 아이콘: 20px, 둘 다 아래로 2px */
.char-hero-stat img {
  width: 20px !important;
  height: 20px !important;
  display: block;
  opacity: 1;
  max-width: 100%;
  filter:
    drop-shadow(0 0 0 #e5e7eb)
    drop-shadow(0 0 0 #e5e7eb);
  transform: translateY(2px);
}

/* 💬 말풍선 아이콘만: 10% 감소 (20px -> 18px) */
.char-hero-stat img[src*="chat_bubble"] {
  width: 18px !important;
  height: 18px !important;
}

/* 👤 사람 아이콘은 20px 유지 */

#charHeroImage {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  display: block;
  max-width: 100%;
}

/* =========================
   Thumbs
========================= */

.char-thumbs {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
  z-index: 2;

  max-width: calc(100% - 24px);
  overflow: hidden;
}

.char-thumbs img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
  opacity: 0.8;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(2px);
  max-width: 100%;
}

.char-thumbs img.active {
  opacity: 1;
  border: 2px solid #a78bfa;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.18);
}

/* =========================
   Content
========================= */

.char-content {
  flex: 0 0 auto;
  overflow-x: hidden;
  padding: 16px 16px 24px 16px;
}

.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.char-tags span {
  font-size: 11px;
  background: rgba(167, 139, 250, 0.22);
  color: #ede9fe;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(167,139,250,0.45);
  cursor: pointer;
  max-width: 100%;
}

.char-section {
  background: #121A2A;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255,255,255,0.10);
  overflow-x: hidden;
}

.char-section h3 {
  font-size: 13px;
  margin: 0 0 8px 0;
  color: #ffffff;
  font-weight: 700;
}

.char-section p,
.creator-comment {
  font-size: 12px;
  line-height: 1.65;
  color: #e5e7eb;
  margin: 0;
  word-break: break-word;
  white-space: pre-wrap;
  font-weight: 300;
}

/* =========================
   Footer (Sticky)
========================= */

.char-footer {
  position: sticky;
  bottom: 0;

  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  gap: 10px;
  flex-shrink: 0;

  background: linear-gradient(180deg, rgba(7,11,22,0.9), rgba(2,6,23,0.98));
  backdrop-filter: blur(4px);
  overflow-x: hidden;
}

.char-footer button {
  flex: 1;
  height: 50px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  max-width: 100%;
}

.char-footer .btn-primary {
  background: linear-gradient(135deg, #8b5cf6, #6d5cff);
  color: #fff;
  box-shadow: 0 6px 16px rgba(139,92,246,0.45);
}

.char-footer .btn-secondary {
  background: #1f2937;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
}