/**
 * Pretendard 는 Google Fonts 에 없는 폰트다 — css2?family=Pretendard 는 400 을 돌려주고,
 * 400 응답에는 CORS 헤더가 붙지 않는다. 그래서 이 @import 는 한 번도 성공한 적이 없고,
 * 화면은 줄곧 아래 font-family 들의 시스템 폴백(-apple-system 등)으로 그려져 왔다.
 * 공유 카드 캡처(snapdom)가 스타일시트를 fetch 로 다시 긁을 때마다 이 실패가 콘솔을 채우고
 * 네트워크 브리지까지 흔들었으므로 링크를 걷어낸다.
 *
 * font-family 의 'Pretendard' 지정은 로컬에 설치한 기기를 위해 남겨둔다.
 * 웹폰트로 실제로 들일지는 전 화면 타이포가 바뀌는 일이라 별도로 정한다.
 */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400;500;600;700&display=swap');
@import url('https://cdn.jsdelivr.net/gh/leetaewook/gmarket-sans-dynamic-subset/GmarketSans.css');

/* Lucide SVG icons (FA 대체) */
[data-lucide],
.lucide {
    width: 1.125rem;
    height: 1.125rem;
    stroke-width: 1.25;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -0.125em;
}
.bottom-nav .nav-item [data-lucide],
.bottom-nav .nav-item .lucide {
    width: 1.375rem;
    height: 1.375rem;
}
.bottom-nav .nav-item i.lucide,
html.platform-native-app .bottom-nav button i.lucide {
    font-size: inherit;
}
#boardWriteBtn.board-write-fab [data-lucide],
#boardWriteBtn.board-write-fab .lucide,
#entryQuickInputFab.entry-quick-input-fab [data-lucide],
#entryQuickInputFab.entry-quick-input-fab .lucide {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2.75;
}
.lucide-spin {
    animation: lucide-spin 0.8s linear infinite;
}
@keyframes lucide-spin {
    to { transform: rotate(360deg); }
}
/*
 * 순수 CSS 스피너 — 로딩 표시는 lucide 로딩 여부에 걸리면 안 된다.
 * (i[data-lucide]는 scheduleLucideIcons가 돌아야 SVG가 되고, 전역 옵저버가 없어
 *  호출을 빠뜨리면 아무것도 안 보인다)
 */
.mealog-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(16, 185, 129, 0.18);
    border-top-color: #10b981;
    border-radius: 9999px;
    animation: lucide-spin 0.8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
    .mealog-spinner { animation-duration: 2.4s; }
}
/* 버튼 안 스피너 — 채운 버튼 위에서도 보이도록 글자색을 따른다 */
.mealog-spinner--btn {
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    margin-right: 0.4em;
    vertical-align: -0.15em;
    border-width: 2px;
    border-color: currentColor;
    border-top-color: transparent;
}
/* 좋아요·북마크 활성: 라인 아이콘 채움 */
.liked [data-lucide],
.liked .lucide,
.bookmarked [data-lucide],
.bookmarked .lucide,
.social-btn.liked .lucide,
.lounge-social-btn.liked .lucide,
.lounge-social-btn.bookmarked .lucide {
    fill: currentColor;
}
.star-btn .lucide,
.star-btn [data-lucide] {
    width: 1.25rem;
    height: 1.25rem;
}
/* 미선택 별: 윤곽이 보이도록 (다른 아이콘과 동일 선 굵기) */
.star-btn.text-slate-400 .lucide,
.star-btn.text-slate-400 [data-lucide],
.star-btn.text-slate-400 svg,
.star-btn.text-slate-200 .lucide,
.star-btn.text-slate-200 [data-lucide],
.star-btn.text-slate-200 svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.25;
    color: #94a3b8;
}
/* 선택(노란) 별: 윤곽만 두지 않고 채움 */
.star-btn.text-amber-500 .lucide,
.star-btn.text-amber-500 [data-lucide],
.star-btn.text-amber-500 svg,
.star-btn.text-yellow-400 .lucide,
.star-btn.text-yellow-400 [data-lucide],
.star-btn.text-yellow-400 svg,
.star-btn.text-yellow-500 .lucide,
.star-btn.text-yellow-500 [data-lucide],
.star-btn.text-yellow-500 svg {
    fill: currentColor;
    stroke-width: 1.25;
}

:root { 
    /* env()가 0 반환해도 최소값 보장 (상태바~28px) */
    --safe-top: max(env(safe-area-inset-top, 28px), 28px);
    /*
     * 하단 safe 토큰 (의미를 분리 — 이중 사용 방지)
     * - gesture: 실제 홈 인디케이터/제스처 inset (IME·시트 하단, 최소 48 강제 없음)
     * - nav-slot: 하단 앱 네비·FAB·뷰 높이용 (네이티브에서 최소 48px)
     * - --safe-bottom: 하위 호환 alias (= nav-slot). 신규 코드는 gesture/nav-slot을 명시
     */
    --safe-bottom-gesture: env(safe-area-inset-bottom, 0px);
    --safe-bottom-nav-slot: max(var(--safe-bottom-gesture), 48px);
    --safe-bottom: var(--safe-bottom-nav-slot);
    /* IME — resize/루트시프트: fixed-bottom=0 / overlay(시프트 실패): overlap */
    --ime-overlap: 0px;
    --ime-inset: 0px;
    --ime-fixed-bottom: 0px;
    --ime-vv-height: 100dvh;
    --ime-vv-top: 0px;
    /*
     * z-index 레이어 사다리 (오름차순)
     *
     * 규칙: 새 레이어는 반드시 여기에 토큰으로 추가한다.
     *   - CSS:     z-index: var(--z-토큰);
     *   - HTML/JS: class="... z-[var(--z-토큰)]"   (숫자 직접 사용 금지)
     * 숫자를 직접 쓰면 어느 층에 끼어드는지 알 수 없어, 지금까지 13개 파일에
     * 295·310·405·406·458처럼 서로를 피하려는 값이 흩어지게 됐다.
     *
     * 값은 토큰화 시점의 동작을 그대로 보존한 것이라 중복이 남아 있다
     * (120·200·400·10050이 각각 두 용도). 통합은 별도 단계에서 다룬다.
     */
    /* 피드·타임라인 내부 */
    --z-feed-overlay-panel: 25;   /* 사진 오버레이 댓글 패널, 모먼트 캡션 푸터 */
    --z-feed-comment-open: 30;    /* 모먼트 도킹 댓글 입력 열림 */
    --z-photo-nav: 35;            /* 타임라인 사진 좌우 내비 */
    --z-photo-nav-toggle: 36;     /* 사진 비율 토글 */
    /* FAB */
    --z-fab-under: 39;            /* 밀당 동기화 재전송 */
    --z-fab: 40;                  /* 글쓰기·빠른입력·새로고침 */
    --z-fab-stacked: 41;          /* 겹쳐 놓인 새로고침 FAB */
    /* 앱 셸 */
    --z-composer: 45;             /* 게시판 인라인 작성기 */
    --z-caption-layer: 48;        /* 모먼트 고정 캡션 레이어 */
    --z-app-chrome: 50;           /* #appTopChrome, .bottom-nav */
    --z-comment-sheet: 56;        /* 모먼트 소셜 댓글 시트 */
    --z-system-bar: 100;          /* 상태바·내비바 오버레이 */
    --z-ime-composer: 120;        /* IME 열림 시 작성기 — 셸 위로 */
    --z-demo-guide-backdrop: 120;
    --z-demo-guide-panel: 125;
    /* 랜딩 */
    --z-landing-backdrop: 199;
    --z-landing: 200;
    --z-landing-bottom: 201;
    /* 피드 버블 메뉴 */
    --z-bubble-backdrop: 200;
    --z-bubble-menu: 210;
    /* 기록 모달 스택 */
    --z-slot-picker: 295;
    --z-slot-picker-help: 296;    /* 기록 항목 설정 위에 겹치는 도움말 팝업 */
    --z-record-modal: 300;        /* 기록·데일리저널·식단리포트 */
    --z-meal-photos-popup: 310;
    --z-detail-modal: 350;
    /* 다이얼로그 */
    --z-dialog: 400;              /* 확인·공유 모달 기본 */
    --z-picker-sheet: 400;        /* 날짜 피커, 카카오 장소 시트 */
    --z-avatar-modal: 405;
    --z-profile-field-modal: 406;
    --z-dialog-over: 410;         /* 모달 위 확인 — 비번재설정·기간안내·사진편집 */
    --z-dialog-over-2: 420;       /* 비번재설정 성공 */
    /* 팝업·시트 */
    --z-content-popup: 450;
    --z-action-menu: 451;         /* .mealog-action-wrap */
    --z-search-sheet: 458;        /* 검색·알림·좋아요·달력 시트 */
    --z-onboarding: 500;          /* 도메인오류·약관·프로필설정, 관리자 모달 */
    --z-share-items: 505;         /* 하루 기록 공유 팝업 위에 겹치는 «공유 항목» 설정 */
    --z-feature-hint: 560;        /* 새 기능을 가리키는 말풍선 — 가리키는 화면보다 위 */
    --z-signup-wizard: 550;
    --z-report-sheet: 580;
    --z-admin-popover: 590;       /* 관리자 표에서 앵커에 붙는 작은 메뉴 — 모달 아래 */
    --z-admin-modal: 600;         /* 관리자 모달·알림 (admin.html 전용) */
    --z-admin-over: 700;
    --z-admin-loading: 999;
    /* 최상위 */
    --z-success-popup: 9500;
    --z-boot-splash: 9998;
    --z-loading-overlay: 9999;
    --z-lightbox: 10001;          /* 게시판 피드 라이트박스 */
    --z-lightbox-image: 10002;    /* 모먼트 이미지 라이트박스 */
    --z-service-guide: 10040;
    --z-comment-lightbox: 10050;
    --z-attendance: 10050;
    --z-install-guide: 10060;
    /*
     * 토스트는 모든 전면 오버레이보다 위 — 라이트박스·로딩·가이드 위에서 누른
     * 동작의 피드백(특히 에러)이 오버레이 뒤에 가려지면 안 된다.
     * #toastContainer는 pointer-events:none이라 위로 올려도 조작을 막지 않는다.
     * 축하·출석 팝업과의 중복 피드백 억제는 z가 아니라 ui.js의
     * isFullScreenMealogOverlayVisible()이 담당한다.
     */
    --z-toast: 10070;
    --z-app-update-dim: 99998;    /* 앱 업데이트는 무엇보다 위 */
    --z-app-update: 99999;
    /* 시안 v2 토큰 — Light Mint mid (#3CB889) */
    --green: #3cb889;
    --green-deep: #2d9f74;
    --green-soft: #eaf8f2;
    --green-mute: #b4e2cd;
    --ink: #241f1c;
    --ink-2: #4f4841;
    --muted: #7a7268;
    --line: #d0c6ba;
    --page: #fffcfa;
    /* Paper보다 한 단계 진한 메뉴 캔버스 — 기기/밝기에 따라 Paper가 씻겨 보일 때 대비 */
    --page-deep: #faf6f2;
    /* Page Deep과 비슷한 밝기, 웜을 줄인 회색빛 표면(옅은 톤) */
    --page-mist: #f8f7f5;
    --card: #ffffff;
    --star: #eab308;
    --color-primary: var(--green); /* 그린: CTA·선택·활성만 사용 */
    /* 팝업 셸 v2 (Soft Mint Air) */
    /* 플로팅 팝업 딤 — ink-2 (#4f4841) */
    --shell-dim: rgba(79, 72, 65, 0.45);
    --shell-dim: color-mix(in srgb, var(--ink-2) 45%, transparent);
    /* 플로팅 패널: 좌우 여백 남기되 화면 폭을 충분히 사용 (꽉 채우지 않음) */
    --shell-float-gutter: 1.25rem;
    --shell-float-width: min(28rem, calc(100vw - (var(--shell-float-gutter) * 2)));
    /* body max-w-md 컬럼 기준 — 웹에서 브라우저 전체 폭의 90%로 늘어나지 않게 */
    --shell-app-column-width: min(28rem, 100vw);
    --shell-dialog-width-90: calc(var(--shell-app-column-width) * 0.9);
    --shell-r-dialog: 18px;
    --shell-r-sheet: 24px;
    --shell-r-btn: 14px;
    --shell-ink: #1c1917;
    /* Danger CTA — Soft Mint와 짝이 되는 선명한 코랄 레드 (탁한 rose 폐기) */
    --danger: #ee5f70;
    --danger-deep: #d9485a;
    --shell-danger: var(--danger);
    --coral: #f2a8b4;
    --coral-soft: #fff0f3;
    /* CTA · Mint Glow (팝업·시트 primary 기본) */
    --cta-mint-grad: linear-gradient(135deg, #5fd4a8 0%, #3cb889 55%, #2d9f74 100%);
    /* 팝업 CTA 공통 — 넓은 글로우 대신 컴팩트 그림자 */
    --cta-mint-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(45, 159, 116, 0.28);
    --cta-danger-grad: linear-gradient(135deg, #f78a96 0%, #ee5f70 55%, #d9485a 100%);
    --cta-danger-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(217, 72, 90, 0.28);
    --cta-btn-h: 52px;
    --cta-btn-r: 16px;
    /* 센터 다이얼로그 가로 여백 — 헤더 텍스트·콘텐츠 박스·액션 버튼 좌측 정렬 기준 */
    --mealog-dialog-pad-x: 20px;
    /* 아바타 그림자: blur ≈ 2px (좁은 적용 범위) */
    --avatar-shadow: 0 1px 2px rgba(36, 31, 28, 0.22);
    --avatar-shadow-profile: 0 1px 2px rgba(100, 116, 139, 0.38);
    --avatar-fallback-bg: var(--green-soft);
    --avatar-fallback-fg: var(--green-deep);
    --avatar-fallback-font: 'GmarketSans', 'Pretendard', sans-serif;
    /* 메인 앱·밀톡 공통 페이지 배경 (= 각 메뉴 캔버스) */
    --app-page-bg: var(--page-deep);
    /* 밀톡 피드 대화 영역 배경 */
    --board-feed-bg: var(--app-page-bg);
    /* 하단 네비: 시안 edge bar (풀폭). FAB 폭 계산용 인셋은 좌우 여백만 유지 */
    --app-bottom-floating-inset: 0px;
    --app-bottom-nav-h: 72px;
    /* FAB ↔ 하단 네비 사이 간격 */
    --fab-above-nav-gap: 12px;
    /* body max-w-md(28rem) 컬럼·뷰포트 둘 다에서 양끝 여백 유지 (448 고정 폭이 컬럼에 꽉 차 보이는 문제 방지) */
    --app-bottom-bar-width: min(28rem, 100vw);
    /* 밀톡 피드 인라인 컴포저 컨테이너 — 시안 흰 바 */
    --board-feed-composer-surface: #ffffff;
    /*
     * 피드 스크롤 하단 패딩: APP 네비가 아니라 fixed 컴포저(#boardInlineComposer) 기준.
     * = 컴포저 bottom 오프셋(뷰포트 하단~컴포저 밑변) + 컴포저 박스 높이(패딩 0.4rem×2 + 한 줄 행 2.25rem + 테두리) + 새로고침 등 여유.
     * 구체 값은 #boardListView #boardFeedPanelContent 및 body 상태별 규칙에서 조합한다.
     */
    --board-feed-composer-face: calc(0.8rem + 2.25rem + 2px);
    --board-feed-above-composer: 0.75rem;
    /* 모먼트 화면2: 사진 vs 타이틀 헤더 `--moment-v2-photo-below-header-gap`. 도크 vs 네비 상단 `--moment-v2-dock-above-nav-gap` */
    --moment-v2-photo-below-header-gap: 20px;
    --moment-v2-app-nav-pill-h: var(--app-bottom-nav-h);
    --moment-v2-dock-above-nav-gap: 5px;
    --moment-v2-app-nav-top-from-bottom: calc(var(--safe-bottom) + var(--moment-v2-app-nav-pill-h));
    --moment-v2-wheel-footer-bottom: calc(var(--moment-v2-app-nav-top-from-bottom) + var(--moment-v2-dock-above-nav-gap));
    /* 기록(최대 3줄 접힘)·휠 한 줄·소셜 — 게시물 min-height·사진 영역 여유 */
    --moment-v2-dock-inset-approx: min(50vh, 12.5rem);
    /* 갤러리 화면2: #galleryPostsInsertPoint `gap` = 이전 글 하단 ↔ 다음 글 상단(투명 래퍼 기준) 유일 간격 */
    --moment-v2-gallery-post-gap: 14px;
}
/* Web: 네비 슬롯 최소치 없음. gesture는 브라우저 env 유지(모바일 웹 IME/홈바용) */
html.platform-web {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom-gesture: env(safe-area-inset-bottom, 0px);
    --safe-bottom-nav-slot: 0px;
    --safe-bottom: 0px;
    /* max-w-md 폰 컬럼 바깥(뷰포트 좌우) — line 톤의 은은한 프레임 */
    background-color: var(--line);
}
html.platform-web #navigationBarOverlay {
    display: none !important;
}
/*
 * 구형 Android WebView(Chromium <140) 전용: @capacitor-community/safe-area가 decorView padding으로
 * 시스템 바를 처리하고 env()는 0 → CSS/오버레이 중복 inset 방지.
 * Chromium≥140·iOS 등 최신 기기에는 index.html applyNativeSafeAreaMode가 이 클래스를 붙이지 않음.
 */
html.platform-native-inset-padded {
    --safe-top: 0px;
    --safe-bottom-gesture: 0px;
    --safe-bottom-nav-slot: 0px;
    --safe-bottom: 0px;
}
html.platform-native-inset-padded #statusBarOverlay,
html.platform-native-inset-padded #navigationBarOverlay {
    display: none !important;
}
/* 네이티브 앱: 상단·탭·설정 서브탭·알림 탭·하단 아이콘 등 메뉴성 UI만 글자/아이콘 최소 크기 보강 (브레이크포인트는 그대로) */
html.platform-native-app .app-chrome-subtab {
    font-size: 0.8125rem;
}
html.platform-native-app #trackerTabs .view-tab {
    font-size: 0.8125rem;
}
html.platform-native-app .notification-modal .notification-tab-btn {
    font-size: 0.8125rem;
}
html.platform-native-app .bottom-nav button i {
    font-size: 1.375rem;
}
html.platform-native-app #boardCategoryRow .board-category-btn {
    font-size: 0.8125rem;
}
/* 레이아웃 시프트 방지 */
html {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: clip;
    overflow-y: auto;
    /* 네이티브·기본: 바깥도 흰색. 웹(platform-web)은 아래에서 line으로 덮음 */
    background-color: #ffffff;
}
html.mealog-landing-active:not(.platform-web) {
    background-color: #ffffff;
}
html.mealog-landing-active.platform-web {
    background-color: var(--line);
}
/*
 * 랜딩 세로 영역: body 패딩은 쓰지 않음(메인용 --safe-top / 하단 네비 여유와 분리).
 * 상단 inset·아래쪽 여유(platform-web 규칙 등)는 모두 #landingPage(box-sizing: border-box) 안에서만 계산.
 */
html.mealog-landing-active body {
    padding-top: 0;
    padding-bottom: 0;
    background-color: #ffffff;
}
/* 로그인 화면: 세로 스크롤·오버스크롤로 하단 흰 띠가 딸려 올라오지 않게 잠금 */
html.mealog-landing-login {
    overflow: hidden !important;
    overscroll-behavior: none;
    background-color: var(--green-deep, #2d9f74);
    height: 100%;
}
html.mealog-landing-login body {
    overflow: hidden !important;
    overscroll-behavior: none;
    background-color: var(--green-deep, #2d9f74) !important;
    height: 100%;
    max-height: 100%;
}
html.mealog-landing-login #landingPage {
    height: 100dvh;
    height: 100svh;
    max-height: 100dvh;
    max-height: 100svh;
    overflow: hidden;
    overscroll-behavior: none;
    background: var(--green-deep, #2d9f74);
}
/* 모먼트 화면2: 자연 스크롤. 갤러리 화면2는 #galleryPostsInsertPoint `gap`으로 게시물 간격(카드 mb 제거). */
html:has(#galleryView:not(.hidden) #galleryContainer.moment-feed-layout-v2) {
    scroll-behavior: auto;
    scroll-snap-type: none;
    scroll-padding-top: calc(var(--safe-top) + 3.75rem);
}
#galleryView:not(.hidden) #galleryContainer.moment-feed-layout-v2 .instagram-post[data-moment-card-layout="2"] {
    box-sizing: border-box;
    flex-shrink: 0;
    overflow: visible;
    min-height: 0;
    scroll-snap-align: none;
    scroll-snap-stop: normal;
    /* 사진+본문 카드 높이 과소추정 완화 (캡션 지연/점프 방지) */
    content-visibility: auto;
    contain-intrinsic-size: auto 720px;
}
/* 시안 skip-dock: 인플로 캡션은 절대 접지 않음 (스크롤 전 본문 미표시 방지) */
#galleryContainer.moment-feed-layout-v2
    .moment-feed-v2-scope[data-moment-v2-skip-dock='1']
    [data-moment-v2-caption].mv2-cap-inflow-hidden {
    max-height: none !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 14px 16px 14px !important;
    border: 0;
    overflow: visible !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    flex: 0 0 auto !important;
}
body {
    width: 100%;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif; 
    background-color: var(--app-page-bg); 
    color: #1e293b; 
    overflow-x: clip; 
    padding-top: var(--safe-top); 
    padding-bottom: calc(80px + var(--safe-bottom)); 
}
/* 메인 앱: body·#mainApp 캔버스는 본문색. 웹 html 바깥은 ink 프레임 유지 */
html:has(#mainApp:not(.hidden)):not(.platform-web) {
    background-color: var(--app-page-bg);
}
html.platform-web:has(#mainApp:not(.hidden)) {
    background-color: var(--line);
}
body:has(#mainApp:not(.hidden)) {
    background-color: var(--app-page-bg) !important;
}
body:has(#mainApp:not(.hidden)) #mainApp {
    background-color: var(--app-page-bg);
}
/* 밀톡·피드: 입력창 아래·네비 뒤 연회색을 대화 영역색과 동일하게 — 상단/타이틀은 그라데이션으로 유지 */
body:has(#boardListView:not(.hidden) #boardFeedPanel:not(.hidden)) {
    background-color: var(--board-feed-bg);
    background-image: none;
}
html:has(#boardListView:not(.hidden) #boardFeedPanel:not(.hidden)):not(.platform-web) {
    background-color: var(--board-feed-bg);
}
html.platform-web:has(#boardListView:not(.hidden) #boardFeedPanel:not(.hidden)) {
    background-color: var(--line);
}
body:has(#boardListView:not(.hidden) #boardFeedPanel:not(.hidden)) #navigationBarOverlay {
    background-color: var(--board-feed-bg) !important;
}
/* 메인 앱: 시스템 제스처(safe-bottom) 오버레이만 본문색 — 앱 네비 슬롯은 채우지 않음 */
body:has(#mainApp:not(.hidden)) #navigationBarOverlay {
    background-color: var(--app-page-bg) !important;
}
/*
 * 앱 전체 키보드(텍스트 포커스) 시:
 * - 하단 네비·트래커만 숨김 (입력 공간)
 * - 상태줄·홈 인디케이터 오버레이·safe-area 패딩은 유지 (침범 방지)
 * - 메인 헤더는 기본 숨김, 라운지/글쓰기/상세/마이는 예외로 유지
 * 푸시 설정 스위치(.push-pref-toggle)는 제외
 */
body:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) .bottom-nav,
body:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) #trackerSection {
    display: none !important;
}
body:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) #statusBarOverlay,
body:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) #navigationBarOverlay {
    display: block !important;
}
body:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) #mainAppHeader {
    display: none !important;
}
/* 라운지·게시판 글쓰기·상세·마이: 헤더 유지 (서브탭/타이틀이 상태줄로 올라가지 않게) */
body:has(#boardListView:not(.hidden) input:not(.push-pref-toggle):focus, #boardListView:not(.hidden) textarea:focus, #boardListView:not(.hidden) [contenteditable="true"]:focus) #mainAppHeader,
body:has(#boardWriteView:not(.hidden) input:focus, #boardWriteView:not(.hidden) textarea:focus, #boardWriteView:not(.hidden) [contenteditable="true"]:focus) #mainAppHeader,
body:has(#boardDetailView:not(.hidden) input:focus, #boardDetailView:not(.hidden) textarea:focus) #mainAppHeader,
body:has(#settingsView:not(.hidden) input:not(.push-pref-toggle):focus, #settingsView:not(.hidden) textarea:focus) #mainAppHeader {
    display: block !important;
}
/* 밀로그 검색창 포커스·확장 시: 헤더·트래커·상태바·네비 유지 */
body:has(#searchInput:focus) #mainAppHeader,
body:has(#timelineSearchPanel.expanded) #mainAppHeader,
body:has(#searchInput:focus) #trackerSection:not(.hidden),
body:has(#timelineSearchPanel.expanded) #trackerSection:not(.hidden),
body:has(#searchInput:focus) #statusBarOverlay,
body:has(#timelineSearchPanel.expanded) #statusBarOverlay {
    display: block !important;
}
body:has(#searchInput:focus) .bottom-nav,
body:has(#timelineSearchPanel.expanded) .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}
body:has(#searchInput:focus) #navigationBarOverlay,
body:has(#timelineSearchPanel.expanded) #navigationBarOverlay {
    display: block !important;
}
/*
 * 포커스/IME: 네비 슬롯·gesture inset을 body에 남기지 않음
 * Capacitor body resize 시 레이아웃이 이미 키보드를 제외하므로
 * padding-bottom에 gesture(또는 예전 env)를 더하면 키보드 위 빈 띠가 됨
 */
body:not(.entry-modal-open):has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus) {
    padding-top: var(--safe-top) !important;
    padding-bottom: 0 !important;
}
/*
 * overlay 웹 루트 VV 시프트: html/body를 visualViewport 박스에 맞춤
 * (JS 인라인 top/height + transform — fixed 자손이 같은 프레임을 씀)
 */
html.ime-root-shifted,
html.ime-root-shifted body.ime-root-shifted {
    min-height: 0 !important;
    max-height: 100% !important;
}
html.ime-root-shifted body.ime-root-shifted {
    margin-left: auto !important;
    margin-right: auto !important;
}
/*
 * IME 열림(body.ime-open): 키보드 위 빈 띠 제거
 * - #navigationBarOverlay(nav-slot) 숨김
 * - padding-bottom: 0 (fixed bottom은 루트 시프트/resize로 이미 키보드 상단)
 * - keyboard-closed 복원 규칙이 IME 중 이기지 않도록 :not(.ime-open) 한정
 */
body.ime-open #navigationBarOverlay {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    pointer-events: none !important;
}
body.ime-open:not(.entry-modal-open) {
    padding-top: var(--safe-top) !important;
    padding-bottom: 0 !important;
}
body.ime-open .bottom-nav,
body.ime-open #trackerSection {
    display: none !important;
}
body.ime-open #boardWriteView {
    padding-bottom: 1rem !important;
}
/* 식사 기록 모달 열림: 입력 포커스로 body padding·배경 chrome이 튀지 않도록 전역 규칙 예외 */
body.entry-modal-open:has(#entryModal:not(.hidden) input:focus, #entryModal:not(.hidden) textarea:focus) {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}
body.entry-modal-open:has(#entryModal:not(.hidden) input:focus, #entryModal:not(.hidden) textarea:focus) #mainAppHeader,
body.entry-modal-open:has(#entryModal:not(.hidden) input:focus, #entryModal:not(.hidden) textarea:focus) #statusBarOverlay,
body.entry-modal-open:has(#entryModal:not(.hidden) input:focus, #entryModal:not(.hidden) textarea:focus) #trackerSection:not(.hidden) {
    display: block !important;
}
/* 글쓰기: 키보드 중 CTA 스크롤 여유 (nav-slot/gesture 제외 — resize 시 이중 여백 방지) */
body:has(#boardWriteContent:focus) #boardWriteView {
    padding-bottom: 1rem !important;
}
/* iOS Safari: 입력 텍스트가 바로 안 보이는 버그 수정 (GPU compositing으로 리페인트 강제) */
input, textarea, [contenteditable="true"] {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
/*
 * 키보드 닫힘: UI 복원
 * - IME 중(body.ime-open)에는 적용하지 않음
 * - 텍스트 입력 포커스 중에도 적용하지 않음
 *   (네이티브: 포커스~Keyboard 이벤트 사이 keyboard-closed가 이겨
 *    하단 네비 높이(~80px) 빈 띠가 키보드 위에 남던 원인)
 */
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) #navigationBarOverlay,
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) #mainAppHeader,
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) #statusBarOverlay {
    display: block !important;
}
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) #trackerSection:not(.hidden) {
    display: block !important;
}
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) {
    padding-top: var(--safe-top) !important;
    padding-bottom: calc(80px + var(--safe-bottom)) !important;
}
body.keyboard-closed:not(.ime-open):not(:has(input:not(.push-pref-toggle):focus, textarea:focus, [contenteditable="true"]:focus)) #boardWriteView {
    padding-bottom: calc(80px + var(--safe-bottom)) !important;
}
/* =========================
   UI Hierarchy (Main Screen)
   main > sub > sub1 > content
   ========================= */
.ui-section-label {
    font-size: 0.75rem;          /* 12px (text-xs) */
    font-weight: 900;            /* font-black */
    color: #64748b;              /* slate-500 */
    text-transform: uppercase;
    letter-spacing: 0.12em;      /* tracking-widest 느낌 */
}
.ui-section-action {
    font-size: 0.75rem;
    font-weight: 700;
    color: #475569;              /* slate-600 */
}
.ui-kpi-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;      /* tracking-tighter 대신 일정한 리듬 */
    opacity: 0.75;
}
.ui-kpi-label--inverse {
    color: #fff;
}
/* 분석 카드 내 식사기록/간식기록 라벨·숫자 흰색 */
#dashboardView .sticker-badge .ui-kpi-label--inverse,
#dashboardView .sticker-badge #insightStats,
#dashboardView .sticker-badge #snackStats {
    color: #fff;
}
#dashboardView .sticker-badge #insightStats span,
#dashboardView .sticker-badge #snackStats span {
    color: #fff;
    opacity: 1;
}
#dashboardView .sticker-badge #insightStats .opacity-60,
#dashboardView .sticker-badge #snackStats .opacity-60 {
    opacity: 0.85;
}
/* 시안 v2 참견 KPI: 흰 칩 위 잉크 텍스트 */
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge .ui-kpi-label,
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #insightStats,
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #snackStats,
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #insightStats span,
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #snackStats span {
    color: var(--ink, #241f1c);
}
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #insightStats .opacity-60,
#dashboardView.dashboard-view-v2 .dashboard-comment-zone .sticker-badge #snackStats .opacity-60 {
    opacity: 0.6;
    color: var(--muted, #7a7268);
}
.ui-card-pad-lg { padding: 0.75rem 1rem; }     /* py-3 px-4 */
.ui-card-pad { padding: 0.625rem 1rem; }       /* py-2.5 px-4 */
.ui-card-pad-compact { padding: 0.5rem 1rem; } /* py-2 px-4 */
.ui-card-pad-chip { padding: 0.375rem 1rem; }  /* py-1.5 px-4 */
.ui-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem; /* mb-2 */
}
/* 밀당 분석 카드 전용: 식사/간식 분석 섹션 안에서만 적용 (다른 컨테이너 영향 없음) */
#mainAnalysisSection .analytics-chart-wrap,
#snackAnalysisSection .analytics-chart-wrap {
    padding-left: 2px;
    padding-right: 2px;
}
#mainAnalysisSection .analytics-card-head,
#snackAnalysisSection .analytics-card-head {
    padding-left: 12px;
    padding-right: 22px;
}
#healthAnalysisSection .analytics-card-head {
    padding-left: 12px;
    padding-right: 22px;
}
.health-vitals-chart-wrap {
    height: auto;
    margin-top: 8px;
    padding-left: 2px;
    padding-right: 2px;
}
/* 라인·캔들 보기 스위치 — 카드 머리, 기간 증감 아래 */
.health-vitals-view-bar {
    display: flex;
    justify-content: flex-end;
}
/* style.css 가 tailwind 뒤에 실려서 .hidden 만으로는 안 눌린다 */
.health-vitals-view-bar.hidden {
    display: none;
}
.health-vitals-chart-scroll {
    height: 220px;
    overflow-x: hidden;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.health-vitals-chart-scroll--scrollable {
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.45) transparent;
}
.health-vitals-chart-scroll--scrollable::-webkit-scrollbar {
    height: 3px;
}
.health-vitals-chart-scroll--scrollable::-webkit-scrollbar-track {
    background: transparent;
}
.health-vitals-chart-scroll--scrollable::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.45);
    border-radius: 999px;
}
.health-vitals-chart-inner {
    position: relative;
    height: 100%;
    min-width: 100%;
}
.health-vitals-chart-inner canvas {
    display: block;
    position: relative;
    z-index: 1;
    width: 100% !important;
    height: 100% !important;
}
.health-vitals-chart-wrap--interactive .health-vitals-chart-inner canvas {
    cursor: pointer;
}
.health-vitals-bubble {
    position: absolute;
    z-index: 10;
    top: 4px;
    max-width: min(220px, calc(100% - 16px));
    padding: 0.5rem 0.625rem;
    border-radius: 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.28);
    color: #f8fafc;
    pointer-events: none;
    transform: translateX(-50%);
}
.health-vitals-bubble::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: #1e293b;
}
.health-vitals-bubble--single {
    max-width: min(240px, calc(100% - 16px));
}
.health-vitals-bubble__single-body {
    line-height: 1.35;
    white-space: nowrap;
}
.health-vitals-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    margin: 0;
    padding: 0 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: #94a3b8;
    pointer-events: none;
}
.health-vitals-chart-empty.hidden {
    display: none;
}
.health-vitals-chart-wrap--empty {
    margin-top: 0;
}
.health-vitals-chart-wrap--empty .health-vitals-chart-scroll {
    height: 0;
    pointer-events: none;
}
.health-vitals-bubble__title {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}
.health-vitals-bubble__list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.health-vitals-bubble__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 0.5rem;
    font-size: 0.75rem;
    line-height: 1.35;
    padding: 0.125rem 0;
    white-space: nowrap;
}
.health-vitals-bubble__row + .health-vitals-bubble__row {
    border-top: 1px solid #334155;
    margin-top: 0.125rem;
    padding-top: 0.25rem;
}
.health-vitals-bubble__row--solo {
    justify-content: center;
}
.health-vitals-bubble__row--solo .health-vitals-bubble__value {
    text-align: center;
}
.health-vitals-bubble__label {
    color: #94a3b8;
    font-weight: 600;
    flex-shrink: 0;
}
.health-vitals-bubble__value {
    color: #f8fafc;
    font-weight: 700;
    text-align: right;
}

