/* ── reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
    background: var(--bg);
    color: var(--t1);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

/* ── 헤더 ── */
header {
    flex-shrink: 0;
    background: var(--header);
    height: 52px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.hd-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.hd-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.hd-brand { display: flex; flex-direction: column; min-width: 0; }
.hd-title { font-size: 14px; font-weight: 900; line-height: 1.25; letter-spacing: -0.3px; }
.hd-title .accent { color: var(--accent); }
.hd-title .plain  { color: rgba(255,255,255,.88); }
.hd-sub { font-size: 10px; color: rgba(255,255,255,.38); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; letter-spacing: 0; }

.hd-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.count-tag { background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 2px; letter-spacing: 0.1px; }
.visit-tag { background: #166534; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 2px; display: none; }

/* ── 필터바 ── */
.filter-bar {
    flex-shrink: 0;
    background: var(--white);
    border-bottom: 1px solid var(--bd);
    display: flex;
    align-items: stretch;
    height: 46px;
}

/* 뒤로가기 버튼 (last.html 전용, 공통 파일에 포함) */
.fb-left { display: flex; align-items: center; padding: 0 10px; border-right: 1px solid var(--bd); flex-shrink: 0; }
.back-btn {
    display: inline-flex; align-items: center;
    height: 28px; padding: 0 10px;
    border: 1px solid var(--bd); border-radius: 2px;
    background: none; color: var(--accent);
    font-family: inherit; font-size: 12px; font-weight: 700;
    text-decoration: none; white-space: nowrap;
    transition: background 120ms, border-color 120ms;
}
.back-btn:hover { background: var(--accent-w); border-color: var(--accent); }

.search-wrap {
    flex: 1; min-width: 0;
    display: flex; gap: 5px; align-items: center;
    padding: 0 10px;
    border-right: 1px solid var(--bd);
}

.search-input {
    flex: 1; min-width: 0;
    height: 28px; padding: 0 9px;
    border: 1px solid var(--bd);
    border-radius: 2px;
    background: var(--in);
    color: var(--t1);
    font-family: inherit; font-size: 12px;
    outline: none;
    transition: border-color 120ms;
}
.search-input::placeholder { color: var(--t3); }
.search-input:focus { border-color: var(--accent); background: var(--white); }

.search-btn {
    height: 28px; padding: 0 11px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 2px;
    font-family: inherit; font-size: 12px; font-weight: 700;
    cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: background 120ms;
}
.search-btn:hover  { background: var(--accent-d); }
.search-btn:active { opacity: .86; }

.fp-row { display: flex; flex-shrink: 0; }
.fp {
    height: 46px; padding: 0 13px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--t3);
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: color 120ms, border-color 120ms;
}
.fp:hover { color: var(--t2); }
.fp.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

/* ── 지도 ── */
#map { width: 100%; flex: 1; min-height: 0; position: relative; }

/* ── 모바일: 필터바 2행 ── */
@media (max-width: 539px) {
    .filter-bar { flex-wrap: wrap; height: auto; }
    .fb-left { height: 46px; border-right: 1px solid var(--bd); border-bottom: 1px solid var(--bd); }
    .search-wrap { width: 100%; border-right: none; border-bottom: 1px solid var(--bd); height: 46px; }
    .search-input { font-size: 16px; }
    .fp-row { width: 100%; }
    .fp { flex: 1; height: 42px; padding: 0; }
    .visit-btn { height: 48px; font-size: 14px; }
    .yt-btn { height: 48px; font-size: 14px; }
    .card-body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* ── FAB ── */
.fab-group { position: absolute; bottom: 20px; right: 14px; z-index: 150; display: flex; flex-direction: column; gap: 8px; }
.fab {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--header);
    box-shadow: 0 2px 8px rgba(0,0,0,.28);
    font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; line-height: 1;
    transition: transform 100ms, background 120ms;
}
.fab:active { transform: scale(.88); }
.fab.on { background: #166534; }

/* ── 오버레이 ── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.46); z-index: 200; align-items: flex-end; justify-content: center; }
@media (min-width: 540px) { .overlay { align-items: center; } }
.overlay.show { display: flex; }

/* ── 팝업 카드 ── */
.card {
    background: var(--white);
    width: 100%; max-width: 440px;
    border-radius: 10px 10px 0 0;
    max-height: 88dvh;
    display: flex; flex-direction: column; overflow: hidden; position: relative;
    box-shadow: 0 -2px 14px rgba(0,0,0,.14);
}
.overlay.show .card { animation: slideUp 200ms ease; }
@keyframes slideUp {
    from { transform: translateY(14px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@media (min-width: 540px) {
    .card { border-radius: 8px; max-height: 85dvh; width: calc(100% - 40px); }
    @keyframes slideUp {
        from { transform: scale(.97) translateY(5px); opacity: 0; }
        to   { transform: scale(1)   translateY(0);   opacity: 1; }
    }
}

.drag-handle { width: 30px; height: 3px; background: var(--bd); border-radius: 2px; position: absolute; top: 9px; left: 50%; transform: translateX(-50%); z-index: 5; }
@media (min-width: 540px) { .drag-handle { display: none; } }

.card-close {
    position: absolute; top: 9px; right: 9px;
    width: 26px; height: 26px;
    background: rgba(0,0,0,.30); border: none;
    color: #fff; font-size: 11px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 5;
    transition: background 120ms;
}
.card-close:hover { background: rgba(0,0,0,.50); }

/* ── 이미지 ── */
.card-img-wrap { position: relative; flex-shrink: 0; }
.card-thumb { width: 100%; height: 196px; object-fit: cover; display: block; }
@media (max-width: 539px) { .card-thumb { height: 168px; } }

.card-thumb-empty {
    width: 100%; height: 76px;
    background: var(--accent-w);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
}

.card-img-caption {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 30px 14px 12px;
    background: linear-gradient(to top, rgba(0,0,0,.70) 0%, transparent 100%);
}
.card-img-wrap.no-img .card-img-caption { display: none; }

.img-chip {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 2px;
    margin-bottom: 5px; width: fit-content;
    letter-spacing: 0.2px;
}
.img-name { font-size: 18px; font-weight: 900; color: #fff; letter-spacing: -0.4px; line-height: 1.25; }

/* ── 카드 바디 ── */
.card-body { padding: 13px 15px 22px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.fb-chip { display: none; }
.cat-chip {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--accent-w); color: var(--accent);
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 2px; margin-bottom: 6px;
    letter-spacing: 0.2px;
}
.fb-name { display: none; }
.place-name { font-size: 18px; font-weight: 900; letter-spacing: -0.4px; line-height: 1.25; margin-bottom: 9px; }

.episode-label { font-size: 12px; color: var(--t2); line-height: 1.65; margin-bottom: 7px; }
.menu-label { font-size: 13px; font-weight: 700; color: var(--t1); margin-bottom: 6px; }
.addr-label { font-size: 12px; color: var(--t3); line-height: 1.65; margin-bottom: 9px; }
.dist-label { font-size: 12px; font-weight: 700; color: #1d4ed8; margin-bottom: 9px; display: none; }
@media (prefers-color-scheme: dark) { .dist-label { color: #93c5fd; } }

.divider { border: none; border-top: 1px solid var(--bd); margin: 11px 0; }

.visit-btn {
    width: 100%; height: 38px;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    border: 1px solid var(--bd); border-radius: 3px; background: none;
    color: var(--t2); font-family: inherit; font-size: 13px; font-weight: 700;
    cursor: pointer; margin-bottom: 7px;
    transition: border-color 120ms, color 120ms, background 120ms;
}
.visit-btn:hover { border-color: var(--t2); color: var(--t1); }
.visit-btn.visited { border-color: #16a34a; color: #16a34a; background: #f0fdf4; }
@media (prefers-color-scheme: dark) { .visit-btn.visited { background: #052e16; border-color: #16a34a; color: #4ade80; } }
.visit-count { font-size: 11px; color: var(--t3); text-align: center; margin-bottom: 9px; }

.yt-btn {
    height: 42px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--accent); color: #fff;
    text-decoration: none; border-radius: 3px;
    font-size: 13px; font-weight: 700; letter-spacing: -0.1px;
    transition: background 120ms;
}
.yt-btn:hover  { background: var(--accent-d); }
.yt-btn:active { opacity: .9; }

/* ── 토스트 ── */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(12px);
    background: var(--t1); color: var(--bg);
    font-size: 13px; font-weight: 500;
    padding: 10px 18px; border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
    opacity: 0; pointer-events: none; z-index: 500;
    transition: opacity 180ms, transform 180ms;
    white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 풋터 ── */
footer {
    flex-shrink: 0;
    background: var(--white);
    border-top: 1px solid var(--bd);
    padding: 12px 16px;
    text-align: center;
}
.footer-ch {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--accent); font-size: 13px; font-weight: 700;
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 1px; margin-bottom: 10px;
    transition: opacity 150ms;
}
.footer-ch:hover { opacity: .72; }
.footer-note { font-size: 11px; color: var(--t3); line-height: 1.9; }
.footer-note a { color: var(--t2); text-decoration: underline; text-underline-offset: 2px; }
.footer-note a:hover { color: var(--accent); }
.footer-toggle {
    background: none; border: none; cursor: pointer;
    font-size: 11px; color: var(--t3); font-family: inherit;
    padding: 0; display: inline-flex; align-items: center; gap: 2px;
    transition: color 120ms;
}
.footer-toggle:hover { color: var(--t2); }
.footer-detail {
    overflow: hidden; max-height: 0;
    transition: max-height 220ms ease;
}
.footer-detail.open { max-height: 40px; }
