/* =====================================================================
   글꼴: 네이버 나눔스퀘어 네오 (네이버 나눔글꼴 라이선스, fonts/LICENSE.txt)
   - 앱 안에 글꼴 파일을 넣어 두어 외부 사이트 없이 쓰고, 한 번 받으면 휴대폰에 저장돼요
   - 글꼴을 받는 동안에는 기본 글꼴로 먼저 보여 줘요(font-display: swap)
   ===================================================================== */
@font-face {
  font-family: 'NanumSquare Neo';
  src: url('../fonts/NanumSquareNeo-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'NanumSquare Neo';
  src: url('../fonts/NanumSquareNeo-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'NanumSquare Neo';
  src: url('../fonts/NanumSquareNeo-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* =====================================================================
   TalkFeed 디자인
   - 따뜻한 크림·주황 톤
   - 기본 글씨 18px (부모님도 읽기 쉽게)
   - 버튼 높이 최소 56px (손가락으로 누르기 쉽게)
   ===================================================================== */

:root {
  --bg: #fff8f1;
  --surface: #ffffff;
  --surface-soft: #fdf1e6;
  --primary: #c9581f;
  --primary-hover: #b04a16;
  --primary-soft: #fde4d4;
  --text: #3a2a20;
  --muted: #7a6558;
  --border: #eadfd4;
  --ok: #2e7d4f;
  --ok-soft: #e1f3e8;
  --warn: #a86200;
  --warn-soft: #fff1d6;
  --danger: #b3261e;
  --danger-soft: #fde7e5;

  /* 테마마다 바뀌는 색 (아래 [data-theme] 에서 덮어씀) */
  --bg-gradient: none;
  --accent-text: #b04a16;      /* 글자로 쓰는 강조색 (링크, 선택된 탭) */
  --accent-strong: #a3420f;    /* 연한 강조 배경 위의 글자 */
  --on-primary: #ffffff;       /* 주황(기본색) 버튼 위 글자 */
  --input-bg: #ffffff;
  --focus-ring: #f2a679;
  --secondary-hover: #fbd5bd;
  --bar-bg: rgba(255, 248, 241, 0.92);
  --bottom-bar-bg: rgba(255, 255, 255, 0.97);
  --bar-shadow: 0 -2px 10px rgba(90, 50, 20, 0.06);
  --toast-bg: rgba(58, 42, 32, 0.94);
  --highlight-border: #f2b48f;
  --highlight-bg: #fffaf6;
  --warn-border: #f2c66d;
  --bubble-mine: #ffd9b8;
  --bubble-mine-border: #f7c49b;
  --chip-bg: rgba(90, 50, 20, 0.08);
  --unread: #8a4a00;
  --like: #d0342c;
  --pill-shadow: 0 4px 14px rgba(150, 70, 20, 0.3);

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(90, 50, 20, 0.08);
  --tap: 56px;
  --max-width: 640px;

  --font: 'NanumSquare Neo', -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
}

/* =====================================================================
   배경 테마: 화이트 · 블랙 · 베이지(주황→노랑) · 블루(파랑→보라)
   <html data-theme="..."> 로 고르고, js/theme.js 가 휴대폰에 기억해요.
   ===================================================================== */
:root[data-theme='beige'] {
  --bg: #fff1dd;
  --bg-gradient: linear-gradient(165deg, #ffd6b3 0%, #ffe6b8 50%, #fff1bf 100%);
  --muted: #6b5446;
  --bar-bg: rgba(255, 246, 236, 0.9);
}

:root[data-theme='white'] {
  --bg: #f4f4f6;
  --surface: #ffffff;
  --surface-soft: #f1f1f3;
  --border: #e3e3e8;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --bar-bg: rgba(255, 255, 255, 0.92);
  --bar-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  --toast-bg: rgba(29, 29, 31, 0.94);
  --highlight-bg: #fff7f2;
  --bubble-mine: #ffe2cc;
  --chip-bg: rgba(0, 0, 0, 0.06);
}

:root[data-theme='black'] {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1d1d1f;
  --surface-soft: #2a2a2e;
  --border: #3a3a3f;
  --text: #f2f2f4;
  --muted: #a5a5ad;
  --primary: #c9581f;
  --primary-hover: #e06a2e;
  --primary-soft: #3b2417;
  --accent-text: #ff9a5c;
  --accent-strong: #ffb07f;
  --ok: #4cc38a;
  --ok-soft: #15301f;
  --warn: #ffb84d;
  --warn-soft: #3a2c12;
  --danger: #ff7a70;
  --danger-soft: #3d1a17;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  --input-bg: #26262a;
  --focus-ring: #ff9a5c;
  --secondary-hover: #4a2c1b;
  --bar-bg: rgba(24, 24, 26, 0.92);
  --bottom-bar-bg: rgba(29, 29, 31, 0.97);
  --bar-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
  --toast-bg: rgba(64, 64, 70, 0.96);
  --highlight-border: #6b3b1f;
  --highlight-bg: #2a1d15;
  --warn-border: #6b5420;
  --bubble-mine: #5a3219;
  --bubble-mine-border: #7a4524;
  --chip-bg: rgba(255, 255, 255, 0.1);
  --unread: #ffb84d;
  --like: #ff6b6b;
  --pill-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

:root[data-theme='blue'] {
  --bg: #e6e4ff;
  --bg-gradient: linear-gradient(165deg, #cfdcff 0%, #dcd8ff 50%, #ead6ff 100%);
  --surface: #ffffff;
  --surface-soft: #eef1ff;
  --border: #d9dcf2;
  --text: #23233a;
  --muted: #555878;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #e0e7ff;
  --accent-text: #4338ca;
  --accent-strong: #3730a3;
  --shadow: 0 2px 10px rgba(40, 40, 120, 0.08);
  --focus-ring: #a5b4fc;
  --secondary-hover: #c7d2fe;
  --bar-bg: rgba(243, 244, 255, 0.9);
  --bar-shadow: 0 -2px 10px rgba(40, 40, 120, 0.06);
  --toast-bg: rgba(35, 35, 58, 0.94);
  --highlight-border: #a5b4fc;
  --highlight-bg: #f5f7ff;
  --bubble-mine: #dde3ff;
  --bubble-mine-border: #c3cdfb;
  --chip-bg: rgba(40, 40, 120, 0.08);
  --unread: #6d28d9;
  --pill-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

/* 그라데이션 배경은 화면에 고정 (스크롤해도 그대로) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-gradient);
  pointer-events: none;
}

* { box-sizing: border-box; }

/* hidden 속성이 붙은 요소는 항상 숨김 (버튼 등의 display 설정보다 우선) */
[hidden] { display: none !important; }

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; display: block; }

h1, h2, h3 { line-height: 1.35; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8em; }

a { color: var(--accent-text); }

/* ---------- 화면 틀 ---------- */
.page {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 24px;
}
.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  flex: none;
}
.brand-name { font-size: 1.6rem; font-weight: 800; margin: 0; }
.brand-sub { color: var(--muted); margin: 0; font-size: 0.95rem; }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn:focus-visible,
.input:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn-block { display: flex; width: 100%; }
.btn-secondary { background: var(--primary-soft); color: var(--accent-strong); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); }

/* ---------- 입력칸 ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-weight: 700; margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem; /* 16px 이상이어야 아이폰에서 화면이 확대되지 않음 */
}
.input:focus { border-color: var(--primary); }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }

/* ---------- 점검 목록 (1단계 연결 확인 화면) ---------- */
.checklist { list-style: none; margin: 0; padding: 0; }
.check {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.check:first-child { border-top: 0; padding-top: 0; }
.check-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  font-weight: 800;
  background: var(--surface-soft);
  color: var(--muted);
}
.check.ok .check-icon { background: var(--ok-soft); color: var(--ok); }
.check.fail .check-icon { background: var(--danger-soft); color: var(--danger); }
.check.warn .check-icon { background: var(--warn-soft); color: var(--warn); }
.check-title { font-weight: 700; margin: 0; }
.check-detail { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; }
.check.fail .check-detail { color: var(--danger); }

.banner {
  border-radius: var(--radius);
  padding: 18px 20px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 16px;
}
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.fail { background: var(--danger-soft); color: var(--danger); }
.banner.wait { background: var(--surface-soft); color: var(--muted); }

/* ---------- 위쪽 막대 ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bar-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 64px;
  padding: 0 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}
.appbar-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-side { display: flex; align-items: center; min-width: 0; }
.appbar-right { justify-content: flex-end; }

.btn-small {
  min-height: 48px;
  padding: 8px 12px;
  font-size: 1rem;
}

/* ---------- 비밀번호 칸 + 보기 버튼 ---------- */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 92px; }
.pw-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  bottom: 4px;
  min-width: 76px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- 폼 안내/오류 상자 ---------- */
.form-msg {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}
.form-msg.error { background: var(--danger-soft); color: var(--danger); }
.form-msg.success { background: var(--ok-soft); color: var(--ok); }
.form-msg.info { background: var(--surface-soft); color: var(--muted); }

.nick-status { margin: 6px 0 0; font-weight: 700; font-size: 0.95rem; min-height: 0; }
.nick-status:empty { display: none; }
.nick-status.good { color: var(--ok); }
.nick-status.bad { color: var(--danger); }

.link-strong { font-weight: 700; display: inline-block; padding: 10px 4px; }

.spinner-sm { width: 18px; height: 18px; border-width: 3px; }

/* ---------- 프로필 동그라미 ---------- */
.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
}
.avatar-sm { width: 32px; height: 32px; font-size: 0.9rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }

.welcome { display: flex; align-items: center; gap: 16px; }
.welcome-hello { font-size: 1.25rem; font-weight: 800; margin: 0; }
.big-emoji { font-size: 3rem; line-height: 1; }

/* ---------- 로딩 ---------- */
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.splash {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

/* ---------- 알림 토스트 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  text-align: center;
  background: var(--toast-bg);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  z-index: 1000;
}

.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .btn:active { transform: none; }
}

/* ---------- 3단계: 홈 · 초대 · 그룹 ---------- */
.section-title {
  font-size: 1.15rem;
  margin: 8px 4px 12px;
}

.invite-card {
  border: 2px solid var(--highlight-border);
  background: var(--highlight-bg);
}
.invite-from { color: var(--muted); margin: 0 0 4px; font-size: 0.95rem; }
.invite-group { font-size: 1.35rem; font-weight: 800; margin: 0 0 6px; }

.btn-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

.group-list { list-style: none; margin: 0 0 16px; padding: 0; }
.group-list li + li { margin-top: 12px; }
.group-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 84px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
}
.group-item:active { background: var(--surface-soft); }
.group-icon {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
}
.group-text { flex: 1; min-width: 0; }
.group-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chevron { color: var(--muted); font-size: 2rem; line-height: 1; }

.empty { text-align: center; padding: 8px 0 4px; }
.empty .big-emoji { margin-bottom: 8px; }
.empty-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 6px; }

.my-nick {
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 12px 0 16px;
  text-align: center;
}
.my-nick-value { font-size: 1.5rem; font-weight: 800; color: var(--accent-strong); margin: 4px 0 0; }

/* 아래쪽 탭 (소식 · 채팅 · 가족) */
.page-with-tabs { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--bottom-bar-bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: var(--bar-shadow);
}
.tabbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 68px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  position: relative;
}
.tab-icon { font-size: 1.5rem; line-height: 1.1; filter: grayscale(0.6); opacity: 0.75; }
.tab.active { color: var(--accent-text); }
.tab.active .tab-icon { filter: none; opacity: 1; }
.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
}

/* 사람 목록 */
.people { list-style: none; margin: 0; padding: 0; }
.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.person:first-child { border-top: 0; padding-top: 0; }
.person:last-child { padding-bottom: 0; }
.person-text { flex: 1; min-width: 0; }
.person-name { margin: 0; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}
.badge-owner { background: var(--primary-soft); color: var(--accent-strong); }

.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }

/* 아래쪽 탭이 있는 화면에서는 알림 문구를 탭 위로 */
body:has(.tabbar) .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }

/* ---------- 4단계: 소식(피드) ---------- */
.textarea { min-height: 0; resize: vertical; line-height: 1.6; display: block; }

.compose-prompt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--muted);
}
.compose-fake-input {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 1rem;
  line-height: 48px;
  display: block;
}
.compose-photo { font-size: 1.6rem; }

.new-pill {
  position: sticky;
  top: calc(72px + env(safe-area-inset-top));
  z-index: 40;
  display: block;
  margin: 0 auto 12px;
  padding: 12px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font: inherit;
  font-weight: 700;
  box-shadow: var(--pill-shadow);
  cursor: pointer;
}
.new-pill[hidden] { display: none; }

.post { padding: 18px 16px 8px; }
.post-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.post-meta { flex: 1; min-width: 0; }
.post-author { margin: 0; font-weight: 800; }
.post-time { margin: 0; color: var(--muted); font-size: 0.9rem; }
.more-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.more-btn:hover, .more-btn[aria-expanded='true'] { background: var(--surface-soft); }
.owner-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.owner-menu[hidden] { display: none; }
.owner-menu .btn { font-size: 1rem; padding: 10px; }

.post-text { white-space: pre-wrap; font-size: 1.05rem; margin: 0 0 12px; }
.post-text.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.read-more { display: inline-block; font-weight: 700; margin: -6px 0 12px; padding: 6px 0; }

/* 사진 묶음 */
.photos {
  display: grid;
  gap: 4px;
  margin: 0 -16px 8px;
  overflow: hidden;
}
.photos-1 { grid-template-columns: 1fr; }
.photos-2, .photos-3, .photos-4 { grid-template-columns: 1fr 1fr; }
.photos-3 .photo:first-child { grid-column: 1 / -1; }
.photo {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: var(--surface-soft);
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}
.photos-1 .photo { aspect-ratio: auto; max-height: 75vh; }
.photos-3 .photo:first-child { aspect-ratio: 16 / 9; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photos-1 .photo img { height: auto; max-height: 75vh; object-fit: contain; margin: 0 auto; }
.photo-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
}
.photo-missing {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 120px;
  color: var(--muted);
  font-size: 0.9rem;
}
.photos-stacked { grid-template-columns: 1fr; gap: 8px; }
.photos-stacked .photo { aspect-ratio: auto; }
.photos-stacked .photo img { height: auto; object-fit: contain; }

.post-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
  margin: 4px -16px 0;
}
.post-actions:has(> :only-child) { grid-template-columns: 1fr; }
.action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.action:hover { background: var(--surface-soft); }
.action.liked { color: var(--like); }
.like-icon { font-size: 1.3rem; }
.likers { margin: 0; padding: 0 0 10px; color: var(--muted); font-size: 0.95rem; }
.likers:empty { display: none; }

/* 댓글 */
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.comment:first-child { border-top: 0; padding-top: 4px; }
.comment-body { flex: 1; min-width: 0; }
.comment-meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.comment-meta strong { color: var(--text); font-size: 1rem; }
.comment-text { margin: 2px 0 0; white-space: pre-wrap; }
.comment-tools { display: flex; gap: 4px; margin-top: 4px; }
.comment-body .textarea { margin-top: 6px; }
.link-btn {
  min-height: 40px;
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.link-btn:hover { background: var(--surface-soft); }
.link-btn.danger { color: var(--danger); }

/* 아래쪽 고정 입력칸 (댓글, 채팅) */
.page-with-composer { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: var(--bottom-bar-bg);
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  box-shadow: var(--bar-shadow);
}
.composer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer-input { flex: 1; resize: none; max-height: 160px; min-height: 52px; padding: 12px 14px; }
.composer-send { flex: none; min-width: 76px; min-height: 52px; padding: 10px 16px; }
body:has(.composer) .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* 글쓰기: 사진 미리보기 */
.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: var(--surface-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

/* 사진 크게 보기 */
.no-scroll { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 6, 4, 0.94);
  display: grid;
  place-items: center;
  padding: calc(64px + env(safe-area-inset-top)) 8px calc(24px + env(safe-area-inset-bottom));
}
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 10px;
  min-height: 48px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.lb-counter {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top));
  left: 16px;
  color: #fff;
  font-weight: 700;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lb-nav[hidden] { display: none; }

/* 아주 작은 휴대폰(폭 360px 이하): 글쓰기 칸을 넓게 */
@media (max-width: 360px) {
  .compose-photo { display: none; }
  .compose-fake-input { padding: 0 12px; }
}

/* ---------- 5단계: 채팅 ---------- */
/* 키보드 높이(--kb)만큼 아래쪽 입력칸을 올림 */
.composer { bottom: var(--kb, 0px); }

.page-chat { padding-top: 12px; padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
.chat-composer { bottom: calc(68px + env(safe-area-inset-bottom) + var(--kb, 0px)); box-shadow: none; }
/* 글자를 입력하는 동안에는 아래쪽 탭을 숨기고 입력칸을 맨 아래로 */
body.typing .tabbar { display: none; }
body.typing .chat-composer { bottom: var(--kb, 0px); }
body.typing .page-chat { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

.composer-photo {
  flex: none;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 1.5rem;
  cursor: pointer;
}

.chat-list { display: flex; flex-direction: column; gap: 6px; }
.chat-empty { margin-top: 8px; }
.chat-day { text-align: center; margin: 14px 0 8px; }
.chat-day span {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.chat-row { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; }
.chat-row.theirs:not(.continued) { margin-top: 8px; }
.chat-row.mine { justify-content: flex-end; }
.chat-avatar-space { width: 32px; flex: none; }
.chat-col { min-width: 0; max-width: 88%; display: flex; flex-direction: column; }
.chat-row.mine .chat-col { align-items: flex-end; }
.chat-name { margin: 0 0 4px; font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.chat-line { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.chat-row.mine .chat-line { flex-direction: row-reverse; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.5;
  min-width: 0;
}
.chat-row.theirs .chat-bubble { border-top-left-radius: 6px; }
.chat-row.mine .chat-bubble {
  background: var(--bubble-mine);
  border-color: var(--bubble-mine-border);
  border-top-right-radius: 6px;
}
.chat-row.continued .chat-bubble { border-radius: 18px; }

.chat-photo {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface-soft);
  cursor: zoom-in;
  max-width: 240px;
}
.chat-photo img { display: block; max-width: 100%; max-height: 320px; object-fit: cover; }
.chat-photo .photo-missing { display: block; padding: 24px 16px; min-height: 0; }
.chat-photo.pending img { opacity: 0.6; }

.chat-meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--muted);
  padding-bottom: 2px;
}
.chat-row.mine .chat-meta { align-items: flex-end; }
.chat-unread { color: var(--unread); font-weight: 800; font-size: 0.85rem; }
.chat-unread:empty { display: none; }
.chat-status { color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.chat-failed { color: var(--danger); font-weight: 700; }
.chat-row.pending .chat-bubble { opacity: 0.7; }

.chat-new-pill {
  position: fixed;
  top: auto;
  bottom: calc(150px + env(safe-area-inset-bottom) + var(--kb, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
}

/* 탭의 안 읽은 수 표시 */
.tab-badge, .unread-badge {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.5;
  text-align: center;
}
.tab-badge { position: absolute; top: 6px; left: calc(50% + 8px); }
.unread-badge { flex: none; font-size: 0.95rem; padding: 4px 10px; }

/* ---------- 6단계: 설치 안내 · 사용 방법 ---------- */
img.brand-logo { object-fit: cover; }

.notice {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  border: 2px solid var(--border);
  background: var(--surface);
}
.notice p { margin: 0 0 12px; }
.notice-title { font-weight: 800; font-size: 1.1rem; }
.notice-warn { border-color: var(--warn-border); background: var(--warn-soft); }
.notice-install { border-color: var(--highlight-border); background: var(--highlight-bg); }

.help h2 { margin-bottom: 12px; }
.help h3 { margin: 18px 0 8px; font-size: 1.05rem; color: var(--accent-strong); }
.help h3:first-of-type { margin-top: 8px; }
.steps { margin: 0 0 8px; padding-left: 1.4em; }
.steps li { margin-bottom: 8px; padding-left: 4px; }
.bullets { margin: 0; padding-left: 1.2em; }
.bullets li { margin-bottom: 10px; }

.share-hint { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--border); }
.share-hint p { margin-bottom: 10px; }

/* ---------- 배경 테마 고르기 ---------- */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.theme-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap);
}
.theme-option.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.theme-swatch {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  background: var(--swatch-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 8px;
}
.theme-swatch-card {
  width: 62%;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.theme-dark .theme-swatch-card { background: #1d1d1f; box-shadow: none; border: 1px solid #3a3a3f; }
.theme-swatch-line { height: 6px; width: 80%; border-radius: 3px; background: rgba(0, 0, 0, 0.15); }
.theme-dark .theme-swatch-line { background: rgba(255, 255, 255, 0.3); }
.theme-swatch-btn { height: 10px; width: 50%; border-radius: 4px; background: var(--swatch-accent); }
.theme-name { font-weight: 800; font-size: 1.05rem; }
.theme-desc { color: var(--muted); font-size: 0.85rem; }
.theme-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 800;
}
.theme-option.selected .theme-check { display: grid; }
