/* ===== 테마 변수 ===== */
:root {
  --bubble-a: #f9c5c5;   /* A: 연한 붉은색 (추후 수정 가능) */
  --bubble-a-text: #3a1414;
  --bubble-b: #c5d8f9;   /* B: 연한 파랑색 */
  --bubble-b-text: #122a4a;
}
/* 파스텔 바이올렛 테마 */
body[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f4f1fb;
  --panel: #ffffff;
  --text: #2b2540;
  --muted: #857da0;
  --border: #ece7f7;
  --accent: #8a7bec;
  --header-bg: #ffffff;
  --shadow: 0 6px 24px rgba(80,60,130,.12);
}
body[data-theme="dark"] {
  --bg: #221d33;
  --bg-soft: #1a1626;
  --panel: #2b2543;
  --text: #ece9f7;
  --muted: #a79ec4;
  --border: #3d3557;
  --accent: #8a7bec;
  --header-bg: #262038;
  --shadow: 0 6px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg-soft); color: var(--text);
  overscroll-behavior: none;
}
/* PC: 트위터 DM 처럼 가운데 정렬된 고정 크기 카드 */
body { display: flex; align-items: center; justify-content: center; padding: 24px; }
.hidden { display: none !important; }

/* 첫 페인트 전 인증 상태에 따른 초기 화면 (로그인 깜빡임 방지) */
html.authed #login { display: none !important; }
html.authed #app { display: flex !important; }
.muted { color: var(--muted); font-size: 14px; }

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  background: none; border: none; color: var(--text); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg-soft); }

/* ===== 로그인 / 모달 오버레이 ===== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 20px;
}
.login-box, .modal {
  background: var(--panel); color: var(--text);
  width: 100%; max-width: 380px; border-radius: 18px; padding: 24px;
  box-shadow: var(--shadow);
}
.login-box h1 { margin: 0 0 4px; font-size: 24px; }
.login-box input, .modal input[type="text"] {
  width: 100%; padding: 12px 14px; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 15px;
}
.btn-primary {
  width: 100%; margin-top: 12px; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}

/* ===== 앱 레이아웃 (카드) ===== */
.app {
  position: relative;
  width: min(600px, 100%);
  height: min(88vh, 900px);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.top-actions {
  position: absolute; top: 6px; right: 8px; z-index: 30;
  display: flex; gap: 2px;
}
/* 다크/라이트 아이콘 토글 */
.ic-moon { display: none; }
body[data-theme="dark"] .ic-sun { display: none; }
body[data-theme="dark"] .ic-moon { display: block; }

/* ===== 채팅 헤더 ===== */
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 52px 8px 12px;   /* 우측은 햄버거 버튼 공간 확보 */
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  position: sticky; top: 0; z-index: 10;
}
.header-profiles { display: flex; gap: 6px; flex-shrink: 0; }
.slot-profile {
  display: flex; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 50%; padding: 3px; cursor: pointer; color: var(--text);
}
/* 헤더 프로필은 프사(아바타)만 표시 — 이름 숨김으로 공간 확보 */
.slot-name { display: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background-size: cover; background-position: center;
  background-color: var(--accent);
  display: inline-grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
}
.title-input {
  flex: 1; min-width: 0; border: none; background: transparent; color: var(--text);
  font-size: 15px; font-weight: 600; padding: 6px 8px; border-radius: 8px;
}
.title-input:focus { outline: none; background: var(--bg-soft); }

/* ===== 메시지 영역 ===== */
.messages {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 2px;
  -webkit-overflow-scrolling: touch;
}
.empty-state { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 20px; text-align: center; }

/* 발신자 프로필 헤더 (턴 시작마다) */
.turn-head {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 4px;
}
.turn-head.right { flex-direction: row-reverse; }
.turn-head .avatar { width: 26px; height: 26px; font-size: 12px; }
.turn-head .turn-name { font-size: 13px; font-weight: 700; color: var(--muted); }

/* 날짜 구분선 */
.date-sep { display: flex; justify-content: center; margin: 16px 0 8px; }
.date-sep span {
  font-size: 12px; color: var(--muted); background: var(--bg-soft);
  padding: 3px 12px; border-radius: 999px; border: 1px solid var(--border);
}

/* 말풍선 (시간은 옆에) */
.row { display: flex; align-items: flex-end; gap: 6px; }
.row.left { justify-content: flex-start; }
/* row-reverse 에서는 flex-start 가 오른쪽 정렬이 됨 (bubble 이 맨 오른쪽, time 은 그 왼쪽) */
.row.right { justify-content: flex-start; flex-direction: row-reverse; }
.msg-time { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
/* 읽음 표시(안 읽으면 1) + 시각 묶음 */
.msg-meta { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; gap: 1px; flex-shrink: 0; padding-bottom: 2px; }
.unread-mark { font-size: 11px; font-weight: 700; color: #f2c200; line-height: 1.1; }
.bubble {
  max-width: min(74%, 560px);
  padding: 9px 13px; border-radius: 18px; font-size: 15px; line-height: 1.45;
  white-space: pre-wrap;       /* 줄바꿈 유지 + 전체 표시 */
  word-break: break-word; overflow-wrap: anywhere;
}
/* 색은 유저 정체성(A 붉음 / B 파랑)으로 고정 */
.row.A .bubble { background: var(--bubble-a); color: var(--bubble-a-text); }
.row.B .bubble { background: var(--bubble-b); color: var(--bubble-b-text); }
/* 말풍선 꼬리는 놓이는 쪽(왼/오)을 따라감 */
.row.left .bubble { border-bottom-left-radius: 6px; }
.row.right .bubble { border-bottom-right-radius: 6px; }

/* 길게 누르기(롱프레스) 시 텍스트 선택/콜아웃 방지 */
.bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.bubble.editing { -webkit-user-select: text; user-select: text; }

/* 메시지 수정/삭제 메뉴 */
.msg-menu {
  position: fixed; z-index: 70; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; min-width: 120px;
}
.msg-menu button {
  display: block; width: 100%; text-align: left; padding: 11px 16px;
  background: none; border: none; color: var(--text); cursor: pointer; font-size: 15px;
}
.msg-menu button + button { border-top: 1px solid var(--border); }
.msg-menu button:hover { background: var(--bg-soft); }
.msg-menu button[data-act="delete"] { color: #e0245e; }

/* 인라인 수정 에디터 */
.bubble.editing { display: flex; flex-direction: column; gap: 6px; max-width: min(82%, 560px); padding: 8px; }
.edit-area {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 15px;
  font-family: inherit; line-height: 1.4; background: var(--bg); color: var(--text);
  resize: none; max-height: 200px; min-width: 180px;
}
.edit-area:focus { outline: none; border-color: var(--accent); }
.edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.edit-actions button { border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.edit-save { background: var(--accent); color: #fff; }
.edit-cancel { background: var(--bg-soft); color: var(--text); }

/* 채팅 이미지 말풍선 */
.bubble.img { padding: 0; background: transparent !important; overflow: hidden; }
.msg-img {
  display: block; max-width: min(70vw, 300px); max-height: 340px; border-radius: 16px;
  cursor: pointer; -webkit-touch-callout: none;
}
/* 사진 전체보기 오버레이 */
.img-view { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.85); display: grid; place-items: center; padding: 20px; }
.img-view img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* 검색 강조 / 이동 플래시 */
.bubble.hit { box-shadow: 0 0 0 2px #ffd54a inset; }
.bubble.hit-current { box-shadow: 0 0 0 3px #ff9800 inset; }
.row.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%,100% { box-shadow: none; } 20%,60% { box-shadow: 0 0 0 3px var(--accent) inset; } }

/* 입력 중 — 점 3개 로딩식(1-2-3 순서로 muted↔accent) */
.typing-ind { display: flex; gap: 5px; align-items: center; padding: 4px 16px 8px; }
.typing-ind.hidden { display: none; }
.typing-ind span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; animation: typing-pulse 1.15s infinite ease-in-out; }
.typing-ind span:nth-child(2) { animation-delay: .18s; }
.typing-ind span:nth-child(3) { animation-delay: .36s; }
@keyframes typing-pulse { 0%,70%,100% { opacity: .3; background: var(--muted); transform: translateY(0); } 30% { opacity: 1; background: var(--accent); transform: translateY(-2px); } }
body.timeline-mode #typing-ind, body.chatlist-mode #typing-ind, body.calendar-mode #typing-ind, body.list-mode #typing-ind { display: none; }

/* 메시지 이모지 반응 칩 */
.row.has-reacts { flex-wrap: wrap; }
.msg-reacts { flex-basis: 100%; display: flex; gap: 4px; margin-top: 3px; }
.row.right .msg-reacts { justify-content: flex-end; }
.row.left .msg-reacts { justify-content: flex-start; }
.react-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; height: 22px; border-radius: 11px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; cursor: pointer; line-height: 1; }
.react-chip.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.react-chip b { font-size: 11px; font-weight: 700; color: var(--muted); }
.react-heart { width: 14px; height: 14px; fill: var(--accent); }
/* 반응 선택(메시지 메뉴 상단) */
.menu-reacts { display: flex; gap: 2px; padding: 3px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-reacts button { border: none; background: transparent; font-size: 20px; padding: 4px 6px; border-radius: 8px; cursor: pointer; line-height: 1; }
.menu-reacts button:hover { background: var(--bg-soft); }
.menu-reacts .react-heart-btn { display: inline-flex; align-items: center; }
.menu-reacts .react-heart-btn .react-heart { width: 20px; height: 20px; fill: var(--accent); }

/* N년 전 오늘(추억) 카드 */
.onthisday-card { border: 1px solid var(--border); background: color-mix(in srgb, var(--accent) 7%, var(--panel)); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.otd-lead { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.otd-mark { width: 22px; height: 22px; flex-shrink: 0; }
.otd-list { display: flex; flex-direction: column; gap: 6px; }
.otd-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 6px; border: none; background: transparent; border-radius: 10px; cursor: pointer; }
.otd-item:hover { background: var(--bg-soft); }
.otd-thumb { width: 46px; height: 46px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: var(--bg-soft); }
.otd-thumb-none { display: inline-block; border: 1px dashed var(--border); }
.otd-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.otd-when { font-size: 11px; font-weight: 700; color: var(--accent); }
.otd-line { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 헤더 좌측 도구(검색/책갈피/다운로드) */
.header-tools { display: flex; gap: 0; flex-shrink: 0; }
.tool-btn { width: 32px; height: 32px; }
.tool-btn svg { width: 18px; height: 18px; }

/* 검색바 */
.search-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--header-bg);
}
.search-bar #search-text { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px; }
.search-bar #search-date { padding: 6px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 13px; }
.search-count { font-size: 12px; color: var(--muted); min-width: 34px; text-align: center; }
.search-nav { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 13px; }

/* 책갈피 목록 */
.bookmark-list { display: flex; flex-direction: column; gap: 2px; }
.bm-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; }
.bm-item:hover { background: var(--bg-soft); }
.bm-main { flex: 1; min-width: 0; cursor: pointer; }
.bm-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; flex-shrink: 0; }
.bm-del:hover { color: #e0245e; }

/* 방 설정 모달 */
.field-label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
#room-title { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: 15px; }
.type-toggle { display: flex; gap: 8px; }
.type-toggle button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 14px; }
.type-toggle button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.type-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 목록 항목 액션(수정/삭제) — 우측 세로 가운데 정렬 */
.chat-item { position: relative; padding-right: 62px; }
.ci-actions { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; gap: 2px; }
.ci-actions button { background: none; border: none; cursor: pointer; font-size: 13px; color: var(--muted); padding: 6px; border-radius: 8px; }
.ci-actions .ci-edit:hover { color: var(--accent); background: var(--bg-soft); }
.ci-actions .ci-del { align-self: auto; margin-top: 0; }
.ci-actions .ci-del:hover { color: #e0245e; background: var(--bg-soft); }

/* ===== 입력 영역 ===== */

/* ===== 입력 영역 ===== */
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--header-bg);
}
.side-toggle { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.side-btn {
  border: none; background: var(--bg-soft); color: var(--muted);
  width: 34px; height: 38px; font-weight: 700; cursor: pointer; font-size: 14px;
}
.side-btn[data-side="A"].active { background: var(--bubble-a); color: var(--bubble-a-text); }
.side-btn[data-side="B"].active { background: var(--bubble-b); color: var(--bubble-b-text); }
/* 백업용 토글: 배경은 역할 색(인라인), 선택된 쪽만 진하게 (테두리 없음) */
.side-btn[data-who] { opacity: .4; transition: opacity .15s; }
.side-btn[data-who].active { opacity: 1; }
#msg-input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 20px;
  padding: 9px 14px; font-size: 15px; background: var(--bg); color: var(--text);
  max-height: 140px; line-height: 1.4; font-family: inherit;
}
#msg-input:focus { outline: none; border-color: var(--accent); }
.send-btn {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.send-btn:disabled { opacity: .4; cursor: default; }
.attach-btn {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.attach-btn svg { width: 24px; height: 24px; }

/* ===== 우측 메뉴 ===== */
.menu {
  position: absolute; top: 0; right: 0; bottom: 0; width: 300px; max-width: 86%;
  background: var(--panel); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .25s ease; z-index: 50;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.menu.open { transform: translateX(0); }
.menu-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.chat-list { flex: 1; overflow-y: auto; padding: 6px; }
.chat-item {
  padding: 12px 14px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.chat-item:hover { background: var(--bg-soft); }
.chat-item.active { background: var(--bg-soft); }
.chat-item .ci-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-del { align-self: flex-end; margin-top: -22px; color: var(--muted); font-size: 12px; background: none; border: none; cursor: pointer; }
.chat-item .ci-del:hover { color: #e0245e; }
.new-chat-btn {
  position: absolute; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.new-chat-btn svg { width: 26px; height: 26px; }

/* 새 채팅 종류 선택 서브메뉴 */
.new-chat-menu {
  position: absolute; right: 18px; bottom: 84px; z-index: 55;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; width: 220px;
}
.new-chat-menu button {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 13px 16px; background: none; border: none; cursor: pointer; color: var(--text);
  text-align: left; font-size: 15px;
}
.new-chat-menu button + button { border-top: 1px solid var(--border); }
.new-chat-menu button:hover { background: var(--bg-soft); }
.new-chat-menu button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--accent); flex-shrink: 0; }
.new-chat-menu button strong { font-weight: 600; }

/* 채팅 목록 종류 뱃지 */
.ci-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: middle; }
.ci-badge.chat { background: #e4ecfb; color: #3f66c9; }       /* 채팅 = 블루 */
.ci-badge.backup { background: #fbe6ef; color: #c14b81; }     /* 백업 = 로즈 */
body[data-theme="dark"] .ci-badge.chat { background: #28324f; color: #a2bef7; }
body[data-theme="dark"] .ci-badge.backup { background: #45293a; color: #f3b0cd; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }

/* ===== 프로필 선택 팝오버 ===== */
.popover {
  position: fixed; z-index: 60; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); width: 240px; padding: 8px; max-height: 60vh; overflow-y: auto;
}
.pop-title { font-size: 12px; color: var(--muted); padding: 4px 8px 8px; }
.pop-list { display: flex; flex-direction: column; gap: 2px; }
.pop-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.pop-item:hover { background: var(--bg-soft); }
.pop-item .avatar { width: 30px; height: 30px; }
.pop-manage { width: 100%; margin-top: 8px; padding: 9px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); border-radius: 10px; cursor: pointer; font-size: 14px; }

/* ===== 프로필 관리 모달 ===== */
.modal { max-width: 440px; max-height: 84vh; display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 17px; margin-bottom: 10px; }
.manager-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 2px; }
.manager-row { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; }
.manager-row .avatar { width: 40px; height: 40px; cursor: pointer; }
.manager-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); }
.manager-row .row-del { background: none; border: none; color: #e0245e; cursor: pointer; font-size: 13px; }
.manager-add { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.add-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.avatar-pick { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.avatar-pick .avatar { width: 44px; height: 44px; }
.pick-text { font-size: 14px; color: var(--accent); }
/* 프로필 관리 대표 지정 버튼 */
.rep-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; cursor: pointer; color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.rep-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ===== 헤더 모드 (타임라인/채팅) ===== */
/* 두 모드 높이 통일 */
.chat-header { min-height: 54px; box-sizing: border-box; }
.header-label { display: none; font-weight: 700; font-size: 16px; }
body.timeline-mode .header-label,
body.chatlist-mode .header-label { display: inline; }
body.timeline-mode .header-profiles, body.chatlist-mode .header-profiles,
body.timeline-mode .title-input, body.chatlist-mode .title-input { display: none; }
body.timeline-mode #download-btn { display: none; }
/* 채팅목록: 검색만 노출(책갈피/다운로드 숨김), 날짜/이전/다음도 숨김 */
body.chatlist-mode #bookmark-btn,
body.chatlist-mode #download-btn { display: none; }
body.chatlist-mode #search-date,
body.chatlist-mode #search-prev,
body.chatlist-mode #search-next { display: none; }
/* 사진첩 버튼은 채팅방에서만 */
body.timeline-mode #gallery-btn,
body.chatlist-mode #gallery-btn { display: none; }

/* ===== 사진첩(사진 모아보기) ===== */
.gallery-modal { max-width: 640px; width: 100%; }
.gallery-count { color: var(--muted); font-weight: 600; font-size: 14px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; flex: 1; min-height: 0; overflow-y: auto; }
.gallery-grid .g-cell { position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: var(--bg-soft); border: 1px solid var(--border); cursor: pointer; }
.gallery-grid .g-cell img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s ease; }
.gallery-grid .g-cell:hover img { transform: scale(1.05); }
.gallery-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 34px 10px; }

/* 사진첩 컨텍스트 메뉴 (모달 위에 떠야 하므로 z-index 상향) */
#gallery-menu { z-index: 130; }
#gallery-menu button[data-act="del"] { color: #e0245e; }

/* ===== 범위 캡처(PNG 저장) ===== */
.capture-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 66;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--panel);
  border-top: 1px solid var(--border); box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.capture-hint { flex: 1; font-size: 13px; color: var(--muted); line-height: 1.35; }
.capture-actions { display: flex; gap: 8px; flex-shrink: 0; }
.capture-actions button { width: auto; margin-top: 0; padding: 8px 16px; border-radius: 10px; font-size: 14px; }
.capture-actions .btn-primary:disabled { opacity: .5; cursor: default; }
/* 캡처 중에는 입력창 숨김 */
body.capture-active .composer { display: none; }
/* 범위 밖은 어둡게, 범위 안은 또렷하게 */
.messages.capturing > * { opacity: .26; transition: opacity .12s ease; }
.messages.capturing > .cap-in { opacity: 1; }
.messages.capturing .row,
.messages.capturing .date-sep { cursor: pointer; }
.post-detail.capturing .post,
.post-detail.capturing .comment,
.post-detail.capturing .detail-comments-title,
.post-detail.capturing .comment-add,
.post-detail.capturing .detail-back { opacity: .26; transition: opacity .12s ease; }
.post-detail.capturing .cap-in { opacity: 1; }
.post-detail.capturing .post,
.post-detail.capturing .comment { cursor: pointer; }
/* 저장될 구간을 감싸는 점선 박스 */
.capture-box {
  position: fixed; z-index: 64; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.capture-box-label {
  position: absolute; top: 4px; left: 6px;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 8px; white-space: nowrap;
}

/* ===== 확인(삭제) 모달 ===== */
.confirm-modal { max-width: 340px; }
.confirm-text { font-size: 15px; line-height: 1.5; margin: 6px 2px 18px; white-space: pre-line; }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions button { flex: 1; width: auto; margin-top: 0; }
.btn-danger {
  padding: 10px 12px; border: none; border-radius: 10px;
  background: #e0245e; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}

/* ===== 캘린더 ===== */
body.calendar-mode .header-label { display: inline; }
body.calendar-mode .header-profiles, body.calendar-mode .title-input { display: none; }
body.calendar-mode #search-btn, body.calendar-mode #bookmark-btn,
body.calendar-mode #download-btn, body.calendar-mode #gallery-btn { display: none; }

/* ===== 리스트(버킷/아이디어) ===== */
body.list-mode .header-label { display: inline; }
body.list-mode .header-profiles, body.list-mode .title-input { display: none; }
body.list-mode #bookmark-btn, body.list-mode #gallery-btn,
body.list-mode #download-btn, body.list-mode #sort-btn { display: none; }
body.list-mode #search-prev, body.list-mode #search-next, body.list-mode #search-count { display: none; }
.list-view { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px; gap: 10px; overflow: hidden; }
.list-tabs { display: flex; gap: 6px; }
.list-tabs button { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.list-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.list-add { display: flex; gap: 8px; }
.list-add input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 14px; }
.list-add-btn { flex-shrink: 0; width: 42px; border-radius: 10px; border: none; background: var(--accent); color: #fff; cursor: pointer; display: grid; place-items: center; }
.list-add-btn svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2.4; }
.list-items { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.list-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 10px; }
.li-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.li-row.done .li-text { text-decoration: line-through; color: var(--muted); }
.li-check { flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border); background: var(--bg-soft); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.li-check.on { background: var(--accent); border-color: var(--accent); }
.li-star { flex-shrink: 0; width: 24px; border: none; background: transparent; color: var(--muted); font-size: 17px; cursor: pointer; line-height: 1; }
.li-star.on { color: #f2b705; }
.li-text { flex: 1; min-width: 0; font-size: 14px; color: var(--text); word-break: break-word; }
.list-ava .avatar { width: 22px; height: 22px; font-size: 11px; flex-shrink: 0; }
.li-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.li-btn { border: 1px solid var(--border); background: var(--panel); color: var(--muted); border-radius: 8px; padding: 4px 7px; font-size: 12px; cursor: pointer; }
.li-btn:hover { background: var(--bg-soft); color: var(--text); }
.li-del:hover { color: var(--bubble-a); }

/* 인앱 토스트 */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; max-width: min(90vw, 420px); padding: 12px 18px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.28); opacity: 0; pointer-events: none; transition: opacity .25s; text-align: center; }
.toast.show { opacity: 1; }

.calendar-view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: 10px; }
.cal-body { flex: 1; min-height: 0; overflow-y: auto; }
/* 월간은 스크롤 없이 남은 높이에 꽉 차게 */
.cal-month { height: 100%; display: flex; flex-direction: column; }

/* 이벤트 색 */
.ev-a { background: var(--bubble-a); color: var(--bubble-a-text); }
.ev-b { background: var(--bubble-b); color: var(--bubble-b-text); }
.ev-both { background: color-mix(in srgb, var(--accent) 26%, var(--panel)); color: var(--text); }

/* 상단 고정 카드 (정사각형에 가깝게 여럿) */
.cal-pinned { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; flex-shrink: 0; }
.cal-pincard { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 66px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); cursor: pointer; }
.cal-pincard-top { display: flex; align-items: center; gap: 3px; }
.cal-pincard-num { font-weight: 800; font-size: 15px; }
.cal-pinheart svg { width: 13px; height: 13px; fill: currentColor; display: block; }
.cal-pincard-title { font-size: 10px; color: var(--muted); max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-pincard.ev-a { color: color-mix(in srgb, var(--bubble-a-text) 55%, var(--bubble-a)); border-color: color-mix(in srgb, var(--bubble-a-text) 28%, var(--border)); }
.cal-pincard.ev-b { color: color-mix(in srgb, var(--bubble-b-text) 55%, var(--bubble-b)); border-color: color-mix(in srgb, var(--bubble-b-text) 28%, var(--border)); }
.cal-pincard.ev-both { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }

/* 도구바 (2줄: 화살표·날짜 / 뷰토글·하트) */
.cal-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; flex-shrink: 0; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-navbtn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; font-size: 18px; line-height: 1; flex-shrink: 0; }
.cal-navbtn:hover, .cal-todaybtn:hover { background: var(--bg-soft); }
.cal-todaybtn { padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; font-size: 12px; flex-shrink: 0; }
.cal-label { flex: 1; text-align: center; font-weight: 700; font-size: 15px; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px 6px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-label:hover { background: var(--bg-soft); }
.cal-row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* 뷰 전환 */
.cal-views { display: flex; gap: 2px; background: var(--bg-soft); border-radius: 9px; padding: 2px; flex-shrink: 0; }
.cal-views button { padding: 5px 9px; border: none; background: transparent; color: var(--muted); border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; }
.cal-views button.active { background: var(--accent); color: #fff; }
/* 색 필터 하트 (테마 톤) */
.cal-filter { display: flex; gap: 2px; flex-shrink: 0; }
.cal-heart { width: 28px; height: 28px; border: none; background: none; cursor: pointer; display: grid; place-items: center; opacity: .3; filter: grayscale(.4); padding: 0; }
.cal-heart svg { width: 18px; height: 18px; fill: currentColor; display: block; }
.cal-heart.active { opacity: 1; filter: none; }
.cal-heart.heart-a { color: color-mix(in srgb, var(--bubble-a-text) 42%, var(--bubble-a)); }
.cal-heart.heart-b { color: color-mix(in srgb, var(--bubble-b-text) 42%, var(--bubble-b)); }
.cal-heart.heart-both { color: var(--accent); }

/* 월간: 날짜별 색 바 */
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.cal-dow .sun, .cal-daynum.sun { color: #e0507a; }
.cal-dow .sat, .cal-daynum.sat { color: #5a7bd0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(6, 1fr); gap: 2px; flex: 1; min-height: 0; }
.cal-cell { min-height: 0; border: 1px solid var(--border); border-radius: 8px; padding: 3px; background: var(--panel); cursor: pointer; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.cal-cell:hover { background: var(--bg-soft); }
.cal-cell.other { opacity: .38; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-daynum { font-size: 12px; font-weight: 600; }
/* 월간: 하트 수 표시 */
.cal-hearts { display: flex; flex-wrap: wrap; gap: 1px 2px; align-content: flex-start; overflow: hidden; }
.cal-h { font-size: 10px; line-height: 1; }
.cal-h.ev-a { color: color-mix(in srgb, var(--bubble-a-text) 45%, var(--bubble-a)); background: none; }
.cal-h.ev-b { color: color-mix(in srgb, var(--bubble-b-text) 45%, var(--bubble-b)); background: none; }
.cal-h.ev-both { color: var(--accent); background: none; }
.cal-hmore { font-size: 9px; color: var(--muted); align-self: center; }

/* 아젠다 목록 (일간 / 목록 모달 공용) */
.cal-agenda { display: flex; flex-direction: column; gap: 6px; padding-bottom: 60px; }
.cal-arow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 11px; border: 1px solid var(--border); border-left: 4px solid transparent; border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; }
.cal-arow:hover { background: var(--bg-soft); }
.cal-arow.ev-a { border-left-color: var(--bubble-a); }
.cal-arow.ev-b { border-left-color: var(--bubble-b); }
.cal-arow.ev-both { border-left-color: var(--accent); }
.cal-arow-time { font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; min-width: 62px; }
.cal-arow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cal-arow-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-arow-memo { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-agenda-empty { font-size: 13px; color: var(--muted); text-align: center; }

/* 목록 모달 */
.cal-list-modal { max-width: 400px; }
.cal-list-body { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.cal-list-body .cal-agenda-empty { padding: 20px; }
/* 날짜 피크 액션(＋일정추가 / 주간 / 일간) */
.cal-list-actions { display: flex; gap: 8px; margin-top: 12px; }
.cal-list-actions.hidden { display: none; }
.cal-list-actions button { flex: 1; padding: 9px 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.cal-list-actions button:hover { background: var(--bg-soft); }
.cal-list-actions button.cal-peek-add { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal-list-actions button.cal-peek-add:hover { filter: brightness(1.05); }

/* 시간표 (주간/일간) — 남은 높이 채우고 시간축만 스크롤 */
.tg { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; height: 100%; }
.tg-gutter-h { width: 36px; flex-shrink: 0; }
.tg-head { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-soft); flex-shrink: 0; }
.tg-col-h { flex: 1; min-width: 0; text-align: center; font-size: 11px; font-weight: 600; padding: 5px 2px; }
.tg-col-h small { display: block; color: var(--muted); font-weight: 400; }
.tg-col-h.today { color: var(--accent); }
.tg-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.tg-body::-webkit-scrollbar { display: none; }
.tg-inner { position: relative; }
.tg-hour { position: absolute; left: 0; width: 36px; text-align: center; font-size: 9px; color: var(--muted); transform: translateY(-5px); }
.tg-cols { margin-left: 36px; display: flex; height: 100%; }
.tg-col { flex: 1; min-width: 0; position: relative; border-left: 1px solid var(--border); }
.tg-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); opacity: .4; }
/* 종일: 하루 전체를 색칠 */
.tg-allev { position: absolute; top: 0; bottom: 0; opacity: .82; cursor: pointer; overflow: hidden; }
.tg-allev-n { position: absolute; top: 3px; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 600; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 시간 일정 (종일 위로) */
.tg-ev { position: absolute; left: 2px; right: 2px; z-index: 2; border-radius: 5px; padding: 1px 4px; font-size: 10px; line-height: 1.25; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.tg-ev-n { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-ev-memo { display: block; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-single .tg-ev { font-size: 12px; }
.tg-ev.tg-merged { background: color-mix(in srgb, var(--accent) 30%, var(--panel)); color: var(--text); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--panel)); font-weight: 600; }

/* 연간: 12개 카드가 스크롤 없이 4×3으로 꽉 차게 */
.cal-year { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr); gap: 8px; height: 100%; }
.cal-ycard { min-height: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; }
.cal-ycard:hover { background: var(--bg-soft); }
.cal-ycard.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.cal-ycard-m { font-size: 19px; font-weight: 800; }
.cal-ycard-counts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.cal-ycount { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.cal-ycard-empty { color: var(--muted); }

/* 월/연 빠른 이동 피커 */
.cal-picker { max-width: 320px; }
.cal-picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-picker-year { font-size: 18px; font-weight: 800; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.cal-picker-year:hover { background: var(--bg-soft); }
.cal-picker-grid { display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); }
.cal-pk-cell { padding: 12px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600; }
.cal-pk-cell:hover { background: var(--bg-soft); }
.cal-pk-cell.today { border-color: var(--accent); color: var(--accent); }

/* 삭제 확인 모달은 일정 모달 위로 */
#confirm-modal { z-index: 140; }

/* 일정 모달 (컴팩트: 라벨 인라인) */
.event-modal { max-width: 440px; max-height: 88vh; overflow-y: auto; }
.event-modal input[type="text"], .event-modal textarea,
.event-modal input[type="date"], .event-modal input[type="time"] {
  box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--panel); color: var(--text); font-size: 14px; font-family: inherit;
}
.event-modal textarea { width: 100%; }
.ev-field { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.ev-lab { font-size: 12px; color: var(--muted); flex-shrink: 0; width: 40px; }
.ev-lab2 { width: auto; margin-left: 4px; }
.ev-field #ev-title, .ev-field #ev-date, .ev-field #ev-enddate { flex: 1; min-width: 0; }
.ev-tilde { color: var(--muted); flex-shrink: 0; }
.ev-field #ev-time, .ev-field #ev-endtime { flex: 1; min-width: 0; }
.ev-inline-check { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; flex-shrink: 0; white-space: nowrap; }
.ev-inline-check input { width: 15px; height: 15px; }
/* 참여자 하트 */
.ev-parts { display: flex; gap: 5px; flex: 1; min-width: 0; }
.ev-part { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--muted); cursor: pointer; }
.ev-part svg { width: 17px; height: 17px; fill: currentColor; opacity: .55; }
.ev-part span { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.ev-part.heart-a { --hc: color-mix(in srgb, var(--bubble-a-text) 42%, var(--bubble-a)); }
.ev-part.heart-b { --hc: color-mix(in srgb, var(--bubble-b-text) 42%, var(--bubble-b)); }
.ev-part.heart-both { --hc: var(--accent); }
.ev-part.active { color: var(--hc); border-color: var(--hc); background: color-mix(in srgb, var(--hc) 10%, var(--panel)); }
.ev-part.active svg { opacity: 1; }
.ev-part.active span { color: var(--text); }
/* 기념일/상단고정 한 줄 */
.ev-checks { display: flex; gap: 18px; margin-top: 12px; }
.ev-lab-block { display: block; font-size: 12px; color: var(--muted); margin: 12px 2px 4px; }
.anniv-ic { width: 12px; height: 12px; fill: currentColor; vertical-align: -1px; }
.event-modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.event-modal-actions .btn-primary { flex: 1; margin-top: 0; width: auto; }
.event-modal-actions .btn-danger { width: auto; }
/* C2: 관련 추억(연결 포스트) + 피커 */
.ev-posts { display: flex; flex-direction: column; gap: 6px; }
.ev-posts-empty { font-size: 12px; color: var(--muted); padding: 8px 2px; }
.ev-post-row, .ev-pick-row { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); cursor: pointer; }
.ev-post-row:hover, .ev-pick-row:hover { background: var(--bg-soft); }
.ev-post-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-soft); }
.ev-post-thumb-none { display: inline-block; border: 1px dashed var(--border); }
.ev-post-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ev-post-line { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-post-date { font-size: 11px; color: var(--muted); }
.ev-post-del { flex-shrink: 0; border: none; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.ev-post-del:hover { background: var(--bg-soft); color: var(--text); }
.ev-addpost { margin-top: 8px; width: 100%; padding: 8px; border-radius: 10px; border: 1px dashed var(--border); background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.ev-addpost:hover { background: var(--bg-soft); color: var(--text); }
.ev-post-picker-modal { max-width: 420px; max-height: 84vh; display: flex; flex-direction: column; }
.ev-post-picker-body { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 62vh; }
.ev-pick-sec { font-size: 11px; color: var(--muted); font-weight: 700; margin: 8px 2px 2px; }
.ev-pick-row.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.ev-pick-check { flex-shrink: 0; width: 20px; text-align: center; color: var(--accent); font-weight: 800; }
.ev-post-picker-foot { margin-top: 12px; }
.ev-post-picker-foot .btn-primary { width: 100%; margin-top: 0; }
/* 체크박스/날짜·시간 입력 — 디자인 톤 */
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input[type="date"], input[type="time"] { accent-color: var(--accent); }

/* ===== 채팅 목록 (메인 화면) ===== */
.chatlist-view { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.room-list { display: flex; flex-direction: column; gap: 8px; max-width: 560px; margin: 0 auto; }
.room-empty { text-align: center; color: var(--muted); padding: 44px 20px; }
.room-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.room-item:hover { background: var(--bg-soft); }
.room-item.dragging { opacity: .75; box-shadow: var(--shadow); }
.room-avatars { display: flex; flex-shrink: 0; }
.room-avatars .avatar { width: 40px; height: 40px; border: 2px solid var(--panel); }
.room-avatars .avatar + .avatar { margin-left: -14px; }
.room-info { flex: 1; min-width: 0; }
.room-info .ci-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-info .ci-last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .ci-actions { position: static; transform: none; display: flex; align-items: center; gap: 2px; flex-shrink: 0; align-self: flex-start; }
.room-time { font-size: 11px; color: var(--muted); white-space: nowrap; margin-right: 4px; }
.room-item.pinned { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.room-item.pinned:hover { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.pin-badge { color: var(--accent); margin-right: 4px; font-size: 12px; }

/* 정렬 버튼 (채팅목록 전용) */
#sort-btn { display: none; }
body.chatlist-mode #sort-btn { display: grid; }

/* 뒤로가기 (채팅방에서만) */
#chat-back-btn { display: none; }
body:not(.timeline-mode):not(.chatlist-mode):not(.calendar-mode):not(.list-mode) #chat-back-btn { display: grid; }
.msg-menu button[data-sort].active { color: var(--accent); font-weight: 700; }

/* ===== 스크롤바 (테마에 맞춤) — 앱 전역 ===== */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }
*::-webkit-scrollbar-track { background: transparent; }
.chat-list, .messages, .timeline, .manager-list, .modal, .popover {
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.chat-list::-webkit-scrollbar, .messages::-webkit-scrollbar, .timeline::-webkit-scrollbar,
.manager-list::-webkit-scrollbar, .modal::-webkit-scrollbar, .popover::-webkit-scrollbar { width: 8px; height: 8px; }
.chat-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb, .timeline::-webkit-scrollbar-thumb,
.manager-list::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb, .popover::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}
.chat-list::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover, .timeline::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
.chat-list::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track, .timeline::-webkit-scrollbar-track { background: transparent; }
/* 텍스트 입력창(메시지/수정/포스트) 스크롤바 */
textarea { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
textarea::-webkit-scrollbar { width: 8px; }
textarea::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
textarea::-webkit-scrollbar-thumb:hover { background: var(--muted); }
textarea::-webkit-scrollbar-track { background: transparent; }

/* ===== 목록 드래그 정렬 ===== */
.chat-item.dragging { opacity: .75; background: var(--bg-soft); box-shadow: var(--shadow); cursor: grabbing; }

/* ===== 사이드바 메뉴 버튼 ===== */
.menu-rows { padding: 8px; display: flex; flex-direction: column; gap: 4px; border-bottom: 1px solid var(--border); }
.menu-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: none; border: none; color: var(--text); cursor: pointer; border-radius: 10px; font-size: 15px; }
.menu-row:hover { background: var(--bg-soft); }
.menu-row svg { width: 20px; height: 20px; fill: none; stroke: currentColor; }
.menu-sub { padding: 12px 16px 6px; font-size: 12px; color: var(--muted); font-weight: 700; }

/* ===== 타임라인 ===== */
.timeline { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.post-feed { display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto; }
.post-empty { text-align: center; color: var(--muted); padding: 44px 20px; }
.post { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.post-head .avatar { width: 40px; height: 40px; }
.p-meta { display: flex; flex-direction: column; min-width: 0; }
.p-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-date { font-size: 12px; color: var(--muted); }
.p-actions { margin-left: auto; display: flex; gap: 2px; flex-shrink: 0; }
.p-actions button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; font-size: 15px; }
.p-actions button:hover { background: var(--bg-soft); }
.p-actions button.on { color: var(--accent); }
.p-actions button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.p-actions .del:hover { color: #e0245e; }

/* 통일된 수정/삭제 아이콘 크기 (목록/프로필관리/댓글) */
.ci-actions button svg { width: 17px; height: 17px; }
.manager-row .row-del svg { width: 18px; height: 18px; }
.comment-actions button svg { width: 16px; height: 16px; }
.post-media img { width: 100%; display: block; max-height: 520px; object-fit: cover; cursor: pointer; }
.post-media.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.post-media.multi img { max-height: 260px; height: 100%; }
.post-text { padding: 10px 14px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.post-reactions { display: flex; gap: 6px; padding: 8px 12px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.react-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--bg-soft); border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 15px; color: var(--text); }
.react-btn .rc { font-size: 12px; color: var(--muted); }
.react-btn.mine { background: var(--accent); border-color: var(--accent); }
.react-btn.mine .rc { color: #fff; }
.post-comments { padding: 10px 12px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 8px; align-items: flex-start; }
.comment .avatar { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-name { font-weight: 600; font-size: 13px; }
.comment-name .c-date { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.comment-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.comment-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; flex-shrink: 0; }
.comment-del:hover { color: #e0245e; }
.comment-add { display: flex; gap: 6px; align-items: center; }
.comment-add input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text); font-size: 14px; }
.comment-add button { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 13px; flex-shrink: 0; }
.new-post-btn { position: absolute; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; border: none; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow); z-index: 20; }
.new-post-btn svg { width: 26px; height: 26px; }
.post.flash { animation: postflash 1.2s ease; }
@keyframes postflash { 0%,100% { box-shadow: none; } 30%,60% { box-shadow: 0 0 0 3px var(--accent); } }

/* ===== 포스트 작성 모달 ===== */
.post-author { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.post-author .avatar { width: 36px; height: 36px; }
.post-author-name { font-weight: 700; }
.post-author-hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.post-text-input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit; background: var(--bg); color: var(--text); resize: vertical; }
.post-media-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.compose-thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--bg-soft); flex-shrink: 0; }
.compose-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; padding: 0; }
.post-modal-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.post-modal-actions .btn-primary { margin-top: 0; width: auto; flex: 1; }
.btn-secondary { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 14px; white-space: nowrap; }

/* ===== 포스트 액션 바 (하트/댓글/책갈피/저장/수정/삭제) ===== */
.post-actions-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-top: 1px solid var(--border); }
.pa { display: inline-flex; align-items: center; gap: 5px; background: none; border: none; cursor: pointer; color: var(--muted); padding: 7px 8px; border-radius: 10px; font-size: 13px; }
.pa:hover { background: var(--bg-soft); }
.pa svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pa .cnt { font-size: 13px; min-width: 6px; }
.pa.right { margin-left: auto; }               /* 오른쪽 그룹 시작 */
.pa.heart.on { color: #e0245e; }
.pa.heart.on svg { fill: #e0245e; stroke: #e0245e; }
.pa.bm.on { color: var(--accent); }
.pa.bm.on svg { fill: var(--accent); stroke: var(--accent); }
.pa.del:hover { color: #e0245e; }

/* ===== 포스트 상세(메인) ===== */
.post-detail { max-width: 560px; margin: 0 auto; }
.detail-back { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--accent); cursor: pointer; font-size: 15px; font-weight: 600; padding: 4px 4px 10px; }
.detail-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.detail-comments-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 14px 4px 6px; }

/* 댓글 인라인 수정 */
.comment-edit { display: flex; gap: 6px; align-items: center; flex: 1; }
.comment-edit input { flex: 1; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--text); font-size: 14px; }
.comment-edit button { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 6px 10px; cursor: pointer; font-size: 12px; }
.comment-actions { display: flex; gap: 2px; flex-shrink: 0; }
.comment-actions button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.comment-actions button:hover { color: var(--accent); }
.comment-actions .c-del:hover { color: #e0245e; }

/* 다운로드 옵션 */
.dl-modal { max-width: 340px; }
.dl-choices { display: flex; gap: 8px; }
.dl-choices button { flex: 1; margin-top: 0; }

/* ===== 모바일: 카드 대신 전체 화면 ===== */
@media (max-width: 640px) {
  body { padding: 0; align-items: stretch; }
  .app { width: 100%; height: 100%; border: none; border-radius: 0; box-shadow: none; }
  .chat-header { padding-right: 50px; gap: 6px; }
  .slot-profile { padding: 2px; }
  .slot-profile .avatar { width: 28px; height: 28px; }
  .bubble { max-width: 82%; font-size: 15px; }
  .title-input { font-size: 14px; }
}
