/* ===== ROOT VARIABLES ===== */
:root {
  --bg: #F9F9FB;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-sidebar: rgba(255, 255, 255, 0.85);
  --bg-input: rgba(0, 0, 0, 0.03);
  --primary: #FF2D55;
  --primary-hover: #E02447;
  --primary-fg: #ffffff;
  --text: #1C1C1E;
  --text-muted: #8E8E93;
  --border: rgba(0, 0, 0, 0.1);
  --accent: rgba(0, 0, 0, 0.04);
  --radius: 20px;
  --radius-sm: 12px;
  --spring: cubic-bezier(0.25, 0.8, 0.25, 1);
  --bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --glass: blur(24px) saturate(180%);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: "SF Pro Display", "SF Pro Text", "Sukhumvit Set", "Prompt", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(255, 45, 85, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(255, 45, 85, 0.03) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.w-full { width: 100%; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s var(--spring);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--accent); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--text-muted); }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-primary { background: rgba(255, 45, 85, 0.1); color: var(--primary); border: 1px solid rgba(255, 45, 85, 0.3); }
.badge-muted { background: var(--accent); color: var(--text-muted); }

/* ===== TOAST ===== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 0.875rem;
  color: var(--text);
  animation: slideIn 0.4s var(--bounce);
  max-width: 300px;
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.toast.success { border-left: 3px solid #4ade80; }
.toast.error { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  animation: scaleIn 0.4s var(--bounce);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== PAGES ===== */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; animation: pageFadeIn 0.5s var(--spring); }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ===== LOGIN PAGE ===== */
#page-login {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  padding: 24px;
}
.hearts-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.heart {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.15;
  animation: floatHeart linear infinite;
}
@keyframes floatHeart {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0.15; }
  100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
}
.login-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-title { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass); }
.passcode-dots { display: flex; justify-content: center; gap: 10px; margin: 16px 0; }
.passcode-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.2s;
}
.passcode-dot.filled { background: var(--primary); border-color: var(--primary); }
.passcode-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.passcode-tap-area {
  cursor: text;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}
.passcode-tap-area:hover { border-color: var(--primary); color: var(--text); }
.passcode-error { color: var(--primary); font-size: 0.85rem; margin-top: 8px; }

/* Profile selection */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.profile-card:hover { border-color: var(--primary); background: rgba(255, 45, 85, 0.05); transform: scale(1.03); box-shadow: 0 8px 24px rgba(255,45,85,0.08); }
.profile-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  margin: 0 auto 10px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 0.9rem; font-weight: 500; }

/* ===== APP SHELL (after login) ===== */
#app-shell {
  display: none;
  width: 100%;
  min-height: 100vh;
  flex-direction: column;
}
#app-shell.active { display: flex; }

/* Top navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.navbar-brand { font-size: 1rem; font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.navbar-actions { display: flex; align-items: center; gap: 8px; }

/* Profile dropdown */
.profile-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
  color: var(--text);
}
.profile-btn:hover { border-color: var(--primary); }
.profile-btn img { width: 100%; height: 100%; object-fit: cover; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 160px;
  padding: 6px;
  z-index: 200;
  animation: scaleIn 0.3s var(--bounce);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s;
  border: none; background: none; width: 100%; color: var(--text); text-align: left;
}
.dropdown-item:hover { background: var(--accent); }
.dropdown-item.danger { color: var(--primary); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  border: none; background: none;
  gap: 3px;
  font-family: inherit;
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--primary); }

/* Page content */
.page-content {
  flex: 1;
  padding: 20px;
  padding-bottom: 80px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ===== HOME PAGE ===== */
.home-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.home-greeting { font-size: 1.8rem; font-weight: 700; margin-bottom: 2px; letter-spacing: -0.5px; }
.home-partner { font-size: 0.95rem; color: var(--text-muted); }
.home-partner span { color: var(--primary); font-weight: 600; }
.home-header-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.home-header-avatar img { width: 100%; height: 100%; object-fit: cover; }

.anniversary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.anniversary-icon { 
  width: 56px; height: 56px; border-radius: 16px;
  background: rgba(255, 45, 85, 0.1); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.anniversary-icon i { width: 28px; height: 28px; }
.anniversary-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.anniversary-date { font-weight: 700; font-size: 1.1rem; color: var(--text); margin-top: 2px; }
.anniversary-days { font-size: 0.85rem; color: var(--primary); margin-top: 2px; font-weight: 500; }

.nav-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.nav-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
  display: flex; flex-direction: column; gap: 12px;
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.nav-card:hover { border-color: var(--primary); background: rgba(255, 45, 85, 0.02); transform: scale(1.02); box-shadow: 0 8px 24px rgba(255,45,85,0.08); }
.nav-card-icon-wrapper {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.nav-card-icon-wrapper i { width: 24px; height: 24px; }
.nav-card-label { font-size: 0.95rem; font-weight: 600; color: var(--text); }

/* iOS Widget Style */
.widget-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04);
  -webkit-backdrop-filter: var(--glass);
  backdrop-filter: var(--glass);
}
.widget-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.widget-title { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.randomizer-box { text-align: center; }
#random-food-text {
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  margin-bottom: 16px; padding: 24px 0;
  background: var(--bg-input); border-radius: 16px;
  border: 1px solid var(--border);
}
.food-slot-spin { animation: slotSpin 0.1s linear infinite; color: var(--primary) !important; }
@keyframes slotSpin { 0% { transform: translateY(-5px); opacity: 0.8; } 50% { transform: translateY(5px); opacity: 1; } 100% { transform: translateY(-5px); opacity: 0.8; } }

.food-add-row { display: flex; gap: 8px; margin-top: 16px; }
.food-add-row .input { flex: 1; border-radius: 12px; }
.food-list-text { margin-top: 12px; font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; text-align: left; background: var(--bg-input); padding: 12px; border-radius: 12px; }

.quick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.quick-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.quick-stat-value { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.quick-stat-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== ALBUM PAGE ===== */
.album-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.album-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s var(--spring);
  margin-bottom: 24px;
  position: relative;
  background: var(--bg-card);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: rgba(255, 45, 85, 0.03); }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-text { font-size: 0.9rem; color: var(--text-muted); }
.upload-text strong { color: var(--text); }
.photo-grid {
  columns: 2;
  gap: 10px;
}
@media (min-width: 480px) { .photo-grid { columns: 3; } }
@media (min-width: 640px) { .photo-grid { columns: 4; } }
.photo-item {
  break-inside: avoid;
  margin-bottom: 10px;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
}
.photo-item img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  transition: transform 0.2s;
}
.photo-item:hover img { transform: scale(1.02); }
.photo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: var(--radius-sm);
}
.photo-item:hover .photo-overlay { opacity: 1; }
.photo-delete-btn {
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: white;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
}
.photo-date { font-size: 0.7rem; color: rgba(255,255,255,0.7); margin-bottom: 4px; }
.album-empty { text-align: center; padding: 48px; color: var(--text-muted); }
.album-empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* ===== LIGHTBOX + COMMENTS ===== */
body.lightbox-open {
  background: #000 !important;
}
body.lightbox-open #app-shell {
  visibility: hidden;
}

.lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  height: 100dvh;
  background: #000; z-index: 2000;
  display: flex; flex-direction: column;
  animation: fadeIn 0.2s ease;
}
.lb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: rgba(0,0,0,0.7); flex-shrink: 0;
}
.lb-btn {
  background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
  width: 36px; height: 36px; color: #fff; font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.lb-btn:hover { background: rgba(255,255,255,0.2); }
.lb-btn.danger:hover { background: rgba(220,50,50,0.6); }
.lb-date { font-size: 0.8rem; color: rgba(255,255,255,0.55); }
.lb-photo-area {
  position: relative; flex: 0 0 auto; height: 44vh;
  display: flex; align-items: center; justify-content: center;
  background: #000; overflow: hidden;
}
.lb-photo-area img { max-width: 100%; max-height: 44vh; object-fit: contain; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(0,0,0,0.55); color: #fff; border: none;
  font-size: 1.8rem; width: 38px; height: 38px; cursor: pointer;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.lb-nav:hover { background: rgba(255,255,255,0.2); }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-comments {
  flex: 1; display: flex; flex-direction: column;
  background: var(--bg); border-top: 1px solid var(--border); min-height: 0;
}
.lb-comments-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: 0.875rem; font-weight: 600;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.lb-comments-list {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px; min-height: 0;
}
.lb-empty-comments {
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
  padding: 20px; margin: auto; line-height: 1.8;
}
.lb-msg { display: flex; flex-direction: column; max-width: 75%; margin-bottom: 2px; }
.lb-msg.mine   { align-self: flex-end;   align-items: flex-end; }
.lb-msg.theirs { align-self: flex-start; align-items: flex-start; }
.lb-msg-name { font-size: 0.65rem; color: var(--text-muted); margin-bottom: 2px; padding: 0 4px; }
.lb-msg-bubble {
  padding: 8px 14px; border-radius: 18px;
  font-size: 0.95rem; line-height: 1.4; word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.lb-msg.mine   .lb-msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.lb-msg.theirs .lb-msg-bubble { background: #E9E9EB; color: #000; border-bottom-left-radius: 4px; }
.lb-msg-time { font-size: 0.6rem; color: var(--text-muted); margin-top: 2px; padding: 0 4px; opacity: 0; transition: opacity 0.2s; }
.lb-msg:hover .lb-msg-time { opacity: 1; }
.lb-input-row {
  display: flex; gap: 8px; padding: 8px 8px 8px 16px;
  margin: 10px 16px 24px 16px;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  flex-shrink: 0; align-items: center;
}
.lb-input {
  flex: 1; min-width: 0; background: transparent;
  border: none; border-radius: 0;
  padding: 4px 0; color: #000;
  font-family: "SF Pro Text", "Sukhumvit Set", "Prompt", sans-serif; font-size: 1rem; outline: none;
  box-shadow: none;
}
.lb-input:focus { border-color: var(--primary); }
.lb-send {
  background: var(--primary); color: #fff; border: none; border-radius: 50%;
  width: 36px; height: 36px; font-size: 0.9rem; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(255,45,85,0.3);
}
.lb-send:active { transform: scale(0.9); }
.lb-send:hover { background: var(--primary-hover); }
.lb-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CROP MODAL ===== */
.crop-wrapper { display: flex; justify-content: center; padding: 6px 0; }
.crop-viewport {
  width: 260px; height: 260px; border-radius: 50%;
  overflow: hidden; position: relative; cursor: grab;
  background: #111; border: 3px solid var(--primary);
  user-select: none; touch-action: none;
}
.crop-viewport:active { cursor: grabbing; }
.crop-viewport img {
  position: absolute; user-select: none;
  pointer-events: none; -webkit-user-drag: none;
}
.crop-hint { font-size: 0.75rem; color: var(--text-muted); text-align: center; margin: 6px 0 12px; }
.photo-loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 0.85rem;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== COUPONS PAGE ===== */
.coupons-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.coupons-title { font-size: 1.3rem; font-weight: 700; cursor: pointer; user-select: none; }
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.coupon-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.coupon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.coupon::before, .coupon::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--bg);
}
.coupon::before { left: -10px; }
.coupon::after { right: -10px; }
.coupon.redeemed { opacity: 0.5; }
.coupon-emoji { font-size: 2rem; flex-shrink: 0; }
.coupon-body { flex: 1; }
.coupon-title { font-weight: 600; }
.coupon-status { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.coupon-actions { flex-shrink: 0; }
.refill-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

/* ===== WRAPPED PAGE ===== */
.wrapped-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.wrapped-title { font-size: 1.3rem; font-weight: 700; }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.chart-title { font-weight: 600; margin-bottom: 16px; }
.chart-container { position: relative; height: 220px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-emoji { font-size: 1.5rem; margin-bottom: 6px; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }
.insights-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.insight-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.insight-item:last-child { border-bottom: none; }
.insight-icon { font-size: 1.2rem; flex-shrink: 0; }
.insight-text { font-size: 0.875rem; color: var(--text-muted); }
.insight-text strong { color: var(--text); }

/* Debt mode */
.debt-section { margin-top: 20px; }
.debt-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: #fbbf24; }
.debt-item {
  background: var(--bg-card);
  border: 1px solid hsl(45, 90%, 20%);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.875rem;
}
.debt-amount { font-weight: 700; color: #fbbf24; }
.debt-add-btn { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.debt-add-btn .input { min-width: 120px; flex: 1; }
.debt-add-btn select.input { min-width: 100px; flex: 0 0 auto; }

/* Edit stats modal */
.edit-stats-grid { display: flex; flex-direction: column; gap: 14px; }
.edit-stat-row { display: flex; align-items: center; gap: 12px; }
.edit-stat-emoji { font-size: 1.5rem; flex-shrink: 0; }
.edit-stat-label { flex: 1; font-size: 0.9rem; }
.edit-stat-input { width: 80px; text-align: center; }

/* ===== PROFILE EDIT ===== */
.avatar-upload { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar-preview {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .nav-cards { grid-template-columns: 1fr 1fr; }
  .nav-cards .nav-card:last-child { grid-column: span 2; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
  /* จัดโครงสร้าง Desktop ด้วย Grid */
  #app-shell.active {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "sidebar navbar"
      "sidebar content";
    align-items: start;
  }
  
  /* ย้าย Bottom Nav มาเป็น Sidebar ด้านซ้าย */
  .bottom-nav {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    gap: 12px;
  }
  .bottom-nav-item {
    flex: none; /* override flex: 1 from mobile */
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 20px;
    border-radius: 12px;
    width: 100%;
  }
  .bottom-nav-item svg { width: 20px; height: 20px; margin-right: 12px; margin-bottom: 0; }
  
  .navbar {
    grid-area: navbar;
    border-bottom: 1px solid var(--border);
  }
  
  /* เนื้อหาหลัก */
  .page-content { 
    grid-area: content;
    padding: 40px; 
    padding-bottom: 40px; /* ไม่ต้องเผื่อที่ให้ Bottom Nav แล้ว */
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
  }
  
  .home-greeting { font-size: 2rem; }
  
  /* จำกัดขนาดกล่องคอมเมนต์ Lightbox ไม่ให้ยืดเต็มจอ */
  .lb-comments {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .lb-photo-area {
    height: 100%; /* ให้รูปภาพแสดงเต็มพื้นที่ซ้ายขวาที่เหลือ */
  }
  .lightbox {
    flex-direction: row; /* แบ่งรูปกับคอมเมนต์ซ้ายขวา */
  }
  .lb-comments {
    width: 400px;
    height: 100%;
    border-top: none;
    border-left: 1px solid var(--border);
  }
  .lb-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, transparent 100%);
  }
}



/* ===== FOOD RANDOMIZER ===== */
.randomizer-box {
  background: var(--bg-card, #ffffff);
  border: 3px dashed #ff477e;
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  margin: 10px 0;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(255, 71, 126, 0.1);
}

#random-food-text {
  font-size: 2.5rem;
  font-weight: 700;
  color: #333;
  transition: transform 0.1s ease;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.random-food-btn {
  background: linear-gradient(135deg, #ff477e, #ff7096);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px auto;
  box-shadow: 0 4px 12px rgba(255, 71, 126, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
  max-width: 300px;
}

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

.food-slot-spin {
  animation: slotSpin 0.1s infinite;
}

@keyframes slotSpin {
  0% { transform: translateY(-5px) scale(1.05); }
  50% { transform: translateY(5px) scale(0.95); }
  100% { transform: translateY(-5px) scale(1.05); }
}

/* ===== BUCKET LIST ===== */
.bucket-progress-card {
  background: var(--bg-card, #ffffff);
  padding: 20px;
  border-radius: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.progress-bar-bg {
  background: #eee;
  border-radius: 10px;
  height: 12px;
  width: 100%;
  overflow: hidden;
}

.progress-bar-fill {
  background: linear-gradient(135deg, #ff477e, #ff7096);
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease-out;
}

.bucket-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.bucket-item {
  background: var(--bg-card, #ffffff);
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: opacity 0.3s, transform 0.2s;
}

.bucket-item:active {
  transform: scale(0.98);
}

.bucket-item.done {
  opacity: 0.6;
}

.bucket-item.done .bucket-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.bucket-item-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  cursor: pointer;
}

.checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.checkbox.checked {
  background: #ff477e;
  border-color: #ff477e;
}

.bucket-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.bucket-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.bucket-add-card {
  background: var(--bg-card, #ffffff);
  padding: 16px;
  border-radius: 16px;
  border: 2px dashed #ff477e;
  box-shadow: 0 4px 12px rgba(255, 71, 126, 0.05);
}

.bucket-delete {
  color: #ff4d4f;
  padding: 8px;
}

/* ===== CALENDAR PAGE ===== */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.calendar-title { font-size: 1.3rem; font-weight: 700; }
.calendar-card { padding: 16px; border-radius: var(--radius); margin-bottom: 24px; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-month-name { font-weight: 600; font-size: 1.1rem; }
.calendar-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
  cursor: pointer;
  background: var(--bg-input);
  border: 1px solid transparent;
  transition: all 0.2s;
  position: relative;
}
.calendar-day:hover { background: var(--accent); transform: scale(1.05); z-index: 10; }
.calendar-day.empty { background: transparent; cursor: default; pointer-events: none; }
.calendar-day.today { border-color: var(--primary); font-weight: bold; color: var(--primary); }
.calendar-day.has-event { background: rgba(255, 71, 126, 0.15); border: 1px solid rgba(255, 71, 126, 0.3); }
.day-number { font-size: 0.85rem; }
.event-dots { display: flex; gap: 2px; margin-top: auto; padding-bottom: 4px; flex-wrap: wrap; justify-content: center; max-width: 80%; }
.event-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--primary); }

.upcoming-events { margin-top: 24px; }
.upcoming-event-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.upcoming-event-item:hover { background: var(--accent); }
.upcoming-date { color: var(--primary); font-weight: 600; font-size: 0.85rem; width: 45px; text-align: center; }
.upcoming-title { flex: 1; font-weight: 500; font-size: 0.95rem; }

.day-events-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.day-event-item {
  background: var(--bg-input);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.day-event-title { font-weight: 500; font-size: 0.95rem; flex: 1; }