: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;
  --spring: cubic-bezier(.2, 1.35, .35, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --sheen: rgba(255, 255, 255, 0.45);
  --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;
    --sheen: rgba(255, 255, 255, 0.10);
  }
}
: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;
    --sheen: rgba(255, 255, 255, 0.10);
  }

* { 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; margin: 0 8px; border-radius: 12px; cursor: pointer; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.room-slide { position: relative; z-index: 1; display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 22px; background: var(--side); border-radius: inherit; transition: transform .34s var(--spring), background-color .2s; touch-action: pan-y; }
.room:hover .room-slide { background: color-mix(in srgb, var(--side), var(--text) 4%); }
.room.active .room-slide { background: var(--active); color: #fff; }
.room-actions { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.room-actions button { width: 72px; color: #fff; font-size: 14px; font-weight: 600; }
.room-actions .add { background: var(--blue); }
.room-actions .del { background: var(--danger); }
.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; }
/* 좁은 화면 안전장치: 어떤 말풍선 내용이 넘쳐도 대화창 전체가 옆으로 밀리지 않게 (표·코드는 자기 칸 안에서 가로 스크롤) */
.scroller { overflow-x: hidden; }
.row > .bubble { min-width: 0; }
.bubble pre { max-width: 100%; overflow-x: auto; }
.bubble img, .bubble video, .bubble iframe { max-width: 100%; height: auto; }
.choice { max-width: 100%; white-space: normal; text-align: left; overflow-wrap: anywhere; }
.call-note, .review-tag { overflow-wrap: anywhere; }
/* 위로 올려 보는 중에 새 글이 오면 뜨는 버튼 (높이 0짜리 sticky 줄이라 스크롤 길이는 안 바뀌어요) */
.new-below-wrap { position: sticky; bottom: 0; height: 0; display: flex; justify-content: center; pointer-events: none; z-index: 3; }
.new-below { pointer-events: auto; transform: translateY(calc(-100% - 12px)); padding: 7px 14px; border-radius: 99px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.new-below[hidden] { display: none; }

.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; }
/* 선택지 버튼 카드 (레미나 씨 페이드·디자인 훅) */
.choices { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; animation: choiceIn .22s ease; }
.choice { padding: 7px 13px; border: 1.5px solid var(--blue); border-radius: 16px; background: transparent; color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, transform .1s; }
.choice:hover { background: var(--blue); color: #fff; }
.choice:active { transform: scale(.96); }
.choices.busy { opacity: .5; pointer-events: none; }
@keyframes choiceIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.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 { content: ""; position: absolute; bottom: 0; width: 28px; height: 21px; background: inherit; background-image: none;
  -webkit-mask: var(--tail) no-repeat 0 0 / 100% 100%; mask: var(--tail) no-repeat 0 0 / 100% 100%; pointer-events: none; z-index: -1; }
.bubble.tail { isolation: isolate; }
:root { --tail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 21'%3E%3Cpath d='M0 0H18C18 10.2 20.4 16.4 28 21C23.6 21.4 20 20.9 17 19.5C14.6 20.6 11.8 21 9 21H0Z'/%3E%3C/svg%3E"); }
.me .bubble.tail::before { right: -10px; }
.them .bubble.tail::before { left: -10px; transform: scaleX(-1); }
.bubble.error.tail::before { 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.42s var(--spring); transform-origin: bottom right; }
.them .pop { transform-origin: bottom left; }
@keyframes pop { 0% { transform: translateY(10px) scale(0.86); opacity: 0; } 55% { opacity: 1; } 100% { transform: none; 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; }
.plus.photo svg { width: 19px; height: 19px; }
/* 사진 첨부: 입력창 위 미리보기 줄, 보낸 사진 */
.attach-bar { display: flex; gap: 8px; padding: 8px 16px 0; overflow-x: auto; max-width: 892px; margin: 0 auto; width: 100%; }
.attach-bar[hidden] { display: none; }
.attach-item { position: relative; flex: none; }
.attach-item img { display: block; width: 64px; height: 64px; object-fit: cover; border-radius: 12px; background: rgba(127,127,127,.12); }
.attach-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.72); color: #fff; font-size: 15px; line-height: 22px; text-align: center; }
.sent-photos { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: min(75%, 360px); margin: 2px 0 3px auto; }
.sent-photos img { display: block; max-width: 100%; max-height: 260px; border-radius: 16px; cursor: zoom-in; background: rgba(127,127,127,.12); }
.sent-photos:has(img + img) img { width: calc(50% - 2px); height: 140px; object-fit: cover; }
.cc-ver { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--sub); }
.cc-ver.outdated span { color: var(--blue); font-weight: 600; }
.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; }
/* 좁은 폰에서 입력칸이 기본 너비(20글자)를 고집해 전송 버튼을 화면 밖으로 밀던 문제: 입력칸이 줄어들 수 있게 */
.field { min-width: 0; }
.field textarea { min-width: 0; width: 100%; }
.field textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 가로로 눕힌 노치 폰: 좌우 안전 영역만큼 입력줄 안쪽 여백 */
.composer { padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
.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 .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; }
  .room-slide { padding-left: 26px; background: var(--bg); }
  .room:hover .room-slide { background: color-mix(in srgb, var(--bg), var(--text) 4%); }
  .room::after { content: ""; position: absolute; z-index: 2; left: 86px; right: 0; bottom: 0; border-bottom: 0.5px solid var(--line); pointer-events: none; }
  .room.active .room-slide { background: var(--bg); 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, body.view-only .guest-note { display: block; }
body.view-only #composer, body.view-only #plusBtn, body.view-only #chips { display: none !important; }
.list-sec { list-style: none; padding: 16px 22px 6px; font-size: 13px; font-weight: 600; color: var(--sub); }
/* 손님 대화 묶음 머리 (접기·펴기) */
.guest-sec { padding: 10px 12px 4px; }
.guest-sec-btn { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border-radius: 10px; font: inherit; font-size: 13px; font-weight: 600; color: var(--sub); text-align: left; min-width: 0; }
.guest-sec-btn:hover { background: var(--hover); }
.gs-arrow { flex: none; font-size: 10px; transition: transform .2s; }
.guest-sec.open .gs-arrow { transform: rotate(90deg); }
.gs-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-title small { font-weight: 500; }
.gs-busy { flex: none; font-size: 11.5px; font-weight: 600; color: var(--blue); }
.gs-unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.name-sheet { z-index: 80; }
.name-card { padding: 26px 22px 18px; text-align: center; width: min(380px, 100%); }
.name-card .avatar { width: 88px; height: 88px; font-size: 40px; margin: 0 auto 12px; }
.name-q { margin: 0 0 16px; font-size: 16px; line-height: 1.5; }
.name-form { display: flex; flex-direction: column; gap: 10px; }
.name-form input { font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px; border: .5px solid var(--line); background: var(--search); color: var(--text); text-align: center; }
.set-btn.primary { background: var(--blue); color: #fff; margin: 0; }
.name-note { display: block; margin-top: 10px; font-size: 12px; color: var(--sub); }
.name-skip { margin-top: 8px; font-size: 13px; color: var(--sub); text-decoration: underline; }
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; }
.more-old { display: block; margin: 6px auto 12px; padding: 6px 14px; border-radius: 99px; background: var(--search); color: var(--sub); font-size: 13px; font-weight: 600; } /* 긴 방: 이전 메시지 더 보기 */
.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; }


/* ================= 화면 효과 (셰이더 + 반응형 모션) ================= */
.fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.fx-ripple { position: fixed; z-index: 95; }

/* 잠금화면: 셰이더 잉크가 벽지를 대신하고, 풀릴 때는 불씨처럼 타들어 가며 사라짐 */
.lock.fx-on .lock-wall { display: none; }
.lock.fx-on { background: transparent; }
.lock-inner { transition: opacity .45s var(--ease-out), transform .6s var(--ease-out), filter .45s; }
.lock.fx-dissolving { pointer-events: none; }
.lock.fx-dissolving .lock-inner { opacity: 0; transform: scale(1.08); filter: blur(8px); }
.key { transition: none; }
.dots i.new { animation: dotIn .34s var(--spring); }
@keyframes dotIn { from { transform: scale(.5); } 60% { transform: scale(1.25); } }

/* 대화방 배경: 캔버스를 내용 뒤에 */
#chat.fx-on { isolation: isolate; }
#chat.fx-on .fx-chat { z-index: -1; }
.fx-chat { opacity: 0; animation: fxIn 1.2s .1s var(--ease-out) forwards; }
@keyframes fxIn { to { opacity: 1; } }

/* 프로필: 셰이더가 배경 사진을 그림 */
.profile.fx-on .profile-bg { opacity: 0; }
.profile-body > * { animation: rise .55s var(--ease-out) both; }
.profile-body > :nth-child(2) { animation-delay: .04s; }
.profile-body > :nth-child(3) { animation-delay: .08s; }
.profile-body > :nth-child(4) { animation-delay: .11s; }
.profile-body > :nth-child(5) { animation-delay: .14s; }
.profile-body > :nth-child(6) { animation-delay: .17s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* 누르는 순간 바로 반응: 살짝 눌리는 느낌 */
.room, .mini-btn, .set-btn, .chip, .seg button, .plus, .profile-chat, .photo-item, .who, .back, .gear, .sheet-card button, .profile-nav, .name-skip {
  transition: transform .32s var(--spring), background-color .2s, opacity .2s, box-shadow .2s; }
.room:active { transform: scale(.985); }
.mini-btn:active, .set-btn:active, .chip:active, .seg button:active, .profile-chat:active, .sheet-card button:active, .photo-item:active { transform: scale(.96); }
.plus:active, .gear:active, .back:active, .profile-nav:active { transform: scale(.88); }
.plus.open:active { transform: rotate(45deg) scale(.88); }
.who:active { transform: scale(.97); }
.send { transition: opacity .15s, transform .35s var(--spring), background-color .2s; }
.send:active { transform: scale(.86); }
.send:not(:disabled) { animation: sendIn .35s var(--spring); }
@keyframes sendIn { from { transform: scale(.4); opacity: 0; } }
@media (hover: hover) {
  .mini-btn:hover, .set-btn:hover, .chip:hover { filter: brightness(1.04); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
  .who:hover { background: var(--hover); }
}

/* 입력창 포커스: 은은한 빛 */
.field { transition: border-color .2s, box-shadow .3s var(--ease-out); }
.field:focus-within { border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 14%, transparent); }

/* 답을 쓰는 중인 말풍선: 빛이 스쳐 지나감 */
.bubble[data-live="1"] { background-image: linear-gradient(105deg, transparent 35%, var(--sheen) 50%, transparent 65%); background-size: 260% 100%; background-repeat: no-repeat; animation: sheen 1.8s linear infinite; }
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -30% 0; } }
.typing i { animation: typingWave 1.25s var(--ease-out) infinite; }
@keyframes typingWave { 0%, 70%, 100% { opacity: .3; transform: translateY(0) scale(1); } 30% { opacity: .95; transform: translateY(-3px) scale(1.12); } }

/* 작업 중인 도구 줄: 글자에 빛이 흐름 */
.tools.live li.spin b, .tools.live li.spin code { background: linear-gradient(90deg, var(--sub) 20%, var(--text) 50%, var(--sub) 80%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: sheen 1.6s linear infinite; }
.tools.live li { animation: rise .35s var(--ease-out) both; }
.call-note { animation: rise .4s var(--ease-out) both; }

/* 목록: 처음 열 때 한 줄씩 떠오름 */
.room.enter { animation: rise .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }
.room.active { transition: background-color .25s, transform .32s var(--spring); }

/* 대화방 바꿀 때 내용이 부드럽게 교체 */
.messages.swap { animation: swapIn .32s var(--ease-out); }
@keyframes swapIn { from { opacity: 0; transform: translateY(6px); } }
#headAvatar.swap { animation: avIn .45s var(--spring); }
@keyframes avIn { from { transform: scale(.7); opacity: .2; } }

/* 시트·설정 창: 스프링으로 열림 */
.settings { animation: fade .22s; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.settings-card, .sheet-card { animation: cardIn .42s var(--spring); }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.96); } }
.sheet { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.toast { animation: toastIn .38s var(--spring); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) scale(.94); } }

/* 효과 끄기 / 동작 줄이기 */
:root[data-fx="off"] *, :root[data-fx="off"] *::before, :root[data-fx="off"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
@media (prefers-reduced-motion: reduce) {
  .bubble[data-live="1"], .tools.live li.spin b, .tools.live li.spin code { animation: none; }
}

/* 초대가 끝난 손님 화면: 숫자판 대신 안내만 (대표님은 '긴급 상황' 자리의 PIN 입력으로 열 수 있음) */
.lock.guest-ended .keypad, .lock.guest-ended .dots, .lock.guest-ended #lockDel { opacity: 0; pointer-events: none; }
.lock.guest-ended .lock-title { font-weight: 600; }

/* 자동 검토 표시 */
.review-tag { align-self: flex-start; font-size: 11.5px; font-weight: 600; color: var(--sub); background: var(--search); padding: 3px 9px; border-radius: 99px; margin: 2px 0 4px; animation: rise .35s var(--ease-out) both; }

/* 손님 대화방 아래 한도 늘리기 */
.guest-note b { color: var(--text); }
.note-actions { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.note-actions input[type="time"] { font: inherit; font-size: 16px; padding: 4px 8px; border-radius: 8px; border: .5px solid var(--line); background: var(--search); color: var(--text); }
.guest-note .note-actions { margin-top: 6px; }
.guest-note .mini-btn, .note-actions.big .mini-btn { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.note-actions.big { display: flex; justify-content: center; margin: 10px 0 0; }
.sheet-card .note-actions.big { width: 100%; gap: 8px; margin: 8px 0 14px; }
.sheet-card .note-actions.big .mini-btn { flex: 1; width: auto; padding: 10px 0; font-size: 15px; background: var(--search); color: var(--blue); }
.sheet-card #sheetEngine { width: 100%; }

/* 꾹 눌렀을 때 선택지 창 */
.act-sheet { z-index: 75; }
.act-card h2 { margin: 0 0 4px; font-size: 19px; }
.act-card .sheet-title { margin: 0 0 12px; }
.act-card > button { margin-top: 8px; }
.act-label { font-size: 13px; color: var(--sub); margin-top: 6px; }
.pin-sheet { z-index: 80; }
.pin-sheet .name-form input { letter-spacing: .3em; }

/* 아래로 당겨서 새로고침 */
@media (min-width: 761px) { #sidebar { position: relative; } }
.ptr { position: absolute; left: 50%; z-index: 6; width: 36px; height: 36px; margin-top: 0; border-radius: 50%; display: grid; place-items: center; color: var(--sub); background: var(--panel); box-shadow: 0 2px 10px rgba(0,0,0,.14); opacity: 0; transform: translate(-50%, 0); transition: transform .3s var(--ease-out), opacity .2s; pointer-events: none; }
.ptr svg { width: 20px; height: 20px; }
.ptr.ready { color: var(--blue); }
.ptr.spin svg { animation: ptrSpin .8s linear infinite; }
.ptr.spin { opacity: 1; color: var(--blue); }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

/* 목록은 꾹 눌러도 글자 선택·복사 메뉴가 뜨지 않게 (대화창 글은 그대로 선택 가능) */
#roomList, #roomList * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#roomList img { -webkit-user-drag: none; pointer-events: none; }

/* =====================================================================
   프리미엄 다듬기 — 글꼴, 색, 유리 질감, 잠금화면
   (위의 기본 스타일을 덮어씁니다. 되돌리려면 이 블록만 지우면 돼요.)
   ===================================================================== */
:root {
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --blue: #0a7cff;
  --active: #0a7cff;
  --me-grad: linear-gradient(180deg, #3595ff 0%, #0a74f5 100%);
  --side: #f7f7f9;
  --line: rgba(60, 60, 67, 0.12);
  --them: #eeeef1;
  --search: rgba(118, 118, 128, 0.10);
  --head: rgba(250, 250, 252, 0.72);
  --card: #ffffff;
  --card-line: rgba(0, 0, 0, 0.06);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 24px 70px rgba(0, 0, 0, 0.16), 0 4px 14px rgba(0, 0, 0, 0.06);
  --glass: rgba(255, 255, 255, 0.72);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b; --panel: #09090b; --side: #0c0c0f;
    --them: #1c1c21; --line: rgba(255, 255, 255, 0.08);
    --search: rgba(255, 255, 255, 0.07); --head: rgba(12, 12, 15, 0.66);
    --card: #141418; --card-line: rgba(255, 255, 255, 0.07);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
    --glass: rgba(24, 24, 28, 0.62); --code-bg: #0c0c10;
  }
}
:root[data-theme="dark"] {
  --bg: #09090b; --panel: #09090b; --side: #0c0c0f;
  --them: #1c1c21; --line: rgba(255, 255, 255, 0.08);
  --search: rgba(255, 255, 255, 0.07); --head: rgba(12, 12, 15, 0.66);
  --card: #141418; --card-line: rgba(255, 255, 255, 0.07);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
  --glass: rgba(24, 24, 28, 0.62); --code-bg: #0c0c10;
}
html, body { font-feature-settings: "tnum" 0; letter-spacing: -0.006em; text-rendering: optimizeLegibility; }
::selection { background: color-mix(in srgb, var(--blue) 26%, transparent); }
@media (hover: hover) {
  ::-webkit-scrollbar { width: 11px; height: 11px; }
  ::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--sub) 38%, transparent); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--sub) 60%, transparent); }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* 목록 */
#sidebar { border-right-color: var(--line); }
.list-head { position: relative; isolation: isolate; }
.list-head .fx-side { z-index: -1; opacity: 0; animation: fxIn 1.4s .15s var(--ease-out) forwards; }
.list-head h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.035em; }
.search { height: 38px; border-radius: 12px; background: var(--search); box-shadow: inset 0 0 0 0.5px var(--card-line); transition: box-shadow .25s, background-color .25s; }
.search:focus-within { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 45%, transparent), 0 0 0 4px color-mix(in srgb, var(--blue) 12%, transparent); }
.room-name { font-weight: 650; letter-spacing: -0.015em; }
.room-preview { letter-spacing: -0.01em; }
.room-slide .avatar { box-shadow: 0 0 0 2px var(--side), 0 0 0 3px color-mix(in srgb, var(--c1, #999) 45%, transparent); }
.room.active .room-slide { background: var(--me-grad); }
.room.active .room-slide .avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
.room .unread { box-shadow: 0 0 10px color-mix(in srgb, var(--blue) 70%, transparent); }
.status-dot { box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16), 0 0 10px rgba(52, 199, 89, 0.5); }

/* 대화 화면 */
.chat-head { background: var(--head); backdrop-filter: saturate(180%) blur(26px); -webkit-backdrop-filter: saturate(180%) blur(26px); border-bottom-color: var(--line); }
#headAvatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px color-mix(in srgb, var(--c1, #999) 50%, transparent), 0 10px 30px rgba(0, 0, 0, 0.18); }
.who-name { font-weight: 650; letter-spacing: -0.015em; }
.stamp { font-size: 11.5px; letter-spacing: 0.01em; font-weight: 500; }
.me .bubble { background-color: #0a74f5; background-image: var(--me-grad); box-shadow: 0 1px 1px rgba(0, 40, 120, 0.12); }
.bubble { letter-spacing: -0.01em; }
.av-col .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--c1, #999) 45%, transparent); }
.av-name { font-weight: 650; }

/* 입력창: 떠 있는 유리 */
.composer { padding-top: 10px; }
.field { background: var(--glass); border: 0.5px solid var(--card-line); border-radius: 21px; box-shadow: var(--shadow-1); backdrop-filter: saturate(170%) blur(20px); -webkit-backdrop-filter: saturate(170%) blur(20px); }
.field textarea { padding-top: 8px; padding-bottom: 8px; }
.send { background: var(--me-grad); box-shadow: 0 3px 10px rgba(10, 116, 245, 0.38); }
.send.stop { background: var(--sub); box-shadow: none; }
.plus { background: var(--glass); box-shadow: var(--shadow-1), inset 0 0 0 0.5px var(--card-line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.chip { background: var(--glass); box-shadow: inset 0 0 0 0.5px var(--card-line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }

/* 시트·설정·토스트 */
.sheet, .settings { background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%); }
.sheet-card, .settings-card,
:root[data-theme="dark"] .sheet-card, :root[data-theme="dark"] .settings-card { background: var(--card); border-radius: 26px; box-shadow: var(--shadow-2); border: 0.5px solid var(--card-line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sheet-card, :root:not([data-theme="light"]) .settings-card { background: var(--card); } }
.settings-top { background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.sheet-card h2 { font-weight: 750; letter-spacing: -0.02em; }
.sheet-card button, .set-btn { border-radius: 14px; }
.set-btn.primary { background: var(--me-grad); box-shadow: 0 4px 14px rgba(10, 116, 245, 0.3); }
.set-sec h3 { letter-spacing: 0.02em; }
.seg { border-radius: 10px; }
.seg button.on { box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16), inset 0 0 0 0.5px var(--card-line); }
.switch.on { background: linear-gradient(180deg, #3ddc68, #2fb350); }
.toast { background: rgba(28, 28, 32, 0.78); border: 0.5px solid rgba(255, 255, 255, 0.1); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); }
.guest-bar { border-radius: 14px; box-shadow: inset 0 0 0 0.5px var(--card-line); }
.review-tag { box-shadow: inset 0 0 0 0.5px var(--card-line); }

/* 잠금 풀린 뒤 화면이 살짝 다가오며 선명해짐 */
#app.pre-reveal { transform: scale(1.055); opacity: 0.35; transition: none !important; }
#app.revealing { transition: transform 1.2s cubic-bezier(.16, .84, .24, 1), opacity .8s ease, filter 1s ease; }
@media (hover: hover) and (pointer: fine) { #app.pre-reveal { filter: blur(10px); } }

/* ---------- 잠금화면 ---------- */
.lock { font-family: var(--font); }
.lock-inner { gap: 4.2vh; }
.lock-clock { display: flex; flex-direction: column; align-items: center; margin-bottom: -1vh; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.25); }
.lock-date { font-size: 16px; font-weight: 550; letter-spacing: 0.01em; opacity: 0.86; }
.lock-time { font-size: clamp(58px, 10.5vh, 92px); font-weight: 250; line-height: 1.02; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; margin-top: 2px;
  background: linear-gradient(180deg, #fff 30%, rgba(255, 225, 235, 0.78)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lock-icon { width: 13px; height: 17px; margin-bottom: 12px; opacity: 0.75; }
.lock-title { font-size: 15.5px; font-weight: 500; letter-spacing: 0.02em; opacity: 0.92; }
.lock-sub { font-size: 13.5px; opacity: 0.75; }
.dots { gap: 22px; margin-top: 20px; }
.dots i { width: 11px; height: 11px; border: 1.2px solid rgba(255, 255, 255, 0.78); transition: background .12s, box-shadow .2s, border-color .12s; }
.dots i.on { background: #fff; border-color: #fff; box-shadow: 0 0 12px rgba(255, 210, 225, 0.75); }
.keypad { gap: 18px 28px; }
.key { background: rgba(255, 255, 255, 0.075); box-shadow: inset 0 0 0 0.75px rgba(255, 255, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08); backdrop-filter: blur(18px) saturate(150%); -webkit-backdrop-filter: blur(18px) saturate(150%); }
.key .kd { font-family: var(--font); font-size: 33px; font-weight: 300; letter-spacing: -0.01em; }
.key .kl { font-size: 9px; font-weight: 600; letter-spacing: 2.6px; opacity: 0.55; margin-top: 3px; }
.lock-bottom { width: calc(3 * 78px + 2 * 28px); font-size: 15px; }
.lock-bottom button, .lock-sos { font-size: 15px; font-weight: 500; opacity: 0.82; }
.lock-inner { transition: opacity .38s var(--ease-out), transform .6s var(--ease-out), filter .38s; }
.lock.fx-dissolving .lock-inner { opacity: 0; transform: scale(1.035); filter: blur(5px); }
.lock-wall { filter: blur(40px) saturate(120%); background:
    radial-gradient(55% 40% at 30% 30%, #5a0a1c 0%, transparent 70%),
    radial-gradient(50% 45% at 80% 45%, #2a0d44 0%, transparent 70%),
    radial-gradient(70% 50% at 40% 95%, #0a1f3d 0%, transparent 70%),
    #07060a; }
@media (max-height: 740px) { .lock-inner { gap: 3vh; } .lock-time { font-size: clamp(48px, 9vh, 70px); } .lock-date { font-size: 14px; } }
@media (max-height: 660px) { .lock-clock { display: none; } .keypad { gap: 12px 22px; } .lock-bottom { width: calc(3 * 70px + 2 * 22px); } }
.lock.disabled .lock-clock, .lock.guest-ended .lock-clock { opacity: 1; }
.me .bubble.error { background: transparent; box-shadow: none; }
@media (max-width: 760px) {
  .room.active .room-slide { background: var(--bg); }
  .room-slide .avatar, .room.active .room-slide .avatar { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px color-mix(in srgb, var(--c1, #999) 45%, transparent); }
}
/* 밀지 않을 때는 뒤의 버튼이 둥근 모서리 틈으로 비치지 않게 */
.room:not(.swiping) .room-actions { visibility: hidden; }

/* 답장 중에 보내 둔 메시지: 차례가 끝날 때까지 흐리게 대기 */
.row.queued .bubble, .row.queued .sent-photos { opacity: .55; }
.row.queued .bubble { border: 1px dashed rgba(255,255,255,.55); }
/* 사진을 끌어다 놓는 중 */
#chat.drop-on::after { content: '여기에 놓으면 사진이 첨부돼요'; position: absolute; inset: 10px; z-index: 50; display: grid; place-items: center; border: 2px dashed #0b84fe; border-radius: 18px; background: rgba(11,132,254,.08); color: #0b84fe; font-weight: 600; font-size: 15px; pointer-events: none; backdrop-filter: blur(2px); }

/* 첨부 파일 카드 (보낸 말풍선 · 입력줄 미리보기) */
.sent-files { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin: 2px 0 4px; max-width: 100%; }
.row.them .sent-files { align-items: flex-start; }
.file-card { display: inline-flex; align-items: center; gap: 8px; max-width: min(320px, 100%); padding: 9px 12px; border-radius: 14px; background: var(--search); color: var(--text); text-decoration: none; font-size: 14px; box-shadow: inset 0 0 0 .5px var(--line); }
a.file-card:hover { filter: brightness(.97); }
.fc-ico { flex: none; font-size: 18px; line-height: 1; }
.fc-name, .af-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fc-size { flex: none; font-size: 12px; color: var(--sub); }
.attach-item.attach-file { display: inline-flex; align-items: center; gap: 6px; width: auto; max-width: 220px; height: auto; padding: 8px 26px 8px 10px; border-radius: 12px; background: var(--search); font-size: 13px; }
.attach-item.attach-file .attach-x { top: 50%; transform: translateY(-50%); right: 4px; }
