/* ============================================================
   单用户模拟聊天 App · 样式表（第五阶段）
   低饱和奶油猫咪风 / 宋体 / 移动端优先
   ============================================================ */

/* ------------------------------------------------------------
   1. 主题变量
   ---------------------------------------------------------- */
:root {
  --bg: #fbf1ee;
  --bg-glow: rgba(226, 173, 165, 0.30);
  --surface: #fffcf9;
  --surface-2: #f4e6e1;
  --line: rgba(120, 90, 85, 0.12);

  --text: #4a3f3c;
  --text-dim: #9c8a85;

  --bubble-me-bg: #dba7a0;
  --bubble-me-text: #4a3230;
  --bubble-them-bg: #e6dac3;
  --bubble-them-text: #4a4034;
  --bubble-shadow: 0 2px 6px rgba(150, 110, 100, 0.14);

  --send-bg: #bc8680;
  --send-ink: #fff9f7;

  --cat-ink: #b78a80;

  --warn: #c8925f;
  --danger: #a1554d;

  --icon-shadow: 0 8px 18px rgba(180, 140, 132, 0.20),
                 0 1px 2px rgba(180, 140, 132, 0.14);
  --nav-bg: rgba(255, 250, 248, 0.82);
  --composer-bg: #fbf2ef;
  --toast-bg: rgba(74, 63, 60, 0.92);
  --toast-text: #fbf1ee;

  color-scheme: light;
}

html[data-theme='dark'] {
  --bg: #1e1919;
  --bg-glow: rgba(150, 100, 95, 0.22);
  --surface: #2a2424;
  --surface-2: #332b2b;
  --line: rgba(255, 235, 230, 0.10);

  --text: #ede0db;
  --text-dim: #a08f8a;

  --bubble-me-bg: #7b4a47;
  --bubble-me-text: #f7e9e5;
  --bubble-them-bg: #4a4133;
  --bubble-them-text: #efe6d7;
  --bubble-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

  --send-bg: #96564f;
  --send-ink: #f8eae6;

  --cat-ink: #c1948a;

  --warn: #b98a5e;
  --danger: #b5675f;

  --icon-shadow: 0 8px 18px rgba(0, 0, 0, 0.50),
                 0 0 0 1px rgba(255, 235, 230, 0.06);
  --nav-bg: rgba(30, 25, 25, 0.86);
  --composer-bg: #221c1c;
  --toast-bg: rgba(240, 228, 224, 0.94);
  --toast-text: #2a2222;

  color-scheme: dark;
}

/* ------------------------------------------------------------
   2. 基础重置
   ---------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "SimSun", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button,
input,
textarea,
label {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------
   3. 屏幕容器
   ---------------------------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.26s ease,
              transform 0.26s cubic-bezier(0.22, 0.8, 0.3, 1),
              visibility 0.26s;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.screen--home {
  transform: translateX(-12%);
}

.screen--chat,
.screen--page {
  transform: translateX(100%);
  background-image: radial-gradient(circle at 50% 0%, var(--bg-glow), transparent 42%);
}

/* ------------------------------------------------------------
   4. 桌面：主题切换
   ---------------------------------------------------------- */
.theme-toggle {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: var(--icon-shadow);
  transition: transform 0.15s ease, background-color 0.3s ease;
  z-index: 3;
}

.theme-toggle:active {
  transform: scale(0.9);
}

.theme-toggle__icon {
  width: 20px;
  height: 20px;
  display: none;
}

html[data-theme-mode='auto'] .theme-toggle__icon--auto,
html[data-theme-mode='light'] .theme-toggle__icon--light,
html[data-theme-mode='dark'] .theme-toggle__icon--dark {
  display: block;
}

/* ------------------------------------------------------------
   5. 桌面：双人信息区（放大居中版）
   ---------------------------------------------------------- */
.screen--home::before {
  content: "";
  position: absolute;
  top: -12%;
  left: 50%;
  width: 140%;
  height: 55%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, var(--bg-glow), transparent 68%);
  pointer-events: none;
  z-index: 0;
}

.screen--home::after {
  content: "";
  position: absolute;
  right: -22px;
  bottom: 3%;
  width: 150px;
  height: 150px;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 22% 34%, var(--cat-ink) 11px, transparent 12px),
    radial-gradient(circle at 41% 15%, var(--cat-ink) 11px, transparent 12px),
    radial-gradient(circle at 61% 15%, var(--cat-ink) 11px, transparent 12px),
    radial-gradient(circle at 80% 34%, var(--cat-ink) 11px, transparent 12px),
    radial-gradient(circle at 51% 70%, var(--cat-ink) 30px, transparent 32px);
}

.home-top {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(58px + env(safe-area-inset-top)) 20px 22px;
  text-align: center;
}

.home-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.pair-mark {
  font-size: 24px;
  line-height: 1;
  color: var(--send-bg);
  opacity: 0.9;
  transform: translateY(-3px);
}

.home-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.home-clock__date {
  font-size: 13px;
  letter-spacing: 0.20em;
  text-indent: 0.20em;
  color: var(--text-dim);
}

.home-clock__time {
  display: inline-flex;
  align-items: baseline;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.home-clock__sec {
  margin-left: 4px;
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

/* ------------------------------------------------------------
   6. 桌面：图标阵列
   ---------------------------------------------------------- */
.home-grid {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 16px;
  align-content: start;
  padding: 8px 20px 32px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.app-icon__glyph {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 26%;
  color: #4a3f3c;
  display: grid;
  place-items: center;
  box-shadow: var(--icon-shadow);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.3, 1),
              background 0.3s ease;
}

.app-icon__glyph svg {
  width: 52%;
  height: 52%;
}

.app-icon:active .app-icon__glyph {
  transform: scale(0.9);
}

.app-icon__name {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text);
  white-space: nowrap;
}

.app-icon[data-app='chat'] .app-icon__glyph {
  background: linear-gradient(160deg, #fff6f3, #f0dcd6);
}

.app-icon[data-app='mailbox'] .app-icon__glyph {
  background: linear-gradient(160deg, #fffaf5, #f2e3d6);
}

.app-icon[data-app='diary'] .app-icon__glyph {
  background: linear-gradient(160deg, #fdf7f6, #ecdfdc);
}

.app-icon[data-app='replies'] .app-icon__glyph {
  background: linear-gradient(160deg, #fffbf3, #eee2cd);
}

.app-icon[data-app='settings'] .app-icon__glyph {
  background: linear-gradient(160deg, #fdf9f7, #eae1dd);
}

html[data-theme='dark'] .app-icon__glyph {
  color: #efe2dd;
}

html[data-theme='dark'] .app-icon[data-app='chat'] .app-icon__glyph {
  background: linear-gradient(160deg, #342b2a, #2a2222);
}

html[data-theme='dark'] .app-icon[data-app='mailbox'] .app-icon__glyph {
  background: linear-gradient(160deg, #342e29, #28221e);
}

html[data-theme='dark'] .app-icon[data-app='diary'] .app-icon__glyph {
  background: linear-gradient(160deg, #322b2b, #272121);
}

html[data-theme='dark'] .app-icon[data-app='replies'] .app-icon__glyph {
  background: linear-gradient(160deg, #33302a, #262220);
}

html[data-theme='dark'] .app-icon[data-app='settings'] .app-icon__glyph {
  background: linear-gradient(160deg, #302b2b, #241f1f);
}

.app-icon[data-app='chat'] .app-icon__glyph::after {
  content: "ᓚᘏᗢ";
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 9px;
  line-height: 1;
  color: var(--cat-ink);
  opacity: 0.8;
  pointer-events: none;
}

/* ------------------------------------------------------------
   7. 通用：头像
   ---------------------------------------------------------- */
.avatar {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bubble-them-bg);
  border: 1px solid var(--line);
}

.avatar--sm {
  width: 30px;
  height: 30px;
}

.avatar--md {
  width: 84px;
  height: 84px;
  box-shadow: var(--bubble-shadow);
}

.avatar--lg {
  width: 72px;
  height: 72px;
}

.avatar__fallback {
  width: 58%;
  height: 58%;
  color: var(--cat-ink);
}

.avatar__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ------------------------------------------------------------
   8. 通用：导航 / 滚动区 / 底栏 / Tabs
   ---------------------------------------------------------- */
.chat-nav,
.page-nav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  transition: background-color 0.18s ease, transform 0.12s ease;
}

.nav-btn svg {
  width: 21px;
  height: 21px;
}

.nav-btn:active {
  background: var(--surface-2);
  transform: scale(0.94);
}

.nav-btn--spacer {
  pointer-events: none;
}

.chat-nav__id {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.chat-nav__title,
.page-nav__title {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.10em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-nav__title {
  min-width: 0;
}

.page-nav__title {
  flex: 1;
  text-align: center;
  letter-spacing: 0.12em;
}

.page-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

.page-footer {
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--composer-bg);
  border-top: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px 2px;
}

.tab {
  flex: 1;
  height: 34px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.10em;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.tab.is-active {
  background: var(--send-bg);
  color: var(--send-ink);
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

/* ------------------------------------------------------------
   9. 分类胶囊条（▼ 新增）
   ---------------------------------------------------------- */
.chip-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 2px 0 14px;
  scrollbar-width: none;
}

.chip-bar::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.12s ease;
}

.chip:active {
  transform: scale(0.96);
}

.chip.is-active {
  background: var(--send-bg);
  color: var(--send-ink);
  border-color: transparent;
}

.chip__count {
  font-size: 11px;
  opacity: 0.65;
}

.chip--add {
  border-style: dashed;
  color: var(--text-dim);
  background: transparent;
}

/* ------------------------------------------------------------
   10. 聊天：消息区
   ---------------------------------------------------------- */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px 14px;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-list:empty {
  display: none;
}

.msg {
  display: flex;
  animation: bubble-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.msg--me {
  justify-content: flex-end;
}

.msg--them {
  justify-content: flex-start;
  gap: 6px;
}

.msg--them::before {
  content: "";
  flex: 0 0 auto;
  align-self: flex-end;
  width: 15px;
  height: 15px;
  margin-bottom: 19px;
  opacity: 0.55;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 22% 36%, var(--cat-ink) 1.5px, transparent 1.8px),
    radial-gradient(circle at 41% 18%, var(--cat-ink) 1.5px, transparent 1.8px),
    radial-gradient(circle at 61% 18%, var(--cat-ink) 1.5px, transparent 1.8px),
    radial-gradient(circle at 80% 36%, var(--cat-ink) 1.5px, transparent 1.8px),
    radial-gradient(circle at 51% 70%, var(--cat-ink) 4.2px, transparent 4.5px);
}

.msg__body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 74%;
  min-width: 0;
}

.msg--me .msg__body {
  align-items: flex-end;
}

.msg--them .msg__body {
  align-items: flex-start;
  max-width: calc(74% - 21px);
}

.msg__time {
  padding: 0 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

html[data-show-time='false'] .msg__time {
  display: none;
}

html[data-show-time='false'] .msg--them::before {
  margin-bottom: 4px;
}

.bubble {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  transition: opacity 0.2s ease;
}

.msg--me .bubble {
  background: var(--bubble-me-bg);
  color: var(--bubble-me-text);
  border-bottom-right-radius: 6px;
  cursor: pointer;
  box-shadow: var(--bubble-shadow);
}

.msg--them .bubble {
  background: var(--bubble-them-bg);
  color: var(--bubble-them-text);
  border-bottom-left-radius: 6px;
  box-shadow: var(--bubble-shadow);
}

.msg--me:active .bubble {
  opacity: 0.62;
}

.msg--removing {
  animation: bubble-out 0.17s ease forwards;
}

.bubble--image {
  padding: 6px;
  background: var(--surface) !important;
  border: 1px solid var(--line);
  overflow: hidden;
}

.bubble--image img {
  display: block;
  width: 100%;
  max-width: 168px;
  height: auto;
  border-radius: 12px;
  object-fit: cover;
}

.bubble--quiz {
  padding: 12px 14px;
  border-radius: 16px;
  white-space: normal;
}

.bubble__tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.12em;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid var(--line);
  color: inherit;
  opacity: 0.85;
}

html[data-theme='dark'] .bubble__tag {
  background: rgba(255, 255, 255, 0.08);
}

.bubble__title {
  margin: 8px 0 2px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.bubble__text {
  margin: 6px 0 0;
  white-space: pre-wrap;
  line-height: 1.7;
}

.bubble__question {
  margin: 8px 0 0;
  line-height: 1.6;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
}

.quiz-options__item {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid var(--line);
  line-height: 1.4;
}

html[data-theme='dark'] .quiz-options__item {
  background: rgba(255, 255, 255, 0.07);
}

.quiz-options__item.is-chosen {
  background: var(--bubble-me-bg);
  color: var(--bubble-me-text);
  border-color: transparent;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes bubble-out {
  to { opacity: 0; transform: scale(0.9) translateY(-2px); }
}

/* ------------------------------------------------------------
   11. 聊天：正在输入
   ---------------------------------------------------------- */
.typing {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: var(--bubble-them-bg);
  box-shadow: var(--bubble-shadow);
  color: var(--bubble-them-text);
  font-size: 13px;
  letter-spacing: 0.06em;
  opacity: 0.92;
  animation: bubble-in 0.2s ease both;
}

.typing::before {
  content: "";
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  opacity: 0.6;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(circle at 22% 36%, var(--cat-ink) 1.2px, transparent 1.5px),
    radial-gradient(circle at 41% 18%, var(--cat-ink) 1.2px, transparent 1.5px),
    radial-gradient(circle at 61% 18%, var(--cat-ink) 1.2px, transparent 1.5px),
    radial-gradient(circle at 80% 36%, var(--cat-ink) 1.2px, transparent 1.5px),
    radial-gradient(circle at 51% 70%, var(--cat-ink) 3.4px, transparent 3.7px);
}

.typing__dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 8px;
}

.typing__dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  animation: typing-blink 1.2s infinite ease-in-out;
}

.typing__dots i:nth-child(2) { animation-delay: 0.2s; }
.typing__dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-blink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* ------------------------------------------------------------
   12. 聊天：Emoji / 表情包面板
   ---------------------------------------------------------- */
.chat-panel {
  flex: 0 0 auto;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 14px;
  background: var(--composer-bg);
  border-top: 1px solid var(--line);
  animation: panel-up 0.2s ease both;
}

@keyframes panel-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.emoji-cell {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.emoji-cell:active {
  background: var(--surface-2);
  transform: scale(0.9);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.sticker-grid:empty {
  display: none;
}

.sticker-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform 0.12s ease;
}

.sticker-cell:active {
  transform: scale(0.94);
}

.sticker-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sticker-cell__del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  color: var(--text);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

html[data-theme='dark'] .sticker-cell__del {
  background: rgba(30, 30, 30, 0.82);
  color: #f0e6e2;
}

/* ------------------------------------------------------------
   13. 聊天：底部输入区
   ---------------------------------------------------------- */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--composer-bg);
  border-top: 1px solid var(--line);
}

.composer__tool {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  transition: background-color 0.18s ease, color 0.18s ease,
              transform 0.12s ease;
}

.composer__tool svg {
  width: 19px;
  height: 19px;
}

.composer__tool:active,
.composer__tool.is-active {
  background: var(--surface-2);
  color: var(--text);
  transform: scale(0.94);
}

.composer__input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease, background-color 0.3s ease,
              box-shadow 0.2s ease;
}

.composer__input::placeholder {
  color: var(--text-dim);
}

.composer__input:focus {
  border-color: var(--send-bg);
  box-shadow: 0 0 0 3px rgba(188, 134, 128, 0.12);
}

.composer__send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--send-bg);
  color: var(--send-ink);
  transition: transform 0.12s ease, background-color 0.2s ease,
              color 0.2s ease, opacity 0.2s ease;
}

.composer__send svg {
  width: 19px;
  height: 19px;
}

.composer__send:active {
  transform: scale(0.92);
}

.composer__send.is-disabled {
  background: var(--surface-2);
  color: var(--text-dim);
  opacity: 0.9;
  box-shadow: none;
}

/* ------------------------------------------------------------
   14. 信箱列表
   ---------------------------------------------------------- */
.mail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mail-list:empty {
  display: none;
}

.mail {
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--bubble-shadow);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease;
}

.mail:active {
  transform: scale(0.985);
  background: var(--surface-2);
}

.mail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mail__badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.10em;
  line-height: 1.5;
}

.mail__badge--out {
  background: var(--bubble-me-bg);
  color: var(--bubble-me-text);
}

.mail__badge--in {
  background: var(--bubble-them-bg);
  color: var(--bubble-them-text);
}

.mail__time {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.mail__title {
  margin: 9px 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.45;
  word-break: break-word;
}

.mail__preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  word-break: break-word;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ------------------------------------------------------------
   15. 日记时间轴
   ---------------------------------------------------------- */
.diary-list {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0 0 0 16px;
  list-style: none;
}

.diary-list:empty {
  display: none;
}

.diary-list::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 3px;
  width: 1px;
  background: var(--line);
}

.diary {
  position: relative;
  padding: 13px 15px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--bubble-shadow);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease;
}

.diary:active {
  transform: scale(0.985);
  background: var(--surface-2);
}

.diary::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -17px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bubble-them-bg);
  border: 1px solid var(--line);
}

.diary--me::before {
  background: var(--bubble-me-bg);
}

.diary__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diary__badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.10em;
  line-height: 1.5;
}

.diary--me .diary__badge {
  background: var(--bubble-me-bg);
  color: var(--bubble-me-text);
}

.diary--them .diary__badge {
  background: var(--bubble-them-bg);
  color: var(--bubble-them-text);
}

.diary__time {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.diary__title {
  margin: 9px 0 4px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.45;
  word-break: break-word;
}

.diary__preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-dim);
  word-break: break-word;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ------------------------------------------------------------
   16. 表单组件
   ---------------------------------------------------------- */
.section {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.section__count {
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.avatar-preview {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field__label {
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.field__input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field__input:focus {
  border-color: var(--send-bg);
  box-shadow: 0 0 0 3px rgba(188, 134, 128, 0.12);
}

.field__input::placeholder {
  color: var(--text-dim);
}

.field__textarea {
  height: auto;
  min-height: 108px;
  padding: 12px 14px;
  line-height: 1.7;
  resize: vertical;
}

.field__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field__row .field__input {
  flex: 1;
  min-width: 0;
}

.field__sep {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 15px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.2s ease,
              opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--send-bg);
  color: var(--send-ink);
}

.btn--ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn--block {
  width: 100%;
}

.btn--sm {
  height: 38px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: 12px;
}

.section .btn--block {
  margin-top: 12px;
}

/* ▼ 新增：并排按钮行 */
.row-btns {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.row-btns .btn {
  flex: 1;
  min-width: 0;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 18px;
}

.switch-row__label {
  font-size: 15px;
  letter-spacing: 0.06em;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background-color 0.22s ease;
}

.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(60, 40, 38, 0.22);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.switch.is-on {
  background: var(--send-bg);
  border-color: transparent;
}

.switch.is-on .switch__knob {
  transform: translateX(20px);
}

/* ------------------------------------------------------------
   17. 存储空间进度条
   ---------------------------------------------------------- */
.storage {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.storage__bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.storage__fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--send-bg);
  transition: width 0.35s ease, background-color 0.3s ease;
}

.storage__fill.is-warn {
  background: var(--warn);
}

.storage__fill.is-danger {
  background: var(--danger);
}

.storage__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.storage__limit {
  color: var(--text-dim);
  opacity: 0.75;
}

/* ------------------------------------------------------------
   18. 字卡列表（▼ 重构：分类 + 屏蔽开关）
   ---------------------------------------------------------- */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface-2);
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.card--blocked {
  opacity: 0.45;
}

.card__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.card__cat {
  align-self: flex-start;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__ops {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 1px;
}

.card__del {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.card__del:active {
  background: var(--surface);
  color: var(--text);
}

/* 屏蔽小开关 */
.mini-switch {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 0.22s ease, border-color 0.22s ease;
}

.mini-switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.5;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1),
              background-color 0.22s ease, opacity 0.22s ease;
}

.mini-switch.is-on {
  background: var(--danger);
  border-color: transparent;
}

.mini-switch.is-on .mini-switch__knob {
  transform: translateX(14px);
  background: #fff9f7;
  opacity: 0.95;
}

.empty {
  margin: 0;
  padding: 18px 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* ------------------------------------------------------------
   19. 弹窗
   ---------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(46, 34, 33, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: backdrop-in 0.2s ease both;
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  overflow: hidden;
  animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.modal__title {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.12em;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: var(--text-dim);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.modal__close:active {
  background: var(--surface-2);
  color: var(--text);
}

.modal__body {
  padding: 4px 18px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal__body .field:last-child {
  margin-bottom: 4px;
}

.modal__foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  background: var(--composer-bg);
  border-top: 1px solid var(--line);
}

.modal__foot .btn {
  flex: 1;
}

.modal.is-reading .field__input {
  background: transparent;
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
  box-shadow: none;
  cursor: default;
}

.modal.is-reading .field__input:focus {
  border-color: transparent;
  box-shadow: none;
}

.modal.is-reading .field__textarea {
  resize: none;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-row .field__input {
  flex: 1;
  min-width: 0;
}

.option-row__del {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.option-row__del:active {
  background: var(--surface-2);
  color: var(--text);
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------
   20. 轻提示
   ---------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 20px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 13px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------
   21. 大屏适配 & 减少动效
   ---------------------------------------------------------- */
@media (min-width: 560px) {
  .screen {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .theme-toggle {
    right: calc(50% - 240px + 18px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}