/* ===== DESIGN TOKENS ===== */
:root {
  --bg-primary: #fffafd;
  --bg-secondary: #f3e6f8;
  --bg-tertiary: #ead7f1;
  --bg-card: rgba(255, 250, 253, 0.9);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(111, 42, 141, 0.14);
  
  --brand-deep: #4a1764;
  --brand-plum: #6f2a8d;
  --brand-lavender: #d9b7ee;
  --brand-blush: #f3d7ea;
  --accent-primary: #b76ad7;
  --accent-secondary: #f0b8d7;
  --accent-gradient: linear-gradient(135deg, #4a1764 0%, #7c3fa0 48%, #f0b8d7 100%);
  --accent-glow: rgba(183, 106, 215, 0.3);
  
  --text-primary: #25102f;
  --text-secondary: #694275;
  --text-muted: #92729b;
  
  --protein: #f0b8d7;
  --carbs: #b76ad7;
  --fat: #f59e0b;
  --water: #06b6d4;
  --success: #b76ad7;
  --warning: #f59e0b;
  
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  
  --shadow-sm: 0 2px 8px rgba(74, 23, 100, 0.08);
  --shadow-md: 0 16px 44px rgba(74, 23, 100, 0.12);
  --shadow-glow: 0 0 40px var(--accent-glow);
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background effects */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(217, 183, 238, 0.34), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(240, 184, 215, 0.28), transparent);
  pointer-events: none;
  z-index: 0;
}

/* ===== GLASS EFFECT ===== */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 24px;
  background:
    linear-gradient(155deg, #fffafd 0%, #f3e6f8 46%, #e6cbed 100%);
}

.login-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
  transition: var(--transition);
}

.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.login-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.32;
  animation: blobFloat 8s ease-in-out infinite;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: #d9b7ee;
  top: -100px;
  left: -100px;
}

.blob-2 {
  width: 300px;
  height: 300px;
  background: #f0b8d7;
  bottom: -50px;
  right: -50px;
  animation-delay: -3s;
}

.blob-3 {
  width: 200px;
  height: 200px;
  background: #7c3fa0;
  top: 50%;
  left: 50%;
  animation-delay: -5s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 34px 28px 30px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 253, 0.84);
  border: 1px solid rgba(111, 42, 141, 0.14);
  box-shadow: 0 24px 70px rgba(74, 23, 100, 0.18);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.login-logo {
  width: 118px;
  height: 104px;
  border-radius: 0;
  background: transparent;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  padding: 0;
  box-shadow: none;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-footer-brand {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(111, 42, 141, 0.14);
  color: #7a5286;
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.login-card h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--brand-deep);
}

.login-subtitle {
  text-align: center;
  color: #694275;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.google-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(111, 42, 141, 0.18);
  background: #ffffff;
  color: var(--brand-deep);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.google-button:hover {
  background: #fbf4ff;
  transform: translateY(-1px);
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #8a6a94;
  font-size: 0.8rem;
  font-weight: 600;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(111, 42, 141, 0.16);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input,
.input-group textarea,
.input-group select {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
  outline: none;
}

.input-group input:focus,
.input-group textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group input::placeholder,
.input-group textarea::placeholder {
  color: var(--text-muted);
}

.primary-button {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-gradient);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.primary-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.primary-button:active {
  transform: translateY(0);
}

.ghost-button {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}

.ghost-button:hover {
  color: var(--text-primary);
}

.login-card .input-group label {
  color: #6f2a8d;
}

.login-card .input-group input {
  background: #ffffff;
  border-color: rgba(111, 42, 141, 0.18);
  color: var(--brand-deep);
}

.login-card .input-group input:focus {
  border-color: var(--brand-plum);
  box-shadow: 0 0 0 3px rgba(183, 106, 215, 0.2);
}

.login-card .input-group input::placeholder {
  color: #a58cad;
}

.login-card .primary-button {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-plum));
  box-shadow: 0 12px 28px rgba(74, 23, 100, 0.24);
}

.login-card .ghost-button {
  color: #6f2a8d;
}

.login-card .ghost-button:hover {
  color: var(--brand-deep);
}

/* ===== APP SHELL ===== */
.app-shell {
  display: none;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 100px;
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, rgba(255,250,253,0.82), rgba(243,230,248,0.52));
}

.app-shell.is-ready {
  display: block;
  animation: fadeIn 0.5s ease;
}

.app-sidebar {
  display: none;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 18px;
}

.app-sidebar-brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.app-sidebar-brand strong,
.app-sidebar-brand span {
  display: block;
}

.app-sidebar-brand strong {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 900;
}

.app-sidebar-brand span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.app-sidebar nav {
  display: grid;
  gap: 8px;
}

.app-sidebar button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 850;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.app-sidebar button:hover {
  border-color: rgba(183, 106, 215, 0.28);
  background: rgba(255, 255, 255, 0.58);
  color: var(--accent-secondary);
}

.app-sidebar button.is-active {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 14px 30px rgba(111, 42, 141, 0.22);
}

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

/* ===== TOP BAR ===== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 -16px 20px;
  padding: calc(22px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: rgba(255, 250, 253, 0.92);
  border-bottom: 1px solid rgba(111, 42, 141, 0.12);
  box-shadow: 0 10px 26px rgba(74, 23, 100, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-bar-info .eyebrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.top-bar-info h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.avatar-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-gradient);
  border: 2px solid rgba(255,255,255,0.1);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: var(--transition);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.avatar-button:hover {
  transform: scale(1.05);
}

.message-bubble-button {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(111, 42, 141, 0.16);
  background: #ffffff;
  color: var(--brand-plum);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(74, 23, 100, 0.1);
  transition: var(--transition);
}

.message-bubble-button:hover {
  transform: translateY(-1px);
  border-color: rgba(111, 42, 141, 0.32);
}

.message-bubble-button span {
  position: absolute;
  top: -4px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand-plum);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 18px;
  box-shadow: 0 3px 10px rgba(74, 23, 100, 0.25);
}

.message-bubble-button span[hidden] {
  display: none;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  animation: slideIn 0.3s ease;
}

.screen.is-active {
  display: block;
}

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

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 8px 4px;
}

.screen-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.back-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* ===== SUMMARY CARD ===== */
.summary-card {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.summary-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 4px;
}

.summary-value strong {
  font-size: 2.2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.summary-value span {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Circular Progress */
.circular-progress {
  position: relative;
  width: 72px;
  height: 72px;
}

.circular-progress svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.circular-progress .track {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
}

.circular-progress .fill {
  fill: none;
  stroke: url(#gradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  transition: stroke-dashoffset 1s ease;
}

.ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Macros Row */
.macros-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.macro-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}

.macro-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s ease;
  width: 0%;
}

.macro-fill.protein { background: var(--protein); }
.macro-fill.carbs { background: var(--carbs); }
.macro-fill.fat { background: var(--fat); }

.macro-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.macro-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Water Tracker */
.water-tracker {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.water-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--water);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition-bounce);
  flex-shrink: 0;
}

.water-btn:hover {
  transform: scale(1.1);
  background: rgba(6, 182, 212, 0.25);
}

.water-btn:active {
  transform: scale(0.95);
}

.water-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.water-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
}

.water-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--water);
}

.water-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  max-width: 80px;
}

.water-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--water);
  transition: width 0.5s ease;
  width: 0%;
}

/* ===== COACH NOTE ===== */
.coach-note-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: -8px 0 24px;
}

.coach-note-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-plum));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
}

.coach-note-content {
  min-width: 0;
}

.coach-note-content span {
  display: block;
  color: var(--accent-primary);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}

.coach-note-content p {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.coach-note-action {
  grid-column: 2;
  justify-self: start;
  border: none;
  background: rgba(183, 106, 215, 0.14);
  color: var(--accent-primary);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 0.76rem;
  cursor: pointer;
}

/* ===== SECTION TITLE ===== */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

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

/* ===== QUICK ACTIONS ===== */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.quick-action:hover {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.15);
  box-shadow: var(--shadow-md);
}

.quick-action:active {
  transform: translateY(0);
}

.quick-action.camera-action .quick-icon {
  background: linear-gradient(135deg, #f97316, #fb7185);
}

.quick-action.chat-action .quick-icon {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-plum));
}

.quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-plum), var(--accent-primary));
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.quick-action span {
  font-size: 0.95rem;
  font-weight: 700;
}

.quick-action small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== MEALS LIST ===== */
.meals-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  transition: var(--transition);
  cursor: pointer;
  min-height: 88px;
}

a.meal-item {
  color: inherit;
  text-decoration: none;
}

.meal-item:hover {
  border-color: rgba(255,255,255,0.15);
}

.meal-icon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(183, 106, 215, 0.16);
  border: 1px solid rgba(183, 106, 215, 0.26);
  color: var(--accent-primary);
  display: grid;
  place-items: center;
  font-size: 1rem;
  font-weight: 900;
  flex-shrink: 0;
}

.meal-info {
  min-width: 0;
}

.meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.meal-type-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.meal-desc {
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.meal-tags span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 800;
}

.meal-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.meals-list .meal-item {
  min-height: 76px;
}

.meals-list .meal-desc {
  display: none;
}

/* ===== CAMERA SECTION ===== */
.camera-section {
  margin-bottom: 20px;
}

.camera-preview {
  aspect-ratio: 4/3;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.62);
  border: 2px dashed var(--glass-border);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 16px;
  transition: var(--transition);
}

.camera-preview.has-image {
  border-style: solid;
  border-color: var(--accent-primary);
}

.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-placeholder {
  text-align: center;
  padding: 20px;
}

.camera-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--glass);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.camera-placeholder p {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.camera-placeholder small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.camera-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.camera-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.camera-btn.primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.camera-btn.secondary {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
}

.camera-btn:hover {
  transform: translateY(-2px);
}

/* ===== ANALYSIS RESULT ===== */
.analysis-result {
  animation: slideUp 0.4s ease;
  scroll-margin-top: calc(104px + env(safe-area-inset-top, 0px));
}

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

.analysis-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  aspect-ratio: 4/3;
}

.analysis-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.analysis-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.analysis-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.confidence-badge {
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(183, 106, 215, 0.16);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 700;
}

.analysis-calories {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--glass-border);
}

.big-calorie {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.big-calorie strong {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.big-calorie span {
  color: var(--text-muted);
  font-weight: 600;
}

.calorie-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: rgba(183, 106, 215, 0.13);
  color: var(--success);
  font-size: 0.8rem;
  font-weight: 700;
}

.calorie-status.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.foods-detected {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.food-detected-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(111, 42, 141, 0.06);
}

.food-detected-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #84cc16);
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.food-detected-info {
  flex: 1;
}

.food-detected-info span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
}

.food-detected-info small {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.food-detected-cals {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-secondary);
}

.analysis-macros {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--glass-border);
}

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

.amacro-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.amacro-dot.protein { background: var(--protein); }
.amacro-dot.carbs { background: var(--carbs); }
.amacro-dot.fat { background: var(--fat); }

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

.amacro strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.suggestions-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(183, 106, 215, 0.08);
  border: 1px solid rgba(183, 106, 215, 0.15);
}

.suggestions-box h4 {
  font-size: 0.8rem;
  color: var(--success);
  margin-bottom: 8px;
  font-weight: 700;
}

.suggestion-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.suggestion-item::before {
  content: '💡';
  flex-shrink: 0;
}

.analysis-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== MEAL TYPE SELECTOR ===== */
.meal-type-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.meal-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.meal-type-btn span {
  font-size: 1.3rem;
}

.meal-type-btn.is-active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* ===== FORM CARD ===== */
.form-card {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.input-row {
  display: flex;
  gap: 12px;
  min-width: 0;
}

.input-group.half {
  flex: 1;
  min-width: 0;
}

.input-group.half label {
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.input-group.half input {
  width: 100%;
  min-width: 0;
}

@media (max-width: 430px) {
  .input-row {
    flex-direction: column;
    gap: 0;
  }
}

/* ===== APPOINTMENTS ===== */
.appointment-card {
  margin-bottom: 16px;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.time-chip {
  min-height: 42px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--brand-deep);
  font-weight: 900;
  cursor: pointer;
  transition: var(--transition);
}

.time-chip.is-active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(74, 23, 100, 0.18);
}

.appointment-list {
  display: grid;
  gap: 10px;
}

.appointment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  padding: 14px;
}

.appointment-row strong {
  display: block;
  color: var(--brand-deep);
  font-size: 0.94rem;
  margin-bottom: 3px;
}

.appointment-row p {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.35;
}

.appointment-badge {
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.appointment-badge.confirmed {
  background: #f3e8ff;
  color: #581c87;
}

.appointment-badge.requested {
  background: #fff7ed;
  color: #9a3412;
}

.appointment-badge.cancelled {
  background: #ffe4e6;
  color: #be123c;
}

.appointment-badge.completed {
  background: #ecfdf5;
  color: #047857;
}

.appointment-alert {
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(111, 42, 141, 0.18);
}

.appointment-alert strong,
.appointment-alert span {
  display: block;
}

.appointment-alert strong {
  color: var(--brand-deep);
  margin-bottom: 3px;
}

.appointment-alert span {
  color: var(--text-secondary);
  font-size: 0.86rem;
}

/* ===== WEIGHT CARD ===== */
.weight-card {
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  text-align: center;
}

.weight-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.weight-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}

.weight-value strong {
  font-size: 3rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.weight-value span {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 600;
}

.weight-change {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(183, 106, 215, 0.13);
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 700;
}

.weight-input-wrapper {
  position: relative;
}

.weight-input-wrapper input {
  padding-right: 50px;
}

.weight-unit {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.weight-chart-card,
.chart-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.weight-chart-card h3,
.chart-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.chart-container {
  height: 200px;
  position: relative;
}

/* ===== CHAT ===== */
.chat-header {
  padding: 8px 4px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  font-size: 1rem;
}

.chat-header-info h2 {
  font-size: 1rem;
  font-weight: 700;
}

.chat-status {
  font-size: 0.75rem;
  color: var(--success);
}

.chat-messages {
  height: calc(100vh - 200px);
  overflow-y: auto;
  padding: 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-date {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 8px 0;
}

.message {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  animation: messagePop 0.3s ease;
}

@keyframes messagePop {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.message.rita {
  align-self: flex-start;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.message.patient {
  align-self: flex-end;
  background: var(--accent-gradient);
  border-bottom-right-radius: 4px;
  color: white;
}

.message-time {
  display: block;
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.chat-input-area {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  padding: 12px 16px;
  background: rgba(255, 250, 253, 0.94);
  border-top: 1px solid var(--glass-border);
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border-radius: 24px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--glass-border);
}

.chat-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  padding: 10px 0;
  outline: none;
}

.chat-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.chat-attach,
.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.chat-attach {
  background: transparent;
  color: var(--text-muted);
}

.chat-send {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.chat-send:hover {
  transform: scale(1.1);
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
  display: block;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* ===== DIARY ===== */
.diary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diary-date-header {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 4px;
  margin-top: 8px;
}

/* ===== PROFILE ===== */
.profile-hero {
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  margin-bottom: 20px;
}

.profile-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  font-size: 2rem;
  font-weight: 800;
  color: white;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.profile-hero h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.profile-hero span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.diet-plan-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.diet-plan-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.plan-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.plan-detail-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(111, 42, 141, 0.06);
}

.plan-detail-item span {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.plan-detail-item strong {
  font-size: 1rem;
  font-weight: 700;
}

.plan-notes {
  grid-column: 1 / -1;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(111, 42, 141, 0.06);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  border: none;
  width: 100%;
}

.settings-item:hover {
  background: rgba(255,255,255,0.08);
}

.settings-item svg:last-child {
  margin-left: auto;
  color: var(--text-muted);
}

.settings-icon {
  font-size: 1.3rem;
}

.settings-label {
  flex: 1;
}

.payment-item {
  background: linear-gradient(135deg, rgba(74, 23, 100, 0.26), rgba(240, 184, 215, 0.1));
  border: 1px solid rgba(183, 106, 215, 0.24);
}

.logout-item {
  color: #ef4444;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 250, 253, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  z-index: 100;
}

.bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  flex: 1;
}

.bottom-nav button svg {
  transition: var(--transition);
}

.bottom-nav button.is-active {
  color: var(--accent-secondary);
}

.bottom-nav button.is-active svg {
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top, 0px));
  left: 50%;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%) translateY(-24px);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1.35;
  color: var(--brand-plum);
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
  white-space: normal;
  overflow-wrap: anywhere;
}

.toast.is-error {
  border-color: rgba(186, 23, 68, 0.24);
}

.toast.is-error .toast-icon {
  color: #ba1744;
}

.pwa-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 88px;
  z-index: 1200;
  max-width: 460px;
  margin: 0 auto;
  border: 1px solid rgba(123, 44, 160, 0.22);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 48px rgba(74, 23, 100, 0.18);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 32px;
  align-items: center;
  gap: 10px;
}

.pwa-notice[hidden] {
  display: none;
}

.pwa-notice strong,
.pwa-notice span {
  display: block;
}

.pwa-notice strong {
  color: #25102f;
  font-size: 0.9rem;
}

.pwa-notice span {
  color: #75617e;
  font-size: 0.76rem;
  line-height: 1.35;
  margin-top: 2px;
}

.pwa-notice button {
  border: none;
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}

#pwa-install-notify {
  background: #7b2ca0;
  color: #fff;
  padding: 10px 13px;
}

#pwa-notice-close {
  width: 32px;
  height: 32px;
  background: #fbf4ff;
  color: #7b2ca0;
  font-size: 1.1rem;
  line-height: 1;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(10px);
  z-index: 3000;
}

.loading-overlay.is-active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent-primary);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
}

/* ===== MANUAL INPUT ===== */
.manual-input-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manual-input-section label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.manual-input-section textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: #ffffff;
  color: var(--text-primary);
  padding: 15px 16px;
  font: inherit;
  line-height: 1.4;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.manual-input-section textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.manual-input-section textarea::placeholder {
  color: var(--text-muted);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 2px;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
  body {
    display: grid;
    place-items: center;
    padding: 20px;
  }
  
  .app-shell {
    min-height: 800px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: 0 32px 80px rgba(0,0,0,0.4);
  }
  
  .chat-input-area {
    position: absolute;
    bottom: 80px;
  }
}

@media (min-width: 980px) {
  body {
    align-items: stretch;
    padding: 24px;
  }

  .app-shell {
    display: none;
    grid-template-columns: 246px minmax(0, 1fr);
    column-gap: 22px;
    width: min(1180px, calc(100vw - 48px));
    max-width: none;
    min-height: calc(100vh - 48px);
    padding: 18px 22px 28px 18px;
  }

  .app-shell.is-ready {
    display: grid;
  }

  .app-sidebar {
    position: sticky;
    top: 18px;
    display: block;
    align-self: start;
    min-height: calc(100vh - 84px);
    padding: 18px;
    border: 1px solid var(--glass-border);
    border-radius: 22px;
    background: rgba(255, 250, 253, 0.84);
    box-shadow: 0 22px 60px rgba(74, 23, 100, 0.1);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .top-bar,
  .screen {
    grid-column: 2;
  }

  .top-bar {
    margin: 0 0 18px;
    padding: 10px 4px 14px;
    background: transparent;
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .screen.is-active {
    max-width: 760px;
  }

  .bottom-nav {
    display: none;
  }

  .chat-input-area {
    position: sticky;
    bottom: 0;
  }
}
