:root {
  /* Colors - Dark Theme Focus */
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-input: #1e293b;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-transparent: rgba(139, 92, 246, 0.2);
  --secondary: #334155;
  --secondary-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);

  /* Status Colors */
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --success: #10b981;
  --info: #3b82f6;

  /* Excretion Colors */
  --pee-color: #facc15;
  /* pure bold yellow */
  --poop-color: #78350f;
  /* dark brown */

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* Sizes */
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --touch-target: 48px;

  /* Animation */
  --transition: all 0.3s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
  max-width: 480px;
  /* Mobile first */
  margin: 0 auto;
  padding: 16px 16px 80px 16px;
  /* Space for floating bottom nav */
  min-height: 100vh;
}

/* Typography & Utilities */
h1,
h2,
h3 {
  font-weight: 600;
}

.text-primary {
  color: var(--primary);
}

.text-danger {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

.mt-1 {
  margin-top: 10px;
}

.mt-2 {
  margin-top: 20px;
}

.relative {
  position: relative;
}

/* Header */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 12px;
}

.top-nav h1 {
  font-size: 24px;
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--secondary);
}

.icon-btn-text {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* Cards (Glassmorphism) */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Buttons */
.btn {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 16px;
  border: none;
  border-radius: var(--radius-md);
  height: 44px;
  padding: 0 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  user-select: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-transparent);
}

.btn.primary:hover {
  background: var(--primary-hover);
}

.btn.primary.outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  box-shadow: none;
}

.btn.primary.outline:hover {
  background: var(--primary-transparent);
}

.btn.secondary {
  background: var(--secondary);
  color: var(--text-main);
}

.btn.secondary:hover {
  background: var(--secondary-hover);
}

/* Latest Health Summary */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.summary-item i {
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-data {
  margin-bottom: 2px;
}

.summary-data .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.summary-data .unit {
  font-size: 12px;
  color: var(--text-muted);
}

.summary-meta {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--secondary);
  padding: 2px 8px;
  border-radius: 12px;
}

/* Fever Alert */
.fever-alert {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Timer */
.timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timer-header h2 {
  font-size: 16px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint-text {
  font-size: 12px;
  color: var(--info);
  font-weight: 500;
  background: rgba(59, 130, 246, 0.2);
  padding: 4px 10px;
  border-radius: 12px;
}

.timer-display {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 12px 0 16px;
  letter-spacing: -1px;
  transition: color 0.3s;
}

.timer-display.overdue {
  color: var(--danger);
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}



.timer-display.forgot {
  font-size: 32px;
  color: var(--warning);
}

.feeding-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.milk-options {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 2px;
}

.milk-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  height: 36px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}

.milk-btn.active {
  background: var(--secondary);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Excretion Panel */
.excretion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.excretion-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stats {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.pee-btn i {
  color: var(--pee-color);
}

.poop-btn i {
  color: var(--poop-color);
}

.lock-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 41, 59, 0.9);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.lock-countdown {
  font-family: monospace;
  font-size: 18px;
  color: var(--text-muted);
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  font-family: var(--font-family);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 48px;
  font-size: 16px;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-transparent);
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row .form-group {
  flex: 1;
  min-width: 0;
  /* Prevents flex items from overflowing */
}

.form-group input {
  width: 100%;
  box-sizing: border-box;
  /* Ensure padding doesn't add to width */
}

/* Bottom Navigation (Floating Pill) */
.bottom-tab-bar {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  height: 64px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 32px;
  z-index: 100;
  padding: 0 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  height: 48px;
  margin: 0 8px;
  border-radius: 24px;
  cursor: pointer;
  transition: var(--transition);
  outline: none !important;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn:focus,
.tab-btn:focus-visible,
.tab-btn:active {
  outline: none !important;
  border: none;
}

.tab-btn i {
  font-size: 22px;
  margin-bottom: 3px;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 12px var(--primary-transparent);
}

.tab-btn.active i {
  transform: translateY(-2px);
  color: #fff;
}

/* Timeline */
.timeline-container {
  position: relative;
  padding: 10px 0;
}

.timeline-item {
  display: flex;
  margin-bottom: 16px;
}

.timeline-time {
  width: 50px;
  text-align: right;
  font-size: 14px;
  color: var(--text-muted);
  padding-top: 10px;
  font-weight: 500;
}

.timeline-marker {
  width: 30px;
  display: flex;
  justify-content: center;
  position: relative;
}

.timeline-marker::before {
  content: '';
  position: absolute;
  top: 28px;
  bottom: -16px;
  width: 2px;
  background: var(--border);
}

.timeline-item:last-child .timeline-marker::before {
  display: none;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  margin-top: 13px;
  z-index: 1;
}

.timeline-dot.feed {
  background: #10b981;
  /* emerald green for feed */
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.timeline-dot.pee {
  background: #f59e0b;
  /* amber for pee */
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.timeline-dot.poop {
  background: #a16207;
  /* dark amber/brown for poop */
  box-shadow: 0 0 8px rgba(161, 98, 7, 0.4);
}

.timeline-content {
  flex: 1;
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-left: 4px;
}

.timeline-title {
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.timeline-desc {
  font-size: 14px;
  color: var(--text-muted);
}


/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-dark);
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal.active .modal-content {
  transform: translateY(0);
}

/* Bottom sheet for history */
.modal-content.bottom-sheet {
  position: absolute;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(100%);
  max-height: 80vh;
}

.modal.active .modal-content.bottom-sheet {
  transform: translateY(0);
}

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* History List Area */
.history-item {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-content {
  flex: 1;
}

.history-date {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.history-actions {
  display: flex;
  gap: 8px;
}

.history-actions button {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.history-actions button:hover {
  background: var(--secondary);
  color: var(--text-main);
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

/* Animations */
.fade-in {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.5s forwards ease-out;
}

.delay-1 {
  animation-delay: 0.1s;
}

.delay-2 {
  animation-delay: 0.2s;
}

.delay-3 {
  animation-delay: 0.3s;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}