/* Why You: envelope, letter paper, archive. */

.top { flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; background: var(--card); padding: 4px; border-radius: 999px; box-shadow: var(--shadow); }
.tabs a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 999px;
}
.tabs a.active { background: var(--rose); color: white; }

.greeting { font-family: var(--hand); font-size: 30px; margin: 4px 0 14px; color: var(--ink); }

.stage { display: flex; justify-content: center; margin: 10px 0 18px; perspective: 900px; }

/* ---------- Envelope ---------- */

.envelope {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 1.45;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffe3ea, #ffc9d6);
  box-shadow: var(--shadow), inset 0 -40px 60px -40px rgba(201, 58, 98, 0.25);
  padding: 0;
  overflow: hidden;
  animation: wiggle 3.2s ease-in-out infinite;
  display: block;
}
.envelope::before, .envelope::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 60%;
  height: 70%;
  background: linear-gradient(160deg, #ffd3de, #ffb8c9);
}
.envelope::before { left: 0; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.envelope::after { right: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.flap {
  position: absolute;
  inset: 0 0 auto;
  height: 62%;
  background: linear-gradient(180deg, #ffbccd, #ffa8bd);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 0.6s ease;
  z-index: 2;
}
.seal {
  position: absolute;
  left: 50%;
  top: 62%;
  transform: translate(-50%, -50%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0708f, var(--rose-deep));
  color: #ffe3ea;
  font-size: 26px;
  display: grid;
  place-items: center;
  z-index: 3;
  box-shadow: 0 4px 10px rgba(120, 20, 50, 0.35);
}
.envelope-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  text-align: center;
  font-family: var(--hand);
  font-size: 26px;
  color: var(--rose-deep);
  z-index: 3;
}
.envelope.opening { animation: none; }
.envelope.opening .flap { transform: rotateX(180deg); }
.envelope.opening .seal { transition: transform 0.4s, opacity 0.4s; transform: translate(-50%, -50%) scale(1.6); opacity: 0; }

@keyframes wiggle {
  0%, 82%, 100% { transform: rotate(0); }
  86% { transform: rotate(-2.5deg); }
  90% { transform: rotate(2.5deg); }
  94% { transform: rotate(-1.5deg); }
}

/* ---------- Letter ---------- */

.letter {
  width: 100%;
  background:
    repeating-linear-gradient(transparent 0 37px, #f6e1dc 37px 38px),
    var(--card);
  border-radius: 6px 6px 18px 18px;
  padding: 18px 22px 20px;
  box-shadow: var(--shadow);
  transform: rotate(-0.6deg);
  position: relative;
}
.letter::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 90px;
  height: 22px;
  transform: translateX(-50%) rotate(2deg);
  background: rgba(255, 179, 138, 0.55);
  border-radius: 3px;
}
.letter.fresh { animation: unfold 0.7s cubic-bezier(0.2, 0.8, 0.2, 1.1); }
@keyframes unfold { from { transform: translateY(40px) rotateX(50deg) scale(0.9); opacity: 0; } }

.letter-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-soft); font-weight: 800; font-size: 13px; letter-spacing: 0.02em; }
.letter-text {
  font-family: var(--hand);
  font-size: 32px;
  line-height: 38px;
  margin: 12px 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.letter-sign { text-align: right; font-family: var(--hand); font-size: 24px; color: var(--rose-deep); }

.status { text-align: center; color: var(--ink-soft); font-weight: 700; margin: -4px 0 14px; }

.empty { flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 30px 10px; }
.empty p { font-family: var(--hand); font-size: 28px; margin: 0 0 8px; }
.quill { font-size: 48px; animation: beat 2s infinite; }

.more { display: block; text-align: center; font-weight: 800; text-decoration: none; margin: 10px 0; }

.stock {
  display: block;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  margin: 8px auto;
  width: fit-content;
}
.stock.low { color: var(--rose-deep); background: var(--rose-soft); }

/* ---------- Archive and queue ---------- */

.count { text-align: center; font-weight: 700; }
.archive, .queue { display: grid; gap: 12px; }
.mini {
  background: var(--card);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: 0 6px 18px -12px rgba(150, 50, 80, 0.4);
  text-decoration: none;
  color: inherit;
  display: block;
}
.mini p { font-family: var(--hand); font-size: 25px; line-height: 1.15; margin: 6px 0 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mini.sealed { text-align: center; font-weight: 800; color: var(--rose-deep); border: 2px dashed var(--rose-soft); box-shadow: none; }
.mini .actions { display: flex; gap: 4px; }
.mini textarea { margin-top: 8px; }

.desk { background: var(--card); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 8px; }
.desk h2 { margin-bottom: 10px; }
.desk textarea { font-family: var(--hand); font-size: 26px; line-height: 1.2; }
.row { display: flex; justify-content: flex-end; margin-top: 10px; gap: 8px; }
.queue-title { margin: 18px 0 10px; }
