:root {
  color-scheme: light;
  --ink: #24211e;
  --muted: #6f6760;
  --paper: #fffaf4;
  --surface: #ffffff;
  --line: #eaded1;
  --tomato: #e85d3f;
  --tomato-dark: #b83d27;
  --leaf: #24745a;
  --sky: #dff2f6;
  --plum: #58416d;
  --mustard: #efb44a;
  --shadow: 0 20px 50px rgba(43, 31, 21, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(223, 242, 246, 0.72), rgba(255, 250, 244, 0.88) 42%, rgba(255, 235, 219, 0.72)),
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 10px 4px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  background: var(--tomato);
  color: white;
  font-weight: 900;
  font-size: 1.45rem;
  box-shadow: 0 12px 28px rgba(232, 93, 63, 0.28);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
}

.top-actions,
.dialog-actions,
.extract-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button,
.icon-button,
.bookmarklet,
.tag-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.primary-button {
  background: var(--tomato);
  color: white;
  box-shadow: 0 12px 28px rgba(232, 93, 63, 0.22);
}

.ghost-button,
.bookmarklet,
.tag-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  background: var(--ink);
  color: white;
  font-size: 1.35rem;
  line-height: 1;
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover,
.bookmarklet:hover,
.tag-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(43, 31, 21, 0.12);
}

.send-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.send-panel[hidden] {
  display: none;
}

.share-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.library-pane,
.detail-pane {
  min-height: calc(100vh - 112px);
}

.library-pane {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box,
.recipe-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.82rem;
}

.search-box input,
.recipe-dialog input,
.recipe-dialog textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.search-box input:focus,
.recipe-dialog input:focus,
.recipe-dialog textarea:focus {
  border-color: var(--tomato);
  box-shadow: 0 0 0 3px rgba(232, 93, 63, 0.14);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.stat strong,
.stat span {
  display: block;
}

.stat strong {
  font-size: 1.35rem;
}

.stat span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tag-button {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--muted);
}

.tag-button.active {
  color: white;
  background: var(--leaf);
  border-color: var(--leaf);
}

.recipe-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  max-height: calc(100vh - 298px);
  padding-right: 4px;
}

.recipe-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 42px;
  gap: 12px;
  align-items: center;
  min-height: 108px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  text-align: left;
  color: inherit;
}

.recipe-card.active {
  border-color: rgba(232, 93, 63, 0.7);
  box-shadow: 0 12px 30px rgba(232, 93, 63, 0.12);
}

.card-image,
.hero-image {
  background-color: var(--sky);
  background-position: center;
  background-size: cover;
}

.card-image {
  width: 92px;
  height: 86px;
  border-radius: 8px;
}

.card-body {
  min-width: 0;
}

.card-body h3,
.detail-title {
  margin: 0;
  line-height: 1.08;
}

.card-body h3 {
  font-size: 1rem;
}

.card-meta,
.detail-meta,
.chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.card-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.chip-row {
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--sky);
  color: #285862;
  font-size: 0.75rem;
  font-weight: 900;
}

.favorite-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--mustard);
  font-size: 1.2rem;
}

.detail-pane {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 112px);
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.hero-image {
  min-height: 310px;
}

.detail-content {
  display: grid;
  gap: 22px;
  padding: 24px;
}

.detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.detail-title {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  letter-spacing: 0;
}

.detail-description {
  max-width: 72ch;
  color: var(--muted);
  line-height: 1.55;
}

.detail-meta {
  color: var(--muted);
  font-weight: 800;
}

.detail-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(220px, 0.82fr) minmax(280px, 1.18fr);
  gap: 20px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1rem;
}

.checklist,
.steps-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.checklist {
  list-style: none;
}

.checklist label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(234, 222, 209, 0.72);
  line-height: 1.4;
}

.checklist input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
}

.steps-list {
  counter-reset: steps;
  list-style: none;
}

.steps-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 8px;
  background: rgba(223, 242, 246, 0.55);
  line-height: 1.45;
}

.steps-list li::before {
  counter-increment: steps;
  content: counter(steps);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--plum);
  color: white;
  font-size: 0.85rem;
  font-weight: 900;
}

.notes-box {
  border-left: 4px solid var(--mustard);
  padding: 12px 14px;
  background: rgba(239, 180, 74, 0.14);
  border-radius: 0 8px 8px 0;
  color: #5d4510;
}

.recipe-dialog {
  width: min(880px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.recipe-dialog::backdrop {
  background: rgba(36, 33, 30, 0.45);
  backdrop-filter: blur(8px);
}

.dialog-card {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-head p,
.dialog-head h2,
.form-status {
  margin: 0;
}

.dialog-head p {
  color: var(--tomato-dark);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.dialog-head h2 {
  margin-top: 4px;
  font-size: 1.7rem;
}

.extract-row {
  align-items: end;
}

.extract-row label {
  flex: 1;
}

.form-status {
  min-height: 20px;
  color: var(--leaf);
  font-weight: 800;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tall-fields textarea {
  resize: vertical;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  padding-top: 6px;
}

#deleteButton {
  color: #9e2c1f;
}

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

  .library-pane {
    position: static;
    min-height: 0;
  }

  .recipe-list {
    max-height: none;
  }

  .detail-pane {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .send-panel {
    width: 100%;
    flex-wrap: wrap;
  }

  .primary-button,
  .ghost-button {
    flex: 1 1 auto;
  }

  .stats-row,
  .two-cols,
  .detail-head,
  .dialog-actions {
    grid-template-columns: 1fr;
  }

  .recipe-card {
    grid-template-columns: 78px minmax(0, 1fr) 36px;
  }

  .card-image {
    width: 78px;
    height: 76px;
  }

  .hero-image {
    min-height: 220px;
  }

  .detail-content,
  .dialog-card {
    padding: 16px;
  }

  .detail-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .extract-row {
    align-items: stretch;
    flex-direction: column;
  }
}
