:root {
  --primary: #ff6b35;
  --primary-light: #ff8c5a;
  --primary-dark: #e55a2b;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-light: #888888;
  --border: #e0e0e0;
  --success: #4caf50;
  --danger: #f44336;
  --meat: #e57373;
  --fish: #64b5f6;
  --vegetable: #81c784;
  --side: #ffb74d;
  --soup: #ba68c8;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 70px;
}

/* Header */
#app-header {
  position: sticky;
  top: 0;
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  z-index: 100;
  box-shadow: var(--shadow);
}

#page-title {
  font-size: 18px;
  font-weight: 600;
}

/* Bottom Nav */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  font-size: 10px;
  padding: 4px 4px;
  transition: color 0.2s;
  min-width: 0;
}

.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; margin-bottom: 2px; }

/* Main content */
#app-content {
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}
/* Non-recipe pages keep narrower layout */
#app-content:has(.pantry-columns) {
  max-width: 900px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Meal Section */
.meal-section {
  margin-bottom: 16px;
}

.meal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}

.meal-slot {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.meal-slot:last-child { border-bottom: none; }

.slot-role {
  font-size: 12px;
  color: var(--text-light);
  width: 50px;
  flex-shrink: 0;
}

.slot-recipe {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.slot-change {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}

/* Category badge */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: white;
  margin-right: 4px;
}

.badge-meat { background: var(--meat); }
.badge-fish { background: var(--fish); }
.badge-vegetable { background: var(--vegetable); }
.badge-side { background: var(--side); }
.badge-soup { background: var(--soup); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-full {
  width: 100%;
  padding: 14px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Shopping List */
.shopping-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.shopping-item.checked .item-name {
  text-decoration: line-through;
  color: var(--text-light);
}

.shopping-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.shopping-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.item-name { flex: 1; font-size: 15px; }

.item-amount {
  font-size: 13px;
  color: var(--text-light);
}

/* Inventory */
.inventory-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.inventory-name { flex: 1; font-size: 15px; }

.inventory-amount {
  font-size: 13px;
  color: var(--text-light);
}

.delete-btn {
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  background: none;
  border: none;
}

/* Week Calendar */
.week-day {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.week-date {
  width: 60px;
  flex-shrink: 0;
  text-align: center;
}

.week-date-num {
  font-size: 20px;
  font-weight: 700;
}

.week-date-day {
  font-size: 11px;
  color: var(--text-light);
}

.week-date.today .week-date-num { color: var(--primary); }

.week-menus { flex: 1; }

.week-meal-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.week-meal-name {
  font-size: 13px;
  margin-bottom: 4px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-light);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus { border-color: var(--primary); }

.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: white;
}

/* Modal */
#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

#modal-overlay.hidden { display: none; }

#modal-content {
  background: var(--card-bg);
  border-radius: 16px 16px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 24px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-light);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-text {
  font-size: 14px;
  line-height: 1.6;
}

/* Source list */
.source-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.source-name { flex: 1; font-size: 15px; }

.source-url {
  font-size: 11px;
  color: var(--text-light);
  word-break: break-all;
}

.source-toggle {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--border);
  cursor: pointer;
  position: relative;
  border: none;
  transition: background 0.2s;
}

.source-toggle.active { background: var(--success); }

.source-toggle::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.source-toggle.active::after { transform: translateX(20px); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg);
  border-radius: 8px;
}

.stat-num {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
}

/* Settings items */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.setting-label { font-size: 15px; }

.setting-value {
  font-size: 15px;
  color: var(--primary);
  font-weight: 600;
}

/* Recipe detail */
.recipe-detail-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.recipe-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-light);
}

.recipe-ingredients {
  margin-bottom: 16px;
}

.recipe-ingredients li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
  font-size: 14px;
}

.recipe-steps { counter-reset: step; }

.recipe-steps li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
  font-size: 14px;
  line-height: 1.6;
  counter-increment: step;
}

.recipe-steps li::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 600;
  margin-right: 8px;
}

/* Rating */
.rating {
  display: flex;
  gap: 4px;
}

.rating-star {
  font-size: 24px;
  cursor: pointer;
  color: var(--border);
  background: none;
  border: none;
}

.rating-star.filled { color: #ffc107; }

.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0 8px;
}

.rating-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.repertoire-btn {
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  cursor: pointer;
  white-space: nowrap;
}
.repertoire-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Action bar */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.action-bar .btn { flex: 1; }

/* Alert Dashboard */
.alert-dashboard {
  margin-bottom: 12px;
}

.alert-card {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.alert-card.alert-warning {
  background: #fff3e0;
  border-left: 3px solid #ff9800;
}

.alert-card.alert-info {
  background: #e3f2fd;
  border-left: 3px solid #2196f3;
}

.alert-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.alert-msg {
  flex: 1;
  line-height: 1.4;
}

.alert-action-btn {
  display: block;
  margin-top: 6px;
  margin-left: 24px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--primary);
  background: white;
  border: 1px solid var(--primary);
  border-radius: 6px;
  cursor: pointer;
}

.alert-action-btn:active {
  background: var(--primary);
  color: white;
}

.alert-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

/* Expiry badges */
.expiry-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.expiry-badge.expired {
  background: #ffcdd2;
  color: #c62828;
}

.expiry-badge.soon {
  background: #fff3e0;
  color: #e65100;
}

.expiry-text {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}

/* Staple button */
.staple-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.staple-btn.staple-on {
  color: #ffc107;
}

.staple-btn.staple-off {
  color: var(--border);
}

/* ===== Category Filter Buttons (Home) ===== */
.category-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0;
}

.category-filters::-webkit-scrollbar { display: none; }

.cat-btn {
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.cat-btn:not(.active):hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

/* ===== Recipe Detail Image ===== */
.recipe-detail-image {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* ===== Slot Thumbnail (Home) ===== */
.slot-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 8px;
}

/* ===== Shopping Category Header ===== */
.shopping-category-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  padding: 12px 0 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shopping-category-header:first-child {
  padding-top: 0;
}

/* ===== Tab Bar (Prep page) ===== */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: var(--card-bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.tab-btn.active {
  color: var(--primary);
  background: white;
}

.tab-btn.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
}

/* ===== Prep Recipe Cards ===== */
.prep-recipe-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.prep-recipe-item:last-child { border-bottom: none; }

.prep-recipe-item:active {
  background: var(--bg);
}

.prep-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.prep-thumb-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.prep-recipe-info {
  flex: 1;
  min-width: 0;
}

.prep-recipe-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prep-recipe-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
}

/* ===== Missing Ingredients List ===== */
.missing-list {
  list-style: none;
  margin: 8px 0 12px;
}

.missing-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.missing-item:last-child { border-bottom: none; }

.missing-amount {
  font-size: 13px;
  color: var(--text-light);
}

/* ===== 6-Tab Navigation Adjustment ===== */
@media (max-width: 480px) {
  .nav-item {
    padding: 4px 6px;
    font-size: 10px;
  }

  .nav-icon {
    font-size: 20px;
  }
}

/* ===== Extra Category Badges ===== */
.badge-daily_goods,
.badge-日用品 {
  background: #42a5f5;
}
.badge-dessert {
  background: #e91e63;
}

/* ===== Compact Home UI v3 ===== */

/* Date + alert row */
.date-alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.date-header-compact {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.alert-badges {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.alert-badge-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.alert-badge-btn:active {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(0.9);
}

/* Bento horizontal scroll */
.bento-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 4px 0 12px;
  margin-bottom: 8px;
}
.bento-scroll::-webkit-scrollbar { display: none; }

.bento-slot-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  padding: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
}
.bento-slot-card:active { transform: scale(0.96); }

/* === Makunouchi 4-cell auto-compose card === */
.makunouchi-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 12px;
  margin: 12px 0;
}
.mkno-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.mkno-title-text {
  font-size: 15px;
  font-weight: 700;
}
.mkno-reroll-all {
  background: var(--primary, #ff7043);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.mkno-reroll-all:active { transform: scale(0.95); }
.mkno-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.mkno-actions .mkno-reroll-all {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border-radius: 8px;
}
.mkno-discord-notify {
  flex: 1;
  background: #5865F2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mkno-discord-notify:active { transform: scale(0.97); }
.mkno-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mkno-cell.mkno-side2 {
  grid-column: span 2;  /* mobile: 5 マス目 (= 副菜②) full width */
}
@media (min-width: 720px) {
  .mkno-grid { grid-template-columns: repeat(5, 1fr); }
  .mkno-cell.mkno-side2 { grid-column: span 1; }
}
.mkno-cell {
  background: var(--bg);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
  min-height: 140px;
}
.mkno-cell:active { transform: scale(0.97); }
.mkno-cell-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #666);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.mkno-cooking {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}
.mkno-cooking.cooking-today {
  background: #fff3e0;
  color: #e65100;
}
.mkno-cooking.cooking-frozen {
  background: #e3f2fd;
  color: #1565c0;
}
.mkno-cooking.cooking-makeahead {
  background: #e8f5e9;
  color: #2e7d32;
}
.mkno-storage {
  display: inline-block;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 6px;
  font-weight: 600;
  background: #f3e5f5;
  color: #6a1b9a;
  margin-left: 2px;
}
.mkno-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.mkno-thumb-empty {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 6px;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.mkno-name {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}
.mkno-meta {
  font-size: 11px;
  color: var(--text-secondary, #888);
  margin-top: 2px;
}
.mkno-reroll {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mkno-reroll:active { transform: scale(0.9); }
.mkno-cell.mkno-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary, #999);
  cursor: default;
}
.mkno-empty-msg { font-size: 13px; margin-top: 8px; }

.bento-card-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.bento-card-thumb-empty {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.bento-card-role {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 6px;
}
.bento-card-role.role-main {
  background: #fce4ec;
  color: #c62828;
}
.bento-card-role.role-side {
  background: #fff3e0;
  color: #e65100;
}
.bento-card-role.role-soup {
  background: #f3e5f5;
  color: #7b1fa2;
}
.bento-card-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bento-card-change {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Empty compact */
.empty-compact {
  text-align: center;
  padding: 16px;
  color: var(--text-light);
  font-size: 14px;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

/* Compact suggest row */
.suggest-compact {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.suggest-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  min-width: 0;
}
.suggest-input:focus { border-color: var(--primary); }
.suggest-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.suggest-icon-btn:active { transform: scale(0.9); }
.suggest-icon-btn.btn-primary {
  background: var(--primary);
  color: white;
}
.suggest-icon-btn.btn-ai {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

/* ===== Browse Tab Bar ===== */
.browse-tab-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.browse-tab-btn {
  padding: 14px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.browse-tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.browse-tab-icon {
  font-size: 20px;
}
.browse-tab-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-light);
  background: var(--bg);
  padding: 0 5px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}
.browse-tab-btn.active .browse-tab-count {
  background: rgba(255,255,255,0.3);
  color: white;
}

/* ===== Recipe Browser Horizontal Scroll ===== */
.recipe-browser-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 0 8px;
  min-height: 100px;
}
.recipe-browser-scroll::-webkit-scrollbar { display: none; }

.rb-card {
  flex-shrink: 0;
  width: 120px;
  cursor: pointer;
  transition: transform 0.15s;
  border-radius: 10px;
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.rb-card:active { transform: scale(0.96); }

.rb-thumb {
  width: 100%;
  height: 70px;
  object-fit: cover;
  display: block;
}
.rb-thumb-empty {
  width: 100%;
  height: 70px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.rb-title {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 6px 6px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.rb-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-light);
  font-size: 13px;
  width: 100%;
}
.rb-loading {
  display: flex;
  align-items: center;
  padding: 16px;
  color: var(--text-light);
  font-size: 13px;
  width: 100%;
}

/* Mini stats bar */
.mini-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 11px;
  color: var(--text-light);
}

/* Empty state sub text */
.empty-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

/* Change recipe list in modal */
.change-recipe-list {
  max-height: 50vh;
  overflow-y: auto;
}

/* ===== Recipes List Page ===== */
/* Two-column: sidebar + grid */
.rp-layout {
  display: flex;
  gap: 16px;
  min-height: calc(100vh - 120px);
}
.rp-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.rp-sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
.rp-main {
  flex: 1;
  min-width: 0;
}
.rp-main-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 4px 0 8px;
}
.rp-filter-toggle {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.rp-filter-toggle:active { background: var(--bg); }
.rp-omakase-mobile { display: none; }
.rp-omakase-sidebar { display: block; width: 100%; margin-top: 4px; }
@media (max-width: 700px) {
  .rp-sidebar {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 85vw;
    max-width: 320px;
    height: 100vh;
    z-index: 100;
    background: var(--white);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    padding: 16px;
    box-sizing: border-box;
  }
  .rp-sidebar.open { display: block; }
  .rp-layout { gap: 0; }
  .rp-omakase-mobile { display: inline-block; }
  .rp-omakase-sidebar { display: none; }
}
@media (min-width: 701px) {
  .rp-filter-toggle { display: none; }
  .rp-omakase-mobile { display: none; }
}
.rp-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.rp-title-label {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.rp-back-btn {
  padding: 6px 12px !important;
  font-size: 14px !important;
}
.rp-omakase-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff6b35, #ff9a56);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.rp-omakase-btn:active { opacity: 0.8; }
.rp-search {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--white);
  margin-bottom: 4px;
  box-sizing: border-box;
}
.rp-search:focus {
  outline: none;
  border-color: var(--primary);
}
.rp-filter-section {
  margin-bottom: 6px;
}
.rp-filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 3px;
  padding-left: 2px;
}
.rp-filters-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.rp-chip {
  padding: 5px 10px;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  background: var(--white);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s;
}
.rp-chip .chip-cnt {
  font-size: 10px;
  opacity: 0.6;
}
.rp-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.rp-chip.active .chip-cnt { opacity: 0.9; }
.rp-sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rp-sort-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
  color: var(--text);
  width: 100%;
}
.rp-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-left: auto;
  white-space: nowrap;
}
.rp-applied {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 0;
}
.rp-applied:empty { display: none; }
.rp-applied-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: #fff3ee;
  border: 1px solid var(--primary);
  border-radius: 14px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}
.rp-applied-chip:active { opacity: 0.7; }
.rp-applied-clear {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
  text-decoration: underline;
}
.rp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
@media (max-width: 700px) {
  .rp-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
.rp-card {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.15s;
}
.rp-card:active { transform: scale(0.98); }
.rp-thumb-wrap {
  position: relative;
}
.rp-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.rp-thumb-empty {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
}
.rp-time-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 13px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
}
.rp-info {
  padding: 10px 12px 12px;
}
.rp-card-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.rp-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 6px;
  flex: 1;
}
.rp-fav-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 22px;
  color: #ccc;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.rp-fav-btn.fav-active { color: #e74c3c; }
.rp-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  flex-wrap: wrap;
}
.rp-tag-row {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.rp-mini-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.4;
}
.tag-bento { background: #fff3e0; color: #e65100; }
.tag-tsukurioki { background: #e8f5e9; color: #2e7d32; }
.tag-frozen { background: #e3f2fd; color: #1565c0; }
.tag-quick { background: #fce4ec; color: #c62828; }
.tag-save { background: #f3e5f5; color: #6a1b9a; }
.rp-load-more {
  text-align: center;
  padding: 16px 0;
}
.rp-sentinel {
  height: 1px;
}
/* Omakase modal */
.omakase-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.omakase-card {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
}
.omakase-card:active { opacity: 0.8; }
.omakase-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.omakase-thumb-empty {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.omakase-info { flex: 1; min-width: 0; }
.omakase-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Week Planner ===== */
.week-hero {
  text-align: center;
  padding: 48px 16px;
}
.week-hero h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.week-hero p {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.week-sticky-bar {
  position: sticky;
  top: 54px;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 10px 0;
  margin-bottom: 4px;
  background: var(--bg);
}

.week-day-card {
  padding: 0;
  margin-bottom: 10px;
  overflow: hidden;
}

.week-day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.week-day-label {
  font-size: 18px;
  font-weight: 700;
  width: 28px;
}

.week-day-date {
  font-size: 13px;
  color: var(--text-light);
}

.week-type-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.week-options {
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.week-option {
  flex: 0 0 calc(50% - 4px);
  min-width: 160px;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.15s, background 0.15s;
}

.week-option:active {
  opacity: 0.8;
}

.week-option-selected {
  border-color: var(--primary);
  background: rgba(76, 175, 80, 0.06);
}

.week-option-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
}

.week-option-selected .week-option-header {
  color: var(--primary);
}

.week-option-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.week-slot-thumb {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
}

.week-slot-role {
  font-size: 10px;
  color: var(--text-light);
  width: 36px;
  flex-shrink: 0;
}

.week-slot-title {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* ===== Recipe Detail Preview ===== */
.week-slot-expandable {
  cursor: pointer;
}
.week-slot-expand {
  font-size: 9px;
  color: var(--text-light);
  margin-left: 2px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.week-slot-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.week-slot-detail.expanded {
  /* max-height set by JS */
}
.recipe-detail-panel {
  padding: 8px 12px;
  background: #f7f7f7;
  border-radius: 6px;
  margin: 4px 0 6px;
  font-size: 12px;
  line-height: 1.5;
}
.recipe-detail-section {
  margin-bottom: 6px;
}
.recipe-detail-section strong {
  font-size: 11px;
  color: var(--text-light);
  display: block;
  margin-bottom: 2px;
}
.recipe-detail-ingredients,
.recipe-detail-steps {
  margin: 2px 0;
  padding-left: 18px;
}
.recipe-detail-ingredients li,
.recipe-detail-steps li {
  margin-bottom: 1px;
  font-size: 11px;
}
.recipe-detail-meta {
  color: var(--text-light);
  font-size: 10px;
  margin-top: 4px;
}
.recipe-detail-loading,
.recipe-detail-error {
  font-size: 11px;
  color: var(--text-light);
  padding: 4px 0;
  text-align: center;
}

/* Small button variant */
.btn-xs {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ===== Week Mode Toggle ===== */
.week-mode-toggle {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 8px 0 4px;
}

/* ===== Mealprep Setup ===== */
.prep-setup-section {
  margin-top: 16px;
  text-align: left;
}
.prep-setup-section h3 {
  font-size: 15px;
  margin-bottom: 12px;
  text-align: center;
}
.prep-day-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.prep-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 56px;
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.prep-day-btn:active { opacity: 0.8; }
.prep-day-off {
  border-color: var(--primary);
  background: rgba(255, 107, 53, 0.08);
}
.prep-day-name {
  font-size: 16px;
  font-weight: 700;
}
.prep-day-date {
  font-size: 11px;
  color: var(--text-light);
}
.prep-day-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prep-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* ===== Mealprep Planner ===== */
.prep-section-header {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 4px 4px;
  color: var(--text);
}
.prep-day-card {
  border-left: 4px solid var(--primary);
}
.prep-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-left: auto;
  white-space: nowrap;
}

/* ===== Prep Group Card ===== */
.prep-group-card {
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--bg);
}
.prep-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.prep-group-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}
.prep-group-arrow {
  font-size: 16px;
  color: var(--text-light);
}
.prep-group-target {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.prep-group-section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  padding: 8px 0 4px;
}
.prep-group-hint {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  padding: 12px 0;
}
/* === Prep-day 段取り表 card === */
.prep-schedule-card {
  border: 1px dashed var(--primary);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  background: var(--bg-light, #fafafa);
}
.prep-schedule-head {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.prep-schedule-section {
  margin-top: 8px;
}
.prep-schedule-title {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 0;
}
.prep-title-makeahead {
  color: #c2622f;
}
.prep-title-today {
  color: #2f6fc2;
}
.prep-schedule-task {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--text);
}
.prep-task-today {
  background: rgba(47, 111, 194, 0.06);
  border-radius: 6px;
  padding: 3px 6px;
}
.prep-task-check {
  color: var(--text-light);
  flex-shrink: 0;
}
.prep-task-text {
  flex: 1;
}
.prep-task-day {
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  min-width: 1.4em;
  text-align: center;
}
.prep-task-badge {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 6px;
  flex-shrink: 0;
}
.badge-fridge {
  background: #e3f2fd;
  color: #1565c0;
}
.badge-freeze {
  background: #e1f5fe;
  color: #0277bd;
}

.work-day-linked {
  border-left: 3px solid var(--success);
  margin-left: 8px;
}
.week-slot-prep {
  opacity: 0.65;
  font-style: italic;
}
.prep-slot-mark {
  font-size: 9px;
  background: var(--primary-light);
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.ai-recommend-badge {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  margin-left: auto;
}

/* ── Nutrition card ── */
.nutrition-card {
  padding: 12px 16px;
  margin-bottom: 12px;
}
.nutrition-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 8px;
}
.nutrition-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.nutrition-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.nutrition-label {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
}
.nutrition-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.nutrition-value small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-light);
}
.nutrition-bar-container {
  margin-bottom: 6px;
}
.nutrition-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
}
.nbar-p {
  background: #4caf50;
  min-width: 2px;
}
.nbar-f {
  background: #ff9800;
  min-width: 2px;
}
.nbar-c {
  background: #2196f3;
  min-width: 2px;
}
.nutrition-bar-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  margin-top: 4px;
}
.nlegend-p { color: #4caf50; font-weight: 600; }
.nlegend-f { color: #ff9800; font-weight: 600; }
.nlegend-c { color: #2196f3; font-weight: 600; }
.nutrition-total {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

/* ===== Pantry Page (食材管理) ===== */
.pantry-alert {
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}
.pantry-alert-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* 2-column layout */
.pantry-columns {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.pantry-col {
  flex: 1;
  min-width: 0;
}

/* On mobile: stack vertically */
@media (max-width: 640px) {
  .pantry-columns {
    flex-direction: column;
  }
  .pantry-col {
    width: 100%;
  }
  .pantry-scroll-area {
    max-height: none !important;
    overflow-y: visible !important;
  }
}

.pantry-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pantry-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pantry-scroll-area {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.pantry-cat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  padding: 6px 12px 2px;
  letter-spacing: 0.5px;
}
.pantry-items {
  padding: 0 4px;
}
.pantry-inv-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  gap: 6px;
  border-bottom: 1px solid #f0f0f0;
}
.pantry-inv-item:last-child { border-bottom: none; }
.pantry-inv-name {
  flex: 1;
  font-size: 14px;
  cursor: pointer;
}
.pantry-inv-amt {
  font-size: 13px;
  color: var(--text-light);
  cursor: pointer;
}
.pantry-checked-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.pantry-empty-compact {
  padding: 16px;
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
}

/* 3-tab nav: larger icons */
.nav-icon { font-size: 24px; margin-bottom: 2px; }
.nav-item { font-size: 12px; padding: 6px 12px; }

/* Cuisine / Role badges */
.badge-cuisine, .badge-role {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}
.badge-cuisine {
  background: #e8f5e9;
  color: #2e7d32;
}
.badge-role {
  background: #e3f2fd;
  color: #1565c0;
}
.badge-bento-score {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 700;
  background: #fff3e0;
  color: #e65100;
  white-space: nowrap;
}

/* Candidate selection UI */
.candidate-slots {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 65vh;
  overflow-y: auto;
  padding: 4px;
}
.candidate-slot-role {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}
.candidate-cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.cand-card {
  flex: 0 0 120px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-bg);
}
.cand-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.cand-card:active {
  transform: scale(0.97);
}
.cand-thumb {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
}
.cand-thumb-empty {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  font-size: 28px;
}
.cand-title {
  padding: 4px 6px 2px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cand-meta {
  padding: 2px 6px 6px;
  font-size: 10px;
  color: var(--text-light);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.badge-cuisine-sm {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #e8f5e9;
  color: #2e7d32;
}

/* ========== 5-Mode Cards ========== */
.mode-section-title {
  font-size: 16px;
  font-weight: 600;
  padding: 8px 16px 4px;
  color: var(--text);
}
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 8px 16px;
}
.mode-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.mode-card:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.mode-card-icon {
  font-size: 32px;
  margin-bottom: 4px;
}
.mode-card-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.mode-card-desc {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Last card spans full width if odd number */
.mode-grid .mode-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ========== Filter Toggles ========== */
.filter-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
  justify-content: center;
}
.filter-btn {
  padding: 6px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ========== Pantry Priority Info ========== */
.pantry-priority-info {
  background: #fff3e0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: #e65100;
  margin: 8px 0;
}

/* ========== Expiring Banner ========== */
.expiring-banner {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  padding: 8px 14px;
  margin: 0 16px 8px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ========== Today Meal Sections ========== */
.today-meal-section {
  margin: 8px 0;
}
.today-meal-header {
  font-size: 14px;
  font-weight: 600;
  padding: 4px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-icon-sm {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.btn-icon-sm:hover {
  opacity: 1;
}

/* ========== Candidate Slot Header (with reroll) ========== */
.candidate-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

/* ========== Notification Dialog ========== */
.notify-dialog {
  text-align: center;
  padding: 8px 0;
}
.notify-dialog p {
  font-size: 14px;
  margin-bottom: 12px;
}
.servings-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}
.servings-input label {
  font-size: 14px;
  font-weight: 600;
}
.servings-input select {
  padding: 6px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: var(--card-bg);
}

/* ========== AI Button ========== */
.btn-ai {
  background: linear-gradient(135deg, #7c4dff, #536dfe);
  color: white;
  border: none;
}

/* ========== Role Carb ========== */
.role-carb {
  background: #fff9c4;
  color: #f57f17;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.5s forwards;
}
.toast.error {
  background: var(--danger);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ========== Week Meal Type Selector ========== */
.week-meal-type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0;
  justify-content: center;
}
.week-type-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* ========== Expiring Alert Enhancements ========== */
.pantry-alert-header {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  color: #e65100;
}
.pantry-alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  gap: 8px;
  flex-wrap: wrap;
}
.pantry-alert-actions {
  display: flex;
  gap: 8px;
}
.expiring-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* ========== 5-Mode Card Grid ========== */
.mode-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.mode-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.mode-card:active {
  transform: scale(0.97);
}

.mode-card-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.mode-card-label {
  font-size: 14px;
  font-weight: 700;
}

.mode-card-desc {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}

/* Last card spans full width when odd count */
.mode-grid .mode-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* ========== Filter Toggles ========== */
.filter-toggles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 10px 0;
}

.filter-btn {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pantry-priority-info {
  text-align: center;
  font-size: 13px;
  color: var(--success);
  padding: 8px;
  background: #e8f5e9;
  border-radius: 8px;
  margin: 8px 0;
}

/* ========== Candidate Selection Modal ========== */
.candidate-slots {
  max-height: 65vh;
  overflow-y: auto;
  padding-right: 4px;
}

.candidate-slot {
  margin-bottom: 16px;
}

.candidate-slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.candidate-slot-role {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.candidate-cards {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.cand-card {
  min-width: 120px;
  max-width: 140px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cand-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 107, 53, 0.25);
}

.cand-thumb {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 6px;
}

.cand-thumb-empty {
  width: 100%;
  height: 80px;
  background: #f0f0f0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 6px;
}

.cand-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cand-meta {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-light);
}

.badge-cuisine-sm {
  background: #e3f2fd;
  color: #1565c0;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
}

/* ========== Notify / Servings Dialog ========== */
.notify-dialog {
  text-align: center;
  padding: 8px 0;
}
.notify-dialog p {
  margin-bottom: 12px;
  font-size: 14px;
}

.servings-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}
.servings-input label {
  font-weight: 600;
}
.servings-input select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card-bg);
}

/* ========== Expiring Banner ========== */
.expiring-banner {
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.expiring-banner span {
  display: block;
}

/* ========== Today Meal Sections ========== */
.today-meal-section {
  margin-bottom: 12px;
}

.today-meal-header {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ========== Date + Alert Row ========== */
.date-alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.date-header-compact {
  font-size: 16px;
  font-weight: 700;
}
.alert-badges {
  display: flex;
  gap: 4px;
}
.alert-badge-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 16px;
  cursor: pointer;
}

/* ========== Browse Tab Bar ========== */
.browse-tab-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.browse-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}
.browse-tab-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff3e0;
}

.browse-tab-icon {
  font-size: 20px;
  margin-bottom: 2px;
}
.browse-tab-count {
  font-size: 10px;
  color: var(--text-light);
}

/* ========== Section Divider ========== */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ========== Bento Scroll (Today menu cards) ========== */
.bento-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.bento-slot-card {
  min-width: 110px;
  max-width: 130px;
  background: var(--card-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.bento-card-thumb {
  width: 100%;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
}

.bento-card-thumb-empty {
  width: 100%;
  height: 70px;
  background: #f5f5f5;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.bento-card-role {
  display: block;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
  color: var(--text-light);
}
.bento-card-role.role-main { color: var(--primary); }
.bento-card-role.role-side { color: var(--side); }
.bento-card-role.role-soup { color: var(--soup); }
.bento-card-role.role-carb { color: #8d6e63; }

.bento-card-name {
  display: block;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bento-card-change {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(255,255,255,0.85);
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Empty state ========== */
.empty-compact {
  text-align: center;
  padding: 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ========== Week Meal Type Selector ========== */
.week-meal-type-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0;
}

/* ========== Week Hero ========== */
.week-hero {
  text-align: center;
  padding: 24px 16px;
}
.week-hero h2 {
  font-size: 18px;
  margin-bottom: 6px;
}
.week-hero p {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* ===== Rotation Stock ===== */
.stock-progress-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}
.stock-progress-track {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.stock-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.stock-progress-label {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}
.consume-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  padding: 1px 6px;
  cursor: pointer;
  color: var(--text-light);
}
.consume-btn:hover {
  background: #f5f5f5;
  color: var(--danger, #e53935);
}
.low-stock-alert {
  background: #fce4ec;
  border: 1px solid #ef9a9a;
  border-radius: var(--radius, 8px);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}
.low-stock-alert-header {
  font-weight: 700;
  color: #c62828;
  margin-bottom: 4px;
}

/* ========== Stockpile Recommendations ========== */
.stockpile-recs-section { margin: 8px 0 4px; }
.stockpile-recs-title {
  font-size: 14px; font-weight: 600;
  padding: 4px 0 6px;
}
.stockpile-recs-scroll {
  display: flex; gap: 8px;
  overflow-x: auto; padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stockpile-recs-scroll::-webkit-scrollbar { display: none; }
.stockpile-rec-card {
  min-width: 150px; max-width: 170px;
  background: var(--card-bg);
  border-radius: 10px; padding: 10px;
  border-left: 4px solid transparent;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stockpile-rec-card.urgency-urgent { border-left-color: #e53935; }
.stockpile-rec-card.urgency-soon   { border-left-color: #ff9800; }
.stockpile-rec-card.urgency-plan   { border-left-color: #4caf50; }
.stockpile-rec-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stockpile-rec-amount { font-size: 11px; color: var(--text-light); }
.stockpile-rec-expiry { font-size: 11px; color: var(--text-light); margin: 2px 0 6px; }
.stockpile-rec-recipe {
  font-size: 12px; color: var(--primary);
  cursor: pointer; padding: 3px 0;
  border-top: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stockpile-rec-recipe:hover { text-decoration: underline; }
.stockpile-rec-shelf {
  font-size: 10px; color: #888; margin-top: 1px;
}
.stockpile-rec-badge {
  font-size: 11px; background: #e8f5e9; color: #2e7d32;
  padding: 2px 6px; border-radius: 4px;
  display: inline-block; margin-top: 4px;
}
.stockpile-rec-suggest {
  font-size: 11px; color: var(--primary);
  background: none; border: 1px solid var(--primary);
  border-radius: 4px; padding: 3px 6px;
  margin-top: 6px; cursor: pointer; width: 100%;
}
.stockpile-rec-suggest:hover { background: var(--primary); color: #fff; }

/* ========== Week Recipe Picker ========== */
.week-slot-change {
  background: none; border: none; color: var(--text-light);
  font-size: 14px; cursor: pointer; padding: 2px 4px;
  margin-left: auto; flex-shrink: 0; opacity: 0.5;
}
.week-slot-change:hover { opacity: 1; color: var(--primary); }
.week-slot-row { display: flex; align-items: center; }
.week-picker-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.week-picker-item:hover { background: #f5f5f5; }
.week-picker-thumb {
  width: 48px; height: 48px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
}
.week-picker-info { flex: 1; min-width: 0; }
.week-picker-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.week-picker-meta { font-size: 11px; color: var(--text-light); }
.week-picker-filters { margin-bottom: 6px; }
.week-picker-filter-row {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px;
}
.week-picker-filter-row .rp-chip { font-size: 11px; padding: 2px 8px; }
.week-picker-count { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.week-picker-list { max-height: 50vh; overflow-y: auto; }
.week-picker-more {
  display: block; width: 100%; padding: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--primary);
  font-size: 13px; cursor: pointer; margin-top: 4px;
}
.week-picker-more:hover { background: var(--primary); color: #fff; }
