:root {
    --primary-color: #2563eb;
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --bg-white: #ffffff;
    --bg-light: #f3f4f6;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-lg: 16px;
    --radius-md: 10px;
    --z-map: 0;
    --z-ui: 10;
    --z-modal: 100;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body, html { margin: 0; padding: 0; height: 100%; width: 100%; font-family: 'Noto Sans TC', sans-serif; overflow: hidden; font-size: 16px; }

#map { position: absolute; top: 0; bottom: 0; width: 100%; z-index: var(--z-map); }

.ui-container {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    display: flex; flex-direction: column; justify-content: space-between;
    z-index: var(--z-ui);
}

/* Top Bar */
.top-bar {
    pointer-events: auto; padding: 16px 16px 0;
    display: flex; flex-direction: column; gap: 12px;
    width: 100%; max-width: 900px;
}

.search-container-relative { position: relative; width: 100%; max-width: 600px; }

.search-box {
    width: 100%; background: var(--bg-white); border-radius: 50px;
    box-shadow: var(--shadow-md); display: flex; align-items: center;
    padding: 0 20px; height: 50px;
}
#searchInput { border: none; outline: none; flex: 1; font-size: 16px; background: transparent; }
.search-icon { color: var(--text-sub); margin-right: 12px; }
.hidden { display: none !important; }

/* Suggestions & History */
.suggestions-list {
    position: absolute; top: 58px; left: 0; right: 0;
    background: white; border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); max-height: 60vh; overflow-y: auto; z-index: 20;
}
.suggestion-header {
    padding: 8px 16px; font-size: 12px; color: var(--text-sub); font-weight: 700; background: #f9fafb;
}
.suggestion-item { padding: 12px 20px; border-bottom: 1px solid var(--bg-light); cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.suggestion-item:hover { background: #eff6ff; }

/* [Modified] Horizontal alignment for icon and text */
.suggestion-content { 
    display: flex; 
    align-items: center; /* Vertically center icon and text */
    gap: 12px; /* Space between icon and text */
    flex: 1;
}
.history-icon { color: var(--text-sub); font-size: 14px; } /* Removed margin-right, using gap */

.suggestion-item strong { display: block; color: var(--text-main); }
.suggestion-item span { font-size: 13px; color: var(--text-sub); }

.delete-history-btn {
    background: none; border: none; color: #9ca3af; padding: 8px; 
    cursor: pointer; font-size: 14px; display: flex; align-items: center;
}
.delete-history-btn:hover { color: #ef4444; }

.suggestion-more {
    padding: 12px 20px; text-align: center; color: var(--primary-color);
    font-weight: 600; cursor: pointer; background: #eff6ff;
}
.suggestion-more:hover { background: #dbeafe; }

/* Filters */
.filter-row { display: flex; align-items: center; }
.filter-chips-container {
    display: flex; gap: 8px; overflow-x: auto; padding: 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
@media (min-width: 768px) { .filter-chips-container { flex-wrap: wrap; overflow-x: visible; } }
.filter-chips-container::-webkit-scrollbar { display: none; }

.chip {
    white-space: nowrap; padding: 6px 14px; border-radius: 20px;
    font-size: 14px; font-weight: 500;
    border: 2px solid transparent; 
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px;
    background: #f3f4f6; color: #6b7280; flex-shrink: 0;
}
.chip.active { background: #ffffff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

/* Controls */
.map-controls {
    pointer-events: auto; position: absolute; right: 16px; top: 140px;
    display: flex; flex-direction: column; gap: 12px; align-items: flex-end;
}
@media (min-width: 768px) { .map-controls { top: 20px; right: 20px; } }

.control-group { position: relative; }
.icon-btn {
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--bg-white); box-shadow: var(--shadow-md);
    cursor: pointer; color: var(--text-main); font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.icon-btn:active { transform: scale(0.95); }
#favFilterBtn.active { color: #fbbf24; }
#favFilterBtn.active i { font-weight: 900; }

.layer-menu {
    position: absolute; right: 55px; top: 0;
    background: var(--bg-white); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); width: 200px; overflow: hidden; padding: 5px 0;
}
.layer-option {
    display: block; width: 100%; text-align: left; padding: 10px 16px;
    border: none; background: transparent; cursor: pointer; color: var(--text-main);
}
.layer-option.active { color: var(--primary-color); background: #eff6ff; font-weight: 700; }

/* Info Card */
.info-card {
    pointer-events: auto; background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    width: 100%; max-width: 500px; margin: 0 auto;
    height: 80vh; transform: translateY(110%);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex; flex-direction: column; position: relative; z-index: 50;
}
.info-card.peek { transform: translateY(calc(80vh - 180px)); }
.info-card.open { transform: translateY(0); }

@media (min-width: 768px) {
    .info-card { 
        position: fixed; top: 150px; left: 20px; margin: 0; border-radius: var(--radius-lg); 
        width: 380px; height: auto; max-height: calc(100vh - 100px);
        box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    }
    .info-card.hidden { transform: translateX(-150%); }
    .info-card.peek, .info-card.open { transform: none; }
}

.card-handle-bar { width: 100%; height: 30px; display: flex; justify-content: center; align-items: center; cursor: grab; flex-shrink: 0; touch-action: none; }
.card-handle-bar:active { cursor: grabbing; }
.card-handle-visual { width: 40px; height: 5px; background: #d1d5db; border-radius: 10px; opacity: 1; }

.close-card-btn { position: absolute; top: 10px; right: 15px; background: transparent; border: none; font-size: 24px; color: var(--text-sub); cursor: pointer; z-index: 10; }
.card-scroll-content { overflow-y: auto; padding: 0 24px 30px; }

.card-header { margin-bottom: 20px; }
.header-badges { display: flex; gap: 8px; margin-bottom: 8px; padding-right: 30px; }
.title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 5px; }
#cardTitle { margin: 0; font-size: 20px; font-weight: 700; color: var(--text-main); line-height: 1.3; }
.fav-action-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: #d1d5db; padding: 0; display: flex; align-items: center; transition: transform 0.1s; }
.fav-action-btn:active { transform: scale(1.2); }
.fav-action-btn.active { color: #fbbf24; }
.fav-action-btn.active i { font-weight: 900; }
.badge { padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fff; background: #555; }
.badge-outline { background: transparent; border: 1px solid #9ca3af; color: #4b5563; }
#cardAddress { margin: 0; color: var(--text-sub); font-size: 14px; }

.card-actions { display: flex; gap: 10px; margin: 20px 0; }
.action-btn { flex: 1; padding: 10px; border-radius: var(--radius-md); text-align: center; text-decoration: none; font-size: 14px; font-weight: 600; display: flex; justify-content: center; align-items: center; gap: 8px; }
.primary { background: var(--primary-color); color: white; }
.secondary { background: var(--bg-light); color: var(--text-main); }

.info-row { display: flex; gap: 14px; margin-bottom: 16px; }
.info-icon { width: 20px; color: var(--text-sub); text-align: center; padding-top: 2px; }
.info-text label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 2px; }
.info-text p, .html-content { margin: 0; font-size: 14px; color: var(--text-main); line-height: 1.5; }
.html-content a { color: var(--primary-color); }
.info-footer { text-align: center; border-top: 1px solid #eee; padding-top: 15px; margin-top: 10px;}
.report-link { font-size: 12px; color: #9ca3af; }

.loader-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.9); z-index: var(--z-modal); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.spinner { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }