.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
}

.recipe-card {
  --pin-fold-size: 1.15rem;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--recipe-bg, #fbf4e8);
  color: var(--recipe-fg, var(--text));
}

.detail-header,
.editor-header,
.scale-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.recipe-card-media {
  display: block;
  background: var(--soft);
}

.recipe-card-media img {
  display: block;
  width: 100%;
  height: auto;
}

.recipe-card-title {
  display: block;
  width: 100%;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid currentColor;
  color: inherit;
  text-decoration: none;
}

.recipe-card h2,
.detail-header h1,
.editor-header h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.recipe-card-summary,
.recipe-summary,
.equipment-section p,
.nutrition-section p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.recipe-hero-image {
  margin: 0;
  padding-bottom: 1rem;
  border-bottom: 1px solid currentColor;
}

.recipe-hero-image img {
  display: block;
  width: 100%;
  height: auto;
}

.recipe-hero-image figcaption {
  margin-top: 0.35rem;
  color: var(--recipe-muted, var(--muted));
  font-size: 0.9rem;
}

.recipe-summary {
  padding-bottom: 1rem;
  border-bottom: 1px solid currentColor;
}

.note-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.note-list div {
  display: grid;
  gap: 0.1rem;
}

.note-list dt {
  font-weight: 700;
  letter-spacing: 0;
}

.note-list dd {
  margin: 0;
  white-space: pre-wrap;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  margin: 0.4rem 0 0;
  color: var(--recipe-muted, var(--muted));
  font-style: italic;
  font-size: 0.9rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  margin: 0.5rem 0 0;
  list-style: none;
}

.tags a {
  font-style: italic;
  text-decoration: none;
}

.tags li:not(:last-child)::after {
  content: ",";
  margin-right: 0.4rem;
}

.ingredient-preview {
  padding-left: 1.2rem;
  margin: 0;
}

.sidebar-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 0.75rem;
}

.recipe-detail,
.editor-shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.recipe-detail {
  --pin-fold-size: 1.15rem;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: var(--page-padding);
  overflow: hidden;
  background: var(--recipe-bg, #fbf4e8);
  color: var(--recipe-fg, var(--text));
}

.recipe-detail .button.emoji-button,
.recipe-detail .button.emoji-button:hover {
  color: var(--recipe-fg, var(--text));
}

.recipe-detail .detail-header > div:first-child {
  min-width: 0;
}

.recipe-detail .detail-header .row-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-self: flex-start;
  white-space: nowrap;
}

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 2rem;
  align-items: start;
}

.recipe-section {
  min-width: 0;
}

.notes-section {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.nutrition-section,
.source-link {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.recipe-section h2,
.recipe-section h3,
.attachment-editor h2,
.step-attachment-editor h2 {
  margin-bottom: 0.6rem;
}

.recipe-section h2 {
  font-size: 1.15rem;
}

.recipe-section h3 {
  font-size: 1rem;
  margin-top: 1rem;
}

.recipe-columns .recipe-section h3 {
  padding-bottom: 0.2rem;
  border-bottom: 1px solid currentColor;
}

.ingredient-list,
.method-list {
  margin-top: 0;
  padding-left: 1.75rem;
}

.ingredient-list li,
.method-list li {
  margin-bottom: 0.45rem;
}

.ingredient-list small {
  display: block;
  color: var(--recipe-muted, var(--muted));
  font-size: 0.82rem;
}

.method-list p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.method-list.is-single-step {
  padding-left: 0;
  list-style: none;
}

.scale-controls {
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.scale-controls label {
  max-width: 11rem;
}

.scale-controls input,
.scale-controls .button {
  background: transparent;
  color: var(--recipe-fg, var(--text));
}

.scale-controls .button:hover {
  background: transparent;
}

.source-link {
  margin: 0;
}

.recipe-media {
  display: grid;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.attachments,
.attachments.detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 1rem;
}

.external-media {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
}

.external-media figure {
  margin: 0;
}

.external-media iframe,
.external-media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
}

.external-media img {
  height: auto;
  object-fit: cover;
}

.attachments img,
.attachments video {
  display: block;
  width: 100%;
  height: auto;
}

.attachments figure {
  margin: 0;
}

.attachments figcaption,
.external-media figcaption,
.attachment-link small {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.recipe-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recipe-form textarea[name="importedText"] {
  display: block;
}

.neutral {
  border-color: var(--line);
  color: var(--text);
}

.attachment-editor,
.step-attachment-editor {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.existing-attachments {
  margin: 0;
  padding-top: 1rem;
}

.editable-attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
}

.editable-attachment strong,
.editable-attachment span {
  display: block;
}

.editable-attachment + .editable-attachment {
  border-top: 1px solid var(--line);
}

.attachment-delete-toggle:has(input:checked) {
  outline: 1px solid var(--danger);
  outline-offset: 0;
}

.step-upload {
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.step-upload p {
  margin-bottom: 0.5rem;
}

.density-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 10rem auto;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.density-table {
  width: 100%;
  border-collapse: collapse;
}

.density-table th,
.density-table td {
  padding: 0.5rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.history-list {
  padding-left: 1.3rem;
}

.history-json {
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .recipe-columns,
  .density-form {
    grid-template-columns: 1fr;
  }

  .detail-header,
  .editor-header {
    flex-direction: column;
  }
}

@media print {
  @page {
    margin: 0;
  }

  html,
  body {
    color: #000000;
    font-size: 9.5pt;
    line-height: 1.22;
  }

  .sidebar,
  .mobile-footer,
  .screen-only,
  .recipe-hero-image,
  .external-media,
  .attachments,
  .nutrition-section,
  .source-link {
    display: none !important;
  }

  .app-shell {
    display: block;
    min-height: 0;
  }

  .page {
    padding: 0;
  }

  .recipe-detail {
    --print-border-width: 0.5px;
    width: 100%;
    gap: 0.7rem;
  }

  .detail-header {
    display: block;
    border-bottom: var(--print-border-width) solid #000000;
    padding-bottom: 0.4rem;
  }

  .detail-header h1 {
    font-size: 16pt;
    line-height: 1.05;
  }

  .recipe-summary {
    font-size: 8.8pt;
  }

  .recipe-summary,
  .recipe-columns .recipe-section h3 {
    border-bottom-width: var(--print-border-width);
  }

  .notes-section {
    border-top: var(--print-border-width) solid #000000;
  }

  .recipe-columns {
    grid-template-columns: 0.9fr 1.1fr;
    gap: 1rem;
  }

  .recipe-section h2 {
    font-size: 11pt;
    margin: 0 0 0.25rem;
  }

  .recipe-section h3 {
    font-size: 9.5pt;
    margin: 0.45rem 0 0.2rem;
  }

  .ingredient-list,
  .method-list {
    margin-bottom: 0;
  }

  .ingredient-list li,
  .method-list li {
    margin-bottom: 0.2rem;
  }
}
