/* ============================================================
   The Nine — in-browser fillable edition
   ============================================================ */

.reader-page { background: var(--porcelain-deep); }

.reader-bar {
  position: sticky;
  top: 74px;
  z-index: 50;
  background: color-mix(in srgb, var(--porcelain) 94%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.reader-bar .wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 62px;
  padding-block: 8px;
}
.reader-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.reader-title b {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-title span {
  font-size: 1.125rem;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-progress {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: transparent;
}
.reader-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brass);
  transition: width 0.4s var(--ease);
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.icon-btn:hover { background: var(--sand-soft); border-color: var(--brass-light); }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }
.icon-btn svg { width: 14px; height: 14px; }

.reader-select {
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  padding: 0 30px 0 14px;
  max-width: 260px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4.5 6 8.5l4-4' fill='none' stroke='%231b2140' stroke-width='1.3'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.reader-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 760px);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  padding: clamp(28px, 4vw, 52px) 0 96px;
  justify-content: center;
}

/* contents rail */
.toc {
  position: sticky;
  top: 156px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 8px;
  scrollbar-width: thin;
}
.toc h2 {
  font-size: 1.125rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 14px;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: 2px; }
.toc button {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 7px 9px;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.35;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.toc button:hover { background: rgba(255, 253, 249, 0.8); color: var(--ink); }
.toc button[aria-current="true"] { background: var(--paper); color: var(--ink); box-shadow: inset 2px 0 0 var(--brass); }
.toc button i {
  font-style: normal;
  font-size: 1.125rem;
  color: var(--brass);
  padding-top: 3px;
  min-width: 20px;
}

/* paper */
.paper {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(27, 33, 64, 0.04), 0 30px 60px -40px rgba(27, 33, 64, 0.4);
  padding: clamp(32px, 5vw, 76px) clamp(24px, 5vw, 78px) clamp(28px, 4vw, 56px);
  min-height: 62vh;
  display: flex;
  flex-direction: column;
}

.page-kicker {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 26px;
}

.page-title {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 3.4vw, 2.55rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 26px;
  color: var(--ink);
}

.page-sub {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
  margin: -16px 0 28px;
}

.prose p {
  font-size: 1.125rem;
  line-height: 1.72;
  color: #2c3252;
  margin: 0 0 1.15em;
  text-wrap: pretty;
}
.prose p:last-child { margin-bottom: 0; }

.prose .note {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 2px solid var(--sand);
  padding-left: 18px;
  margin: 1.6em 0;
}

.signature {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--ink);
  margin: 1.4em 0 0;
}

.keywords {
  margin-top: 2em;
  padding-top: 1.4em;
  border-top: 1px solid var(--line-soft);
}
.keywords b {
  display: block;
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 8px;
}
.keywords span {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-style: italic;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* prompt pages */
.prompt-q {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 2.6vw, 1.95rem);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin: 0 0 8px;
  max-width: 30ch;
}
.prompt-hint {
  font-size: 1.125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 26px;
}

.answer-wrap { position: relative; flex: 1; display: flex; }
.answer {
  width: 100%;
  min-height: 340px;
  flex: 1;
  resize: vertical;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(2.05rem - 1px),
    rgba(27, 33, 64, 0.13) calc(2.05rem - 1px),
    rgba(27, 33, 64, 0.13) 2.05rem
  );
  background-position: 0 0.35rem;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 2.05rem;
  color: var(--ink);
  padding: 0.35rem 0 0;
  outline: none;
}
.answer:focus { background-color: rgba(234, 223, 203, 0.22); }
.answer::placeholder { color: rgba(107, 112, 137, 0.6); }

.answer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

/* special layouts */
.cover-page {
  justify-content: center;
  text-align: center;
  min-height: 62vh;
}
.cover-page .cover-eyebrow {
  font-size: 1.125rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 22px;
}
.cover-page h1 {
  font-family: var(--serif);
  font-size: clamp(3rem, 9vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  font-weight: 600;
  margin: 0 0 14px;
}
.cover-page .cover-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.15rem, 2.6vw, 1.7rem);
  color: var(--ink-soft);
  margin: 0 0 40px;
}
.cover-page .cover-by {
  font-size: 1.125rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.divider-page {
  justify-content: center;
  text-align: center;
  min-height: 52vh;
}
.divider-page .part {
  font-size: 1.125rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 18px;
}
.divider-page h2 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.03em;
}

.steps-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.steps-list li {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--sand-soft);
  padding: 18px 22px;
  border-radius: 2px;
}
.steps-list li:nth-child(even) { flex-direction: row-reverse; text-align: right; }
.steps-list b {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--brass-light);
  color: #fffdf7;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.steps-list span { font-size: 1.125rem; color: var(--ink); line-height: 1.4; }

.layout-frame {
  border: 1px solid var(--line);
  border-radius: 6px;
  aspect-ratio: 2 / 3;
  width: min(200px, 46%);
  background:
    linear-gradient(135deg, rgba(234, 223, 203, 0.55), rgba(255, 253, 249, 0.9)),
    var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  font-size: 1.125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  box-shadow: 0 18px 30px -24px rgba(27, 33, 64, 0.6);
}
.layout-row { display: flex; gap: 20px; justify-content: center; margin: 28px 0 6px; flex-wrap: wrap; }
.layout-cap { font-size: 1.125rem; color: var(--ink-soft); text-align: center; max-width: 30ch; }

.cols-4 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px 32px;
  margin-top: 8px;
}
.cols-4 h4 {
  font-family: var(--sans);
  font-size: 1.125rem;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 8px;
}
.cols-4 p { font-size: 1.125rem; line-height: 1.6; color: var(--ink-soft); margin: 0; }

.end-page { justify-content: center; align-items: center; text-align: center; min-height: 50vh; }
.end-page .mark { width: 54px; height: 54px; margin-bottom: 22px; }
.end-page p { color: var(--ink-soft); max-width: 40ch; margin: 0 auto; }

/* pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
}
.pager .count {
  font-size: 1.125rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.pager-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: var(--sans);
  font-size: 1.125rem;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.pager-btn:hover { background: #fff; border-color: var(--brass-light); }
.pager-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.reader-foot {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 0 40px;
  font-size: 1.125rem;
  color: var(--ink-mute);
  text-align: center;
}

.saved-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.saved-note.show { opacity: 1; }
.saved-note::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--brass);
}

/* print */
.print-root { display: none; }
body.preview-print .print-root { display: block; }
body.preview-print .print-page { background:#fff; padding: 24px 32px; border-bottom: 1px dashed #c9c0ae; font-family: var(--sans); }
body.preview-print .print-page h2 { font-family: var(--serif); }
body.preview-print .print-page .pq { font-family: var(--serif); font-size: 1.4rem; }
body.preview-print .print-page .pans, body.preview-print .print-page .blank-line { border-bottom: 1px solid #ddd; min-height: 22pt; }

@media print {
  @page { size: letter; margin: 16mm 18mm; }
  html, body { background: #fff !important; font-size: 11pt; }
  body.preview-print .print-page { padding: 0 !important; border: 0 !important; }
  .site-header, .reader-bar, .toc, .pager, .reader-foot, .print-hide, .skip-link { display: none !important; }
  .reader-shell { display: block; padding: 0; }
  .paper { box-shadow: none; border: 0; padding: 0; min-height: 0; }
  .reader-page { background: #fff; }
  .print-root { display: block !important; }
  .print-page { page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; }
  .print-page h2 { font-family: var(--serif); font-size: 17pt; margin: 0 0 10pt; }
  .print-page .pq { font-family: var(--serif); font-size: 13pt; line-height: 1.35; margin: 0 0 10pt; }
  .print-page p { font-size: 10.5pt; line-height: 1.5; margin: 0 0 7pt; color: #222; }
  .print-page .pk { font-size: 7.5pt; letter-spacing: 0.18em; text-transform: uppercase; color: #8a6b32; margin: 0 0 8pt; }
  .print-page .pans { font-size: 10.5pt; line-height: 2; border-bottom: 1px solid #ddd; padding-bottom: 4pt; white-space: pre-wrap; }
  .print-page .blank-line { border-bottom: 1px solid #ddd; height: 22pt; }
  .print-page .pfoot { font-size: 7.5pt; color: #999; margin-top: 14pt; }
}

@media (max-width: 900px) {
  .reader-shell { grid-template-columns: 1fr; }
  .toc { display: none; }
  .reader-bar { top: 74px; }
  .reader-controls .label { display: none; }
  .reader-select { max-width: 150px; }
}

@media (max-width: 560px) {
  .reader-bar .wrap { gap: 8px; }
  .reader-title { display: none; }
  .reader-title span { display: none; }
  .reader-select { max-width: 118px; font-size: 1.125rem; }
  .icon-btn { padding: 0 10px; }
}

/* ---------- notes: a plain lined page ---------- */

.notes-block {
  margin-top: 2.2rem;
  flex: 1 1 auto;
  display: flex;
}
.notes-field {
  flex: 1 1 auto;
  width: 100%;
  min-height: 260px;
  border: 0;
  border-radius: 0;
  resize: none;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(2rem - 1px),
    rgba(27, 33, 64, 0.14) calc(2rem - 1px),
    rgba(27, 33, 64, 0.14) 2rem
  );
  background-position: 0 0.3rem;
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 2rem;
  color: var(--ink);
  padding: 0.3rem 0 0;
  outline: none;
}
.notes-field::placeholder {
  color: rgba(107, 112, 137, 0.42);
  font-style: italic;
}
.notes-field:focus { background-color: rgba(234, 223, 203, 0.16); }

@media print {
  .notes-block { display: none !important; }
  .pn-head {
    font-size: 7pt;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #8a8fa3;
    margin: 16pt 0 6pt;
  }
}
