/* ============================================================
   林离的信箱 · BSide Letters
   纸墨美学 · 昼/夜双主题 · 单页书信界面
   ============================================================ */

:root {
  --font-hand: "Ma Shan Zheng", "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", "Noto Serif SC", serif;
  --font-kai:  "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", "Noto Serif SC", "Songti SC", serif;
  --font-serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg1: #efe8da;
  --bg2: #e2d8c4;
  --paper: #faf6ec;
  --paper-her: #f8f4e8;
  --ink: #2c2620;
  --ink-soft: #5d5647;
  --muted: #948a79;
  --line: rgba(64, 52, 34, 0.16);
  --line-strong: rgba(64, 52, 34, 0.3);
  --seal: #8c3b2e;
  --shadow: rgba(74, 58, 32, 0.2);
  --grain-opacity: 0.05;
}

html[data-theme="night"] {
  --bg1: #171a22;
  --bg2: #0e1016;
  --paper: #1d212c;
  --paper-her: #1a1f2a;
  --ink: #e9e2d2;
  --ink-soft: #b3ab9a;
  --muted: #7c766a;
  --line: rgba(233, 226, 210, 0.14);
  --line-strong: rgba(233, 226, 210, 0.3);
  --seal: #b25a41;
  --shadow: rgba(0, 0, 0, 0.55);
  --grain-opacity: 0.08;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  transition: background 0.6s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* 纸纹颗粒 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.16 0 0 0 0 0.1 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(#n)'/%3E%3C/svg%3E");
}

::selection { background: var(--seal); color: var(--paper); }

#bokeh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.seal-text { font-family: var(--font-kai); }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: relative;
  z-index: 3;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 24px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal { width: 36px; height: 36px; flex: none; filter: drop-shadow(0 2px 4px var(--shadow)); }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.brand-name {
  font-size: 12px;
  letter-spacing: 0.34em;
  color: var(--ink-soft);
  font-weight: 600;
}
.brand-sub { font-size: 11px; letter-spacing: 0.16em; color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #c9a24a; transition: background 0.3s; }
.pill.ok .dot { background: #6f9a6b; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}
.switch input { accent-color: var(--seal); width: 14px; height: 14px; margin: 0; cursor: pointer; }

.iconbtn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}
.iconbtn:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.iconbtn.on { color: var(--seal); border-color: var(--seal); }

/* ---------------- 舞台 ---------------- */

.stage {
  position: relative;
  z-index: 2;
  max-width: 1240px;
  margin: 4px auto 0;
  padding: 10px 24px 8px;
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(400px, 1.08fr);
  gap: 26px;
  align-items: stretch;
}

.letter {
  position: relative;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  box-shadow:
    0 1px 2px var(--shadow),
    0 14px 44px var(--shadow);
  transition: background 0.6s ease, border-color 0.4s ease;
}
.my-card  { background: var(--paper); }
.her-card { background: var(--paper-her); }

/* 内框（信纸双线框） */
.card-inner {
  position: relative;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 24px 30px 18px;
  display: flex;
  flex-direction: column;
}

.letter-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.letter-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }
.dim { color: var(--muted); }

.letter-to { display: flex; align-items: baseline; gap: 10px; }
.to-label { font-size: 12px; letter-spacing: 0.5em; color: var(--muted); }
.to-name { font-family: var(--font-kai); font-size: 21px; letter-spacing: 0.1em; }
.to-name em { font-style: normal; font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.22em; color: var(--muted); margin-left: 6px; }

.her-id { display: flex; align-items: center; gap: 12px; }
.her-seal { width: 42px; height: 42px; flex: none; filter: drop-shadow(0 2px 5px var(--shadow)); }
.her-name { display: flex; flex-direction: column; gap: 2px; }
.her-name .cn { font-family: var(--font-hand); font-size: 32px; line-height: 1.1; }
.her-name .en { font-size: 10px; letter-spacing: 0.34em; color: var(--muted); }

/* 我的信：输入区 */
#draft {
  flex: 1;
  min-height: 250px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 2;
  color: var(--ink);
  caret-color: var(--seal);
}
#draft::placeholder { color: var(--muted); opacity: 0.75; line-height: 2; }
#draft:focus { background: color-mix(in srgb, var(--ink) 3%, transparent); }

/* 信件底栏 */
.letter-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}
.foot-left { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); letter-spacing: 0.05em; }
.sep { opacity: 0.6; }
.foot-right { display: flex; align-items: center; gap: 8px; }

.ghostbtn {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
}
.ghostbtn:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.ghostbtn.sm { padding: 4px 10px; font-size: 12px; }

.sendbtn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--paper);
  background: var(--ink);
  border: none;
  border-radius: 3px;
  padding: 10px 20px 10px 14px;
  cursor: pointer;
  box-shadow: 0 3px 10px var(--shadow);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.sendbtn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 7px 20px var(--shadow); }
.sendbtn:active:not(:disabled) { transform: translateY(0); }
.sendbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.send-seal { width: 22px; height: 22px; display: block; color: var(--seal); }
.send-seal svg { width: 100%; height: 100%; display: block; }

/* 火漆印动画 */
.wax-seal {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 6;
  width: 112px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(2.1) rotate(14deg);
}
.wax-seal svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 14px var(--shadow)); }
.wax-seal.stamped { animation: stamp 0.75s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards; }
@keyframes stamp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(2.1) rotate(14deg); }
  55%  { opacity: 1; transform: translate(-50%, -50%) scale(0.95) rotate(-7deg); }
  75%  { transform: translate(-50%, -50%) scale(1.03) rotate(-4deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-5deg); }
}
.wax-seal.faded { opacity: 0; transition: opacity 0.7s ease 0.15s; }

/* 她的回信 */
.letter-body {
  flex: 1;
  font-family: var(--font-kai);
  font-size: 17.5px;
  line-height: 2.15;
  letter-spacing: 0.02em;
  color: var(--ink);
  overflow-y: auto;
  padding-right: 4px;
}
.letter-body p { margin: 0 0 1em; }
.letter-body p:last-child { margin-bottom: 0; }
.letter-body .sign {
  font-family: var(--font-hand);
  font-size: 23px;
  text-align: right;
  margin: 1.5em 0 0;
}
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  background: var(--ink);
  margin-left: 2px;
  vertical-align: -0.15em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 天气 / 心情 */
.weather-chip, .mood-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  letter-spacing: 0.06em;
  background: color-mix(in srgb, var(--paper) 60%, transparent);
}
.weather-chip i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.weather-chip.w-sunny i   { background: #d9a441; }
.weather-chip.w-cloudy i  { background: #9a9a92; }
.weather-chip.w-shower i  { background: #7d94b5; }
.weather-chip.w-rain i    { background: #5f7ba6; }
.mood-chip { border-style: dashed; }

/* 读信状态 + 琴键 */
.reading { margin-top: 14px; text-align: center; }
.reading span {
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--muted);
  animation: readingpulse 1.9s ease-in-out infinite;
}
@keyframes readingpulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.keys { display: flex; gap: 7px; align-items: flex-end; height: 40px; margin-top: 16px; }
.keys i {
  width: 11px;
  height: 14px;
  background: var(--line-strong);
  border-radius: 2px;
}
.keys.playing i { animation: keypulse 1.5s ease-in-out infinite; }
.keys.playing i:nth-child(2) { animation-delay: 0.12s; }
.keys.playing i:nth-child(3) { animation-delay: 0.24s; }
.keys.playing i:nth-child(4) { animation-delay: 0.36s; }
.keys.playing i:nth-child(5) { animation-delay: 0.48s; }
@keyframes keypulse {
  0%, 100% { height: 14px; opacity: 0.5; }
  50% { height: 36px; opacity: 1; }
}

/* 雨（她的信纸内） */
.rain-canvas {
  position: absolute;
  inset: 10px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
  display: none;
}
.rain-canvas.raining { display: block; }

/* ---------------- 飞行信封 ---------------- */

.envelope {
  position: fixed;
  width: 110px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 8px 18px var(--shadow));
}
.envelope.flying {
  opacity: 1;
  transition: transform 1.15s cubic-bezier(0.45, 0.05, 0.3, 1), opacity 1.15s cubic-bezier(0.45, 0.05, 0.3, 1);
}

/* ---------------- 存档抽屉 ---------------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(360px, 88vw);
  z-index: 40;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 44px var(--shadow);
  transform: translateX(105%);
  transition: transform 0.38s cubic-bezier(0.3, 0.8, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 20px 20px 16px;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.drawer-head h2 { font-size: 15px; font-weight: 600; letter-spacing: 0.2em; margin: 0; display: flex; gap: 12px; align-items: center; }
#history-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#history-list li {
  border-bottom: 1px dashed var(--line);
  padding: 12px 2px;
  cursor: pointer;
  transition: background 0.2s;
}
#history-list li:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.h-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); letter-spacing: 0.06em; margin-bottom: 5px; }
.h-txt { font-size: 13.5px; line-height: 1.75; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.h-act { margin-top: 6px; display: flex; gap: 8px; }
.history-empty { color: var(--muted); font-size: 13px; letter-spacing: 0.08em; text-align: center; margin-top: 40px; }

/* ---------------- 页脚 / 提示 ---------------- */

.footnote {
  position: relative;
  z-index: 2;
  max-width: 1240px;
  margin: 4px auto 26px;
  padding: 0 24px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translate(-50%, 16px);
  z-index: 60;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 10px 20px;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 8px 24px var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 抖动（空信提醒） */
.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ---------------- 系统设置抽屉与表单 ---------------- */

.settings-drawer {
  width: min(420px, 92vw);
}
.settings-body {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}
.cfg-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cfg-row {
  display: flex;
  gap: 10px;
}
.flex-1 { flex: 1; min-width: 0; }
.w-80 { width: 90px; }
.cfg-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.cfg-input {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.2s;
}
.cfg-input:focus {
  border-color: var(--seal);
}
.cfg-select {
  cursor: pointer;
  background-color: var(--paper);
}
.cfg-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.cfg-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}
.cfg-info-box {
  background: color-mix(in srgb, var(--line) 30%, transparent);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
}
.cfg-info-row {
  display: flex;
  justify-content: space-between;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cfg-info-k { color: var(--muted); flex: none; }
.cfg-info-v { color: var(--ink-soft); font-family: monospace; overflow: hidden; text-overflow: ellipsis; }
.cfg-tag {
  font-size: 10.5px;
  font-weight: normal;
  padding: 2px 7px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--seal) 15%, transparent);
  color: var(--seal);
}
.cfg-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.cfg-secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.full-width {
  width: 100%;
  justify-content: center;
}

/* ---------------- 长按按钮（重大决策 3 秒防误触） ---------------- */

.hold-btn {
  position: relative;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}
.hold-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--seal);
  opacity: 0.32;
  transition: width 0.06s linear;
  pointer-events: none;
}
.hold-label { position: relative; z-index: 1; }
.hold-btn.holding {
  border-color: var(--seal);
  transform: scale(0.98);
}
.hold-btn.holding .hold-progress {
  opacity: 0.45;
}
.text-danger { color: #b84334 !important; border-color: rgba(184, 67, 52, 0.4) !important; }
.text-danger:hover { border-color: #b84334 !important; }

/* ---------------- 抽屉与被删后悔处 ---------------- */

.drawer-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: normal;
  display: block;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.accent-link {
  color: var(--seal);
  border-color: var(--seal);
}
.regret-drawer {
  width: min(460px, 94vw);
}
.regret-filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}
.filter-tab {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 11.5px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--paper) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
}
.filter-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.filter-tab.active {
  background: var(--seal);
  color: var(--paper);
  border-color: var(--seal);
  font-weight: 500;
}
.regret-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.regret-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.regret-select-all input { accent-color: var(--seal); width: 14px; height: 14px; cursor: pointer; }
.regret-actions { display: flex; gap: 8px; }

.regret-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.regret-item {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--paper) 75%, transparent);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  transition: border-color 0.2s, background 0.2s;
}
.regret-item:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
}
.regret-item input[type="checkbox"] {
  accent-color: var(--seal);
  width: 15px;
  height: 15px;
  margin-top: 3px;
  cursor: pointer;
}
.regret-item-content { flex: 1; min-width: 0; }
.regret-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}
.regret-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  background: color-mix(in srgb, var(--seal) 16%, transparent);
  color: var(--seal);
}
.regret-user-txt {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 4px;
  font-weight: 500;
  word-break: break-word;
}
.regret-reply-txt {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  font-family: var(--font-kai);
  word-break: break-word;
}
.regret-single-btn {
  align-self: center;
  flex: none;
}

/* ---------------- 模态弹窗（密码验证） ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(14, 16, 22, 0.58);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 16px 44px var(--shadow);
  width: min(390px, 92vw);
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: modalpop 0.24s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
@keyframes modalpop {
  from { opacity: 0; transform: scale(0.93) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 14.5px; font-weight: 600; margin: 0; letter-spacing: 0.08em; color: var(--ink); }
.modal-body { display: flex; flex-direction: column; gap: 8px; }
.modal-tip { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; margin: 0; }
.modal-input { width: 100%; }
.modal-err { color: #b84334; font-size: 12px; margin: 2px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------------- 批量导入信件弹窗 ---------------- */

.import-card { width: min(560px, 94vw); }
.modal-tip code {
  background: color-mix(in srgb, var(--line) 40%, transparent);
  border-radius: 3px;
  padding: 0 3px;
  font-size: 11px;
}
.modal-textarea {
  width: 100%;
  min-height: 170px;
  max-height: 46vh;
  resize: vertical;
  font-size: 13px;
  line-height: 1.6;
}
.import-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.import-file-label { cursor: pointer; }
.import-status {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 2px 0 0;
  white-space: pre-wrap;
}
.import-status.error { color: #b84334; }
.import-verify {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 4px;
  background: color-mix(in srgb, var(--line) 18%, transparent);
}
.import-verify[hidden] { display: none; }
.import-verify .cfg-hint { flex: 1 1 220px; font-size: 12px; line-height: 1.5; }
.import-verify-actions { display: flex; gap: 8px; }
.cfg-mem-tools { justify-content: flex-start; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 980px) {
  .stage { grid-template-columns: 1fr; gap: 20px; padding: 8px 14px; }
  .letter { min-height: 460px; }
  .topbar { padding: 14px 14px 8px; }
  .footnote { padding: 0 14px; }
  .her-name .cn { font-size: 28px; }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px 6px;
    gap: 10px;
  }
  .brand { gap: 8px; }
  .brand-seal { width: 30px; height: 30px; }
  .brand-name { font-size: 11px; letter-spacing: 0.2em; }
  .brand-sub { font-size: 10px; letter-spacing: 0.08em; }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .pill {
    padding: 4px 9px;
    font-size: 11px;
    gap: 5px;
  }
  .switch {
    font-size: 11px;
    gap: 4px;
  }
  .iconbtn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .stage {
    padding: 6px 10px;
    gap: 14px;
  }
  .letter {
    min-height: 400px;
    padding: 6px;
  }
  .card-inner {
    padding: 16px 14px 12px;
  }

  .letter-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 12px;
  }
  .letter-to { gap: 6px; }
  .to-name { font-size: 18px; }
  .letter-meta {
    font-size: 11px;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
  }

  .her-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .her-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }

  #draft {
    min-height: 180px;
    font-size: 14px;
    line-height: 1.8;
  }
  .letter-body {
    font-size: 16px;
    line-height: 1.95;
  }

  .letter-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 10px;
  }
  .foot-left {
    justify-content: space-between;
    width: 100%;
  }
  .foot-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }
  .foot-right .ghostbtn {
    flex: 1;
    min-width: 50px;
    padding: 6px 8px;
    font-size: 12px;
    text-align: center;
  }
  .foot-right .sendbtn {
    flex: 2;
    min-width: 110px;
    padding: 8px 12px;
    font-size: 13px;
    justify-content: center;
  }

  .drawer, .settings-drawer, .regret-drawer {
    width: 100vw;
    max-width: 100vw;
    padding: 16px 14px 12px;
  }
  .cfg-row {
    flex-direction: column;
    gap: 8px;
  }
  .w-80 {
    width: 100%;
  }
  .cfg-secondary-actions {
    flex-direction: column;
    gap: 8px;
  }
  .cfg-secondary-actions button {
    width: 100%;
    text-align: center;
  }
  .regret-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .regret-item {
    padding: 8px 10px;
    gap: 8px;
  }

  .modal-card {
    width: min(340px, 94vw);
    padding: 18px 14px 14px;
  }

  .footnote {
    padding: 0 10px;
    font-size: 10.5px;
    text-align: center;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 8px auto 20px;
  }
}

/* ---------------- 打印：只留她的信 ---------------- */

@media print {
  body { background: #fff; }
  body::before, #bokeh, .topbar, .my-card, .footnote, .drawer, #envelope, .toast, .rain-canvas { display: none !important; }
  .stage { display: block; padding: 0; max-width: none; }
  .her-card { box-shadow: none; border: none; min-height: 0; }
  .card-inner { border: none; padding: 0; }
  .letter-body { font-family: "Kaiti SC", "KaiTi", serif; font-size: 16px; }
}

/* ---------------- 减少动态 ---------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
