/* =========================================================
   오렌지톡 — Design Tokens
   Palette: 로고(오렌지 육각 스피어)에서 추출한 웜톤 + 깊은 에스프레소 배경
   Type: Pretendard(한글 본문/디스플레이) + Manrope(라틴/숫자 유틸리티)
   Signature: 로고의 육각형(hexagon) 모티프 — 벨소리를 원이 아닌
              육각 링 파동으로 표현
   ========================================================= */

:root {
  --bg: #241a12;
  --bg-soft: #2f2117;
  --card-bg: #2a1d14;
  --line: rgba(255, 199, 130, 0.18);

  --orange-1: #fdba74; /* light */
  --orange-2: #f97316; /* mid */
  --orange-3: #ea580c; /* deep */

  --cream: #fff4e6;
  --muted: #c9a67d;
  --muted-2: #8a7157;

  --danger: #e5484d;
  --success: #34d399;

  --font-kr: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-num: 'Manrope', var(--font-kr);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-kr);
  overflow: hidden;
}

body {
  position: relative;
  min-height: 100vh;
}

/* ---------- 배경 육각형 필드 (앰비언트) ---------- */
.bg-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.hex {
  position: absolute;
  width: 220px;
  height: 190px;
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%);
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  opacity: 0.05;
  filter: blur(1px);
  animation: drift 22s ease-in-out infinite;
}
.h1 { top: -60px; left: -60px; animation-delay: 0s; }
.h2 { top: 20%; right: -100px; width: 300px; height: 260px; animation-delay: -4s; }
.h3 { bottom: -80px; left: 10%; animation-delay: -9s; }
.h4 { bottom: 10%; right: 5%; width: 150px; height: 130px; animation-delay: -13s; }
.h5 { top: 55%; left: -80px; width: 180px; height: 155px; animation-delay: -6s; }
.h6 { top: -40px; right: 20%; width: 130px; height: 112px; animation-delay: -17s; }

@keyframes drift {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-24px) rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hex { animation: none; }
}

/* ---------- 홈 화면에 추가(설치) 안내 배너 ---------- */
.install-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.install-banner[hidden] {
  display: none;
}

.install-banner-text {
  color: #1b0f06;
  font-size: 13.5px;
  font-weight: 700;
  flex: 1;
  min-width: 180px;
}

.install-banner-btns {
  display: flex;
  gap: 8px;
}

.install-btn-primary,
.install-btn-dismiss {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.install-btn-primary {
  background: #1b0f06;
  color: var(--orange-1);
}

.install-btn-dismiss {
  background: rgba(27, 15, 6, 0.15);
  color: #1b0f06;
}

/* ---------- 로고 입체(3D) 한바퀴 회전 (앱 진입 시 한 번만) ---------- */
/* 기존의 별도 인트로 화면(로고 회전 → 정지 → 타이틀) 대신, 실제 화면(게이트 또는
   통화 화면)에 로고가 나타나면서 그 자리에서 한 바퀴만 입체적으로 회전합니다.
   평면(2D) 회전과 달리 rotateY + perspective를 써서, 회전 중간에 로고의
   "옆면 → 뒷면 → 다시 앞면" 순서로 보이는 입체적인 느낌을 줍니다. */
@keyframes logoFlip3D {
  from { transform: perspective(600px) rotateY(0deg); }
  to { transform: perspective(600px) rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .logo,
  .ring-static {
    animation: none !important;
  }
}

/* ---------- 공통 화면 레이아웃 ---------- */
.screen {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.screen.active { display: flex; }

/* ---------- 1. 게이트 ---------- */
.card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 40px 28px 32px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}

.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 18px;
  animation: logoFlip3D 1s cubic-bezier(0.65, 0, 0.35, 1) both;
}

.eyebrow {
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--orange-1);
  font-weight: 800;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--cream);
  letter-spacing: -0.01em;
}

.sub {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 28px;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#gate-nickname,
#gate-password {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--cream);
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.15s ease;
}
#gate-nickname:focus,
#gate-password:focus {
  border-color: var(--orange-2);
}
#gate-nickname::placeholder,
#gate-password::placeholder { color: var(--muted-2); }

.gate-error {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--danger);
  margin: 10px 0 0;
}

/* ---------- 버튼 공통 ---------- */
button {
  font-family: var(--font-kr);
  border: none;
  cursor: pointer;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.12s ease, opacity 0.12s ease, filter 0.12s ease;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; pointer-events: none; }
button:focus-visible {
  outline: 2px solid var(--orange-1);
  outline-offset: 2px;
}

.btn-primary {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #1b0f06;
  font-size: 15px;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 15px;
}

.btn-danger {
  padding: 14px 20px;
  background: var(--danger);
  color: #2a0a0a;
  font-size: 15px;
}

.btn-icon {
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 14px;
}

.btn-row { display: flex; gap: 12px; margin-top: 6px; }

/* ---------- 2. 통화 화면 ---------- */
.call-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 20px;
}
.logo-sm { width: 22px; height: 22px; object-fit: contain; }
.header-title {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.header-role {
  font-family: var(--font-num);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--orange-1);
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: auto;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.state[hidden] {
  display: none;
}

.status-text {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.02em;
}

.timer {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 800;
  color: var(--orange-1);
  margin: -10px 0 0;
  letter-spacing: 0.05em;
}

.call-volume-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: 18px auto 0;
}
.call-volume-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.call-volume-row input[type='range'] {
  flex: 1;
  accent-color: var(--orange-2);
}

/* ---------- 시그니처: 육각 링 파동 (벨/연결 표시) ---------- */
.ring-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-static,
.ring-core {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.ring-static {
  animation: logoFlip3D 1s cubic-bezier(0.65, 0, 0.35, 1) both;
}

.ring-core.solid {
  box-shadow: 0 0 40px rgba(249, 115, 22, 0.45);
}

.pulsing .ring-core {
  animation: logo-glow 1.6s ease-in-out infinite;
}

@keyframes logo-glow {
  0%, 100% {
    filter: drop-shadow(0 0 0px rgba(249, 115, 22, 0));
  }
  50% {
    filter: drop-shadow(0 0 22px rgba(249, 115, 22, 0.75));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pulsing .ring-core {
    animation: none;
    filter: drop-shadow(0 0 14px rgba(249, 115, 22, 0.5));
  }
}

.ring-pulse {
  position: absolute;
  width: 96px;
  height: 96px;
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%);
  border: 2px solid var(--orange-2);
  opacity: 0;
  animation: hexpulse 2.4s ease-out infinite;
}
.r1 { animation-delay: 0s; }
.r2 { animation-delay: 0.8s; }
.r3 { animation-delay: 1.6s; }

@keyframes hexpulse {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ring-pulse { animation: none; opacity: 0.25; }
}

.conn-note {
  position: fixed;
  bottom: 18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted-2);
  margin: 0;
  padding: 0 24px;
}

/* ---------- 접속자 목록 / 채팅 패널 ---------- */
.panel-fab {
  position: fixed;
  right: 18px;
  bottom: 24px;
  z-index: 10;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #1b0f06;
  font-size: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: 100%;
  max-width: 720px;
  height: 100%;
  height: 100dvh;
  background: var(--card-bg);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

/* 실제 휴대폰 화면(대부분 480px 이하)에서는 무조건 화면 전체를 꽉 채웁니다 */
@media (max-width: 480px) {
  .side-panel {
    max-width: 100%;
  }
}
.side-panel.open {
  transform: translateX(0);
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.side-panel-header span {
  font-size: 14px;
  font-weight: 800;
  color: var(--cream);
  letter-spacing: 0.03em;
}

.panel-close {
  background: none;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 8px;
}

.people-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
}

.idle-list {
  flex: none;
  width: 100%;
  max-width: 300px;
  max-height: 200px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 8px;
  margin-top: 4px;
}

.people-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 12px;
  border-radius: 12px;
  color: var(--cream);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s ease;
}
.people-item:hover {
  background: var(--bg-soft);
}

.people-name {
  flex: 1;
}

.people-call-btn,
.people-msg-btn {
  background: none;
  color: var(--orange-1);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 8px;
}
.people-call-btn:hover,
.people-msg-btn:hover {
  background: rgba(249, 115, 22, 0.15);
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.dot-online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}
.dot-offline {
  background: var(--muted-2);
}

.people-empty {
  color: var(--muted-2);
  font-size: 13px;
  padding: 14px 12px;
  cursor: default;
}
.people-empty:hover {
  background: none;
}

.chat-area {
  position: absolute;
  inset: 0;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
}

.chat-area[hidden] {
  display: none;
}

.chat-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 15px;
  font-weight: 800;
  padding: 10px 16px;
  margin: 14px 14px 6px;
  border-radius: 999px;
  align-self: flex-start;
}
.chat-back:hover {
  background: rgba(249, 115, 22, 0.15);
  border-color: var(--orange-2);
}
.chat-back:active {
  transform: scale(0.96);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease;
}
.chat-bubble:active {
  transform: scale(0.97);
}
.chat-bubble.mine {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #ffffff;
}
.chat-bubble.theirs {
  align-self: flex-start;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.chat-form[hidden] {
  display: none;
}

.chat-image-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--orange-1);
  font-size: 16px;
  padding: 0 12px;
  border-radius: 12px;
  flex-shrink: 0; /* 좁은 화면에서도 이 버튼들은 절대 찌그러지지 않게 고정 */
}
.chat-image-btn:hover {
  background: rgba(249, 115, 22, 0.12);
}

.chat-attach-btn {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  width: 40px;
  padding: 0;
}

.chat-bubble-image {
  padding: 4px;
  background: transparent !important;
  border: none !important;
}
.chat-bubble-image img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
}

#chat-input {
  flex: 1;
  min-width: 0; /* ★ 이게 빠져있으면 좁은 화면에서 입력창이 안 줄어들고
                   전송 버튼을 밀어내서 화면 밖으로 잘려나갑니다 */
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--cream);
  font-size: 14px;
  outline: none;
}
#chat-input:focus {
  border-color: var(--orange-2);
}
#chat-input::placeholder {
  color: var(--muted-2);
}

.chat-send {
  padding: 12px 16px;
  background: #ff8a2b; /* 더 밝은 오렌지 */
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  border-radius: 12px;
  flex-shrink: 0; /* 절대 안 찌그러지고 항상 보이도록 고정 */
  white-space: nowrap;
}
.chat-send:hover {
  filter: brightness(1.06);
}

/* ---------- "+" 첨부 시트 (앨범 / 카메라 / 음성메시지) ---------- */
.attach-sheet {
  display: flex;
  gap: 10px;
  padding: 14px 14px 6px;
  border-top: 1px solid var(--line);
}

.attach-sheet[hidden] {
  display: none;
}

.attach-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 6px 14px;
  color: var(--cream);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.attach-option:hover {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--orange-2);
}
.attach-option:active {
  transform: scale(0.96);
}

.attach-option-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(253, 186, 116, 0.18), rgba(234, 88, 12, 0.14));
  color: var(--orange-1);
}

.attach-option-icon svg {
  width: 24px;
  height: 24px;
}

/* 아주 좁은 화면(갤럭시 폴드 커버 화면 등)에서도 전송 버튼이 절대
   화면 밖으로 밀려나가지 않도록 여백/크기를 한 번 더 줄여줍니다 */
@media (max-width: 340px) {
  .chat-form {
    gap: 4px;
    padding: 10px 8px;
  }
  .chat-attach-btn {
    width: 34px;
    font-size: 18px;
  }
  #chat-input {
    padding: 10px 10px;
    font-size: 13px;
  }
  .chat-send {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* ---------- 모바일 ---------- */
@media (max-width: 420px) {
  .card { padding: 32px 22px 26px; }
  .ring-wrap { width: 150px; height: 150px; }
  .ring-static, .ring-core, .ring-pulse { width: 80px; height: 80px; }
}

/* ---------- 선택/롱프레스 네모 박스 방지 (Android 텍스트 선택 충돌 수정) ---------- */
*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.people-del-btn {
  background: none;
  color: var(--danger);
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 8px;
  opacity: 0.85;
}
.people-del-btn:hover {
  background: rgba(229, 72, 77, 0.15);
  opacity: 1;
}

/* ---------- 로그인 입력창: 자동완성 시 글자가 안 보이는 문제 방지 ---------- */
/* 브라우저 자동완성(자동채움)이 켜지면 배경/글자색을 브라우저가 임의로
   흰 배경+검은 글씨로 바꿔버려서, 어두운 테마에서는 글자가 안 보이게 됩니다. */
#gate-nickname,
#gate-password {
  caret-color: var(--cream);
}
#gate-nickname:-webkit-autofill,
#gate-nickname:-webkit-autofill:hover,
#gate-nickname:-webkit-autofill:focus,
#gate-password:-webkit-autofill,
#gate-password:-webkit-autofill:hover,
#gate-password:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--cream);
  -webkit-box-shadow: 0 0 0px 1000px var(--bg-soft) inset;
  box-shadow: 0 0 0px 1000px var(--bg-soft) inset;
  transition: background-color 9999s ease-in-out 0s;
}
.settings-pill {
  margin-left: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.32);
  color: var(--orange-1);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.settings-pill:hover {
  background: rgba(249, 115, 22, 0.2);
}

/* ---------- 데스크탑 접속 안내 (모바일 유도) ---------- */
#desktop-guard {
  display: none;
}

/* PC로 접속한 경우(html.is-desktop-guard)에는 배경/모든 화면을 숨기고
   안내 화면만 보여줍니다 */
html.is-desktop-guard .bg-field,
html.is-desktop-guard .screen,
html.is-desktop-guard .install-banner,
html.is-desktop-guard .msg-toast,
html.is-desktop-guard .settings-panel {
  display: none !important;
}

html.is-desktop-guard #desktop-guard {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 32px 20px;
  overflow-y: auto;
}

.dg-card {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 40px 28px 32px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}

.dg-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 18px;
}

.dg-eyebrow {
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--orange-1);
  font-weight: 800;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.dg-title {
  font-size: 23px;
  font-weight: 800;
  color: var(--cream);
  line-height: 1.4;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

.dg-accent {
  background: linear-gradient(135deg, var(--orange-1), var(--orange-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dg-sub {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 24px;
}

.dg-qr-wrap {
  width: 168px;
  height: 168px;
  margin: 0 auto 14px;
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(253, 186, 116, 0.16), rgba(234, 88, 12, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
}

#dg-qrcode {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
}

#dg-qrcode img,
#dg-qrcode canvas {
  width: 100% !important;
  height: 100% !important;
}

.dg-url {
  font-family: var(--font-num);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin: 0 0 26px;
  word-break: break-all;
}

.dg-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dg-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 8px;
  font-size: 11.5px;
  color: var(--cream);
  line-height: 1.4;
}

.dg-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #1b0f06;
  font-family: var(--font-num);
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 메시지 시각 + 안읽음 표시 (카톡 스타일) ---------- */
/* 말풍선 자체가 아니라, 말풍선 바로 앞(내 메시지는 왼쪽 옆)에
   시각과 안읽음 표시를 담는 별도 영역을 둡니다 */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 100%; /* 폭을 명확히 고정해야 말풍선의 max-width(%)가 정확히 계산됩니다 */
}
.msg-row.mine {
  justify-content: flex-end;
}
.msg-row.theirs {
  justify-content: flex-start;
}

/* 말풍선이 이제 msg-row 안에 있으므로, 기존 .chat-bubble.mine/.theirs의
   align-self(원래는 chat-messages 기준 좌우 정렬용)가 row 안에서는
   세로 정렬을 어긋나게 만들 수 있어 이 부분만 무효화합니다 */
.msg-row .chat-bubble.mine,
.msg-row .chat-bubble.theirs {
  align-self: auto;
}

.msg-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.msg-time {
  font-size: 10px;
  font-family: var(--font-num);
  color: var(--muted-2);
  white-space: nowrap;
}

/* 안읽음 표시 — 오렌지빛 작은 탁구공. 상대가 읽으면 사라집니다 */
.msg-unread-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fdba74, var(--orange-2) 55%, var(--orange-3));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.msg-unread-dot[hidden] {
  display: none;
}

/* ---------- 메시지 도착 알림 배너 ---------- */
.msg-toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70; /* 설치 배너(60)보다 위, 데스크탑 안내(9999)보다는 아래 */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transform: translateY(-100%);
  transition: transform 0.25s cubic-bezier(0.34, 1.2, 0.4, 1);
}

.msg-toast[hidden] {
  display: none;
}

.msg-toast.show {
  transform: translateY(0);
}

.msg-toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.msg-toast-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.msg-toast-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--orange-1);
}

.msg-toast-body {
  font-size: 12.5px;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 음성 메시지 녹음 바 ---------- */
.voice-record-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.voice-record-bar[hidden] {
  display: none;
}

.voice-cancel-btn {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
}

.voice-record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: voice-record-pulse 1s ease-in-out infinite;
}

@keyframes voice-record-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.voice-record-hint {
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.voice-record-time {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
  flex: 1;
}

.voice-stop-btn {
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #1b0f06;
  font-size: 13px;
  font-weight: 700;
  border-radius: 12px;
  flex-shrink: 0;
}

/* ---------- 음성 메시지 말풍선 ---------- */
.chat-bubble-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 130px;
  cursor: default;
}

.voice-play-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  font-size: 13px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble.mine .voice-play-btn {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.chat-bubble.theirs .voice-play-btn {
  background: rgba(249, 115, 22, 0.18);
  color: var(--orange-1);
}

.voice-waveform {
  flex: 1;
  height: 18px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-waveform span {
  display: block;
  width: 2px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.55;
}

.voice-duration {
  font-family: var(--font-num);
  font-size: 11.5px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ---------- 사진 크게 보기 (라이트박스) ---------- */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 6, 3, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 12px;
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer img {
  max-width: 100%;
  max-height: 82vh;
  border-radius: 12px;
  object-fit: contain;
}

.image-viewer-hint {
  font-size: 12px;
  color: var(--muted-2);
  margin: 0;
}

/* ---------- 사진 롱프레스 액션 시트 (다운로드/삭제/취소) ---------- */
.image-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(10, 6, 3, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 14px 26px;
}

.image-action-sheet[hidden] {
  display: none;
}

.image-action-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
}

.image-action-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 14.5px;
  font-weight: 700;
}
.image-action-btn:hover {
  background: rgba(249, 115, 22, 0.12);
}

.image-action-danger {
  color: var(--danger);
}

.image-action-cancel {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- 설정 패널 (왼쪽에서 슬라이드) ---------- */
/* 메시지 목록/채팅 패널(.side-panel)은 오른쪽에서 열리므로, 설정은 반대쪽인
   왼쪽에서 열리도록 해서 두 패널이 서로 다른 종류의 화면이라는 걸 구분해줍니다.
   항목 수가 많아서 중앙 팝업보다 세로로 긴 패널 형태가 더 적합합니다. */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 25;
  width: 100%;
  max-width: 720px;
  height: 100%;
  height: 100dvh;
  background: var(--card-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

@media (max-width: 480px) {
  .settings-panel {
    max-width: 100%;
  }
}

.settings-panel.open {
  transform: translateX(0);
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.settings-panel-header span {
  font-size: 14px;
  font-weight: 800;
  color: var(--cream);
  letter-spacing: 0.03em;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 28px;
}

.settings-section-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  text-transform: uppercase;
  margin: 4px 0 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.settings-row-tight {
  margin-top: 14px;
}
.settings-row-label {
  font-size: 14px;
  color: var(--cream);
}
.settings-row-value {
  font-size: 13px;
  color: var(--muted);
}

.settings-hint {
  font-size: 11.5px;
  color: var(--muted-2);
  margin: 2px 0 0;
  line-height: 1.5;
}

.settings-divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.settings-action-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--cream);
  font-size: 14px;
  font-weight: 700;
  margin-top: 10px;
}
.settings-action-btn.settings-danger {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.35);
}
.settings-action-btn.settings-danger:hover {
  background: rgba(229, 72, 77, 0.12);
}

.settings-toggle {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  position: relative;
  padding: 0;
}
.settings-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: transform 0.18s ease, background 0.18s ease;
}
.settings-toggle.on {
  background: rgba(249, 115, 22, 0.18);
  border-color: rgba(249, 115, 22, 0.4);
}
.settings-toggle.on .settings-toggle-knob {
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  transform: translateX(20px);
}

.settings-segmented {
  display: flex;
  gap: 6px;
}
.settings-segment {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}
.settings-segment.active {
  background: linear-gradient(135deg, var(--orange-2), var(--orange-3));
  color: #1b0f06;
  border-color: transparent;
}

.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-slider-row input[type='range'] {
  flex: 1;
  accent-color: var(--orange-2);
}

.settings-preview-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(249, 115, 22, 0.15);
  border: 1px solid rgba(249, 115, 22, 0.32);
  color: var(--orange-1);
  font-size: 13px;
  flex-shrink: 0;
}
.settings-preview-btn:hover {
  background: rgba(249, 115, 22, 0.24);
}
