/* =========================================================
   app.css - 지니톡(가족 메신저) 모양
   · 색은 :root 변수로. 어두운 모드는 기기 설정(prefers-color-scheme)을 따름
   · 글자 크기: <html data-font="s|m|l|xl"> (설정 화면에서 기기별로)
   · 누르는 곳은 최소 44px, 아이폰 노치·홈 막대는 safe-area 로 비켜 감
   ========================================================= */
:root {
    --bg: #f5f3fa;
    --surface: #ffffff;
    --surface-2: #ebe7f3;
    --text: #221f29;
    --text-2: #6a6577;
    --line: #ddd8e8;
    --brand: #9370db;        /* 사이트 기본색 (표시줄·아이콘 칸·앱 아이콘과 같은 값, 어두운 모드에서도 그대로) */
    --accent: #9370db;       /* 버튼·스위치 등 바탕 */
    --accent-ink: #6e4fc0;   /* 링크·[공지]·[답장] 같은 글자 (연한 보라는 흰 바탕 글자로 흐려서 진하게) */
    --accent-text: #ffffff;
    --mine: #e4dafa;
    --mine-text: #231a36;
    --theirs: #ffffff;
    --danger: #c0352b;
    --unread: #d18a12;
    --chat-bg: #e8e4f0;
    --shadow: 0 2px 10px rgba(0, 0, 0, .12);
    --fs: 17px;
    --app-h: 100dvh;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181c;
        --surface: #22252b;
        --surface-2: #2c3037;
        --text: #ece9e3;
        --text-2: #a39e95;
        --line: #353a42;
        --accent: #b69cf2;
        --accent-ink: #b69cf2;
        --accent-text: #1a1230;
        --mine: #4b3c7a;
        --mine-text: #f1ebff;
        --theirs: #2c3037;
        --danger: #ef6b5f;
        --unread: #f0b445;
        --chat-bg: #111316;
        --shadow: 0 2px 12px rgba(0, 0, 0, .5);
    }
}
html[data-font="s"] { --fs: 15px; }
html[data-font="m"] { --fs: 17px; }
html[data-font="l"] { --fs: 20px; }
html[data-font="xl"] { --fs: 24px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
    line-height: 1.45;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

#app { height: var(--app-h); display: flex; flex-direction: column; }
.view-host { flex: 1; min-height: 0; display: flex; }
.view { flex: 1; min-width: 0; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; width: 100%; background: var(--bg); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
.pad { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.scroll.pad { padding-top: 12px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 14px; }
.boot { margin: auto; padding: 40px 16px; color: var(--text-2); text-align: center; }
.center { text-align: center; }
.lead { font-size: 1.05rem; margin: 4px 0 16px; }

/* ---------- 위 막대 ---------- */
.bar {
    display: flex; align-items: center; gap: 4px;
    min-height: 56px;
    padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(6px, env(safe-area-inset-left));
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.bar-title { flex: 1; min-width: 0; margin: 0 4px; font-family: "Noto Sans KR Title", "Noto Sans KR", sans-serif; font-size: 1.235rem; font-weight: 900; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: baseline; gap: 6px; }
.bar-title > span { overflow: hidden; text-overflow: ellipsis; }
.bar-pad { width: 8px; }
.bar-logo { flex: none; width: 36px; height: 36px; margin: 0 6px 0 8px; border-radius: 11px; background: var(--brand) url(icons/title.svg) center / 21px no-repeat; }
.bar-actions { display: flex; align-items: center; }
.icon-btn {
    min-width: 44px; min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; background: none; border-radius: 12px;
    font-size: 1.5rem; line-height: 1; color: var(--text); text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { min-width: 36px; min-height: 36px; font-size: 1.2rem; }

/* 아이콘 (그림 파일 없이 CSS 로) */
.ico { display: inline-block; width: 22px; height: 22px; position: relative; }
.ico-search::before { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border: 2.5px solid currentColor; border-radius: 50%; }
.ico-search::after { content: ""; position: absolute; left: 14px; top: 14px; width: 8px; height: 2.5px; background: currentColor; transform: rotate(45deg); transform-origin: 0 0; border-radius: 2px; }
.ico-plus::before, .ico-plus::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 2.5px; background: currentColor; border-radius: 2px; transform: translate(-50%, -50%); }
.ico-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
.ico-gear::before { content: ""; position: absolute; inset: 3px; border: 2.5px solid currentColor; border-radius: 50%; }
.ico-gear::after { content: ""; position: absolute; inset: -1px; border: 4px dotted currentColor; border-radius: 50%; }
.ico-send::before { content: ""; position: absolute; left: 3px; top: 3px; border-left: 18px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }

/* ---------- 버튼·입력 ---------- */
.btn {
    min-height: 44px; padding: 0 16px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface); color: var(--text);
    font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn:disabled, .btn.busy { opacity: .55; cursor: default; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; }
.row-btns.wrap { flex-wrap: wrap; }

input[type=text], input[type=password], input[type=search], textarea, select, .link-input {
    width: 100%; min-height: 48px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--text-2); font-size: .85rem; display: block; margin-top: 4px; }
.form-error { color: var(--danger); font-weight: 600; margin: 8px 0; }
.flash { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 0 0 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.check input { width: 22px; height: 22px; }

.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.card h2 { font-size: 1.05rem; margin: 0 0 8px; }
.form-title { font-size: 1.15rem; margin: 0 0 16px; }

/* ---------- 로그인·가입 ---------- */
.auth { overflow-y: auto; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); max-width: 460px; }
.brand { text-align: center; margin: 12px 0 20px; }
.brand h1 { margin: 10px 0 0; font-size: 1.5rem; }
.logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; background: url("icons/icon-192.png?v=20261103b") center / cover, var(--brand); }

/* ---------- 대화 목록 ---------- */
.rooms, .people, .search-results, .toggles, .devices, .family, .linklog, .steps { list-style: none; margin: 0; padding: 0; }
.room-row, .person-row, .result-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    min-height: 72px; border: 0; border-bottom: 1px solid var(--line);
    background: none; color: var(--text); text-decoration: none; text-align: left; cursor: pointer;
}
.room-row:hover, .person-row:hover, .result-row:hover { background: var(--surface-2); }
.avatar {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); font-weight: 700; font-size: 1.2rem;
}
.avatar.group { background: var(--accent); color: var(--accent-text); }
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.room-top, .room-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.room-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-count { color: var(--text-2); font-size: .85rem; font-weight: 400; }
.muted-mark { font-size: .8rem; }
.room-time { margin-left: auto; color: var(--text-2); font-size: .78rem; white-space: nowrap; }
.room-snippet { flex: 1; min-width: 0; color: var(--text-2); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex-shrink: 0; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--danger); color: #fff; font-size: .78rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.person-name { font-weight: 600; }
.empty { padding: 24px 16px; color: var(--text-2); text-align: center; }

.notice { display: flex; align-items: flex-start; gap: 8px; margin: 10px 12px 2px; padding: 10px 6px 10px 12px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; }
.notice-tag { flex-shrink: 0; font-size: .78rem; font-weight: 700; color: var(--accent-ink); padding-top: 3px; }
.notice-text { flex: 1; margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------- 대화방 ---------- */
/* 사용자가 고른 색 (설정 > 채팅방 색상). 값은 app.js 의 applyChatColors() 가 <html> 에 넣음.
   고른 배경이 어두우면 날짜, 이름, 시간 글자도 밝게 바꿈 */
html[data-chat-bg] .msgs-wrap, html[data-chat-bg] .chat-preview { --text-2: var(--chat-ink-2); --line: var(--chat-ink-2); }
html[data-chat-bg="dark"] .day span { background: rgba(255, 255, 255, .14); }
.room .bar { position: relative; z-index: 2; }
.msgs-wrap { flex: 1; min-height: 0; position: relative; background: var(--chat-bg); }
.msgs { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px max(10px, env(safe-area-inset-right)) 12px max(10px, env(safe-area-inset-left)); }
.loader, .start { text-align: center; color: var(--text-2); font-size: .82rem; padding: 10px; }
.day { text-align: center; margin: 14px 0 8px; }
.day span { display: inline-block; padding: 3px 12px; border-radius: 12px; background: rgba(0, 0, 0, .08); color: var(--text-2); font-size: .8rem; }
.msg { margin-top: 10px; display: flex; flex-direction: column; }
.msg.cont { margin-top: 3px; }
.msg.mine { align-items: flex-end; }
.msg.theirs { align-items: flex-start; }
.who { font-size: .82rem; color: var(--text-2); margin: 0 0 3px 4px; }
.msg-row { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; }
.msg.mine .msg-row { flex-direction: row-reverse; }
.bubble {
    padding: 8px 12px; border-radius: 16px;
    background: var(--theirs); color: var(--theirs-text, var(--text));
    white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
    -webkit-user-select: text; user-select: text;
    -webkit-touch-callout: none;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); }
.msg.theirs:not(.cont) .bubble { border-top-left-radius: 6px; }
.msg.mine:not(.cont) .bubble { border-top-right-radius: 6px; }
.bubble.deleted { font-style: italic; color: var(--text-2); background: transparent; box-shadow: none; border: 1px dashed var(--line); }
.bubble a { color: inherit; text-decoration: underline; word-break: break-all; }
.msg.pending .bubble { opacity: .7; }
.msg.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.meta { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; font-size: .72rem; color: var(--text-2); line-height: 1.2; }
.msg.theirs .meta { align-items: flex-start; }
.unread { color: var(--unread); font-weight: 700; }
.sending { white-space: nowrap; }
.retry { border: 0; background: none; color: var(--danger); font: inherit; font-weight: 700; cursor: pointer; min-height: 32px; padding: 0 2px; white-space: nowrap; }
.quote {
    display: block; width: 100%; text-align: left;
    margin: 0 0 6px; padding: 5px 8px;
    border: 0; border-left: 3px solid var(--accent); border-radius: 6px;
    background: rgba(0, 0, 0, .06); cursor: pointer; font-size: .85rem;
}
.quote-who { display: block; font-weight: 700; font-size: .78rem; }
.quote-text { display: block; color: inherit; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.new-msg {
    position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px;
    background: var(--accent); color: var(--accent-text); font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
}

.composer {
    flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer .input { flex: 1; min-height: 44px; max-height: 160px; resize: none; border-radius: 22px; padding: 10px 16px; line-height: 1.35; }
.send-btn { flex-shrink: 0; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.send-btn:disabled { opacity: .45; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 0 0 6px 6px; font-size: .85rem; }
.reply-label { color: var(--accent-ink); font-weight: 700; flex-shrink: 0; }
.reply-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }

.room-search { background: var(--surface); border-bottom: 1px solid var(--line); max-height: 50%; overflow-y: auto; flex-shrink: 0; }
.room-search .search-row { padding: 8px 12px; }
.search-row { display: flex; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.search-row input { flex: 1; }
.result-row { flex-direction: column; align-items: stretch; gap: 4px; min-height: 0; }
.result-top { display: flex; gap: 8px; font-size: .82rem; color: var(--text-2); }
.result-room { font-weight: 700; color: var(--text); }
.result-time { margin-left: auto; }
.result-text { word-break: break-word; }
mark { background: var(--mine); color: var(--mine-text); border-radius: 3px; padding: 0 1px; }

/* ---------- 떠 있는 것들 ---------- */
.ctx { position: fixed; z-index: 50; min-width: 150px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.ctx button { display: block; width: 100%; min-height: 46px; padding: 0 16px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 1rem; cursor: pointer; }
.ctx button:hover, .ctx button:focus { background: var(--surface-2); outline: none; }
.ctx button.danger { color: var(--danger); }
.toast {
    position: fixed; z-index: 60; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 22px;
    background: rgba(30, 30, 30, .92); color: #fff; font-size: .92rem; text-align: center; box-shadow: var(--shadow);
}
.conn, .update { flex-shrink: 0; text-align: center; font-size: .85rem; padding: calc(4px + env(safe-area-inset-top)) 8px 4px; }
.conn { background: var(--surface-2); color: var(--text-2); }
.update { background: var(--accent); padding: 0; }
.update button { width: 100%; min-height: 44px; padding-top: env(safe-area-inset-top); border: 0; background: none; color: var(--accent-text); font-weight: 700; cursor: pointer; }
.conn:not([hidden]) ~ .view-host .bar, .update:not([hidden]) ~ .view-host .bar { padding-top: 0; }

/* ---------- 설정·관리자 ---------- */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg-btn { min-height: 48px; white-space: nowrap; padding: 0 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-weight: 600; }
.seg-btn:nth-child(1) { font-size: 15px; }
.seg-btn:nth-child(2) { font-size: 17px; }
.seg-btn:nth-child(3) { font-size: 20px; }
.seg-btn:nth-child(4) { font-size: 24px; }
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.toggle { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggles li:last-child .toggle { border-bottom: 0; }
.toggle > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex-shrink: 0; width: 52px; height: 30px; border-radius: 15px; background: var(--line); transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(22px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.device, .fam { padding: 12px 0; border-bottom: 1px solid var(--line); }
.device { display: flex; align-items: center; gap: 10px; }
.devices li:last-child, .family li:last-child { border-bottom: 0; }
.device-main { flex: 1; min-width: 0; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: .75rem; font-weight: 600; vertical-align: middle; }
.tag.on { background: var(--accent); color: var(--accent-text); }
.fam.removed { opacity: .55; }
.fam-top { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.linklog li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.linklog .tag { margin-left: 0; }
.linklog-main { flex: 1; min-width: 180px; }
.link-box { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.link-input { font-size: .85rem; }
.links { padding: 4px 16px; }
.menu-row { display: flex; align-items: center; width: 100%; min-height: 52px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); text-decoration: none; text-align: left; cursor: pointer; font-size: 1rem; padding: 0; }
.menu-row:last-child { border-bottom: 0; }
.menu-row.danger { color: var(--danger); }
.steps { counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 8px 0 8px 40px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.guide-actions { margin-top: 16px; }

@media (max-width: 480px) {
    .seg { grid-template-columns: repeat(2, 1fr); }
}
.scroll, .msgs, .room-search { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
@media (min-width: 761px) {
    .view { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 사진 (2단계) ---------- */
.ico-photo::before { content: ""; position: absolute; left: 1px; top: 4px; width: 20px; height: 15px; border: 2.5px solid currentColor; border-radius: 4px; box-sizing: border-box; }
.ico-photo::after { content: ""; position: absolute; left: 8px; top: 8px; width: 6px; height: 6px; border: 2.5px solid currentColor; border-radius: 50%; box-sizing: border-box; }
.photo-btn { flex-shrink: 0; align-self: flex-end; color: var(--text-2); }
.bubble.has-photos { padding: 4px; }
.bubble.has-photos .body { display: block; padding: 4px 8px 4px; }
.bubble.has-photos .quote { margin: 4px 4px 6px; width: calc(100% - 8px); }
.msg .bubble.photo-only { background: transparent; box-shadow: none; padding: 0; }
.photos { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; }
.photos.g2 { grid-template-columns: repeat(2, 1fr); width: min(240px, 62vw); }
.photos.g3 { grid-template-columns: repeat(3, 1fr); width: min(270px, 66vw); }
.photos.g4 { grid-template-columns: repeat(2, 1fr); width: min(240px, 62vw); }
.photo { position: relative; display: block; padding: 0; border: 0; background: var(--surface-2); cursor: zoom-in; overflow: hidden; }
.photos.g1 .photo { background: transparent; }
.photos.g1 img { display: block; max-width: min(240px, 62vw); max-height: 320px; width: auto; height: auto; border-radius: 12px; background: var(--surface-2); }
.photos.g2 .photo, .photos.g3 .photo, .photos.g4 .photo { aspect-ratio: 1; }
.photos.g2 img, .photos.g3 img, .photos.g4 img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo .more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .5); color: #fff; font-size: 1.4rem; font-weight: 700; }
.msg.pending .photo img { opacity: .6; }

.tray { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.tray-item { position: relative; flex: none; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.tray-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-item.prep img, .tray-item.up img { opacity: .55; }
.tray-bar { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.tray-fill { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.tray-item.done .tray-bar { display: none; }
.tray-label { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #fff; font-size: .78rem; font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, .7); pointer-events: none; }
.tray-item.failed { outline: 2px solid var(--danger); outline-offset: -2px; cursor: pointer; }
.tray-item.failed .tray-label { background: var(--danger); padding: 2px 0; }
.tray-x { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
/* 사진 뷰어(/common/photo-viewer.css) 위 저장 버튼 색 */
:root { --pv-accent: #e4dafa; }

/* ---------- 이모지 반응 (2단계) ---------- */
.emoji-row { display: flex; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ctx .emoji-row:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 2px; }
.ctx .emoji { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; text-align: center; font-size: 1.5rem; line-height: 1; }
.ctx .emoji.on { background: var(--mine); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; max-width: 86%; }
.msg.mine .reactions { justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 3px; min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--text); font-size: .85rem; cursor: pointer; }
.chip.mine { border-color: var(--accent); background: var(--mine); color: var(--mine-text); font-weight: 700; }
.chip-e { font-size: 1rem; line-height: 1; }
.react-btn { display: none; flex-shrink: 0; align-self: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface); color: var(--text-2); font-size: 1.1rem; cursor: pointer; opacity: 0; transition: opacity .12s; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
@media (hover: hover) and (pointer: fine) {
    .react-btn { display: inline-flex; align-items: center; justify-content: center; }
    .msg:hover .react-btn, .react-btn:focus-visible { opacity: 1; }
}
.who-list { min-width: 180px; max-width: 280px; padding: 4px 6px; }
.who-row { display: flex; gap: 8px; align-items: baseline; padding: 6px 4px; }
.who-row + .who-row { border-top: 1px solid var(--line); }
.who-e { font-size: 1.2rem; }
.who-names { font-size: .92rem; word-break: keep-all; }

/* ---------- 푸시 알림 (2단계) ---------- */
.hint.warn { color: var(--danger, #b3261e); background: var(--bg); border-radius: 8px; padding: 8px 10px; line-height: 1.5; }
.hint[hidden] { display: none; }
.toggle .sub { display: block; color: var(--text-2); font-size: .8rem; font-weight: 400; white-space: normal; }
.toggle input:disabled + .switch { opacity: .45; }
.push-ask { align-items: center; }
.push-ask .notice-text { align-self: center; }
.push-ask .btn { flex-shrink: 0; }
.inapp {
    position: fixed; z-index: 55; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    width: min(440px, calc(100% - 24px)); padding: 10px 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px;
    background: var(--surface); color: var(--text); box-shadow: 0 6px 24px rgba(0, 0, 0, .22); text-align: left; cursor: pointer;
    animation: inapp-in .18s ease-out;
}
.inapp[hidden] { display: none; }
.inapp strong { font-size: .9rem; }
.inapp span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: .88rem; }
@keyframes inapp-in { from { transform: translate(-50%, -120%); } }
@media (prefers-reduced-motion: reduce) { .inapp { animation: none; } }

/* 설정 > 채팅방 색상 */
.chat-preview { display: flow-root; margin: 10px 0 12px; padding: 4px 10px 12px; border-radius: 12px; background: var(--chat-bg); }
.color-row { margin-top: 12px; }
.color-row + .btn { margin-top: 16px; }
.color-row > b { display: block; margin-bottom: 6px; font-size: .9rem; }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.swatch { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch-custom { position: relative; display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; font-size: .85rem; cursor: pointer; }
.swatch-custom.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch-custom input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }

/* 안내 문구의 문장 덩어리 (app.js 의 setSentences) */
.sent { display: inline-block; max-width: 100%; }

/* 대화방 머리말: 제목 + 참여자 이름 (누르면 방 정보) */
.room-head { flex: 1; min-width: 0; margin: 0 4px; display: flex; flex-direction: column; justify-content: center; color: inherit; text-decoration: none; }
.room-head .bar-title { flex: none; margin: 0; line-height: 1.25; }
.room-people { color: var(--text-2); font-size: .72rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 들어옴·나감 안내 */
.sys { text-align: center; margin: 10px 0; }
.sys span { display: inline-block; max-width: 90%; padding: 3px 12px; border-radius: 12px; background: rgba(0, 0, 0, .08); color: var(--text-2); font-size: .8rem; }
html[data-chat-bg="dark"] .sys span { background: rgba(255, 255, 255, .14); }

/* 새 대화방, 방 정보 */
.room-form .field-label { display: block; margin: 16px 0 0; }
.person-check { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
label.person-row { min-height: 60px; }
.card .people { margin: 8px 0 12px; }
.card label.person-row { padding-left: 0; padding-right: 0; min-height: 52px; }
.room-members { list-style: none; margin: 0; padding: 0; }
.room-members li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.admin-rooms { list-style: none; margin: 12px 0 0; padding: 0; }
.admin-rooms li { padding: 10px 0; border-top: 1px solid var(--line); }
.admin-rooms b { display: block; }
