:root {
  color-scheme: light;
  --ink: #26231e;
  --soft-ink: #71695f;
  --paper: #fffaf0;
  --paper-deep: #efe3cf;
  --paper-edge: #d6c6a8;
  --line: #d9cbb1;
  --sage: #7e9077;
  --sage-dark: #364b3a;
  --plum: #65536c;
  --blue: #315a73;
  --brass: #b48644;
  --cover: #263f3b;
  --cover-deep: #182c2a;
  --shadow: 0 30px 80px rgba(36, 26, 15, 0.24);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--sans);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(180, 134, 68, 0.24), transparent 28%),
    linear-gradient(90deg, rgba(38, 63, 59, 0.22) 0 14px, transparent 14px),
    linear-gradient(180deg, var(--cover) 0, var(--cover) 220px, #e9ddc8 220px, #f3eadb 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(38, 35, 30, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38, 35, 30, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
}

.app-shell {
  position: relative;
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 10px 34px;
  color: #fbfaf6;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--plum);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #d7c9a4;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.8rem, 7vw, 6.2rem);
  line-height: 0.88;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

h2 {
  margin-bottom: 8px;
  font-size: 2rem;
  line-height: 1;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: calc(100vh - 180px);
  overflow: hidden;
  border: 1px solid rgba(76, 57, 35, 0.28);
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(24, 44, 42, 0.22), transparent 22px),
    var(--paper);
  box-shadow: var(--shadow);
}

.workspace::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 376px;
  width: 22px;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(45, 28, 14, 0.28), rgba(45, 28, 14, 0.08), transparent),
    repeating-linear-gradient(180deg, rgba(255, 250, 240, 0.35) 0 1px, transparent 1px 16px);
  z-index: 2;
}

.recipe-panel {
  min-width: 0;
  border-right: 1px solid rgba(24, 44, 42, 0.38);
  background:
    linear-gradient(90deg, rgba(255, 250, 240, 0.1), transparent 22px),
    linear-gradient(180deg, #304f49, #223c39);
  color: #fffaf0;
}

.toc-heading {
  padding: 24px 22px 10px;
}

.toc-heading h2 {
  margin-bottom: 0;
  color: #fffaf0;
}

.recipe-panel .eyebrow {
  color: #d9bd82;
}

.search-row {
  padding: 14px 18px 18px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.18);
}

input,
textarea {
  width: 100%;
  border: 1px solid #cbd5d2;
  border-radius: 5px;
  background: rgba(251, 250, 246, 0.96);
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: var(--sage-dark);
  box-shadow: 0 0 0 3px rgba(84, 112, 90, 0.18);
}

.recipe-list {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  padding: 18px;
}

.sidebar-note,
.active-book-mini {
  padding: 14px;
  border: 1px solid rgba(255, 250, 240, 0.18);
  border-radius: 5px;
  background: rgba(255, 250, 240, 0.08);
}

.sidebar-note p:last-child {
  margin-bottom: 0;
  color: rgba(255, 250, 240, 0.78);
  line-height: 1.45;
}

.active-book-mini {
  display: grid;
  gap: 6px;
}

.active-book-mini span {
  color: #fffaf0;
  font-weight: 850;
}

.active-book-mini code,
.access-code {
  color: #dcc596;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
}

.toc-section {
  display: grid;
  gap: 8px;
}

.chapter-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.2);
  color: #f4dfb2;
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 700;
  text-decoration: none;
}

.chapter-link small {
  color: rgba(255, 250, 240, 0.58);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chapter-recipes {
  display: grid;
  gap: 6px;
}

.recipe-card {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 64px;
  padding: 10px 12px;
  border-left: 4px solid rgba(255, 250, 240, 0.16);
  border-radius: 5px;
  background: rgba(255, 250, 240, 0.08);
  text-align: left;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.recipe-card:hover,
.recipe-card.active {
  border-color: var(--brass);
  background: rgba(255, 250, 240, 0.16);
}

.recipe-card:hover {
  transform: translateX(2px);
}

.recipe-title {
  color: #fffaf0;
  font-weight: 800;
}

.recipe-meta,
.status-line,
.empty-state p {
  color: var(--soft-ink);
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
}

.recipe-panel .recipe-meta {
  color: rgba(255, 250, 240, 0.68);
}

.detail-panel {
  min-width: 0;
  padding: 38px;
  background:
    linear-gradient(90deg, rgba(70, 46, 22, 0.08), transparent 28px),
    linear-gradient(180deg, #f8edd9, #fffaf0 160px);
}

.empty-state {
  display: grid;
  place-items: start;
  align-content: center;
  min-height: 58vh;
  max-width: 480px;
  padding: 28px;
  border: 1px solid var(--paper-edge);
  background: rgba(255, 250, 240, 0.88);
  box-shadow: 0 18px 40px rgba(54, 35, 19, 0.12);
}

.home-screen {
  display: grid;
  gap: 30px;
}

.home-intro {
  max-width: 680px;
}

.home-intro h2 {
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 0.92;
}

.home-intro p:last-child {
  color: var(--soft-ink);
  font-size: 1.05rem;
  line-height: 1.55;
}

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

.home-card {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 260px;
  padding: 20px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.95), rgba(248, 237, 217, 0.88));
  box-shadow: 0 14px 28px rgba(54, 35, 19, 0.11);
}

.home-card h3 {
  margin-bottom: 0;
  color: var(--blue);
}

.home-card p {
  color: var(--soft-ink);
  line-height: 1.45;
}

.saved-books {
  display: grid;
  gap: 14px;
  padding-top: 8px;
}

.section-heading h3 {
  margin-bottom: 0;
}

.saved-book-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.saved-book-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.88);
  color: var(--ink);
  text-align: left;
}

.saved-book-card:hover {
  border-color: var(--sage-dark);
}

.saved-book-card span:first-child {
  display: grid;
  gap: 4px;
}

.saved-book-card small {
  color: var(--soft-ink);
}

.recipe-detail {
  position: relative;
  display: grid;
  gap: 28px;
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 56px);
  border: 1px solid var(--paper-edge);
  background:
    linear-gradient(90deg, rgba(180, 134, 68, 0.12) 0 1px, transparent 1px calc(100% - 1px), rgba(180, 134, 68, 0.12) calc(100% - 1px)),
    repeating-linear-gradient(0deg, rgba(214, 198, 168, 0.22) 0 1px, transparent 1px 36px),
    linear-gradient(180deg, #fffdf6, #fff8ea);
  box-shadow:
    0 24px 45px rgba(61, 40, 22, 0.16),
    inset 0 0 0 10px rgba(255, 250, 240, 0.45);
}

.recipe-detail::before {
  content: "JWK Recipes";
  position: absolute;
  top: 18px;
  right: 24px;
  color: rgba(113, 105, 95, 0.35);
  font-family: var(--serif);
  font-size: 0.92rem;
  font-style: italic;
}

.recipe-detail::after {
  content: "";
  position: absolute;
  inset: 16px;
  pointer-events: none;
  border: 1px solid rgba(180, 134, 68, 0.22);
}

.recipe-detail > * {
  position: relative;
  z-index: 1;
}

.detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 12px 0 24px;
  border-bottom: 3px double var(--paper-edge);
}

.book-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  background: rgba(239, 227, 207, 0.65);
  color: var(--soft-ink);
  font-weight: 800;
}

.copy-code-button {
  min-height: 32px;
  border: 1px solid rgba(49, 90, 115, 0.24);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 250, 240, 0.9);
  color: var(--blue);
  font-weight: 850;
}

.copy-status {
  color: var(--sage-dark);
  font-size: 0.9rem;
}

.detail-header h2 {
  max-width: 18ch;
  font-size: clamp(2.8rem, 5.4vw, 5rem);
  line-height: 0.92;
}

.detail-actions,
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(126, 144, 119, 0.38);
  border-radius: 999px;
  background: rgba(247, 242, 230, 0.92);
  color: var(--soft-ink);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.pill strong {
  color: var(--sage-dark);
  font-weight: 850;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  border: 1px solid var(--paper-edge);
  background: rgba(239, 227, 207, 0.5);
}

.page-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-right: 1px solid var(--paper-edge);
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.page-links a:hover {
  background: rgba(180, 134, 68, 0.12);
}

.recipe-image {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 12px 24px rgba(35, 44, 52, 0.13);
}

.recipe-columns {
  display: grid;
  grid-template-columns: minmax(260px, 0.62fr) 1fr;
  gap: 28px;
}

.recipe-section {
  min-width: 0;
  scroll-margin-top: 24px;
  padding: 20px;
  border: 1px solid rgba(214, 198, 168, 0.86);
  background: rgba(255, 250, 240, 0.72);
}

.recipe-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--sage-dark);
}

.recipe-section h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.note-page {
  border: 1px solid rgba(214, 198, 168, 0.9);
  background:
    linear-gradient(90deg, rgba(180, 134, 68, 0.12), transparent 10px),
    rgba(239, 227, 207, 0.56);
}

ol,
ul {
  padding-left: 1.25rem;
}

li {
  margin-bottom: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.recipe-form {
  display: grid;
  gap: 18px;
  max-width: 980px;
}

.form-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
}

.sticky-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0 0;
  border-top: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.82), var(--paper) 45%);
}

.upload-band {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(207, 214, 213, 0.95);
  background: rgba(236, 231, 220, 0.52);
}

.link-import {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px dashed var(--sage-dark);
  border-radius: 5px;
  background: rgba(251, 250, 246, 0.94);
  color: var(--sage-dark);
  font-weight: 800;
}

.upload-box input {
  display: none;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 5px;
  padding: 0 14px;
  font-weight: 850;
  white-space: nowrap;
}

.primary-button {
  background: var(--sage-dark);
  color: #fbfaf6;
}

.secondary-button {
  background: var(--brass);
  color: #241f1b;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fbfaf6;
  color: var(--ink);
}

.light-button {
  border-color: rgba(251, 250, 246, 0.42);
  background: rgba(251, 250, 246, 0.12);
  color: #fbfaf6;
}

.danger-button {
  background: #fbfaf6;
  color: #8f3b48;
  border: 1px solid #d7b7bd;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  body {
    background:
      linear-gradient(180deg, #273b45 0, #273b45 170px, #e7ebe8 170px, #f2efe8 100%);
  }

  .app-shell {
    padding: 14px;
  }

  .topbar,
  .form-header,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace::before {
    display: none;
  }

  .recipe-panel {
    border-right: 0;
    border-bottom: 2px solid #bcc8c4;
  }

  .recipe-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(250px, 84%);
    max-height: none;
    overflow-x: auto;
  }

  .toc-section {
    align-content: start;
  }

  .detail-panel {
    padding: 18px 14px;
    overflow: hidden;
  }

  .recipe-columns,
  .form-grid,
  .link-import,
  .upload-band,
  .home-grid,
  .saved-book-list {
    grid-template-columns: 1fr;
  }

  .recipe-detail {
    max-width: 100%;
    padding: 24px 14px;
    overflow: hidden;
  }

  .recipe-section {
    padding: 18px 14px;
  }

  ol,
  ul {
    padding-left: 1.1rem;
  }

  .recipe-detail::before {
    display: none;
  }

  .detail-header h2 {
    max-width: none;
    font-size: clamp(2.25rem, 11vw, 3.7rem);
  }

  .form-actions,
  .detail-actions,
  .sticky-save-bar {
    flex-wrap: wrap;
  }

  .sticky-save-bar .primary-button,
  .sticky-save-bar .ghost-button {
    flex: 1;
  }
}
