.message-board-tab {
  right: 22px;
  top: 38%;
  bottom: auto;
  width: auto;
  min-width: 108px;
  padding: 13px 17px;
  border: 1px solid #607356;
  border-radius: 999px;
  background: #f8f5e9;
  color: #40523d;
  font: 600 15px "KaiTi", "STKaiti", serif;
  letter-spacing: .08em;
  writing-mode: horizontal-tb;
  box-shadow: 0 10px 30px #4151393d;
  transition: transform .25s, background .25s, color .25s, box-shadow .25s;
}

.message-board-tab::before {
  content: "✎";
  display: inline-block;
  margin-right: 8px;
  font: 500 18px Georgia, serif;
  transform: rotate(-8deg);
}

.message-board-tab:hover {
  width: auto;
  transform: translateY(-2px);
  background: #6f8663;
  color: #fff;
  box-shadow: 0 13px 34px #41513952;
}

@media (max-width: 600px) {
  .message-board-tab {
    right: 14px;
    top: auto;
    bottom: 82px;
    min-width: 102px;
    padding: 12px 15px;
  }
}

.notebook {
  perspective: 1000px;
}

.message-page {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100% - 345px);
  min-height: 150px;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}

.message-page .message-list {
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 18px 8px 8px;
  overflow-y: auto;
}

.message-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 43px;
  padding: 6px 8px 2px;
  border-top: 1px solid #6f6b62;
  color: #292823;
}

.message-pagination button {
  width: max-content;
  border: 0;
  background: transparent;
  color: #292823;
  padding: 7px 0;
  font: 600 13px "KaiTi", "STKaiti", cursive;
  cursor: pointer;
}

.message-pagination button:last-child {
  justify-self: end;
}

.message-pagination button:not(:disabled):hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.message-pagination button:disabled {
  color: #9a9589;
  cursor: default;
}

.message-pagination span {
  font: 500 11px "KaiTi", "STKaiti", cursive;
  letter-spacing: .08em;
  white-space: nowrap;
}

.message-page.turn-out-next {
  transform-origin: left center;
  animation: page-out-next .18s ease-in forwards;
}

.message-page.turn-in-next {
  transform-origin: right center;
  animation: page-in-next .24s ease-out;
}

.message-page.turn-out-prev {
  transform-origin: right center;
  animation: page-out-prev .18s ease-in forwards;
}

.message-page.turn-in-prev {
  transform-origin: left center;
  animation: page-in-prev .24s ease-out;
}

.message-page.new-note {
  animation: pencil-page .42s ease;
}

@keyframes page-out-next {
  to { opacity: .08; transform: rotateY(-22deg) translateX(-24px); }
}

@keyframes page-in-next {
  from { opacity: .08; transform: rotateY(22deg) translateX(24px); }
  to { opacity: 1; transform: none; }
}

@keyframes page-out-prev {
  to { opacity: .08; transform: rotateY(22deg) translateX(24px); }
}

@keyframes page-in-prev {
  from { opacity: .08; transform: rotateY(-22deg) translateX(-24px); }
  to { opacity: 1; transform: none; }
}

@keyframes pencil-page {
  50% { filter: brightness(.97); transform: translateY(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .message-page.turn-out-next,
  .message-page.turn-in-next,
  .message-page.turn-out-prev,
  .message-page.turn-in-prev,
  .message-page.new-note {
    animation-duration: .01ms;
  }
}

@media (max-width: 600px) {
  .message-page {
    height: calc(100% - 335px);
  }

  .message-pagination button {
    font-size: 12px;
  }
}

.notebook {
  display: flex;
  flex-direction: column;
}

.notebook > header,
.notebook > form {
  flex: 0 0 auto;
}

.notebook textarea {
  height: clamp(170px, 23vh, 220px);
  min-height: 170px;
  transition: height .28s ease;
}

.notebook textarea:focus {
  height: clamp(210px, 30vh, 285px);
}

.message-page {
  flex: 1 1 auto;
  height: auto;
  min-height: 125px;
}

.notebook > header {
  order: 0;
}

.notebook > #message-form {
  order: 1;
  display: none;
}

.notebook > .message-page {
  order: 1;
}

.notebook > .compose-launcher {
  order: 2;
}

.message-page .message-list {
  padding: 24px 8px 10px;
}

.message-list .featured-message {
  min-height: 120px;
  margin: 0;
  padding: 8px 9px 18px;
}

.message-list .featured-message p {
  font-size: 20px;
  line-height: 2;
}

.message-list .featured-message footer {
  margin-top: 18px;
}

.message-empty b {
  font-weight: 500;
  font-size: 18px;
}

.compose-launcher {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 9px 8px 3px;
  border-top: 1px dashed #77736b;
  color: #555149;
  transform-style: preserve-3d;
}

.compose-launcher span {
  font: 600 8px "Cormorant Garamond", serif;
  letter-spacing: .2em;
}

.compose-launcher button {
  border: 0;
  background: transparent;
  color: #25241f;
  padding: 8px 0;
  font: 600 14px "KaiTi", "STKaiti", cursive;
  cursor: pointer;
}

.compose-launcher button:hover {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.notebook.composing > .message-page,
.notebook.composing > .compose-launcher {
  display: none;
}

.notebook.composing > #message-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 20px 8px 8px;
  border-bottom: 0;
  transform-style: preserve-3d;
}

.compose-heading {
  display: flex !important;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 20px !important;
  padding-bottom: 11px;
  border-bottom: 1px solid #2e2d28;
}

.compose-heading button {
  border: 0;
  background: transparent;
  color: #292823;
  padding: 5px 0;
  font: 600 13px "KaiTi", "STKaiti", cursive;
  cursor: pointer;
}

.compose-heading span {
  font: 600 8px "Cormorant Garamond", serif;
  letter-spacing: .18em;
  color: #5d5b53;
}

.notebook.composing #message-form > label {
  flex: 0 0 auto;
  margin-bottom: 9px;
}

.notebook.composing textarea,
.notebook.composing textarea:focus {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 240px;
  max-height: none;
  padding: 10px 5px;
  overflow-y: auto;
  transition: none;
}

.notebook.composing #message-form > div:not(.compose-heading) {
  flex: 0 0 auto;
  margin-top: 10px;
}

.notebook.composing #message-status {
  flex: 0 0 auto;
}

.compose-launcher.turn-out-next {
  transform-origin: left center;
  animation: page-out-next .18s ease-in forwards;
}

.compose-launcher.turn-in-next {
  transform-origin: right center;
  animation: page-in-next .24s ease-out;
}

.compose-launcher.turn-in-prev {
  transform-origin: left center;
  animation: page-in-prev .24s ease-out;
}

#message-form.compose-in {
  transform-origin: right center;
  animation: page-in-next .24s ease-out;
}

#message-form.compose-out {
  transform-origin: right center;
  animation: page-out-prev .18s ease-in forwards;
}

@media (max-width: 600px) {
  .message-list .featured-message p {
    font-size: 18px;
  }

  .notebook.composing textarea,
  .notebook.composing textarea:focus {
    min-height: 200px;
  }

  .compose-launcher {
    min-height: 54px;
  }
}

.message-page .message-list {
  overflow: hidden;
  scrollbar-width: none;
}

.message-page .message-list::-webkit-scrollbar,
.compose-text-page::-webkit-scrollbar {
  display: none;
}

.reading-page-measure {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: -1;
  visibility: hidden;
  margin: 0;
  padding: 0 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 500 20px/2 "KaiTi", "STKaiti", "Segoe Print", cursive;
  text-shadow: .3px .3px #5d5b55;
}

.compose-pages {
  position: relative;
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 210px;
  margin: 0 !important;
  overflow: hidden;
}

.notebook.composing .compose-text-page,
.notebook.composing .compose-text-page:focus {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 10px 5px;
  overflow: hidden;
  resize: none;
  scrollbar-width: none;
}

.notebook.composing .compose-text-page.active {
  display: block;
}

.notebook.composing .compose-text-page.compose-page-flip {
  transform-origin: right center;
  animation: page-in-next .24s ease-out;
}

.notebook.composing .compose-text-page.compose-measure {
  display: block;
  visibility: hidden;
  pointer-events: none;
}

.compose-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 40px;
  margin-top: 5px;
  border-top: 1px solid #6f6b62;
}

.compose-pagination button {
  width: max-content;
  border: 0;
  background: transparent;
  color: #292823;
  padding: 7px 0;
  font: 600 12px "KaiTi", "STKaiti", cursive;
  cursor: pointer;
}

.compose-pagination button:last-child {
  justify-self: end;
}

.compose-pagination button:disabled {
  color: #9a9589;
  cursor: default;
}

.compose-pagination span {
  font: 500 11px "KaiTi", "STKaiti", cursive;
  letter-spacing: .08em;
  white-space: nowrap;
}

.featured-message p {
  max-height: none;
  overflow: visible;
}

@media (max-width: 600px) {
  .reading-page-measure {
    font-size: 18px;
  }

  .compose-pages {
    min-height: 175px;
  }
}
