.page {
  max-width: 1024px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 16px;
  border: 2px solid var(--theme, #ff474c);
}

.toc a {
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  margin: 0 6px;
}

main h2 {
  background: var(--theme, #ff474c);
  color: #fff;
  padding: 18px 20px;
  font-weight: bold;
  font-size: 1.8rem;
  letter-spacing: .5px;
  margin: 32px 0 16px 0;
  border-radius: 12px;
}

main h2:first-child {
  margin-top: 0;
}


main p, main li {
  line-height: 1.6;
}

main p {
  margin: 0 0 12px 0;
  position: relative;
  padding-right: 40px;
}

main ul, main ol {
  margin: 0 0 12px 1.25em;
}

.double-rule {
  margin: 16px 0 6px 0;
}

.double-rule .rule {
  height: 1px;
  background: #000;
}

.double-rule .rule + .rule {
  margin-top: 4px;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .92rem;
  color: #444;
  padding: 4px 0;
}

/* Mobile + small-screen polish (non-image) */
html {
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
}

main {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 12px;
    border-radius: 12px;
  }

  nav[aria-label="Table of Contents"] {
    padding: 12px 14px;
  }

  .toc {
    font-size: .9rem;
    line-height: 1.6;
  }

  main h2 {
    font-size: 1.4rem;
    padding: 14px 16px;
  }
}

@media (min-width: 481px) and (max-width: 640px) {
  .page {
    padding: 14px;
  }

  main h2 {
    font-size: 1.55rem;
    padding: 16px 18px;
  }
}

body {
  color: rgb(32, 33, 34);
  font-family: 'Lato', sans-serif;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.chapter-banner {
  border-radius: 14px;
  overflow: hidden;
  margin: 0 0 24px 0;
}

.chapter-banner img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  outline: 0;
}

nav[aria-label="Table of Contents"] {
  background: var(--toc-bg, #ffe5e6);
  border-radius: 14px;
  padding: 16px 20px;
  margin: 0 0 32px 0;
}

#podlove-player {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#podlove-player * {
  margin-bottom: 0 !important;
}

#podlove-player iframe {
  display: block;
  margin: 0;
  padding: 0;
  vertical-align: bottom;
  border: 0;
}

#podlove-player.loaded {
  opacity: 1;
}

.toc-heading {
  margin: 0 0 8px 0;
  font-weight: bold;
  font-size: 1.05rem;
}

.toc {
  font-size: .92rem;
  line-height: 1.8;
  margin: 0;
}


/* Paragraph numbering */
.para-number {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: #999;
  font-weight: 600;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: none;
}

/* Modal trigger */
.modal-trigger {
  color: var(--theme, #ff474c);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-trigger:hover {
  text-decoration-style: solid;
  opacity: 0.8;
}

.modal-trigger:focus {
  outline: 2px solid var(--theme, #ff474c);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Dialog/Modal */
dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 90vw;
  width: 600px;
  max-height: 80vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  background: white;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.2);
}

dialog[open] {
  animation: modal-fade-in 0.2s ease;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e5e5;
  background: var(--theme, #ff474c);
  color: white;
}

.modal-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-close:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

.modal-body p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  dialog {
    width: calc(100vw - 32px);
    max-height: 90vh;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  .modal-body {
    padding: 20px;
    max-height: calc(90vh - 70px);
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog[open] {
    animation: none;
  }
}
