/* Accord — Discord 스타일 다크 테마
   순수 그레이 계열 배경(#1e1f22/#2b2d31/#313338) + Blurple 포인트, 8px 라운딩, 플랫 카드 */

:root {
  color-scheme: dark;
  --bg-deepest: #1e1f22;
  --bg-surface: #2b2d31;
  --bg-base: #313338;
  --bg-elevated: #383a40;
  --bg-input: #1e1f22;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #dbdee1;
  --heading: #f2f3f5;
  --muted: #949ba4;
  --blurple: #5865f2;
  --blurple-strong: #4752c4;
  --green: #23a559;
  --danger: #da373c;
  --danger-strong: #a12828;
  --warning: #f0b232;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

/* display를 지정한 요소(.switch 등)가 hidden 속성을 덮어쓰지 못하게 한다 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 380px;
  min-height: 100vh;
  color: var(--text);
  font-family:
    "gg sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 14px;
  background: var(--bg-deepest);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12) padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none; /* 맥 네이티브(Aqua) 버튼 렌더링 방지 → 아이콘 늘어남/중심 어긋남 해결 */
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--blurple);
  outline-offset: 2px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: var(--bg-input);
  color: var(--text);
  outline: none;
}

input[type="range"] {
  padding: 0;
  border: 0;
  min-height: 24px;
  background: transparent;
  accent-color: var(--blurple);
}

/* 체크박스·라디오: 위 전역 input 규칙(width:100%·min-height:38px·배경·테두리)이 먹어
   거대한 사각형으로 깨지므로 네이티브 크기로 되돌린다. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  min-width: 0;
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  accent-color: var(--blurple);
  cursor: pointer;
}

select {
  appearance: none;
}

input:focus,
select:focus {
  border-color: var(--blurple);
}

h1,
h2,
h3,
p,
dl {
  margin: 0;
}

h1 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--heading);
}

h2 {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--heading);
}

h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 12px 12px;
}

/* 채팅/메모를 열면 페이지 전체가 늘어나지 않고 패널 안에서 스크롤되도록
   앱 높이를 화면에 고정한다(통화 UI에는 영향 없음). */
body.chat-open .app,
body.memo-open .app,
body.draw-open .app,
body.log-open .app,
body.dm-open .app {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

/* ─── 상단 바 ─────────────────────────────── */

.topbar,
.top-actions,
.section-head,
.call-head,
.room-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar {
  min-height: 56px;
  padding: 8px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  overflow: hidden;
}
.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  color: var(--muted);
  background: var(--bg-surface);
  font-size: 13px;
  white-space: nowrap;
}
.status.clickable { cursor: pointer; }
.status.clickable:hover { background: var(--bg-elevated); }

.status span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
}

.status[data-tone="good"] span {
  background: var(--green);
}

.status[data-tone="bad"] span {
  background: var(--danger);
}

/* ─── 버튼 ────────────────────────────────── */

.primary {
  background: var(--blurple);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--blurple-strong);
}

.secondary,
.ghost {
  background: var(--bg-elevated);
  color: var(--text);
}

.secondary:hover:not(:disabled),
.ghost:hover:not(:disabled) {
  background: #45474e;
  color: var(--heading);
}

.ghost {
  background: transparent;
  color: var(--muted);
}

.ghost.small {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

/* 상단 막대 아이콘 토글(방/멤버 목록 여닫기).
   전역 button min-height:36px / padding:0 14px 상속을 리셋해 정사각 유지. */
.icon-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  flex: none;
  border-radius: var(--radius-sm);
}
.icon-toggle svg {
  display: block;
}
.icon-toggle[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--heading);
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover:not(:disabled) {
  background: var(--danger-strong);
}

/* ─── 레이아웃 ────────────────────────────── */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 56px var(--rooms-w, 232px) minmax(0, 1fr) var(--members-w, 208px);
  gap: 6px;
  align-items: stretch;
  min-height: 0;
  position: relative;
}

/* 멤버 리스트가 숨겨지거나(채널 없음) 사용자가 접으면 4번째 열을 접는다 */
.layout:has(.member-list[hidden]),
.layout.members-collapsed {
  grid-template-columns: 56px var(--rooms-w, 232px) minmax(0, 1fr);
}

/* 방 목록을 접으면 2번째 열을 접는다 */
.layout.rooms-collapsed {
  grid-template-columns: 56px minmax(0, 1fr) var(--members-w, 208px);
}
.layout.rooms-collapsed:has(.member-list[hidden]),
.layout.rooms-collapsed.members-collapsed {
  grid-template-columns: 56px minmax(0, 1fr);
}
.layout.rooms-collapsed .channel-panel {
  display: none;
}
.layout.members-collapsed .member-list {
  display: none;
}

/* ─── 사이드바 폭 조절 핸들 ───────────────────────────── */
.layout-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  z-index: 6;
  cursor: col-resize;
  touch-action: none;
}
.layout-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.12s ease;
}
.layout-resize-handle:hover::before,
.layout-resize-handle.dragging::before {
  background: var(--blurple, #5865f2);
}
body.resizing-layout {
  cursor: col-resize;
  user-select: none;
}
body.resizing-layout * {
  cursor: col-resize !important;
}
.rooms-resize-handle {
  left: calc(62px + var(--rooms-w, 232px) - 4px);
}
.members-resize-handle {
  right: calc(var(--members-w, 208px) - 4px);
}
.layout.rooms-collapsed .rooms-resize-handle,
.layout.members-collapsed .members-resize-handle,
.layout:has(.member-list[hidden]) .members-resize-handle,
body.dm-open .layout-resize-handle,
body.focus-mode .layout-resize-handle {
  display: none;
}

/* ─── 집중모드 ───────────────────────────── */
/* 채팅 · 메모장 · 그림판을 화면 전체로 펼치고 사이드/상단 UI를 모두 숨긴다.
   상단에는 제목과 "집중모드 나가기"만 남는다. */
.focus-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.focus-bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

body.focus-mode .focus-bar {
  display: flex;
}

body.focus-mode .topbar {
  display: none;
}

body.focus-mode .app {
  max-width: none;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 0 8px 8px;
}

body.focus-mode .channel-rail,
body.focus-mode .channel-panel,
body.focus-mode .member-list,
body.focus-mode .dm-panel {
  display: none !important;
}

body.focus-mode .layout {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0;
}

/* 패널 헤더의 집중모드 아이콘 버튼 */
.focus-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 0; /* 전역 button min-height:36px 상속 방지 */
  padding: 0;    /* 전역 button padding 상속 방지 */
  flex: none;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--muted);
  cursor: pointer;
}

.focus-btn:hover {
  background: var(--line-strong);
  color: var(--heading);
}

.chat-head .focus-btn {
  margin-left: auto;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 14px;
}

.main-panel,
.main-empty {
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  padding: 14px;
}

.main-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* 통화 전에는 오른쪽에 아무 UI도 띄우지 않는다 */
body:not(.in-call) .main-panel {
  display: none;
}

body.in-call .main-empty {
  display: none;
}

.main-empty {
  display: grid;
  place-content: center;
  gap: 12px;
  justify-items: center;
  color: rgba(148, 155, 164, 0.5);
  font-size: 13px;
}

.main-empty-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(148, 155, 164, 0.4);
  font-size: 28px;
  font-weight: 800;
}

/* ─── 채팅방 ─────────────────────────────── */
/* 채팅을 열면 채팅 패널이 main 열을 차지하고 통화/빈 화면은 감춘다(그리드 열 개수 유지) */
.chat-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
body.chat-open .chat-panel {
  display: flex;
}
body.chat-open .main-panel,
body.chat-open .main-empty,
body.chat-open .memo-panel,
body.chat-open .draw-panel,
body.chat-open .log-panel {
  display: none !important;
}

.chat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.chat-title-icon {
  color: var(--muted);
  font-size: 20px;
  font-weight: 700;
}
.chat-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
}
.chat-messages {
  display: flex;
  flex-direction: column;
}
.chat-loading,
.chat-empty {
  padding: 24px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.chat-group {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 4px 0;
  margin-top: 8px;
}
.chat-avatar {
  width: 40px;
  height: 40px;
  margin-top: 2px;
  flex-shrink: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
}
.chat-group-body {
  min-width: 0;
}
.chat-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.chat-msg-name {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
}
.chat-msg-time {
  color: var(--muted);
  font-size: 11px;
}
.chat-msg-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* 채팅 인라인 마크다운 */
.chat-msg-text code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-elevated);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}
.chat-msg-text .chat-code {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: pre;
}
.chat-msg-text .chat-code code {
  padding: 0;
  background: none;
  font-size: 12.5px;
  line-height: 1.5;
}
.chat-msg-text a {
  color: #00a8fc;
  text-decoration: none;
}
.chat-msg-text a:hover { text-decoration: underline; }
.chat-msg-text strong { color: var(--heading); font-weight: 700; }
.chat-msg-text del { color: var(--muted); }
.chat-msg-edited { color: var(--muted); font-size: 11px; user-select: none; }

/* 메시지 인라인 편집기 */
.chat-edit-box { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.chat-edit-input {
  width: 100%;
  resize: none;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
.chat-edit-input:focus { border-color: var(--blurple); }
.chat-edit-actions { display: flex; align-items: center; gap: 8px; }
.chat-edit-hint { color: var(--muted); font-size: 11px; margin-right: auto; }

/* 메시지 hover 하이라이트 + 삭제 액션(디스코드식) */
.chat-msg {
  position: relative;
  border-radius: 4px;
  margin: 0 -8px;
  padding: 1px 8px;
}
.chat-msg:hover {
  background: rgba(255, 255, 255, 0.035);
}
.chat-msg-actions {
  position: absolute;
  top: -12px;
  right: 6px;
  display: none;
  gap: 2px;
  padding: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.chat-msg:hover .chat-msg-actions {
  display: flex;
}
.chat-act {
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.chat-act:hover {
  background: var(--bg-elevated);
  color: var(--text);
}
.chat-act.trash {
  display: none;
}
.chat-act.trash:hover {
  color: var(--danger);
}
/* Shift를 누르면 즉시삭제(🗑)만 노출 */
body.chat-shift .chat-act.more {
  display: none;
}
body.chat-shift .chat-act.trash {
  display: grid;
}

.chat-msg-menu {
  position: fixed;
  z-index: 100;
  min-width: 130px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.chat-msg-menu-item {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.chat-msg-menu-item.danger {
  color: var(--danger);
}
.chat-msg-menu-item:hover {
  background: var(--danger);
  color: #fff;
}
.chat-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.chat-image-link {
  display: inline-block;
  max-width: 360px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chat-image {
  display: block;
  max-width: 360px;
  max-height: 300px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.chat-file:hover {
  border-color: var(--line-strong);
}
.chat-file-icon {
  font-size: 22px;
}
.chat-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chat-file-info b {
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-file-info em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.chat-typing {
  height: 18px;
  flex-shrink: 0;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
}

.chat-composer {
  position: relative;
  flex-shrink: 0;
  padding: 6px 16px 14px;
}
.chat-mention-menu {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(100% - 2px);
  z-index: 12;
  max-height: 260px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.chat-mention-option {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.chat-mention-option:hover,
.chat-mention-option.active { background: var(--blurple); color: #fff; }
.chat-mention-option .account-avatar.small { width: 28px; height: 28px; flex: none; }
.chat-mention-option .account-avatar.small.special {
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--bg-input);
}
.chat-mention-option-label { min-width: 0; display: flex; flex-direction: column; }
.chat-mention-option-label b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-mention-option-label em { color: currentColor; font-size: 11px; font-style: normal; opacity: 0.65; }
.chat-mention {
  display: inline;
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(88, 101, 242, 0.28);
  color: #c9cdfb;
  font-weight: 600;
  cursor: pointer;
}
.chat-mention:hover { background: var(--blurple); color: #fff; }
.chat-mention-special {
  background: rgba(240, 178, 50, 0.28);
  color: #f3c869;
  cursor: default;
}
.chat-msg.mentioned {
  margin-left: -6px;
  padding-left: 4px;
  border-left: 2px solid var(--warning);
  background: rgba(240, 178, 50, 0.08);
}
.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chat-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
}
.chat-attach-chip.has-thumb {
  padding-left: 6px;
}
.chat-attach-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-attach-chip.uploading {
  opacity: 0.7;
}
.chat-attach-remove {
  min-height: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.chat-attach-remove:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.chat-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
.chat-attach-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  flex: 0 0 32px;
  align-self: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
/* 텍스트 '+' 글리프는 폰트마다 중심이 어긋나 삐딱하게 보였다.
   기하학적으로 완벽히 대칭인 SVG 아이콘으로 교체 → 어떤 폰트/OS에서도 정중앙 */
.chat-attach-icon {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}
.chat-attach-button:hover {
  color: var(--text);
}
#chatInput {
  flex: 1;
  min-width: 0;
  max-height: 160px;
  padding: 7px 4px;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.chat-send-button {
  flex-shrink: 0;
  align-self: stretch;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--blurple);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.chat-send-button:hover {
  background: var(--blurple-strong);
}
.chat-emoji-button {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-height: 32px;
  align-self: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.chat-emoji-button:hover {
  background: var(--bg-elevated);
}
.chat-composer-hint {
  margin: 6px 2px 0;
  min-height: 14px;
  color: var(--warning);
  font-size: 12px;
}

.chat-drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--blurple);
  border-radius: var(--radius-lg);
  background: rgba(88, 101, 242, 0.12);
  pointer-events: none;
}
.chat-drop-inner {
  color: var(--heading);
  font-size: 15px;
  font-weight: 600;
}

/* 방 목록 안 읽음 배지 */
.room-unread {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.room-unread.mention { background: var(--warning); color: #18191c; }

/* ─── 공동 메모장 ─────────────────────────── */
.memo-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
body.memo-open .memo-panel {
  display: flex;
}
body.memo-open .main-panel,
body.memo-open .main-empty,
body.memo-open .chat-panel,
body.memo-open .draw-panel,
body.memo-open .log-panel {
  display: none !important;
}

.memo-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap; /* 좁은 창(창모드)에서 툴바가 글자 세로쪼개짐 없이 줄바꿈되도록 */
  row-gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.memo-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.memo-title-icon {
  font-size: 16px;
}
.memo-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.memo-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  row-gap: 8px;
  margin-left: auto;
  flex-wrap: wrap; /* 폭이 모자라면 도구 묶음이 통째로 다음 줄로 내려간다(쪼개짐 방지) */
  justify-content: flex-end;
}
.memo-status {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.memo-status.ok {
  color: var(--green);
}
.memo-status.bad {
  color: var(--danger);
}
.memo-view-toggle {
  display: inline-flex;
  flex: none;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.memo-view-btn {
  min-height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap; /* '나란히/편집/미리보기' 글자가 세로로 쪼개지지 않게 */
  cursor: pointer;
}
.memo-view-btn.active {
  background: var(--bg-elevated);
  color: var(--heading);
}

/* 글꼴·글자색 도구 (모든 참가자에게 공유) */
.memo-tools {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
}
.memo-tools.disabled {
  opacity: 0.45;
  pointer-events: none;
}
.memo-font-select {
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 0;
}
.memo-font-manage {
  flex: none;
  height: 28px;
  min-height: 0;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.memo-font-manage:hover {
  background: var(--bg-elevated);
  color: var(--heading);
}
.memo-color-tools {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
}
.memo-color-btn {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: var(--sw, #888);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.memo-color-btn:hover {
  transform: scale(1.12);
}
.memo-color-btn.custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(#f23f43, #f0b232, #23a559, #00a8fc, #eb459e, #f23f43);
}
.memo-color-custom-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bg-base);
}
.memo-color-btn.custom input[type="color"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  cursor: pointer;
}

.memo-remote-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 8px 16px;
  background: rgba(240, 178, 50, 0.12);
  border-bottom: 1px solid var(--line);
  color: var(--warning);
  font-size: 12px;
}
.memo-remote-notice span {
  flex: 1;
}

.memo-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  background: var(--line);
}
.memo-body.view-edit {
  grid-template-columns: minmax(0, 1fr);
}
.memo-body.view-edit .memo-preview {
  display: none;
}
.memo-body.view-preview {
  grid-template-columns: minmax(0, 1fr);
}
.memo-body.view-preview .memo-editor-wrap {
  display: none;
}
.memo-body.view-live {
  grid-template-columns: minmax(0, 1fr);
}
.memo-body.view-live .memo-preview {
  display: none;
}
.memo-editor-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-base);
}
.memo-editor {
  width: 100%;
  height: 100%;
  min-width: 0;
  --memo-font: var(--font, system-ui, sans-serif);
  --memo-weight: 400;
  --memo-size: 13px;
}
.memo-editor .cm-editor {
  height: 100%;
  background: var(--bg-base);
  color: var(--text);
  font-family: var(--memo-font);
  font-size: var(--memo-size);
  font-weight: var(--memo-weight);
}
.memo-editor .cm-editor.cm-focused {
  outline: none;
}
.memo-editor .cm-cursor { border-left-color: var(--text); }
.memo-editor .cm-scroller {
  overflow: auto;
  line-height: 1.6;
  font-family: inherit;
}
.memo-editor .cm-content {
  padding: 16px 18px;
  caret-color: var(--text);
}
.memo-editor .cm-line {
  padding: 0;
}
.memo-editor .cm-gutters {
  min-width: 38px;
  border-right: 1px solid var(--line);
  background: var(--bg-base);
  color: var(--muted);
}
/* 접기 화살표는 줄번호 옆(거터)이 아니라 cm-live-fold(접히는 문장 바로 왼쪽, 인라인)로만 표시한다. */
.memo-editor .cm-foldGutter {
  display: none !important; /* CM6 baseTheme의 .cm-gutter{display:flex !important;}를 이겨야 함 */
}
.memo-editor .cm-activeLine,
.memo-editor .cm-activeLineGutter {
  background: rgba(255, 255, 255, 0.025);
}
.memo-editor .cm-selectionBackground,
.memo-editor .cm-content ::selection {
  background: rgba(240, 178, 50, 0.28) !important;
}
.memo-editor[data-memo-mode="live"] .cm-activeLine {
  background: transparent;
}
.memo-editor .cm-live-heading {
  font-weight: 750;
  line-height: 1.3;
  padding-top: 0.18em;
  padding-bottom: 0.08em;
}
.memo-editor .cm-live-h1 { font-size: 1.75em; }
.memo-editor .cm-live-h2 { font-size: 1.5em; }
.memo-editor .cm-live-h3 { font-size: 1.3em; }
.memo-editor .cm-live-h4 { font-size: 1.15em; }
.memo-editor .cm-live-h5 { font-size: 1.05em; }
.memo-editor .cm-live-h6 { font-size: 1em; color: var(--muted); }
.memo-editor .cm-live-strong { font-weight: 750; color: var(--memo-color-strong, inherit); }
.memo-editor .cm-live-em { font-style: italic; color: var(--memo-color-em, inherit); }
.memo-editor .cm-live-strong .cm-live-em,
.memo-editor .cm-live-em .cm-live-strong { color: var(--memo-color-strongem, inherit); }
.memo-editor .cm-live-strike { text-decoration: line-through; color: var(--muted); }
.memo-editor .cm-live-inline-code {
  padding: 0.08em 0.28em;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--warning);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
.memo-editor .cm-live-link {
  color: var(--blurple);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.memo-editor .cm-live-quote {
  border-left: 3px solid var(--warning);
  padding-left: 10px;
  color: var(--muted);
}
.memo-editor .cm-live-code-block {
  padding: 0 10px;
  background: var(--bg-input);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.memo-editor .cm-live-code-fence {
  height: 0;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}
.memo-editor .cm-live-bullet {
  display: inline-block;
  min-width: 1em;
  color: var(--memo-color-marker, var(--warning));
  text-align: center;
}
.memo-editor .cm-live-check {
  width: 14px;
  height: 14px;
  margin: 0 5px 0 1px;
  accent-color: var(--memo-color-marker, var(--warning));
  vertical-align: -2px;
}
.memo-editor .cm-live-task-done { color: var(--muted); text-decoration: line-through; }
/* 마커 왼쪽 여백에 띄운다. 흐름 안에 두면 숫자와 겹치고, 전역 button min-height 가 줄 높이까지 늘린다. */
.memo-editor .cm-live-fold {
  position: absolute;
  width: 14px;
  height: 16px;
  min-height: 0;
  margin-left: -15px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}
.memo-editor .cm-live-fold::before { content: "▾"; }
.memo-editor .cm-live-fold.collapsed::before { content: "▸"; }
.memo-editor .cm-live-rule {
  display: inline-block;
  width: 100%;
  border-top: 1px solid var(--line-strong);
  vertical-align: middle;
}
.memo-editor .cm-memo-remote-cursor {
  position: relative;
  display: inline-block;
  width: 0;
  height: 1lh;
  border-left: 2px solid var(--memo-cursor-color);
  vertical-align: text-bottom;
  pointer-events: none;
  z-index: 4;
}
.memo-editor .cm-memo-remote-label {
  position: absolute;
  left: -2px;
  bottom: 100%;
  padding: 1px 5px;
  border-radius: 4px 4px 4px 0;
  background: var(--memo-cursor-color);
  color: #fff;
  font-family: var(--font, sans-serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}
.memo-editor .cm-memo-remote-selection {
  background: color-mix(in srgb, var(--memo-cursor-color) 24%, transparent);
}
/* 자동완성 팝업: CM6 기본 테마가 밝은 배경 + 파란 선택줄 + 🔑 아이콘이라 앱 UI 와 따로 놀았다.
   CM6 baseTheme(.ͼx.cm-light …)과 특이도가 같거나 높아야 이긴다(.cm-editor 를 한 단계 더 씀). */
.memo-editor .cm-editor .cm-tooltip {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
}
.memo-editor .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul {
  padding: 4px;
  font-family: "gg sans", Inter, system-ui, sans-serif; /* 편집기 글꼴이 아니라 앱 UI 글꼴(body)로 */
  font-size: 13px;
}
.memo-editor .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li {
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  line-height: 1.5;
}
.memo-editor .cm-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li[aria-selected] {
  background: var(--blurple);
  color: #fff;
}
.memo-editor .cm-editor .cm-completionIcon { display: none; }
.memo-editor .cm-editor .cm-completionMatchedText { text-decoration: none; font-weight: 700; }
.memo-editor .cm-editor .cm-completionDetail { margin-left: 0.6em; color: var(--muted); font-style: normal; }
.memo-editor .cm-editor li[aria-selected] .cm-completionDetail { color: rgba(255, 255, 255, 0.72); }
.memo-preview {
  min-width: 0;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--bg-base);
}
/* 미리보기는 편집기 줄과 촘촘히 맞도록 문단·목록 간격을 좁힌다. */
.memo-preview.markdown-body { line-height: 1.5; }
.memo-preview.markdown-body p { margin: 0.1em 0; }
.memo-preview.markdown-body ul,
.memo-preview.markdown-body ol { margin: 0.15em 0; }
.memo-preview.markdown-body li { margin: 0.05em 0; }
.memo-preview.markdown-body h1,
.memo-preview.markdown-body h2,
.memo-preview.markdown-body h3,
.memo-preview.markdown-body h4,
.memo-preview.markdown-body h5,
.memo-preview.markdown-body h6 { margin: 0.6em 0 0.25em; }
.memo-preview.markdown-body blockquote { margin: 0.25em 0; }

/* ─── 공동 그림판 ─────────────────────────── */
.draw-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
body.draw-open .draw-panel {
  display: flex;
}
body.draw-open .main-panel,
body.draw-open .main-empty,
body.draw-open .chat-panel,
body.draw-open .memo-panel,
body.draw-open .log-panel {
  display: none !important;
}

.draw-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.draw-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.draw-title-icon { font-size: 16px; }
.draw-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draw-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}
.draw-tool-group {
  display: inline-flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.draw-tool-btn {
  min-width: 32px;
  min-height: 30px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.draw-tool-btn:hover { background: var(--bg-elevated); color: var(--heading); }
.draw-tool-btn.active { background: var(--accent, #5865f2); color: #fff; }
.draw-zoom-val {
  min-width: 46px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* 자주 안 쓰는 동작(저장·복사·크기)은 ⋯ 더보기 메뉴로 모아 툴바를 정리한다. */
.draw-more-wrap {
  position: relative;
  display: inline-flex;
}
.draw-more-btn {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
}
.draw-more-btn:hover { background: var(--bg-elevated); color: var(--heading); }
.draw-more-wrap.open .draw-more-btn { background: var(--bg-elevated); color: var(--heading); }
.draw-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 200px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.draw-more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.draw-more-item:hover { background: var(--accent, #5865f2); color: #fff; }
.draw-more-icon {
  width: 18px;
  font-size: 14px;
  text-align: center;
  flex: none;
}
.draw-color-wrap {
  display: inline-flex;
  align-items: center;
}
.draw-color-wrap input[type="color"] {
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}
.draw-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.draw-size-wrap input[type="range"] { width: 92px; }
.draw-size-val {
  min-width: 20px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}
/* 상태 메시지: 캔버스 위에 떠 있는 토스트라 툴바 버튼 배치를 밀지 않는다. */
.draw-status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  /* 레이어 패널(200px)만큼 왼쪽 보정해 캔버스 영역 중앙에 오게 한다. */
  margin-left: -100px;
  z-index: 8;
  max-width: min(72%, 460px);
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.9);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.draw-status.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.draw-status.bad { background: rgba(190, 46, 50, 0.94); }
.draw-resize-pop {
  position: absolute;
  top: 100%;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  color: var(--muted);
}
.draw-resize-pop label { display: inline-flex; align-items: center; gap: 4px; }
.draw-resize-pop input[type="number"] {
  width: 64px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--text);
}
.draw-resize-apply {
  padding: 5px 12px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--accent, #5865f2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.draw-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--draw-layers-w, 200px);
  gap: 1px;
  background: var(--line);
}
.draw-layers-resize-handle {
  right: calc(var(--draw-layers-w, 200px) - 4px);
}
.draw-canvas-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    repeating-conic-gradient(var(--bg-deepest) 0% 25%, transparent 0% 50%) 50% / 24px 24px;
  background-color: var(--bg-input);
}
.draw-canvas-stage {
  position: relative;
  /* 투명 영역(레이어 전부 끔)은 포토샵식 체커보드로 보이게 한다. */
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #c7ccd1 25%, transparent 25%),
    linear-gradient(-45deg, #c7ccd1 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c7ccd1 75%),
    linear-gradient(-45deg, transparent 75%, #c7ccd1 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  line-height: 0;
}
#drawCanvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}
#drawCanvas.tool-eraser { cursor: cell; }
#drawCanvas.tool-fill { cursor: crosshair; }
#drawCanvas.tool-move { cursor: move; }
.draw-canvas-stage.space #drawCanvas,
.draw-canvas-scroll.space { cursor: grab; }
.draw-canvas-stage.panning #drawCanvas,
.draw-canvas-scroll.panning { cursor: grabbing; }
/* 오버레이: 원격 커서·브러시 미리보기·변형 핸들을 그린다(입력은 통과). */
.draw-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
}
/* 캔버스 크기를 마우스로 직접 조절하는 손잡이 */
.draw-rz-handle {
  position: absolute;
  z-index: 3;
  background: var(--accent, #5865f2);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.12s;
}
.draw-canvas-stage:hover .draw-rz-handle { opacity: 0.85; }
.draw-rz-handle:hover { opacity: 1; }
.draw-rz-e {
  top: 50%; right: -6px;
  width: 12px; height: 46px;
  margin-top: -23px;
  border-radius: 6px;
  cursor: ew-resize;
}
.draw-rz-s {
  left: 50%; bottom: -6px;
  width: 46px; height: 12px;
  margin-left: -23px;
  border-radius: 6px;
  cursor: ns-resize;
}
.draw-rz-se {
  right: -7px; bottom: -7px;
  width: 16px; height: 16px;
  border-radius: 5px;
  cursor: nwse-resize;
}
.draw-layers {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-base);
}
.draw-layers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--heading);
  font-size: 13px;
  font-weight: 700;
}
.draw-layer-add {
  width: 26px;
  height: 26px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--heading);
  font-size: 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.draw-layer-add:hover { background: var(--bg-elevated); }
.draw-layer-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column-reverse; /* 위에 있는 레이어(배열 뒤)가 목록 상단에 오도록 */
  gap: 4px;
}
.draw-layer-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  user-select: none; /* Shift+클릭 다중선택 때 레이어 이름·아이콘이 파랗게 드래그 선택되던 문제 */
}
.draw-layer-item input {
  user-select: text; /* 이름 변경 입력칸에서는 글자 선택이 되어야 함 */
}
.draw-layer-item.active {
  border-color: var(--accent, #5865f2);
  background: var(--bg-elevated);
}
.draw-layer-vis,
.draw-layer-lock,
.draw-layer-rename {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  min-height: 0; /* 전역 button min-height:36 상속 차단 → 항목이 세로로 늘어나지 않게 */
  padding: 2px;
  flex-shrink: 0;
}
.draw-layer-rename { font-size: 11px; opacity: 0.7; }
.draw-layer-rename:hover { opacity: 1; }
.draw-layer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  padding: 3px 0;
}
.draw-layer-item.hidden-layer .draw-layer-name { opacity: 0.4; }
.draw-layer-item.locked-layer .draw-layer-name { color: var(--muted); }
.draw-layer-item.multi-selected { border-color: var(--green, #3ba55d); }
body.hide-draw-layer-names .draw-layer-name { display: none; }
body.hide-draw-hint .draw-hint { display: none; }
.draw-layer-order {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
}
.draw-layer-order button,
.draw-layer-del {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  min-height: 0; /* 전역 button min-height:36 상속 차단 */
  padding: 1px 2px;
}
.draw-layer-del { font-size: 12px; }
.draw-layer-order button:hover,
.draw-layer-del:hover { color: var(--heading); }
.draw-layer-order button:disabled { opacity: 0.25; cursor: default; }
.draw-hint {
  flex-shrink: 0;
  margin: 0;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.draw-layer-bulk {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
}
.draw-layer-bulk-count {
  flex: 1;
  color: var(--muted);
  font-size: 11px;
}
.draw-layer-bulk button {
  min-height: 0;
  padding: 4px 8px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--heading);
  font-size: 11px;
  cursor: pointer;
}
.draw-layer-bulk button:hover { background: var(--bg-elevated); }

/* 마크다운 렌더 결과 */
.markdown-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  color: var(--heading);
  margin: 1em 0 0.5em;
  line-height: 1.3;
}
.markdown-body h1 { font-size: 1.6em; border-bottom: 1px solid var(--line); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.35em; border-bottom: 1px solid var(--line); padding-bottom: 0.2em; }
.markdown-body h3 { font-size: 1.15em; }
.markdown-body p { margin: 0.5em 0; }
.markdown-body a { color: #00a8fc; text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body ul,
.markdown-body ol { margin: 0.5em 0; padding-left: 1.6em; }
.markdown-body li { margin: 0.2em 0; }
.markdown-body blockquote {
  margin: 0.5em 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.markdown-body blockquote p { margin: 0.2em 0; }
.markdown-body code {
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--bg-deepest);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}
.markdown-body pre {
  margin: 0.6em 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-deepest);
  overflow-x: auto;
}
.markdown-body pre code {
  padding: 0;
  background: none;
  font-size: 0.86em;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
/* 코드블록 언어 배지 + 구문 강조(채팅과 동일한 원다크 색) */
.markdown-body pre.md-code {
  position: relative;
}
.markdown-body .md-code-lang {
  display: inline-block;
  margin-bottom: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: lowercase;
}
.markdown-body .md-code-lang + code { display: block; }
.markdown-body .md-code .hl-keyword { color: #c678dd; }
.markdown-body .md-code .hl-string { color: #98c379; }
.markdown-body .md-code .hl-number { color: #d19a66; }
.markdown-body .md-code .hl-comment { color: #7f848e; font-style: italic; }
.markdown-body .md-code .hl-fn { color: #61afef; }
.markdown-body hr {
  margin: 1em 0;
  border: none;
  border-top: 1px solid var(--line-strong);
}
.markdown-body strong { color: var(--heading); font-weight: 700; }
.markdown-body del { color: var(--muted); }
/* 체크박스 목록 — 전역 input[type=checkbox] 규칙(auto/native)보다 특이도가 높아 크기가 살아남는다 */
.markdown-body li.md-task { list-style: none; }
.markdown-body .md-check {
  width: 15px;
  height: 15px;
  margin: 0 0.5em 0 0;
  vertical-align: -2px;
  cursor: pointer;
  accent-color: var(--blurple);
}
.markdown-body li.md-task-done > .md-task-text { color: var(--muted); text-decoration: line-through; }
/* 접기/펼치기 — 자식이 있는 항목은 번호/불릿을 그대로 두고 그 옆(내용 앞)에 삼각형 토글을 둔다 */
.markdown-body li.md-foldable { position: relative; }
.markdown-body .md-fold {
  display: inline-block;
  width: 1em;
  margin-right: 0.15em;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  vertical-align: baseline;
}
.markdown-body .md-fold::before {
  content: "▾";
  display: inline-block;
  font-size: 0.8em;
  transition: transform 0.12s ease;
}
.markdown-body li.md-collapsed > .md-fold::before { transform: rotate(-90deg); }
.markdown-body li.md-collapsed > ul,
.markdown-body li.md-collapsed > ol { display: none; }
.markdown-body .md-fold:hover { color: var(--text); }
/* 중첩 목록은 위아래 여백 없이 붙여 층이 촘촘히 보이게 */
.markdown-body li > ul,
.markdown-body li > ol { margin: 0.1em 0 0.1em; }

.field {
  display: grid;
  gap: 6px;
}

.checkbox-field {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checkbox-field input {
  width: 16px;
  height: 16px;
}
.checkbox-field span {
  color: var(--text);
}

.field span,
.quality-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field b {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

/* 파일 선택 — 네이티브 file 버튼(::file-selector-button)은 라벨 수직정렬이
   OS/Electron마다 어긋나 삐딱하게 보인다. 네이티브 input은 화면에서 숨기고
   커스텀 라벨 버튼(.file-cta)으로 대체해 정렬을 완전히 제어한다. */
.file-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-top: 8px;
  padding-left: 10px;
}
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.file-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-height: 0;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.file-cta:hover {
  background: var(--bg-surface);
}
.file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 전역 로그 ───────────────────────────── */
.log-panel {
  display: none;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
body.log-open .log-panel {
  display: flex;
}
body.log-open .main-panel,
body.log-open .main-empty,
body.log-open .chat-panel,
body.log-open .memo-panel,
body.log-open .draw-panel {
  display: none !important;
}

.log-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.log-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.log-title-icon {
  font-size: 16px;
}
.log-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4px;
}
.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.log-empty {
  margin: 24px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
}
.log-entry:hover {
  background: var(--bg-elevated);
}
.log-entry-icon {
  flex: 0 0 auto;
  font-size: 15px;
  line-height: 1.4;
  width: 20px;
  text-align: center;
}
.log-entry-body {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
}
.log-entry-body b {
  color: var(--heading);
  font-weight: 600;
}
.log-entry-time {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 1px;
}
.log-day {
  margin: 10px 8px 2px;
}
.log-day-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 0;
  padding: 4px 6px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  cursor: pointer;
}
.log-day-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text);
}
.log-day-arrow {
  font-size: 9px;
  line-height: 1;
  transition: transform 0.15s ease;
  color: var(--muted);
}
.log-day.collapsed .log-day-arrow {
  transform: rotate(-90deg);
}
.log-day-count {
  margin-left: auto;
  padding: 0 7px;
  border-radius: 9px;
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
}

/* ─── 로그 검색·필터 ─────────────────────── */
.log-search-toggle {
  margin-left: auto;
  align-self: center;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.log-search-toggle svg {
  width: 17px;
  height: 17px;
}
.log-search-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text);
}
.log-search-toggle.active {
  background: var(--accent-soft, var(--bg-elevated));
  color: var(--accent, var(--heading));
}
.log-filters {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-base);
}
.log-search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.log-search-icon {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.log-search-box input {
  width: 100%;
  min-height: 0;
  padding: 8px 30px 8px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13px;
}
.log-search-box input:focus {
  outline: none;
  border-color: var(--accent, var(--heading));
}
.log-search-clear {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.log-search-clear:hover {
  background: var(--bg-base);
  color: var(--text);
}
.log-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.log-filter-select,
.log-filter-date {
  flex: 1 1 100px;
  min-width: 0;
  min-height: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 12px;
}
.log-filter-select:focus,
.log-filter-date:focus {
  outline: none;
  border-color: var(--accent, var(--heading));
}
.log-filter-reset {
  flex: 0 0 auto;
  min-height: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.log-filter-reset:hover {
  background: var(--bg-base);
  color: var(--text);
}
.log-filter-count {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

/* ─── 다이렉트 메시지(DM) ─────────────────── */
.channel-home {
  position: relative;
  font-size: 18px;
}
.dm-home-icon {
  width: 26px;
  height: 26px;
  display: block;
}
.channel-rail-divider {
  width: 32px;
  height: 2px;
  margin: 2px auto 4px;
  border-radius: 1px;
  background: var(--line);
}
.channel-unread {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #f23f43;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.dm-panel {
  display: none;
  min-width: 0;
  overflow: hidden;
  gap: 6px;
}
body.dm-open .layout {
  grid-template-columns: 56px minmax(0, 1fr) !important;
}
body.dm-open .channel-panel,
body.dm-open .member-list,
body.dm-open .main-panel,
body.dm-open .main-empty,
body.dm-open .chat-panel,
body.dm-open .memo-panel,
body.dm-open .draw-panel,
body.dm-open .log-panel {
  display: none !important;
}
body.dm-open .dm-panel {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.dm-threads {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.dm-threads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.dm-threads-head h2 {
  margin: 0;
  font-size: 14px;
  color: var(--heading);
}
.dm-new-button {
  width: 26px;
  height: 26px;
  min-height: 0; /* 전역 button min-height:36px 이 정사각형을 세로로 늘리는 것 방지 */
  padding: 0;    /* 전역 button padding:0 14px 로 가로가 넓어지는 것 방지 */
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.dm-new-button:hover {
  background: var(--bg-base);
}
.dm-new-button svg {
  width: 16px;
  height: 16px;
  display: block;
}
.dm-new-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.dm-new-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.dm-new-input > span {
  color: var(--muted);
  font-weight: 700;
}
.dm-new-input input {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text);
  font-size: 13px;
}
.dm-new-input button {
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent, #5865f2);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.dm-find-msg {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}
.dm-thread-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.dm-thread-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 20px 8px;
}
.dm-thread {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dm-thread:hover {
  background: var(--bg-elevated);
}
.dm-thread.active {
  background: var(--bg-elevated);
}
.dm-thread-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2 center/cover no-repeat;
  font-size: 13px;
  color: #fff;
}
.dm-thread-body {
  min-width: 0;
  flex: 1;
}
.dm-thread-name {
  font-size: 13px;
  color: var(--heading);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-thread-preview {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dm-thread-unread {
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #f23f43;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.dm-conversation {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
}
.dm-conv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.dm-conv-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #5865f2 center/cover no-repeat;
  font-size: 13px;
  color: #fff;
}
.dm-conv-title h2 {
  margin: 0;
  font-size: 15px;
  color: var(--heading);
}
.dm-conv-title p {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}
.dm-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
}
.dm-empty {
  margin: auto;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.dm-loading {
  color: var(--muted);
  font-size: 13px;
}
.dm-group {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 4px 0;
  margin-top: 8px;
}
.dm-avatar {
  width: 40px;
  height: 40px;
  margin-top: 2px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blurple) center/cover no-repeat;
}
.dm-group-body {
  min-width: 0;
}
.dm-msg {
  padding: 2px 0;
}
.dm-msg.grouped {
  padding-top: 0;
}
.dm-msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 2px;
}
.dm-msg-head b {
  font-size: 13px;
  color: var(--heading);
}
.dm-msg-head span {
  font-size: 11px;
  color: var(--muted);
}
.dm-msg-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.dm-msg-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}
.dm-msg-del {
  opacity: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
}
.dm-msg:hover .dm-msg-del {
  opacity: 0.6;
}
.dm-msg-del:hover {
  opacity: 1;
}
.dm-composer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.dm-composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.dm-send-button {
  align-self: flex-end;
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent, #5865f2);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* ─── 사이드 패널: 방 만들기/목록 ─────────── */

.create-room {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
  align-items: end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.create-room button {
  grid-column: 1 / -1;
}

.room-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.room-list,
.participant-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.room-list {
  overflow: auto;
}

.empty-state {
  min-height: 64px;
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.room-card {
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 10px 12px;
  transition: background 120ms ease;
}

.room-card:hover {
  background: #404249;
}

.room-card-current {
  outline: 1px solid rgba(88, 101, 242, 0.55);
}

.room-main {
  align-items: center;
}

.room-main > div {
  min-width: 0;
}

.room-card button {
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
  background: var(--blurple);
  color: #fff;
  border: 0;
  flex: none;
}

.room-card button:hover:not(:disabled) {
  background: var(--blurple-strong);
}

.room-name {
  font-weight: 700;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-meta,
.room-people,
#currentRoomMeta,
.message {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.room-people {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 통화 헤더 ───────────────────────────── */

.call-head {
  min-height: 52px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.call-title {
  min-width: 0;
}

#currentRoomName {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

#currentRoomName::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  flex: none;
}

#currentRoomMeta {
  margin-top: 2px;
}

.call-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.inline-field select {
  width: auto;
  min-height: 34px;
  padding-right: 26px;
}

/* ─── 미터 ────────────────────────────────── */

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
}

.meter span {
  display: block;
  width: var(--level, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 70ms linear;
}

.meter.mini {
  height: 6px;
}

/* ─── 통화 액션 바 ────────────────────────── */

.call-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.action-switch {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

/* ─── 스위치 ─────────────────────────────── */

.switch {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.switch input {
  appearance: none;
  width: 38px;
  min-height: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #4e5058;
  position: relative;
  cursor: pointer;
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform 120ms ease;
}

.switch input:checked {
  background: var(--green);
}

.switch input:checked::after {
  transform: translateX(16px);
}

/* ─── 접이식 패널 (details) ───────────────── */

details {
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: inherit;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::after {
  content: "";
  order: 99;
  width: 7px;
  height: 7px;
  margin-left: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 140ms ease;
  flex: none;
}

details[open] summary::after {
  transform: rotate(-135deg);
}

summary:hover {
  color: var(--heading);
}

/* ─── 프로그램 오디오 패널 ────────────────── */

.program-audio-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.program-audio-head,
.capture-mode-group {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.capture-mode-group {
  justify-content: flex-start;
}

.program-audio-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 320px;
  min-width: min(100%, 320px);
}

.program-audio-tools input,
.program-audio-tools button {
  min-height: 34px;
}

.program-audio-tools button {
  white-space: nowrap;
}

.radio-option,
.program-audio-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.radio-option {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  white-space: nowrap;
  cursor: pointer;
}

.radio-option input,
.program-audio-item input {
  width: 15px;
  min-width: 15px;
  height: 15px;
  min-height: 15px;
  padding: 0;
  accent-color: var(--blurple);
}

.radio-option:has(input:checked) {
  background: rgba(88, 101, 242, 0.25);
  color: var(--heading);
}

.program-audio-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px;
  max-height: min(40vh, 380px);
  overflow: auto;
  padding-right: 4px;
}

.program-audio-item,
.program-audio-empty {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
}

.program-audio-item:has(input:checked) {
  background: rgba(88, 101, 242, 0.25);
}

.program-audio-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.program-audio-status,
.program-audio-selected {
  color: var(--muted);
  font-size: 12px;
}

.program-audio-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.program-audio-chip {
  max-width: 240px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(88, 101, 242, 0.25);
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── 화면 공유 ───────────────────────────── */

.screen-stage {
  position: relative;
  display: block;
  min-height: 280px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: #000;
  overflow: hidden;
}

.screen-stage[hidden],
.screen-share-panel[hidden],
.program-audio-panel[hidden] {
  display: none;
}

.screen-stage-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.3) 72%, transparent);
  transition: opacity 160ms ease;
}

.screen-stage-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.screen-stage-actions button {
  min-height: 32px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
}

#screenViewer {
  display: block;
  width: 100%;
  height: clamp(320px, 62vh, 720px);
  max-height: none;
  background: #000;
  object-fit: contain;
}

.screen-stage[data-fit="cover"] #screenViewer {
  object-fit: cover;
}

.screen-stage.screen-controls-hidden .screen-stage-head,
.screen-stage.screen-controls-hidden .screen-share-list {
  opacity: 0;
  pointer-events: none;
}

.screen-stage.screen-controls-hidden {
  cursor: none;
}

.screen-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
  border: 0;
  max-height: none;
  border-radius: 0;
  background: #000;
}

.screen-stage:fullscreen #screenViewer {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
}

#screenViewer:fullscreen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  border-radius: 0;
  background: #000;
}

.screen-share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  padding: 12px;
}

.screen-share-note {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.screen-preview-switch,
.screen-probe-switch,
.screen-test-button {
  align-self: end;
}

.screen-share-list {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  transition: opacity 160ms ease;
}

.screen-share-pill,
.participant-screen-button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.screen-share-pill:hover,
.participant-screen-button:hover {
  background: var(--blurple);
}

/* ─── 참가자 ─────────────────────────────── */

.participant-list {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-top: 0;
}

.participant-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.participant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.participant-head strong {
  font-weight: 700;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-card span {
  color: var(--muted);
  font-size: 12px;
}

.participant-head > span {
  flex: none;
}

.participant-meters {
  display: grid;
  gap: 6px;
}

.participant-volumes {
  display: grid;
  gap: 5px;
}

.participant-meter {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.participant-volume {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.participant-volume input {
  min-height: 24px;
}

.sound-prefs-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sound-pref-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(0, 1fr) 40px;
  gap: 12px;
  align-items: center;
}

.sound-pref-row input[type="range"] {
  min-height: 24px;
}

.participant-volume b {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}

.participant-screen-button {
  background: var(--bg-elevated);
  color: var(--text);
}

.participant-mod {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.participant-mod-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}
.participant-mod-btn:hover {
  background: var(--bg-base);
}
.participant-mod-btn.danger {
  color: #f6a2a2;
  border-color: rgba(240, 120, 120, 0.35);
}
.participant-mod-btn.danger:hover {
  background: rgba(240, 90, 90, 0.14);
}

/* ─── 설정 모달 ───────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.7);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(620px, 100%);
  max-height: min(84vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 16px;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 18px;
  padding: 16px;
  overflow: auto;
}

.modal-section {
  display: grid;
  gap: 10px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-hint {
  color: var(--muted);
  font-size: 12px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  align-items: end;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
}

/* ─── 설정 모달 탭 ────────────────────────── */

.settings-modal {
  width: min(680px, 100%);
}

.settings-tabs {
  flex: none;
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.settings-tab {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.settings-tab:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.settings-tab.active {
  color: var(--heading);
  background: var(--bg-surface);
  box-shadow: inset 0 -2px 0 var(--blurple);
}

.settings-pane {
  display: none;
  gap: 12px;
}

.settings-pane.active {
  display: grid;
}

.settings-pane-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-pane-head h3 {
  font-size: 14px;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
  margin: 0;
}

.quality-summary {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.quality-grid div {
  min-height: 52px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-deepest);
}

.quality-grid dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.quality-grid div:nth-child(n + 9) {
  grid-column: span 2;
}

.diagnostics-copy {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
}

.diagnostics-copy:hover:not(:disabled) {
  background: #45474e;
}

.client-log-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.client-log-actions button {
  min-height: 32px;
  font-size: 12px;
}

#clientLogOutput {
  max-height: 300px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--bg-deepest);
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, "SF Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── 토스트 알림 ─────────────────────────── */

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: min(560px, calc(100vw - 40px));
  padding: 10px 16px;
  border-left: 3px solid var(--blurple);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--heading);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 200ms ease-out;
}

.toast-hide {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 280ms ease, transform 280ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 메시지는 토스트로 대체 — 스크린리더용으로만 유지 */
.message {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

audio,
#remoteAudios {
  display: none;
}

/* ─── 반응형 ─────────────────────────────── */

@media (max-width: 920px) {
  .layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .toggle-grid,
  .quality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:not(.in-call) .main-empty {
    display: none;
  }
}

@media (max-width: 580px) {
  .app {
    padding: 0 8px 8px;
  }

  .topbar,
  .call-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .create-room,
  .toggle-grid,
  .quality-grid {
    grid-template-columns: 1fr;
  }

  .call-actions button,
  .call-actions .action-switch,
  .create-room button {
    width: 100%;
  }

  .program-audio-tools {
    width: 100%;
  }

  .quality-grid div:nth-child(n + 9) {
    grid-column: auto;
  }
}

/* ===== 계정 · 인증 · 관리자 UI ===== */

/* 로그인/회원가입 오버레이 */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, #2b2d55, var(--bg-deepest) 70%);
  overflow: auto;
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand h1 {
  font-size: 20px;
  color: var(--heading);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--bg-elevated);
  color: var(--heading);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-submit {
  margin-top: 4px;
}

.auth-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-avatar-field {
  flex: 1;
}

.auth-message,
.account-message,
.admin-message {
  min-height: 18px;
  margin: 0;
  font-size: 13px;
  color: var(--warning);
}

.auth-message.ok,
.account-message.ok,
.admin-message.ok {
  color: var(--green);
}

/* 상단 프로필 칩 */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 4px;
  background: var(--bg-surface);
  color: var(--text);
}

.profile-chip:hover:not(:disabled) {
  background: var(--bg-elevated);
}

.profile-chip-avatar,
.account-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: var(--blurple) center/cover no-repeat;
  display: inline-block;
}

.account-avatar {
  width: 44px;
  height: 44px;
}

.account-avatar.large {
  width: 64px;
  height: 64px;
}

.profile-chip-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.profile-chip-text b {
  font-size: 13px;
  color: var(--heading);
}

.profile-chip-text em {
  font-size: 11px;
  font-style: normal;
  color: var(--muted);
}

.admin-toggle {
  color: var(--warning);
}

/* 설정 모달 내 계정 섹션 */
.account-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.account-summary-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  line-height: 1.2;
}

.account-summary-text b {
  color: var(--heading);
}

.account-summary-text em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.account-password {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.account-password summary {
  cursor: pointer;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ─── 프로필 창 · 프로필 카드(ID 카드) ────── */

.profile-modal {
  width: min(560px, 100%);
}

.profile-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--line);
}

.profile-card-banner {
  height: 120px;
  background-color: var(--bg-elevated);
  background-size: cover;
  background-position: center;
}

.profile-card-banner.empty {
  background-image: linear-gradient(
    135deg,
    hsl(var(--banner-hue, 230) 45% 32%),
    hsl(calc(var(--banner-hue, 230) + 40) 50% 22%)
  );
}

.profile-card-main {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 10px 16px 14px;
  margin-top: -18px;
}

.profile-card-avatar {
  flex: none;
  border: 4px solid var(--bg-surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.profile-card-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-bottom: 4px;
}

.profile-card-id b {
  color: var(--heading);
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card-id em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.profile-image-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.profile-gradient-field {
  margin-top: 12px;
}

.profile-gradient-field .modal-hint {
  margin-top: 6px;
}

.gradient-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gradient-swatch {
  width: 44px;
  height: 30px;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.gradient-swatch:hover {
  transform: translateY(-1px);
}

.gradient-swatch.active {
  border-color: var(--accent, #5865f2);
  box-shadow: 0 0 0 2px var(--bg-surface), inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* 유저를 눌러 프로필 카드를 여는 지점(멤버 · 참가자 · 채팅 · DM) */
.profile-popover {
  position: fixed;
  z-index: 60;
  width: 280px;
  animation: profile-pop 0.12s ease-out;
}

@keyframes profile-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.profile-popover .profile-card {
  background: var(--bg-base);
  border: 1px solid var(--line-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.profile-popover .profile-card-banner {
  height: 84px;
}

.profile-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 16px 10px;
}

.profile-card-presence {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.profile-card-presence.online {
  color: var(--green);
}

.profile-card-actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 14px;
}

.profile-card-actions button {
  flex: 1;
  min-height: 32px;
  font-size: 12px;
}

.profile-link {
  cursor: pointer;
}

.profile-link:hover {
  text-decoration: underline;
}

.chat-avatar.profile-link:hover,
.dm-avatar.profile-link:hover,
.dm-thread-avatar.profile-link:hover {
  text-decoration: none;
  filter: brightness(1.15);
}

.member-row {
  cursor: pointer;
}

.dm-conv-head {
  cursor: pointer;
}

#profileBannerClear {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* 배경 이미지 자르기(가로로 긴 캔버스) */
#cropCanvas.wide {
  width: 320px;
  height: 107px;
  border-radius: var(--radius-sm);
}

/* 관리자 패널 */
.admin-modal {
  width: min(760px, 100%);
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
}

.admin-toolbar input {
  flex: 1;
}

.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 52vh;
  overflow: auto;
}

.admin-user-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.admin-user-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-user-main b {
  color: var(--heading);
}

.admin-user-main .admin-user-code {
  font-size: 12px;
  color: var(--muted);
}

.admin-user-meta {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.admin-user-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.admin-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(240, 178, 50, 0.16);
  color: var(--warning);
}

.admin-online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}

.admin-online-dot.online {
  background: var(--green);
}

.admin-conn-log {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.admin-conn-log summary {
  cursor: pointer;
}

.admin-conn-log pre {
  margin: 6px 0 0;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== 채널 레일 · 채널 패널 · 멤버 리스트 (2단계) ===== */
.channel-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-radius: var(--radius-lg);
  background: var(--bg-deepest);
  overflow-y: auto;
}

.channel-icon {
  width: 46px;
  height: 46px;
  min-width: 46px;
  max-width: 46px;
  min-height: 46px;
  max-height: 46px;
  flex: 0 0 46px; /* 맥 Electron에서 flex로 가로/세로 늘어나는 것 방지 */
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  transition: border-radius 0.15s, background 0.15s;
}
.channel-icon:hover:not(:disabled) {
  border-radius: 12px;
  background-color: var(--blurple);
  color: #fff;
}
.channel-icon.active {
  border-radius: 12px;
  background-color: var(--blurple);
  color: #fff;
}
/* 아이콘 이미지가 있는 채널은 hover/active 시에도 배경 이미지(위치·크기)를 유지 */
.channel-icon.has-icon:hover:not(:disabled),
.channel-icon.has-icon.active {
  background-color: transparent;
}
.channel-icon.channel-add {
  background: var(--bg-surface);
  color: var(--green);
  font-size: 22px;
}
.channel-icon.channel-add:hover {
  background: var(--green);
  color: #fff;
}

.channel-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 12px 10px;
  min-height: 0;
}
.channel-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--line);
}
.channel-panel-head h2 {
  font-size: 15px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-menu-button {
  font-size: 18px;
  line-height: 1;
}
.channel-empty {
  margin-top: 12px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

.room-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}
.room-group {
  border-radius: var(--radius-sm);
  /* 그룹을 살짝 눌러 들어간 상자로 만들어 안의 방들과 묶어 보이게 한다. */
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--line);
  padding: 2px 4px 4px;
}
.room-group-head {
  position: relative;
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 0;
}
.room-group-toggle {
  flex: 1;
  min-width: 0;
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}
.room-group-toggle:hover { color: var(--text); }
.room-group-draggable > .room-group-head .room-group-toggle { cursor: grab; }
.room-group-draggable > .room-group-head .room-group-toggle:active { cursor: grabbing; }
.room-group.dragging-group { opacity: 0.38; }
.room-group-caret { flex: none; transition: transform 0.14s ease; }
.room-group.collapsed .room-group-caret { transform: rotate(-90deg); }
.room-group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-group-count { margin-left: auto; margin-right: 0; font-size: 10px; opacity: 0.65; transition: margin-right 0.14s ease; }
.room-group-action {
  position: absolute;
  right: 26px;
  z-index: 1;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.room-group-action.danger { right: 2px; }
.room-group-head:hover .room-group-count,
.room-group-head:focus-within .room-group-count { margin-right: 48px; }
.room-group-head:hover .room-group-action,
.room-group-head:focus-within .room-group-action { opacity: 1; pointer-events: auto; }
.room-group-action:hover { background: var(--bg-elevated); color: var(--text); }
.room-group-action.danger:hover { background: var(--danger); color: #fff; }
.room-group-rooms {
  min-height: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 3px;
  border-radius: var(--radius-sm);
}
.room-group-rooms[hidden] { display: none; }
.room-group > .room-group-rooms {
  margin-left: 4px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}
.room-tree-root { padding-top: 1px; }
/* 드래그 중에는 그룹 카드 배경/테두리를 없애 드롭 표시(파란 선·빈 그룹 안내)가 겹쳐 지저분해지지 않게 한다. */
.room-list.room-tree-drag-active .room-group {
  background: transparent;
  border-color: transparent;
}
.room-tree-empty { display: none; }
.room-list.room-tree-drag-active .room-tree-empty { display: block; }
.room-list.room-tree-drag-active .room-tree-root { min-height: 36px; }
.room-tree-children.drop-target > .room-tree-empty { display: none; }
.room-tree-children.drop-target {
  box-shadow: inset 0 0 0 1px var(--blurple);
  background: rgba(88, 101, 242, 0.08);
}
.room-tree-drop-indicator {
  height: 2px;
  flex: none;
  margin: 1px 6px;
  border-radius: 999px;
  background: var(--blurple);
  box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.24);
  pointer-events: none;
}
.room-group-empty { padding: 8px; color: var(--muted); font-size: 11px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-xs); }
/* 방을 '떠 있는 글자'가 아니라 경계가 있는 상자로 보이게 한다.
   경계선을 항목(.room-item) 전체에 두어 통화방의 참가자 목록까지 한 상자로 묶는다. */
.room-item {
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  border: 1px solid var(--line);
  overflow: hidden;
}
.room-item:hover { border-color: var(--line-strong); }
.room-item.room-draggable { cursor: grab; }
.room-item.room-draggable:active { cursor: grabbing; }
.room-list.room-pointer-drag-active { user-select: none; cursor: grabbing; }
.room-item.dragging { opacity: 0.35; }
.room-item.active {
  background: rgba(88, 101, 242, 0.16);
  border-color: rgba(88, 101, 242, 0.5);
}
/* 지금 접속해 있는 방: 왼쪽 얇은 초록선 + 작은 '여기' 칩으로 거슬리지 않게 표시.
   보는 방(파란 active)과 접속한 방(초록)을 구분한다. */
.room-item.here .room-item-head::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 15px;
  border-radius: 0 3px 3px 0;
  background: var(--green);
}
.room-here {
  flex: none;
  height: 16px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--green);
  background: rgba(35, 165, 89, 0.16);
  display: inline-grid;
  place-items: center;
}
.room-item-head {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-weight: 500;
  justify-content: flex-start;
}
.room-item-head:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text);
}
.room-item.active .room-item-head {
  color: var(--heading);
}
.room-icon {
  width: 18px;
  text-align: center;
  flex: none;
  font-size: 13px;
}
.room-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.room-count {
  flex: none;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.room-muted {
  flex: none;
  font-size: 11px;
  opacity: 0.6;
}
/* 삭제(×) 버튼은 흐름에서 빼 절대배치한다. flex 자리(20px+gap)를 차지하면
   대표자 모드에서만 방 이름이 그만큼 일찍 잘려 비대표자와 표시가 달라지던 문제가 생긴다. */
.room-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  flex: none;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
}
.room-item-head:hover .room-del {
  opacity: 1;
  pointer-events: auto;
}
/* 오른쪽 뱃지(인원수/안읽음)가 있으면 ×와 겹치지 않게 hover 시 살짝 왼쪽으로 밀어준다. */
.room-item-head:hover .room-count,
.room-item-head:hover .room-unread,
.room-item-head:hover .room-here:last-child {
  margin-right: 22px;
}
.room-del:hover {
  background: var(--danger);
  color: #fff;
}
.room-occupants {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 1px 8px 4px 30px;
}
.room-occupant {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
}
.occupant-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}
/* 통화 접속이 아니라 '지금 이 방을 열람 중'인 사람은 빈 점으로 은은하게 구분한다. */
.occupant-dot.viewing {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--muted);
}
.room-occupant.room-occupant-more {
  color: var(--muted);
  font-size: 11px;
  padding-left: 14px;
  cursor: default;
}
.room-add-button {
  margin-top: 0;
  background: var(--bg-base);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  justify-content: flex-start;
  min-height: 32px;
}
.room-list-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
  padding-top: 5px;
  background: var(--bg-surface);
}
.room-list-actions .room-add-button { justify-content: center; }
.room-add-button:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--line-strong);
  color: var(--text);
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 12px 8px;
  overflow-y: auto;
  min-height: 0;
}
.member-head {
  padding: 4px 8px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.member-row {
  position: relative; /* 관리 버튼을 오버레이로 띄우기 위한 기준 */
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.member-row:hover {
  background: var(--bg-elevated);
}
.member-row.offline {
  opacity: 0.45;
}
.member-row .account-avatar.small {
  position: relative;
  width: 30px;
  height: 30px;
}
.member-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
  background: var(--muted);
}
.member-dot.online {
  background: var(--green);
}
.member-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
  flex: 1;
}
.member-info b {
  font-size: 13px;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-info em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}
.owner-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(240, 178, 50, 0.16);
  color: var(--warning);
}
/* 관리 버튼은 평소엔 숨기고 hover 시에만 우측에 오버레이한다.
   (예전엔 opacity:0 이라 자리를 계속 차지 → 다른 멤버 닉네임이 2px로 잘려 안 보였음) */
.member-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 4px;
  padding-left: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.member-row:hover .member-actions {
  opacity: 1;
  pointer-events: auto;
}
.member-action-btn {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  background: var(--bg-surface);
  color: var(--muted);
}
.member-action-btn:hover {
  background: #45474e;
  color: var(--heading);
}
.member-action-btn.kick:hover {
  background: var(--danger);
  color: #fff;
}

/* 채널 모달 · 방 추가 · 채널 관리 */
.room-type-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
}
.room-type-option:hover {
  background: var(--bg-elevated);
}
.room-type-option:has(input:checked) {
  border-color: var(--blurple);
  background: rgba(88, 101, 242, 0.12);
}
.room-type-option input {
  width: auto;
  min-height: 0;
  accent-color: var(--blurple);
}
.room-group-modal { width: min(420px, 100%); }

/* 이미지 크롭 모달 */
.crop-modal {
  width: min(360px, 100%);
}
.crop-stage {
  display: grid;
  place-items: center;
  padding: 8px 0;
}
#cropCanvas {
  width: 256px;
  height: 256px;
  max-width: 100%;
  border-radius: 50%;
  background: var(--bg-input);
  cursor: grab;
  touch-action: none;
}
#cropCanvas:active {
  cursor: grabbing;
}

/* 채널 아이콘 변경 */
.channel-icon-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.channel-icon-preview {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 16px;
  background: var(--blurple) center/cover no-repeat;
}
.channel-icon-field {
  flex: 1;
}
.channel-icon.has-icon {
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  color: transparent;
}
.invite-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.invite-label {
  font-size: 12px;
  color: var(--muted);
}
.invite-code {
  flex: 1;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--heading);
}
.channel-menu-actions {
  flex-wrap: wrap;
}

/* ===== 역할 · 권한 시스템 ===== */
.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 6px 8px;
  padding: 8px 10px;
  background: rgba(88, 101, 242, 0.16);
  border: 1px solid var(--blurple);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--heading);
}
.preview-banner b { color: #fff; }
.preview-stop {
  flex: none;
  padding: 4px 8px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--blurple);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}
.preview-stop:hover { background: var(--blurple-strong); }

.perms-modal { width: min(880px, 95vw); max-height: 88vh; display: flex; flex-direction: column; }
.perms-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.perms-tab {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.perms-tab:hover { color: var(--text); }
.perms-tab.active { color: var(--heading); border-bottom-color: var(--blurple); }
.perms-body { flex: 1; min-height: 0; overflow-y: auto; }
.perms-pane { min-height: 0; display: flex; flex-direction: column; gap: 12px; }

.perms-row-add { display: flex; gap: 8px; }
.perms-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}
.small { padding: 6px 12px; font-size: 13px; }

.role-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.role-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-count { font-size: 11px; color: var(--muted); background: var(--bg-input); padding: 1px 6px; border-radius: 10px; }
.perms-subtitle { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 12px 0 6px; }

/* --- 역할 탭: 마스터(목록) · 디테일(편집) --- */
.rolemgr { min-height: min(56vh, 500px); display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: stretch; }
.rolemgr-side {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.rolemgr-side-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
}
.rolemgr-list { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.rolemgr-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.rolemgr-item:hover { background: var(--bg-elevated); }
.rolemgr-item.active { background: var(--bg-elevated); border-color: var(--blurple); color: var(--heading); font-weight: 600; }
.rolemgr-empty { padding: 12px 4px; font-size: 12px; color: var(--muted); }
.rolemgr-add { display: flex; gap: 6px; }
.rolemgr-add .perms-input { padding: 7px 9px; font-size: 13px; min-width: 0; }
.rolemgr-add button { flex: none; width: 36px; min-height: 0; padding: 0; font-size: 16px; display: grid; place-items: center; }

.rolemgr-detail {
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
  overflow-y: auto;
}
.rolemgr-detail-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 280px;
  text-align: center;
  color: var(--muted);
}
.rolemgr-detail-empty .rme-icon { font-size: 34px; }
.rolemgr-detail-empty b { color: var(--heading); font-size: 15px; }
.rolemgr-detail-empty p { margin: 0; font-size: 13px; line-height: 1.6; }

.rd { display: flex; flex-direction: column; gap: 14px; }
.rd-head { display: flex; align-items: center; gap: 8px; }
.rd-color {
  flex: none;
  display: grid; place-items: center;
  width: 40px; height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
}
.rd-color input[type="color"] { width: 28px; height: 24px; padding: 0; border: none; background: none; cursor: pointer; }
.rd-name { flex: 1; min-width: 0; }
.rd-delete {
  flex: none;
  min-height: 0;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid rgba(218, 55, 60, 0.5);
  border-radius: var(--radius-xs);
  color: #f0a0a2;
  font-size: 13px;
  cursor: pointer;
}
.rd-delete:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.rd-section { display: flex; flex-direction: column; gap: 6px; }
.rd-sec-title {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 2px;
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
}

/* 권한 카드: 제목 + 설명 + 오른쪽 스위치 */
.perm-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.perm-card:hover { border-color: var(--line-strong); }
.perm-card.dim { opacity: 0.62; }
.perm-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.perm-card-text b { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--heading); }
.perm-card-text span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.perm-badge { padding: 1px 6px; border-radius: 8px; background: var(--bg-elevated); color: var(--muted); font-size: 10px; font-weight: 700; }

/* 권한 토글(설정창 .switch 와 같은 모양, 라벨 중첩 없이 input 단독으로 쓴다) */
input.perm-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 38px;
  height: 22px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #4e5058;
  cursor: pointer;
}
input.perm-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform 120ms ease;
}
input.perm-switch:checked { background: var(--green); }
input.perm-switch:checked::after { transform: translateX(16px); }

.rd-members { display: flex; flex-direction: column; gap: 4px; max-height: 26vh; overflow-y: auto; }
.rd-member {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.rd-member:hover { border-color: var(--line-strong); }
.rd-member.on { border-color: rgba(88, 101, 242, 0.6); }
.rd-member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; color: var(--text); }
.rd-member-name em { color: var(--muted); font-style: normal; font-size: 11.5px; }

/* --- 멤버 탭: 개별 권한 --- */
.mp-list { display: flex; flex-direction: column; gap: 6px; }
.mp-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.mp-who { display: flex; flex-direction: column; gap: 5px; min-width: 150px; }
.mp-name { font-size: 14px; font-weight: 600; color: var(--heading); }
.mp-name em { color: var(--muted); font-style: normal; font-weight: 400; font-size: 11.5px; }
.mp-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.mp-chip {
  --chip: #5865f2;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  color: var(--text);
}
.mp-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--chip); }
.mp-chip.owner { background: rgba(240, 178, 50, 0.15); border-color: rgba(240, 178, 50, 0.5); color: #f0c34e; }
.mp-chip.none { color: var(--muted); }
.mp-chip.owner::before, .mp-chip.none::before { display: none; }

.mp-caps { display: flex; flex-wrap: wrap; gap: 6px; }
.mp-pill {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 0;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.mp-pill:hover:not(:disabled) { filter: brightness(1.2); }
.mp-pill.on { background: var(--blurple); border-color: var(--blurple); color: #fff; }
.mp-pill.via { background: rgba(35, 165, 89, 0.16); border-color: var(--green); color: #7bd99e; }
.mp-pill.owner { background: rgba(240, 178, 50, 0.14); border-color: rgba(240, 178, 50, 0.45); color: #f0c34e; cursor: default; }
.mp-pill.gate-off { opacity: 0.5; }
.mp-pill-tag { padding: 0 5px; border-radius: 8px; background: rgba(35, 165, 89, 0.28); font-size: 10px; font-weight: 700; }

.perms-room-select { display: flex; align-items: center; gap: 10px; }
.perms-room-select > span { font-size: 13px; color: var(--muted); }
.perms-room-select select, .perms-body select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}

.perms-table { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.perms-trow { display: grid; grid-template-columns: var(--perm-cols, 1.6fr 1fr 1fr); align-items: center; border-top: 1px solid var(--line); }
.perms-trow:first-child { border-top: none; }
.perms-thead { background: var(--bg-surface); font-size: 12px; color: var(--muted); text-transform: uppercase; }
.perms-tcell { padding: 8px 10px; display: flex; align-items: center; gap: 6px; }
.perms-tcell.name { font-size: 14px; }
.perms-user-ic { color: var(--muted); }
.perm-tri {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.perm-tri.allow { background: rgba(35, 165, 89, 0.18); border-color: var(--green); color: #7bd99e; }
.perm-tri.deny { background: rgba(218, 55, 60, 0.18); border-color: var(--danger); color: #f0a0a2; }
.perm-tri:hover { filter: brightness(1.15); }
.perms-del-cell { padding: 4px 6px; justify-content: center; }
.perms-user-del {
  width: 26px;
  height: 26px;
  min-height: 0; /* 전역 button min-height:36px 로 세로가 늘어나는 것 방지 */
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.perms-user-del:hover { background: rgba(218, 55, 60, 0.18); color: var(--danger); }

.perms-preview-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.perms-preview-col { display: flex; flex-direction: column; gap: 4px; max-height: 30vh; overflow-y: auto; }
.perms-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.perms-pick:hover { background: var(--bg-elevated); border-color: var(--line-strong); }
.perms-preview-result { background: var(--bg-surface); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.perms-preview-line { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: var(--radius-xs); font-size: 14px; }
.perms-preview-line.no-access { opacity: 0.5; }
.perms-caps { font-size: 12px; color: var(--muted); }
.perms-preview-result .primary { margin-top: 8px; }

/* 멤버 탭: 채널 기본 제한 박스 */
.perms-channel-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}
.perms-channel-box .rd-sec-title { margin: 0; }
.perms-channel-box .modal-hint { margin: -4px 0 2px; }
.perms-channel-box .perm-card { background: var(--bg-input); }

/* ===== 채팅 이미지: 래퍼 + ⋯ 버튼 ===== */
.chat-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 360px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chat-image-more {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
  display: grid;
  place-items: center;
}
.chat-image-wrap:hover .chat-image-more { opacity: 1; }

/* ===== 채팅 심화 마크다운 ===== */
.chat-msg-text .chat-code {
  position: relative;
}
.chat-code-lang {
  display: inline-block;
  margin-bottom: 4px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: lowercase;
}
.chat-code-lang + code { display: block; }
/* 코드 구문 강조(디스코드/원다크식, 앱은 다크 고정) */
.chat-code .hl-keyword { color: #c678dd; }
.chat-code .hl-string { color: #98c379; }
.chat-code .hl-number { color: #d19a66; }
.chat-code .hl-comment { color: #7f848e; font-style: italic; }
.chat-code .hl-fn { color: #61afef; }
.chat-msg-text .chat-h {
  margin: 6px 0 2px;
  color: var(--heading);
  line-height: 1.3;
  font-weight: 700;
}
.chat-msg-text h1.chat-h { font-size: 1.4em; }
.chat-msg-text h2.chat-h { font-size: 1.25em; }
.chat-msg-text h3.chat-h { font-size: 1.12em; }
.chat-msg-text h4.chat-h,
.chat-msg-text h5.chat-h,
.chat-msg-text h6.chat-h { font-size: 1em; }
.chat-msg-text .chat-quote {
  margin: 3px 0;
  padding: 2px 10px;
  border-left: 3px solid var(--line-strong);
  color: var(--text);
}
.chat-msg-text .chat-list {
  margin: 2px 0;
  padding-left: 22px;
}
.chat-msg-text .chat-list li { margin: 1px 0; }
.chat-msg-text .chat-hr {
  margin: 8px 0;
  border: none;
  border-top: 1px solid var(--line-strong);
}
.chat-msg-text p { margin: 0; }
.chat-emoji {
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  vertical-align: -0.4em;
  object-fit: contain;
}
/* 이모지만 보낸 메시지: 디스코드처럼 크게(점보) 표시 */
.chat-msg-text.jumbo,
.chat-input-preview.jumbo {
  font-size: 32px;
  line-height: 1.2;
}
.chat-msg-text.jumbo .chat-emoji,
.chat-input-preview.jumbo .chat-emoji {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.25em;
}

/* ===== 입력창 마크다운 미리보기 ===== */
.chat-input-preview {
  margin-bottom: 8px;
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
.chat-input-preview::before {
  content: "미리보기";
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}
.chat-input-preview .chat-code {
  margin: 4px 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.chat-input-preview code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-elevated);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}
.chat-input-preview .chat-code code { padding: 0; background: none; }
.chat-input-preview a { color: #00a8fc; text-decoration: none; }
.chat-input-preview strong { color: var(--heading); font-weight: 700; }
.chat-input-preview .chat-emoji { width: 1.6em; height: 1.6em; vertical-align: -0.4em; }

/* ===== 이미지 크게 보기 + 크롭 모달 ===== */
.img-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
}
/* 커스텀 이모지 이름 입력 모달(일렉트론 prompt 미지원 대체) */
.emoji-name-backdrop { z-index: 260; }
.emoji-name-modal {
  width: min(92vw, 360px);
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-base);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
.emoji-name-modal h3 { margin: 0 0 6px; color: var(--heading); font-size: 16px; }
.emoji-name-modal .modal-hint { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.emoji-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-weight: 700;
}
.emoji-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
}
.emoji-name-err { margin: 8px 0 0; color: var(--danger); font-size: 12px; }
.emoji-name-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ===== 공유 글꼴 관리 모달 ===== */
.font-manager-backdrop { z-index: 260; }
.font-manager {
  position: relative;
  width: min(94vw, 760px);
  max-height: 88vh;
}
.font-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 4px;
  max-height: 60vh;
  overflow-y: auto;
}
/* 글꼴(family) 카드: 제목(이름) + 파일 행들 */
.font-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  padding: 10px 12px;
}
.font-group.font-group-drop-target {
  border-color: var(--blurple);
  box-shadow: inset 0 0 0 1px var(--blurple);
}
.font-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.font-group-name {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 5px 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
}
.font-group-count {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}
.font-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  cursor: grab;
}
body.font-row-dragging,
body.font-row-dragging * { cursor: grabbing !important; }
.font-row-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  width: 46%;
  min-width: 0;
}
.font-row-file {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.font-row-weight-label { flex: none; font-size: 12px; color: var(--muted); }
.font-row-weight {
  flex: none;
  width: 96px;
  min-height: 0;
  padding: 4px 6px;
  font-size: 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-input);
}
.font-row-sample {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.font-row-del {
  flex: none;
  min-height: 0;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.font-row-del:hover { background: var(--danger); color: #fff; }
.font-empty { color: var(--muted); font-size: 13px; padding: 12px 2px; }
.font-manager-foot { margin-top: 10px; }
.font-manager-msg { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.font-manager-msg.ok { color: var(--green); }
/* 글꼴 파일 드래그&드롭 오버레이 */
.font-drop-hint {
  position: absolute;
  inset: 8px;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--blurple);
  border-radius: var(--radius-sm);
  background: rgba(88, 101, 242, 0.14);
  color: var(--heading);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}
.font-manager.font-dragging .font-drop-hint { display: flex; }

/* ─── 모니터 선택(듀얼모니터 화면 공유) ─────── */
.monitor-picker-backdrop { z-index: 260; }
.monitor-picker { width: min(94vw, 460px); }
.monitor-map {
  position: relative;
  margin: 6px auto 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-deepest);
  border: 1px solid var(--line);
}
.monitor-tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.monitor-tile:hover {
  border-color: var(--blurple);
  background: rgba(88, 101, 242, 0.22);
  color: var(--heading);
  transform: translateY(-1px);
}
.monitor-tile-cursor { border-color: var(--green); }
.monitor-tile-num { font-size: 18px; font-weight: 800; line-height: 1; }
.monitor-tile-meta { font-size: 10px; line-height: 1.15; text-align: center; color: var(--muted); }
.monitor-tile:hover .monitor-tile-meta { color: var(--text); }
.camera-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.camera-option {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.camera-option:hover { background: rgba(88, 101, 242, 0.18); border-color: var(--blurple); color: var(--heading); }
.img-viewer {
  display: flex;
  flex-direction: column;
  width: min(92vw, 900px);
  max-height: 90vh;
  background: var(--bg-base);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.img-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.img-viewer-title {
  color: var(--heading);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.img-viewer-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.img-viewer-close:hover { background: var(--bg-elevated); color: var(--text); }
.img-viewer-stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  overflow: hidden;
  background:
    repeating-conic-gradient(#2a2c30 0% 25%, #303338 0% 50%) 50% / 22px 22px;
  touch-action: none;
}
.img-viewer-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.img-viewer.cropping .img-viewer-img { pointer-events: none; }
.img-crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
  cursor: move;
}
.img-crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 50%;
}
.img-crop-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.img-crop-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.img-crop-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.img-crop-handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.img-viewer-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}
.img-viewer-hint { color: var(--muted); font-size: 12px; }

/* ===== 이모지 피커 ===== */
.emoji-picker {
  position: absolute;
  right: 12px;
  bottom: calc(100% - 6px);
  z-index: 30;
  width: 300px;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.emoji-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--heading);
  font-size: 13px;
  font-weight: 600;
}
.emoji-picker-close {
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.emoji-picker-close:hover { background: var(--bg-surface); color: var(--text); }
.emoji-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}
.emoji-section-title {
  margin: 6px 2px 4px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.emoji-empty {
  margin: 2px;
  color: var(--muted);
  font-size: 12px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}
.emoji-grid.unicode { grid-template-columns: repeat(8, 1fr); }
.emoji-cell { position: relative; }
.emoji-btn {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  padding: 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.emoji-btn:hover { background: var(--bg-surface); }
.emoji-btn.uni { font-size: 20px; line-height: 1; }
.emoji-btn-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.emoji-del {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  display: grid;
  place-items: center;
}
.emoji-cell:hover .emoji-del { opacity: 1; }
.emoji-picker-foot {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.emoji-picker-foot .primary { width: 100%; }
