/* ==========================================================================
   信封 · 样式
   纸张、火漆、邮戳、拆信动画。全部用 CSS 画，没有一张图片。
   ========================================================================== */

/* ------------------------------------------------------------ 1. 基础 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 必须放在所有布局规则之前：本文件里很多组件把 display 设成了 flex/grid，
   会盖掉浏览器给 [hidden] 的默认 display:none。 */
[hidden] {
  display: none !important;
}

:root {
  --paper: #fffdf7;
  --paper-2: #f9f2e4;
  --paper-3: #f2e8d6;
  --ink: #35312b;
  --ink-soft: #6d6255;
  --ink-faint: #a2957f;
  --line: #e3d7c2;
  --desk: #e9dfcd;
  --desk-2: #dccfb6;
  --seal: #b3382f;
  --seal-dark: #8c2620;
  --gold: #c19a3d;
  --kraft: #d9c3a2;

  --shadow-sm: 0 1px 2px rgba(80, 62, 40, 0.1), 0 4px 14px rgba(80, 62, 40, 0.06);
  --shadow-md: 0 2px 6px rgba(80, 62, 40, 0.1), 0 14px 34px rgba(80, 62, 40, 0.12);
  --shadow-lg: 0 10px 30px rgba(60, 45, 28, 0.18), 0 30px 70px rgba(60, 45, 28, 0.18);

  --radius: 10px;
  --radius-lg: 16px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia,
    "Times New Roman", serif;
  --font-hand: "Kaiti SC", "KaiTi", "STKaiti", "楷体", "Xingkai SC", "LiSu", cursive;

  --safe: 22px;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--desk);
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 253, 246, 0.85), transparent 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(150, 121, 80, 0.22), transparent 65%),
    linear-gradient(175deg, #efe6d5 0%, #e6dbc6 45%, #ddd0b7 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 纸张颗粒感 */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 96, 62, 0.035) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120, 96, 62, 0.028) 0 1px, transparent 1px 4px);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(179, 56, 47, 0.18);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------- 2. 顶栏 */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(250, 245, 234, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(140, 116, 80, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 21px;
  letter-spacing: 0.16em;
  color: var(--ink);
  flex: none;
}

.brand-mark {
  width: 30px;
  height: 23px;
  fill: none;
  stroke: var(--seal);
  stroke-width: 1.7;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}

.nav a:hover {
  background: rgba(160, 133, 92, 0.14);
  color: var(--ink);
}

.nav a.active {
  background: var(--ink);
  color: #fdf9f0;
}

.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--seal);
  color: #fff;
  font-size: 11.5px;
  line-height: 18px;
  text-align: center;
  font-weight: 600;
}

.nav a.active .badge {
  background: #fdf9f0;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.whoami {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.18s, border-color 0.18s;
}

.whoami:hover,
.whoami:focus-visible {
  background: rgba(160, 133, 92, 0.13);
  border-color: rgba(140, 116, 80, 0.25);
  outline: none;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #cf5a50, var(--seal) 62%, var(--seal-dark));
  color: #fff2ec;
  font-family: var(--font-hand);
  font-size: 15px;
  box-shadow: inset 0 -1px 3px rgba(80, 20, 14, 0.4), 0 1px 3px rgba(80, 62, 40, 0.25);
}

.whoami-name {
  font-size: 14px;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 176px;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.menu a,
.menu button {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: none;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.menu a:hover,
.menu button:hover {
  background: rgba(160, 133, 92, 0.14);
  color: var(--ink);
}

/* --------------------------------------------------------- 3. 布局 */

.view {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px, 3.4vw, 38px) clamp(16px, 4vw, 40px) 72px;
}

.footer {
  position: relative;
  z-index: 1;
  padding: 26px 20px 40px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 12.5px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: 0.08em;
}

.page-sub {
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.stats-row {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.stat {
  text-align: right;
}

.stat b {
  display: block;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.1;
}

.stat span {
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
}

/* --------------------------------------------------------- 4. 控件 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--ink);
  color: #fdf9f0;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, background 0.16s, opacity 0.16s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-seal {
  background: linear-gradient(180deg, #c04a40, var(--seal));
  box-shadow: 0 2px 0 var(--seal-dark), var(--shadow-sm);
}

.btn-seal:hover {
  background: linear-gradient(180deg, #c95046, #a83228);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: rgba(120, 96, 62, 0.4);
}

.btn-ghost:hover {
  background: rgba(255, 253, 246, 0.7);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
  padding: 9px 12px;
}

.btn-quiet:hover {
  color: var(--seal);
  background: rgba(179, 56, 47, 0.08);
}

.btn-sm {
  padding: 7px 13px;
  font-size: 13.5px;
}

.ico {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.field {
  display: block;
  margin-bottom: 15px;
}

.field > .label {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 11px 14px;
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(179, 56, 47, 0.55);
  box-shadow: 0 0 0 3px rgba(179, 56, 47, 0.12);
}

.textarea {
  resize: vertical;
  min-height: 96px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 22px;
}

.hint {
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.7;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffefb;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.16s;
}

.chip:hover {
  border-color: rgba(179, 56, 47, 0.4);
}

.chip[aria-pressed="true"] {
  border-color: var(--seal);
  color: var(--seal);
  background: rgba(179, 56, 47, 0.07);
  box-shadow: inset 0 0 0 1px rgba(179, 56, 47, 0.25);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------ 5. 落地页 */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
  padding: clamp(24px, 5vw, 60px) 0 clamp(30px, 5vw, 60px);
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(34px, 5.6vw, 58px);
  line-height: 1.22;
  letter-spacing: 0.04em;
  margin-bottom: 18px;
}

.hero h1 em {
  font-style: normal;
  color: var(--seal);
  position: relative;
  white-space: nowrap;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.04em;
  height: 0.34em;
  background: rgba(179, 56, 47, 0.14);
  border-radius: 3px;
  z-index: -1;
}

.hero p.lead {
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink-soft);
  max-width: 34em;
  margin: 0 0 26px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.hero-note {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.8;
}

.hero-visual {
  display: grid;
  place-items: center;
  min-height: 300px;
}

.hero-stack {
  position: relative;
  width: min(100%, 380px);
  aspect-ratio: 380 / 250;
}

.hero-stack .env {
  position: absolute;
  inset: 0;
}

.hero-stack .env:nth-child(2) {
  transform: translate(-16px, -20px) rotate(-5.5deg) scale(0.95);
  z-index: 1;
}

.hero-stack .env:nth-child(1) {
  transform: rotate(3.5deg) scale(1.02);
  z-index: 2;
}

.hero-stack .env:nth-child(3) {
  transform: translate(18px, 14px) rotate(7deg) scale(0.9);
  z-index: 0;
}

.auth-card {
  margin-top: 10px;
  padding: 24px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--paper-3);
  border-radius: 999px;
}

.tabs button {
  flex: 1;
  padding: 9px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s;
}

.tabs button[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-top: clamp(28px, 4vw, 52px);
}

.feature {
  padding: 22px;
}

.feature h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  margin-bottom: 9px;
  letter-spacing: 0.06em;
}

.feature p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--ink-soft);
}

.feature .n {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 12px;
  border-radius: 50%;
  border: 1px solid rgba(179, 56, 47, 0.35);
  color: var(--seal);
  font-family: var(--font-serif);
  font-size: 15px;
}

/* ------------------------------------------------- 6. 信封（组件） */

.env {
  --env-front-1: #f6ecd9;
  --env-front-2: #e9d8ba;
  --env-flap-1: #f1e4cc;
  --env-flap-2: #ddc9a6;
  position: relative;
  width: 100%;
  aspect-ratio: 260 / 168;
  border-radius: 4px;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(160deg, var(--env-front-1), var(--env-front-2));
  box-shadow:
    inset 0 0 0 1px rgba(122, 96, 58, 0.22),
    var(--shadow-sm);
}

.env-letter {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 12%;
  bottom: 9%;
  border-radius: 2px;
  background: linear-gradient(180deg, #fffdf6, #f7eddc);
  box-shadow: 0 -3px 10px rgba(90, 70, 44, 0.12);
  overflow: hidden;
  z-index: 1;
}

.env-letter::after {
  content: "";
  position: absolute;
  inset: 10px 12px auto;
  height: 3px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, rgba(120, 96, 62, 0.22) 0 14px, transparent 14px 22px);
}

.env-front {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: linear-gradient(200deg, var(--env-front-1) 0%, var(--env-front-2) 100%);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 1px rgba(122, 96, 58, 0.2);
  z-index: 2;
}

.env-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 54%;
  background: linear-gradient(180deg, var(--env-flap-1), var(--env-flap-2));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.55s cubic-bezier(0.6, 0.02, 0.3, 1), z-index 0s linear 0.25s;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(90, 70, 44, 0.14));
}

.env-to {
  position: absolute;
  z-index: 4;
  left: 10%;
  bottom: 15%;
  max-width: 64%;
  font-family: var(--font-hand);
  font-size: clamp(15px, 2.1vw, 21px);
  line-height: 1.3;
  color: rgba(66, 51, 33, 0.82);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.env-to small {
  display: block;
  font-family: var(--font-ui);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(110, 90, 60, 0.6);
  margin-bottom: 3px;
}

.env-stamp {
  position: absolute;
  top: 7%;
  right: 5%;
  width: 17%;
  aspect-ratio: 5 / 6;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.5) 0 2px, transparent 2px 4px),
    radial-gradient(circle at 40% 30%, #fdf6e6, #efe0c6);
  box-shadow: inset 0 0 0 1.5px rgba(122, 96, 58, 0.3);
  transform: rotate(-3.5deg);
  font-size: clamp(11px, 1.5vw, 16px);
  color: var(--seal);
}

.env-stamp[data-stamp="flower"] { color: #b4547a; }
.env-stamp[data-stamp="bird"]   { color: #2f6d6a; }
.env-stamp[data-stamp="moon"]   { color: #4a5b8c; }
.env-stamp[data-stamp="plane"]  { color: #2f6d6a; }
.env-stamp[data-stamp="star"]   { color: var(--gold); }

.env-seal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 21%;
  aspect-ratio: 1;
  translate: -50% -50%;
  z-index: 5;
  display: grid;
  place-items: center;
  border-radius: 47% 53% 52% 48% / 51% 46% 54% 49%;
  background: radial-gradient(circle at 34% 28%, #d4605a, var(--seal) 58%, var(--seal-dark));
  color: #ffece6;
  font-family: var(--font-serif);
  font-size: clamp(11px, 1.6vw, 17px);
  box-shadow:
    inset 0 -2px 5px rgba(70, 12, 8, 0.5),
    inset 0 2px 4px rgba(255, 200, 190, 0.28),
    0 2px 5px rgba(80, 40, 20, 0.3);
  transition: transform 0.3s, opacity 0.3s;
}

.env-seal[data-seal="gold"]   { background: radial-gradient(circle at 34% 28%, #e6c86a, var(--gold) 58%, #8d6d1c); color: #4a3708; }
.env-seal[data-seal="wine"]   { background: radial-gradient(circle at 34% 28%, #9c4157, #72304a 58%, #4d1c30); color: #ffe9f0; }
.env-seal[data-seal="ink"]    { background: radial-gradient(circle at 34% 28%, #4d4a53, #33313a 58%, #1e1d23); color: #e8e5ee; }
.env-seal[data-seal="forest"] { background: radial-gradient(circle at 34% 28%, #4e7a58, #35583e 58%, #22402b); color: #e6f5ea; }
.env-seal[data-seal="sky"]    { background: radial-gradient(circle at 34% 28%, #5c8fc0, #3d6c9c 58%, #26496f); color: #e9f3ff; }

.env[data-paper="ivory"] { --env-front-1: #fbf6ea; --env-front-2: #eee3cd; --env-flap-1: #f8f1e2; --env-flap-2: #e6d9c0; }
.env[data-paper="rose"]  { --env-front-1: #fbeef0; --env-front-2: #f0d6da; --env-flap-1: #fae8ea; --env-flap-2: #e8ccd1; }
.env[data-paper="sage"]  { --env-front-1: #eff2e6; --env-front-2: #d9dfc8; --env-flap-1: #eaeee0; --env-flap-2: #d0d8bc; }
.env[data-paper="night"] { --env-front-1: #565a6b; --env-front-2: #3d4152; --env-flap-1: #4c5061; --env-flap-2: #353949; }
.env[data-paper="kraft"] { --env-front-1: #e3cdae; --env-front-2: #cdb08a; --env-flap-1: #dcc3a0; --env-flap-2: #c3a479; }
.env[data-paper="night"] .env-combo,
.env[data-paper="night"] .env-to { color: rgba(255, 250, 240, 0.82); }

.env-combo {
  position: absolute;
  left: 10%;
  top: 12%;
  max-width: 56%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  z-index: 4;
  font-family: var(--font-serif);
  font-size: clamp(10.5px, 1.35vw, 13px);
  letter-spacing: 0.14em;
  color: rgba(122, 96, 58, 0.72);
}

.env-combo::after {
  content: "";
  display: block;
  width: 26px;
  height: 2px;
  margin-top: 5px;
  background: currentColor;
  opacity: 0.4;
}

/* ------------------------------------- 7. 收件箱里的信封卡片 */

.letter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: clamp(16px, 2.4vw, 26px);
}

.letter-card {
  position: relative;
  border: 0;
  padding: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: transform 0.28s cubic-bezier(0.34, 1.3, 0.64, 1), filter 0.28s;
  animation: cardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
}

.letter-card:nth-child(1) { animation-delay: 0.02s; }
.letter-card:nth-child(2) { animation-delay: 0.06s; }
.letter-card:nth-child(3) { animation-delay: 0.1s; }
.letter-card:nth-child(4) { animation-delay: 0.14s; }
.letter-card:nth-child(5) { animation-delay: 0.18s; }
.letter-card:nth-child(6) { animation-delay: 0.22s; }
.letter-card:nth-child(n + 7) { animation-delay: 0.26s; }

.letter-card:hover,
.letter-card:focus-visible {
  transform: translateY(-6px) rotate(-1deg);
  outline: none;
  filter: drop-shadow(0 16px 22px rgba(80, 62, 40, 0.2));
}

.letter-card:hover .env-seal {
  transform: scale(1.06) rotate(6deg);
}

.letter-card[data-status="unread"] .env-seal {
  animation: sealPulse 2.6s ease-in-out infinite;
}

@keyframes sealPulse {
  0%, 100% { box-shadow: inset 0 -2px 5px rgba(70, 12, 8, 0.5), 0 2px 5px rgba(80, 40, 20, 0.3); }
  50% { box-shadow: inset 0 -2px 5px rgba(70, 12, 8, 0.5), 0 0 0 7px rgba(179, 56, 47, 0.13), 0 2px 5px rgba(80, 40, 20, 0.3); }
}

.letter-card[data-status="read"] .env,
.letter-card[data-status="opened"] .env {
  filter: saturate(0.72) brightness(1.03);
}

.letter-card[data-status="transit"] .env {
  opacity: 0.86;
}

.letter-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  padding: 0 3px;
}

.letter-subject {
  font-family: var(--font-serif);
  font-size: 15.5px;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-time {
  flex: none;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  border: 1px solid currentColor;
  opacity: 0.9;
}

.tag-unread { color: var(--seal); background: rgba(179, 56, 47, 0.07); }
.tag-read { color: var(--ink-faint); }
.tag-transit { color: #8a6a2b; background: rgba(193, 154, 61, 0.1); }
.tag-draft { color: #5b6a7d; background: rgba(91, 106, 125, 0.08); }
.tag-opened { color: #4a6b52; background: rgba(74, 107, 82, 0.08); }
.tag-delivered { color: #7a6a55; }

.letter-tags {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 3px 0;
  flex-wrap: wrap;
}

.empty {
  padding: clamp(46px, 9vw, 90px) 22px;
  text-align: center;
}

.empty-art {
  width: 92px;
  height: 66px;
  margin: 0 auto 20px;
  opacity: 0.4;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 4 5;
}

.empty h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.empty p {
  margin: 0 auto 22px;
  max-width: 32em;
  font-size: 14px;
  line-height: 1.9;
  color: var(--ink-soft);
}

/* --------------------------------------------------- 8. 拆信舞台 */

.envelope-stage {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 30, 22, 0.5);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn 0.28s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.stage-inner {
  position: relative;
  width: min(92vw, 560px);
  display: grid;
  place-items: center;
  gap: 18px;
}

.stage-env {
  width: min(92vw, 480px);
  perspective: 1400px;
  transform-style: preserve-3d;
  cursor: pointer;
}

.stage-env .env-flap {
  transition: transform 0.72s cubic-bezier(0.55, 0.06, 0.24, 1);
}

.stage-env.is-open .env-flap {
  transform: rotateX(179.6deg);
  z-index: 0;
  filter: drop-shadow(0 -2px 3px rgba(90, 70, 44, 0.12));
}

.stage-env .env-letter {
  transition: transform 0.62s cubic-bezier(0.3, 0.9, 0.35, 1);
}

.stage-env.is-rising .env-letter {
  transform: translateY(-58%) scale(1.02);
}

.stage-env.is-breaking .env-seal {
  transform: scale(1.5) rotate(14deg);
  opacity: 0;
}

.stage-env .env-flap,
.stage-env .env-front,
.stage-env .env-back,
.stage-env .env-seal {
  backface-visibility: visible;
}

.stage-hint {
  font-family: var(--font-serif);
  font-size: 13.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 249, 238, 0.82);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  animation: hintIn 0.6s 0.35s ease backwards;
}

@keyframes hintIn {
  from { opacity: 0; transform: translateY(6px); }
}

.stage-close {
  position: absolute;
  top: -6px;
  right: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: #fff8ee;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s;
}

.stage-close:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* 信纸飞出后，铺满屏幕阅读 */
/* 信纸飞出后，铺满屏幕阅读。底色必须完全不透明，
   否则能透出后面的收件箱，看起来像一张贴纸而不是一张纸。 */
.reader {
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow-y: auto;
  padding: clamp(16px, 4vh, 46px) 16px 60px;
  background-color: #e4d9c3;
  background-image:
    radial-gradient(115% 75% at 50% -8%, rgba(255, 253, 246, 0.92), transparent 60%),
    radial-gradient(95% 60% at 50% 112%, rgba(146, 117, 76, 0.26), transparent 66%);
  animation: paperIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes paperIn {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.94);
    filter: blur(3px);
  }
}

.sheet-wrap {
  max-width: 720px;
  margin: 0 auto;
}

.sheet {
  position: relative;
  padding: clamp(26px, 5vw, 52px) clamp(22px, 5vw, 56px) clamp(30px, 5vw, 52px);
  border-radius: 4px;
  background: var(--sheet-bg, linear-gradient(180deg, #fffdf6, #f9f1e2));
  color: var(--sheet-ink, var(--ink));
  box-shadow: var(--shadow-lg);
  background-image:
    var(--sheet-lines, repeating-linear-gradient(180deg, transparent 0 31px, rgba(140, 116, 80, 0.13) 31px 32px));
  background-size: 100% 32px;
  background-position: 0 clamp(26px, 5vw, 52px);
  background-repeat: repeat-y;
}

.sheet::before,
.sheet::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(120, 96, 62, 0.22), transparent);
}

.sheet::before { top: 16px; }
.sheet::after { bottom: 16px; }

.sheet-head {
  position: relative;
  z-index: 1;
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 1px dashed rgba(120, 96, 62, 0.3);
}

.sheet-subject {
  font-family: var(--font-serif);
  font-size: clamp(21px, 3.4vw, 28px);
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.sheet-route {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: 13px;
  color: var(--ink-soft);
}

.sheet-route .who {
  font-family: var(--font-hand);
  font-size: 16px;
  color: var(--ink);
}

.sheet-route .arrow {
  color: var(--ink-faint);
}

.sheet-when {
  font-size: 12.5px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}

.sheet-body {
  position: relative;
  z-index: 1;
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 32px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 32px;
}

.sheet-body:empty::before {
  content: "（这封信里没有写字）";
  color: var(--ink-faint);
}

.sheet-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
}

/* 底部的操作按钮靠左排，别散开；删除按钮推到最右 */
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.sheet-actions .btn-quiet {
  margin-left: auto;
}

.sheet-bar {
  margin-bottom: 14px;
}

.sheet-sign {
  position: relative;
  z-index: 1;
  margin-top: 30px;
  padding-right: 86px;
  text-align: right;
  font-family: var(--font-hand);
  font-size: 17px;
  color: var(--ink-soft);
}

.sheet-wax {
  position: absolute;
  right: clamp(16px, 4vw, 34px);
  bottom: clamp(16px, 4vw, 30px);
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 47% 53% 52% 48% / 51% 46% 54% 49%;
  font-family: var(--font-serif);
  font-size: 19px;
  color: #ffece6;
  opacity: 0.92;
  pointer-events: none;
  transform: rotate(-8deg);
  background: radial-gradient(circle at 34% 28%, #d4605a, var(--seal) 58%, var(--seal-dark));
  box-shadow: inset 0 -2px 6px rgba(70, 12, 8, 0.5), 0 3px 8px rgba(80, 40, 20, 0.28);
}

.sheet-wax[data-seal="gold"]   { background: radial-gradient(circle at 34% 28%, #e6c86a, var(--gold) 58%, #8d6d1c); color: #4a3708; }
.sheet-wax[data-seal="wine"]   { background: radial-gradient(circle at 34% 28%, #9c4157, #72304a 58%, #4d1c30); color: #ffe9f0; }
.sheet-wax[data-seal="ink"]    { background: radial-gradient(circle at 34% 28%, #4d4a53, #33313a 58%, #1e1d23); color: #e8e5ee; }
.sheet-wax[data-seal="forest"] { background: radial-gradient(circle at 34% 28%, #4e7a58, #35583e 58%, #22402b); color: #e6f5ea; }
.sheet-wax[data-seal="sky"]    { background: radial-gradient(circle at 34% 28%, #5c8fc0, #3d6c9c 58%, #26496f); color: #e9f3ff; }

/* 信纸主题 */
.sheet[data-paper="cream"] { --sheet-bg: linear-gradient(180deg, #fffdf6, #f8f0df); }
.sheet[data-paper="ivory"] { --sheet-bg: linear-gradient(180deg, #fffefa, #f4ecdc); }
.sheet[data-paper="rose"]  { --sheet-bg: linear-gradient(180deg, #fff8f9, #fbeaec); --sheet-lines: repeating-linear-gradient(180deg, transparent 0 31px, rgba(178, 120, 132, 0.16) 31px 32px); }
.sheet[data-paper="sage"]  { --sheet-bg: linear-gradient(180deg, #fbfdf5, #eef3e2); --sheet-lines: repeating-linear-gradient(180deg, transparent 0 31px, rgba(110, 138, 96, 0.18) 31px 32px); }
.sheet[data-paper="night"] { --sheet-bg: linear-gradient(180deg, #2f3343, #24283a); --sheet-ink: #ece7f3; --sheet-lines: repeating-linear-gradient(180deg, transparent 0 31px, rgba(200, 205, 230, 0.14) 31px 32px); }
.sheet[data-paper="kraft"] { --sheet-bg: linear-gradient(180deg, #efdcc0, #e3caa6); --sheet-lines: repeating-linear-gradient(180deg, transparent 0 31px, rgba(120, 88, 50, 0.18) 31px 32px); }

.sheet[data-paper="night"] .sheet-route,
.sheet[data-paper="night"] .sheet-when,
.sheet[data-paper="night"] .sheet-sign { color: #b9b3c8; }

.thread {
  max-width: 720px;
  margin: 26px auto 0;
}

.thread-title {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--ink-soft);
  margin-bottom: 12px;
  text-align: center;
}

.thread-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 16px;
  margin-bottom: 9px;
  background: rgba(255, 253, 246, 0.72);
  border: 1px solid rgba(140, 116, 80, 0.2);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}

.thread-item:hover {
  background: #fffdf6;
  transform: translateX(3px);
}

.thread-item[aria-current="true"] {
  border-color: rgba(179, 56, 47, 0.5);
  background: #fffdf6;
}

.thread-dot {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
}

.thread-item[data-dir="in"] .thread-dot { background: var(--seal); }
.thread-item[data-dir="out"] .thread-dot { background: #4a6b52; }

.thread-main {
  min-width: 0;
  flex: 1;
}

.thread-line {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-line b {
  font-family: var(--font-hand);
  font-size: 15px;
  font-weight: 400;
}

.thread-excerpt {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-time {
  flex: none;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ------------------------------------------------------ 9. 写信台 */

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
}

.write-sheet {
  position: relative;
  padding: clamp(20px, 3vw, 34px);
  border-radius: 6px;
  background: var(--sheet-bg, linear-gradient(180deg, #fffdf6, #f9f1e2));
  color: var(--sheet-ink, var(--ink));
  box-shadow: var(--shadow-md);
  background-image:
    var(--sheet-lines, repeating-linear-gradient(180deg, transparent 0 31px, rgba(140, 116, 80, 0.13) 31px 32px));
  background-size: 100% 32px;
  background-position: 0 0;
  background-repeat: repeat-y;
  border: 1px solid rgba(140, 116, 80, 0.22);
}

.write-sheet .subject-input {
  width: 100%;
  padding: 0 0 12px;
  margin-bottom: 16px;
  border: 0;
  border-bottom: 1px dashed rgba(120, 96, 62, 0.35);
  background: none;
  font-family: var(--font-serif);
  font-size: clamp(19px, 2.6vw, 25px);
  letter-spacing: 0.05em;
  outline: none;
}

.write-sheet .subject-input::placeholder {
  color: var(--ink-faint);
  opacity: 0.75;
}

.write-body {
  width: 100%;
  min-height: clamp(240px, 42vh, 420px);
  padding: 0;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-family: var(--font-hand);
  font-size: 19px;
  line-height: 32px;
  color: inherit;
}

.write-body::placeholder {
  color: var(--ink-faint);
  opacity: 0.8;
}

.write-count {
  text-align: right;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.side-panel {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 78px;
}

.panel-block {
  padding: 18px;
}

.panel-block h4 {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  margin-bottom: 12px;
  font-weight: 500;
}

.recipient-box {
  position: relative;
}

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 232px;
  overflow-y: auto;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.suggest button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
}

.suggest button:hover {
  background: rgba(160, 133, 92, 0.14);
}

.suggest .s-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest .s-user {
  font-size: 12px;
  color: var(--ink-faint);
}

.deliver-row {
  display: grid;
  gap: 9px;
}

.deliver-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffefb;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.mini:hover {
  border-color: rgba(179, 56, 47, 0.45);
  color: var(--seal);
}

.composer-foot {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 22px;
}

.preview-env {
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
}

/* ------------------------------------------------------ 10. 其他 */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 28px;
  translate: -50% 0;
  z-index: 120;
  display: grid;
  gap: 9px;
  justify-items: center;
  pointer-events: none;
}

.toast {
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(45, 38, 30, 0.94);
  color: #fdf7ec;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 88vw;
}

.toast[data-kind="error"] {
  background: rgba(140, 38, 32, 0.96);
}

.toast[data-kind="out"] {
  animation: toastIn 0.32s cubic-bezier(0.22, 1, 0.36, 1), toastOut 0.3s 3.4s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px) scale(0.98); }
}

.skeleton {
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, rgba(255, 253, 246, 0.5) 30%, rgba(255, 253, 246, 0.85) 50%, rgba(255, 253, 246, 0.5) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 26px;
}

.skeleton-grid .skeleton {
  aspect-ratio: 260 / 168;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed rgba(120, 96, 62, 0.22);
  font-size: 14px;
}

.kv:last-child {
  border-bottom: 0;
}

.kv span {
  color: var(--ink-faint);
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
}

.switch input {
  appearance: none;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: var(--desk-2);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex: none;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fffdf6;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

.switch input:checked {
  background: var(--seal);
}

.switch input:checked::after {
  transform: translateX(17px);
}

.spinner {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------ 11. 响应式 */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .hero-visual {
    order: -1;
    min-height: 220px;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .brand-name {
    display: none;
  }

  .whoami-name {
    display: none;
  }

  .nav a {
    padding: 7px 11px;
    font-size: 13.5px;
  }
  .letter-grid,
  .skeleton-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .letter-subject {
    font-size: 13.5px;
  }

  .stats-row {
    gap: 14px;
  }

  .stat b {
    font-size: 19px;
  }

  .sheet-body {
    font-size: 17.5px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 10px;
    padding: 10px 14px;
  }

  .topbar-right {
    gap: 8px;
  }

  /* 窄屏只留图标，免得顶栏被挤爆 */
  .btn-label {
    display: none;
  }

  .topbar .btn {
    padding: 9px 12px;
  }

  .brand-mark {
    width: 26px;
    height: 20px;
  }
}

@media (max-width: 430px) {
  .letter-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
