body.sheet-open { overflow: hidden; }

.quick-add-fab {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  gap: 6px;
  padding: 0 17px;
  border: 1px solid #8f4e36;
  border-radius: 999px;
  color: #fffdf9;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(77, 61, 45, .22);
  font: inherit;
  font-size: .9rem;
  font-weight: 800;
  cursor: pointer;
}

.quick-add-fab span { font-size: 1.2rem; line-height: 1; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 18px;
  background: rgba(43, 41, 38, .34);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.sheet-backdrop[hidden] { display: none; }

.quick-add-sheet {
  width: min(100%, 520px);
  max-height: min(88dvh, 780px);
  overflow-y: auto;
  padding: 9px 20px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 28px 70px rgba(43, 41, 38, .22);
}

.record-detail-sheet {
  width: min(100%, 520px);
  max-height: min(78dvh, 680px);
  overflow-y: auto;
  padding: 9px 20px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 28px 70px rgba(43, 41, 38, .22);
}

.record-detail-list { display: grid; gap: 10px; }
.record-detail-card { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #f8f3ec; }
.record-detail-card__heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.record-detail-card__heading > div { display: grid; gap: 3px; min-width: 0; }
.record-detail-card__heading strong { overflow: hidden; font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.record-detail-card__heading span { color: var(--muted); font-size: .72rem; }
.record-detail-card__id { flex: 0 0 auto; color: var(--muted); font-size: .68rem !important; }
.record-detail-card__facts { display: grid; gap: 3px; margin-top: 10px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.record-detail-card__actions { display: flex; gap: 7px; margin-top: 12px; }
.sheet-action { min-height: 35px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font: inherit; font-size: .76rem; font-weight: 800; cursor: pointer; }
.sheet-action--secondary { color: #7c3d28; background: var(--accent-soft); }
.sheet-action--danger { color: #8b3f35; background: #f6e2de; }

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--empty);
}

.quick-add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.quick-add-header h2 { font-size: 1.55rem; }

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #f5f0e9;
  font: inherit;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.field-label {
  display: block;
  margin: 13px 0 7px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.text-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--ink);
  background: #fffdf9;
  font: inherit;
  font-size: 16px;
}

.text-input:focus {
  border-color: #c68467;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input { appearance: none; -webkit-appearance: none; }

.search-results {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.search-result-row { display: flex; align-items: stretch; gap: 6px; }
.search-result-row .search-result { flex: 1 1 auto; min-width: 0; }
.search-empty-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 2px 4px; }
.search-result-edit {
  flex: 0 0 auto;
  align-self: center;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fffdf9;
  font: inherit;
  font-size: .7rem;
  font-weight: 750;
  cursor: pointer;
}
.search-result-edit:hover,
.search-result-edit:focus-visible { border-color: #d9b5a3; color: #7c3d28; background: var(--accent-soft); outline: none; }

.search-hint {
  margin: 0;
  padding: 8px 2px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.5;
}

.search-result {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  text-align: left;
  color: var(--ink);
  background: #f5f0e9;
  font: inherit;
  cursor: pointer;
}

.search-result:focus,
.search-result:hover { border-color: #d9b5a3; background: #fbf1e9; }
.search-result__primary { font-size: .9rem; font-weight: 800; }
.search-result__secondary { color: var(--muted); font-size: .75rem; }

.selected-result {
  display: grid;
  gap: 7px;
  margin: 10px 0 4px;
  padding: 11px 12px;
  border: 1px solid #d6e0d7;
  border-radius: 12px;
  background: var(--sage-soft);
}

.selected-result[hidden] { display: none; }
.selected-result .selected-label { color: #45604c; font-size: .64rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.selected-result strong { font-size: .92rem; }
.selected-result > span:last-child { color: #58725f; font-size: .74rem; }

.selected-items { display: grid; gap: 7px; margin-top: 5px; }
.selected-item {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid #d6e0d7;
  border-radius: 10px;
  background: rgba(255, 253, 249, .7);
}
.selected-item__body { display: grid; min-width: 0; gap: 3px; }
.selected-item__body strong { font-size: .86rem; }
.selected-item__body > span { color: #58725f; font-size: .72rem; line-height: 1.35; }
.selected-item__remove {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fffdf9;
  font: inherit;
  font-size: .68rem;
  cursor: pointer;
}
.selected-item__remove:hover,
.selected-item__remove:focus-visible { border-color: #d9b5a3; color: #7c3d28; outline: none; }
.selected-item__ingredients { color: #58725f; font-size: .7rem; }
.selected-item__ingredients summary { width: fit-content; cursor: pointer; color: #45604c; font-weight: 750; }
.selected-item__ingredients > span { display: block; margin-top: 3px; line-height: 1.4; }

.quick-add-manage-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

.catalog-editor {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid #d9b5a3;
  border-radius: 14px;
  background: #fff8f0;
}
.catalog-editor[hidden] { display: none; }
.catalog-editor__heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.catalog-editor__heading h3 { margin: 0; font-size: 1rem; }
.catalog-editor__heading .section-kicker { margin-bottom: 4px; }
.icon-button--small { width: 32px; height: 32px; font-size: 1.15rem; }
.catalog-editor__actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 12px; }
.catalog-editor__actions .save-button { width: auto; min-height: 36px; padding: 6px 13px; border-radius: 999px; font-size: .76rem; }
.catalog-editor__actions .sheet-action { min-height: 36px; }

.quick-add-sheet.is-catalog-mode #quick-add-form > :not(.catalog-editor) { display: none !important; }
.quick-add-sheet.is-catalog-mode .catalog-editor { margin-top: 0; }
.quick-add-sheet.is-catalog-mode .catalog-editor__heading .icon-button { display: none; }


.ingredient-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 260px;
  margin-top: 8px;
  padding: 7px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fffdf9;
}
.ingredient-option {
  display: flex;
  align-items: start;
  gap: 7px;
  min-width: 0;
  padding: 7px;
  border-radius: 8px;
  background: #f5f0e9;
  cursor: pointer;
}
.ingredient-option:has(input:checked) { background: var(--sage-soft); }
.ingredient-option input { flex: 0 0 auto; margin-top: 3px; accent-color: var(--sage); }
.ingredient-option span { display: grid; min-width: 0; gap: 2px; }
.ingredient-option strong { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-option small { overflow: hidden; color: var(--muted); font-size: .63rem; text-overflow: ellipsis; white-space: nowrap; }

.ingredient-shortcut {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 8px 9px;
  border-radius: 9px;
  background: #f5f0e9;
}
.ingredient-shortcut__body { display: grid; min-width: 0; gap: 2px; }
.ingredient-shortcut__body strong { overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-shortcut__body small { color: var(--muted); font-size: .63rem; }
.ingredient-shortcut__add {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #7c3d28;
  background: #fffdf9;
  font: inherit;
  font-size: .65rem;
  font-weight: 800;
  cursor: pointer;
}
.ingredient-shortcut__add:hover,
.ingredient-shortcut__add:focus-visible { border-color: #d9b5a3; background: var(--accent-soft); outline: none; }
.ingredient-shortcut__add:disabled { opacity: .55; cursor: default; }


.optional-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0 7px;
}

.optional-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fffdf9;
  font: inherit;
  font-size: .74rem;
  font-weight: 750;
  cursor: pointer;
}

.optional-button[aria-expanded="true"] { border-color: #d9b5a3; color: #7c3d28; background: var(--accent-soft); }
.quick-add-extra { margin-top: 10px; }
.quick-add-extra[hidden] { display: none; }
.amount-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.text-area { min-height: 80px; resize: vertical; line-height: 1.5; }
.form-status { min-height: 20px; margin: 10px 0 5px; color: var(--muted); font-size: .76rem; }

.save-button {
  width: 100%;
  min-height: 49px;
  border: 0;
  border-radius: 13px;
  color: white;
  background: var(--accent);
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.save-button:disabled { opacity: .42; cursor: default; }

@media (min-width: 760px) {
  .sheet-backdrop { align-items: end; justify-items: end; }
  .quick-add-sheet { margin-right: 12px; }
  .record-detail-sheet { margin-right: 12px; }
}

@media (max-width: 520px) {
  .sheet-backdrop { padding: 0; }
  .quick-add-sheet {
    width: 100%;
    max-height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }
  .record-detail-sheet {
    width: 100%;
    max-height: 88dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 24px 24px 0 0;
  }
  .quick-add-fab {
    left: max(12px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .ingredient-options { grid-template-columns: 1fr; }
}
