:root {
  --primary: #6B4F3B;
  --bg-color: #F7F3EF;
  --accent: #4CAF50;
  --text-dark: #1A1A1A;
  --text-light: #666666;
  --white: #FFFFFF;
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.06);
  --shadow-heavy: 0 12px 40px rgba(0, 0, 0, 0.12);
  
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: 1px solid rgba(255, 255, 255, 0.4);
  
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  display: flex;
  margin: 0;
  padding: 0;
  height: 100dvh;
  min-height: 100dvh;
  color: var(--text-dark);
}

/* App Container Mockup */
#app {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100dvh;
  background-color: var(--bg-color);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(100% - 80px);
  background-color: var(--bg-color);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 20px;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}
.screen.slide-up {
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  height: 100%;
  z-index: 50;
  background: var(--white);
  padding-bottom: 0px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen.slide-up.active {
  transform: translateY(0);
}

/* Hide scrollbar */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Utilities */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: var(--glass-border);
}

/* Typography */
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; margin-bottom: 16px; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 16px; font-weight: 600; }
p { font-size: 14px; color: var(--text-light); line-height: 1.5; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  background: var(--white);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: 20px;
  box-shadow: 0 -5px 20px rgba(0,0,0,0.03);
  z-index: 30;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #B0A8A0;
  cursor: pointer;
  transition: var(--transition);
}
.nav-item ion-icon { font-size: 24px; }
.nav-item span { font-size: 11px; font-weight: 500; }
.nav-item.active { color: var(--primary); }

/* Components */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
}

.chip {
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  background: var(--white);
  border: 1px solid #EAE5E0;
  color: var(--text-dark);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.chip.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.btn-primary:active { transform: scale(0.98); }

.circle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-dark);
}

.home-header {
  padding: 40px 24px 20px;
  background: linear-gradient(180deg, var(--white) 0%, var(--bg-color) 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.greeting {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 4px;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: url('./assets/profile_image.png') center/cover;
}
.search-container {
  display: flex;
  gap: 12px;
}
.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 52px;
  border-radius: var(--radius-md);
  gap: 12px;
}
.search-bar ion-icon {
  font-size: 20px;
  color: var(--text-light);
}
.search-bar input {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.filter-btn {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-dark);
  cursor: pointer;
}

.feed-section {
  padding: 0 24px;
}
.cafe-card {
  margin-bottom: 24px;
  cursor: pointer;
}
.card-image-wrapper {
  position: relative;
  height: 220px;
  width: 100%;
}
.card-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.score-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 6px 12px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dark);
}
.save-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-dark);
}
.card-content {
  padding: 16px;
}
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.distance {
  font-weight: 500;
}
.indicators {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  background: var(--bg-color);
  padding: 4px 10px;
  border-radius: 6px;
}
.indicator ion-icon { font-size: 16px; }

/* Map Screen */
.map-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
}
.map-bg img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.map-top-bar {
  position: absolute;
  top: 40px;
  left: 24px;
  right: 24px;
  z-index: 5;
  border-radius: var(--radius-md);
}
.map-search { background: transparent; }

/* Leaflet Overrides & Custom Pins */
#interactive-map { background-color: #f8f6f4; }
.leaflet-control-container .leaflet-control { z-index: 5 !important; }

.leaflet-custom-marker {
  position: relative;
  transform: translate(-50%, -100%);
  cursor: pointer;
  transition: transform 0.2s;
  display: flex !important;
  justify-content: center;
  align-items: center;
  margin-top: -12px;
  margin-left: -12px;
}
.leaflet-custom-marker:active { transform: translate(-50%, -100%) scale(0.9); }
.leaflet-custom-marker::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 5px 0;
  border-style: solid;
  border-color: var(--white) transparent transparent transparent;
}
.leaflet-custom-marker .pin-score {
  background: var(--white);
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  transition: var(--transition);
  color: var(--text-dark);
}
.leaflet-custom-marker.active-pin .pin-score {
  background: var(--primary);
  color: var(--white);
}
.leaflet-custom-marker.active-pin::after { border-color: var(--primary) transparent transparent transparent; }

#recenter-map-btn {
  position: absolute;
  top: 100px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--primary);
  z-index: 9999;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}

.map-preview-container {
  position: absolute;
  bottom: 100px;
  left: 0;
  width: 100%;
  z-index: 5;
  display: flex;
  gap: 16px;
  padding: 0 24px;
}
.single-card-container {
  display: flex !important;
  justify-content: center;
  padding-bottom: 20px;
}
.map-preview-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  padding: 12px;
  gap: 12px;
  background: var(--white);
  cursor: pointer;
}
.map-preview-card img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.preview-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}
.preview-info h4 { margin-bottom: 2px; }

/* Detail Screen */
.detail-hero {
  position: relative;
  height: 380px;
  width: 100%;
  z-index: 0;
  flex-shrink: 0;
}
.hero-img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.hero-top {
  position: absolute;
  top: 0; left: 0; width: 100%;
  padding: 40px 24px 20px;
  display: flex;
  justify-content: space-between;
}
.hero-actions { display: flex; gap: 12px; }
.detail-content {
  padding: 24px;
  background: var(--white);
  margin-top: -30px;
  position: relative;
  border-radius: 30px 30px 0 0;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}
.title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
}
.subtitle {
  margin-top: 6px;
  font-weight: 500;
}
.big-score {
  background: var(--primary);
  color: var(--white);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
}
.big-score .num { font-size: 24px; font-weight: 700; line-height: 1; }
.big-score .lbl { font-size: 11px; font-weight: 500; margin-top: 4px; opacity: 0.9; }

.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}
.feature-card {
  padding: 16px;
  background: var(--bg-color);
  box-shadow: none;
}
.f-icon {
  font-size: 28px;
  margin-bottom: 12px;
}
.f-icon.wifi { color: #2196F3; }
.f-icon.quiet { color: #9C27B0; }
.f-icon.power { color: #FF9800; }
.f-icon.seat { color: #795548; }

.about-section { margin-bottom: 32px; }

.bottom-action-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px 24px calc(24px + env(safe-area-inset-bottom));
  background: var(--white);
  border-top: 1px solid #EAE5E0;
  z-index: 10;
}

/* Filter Modal */
.bottom-sheet {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 100;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.bottom-sheet-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s;
}
.bottom-sheet-content {
  position: relative;
  background: var(--white);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  padding: 24px;
  padding-bottom: 40px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: var(--shadow-heavy);
  max-height: 90%;
  overflow-y: auto;
}
.bottom-sheet.active { pointer-events: auto; }
.bottom-sheet.active .bottom-sheet-overlay { opacity: 1; }
.bottom-sheet.active .bottom-sheet-content { transform: translateY(0); }
.drag-handle {
  width: 40px; height: 4px;
  background: #E0DCD8;
  border-radius: 2px;
  margin: 0 auto 20px auto;
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.clear-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}
.filter-group {
  margin-bottom: 24px;
}
.filter-group h3 {
  margin-bottom: 12px;
}
.chip-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
/* Switch styling */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary); }
input:focus + .slider { box-shadow: 0 0 1px var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* --- Screen 4: Saved Cafes --- */
.saved-header {
  padding: 40px 24px 20px;
  background: linear-gradient(180deg, var(--white) 0%, var(--bg-color) 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}
.saved-header h2 {
  font-size: 28px;
  margin-bottom: 4px;
}
.saved-header p {
  font-size: 15px;
}
.save-btn.active ion-icon, #detail-save-btn.active ion-icon {
  color: var(--primary);
  transform: scale(1.1);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  color: var(--text-light);
}
.empty-state ion-icon {
  font-size: 64px;
  color: #D4CDC6;
  margin-bottom: 16px;
}
.empty-state h3 {
  color: var(--text-dark);
  margin-bottom: 8px;
}

/* --- Screen 5: Profile --- */
.profile-header {
  padding: 40px 24px 32px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}
.profile-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: url('./assets/profile_image.png') center/cover;
  margin-bottom: 16px;
  border: 4px solid var(--bg-color);
}
.profile-header h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

.profile-content {
  padding: 24px;
}
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  flex: 1;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card h4 {
  font-size: 24px;
  color: var(--primary);
}
.stat-card p {
  font-size: 13px;
  font-weight: 500;
}

.profile-section {
  margin-bottom: 32px;
}
.profile-section h3 {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: 12px;
  padding-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.settings-card {
  display: flex;
  flex-direction: column;
}
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}
.setting-item.clickable {
  cursor: pointer;
  transition: var(--transition);
}
.setting-item.clickable:active {
  background: var(--bg-color);
}
.setting-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 15px;
}
.icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 18px;
}
.divider {
  height: 1px;
  background: #EAE5E0;
  margin: 0 20px;
}
.logout-btn {
  width: 100%;
  padding: 16px;
  background: transparent;
  color: #E53935;
  border: 2px solid #E53935;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 16px;
}
.logout-btn:active {
  background: #FFEBEE;
}

/* --- Screen 0: Auth --- */
.auth-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 40px 24px;
}
.auth-logo {
  text-align: center;
  margin-bottom: 48px;
}
.auth-logo h2 {
  font-size: 40px;
  color: var(--primary);
  margin-bottom: 8px;
}
.auth-logo p {
  color: var(--text-light);
  font-size: 16px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--white);
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.input-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}
.input-group input {
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #EAE5E0;
  background: var(--bg-color);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}
.input-group input:focus {
  border-color: var(--primary);
  background: var(--white);
}
.auth-toggle {
  text-align: center;
  margin-top: 32px;
  font-size: 15px;
  color: var(--text-light);
}
.auth-toggle span {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

/* Profile Image Upload Styles */
.avatar-upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.avatar-preview-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background-color: var(--surface);
  border: 2px dashed #D4CDC6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #D4CDC6;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: var(--transition);
  overflow: hidden;
}

.avatar-preview-circle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.avatar-preview-circle.has-image {
  border: 2px solid var(--primary);
}

.avatar-preview-circle.has-image ion-icon {
  display: none;
}

.avatar-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
}
