/* ナエ韓国語 — アプリモード専用スタイル
   모든 규칙은 .app-mode(html) 스코프 안에만 있어 웹 브라우저 표시에는 영향 없음.
   .app-mode 는 js/app-mode.js 가 Capacitor 앱 환경에서만 부여한다. */

/* ---------- 기본: 앱 전용 요소는 웹에서 항상 숨김(이중 안전장치) ---------- */
.app-tabbar, .app-home, .app-links { display: none; }

/* ---------- 전역(터치 최적화·탭바 공간 확보) ---------- */
.app-mode { overflow-x: clip; }   /* 문서 루트 가로 넘침 차단 */
.app-mode body {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: clip;   /* 긴 URL 등이 뷰포트를 넘겨도 가로 스크롤·하단 탭바(fixed) 밀림 방지. clip=스크롤컨테이너 미생성이라 admin .tabs sticky 안전 */
  max-width: 100%;
}

/* ---------- 상단: 컴팩트 헤더 (로고만 남기고 중앙 배치) ----------
   헤더는 2계열: .header(.header-in) — index 등 / .site-header(.header-inner) — pay·legal·apply·404.
   내부 구성이 페이지마다 달라(내비·CTA 래퍼·직접 버튼) 로고 외 전부 숨김으로 일반화. */
.app-mode .header .header-in > *:not(.logo),
.app-mode .site-header .header-inner > *:not(.logo) { display: none !important; }
.app-mode .header .header-in { justify-content: center; min-height: 54px; }
.app-mode .site-header .header-inner { justify-content: center; }

/* ---------- 전면 카메라(노치·다이나믹아일랜드·펀치홀) 회피: 헤더 상단 safe-area 여백 ----------
   iOS: viewport-fit=cover + env(safe-area-inset-top) 로 상태바/카메라 높이만큼 헤더를 내림.
   Android: 앱쪽 adjustMarginsForEdgeToEdge:"auto" 가 웹뷰 뷰에 마진을 주므로 env 는 0px → 이중여백 없음.
   Capacitor 가 주입하는 --safe-area-inset-top 이 있으면 우선(구형 WebView 대응), 없으면 env 폴백. */
.app-mode .header,
.app-mode .site-header {
  padding-top: constant(safe-area-inset-top, 0px); /* iOS 11.0–11.2 구형 폴백(먼저 선언) */
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  background: #fff; /* sticky 헤더가 카메라 영역까지 흰 배경으로 덮어 로고 밑 여백을 자연스럽게 */
}

/* ---------- 관리자 대시보드(admin.html): .topbar 계열 헤더도 카메라 영역 회피 + 탭바 겹침 방지 ----------
   admin 페이지의 sticky 탭줄(.tabs)은 safe-area 만큼 내려 붙여 노치 아래에서 고정되게 한다. */
.app-mode .topbar {
  padding-top: calc(14px + constant(safe-area-inset-top, 0px)); /* iOS 11.0–11.2 구형 폴백 */
  padding-top: calc(14px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
}
.app-mode .tabs {
  top: constant(safe-area-inset-top, 0px);
  top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
}

/* ---------- 숨김: 웹 푸터(.footer / .site-footer 2계열)·index 모바일 CTA 바 ---------- */
.app-mode .footer,
.app-mode .site-footer { display: none !important; }
.app-mode .mbar { display: none !important; }

/* ---------- LINE 플로팅 버튼: 탭바 위로 ---------- */
.app-mode .line-fab {
  bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ---------- 하단 탭바 ---------- */
.app-mode .app-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  display: flex;
  background: #fff;
  border-top: 1px solid #ececec;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, .05);
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom, 0px));
}
.app-mode .app-tabbar a {
  flex: 1;
  min-height: 48px; /* 터치영역 확보 */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .66rem; font-weight: 700; line-height: 1;
  color: #8b8b8b; text-decoration: none;
  border-radius: 12px;
}
.app-mode .app-tabbar a:active { background: #f6f6f6; }
.app-mode .app-tabbar a svg { width: 22px; height: 22px; }
.app-mode .app-tabbar a.active { color: var(--red, #FF4536); }

/* ---------- 앱 전용 홈 (index — 사장님 확정 구상안) ----------
   html.app-home-active(앱모드 index에서만 부여)가 웹 마케팅 섹션을 통째로 숨기고
   .app-home 컨테이너(app-mode.js 주입)만 보여준다. 웹 표시는 불변. */
.app-mode.app-home-active section.hero,
.app-mode.app-home-active .topics,
.app-mode.app-home-active section.sec,
.app-mode.app-home-active section.realband,
.app-mode.app-home-active section.cta { display: none !important; }
/* 로그인(회원) 홈은 심플하게 — 캠페인 배너 숨김(비로그인 홈에서는 유지) */
.app-mode.app-home-member #campBar { display: none !important; }

.app-mode .app-home {
  display: block;
  padding: 18px 20px 10px;
  max-width: 560px; margin: 0 auto;
}

/* 스켈레톤 (로딩 깜빡임 최소화) */
.app-mode .ah-skel-card {
  height: 120px; border-radius: 16px; margin-bottom: 12px;
  background: linear-gradient(100deg, #f3f4f6 40%, #fafbfc 50%, #f3f4f6 60%);
  background-size: 200% 100%;
  animation: ah-shimmer 1.2s infinite linear;
}
.app-mode .ah-skel-card.short { height: 72px; }
@keyframes ah-shimmer { to { background-position: -200% 0; } }

/* 공통 카드·버튼 */
.app-mode .ah-card {
  display: block; background: #fff; border: 1px solid #ececec; border-radius: 16px;
  padding: 16px 18px; margin-bottom: 12px;
}
.app-mode .ah-card h2 { font-size: .86rem; font-weight: 900; color: var(--sub, #5E6670); margin: 0 0 8px; }
.app-mode .ah-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: .5em 1.2em; border-radius: 10px;
  font-size: .9rem; font-weight: 700; text-decoration: none;
}
.app-mode .ah-btn-red { background: var(--red, #FF4536); color: #fff; }
.app-mode .ah-btn-red:active { background: #E63A2B; }
.app-mode .ah-btn-ghost { border: 2px solid #ececec; color: var(--ink, #1F2329); background: #fff; }

/* A-1. 인사 + 포인트 (브랜드 연한 배경) */
.app-mode .ah-greet {
  background: #FFF0EE; border-radius: 16px; padding: 18px; margin-bottom: 12px;
}
.app-mode .ah-greet-hi { margin: 0 0 4px; font-size: 1.02rem; font-weight: 900; color: var(--ink, #1F2329); }
.app-mode .ah-greet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.app-mode .ah-balance { margin: 0; font-size: 2rem; font-weight: 900; color: var(--red, #FF4536); line-height: 1.2; }
.app-mode .ah-balance small { font-size: 1.05rem; margin-left: 2px; }
.app-mode .ah-charge {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: .4em 1.3em; border-radius: 999px;
  background: var(--red, #FF4536); color: #fff; font-size: .88rem; font-weight: 900; text-decoration: none;
}
.app-mode .ah-charge:active { background: #E63A2B; }
.app-mode .ah-greet-sub { margin: 4px 0 0; font-size: .8rem; color: #8a6b66; }

/* A-2. 다음 레슨 */
.app-mode .ah-next-when { margin: 0; font-size: 1.3rem; font-weight: 900; color: var(--ink, #1F2329); }
.app-mode .ah-next-teacher { margin: 2px 0 12px; font-size: .86rem; color: var(--sub, #5E6670); }
.app-mode .ah-next-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-mode .ah-next-actions .ah-btn { flex: 1; }
.app-mode .ah-next-empty .ah-next-none { margin: 0 0 12px; font-size: .92rem; color: var(--sub, #5E6670); }
.app-mode .ah-next-empty .ah-btn { width: 100%; }

/* A-3/B. 메인 CTA */
.app-mode .ah-cta {
  display: block; text-decoration: none; text-align: center;
  background: var(--red, #FF4536); color: #fff;
  border-radius: 16px; padding: 16px 18px; margin-bottom: 12px;
  font-size: 1.05rem; font-weight: 900;
  box-shadow: 0 6px 18px rgba(255, 69, 54, .28);
}
.app-mode .ah-cta:active { transform: scale(.985); }
.app-mode .ah-cta span { display: block; font-size: .78rem; font-weight: 700; opacity: .92; margin-top: 5px; }

/* A-4. 학습 기록 2칸 */
.app-mode .ah-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.app-mode .ah-stats > div {
  background: #fff; border: 1px solid #ececec; border-radius: 16px; padding: 14px 16px; text-align: center;
}
.app-mode .ah-stats p { margin: 0; font-size: .76rem; font-weight: 700; color: var(--sub, #5E6670); }
.app-mode .ah-stat-n { margin-top: 2px !important; color: var(--ink, #1F2329) !important; }
.app-mode .ah-stat-n b { font-size: 1.5rem; font-weight: 900; }

/* A-5. 今日のひとこと韓国語 (teal 계열) */
.app-mode .ah-phrase { background: #E8F6F4; border-color: #d2ebe7; }
.app-mode .ah-phrase h2 { color: #0E7568; }
.app-mode .ah-phrase-ko { margin: 0; font-size: 1.45rem; font-weight: 900; color: #0B5D53; line-height: 1.45; }
.app-mode .ah-phrase-ja { margin: 2px 0 0; font-size: .9rem; color: #3d7a72; }

/* A-6. 서포트 3버튼 */
.app-mode .ah-support { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.app-mode .ah-support a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 64px; padding: 8px 4px;
  background: #fff; border: 1px solid #ececec; border-radius: 14px;
  font-size: .74rem; font-weight: 700; color: var(--ink, #1F2329); text-decoration: none;
}
.app-mode .ah-support a:active { background: #f6f6f6; }
.app-mode .ah-support a span { font-size: 1.25rem; line-height: 1; }

/* B. 비로그인 홈 */
.app-mode .ah-hero { padding: 10px 2px 16px; }
.app-mode .ah-hero h1 { margin: 0 0 6px; font-size: 1.5rem; font-weight: 900; color: var(--ink, #1F2329); line-height: 1.4; }
.app-mode .ah-hero p { margin: 0; font-size: .9rem; color: var(--sub, #5E6670); }
.app-mode .ah-google {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; margin-bottom: 12px; border: 2px solid #ececec; border-radius: 12px;
  background: #fff; color: var(--ink, #1F2329); font-size: .95rem; font-weight: 700; text-decoration: none;
}
.app-mode .ah-google:active { background: #f6f6f6; }
.app-mode .ah-link { display: flex; align-items: center; gap: 12px; }
.app-mode .ah-emoji { font-size: 1.4rem; }
.app-mode .ah-link-tx { flex: 1; }
.app-mode .ah-link-tx b { display: block; font-size: .95rem; color: var(--ink, #1F2329); }
.app-mode .ah-link-tx small { display: block; font-size: .78rem; color: var(--sub, #5E6670); margin-top: 1px; }
.app-mode .ah-arrow { color: #bbb; font-weight: 700; font-size: 1.2rem; }

/* 캠페인 배너 컴팩트화 (index #campBar 안쪽 wrap) */
.app-mode #campBar .wrap { padding: 9px 14px !important; font-size: .88rem !important; }

/* ---------- 마이페이지: 법적 링크 블록 ---------- */
.app-mode .app-links {
  display: block;
  margin: 28px 0 8px; padding: 18px;
  background: #fafafa; border: 1px solid #ececec; border-radius: 14px;
}
.app-mode .app-links h3 {
  font-size: .95rem; font-weight: 900; margin: 0 0 8px; color: var(--ink, #1a1a1a);
}
.app-mode .app-links a {
  display: flex; align-items: center; min-height: 44px;
  font-size: .9rem; font-weight: 500; color: #444; text-decoration: none;
  border-bottom: 1px solid #efefef;
}
.app-mode .app-links a:last-of-type { border-bottom: 0; }
.app-mode .app-links a::after { content: "›"; margin-left: auto; color: #bbb; font-weight: 700; }
.app-mode .app-links-copy { margin: 10px 0 0; font-size: .74rem; color: #999; }

/* ---------- 터치 최적화: 주요 버튼 최소 높이 ---------- */
.app-mode .btn { min-height: 46px; }
