:root {
  --bg: #ffffff;
  --fg: #37352f;
  --muted: #787774;
  --faint: #a5a29c;
  --side: #f7f7f5;
  --hover: rgba(55, 53, 47, 0.07);
  --active: rgba(55, 53, 47, 0.1);
  --border: rgba(55, 53, 47, 0.13);
  --accent: #2383e2;
  --accent-fg: #ffffff;
  --code-bg: #f6f5f2;
  --inline-code: #eb5757;
  --callout: #f1f1ef;
  --danger: #e03e3e;
  --sel: rgba(35, 131, 226, 0.2);
  --shadow: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 4px 10px rgba(15, 15, 15, 0.08), 0 12px 32px rgba(15, 15, 15, 0.12);
  --font: "Pretendard Variable", Pretendard, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "D2Coding", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919;
    --fg: #e3e2e0;
    --muted: #9b9a97;
    --faint: #6f6e69;
    --side: #202020;
    --hover: rgba(255, 255, 255, 0.06);
    --active: rgba(255, 255, 255, 0.1);
    --border: rgba(255, 255, 255, 0.1);
    --code-bg: #252525;
    --inline-code: #ff7369;
    --callout: #262626;
    --sel: rgba(35, 131, 226, 0.35);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 28px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* 가로 스와이프가 브라우저의 뒤로 가기로 넘어가지 않게(사이드바 열기에 쓴다) */
html, body { overscroll-behavior-x: none; }
body { background: var(--bg); color: var(--fg); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
::selection { background: var(--sel); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
kbd { font: 11px var(--font); color: var(--faint); margin-left: auto; }
.ic { display: block; flex: none; }

/* ---------- 공통 컨트롤 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 6px; font-size: 14px; text-decoration: none;
  border: 1px solid var(--border); background: var(--bg); white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; }
.btn.block { width: 100%; height: 38px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.on { color: var(--accent); }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 6px;
  color: #fff; font-size: 12px; font-weight: 600;
}
.avatar.sm { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg); }
.avatar.more { background: var(--muted); font-size: 11px; }

/* ---------- 인증 ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.auth-logo { font-size: 40px; text-align: center; }
.auth-card h1 { margin: 0; font-size: 24px; text-align: center; }
.auth-sub { margin: -8px 0 8px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card input {
  height: 38px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); font-size: 15px;
}
.auth-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.auth-error { color: var(--danger); font-size: 13px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* ---------- 레이아웃 ---------- */
.shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 248px; flex: none; display: flex; flex-direction: column; background: var(--side);
  border-right: 1px solid var(--border); transition: margin-left 0.18s ease; font-size: 14px;
}
.shell.side-collapsed .sidebar { margin-left: -248px; }
.side-top { padding: 8px 6px 4px; }
.ws-switch {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin-bottom: 4px;
  border-radius: 6px; font-weight: 600; text-align: left;
}
.ws-switch:hover { background: var(--hover); }
.ws-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-caret { display: grid; color: var(--faint); }
.ws-caret .ic { width: 14px; height: 14px; transform: rotate(90deg); }
.ws-icon {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 5px; font-size: 16px; line-height: 1;
}
.ws-icon.letter { color: #fff; font-size: 12px; font-weight: 700; }
.ws-icon.sm { width: 20px; height: 20px; font-size: 14px; }
.ws-icon.lg { width: 56px; height: 56px; border-radius: 12px; font-size: 40px; }
.ws-icon.lg.letter { font-size: 26px; }
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 30px; padding: 0 10px;
  border-radius: 6px; color: var(--muted); text-align: left;
}
.side-item:hover { background: var(--hover); color: var(--fg); }
.side-item .ic { width: 16px; height: 16px; color: var(--faint); }
.side-item:hover .ic { color: var(--muted); }
.side-scroll { flex: 1; overflow-y: auto; padding: 0 6px 12px; }
.side-section { margin-top: 10px; }
.side-label { display: flex; align-items: center; height: 26px; padding: 0 4px 0 2px; }
.side-label-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; height: 24px; padding: 0 6px 0 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600; color: var(--faint); text-align: left; white-space: nowrap; overflow: hidden;
}
.side-label-toggle:hover { color: var(--muted); }
.side-label-toggle .ic { width: 12px; height: 12px; transform: rotate(90deg); transition: transform 0.12s; opacity: 0; }
.side-label-toggle span { overflow: hidden; text-overflow: ellipsis; }
.side-label:hover .side-label-toggle .ic, .side-section.collapsed .side-label-toggle .ic { opacity: 1; }
.side-section.collapsed .side-label-toggle .ic { transform: none; }
.side-section.collapsed > .tree { display: none; }
.side-add { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; color: var(--faint); opacity: 0; }
.side-add .ic { width: 14px; height: 14px; }
.side-label:hover .side-add, .side-add:focus-visible { opacity: 1; }
.side-add:hover { background: var(--active); color: var(--fg); }
.side-user { display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 12px; border-top: 1px solid var(--border); }
.side-user .dm-avatar { width: 28px; height: 28px; border-radius: 50%; font-size: 12px; }
.side-user .dm-avatar .dot { border-color: var(--side); }
.side-user-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.side-user-name b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-name span { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .icon-btn { width: 28px; height: 28px; }
.side-user .icon-btn .ic { width: 16px; height: 16px; }
.me-line { padding: 4px 10px; font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty { padding: 4px 10px; color: var(--faint); font-size: 13px; }
.tree-row {
  display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px 0 calc(6px + var(--depth) * 16px);
  border-radius: 6px; cursor: pointer; color: var(--muted);
}
.tree-row:hover { background: var(--hover); }
.tree-row.active { background: var(--active); color: var(--fg); font-weight: 500; }
.tree-toggle { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 4px; color: var(--faint); flex: none; }
.tree-toggle .ic { width: 12px; height: 12px; transition: transform 0.12s; }
.tree-toggle.open .ic { transform: rotate(90deg); }
.tree-toggle:hover { background: var(--active); }
.tree-toggle.leaf { visibility: hidden; }
.tree-icon { width: 20px; text-align: center; flex: none; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: none; gap: 2px; flex: none; }
.tree-row:hover .tree-actions { display: flex; }
.tree-actions button { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; color: var(--muted); }
.tree-actions .ic { width: 14px; height: 14px; }
.tree-actions button:hover { background: var(--active); color: var(--fg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 46px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 14px; }
.brand { font-weight: 600; text-decoration: none; white-space: nowrap; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; white-space: nowrap; }
.crumb { padding: 2px 6px; border-radius: 4px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.crumb:hover { background: var(--hover); }
.crumb-sep { color: var(--faint); }
.top-right { display: flex; align-items: center; gap: 6px; flex: none; }
.presence { display: flex; }
.presence .avatar + .avatar { margin-left: -6px; }
.status { font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 10px; background: var(--hover); }
.status[data-status="offline"] { color: var(--danger); }
.scroller { flex: 1; overflow-y: auto; }
.scrim { display: none; }

/* ---------- 페이지 / 에디터 ---------- */
.page { max-width: 820px; margin: 0 auto; padding: 72px 96px 30vh; }
.loading { color: var(--faint); padding: 40px 0; }
.empty-state { text-align: center; padding: 12vh 0; }
.empty-emoji { font-size: 48px; }
.empty-state h2 { margin: 12px 0 6px; font-size: 22px; }
.empty-state p { color: var(--muted); margin: 0 0 20px; }

.page-head { margin-bottom: 8px; }
.page-icon-row { min-height: 32px; display: flex; align-items: flex-end; }
.page-icon { font-size: 64px; line-height: 1.1; border-radius: 8px; padding: 4px; margin-left: -4px; }
.page:not(.readonly) .page-icon:hover { background: var(--hover); }
.add-icon { font-size: 14px; color: var(--faint); padding: 4px 8px; border-radius: 6px; opacity: 0; transition: opacity 0.12s; margin-left: -8px; }
.page-head:hover .add-icon, .add-icon:focus-visible { opacity: 1; }
.add-icon:hover { background: var(--hover); color: var(--muted); }
.page-title { font-size: 40px; font-weight: 700; line-height: 1.2; margin: 8px 0 12px; outline: none; word-break: break-word; }
.page-title.empty::before { content: attr(data-ph); color: var(--faint); opacity: 0.6; pointer-events: none; }

.blocks { counter-reset: ol; }
.block { position: relative; display: flex; padding: 2px 0; }
.block:not([data-type="ol"]) { counter-reset: ol; }
.block[data-type="ol"] { counter-increment: ol; }
.gutter {
  position: absolute; left: -52px; top: 3px; width: 48px; display: flex; justify-content: flex-end; gap: 2px;
  opacity: 0; transition: opacity 0.1s; user-select: none;
}
.block:hover .gutter { opacity: 1; }
.gutter .add, .gutter .handle {
  display: grid; place-items: center; width: 22px; height: 24px; border-radius: 4px; color: var(--faint); font-size: 16px;
}
.gutter .handle { font-size: 12px; letter-spacing: -2px; cursor: grab; }
.gutter .add:hover, .gutter .handle:hover { background: var(--hover); color: var(--muted); }
.readonly .gutter { display: none; }
.block[data-type="h1"] .gutter { top: 22px; }
.block[data-type="h2"] .gutter { top: 16px; }
.block[data-type="h3"] .gutter { top: 10px; }
.block.dragging { opacity: 0.4; }
.block.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.block.drop-after { box-shadow: 0 2px 0 var(--accent); }

.body { display: flex; flex: 1; min-width: 0; }
.prefix { display: none; flex: none; justify-content: center; width: 26px; line-height: 1.65; user-select: none; }
.content {
  position: relative; flex: 1; min-width: 0; min-height: 1.65em; line-height: 1.65; padding: 1px 2px;
  outline: none; white-space: pre-wrap; word-break: break-word; caret-color: var(--fg);
}
.block.empty .content::before {
  content: attr(data-ph); position: absolute; left: 2px; color: var(--faint); pointer-events: none;
}
.block[data-type="p"].empty .content:not(:focus)::before { content: none; }
.readonly .block.empty .content::before { content: none; }
.content a { color: inherit; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 2px; }
.content code {
  font-family: var(--mono); font-size: 0.86em; padding: 0.15em 0.35em; border-radius: 4px;
  background: var(--code-bg); color: var(--inline-code);
}
.content mark { background: #fbf3db; color: inherit; }

.block[data-type="h1"] { margin-top: 1.4em; }
.block[data-type="h2"] { margin-top: 1.1em; }
.block[data-type="h3"] { margin-top: 0.8em; }
.block[data-type="h1"] .content { font-size: 1.875em; font-weight: 700; line-height: 1.3; }
.block[data-type="h2"] .content { font-size: 1.5em; font-weight: 650; line-height: 1.3; }
.block[data-type="h3"] .content { font-size: 1.25em; font-weight: 600; line-height: 1.3; }

.block[data-type="ul"] .prefix, .block[data-type="ol"] .prefix, .block[data-type="todo"] .prefix { display: flex; }
.block[data-type="ul"] .prefix::before { content: "•"; font-size: 1.4em; line-height: 1.2; }
.block[data-type="ol"] .prefix::before { content: counter(ol) "."; }
.block[data-type="todo"] .prefix { align-items: flex-start; padding-top: 5px; }
.cb { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.block.checked .content { text-decoration: line-through; color: var(--faint); }

.block[data-type="quote"] .content { border-left: 3px solid currentColor; padding-left: 14px; }
.block[data-type="callout"] .body { background: var(--callout); border-radius: 6px; padding: 14px 16px 14px 12px; margin: 2px 0; }
.block[data-type="callout"] .prefix { display: flex; width: 30px; }
.block[data-type="callout"] .prefix::before { content: "💡"; }
.block[data-type="callout"] .gutter { top: 15px; }
.block[data-type="code"] .content {
  font-family: var(--mono); font-size: 14px; line-height: 1.6; tab-size: 2;
  background: var(--code-bg); border-radius: 6px; padding: 16px 18px; margin: 4px 0; overflow-x: auto; white-space: pre;
}
.block[data-type="code"].empty .content::before { left: 18px; }
.block[data-type="code"] .gutter { top: 14px; }
.block[data-type="divider"] .content { display: none; }
.block[data-type="divider"] .body { align-items: center; min-height: 26px; }
.block[data-type="divider"] .body::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.block[data-type="page"] .content { cursor: pointer; border-radius: 4px; display: flex; gap: 6px; align-items: center; }
.block[data-type="page"] .content:hover { background: var(--hover); }
.page-link-title { font-weight: 500; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }

.block.peer-focus .body { box-shadow: -3px 0 0 var(--peer); }
.block.peer-focus::after {
  content: attr(data-peer); position: absolute; right: 0; top: -9px; font-size: 10.5px; line-height: 1;
  padding: 3px 6px; border-radius: 4px; background: var(--peer); color: #fff; pointer-events: none;
}

.blocks-tail { min-height: 120px; cursor: text; }
.readonly .blocks-tail { cursor: default; }

/* ---------- 메뉴 / 팝오버 ---------- */
.menu, .popover {
  position: fixed; z-index: 50; min-width: 220px; max-width: 320px; max-height: 340px; overflow-y: auto;
  padding: 6px; border-radius: 8px; background: var(--bg); box-shadow: var(--shadow); font-size: 14px;
}
.menu-section { padding: 6px 8px 4px; font-size: 12px; color: var(--faint); font-weight: 500; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 6px; text-align: left; }
.menu-item:hover, .menu-item.active { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-icon {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); font-size: 13px; font-weight: 600;
}
.popover .menu-icon, .menu-item.danger .menu-icon { width: 20px; height: 20px; border: 0; }
.menu-text { display: flex; flex-direction: column; min-width: 0; }
.menu-desc { font-size: 12px; color: var(--muted); }
.emoji-menu { width: 300px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 4px; }
.emoji-grid button { font-size: 20px; height: 32px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--hover); }

.format-bar {
  position: fixed; z-index: 40; display: flex; padding: 3px; gap: 1px; border-radius: 7px; background: var(--bg); box-shadow: var(--shadow);
}
.format-bar button { min-width: 30px; height: 28px; padding: 0 6px; border-radius: 5px; font-size: 14px; }
.format-bar button:hover { background: var(--hover); }

/* ---------- 모달 ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(15, 15, 15, 0.35); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.modal { width: 100%; max-width: 520px; background: var(--bg); border-radius: 10px; box-shadow: var(--shadow); padding: 18px 20px; }
.modal h3 { margin: 0 0 2px; font-size: 16px; }
.invite { display: flex; gap: 6px; margin: 14px 0 10px; }
.invite input, .modal select, .share-link input {
  height: 32px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); font-size: 14px; min-width: 0;
}
.invite input { flex: 1; }
.members { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.members li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.member-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.member-info .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-public { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; margin-top: 6px; border-top: 1px solid var(--border); font-size: 14px; }
.share-link { display: flex; gap: 6px; }
.share-link input { flex: 1; color: var(--muted); }

.search-modal { padding: 0; overflow: hidden; max-width: 600px; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.search-input { flex: 1; height: 52px; border: 0; outline: none; background: none; font-size: 17px; }
.search-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.search-item { display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 6px; text-align: left; }
.search-item.active, .search-item:hover { background: var(--hover); }
.search-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.search-text .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 16px 10px; font-size: 14px; }

.btn.danger { color: var(--danger); }

/* 이미지 블록 */
.block[data-type="image"] .content { cursor: default; padding: 4px 0; }
.block[data-type="image"] img { display: block; max-width: 100%; max-height: 70vh; border-radius: 6px; }
.block[data-type="image"] .gutter { top: 8px; }

/* 휴지통 */
.trash-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.trash-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.trash-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 24px;
  border-radius: 8px; background: rgba(224, 62, 62, 0.1); font-size: 14px;
}
.trash-banner > span:first-child { flex: 1; min-width: 180px; }

/* 버전 기록 */
.history-modal { max-width: 960px; display: flex; padding: 0; overflow: hidden; height: min(76vh, 720px); }
.history-list { width: 240px; flex: none; overflow-y: auto; padding: 16px 8px; border-right: 1px solid var(--border); }
.history-list h3 { padding: 0 8px 8px; }
.history-item { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px; border-radius: 6px; text-align: left; font-size: 14px; }
.history-item:hover, .history-item.active { background: var(--hover); }
.history-preview { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.history-doc { flex: 1; overflow-y: auto; padding: 24px 40px 48px; }
.history-doc .page-title { font-size: 32px; }

.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* 워크스페이스 */
.ws-menu { min-width: 260px; }
.ws-item .menu-label { font-weight: 500; }
.ws-item.current { background: var(--hover); }
.ws-check { margin-left: auto; color: var(--accent); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.ws-form { display: flex; gap: 6px; margin-top: 12px; }
.ws-form input {
  height: 34px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); font-size: 14px; min-width: 0; flex: 1;
}
.ws-form .ws-icon-input { flex: none; width: 46px; text-align: center; font-size: 18px; padding: 0; }
.ws-form input:disabled { color: var(--fg); background: var(--hover); }
.ws-settings-modal { max-width: 560px; max-height: 84vh; overflow-y: auto; }
.ws-sec { padding: 14px 0; border-top: 1px solid var(--border); }
.ws-sec:first-of-type { border-top: 0; padding-top: 0; }
.ws-sec h4 { margin: 0 0 4px; font-size: 14px; }
.ws-sec .invite { margin-top: 8px; }
.ws-sec .share-public { border-top: 0; margin: 0; padding: 0 0 10px; }
.role-tag { white-space: nowrap; }
.avatar.pending { background: var(--faint); font-size: 12px; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.share-ws {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: var(--hover); font-size: 13px;
}
.join-card { text-align: center; align-items: center; }
.join-card .btn.block { width: 100%; }
.join-icon { margin-bottom: 4px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #2f2f2f; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); transition: opacity 0.3s, transform 0.3s; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- 채팅 ---------- */
.channel-row {
  position: relative; display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px;
  border-radius: 6px; cursor: pointer; color: var(--muted);
}
.channel-row:hover { background: var(--hover); }
.channel-row.active { background: var(--active); color: var(--fg); font-weight: 500; }
.channel-row.unread { color: var(--fg); font-weight: 650; }
.channel-row.unread::before {
  content: ""; position: absolute; left: -6px; top: 11px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--fg);
}
.channel-row:hover .tree-actions { display: flex; }
.channel-hash { width: 20px; text-align: center; color: var(--faint); font-size: 17px; font-weight: 400; flex: none; }
.badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; flex: none;
}
.crumb.chan { display: inline-flex; align-items: center; font-weight: 600; }
.crumb.chan .channel-hash { width: auto; margin-right: 4px; }
.chan-topic {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 13px;
  margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--border);
}

.chat-view { flex: 1; min-height: 0; display: flex; border-top: 1px solid var(--border); }
.chat-main { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.chat-log { min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 8px 0 12px; }
.chat-log .loading { padding: 12px 16px; text-align: center; font-size: 13px; }
.chat-intro { padding: 24px 16px 8px; }
.chat-intro-icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--hover); color: var(--muted); font-size: 36px;
}
.chat-intro h2 { margin: 12px 0 2px; font-size: 26px; }
.chat-intro p { margin: 0; }

.msg-day { display: flex; align-items: center; gap: 8px; margin: 18px 16px 4px; font-size: 12px; font-weight: 600; color: var(--faint); }
.msg-day::before, .msg-day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg-row { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); padding: 2px 56px 2px 16px; margin-top: 14px; }
.msg.cont .msg-row { margin-top: 0; }
.msg-row:hover { background: var(--hover); }
.msg.mentioned .msg-row { background: rgba(223, 171, 1, 0.1); box-shadow: inset 2px 0 0 #dfab01; }
.msg.flash .msg-row { animation: msg-flash 1.6s ease; }
@keyframes msg-flash { from { background: rgba(35, 131, 226, 0.25); } to { background: transparent; } }

.msg-reply {
  position: relative; grid-column: 2; display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 2px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.msg-reply::before {
  content: ""; position: absolute; left: -36px; top: 9px; width: 28px; height: 10px;
  border-left: 2px solid var(--border); border-top: 2px solid var(--border); border-top-left-radius: 6px;
}
.msg-reply b { flex: none; font-weight: 600; color: var(--fg); }
.reply-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-reply:hover .reply-text { color: var(--fg); }
.msg-gutter { grid-column: 1; padding-top: 2px; }
.msg-main { grid-column: 2; min-width: 0; }
.avatar.md { position: relative; width: 40px; height: 40px; border-radius: 50%; font-size: 16px; }
.avatar.xs { width: 16px; height: 16px; border-radius: 50%; font-size: 9px; }
.msg-hover-time { display: block; font-size: 11px; line-height: 22px; color: var(--faint); visibility: hidden; white-space: nowrap; }
.msg-row:hover .msg-hover-time { visibility: visible; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-head time { font-size: 12px; color: var(--faint); }
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: 15px; line-height: 1.45; }
.msg-body.jumbo { font-size: 44px; line-height: 1.2; }
.msg-body code { font-family: var(--mono); font-size: 0.86em; padding: 0.15em 0.35em; border-radius: 4px; background: var(--code-bg); }
.msg-body .md-pre { margin: 4px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--code-bg); white-space: pre; overflow-x: auto; }
.msg-body .md-pre code { padding: 0; background: none; font-size: 13.5px; }
.msg-body blockquote { margin: 0; padding-left: 10px; border-left: 4px solid var(--border); }
.msg-body a { color: var(--accent); text-decoration: none; }
.msg-body a:hover { text-decoration: underline; }
.mention { padding: 0 2px; border-radius: 3px; background: rgba(35, 131, 226, 0.15); color: var(--accent); font-weight: 500; }
.spoiler { border-radius: 3px; background: var(--fg); color: transparent; cursor: pointer; }
.spoiler.shown { background: var(--active); color: inherit; cursor: auto; }
.edited { margin-left: 4px; font-size: 11px; color: var(--faint); }
/* 보내는 중: 처음엔 평소대로, 잠시 뒤에도 확인이 없으면(--slow-after) 흐리게 */
.msg.pending .msg-body, .msg.pending .msg-attachments { animation: msg-slow 0.25s ease var(--slow-after, 1.5s) both; }
@keyframes msg-slow { from { opacity: 1; } to { opacity: 0.5; } }
.msg.failed .msg-body { color: var(--danger); }
.msg-failed { font-size: 12px; color: var(--danger); }
.msg-failed button { color: var(--accent); text-decoration: underline; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 8px;
  border: 1px solid transparent; background: var(--hover); font-size: 14px;
}
.reaction:hover { border-color: var(--border); }
.reaction .count { font-size: 12px; font-weight: 600; color: var(--muted); }
.reaction.on { border-color: var(--accent); background: rgba(35, 131, 226, 0.15); }
.reaction.on .count { color: var(--accent); }

.msg-actions {
  position: absolute; top: -14px; right: 16px; z-index: 1; display: none; padding: 2px; border-radius: 6px;
  background: var(--bg); box-shadow: var(--shadow);
}
.msg-row:hover .msg-actions { display: flex; }
.msg-actions button { display: grid; place-items: center; width: 30px; height: 28px; border-radius: 4px; color: var(--muted); }
.msg-actions .ic { width: 16px; height: 16px; }
.msg-actions button:hover { background: var(--hover); color: var(--fg); }
.msg-actions button.danger:hover { color: var(--danger); }
.msg-edit-box textarea {
  display: block; width: 100%; resize: none; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--code-bg); font: inherit; font-size: 15px; line-height: 1.45; outline: none; color: inherit;
}
.msg-edit-box .small { margin: 2px 0 4px; }
.msg-edit-box button { color: var(--accent); }
.react-picker { display: grid; grid-template-columns: repeat(6, 36px); gap: 2px; min-width: 0; }
.react-picker button { height: 36px; border-radius: 6px; font-size: 20px; }
.react-picker button:hover { background: var(--hover); }

.chat-jump {
  position: absolute; left: 50%; bottom: 96px; z-index: 2; transform: translateX(-50%); padding: 6px 14px; border-radius: 16px;
  background: var(--accent); color: #fff; font-size: 13px; box-shadow: var(--shadow);
}
.chat-compose { position: relative; padding: 0 16px 2px; }
.compose-box { display: flex; padding: 0 12px 0 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--code-bg); }
.compose-box:focus-within { border-color: var(--faint); }
.compose-box textarea {
  flex: 1; max-height: 240px; padding: 11px 0; border: 0; outline: none; resize: none; background: none;
  font: inherit; font-size: 15px; line-height: 1.45; color: inherit;
}
.reply-bar {
  display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 14px; border: 1px solid var(--border);
  border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--hover); font-size: 13px; color: var(--muted);
}
.reply-bar b { color: var(--fg); }
.reply-bar:not([hidden]) + .compose-box { border-top-left-radius: 0; border-top-right-radius: 0; }
.typing-line { display: flex; align-items: center; gap: 4px; height: 22px; padding-left: 2px; overflow: hidden; white-space: nowrap; font-size: 12px; color: var(--muted); }
.typing-line b { color: var(--fg); }
.typing-dots { display: inline-flex; gap: 2px; margin-right: 2px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.mention-suggest {
  position: absolute; left: 16px; right: 16px; bottom: 100%; z-index: 5; max-height: 300px; overflow-y: auto; margin-bottom: 4px;
  padding: 6px; border-radius: 8px; background: var(--bg); box-shadow: var(--shadow); font-size: 14px;
}
.mention-suggest .menu-desc { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-side { display: none; flex: none; min-height: 0; border-left: 1px solid var(--border); background: var(--side); }
.chat-view.members-open .chat-side, .chat-view.thread-open .chat-side { display: flex; }
.chat-members { display: none; width: 240px; overflow-y: auto; padding: 0 8px 16px; }
.chat-view.members-open:not(.thread-open) .chat-members { display: block; }
.chat-thread { display: none; width: 420px; min-height: 0; flex-direction: column; background: var(--bg); }
.chat-view.thread-open .chat-thread { display: flex; }
.thread-head { display: flex; align-items: center; gap: 8px; height: 46px; flex: none; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.thread-ch { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-pane { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.thread-root .msg-row { margin-top: 8px; }
.thread-divider { display: flex; align-items: center; gap: 8px; margin: 8px 16px 0; font-size: 12px; font-weight: 600; color: var(--faint); }
.thread-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.thread-summary {
  display: inline-flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; padding: 4px 10px; border: 1px solid transparent; border-radius: 6px;
  background: var(--hover); font-size: 13px; font-weight: 500; color: var(--accent); text-align: left;
}
.thread-summary:hover { border-color: var(--border); }
.thread-summary .muted { font-weight: 400; }
.members-label { padding: 16px 8px 4px; font-size: 12px; font-weight: 600; color: var(--faint); }
.member-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 5px 8px; border-radius: 6px; text-align: left; font-size: 14px; opacity: 0.5; }
.member-row.online { opacity: 1; }
.member-row:hover { background: var(--hover); opacity: 1; }
.member-row .avatar.md { width: 32px; height: 32px; font-size: 14px; }
.avatar .dot {
  position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%;
  border: 3px solid var(--side); background: var(--faint);
}
.member-row.online .dot, .avatar .dot.on { background: #23a55a; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-role { flex: none; font-size: 12px; }
.chat-missing { flex: 1; }

.channel-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.channel-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.channel-form input {
  height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 14px; color: var(--fg);
}
.channel-name-input { display: flex; align-items: center; padding-left: 10px; border: 1px solid var(--border); border-radius: 6px; }
.channel-name-input > span { color: var(--faint); font-size: 16px; }
.channel-name-input input { flex: 1; min-width: 0; border: 0; outline: none; padding-left: 6px; }
.channel-name-input:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }

/* 첨부 파일 */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.att-img { display: block; max-width: 100%; }
.att-img img {
  display: block; max-width: min(360px, 100%); max-height: 300px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--code-bg); object-fit: contain;
}
.att-file {
  display: flex; align-items: center; gap: 10px; width: min(380px, 100%); padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--code-bg); text-decoration: none;
}
.att-file:hover { border-color: var(--faint); }
.att-icon { flex: none; font-size: 24px; }
.att-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.att-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-file .att-meta b { color: var(--accent); }
.att-dl { color: var(--muted); }
.att-tray {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 8px 8px 0 0; background: var(--code-bg);
}
.reply-bar:not([hidden]) + .att-tray { border-radius: 0; }
.att-tray:not([hidden]) + .compose-box, .reply-bar:not([hidden]) ~ .compose-box { border-top-left-radius: 0; border-top-right-radius: 0; }
.att-chip { display: flex; align-items: center; gap: 8px; flex: none; width: 210px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.att-chip img { width: 40px; height: 40px; flex: none; border-radius: 4px; object-fit: cover; }
.att-chip .att-icon { width: 40px; text-align: center; }
.att-chip.uploading { opacity: 0.6; }
.att-chip.error { border-color: var(--danger); }
.compose-add {
  flex: none; align-self: flex-start; width: 26px; height: 26px; margin: 9px 10px 0 -4px; border-radius: 50%;
  background: var(--active); color: var(--muted); font-size: 16px; line-height: 1;
}
.compose-add:hover { color: var(--fg); }
.drop-target::after {
  content: "여기에 놓으면 첨부됩니다"; position: absolute; inset: 8px; z-index: 10; display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 10px; background: rgba(35, 131, 226, 0.08); color: var(--accent); font-weight: 600; pointer-events: none;
}

/* DM / 멤버 카드 / 검색 */
.avatar.xl { position: relative; width: 72px; height: 72px; border-radius: 50%; font-size: 30px; }
.chat-intro .avatar.xl { margin-bottom: 4px; }
.member-card { width: 270px; }
.member-card-top { padding: 8px 8px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.member-card-top .dot { border-color: var(--bg); width: 18px; height: 18px; right: 0; bottom: 0; }
.member-card-name { margin-top: 8px; font-size: 17px; font-weight: 700; }
.dm-avatar { position: relative; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; }
.dm-avatar .dot { right: -3px; bottom: -3px; width: 10px; height: 10px; border-width: 2px; }
.chat-tools { display: inline-flex; gap: 2px; }
.dm-filter { width: 100%; height: 34px; margin: 12px 0 6px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 14px; }
.dm-pick-item { padding: 8px !important; border-radius: 6px; cursor: pointer; }
.dm-pick-item:hover { background: var(--hover); }
.chat-search-scope { flex: none; max-width: 170px; height: 30px; border: 0; border-radius: 6px; background: var(--hover); font-size: 13px; }
.chat-search-snippet { font-size: 14px; white-space: normal; word-break: break-word; }
.search-results mark { border-radius: 2px; background: rgba(223, 171, 1, 0.35); color: inherit; }

/* ---------- 음성 채널 ---------- */
.channel-hash svg, .channel-name-input > span svg { display: block; width: 16px; height: 16px; margin: 0 auto; }
.voice-row.joined { color: var(--fg); }
.voice-users { padding: 0 0 4px 26px; }
.voice-user { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.voice-avatar { width: 20px; height: 20px; border-radius: 50%; font-size: 10px; transition: box-shadow 0.12s; }
.voice-user.speaking { color: var(--fg); }
.voice-user.speaking .voice-avatar { box-shadow: 0 0 0 2px var(--side), 0 0 0 4px #23a55a; }
.vu-icon { flex: none; display: inline-flex; color: var(--faint); }
.vu-icon svg { width: 14px; height: 14px; }
.vu-icon.off { color: var(--danger); }
.live-badge { flex: none; padding: 0 4px; border-radius: 4px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; }

.vbtn { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--hover); color: var(--fg); }
.vbtn:hover { background: var(--active); }
.vbtn.off { color: var(--danger); }
.vbtn.active { background: var(--accent); color: var(--accent-fg); }
.vbtn.leave { background: var(--danger); color: #fff; }
.vbtn.leave:hover { filter: brightness(1.1); }

.voice-panel { padding: 8px 8px 6px; border-top: 1px solid var(--border); font-size: 13px; }
.vp-top { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.vp-info { flex: 1; min-width: 0; }
.vp-status { display: block; color: var(--muted); font-weight: 600; }
.vp-status.ok { color: #23a55a; }
.vp-ch { display: flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-ch svg { flex: none; width: 13px; height: 13px; }
.vp-ch:hover { color: var(--fg); text-decoration: underline; }
.voice-panel .vbtn { width: 32px; height: 32px; border-radius: 6px; background: none; color: var(--muted); }
.voice-panel .vbtn:hover { background: var(--hover); color: var(--fg); }
.voice-panel .vbtn.off { color: var(--danger); }
.voice-panel .vbtn.active { background: var(--accent); color: var(--accent-fg); }
.voice-panel .vbtn.leave { background: none; color: var(--danger); }
.voice-panel .vbtn.leave:hover { background: var(--hover); }
.vp-controls { display: flex; justify-content: space-between; margin-top: 6px; }

.voice-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--side); }
.voice-lobby { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px 16px; text-align: center; }
.voice-lobby h2 { margin: 6px 0 0; font-size: 22px; }
.voice-lobby p { margin: 0 0 8px; }
.voice-lobby-icon svg { width: 56px; height: 56px; color: var(--faint); }
.voice-lobby-people { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 12px; }
.voice-lobby .btn { height: 40px; padding: 0 20px; font-size: 15px; }
.voice-grid {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 8px;
  width: 100%; margin: 0 auto; padding: 16px;
  /* 타일(16:9)이 세로로 넘치지 않을 만큼만 넓힌다. */
  max-width: min(1400px, calc((100dvh - 190px) / var(--rows, 1) * 16 / 9 * var(--cols, 1) + 32px));
}
.voice-grid.focused { max-width: 1400px; align-content: flex-start; }
.voice-grid.focused .vtile.big { flex-basis: 100%; order: -1; max-height: calc(100dvh - 330px); aspect-ratio: auto; min-height: 240px; }
.vtile {
  position: relative; flex: 0 0 calc((100% - (var(--cols, 1) - 1) * 8px) / var(--cols, 1)); aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: 10px; background: #232428; color: #fff; cursor: pointer;
}
.vtile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; transition: box-shadow 0.12s; }
.vtile.speaking::after { box-shadow: inset 0 0 0 3px #23a55a; }
.vtile video { position: absolute; inset: 0; display: none; width: 100%; height: 100%; object-fit: cover; }
.vtile.has-video video { display: block; }
.vtile.screen video { object-fit: contain; background: #000; }
.vtile.mirror video { transform: scaleX(-1); }
.vt-center { position: absolute; inset: 0; display: grid; place-items: center; }
.vtile.has-video .vt-center { display: none; }
.vt-avatar { width: clamp(48px, 22%, 96px); height: auto; aspect-ratio: 1; border-radius: 50%; font-size: clamp(20px, 3vw, 40px); }
.vt-screen-icon svg { width: 40px; height: 40px; opacity: 0.5; }
.vt-note:not(:empty) { position: absolute; top: 8px; left: 8px; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.55); font-size: 12px; }
.vt-label {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 4px; max-width: calc(100% - 16px);
  padding: 3px 4px 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.55); font-size: 13px;
}
.vt-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 4px; }
.vt-label i { display: inline-flex; color: #f23f43; }
.vt-label svg { width: 14px; height: 14px; }
.vt-menu { width: 20px; height: 20px; border-radius: 4px; color: #fff; opacity: 0; }
.vtile:hover .vt-menu, .vt-menu:focus-visible { opacity: 1; }
.vt-menu:hover { background: rgba(255, 255, 255, 0.2); }
.voice-bar { display: flex; justify-content: center; gap: 12px; flex: none; padding: 4px 16px 18px; }
.voice-pop { position: fixed; z-index: 70; width: 260px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.vol-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.vol-row { display: flex; align-items: center; gap: 8px; }
.vol-row input { flex: 1; min-width: 0; }
.vol-val { width: 38px; text-align: right; color: var(--muted); }
.voice-settings label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.voice-settings select { height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--fg); }
.voice-settings p { margin: 0; }

/* 팝업: 별도 창(PiP)과 앱 안의 작은 창이 같은 통화 화면을 쓴다. 타일 크기는 창 높이(cqh)에 맞춘다. */
.voice-popped { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px 16px; text-align: center; }
.voice-popped h2 { margin: 6px 0 0; font-size: 22px; }
.voice-popped p { margin: 0 0 8px; }
.voice-popup-body { margin: 0; height: 100vh; display: flex; overflow: hidden; background: var(--side); }
.voice-popup-root, .vf-body { flex: 1; min-width: 0; min-height: 0; display: flex; container-type: size; }
.voice-stage.popup .voice-grid {
  padding: 8px; gap: 6px; max-width: calc((100cqh - 70px) / var(--rows, 1) * 16 / 9 * var(--cols, 1) + 16px);
}
.voice-stage.popup .vtile { flex-basis: calc((100% - (var(--cols, 1) - 1) * 6px) / var(--cols, 1)); border-radius: 8px; }
.voice-stage.popup .voice-grid.focused { max-width: none; }
.voice-stage.popup .voice-grid.focused .vtile.big { max-height: calc(100cqh - 160px); min-height: 120px; }
.voice-stage.popup .voice-bar { gap: 8px; padding: 0 8px 10px; }
.voice-stage.popup .vbtn { width: 38px; height: 38px; }
.voice-stage.popup .vt-label { font-size: 12px; left: 6px; bottom: 6px; }
.voice-float {
  position: fixed; z-index: 45; width: 420px; height: 320px; min-width: 260px; min-height: 200px; max-width: 100vw; max-height: 100vh;
  display: flex; flex-direction: column; overflow: hidden; resize: both; border-radius: 12px; background: var(--side); box-shadow: var(--shadow);
}
.vf-head {
  display: flex; align-items: center; gap: 6px; height: 34px; flex: none; padding: 0 4px 0 10px; border-bottom: 1px solid var(--border);
  font-size: 13px; cursor: move; user-select: none; touch-action: none;
}
.vf-head > span { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.vf-head b { overflow: hidden; text-overflow: ellipsis; }
.vf-head svg { flex: none; width: 14px; height: 14px; color: var(--muted); }
@media (max-width: 768px) {
  .voice-float { width: min(360px, calc(100vw - 16px)); height: 260px; }
}

/* ---------- 모바일 ---------- */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; margin-left: -260px; width: 260px; box-shadow: var(--shadow); }
  .shell.side-open .sidebar { margin-left: 0; }
  .shell.side-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(15, 15, 15, 0.3); }
  .page { padding: 40px 16px 30vh; }
  .page-title { font-size: 30px; }
  .page-icon { font-size: 48px; }
  .gutter { display: none; }
  .crumb { max-width: 140px; }
  .topbar { padding: 0 8px; }
  .invite { flex-wrap: wrap; }
  .invite input { flex-basis: 100%; }
  .history-modal { flex-direction: column; height: 86vh; }
  .history-list { width: auto; max-height: 34%; border-right: 0; border-bottom: 1px solid var(--border); }
  .history-doc { padding: 16px; }
  .chat-side { position: fixed; z-index: 20; top: 46px; right: 0; bottom: 0; box-shadow: var(--shadow); }
  .chat-thread { width: 100vw; }
  .att-chip { width: 160px; }
  .msg-row { padding-right: 16px; }
  .msg-actions { right: 8px; }
  .chat-compose { padding: 0 8px 2px; }
  .chan-topic { display: none; }
}

/* ---------- 사이드바 멤버 ---------- */
.side-member { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 8px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.side-member:hover { background: var(--hover); }
.side-member:not(.online) { opacity: 0.55; }
.side-member.online { color: var(--fg); }
.side-member .dm-avatar .dot { border-color: var(--side); }
.side-member .member-role { font-size: 11px; }
.member-voice { flex: none; display: inline-flex; color: #23a55a; }
.member-voice svg { width: 14px; height: 14px; }
.side-member-toggle { display: block; width: 100%; height: 26px; padding: 0 10px; border-radius: 6px; color: var(--faint); font-size: 12px; text-align: left; }
.side-member-toggle:hover { background: var(--hover); color: var(--fg); }
.member-card-voice { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: var(--hover); font-size: 13px; color: #23a55a; }
.member-card-voice svg { flex: none; width: 15px; height: 15px; }
.member-card-voice span { color: var(--fg); }
.member-card .menu-icon svg { width: 15px; height: 15px; }

/* ---------- 빠른 이동 ---------- */
.switch-kind { flex: none; margin-left: auto; padding: 1px 6px; border-radius: 4px; background: var(--hover); color: var(--muted); font-size: 11px; }
.search-item .badge { margin-left: auto; }
.search-item .badge + .switch-kind { margin-left: 6px; }
.search-item.unread b { font-weight: 700; }
.search-item .channel-hash { width: 20px; }
.switcher-hint { padding: 8px 12px 2px; border-top: 1px solid var(--border); color: var(--faint); font-size: 11.5px; line-height: 1.6; }

/* ---------- 업로드 진행률 ---------- */
.att-progress { display: block; height: 4px; margin-top: 6px; overflow: hidden; border-radius: 2px; background: var(--border); }
.att-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }
.msg .att-chip { width: 220px; }
.block[data-type="image"] .content { position: relative; }
.block.uploading img { opacity: 0.55; }
.image-pending {
  display: grid; place-items: center; height: 120px; border: 1px dashed var(--border); border-radius: 6px; color: var(--faint); font-size: 13px;
}
.upload-bar { position: absolute; left: 12px; right: 12px; bottom: 14px; height: 5px; overflow: hidden; border-radius: 3px; background: rgba(0, 0, 0, 0.25); }
.upload-bar i { display: block; height: 100%; background: var(--accent); transition: width 0.15s; }

.voice-panel .vbtn .ic { width: 18px; height: 18px; }
.thread-head .icon-btn .ic { width: 16px; height: 16px; }

/* ---------- 불러오는 중 ---------- */
/* 응답이 빠르면 보이지 않도록 잠깐 뒤에 나타난다. */
.skeleton { animation: sk-in 0.2s ease 0.15s both; }
@keyframes sk-in { from { opacity: 0; } to { opacity: 1; } }
.sk {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--hover) 30%, var(--active) 50%, var(--hover) 70%); background-size: 300% 100%;
  animation: sk-shine 1.4s ease-in-out infinite;
}
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
/* 페이지: 편집기의 제목·본문 자리와 맞춘다(아이콘 줄 32px + 제목 위 여백 8px). */
.sk-page { padding-top: 40px; }
.sk-page .sk { height: 14px; margin-bottom: 14px; }
.sk-page .sk-title { height: 40px; margin-bottom: 28px; border-radius: 8px; }
/* 채팅: 메시지 줄과 같은 여백·아바타 크기 */
.sk-chat { display: flex; flex-direction: column; gap: 20px; padding: 16px 16px 12px; }
.sk-msg { display: flex; gap: 16px; }
.sk-msg .sk-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
/* 사이드바 목록 */
.sk-list { display: flex; flex-direction: column; gap: 0; padding: 0 10px; }
.sk-list .sk { height: 10px; margin: 10px 0; }
.sk-ws { pointer-events: none; }
.sk-ws .sk-ws-icon { width: 22px; height: 22px; border-radius: 5px; flex: none; }
.sk-ws .sk { height: 12px; }
/* 모달 */
.sk-modal { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 8px; min-height: 180px; }
.sk-modal .sk-heading { height: 18px; margin-bottom: 6px; }
.history-doc .sk-page { padding-top: 8px; }

/* 처음 열 때: 로그인 확인이 오래 걸릴 때만 가운데에 로고와 진행 막대 */
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; animation: sk-in 0.3s ease 0.3s both; }
.boot-logo { font-size: 40px; }
.boot-bar { width: 120px; height: 3px; overflow: hidden; border-radius: 2px; background: var(--hover); }
.boot-bar i { display: block; width: 40%; height: 100%; border-radius: 2px; background: var(--accent); animation: boot-slide 1.1s ease-in-out infinite; }
@keyframes boot-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- 워크스페이스 아이콘 ---------- */
.ws-icon { position: relative; overflow: hidden; }
.ws-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ws-icon.preset { color: #fff; }
.ws-icon.preset .ic { width: 68%; height: 68%; }
.ws-icon.md { width: 40px; height: 40px; border-radius: 9px; font-size: 24px; }
.ws-icon.md.letter { font-size: 17px; }
.ws-icon.lg.preset .ic { stroke-width: 1.6; }
.ws-icon-btn { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.ws-icon-btn:not(:disabled):hover { background: var(--hover); }
.ws-icon-btn:disabled { cursor: default; }
.ws-form { align-items: center; }

.icon-picker { z-index: 70; width: 316px; max-height: none; padding: 8px; }
.ip-tabs { display: flex; align-items: center; gap: 2px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.ip-tab { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.ip-tab:hover { background: var(--hover); color: var(--fg); }
.ip-tab.on { background: var(--active); color: var(--fg); font-weight: 600; }
.ip-remove { height: 28px; padding: 0 8px; border-radius: 6px; font-size: 13px; color: var(--muted); }
.ip-remove:hover { background: var(--hover); color: var(--danger); }
.ip-colors { display: flex; gap: 6px; padding: 2px 2px 10px; }
.ip-color { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.ip-color.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.ip-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.ip-icon { display: grid; place-items: center; aspect-ratio: 1; border-radius: 7px; color: #fff; transition: transform 0.08s; }
.ip-icon .ic { width: 62%; height: 62%; }
.ip-icon:hover { transform: scale(1.08); }
.ip-grid.emoji button { aspect-ratio: 1; border-radius: 6px; font-size: 20px; line-height: 1; }
.ip-grid.emoji button:hover { background: var(--hover); }
.ip-custom { display: flex; gap: 6px; margin-top: 8px; }
.ip-custom input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.ip-upload { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 8px 10px; text-align: center; }
.ip-upload p { margin: 0; line-height: 1.6; }

/* ---------- 프로필 사진 ---------- */
.avatar { position: relative; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar.has-img { color: transparent; }
.avatar.xxl { width: 88px; height: 88px; border-radius: 50%; font-size: 36px; }
.side-me { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: -4px 0 -4px -6px; padding: 4px 6px; border-radius: 6px; text-align: left; }
.side-me:hover { background: var(--hover); }
.side-user { padding-left: 8px; }
.side-me .dm-avatar { width: 28px; height: 28px; border-radius: 50%; font-size: 12px; }
.side-me .dm-avatar .dot { border-color: var(--side); }
.profile { display: flex; align-items: center; gap: 20px; margin-top: 16px; }
.profile-photo { flex: none; }
.profile-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-info b { font-size: 17px; }
.profile-actions { display: flex; gap: 8px; margin: 12px 0 6px; }
.profile-info p { margin: 0; }
.profile-modal { max-width: 440px; }

/* ---------- 모바일 · 터치 ---------- */
.touch-only { display: none !important; }
@media (max-width: 768px) {
  /* 닫힌 사이드바의 그림자가 화면 왼쪽에 비치지 않게 */
  .shell:not(.side-open) .sidebar { box-shadow: none; visibility: hidden; transition: margin-left 0.18s ease, visibility 0s 0.18s; }
  .shell.side-open .sidebar { visibility: visible; transition: margin-left 0.18s ease; }
  .sidebar { width: min(300px, 84vw); margin-left: calc(-1 * min(300px, 84vw)); }
  /* iOS는 16px보다 작은 입력칸을 누르면 화면을 확대한다. */
  input, textarea, select { font-size: 16px !important; }
  /* 손가락으로 누르기 좋은 크기(40px 이상) */
  .topbar { height: 52px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn .ic { width: 20px; height: 20px; }
  .side-item, .tree-row, .channel-row, .side-member { height: 40px; font-size: 15px; }
  .voice-user { height: 34px; }
  .side-label { height: 32px; }
  .side-user .icon-btn { width: 40px; height: 40px; }
  .chat-side { top: 52px; width: min(320px, 86vw); }
  .chat-members { width: 100%; }
  .member-row { padding: 8px; }
  /* 아이폰 홈 막대·노치 */
  .chat-compose { padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .voice-bar { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .side-user { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  /* 모달은 화면 위쪽에, 길면 안에서 스크롤 */
  .modal-backdrop { padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
  .modal { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
  .switcher-modal .search-results { max-height: 60dvh; }
  .voice-bar { gap: 10px; }
  .voice-bar .vbtn { width: 48px; height: 48px; }
}
/* 마우스가 없는 기기: 마우스를 올려야 보이던 것들 */
@media (hover: none) {
  .touch-only { display: grid !important; }
  kbd, .switcher-hint { display: none; }
  .side-add, .side-label-toggle .ic { opacity: 1; }
  /* 페이지 줄의 ＋·🗑은 지금 연 페이지에서만 보인다. */
  .tree-row.active .tree-actions, .channel-row.active .tree-actions { display: flex; }
  .tree-actions button { width: 34px; height: 34px; }
  /* 메시지: 누르면 생기는 hover 대신 길게 누르기로 버튼 모음 */
  .msg-row:hover { background: none; }
  .msg-row:hover .msg-actions { display: none; }
  .msg-row:hover .msg-hover-time { visibility: hidden; }
  .msg.show-actions .msg-row { background: var(--hover); }
  .msg.show-actions .msg-actions { display: flex; }
  .msg-actions { top: -22px; padding: 2px; box-shadow: var(--shadow); }
  .msg-actions button { width: 40px; height: 36px; }
  .msg-actions .ic { width: 18px; height: 18px; }
  .msg { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  .vt-menu { opacity: 1; }
}

/* ---------- 통화 안내(소리 막힘·연결 실패) ---------- */
.voice-notice {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; margin-bottom: 8px; padding: 8px 10px; border-radius: 8px;
  background: rgba(223, 171, 1, 0.14); color: var(--fg); font-size: 12.5px; line-height: 1.45; text-align: left;
}
.voice-notice b { display: block; font-size: 13px; }
.voice-notice .ic { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.voice-notice.warn { background: rgba(224, 62, 62, 0.12); cursor: pointer; }
.voice-notice.warn:hover { background: rgba(224, 62, 62, 0.2); }
.voice-stage-notice:not(:empty) { flex: none; padding: 12px 16px 0; max-width: 640px; width: 100%; margin: 0 auto; }
.voice-stage-notice .voice-notice { margin: 0; font-size: 13.5px; }
