:root {
  --bg-cream: #FFF9F5;
  --bg-card: #FFFFFF;
  --pink-soft: #FFB5B5;
  --pink-light: #FFF0F0;
  --pink-accent: #FF8E8E;
  --sage-green: #A8C5A8;
  --sage-light: #E8F0E8;
  --text-primary: #4A4A4A;
  --text-secondary: #8A8A8A;
  --shadow-soft: 0 4px 20px rgba(255, 181, 181, 0.15);
  --shadow-hover: 0 8px 30px rgba(255, 181, 181, 0.25);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

.dark {
  --bg-cream: #1E1E24;
  --bg-card: #2A2A32;
  --pink-soft: #8B6B6B;
  --pink-light: #3A3038;
  --pink-accent: #D49A9A;
  --sage-green: #6B8B6B;
  --sage-light: #2A322A;
  --text-primary: #E8E8E8;
  --text-secondary: #A0A0A0;
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg-cream);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Pet Corner */
.pet-corner {
  position: fixed;
  bottom: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 50;
  pointer-events: none;
}

.pet-blob {
  font-size: 2.5rem;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(255, 181, 181, 0.3));
}

.pet-blob.sleeping {
  animation: sleep 3s ease-in-out infinite;
}

.pet-blob.happy {
  animation: bounce 1s ease-in-out infinite;
}

.pet-message {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 12px;
  opacity: 0.9;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes sleep {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-3px) rotate(5deg); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.1); }
}

/* Header */
.header {
  padding: 24px 20px 16px;
  text-align: center;
  background: linear-gradient(180deg, var(--pink-light) 0%, transparent 100%);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 2rem;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.settings-btn {
  background: var(--bg-card);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.settings-btn:hover {
  transform: rotate(45deg);
  box-shadow: var(--shadow-hover);
}

.greeting {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-top: 8px;
  font-weight: 500;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 16px 16px 100px;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

/* App Card */
.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: grab;
  user-select: none;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.app-card:active {
  cursor: grabbing;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.app-icon {
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.app-card:hover .card-actions {
  opacity: 1;
}

.action-btn {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.action-btn:hover {
  opacity: 1;
}

.remove-btn {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--pink-accent);
}

.app-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.status-container {
  background: var(--pink-light);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px;
  width: 100%;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.status-container:hover {
  background: var(--sage-light);
  transform: scale(1.02);
}

.status-widget {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pet Status */
.pet-status .pet-mood {
  font-size: 1.5rem;
}

.pet-status .pet-name {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Streak Status */
.streak-status {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.streak-flames {
  display: flex;
  gap: 2px;
}

.flame {
  font-size: 0.9rem;
  animation: flicker 1s ease-in-out infinite alternate;
}

@keyframes flicker {
  0% { opacity: 0.8; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

.streak-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Progress Status */
.progress-status {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.progress-bar-container {
  height: 8px;
  background: var(--sage-light);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage-green) 0%, var(--pink-soft) 100%);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-align: right;
}

/* Count Status */
.count-status {
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.count-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--sage-green);
}

.count-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Card Footer */
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.last-visited {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.visit-btn {
  background: linear-gradient(135deg, var(--pink-soft) 0%, var(--pink-accent) 100%);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.visit-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 142, 142, 0.4);
}

/* Add Card */
.add-card {
  background: var(--bg-card);
  border: 2px dashed var(--pink-soft);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease;
  min-height: 180px;
}

.add-card:hover {
  border-color: var(--pink-accent);
  background: var(--pink-light);
  transform: translateY(-2px);
}

.add-icon {
  font-size: 2rem;
  color: var(--pink-soft);
  font-weight: 300;
  line-height: 1;
}

.add-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

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

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-cream);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--pink-accent);
}

.icon-picker-container {
  position: relative;
}

.icon-preview {
  width: 60px;
  height: 60px;
  font-size: 2rem;
  background: var(--pink-light);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.icon-preview:hover {
  border-color: var(--pink-accent);
}

.emoji-picker {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  z-index: 10;
  margin-top: 8px;
  max-width: 260px;
}

.emoji-option {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  padding: 6px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.emoji-option:hover {
  background: var(--pink-light);
}

.status-type-options {
  display: flex;
  gap: 8px;
}

.status-type-btn {
  flex: 1;
  padding: 12px;
  font-size: 1.5rem;
  background: var(--pink-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.status-type-btn.active {
  border-color: var(--pink-accent);
  transform: scale(1.05);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.cancel-btn,
.submit-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.2s ease;
}

.cancel-btn {
  background: var(--pink-light);
  color: var(--text-secondary);
}

.submit-btn {
  background: linear-gradient(135deg, var(--pink-soft) 0%, var(--pink-accent) 100%);
  color: white;
}

.cancel-btn:hover,
.submit-btn:hover {
  transform: scale(1.02);
}

/* Settings Panel */
.settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.settings-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--bg-card);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--pink-light);
}

.settings-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.settings-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.setting-item {
  margin-bottom: 24px;
}

.setting-item label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.toggle-group {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  padding: 12px;
  font-size: 1.5rem;
  background: var(--pink-light);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  border-color: var(--pink-accent);
  background: var(--bg-cream);
}

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

.data-btn {
  flex: 1;
  padding: 10px;
  font-size: 0.85rem;
  background: var(--pink-light);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: background 0.2s ease;
}

.data-btn:hover {
  background: var(--sage-light);
}

.pwa-hint {
  margin-top: 24px;
  padding: 14px;
  background: var(--sage-light);
  border-radius: var(--radius-md);
}

.pwa-hint p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Quick Stats */
.quick-stats {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease;
  z-index: 60;
}

.stats-toggle {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stats-content {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 20px 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--pink-accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.encouragement {
  width: 100%;
  text-align: center;
  font-size: 0.9rem;
  color: var(--sage-green);
  font-weight: 600;
  padding-top: 8px;
  border-top: 1px solid var(--pink-light);
}

/* Footer */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: linear-gradient(0deg, var(--bg-cream) 50%, transparent 100%);
  pointer-events: none;
  z-index: 40;
}

.footer a {
  color: var(--pink-accent);
  text-decoration: none;
  pointer-events: auto;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 480px) {
  .apps-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .app-card {
    padding: 14px;
  }
  
  .app-icon {
    font-size: 1.6rem;
  }
  
  .app-name {
    font-size: 0.9rem;
  }
  
  .visit-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }
  
  .pet-corner {
    bottom: 100px;
    right: 12px;
  }
  
  .pet-blob {
    font-size: 2rem;
  }
}

@media (min-width: 768px) {
  .apps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .main-content {
    padding: 24px 24px 120px;
  }
}