/* ============================================================
 * 명당 리뉴얼 — 태블릿 · PC 틀 (시안에는 PC 가 없어 모바일 시안을 넓힌 것)
 *  - 화면 폭: 모바일 < 768 (시안 그대로) · 태블릿 768 이상
 *  - [2026-11-27] PC(≥1024) 틀은 꺼 둠 — 넓은 화면도 태블릿 틀(가운데 750 · 하단 탭바). 아래 PC 블록 · md2_*.css 의 PC 블록 · md2_ui.js 의 100000px 을 1024px 로 되돌리면 다시 켜진다
 *  - 화면 css(md2_home · md2_list …) 다음에 불러온다. md2_tokens.css 가 먼저 있어야 한다
 *  - body.md2 (또는 body.md2-shell) 아래만 — 기존 화면은 그대로
 *
 *  PC(≥1024)
 *   · 하단 탭바 → 위쪽 고정 메뉴 .md2-pcnav (bottom_navigation.php 가 v2 탭바와 함께 찍고 body 에 .md2-has-pcnav 를 붙인다)
 *     → 있으면 --md2-top = 64px · --md2-bottom = 0 · 하단 탭바 숨김
 *   · 콘텐츠 폭: 기본 750 (common.css --max-width 그대로) · body.md2-wide = 1120 + 좌우 여백 · body.md2-read = 720
 *   · 바탕은 흰색 한 장 (바깥 회색 · 틀 그림자 없음)
 *   · .md2-sheet(바텀시트) → 가운데 대화창 (태블릿부터) · .md2-over(풀스크린) → 오른쪽 패널 · .md2-over.up → 가운데 큰 창
 *   · .md2-rail(가로 레일) → 격자 (--md2-cols)
 * ============================================================ */
/* 상단 메뉴는 PC 에서만 — 이 css 가 없는 화면에서는 인라인 display:none 그대로 숨김 */
.md2-pcnav { display: none; }

/* ── 태블릿 이상: 바텀시트 → 가운데 대화창 ─────────────────────── */
@media (min-width: 768px) {
    .md2-layer > .md2-sheet {
        top: 50%; left: 50%; right: auto; bottom: auto; margin: 0;
        width: min(var(--md2-dialog-w), calc(100% - 48px)); max-width: none; max-height: min(760px, calc(100% - 64px));
        border-radius: var(--r-sheet); box-shadow: var(--sh-panel);
        opacity: 0; transform: translate(-50%, -50%) scale(.96);
        transition: transform var(--md-dialog-dur) var(--md-ease), opacity var(--md-dialog-dur) var(--md-ease);
    }
    .md2-layer.is-open > .md2-sheet { opacity: 1; transform: translate(-50%, -50%); }
    .md2-layer > .md2-sheet.tall { height: min(760px, calc(100% - 64px)); }
    .md2-layer > .md2-sheet.wide { width: min(640px, calc(100% - 48px)); }
    .md2-sheet-grab { display: none; }
    .md2-sheet-x { display: flex; }
    .md2-sheet-head { padding-top: 18px; }
    .md2-sheet-foot { padding-bottom: 16px; border-radius: 0 0 var(--r-sheet) var(--r-sheet); }

    /* 기존 Bootstrap 바텀시트(.modal.bottom-sheet)도 대화창으로 — 로그인 시트는 모양이 달라 폭만 줄인다 */
    :is(body.md2, body.md2-shell) .modal.bottom-sheet:not(#loginBottomSheet) .modal-dialog { align-items: center; max-width: var(--md2-dialog-w); padding: 32px 0; }
    :is(body.md2, body.md2-shell) .modal.bottom-sheet:not(#loginBottomSheet) .modal-content { border-radius: var(--r-sheet); overflow: hidden; }
    :is(body.md2, body.md2-shell) .modal.bottom-sheet.fade .modal-dialog { opacity: 0; transform: scale(.96) !important; transition: transform var(--md-dialog-dur) var(--md-ease), opacity var(--md-dialog-dur) var(--md-ease) !important; }
    :is(body.md2, body.md2-shell) .modal.bottom-sheet.show .modal-dialog { opacity: 1; transform: none !important; }
    :is(body.md2, body.md2-shell) .modal.bottom-sheet .bottom-sheet-handle { display: none; }
    :is(body.md2, body.md2-shell) #loginBottomSheet { --max-width: var(--md2-dialog-w); }
}

/* ── PC ─────────────────────────────────────────────────────────── */
@media (min-width: 100000px) { /* PC 틀 꺼 둠 — 넓은 화면도 태블릿 틀(750 · 하단 탭바). 다시 켜려면 1024px */
    body.md2, body.md2-shell { --md2-gutter: 24px; }

    /* 바탕 흰색 한 장 */
    html body.md2:not(.vr-body), html body.md2-shell { background: var(--bg); }
    /* html 이 회색이면 body(화면 높이 1장)까지만 흰색이고 그 아래가 회색으로 갈린다 — html 도 같이 */
    html:has(> body.md2:not(.vr-body)), html:has(> body.md2-shell) { background: var(--bg); }
    html body.md2 > .container, html body.md2-shell > .container { box-shadow: none; }

    /* 콘텐츠 폭 — .container 와 화면 아래 고정 줄(footer.sticky-bottom · .bottom-nav)이 함께 --max-width 를 따른다 */
    body.md2.md2-wide, body.md2-shell.md2-wide { --max-width: calc(var(--md2-pc-w) + 2 * var(--md2-gutter)); }
    body.md2.md2-read, body.md2-shell.md2-read { --max-width: var(--md2-read-w); }

    /* 상단 메뉴 */
    :is(body.md2, body.md2-shell) .md2-pcnav {
        display: block !important; position: fixed; top: 0; left: 0; right: 0; z-index: var(--md-z-nav);
        height: var(--md2-pcnav-h); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line);
        -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
        font-family: var(--sans); letter-spacing: -0.01em; color: var(--ink);
    }
    html.md2-lock .md2-pcnav { padding-right: var(--md2-sbw, 0px); }
    :is(body.md2, body.md2-shell).md2-has-pcnav { --md2-top: var(--md2-pcnav-h); --md2-bottom: 0px; padding-top: var(--md2-pcnav-h); }
    /* 모바일 기기로 넓은 화면을 볼 때 — 띠배너 아래에 상단 메뉴 */
    html.app-ticker-shown :is(body.md2, body.md2-shell).md2-has-pcnav { --md2-top: calc(var(--md2-pcnav-h) + var(--sz-48)); }
    html.app-ticker-shown .md2-pcnav { top: var(--sz-48); }
    html.app-ticker-shown :is(body.md2, body.md2-shell).md2-has-pcnav { padding-top: calc(var(--md2-pcnav-h) + var(--sz-48)) !important; }
    html :is(body.md2, body.md2-shell).md2-has-pcnav > .container { min-height: calc(100vh - var(--md2-pcnav-h)); padding-bottom: 0 !important; }
    html :is(body.md2, body.md2-shell).md2-has-pcnav nav.bottom-nav { display: none !important; }
    /* 상단 메뉴와 겹치는 화면 머리(로고 · 알림 · 검색 · 탭 제목) */
    :is(body.md2, body.md2-shell).md2-has-pcnav .md2-hide-pcnav { display: none !important; }

    .md2-pcnav-in { height: 100%; max-width: calc(var(--md2-pc-w) + 2 * var(--md2-gutter)); margin: 0 auto; padding: 0 var(--md2-gutter); display: flex; align-items: center; gap: 28px; }
    .md2-pcnav-logo { display: flex; align-items: center; flex-shrink: 0; }
    .md2-pcnav-logo img { height: 26px; width: auto; display: block; }
    .md2-pcnav-tabs { flex: 1; min-width: 0; height: 100%; display: flex; align-items: stretch; gap: 2px; }
    .md2-pcnav-tabs a {
        position: relative; display: flex; align-items: center; gap: 7px; padding: 0 14px;
        font-size: 15.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; white-space: nowrap; transition: color var(--md-select-dur);
    }
    .md2-pcnav-tabs a svg { flex-shrink: 0; }
    .md2-pcnav-tabs a.on { color: var(--ink); font-weight: 800; }
    .md2-pcnav-tabs a.on::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2.5px; border-radius: 2px; background: var(--ink); }
    .md2-pcnav-r { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
    .md2-pcnav-ic { position: relative; width: 40px; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; color: var(--ink); text-decoration: none; transition: background-color var(--md-select-dur); }
    .md2-pcnav-dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 1.5px solid #fff; box-sizing: content-box; }
    .md2-pcnav-pt { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 5px; margin-left: 6px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap; transition: border-color var(--md-select-dur); }
    .md2-pcnav-pt i { width: 24px; height: 24px; border-radius: 12px; background: var(--seal); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
    .md2-pcnav-login { height: 36px; padding: 0 16px; margin-left: 6px; border: 0; border-radius: var(--r-btn-sm); background: var(--seal); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }

    @media (hover: hover) {
        .md2-pcnav-tabs a:hover { color: var(--ink); }
        .md2-pcnav-ic:hover { background: var(--paper); }
        .md2-pcnav-pt:hover { border-color: #D5D9E0; }
        .md2-pcnav-login:hover { filter: brightness(1.1); }
    }

    /* 풀스크린 오버레이 → 오른쪽 패널 (배경 어둡게) */
    .md2-layer.is-over > .md2-backdrop { display: block; }
    .md2-layer.is-over > .md2-over:not(.up) { left: auto; width: min(var(--md2-panel-w), 100%); box-shadow: var(--sh-panel); }
    .md2-layer.is-over > .md2-over:not(.up) .md2-over-in { max-width: none; }
    .md2-layer.is-over > .md2-over.wide:not(.up) { width: min(720px, 100%); }
    .md2-over-head { padding-top: 14px; }

    /* 아래에서 올라오는 오버레이(매거진 아티클 · 결제 완료) → 가운데 큰 창 */
    .md2-layer.is-up > .md2-over.up {
        top: 24px; bottom: 24px; left: 50%; right: auto; width: min(var(--md2-read-w), calc(100% - 48px));
        border-radius: 20px; overflow: hidden; box-shadow: var(--sh-panel);
        opacity: 0; transform: translate(-50%, 40px);
        transition: transform var(--md-article-dur) var(--md-ease), opacity var(--md-dialog-dur) var(--md-ease);
    }
    .md2-layer.is-up.is-open > .md2-over.up { opacity: 1; transform: translateX(-50%); }
    /* 짧은 내용(결제 완료) — 대화창 크기 */
    .md2-layer.is-up > .md2-over.up.compact { top: 50%; bottom: auto; width: min(var(--md2-dialog-w), calc(100% - 48px)); max-height: calc(100% - 64px); border-radius: var(--r-sheet); transform: translate(-50%, calc(-50% + 24px)); }
    .md2-layer.is-up.is-open > .md2-over.up.compact { transform: translate(-50%, -50%); }

    /* 가로 레일 → 격자 (칸 수: style="--md2-cols:4") */
    .md2-rail { display: grid; grid-template-columns: repeat(var(--md2-cols, 4), minmax(0, 1fr)); gap: var(--md2-grid-gap); padding: 0 var(--md2-gutter); overflow: visible; scroll-snap-type: none; }
    .md2-rail > * { width: auto !important; min-width: 0; }

    /* 격자 · 두 줄 · 본문 + 옆 칸 */
    .md2-grid { display: grid; grid-template-columns: repeat(var(--md2-cols, 3), minmax(0, 1fr)); gap: var(--md2-grid-gap); }
    .md2-cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--md2-grid-gap); align-items: start; }
    .md2-split { display: grid; grid-template-columns: minmax(0, 1fr) var(--md2-aside-w, 360px); gap: 32px; align-items: start; }
    .md2-split-aside { position: sticky; top: calc(var(--md2-top) + 24px); }
    .md2-narrow { max-width: var(--md2-read-w); margin-left: auto; margin-right: auto; }

    .md2-pc-hide { display: none !important; }
}
/* 태블릿까지만 보이는 것 / PC 에서만 보이는 것 */
@media (max-width: 1023.98px) { .md2-pc-only { display: none !important; } }

/* 태블릿: 모바일 틀(하단 탭바 · 750 폭) 그대로, 격자만 2칸부터 */
@media (min-width: 768px) and (max-width: 1023.98px) {
    .md2-grid { display: grid; grid-template-columns: repeat(var(--md2-cols-t, 2), minmax(0, 1fr)); gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .md2-pcnav-tabs a, .md2-pcnav-ic, .md2-pcnav-pt { transition: none; }
    :is(body.md2, body.md2-shell) .modal.bottom-sheet.fade .modal-dialog { transition: none !important; }
}
