:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1f2329;
  --muted: #8a9099;
  --line: #e6e8ec;
  --mine: #2f6df6;
  --mine-ink: #ffffff;
  --other: #eef0f3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
}

/* ── 입장 게이트 ── */
.gate-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}
.gate h1 { margin: 0 0 4px; font-size: 24px; }
.gate .sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.gate input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
}
.gate button {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  border: 0;
  border-radius: 10px;
  background: var(--mine);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.gate .error {
  color: #d23f3f;
  font-size: 14px;
  margin: 0 0 12px;
}

/* ── 채팅방 ── */
.room {
  max-width: 720px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.room-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.room-head .title { font-weight: 700; }
.room-head .me { color: var(--muted); font-size: 13px; margin-left: auto; }
.room-head .logout {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 8px;
}
.room-head .enable-push {
  font-size: 13px;
  color: var(--mine);
  background: #eaf1ff;
  border: 1px solid #cfe0ff;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.room-head .enable-push[hidden] { display: none; }

.status {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 6px;
}
.status.warn { color: #c98a00; background: #fff7e6; }

.messages {
  list-style: none;
  margin: 0;
  padding: 14px 16px;
  flex: 1;
  overflow-y: auto;
}
.msg { margin-bottom: 12px; max-width: 78%; }
.msg .meta {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 3px;
}
.msg .who { font-size: 13px; font-weight: 600; color: #4a5160; }
.msg .time { font-size: 11px; color: var(--muted); }
.msg .bubble {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 14px;
  background: var(--other);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

/* 내 메시지 오른쪽 정렬 */
.msg.mine { margin-left: auto; text-align: right; }
.msg.mine .meta { justify-content: flex-end; }
.msg.mine .bubble {
  background: var(--mine);
  color: var(--mine-ink);
  text-align: left;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  font-size: 16px;
}
.composer button[type="submit"] {
  border: 0;
  border-radius: 22px;
  padding: 0 18px;
  background: var(--mine);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.composer .photo-btn {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

/* 사진 메시지 */
.msg .photo {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 14px;
  margin: 2px 0;
  cursor: pointer;
  object-fit: cover;
  background: var(--other);
}
.msg.mine .photo {
  margin-left: auto;
}

/* 라이트박스 (앱 내 이미지 뷰어) */
body.lb-open {
  overflow: hidden;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox[hidden] {
  display: none;
}
.lightbox-img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
  touch-action: none; /* 브라우저 기본 핀치/스크롤 끄고 직접 처리 */
  will-change: transform;
  cursor: zoom-in;
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  border-radius: 50%;
}
.lightbox-close {
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  font-size: 20px;
}
.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 34px;
}
.lightbox-nav.prev {
  left: 10px;
}
.lightbox-nav.next {
  right: 10px;
}
