:root {
  --bg-color: #000000;
  --card-bg: rgba(18, 18, 18, 0.7);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: #aaaaaa;
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  --accent-green: #22c55e;
  --accent-orange: #f97316;
  --accent-red: #ef4444;
  --accent-yellow: #facc15;
  --nav-bg: rgba(0, 0, 0, 0.8);
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --fab-border: #000;
}

body.light-mode {
  --bg-color: #f2f2f7;
  --card-bg: rgba(255, 255, 255, 0.8);
  --card-border: rgba(0, 0, 0, 0.05);
  --text-primary: #000000;
  --text-secondary: #666666;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --accent-blue: #007aff;
  --fab-border: #fff;
}

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

body {
  background: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-main);
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.app-container {
  width: 100%;
  max-width: 420px;
  position: relative;
  min-height: 100vh;
  padding: calc(20px + var(--safe-area-top)) 20px 100px 20px; /* Safe area + standard padding */
  display: flex;
  flex-direction: column;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 16px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.glass-card:active {
  transform: scale(0.98);
}

/* Typography */
h1 { font-size: 32px; font-weight: 800; margin-bottom: 20px; letter-spacing: -1px; }
h2 { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 18px; font-weight: 600; }
p { color: var(--text-secondary); font-size: 14px; }

/* Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 12px 10px calc(12px + var(--safe-area-bottom));
  z-index: 1000;
}

.nav-item {
  color: var(--text-secondary);
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  transition: 0.3s ease;
  flex: 1;
  cursor: pointer;
}

.nav-item i {
  font-size: 20px;
  margin-bottom: 4px;
  display: block;
}

.nav-item.active {
  color: var(--text-primary);
}

/* FAB - Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(90px + var(--safe-area-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  background: var(--accent-blue);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  z-index: 1001;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
  border: 4px solid var(--fab-border); /* Adaptive border */
}

.fab:active {
  transform: scale(0.9) rotate(45deg);
}

.notification-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: 0.3s;
}

.notification-icon:active {
  transform: scale(0.9);
}

/* Progress Bars */
.progress-container {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 15px currentColor;
}

/* Habit Items */
.habit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.habit-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.habit-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.habit-check {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 2px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.habit-check.done {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: #000;
}

/* FAB */
.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 20px;
  background: var(--accent-blue);
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  z-index: 100;
  cursor: pointer;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-content {
  width: 100%;
  max-width: 420px;
  background: #111;
  border-radius: 32px 32px 0 0;
  padding: 30px 20px calc(30px + var(--safe-area-bottom));
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active { display: flex; }
.modal-overlay.active .modal-content { transform: translateY(0); }

/* Inputs */
input, select {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  color: #fff;
  font-size: 16px;
  margin-bottom: 20px;
}

.btn-primary {
  width: 100%;
  padding: 18px;
  border-radius: 18px;
  border: none;
  background: var(--accent-blue);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* Hidden Haptic Trigger */
#haptic-trigger {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Icon Picker Grid */
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px;
  background: #0a0a0a;
  border-radius: 16px;
  border: 1px solid var(--card-border);
  margin-bottom: 20px;
}

.icon-option {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #1a1a1a;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: 0.2s;
}

.icon-option.selected {
  background: var(--accent-blue);
  color: #fff;
  box-shadow: 0 0 15px var(--accent-blue);
}

.edit-btn {
  padding: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.edit-btn:hover {
  color: var(--text-primary);
}

/* Settings Styles */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--card-border);
}

.settings-row:last-child {
  border-bottom: none;
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 50;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: .4s;
  border-radius: 34px;
}

.light-mode .slider {
  background-color: #ddd;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--accent-blue);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Social View Styles */
.social-search-results {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  margin-bottom: 8px;
}

.light-mode .search-result-item {
  background: rgba(0, 0, 0, 0.03);
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 24px 0 12px;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--card-border);
}

.friend-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
}

.streak-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(249, 115, 22, 0.1);
  color: var(--accent-orange);
  border-radius: 20px;
  font-weight: 700;
  font-size: 14px;
}

.request-actions {
  display: flex;
  gap: 8px;
}

.btn-small {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.btn-accept { background: var(--accent-green); color: #000; }
.btn-reject { background: #333; color: #fff; }

.habit-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 8px;
  cursor: pointer;
  transition: 0.2s;
}

.habit-select-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.habit-select-item.selected {
  border: 1px solid var(--accent-blue);
  background: rgba(59, 130, 246, 0.1);
}
