/* =========================================================
   난장톡 — Design Tokens (오렌지톡 구조 기반, 색상만 분리)
   Palette: 차가운 먹색 배경 + 옥색(청록) 액션 컬러 + 도장(낙관) 전용 단청 주색
   Type: Pretendard(한글 본문) + Manrope(라틴/숫자) + Noto Serif KR(도장/타이틀)
   Signature: "도장(낙관)" 모티브 — 공연 상태 배지에 반복 사용
   ========================================================= */

:root {
  --bg: #12161b;
  --bg-soft: #1b2027;
  --card-bg: #1a1f26;
  --line: rgba(160, 210, 195, 0.14);

  --accent-1: #86e0c4; /* light */
  --accent-2: #24936f; /* mid */
  --accent-3: #176b52; /* deep */
  --vermillion: #b8272e; /* 도장/미확인 배지 전용 포인트 */

  --cream: #f2f6f4;
  --muted: #9db3ac;
  --muted-2: #71857f;

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

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

* { 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;
}

/* ---------- 홈 화면에 추가(설치) 안내 배너 ---------- */
.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(--accent-2), var(--accent-3));
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.install-banner[hidden] {
  display: none;
}

.install-banner-text {
  color: #ffffff;
  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: #ffffff;
  color: var(--accent-1);
}

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

/* ---------- 로고 입체(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);
}

.gate-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border: 2px solid var(--vermillion);
  border-radius: 10px;
  color: var(--vermillion);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  letter-spacing: 0.05em;
  transform: rotate(-3deg);
  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(--accent-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-role-select {
  display: flex;
  gap: 12px;
}
.gate-role-select[hidden] { display: none; }
.gate-role-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--cream);
  font-size: 14px;
  font-weight: 700;
}
.gate-role-btn:hover { border-color: var(--accent-2); }
.gate-role-icon { font-size: 30px; }

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gate-form[hidden] { display: none; }

#gate-nickname,
#gate-password,
#gate-member-password,
#gate-member-select {
  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;
  font-family: var(--font-kr);
  appearance: none;
  -webkit-appearance: none;
}
#gate-nickname:focus,
#gate-password:focus,
#gate-member-password:focus,
#gate-member-select:focus {
  border-color: var(--accent-2);
}
#gate-nickname::placeholder,
#gate-password::placeholder,
#gate-member-password::placeholder { color: var(--muted-2); }

.gate-back-btn {
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 4px 0;
}

.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(--accent-1);
  outline-offset: 2px;
}

.btn-primary {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
  color: #ffffff;
  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: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.header-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--vermillion);
  border-radius: 6px;
  color: var(--vermillion);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 9px;
  flex-shrink: 0;
}
.header-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.settings-pill {
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
}

.header-role {
  font-family: var(--font-num);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-1);
  background: rgba(36, 147, 111, 0.14);
  border: 1px solid rgba(36, 147, 111, 0.3);
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: auto;
}

.conn-note {
  position: fixed;
  bottom: 74px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted-2);
  margin: 0;
  padding: 0 24px;
  pointer-events: none;
  z-index: 5;
}

/* ---------- 메인 화면 레이아웃 (문의 / 공연 / 히스토리 탭) ---------- */
#main.screen {
  display: none;
  min-height: auto;
  height: 100dvh;
  padding: 0;
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}
#main.screen.active {
  display: flex;
  flex-direction: column;
}

.tab-content {
  flex: 1;
  min-height: 0;
  margin-top: 56px; /* call-header 높이만큼 */
  position: relative;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.tab-pane:not([hidden]) { display: flex; }

#tab-performances,
#tab-archive {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  padding-bottom: 90px;
}
#tab-performances[hidden],
#tab-archive[hidden] { display: none; }

.tab-bar {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px 12px;
  cursor: pointer;
  color: var(--muted-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}
.tab-btn .tab-icon { font-size: 19px; }
.tab-btn.active { color: var(--accent-1); }
.tab-btn[hidden] { display: none; }

.section-label {
  padding: 18px 18px 8px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 14px;
  color: var(--cream);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label .rule { flex: 1; height: 1px; background: var(--line); }

.empty-state {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- 도장(seal) 상태 배지 — 공연 상태 표시 ---------- */
.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid currentColor;
  border-radius: 4px;
  padding: 2px 9px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--vermillion);
  transform: rotate(-2deg);
  white-space: nowrap;
}
.seal.jade { color: var(--accent-1); }
.seal.grey { color: var(--muted-2); }

/* ---------- 공연 카드 ---------- */
.perf-card {
  margin: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.perf-card .poster {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--bg-soft);
  display: block;
}
.perf-card .poster.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  font-size: 12px;
}
.poster-wrap { position: relative; }
.poster-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.poster-overlay .coming-soon {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 22px;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.poster-overlay .coming-soon-sub {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-1);
  letter-spacing: 0.05em;
}
.perf-card .body { padding: 14px 16px 16px; }
.perf-card .status-row { margin-bottom: 8px; }
.perf-card .title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 17px;
  color: var(--cream);
  margin: 0 0 6px;
}
.perf-card .synopsis { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 10px; }
.perf-card .cast { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.perf-card .cast b { color: var(--cream); font-weight: 700; }
.perf-card .actions { display: flex; gap: 8px; }
.perf-card .actions button,
.perf-card .actions a {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--line);
}
.perf-card .btn-toss { background: var(--accent-2); color: #ffffff; border: none; }
.perf-card .btn-interpark { background: transparent; color: var(--cream); }

/* ---------- 히스토리 카드 ---------- */
.archive-card {
  display: flex;
  gap: 12px;
  margin: 0 16px 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.archive-card .poster {
  width: 76px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-soft);
  flex-shrink: 0;
}
.archive-card .info .year { font-size: 11px; color: var(--vermillion); font-weight: 700; }
.archive-card .info .title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  margin: 2px 0 5px;
  color: var(--cream);
}
.archive-card .info .synopsis { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0 0 4px; }
.archive-card .info .cast { font-size: 11.5px; color: var(--muted); }

/* ---------- 결제 모달 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 999;
}
.modal-overlay[hidden] { display: none; }
.modal-sheet {
  background: var(--card-bg);
  border: 1px solid var(--line);
  color: var(--cream);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}
.modal-sheet h2 { font-family: var(--font-display); margin: 0 0 4px; font-size: 18px; }
.modal-sheet p { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.modal-sheet .qr-box {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  min-height: 180px;
  color: var(--muted);
}
.modal-sheet .close-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--cream);
  font-size: 14px;
  cursor: pointer;
}

/* ---------- 호스트 전용 관리 UI (공연/히스토리 추가·수정·삭제) ---------- */
.host-add-btn {
  display: block;
  margin: 16px 16px 0;
  width: calc(100% - 32px);
  padding: 12px;
  background: transparent;
  border: 1.5px dashed var(--accent-2);
  border-radius: 12px;
  color: var(--accent-1);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.host-add-btn[hidden] { display: none; }

.host-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.host-actions button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  cursor: pointer;
}
.host-actions .host-delete-btn {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.35);
}
.archive-card { position: relative; }
.archive-card .host-actions { margin-top: 8px; }

/* ---------- 단원 명단 ---------- */
.roster-list { list-style: none; margin: 0; padding: 8px 16px 24px; }
.roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.roster-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-2);
  flex-shrink: 0;
}
.roster-dot.online {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(229, 72, 77, 0.6);
}
.roster-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-1);
  background: rgba(36, 147, 111, 0.14);
  border-radius: 999px;
  padding: 3px 9px;
  flex-shrink: 0;
}
.roster-name {
  flex: 1;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--cream);
}
.roster-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.roster-item-actions button {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  cursor: pointer;
}
.roster-item-actions .host-delete-btn { border-color: rgba(229, 72, 77, 0.35); }

/* 편집 폼 모달 */
.form-sheet { max-height: 88vh; overflow-y: auto; }
.form-sheet form { display: flex; flex-direction: column; gap: 12px; }
.form-sheet label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 700;
}
.form-sheet label.checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.form-sheet input[type="text"],
.form-sheet input[type="number"],
.form-sheet input[type="url"],
.form-sheet select,
.form-sheet textarea {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--cream);
  font-size: 14px;
  font-family: var(--font-kr);
}
.form-sheet textarea { resize: vertical; }
.form-poster-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 10px;
  background: var(--bg-soft);
}
.form-poster-preview[hidden] { display: none; }
.form-error { color: var(--danger); font-size: 12.5px; margin: 0; min-height: 16px; }
.form-btn-row { display: flex; gap: 8px; margin-top: 4px; }
.form-btn-row .btn-primary,
.form-btn-row .close-btn { margin: 0; }

/* ---------- 접속자 목록 / 채팅 패널 ---------- */
.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  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;
}

.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-msg-btn {
  background: none;
  color: var(--accent-1);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 8px;
}
.people-msg-btn:hover {
  background: rgba(36, 147, 111, 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(36, 147, 111, 0.15);
  border-color: var(--accent-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(--accent-2), var(--accent-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(--accent-1);
  font-size: 16px;
  padding: 0 12px;
  border-radius: 12px;
  flex-shrink: 0; /* 좁은 화면에서도 이 버튼들은 절대 찌그러지지 않게 고정 */
}
.chat-image-btn:hover {
  background: rgba(36, 147, 111, 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(--accent-2);
}
#chat-input::placeholder {
  color: var(--muted-2);
}

.chat-send {
  padding: 12px 16px;
  background: #2fb08a; /* 더 밝은 옥색 */
  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(36, 147, 111, 0.12);
  border-color: var(--accent-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(134, 224, 196, 0.18), rgba(23, 107, 82, 0.14));
  color: var(--accent-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(36, 147, 111, 0.12);
  border: 1px solid rgba(36, 147, 111, 0.32);
  color: var(--accent-1);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.settings-pill:hover {
  background: rgba(36, 147, 111, 0.2);
}

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

/* PC로 접속한 경우(html.is-desktop-guard)에는 배경/모든 화면을 숨기고
   안내 화면만 보여줍니다 */
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-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border: 2px solid var(--vermillion);
  border-radius: 10px;
  color: var(--vermillion);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 15px;
  transform: rotate(-3deg);
}

.dg-eyebrow {
  font-family: var(--font-num);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent-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(--accent-1), var(--accent-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(134, 224, 196, 0.16), rgba(23, 107, 82, 0.12));
  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(--accent-2), var(--accent-3));
  color: #ffffff;
  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%, #86e0c4, var(--accent-2) 55%, var(--accent-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(--accent-1);
}

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

/* ---------- 사진 크게 보기 (라이트박스) ---------- */
.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(36, 147, 111, 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(36, 147, 111, 0.18);
  border-color: rgba(36, 147, 111, 0.4);
}
.settings-toggle.on .settings-toggle-knob {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-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(--accent-2), var(--accent-3));
  color: #ffffff;
  border-color: transparent;
}

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

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