:root {
  color-scheme: light dark;
  --primary: #ff7e67;
  --primary-dark: #e0634f;
  --primary-bg: #fff1f0;
  --bg-app: #faf9f6;
  --card-bg: #ffffff;
  --text-main: #2c2a29;
  --text-muted: #8a8580;
  --border: #f0ede6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --caution: #eab308;
  --caution-bg: #fef9c3;

  /* --- Design tokens added 2026-09-18: spacing/radius/shadow/typography scale --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 50px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.08);

  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 28px;

  /* Semantic color tokens (a later task will use these) */
  --danger-bg: #fee2e2;
  --danger-bg-hover: #fecaca;
  --danger-text-strong: #991b1b;
  --success-bg: #d1fae5;
  --info-bg: #dbeafe;
  --info-bg-soft: #eff6ff;
  --neutral-bg: #f8fafc;
  --neutral-bg-strong: #f1f5f9;
  --neutral-border: #cbd5e1;
  --neutral-text-muted: #94a3b8;
  --favorite-bg: #facc15;
  --favorite-text: #854d0e;
  --pending-bg: #fef9c3;
  --approved-bg: #dcfce7;
  --approved-text: #166534;
  --tip-bg: #fffbeb;
  --tip-border: #fef3c7;
  --tip-text: #b45309;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: 'Noto Sans KR', 'Outfit', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden;
  /* Prevent body scroll, use app-content scroll */
  overscroll-behavior: none;
  /* iOS scroll bounce prevent */
  user-select: none;
  /* Make it feel more like an app */
}

h1,
h2,
h3 {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  margin: 0;
}

/* App Layout */
.app-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
  /* Safe area support */
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
  padding: 0 20px 24px;
  /* Removed top padding, handled by sticky header */
  animation: fadeIn 0.3s ease-out;
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Headers */
.sticky-top-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-app);
  margin: 0 -20px;
  padding: 0 20px 0;
  /* Safe area is handled by the ad container */
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0 10px;
  /* Reduced top padding to minimize gap with ad */
  background: transparent;
}

.view-header h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.more-menu-wrapper {
  position: relative;
}

.header-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 150;
}

.header-more-menu[hidden] {
  display: none;
}

.header-more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.header-more-item:hover,
.header-more-item:active {
  background: var(--bg-app);
}

.header-more-item-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.food-tip-hint {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--primary-bg, #eef4ff);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.food-tip-hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.food-tip-hint-emoji {
  font-size: 16px;
  flex-shrink: 0;
}

.food-tip-hint-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.food-tip-apply-btn {
  flex-shrink: 0;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.food-tip-apply-btn:active {
  transform: scale(0.96);
}

.food-tip-hint-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.search-container {
  margin-bottom: 8px;
}

.search-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box svg {
  color: var(--text-muted);
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 15px;
  outline: none;
}

.fridge-sort-toggle {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.sort-toggle-btn {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-toggle-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.sort-toggle-btn.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Buttons */
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--card-bg);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:active {
  transform: scale(0.95);
  background: var(--border);
}

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:active {
  background: var(--primary-dark);
}

.secondary-btn {
  background: var(--neutral-bg-strong);
  color: #475569;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
}

/* Category Chips */
.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: transparent;
  padding: 10px 0 20px;
  margin-bottom: 8px;
}

.category-scroll::-webkit-scrollbar {
  display: none;
}

.category-chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  gap: 6px;
}

.count-badge {
  font-size: 11px;
  background: var(--primary-bg);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-lg);
  font-weight: 800;
  transition: all 0.2s;
}

.category-chip.active .count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.category-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

.category-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.favorite-chip.active {
  background: var(--favorite-bg);
  border-color: var(--favorite-bg);
  color: var(--favorite-text);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.3);
}

.favorite-chip.active .count-badge {
  background: rgba(255, 255, 255, 0.4);
  color: var(--favorite-text);
}

.expired-chip.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.expired-chip.active .count-badge {
  background: rgba(255, 255, 255, 0.4);
  color: #fff;
}

/* Food List */
.food-list {
  display: grid;
  gap: 12px;
}

.food-item {
  background: var(--card-bg);
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.food-item:hover {
  transform: scale(1.01) translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-bg);
}

.food-item.caution {
  border-left: 3px solid var(--caution);
}

.food-item.warning {
  border-left: 4px solid var(--warning);
}

.food-item.expired {
  border-left: 4px solid var(--danger);
  background: var(--danger-bg);
}

.food-name {
  font-weight: 700;
  font-size: 16px;
}

.food-expiry {
  font-size: 13px;
  color: var(--text-muted);
}

.food-actions {
  display: flex;
  gap: 8px;
}

.food-actions button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.edit-btn {
  background: var(--primary-bg);
  color: var(--primary);
}

.delete-btn {
  background: var(--danger-bg);
  color: var(--danger);
}

.cart-btn {
  background: var(--bg-app);
  color: var(--text-muted);
}

.edit-btn:active,
.delete-btn:active,
.cart-btn:active {
  transform: scale(0.9);
}

.favorite-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
  transition: all 0.2s;
}

.favorite-btn:hover {
  transform: scale(1.2);
}

.favorite-btn.active {
  color: var(--favorite-bg);
  /* Yellow-400 */
  filter: drop-shadow(0 0 2px rgba(234, 179, 8, 0.3));
}

.star-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(80px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px env(safe-area-inset-bottom);
  z-index: 1000;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.03);
}

.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s;
}

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item span {
  font-size: 11px;
  font-weight: 700;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background-color: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  padding: 0 4px;
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.3);
}

/* Recipes */
.recipe-grid {
  display: grid;
  gap: 20px;
}

.recipe-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.03);
  display: flex;
  align-items: center;
  padding: 12px;
  gap: 16px;
}

.recipe-img-placeholder {
  width: 70px;
  height: 70px;
  border-radius: 16px;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.recipe-info h3 {
  font-size: 17px;
  margin-bottom: 4px;
}

.recipe-info p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Settings */
.settings-group {
  margin-bottom: 20px;
}

.settings-group label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  margin-left: 4px;
}

.settings-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 8px 20px;
  box-shadow: var(--shadow-sm);
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.code-with-share,
.nickname-with-edit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row .label {
  color: var(--text-muted);
  font-size: 15px;
}

.participation-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 6px;
  display: flex;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.participation-box input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 16px;
  outline: none;
}

.participation-box .primary-btn {
  padding: 12px 20px;
  border-radius: 12px;
}

/* Fridge Management List Style */
.fridge-management-list {
  padding: 0 !important;
}

.fridge-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.fridge-list-item:last-child {
  border-bottom: none;
}

.fridge-info-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fridge-icon-badge {
  width: 32px;
  height: 32px;
  background: var(--primary-bg);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.fridge-owner-name {
  font-weight: 700;
  font-size: 15px;
}

.fridge-tag {
  font-size: 11px;
  background: var(--neutral-bg-strong);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
}

.switch-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.switch-btn.current {
  background: var(--primary);
  color: white;
  cursor: default;
}

.switch-btn:hover:not(.current) {
  background: var(--info-bg);
}

.trash-btn {
  background: none;
  border: none;
  color: var(--neutral-text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trash-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.fridge-actions-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Memo Styles */
.memo-list {
  display: grid;
  gap: 16px;
  padding-bottom: 20px;
}

.memo-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  animation: fadeIn 0.3s ease-out;
}

.memo-content {
  font-size: 16px;
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-all;
  margin-bottom: 12px;
  line-height: 1.6;
}

.memo-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 6px;
}

.memo-tag-notice {
  background: #fee2e2;
  color: #ef4444;
  border: 1px solid #fca5a5;
}

.memo-tag-recipe {
  background: #ecfdf5;
  color: #10b981;
  border: 1px solid #6ee7b7;
}

.memo-tag-shopping {
  background: #fef3c7;
  color: #f59e0b;
  border: 1px solid #fcd34d;
}

.memo-tag-general {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.roulette-result-card {
  background: #fff8f7;
}

.memo-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.memo-date {
  font-weight: 400;
}

.memo-actions {
  display: flex;
  gap: 8px;
}

.memo-action-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.memo-edit-btn {
  color: var(--primary);
  background: var(--primary-bg);
}

.memo-delete-btn {
  color: var(--danger);
  background: var(--danger-bg);
}

.memo-edit-btn:hover {
  background: var(--info-bg);
}

.memo-delete-btn:hover {
  background: var(--danger-bg-hover);
}

/* Request Styles */
.request-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.request-item:last-child {
  border-bottom: none;
}

.request-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.request-requester {
  font-weight: 700;
  font-size: 15px;
}

.request-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.request-actions {
  display: flex;
  gap: 8px;
}

.btn-xs {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
}

.btn-approve {
  background: var(--primary);
  color: white;
}

.btn-reject {
  background: var(--neutral-bg-strong);
  color: var(--text-muted);
}

.status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.status-pending {
  background: var(--pending-bg);
  color: var(--favorite-text);
}

.status-approved {
  background: var(--approved-bg);
  color: var(--approved-text);
}

.status-rejected {
  background: var(--danger-bg);
  color: var(--danger-text-strong);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

#confirm-modal {
  z-index: 3000;
}

.modal-container {
  background: var(--card-bg);
  width: 100%;
  max-width: 450px;
  max-height: calc(100vh - 40px);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.15);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  padding: 24px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-close {
  font-size: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 52px;
  /* Fixed height for consistency */
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-app);
  font-size: 16px;
  /* Prevents iOS zoom */
  font-family: inherit;
  color: var(--text-main);
  box-sizing: border-box;
  -webkit-appearance: none;
  /* Mobile Safari consistency */
  -moz-appearance: none;
  appearance: none;
}

/* Custom Arrow for select on iOS/Modern Browsers */
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 40px;
}

.form-group input[type="date"] {
  position: relative;
  min-height: 52px;
}

/* Ensure date input displays content properly on iOS */
.form-group input[type="date"]::-webkit-inner-spin-button,
.form-group input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
}

.modal-footer {
  padding: 0 24px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex-shrink: 0;
}

/* Utils */
.w-full {
  width: 100%;
}

/* Auth Pages Styling (Restored and Improved) */
.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--neutral-bg) 0%, var(--info-bg-soft) 100%);
}

.auth-panel {
  background: var(--card-bg);
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.5s ease-out;
}

@media (max-width: 480px) {
  .auth-panel {
    padding: 30px 24px;
    border-radius: var(--radius-xl);
  }
}

.brand-area {
  text-align: center;
  margin-bottom: 20px;
}

.brand-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: inline-block;
}

.brand-logo {
  width: 100px;
  height: auto;
  margin-bottom: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

@media (max-width: 480px) {
  .brand-logo {
    width: 80px;
  }
}

.brand-area h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

.brand-area p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
  word-break: keep-all;
}

.auth-form h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-form p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.input-label {
  display: block;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}

.input-label input {
  width: 100%;
  margin-top: 6px;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--neutral-bg);
  font-size: 16px;
  transition: all 0.2s;
  box-sizing: border-box;
}

.input-label input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  margin-top: 4px;
}

.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.form-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
  margin-left: 4px;
}

.feedback {
  margin-top: 16px;
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

.feedback.error {
  color: var(--danger);
}

.feedback.success {
  color: var(--success);
}

/* Participation Display in Profile Setup */
.participation-code-display {
  background: var(--primary-bg);
  padding: 16px;
  border-radius: 16px;
  margin-bottom: 24px;
  text-align: center;
}

.participation-code-display p {
  margin: 0;
  font-weight: 700;
  color: var(--primary);
}

.participation-code-display span {
  font-size: 20px;
  letter-spacing: 2px;
}

.participation-code-display small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  /* Changed via JS */
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--primary-bg);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Modal and Page animations improve */
.modal-overlay {
  background: rgba(15, 23, 42, 0.4);
  /* Darker backdrop */
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 100px;
  /* Above the bottom nav */
  left: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  color: var(--text-main);
  padding: 14px 18px;
  border-radius: 18px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.14);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), toastOut 0.3s 2.7s forwards;
  pointer-events: auto;
  border: 1px solid var(--border);
}

.toast-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-message {
  flex: 1;
  min-width: 0;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.success .toast-icon {
  background: var(--success-bg);
  color: var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.error .toast-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.toast.info {
  border-left: 4px solid var(--primary);
}

.toast.info .toast-icon {
  background: var(--primary-bg);
  color: var(--primary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
}

/* Loading Overlay fix */
.loading-overlay {
  z-index: 9998;
}

.badge-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background-color: var(--danger);
  border: 2px solid white;
  border-radius: 50%;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--neutral-border);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(22px);
}

/* Shopping List Styles */
.shopping-summary {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: var(--space-4);
  padding: 10px 14px;
  background: var(--primary-bg);
  border-radius: var(--radius-md);
  text-align: center;
}

.notification-card {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.notification-card:last-child {
  border-bottom: none;
}

.notification-card.unread {
  background: var(--primary-bg);
  margin: 0 calc(-1 * var(--space-4));
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  border-radius: var(--radius-md);
}

.notification-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.notification-card.unread .notification-icon {
  background: var(--card-bg);
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-title {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-main);
}

.notification-body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.notification-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.shopping-item.purchased {
  opacity: 0.6;
  background: var(--neutral-bg);
}

.shopping-item.purchased .shopping-item-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.shopping-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.shopping-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.shopping-item.purchased .shopping-checkbox {
  background: var(--success);
  border-color: var(--success);
}

.shopping-checkbox svg {
  color: white;
  display: none;
}

.shopping-item.purchased .shopping-checkbox svg {
  display: block;
}

.shopping-item-name {
  font-weight: 700;
  font-size: 16px;
}

.shopping-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.shopping-item-actions {
  display: flex;
  gap: 8px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(59, 130, 246, 0.1);
  border-left-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Calendar & Stamp Diary */
.calendar-day-cell {
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  font-family: inherit;
  padding: 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.calendar-day-cell:hover {
  background: var(--primary-bg);
  transform: scale(1.08);
}

.calendar-day-cell.other-month {
  opacity: 0.3;
}

.calendar-day-cell.today {
  background: #fff0ed;
  border: 1.5px solid #ffbeb2;
}

.calendar-day-cell.today .day-number {
  font-weight: 800;
  color: var(--primary);
}

.calendar-day-cell .day-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.calendar-day-cell.has-stamp .day-number {
  transform: translateY(-8px);
  font-size: 11px;
}

.calendar-day-cell .day-stamp-grid {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  animation: stampPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.calendar-day-cell .day-stamp {
  font-size: 11px;
  line-height: 1;
}

.stamp-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stamp-btn {
  font-size: 28px;
  padding: 12px;
  background: var(--bg-app);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stamp-btn:hover {
  transform: scale(1.15);
  background: #ffebe7 !important;
}

.stamp-btn.selected {
  background: var(--primary-bg) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 4px 12px rgba(255, 126, 103, 0.2);
}

@keyframes stampPop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Roulette */
.roulette-wheel-container {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); opacity: 0.8; }
  70% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1); opacity: 1; }
}

/* PWA Installation styles */
.pwa-banner {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 126, 103, 0.15);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  z-index: 1050;
  display: none; /* Controlled by JS */
  flex-direction: column;
  gap: 12px;
  animation: pwaSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}

.pwa-banner.has-bottom-nav {
  bottom: calc(92px + env(safe-area-inset-bottom));
}

@keyframes pwaSlideUp {
  from { transform: translateY(120%) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.pwa-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.pwa-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
  color: var(--text-main);
}

.pwa-banner-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.2s;
}

.pwa-banner-close:hover {
  color: var(--danger);
}

.pwa-banner-body {
  font-size: 13px;
  color: #4b5563;
  line-height: 1.5;
}

.pwa-banner-actions {
  display: flex;
  gap: 8px;
}

.pwa-banner-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.pwa-banner-btn.primary {
  background: var(--primary);
  color: white;
}

.pwa-banner-btn.primary:active {
  background: var(--primary-dark);
}

.pwa-banner-btn.secondary {
  background: var(--primary-bg);
  color: var(--primary);
}

.pwa-banner-btn.secondary:active {
  background: #ffe2de;
}

/* Modal Tab Styles */
.pwa-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}

.pwa-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.pwa-tab-btn.active {
  color: var(--primary);
}

.pwa-tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary);
  border-radius: 2px;
}

.pwa-tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.pwa-tab-content.active {
  display: block;
}

/* Step-by-step guide styles */
.pwa-step-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.pwa-step-item {
  display: flex;
  gap: 12px;
  background: var(--neutral-bg);
  padding: 14px 16px;
  border-radius: 16px;
  align-items: flex-start;
  border: 1px solid rgba(0, 0, 0, 0.02);
}

.pwa-step-num {
  background: var(--primary-bg);
  color: var(--primary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 2px;
}

.pwa-step-text {
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.5;
}

.pwa-step-text strong {
  font-weight: 700;
  color: var(--primary-dark);
}

.pwa-highlight-box {
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--tip-text);
  line-height: 1.6;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* Desktop/tablet "phone frame" — added 2026-09-18. The app shell (.app-body) is
   intentionally a fixed-viewport, native-app-like layout for mobile. On wider
   screens, center it at phone width instead of letting it stretch full-bleed. */
@media (min-width: 640px) {
  .app-body {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.08);
  }

  .bottom-nav,
  .pwa-banner {
    max-width: 480px;
    margin: 0 auto;
  }
}

/* Automatic dark mode — added 2026-09-18. No manual toggle; follows OS setting. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #17140f;
    --card-bg: #221e18;
    --text-main: #f5f1ea;
    --text-muted: #a39c8f;
    --border: #332d24;
    --primary: #ff9280;
    --primary-dark: #ff7e67;
    --primary-bg: #3a251f;
    --danger-bg: rgba(239, 68, 68, 0.16);
    --caution-bg: rgba(234, 179, 8, 0.16);
    --success-bg: rgba(16, 185, 129, 0.16);
  }

  .bottom-nav {
    background: rgba(34, 30, 24, 0.95);
  }

  .pwa-banner {
    background: rgba(34, 30, 24, 0.95);
  }

  .memo-tag-notice {
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.4);
  }

  .memo-tag-recipe {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.4);
  }

  .memo-tag-shopping {
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.4);
  }

  .memo-tag-general {
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.4);
  }

  .roulette-result-card {
    background: rgba(255, 146, 128, 0.12);
  }
}

/* Meal diary — design polish (2026-09-19) */
.diary-container {
  padding: var(--space-4);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.calendar-nav-btn {
  font-size: 18px;
  padding: 4px 12px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
}

.calendar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.calendar-grid-wrapper {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  font-size: var(--text-xs);
  margin-bottom: var(--space-3);
}

.calendar-weekdays .sun {
  color: var(--primary);
}

.calendar-weekdays .sat {
  color: #3b82f6;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  justify-items: center;
}

.diary-tip {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--tip-text);
  background: var(--tip-bg);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--tip-border);
  line-height: 1.5;
}

.diary-meal-tabs,
.diary-view-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.diary-meal-tab,
.diary-view-tab {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.diary-meal-tab.active,
.diary-view-tab.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.diary-month-summary {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: var(--space-4);
  padding: 10px 14px;
  background: var(--primary-bg);
  border-radius: var(--radius-md);
  text-align: center;
}

.diary-form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 700;
  color: var(--text-main);
}

.diary-note-input {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-app);
  font-size: 16px;
  box-sizing: border-box;
  color: var(--text-main);
}

.diary-photo-input-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.diary-photo-tile-wrap {
  position: relative;
  width: 96px;
}

.diary-photo-tile-wrap .diary-photo-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin-bottom: 0;
  border-radius: var(--radius-lg);
  border: 2px dashed var(--border);
  background: var(--bg-app);
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s ease;
}

.diary-photo-tile-wrap .diary-photo-tile:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.diary-photo-input-native:focus + .diary-photo-tile {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.diary-photo-tile-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  pointer-events: none;
}

.diary-photo-tile:hover .diary-photo-tile-placeholder {
  color: var(--primary-dark);
}

.diary-photo-tile-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.diary-photo-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: 2px solid var(--card-bg);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

/* Empty state — added 2026-09-18 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}
.empty-state .empty-title {
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--text-main);
  margin-bottom: 4px;
}
.empty-state .empty-desc {
  font-size: var(--text-sm);
  margin-bottom: 16px;
}
.empty-state .empty-cta {
  display: inline-block;
}

/* Auth pages (login/signup/reset-password) are not part of the fixed-viewport
   app shell (body.overflow:hidden above is for .app-body/.app-content's own
   internal scroll) -- they have no internal scroll container of their own, so
   when their content (top ad banner + .page-shell) exceeds the visible mobile
   viewport, it must be able to scroll instead of being clipped. Added 2026-09-19. */
body.auth-body {
  overflow-y: auto;
}

/* Hide the auth pages' scroll indicator while keeping it scrollable (the
   overflow-y:auto above is needed so content is reachable, not just decorative).
   Added 2026-09-19. */
body.auth-body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body.auth-body::-webkit-scrollbar {
  display: none;
}

/* Meal diary timeline view — added 2026-09-20 */
.diary-timeline-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.timeline-month-header {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--text-muted);
  padding-left: 4px;
}

.timeline-day-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.timeline-day-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.timeline-day-header > span:first-child {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-main);
}

.timeline-weekday {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.timeline-weekday.sun {
  color: var(--primary);
}

.timeline-weekday.sat {
  color: #3b82f6;
}

.timeline-meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.timeline-meal-row + .timeline-meal-row {
  border-top: 1px solid var(--border);
}

.timeline-meal-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.timeline-meal-emoji {
  font-size: 22px;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  border-radius: var(--radius-full);
}

.timeline-meal-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.timeline-meal-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary-dark);
}

.timeline-meal-note {
  font-size: var(--text-sm);
  color: var(--text-main);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.timeline-meal-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.timeline-meal-photo:hover {
  transform: scale(1.05);
}

.photo-lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.photo-lightbox-content img {
  display: block;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  object-fit: contain;
}

.photo-lightbox-close-btn {
  position: absolute;
  top: -16px;
  right: -16px;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}

/* Google SSO 구분선 (로그인/가입 폼 버튼과 Google 버튼 사이) */
.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 16px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.auth-divider span {
  padding: 0 12px;
}

.fridge-stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary-bg);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.fridge-stat-chip strong {
  color: var(--text-main);
  font-weight: 800;
}

.fridge-stat-sep {
  color: var(--border);
}

/* ==========================================================================
   Fridge list rows + action sheet, shopping checklist (2026-09-28)
   ========================================================================== */
:root {
  --fresh-bg: #e6f4ec;
  --fresh-fg: #1d7a4e;
  --caution-tile-bg: #fff2cc;
  --caution-fg: #9a5b00;
  --urgent-bg: #ffe5dd;
  --urgent-fg: #cf4420;
  --expired-bg: #fbe1e1;
  --expired-fg: #b42323;
  --ice-bg: #e3f1fb;
  --ice-fg: #1f6a9a;
  --done: #22a06b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fresh-bg: rgba(52, 168, 110, 0.18);
    --fresh-fg: #86d8ab;
    --caution-tile-bg: rgba(234, 179, 8, 0.18);
    --caution-fg: #f1c860;
    --urgent-bg: rgba(255, 126, 103, 0.2);
    --urgent-fg: #ffa08c;
    --expired-bg: rgba(239, 68, 68, 0.2);
    --expired-fg: #ff9a9a;
    --ice-bg: rgba(56, 152, 214, 0.2);
    --ice-fg: #8cc8ef;
    --done: #3cc587;
  }

  .tone-expired .dday-tile,
  .dday-tile.tone-expired {
    background: #c73636;
  }

  .view-header h1 {
    background: none;
    -webkit-text-fill-color: var(--text-main);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- D-day tile (shared by row + sheet) --- */
.dday-tile {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  background: var(--fresh-bg);
  color: var(--fresh-fg);
}

.dday-big {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.dday-small {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0.85;
}

.tone-caution .dday-tile,
.dday-tile.tone-caution {
  background: var(--caution-tile-bg);
  color: var(--caution-fg);
}

.tone-urgent .dday-tile,
.dday-tile.tone-urgent {
  background: var(--urgent-bg);
  color: var(--urgent-fg);
}

.tone-expired .dday-tile,
.dday-tile.tone-expired {
  background: var(--expired-fg);
  color: #fff;
}

.dday-tile-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
}

.dday-tile-lg .dday-big {
  font-size: 21px;
}

/* --- Fridge row --- */
#food-items-list {
  gap: 8px;
}

.food-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 8px 12px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}

.food-row:active {
  transform: scale(0.985);
  background: var(--bg-app);
}

.food-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.food-row.tone-expired {
  border-color: color-mix(in srgb, var(--expired-fg) 30%, var(--border));
}

.food-row-body {
  flex: 1;
  min-width: 0;
}

.food-row-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.food-row-emoji {
  margin-right: 6px;
}

.food-row-star {
  display: inline-block;
  margin-left: 5px;
  vertical-align: -1px;
  color: var(--favorite-bg);
}

.food-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.food-row-meta > span + span:not(.food-row-frozen)::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 10px 2px 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  vertical-align: middle;
}

.food-row-frozen {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--ice-bg);
  color: var(--ice-fg);
  font-size: 11px;
  font-weight: 700;
}

.food-row-more {
  flex-shrink: 0;
  width: 32px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0.7;
}

/* --- Action sheet --- */
.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0);
  visibility: hidden;
  transition: background-color 0.25s ease, visibility 0s linear 0.25s;
}

.action-sheet.show {
  visibility: visible;
  background: rgba(15, 23, 42, 0.45);
  transition: background-color 0.25s ease;
}

.action-sheet-panel {
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  border-radius: 26px 26px 0 0;
  padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);
}

.action-sheet.show .action-sheet-panel {
  transform: translateY(0);
}

.action-sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  margin: 0 auto 18px;
}

.food-sheet-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
}

.food-sheet-info {
  flex: 1;
  min-width: 0;
}

.food-sheet-name {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-main);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.food-sheet-facts {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.food-sheet-expiry {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
}

.tone-text-fresh { color: var(--fresh-fg); }
.tone-text-caution { color: var(--caution-fg); }
.tone-text-urgent { color: var(--urgent-fg); }
.tone-text-expired { color: var(--expired-fg); }

.food-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sheet-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  border: none;
  border-radius: 16px;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  word-break: keep-all;
  transition: transform 0.12s, background-color 0.15s;
}

.sheet-action:active {
  transform: scale(0.95);
}

.sheet-action:focus-visible,
.sheet-cancel:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sheet-action-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  color: var(--text-main);
}

#food-sheet-fav.is-on .sheet-action-icon {
  color: var(--favorite-bg);
}

#food-sheet-fav.is-on .sheet-action-icon svg {
  fill: currentColor;
}

.sheet-action-danger {
  color: var(--danger);
}

.sheet-action-danger .sheet-action-icon {
  color: var(--danger);
}

.sheet-cancel {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* --- Shopping: quick add --- */
.shop-quick-add {
  position: relative;
  display: flex;
  align-items: center;
  margin: 4px 0 18px;
}

.shop-quick-add input {
  width: 100%;
  height: 54px;
  padding: 0 84px 0 18px;
  border: 1.5px solid var(--border);
  border-radius: 18px;
  background: var(--card-bg);
  color: var(--text-main);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
  user-select: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.shop-quick-add input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.shop-quick-add input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-bg);
}

.shop-quick-btn {
  position: absolute;
  right: 7px;
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 13px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.shop-quick-btn:active {
  transform: scale(0.95);
}

/* --- Shopping: progress --- */
.shopping-progress {
  margin: 0 2px 8px;
}

.shopping-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.shopping-progress-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

.shopping-progress-count {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.shopping-progress-track {
  height: 6px;
  border-radius: 6px;
  background: var(--border);
  overflow: hidden;
}

.shopping-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: var(--primary);
  transition: width 0.4s cubic-bezier(0.2, 0.9, 0.3, 1), background-color 0.3s;
}

.shopping-progress.is-complete .shopping-progress-fill {
  background: var(--done);
}

/* --- Shopping: grouped checklist --- */
.shop-group {
  margin-top: 18px;
}

.shop-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 4px 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

.shop-group-count {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.shop-group-done .shop-group-title {
  color: var(--text-muted);
}

.shop-card {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.shop-subhead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 2px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.shop-subhead + .shop-row {
  margin-top: -4px;
}

.shop-row + .shop-subhead {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.shop-row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 60px;
  padding-right: 6px;
}

.shop-row + .shop-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 54px;
  right: 0;
  border-top: 1px solid var(--border);
}

.shop-check {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 6px 12px 16px;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.shop-check:focus-visible,
.shop-remove:focus-visible,
.shop-to-fridge:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 12px;
}

.shop-check-box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--neutral-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: background-color 0.2s, border-color 0.2s;
}

.shop-check-box svg {
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.15s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.shop-row.is-done .shop-check-box {
  background: var(--done);
  border-color: var(--done);
}

.shop-row.is-done .shop-check-box svg {
  opacity: 1;
  transform: scale(1);
}

.shop-row-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.shop-row-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
  word-break: keep-all;
  overflow-wrap: anywhere;
  transition: color 0.2s;
}

.shop-row-meta {
  margin-top: 2px;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-muted);
}

.shop-row.is-done .shop-row-name {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--text-muted) 60%, transparent);
}

.shop-to-fridge {
  flex-shrink: 0;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.shop-to-fridge:active {
  transform: scale(0.95);
}

.shop-remove {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--neutral-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.shop-remove:hover,
.shop-remove:active {
  background: var(--danger-bg);
  color: var(--danger);
}

@media (prefers-reduced-motion: reduce) {
  .action-sheet,
  .action-sheet-panel,
  .shop-check-box svg,
  .shopping-progress-fill,
  .food-row {
    transition: none;
  }
}
