:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7f3ec;
  color: #22252a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.import-panel {
  display: grid;
  gap: 28px;
}

.app-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-button {
  min-height: 40px;
  border: 1px solid #b9b1a4;
  background: #fffdfa;
  color: #2f3737;
}

.nav-button.is-active {
  border-color: #2f6f6d;
  background: #2f6f6d;
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: #6a665f;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5rem);
}

h2 {
  font-size: 1.1rem;
}

h3 {
  margin: 0;
  font-size: 1.7rem;
}

h4 {
  margin: 0 0 10px;
  font-size: 1rem;
}

h5 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
}

.import-form {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

input,
button,
textarea {
  min-height: 48px;
  border-radius: 8px;
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid #b9b1a4;
  padding: 0 14px;
  background: #fffdfa;
  color: #22252a;
}

textarea {
  min-height: 90px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: #2f6f6d;
  outline: 3px solid rgba(47, 111, 109, 0.2);
  outline-offset: 2px;
}

button {
  border: 0;
  padding: 0 18px;
  background: #2f6f6d;
  color: white;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.error-area {
  min-height: 24px;
  color: #9b1c31;
  font-weight: 700;
}

.status-area {
  min-height: 24px;
  color: #2f6f6d;
  font-weight: 800;
}

.results {
  display: grid;
  gap: 12px;
}

.results-area {
  min-height: 180px;
  overflow-x: hidden;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 22px;
  background: #fffdfa;
  color: #3c3d40;
}

.result-grid {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.result-grid div {
  display: grid;
  gap: 2px;
}

.result-grid dt {
  color: #68635d;
  font-size: 0.84rem;
  font-weight: 800;
}

.result-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  padding: 14px;
  background: #20242a;
  color: #f5f1e9;
  font-size: 0.88rem;
}

.recipe-preview {
  display: grid;
  gap: 24px;
  max-width: 1040px;
  margin: 0 auto;
}

.recipe-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  gap: 24px;
  align-items: start;
}

.recipe-header img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
  background: #ece3d7;
}

.recipe-image {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1;
  justify-self: end;
}

.recipe-image.is-editable {
  cursor: pointer;
  outline-offset: 4px;
}

.recipe-image.is-editable:focus-visible {
  outline: 3px solid rgba(47, 111, 109, 0.32);
}

.recipe-image img,
.image-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 8px;
}

.image-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed #b9b1a4;
  background: #f4ede3;
  color: #68635d;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.image-editor {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.image-upload-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.image-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.image-remove-button {
  color: #8a2434;
}

.image-paste-button {
  color: #2f6f6d;
}

.image-paste-hint {
  flex-basis: 100%;
  margin: 0;
  color: #68635d;
  font-size: 0.78rem;
  line-height: 1.35;
}

.media-gallery {
  margin: 0;
}

.media-gallery:empty {
  display: none;
}

.media-gallery h4,
.image-text-panel h4 {
  margin: 0 0 10px;
  color: #403b36;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.media-carousel {
  display: grid;
  gap: 10px;
}

.media-carousel-viewport {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: center;
}

.media-carousel-frame {
  min-width: 0;
}

.media-carousel-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
}

.media-item {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 8px;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  background: #fffaf4;
}

.media-item.is-cover {
  border-color: #2f6f6d;
  box-shadow: 0 0 0 2px rgba(47, 111, 109, 0.14);
}

.media-item img,
.media-item-placeholder {
  width: 100%;
  max-height: 520px;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  object-fit: contain;
  background: #f4ede3;
}

.media-item-placeholder {
  display: grid;
  place-items: center;
  color: #68635d;
  font-size: 0.78rem;
  font-weight: 800;
}

.media-item figcaption {
  color: #68635d;
  font-size: 0.78rem;
  font-weight: 800;
}

.media-cover-button {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 0.78rem;
}

.media-carousel-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.media-dot {
  min-width: 30px;
  min-height: 30px;
  border: 1px solid #c7bdae;
  border-radius: 999px;
  background: #fffaf4;
  color: #403b36;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.media-dot.is-active {
  border-color: #2f6f6d;
  background: #2f6f6d;
  color: #fff;
}

.image-text-panel {
  display: grid;
  gap: 8px;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 14px;
  background: #fffaf4;
}

.image-text-panel:empty {
  display: none;
}

.image-text-content {
  max-height: 260px;
  border: 1px solid #e1d7ca;
  background: #fffdfa;
  color: #3c3d40;
  white-space: pre-wrap;
}

.recipe-source {
  margin: 8px 0 0;
  color: #68635d;
  overflow-wrap: anywhere;
}

.recipe-source a {
  color: #2f6f6d;
  font-weight: 800;
}

.recipe-title-block {
  min-width: 0;
}

.recipe-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 14px;
  align-items: start;
  position: relative;
}

.recipe-title {
  overflow-wrap: anywhere;
}

.mode-button {
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.done-button {
  background: #3d5958;
}

.save-button {
  background: #6b5b2e;
}

.share-menu {
  position: absolute;
  z-index: 10;
  top: 46px;
  right: 0;
  display: grid;
  min-width: 190px;
  gap: 4px;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 8px;
  background: #fffdfa;
  box-shadow: 0 12px 28px rgba(34, 37, 42, 0.14);
}

.share-menu button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: #22252a;
  text-align: left;
}

.library-area {
  display: grid;
  gap: 18px;
}

.library-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, auto) auto auto auto;
  gap: 10px;
  align-items: center;
}

.library-controls select {
  min-height: 48px;
  border: 1px solid #b9b1a4;
  border-radius: 8px;
  padding: 0 12px;
  background: #fffdfa;
  font: inherit;
}

.favourite-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #3c3d40;
  white-space: nowrap;
}

.favourite-filter input {
  width: auto;
  min-height: auto;
}

.import-json-label {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.import-json-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.recipe-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.saved-recipe-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.saved-recipe-thumb {
  display: grid;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f4ede3;
  color: #68635d;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.saved-recipe-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-recipe-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.saved-recipe-card p {
  margin: 0 0 8px;
  color: #68635d;
  font-size: 0.88rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  border: 1px solid #d4cabe;
  border-radius: 999px;
  padding: 4px 9px;
  background: #fbf5ee;
  color: #3c3d40;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-list .empty-note {
  border: 0;
  padding: 0;
  background: transparent;
  color: #68635d;
  font-weight: 600;
}

.card-tag-list {
  margin-bottom: 10px;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.library-action-button {
  min-height: 38px;
}

.favourite-button {
  width: fit-content;
}

.library-empty {
  margin: 0;
  border: 1px dashed #d4cabe;
  border-radius: 8px;
  padding: 18px;
  color: #68635d;
}

.recipe-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.recipe-meta div,
.recipe-meta label {
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 10px;
  background: #fbf5ee;
}

.recipe-meta dt,
.recipe-meta label span {
  display: block;
  color: #68635d;
  font-size: 0.82rem;
  font-weight: 800;
}

.recipe-meta dd,
.recipe-meta input {
  margin: 4px 0 0;
}

.recipe-tags {
  display: grid;
  gap: 8px;
  border: 1px solid #d4cabe;
  border-radius: 8px;
  padding: 12px;
  background: #fbf5ee;
}

.recipe-tags h4 {
  margin-bottom: 0;
}

.tag-readonly-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tag-field {
  display: grid;
  gap: 6px;
}

.tag-field span {
  color: #68635d;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-field small {
  color: #68635d;
  font-size: 0.84rem;
  font-weight: 600;
}

.tag-edit-button {
  min-height: 36px;
  white-space: nowrap;
}

.editable-label {
  display: block;
  margin: 0 0 6px;
  color: #68635d;
  font-size: 0.82rem;
  font-weight: 800;
}

.title-input {
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid #d4cabe;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-size: 1.7rem;
  font-weight: 800;
}

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(240px, 35%) minmax(0, 65%);
  gap: 32px;
  align-items: start;
}

.ingredients-list,
.steps-list,
.recipe-warnings ul {
  margin: 0;
  padding-left: 1.25rem;
}

.ingredients-list li,
.steps-list li,
.recipe-warnings li {
  margin: 0 0 10px;
  line-height: 1.5;
}

.ingredients-list li::marker,
.steps-list li::marker {
  color: #2f6f6d;
  font-weight: 800;
}

.recipe-warnings {
  border-top: 1px solid #d4cabe;
  padding-top: 16px;
  color: #6b4e00;
}

.editable-list {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.ingredient-row,
.step-row {
  display: grid;
  gap: 8px;
  align-items: start;
}

.ingredient-row {
  grid-template-columns: minmax(104px, 124px) minmax(180px, 1fr) repeat(3, 38px);
}

.step-row {
  grid-template-columns: 36px minmax(0, 1fr) repeat(3, 38px);
}

.step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-top: 9px;
  border-radius: 999px;
  background: #2f6f6d;
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
}

.direction-section {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}

.direction-section h5 {
  margin: 0;
  color: #2f3737;
  font-size: 1rem;
}

.section-title-field {
  display: grid;
  gap: 6px;
}

.section-title-field span {
  color: #68635d;
  font-size: 0.82rem;
  font-weight: 800;
}

.row-controls {
  display: contents;
}

.secondary-button {
  min-width: 38px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid #b9b1a4;
  background: #fffdfa;
  color: #2f3737;
  font-size: 0.84rem;
  font-weight: 800;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.delete-button {
  color: #8a2434;
}

.add-button,
.add-section-button {
  width: fit-content;
  min-height: 40px;
}

.add-section-button {
  border-color: #2f6f6d;
  color: #2f6f6d;
}

.empty-note {
  margin: 0;
  color: #68635d;
}

.ingredients-panel,
.directions-panel {
  min-width: 0;
}

.diagnostics {
  border-top: 1px solid #d4cabe;
  margin-top: 22px;
  padding-top: 16px;
}

.diagnostics summary {
  cursor: pointer;
  font-weight: 800;
}

.diagnostics .result-grid {
  margin-top: 16px;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 1120px);
    padding: 32px 0;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .recipe-header,
  .recipe-columns,
  .recipe-meta {
    grid-template-columns: 1fr;
  }

  .recipe-title-row {
    grid-template-columns: 1fr;
  }

  .mode-button {
    width: fit-content;
  }

  .recipe-image,
  .recipe-header img {
    width: 100%;
    max-width: none;
    max-height: 260px;
  }

  .ingredient-row,
  .step-row {
    grid-template-columns: 1fr;
  }

  .ingredient-row .row-controls,
  .step-row .row-controls {
    display: flex;
    gap: 8px;
  }

  .ingredient-row .secondary-button,
  .step-row .secondary-button {
    flex: 0 0 auto;
  }

  .step-number {
    margin-top: 0;
  }

  .row-controls {
    flex-wrap: wrap;
  }

  .add-button,
  .add-section-button {
    width: 100%;
  }

  .library-controls {
    grid-template-columns: 1fr;
  }

  .saved-recipe-card {
    grid-template-columns: 1fr;
  }

  .saved-recipe-thumb {
    width: 100%;
    max-height: 220px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .eyebrow,
  h1,
  .app-nav,
  #import-view,
  #library-view,
  #status-area,
  #error-area,
  #results-title,
  .mode-button,
  .share-menu,
  .recipe-warnings,
  .diagnostics {
    display: none !important;
  }

  .shell,
  .results-area {
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    padding: 0;
    background: #fff;
  }

  .recipe-preview {
    color: #111;
  }
}
