:root {
  --stage-bg: #e7e4dc;
  --app-bg: #ffffff;
  --chat-bg: #efece6;
  --surface-soft: #f7f5f0;
  --border: #ebe7de;
  --text: #191f28;
  --text-muted: #6b7684;
  --primary: #2f6b57;
  --primary-soft: #e6f2ed;
  --accent: #d97736;
  --danger: #d14343;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--text);
  background: var(--stage-bg);
  overflow: hidden;
}

.stage {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.phone-frame {
  position: relative;
  width: 100%;
  max-width: 412px;
  height: min(844px, 100%);
  background: var(--app-bg);
  border-radius: 32px;
  box-shadow: 0 24px 60px rgba(25, 31, 40, 0.18), 0 0 0 8px #1f2428;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 640px) {
  .stage { padding: 0; background: var(--app-bg); }
  .phone-frame { max-width: 100%; height: 100dvh; border-radius: 0; box-shadow: none; }
}

/* 로그인 & 온보딩 */
.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px;
  background: linear-gradient(180deg, #f3f8f5 0%, #ffffff 55%);
  overflow-y: auto;
}

.auth-screen[hidden], .main-shell[hidden], .auth-card[hidden] { display: none; }

.auth-hero { text-align: center; margin-bottom: 20px; }
.auth-logo {
  width: 60px; height: 60px; border-radius: 20px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center; font-size: 30px; margin: 0 auto 10px;
}
.auth-hero h1 { margin: 0; font-size: 20px; font-weight: 800; }
.auth-hero p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }

.auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(25, 31, 40, 0.06);
}

.auth-divider {
  text-align: center;
  margin: 12px 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* 메인 앱 */
.main-shell { display: flex; flex-direction: column; height: 100%; }

.app-bar {
  height: 56px; padding: 0 14px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.app-bar-left { display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 0; text-align: left; cursor: pointer; }
.room-avatar { width: 34px; height: 34px; border-radius: 12px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 17px; }
.room-name { font-size: 15px; font-weight: 800; }
.room-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--primary); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #2bb673; }
.app-bar-right { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border: none; background: transparent; border-radius: 50%; font-size: 16px; cursor: pointer; }

.screen-body { flex: 1; min-height: 0; display: flex; position: relative; }
.screen { display: none; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.screen.active { display: flex; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; background: var(--chat-bg); display: flex; flex-direction: column; gap: 10px; }
.msg-wrap { display: flex; flex-direction: column; align-items: flex-start; max-width: 85%; }
.msg-wrap.mine { align-self: flex-end; align-items: flex-end; }
.msg-sender { font-size: 11px; font-weight: 700; color: #56606d; margin-bottom: 2px; }
.msg-bubble { padding: 9px 12px; border-radius: 4px 15px 15px 15px; background: #fff; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.msg-wrap.mine .msg-bubble { border-radius: 15px 4px 15px 15px; background: var(--primary); color: #fff; }
.msg-wrap.ai-row .msg-bubble { background: #f3faf6; border: 1px solid #cce2d8; }
.msg-wrap.whisper-row .msg-bubble { background: #fff5ec; border: 1px solid #f2c49e; color: var(--text); }
.msg-time { font-size: 10px; color: #7c8591; margin-top: 2px; }

.chat-composer { background: #fff; border-top: 1px solid var(--border); padding: 7px 10px 9px; flex-shrink: 0; }
.vis-pills { display: flex; gap: 5px; margin-bottom: 6px; }
.vis-pill { border: none; background: var(--surface-soft); color: var(--text-muted); border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; cursor: pointer; }
.vis-pill.active { background: var(--primary); color: #fff; }
.input-capsule { display: flex; align-items: flex-end; gap: 6px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 22px; padding: 5px 6px 5px 7px; }
.attach-btn { width: 30px; height: 30px; border-radius: 50%; border: none; background: #fff; font-size: 17px; cursor: pointer; }
.input-capsule textarea { flex: 1; border: none; background: transparent; font-family: inherit; font-size: 13.5px; resize: none; outline: none; padding: 5px 0; }
.send-circle { width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }

.screen-header { padding: 14px 16px 10px; display: flex; align-items: center; justify-content: space-between; }
.screen-header h2 { margin: 0; font-size: 18px; font-weight: 800; }
.screen-header .sub { margin: 2px 0 0; font-size: 11.5px; color: var(--text-muted); }
.screen-scroll { flex: 1; overflow-y: auto; padding: 0 14px 18px; }
.chip-action { border: none; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.chip-action[hidden] { display: none; }

.mobile-privacy-bar { background: #eaf4ef; border-top: 1px solid #d5e6de; border-bottom: 1px solid #d5e6de; color: #214d3e; padding: 7px 14px; font-size: 11px; font-weight: 600; }
.mobile-section { margin-bottom: 16px; }
.mobile-section h3 { margin: 0 0 8px; font-size: 14px; }

.prayer-list, .member-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.family-prayer-card, .notice-card, .member-item, .urgent-prayer-item {
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 14px; padding: 11px 12px; font-size: 12.5px;
}
.family-prayer-card.mine-highlight { background: #eef7f3; border-color: var(--primary); }
.urgent-prayer-item { border-left: 4px solid var(--danger); background: #fff9f9; margin-bottom: 8px; }

.bottom-nav { height: 60px; background: #fff; border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; flex-shrink: 0; }
.nav-item { flex: 1; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #8b95a1; cursor: pointer; }
.nav-item[hidden] { display: none; }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 18px; }
.nav-label { font-size: 10.5px; font-weight: 700; }

.app-btn { border: none; border-radius: 12px; padding: 10px 14px; font-size: 13px; font-weight: 700; cursor: pointer; }
.app-btn.primary { background: var(--primary); color: #fff; }
.app-btn.soft { background: var(--primary-soft); color: var(--primary); }
.sm-btn { border: none; border-radius: 9px; padding: 6px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.sm-btn.primary { background: var(--primary); color: #fff; }
.voice-mic-btn { border: 1.5px solid var(--primary); background: var(--primary-soft); color: var(--primary); border-radius: 12px; padding: 10px; font-size: 13px; font-weight: 800; cursor: pointer; }

.field-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; margin-bottom: 10px; }
.field-label input, .field-label textarea, .field-label select, .bulk-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font-family: inherit; font-size: 13px; background: var(--surface-soft);
}
.hub-inline-row { display: flex; gap: 6px; }
.muted { color: var(--text-muted); }
.tiny { font-size: 11.5px; }

.sheet-backdrop { position: absolute; inset: 0; background: rgba(25,31,40,0.45); display: flex; align-items: flex-end; z-index: 50; }
.sheet-backdrop[hidden] { display: none; }
.bottom-sheet { width: 100%; background: #fff; border-radius: 22px 22px 0 0; padding: 10px 18px 22px; }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: #d8dce0; margin: 0 auto 12px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-header h3 { margin: 0; font-size: 15.5px; }

.toast { position: absolute; bottom: 72px; left: 50%; transform: translateX(-50%); background: rgba(25,31,40,0.92); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; z-index: 80; }
.toast[hidden] { display: none; }

/* 카톡 인앱 브라우저 탈출 & PWA 설치 배너 */
.install-banner {
  background: #22463a;
  color: #ffffff;
  padding: 9px 12px;
  font-size: 11.5px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 60;
}

.install-banner.pwa {
  background: #eaf4ef;
  color: #1f4d3d;
  border-bottom: 1px solid #cce2d8;
}

.install-banner[hidden] { display: none; }

.banner-btn {
  border: none;
  background: var(--primary);
  color: #ffffff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.install-banner:not(.pwa) .banner-btn {
  background: #ffffff;
  color: #22463a;
}

.banner-close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
}
