* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

/* ヘッダー */
header {
  background: #4CAF50;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

header h1 {
  font-size: 1.2rem;
  font-weight: bold;
  margin-right: auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions button {
  background: rgba(255,255,255,0.25);
  border: none;
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.header-actions button:hover {
  background: rgba(255,255,255,0.4);
}

#weekLabel {
  font-size: 0.9rem;
  font-weight: bold;
  white-space: nowrap;
}

/* タブ */
.tabs {
  display: flex;
  background: white;
  border-bottom: 2px solid #e0e0e0;
}

.tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: #666;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab.active {
  color: #4CAF50;
  border-bottom-color: #4CAF50;
  font-weight: bold;
}

/* タブコンテンツ */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* カレンダー */
.calendar-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-x: auto;
  min-width: 375px;
}

.cal-header {
  background: #4CAF50;
  color: white;
  text-align: center;
  padding: 8px 4px;
  font-size: 0.75rem;
  font-weight: bold;
  border-radius: 6px;
}

.cal-header.today-header {
  background: #2E7D32;
}

.cal-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 0.75rem;
  color: #666;
  font-weight: bold;
}

.cal-cell {
  background: white;
  border-radius: 6px;
  padding: 6px;
  min-height: 64px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-cell:hover {
  background: #f1f8e9;
  border-color: #4CAF50;
}

.cal-cell.has-meal {
  background: #f9ffe9;
  border-color: #81C784;
}

.cal-cell.today-cell {
  border-color: #4CAF50;
  border-width: 2px;
}

.meal-name {
  font-size: 0.7rem;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-ingredients {
  font-size: 0.62rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-icon {
  color: #ccc;
  font-size: 1rem;
  text-align: center;
  margin: auto;
}

/* 買い物リスト */
.shopping-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  flex-wrap: wrap;
}

.shopping-header h2 {
  font-size: 1rem;
  margin-right: auto;
}

.shopping-header button {
  font-size: 0.8rem;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  color: #555;
}

.shopping-header button:hover {
  background: #f5f5f5;
}

.shopping-list {
  padding: 8px 16px;
}

.shopping-group {
  margin-bottom: 12px;
}

.shopping-group-title {
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 4px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 2px;
}

.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: white;
  border-radius: 6px;
  margin-bottom: 4px;
  border: 1px solid #e0e0e0;
}

.shopping-item.checked {
  opacity: 0.45;
}

.shopping-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4CAF50;
}

.shopping-item label {
  flex: 1;
  font-size: 0.9rem;
  cursor: pointer;
}

.shopping-item.checked label {
  text-decoration: line-through;
}

.shopping-item .del-btn {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}

.shopping-item .del-btn:hover {
  color: #e53935;
}

.add-item {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  position: sticky;
  bottom: 0;
}

.add-item input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

.add-item button {
  padding: 8px 14px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.add-item button:hover {
  background: #43A047;
}

.empty-shopping {
  text-align: center;
  color: #aaa;
  padding: 40px 16px;
  font-size: 0.9rem;
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #4CAF50;
  color: white;
}

.modal-header h2 {
  font-size: 0.95rem;
}

#closeModal {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body label {
  font-size: 0.8rem;
  color: #555;
  font-weight: bold;
}

.modal-body input,
.modal-body textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.modal-body textarea {
  height: 72px;
  resize: vertical;
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e0e0e0;
  flex-wrap: wrap;
}

.btn-primary {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
}

.btn-primary:hover { background: #43A047; }

.btn-danger {
  background: white;
  color: #e53935;
  border: 1px solid #e53935;
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-danger:hover { background: #ffebee; }

#cancelModal {
  background: white;
  color: #555;
  border: 1px solid #ccc;
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  margin-left: auto;
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

#overlay.hidden { display: none; }

/* レスポンシブ（スマホ） */
@media (max-width: 600px) {
  .calendar-grid {
    grid-template-columns: 50px repeat(7, 1fr);
    padding: 4px;
    gap: 1px;
  }

  .cal-cell {
    min-height: 52px;
    padding: 4px;
  }

  .cal-header {
    font-size: 0.65rem;
    padding: 6px 2px;
  }

  .cal-label {
    font-size: 0.65rem;
    padding-right: 4px;
  }

  .meal-name {
    font-size: 0.62rem;
  }

  .meal-ingredients {
    display: none;
  }

  header h1 {
    font-size: 1rem;
  }
}
