:root {
  --bg: #0f1115; --panel: #171a20; --line: #262a32; --text: #f2f3f5; --sub: #9aa1ad;
  --me: #2f6bff; --me-sub: #dbe6ff; --them: #20242c; --accent: #3ddc84; --warn: #ffb020; --bad: #ff5a5f;
  --fs: 1; --safe-b: env(safe-area-inset-bottom); --safe-t: env(safe-area-inset-top);
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f7; --panel: #ffffff; --line: #e3e5ea; --text: #15171c; --sub: #6b7280; --them: #ffffff; --me-sub: #e6eeff; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: calc(16px * var(--fs))/1.45 -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans", system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
#app { height: 100%; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; }

/* ── 시작 화면 ── */
.onb { flex: 1; overflow-y: auto; padding: calc(var(--safe-t) + 40px) 20px calc(var(--safe-b) + 24px); display: flex; flex-direction: column; gap: 18px; }
.onb h1 { font-size: 28px; margin: 0; letter-spacing: -0.5px; }
.onb .tag { color: var(--sub); margin: -10px 0 8px; }
.onb h2 { font-size: 19px; margin: 8px 0 0; }
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.langs button { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px; text-align: left; display: flex; gap: 10px; align-items: center; }
.langs button.sel { border-color: var(--me); box-shadow: 0 0 0 2px var(--me) inset; }
.langs .f { font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--sub); }
.field input, .field select { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; outline: none; }
.field input:focus { border-color: var(--me); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.seg button.sel { background: var(--me); border-color: var(--me); color: #fff; }
.primary { background: var(--me); color: #fff; border: none; border-radius: 14px; padding: 15px; font-weight: 700; font-size: 17px; }
.primary:disabled { opacity: .4; }
.ghost { background: none; border: none; color: var(--sub); padding: 8px; }
.err { color: var(--bad); font-size: 14px; min-height: 1.2em; }
.codebox { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 16px; text-align: center; }
.codebox .code { font-size: 30px; letter-spacing: 6px; font-weight: 800; margin-top: 4px; }
.waiting { color: var(--sub); text-align: center; display: flex; gap: 8px; justify-content: center; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.notice { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.4; }

/* ── 채팅 ── */
.top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 14px 10px; border-bottom: 1px solid var(--line); background: var(--panel); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #ff7aa2, #ffb36b); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: none; }
.who { flex: 1; min-width: 0; }
.who b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--sub); }
.who span.on { color: var(--accent); }
.icon { background: none; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 20px; display: flex; align-items: center; justify-content: center; }
.icon:active { background: var(--line); }
.banner { font-size: 12.5px; text-align: center; padding: 7px 12px; background: color-mix(in srgb, var(--warn) 16%, var(--panel)); }
.banner.bad { background: color-mix(in srgb, var(--bad) 22%, var(--panel)); }

.list { flex: 1; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.day { align-self: center; font-size: 11.5px; color: var(--sub); background: color-mix(in srgb, var(--text) 7%, transparent); padding: 3px 10px; border-radius: 10px; margin: 8px 0; }
.more { align-self: center; font-size: 13px; color: var(--sub); background: none; border: 1px solid var(--line); border-radius: 14px; padding: 5px 12px; }
.row { display: flex; flex-direction: column; max-width: 82%; }
.row.me { align-self: flex-end; align-items: flex-end; }
.row.them { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 9px 13px; border-radius: 18px; word-break: break-word; white-space: pre-wrap; position: relative; }
.me .bubble { background: var(--me); color: #fff; border-bottom-right-radius: 6px; }
.them .bubble { background: var(--them); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble .main { font-size: calc(16.5px * var(--fs)); }
.bubble .sub { font-size: calc(13px * var(--fs)); margin-top: 4px; opacity: .78; }
.me .bubble .sub { color: var(--me-sub); opacity: .95; }
.bubble .sub.back::before { content: "↩ "; }
.bubble .fix { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 7px; background: #00000030; color: var(--warn); margin-bottom: 4px; }
.them .bubble .fix { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.bubble.pending .main { opacity: .7; }
.state { font-size: 11px; color: var(--sub); margin: 2px 6px 0; }
.state.bad { color: var(--bad); }
.time { font-size: 10.5px; color: var(--sub); margin: 2px 6px 0; }
.typing { font-size: 12px; color: var(--sub); padding: 0 16px 4px; height: 18px; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(var(--safe-b) + 8px); border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; resize: none; max-height: 120px; min-height: 42px; background: var(--bg); border: 1px solid var(--line); border-radius: 21px; padding: 10px 14px; outline: none; line-height: 1.35; }
.send { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--me); color: #fff; font-size: 18px; flex: none; }
.send:disabled { opacity: .35; }

/* ── 설정 시트 ── */
.sheet-bg { position: fixed; inset: 0; background: #0008; display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 640px; background: var(--panel); border-radius: 20px 20px 0 0; padding: 10px 18px calc(var(--safe-b) + 18px); max-height: 85%; overflow-y: auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 4px 0 14px; }
.sheet .row2 { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.sizes { display: flex; gap: 6px; }
.sizes button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
.sizes button.sel { background: var(--me); border-color: var(--me); color: #fff; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line); border: none; position: relative; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 21px; }
.usage { font-size: 13px; color: var(--sub); }
.usage b { color: var(--text); font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 90px); transform: translateX(-50%); background: #000c; color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 14px; z-index: 40; }   /* 통화 화면(30) 위로 */
.empty { margin: auto; text-align: center; white-space: pre-line; color: var(--sub); font-size: 15px; line-height: 1.6; padding: 24px; }
.bubble .draft { opacity: .72; }
.banner.push { background: color-mix(in srgb, var(--me) 18%, var(--panel)); padding: 6px 12px; }
.pushbtn { background: var(--me); color: #fff; border: none; border-radius: 10px; padding: 7px 14px; font-weight: 700; font-size: 14px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand img { width: 58px; height: 58px; border-radius: 16px; }
.brand h1 { margin: 0; } .brand .tag { margin: 2px 0 0; }
.maker { margin-top: auto; padding-top: 18px; text-align: center; font-size: 11px; color: var(--sub); }
.maker img { display: block; height: 22px; margin: 6px auto 0; }
.gbtn { display: flex; justify-content: center; min-height: 44px; margin: 6px 0; }
.note { font-size: 12px; color: var(--sub); text-align: center; }
.ghost.danger { color: var(--bad); padding-left: 0; }
.gfallback { background: #fff; color: #222; border: none; border-radius: 20px; padding: 10px 18px; font-weight: 700; }

/* ── 통화 기록 줄 ── */
.callrow { align-self: center; font-size: 12.5px; color: var(--sub); background: color-mix(in srgb, var(--text) 7%, transparent); padding: 5px 12px; border-radius: 12px; margin: 6px 0; cursor: pointer; }
.callrow.bad { color: var(--bad); }

/* ── 영상통화 화면 (시안 docs/mockups/call.html) ── */
.callui { position: fixed; inset: 0; z-index: 30; background: #000; color: #fff; overflow: hidden; }
.callui[hidden] { display: none; }
.callui #rv { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #111; }
.c-face { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
          background: radial-gradient(ellipse at 50% 30%, #3a2f45, #17141d 70%); }
.c-av { width: 120px; height: 120px; border-radius: 50%; background: linear-gradient(135deg, #ff7aa2, #ffb36b); display: flex; align-items: center; justify-content: center;
        font-size: 52px; font-weight: 800; box-shadow: 0 0 0 16px #ffffff12, 0 0 0 34px #ffffff08; }
.c-face p { margin: 28px 0 0; color: #ddd; font-size: 15px; }
.callui:not([data-state=live]) .c-face, .callui.camoff .c-face { display: flex; }
.callui[data-state=ringing] .c-av { animation: ringpulse 1.6s infinite; }
@keyframes ringpulse { 50% { box-shadow: 0 0 0 22px #ffffff18, 0 0 0 44px #ffffff0a; } }
.c-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-t) + 16px) 16px 18px; display: flex; align-items: flex-start; gap: 10px;
         background: linear-gradient(#000a, #0000); }
.c-who b { display: block; font-size: 18px; }
.c-who span { font-size: 13px; color: #ddd; }
.c-lang { margin-left: auto; font-size: 12px; background: #0006; border: 1px solid #fff3; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.callui[data-state=ringing] .c-lang { display: none; }
.c-stat { position: absolute; top: calc(var(--safe-t) + 66px); left: 12px; margin: 0; font: 11px/1.4 ui-monospace, monospace; background: #0009; padding: 6px 8px; border-radius: 8px; z-index: 2; white-space: pre; }
.c-pip { position: absolute; top: calc(var(--safe-t) + 74px); right: 12px; width: 96px; height: 136px; object-fit: cover; border-radius: 14px; border: 2px solid #ffffff40; background: #1f2833; z-index: 1; }
.c-pip:not(.back) { transform: scaleX(-1); }   /* 셀카는 거울처럼 */
.callui[data-state=ringing] .c-pip { display: none; }
.c-subs { position: absolute; left: 14px; right: 14px; bottom: calc(var(--safe-b) + 130px); text-align: center; transition: opacity .6s; }
.c-subs.stale { opacity: .35; }
.c-subs .them { font-size: calc(22px * var(--fs)); font-weight: 700; line-height: 1.5; background: #000a; padding: 3px 12px; border-radius: 8px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.c-subs .them:empty, .c-subs .mine:empty, .c-subs .orig:empty { display: none; }
.c-subs .them.draft { opacity: .75; }
.c-subs .orig { margin-top: 6px; font-size: calc(13px * var(--fs)); color: #ddd; text-shadow: 0 1px 3px #000; }
.c-subs .mine { display: inline-block; margin-top: 10px; font-size: calc(15px * var(--fs)); color: #cfe; background: #0009; padding: 3px 10px; border-radius: 8px; }
.callui[data-state=ringing] .c-subs { display: none; }
.c-bar { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 22px); display: flex; justify-content: center; gap: 10px; padding: 0 8px; }
.c-bar.ringbar { gap: 90px; bottom: calc(var(--safe-b) + 70px); }
.c-btn { position: relative; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: #eee; background: none; border: none; padding: 0; }
.c-btn i { width: 56px; height: 56px; border-radius: 50%; background: #ffffff26; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 23px; }
.ringbar .c-btn i { width: 72px; height: 72px; font-size: 30px; }
.c-btn.end i { background: #ff4d4f; }
.c-btn.ok i { background: #22c55e; }
.c-btn.off i { background: #fff; color: #000; }
.c-badge { position: absolute; top: -2px; right: 6px; background: var(--accent); color: #000; font-size: 10px; font-weight: 800; border-radius: 9px; padding: 1px 5px; }
.c-sheet { position: absolute; left: 0; right: 0; bottom: 0; height: 64%; background: var(--panel); color: var(--text); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 30px #0008;
           display: flex; flex-direction: column; z-index: 3; max-width: 640px; margin: 0 auto; }
.c-sheet[hidden] { display: none; }
.c-sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 9px auto 4px; flex: none; }
.c-sheet .sh-head { display: flex; align-items: center; gap: 8px; padding: 2px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.c-sheet .sh-head span { font-size: 12px; color: var(--sub); }
.c-sheet .sh-head .ghost { margin-left: auto; }
.c-slot { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.callui.open .c-subs, .callui.open .c-bar { display: none; }
body.incall { overflow: hidden; }
.c-soundpop { position: absolute; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 112px); z-index: 4; display: flex; flex-direction: column; gap: 10px;
              padding: 12px; border-radius: 14px; background: #000c; max-width: 480px; margin: 0 auto; }
.c-soundpop[hidden] { display: none; }
.c-soundpop #cout { min-height: 44px; border-radius: 10px; border: 1px solid #888; background: transparent; color: #fff; font-size: 15px; padding: 6px 10px; }
.c-vol { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.c-vol input { flex: 1; accent-color: #fff; height: 28px; }
.c-vol b { font-size: 14px; min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.callui.open .c-soundpop { display: none; }

/* ── 이메일 연결 요청 ── */
.byemail { display: flex; flex-direction: column; gap: 8px; }
.emrow { display: flex; gap: 8px; }
.emrow input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; }
.emrow input:focus { border-color: var(--me); }
.emrow .primary { padding: 12px 18px; font-size: 15px; }
.reqout { font-size: 13px; color: var(--sub); }
.reqout .ghost { font-size: 13px; padding: 2px 6px; }
.reqcard { background: color-mix(in srgb, var(--me) 14%, var(--panel)); border: 1px solid var(--me); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.reqcard b { font-size: 16px; }
.reqbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.reqbtns .primary { padding: 9px 18px; font-size: 15px; }
.gfallback b { font-weight: 900; margin-right: 6px; color: #4285f4; }
.gerr { color: var(--bad); font-size: 13px; text-align: center; margin: 6px 0 0; }

/* ── 친구 목록 (2026-10-14) ── */
.brandmark { width: 34px; height: 34px; border-radius: 10px; }
.friends { flex: 1; overflow-y: auto; padding: 8px 10px 12px; }
.fhead { font-size: 12.5px; color: var(--sub); margin: 8px 6px 4px; }
.friend { width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px 8px; background: none; border: none; border-radius: 14px; text-align: left; }
.friend:active { background: var(--line); }
.friend .avatar { position: relative; width: 46px; height: 46px; font-size: 18px; }
.dot-on { position: absolute; right: 0; bottom: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.fmain { flex: 1; min-width: 0; }
.fname { display: flex; justify-content: space-between; gap: 8px; }
.fname b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname span { font-size: 11.5px; color: var(--sub); flex: none; }
.fprev { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.fprev span { flex: 1; min-width: 0; font-size: 13.5px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff; font-size: 11.5px; display: flex; align-items: center; justify-content: center; }
.homebar { padding: 10px 14px calc(var(--safe-b) + 12px); border-top: 1px solid var(--line); background: var(--panel); }
.homebar .primary { width: 100%; }
.leave { flex: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 16px; padding: 6px 12px 6px 9px; font-size: 14px; }
.leave:active { background: var(--line); }
.addsec { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.addsec .usage { margin: -2px 0 2px; }
.codein { text-transform: uppercase; letter-spacing: 3px; }
.admlog { font-size: 13.5px; line-height: 1.9; padding: 0 6px; }
.admlog span { color: var(--sub); font-variant-numeric: tabular-nums; margin-right: 4px; }
.unread1 { color: var(--warn); font-size: 11px; font-weight: 800; margin-right: 5px; }
