/* Wrapper acts as the isolated environment */
  .tm-letter-wrapper {
    /* Dimensions for the area the letter sits in */
    width: 100%;
    min-height: 600px; /* Adjust based on how much space you want to reserve */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent; /* Or match your page bg */
    font-family: "Special Elite", cursive !important;
    perspective: 1800px; /* Crucial for 3D effect */
    overflow: visible;
  }

  /* --- Checkbox Logic (Scoped) --- */
  #tm-task-toggle {
    display: none;
  }

  /* --- The Letter Container --- */
  .tm-letter-container {
    width: 90%;
    max-width: 500px;
    height: 600px; /* Full open height */
    position: relative;
    display: flex;
    flex-direction: column;
    transition: transform 0.8s ease-in-out;
    cursor: pointer;
    transform-style: preserve-3d;
    text-align: center;
  }

  /* --- Sections --- */
  .tm-paper-part {
    width: 100%;
    position: relative;
    background-color: #f4f1ea;
    transform-style: preserve-3d;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    -webkit-font-smoothing: antialiased;
  }

  /* Top Flap */
  .tm-paper-top {
    height: 25%;
    z-index: 10;
    transform-origin: bottom center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotateX(-180deg);
    border-bottom: 1px dashed #dcdcdc;
  }

  /* Middle Body */
  .tm-paper-middle {
    height: 50%;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 40px;
    box-sizing: border-box;
  }

  /* Bottom Flap */
  .tm-paper-bottom {
    height: 25%;
    z-index: 5;
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform: rotateX(180deg);
    border-top: 1px dashed #dcdcdc;
  }

  /* --- Faces --- */
  .tm-face-front {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    backface-visibility: hidden;
    padding: 20px 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .tm-paper-top .tm-face-front { justify-content: flex-end; padding-bottom: 5px; }
  .tm-paper-bottom .tm-face-front { justify-content: flex-start; padding-top: 5px; }

  .tm-face-back {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    backface-visibility: hidden;
    background-color: #fbf9f5;
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    background-image: linear-gradient(135deg, transparent 0%, rgba(0,0,0,0.02) 100%);
  }

  .tm-paper-top .tm-face-back {
    transform: rotateY(180deg) rotateZ(180deg);
  }

  /* --- Seal --- */
  .tm-seal-anchor {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    z-index: 100;
  }

  .tm-wax-seal {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #d93838, #8b0000);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid #a31818;
    color: #720e0e;
    font-weight: bold;
    font-size: 28px;
  }

  .tm-wax-seal span {
    letter-spacing: -2px;
    transform: translateY(1px);
  }

  /* --- Typography (Scoped) --- */
  .tm-letter-wrapper p {
    margin: 0;
    line-height: 1.5;
    font-size: 15px;
    color: #222;
    margin-bottom: 1em;
  }

  .tm-letter-footer {
    margin-top: auto;
    font-weight: 800;
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #000;
    border-top: 2px solid #000;
    padding-top: 15px;
  }

  .tm-letter-header {
    opacity: 0.6;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #000;
  }

  /* --- Animation Triggers --- */
  #tm-task-toggle:checked + .tm-letter-container .tm-paper-top {
    transform: rotateX(0deg);
  }

  #tm-task-toggle:checked + .tm-letter-container .tm-paper-bottom {
    transform: rotateX(0deg);
  }

  /* Mobile */
  @media (max-width: 600px) {
    .tm-letter-container { height: 500px; }
    .tm-letter-wrapper p { font-size: 13px; }
    .tm-face-front, .tm-paper-middle { padding: 10px 20px; }
  }
