:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --side: #f7f7f8;
  --text: #000000;
  --sub: #8a8a8e;
  --line: rgba(60, 60, 67, 0.18);
  --blue: #0b84fe;
  --them: #e9e9eb;
  --them-text: #000000;
  --search: rgba(118, 118, 128, 0.12);
  --head: rgba(247, 247, 248, 0.82);
  --code-bg: #1e1e24;
  --code-text: #e8e8ee;
  --inline-code: rgba(0, 0, 0, 0.07);
  --active: #0b84fe;
  --hover: rgba(0, 0, 0, 0.04);
  --danger: #ff3b30;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: "SF Mono", ui-monospace, "Cascadia Code", Consolas, "D2Coding", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --panel: #000000;
    --side: #0d0d0e;
    --text: #ffffff;
    --sub: #8d8d93;
    --line: rgba(84, 84, 88, 0.55);
    --them: #262628;
    --them-text: #ffffff;
    --search: rgba(118, 118, 128, 0.24);
    --head: rgba(22, 22, 24, 0.82);
    --inline-code: rgba(255, 255, 255, 0.12);
    --code-bg: #0e0e11;
    --hover: rgba(255, 255, 255, 0.05);
    --danger: #ff453a;
  }
}
:root[data-theme="dark"] {
    --bg: #000000;
    --panel: #000000;
    --side: #0d0d0e;
    --text: #ffffff;
    --sub: #8d8d93;
    --line: rgba(84, 84, 88, 0.55);
    --them: #262628;
    --them-text: #ffffff;
    --search: rgba(118, 118, 128, 0.24);
    --head: rgba(22, 22, 24, 0.82);
    --inline-code: rgba(255, 255, 255, 0.12);
    --code-bg: #0e0e11;
    --hover: rgba(255, 255, 255, 0.05);
    --danger: #ff453a;
  }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { display: block; }

#app { display: grid; grid-template-columns: 340px 1fr; height: 100dvh; }

/* ---------- 대화 목록 ---------- */
#sidebar { background: var(--side); border-right: 0.5px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: calc(10px + env(safe-area-inset-top)) 16px 8px; }
.list-top { height: 22px; display: flex; justify-content: flex-end; align-items: center; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #34c759; box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18); transition: background .3s; }
.status-dot.off { background: #ff3b30; box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.2); }
.list-head h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 10px; }
.search { display: flex; align-items: center; gap: 6px; background: var(--search); border-radius: 10px; padding: 0 8px; height: 36px; color: var(--sub); }
.search svg { width: 16px; height: 16px; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 17px; color: var(--text); min-width: 0; }
.search input::placeholder { color: var(--sub); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.room-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.room { position: relative; display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 22px; margin: 0 8px; border-radius: 12px; cursor: pointer; }
.room:hover { background: var(--hover); }
.room.active { background: var(--active); color: #fff; }
.room.active .room-time, .room.active .room-preview { color: rgba(255, 255, 255, 0.85); }
.room .unread { position: absolute; left: 7px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--blue); }
.room-body { flex: 1; min-width: 0; padding: 2px 0; }
.room-top { display: flex; align-items: baseline; gap: 8px; }
.room-name { font-weight: 600; font-size: 16px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-team { font-weight: 400; font-size: 13px; color: var(--sub); margin-left: 6px; }
.room.active .room-team { color: rgba(255, 255, 255, 0.8); }
.room-time { font-size: 14px; color: var(--sub); flex: none; }
.room-preview { font-size: 14.5px; line-height: 1.3; color: var(--sub); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; word-break: break-all; }
.room-preview.is-typing { font-style: italic; }

.avatar { flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; background: linear-gradient(160deg, var(--c1, #a1a1a6), var(--c2, #6e6e73)); user-select: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.avatar.xs { width: 28px; height: 28px; font-size: 14px; }
.avatar.xl { width: 88px; height: 88px; font-size: 44px; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- 대화 화면 ---------- */
#chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { position: absolute; z-index: 5; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; padding: calc(6px + env(safe-area-inset-top)) 8px 6px; background: var(--head); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: 0.5px solid var(--line); }
.back { width: 40px; height: 40px; display: grid; visibility: hidden; place-items: center; color: var(--blue); }
.back svg { width: 12px; height: 20px; }
.who { justify-self: center; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 2px 10px; border-radius: 10px; }
.who-name { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text); }
.who-name svg { width: 6px; height: 10px; color: var(--sub); }

.mock-banner { position: absolute; z-index: 4; top: calc(70px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font-size: 12px; color: #8a6d00; background: #fff6cc; border: 0.5px solid #f1dd80; padding: 5px 12px; border-radius: 99px; white-space: nowrap; }
.mock-banner code { font-family: var(--mono); font-size: 11px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mock-banner { background: #3a3000; color: #ffd84d; border-color: #5a4a00; } }

.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: calc(78px + env(safe-area-inset-top)) 0 8px; }
.messages { max-width: 860px; margin: 0 auto; padding: 0 16px 4px; }

.stamp { text-align: center; font-size: 11.5px; color: var(--sub); margin: 18px 0 8px; }
.stamp b { font-weight: 600; }

.row { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; }
.row.first { margin-top: 10px; }
.row.me { justify-content: flex-end; }
.row .av-slot { width: 28px; flex: none; position: relative; z-index: 1; }
.sender { font-size: 11.5px; color: var(--sub); margin: 12px 0 2px 48px; }
.sender.solo { margin-left: 12px; }

.bubble { position: relative; max-width: min(75%, 560px); padding: 7px 13px 8px; border-radius: var(--radius); font-size: 16px; line-height: 1.38; word-wrap: break-word; overflow-wrap: anywhere; }
.me .bubble { background: var(--blue); color: #fff; }
.them .bubble { background: var(--them); color: var(--them-text); }
.bubble.wide { max-width: min(88%, 720px); }
.bubble.error { background: transparent; border: 1px solid var(--danger); color: var(--danger); }

/* 말풍선 꼬리 */
.bubble.tail::before, .bubble.tail::after { content: ""; position: absolute; bottom: 0; height: 20px; }
.me .bubble.tail::before { right: -7px; width: 20px; background: var(--blue); border-bottom-left-radius: 16px 14px; }
.me .bubble.tail::after { right: -26px; width: 26px; background: var(--bg); border-bottom-left-radius: 10px; }
.them .bubble.tail::before { left: -7px; width: 20px; background: var(--them); border-bottom-right-radius: 16px 14px; }
.them .bubble.tail::after { left: -26px; width: 26px; background: var(--bg); border-bottom-right-radius: 10px; }
.bubble.error.tail::before, .bubble.error.tail::after { display: none; }

.jumbo { font-size: 44px; line-height: 1.1; padding: 2px 4px; }

.receipt { text-align: right; font-size: 11px; color: var(--sub); margin: 3px 4px 0 0; font-weight: 500; }

/* 말풍선 안의 마크다운 */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 0.55em; }
.bubble ul, .bubble ol { margin: 0.3em 0 0.6em; padding-left: 1.3em; }
.bubble li { margin: 0.15em 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { font-size: 1em; font-weight: 700; margin: 0.7em 0 0.3em; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.them .bubble a { color: var(--blue); }
.bubble blockquote { margin: 0.4em 0; padding-left: 10px; border-left: 3px solid currentColor; opacity: 0.8; }
.bubble hr { border: 0; border-top: 1px solid currentColor; opacity: 0.2; margin: 0.8em 0; }
.bubble :not(pre) > code { font-family: var(--mono); font-size: 0.88em; background: var(--inline-code); padding: 1px 5px; border-radius: 5px; }
.me .bubble :not(pre) > code { background: rgba(255, 255, 255, 0.2); }
.bubble table { border-collapse: collapse; font-size: 14px; margin: 0.4em 0 0.7em; display: block; overflow-x: auto; max-width: 100%; }
.bubble th, .bubble td { border: 1px solid rgba(128, 128, 128, 0.35); padding: 4px 9px; text-align: left; white-space: nowrap; }
.bubble th { font-weight: 600; background: rgba(128, 128, 128, 0.12); }
.codebox { position: relative; margin: 0.45em -5px 0.6em; }
.codebox pre { margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: 12px; padding: 30px 14px 12px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.5; tab-size: 4; }
.codebox .lang { position: absolute; top: 8px; left: 14px; font-size: 11px; color: #9a9aa6; font-family: var(--mono); }
.codebox .copy { position: absolute; top: 5px; right: 8px; font-size: 11.5px; color: #c7c7d2; padding: 3px 8px; border-radius: 6px; }
.codebox .copy:hover { background: rgba(255, 255, 255, 0.1); }

/* 입력 중 표시 */
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--sub); opacity: 0.4; animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 0.9; transform: translateY(-2px); } }

.pop { animation: pop 0.22s cubic-bezier(.2, .9, .3, 1.2); transform-origin: bottom right; }
.them .pop { transform-origin: bottom left; }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 입력창 ---------- */
.chips { display: flex; gap: 8px; padding: 8px 16px 0; overflow-x: auto; max-width: 892px; margin: 0 auto; width: 100%; }
.chip { flex: none; display: flex; align-items: center; gap: 6px; font-size: 14px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--search); }
.chip .avatar { width: 22px; height: 22px; font-size: 12px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); max-width: 892px; width: 100%; margin: 0 auto; }
.plus { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--search); color: var(--sub); display: grid; place-items: center; margin-bottom: 1px; transition: transform .2s; }
.plus svg { width: 18px; height: 18px; }
.plus.open { transform: rotate(45deg); }
.plus[hidden] { display: none; }
.field { flex: 1; position: relative; display: flex; align-items: flex-end; border: 1px solid var(--line); border-radius: 19px; background: var(--bg); min-height: 36px; }
.field textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; color: var(--text); font: inherit; font-size: 16px; line-height: 1.35; padding: 7px 44px 7px 14px; max-height: 160px; min-height: 34px; }
.field textarea::placeholder { color: var(--sub); }
.send { position: absolute; right: 3px; bottom: 3px; width: 28px; height: 28px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; transition: opacity .15s, transform .15s; }
.send svg { width: 16px; height: 16px; }
.send:disabled { opacity: 0; transform: scale(0.6); pointer-events: none; }
.send .i-stop { display: none; }
.send.stop { background: var(--sub); }
.send.stop .i-stop { display: block; }
.send.stop .i-send { display: none; }

/* ---------- 시트 / 잠금 / 토스트 ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0, 0, 0, 0.35); padding: 20px; animation: fade .2s; }
.sheet[hidden], .lock[hidden], .toast[hidden], .chips[hidden], .mock-banner[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet-card { width: min(360px, 100%); background: var(--panel); border-radius: 20px; padding: 28px 22px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet-card { background: #1c1c1e; } }
.sheet-card h2 { margin: 12px 0 2px; font-size: 22px; }
.sheet-title { margin: 0; color: var(--sub); font-size: 14px; }
.sheet-greeting { font-size: 14px; line-height: 1.5; color: var(--text); opacity: 0.85; margin: 14px 4px 18px; }
.sheet-card button { width: 100%; padding: 12px; border-radius: 12px; font-size: 16px; }
.danger { color: var(--danger); background: var(--search); margin-bottom: 8px; }
.soft { color: var(--text); background: var(--search); margin-bottom: 8px; }
.plain { color: var(--blue); }

/* ---------- 잠금화면 (아이폰 암호 입력 화면) ---------- */
.lock { position: fixed; inset: 0; z-index: 50; color: #fff; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: transform .38s cubic-bezier(.4, 0, .2, 1), opacity .38s; }
.lock.leaving { transform: translateY(-100%); opacity: 0.6; }
.lock-wall { position: absolute; inset: -40px; background:
    radial-gradient(60% 45% at 20% 18%, #b3122e 0%, transparent 70%),
    radial-gradient(55% 50% at 85% 30%, #4a1470 0%, transparent 70%),
    radial-gradient(70% 55% at 40% 95%, #0d2a4d 0%, transparent 70%),
    #120812;
  filter: blur(30px) saturate(140%); }
.lock-wall::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, 0.28); }
.lock-inner { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); gap: 5vh; }
.lock-top { display: flex; flex-direction: column; align-items: center; }
.lock-icon { width: 17px; height: 22px; margin-bottom: 14px; opacity: 0.95; }
.lock-title { font-size: 20px; font-weight: 400; letter-spacing: -0.01em; min-height: 26px; text-align: center; }
.lock-sub { font-size: 14px; opacity: 0.85; min-height: 20px; margin-top: 10px; text-align: center; max-width: 280px; line-height: 1.4; }
.dots { display: flex; gap: 24px; margin-top: 22px; height: 14px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; border: 1.4px solid #fff; transition: background .08s; }
.dots i.on { background: #fff; }
.dots.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-16px); } 30% { transform: translateX(13px); } 45% { transform: translateX(-10px); } 60% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 78px); gap: 16px 26px; }
.key { width: 78px; height: 78px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; transition: background .25s; -webkit-tap-highlight-color: transparent; }
.key.down { background: rgba(255, 255, 255, 0.55); transition: none; }
.key .kd { font-size: 36px; font-weight: 300; line-height: 1; font-family: -apple-system, "SF Pro Display", "Helvetica Neue", system-ui, sans-serif; }
.key .kl { font-size: 10px; font-weight: 600; letter-spacing: 2px; margin-top: 2px; min-height: 12px; }
.key-gap { width: 78px; height: 78px; }
.lock-bottom { width: calc(3 * 78px + 2 * 26px); display: flex; justify-content: space-between; font-size: 16px; }
.lock-bottom button { color: #fff; font-size: 16px; padding: 6px 4px; }
.lock-sos { opacity: 0.9; padding: 6px 4px; }
.lock.disabled .keypad, .lock.disabled .dots, .lock.disabled #lockDel { opacity: 0; pointer-events: none; }
.lock.disabled .lock-title { font-weight: 600; }
@media (max-height: 640px) { .keypad { gap: 12px 22px; } .key, .key-gap { width: 70px; height: 70px; } .keypad { grid-template-columns: repeat(3, 70px); } .lock-bottom { width: calc(3 * 70px + 2 * 22px); } .lock-inner { gap: 3vh; } }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: rgba(40, 40, 44, 0.92); color: #fff; font-size: 14px; padding: 9px 16px; border-radius: 99px; max-width: calc(100% - 40px); text-align: center; }

/* ---------- 모바일 ---------- */
@media (max-width: 760px) {
  #app { display: block; position: relative; overflow: hidden; }
  #sidebar, #chat { position: absolute; inset: 0; transition: transform .32s cubic-bezier(.3, .8, .3, 1), visibility .32s; }
  #chat { transform: translateX(100%); visibility: hidden; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.08); }
  #app.in-chat #chat { transform: none; visibility: visible; }
  #app.in-chat #sidebar { transform: translateX(-28%); visibility: hidden; }
  #sidebar { background: var(--bg); border-right: 0; }
  .room { margin: 0; border-radius: 0; padding-left: 26px; }
  .room::after { content: ""; position: absolute; left: 86px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--line); }
  .room.active { background: none; color: inherit; }
  .room.active .room-time, .room.active .room-preview { color: var(--sub); }
  .back { visibility: visible; }
  .messages { padding: 0 12px 4px; }
  .bubble { max-width: 78%; }
  .bubble.wide { max-width: 92%; }
}

/* 체험 모드 안내가 첫 메시지를 가리지 않게 */
#chat.mock .scroller { padding-top: calc(112px + env(safe-area-inset-top)); }

/* ---------- 프로필 보기 ---------- */
.avatar.clickable { cursor: zoom-in; }
.profile { position: fixed; inset: 0; z-index: 40; color: #fff; overflow: hidden; background: #000; animation: profileIn .28s cubic-bezier(.2, .8, .2, 1); }
.profile[hidden] { display: none; }
@keyframes profileIn { from { opacity: 0; transform: scale(1.03); } }
.profile-bg { position: absolute; inset: 0; background-size: cover; background-position: center; transform: scale(1.02); transition: background-image .3s; }
.profile-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0.08) 22%, rgba(0, 0, 0, 0.15) 55%, rgba(0, 0, 0, 0.78) 100%); }
.profile-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
.profile-x { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, 0.25); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.profile-x svg { width: 18px; height: 18px; }
.profile-count { font-size: 14px; font-weight: 600; padding: 5px 11px; border-radius: 99px; background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-variant-numeric: tabular-nums; }
.profile-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; padding: 0 20px calc(28px + env(safe-area-inset-bottom)); }
.profile-stage { position: relative; width: min(78vw, 340px, 44vh); }
.profile-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 30px; aspect-ratio: 1 / 1; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); outline: 1px solid rgba(255, 255, 255, 0.18); outline-offset: -1px; overscroll-behavior-x: contain; }
.profile-track::-webkit-scrollbar { display: none; }
.profile-track img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; scroll-snap-stop: always; user-select: none; -webkit-user-drag: none; }
.profile-nav { position: absolute; top: 50%; width: 38px; height: 38px; margin-top: -19px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: opacity .2s; z-index: 1; }
.profile-nav svg { width: 10px; height: 16px; }
.profile-nav.prev { left: -52px; }
.profile-nav.next { right: -52px; }
.profile-nav[disabled] { opacity: 0; pointer-events: none; }
.profile-dots { display: flex; gap: 7px; margin: 16px 0 6px; min-height: 7px; }
.profile-dots button { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.4); transition: background .2s, transform .2s; }
.profile-dots button.on { background: #fff; transform: scale(1.15); }
.profile-name { margin: 8px 0 2px; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4); }
.profile-title { margin: 0; font-size: 14px; opacity: 0.85; }
.profile-status { margin: 10px 0 18px; font-size: 15px; opacity: 0.95; min-height: 1em; text-align: center; max-width: 320px; }
.profile-status:empty { margin: 6px 0 12px; }
.profile-chat { display: flex; align-items: center; gap: 8px; padding: 11px 22px; border-radius: 99px; color: #fff; font-size: 15px; font-weight: 600; background: rgba(255, 255, 255, 0.18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.25); }
.profile-chat svg { width: 18px; height: 18px; }
@media (max-width: 760px), (pointer: coarse) {
  .profile-nav { display: none; }
}

/* Claude Code 작업 표시 */
.tools { margin: 8px 0 3px; font-size: 12.5px; color: var(--sub); max-width: min(88%, 720px); }
.tools.group { margin-left: 36px; }
.tools summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 10px; background: var(--search); font-weight: 600; user-select: none; }
.tools summary::-webkit-details-marker { display: none; }
.tools summary::before { content: "▸"; font-size: 10px; transition: transform .15s; }
.tools[open] summary::before { transform: rotate(90deg); }
.tools summary span { font-weight: 400; }
.tools ul { list-style: none; margin: 4px 0 0; padding: 0 0 0 4px; display: grid; gap: 2px; }
.tools li { display: flex; align-items: baseline; gap: 5px; min-width: 0; line-height: 1.35; }
.tools li b { font-weight: 600; flex: none; }
.tools li code { font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tools li .ti { flex: none; width: 1.3em; text-align: center; }
.tools li.more { font-style: italic; opacity: .8; }
.tools li.spin .ti { animation: blink 1.1s infinite; }
.sheet-engine { margin: 4px 0 0; font-size: 12.5px; color: var(--sub); text-align: center; line-height: 1.5; }
.sheet-engine code { font-family: var(--mono); background: var(--search); padding: 1px 5px; border-radius: 5px; }

/* GPT 직원 표시, 채팅 속 이미지 */
.eng-badge { display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 5px; font-size: 10px; font-weight: 700; line-height: 15px; letter-spacing: .02em; vertical-align: 1px; color: #fff; background: #10a37f; }
.bubble img.gen { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; border-radius: 12px; margin: 6px 0; cursor: zoom-in; background: rgba(127,127,127,.12); }
.bubble:has(img.gen) { max-width: min(80%, 520px); }
.img-missing { display: inline-block; font-size: 13px; color: var(--sub); }

:root[data-theme="dark"] .mock-banner { background: #3a3000; color: #ffd84d; border-color: #5a4a00; }
:root[data-theme="dark"] .sheet-card { background: #1c1c1e; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ---------- 대화창 크기 설정 (설정에서 바꿀 수 있음) ---------- */
:root { --av-head: 108px; --av-msg: 84px; --fs-bubble: 16px; --head-h: 170px; }
:root[data-avatar="m"] { --av-head: 64px; --av-msg: 44px; }
:root[data-avatar="xl"] { --av-head: 132px; --av-msg: 112px; }
:root[data-font="s"] { --fs-bubble: 14.5px; }
:root[data-font="l"] { --fs-bubble: 18px; }
:root[data-font="xl"] { --fs-bubble: 20px; }
.bubble { font-size: var(--fs-bubble); }

/* 상단: 큰 원형 사진 + 그 아래 이름 */
.chat-head { grid-template-columns: 60px 1fr 60px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; }
.who { gap: 6px; padding: 0 10px; }
#headAvatar { width: var(--av-head); height: var(--av-head); font-size: calc(var(--av-head) / 2); box-shadow: 0 2px 12px rgba(0,0,0,.16); }
.who-name { font-size: 17px; font-weight: 600; gap: 4px; }
.who-name svg { width: 7px; height: 12px; }
.gear { justify-self: end; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); }
.gear svg { width: 24px; height: 24px; }
.gear:hover { background: var(--hover); }
/* 헤더 높이에 맞춰 대화가 바로 아래에서 시작 */
.scroller { padding-top: calc(var(--head-h) + 6px); }
.mock-banner { top: calc(var(--head-h) + 6px); }
#chat.mock .scroller { padding-top: calc(var(--head-h) + 44px); }

/* 단체방: 왼쪽에 사진, 사진 밑에 이름, 말풍선은 사진 윗줄에 맞춤 */
.row.grp { align-items: flex-start; gap: 10px; margin-top: 3px; }
.row.grp.first { margin-top: 16px; }
.av-col { width: var(--av-msg); flex: none; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.av-col .avatar { width: var(--av-msg); height: var(--av-msg); font-size: calc(var(--av-msg) / 2); }
.av-name { font-size: 13px; font-weight: 600; color: var(--text); opacity: .8; text-align: center; line-height: 1.25; max-width: calc(var(--av-msg) + 24px); display: flex; flex-direction: column; align-items: center; gap: 3px; word-break: keep-all; }
.av-name .eng-badge { margin: 0; }
.msg-col { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.msg-col .bubble { max-width: min(100%, 600px); }
.msg-col .bubble.wide { max-width: min(100%, 760px); }
.row.grp.first .msg-col > .bubble:last-child, .row.grp.first .msg-col > .jumbo:last-child { border-top-left-radius: 6px; }
.row.grp.first .msg-col { padding-top: 2px; }
.msg-col .tools { margin: 0 0 5px; max-width: 100%; }
.row.grp .bubble.tail::before, .row.grp .bubble.tail::after { display: none; }
@media (max-width: 760px) {
  .row.grp { gap: 8px; }
  .msg-col .bubble, .msg-col .bubble.wide { max-width: 100%; }
}

/* ---------- 설정 ---------- */
.settings { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 16px; }
.settings[hidden] { display: none; }
.settings-card { width: min(520px, 100%); max-height: min(86vh, 900px); overflow-y: auto; background: var(--bg); border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
:root[data-theme="dark"] .settings-card { background: #1c1c1e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .settings-card { background: #1c1c1e; } }
.settings-top { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: inherit; border-bottom: .5px solid var(--line); }
.settings-top h2 { margin: 0; font-size: 18px; }
.settings-top button { color: var(--blue); font-weight: 600; font-size: 16px; }
.set-sec { padding: 14px 18px 4px; }
.set-sec h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--sub); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: .5px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > span { font-size: 15px; }
.set-row small { display: block; font-size: 12px; color: var(--sub); margin-top: 2px; }
.seg { display: inline-flex; background: var(--search); border-radius: 9px; padding: 2px; flex: none; }
.seg button { padding: 5px 10px; border-radius: 7px; font-size: 13px; color: var(--text); white-space: nowrap; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.18); font-weight: 600; }
:root[data-theme="dark"] .seg button.on { background: #3a3a3c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: #3a3a3c; } }
.switch { position: relative; width: 50px; height: 30px; border-radius: 99px; background: var(--search); flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch.on { background: #34c759; }
.switch.on::after { transform: translateX(20px); }
.staff-row { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 10px 0; border-bottom: .5px solid var(--line); }
.staff-row .avatar { width: 44px; height: 44px; font-size: 22px; }
.staff-row b { font-size: 15px; }
.staff-row .team { font-size: 12px; color: var(--sub); margin-left: 4px; }
.staff-ctl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.staff-ctl input { flex: 1 1 100%; font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 8px; border: .5px solid var(--line); background: var(--search); color: var(--text); }
.set-btn { width: 100%; padding: 11px; border-radius: 12px; background: var(--search); font-weight: 600; margin: 4px 0 10px; }
.set-btn.danger { color: var(--danger); }
.set-info { font-size: 13px; color: var(--sub); line-height: 1.6; word-break: break-all; }
.set-info code { font-family: var(--mono); font-size: 12px; background: var(--search); padding: 1px 5px; border-radius: 5px; }
.settings-foot { padding: 6px 18px 18px; }
.list-top { height: 34px; gap: 10px; }
.list-gear { width: 34px; height: 34px; }
.list-gear svg { width: 22px; height: 22px; }

/* ---------- 게스트(초대 링크) · 사진 올리기 ---------- */
.guest-bar { margin: 0 12px 8px; padding: 8px 12px; border-radius: 12px; background: var(--search); font-size: 13px; color: var(--sub); text-align: center; }
.guest-note { display: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; color: var(--sub); border-top: .5px solid var(--line); }
body.guest:not(.guest-talk) .guest-note { display: block; }
body.guest:not(.guest-talk) #composer, body.guest #chips, body.guest .gear, body.guest #clearBtn, body.guest #plusBtn { display: none !important; }
.call-note { text-align: center; font-size: 12px; color: var(--sub); margin: 6px 0 10px; }
.call-note b { color: var(--text); font-weight: 600; }
.photo-sheet { z-index: 70; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.photo-item { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--search); padding: 0; outline: 3px solid transparent; outline-offset: -3px; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item .tag { position: absolute; left: 6px; top: 6px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.6); padding: 2px 7px; border-radius: 99px; }
.photo-item .chk { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.photo-item.sel { outline-color: var(--blue); }
.photo-item.sel img { opacity: .75; }
.photo-item.sel .chk { background: var(--blue); }
.photo-item.sel .chk::after { content: '✓'; position: absolute; inset: 0; color: #fff; font-size: 13px; font-weight: 800; font-style: normal; display: grid; place-items: center; }
.photo-actions { display: flex; gap: 8px; }
.photo-actions .set-btn { flex: 1; margin-bottom: 14px; }
.set-btn:disabled { opacity: .4; }
.mini-btn { padding: 5px 10px; border-radius: 8px; background: var(--search); font-size: 13px; font-weight: 600; color: var(--blue); flex: none; }
.mini-btn.danger { color: var(--danger); }
.invite-out { margin: 4px 0 10px; padding: 10px; border-radius: 10px; background: var(--search); font-size: 12.5px; word-break: break-all; }
.invite-out code { font-family: var(--mono); display: block; margin-bottom: 8px; }
.invite-out small { display: block; color: var(--sub); margin-top: 6px; }
.invite-actions { display: flex; gap: 6px; }
