/* 깔끔한 플랫·각진 채팅 UI — 둥근 모서리 없음, 얇은 회색 선 + 흰 배경 + 포인트 색. */
* { box-sizing: border-box; }

/* WordPress 테마 CSS 침범 방지 — 위젯 내부 폼요소/요소 초기화 */
#chat-app, #chat-app * { box-sizing: border-box; }
#chat-app input,
#chat-app button {
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  line-height: normal;
  min-height: 0;
  height: auto;
  box-shadow: none;
  background-image: none;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: normal;
  text-transform: none;
  width: auto;
}
#chat-app ul, #chat-app li { list-style: none; margin: 0; padding: 0; }

#chat-app {
  --line: #d7dbe0;        /* 헤어라인 테두리 */
  --line-soft: #edeff2;   /* 더 옅은 구분선 */
  --text: #1f2328;
  --muted: #8a9099;
  --accent: #2f6fed;      /* 포인트 색 */
  --panel: #fafbfc;       /* 아주 옅은 배경 (회색98 아님) */
  --self-bg: #eef4ff;
  --hover: #f4f6f8;
  --admin: #e0245e;

  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  background: #fff;
  width: 100%;
  max-width: 640px;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 상단바 — 좁은 폭에서도 한 줄 유지: 제목은 말줄임, 카운트 칩은 줄바꿈 금지 */
#chat-app .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
/* 제목: 이름 부분만 말줄임되고 버전(v1.x.x)은 항상 보이게 분리 */
#chat-app .topbar .title { display: inline-flex; align-items: baseline; gap: 5px; font-size: 15px; font-weight: 700; min-width: 0; white-space: nowrap; }
#chat-app .topbar .title .tname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#chat-app .topbar .ver { font-size: 12px; font-weight: 600; color: var(--accent); flex: none; }
#chat-app .topbar .count-wrap { font-size: 12.5px; color: var(--muted); white-space: nowrap; flex: none; }
#chat-app .topbar #usercount { font-weight: 700; color: var(--accent); }

/* 공지 (우측 X 닫기 / 10초 후 위로 슬라이드하며 닫힘) */
#chat-app .announce {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffbe6;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid #f4c430;
  padding: 6px 8px 6px 14px;
  font-size: 12.5px;
  color: #6b5900;
  overflow: hidden;
  max-height: 80px;
  transition: transform .35s ease, opacity .35s ease, max-height .35s ease,
    padding .35s ease, border-bottom-width .35s ease;
}
#chat-app .announce .announce-text { flex: 1; white-space: pre-wrap; min-width: 0; }
#chat-app .announce .announce-close {
  flex: none;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: #b59a00;
  padding: 0 4px;
}
#chat-app .announce .announce-close:hover { color: #6b5900; }
#chat-app .announce.slideup {
  transform: translateY(-100%);
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-width: 0;
}
#chat-app .hidden { display: none; }

/* 아이디 앞 아이콘 (hera.pet 식) */
#chat-app .nickicon {
  height: 15px;
  width: auto;              /* 레벨 배지 등 가로형 이미지도 비율 유지 */
  max-width: 44px;
  object-fit: contain;
  vertical-align: -3px;
  margin-right: 4px;
}
#chat-app .nickicon-emoji { margin-right: 3px; }
#chat-app .userlist li .nickicon { height: 16px; }

/* 본문 */
#chat-app .main { display: flex; height: 320px; min-height: 0; }
/* min-height:0 필수: 컴팩트(세로 배치) 모드에서 이게 없으면 flex 아이템이 내용 크기만큼
   늘어나 메시지가 스크롤되지 않고 채팅 영역 밖으로 넘친다. */
#chat-app .chatpane { flex: 1; min-width: 0; min-height: 0; display: flex; }
#chat-app .messages { flex: 1; overflow-y: auto; padding: 10px 14px; min-width: 0; min-height: 0; font-size: 12.5px; }
#chat-app .userpane {
  width: 172px;
  flex: none;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#chat-app .userpane-head {
  padding: 7px 14px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
#chat-app .userlist { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
#chat-app .userlist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  font-weight: 600;
}
#chat-app .userlist li:hover { background: var(--hover); }
#chat-app .userlist li.me { background: var(--self-bg); }
#chat-app .userlist li .dot { width: 8px; height: 8px; flex: none; } /* 각진 색상 스와치 */
#chat-app .userlist li .uname { overflow: hidden; text-overflow: ellipsis; }
#chat-app .userlist li .badge { margin-left: auto; font-size: 10px; color: var(--muted); font-weight: 600; }
/* 관전자(게스트) 요약 행: 클릭 불가, 옅은 색 */
#chat-app .userlist li.spec { cursor: default; color: var(--muted); font-weight: 600; }
#chat-app .userlist li.spec:hover { background: none; }

/* 좁은 폭(사이드바/모바일 임베드) 대응.
   폭이 좁으면 고정폭 접속자 패널(172px)이 채팅 영역을 다 먹어 대화 확인이 불가능해지므로,
   패널을 숨기고 상단 "접속자 N ▾" 클릭 시 채팅 위쪽에 가로 칩 목록이 아코디언으로 펼쳐진다.
   (오버레이가 아니라 본문을 아래로 밀기 때문에 대화를 가리지 않는다) */
#chat-app.is-compact .topbar .count-wrap {
  cursor: pointer;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: #fff;
  user-select: none;
}
#chat-app.is-compact .topbar .count-wrap:hover { background: var(--hover); }
#chat-app.is-compact .topbar .count-wrap::after { content: " ▾"; color: var(--muted); font-size: 10px; }
#chat-app.is-compact.show-users .topbar .count-wrap::after { content: " ▴"; }
#chat-app.is-compact .main { flex-direction: column; }
#chat-app.is-compact .userpane { display: none; }
#chat-app.is-compact.show-users .userpane {
  display: flex;
  order: -1;               /* 채팅 위로 */
  width: 100%;
  flex: none;
  max-height: 96px;
  border-left: 0;
  border-bottom: 1px solid var(--line);
}
#chat-app.is-compact.show-users .userlist {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 5px;
  padding: 8px 10px;
  overflow-y: auto;
}
#chat-app.is-compact.show-users .userlist li {
  width: auto;
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  gap: 5px;
}
#chat-app.is-compact.show-users .userlist li.me { background: var(--self-bg); border-color: #c9d8f5; }
#chat-app.is-compact.show-users .userlist li .badge { margin-left: 2px; }

/* 메시지 라인 */
#chat-app .messages .line { padding: 1px 0; word-break: break-word; }
#chat-app .messages .time { color: #bcc1c8; font-size: 11px; margin-right: 5px; }
#chat-app .messages .nick { font-weight: 700; cursor: pointer; }
#chat-app .messages .nick:hover { text-decoration: underline; }
#chat-app .messages .sep { color: var(--muted); margin-right: 3px; }
#chat-app .messages .system { color: var(--muted); font-size: 12px; }
#chat-app .messages .whisper { color: #9b30d0; }
#chat-app .messages .report { color: var(--admin); font-weight: 700; }
#chat-app .messages .hist { opacity: .5; }
/* 관리자: 채팅 라인에 마우스 올리면 아주 연한 회색 → 우클릭으로 삭제 */
#chat-app.is-admin .messages .line[data-mid] { cursor: context-menu; }
#chat-app.is-admin .messages .line[data-mid]:hover { background: #f4f4f5; }
#chat-app .messages .histbar {
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  margin: 6px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 2px 0;
}

/* 하단 입력 — 심플: 상단 구분선 하나만, 아이디 박스·입력칸 테두리 없음 */
#chat-app .inputbar {
  display: flex;
  align-items: stretch;
  padding: 0;
  border-top: 1px solid var(--line);
  height: 40px;
}
#chat-app .myname { display: none; }
#chat-app .input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  padding: 0 14px;
  font: inherit;
  background: #fff;
}
#chat-app .input:focus { box-shadow: none; }
/* 읽기 전용 관전자(비로그인): 내 이름 자리는 회색 "게스트", 입력칸도 옅게 */
#chat-app.is-readonly .myname { color: var(--muted); font-weight: 600; }
#chat-app.is-readonly .input { background: var(--panel); color: var(--muted); }

/* 닉네임 클릭 메뉴 */
#chat-app .usermenu {
  position: fixed;
  z-index: 1000;
  min-width: 136px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
  font-size: 13px;
}
#chat-app .usermenu .mhead {
  padding: 7px 12px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
#chat-app .usermenu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
#chat-app .usermenu button:last-child { border-bottom: 0; }
#chat-app .usermenu button:hover { background: var(--hover); }
#chat-app .usermenu button.danger { color: var(--admin); }
#chat-app .usermenu .mgroup { border-top: 1px solid var(--line); }
#chat-app .usermenu .mgroup-label { padding: 4px 12px; font-size: 10px; color: var(--muted); font-weight: 700; }

/* 강제 종료(중복 접속) 오버레이 */
#chat-app .overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
#chat-app .overlay .overlay-box {
  border: 1px solid var(--line);
  border-top: 3px solid var(--admin);
  background: #fff;
  padding: 22px 26px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
}
