/* ===== tokens =====
   bg-deep   #1B1E2B  night desk
   bg-vig    #10121C  vignette edge
   paper     #E2D6B8  kraft note
   paper-2   #EFE4C6  lit paper (reframe layer)
   ink       #3A3222  warm dark ink
   ink-soft  #6B6148  secondary ink
   amber     #DDA45E  lamp accent
   mist      #A7AFC9  cool text on dark
   mist-dim  #6E7690  dim cool text
*/

html, body {
  background: #10121C;
}

body {
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.scene {
  min-height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: calc(44px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) 20px
           calc(40px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(ellipse 120% 70% at 50% -10%, #262B3E 0%, #1B1E2B 46%, #10121C 100%);
}

.lamp-glow {
  position: absolute;
  top: 210px;
  left: 50%;
  width: min(520px, 130vw);
  height: min(520px, 130vw);
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(221,164,94,0.16) 0%, rgba(221,164,94,0.05) 40%, rgba(221,164,94,0) 70%);
  pointer-events: none;
  transition: opacity 0.9s ease, transform 1.2s ease;
  opacity: 0.55;
}
.lamp-glow.lit {
  opacity: 1;
  transform: translateX(-50%) scale(1.08);
}

.hero {
  position: relative;
  text-align: center;
  max-width: 360px;
  margin-bottom: 34px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: #6E7690;
  margin-bottom: 14px;
}

.title {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #E7E4D8;
  margin-bottom: 14px;
}

.slogan {
  font-size: 13.5px;
  line-height: 1.9;
  color: #9AA3BE;
  letter-spacing: 0.02em;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.note-wrap {
  position: relative;
  width: 100%;
  min-height: 380px;
  height: min(62vh, 520px);
  min-height: 380px;
}

.note {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  padding: 30px 26px 26px;
    /* 关键：便签内部允许滚动 */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* 增加 */
  background-color: #E2D6B8;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    linear-gradient(155deg, #EAE0C4 0%, #DCCEA9 55%, #D2C299 100%);
  box-shadow:
    0 18px 40px rgba(0,0,0,0.38),
    0 2px 0 rgba(255,255,255,0.25) inset;
  display: flex;
  flex-direction: column;
  /* 隐藏滚动条 */
  scrollbar-width: none; 
  }
  .note::-webkit-scrollbar { display: none; }

/* back layer: the reframed note, lives underneath */
.note--back {
  background-color: #EFE4C6;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.045 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    linear-gradient(160deg, #F6EFD6 0%, #EBE0BE 60%, #E2D5AC 100%);
  z-index: 1;
  padding-top: 34px;
  overflow: hidden;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.note--back::-webkit-scrollbar { display: none; }
.tag {
  align-self: flex-start;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: #8A7C55;
  border: 1px solid rgba(138,124,85,0.45);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 18px;
  min-height: 20px;
}

.pattern-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: #8A7C55;
  margin-bottom: 8px;
  opacity: 0;
  transition: opacity 0.5s ease 0.3s;
}
.note--back.revealed .pattern-label { opacity: 1; }

.pattern-text {
  font-size: 13.5px;
  line-height: 1.7;
  color: #6B6148;
  font-style: italic;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px dashed rgba(138,124,85,0.35);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.6s ease 0.3s, transform 0.6s ease 0.3s;
}
.note--back.revealed .pattern-text {
  opacity: 1;
  transform: translateY(0);
}

.back-label {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: #B98A3E;
  margin-bottom: 12px;
  opacity: 0;
  transition: opacity 0.5s ease 0.75s;
}
.note--back.revealed .back-label { opacity: 1; }

.back-text {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 19px;
  line-height: 1.75;
  color: #3A3222;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.7s ease 0.85s, transform 0.7s ease 0.85s;
}
.note--back.revealed .back-text {
  opacity: 1;
  transform: translateY(0);
}

/* front flap: original quote, sits above, gets torn away */
.note--flap {
  z-index: 3;
  justify-content: space-between;
  cursor: pointer;
  transform-origin: 18% 100%;
  transition: transform 0.85s cubic-bezier(.5,-0.2,.4,1.15), opacity 0.7s ease 0.15s;
  clip-path: polygon(
    0% 0%, 100% 0%, 100% 100%,
    93% 93%, 86% 99%, 79% 91%, 72% 97%,
    65% 90%, 58% 96%, 51% 89%, 44% 97%,
    37% 90%, 30% 98%, 23% 91%, 16% 97%,
    9% 90%, 2% 96%, 0% 89%
  );
}

.note--flap.torn {
  transform: translate(14px, -128%) rotate(-13deg);
  opacity: 0;
  pointer-events: none;
}

.front-text {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 19px;
  line-height: 1.75;
  color: #3A3222;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.hint {
  align-self: center;
  font-size: 11.5px;
  color: #8A7C55;
  letter-spacing: 0.08em;
  margin-top: 18px;
}

/* "留给自己" sub-note */
.forself {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed rgba(138,124,85,0.4);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.6s ease, opacity 0.5s ease;
}
.forself.open {
  max-height: 220px;
  opacity: 1;
}

.forself-label {
  font-size: 11px;
  letter-spacing: 0.24em;
  color: #B98A3E;
  margin-bottom: 10px;
}

.forself-text {
  font-size: 15px;
  line-height: 1.8;
  color: #4A4230;
  margin-bottom: 10px;
  min-height: 27px;
}

.link-btn {
  background: none;
  border: none;
  font-size: 12px;
  color: #A9863F;
  letter-spacing: 0.06em;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:active { opacity: 0.6; }

.reveal-btn {
  margin-top: auto;
  align-self: flex-start;
  background: none;
  border: none;
  font-size: 12.5px;
  color: #8A7C55;
  letter-spacing: 0.1em;
  padding: 10px 0 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.5s ease 1.15s;
}
.note--back.revealed .reveal-btn {
  opacity: 1;
}
.reveal-btn.hidden { display: none; }

.actions {
  display: flex;
  gap: 14px;
  margin-top: 26px;
  width: 100%;
  justify-content: center;
}

.primary-btn {
  background: linear-gradient(160deg, #E3B06E, #C98A3E);
  color: #221A0C;
  border: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  padding: 13px 30px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(201,138,62,0.28);
  transition: transform 0.25s ease, opacity 0.4s ease;
}
.primary-btn:active { transform: scale(0.96); }
.primary-btn.hidden { display: none; }

.secondary-btn {
  background: rgba(255,255,255,0.06);
  color: #B9C0D6;
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 13px;
  letter-spacing: 0.1em;
  padding: 12px 24px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.3s ease, opacity 0.4s ease;
}
.secondary-btn:active { transform: scale(0.96); }
.secondary-btn.hidden { display: none; }

.counter {
  margin-top: 20px;
  font-size: 11px;
  color: #4C5270;
  letter-spacing: 0.1em;
}

:focus-visible {
  outline: 2px solid #DDA45E;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .note--flap, .lamp-glow, .back-text, .back-label,
  .pattern-text, .pattern-label, .forself, .reveal-btn { transition: none !important; }
}

@media (max-width: 360px) {
  .title { font-size: 26px; }
  .note { padding: 24px 20px 22px; }
  .front-text, .back-text { font-size: 17px; }
}
