/* ============================================================
   명상코칭 카피챗 · styles.css
   Stage 1: 기본 골격 + 화면 0(로그인) + 화면 1(인트로)
   테마: 밝은 베이지 (카피바라 캐릭터 톤과 조화)
   ============================================================ */


/* ============================================================
   1. CSS Variables — 베이지 팔레트
   ============================================================ */
:root {
  /* 색상 */
  --bg:        #FBF4E6;          /* 아이보리 크림 — 전체 배경 */
  --bg2:       #EAD5B5;          /* 웜 샌드 베이지 — 카드 보조 */
  --accent:    #B8956A;          /* 파스텔 모카 — 주조색 */
  --accent-2:  #D9C3A2;          /* 옅은 베이지 — 보조 강조 */
  --peach:     #F3E7D3;          /* 크림 */
  --gold:      #D9C3A2;          /* 베이지 — 버튼 그라데이션 끝 */
  --text:      #4A3A2A;          /* 코코아 — 본문 */
  --text-soft: #6A5A48;          /* 살짝 옅은 본문 */
  --muted:     #8A7A66;          /* 회갈색 — 부제·캡션 */
  --card:      rgba(255, 255, 255, 0.65);   /* 반투명 화이트 카드 */
  --card-strong: rgba(255, 255, 255, 0.80); /* 진한 화이트 카드 */
  --border:    rgba(138, 111, 79, 0.20);    /* 따뜻한 회갈색 보더 */

  /* 배경 이미지 투명도 (사용자 지정 65%) */
  --bg-opacity: 0.72;

  /* 폰트 — 고운돋움(Gowun Dodum)을 기본으로, 기존 폰트는 폴백으로 유지 */
  --font-sans:  'Gowun Dodum', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif;
  --font-serif: 'Gowun Dodum', 'Noto Serif KR', 'Nanum Myeongjo', serif;
}


/* ============================================================
   2. Reset / Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
}

button,
input {
  font-family: inherit;
  color: inherit;
}


/* ============================================================
   3. App Container (max-width 430px · 모바일 컨테이너)
   ============================================================ */
.app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  margin: 0 auto;
  box-shadow: 0 0 0 1px rgba(138, 111, 79, 0.06);
}


/* ============================================================
   4. Screen System (한 번에 하나만 표시 · 단순 display 토글)
   ============================================================ */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

.screen.active {
  display: block;
}

/* 화면 배경 이미지 레이어 (투명도 0.65) */
.screen-bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: var(--bg-opacity);
  z-index: 0;
  pointer-events: none;
}

/* 화면 1(인트로) 전용 — 사진 대신 파스텔 브라운~베이지 그라데이션 */
.intro-gradient-bg {
  background-image: linear-gradient(160deg, #FBF4E6 0%, #F3E7D3 45%, #EAD5B5 100%);
  opacity: 1;
}

/* 본문 컨테이너 — 배경 위에 z-index 1로 */
.screen-content {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 24px 32px;
}


/* ============================================================
   5. Header (마스코트 영역)
   ============================================================ */
.header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 0;
}

/* 인트로처럼 배경 위에 떠있는 헤더 */
.header-floating {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
}

.mascot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 14px rgba(138, 111, 79, 0.18);
  display: block;
}


/* ============================================================
   6. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 14px;
  padding: 13px 22px;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  text-align: center;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #C9A97F 0%, #B8956A 100%);
  color: #ffffff;
  font-weight: 500;
  border: none;
  box-shadow: 0 8px 20px rgba(184, 149, 106, 0.30);
  text-shadow: 0 1px 2px rgba(90, 69, 48, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(232, 184, 157, 0.40);
}

.btn-large {
  font-size: 16px;
  font-weight: 500;
  padding: 13px 24px;
  border-radius: 16px;
  letter-spacing: -0.2px;
}


/* ============================================================
   7. 화면 0 · 로그인
   ------------------------------------------------------------
   배치(화면 4등분):
     [위 3/4]  소개 박스 (상단 정렬 — 위치 변경 없음)
     [아래 1/4] 제목 → 비밀번호 입력 → 로그인 버튼 (영역 시작점 정렬)
   ============================================================ */
.login-content {
  display: grid;
  grid-template-rows: auto 3fr 1fr;  /* 마스코트(auto) + 3:1 — 하단 그룹을 1/4 시작점으로 */
  padding: 8px 24px 8px;
  text-align: left;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 상단 작은 카피바라 마스코트 원형 아이콘 */
.login-mascot-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  margin: 4px auto 12px;
  border: 3px solid var(--accent-2);
  box-shadow: 0 8px 22px rgba(138, 111, 79, 0.20);
  background: var(--bg2);
  flex-shrink: 0;
}

.login-mascot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 소개 문구 (상단 2/3 영역의 시작에 정렬) */
.login-intro {
  align-self: start;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  letter-spacing: -0.1px;
  margin: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(138, 111, 79, 0.10);
}

/* 하단 1/3 영역 그룹 — 영역 시작점에 붙음 */
.login-bottom {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

/* 제목 — 흰색 글로우 그라데이션 */
.login-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 26px;
  text-align: center;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.5px;
  text-shadow:
    0 0 4px  rgba(255, 255, 255, 0.95),
    0 0 10px rgba(255, 255, 255, 0.75),
    0 0 20px rgba(255, 255, 255, 0.55),
    0 0 32px rgba(255, 255, 255, 0.35),
    0 0 48px rgba(255, 255, 255, 0.20);
}

/* 비밀번호 + 로그인 버튼 */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

/* ID + 비밀번호 두 칸 좌우 배치 */
.login-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.login-input {
  width: 100%;
  min-width: 0;                  /* grid 안에서 input 줄어들 수 있게 */
  padding: 15px 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

/* ID 입력란은 letter-spacing으로 5글자 안에 ‘예시’ 안내가 자연스럽게 보이도록 */
#login-id {
  letter-spacing: 0.5px;
}

.login-input::placeholder {
  color: var(--muted);
  font-weight: 300;
}

.login-input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.login-error {
  color: #c44d3a;
  font-size: 13px;
  margin: 4px 0 0;
  text-align: center;
  font-weight: 400;
}

/* 관리자 페이지 링크 — 눈에 띄지 않게 아주 작게 */
.admin-link {
  display: block;
  margin: 10px auto 0;
  width: fit-content;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.5;
  text-decoration: none;
  letter-spacing: 0.2px;
}

.admin-link:hover,
.admin-link:focus {
  opacity: 0.9;
}


/* ============================================================
   8. 화면 1 · 인트로
   ------------------------------------------------------------
   동의서 추가로 콘텐츠가 늘어남 → flex column + auto spacer로
   화면 안에 모두 들어오도록 재구성. 매우 작은 화면에선 자연 스크롤.
   ============================================================ */

/* 상단 바 — 작은 원형 마스코트(관리자 진입) + 제목/부제 + 주차 배지 */
.intro-topbar {
  position: absolute;
  z-index: 2;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
}

.intro-mascot-btn {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
}

.intro-mascot-icon {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 14px rgba(138, 111, 79, 0.18);
}

.intro-mascot-btn:active .intro-mascot-icon {
  transform: scale(0.93);
}

.intro-topbar-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.intro-topbar-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.2px;
}

.intro-topbar-sub {
  font-size: 10.5px;
  font-weight: 300;
  color: var(--muted);
  margin: 1px 0 0;
}

.intro-week-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--card-strong);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* 큰 원형 카피바라 사진 */
.intro-hero-circle {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 14px;
  border: 3px solid var(--accent-2);
  box-shadow: 0 8px 22px rgba(138, 111, 79, 0.20);
  background: var(--bg2);
}

.intro-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 안내 카드 위 작은 섹션 라벨("참여 전 안내") */
.intro-section-label {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 14px;
  color: var(--accent);
  margin: 4px 0 8px;
  text-align: left;
  width: 100%;
}

.intro-content {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding-top: 72px;             /* 상단 바 높이 확보 */
  padding-bottom: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.intro-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex-shrink: 0;
}

.intro-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 8px;
  margin-top: 4px;               /* 안내문이 화면 중앙 쪽에 더 잘 보이도록 상단에 붙임 */
  flex-shrink: 0;
}

.intro-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 23px;                /* 26 → 23 살짝 축소 */
  color: var(--accent);
  margin: 0 0 6px;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7);
}

.intro-sub {
  font-size: 13px;                /* 14 → 13 살짝 축소 */
  font-weight: 300;
  color: var(--text-soft);
  margin: 0 0 18px;               /* 28 → 18 축소 */
  line-height: 1.6;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6);
}

/* 여정 단계 칩 4개 */
.journey-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 2px;
  margin: 0 0 16px;               /* 32 → 16 축소 */
  padding: 10px 10px;             /* 16 → 10 축소 */
  background: var(--card-strong);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  box-shadow: 0 6px 18px rgba(138, 111, 79, 0.10);
}

.journey-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 2px 4px;
  min-width: 44px;
}

.journey-chip .emoji {
  font-size: 19px;                /* 22 → 19 축소 */
  line-height: 1;
}

.journey-chip .label {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text);
  opacity: 0.9;
  margin-top: 2px;
}

.arrow {
  color: var(--accent);
  font-weight: 500;
  font-size: 14px;
  flex-shrink: 0;
}

/* ID(두 자리 숫자) 재입력 + 시작하기 버튼 */
.intro-start-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.intro-id-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-align: left;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
}

.intro-start-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  width: 100%;
}

.intro-id-input {
  flex-shrink: 0;
  width: 68px;
  text-align: center;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.intro-id-input::placeholder {
  color: var(--muted);
  font-weight: 300;
  letter-spacing: 2px;
}

.intro-id-input:focus {
  border-color: var(--accent);
  background: #ffffff;
}

.intro-start-btn {
  flex: 1;
}

.intro-id-error {
  color: #c44d3a;
  font-size: 12px;
  margin: 0;
  text-align: left;
  font-weight: 400;
}

.intro-warn {
  font-size: 11px;
  font-weight: 300;
  color: var(--text-soft);
  text-align: center;
  margin: 6px 0 0;
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
}


/* ============================================================
   9. Placeholder (화면 2~7 · 이후 단계 구현 예정)
   ============================================================ */
.placeholder {
  margin: auto;
  padding: 40px 28px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--card);
  max-width: 320px;
}

.ph-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--accent);
  margin: 0 0 6px;
}

.ph-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
}

.ph-back {
  font-size: 13px;
  padding: 10px 18px;
}


/* ============================================================
   10. Float Animation (마스코트·아이콘 부드러운 떠오름)
   ============================================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.float-anim {
  animation: float 4s ease-in-out infinite;
}


/* ============================================================
   11. 디버그 표시기 (Stage 1 임시 — 2단계에서 제거)
   ============================================================ */
.stage-tag {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 9999;
  background: rgba(138, 111, 79, 0.85);
  color: #faf5ed;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 10px;
  pointer-events: none;
  letter-spacing: 0.3px;
}


/* ============================================================
   13. 화면 2 · 대화
   ============================================================ */

/* 화면 2는 grid 레이아웃: 헤더 / 진행점 / 메시지 / 칩 / 입력창 */
#s-chat.active {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  height: 100vh;
}

/* 채팅 헤더 (마스코트 + 제목) */
.chat-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 10px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.chat-header .mascot {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.chat-header-text {
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.3px;
}

.chat-header-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin: 2px 0 0;
  font-weight: 300;
}


/* 진행 점 12개 */
.chat-dots {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(250, 245, 237, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(138, 111, 79, 0.20);
  transition: all 0.25s ease;
}

.dot.done {
  background: var(--accent);
}

.dot.current {
  background: var(--accent);
  width: 11px;
  height: 11px;
  box-shadow: 0 0 0 3px rgba(138, 111, 79, 0.18);
}


/* 채팅 메시지 영역 */
.chat-messages {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  width: 100%;
}

.msg-bot {
  justify-content: flex-start;
}

.msg-user {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  font-weight: 300;
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.10);
}

.msg-bot .msg-bubble {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, var(--peach) 0%, var(--accent-2) 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  text-shadow: 0 1px 2px rgba(90, 69, 48, 0.15);
}


/* 타이핑 인디케이터 */
.msg-bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
}

.msg-bubble.typing span {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.msg-bubble.typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-bubble.typing span:nth-child(3) { animation-delay: 0.30s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}


/* 칩 영역 */
.chat-chips {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 14px 4px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.chat-chips.hidden {
  display: none;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 13.5px;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-align: center;
  letter-spacing: -0.1px;
  box-shadow: 0 2px 8px rgba(138, 111, 79, 0.06);
}

.chip:active {
  transform: scale(0.96);
  background: rgba(232, 184, 157, 0.30);
}

.chip:hover {
  border-color: var(--accent-2);
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.12);
}

.chip-free {
  grid-column: span 2;
  background: rgba(255, 255, 255, 0.7);
  border-style: dashed;
  color: var(--accent);
  font-weight: 400;
}


/* 입력창 + 전송 버튼 */
.chat-input-area {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 22px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.chat-input::placeholder {
  color: var(--muted);
  font-weight: 300;
}

.chat-input:focus {
  border-color: var(--accent);
  background: #ffffff;
}

.chat-input:disabled {
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
}

.chat-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--peach) 0%, var(--gold) 100%);
  color: #ffffff;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 12px rgba(212, 169, 107, 0.30);
}

.chat-send:active { transform: scale(0.93); }

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}


/* ============================================================
   14. 화면 3 · 대화 정리
   ============================================================ */

#s-chat-result.active {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

.result-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 18px 14px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.result-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 6px 16px rgba(138, 111, 79, 0.18);
}

.result-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  color: var(--accent);
  margin: 6px 0 0;
  letter-spacing: -0.3px;
}

.result-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-weight: 300;
}


/* 본문 — 스크롤 가능 영역 */
.result-body {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}


.result-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-section-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 14.5px;
  color: var(--accent);
  margin: 0 0 2px;
  letter-spacing: -0.2px;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6);
}


/* Q1~Q7 선택 칩 영역 */
.result-chips {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.result-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(138, 111, 79, 0.08);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.result-chip-label {
  flex-shrink: 0;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  background: rgba(232, 184, 157, 0.30);
  padding: 3px 9px;
  border-radius: 8px;
  letter-spacing: -0.1px;
}

.result-chip-value {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
}


/* Q8~Q12 답변 카드 */
.result-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.10);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.result-card-q {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--accent);
  margin: 0 0 8px;
  line-height: 1.55;
  letter-spacing: -0.2px;
}

.result-card-a {
  font-size: 14px;
  font-weight: 300;
  color: var(--text);
  margin: 0;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
  padding-left: 8px;
  border-left: 2px solid rgba(232, 184, 157, 0.55);
}


/* 하단 푸터 */
.result-footer {
  position: relative;
  z-index: 2;
  padding: 12px 18px 14px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.result-footer .btn {
  width: 100%;
  max-width: 320px;
}


/* ============================================================
   15. 화면 4 · 심상화 (Goal)
   ============================================================ */

#s-goal-image.active {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

.goal-header {
  position: relative;
  z-index: 2;
  padding: 18px 18px 12px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.goal-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 20px;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.3px;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.7);
}


.goal-body {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}


/* SVG 카드 */
.goal-image-wrap {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 6 / 5;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(138, 111, 79, 0.16);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.goal-image-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.goal-image-error {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

/* Gemini PNG 이미지 (API 성공 시) */
.goal-image-png {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 17px;
}

/* 그림 로딩 표시 — 이미지 카드 바로 아래 */
.goal-loading {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--accent);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  border: 1px solid var(--border);
  margin-top: -8px;
  width: 100%;
  max-width: 360px;
  align-self: center;
  box-shadow: 0 2px 8px rgba(138, 111, 79, 0.10);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.goal-loading[hidden] {
  display: none;
}

.goal-loading-text {
  letter-spacing: -0.2px;
}

.goal-loading-dots {
  display: inline-flex;
  gap: 4px;
}

.goal-loading-dots span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: goalLoadingPulse 1.3s ease-in-out infinite;
}

.goal-loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.goal-loading-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes goalLoadingPulse {
  0%, 70%, 100% { opacity: 0.30; transform: scale(0.8); }
  35%           { opacity: 1.00; transform: scale(1.15); }
}


.goal-desc {
  margin-top: auto;             /* SVG와 사이를 자동 공간으로 채워 안내문을 푸터 바로 위로 */
  width: 100%;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 0;
  letter-spacing: -0.1px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.08);
}


.goal-footer {
  position: relative;
  z-index: 2;
  padding: 12px 18px 14px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.goal-footer .btn {
  width: 100%;
  max-width: 320px;
}


/* ============================================================
   16. 화면 5 · 호흡 명상
   ============================================================ */

#s-meditation.active {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  height: 100vh;
}

.med-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px 8px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.med-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.3px;
}

.med-timer {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 22px;
  color: var(--accent);
  margin: 0;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}


.breath-stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;  /* 이미지를 화면 위쪽으로 붙이기 위해 상단 정렬 */
  gap: 150px;                    /* 이미지-호흡원 사이 간격 — 원이 배경 캐릭터의 가슴 쪽으로 더 내려오도록 */
  padding: 0 16px 0;
  min-height: 280px;
}

/* 심상화 이미지 — 호흡 원 위쪽에 표시 */
.breath-goal-image {
  width: 238px;
  height: 238px;
  margin-top: 16px;   /* 헤더 바로 아래 딱 붙지 않도록 상단 여백 확보 */
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.5);
  border: 3px solid var(--accent-2);
  box-shadow: 0 6px 18px rgba(138, 111, 79, 0.20);
}

.breath-goal-image:empty {
  display: none;
}

.breath-goal-image img,
.breath-goal-image svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#breath-svg {
  width: 260px;
  height: 260px;
  max-width: 100%;
  flex-shrink: 0;    /* 세로 공간이 빠듯해도 원이 타원으로 찌그러지지 않도록 */
}

#breath-svg circle {
  transition: opacity 0.3s ease, fill 0.5s ease;
}

#bc-main, #bc-inn {
  filter: drop-shadow(0 8px 24px rgba(184, 224, 160, 0.40));
}


.med-progress {
  position: relative;
  z-index: 2;
  padding: 4px 22px 2px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.med-stage-chip {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--accent);
  letter-spacing: -0.3px;
  text-shadow:
    0 0 4px  rgba(255, 255, 255, 0.95),
    0 0 10px rgba(255, 255, 255, 0.78),
    0 0 20px rgba(255, 255, 255, 0.55),
    0 0 32px rgba(255, 255, 255, 0.35),
    0 0 48px rgba(255, 255, 255, 0.20);
  transition: opacity 0.4s ease;
}

.med-progress-bar {
  width: 100%;
  max-width: 320px;
  height: 5px;
  background: rgba(138, 111, 79, 0.18);
  border-radius: 3px;
  overflow: hidden;
}

.med-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--peach) 0%, var(--gold) 100%);
  border-radius: 3px;
  transition: width 0.3s linear;
}


.med-script {
  position: relative;
  z-index: 2;
  padding: 2px 18px 4px;       /* 호흡 원과의 사이를 가깝게 */
  margin-top: -10px;           /* 살짝 위로 끌어올림 */
}

.med-script-text {
  font-size: 15.5px;           /* 13px → 15.5px 확대 */
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 16px;
  margin: 0;
  text-align: center;
  letter-spacing: -0.1px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.10);
  transition: opacity 0.4s ease;
  min-height: 44px;
}


.med-footer {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 10px;
  padding: 8px 18px 10px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.med-btn-reset {
  flex: 0 0 38%;
  font-size: 14px;
}

.med-btn-start {
  flex: 1;
  font-size: 15px;
}


/* ============================================================
   17. 화면 6 · 마무리
   ============================================================ */

#s-closing.active {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
}

.closing-header {
  position: relative;
  z-index: 2;
  padding: 18px 18px 12px;
  background: rgba(250, 245, 237, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.closing-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 20px;
  color: var(--accent);
  margin: 0;
  letter-spacing: -0.3px;
  text-shadow:
    0 0 4px  rgba(255, 255, 255, 0.85),
    0 0 12px rgba(255, 255, 255, 0.60),
    0 0 24px rgba(255, 255, 255, 0.35);
}


.closing-body {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.closing-desc {
  margin-top: auto;
  width: 100%;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.85;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  letter-spacing: -0.1px;
  text-align: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.08);
}


.closing-footer {
  position: relative;
  z-index: 2;
  padding: 12px 18px 14px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.closing-footer .btn {
  width: 100%;
  max-width: 320px;
}


/* ============================================================
   18. 화면 7 · 축원
   ============================================================ */

#s-blessing.active {
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

.blessing-content {
  position: relative;
  z-index: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.blessing-icon-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.blessing-icon {
  font-size: 56px;
  display: inline-block;
  filter: drop-shadow(0 6px 18px rgba(212, 169, 107, 0.40));
}

/* 마스코트 이미지일 때 */
.blessing-icon-img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 6px 20px rgba(138, 111, 79, 0.20);
}

.blessing-quote {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--accent);
  margin: 0;
  line-height: 1.8;
  letter-spacing: -0.2px;
  text-shadow:
    0 0 4px  rgba(255, 255, 255, 0.90),
    0 0 14px rgba(255, 255, 255, 0.55);
}


/* 축원 카드 — 흰색 70% 투명도, 골드 테두리 유지 */
.blessing-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.70);
  border: 1.5px solid var(--gold);
  border-radius: 18px;
  padding: 22px 22px;
  box-shadow:
    0 10px 28px rgba(212, 169, 107, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.40);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  margin-top: 4px;
}

.blessing-text {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 14px;
  line-height: 2.0;
  color: #5a4530;
  margin: 0;
  white-space: pre-wrap;
  text-align: center;
  letter-spacing: -0.1px;
}

/* 축원문 로딩 중 살짝 옅게 + 깜빡임 */
.blessing-text.blessing-loading {
  color: var(--muted);
  font-style: italic;
  animation: blessingPulse 1.8s ease-in-out infinite;
}

@keyframes blessingPulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1.0; }
}


.blessing-footer {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px 14px;
  background: rgba(250, 245, 237, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}

.blessing-footer .btn {
  width: 100%;
}


/* ============================================================
   19. 인트로 동의서 카드 (모바일 최적화)
   ============================================================ */
.consent-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 4px;
  box-shadow: 0 4px 12px rgba(138, 111, 79, 0.10);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.consent-scroll {
  max-height: 640px;              /* 짧아진 안내문 전체가 내부 스크롤 없이 보이도록 넉넉히 확장 */
  overflow-y: auto;               /* 만약을 대비한 안전장치 — 평소엔 화면 전체(.intro-content) 스크롤로 충분 */
  -webkit-overflow-scrolling: touch;
  font-size: 13px;                /* 짧아진 안내문 가독성을 위해 확대 */
  line-height: 1.7;
  color: var(--text);
  padding: 12px 14px;
  background: rgba(250, 245, 237, 0.55);
  border: 1px solid rgba(138, 111, 79, 0.10);
  border-radius: 8px;
  text-align: left;
  letter-spacing: -0.1px;
}

.consent-scroll p {
  margin: 0 0 8px;
}

.consent-scroll ul {
  margin: 4px 0 8px;
  padding-left: 16px;
}

.consent-scroll li {
  margin-bottom: 4px;
}

.consent-h {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 12.5px !important;
  color: var(--accent);
  margin-bottom: 8px !important;
}

.consent-h2 {
  font-weight: 500;
  font-size: 11.5px !important;
  color: var(--accent);
  margin-top: 8px !important;
  margin-bottom: 4px !important;
}

.consent-h3 {
  font-weight: 500;
  font-size: 10.8px !important;
  color: var(--text-soft);
  margin-top: 6px !important;
  margin-bottom: 3px !important;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 4px 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text);
  cursor: pointer;
}

.consent-check input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
}

.consent-check span {
  flex: 1;
  letter-spacing: -0.1px;
}

/* 비활성 시작 버튼 표시 */
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.3);
}

/* ============================================================
   20. 호흡 명상 — 배경 음악 토글 버튼
   ============================================================ */
.med-header {
  position: relative;
}

/* 버튼 자체는 시각적으로 보기 좋게 + 충분한 터치 영역 (48×48 권장) */
.med-audio-toggle {
  position: absolute;
  right: 10px;
  top: calc(100% + 10px);   /* 헤더(제목·타이머) 아래로 확실히 떨어뜨려 겹침 방지 */
  bottom: auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(138, 111, 79, 0.20);
  z-index: 5;
  transition: transform 0.15s, opacity 0.2s, background 0.2s;
  padding: 0;
  -webkit-tap-highlight-color: rgba(232, 184, 157, 0.30);
}

/* 음악 아이콘 이미지 */
.med-audio-icon {
  width: 26px;
  height: 26px;
  display: block;
  pointer-events: none;            /* 클릭은 부모 버튼이 받도록 */
  transition: opacity 0.25s ease, filter 0.25s ease;
}

/* 보이지 않는 추가 터치 영역 — 사방으로 12px 확장 (실제 hit area 72×72) */
.med-audio-toggle::before {
  content: '';
  position: absolute;
  top: -12px;
  right: -12px;
  bottom: -12px;
  left: -12px;
  border-radius: 50%;
  /* 보이지 않지만 클릭 가능 */
}

.med-audio-toggle:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 1);
}

/* 꺼진 상태 — 아이콘 회색조·옅음 + 빨간 사선 */
.med-audio-toggle.muted {
  background: rgba(255, 255, 255, 0.78);
}

.med-audio-toggle.muted .med-audio-icon {
  opacity: 0.40;
  filter: grayscale(1);
}

.med-audio-toggle.muted::after {
  content: '';
  position: absolute;
  width: 36px;
  height: 2.5px;
  background: var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-32deg);
  border-radius: 2px;
  opacity: 0.85;
  pointer-events: none;
}


/* ============================================================
   12. iOS Safari Safe-Area
   ============================================================ */
@supports (padding: max(0px)) {
  .login-content {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .intro-content {
    padding-top: max(68px, calc(env(safe-area-inset-top) + 60px));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .header-floating {
    padding-top: max(16px, env(safe-area-inset-top));
  }
  .chat-header {
    padding-top: max(14px, calc(env(safe-area-inset-top) + 6px));
  }
  .chat-input-area {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .result-header {
    padding-top: max(18px, calc(env(safe-area-inset-top) + 10px));
  }
  .result-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .goal-header {
    padding-top: max(18px, calc(env(safe-area-inset-top) + 10px));
  }
  .goal-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .med-header {
    padding-top: max(14px, calc(env(safe-area-inset-top) + 6px));
  }
  .med-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .closing-header {
    padding-top: max(18px, calc(env(safe-area-inset-top) + 10px));
  }
  .closing-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .blessing-content {
    padding-top: max(32px, calc(env(safe-area-inset-top) + 20px));
  }
  .blessing-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}


/* ============================================================
   21. 동의 화면 (별도 화면, v2 — 2주차와 동일 구조)
   ============================================================ */
.consent-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  min-height: 100dvh;
}
.consent-title {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--accent);
  text-align: center;
  margin: 0 0 12px;
}
.consent-card-full {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
}
.consent-scroll-full {
  max-height: 52vh;
  max-height: calc(var(--vh, 1vh) * 52);
  min-height: 180px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.65;
  word-break: keep-all;
}
.consent-scroll-full p { font-size: 12px; }
.consent-scroll-full .consent-h { font-size: 13.5px !important; }
.consent-scroll-full .consent-h2 { font-size: 12.5px !important; margin-top: 10px !important; }
.consent-scroll-full .consent-h3 { font-size: 12px !important; }
.consent-card-full .consent-check { font-size: 12.5px; padding-top: 10px; }
.consent-card-full .consent-check input[type="checkbox"] { width: 20px; height: 20px; }
.consent-card-full .consent-check input[type="checkbox"]:disabled { opacity: 0.4; }
.consent-hint {
  font-size: 11.5px;
  color: var(--text-soft);
  text-align: center;
  margin: 8px 0 0;
  min-height: 16px;
}
.consent-next-btn {
  width: 100%;
  margin-top: auto;
}

/* ============================================================
   22. v2 (2026-09-03) — 코치 ⚙️ · 위험 안내 카드 · 위급 확인 설문 · 코치 패널
   ============================================================ */
.coach-gear {
  position: absolute; right: 14px; bottom: max(12px, env(safe-area-inset-bottom));
  width: 38px; height: 38px; border-radius: 50%; font-size: 17px; opacity: 0.38;
  background: rgba(255,255,255,0.7); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; z-index: 3; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.coach-gear:active { opacity: 0.9; }

/* 코치 패널 화면 공통 */
.coach-content {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* 코치 패널 */
.coach-title { font-family: var(--font-serif); font-size: 19px; color: var(--accent); text-align: left; display: flex; align-items: center; gap: 8px; margin: 0; }
.coach-sub { font-size: 12.5px; color: var(--muted); text-align: left; }
.coach-pin-row { display: flex; gap: 8px; }
.coach-pin-row input {
  flex: 1; background: #fff; border: 1px solid var(--border); padding: 12px 14px; border-radius: 12px;
  font-size: 17px; letter-spacing: 6px; text-align: center; color: var(--text); font-family: inherit;
}
.coach-section {
  background: rgba(255,255,255,0.85); border: 1px solid var(--border); border-radius: 16px; padding: 14px 14px 12px; text-align: left;
}
.coach-section > summary { list-style: none; cursor: pointer; font-weight: 500; font-size: 15px; color: var(--accent); display: flex; justify-content: space-between; align-items: center; }
.coach-section > summary::-webkit-details-marker { display: none; }
.coach-section > summary::after { content: '▾'; color: var(--muted); }
.coach-section[open] > summary::after { content: '▴'; }
.coach-section .body { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); }
.field label { font-size: 12.5px; color: var(--muted); }
.field input[type="number"], .field input[type="text"], .field input[type="email"], .field select {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font-size: 14px; color: var(--text); width: 100%; font-family: inherit;
}
.toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.toggle input { -webkit-appearance: checkbox; appearance: auto; width: 18px; height: 18px; accent-color: var(--accent); }
.q-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.q-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.q-head .qn { font-weight: 600; color: var(--accent); }
.q-head .spacer { flex: 1; }
.q-head select { font-size: 12.5px; padding: 3px 6px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-family: inherit; }
.q-head button { font-size: 13px; padding: 4px 8px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--border); cursor: pointer; font-family: inherit; }
.q-item textarea { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13.5px; line-height: 1.5; min-height: 56px; width: 100%; resize: vertical; font-family: inherit; }
.coach-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.coach-actions .btn { flex: 1; padding: 12px 10px; font-size: 14px; }
.coach-status { font-size: 12.5px; color: var(--muted); min-height: 18px; text-align: center; margin: 0; }
.risk-item { border-radius: 12px; padding: 10px 12px; background: #fff; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; font-size: 13px; text-align: left; }
.risk-item.t3 { border-color: #B3261E; background: #FDF1EF; }
.risk-item.t2 { border-color: #C49A4A; background: #FFF8E6; }
.risk-item.acked { opacity: 0.6; }
.risk-head { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; color: #fff; font-weight: 600; }
.badge.t3 { background: #B3261E; } .badge.t2 { background: #C49A4A; } .badge.t1 { background: #7F88B8; }
.risk-text { white-space: pre-wrap; word-break: keep-all; color: var(--text); font-size: 13.5px; }
.risk-meta { font-size: 12px; color: var(--muted); }
.risk-item .ack-row { display: flex; gap: 6px; }
.risk-item .ack-row input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; font-family: inherit; }
.risk-item .ack-row button { font-size: 12.5px; padding: 6px 10px; border-radius: 8px; background: var(--peach); border: none; cursor: pointer; font-family: inherit; }
.stat-row { display: flex; gap: 8px; }
.stat { flex: 1; text-align: center; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 4px; }
.stat b { display: block; font-size: 18px; color: var(--accent); }
.stat span { font-size: 11px; color: var(--muted); }


/* ===== 22. v3 공통 진입 화면 (4주차 형식) ===== */
.entry-content{display:block;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:0;}
/* ===== 카피챗 공통 진입 화면 (v3 · 2026-09-04) — 4주차 형식 ===== */
.entry{display:flex;flex-direction:column;justify-content:flex-start;width:100%;max-width:430px;margin:auto;padding:18px 20px 22px;box-sizing:border-box;}
.entry-mascot{width:108px;height:108px;border-radius:50%;object-fit:cover;display:block;margin:0 auto;box-shadow:0 4px 16px rgba(120,95,70,0.25);border:2px solid rgba(255,255,255,0.65);cursor:pointer;background:rgba(255,255,255,0.35);}
.entry-title{font-size:25px;text-align:center;margin:8px 0 0;font-weight:500;text-shadow:0 1px 3px rgba(255,255,255,0.65);}
.entry-sub{text-align:center;font-size:13px;margin:4px 0 0;opacity:.8;}
.entry-greet{margin-top:14px;font-size:13.5px;line-height:1.7;background:rgba(255,251,244,0.80);border:1px solid rgba(120,95,70,0.22);border-radius:14px;padding:12px 14px;word-break:keep-all;}
.entry-tag{display:inline-block;font-size:12px;letter-spacing:.12em;opacity:.75;margin:16px 0 6px;}
.entry-notice{font-size:12.5px;line-height:1.6;max-height:230px;overflow-y:auto;background:rgba(255,251,244,0.88);border:1px solid rgba(120,95,70,0.22);border-radius:14px;padding:12px 14px;word-break:keep-all;-webkit-overflow-scrolling:touch;}
.entry-notice p{margin:0 0 8px;}
.entry-notice ul{margin:4px 0 8px;padding-left:16px;}
.entry-notice li{margin-bottom:4px;}
.entry-notice .consent-h{font-weight:600;font-size:13.5px;margin-bottom:8px;}
.entry-notice .consent-h2{font-weight:600;margin:10px 0 4px;}
.entry-notice .consent-h3{font-weight:600;margin:8px 0 3px;font-size:12.5px;}
.entry-consent{display:flex;gap:10px;align-items:flex-start;margin-top:10px;background:rgba(255,251,244,0.74);border:1px solid rgba(120,95,70,0.22);border-radius:12px;padding:12px;cursor:pointer;}
.entry-consent input{margin-top:3px;width:18px;height:18px;flex:0 0 18px;-webkit-appearance:checkbox;appearance:auto;}
.entry-consent input:disabled{opacity:.4;}
.entry-consent label{font-size:13.5px;cursor:pointer;line-height:1.5;}
.entry-hint{font-size:12px;opacity:.7;text-align:center;margin-top:6px;min-height:16px;}
.entry-row{display:flex;gap:10px;margin-top:12px;}
.entry-row input{flex:1 1 50%;min-width:0;padding:14px 10px;border-radius:14px;border:1px solid rgba(120,95,70,0.22);background:rgba(255,251,244,0.85);font-family:inherit;font-size:16px;text-align:center;letter-spacing:2px;color:inherit;}
.entry-row input::placeholder{letter-spacing:0;font-size:14px;opacity:.7;}
.entry-row button{flex:1 1 50%;}
.entry-row.two input{flex:1 1 45%;}
.entry-err{font-size:12.5px;color:#B3261E;margin-top:8px;min-height:16px;text-align:center;}


#s-login .entry-title{font-size:25px;}
#s-login .entry-mascot{border-color:var(--accent-2);}
#s-login .entry-row input{letter-spacing:1px;font-size:15px;}


/* ===== 공통 UI v5 (2026-09-06) ===== */
/* ============================================================
   카피챗 공통 UI v5 (2026-09-06) — 1~4주차 공통 규격
   body[data-week="1|2|3|4"] 로 주차 테마 선택
   ============================================================ */
:root{
  --ui-white:rgba(255,255,255,.78);
  --ui-white2:rgba(255,255,255,.62);
  --ui-radius:18px;
  --ui-shadow:0 6px 18px rgba(60,40,20,.10);
  --ui-font:"Pretendard","Noto Sans KR","Apple SD Gothic Neo","Malgun Gothic",system-ui,sans-serif;
}
body[data-week="1"]{ --c1:#FBF4E6; --c2:#EAD5B5; --accent:#B8956A; --accent2:#D9C3A2; --soft:#F3E7D3; --text:#4A3A2A; --muted:#8A7A66; --line:rgba(184,149,106,.35); }
body[data-week="2"]{ --c1:#FFF4B8; --c2:#F9BF7A; --accent:#E9A25A; --accent2:#F6D3A6; --soft:#FFF1D6; --text:#4A3320; --muted:#9A7A55; --line:rgba(233,162,90,.35); }
body[data-week="3"]{ --c1:#DDEFD8; --c2:#F3F0C2; --accent:#8CBF7A; --accent2:#CDE6C0; --soft:#EEF6E6; --text:#2E3A2A; --muted:#6E8266; --line:rgba(140,191,122,.38); }
body[data-week="4"]{ --c1:#E4DCF4; --c2:#F7DCE6; --accent:#A78BC9; --accent2:#D9CBEC; --soft:#F1EAF8; --text:#3A2E44; --muted:#7E6E92; --line:rgba(167,139,201,.38); }

/* 배경 이미지 화면: <section class="screen bgimg" data-bg="intro|chat|med|bless|etc"> (JS가 --bg-url 지정) */
.bgimg{ background-color:var(--c1); background-image:linear-gradient(180deg,rgba(255,255,255,.42),rgba(255,255,255,.30) 55%,rgba(255,255,255,.44)), var(--bg-url); background-size:cover, cover; background-position:center top, center top; background-repeat:no-repeat; }
.bgimg.deep{ background-image:linear-gradient(180deg,rgba(255,255,255,.16),rgba(255,255,255,.10) 55%,rgba(255,255,255,.22)), var(--bg-url); }

/* 카피바라 원형 이모티콘 */
.capy{ display:inline-block; border-radius:50%; object-fit:cover; background:transparent; box-shadow:0 4px 14px rgba(60,40,20,.14); }
.capy.sm{ width:44px; height:44px; } .capy.md{ width:84px; height:84px; } .capy.lg{ width:120px; height:120px; } .capy.xl{ width:150px; height:150px; }
.capy.float{ animation:capyFloat 3.2s ease-in-out infinite; }
@keyframes capyFloat{ 0%,100%{ transform:translateY(0);} 50%{ transform:translateY(-6px);} }

/* 안내 글상자: 남은 공간의 정중앙 */
.fill-center{ flex:1; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:14px; padding:12px 0; min-height:0; }
.guide-box{ width:100%; background:var(--ui-white); border:1px solid var(--line); border-radius:var(--ui-radius); padding:18px 18px; box-shadow:var(--ui-shadow); color:var(--text); font-size:15.5px; line-height:1.75; white-space:pre-line; }
.guide-box .t{ font-weight:700; font-size:17px; margin-bottom:6px; color:var(--text); }

/* 버튼 */
.ubtn{ display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:13px 18px; border-radius:16px; border:1px solid var(--line); background:var(--ui-white); color:var(--text); font-family:inherit; font-size:15.5px; font-weight:600; cursor:pointer; box-shadow:0 3px 10px rgba(60,40,20,.08); }
.ubtn.primary{ background:var(--accent); border-color:var(--accent); color:#fff; }
.ubtn.wide{ width:100%; }
.ubtn:disabled{ opacity:.45; cursor:default; }
.ubtn-row{ display:flex; gap:8px; width:100%; }
.ubtn-row .ubtn{ flex:1; padding:12px 6px; font-size:14.5px; }

/* 헤더(대화·활동 공통): 좌 카피바라 · 제목/부제 · 우 배지 */
.uhead{ display:flex; align-items:center; gap:10px; padding:10px 14px; background:var(--ui-white2); border-bottom:1px solid var(--line); }
.uhead .tt{ flex:1; min-width:0; } .uhead .tt b{ display:block; font-size:15px; color:var(--text); } .uhead .tt span{ display:block; font-size:12px; color:var(--muted); }
.uhead .badge{ font-size:11.5px; padding:4px 9px; border-radius:12px; background:var(--soft); color:var(--muted); border:1px solid var(--line); }

/* 명상 화면 공통 */
.med-layout{ display:flex; flex-direction:column; min-height:100%; padding:14px 16px 18px; gap:10px; }
.med-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.med-top .capy{ flex:0 0 auto; }
.med-time{ flex:1; text-align:center; }
.med-time .now{ font-size:34px; font-weight:700; color:var(--text); letter-spacing:.5px; line-height:1.1; font-variant-numeric:tabular-nums; }
.med-time .left{ font-size:12.5px; color:var(--muted); margin-top:2px; }
.snd-btn{ width:46px; height:46px; border:none; background:transparent; padding:0; cursor:pointer; flex:0 0 auto; }
.snd-btn img{ width:46px; height:46px; display:block; }
.med-bar{ height:6px; border-radius:6px; background:rgba(255,255,255,.55); overflow:hidden; border:1px solid var(--line); }
.med-bar i{ display:block; height:100%; width:0; background:var(--accent); transition:width .5s linear; }
.med-stage{ flex:1; position:relative; display:flex; align-items:center; justify-content:center; min-height:200px; }
.med-guide{ background:var(--ui-white); border:1px solid var(--line); border-radius:var(--ui-radius); padding:14px 16px; text-align:center; color:var(--text); font-size:15.5px; line-height:1.7; min-height:78px; display:flex; align-items:center; justify-content:center; white-space:pre-line; box-shadow:var(--ui-shadow); }
.med-btns{ display:flex; gap:8px; }
.med-btns .ubtn{ flex:1; padding:12px 4px; font-size:14.5px; }
.med-bottom-capy{ display:flex; justify-content:center; }

/* 명상 마무리 패널 */
.med-end{ position:absolute; inset:0; z-index:5; display:none; align-items:center; justify-content:center; padding:24px; background:rgba(255,255,255,.35); backdrop-filter:blur(3px); }
.med-end.show{ display:flex; }
.med-end .panel{ width:100%; background:var(--ui-white); border:1px solid var(--line); border-radius:22px; padding:22px 18px; text-align:center; box-shadow:var(--ui-shadow); display:flex; flex-direction:column; align-items:center; gap:12px; }
.med-end .panel h3{ margin:0; font-size:18px; color:var(--text); }
.med-end .panel p{ margin:0; color:var(--text); font-size:15px; line-height:1.7; white-space:pre-line; }

/* 축원 화면 공통 */
.bless-layout{ display:flex; flex-direction:column; align-items:center; min-height:100%; padding:18px 16px 20px; gap:12px; }
.bless-layout h2{ margin:0; font-size:19px; color:var(--text); text-align:center; }
.bless-box{ width:100%; background:rgba(255,255,255,.80); border:1px solid var(--line); border-radius:20px; padding:18px 18px; color:var(--text); font-size:15.5px; line-height:1.85; text-align:center; white-space:pre-line; box-shadow:var(--ui-shadow); }
.bless-note{ font-size:12px; color:var(--muted); text-align:center; }

/* 활동 화면 공통 */
.act-layout{ flex-direction:column; min-height:100%; }
.screen.act-layout.active{ display:flex; }
.act-stage{ flex:1; position:relative; min-height:240px; overflow:hidden; }
.act-bottom{ padding:10px 14px 16px; background:var(--ui-white2); border-top:1px solid var(--line); display:flex; flex-direction:column; gap:8px; }

/* 코치 패널 하단 버튼 3개 */
#capyCoach .cc-foot{ display:flex; gap:8px; margin-top:14px; }
#capyCoach .cc-foot .cc-btn{ flex:1; text-align:center; }

/* ===== w1 v5 전용 ===== */
.screen-content .fill-center{ width:100%; }
#s-intro .intro-content{ min-height:100vh; }
#s-intro .intro-bottom{ margin-top:auto; }
#s-meditation .med-header.med-top{ padding:12px 18px 8px; background:rgba(251,244,230,0.78); }
#s-meditation .med-header .capy{ flex:0 0 auto; }
#s-meditation .med-time .now{ font-family:var(--font-serif); }
#s-meditation .breath-stage{ gap:24px; padding-top:8px; }
#s-meditation .med-progress{ padding:2px 22px; }
#s-meditation .med-script{ margin-top:0; padding:4px 18px; }
#s-meditation .med-guide{ padding:10px 14px; min-height:64px; }
#s-meditation .med-guide .capy{ margin-right:10px; flex:0 0 auto; }
#s-meditation .med-script-text{ background:none; border:none; box-shadow:none; padding:0; text-align:left; flex:1; backdrop-filter:none; }
#s-meditation .med-footer.med-btns{ gap:8px; padding:8px 16px 12px; }
#s-meditation .med-footer .ubtn{ flex:1; padding:12px 4px; font-size:14.5px; }
#s-goal-image .goal-header.uhead{ position:relative; z-index:2; }
#s-goal-image .guide-box{ margin:12px 0 0; }
#s-closing .closing-header.uhead{ position:relative; z-index:2; }
#s-closing .closing-body.fill-center{ position:relative; z-index:1; padding:16px 20px; }
#s-blessing .blessing-content.bless-layout{ padding:22px 20px 8px; }
#s-blessing .blessing-card.bless-box{ margin:0; }
#s-blessing .bless-layout h2{ font-size:17px; line-height:1.7; background:rgba(255,255,255,0.55); border-radius:40px; padding:8px 18px; }
.result-icon.capy{ width:72px; height:72px; border:none; }
.chat-header .mascot{ border-radius:50%; }
.coach-actions .btn-primary{ background:var(--accent); color:#fff; }

#s-blessing .blessing-footer.ubtn-row{ flex-direction:row; }
