* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: #f4efe5;
  color: #2b241d;
  font-family: Georgia, "Times New Roman", serif;
}

header {
  text-align: center;
  padding: 28px 16px 12px;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

header p {
  margin: 8px 0 0;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 16px 22px;
}

.actions a {
  font-family: Arial, sans-serif;
  font-weight: 700;
  text-decoration: none;
  padding: 11px 18px;
  border-radius: 7px;
  background: #f4efe5;
  color: #17365d;
  border: 1px solid #17365d;
}

.actions a.selected {
  background: #17365d;
  color: #fff;
}

main {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto 34px;
  background: transparent;
  border-radius: 14px;
  padding: 0;
  box-shadow: none;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px;
  background: #eee5d8;
  border-radius: 8px 8px 0 0;
  font-family: Arial, sans-serif;
}

.toolbar button {
  padding: 8px 11px;
  border-radius: 6px;
  border: 1px solid #73685c;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}

.toolbar button:disabled {
  opacity: .42;
  cursor: default;
}

.toolbar .back {
  background: #17365d;
  color: #fff;
  border-color: #17365d;
}

.toolbar input {
  width: 66px;
  padding: 7px 5px;
  text-align: center;
}

.toolbar label {
  font-weight: 700;
}

#status {
  display: none;
}

#stage {
  min-height: 72vh;
  max-height: 78vh;
  overflow: auto;
  background: #b7b4ae;
  padding: 20px;
  text-align: center;

  scrollbar-width: none;
  -ms-overflow-style: none;
}

#stage::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

#pageWrap {
  position: relative;
  display: inline-block;
  margin-top: 12px;
  margin-bottom: 32px;
  background: #fff;
  box-shadow: 0 3px 18px rgba(0, 0, 0, .35);
  line-height: 0;
}

#pdfCanvas {
  display: block;
}

#annotationLayer {
  position: absolute;
  inset: 0;
  pointer-events: auto !important;
  z-index: 50 !important;
}

.pdfLink {
  position: absolute;
  display: block;
  pointer-events: auto;
  background: transparent;
}

.pdfLink:hover {
  outline: 2px solid rgba(116, 36, 50, .55);
  background: rgba(116, 36, 50, .08);
}

#errorPanel {
  background: #fff2f2;
  color: #501a1a;
  padding: 18px;
  font-family: Arial, sans-serif;
}

footer {
  text-align: center;
  padding: 0 16px 28px;
  color: #6a5e52;
}


/* =========================================================
   KooKBooK simplified blue theme
   Visual changes only. Layout/behavior preserved.
   ========================================================= */

/* Clean white page instead of tan/cream. */
body {
  background: #ffffff;
  color: #17365d;
}

/* KooKBooK identity. */
h1,
header p {
  color: #17365d;
}

/* Main action buttons: restrained, white, and outlined. */
.actions a,
.actions a:visited {
  background: #ffffff;
  color: #17365d;
  border-color: #17365d;
}

.actions a:hover {
  background: #f3f7fd;
}

.actions a.selected {
  background: #17365d;
  color: #ffffff;
  border-color: #17365d;
}

/* Search controls. */
#recipeSearchInput {
  background: #ffffff !important;
  color: #17365d !important;
  border-color: #17365d !important;
}

#recipePrevBtn,
#recipeNextBtn {
  background: #ffffff !important;
  color: #17365d !important;
  border-color: #17365d !important;
}

#recipePrevBtn:hover:not(:disabled),
#recipeNextBtn:hover:not(:disabled) {
  background: #f3f7fd !important;
}

/* Navigation row: white instead of tan. */
.toolbar {
  background: #ffffff;
  color: #17365d;
  border: 1px solid #17365d;
  border-bottom: 0;
}

.toolbar button {
  background: #ffffff;
  color: #17365d;
  border-color: #17365d;
}

.toolbar button:hover:not(:disabled) {
  background: #f3f7fd;
}

.toolbar .back {
  background: #17365d;
  color: #ffffff;
  border-color: #17365d;
}

.toolbar input {
  background: #ffffff;
  color: #17365d;
  border: 1px solid #17365d;
}

/*
  Scroll boundary.
  This replaces the former greenish-gray stage with white and
  places a restrained light-blue strip immediately below the
  PREVIOUS / PAGE / NEXT navigation row.
*/
#stage {
  background: #ffffff;
  border-top: 12px solid #dbe7f7;
}

/* Preserve the existing page breathing room. */
#pageWrap {
  margin-top: 12px;
  margin-bottom: 32px;
}

/* Footer stays quiet and coordinated. */
footer {
  color: #17365d;
}

/* =========================================================
   KooKBooK simplified blue theme - refinement 2
   Remove toolbar container treatment and make the scroll
   boundary match the PDF page width.
   ========================================================= */

/* Remove the beige/boxed area surrounding BACK / PREVIOUS / PAGE / NEXT.
   !important is required because index.html currently contains an
   internal .toolbar background rule after the external stylesheet. */
.toolbar {
  background: #ffffff !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* The stage itself is plain white.  No full-width colored band. */
#stage {
  background: #ffffff;
  border-top: 0 !important;
}

/* Give the page enough room for a narrow boundary line above it. */
#pageWrap {
  margin-top: 22px;
  margin-bottom: 32px;
}

/* Centered scroll-boundary line.
   Because it belongs to #pageWrap, it automatically has exactly
   the same width as the displayed KooKBooK page. */
#pageWrap::before {
  content: "";
  display: block;
  position: sticky;
  top: 0;
  width: 100%;
  height: 12px;
  margin-top: -22px;
  margin-bottom: 10px;
  background: #ffffff;
  border-bottom: 4px solid #dbe7f7;
  pointer-events: none;
  z-index: 200;
}

/* =========================================================
   KooKBooK scroll-boundary correction - v5
   The boundary is now at the actual top of the scroll viewport.
   ========================================================= */

/* Remove the top padding that allowed the PDF to scroll above the line. */
#stage {
  position: relative;
  padding-top: 0 !important;
  background: #ffffff !important;
  border-top: 0 !important;
}

/* Restore ordinary page spacing below the fixed boundary. */
#pageWrap {
  margin-top: 20px !important;
  margin-bottom: 32px !important;
}

/* Disable the earlier page-attached boundary experiments. */
#pageWrap::before {
  content: none !important;
}

/* Fixed visual boundary at the top of the scrolling viewport.
   Width follows the visible KooKBooK page area rather than spanning
   the whole browser window. */
#stage::before {
  content: "";
  display: block;
  position: sticky;
  top: 0;
  width: min(
    calc(var(--book-width, 800px) + 24px),
    calc(100% - 8px)
  );
  height: 8px;
  margin: 0 auto;
  background: #ffffff;
  border-bottom: 4px solid #dbe7f7;
  pointer-events: none;
  z-index: 500;
}

/* =========================================================
   KooKBooK title typography test
   Title-only change.
   ========================================================= */

h1 {
  color: #17365d;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.015em;
  font-size: clamp(2.2rem, 4.4vw, 3.7rem);
}
