:root {
  --bg-warm: #fff5f7;
  --glass-bg: rgba(255, 251, 252, 0.74);
  --glass-bg-strong: rgba(255, 253, 254, 0.88);
  --glass-border: rgba(255, 255, 255, 0.82);
  --glass-rose-border: rgba(244, 114, 182, 0.24);
  --rose-400: #fb7185;
  --rose-500: #ec4899;
  --rose-600: #db2777;
  --rose-700: #be185d;
  --peach-400: #fb923c;
  --text-main: #2d1c23;
  --text-muted: #6e525e;
  --safe-bg: rgba(236, 253, 245, 0.9);
  --safe-text: #065f46;
  --warn-bg: rgba(255, 251, 235, 0.92);
  --warn-text: #92400e;
  --avoid-bg: rgba(255, 241, 242, 0.92);
  --avoid-text: #9f1239;
  --shadow-glass: 0 12px 34px rgba(190, 24, 93, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 15px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(155deg, #ffe4ee 0%, #fff1e6 48%, #fce7f3 100%);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: 'Playfair Display', Georgia, serif;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* Liquid Organic Background Blobs */
.liquid-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.65;
  animation: floatBlob 14s ease-in-out infinite alternate;
}

.blob-1 {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, #f9a8d4, #fbcfe8);
  top: -80px;
  left: -60px;
}

.blob-2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #fed7aa, #fecdd3);
  top: 35%;
  right: -70px;
  animation-delay: -4s;
}

.blob-3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #fbcfe8, #fde68a);
  bottom: -90px;
  left: 15%;
  animation-delay: -8s;
}

@keyframes floatBlob {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(24px, -28px) scale(1.08); }
}

/* Mobile-First Device Frame */
.mobile-viewport {
  position: relative;
  z-index: 1;
  max-width: 450px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 14px 14px 104px;
}

@media (min-width: 520px) {
  body {
    padding: 18px 0;
  }
  .mobile-viewport {
    background: rgba(255, 247, 250, 0.42);
    backdrop-filter: blur(30px);
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    border-radius: 38px;
    box-shadow: 0 28px 70px rgba(190, 24, 93, 0.16);
    min-height: calc(100vh - 36px);
    padding: 16px 16px 106px;
  }
}

/* Liquid Glass Cards */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.glass-rose {
  background: linear-gradient(145deg, rgba(255, 240, 246, 0.84), rgba(255, 248, 243, 0.78));
  border: 1px solid rgba(251, 113, 133, 0.32);
}

/* Sticky Liquid Topbar */
.topbar {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: var(--shadow-glass);
  position: sticky;
  top: 10px;
  z-index: 40;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: linear-gradient(135deg, #fb7185, #db2777);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 6px 14px rgba(219, 39, 119, 0.28);
}

.brand-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--rose-700);
  line-height: 1.05;
}

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

.role-switch {
  display: inline-flex;
  background: rgba(252, 231, 243, 0.8);
  border: 1px solid rgba(244, 114, 182, 0.25);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.role-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.role-btn.active {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #fff;
  box-shadow: 0 4px 12px rgba(219, 39, 119, 0.26);
}

.badge-count {
  background: #fff;
  color: var(--rose-600);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
}

/* Hero Photo Card */
.hero-photo-card {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  min-height: 215px;
  margin-bottom: 14px;
  box-shadow: 0 16px 36px rgba(190, 24, 93, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.hero-photo-card img {
  width: 100%;
  height: 230px;
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(45, 28, 35, 0.08) 0%, rgba(45, 28, 35, 0.72) 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.24);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  width: fit-content;
  margin-bottom: 6px;
}

.glass-pill-pink {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(253, 242, 248, 0.9);
  border: 1px solid rgba(244, 114, 182, 0.35);
  color: var(--rose-700);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

/* Progress */
.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #fda4af, #fb7185, #f472b6);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Horizontal Swipe Carousels */
.h-scroll {
  display: flex;
  gap: 11px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

.h-scroll::-webkit-scrollbar {
  display: none;
}

.story-chip-card {
  min-width: 145px;
  scroll-snap-align: start;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(190, 24, 93, 0.08);
  cursor: pointer;
}

.story-chip-card img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
}

.story-chip-card .caption {
  padding: 8px 10px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Buttons & Inputs */
.btn {
  border: none;
  padding: 11px 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #fb7185, #db2777);
  color: #fff;
  box-shadow: 0 8px 20px rgba(219, 39, 119, 0.28);
}

.btn-soft {
  background: rgba(252, 231, 243, 0.85);
  color: var(--rose-700);
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.95);
  color: var(--text-main);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.76rem;
  border-radius: 11px;
}

.btn-full {
  width: 100%;
}

.input, .select, .textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(244, 114, 182, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--rose-500);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.14);
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.form-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
}

/* Chips */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.chip {
  border: 1px solid rgba(244, 114, 182, 0.26);
  background: rgba(255, 255, 255, 0.72);
  color: var(--rose-700);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #fff;
  border-color: transparent;
}

/* Segment Control */
.segment-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 4px;
  margin-bottom: 14px;
}

.segment-btn {
  border: none;
  background: transparent;
  padding: 9px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
}

.segment-btn.active {
  background: #fff;
  color: var(--rose-700);
  box-shadow: 0 4px 12px rgba(190, 24, 93, 0.1);
}

/* Lists & Badges */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 1.12rem;
  color: var(--rose-700);
}

.muted {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.list-row {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.list-row.done {
  opacity: 0.78;
  background: rgba(255, 255, 255, 0.52);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-safe { background: var(--safe-bg); color: var(--safe-text); }
.status-warn { background: var(--warn-bg); color: var(--warn-text); }
.status-avoid { background: var(--avoid-bg); color: var(--avoid-text); }

/* Floating SOS Craving FAB */
.fab-craving {
  position: fixed;
  right: 18px;
  bottom: 84px;
  z-index: 45;
  border: none;
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.84rem;
  box-shadow: 0 12px 28px rgba(225, 29, 72, 0.36);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (min-width: 520px) {
  .fab-craving {
    right: calc(50% - 208px);
    bottom: 92px;
  }
}

/* Liquid Glass Floating Bottom Tab Bar */
.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 426px;
  background: rgba(255, 250, 252, 0.82);
  backdrop-filter: blur(26px) saturate(200%);
  -webkit-backdrop-filter: blur(26px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 36px rgba(190, 24, 93, 0.16), inset 0 1px 0 #fff;
  border-radius: 26px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  z-index: 50;
}

.bottom-nav-btn {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  border-radius: 20px;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.bottom-nav-btn .ico {
  font-size: 1.15rem;
}

.bottom-nav-btn.active {
  background: linear-gradient(135deg, rgba(251, 113, 133, 0.2), rgba(236, 72, 153, 0.14));
  color: var(--rose-700);
}

/* Views */
.view-section {
  display: none;
  animation: fadeUp 0.24s ease;
}

.view-section.active {
  display: block;
}

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

/* Gallery & OCR */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.eco-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(190, 24, 93, 0.08);
}

.eco-card img {
  width: 100%;
  height: 132px;
  object-fit: cover;
  display: block;
}

.eco-card-body {
  padding: 9px 10px;
}

.ocr-box {
  background: linear-gradient(145deg, rgba(255, 245, 250, 0.9), rgba(255, 250, 242, 0.85));
  border: 1.5px dashed rgba(236, 72, 153, 0.4);
  border-radius: 18px;
  padding: 14px;
  text-align: center;
}

#scanner-video {
  width: 100%;
  max-height: 200px;
  border-radius: 14px;
  background: #1a1115;
  object-fit: cover;
  display: none;
  margin-bottom: 8px;
}

/* Modal Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 28, 35, 0.45);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  background: rgba(255, 250, 252, 0.96);
  backdrop-filter: blur(24px);
  border: 1px solid #fff;
  border-radius: 28px 28px 0 0;
  width: 100%;
  max-width: 450px;
  padding: 20px 18px 28px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(190, 24, 93, 0.2);
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(190, 24, 93, 0.94);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 10px 26px rgba(190, 24, 93, 0.3);
  z-index: 120;
  display: none;
  white-space: nowrap;
}

.toast.show {
  display: block;
}

@media print {
  body { background: #fff; padding: 0; }
  .liquid-bg, .topbar, .bottom-nav, .fab-craving, .no-print { display: none !important; }
  .mobile-viewport { max-width: 100%; box-shadow: none; border: none; padding: 0; }
  .view-section { display: none !important; }
  #view-album { display: block !important; }
}
