:root {
  --bg: #FBF3E7;
  --ink: #2B2521;
  --orange: #E76F51;
  --teal: #2A9D8F;
  --yellow: #E9C46A;
  --red: #B5432E;
  --placeholder-a: #F1E6D3;
  --placeholder-b: #EADFC9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
}

body { padding-bottom: 40px; min-height: 100vh; }

input, textarea, select, button { font-family: 'Nunito', sans-serif; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.app { min-height: 100vh; }

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  border-bottom: 2.5px solid var(--ink);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-title { font-weight: 900; font-size: 22px; letter-spacing: -0.3px; }
.brand-logo { width: 42px; height: 42px; object-fit: cover; border-radius: 10px; border: 2.5px solid var(--ink); flex: none; }

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

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.btn {
  font-weight: 800;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2.5px solid var(--ink);
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  transition: transform .12s;
}
.btn:hover { transform: translate(-1px, -1px); }
.btn:active { transform: translate(2px, 2px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

.btn-primary { background: var(--orange); color: #fff; box-shadow: 4px 4px 0 var(--ink); }
.btn-primary:hover { box-shadow: 5px 5px 0 var(--ink); }
.btn-primary:active { box-shadow: 1px 1px 0 var(--ink); }

.btn-outline { background: #fff; box-shadow: 3px 3px 0 var(--ink); font-weight: 700; }
.btn-edit { background: var(--yellow); box-shadow: 3px 3px 0 var(--ink); border-radius: 12px; padding: 9px 16px; }
.btn-delete { background: #fff; color: var(--red); box-shadow: 3px 3px 0 var(--ink); border-radius: 12px; padding: 9px 16px; }
.btn-save { background: var(--teal); color: #fff; box-shadow: 4px 4px 0 var(--ink); border-radius: 12px; font-weight: 900; font-size: 15px; padding: 13px; }
.btn-cancel { background: #fff; border-radius: 12px; font-weight: 800; font-size: 15px; padding: 13px; box-shadow: none; }

.view-toggle { display: flex; align-items: center; gap: 6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; padding: 4px; }
.view-toggle-btn { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px; border: none; cursor: pointer; font-weight: 800; font-size: 13px; background: transparent; color: var(--ink); }
.view-toggle-btn.active { background: var(--teal); color: #fff; }

.grid-icon { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 14px; height: 14px; }
.grid-icon span { background: currentColor; border-radius: 2px; }
.list-icon { display: flex; flex-direction: column; gap: 2px; width: 14px; }
.list-icon span { height: 2.5px; background: currentColor; border-radius: 2px; }

.page-title { font-weight: 900; font-size: 26px; }
.page-subtitle { color: rgba(43,37,33,0.55); font-weight: 600; font-size: 14px; margin: 6px 0 18px; }
.overview-top { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 6px; }

.search-box { position: relative; margin-bottom: 16px; }
.search-input {
  width: 100%; padding: 12px 44px 12px 16px; border-radius: 14px; border: 2.5px solid var(--ink);
  font-size: 15px; font-weight: 700; background: #fff; color: var(--ink);
}
.search-input::placeholder { color: rgba(43,37,33,0.4); font-weight: 600; }
.search-clear-btn {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--ink); background: #fff;
  font-weight: 900; font-size: 15px; cursor: pointer; color: var(--red);
}

.chip { display: flex; align-items: center; gap: 8px; padding: 6px 16px 6px 6px; border-radius: 999px; font-weight: 800; font-size: 13.5px; cursor: pointer; border-width: 2.2px; border-style: solid; user-select: none; }
.chip-dot { width: 20px; height: 20px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 900; flex: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.recipe-card { background: #fff; border: 2.5px solid var(--ink); border-radius: 18px; overflow: hidden; cursor: pointer; box-shadow: 4px 4px 0 var(--ink); transition: transform .12s, box-shadow .12s; }
.recipe-card:hover { transform: translate(-3px,-3px); box-shadow: 7px 7px 0 var(--ink); }
.recipe-card-img { width: 100%; height: 150px; object-fit: cover; display: block; border-bottom: 2.5px solid var(--ink); }
.recipe-card-placeholder { width: 100%; height: 150px; background: repeating-linear-gradient(135deg, var(--placeholder-a) 0 10px, var(--placeholder-b) 10px 20px); border-bottom: 2.5px solid var(--ink); display: flex; align-items: center; justify-content: center; font-family: monospace; font-size: 11px; color: rgba(43,37,33,0.4); text-transform: uppercase; letter-spacing: 1px; }
.recipe-card-body { padding: 14px 16px 16px; }
.recipe-card-title { font-weight: 900; font-size: 17px; margin-bottom: 9px; }
.recipe-card-cats { display: flex; flex-wrap: wrap; gap: 6px; }

.mini-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; padding: 3px 10px 3px 3px; border-radius: 999px; border-width: 1.5px; border-style: solid; }
.mini-chip-dot { width: 15px; height: 15px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 900; flex: none; }

.list-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.list-sidebar { flex: 1 1 200px; min-width: 180px; background: #fff; border: 2.5px solid var(--ink); border-radius: 16px; padding: 16px; box-shadow: 4px 4px 0 var(--ink); }
.list-sidebar-title { font-weight: 900; font-size: 15px; margin-bottom: 10px; }
.list-checkbox-row { display: flex; align-items: center; gap: 9px; padding: 7px 2px; cursor: pointer; font-weight: 700; font-size: 14px; }
.list-checkbox-row input { width: 19px; height: 19px; accent-color: var(--teal); flex: none; }
.list-main { flex: 3 1 420px; display: flex; flex-direction: column; gap: 10px; }
.list-row { display: flex; align-items: center; gap: 14px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform .12s, box-shadow .12s; }
.list-row:hover { transform: translate(-2px,-2px); box-shadow: 5px 5px 0 var(--ink); }
.list-row-img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 2px solid var(--ink); flex: none; }
.list-row-placeholder { width: 64px; height: 64px; border-radius: 10px; border: 2px solid var(--ink); flex: none; background: repeating-linear-gradient(135deg, var(--placeholder-a) 0 8px, var(--placeholder-b) 8px 16px); }
.list-row-title { font-weight: 900; font-size: 16px; margin-bottom: 6px; }

.empty-state { text-align: center; padding: 50px 20px; color: rgba(43,37,33,0.55); font-weight: 700; }

.back-btn { margin-bottom: 18px; }

.detail-image { width: 100%; height: 280px; object-fit: cover; border-radius: 20px; border: 2.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); display: block; }
.detail-image-placeholder { width: 100%; height: 280px; border-radius: 20px; border: 2.5px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); background: repeating-linear-gradient(135deg, var(--placeholder-a) 0 14px, var(--placeholder-b) 14px 28px); display: flex; align-items: center; justify-content: center; font-family: monospace; font-size: 13px; color: rgba(43,37,33,0.4); text-transform: uppercase; letter-spacing: 1px; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 20px; }
.detail-title { font-weight: 900; font-size: 30px; margin-bottom: 10px; }
.detail-cats { display: flex; flex-wrap: wrap; gap: 7px; }
.detail-cat-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; padding: 4px 12px 4px 4px; border-radius: 999px; border-width: 1.5px; border-style: solid; }
.detail-cat-dot { width: 18px; height: 18px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 900; flex: none; }
.detail-actions { display: flex; gap: 8px; flex: none; }

.detail-body { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 26px; }
.ingredients-panel { flex: 1 1 260px; background: #fff; border: 2.5px solid var(--ink); border-radius: 18px; padding: 20px; box-shadow: 4px 4px 0 var(--ink); align-self: flex-start; }
.panel-title { font-weight: 900; font-size: 18px; margin-bottom: 14px; }
.ingredient-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; font-weight: 700; font-size: 15px; border-bottom: 1.5px dashed rgba(43,37,33,0.15); }
.ingredient-row input { width: 20px; height: 20px; flex: none; accent-color: var(--teal); }
.ingredient-row span.checked { text-decoration: line-through; opacity: .45; }
.ingredient-heading { font-weight: 900; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--teal); margin: 16px 0 4px; }
.ingredient-heading:first-child { margin-top: 0; }

.portion-stepper {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 2px solid var(--ink); border-radius: 14px;
  padding: 10px 14px; margin-bottom: 16px;
}
.portion-stepper-label { font-weight: 800; font-size: 15px; }
.portion-btn {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--teal); background: #fff; color: var(--teal);
  font-size: 22px; font-weight: 900; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, background .1s, color .1s;
}
.portion-btn:hover:not(:disabled) { background: var(--teal); color: #fff; }
.portion-btn:active:not(:disabled) { transform: scale(0.92); }
.portion-btn:disabled { opacity: .35; cursor: default; }
.portion-value {
  width: 68px; text-align: center; padding: 7px 6px; border-radius: 10px;
  border: 2.5px solid var(--ink); background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 800;
}

.field-hint { font-size: 13px; font-weight: 600; opacity: .55; margin-top: 6px; }
.servings-input { max-width: 140px; }

.steps-panel { flex: 2 1 420px; background: #fff; border: 2.5px solid var(--ink); border-radius: 18px; padding: 20px; box-shadow: 4px 4px 0 var(--ink); }
.step { display: flex; gap: 14px; margin-bottom: 18px; }
.step-num { width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; border: 2px solid var(--ink); flex: none; }
.step-text { font-weight: 600; font-size: 15.5px; line-height: 1.5; }
.step-image { width: 100%; max-width: 340px; border-radius: 14px; border: 2px solid var(--ink); margin-top: 10px; display: block; }

.edit-page { max-width: 640px; margin: 0 auto; }
.form-heading { font-weight: 900; font-size: 26px; margin-bottom: 20px; }
.field { margin-bottom: 20px; }
.field-label { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.text-input, .textarea-input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 2.5px solid var(--ink);
  font-size: 16px; font-weight: 700; background: #fff; color: var(--ink);
}
.textarea-input { font-size: 14.5px; font-weight: 600; resize: vertical; padding: 10px; border-radius: 10px; border-width: 2px; }

.category-editor-row { display: flex; gap: 8px; }
.new-category-input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--ink); font-size: 14px; font-weight: 600; }
.add-category-btn { padding: 10px 16px; border-radius: 10px; background: var(--teal); color: #fff; border: 2px solid var(--ink); font-weight: 800; font-size: 14px; cursor: pointer; }

.image-preview-wrap { position: relative; }
.image-preview { width: 100%; height: 200px; object-fit: cover; border-radius: 14px; border: 2.5px solid var(--ink); display: block; }
.image-remove-btn { position: absolute; top: 10px; right: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 12px; font-weight: 800; font-size: 13px; cursor: pointer; }

.image-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  height: 160px; border: 2.5px dashed var(--ink); border-radius: 14px; cursor: pointer; background: var(--bg);
}
.image-drop-icon { width: 38px; height: 38px; border-radius: 50%; border: 2.5px solid var(--ink); display: flex; align-items: center; justify-content: center; }
.image-drop-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--orange); }
.image-drop-label { font-weight: 700; font-size: 14px; color: rgba(43,37,33,0.6); }

.ingredient-edit-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.ingredient-edit-heading-row { background: var(--bg); border: 2px dashed var(--teal); border-radius: 10px; padding: 6px 8px; }
.heading-input { flex: 1; padding: 10px; border-radius: 8px; border: 2px solid var(--teal); font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; color: var(--teal); background: #fff; }
.ingredient-edit-row.dragging { box-shadow: 4px 4px 0 var(--ink); background: #fff; opacity: .95; }

.drag-handle { flex: none; display: flex; align-items: center; padding: 4px 2px; cursor: grab; touch-action: none; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle-icon { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 9px; }
.drag-handle-icon span { width: 3px; height: 3px; border-radius: 50%; background: rgba(43,37,33,0.35); }
.amount-input { width: 70px; padding: 10px; border-radius: 10px; border: 2px solid var(--ink); font-size: 14px; font-weight: 600; flex: none; }
.unit-input { width: 88px; padding: 10px 8px; border-radius: 10px; border: 2px solid var(--ink); font-size: 14px; font-weight: 600; flex: none; }
.name-input { flex: 1; min-width: 0; padding: 10px; border-radius: 10px; border: 2px solid var(--ink); font-size: 14px; font-weight: 600; }
.row-remove-btn { width: 38px; height: 38px; flex: none; border-radius: 10px; border: 2px solid var(--ink); background: #fff; font-weight: 900; font-size: 16px; cursor: pointer; color: var(--red); }
.add-row-btn { margin-top: 6px; padding: 9px 15px; border-radius: 10px; background: #fff; color: var(--ink); border: 2px solid var(--ink); font-weight: 800; font-size: 13.5px; cursor: pointer; }

.step-edit-row { display: flex; gap: 10px; margin-bottom: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 12px; }
.step-edit-num { width: 28px; height: 28px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 13px; flex: none; }
.step-edit-body { flex: 1; min-width: 0; }
.step-image-preview-wrap { position: relative; margin-top: 8px; display: inline-block; }
.step-image-preview { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; border: 2px solid var(--ink); display: block; }
.step-image-remove { position: absolute; top: 4px; right: 4px; background: #fff; border: 1.5px solid var(--ink); border-radius: 8px; padding: 2px 7px; font-weight: 800; font-size: 11px; cursor: pointer; }
.step-image-add-label { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 7px 12px; border-radius: 9px; border: 1.5px dashed var(--ink); font-size: 12.5px; font-weight: 700; cursor: pointer; color: rgba(43,37,33,0.6); }
.step-edit-remove { width: 32px; height: 32px; flex: none; border-radius: 10px; border: 2px solid var(--ink); background: #fff; font-weight: 900; font-size: 15px; cursor: pointer; color: var(--red); }

.form-actions { position: sticky; bottom: 0; background: var(--bg); border-top: 2.5px solid var(--ink); padding: 14px 20px; display: flex; gap: 10px; margin: 0 -20px; }
.form-actions .btn-cancel, .form-actions .btn-save { flex: 1; }
.form-actions .btn-save { flex: 2; }

.modal-overlay { position: fixed; inset: 0; background: rgba(43,37,33,0.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--bg); border: 2.5px solid var(--ink); border-radius: 20px; padding: 26px; width: 100%; max-width: 340px; box-shadow: 6px 6px 0 var(--ink); animation: modalIn .18s ease-out; }
.modal-title { font-weight: 900; font-size: 20px; margin-bottom: 16px; }
.modal-error { color: var(--red); font-weight: 700; font-size: 13px; margin-bottom: 6px; min-height: 16px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; padding: 11px; border-radius: 12px; font-weight: 800; font-size: 14px; cursor: pointer; border: 2px solid var(--ink); }

.hidden { display: none !important; }
.upload-status { font-size: 12px; font-weight: 700; color: rgba(43,37,33,0.55); margin-top: 6px; }

/* ---- Handy-Layout (bisher nur Flex-Wrap, hier gezielte Breakpoints) ---- */
@media (max-width: 600px) {
  .container { padding: 16px 14px 48px; }

  /* Header: drei Aktionen (Neu / Nutzer / Abmelden) sollen nicht ueberlaufen */
  .header-inner { flex-wrap: wrap; gap: 8px; }
  .header-actions { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
  .header-actions .btn { padding: 8px 12px; font-size: 13px; }

  .page-title { font-size: 22px; }
  .detail-title { font-size: 24px; }

  /* Zwei Karten pro Reihe statt einer sehr breiten */
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .recipe-card-img, .recipe-card-placeholder { height: 120px; }

  .detail-image, .detail-image-placeholder { height: 200px; }
  .detail-body { gap: 16px; margin-top: 20px; }
  .ingredients-panel { padding: 16px; }

  /* Zutaten-Editor: Menge/Einheit/Zutat brechen bei Bedarf um statt zu quetschen */
  .ingredient-edit-row { flex-wrap: wrap; }
  .ingredient-edit-row .amount-input { flex: 1 1 70px; }
  .ingredient-edit-row .unit-input { flex: 1 1 70px; }
  .ingredient-edit-row .name-input { flex: 1 1 100%; order: 3; }

  .edit-page { max-width: 100%; }
}
