* {
      box-sizing: border-box;
    }
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
      font-family: 'Segoe UI', sans-serif;
      background:#f8fafc;
      color:#333;
      display: flex;
      flex-direction: column;
    }
    header {
      padding: 15px 20px;
      text-align: center;
      background: linear-gradient(135deg, #6d5dfc, #46c6fd);
      color: white;
      box-shadow: 0 4px 15px rgba(0,0,0,0.1);
      z-index: 2000;
      position: relative; /* Needed for z-index context and positioning children */
    }
    h2 { 
      margin:0; 
      font-size: 2.2em; 
      font-weight: 700;
      text-shadow: 0 2px 4px rgba(0,0,0,0.2);
      animation: fadeInDown 0.8s ease-out;
    }
    p { 
      margin: 5px 0 10px; 
      font-size: 1.1em; 
      opacity: 0.95;
      animation: fadeInUp 0.8s ease-out 0.2s backwards;
    }

    @keyframes fadeInDown {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    @keyframes fadeInUp {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
  
    #main-container {
      display: flex;
      flex-grow: 1;
      overflow: hidden;
    }
  
    #map {
      flex: 2;
      height: 100%;
      border-right: 1px solid #ddd;
    }
    #sidebar {
      flex: 1;
      min-width: 350px; /* Default for larger screens */
      max-width: 450px; /* Default for larger screens */
      background:white;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
    }
  
    #sidebar-content {
      overflow-y: auto;
      padding: 20px;
    }
  
    button {
      padding: 10px 18px;
      background: linear-gradient(135deg, #6d5dfc, #46c6fd);
      border: none;
      border-radius: 8px; /* Slightly smaller radius for consistency */
      color: white;
      cursor: pointer;
      font-weight: 600;
      margin: 5px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* Lighter shadow */
      transition: all 0.3s ease; /* Smooth transition */
    }
    button:hover {
      opacity: 0.9;
      transform: translateY(-1px); /* Subtle hover effect */
    }
    button:disabled {
      background: #ccc;
      cursor: not-allowed;
      transform: none;
      box-shadow: none;
    }
  
    .toast {
      position: fixed;
      top: 20px;
      right: 20px;
      padding: 12px 20px; /* Slightly smaller padding */
      border-radius: 10px; /* Slightly smaller radius */
      color: white;
      font-weight: bold;
      background: linear-gradient(45deg, #43e97b, #38f9d7);
      opacity: 0;
      transform: translateY(-20px);
      transition: all .5s;
      box-shadow: 0 3px 12px rgba(0,0,0,0.2); /* Lighter shadow */
      z-index: 2000;
    }
    .toast.show { opacity:1; transform:translateY(0); }
  
    .cute-marker { width:16px; height:16px; border-radius:50%; border:2px solid white; box-shadow:0 1px 6px rgba(0,0,0,0.3);}
    .emoji-marker { font-size: 20px; text-shadow: 0 0 3px white; display: flex; justify-content: center; align-items: center; line-height: 1; width: 100%; height: 100%;}
  
    /* Styles for the new emoji input and import controls */
    #import-controls {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-wrap: wrap; /* Allow items to wrap on smaller screens */
      gap: 10px; /* Spacing between elements */
      margin-top: 2px;
    }
    .emoji-input {
      padding: 10px;
      border: 1px solid #ccc;
      border-radius: 8px;
      font-size: 1em;
      width: 150px; /* Default width */
      text-align: center;
    }
    
    /* Button Row for side-by-side buttons */
    .button-row {
      display: flex;
      gap: 10px;
      margin-top: 10px;
    }
    .button-row button {
      flex: 1; /* Distribute space equally */
      margin: 0; /* Override default margin */
      width: auto; /* Override mobile full width */
    }

    /* Responsive Adjustments */
    @media (max-width: 1024px) {
      #sidebar {
        min-width: 300px;
        max-width: 400px;
      }
      .emoji-input {
        width: 120px; /* Adjust for medium screens */
      }
    }
  
    @media (max-width: 768px){
      header {
        padding: 10px;
      }
      h2 { font-size: 1.5em; }
      p { font-size: 0.8em; }
  
      #main-container {
        flex-direction: column;
      }
      #map {
        height: 50vh; /* Make map take 50% of viewport height on mobile */
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
      }
      #sidebar {
        height: auto; /* Allow sidebar to take natural height */
        min-width: 100%; /* Take full width on mobile */
        max-width: 100%; /* Take full width on mobile */
      }
      #sidebar-content {
        padding: 10px;
      }
      button {
        padding: 8px 15px;
        font-size: 0.9em;
        margin: 3px;
      }
      .toast {
        top: 10px;
        right: 10px;
        padding: 10px 15px;
        font-size: 0.9em;
      }
      #import-controls {
        flex-direction: column; /* Stack items vertically on smaller screens */
        gap: 5px;
      }
      .emoji-input {
        width: calc(100% - 20px); /* Full width minus padding/margin */
        margin: 0 10px;
      }
    }
  
    @media (max-width: 480px) {
      header {
        flex-direction: column;
        align-items: center;
      }
      header div {
        margin-top: 10px;
      }
      button {
        width: calc(100% - 10px); /* Full width buttons with some margin */
        margin: 5px 5px;
        display: block;
      }
      #search-container {
        padding: 10px;
      }
      #place-search-input {
        font-size: 0.9em;
        padding: 8px;
      }
      .emoji-input {
        width: calc(100% - 20px); /* Ensure full width on very small screens */
      }
    }
  /* --- New Sidebar Styles --- */
  #search-container {
    padding: 15px;
    border-bottom: 1px solid #eee;
  }
  #place-search-input {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1em;
  }

  .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    cursor: pointer;
  }
  .section-header h5 { margin: 0; font-size: 1.1em; }
  .section-content {
    padding: 10px 20px;
    display: block; /* Hidden by default in JS */
  }

  .map-item, .layer-item {
    padding: 10px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: #fefefe;
    border: 1px solid #eee;
    cursor: pointer;
  }
  .map-item-header, .layer-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .map-item-header span, .layer-item-header span {
    font-weight: bold;
  }
  .item-controls button {
    padding: 4px 8px;
    font-size: 0.8em;
    margin: 0 2px;
  }
  .layer-list {
    margin-top: 10px;
    padding-left: 20px;
  }

  .layer-item.active {
    background: #e6f7ff;
    border-color: #91d5ff;
  }

  /* Card Styles from old #stats */
  #statsCard {
    max-width:900px;
    padding:25px;
    border-radius:20px;
    background: linear-gradient(135deg,#6d5dfc,#46c6fd);
    color:white;
    font-family:'Segoe UI',sans-serif;
    text-align:center;
    margin-bottom: 15px;
  }
  #statsCard h3, #statsCard p, #statsCard h4 { color: white; }
  #miniMap {height:250px;margin:15px 0;border-radius:12px;overflow:hidden;}
  #statsCard .dist-container { display:flex; gap:20px; margin-top:15px; text-align:left; }
  #statsCard .dist-item { flex:1; }
  #statsCard .dist-row { display:flex; justify-content:space-between; padding:6px 10px; background:rgba(255,255,255,0.1); border-radius:8px; margin-bottom:6px; }
  #typeChartContainer { position: relative; width:90%; max-width: 400px; margin: auto; }
  .persona-profile { border-radius: 15px; padding: 20px; background: rgba(230,230,230,0.4); margin-top: 20px; color: #333; }
  .main-persona h5 { margin: 0 0 10px; font-size: 1.5em; color: #333; }
  .main-persona p { margin: 0; font-style: italic; opacity: 0.9; color: #555; }

/* --- Marker Detail Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1999;
    display: none;
    justify-content: center;
    align-items: center;
}
.modal-overlay.show {
    display: flex;
}
.detail-modal {
    width: 90%;
    max-width: 800px;
    max-height: 90vh; /* Use max-height instead of fixed height */
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensure content inside is scrollable if it exceeds max-height */
}
.detail-modal-header {
    padding: 15px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.detail-modal-header h4 {
    margin: 0;
    font-size: 1.4em;
}
.detail-modal-header button {
    background: none;
    border: none;
    font-size: 1.8em;
    cursor: pointer;
    color: #888;
    padding: 0 10px;
}
.detail-modal-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 25px;
}
.detail-section {
    margin-bottom: 30px;
}
.detail-section h5 {
    margin: 0 0 15px 0;
    border-bottom: 2px solid #6d5dfc;
    padding-bottom: 8px;
    display: inline-block;
}
.comment-list .comment-item {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #f0f0f0;
}
.comment-item-meta {
    font-size: 0.8em;
    color: #888;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}
.comment-item-meta button {
    padding: 2px 6px;
    font-size: 0.9em;
    background: #ff4d4f;
}
.comment-form textarea {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 8px;
    height: 70px;
    margin-bottom: 10px;
}

/* Photo Gallery Styles */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}
.photo-item {
    position: relative;
    width: 100px;
    height: 100px;
}
.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}
.photo-item .delete-photo-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4d4f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}
.photo-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2001;
    display: none;
    justify-content: center;
    align-items: center;
}
.photo-preview-overlay.show {
    display: flex;
}
.photo-preview-overlay img {
    max-width: 90%;
    max-height: 90%;
}

/* Comparison UI Styles */
.compare-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.compare-container select {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #ccc;
}
#compare-results-container {
    margin-top: 20px;
}

/* Additional Mobile styles for modal */
@media (max-width: 768px) {
    .detail-modal {
        width: 95%;
        margin: 0 auto;
        border-radius: 10px;
    }
    .detail-modal-header {
        padding: 10px 15px;
    }
    .detail-modal-header h4 {
        font-size: 1.2em;
    }
    .detail-modal-content {
        padding: 15px;
    }
    .detail-section {
        margin-bottom: 20px;
    }
    .detail-section h5 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }
    .comment-item-meta {
        font-size: 0.75em;
    }
    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 5px;
    }
    .photo-item {
        width: 70px;
        height: 70px;
    }
}

/* Emoji Picker Styles */
.emoji-picker-container {
    position: relative;
    display: inline-block;
    vertical-align: middle;
    margin: 0 2px;
}

.selected-emoji-display {
    width: 40px;
    height: 40px;
    border: 1px solid #ccc;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    background-color: #f9f9f9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.emoji-grid {
    position: absolute;
    top: 100%; /* Position below the selected emoji display */
    left: 0;
    z-index: 1000;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 emojis per row */
    gap: 5px;
    visibility: hidden; /* Hidden by default */
    opacity: 0;
    transition: opacity 0.2s, visibility 0.2s;
}

.emoji-grid.show-grid {
    visibility: visible;
    opacity: 1;
}

.emoji-option {
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.emoji-option:hover {
    background-color: #eee;
}

/* Responsive adjustments for emoji picker */
@media (max-width: 768px) {
    .emoji-picker-container {
        margin: 5px 0;
        width: 100%;
        display: block; /* Stack on smaller screens */
        text-align: center;
    }
    .selected-emoji-display {
        margin: 0 auto;
    }
    .emoji-grid {
        left: 50%;
        transform: translateX(-50%);
        width: min(300px, 90vw); /* Max 300px or 90% of viewport width */
        grid-template-columns: repeat(auto-fit, minmax(36px, 1fr)); /* Adjust columns dynamically */
    }
}

/* Stats Card Styles */
.stats-card {
    max-width: 900px;
    padding: 25px;
    border-radius: 20px;
    background: linear-gradient(135deg, #6d5dfc, #46c6fd);
    color: white;
    font-family: 'Segoe UI', sans-serif;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.stats-card h3, .stats-card p, .stats-card h4, .stats-card h5 {
    color: white;
    margin-bottom: 10px;
}
.stats-card h3 { font-size: 1.8em; margin-top: 0; }
.stats-card h4 { font-size: 1.2em; }
.stats-card p { font-size: 1em; }

.stats-summary {
    margin-bottom: 20px;
    text-align: left;
}

.stats-summary p { margin-bottom: 5px; }
.stats-summary span { font-weight: bold; }

.dist-container {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    text-align: left;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.dist-item {
    flex: 1;
    min-width: 120px; /* Ensure items don't get too small */
}

.dist-item h4 {
    margin-bottom: 10px;
    color: #e0e0e0;
}

.dist-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.mini-map {
    height: 250px;
    margin: 15px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.chart-section {
    margin-top: 20px;
}

.chart-section h4 {
    margin-bottom: 15px;
    color: #e0e0e0;
}

#typeChartContainer {
    position: relative;
    width: 90%;
    max-width: 300px; /* Limit chart size */
    margin: auto;
}

.persona-analysis {
    margin-top: 30px;
    text-align: left;
}

.persona-analysis h4 {
    margin-bottom: 15px;
    color: #e0e0e0;
}

.main-persona {
    border-radius: 15px;
    padding: 15px 20px;
    background: rgba(230,230,230,0.2);
    margin-bottom: 20px;
    color: white;
}

.main-persona h5 {
    margin: 0 0 8px;
    font-size: 1.5em;
    color: white;
}

.main-persona p {
    margin: 0;
    font-style: italic;
    opacity: 0.9;
    color: #f0f0f0;
}

.persona-scores {
    position: relative;
    width: 90%;
    max-width: 400px; /* Limit chart size */
    margin: auto;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
}

#downloadStatsCard {
    margin-top: 30px;
    background: #ffffff;
    color: #6d5dfc;
    border: none;
    padding: 12px 25px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

#downloadStatsCard:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Responsive adjustments for stats card */
@media (max-width: 768px) {
    .stats-card {
        padding: 15px;
        border-radius: 15px;
    }
    .stats-card h3 { font-size: 1.5em; }
    .stats-card h4 { font-size: 1.1em; }
    .dist-container {
        flex-direction: column;
        gap: 10px;
    }
    .dist-item {
        min-width: unset;
        width: 100%;
    }
    .mini-map {
        height: 200px;
    }
    #typeChartContainer, .persona-scores {
        max-width: 100%;
        width: 100%;
    }
    #downloadStatsCard {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}

/* Language Selector Styles */
.language-selector {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 2500;
}

.language-selector .icon-button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    margin: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    transition: background 0.3s ease;
}

.language-selector .icon-button .material-symbols-outlined {
    font-size: 28px;
    transition: color 0.2s ease;
}

.language-selector .icon-button:hover .material-symbols-outlined {
    color: white;
}
.language-selector .icon-button:hover {
    background: rgba(255,255,255,0.4);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px 0;
    margin-top: 8px;
    min-width: 150px;
    display: flex;
    flex-direction: column;
    z-index: 2500;
}

.language-dropdown.hidden {
    display: none;
}

.language-dropdown .dropdown-item {
    background: none;
    border: none;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    color: #333;
    font-size: 1em;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 100%;
    font-weight: normal;
}

.language-dropdown .dropdown-item:hover {
    background-color: #f0f0f0;
    color: #6d5dfc;
}
/* Sidebar Toggle Button for Mobile */
.mobile-only {
    display: none; /* Hidden by default */
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex; /* Show on mobile */
        position: absolute;
        top: 50%;
        left: 10px;
        transform: translateY(-50%);
        z-index: 1010;
        background: rgba(255,255,255,0.2);
        border: none;
        color: white;
        cursor: pointer;
        padding: 5px;
        margin: 0;
        box-shadow: none;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        transition: background 0.3s ease;
    }
    
    .mobile-only:hover {
        background: rgba(255,255,255,0.4);
    }

    .mobile-only .material-symbols-outlined {
        font-size: 28px;
    }

    /* Adjust header layout for mobile */
    header {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 15vh;
        min-height: 50px;
        padding: 0 50px; /* Reserve space for buttons */
        overflow: visible;
    }
    header h2 {
        font-size: clamp(1rem, 4vw, 1.4em);
        line-height: 1.1;
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    header p {
        font-size: clamp(0.7rem, 3vw, 0.9em);
        margin: 2px 0 0 0;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .language-selector {
        position: absolute;
        top: 50%;
        right: 10px;
        transform: translateY(-50%);
    }

    /* Main container and map on mobile */
    #main-container {
        flex-direction: column;
        position: relative; /* Needed for sidebar absolute positioning */
    }
    #map {
        width: 100%;
        height: 100vh; /* Make map take full viewport height */
        border-right: none;
    }
    #sidebar {
        position: absolute;
        top: 0;
        right: -100%; /* Hide sidebar off-screen */
        width: 80%; /* Adjust as needed */
        max-width: 300px; /* Max width for sidebar on mobile */
        height: 100vh;
        background: white;
        z-index: 1000;
        box-shadow: -2px 0 10px rgba(0,0,0,0.2);
        transition: right 0.3s ease-in-out;
        flex: none; /* Override flex: 1 */
    }
    #sidebar.sidebar-open {
        right: 0; /* Show sidebar */
    }
    #sidebar-content {
        padding-top: 60px; /* Adjust for header height */
    }
    /* Hide scrollbar of main body when sidebar is open */
    body.sidebar-open {
        overflow: hidden;
    }

    /* Fix for sidebar close button positioning and hover effect */
    #sidebar-close-btn {
        transform: none !important; /* Override mobile-only transform */
        margin: 0; /* Reset default button margin */
        box-shadow: none;
    }
    #sidebar-close-btn:hover {
        transform: none !important;
        background: #f0f0f0 !important; /* Hover effect */
    }
}