@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/montserrat-400.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600;
  src: url("fonts/montserrat-600.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 700;
  src: url("fonts/montserrat-700.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: italic;
  font-weight: 400;
  src: url("fonts/montserrat-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Montserrat";
  font-style: italic;
  font-weight: 600;
  src: url("fonts/montserrat-600-italic.woff2") format("woff2");
}

:root {
  --ink: #1a1a1a;
  --paper: #fffdf6;
  --accent: #8b2500;
  --rule: #000;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #efe9dc;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
}

.site-title {
  color: #fff;
  text-decoration: none;
  font-size: 1.4rem;
  font-weight: bold;
}

.search-form { display: flex; gap: 0.4rem; }

.search-form input {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 4px;
  width: 16rem;
  max-width: 60vw;
}

.search-form button {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
}

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  padding: 0.5rem 1.25rem;
  background: #f7f1e3;
  border-bottom: 2px solid var(--rule);
}

.category-nav a {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}

.category-nav a:hover { text-decoration: underline; }

.page {
  max-width: 700px;
  margin: 1.5rem auto 3rem;
  background: var(--paper);
  border: 1px solid #d8d0bd;
  box-shadow: 2px 3px 8px rgba(0, 0, 0, 0.15);
  padding: 2rem 2.5rem 2.5rem;
  min-height: 60vh;
}

/* Title page + TOC */
.title-page { text-align: center; margin-bottom: 2rem; }
.title-page h1 { font-size: 2.2rem; margin: 0 0 0.25rem; }
.title-page .subtitle { font-style: italic; margin: 0; }

.book-download { text-align: center; }

.footer-link { color: #777; }
.footer-link:hover { color: var(--accent); }

.print-list { list-style: none; padding: 0; }
.print-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.4rem 0;
}

/* Prominent in-page search box */
.page-search {
  display: flex;
  gap: 0.5rem;
  margin: 1.25rem 0;
}
.page-search input[type="search"] {
  font-family: inherit;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
  background: #fff;
}
.page-search input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139, 37, 0, 0.15);
}
.page-search button { white-space: nowrap; }

.toc-heading {
  font-size: 1.4rem;
  border-bottom: 4px solid var(--rule);
  padding-bottom: 0.25rem;
}

.toc-section h3 { margin: 1.1rem 0 0.3rem; }
.toc-section h3 a { color: var(--accent); text-decoration: none; }
.toc-section h3 a:hover { text-decoration: underline; }
.toc-section ul { margin: 0; padding-left: 1.5rem; }
.toc-section li { margin: 0.15rem 0; }
.toc-section a { color: var(--ink); text-decoration: none; }
.toc-section li a:hover { text-decoration: underline; }

.empty-note { font-style: italic; color: #777; }

/* Category page */
.category-divider { text-align: center; margin-bottom: 1.5rem; }
.category-divider img {
  max-width: 100%;
  width: 340px;
  border: 1px solid #d8d0bd;
  border-radius: 6px;
}
.category-divider h1 { margin: 0.5rem 0 0; }

.recipe-list { list-style: none; padding: 0; }
.recipe-list li { margin: 0.4rem 0; }
.recipe-list a {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
}
.recipe-list a:hover { text-decoration: underline; color: var(--accent); }
.result-category { color: #777; font-size: 0.9rem; }
.result-where { color: #999; font-size: 0.82rem; font-style: italic; }
.search-summary { font-style: italic; }

/* Recipe page — echoes the original book layout */
.breadcrumb { font-size: 0.85rem; margin-top: 0; }
.breadcrumb a { color: var(--accent); }

.recipe-title {
  text-align: center;
  font-size: 1.8rem;
  margin: 0.5rem 0 0.2rem;
}

.description {
  font-style: italic;
  text-align: center;
  margin: 0.25rem 0 0.75rem;
  color: #444;
}

.serving-size {
  text-align: right;
  font-style: italic;
  font-weight: bold;
  margin: 0 0 1rem;
}

.recipe-photo {
  display: block;
  margin: 1.5rem auto 0.5rem;
  max-width: 300px;
  border: 1px solid #d8d0bd;
  border-radius: 4px;
}

.section-label {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.4rem;
  border-bottom: 4px solid var(--rule);
  display: inline-block;
  padding-bottom: 0.1rem;
}

table.ingredients {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.25rem;
}

table.ingredients th {
  text-align: left;
  font-style: italic;
  border-bottom: 4px solid var(--rule);
  padding: 0.25rem 0.5rem;
}

table.ingredients td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid #e0d8c4;
}

table.ingredients th:nth-child(1), table.ingredients td:nth-child(1) { width: 15%; }
table.ingredients th:nth-child(2), table.ingredients td:nth-child(2) { width: 22%; }

.equipment {
  margin: 0.9rem 0 0;
  padding: 0.5rem 0.7rem;
  border-left: 3px solid var(--accent);
  background: #f7f1e3;
}

/* A row that is only a label, e.g. "Frosting:" — runs the full width
   instead of sitting indented under the Ingredient column. */
table.ingredients tr.ing-label td {
  font-weight: 600;
  padding-top: 0.7rem;
  border-bottom: none;
}

.directions {
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
}

.directions li { margin: 0.45rem 0; }

/* A direction that introduces what follows, e.g. "Assemble in layers:" —
   no bullet, flush with the section heading. */
.directions li.step-label {
  list-style: none;
  margin-left: -1.4rem;
  font-weight: 600;
  margin-top: 0.9rem;
}

.hint { margin-top: 1.5rem; }

.attribution {
  text-align: right;
  font-size: 0.85rem;
  font-weight: bold;
  font-style: italic;
  margin-top: 1.5rem;
}

/* Header tools + flashes */
.header-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.hdr-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
}
.hdr-link:hover { background: rgba(255, 255, 255, 0.15); }
.hdr-signout { border-color: rgba(255, 255, 255, 0.35); }

.flash {
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  margin: 0 0 1rem;
}
.flash-ok { background: #e7f3e7; border: 1px solid #9c9; }
.flash-error { background: #fbeaea; border: 1px solid #d99; }

/* Cookbook switcher bar */
.book-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 1.25rem;
  background: #efe6d2;
  border-bottom: 1px solid #d8d0bd;
  font-size: 0.9rem;
}
.book-switch-label { color: #777; font-style: italic; }
.book-switch a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.2rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
}
.book-switch a:hover { border-color: var(--accent); color: var(--accent); }
.book-switch a.current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* All-recipes view */
.letter-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  border-bottom: 1px solid #e0d8c4;
  padding-bottom: 0.5rem;
}
.letter-jump a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
}
.letter-jump a:hover { text-decoration: underline; }
.all-list { list-style: none; padding-left: 0; }
.all-list li {
  margin: 0.3rem 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.all-list > li > a { color: var(--ink); text-decoration: none; }
.all-list > li > a:hover { text-decoration: underline; color: var(--accent); }
.book-tag { color: var(--accent); text-decoration: none; }
.result-category a { color: inherit; text-decoration: none; }
.result-category a:hover { text-decoration: underline; }

/* Cookbook picker */
.cookbook-list { list-style: none; padding: 0; }
.cookbook-list li { margin: 0.6rem 0; }
.cookbook-card {
  display: block;
  padding: 0.9rem 1.1rem;
  border: 1px solid #d8d0bd;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
}
.cookbook-card:hover { border-color: var(--accent); background: #fdf8ec; }
.cookbook-card-all { background: #f7f1e3; border-style: dashed; }
.cookbook-name { display: block; font-size: 1.2rem; font-weight: 600; color: var(--accent); }
.cookbook-sub { display: block; font-style: italic; color: #666; font-size: 0.9rem; }
.cookbook-count { display: block; font-size: 0.85rem; color: #888; margin-top: 0.25rem; }

/* Settings */
.settings-table { width: 100%; border-collapse: collapse; }
.settings-table td {
  border-bottom: 1px solid #e0d8c4;
  padding: 0.6rem 0.4rem;
  vertical-align: top;
}
.order-cell { width: 2.2rem; white-space: nowrap; }
.order-cell form { display: block; margin: 0; }
.row-move {
  border: 1px solid #c9c0aa;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  width: 1.6rem;
  margin-bottom: 2px;
}
.row-move:disabled { opacity: 0.3; cursor: default; }
.art-cell { width: 4.5rem; }
.section-thumb { max-width: 4rem; max-height: 3rem; border: 1px solid #d8d0bd; border-radius: 3px; }
.no-art { font-size: 0.75rem; color: #aaa; font-style: italic; }
.inline-form { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin: 0; }
.inline-form input[type="text"] {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
  flex: 1 1 9rem;
}
.file-input { font-size: 0.8rem; flex: 1 1 12rem; }
.danger-cell { width: 6rem; }
.danger-summary { cursor: pointer; color: #a33; font-size: 0.85rem; }
.danger-cell input[type="text"] {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
  width: 100%;
  margin-bottom: 0.3rem;
}
.danger-cell select, .danger-cell button { font-family: inherit; font-size: 0.85rem; }
.checkbox-label { font-weight: normal !important; font-size: 0.9rem; }
.checkbox-label input { width: auto !important; margin-right: 0.4rem; }
.settings-table code { font-size: 0.8rem; color: #777; }

.login-form {
  max-width: 22rem;
  margin: 2rem auto;
  text-align: center;
}
.login-form label { display: block; font-weight: 600; margin-bottom: 1rem; }
.login-form input {
  font-family: inherit;
  font-size: 1.05rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
  margin-top: 0.4rem;
  text-align: center;
}
.login-error { color: #a33; font-style: italic; }

.site-footer {
  text-align: center;
  font-size: 0.85rem;
  color: #777;
  padding-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .page { padding: 1.25rem 1rem 2rem; margin: 0.75rem; }
}

/* Buttons and recipe actions */
.print-btn, .btn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.print-btn:hover, .btn:hover { background: var(--accent); color: #fff; }
.btn-small { font-size: 0.85rem; padding: 0.25rem 0.7rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6d1d00; }
.btn-danger { border-color: #a33; color: #a33; }
.btn-danger:hover { background: #a33; color: #fff; }

.recipe-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.recipe-topbar .breadcrumb { margin: 0; }

.recipe-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.recipe-actions form { margin: 0; }

.recipe-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e0d8c4;
  font-size: 0.95rem;
}
.recipe-nav a { color: var(--accent); text-decoration: none; }
.recipe-nav a:hover { text-decoration: underline; }
.recipe-nav .nav-next { text-align: right; margin-left: auto; }

/* Swipe navigation (touch screens only) */
.recipe-page { touch-action: pan-y; }

.swipe-hint { display: none; }

@media (max-width: 768px) and (pointer: coarse) {
  .page { overflow-x: hidden; }
  .swipe-hint {
    display: block;
    text-align: center;
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
    margin: 1.5rem 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .recipe-page { transition: none !important; }
}

.add-link {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
}
.add-link:hover { background: rgba(255, 255, 255, 0.15); }

/* Recipe form */
.recipe-form label { display: block; margin: 0.75rem 0; font-weight: 600; }
.recipe-form input[type="text"], .recipe-form select, .recipe-form textarea {
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
  background: #fff;
  margin-top: 0.2rem;
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row label { flex: 1 1 10rem; }
.help-text { font-weight: normal; font-style: italic; color: #777; font-size: 0.85rem; }

table.ing-edit { width: 100%; border-collapse: collapse; }
table.ing-edit th { text-align: left; font-style: italic; padding: 0.2rem 0.3rem; }
table.ing-edit td { padding: 0.15rem 0.3rem; }
table.ing-edit input {
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
}
table.ing-edit td:nth-child(1) { width: 15%; }
table.ing-edit td:nth-child(2) { width: 20%; }
table.ing-edit td:nth-child(4) { width: 2rem; }
.row-del {
  border: none;
  background: none;
  color: #a33;
  font-size: 1.1rem;
  cursor: pointer;
}

.row-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

/* Section-label rows in the editor read as headings, not ingredients */
table.ing-edit tr.is-label input[name="ing_name"] {
  font-weight: 600;
  background: #f7f1e3;
}

.paste-box {
  border: 1px dashed var(--accent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  background: #fdf8ec;
}
.paste-box summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.paste-box textarea {
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  margin: 0.5rem 0;
  padding: 0.5rem;
  border: 1px solid #c9c0aa;
  border-radius: 4px;
}

.image-area {
  border: 2px dashed #c9c0aa;
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  margin: 0.5rem 0;
}
.image-area:focus { outline: 2px solid var(--accent); }
.image-area img { max-width: 250px; max-height: 250px; display: block; margin: 0 auto 0.5rem; }

.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }

/* Print layout: just the recipe, clean on white */
@media print {
  .site-header, .category-nav, .site-footer, .recipe-topbar, .recipe-nav,
  .swipe-hint {
    display: none !important;
  }
  body { background: #fff; }
  .page {
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: #fff;
    min-height: 0;
  }
  .recipe-page { page-break-inside: avoid; }
  a { color: var(--ink); text-decoration: none; }
}
