/* 好友降临节日历工具样式 — 暖纸肌理、手绘信封、每日图案与火漆印风格 */
.env-app {
  margin-top: 8px;
}

.env-preview-banner {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  margin: 0 0 16px;
}

.env-preview-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  max-width: none;
}

/* 双栏工作台：移动端面板在上、信封格在下；桌面端左格右面板 */
.env-workbench {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

.env-panel {
  order: -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 20px;
}

/* 暖色纸纹底板：使用 paper-bg.webp 重复平铺 */
.env-board {
  background-color: #f3e4ca;
  background-image: url("../_a/paper-bg.94adbe9da1.webp");
  background-repeat: repeat;
  background-size: 320px 320px;
  border: 1px solid rgba(43, 33, 24, 0.18);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 250, 242, 0.72), var(--shadow-md);
  padding: 16px;
}

.env-board-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(255, 250, 242, 0.86);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.env-board-title {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin: 0;
}

.env-board-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.env-pill.is-owner {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(194, 86, 47, 0.3);
}

.env-pill.is-friend {
  background: var(--accent-soft);
  color: var(--text);
  border-color: rgba(224, 160, 58, 0.5);
}

.env-pill.is-today {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* 顶部进度条 */
.env-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  width: 100%;
}

.env-dots {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 3px;
  flex: 1 1 180px;
  min-width: 140px;
}

.env-dots i {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: rgba(43, 33, 24, 0.15);
  transition: background-color 0.2s ease;
}

.env-dots i.on {
  background: var(--primary);
}

.env-dots i.mine {
  background: var(--accent);
}

.env-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* 24 扇插画信封门网格（移动端 3 列、桌面端 6 列） */
.env-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.env-door {
  position: relative;
  appearance: none;
  min-height: 120px;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid rgba(43, 33, 24, 0.16);
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(43, 33, 24, 0.08);
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

/* 信封主画面容器：闭合信封与打开信封共用容器并底部对齐 */
.env-door-art {
  position: relative;
  width: 100%;
  aspect-ratio: 768 / 672;
  display: block;
  pointer-events: none;
}

.env-envelope-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 3px 4px rgba(43, 33, 24, 0.16));
  transition: transform 0.22s ease, opacity 0.2s ease;
}

/* 每日专属小插画（day-01..day-24.webp） */
.env-motif-img {
  position: absolute;
  left: 50%;
  top: 4%;
  width: 48%;
  height: 48%;
  transform: translateX(-50%);
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(43, 33, 24, 0.2));
  transition: transform 0.22s ease;
}

/* 打开信封时，每日图案从袋口探出如手绘信笺 */
.env-door.is-opened .env-motif-img {
  top: 12%;
  width: 44%;
  height: 44%;
}

/* 火漆印状态图层（seal-idle / locked / ready / opened / today） */
.env-seal-img {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 34%;
  height: 34%;
  transform: translateX(-50%);
  object-fit: contain;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(43, 33, 24, 0.28));
  transition: transform 0.2s ease;
}

.env-door.is-opened .env-seal-img {
  bottom: 10%;
  width: 32%;
  height: 32%;
}

/* 日期邮戳角标：确保 1-24 数字一目了然且不遮挡火漆图案 */
.env-day-num {
  position: absolute;
  top: 5px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.94);
  border: 1px solid rgba(43, 33, 24, 0.2);
  color: var(--text);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  z-index: 4;
  box-shadow: 0 1px 2px rgba(43, 33, 24, 0.12);
}

/* 底部状态标签 */
.env-meta {
  position: relative;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  z-index: 4;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.88);
  border: 1px solid rgba(43, 33, 24, 0.1);
}

/* 多人共门小点提示（右上角） */
.env-voices {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  gap: 3px;
  padding: 3px 5px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.9);
  border: 1px solid rgba(43, 33, 24, 0.14);
  z-index: 4;
}

.env-voices i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
}

/* 门状态：空信封（浅虚线边框邀请好友填写） */
.env-door.is-empty {
  background: rgba(255, 250, 242, 0.56);
  border-style: dashed;
  border-color: rgba(43, 33, 24, 0.24);
  box-shadow: none;
}

.env-door.is-empty .env-envelope-img {
  opacity: 0.9;
}

.env-door.is-empty .env-seal-img {
  opacity: 0.88;
}

/* 门状态：已填待开启（红陶锁印） */
.env-door.is-filled.is-locked {
  background: rgba(255, 250, 242, 0.88);
  border: 1px solid rgba(194, 86, 47, 0.34);
}

.env-door.is-filled.is-locked .env-day-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* 门状态：房主今日或往期可立刻拆封（绿蜡信封印 + 暖框强调） */
.env-door.is-filled.is-ready {
  background: #fffaf2;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.env-door.is-filled.is-ready .env-day-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.env-door.is-filled.is-ready .env-meta {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* 门状态：已拆封读过（打开信封 + 裂纹勾印） */
.env-door.is-opened {
  background: rgba(255, 250, 242, 0.92);
  border: 1px solid rgba(224, 160, 58, 0.65);
}

.env-door.is-opened .env-day-num {
  background: var(--accent);
  border-color: rgba(43, 33, 24, 0.16);
  color: var(--text);
}

/* 门状态：今天（Dec 1-24 金星红印） */
.env-door.is-today {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-md);
}

.env-door.is-today .env-meta {
  color: var(--primary);
  border-color: rgba(194, 86, 47, 0.3);
}

.env-door.is-today.is-filled.is-ready .env-meta {
  color: #ffffff;
}

/* 门状态：当前正在填写 */
.env-door.is-selected {
  background: #fff7ea;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft), var(--shadow-md);
  transform: translateY(-2px);
}

.env-door.is-selected .env-day-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.env-door.is-selected .env-meta {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

/* 门状态：我留过的纸条（金框标识） */
.env-door.is-mine {
  border: 2px solid var(--accent);
  background: #fffaf0;
}

.env-door.is-mine .env-day-num {
  background: var(--accent);
  border-color: rgba(43, 33, 24, 0.18);
  color: var(--text);
}

.env-door.has-thanks {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm);
}

.env-door.has-thanks .env-meta {
  background: var(--accent);
  border-color: rgba(43, 33, 24, 0.16);
  color: var(--text);
}

/* 首页预览态信封 */
.env-door.is-preview {
  background: rgba(255, 250, 242, 0.8);
  border: 1px solid rgba(43, 33, 24, 0.15);
}

/* 骨架加载态：零高度跳动 */
.env-door.is-loading {
  opacity: 0.68;
  cursor: progress;
}

/* 刚刚盖章封口动效 */
.env-door.is-just-sealed {
  animation: env-stamp 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes env-stamp {
  0% { transform: scale(1.06); }
  45% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.env-door:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.env-door:hover:not(:disabled) .env-motif-img {
  transform: translateX(-50%) translateY(-2px) scale(1.05);
}

.env-door:hover:not(:disabled) .env-seal-img {
  transform: translateX(-50%) scale(1.06);
}

.env-door:active:not(:disabled) {
  transform: translateY(0);
}

/* 网格底部图例（使用真实火漆缩略图） */
.env-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(255, 250, 242, 0.84);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--muted);
}

.env-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.env-legend-seal {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 20px;
}

/* 大幅插画展示区（空状态、好友写信、感谢瞬间、拆封信封） */
.env-illus-figure {
  margin: 0 0 16px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.env-illus-img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: #f5ead8;
}

.env-illus-figure.is-compact .env-illus-img {
  max-height: 196px;
}

.env-thanks-illus {
  margin: 0 0 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(194, 86, 47, 0.22);
  background: #f5ead8;
}

.env-thanks-illus img {
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* 右侧 / 顶部面板排版 */
.env-panel-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.env-kicker {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

.env-title {
  font-family: var(--font-heading);
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.env-sub {
  font-family: var(--font-heading);
  font-size: 18px;
  line-height: 1.2;
  margin: 0 0 8px;
}

.env-lead {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

.env-fine {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
}

/* 首页三步流程小条 */
.env-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.env-step {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.env-step b {
  display: block;
  color: var(--text);
  font-size: 12px;
  margin-bottom: 2px;
}

/* 强调卡片（今日拆封 / 收到感谢） */
.env-callout {
  background: var(--surface-tint);
  border: 1px solid rgba(194, 86, 47, 0.28);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

.env-callout.is-gold {
  border-color: rgba(224, 160, 58, 0.45);
  border-left-color: var(--accent);
}

.env-callout-title {
  font-family: var(--font-heading);
  font-size: 18px;
  margin: 0 0 4px;
}

.env-callout p {
  font-size: 14px;
  margin: 0 0 12px;
  color: var(--muted);
}

.env-callout p:last-child {
  margin-bottom: 0;
}

/* 好友额度点 */
.env-quota {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 16px;
  font-size: 14px;
}

.env-quota-dots {
  display: inline-flex;
  gap: 6px;
}

.env-quota-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: block;
}

.env-quota-dots i.used {
  background: var(--accent);
  border-color: var(--primary);
}

/* 表单与按钮组 */
.env-form {
  margin: 0;
}

.env-field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
}

.env-optional {
  font-weight: 400;
  color: var(--muted);
}

.env-field input,
.env-field textarea,
.env-share-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.env-count {
  display: block;
  text-align: right;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.env-count.is-near {
  color: var(--primary);
  font-weight: 600;
}

.env-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.env-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--primary);
}

.env-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.env-actions .btn-primary,
.env-actions .btn-secondary {
  flex: 1 1 auto;
}

.env-actions.is-compact {
  margin-bottom: 0;
}

.env-text-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0 4px;
  color: var(--primary);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.env-text-btn:hover {
  color: var(--primary-hover);
}

.env-btn-copied {
  background: var(--text) !important;
  border-color: var(--text) !important;
  color: #ffffff !important;
}

/* 分享卡与恢复码 */
.env-share {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
}

.env-share-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.env-share-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  background: var(--surface);
}

.env-code-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: 0 0 12px;
}

.env-code-label {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

.env-code-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

/* 折叠式代码入口与高级设置 */
.env-disclosure {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.env-disclosure summary {
  list-style: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.env-disclosure summary::-webkit-details-marker {
  display: none;
}

.env-disclosure summary:hover {
  color: var(--primary);
}

.env-disclosure-body {
  padding-top: 8px;
}

/* 写作灵感提示条 */
.env-prompt {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 12px;
}

.env-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.env-prompt-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.env-prompt-text {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text);
}

.env-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.env-chip {
  appearance: none;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.env-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.env-chip.is-small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
}

.env-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.env-mine-teaser {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* 表单内联报错，避免低头找底部状态栏 */
.env-inline-msg {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 12px;
}

/* 弹窗 / 移动端底部抽屉（拆信、等待、感谢、提醒、删除） */
.env-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(43, 33, 24, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
  animation: env-fade-in 0.18s ease;
}

.env-sheet[hidden] {
  display: none;
}

.env-sheet-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 20px;
  animation: env-sheet-up 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.env-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.env-close-x {
  appearance: none;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.env-close-x:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* 拆封与等待弹窗的大幅插画信封头 */
.env-unseal-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background-color: #f3e4ca;
  background-image: url("../_a/paper-bg.94adbe9da1.webp");
  background-repeat: repeat;
  background-size: 260px 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 16px;
}

.env-unseal-art {
  position: relative;
  width: 128px;
  aspect-ratio: 768 / 672;
  flex: 0 0 128px;
}

.env-unseal-env {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 3px 5px rgba(43, 33, 24, 0.18));
}

.env-unseal-motif {
  position: absolute;
  left: 50%;
  top: 10%;
  width: 52px;
  height: 52px;
  transform: translateX(-50%);
  object-fit: contain;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(43, 33, 24, 0.2));
}

.env-unseal-seal {
  position: absolute;
  right: 4px;
  bottom: 6px;
  width: 40px;
  height: 40px;
  object-fit: contain;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(43, 33, 24, 0.25));
}

.env-unseal-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.env-letter {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  animation: env-letter-in 0.34s ease;
}

.env-letter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.env-letter-from {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.env-letter-stamp {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.env-letter-text {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.env-thanks-box {
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.env-thanks-sent {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 6px;
}

.env-thanks-quote {
  margin: 0 0 6px;
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--text);
}

.env-sheet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.env-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.env-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.env-list li:first-child {
  border-top: 0;
}

/* 底部轻量状态条 */
.env-status {
  font-size: 14px;
  min-height: 1.6em;
  margin: 12px 0 0;
  color: var(--muted);
}

.env-status[data-kind="error"] {
  color: var(--primary);
  font-weight: 600;
}

.env-status[data-kind="ok"] {
  color: var(--text);
  font-weight: 600;
}

@keyframes env-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes env-sheet-up {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes env-letter-in {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 平板与桌面端响应：左 24 门信封桌，右吸顶控制面板 */
@media (min-width: 640px) {
  .env-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  .env-board {
    padding: 20px;
  }
  .env-panel {
    padding: 24px;
  }
  .env-sheet {
    align-items: center;
    padding: 24px;
  }
  .env-sheet-card {
    padding: 24px;
  }
}

@media (min-width: 960px) {
  .env-workbench {
    grid-template-columns: minmax(0, 1.48fr) minmax(320px, 0.86fr);
    gap: 24px;
  }
  .env-panel {
    order: 0;
    position: sticky;
    top: 16px;
  }
  .env-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
  }
  .env-door {
    min-height: 118px;
  }
}

@media (max-width: 640px) {
  .env-panel {
    padding: 16px;
  }
  .env-board {
    padding: 12px;
  }
  .env-share-row {
    flex-direction: column;
  }
  .env-actions .btn-primary,
  .env-actions .btn-secondary {
    width: 100%;
  }
  .env-steps {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .env-door {
    min-height: 110px;
    padding: 5px 4px 6px;
  }
  .env-unseal-hero {
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .env-door,
  .env-envelope-img,
  .env-motif-img,
  .env-seal-img,
  .env-sheet,
  .env-sheet-card,
  .env-letter {
    animation: none !important;
    transition: none !important;
  }
  .env-door:hover:not(:disabled),
  .env-door.is-selected {
    transform: none;
  }
}

/* ==========================================================================
   工具内完整按钮视觉系统与弹窗排版修复（覆盖 .env-app 与独立挂载的 .env-sheet）
   ========================================================================== */

.env-app .env-field-label,
.env-sheet .env-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #2b2118);
  margin: 0;
}

/* 按钮通用基础：高特异性覆盖 theme 中 button.btn-secondary 的透明边框 */
.env-app .btn-primary,
.env-app button.btn-primary,
.env-sheet .btn-primary,
.env-sheet button.btn-primary,
.env-app .btn-secondary,
.env-app button.btn-secondary,
.env-sheet .btn-secondary,
.env-sheet button.btn-secondary,
.env-app .btn-danger,
.env-app button.btn-danger,
.env-sheet .btn-danger,
.env-sheet button.btn-danger {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius, 12px);
  font-family: var(--font-body, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}

/* 主按钮：陶红实心 */
.env-app .btn-primary,
.env-app button.btn-primary,
.env-sheet .btn-primary,
.env-sheet button.btn-primary {
  background: var(--primary, #c2562f);
  border: 1px solid var(--primary, #c2562f);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(43, 33, 24, 0.14);
}

.env-app .btn-primary:hover:not(:disabled),
.env-app button.btn-primary:hover:not(:disabled),
.env-sheet .btn-primary:hover:not(:disabled),
.env-sheet button.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover, #a54522);
  border-color: var(--primary-hover, #a54522);
  color: #ffffff;
}

/* 次按钮：暖羊皮纸底色 + 清晰可见边框，与 #fffaf2 卡片及 #f7f1e8 分享区均有明确对比 */
.env-app .btn-secondary,
.env-app button.btn-secondary,
.env-sheet .btn-secondary,
.env-sheet button.btn-secondary {
  background: #f1e6d6;
  border: 1px solid rgba(43, 33, 24, 0.34);
  color: var(--text, #2b2118);
  box-shadow: 0 1px 2px rgba(43, 33, 24, 0.06);
}

.env-app .btn-secondary:hover:not(:disabled),
.env-app button.btn-secondary:hover:not(:disabled),
.env-sheet .btn-secondary:hover:not(:disabled),
.env-sheet button.btn-secondary:hover:not(:disabled) {
  background: #e7d8c1;
  border-color: rgba(43, 33, 24, 0.54);
  color: var(--text, #2b2118);
}

/* 低调次按钮（如 Report / 弹窗底部 Close）：仍保持清晰按钮边框与底色 */
.env-app .btn-secondary.is-quiet,
.env-app button.btn-secondary.is-quiet,
.env-sheet .btn-secondary.is-quiet,
.env-sheet button.btn-secondary.is-quiet {
  background: var(--bg, #f7f1e8);
  border: 1px solid var(--border-strong, rgba(43, 33, 24, 0.28));
  color: var(--muted, #5c4c3d);
  box-shadow: none;
}

.env-app .btn-secondary.is-quiet:hover:not(:disabled),
.env-app button.btn-secondary.is-quiet:hover:not(:disabled),
.env-sheet .btn-secondary.is-quiet:hover:not(:disabled),
.env-sheet button.btn-secondary.is-quiet:hover:not(:disabled) {
  background: #efe4d3;
  border-color: rgba(43, 33, 24, 0.48);
  color: var(--text, #2b2118);
}

/* 危险按钮：温暖深绯红描边填充（区别于主按钮陶红，适配暖纸风格） */
.env-app .btn-danger,
.env-app button.btn-danger,
.env-sheet .btn-danger,
.env-sheet button.btn-danger {
  background: #fdf0ed;
  border: 1px solid rgba(158, 42, 43, 0.48);
  color: #8f2424;
  box-shadow: 0 1px 2px rgba(158, 42, 43, 0.08);
}

.env-app .btn-danger:hover:not(:disabled),
.env-app button.btn-danger:hover:not(:disabled),
.env-sheet .btn-danger:hover:not(:disabled),
.env-sheet button.btn-danger:hover:not(:disabled) {
  background: #9e2a2b;
  border-color: #9e2a2b;
  color: #ffffff;
}

/* 危险主确认按钮（删除弹窗的 Delete permanently） */
.env-app .btn-danger.is-solid,
.env-app button.btn-danger.is-solid,
.env-sheet .btn-danger.is-solid,
.env-sheet button.btn-danger.is-solid {
  background: #9e2a2b;
  border: 1px solid #9e2a2b;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(43, 33, 24, 0.16);
}

.env-app .btn-danger.is-solid:hover:not(:disabled),
.env-app button.btn-danger.is-solid:hover:not(:disabled),
.env-sheet .btn-danger.is-solid:hover:not(:disabled),
.env-sheet button.btn-danger.is-solid:hover:not(:disabled) {
  background: #7f1f20;
  border-color: #7f1f20;
  color: #ffffff;
}

/* 按下、焦点与禁用状态 */
.env-app .btn-primary:active:not(:disabled),
.env-sheet .btn-primary:active:not(:disabled),
.env-app .btn-secondary:active:not(:disabled),
.env-sheet .btn-secondary:active:not(:disabled),
.env-app .btn-danger:active:not(:disabled),
.env-sheet .btn-danger:active:not(:disabled) {
  transform: translateY(1px);
}

.env-app .btn-primary:focus-visible,
.env-sheet .btn-primary:focus-visible,
.env-app .btn-secondary:focus-visible,
.env-sheet .btn-secondary:focus-visible {
  outline: 2px solid var(--primary, #c2562f);
  outline-offset: 2px;
}

.env-app .btn-danger:focus-visible,
.env-sheet .btn-danger:focus-visible {
  outline: 2px solid #9e2a2b;
  outline-offset: 2px;
}

.env-app .btn-primary:disabled,
.env-sheet .btn-primary:disabled,
.env-app .btn-secondary:disabled,
.env-sheet .btn-secondary:disabled,
.env-app .btn-danger:disabled,
.env-sheet .btn-danger:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 已复制状态（兼容按钮与胶囊芯片） */
.env-app .env-btn-copied,
.env-app button.env-btn-copied,
.env-sheet .env-btn-copied,
.env-sheet button.env-btn-copied {
  background: var(--text, #2b2118) !important;
  border-color: var(--text, #2b2118) !important;
  color: #ffffff !important;
}

/* 胶囊芯片样式（同步支持 .env-sheet 内的感谢快捷语） */
.env-app .env-chip,
.env-sheet .env-chip {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f4eadb;
  border: 1px solid rgba(43, 33, 24, 0.3);
  color: var(--text, #2b2118);
}

.env-app .env-chip:hover:not(:disabled),
.env-sheet .env-chip:hover:not(:disabled) {
  background: #ecdec9;
  border-color: var(--primary, #c2562f);
  color: var(--primary, #c2562f);
}

/* 按钮组布局：包含 .btn-danger，避免挤压溢出 */
.env-app .env-actions .btn-primary,
.env-app .env-actions .btn-secondary,
.env-app .env-actions .btn-danger,
.env-sheet .env-actions .btn-primary,
.env-sheet .env-actions .btn-secondary,
.env-sheet .env-actions .btn-danger {
  flex: 1 1 140px;
  min-width: 0;
}

.env-app .env-share-row .btn-primary {
  flex: 0 0 auto;
  white-space: nowrap;
}

.env-app .env-actions-options {
  gap: 8px;
}

.env-app .env-actions-options .btn-secondary,
.env-app .env-actions-options .btn-danger {
  flex: 1 1 120px;
  font-size: 14px;
  padding: 9px 14px;
}

/* 折叠面板展开指示符 */
.env-app .env-disclosure summary::after {
  content: "▾";
  font-size: 13px;
  color: var(--muted, #6b5b4b);
  transition: transform 0.16s ease;
  margin-left: 8px;
}

.env-app .env-disclosure[open] summary::after {
  transform: rotate(180deg);
}

/* 预览提示小字间距 */
.env-app .env-preview-note,
.env-sheet .env-preview-note {
  margin: 10px 0 0;
}

/* 弹窗与提醒对话框排版优化：桌面居中可控高度、移动底部抽屉、无裁切溢出 */
.env-sheet {
  box-sizing: border-box;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain;
}

.env-sheet-card {
  box-sizing: border-box;
  max-height: min(88vh, 88dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.env-sheet-card.is-compact {
  max-width: 480px;
}

.env-sheet-head > div {
  min-width: 0;
  flex: 1 1 auto;
}

.env-sheet-head .env-title {
  margin-bottom: 4px;
}

.env-sheet-head .env-fine {
  margin-bottom: 0;
}

.env-close-x {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(43, 33, 24, 0.3);
  background: #f1e6d6;
  color: var(--text, #2b2118);
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.env-close-x:hover {
  background: #e7d8c1;
  border-color: var(--primary, #c2562f);
  color: var(--primary, #c2562f);
}

.env-close-x:focus-visible {
  outline: 2px solid var(--primary, #c2562f);
  outline-offset: 2px;
}

.env-remind-actions {
  margin: 0 0 14px;
}

.env-remind-dest {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg, #f7f1e8);
  border: 1px solid var(--border, rgba(43, 33, 24, 0.14));
  border-radius: var(--radius, 12px);
  font-size: 12px;
  color: var(--muted, #6b5b4b);
  margin: 0;
}

.env-remind-dest-label {
  font-weight: 600;
  color: var(--muted, #6b5b4b);
}

.env-url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text, #2b2118);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.env-sheet-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(43, 33, 24, 0.13));
}

.env-sheet-footer .btn-secondary {
  flex: 0 0 auto;
  min-width: 96px;
}

@media (min-width: 640px) {
  .env-sheet {
    align-items: center;
    padding: 24px;
  }
  .env-sheet-card {
    max-height: min(86vh, 760px);
  }
}

@media (max-width: 640px) {
  .env-app .env-actions .btn-primary,
  .env-app .env-actions .btn-secondary,
  .env-app .env-actions .btn-danger,
  .env-sheet .env-actions .btn-primary,
  .env-sheet .env-actions .btn-secondary,
  .env-sheet .env-actions .btn-danger {
    flex: 1 1 100%;
    width: 100%;
  }
  .env-app .env-share-row .btn-primary {
    width: 100%;
  }
  .env-sheet-footer .btn-secondary {
    width: 100%;
  }
}
