:root {
  --page-background: #eeeeee;
  --paper: #ffffff;
  --ink: #000000;
  --ink-soft: #222222;
  --rule: #e6e6e6;
  --muted: #5b5b5b;
  --menu: #000000;
  --accent: #fab526;
  --accent-hover: #e09e12;
  --link-hover: #8c6100;
  --shell-width: 1180px;
  --content-pad: 25px;
  --focus-ring: 0 0 0 3px rgba(250, 181, 38, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-background);
  color: var(--ink);
  font-family: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page-background);
}

a {
  color: #111111;
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

.skip-link,
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  width: auto;
  height: auto;
  padding: 0.6rem 0.9rem;
  margin: 0;
  clip: auto;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--focus-ring);
}

.site-shell {
  width: min(90%, var(--shell-width));
  margin: 30px auto 50px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.masthead {
  padding: 35px 30px 40px;
  text-align: center;
}

.custom-logo-link {
  display: inline-block;
  margin-bottom: 2px;
}

.custom-logo-link:focus-visible {
  box-shadow: var(--focus-ring);
}

.custom-logo {
  width: 55px;
  height: 48px;
  margin-inline: auto;
}

.site-title {
  margin: 0;
  font-family: Merriweather, Georgia, serif;
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 400;
  line-height: 1.5;
}

.site-title a {
  color: var(--ink);
}

.site-title a:hover,
.site-title a:focus-visible {
  color: var(--ink);
}

.site-description {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.site-nav {
  min-height: 52px;
  background: var(--menu);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  min-height: 52px;
  margin: 0;
  padding: 0 1rem;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 1.5rem;
  list-style: none;
}

.site-nav a {
  display: inline-block;
  padding: 0.9rem 0.35rem;
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--accent);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 700;
}

.header-image {
  line-height: 0;
}

.header-image img {
  width: 100%;
  height: auto;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(260px, 3fr);
  gap: 0;
  align-items: start;
  padding-top: 20px;
}

.site-main {
  min-width: 0;
}

.post-entry {
  margin: 0 0 30px;
  padding: 25px var(--content-pad) 30px;
}

.entry-header h1 {
  margin: 0 0 18px;
  font-family: Merriweather, Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  font-weight: 400;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
}

.entry-figure,
.entry-content figure {
  margin: 0 0 1.5rem;
}

.entry-figure img,
.entry-content figure img {
  width: 100%;
}

.entry-figure a {
  display: block;
}

.entry-figure a:focus-visible {
  box-shadow: var(--focus-ring);
}

.entry-content p,
.post-entry > p,
.contents-intro {
  margin: 0 0 1.5rem;
  line-height: 1.625;
}

.entry-content a,
.post-entry > p a,
.contents-list a,
.sidebar-widget a {
  text-decoration: underline;
  text-decoration-color: #bcbcbc;
  text-underline-offset: 0.14em;
}

.entry-content a:hover,
.post-entry > p a:hover,
.contents-list a:hover,
.sidebar-widget a:hover {
  text-decoration-color: currentColor;
}

.entry-content hr {
  margin: 2rem 0 1.5rem;
  border: 0;
  border-top: 1px solid var(--rule);
}

/* Source pages keep handwritten next links; generated nav stays accurate. */
.entry-content .next-story {
  display: none;
}

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule);
}

.chapter-nav a {
  font-family: Merriweather, Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.chapter-nav a span {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-family: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-nav__next {
  text-align: right;
}

.site-sidebar {
  padding: 25px 20px 30px;
}

.chapter-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 2.75rem;
}

.chapter-search input {
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #dddddd;
  border-right: 0;
  border-radius: 0;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.chapter-search input::placeholder {
  color: #888888;
}

.chapter-search button {
  height: 46px;
  padding: 0 22px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background 0.2s ease;
}

.chapter-search button:hover,
.chapter-search button:focus-visible {
  background: var(--accent-hover);
  color: #ffffff;
}

.sidebar-widget {
  margin-bottom: 2.75rem;
}

.sidebar-widget:last-child {
  margin-bottom: 1rem;
}

.sidebar-widget h2 {
  margin: 0 0 1rem;
  padding: 0 0 0.5rem;
  border-bottom: 3px double var(--ink-soft);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.sidebar-widget p {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.sidebar-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--rule);
}

.sidebar-list a {
  text-decoration: none;
}

.sidebar-list a:hover,
.sidebar-list a:focus-visible {
  text-decoration: underline;
  text-decoration-color: currentColor;
}

.sidebar-list li.is-current a {
  font-weight: 700;
}

.search-empty {
  color: var(--muted);
  font-style: italic;
}

.contents-intro {
  text-align: center;
  color: var(--muted);
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.contents-list {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: chapter;
}

.contents-list li {
  counter-increment: chapter;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 0.35rem 0.85rem;
  margin: 0;
  padding: 1.15rem 0;
  border-top: 1px solid var(--rule);
}

.contents-list li:last-child {
  border-bottom: 1px solid var(--rule);
}

.contents-list li::before {
  content: counter(chapter, decimal-leading-zero);
  font-family: Merriweather, Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--muted);
}

.contents-list li > a {
  font-family: Merriweather, Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.4;
  text-decoration-thickness: 1px;
}

.contents-list p {
  grid-column: 2;
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.site-footer {
  min-height: 58px;
  padding: 18px 25px;
  background: var(--menu);
  color: #ffffff;
  text-align: center;
}

.site-footer p {
  margin: 0;
  font-size: 0.875rem;
  opacity: 0.9;
}

.site-footer a {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--accent);
}

@media (max-width: 1023px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .site-sidebar {
    padding-top: 0;
    border-top: 1px solid var(--rule);
  }

  .chapter-search,
  .sidebar-widget {
    margin-bottom: 2rem;
  }
}

@media (max-width: 767px) {
  .site-shell {
    width: min(calc(100% - 24px), var(--shell-width));
    margin: 12px auto 24px;
  }

  .masthead {
    padding: 28px 20px 30px;
  }

  .site-nav ul {
    gap: 0.15rem 1rem;
    padding: 0 0.75rem;
  }

  .site-nav a {
    font-size: 0.8rem;
    padding: 0.85rem 0.2rem;
  }

  .post-entry,
  .site-sidebar {
    padding-right: 18px;
    padding-left: 18px;
  }

  .chapter-nav {
    grid-template-columns: 1fr;
  }

  .chapter-nav__next {
    text-align: left;
  }

  .chapter-search button {
    padding: 0 16px;
  }

  .contents-list li {
    grid-template-columns: 2rem 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
