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

body {
  font-family: 'Georgia', serif;
  background: #faf7f2;
  color: #2c2c2c;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #8b2e1a, #c0392b);
  color: white;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
header h1 { font-size: 2rem; letter-spacing: 1px; }
header .subtitle { font-style: italic; opacity: .85; margin-top: 4px; font-size: 1.1rem; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* ── Rules ── */
.rules-section { margin-bottom: 20px; }

.rules-toggle {
  background: none;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  color: #666;
  width: 100%;
  text-align: left;
  transition: background .15s;
}
.rules-toggle:hover { background: #f0ebe3; }

.rules-panel { margin-top: 10px; }
.rules-panel.hidden { display: none; }

.rules-panel textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: monospace;
  font-size: .88rem;
  line-height: 1.6;
  resize: vertical;
  background: #fffdf9;
}
.rules-panel textarea:focus { outline: none; border-color: #c0392b; }

.rules-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }

.btn-save {
  background: #555;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: .88rem;
  transition: background .15s;
}
.btn-save:hover { background: #333; }

.saved-hint { font-size: .85rem; color: #2e7d32; font-family: sans-serif; }

/* ── Actions ── */
.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.btn-primary {
  background: #c0392b; color: white; border: none;
  padding: 14px 28px; font-size: 1rem; border-radius: 8px;
  cursor: pointer; font-family: inherit;
  transition: background .2s, transform .1s;
  box-shadow: 0 3px 8px rgba(192,57,43,.3);
}
.btn-primary:hover { background: #a93226; transform: translateY(-1px); }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: #2c7a3c; color: white; border: none;
  padding: 14px 28px; font-size: 1rem; border-radius: 8px;
  cursor: pointer; font-family: inherit;
  transition: background .2s, transform .1s;
  box-shadow: 0 3px 8px rgba(44,122,60,.3);
}
.btn-secondary:hover { background: #236130; transform: translateY(-1px); }

/* ── Loading ── */
.loading { text-align: center; padding: 40px; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #ddd; border-top-color: #c0392b;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Menu grid ── */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.day-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  transition: box-shadow .2s;
}
.day-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.14); }

.day-header {
  background: linear-gradient(135deg, #8b2e1a, #c0392b);
  color: white;
  padding: 10px 16px;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: .5px;
}

.meal {
  padding: 10px 16px;
  border-bottom: 1px solid #f0ebe3;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.meal:last-child { border-bottom: none; }
.meal-icon { font-size: 1.2rem; min-width: 26px; text-align: center; margin-top: 1px; }
.meal-body { flex: 1; }
.meal-label {
  font-size: .7rem; text-transform: uppercase;
  letter-spacing: 1px; color: #999; font-family: sans-serif; margin-bottom: 2px;
}
.meal-name { font-size: .95rem; color: #2c2c2c; line-height: 1.4; }
.dish-link {
  color: #2c2c2c; text-decoration: none; cursor: pointer;
  border-bottom: 1px dashed #c0392b; transition: color .15s;
}
.dish-link:hover { color: #c0392b; }

/* ── Add dish form ── */
.add-dish-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.add-dish-row input[type="text"] {
  flex: 1;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
}
.add-dish-row input:focus { outline: none; border-color: #c0392b; }
.add-dish-row select {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
  background: white;
}

/* ── Dishes list ── */
.dishes-list { display: flex; flex-direction: column; gap: 6px; }
.dishes-empty { color: #aaa; font-size: .88rem; font-family: sans-serif; padding: 8px 0; }

.dish-item {
  background: #fffdf9;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
}
.dish-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.dish-item-name { flex: 1; font-size: .9rem; }
.dish-item-type {
  font-size: .7rem; font-family: sans-serif;
  background: #f0ebe3; color: #888;
  padding: 2px 7px; border-radius: 10px;
}
.dish-item-details-btn, .dish-item-del {
  background: none; border: none; cursor: pointer;
  font-size: .85rem; padding: 2px 4px;
  opacity: .4; transition: opacity .15s;
}
.dish-item-details-btn:hover, .dish-item-del:hover { opacity: 1; }

.dish-item-details { padding: 0 12px 10px; }
.dish-item-details.hidden { display: none; }
.dish-nutrients {
  font-size: .78rem; font-family: sans-serif;
  color: #666; margin-bottom: 8px;
}
.dish-ingredients {
  list-style: none; padding: 0; margin: 0;
}
.dish-ingredients li {
  font-size: .82rem; padding: 2px 0;
  border-bottom: 1px dotted #f0ebe3;
}
.dish-ingredients li::before { content: '— '; color: #c0392b; }

/* ── Inline manual input ── */
.manual-input-row {
  display: flex; gap: 6px; align-items: center;
  margin-top: 6px;
}
.manual-input-row.hidden { display: none; }
.manual-input-field {
  flex: 1; padding: 5px 8px;
  border: 1px solid #c0392b; border-radius: 5px;
  font-family: inherit; font-size: .88rem;
}
.btn-confirm, .btn-cancel {
  background: none; border: 1px solid #ddd;
  border-radius: 5px; cursor: pointer;
  padding: 4px 8px; font-size: .85rem;
  transition: background .15s;
}
.btn-confirm { color: #2e7d32; border-color: #2e7d32; }
.btn-confirm:hover { background: #e8f5e9; }
.btn-cancel { color: #888; }
.btn-cancel:hover { background: #f5f5f5; }

.veto-btn {
  background: none; border: none; cursor: pointer;
  font-size: .9rem; padding: 2px 4px;
  opacity: .25; transition: opacity .15s;
  flex-shrink: 0; align-self: center;
}
.veto-btn:hover { opacity: 1; }
.veto-btn:disabled { cursor: default; }

.edit-btn {
  background: none; border: none; cursor: pointer;
  font-size: .9rem; padding: 2px 4px;
  opacity: .3; transition: opacity .15s;
  flex-shrink: 0; align-self: center;
}
.edit-btn:hover { opacity: 1; }

.regen-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.35;
  transition: opacity .15s;
  flex-shrink: 0;
  align-self: center;
}
.regen-btn:hover { opacity: 1; }
.regen-btn:disabled { cursor: default; }

.legume-badge {
  display: inline-block;
  background: #e8f5e9; color: #2e7d32;
  font-size: .65rem; font-family: sans-serif;
  padding: 1px 6px; border-radius: 10px; margin-left: 6px;
  vertical-align: middle; letter-spacing: .5px;
}

/* ── Nutrients ── */
.nutrients {
  border-top: 1px solid #f0ebe3;
}

.nutrients-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 9px 16px;
  font-size: .8rem;
  font-family: sans-serif;
  color: #888;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nutrients-toggle:hover, .nutrients-toggle.open {
  background: #fdf5ef;
  color: #8b2e1a;
}

.nutrients-body { padding: 0 16px 10px; }
.nutrients-body.hidden { display: none; }

.nutrient-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  border-bottom: 1px dotted #f0ebe3;
  font-size: .82rem;
}
.nutrient-row.sub {
  padding-left: 12px;
  color: #888;
  font-size: .78rem;
}
.nutrient-row.mineral { color: #555; }

.nutrient-label { color: inherit; }
.nutrient-val { font-family: sans-serif; font-weight: 600; color: #8b2e1a; font-size: .82rem; }

/* ── Modal ── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }

.modal-content {
  background: white; border-radius: 14px; padding: 28px;
  max-width: 540px; width: 100%;
  position: relative; margin: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 1.6rem;
  cursor: pointer; color: #888; line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-title { font-size: 1.3rem; margin-bottom: 18px; color: #8b2e1a; padding-right: 30px; }
.modal-loading { text-align: center; padding: 30px; color: #888; }

.category { margin-bottom: 18px; }
.category-name {
  font-size: .75rem; text-transform: uppercase; letter-spacing: 1px;
  color: #888; font-family: sans-serif; margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 1px solid #eee;
}
.category ul { list-style: none; padding: 0; }
.category ul li, .ingredients-list li {
  padding: 4px 0; font-size: .95rem;
  border-bottom: 1px dotted #f0ebe3;
  display: flex; align-items: center; gap: 8px;
}
.category ul li::before, .ingredients-list li::before {
  content: '—'; color: #c0392b; font-size: .8rem;
}
.ingredients-list { list-style: none; padding: 0; }

.error { color: #c0392b; text-align: center; padding: 20px; }

@media (max-width: 600px) {
  header h1 { font-size: 1.5rem; }
  .menu-grid { grid-template-columns: 1fr; }
}
