/* ===== CSS VARIABLES ===== */
:root {
    --primary:          #2563EB;
    --primary-hover:    #1D4ED8;
    --primary-light:    #EFF6FF;
    --text-primary:     #111827;
    --text-secondary:   #6B7280;
    --text-muted:       #9CA3AF;
    --text-link:        #2563EB;
    --border:           #E5E7EB;
    --border-focus:     #2563EB;
    --bg:               #F9FAFB;
    --bg-card:          #FFFFFF;
    --bg-tag:           #EFF6FF;
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card-hover:0 6px 20px rgba(37,99,235,0.12);
    --radius:           10px;
    --radius-sm:        6px;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Binggrae', 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== HEADER ===== */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.header-inner {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 64px;
}
.logo {
    font-family: 'Binggrae', 'Noto Sans KR', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 1px;
    margin-right: 8px;
}
.logo-text-mobile { display: none; }

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    flex: 1;
    gap: 6px;
    align-items: center;
}
.search-input-wrap {
    position: relative;
    flex: 1;
}
.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}
.search-input {
    width: 100%;
    height: 42px;
    padding: 0 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    padding: 2px;
    line-height: 1;
}
.search-clear:hover { color: var(--text-secondary); }

/* ===== 검색 기록 드롭다운 ===== */
.search-history {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid var(--border-focus);
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    z-index: 200;
    overflow: hidden;
}
.sh-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background .15s;
}
.sh-item:hover, .sh-item.sh-active { background: var(--primary-light); color: var(--primary); }
.sh-item svg { flex-shrink: 0; color: var(--text-muted); }
.sh-kw  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-ago { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.btn-icon { display: none; }

.search-btn {
    height: 42px;
    padding: 0 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s, transform .1s;
    white-space: nowrap;
    margin-right: 4px;
}
.search-btn:hover  { background: var(--primary-hover); }
.search-btn:active { transform: scale(.98); }

/* ===== MAIN ===== */
.main {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ===== RESULT META ===== */
.result-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.result-count { font-size: 13px; color: var(--text-secondary); }
.result-count strong { color: var(--primary); font-weight: 700; }
.meta-divider { width: 1px; height: 12px; background: var(--border); }

/* ===== SORT TABS ===== */
.sort-tabs { display: flex; gap: 4px; }
.sort-tab {
    padding: 4px 12px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-secondary);
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
}
.sort-tab.active, .sort-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.shop-nav-btn {
    padding: 4px 10px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all .2s;
    white-space: nowrap;
}
.shop-nav-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245,158,11,.08);
}

/* ===== REFINE SEARCH ===== */
.refine-wrap {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}
.refine-input {
    height: 32px;
    padding: 0 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    outline: none;
    width: 160px;
    transition: border-color .2s;
}
.refine-input:focus { border-color: var(--border-focus); }
.refine-input::placeholder { color: var(--text-muted); }
.refine-btn {
    height: 32px;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all .2s;
}
.refine-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ===== ACTIVE FILTERS ===== */
.active-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tag);
    border: 1px solid #BFDBFE;
    border-radius: 20px;
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
}
.filter-tag-remove {
    display: flex;
    align-items: center;
    color: var(--primary);
    text-decoration: none;
}

/* ===== RESULT CARDS ===== */
.result-list { display: flex; flex-direction: column; gap: 10px; }

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    cursor: pointer;
    transition: box-shadow .2s, border-color .2s, transform .2s;
    animation: fadeInUp .3s ease both;
}
.result-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: #BFDBFE;
    transform: translateY(-1px);
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.5;
}
.card-div1 {
    display: inline-block;
    color: #F97316;
    font-weight: 700;
    font-size: 13px;
    margin-right: 4px;
}
.card-title mark, .card-body mark {
    background: #F59E0B;
    color: #111;
    border-radius: 3px;
    padding: 0 3px;
    font-weight: 700;
}
@media (prefers-color-scheme: dark) {
    .card-title mark, .card-body mark {
        background: #F59E0B;
        color: #000;
    }
}
.card-body {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 10px;
}
.card-body-clamp {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-more {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-top: 4px;
}
.card-more:hover { text-decoration: underline; }
.card-footer {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #F3F4F6;
}
.card-meta-item { display: flex; align-items: center; gap: 4px; }

/* ===== 업소 정보 ===== */
.related-loading {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: .55;
    padding: 10px 0 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.related-loading-bar {
    width: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}
.related-loading-bar::after {
    content: '';
    display: block;
    height: 100%;
    width: 40%;
    background: var(--accent);
    border-radius: 2px;
    animation: loadbar 1.2s ease-in-out infinite;
}
@keyframes loadbar {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

.shop-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.shop-results-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.shop-more-btn {
    margin-left: auto;
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0;
}
.shop-more-btn:hover { text-decoration: underline; }
.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-item {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.shop-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.shop-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.shop-name a {
    color: var(--text-primary);
    text-decoration: none;
}
.shop-name a:hover { text-decoration: underline; }
.shop-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 20px;
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}
.shop-item-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ===== EMPTY / INITIAL STATE ===== */
.empty-state {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-icon { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .3; }
.empty-state p { font-size: 14px; }

.initial-state { text-align: center; padding: 80px 20px; }
.initial-state .big-icon { width: 56px; height: 56px; margin: 0 auto 20px; color: #BFDBFE; }
.initial-state h2 { font-size: 18px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.initial-state p  { font-size: 14px; color: var(--text-muted); }

/* ===== 잘못된 페이지 ===== */
.invalid-page-wrap {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.invalid-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: #BFDBFE;
}
.invalid-page-wrap h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.invalid-page-wrap p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
}
.invalid-btns {
    display: flex;
    justify-content: center;
    gap: 8px;
}

/* ===== PAGINATION ===== */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 28px; }
.page-btn {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all .2s;
    padding: 0 10px;
}
.page-btn:hover, .page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.page-btn-arrow {
    font-weight: 600;
    color: var(--primary);
    border-color: var(--primary);
}
.page-btn-disabled {
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
    cursor: default;
    pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .header-inner { height: 52px; gap: 6px; }
    .logo { font-size: 12px; line-height: 1.2; margin-right: 4px; white-space: normal; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; text-align: center; }
    .logo-text-pc     { display: none; }
    .logo-text-mobile { display: inline; }
    .main { padding: 16px 14px 50px; }
    .refine-wrap { width: 100%; margin-left: 0; }
    .refine-input { flex: 1; width: auto; }
    .card-footer { gap: 12px; flex-wrap: wrap; }

    .search-input { height: 36px; font-size: 13px; }

    .btn-text { display: none; }
    .btn-icon { display: block; }

    .search-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        margin-right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    .btn-write-review {
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
}



/* ===== 작성일 오른쪽 정렬 ===== */
.card-meta-date {
    margin-left: auto;
}

/* ===== 후기 등록/수정 폼 ===== */
.review-form-wrap {
    max-width: 700px;
    margin: 12px auto;
    padding: 0 16px 60px;
}
.review-form-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary);
}
.review-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.review-table th {
    width: 90px;
    background: #f4f6fb;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.review-table td {
    padding: 10px 12px;
    border: 1px solid var(--border);
    vertical-align: middle;
}
.review-th-content { vertical-align: top !important; padding-top: 14px !important; }
.review-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: border-color .15s;
}
input[type="password"].review-input {
    color: var(--text-primary);
    -webkit-text-fill-color: var(--text-primary);
}
.review-input:focus { border-color: var(--border-focus); }
.review-input-pw { max-width: 200px; }
.review-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.review-textarea {
    width: 100%;
    min-height: 180px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color .15s;
    line-height: 1.7;
}
.review-textarea:focus { border-color: var(--border-focus); }
.review-textarea-full {
    min-height: 340px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border-top: none;
    padding: 14px;
}
.review-textarea-full:focus { border-color: var(--border); box-shadow: none; }
.review-btn-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.btn-review-save {
    padding: 8px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s;
}
.btn-review-save:hover { background: var(--primary-hover); }
.btn-review-edit {
    height: 42px;
    padding: 0 20px;
    background: #F97316;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn-review-edit:hover  { background: #EA6C00; }
.btn-review-edit:active { transform: scale(.98); }
.btn-review-delete {
    height: 42px;
    padding: 0 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.btn-review-delete:hover  { background: var(--primary-hover); }
.btn-review-delete:active { transform: scale(.98); }
.btn-review-cancel {
    padding: 8px 24px;
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}
.btn-review-cancel:hover { background: var(--bg); }

/* 상세 */
.review-table-detail td { font-size: 14px; color: var(--text-primary); }
.review-detail-content { white-space: pre-wrap; line-height: 1.8; min-height: 120px; vertical-align: top; }

/* 비밀번호 팝업 */
.pw-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 999;
}
.pw-modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 28px 32px;
    min-width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.pw-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
}
.pw-error {
    font-size: 12px;
    color: #DC2626;
    text-align: center;
}
.pw-modal-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 4px;
}

/* 후기등록 버튼 (헤더) */
.btn-write-review {
    flex-shrink: 0;
    height: 42px;
    padding: 0 18px;
    background: #F97316;
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background .2s, transform .1s;
}
.btn-write-review:hover  { background: #EA6C00; color: #fff; }
.btn-write-review:active { transform: scale(.98); }

/* 카드 클릭 커서 */
.result-card { cursor: pointer; }

/* ===== 상세 화면 ===== */
.detail-wrap {
    width: 100%;
}
.detail-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 4px 6px;
    margin-bottom: 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.detail-back-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}
.detail-card {
    cursor: default;
    padding: 24px 28px;
}
.detail-card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
    border-color: var(--border);
}
.detail-title {
    font-size: 17px;
    margin-bottom: 10px;
}
.detail-divider {
    border-top: 1px solid #F3F4F6;
    margin: 14px 0;
}
.detail-content {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}
.detail-btn-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.detail-card .card-footer {
    font-size: 14px;
}
.detail-card .card-meta-item svg {
    width: 14px;
    height: 14px;
}

/* ===== 인기 검색어 ===== */
.popular-wrap {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    position: relative;
}
.popular-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    padding-top: 8px;
    flex-shrink: 0;
}
.popular-dropdown {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: visible;
    min-width: 0;
    position: relative;
    z-index: 50;
}
.popular-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}
.popular-header:hover { background: var(--primary-light); }
.popular-preview {
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.popular-list {
    list-style: none;
    border-top: 1px solid var(--border);
    padding: 4px 0;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    z-index: 50;
}
.popular-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 6px 12px;
    transition: background .15s;
}
.popular-item:hover { background: var(--primary-light); }
.popular-rank {
    min-width: 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}
.popular-rank.rank-hot { color: var(--primary); }
.popular-kw { font-size: 13px; color: var(--text-primary); }
.popular-item:hover .popular-kw { color: var(--primary); }
