/*
  fyf520 · Claude 手写花体笔记风
  ---------------------------------
  调性：米色羊皮纸 + 暖棕墨色 + 手写衬线，像一本写满字的笔记本。
*/

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Ma+Shan+Zheng&family=Crimson+Pro:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Kalam:wght@300;400;700&display=swap');

:root {
  color-scheme: light;
  /* 纸张 — 信笺淡米 */
  --bg: #fbf8ef;
  --paper: #fffdf6;
  --paper-strong: #f7f0dd;
  --ruled: rgba(120, 70, 30, 0.05);
  /* 墨水 — 温和暖棕 */
  --ink: #3b2c1d;
  --ink-soft: #6a543b;
  --ink-faint: #aa9573;
  --line: rgba(80, 50, 20, 0.12);
  --line-soft: rgba(80, 50, 20, 0.06);
  --line-strong: rgba(80, 50, 20, 0.22);
  /* 颜料 — 朱砂调淡 */
  --accent: #c97a48;
  --accent-deep: #a85a2d;
  --warm: #cfa15a;
  --leaf: #7a9362;
  --blue: #4d7596;
  --rose: #c47683;

  /* 信笺纸阴影：贴近平面，几乎不漂浮 */
  --shadow-paper: 0 1px 0 rgba(255,255,255,0.6) inset,
                  0 1px 2px rgba(80,40,10,0.04),
                  0 14px 28px -20px rgba(80,40,10,0.18);
  --shadow-paper-hover: 0 1px 0 rgba(255,255,255,0.6) inset,
                        0 1px 2px rgba(80,40,10,0.06),
                        0 18px 34px -22px rgba(80,40,10,0.22);

  --font-hand: 'Caveat', 'Ma Shan Zheng', 'STKaiti', '楷体', 'KaiTi', cursive;
  --font-serif: 'Crimson Pro', 'Ma Shan Zheng', 'STKaiti', 'Georgia', '楷体', serif;
  --font-note: 'Kalam', 'Ma Shan Zheng', 'STKaiti', 'Georgia', cursive;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  background:
    radial-gradient(circle at 14% 12%, rgba(207, 161, 90, 0.07), transparent 42%),
    radial-gradient(circle at 86% 18%, rgba(201, 122, 72, 0.04), transparent 38%),
    linear-gradient(180deg, #fbf8ef 0%, #f7f1e0 100%);
}

/* 纸张纹理（弱化）+ 极淡横线 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg,
      transparent 0 36px,
      var(--ruled) 36px 37px);
  mix-blend-mode: multiply;
  opacity: 0.5;
  z-index: 0;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center,
      transparent 72%,
      rgba(120, 70, 20, 0.04) 100%);
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

/* —— topnav —— */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  background: rgba(252, 247, 232, 0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-hand);
}

.topnav .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.topnav .brand img {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,0.06));
}

.topnav .brand span {
  font-family: var(--font-hand);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.topnav .menu {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.topnav .menu a,
.topnav .menu button {
  padding: 4px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  font: inherit;
  font-family: var(--font-hand);
  font-size: 1.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.topnav .menu a:hover,
.topnav .menu button:hover {
  color: var(--accent-deep);
  background: rgba(192, 139, 58, 0.12);
}

.topnav .menu a.active {
  color: var(--accent-deep);
  border-color: var(--line);
  background: rgba(192, 139, 58, 0.16);
}

/* —— 容器 —— */
.shell {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

/* —— Hero（首页大标题） —— */
.hero {
  padding: 24px 0 28px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: end;
}

.headline {
  max-width: 760px;
}

.kicker,
.eyebrow {
  font-family: var(--font-hand);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.headline h2 {
  margin: 6px 0 0;
  font-family: var(--font-hand);
  font-size: clamp(3rem, 6.5vw, 5.6rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  word-break: keep-all;     /* 中文不在词间断字 */
  overflow-wrap: break-word;
  /* 手稿下划线点缀 */
  position: relative;
}

.headline h2::after {
  content: "";
  display: block;
  width: 92px;
  height: 14px;
  margin-top: 8px;
  background:
    radial-gradient(circle at 8px 6px, var(--accent) 2px, transparent 3px),
    radial-gradient(circle at 24px 8px, var(--warm) 2px, transparent 3px),
    radial-gradient(circle at 40px 6px, var(--leaf) 2px, transparent 3px),
    radial-gradient(circle at 56px 8px, var(--blue) 2px, transparent 3px),
    radial-gradient(circle at 72px 6px, var(--rose) 2px, transparent 3px);
}

.lead {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: clamp(1rem, 1.2vw, 1.15rem);
  line-height: 1.7;
  max-width: 620px;
}

.actions {
  display: grid;
  gap: 10px;
}

.actions a {
  min-height: 48px;
  padding: 10px 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 1.2rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-paper);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.actions a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-paper-hover);
  background: var(--paper-strong);
}

.actions .primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff8e8;
  border-color: rgba(120, 60, 25, 0.35);
}

.actions .primary:hover {
  filter: brightness(1.04);
}

/* —— 卡片网格 —— */
.card-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 40px;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-paper);
}

/* 信纸折角 — 极淡 */
.card::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, transparent 50%, rgba(80, 50, 20, 0.06) 50%);
  border-radius: 0 0 6px 0;
  pointer-events: none;
}

.card h3 {
  margin: 0 0 8px;
  font-family: var(--font-hand);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.card p {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.65;
}

.card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-paper-hover);
}

/* —— 表单 —— */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
}

.form-row label {
  color: var(--accent-deep);
  font-family: var(--font-hand);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="url"],
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1rem;
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(177, 90, 43, 0.18);
}

.form-row textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, 'Crimson Pro', 'Ma Shan Zheng', monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.form-row .hint {
  color: var(--ink-faint);
  font-size: 0.86rem;
  font-style: italic;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-paper);
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

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

.btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(80,40,10,0.06);
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff8e8;
  border-color: rgba(120, 60, 25, 0.35);
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.danger {
  background: rgba(196, 118, 131, 0.12);
  border-color: rgba(180, 90, 105, 0.45);
  color: #a8536a;
}

.btn.danger:hover {
  background: rgba(196, 118, 131, 0.22);
}

.notice {
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: var(--font-serif);
}

.notice.warn  { background: rgba(192, 139, 58, 0.16); border-color: var(--warm); color: var(--accent-deep); }
.notice.error { background: rgba(182, 83, 95, 0.14); border-color: var(--rose); color: var(--rose); }
.notice.ok    { background: rgba(93, 122, 69, 0.14); border-color: var(--leaf); color: var(--leaf); }

/* ============================================================
 * chat 布局：左侧"信件夹"书签条 + 右侧聊天信纸铺开
 * sidebar 默认折叠成 36px 宽彩色书签条，悬停/点击展开 280px。
 * 视口高度严格用 dvh，避免下方留白。
 * ============================================================ */

.chat-layout {
  --sidebar-w: 36px;
  --sidebar-w-open: 268px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 12px;
  max-width: 1100px;
  margin: 10px auto 0;
  height: calc(100dvh - 80px);
  min-height: 460px;
  transition: grid-template-columns 220ms ease;
}

.chat-layout.expanded {
  grid-template-columns: var(--sidebar-w-open) 1fr;
}

/* 未登录：隐 sidebar，chat 占满 */
.chat-layout.guest {
  grid-template-columns: 1fr;
  gap: 0;
}
.chat-layout.guest .chat-sidebar { display: none; }
.chat-layout.guest .chat-wrap {
  grid-column: 1;
  width: 100%;
}

/* ---------- sidebar：信件夹 ---------- */
.chat-sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
  overflow: visible;
}

/* 折叠态：只露书签条；其余 UI 隐藏 */
.chat-sidebar .sidebar-head,
.chat-sidebar .session-list-full {
  display: none;
}

.chat-sidebar .bookmark-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  height: 100%;
  overflow-y: auto;
}

/* 展开态：隐藏书签条，露完整列表 */
.chat-layout.expanded .chat-sidebar .bookmark-rail { display: none; }
.chat-layout.expanded .chat-sidebar .sidebar-head { display: flex; }
.chat-layout.expanded .chat-sidebar .session-list-full { display: flex; }
.chat-layout.expanded .chat-sidebar {
  background: linear-gradient(180deg, #fbf5e1 0%, #f6ecd0 100%);
  border-radius: 14px;
  box-shadow: var(--shadow-paper);
  border: 1px solid var(--line);
  overflow: hidden;
}

/* —— 折叠态：每条 session 一个垂直书签 —— */
.bookmark-rail .bookmark {
  position: relative;
  flex: 0 0 auto;
  height: 64px;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(80, 50, 20, 0.78);
  font-family: var(--font-hand);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transition: transform 160ms ease, filter 160ms ease;
  text-shadow: 0 1px 0 rgba(255, 250, 235, 0.6);
  box-shadow: 1px 1px 2px rgba(80, 40, 10, 0.1);
  padding: 8px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid rgba(80, 40, 10, 0.10);
  border-left: none;
}

.bookmark-rail .bookmark::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--bg);
  transform: translateY(-50%);
}

.bookmark-rail .bookmark.active {
  transform: translateX(2px);
  box-shadow: 2px 2px 3px rgba(80, 40, 10, 0.22);
}

.bookmark-rail .bookmark:hover {
  transform: translateX(3px);
}

.bookmark-rail .bookmark .seq {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  opacity: 0.75;
  writing-mode: horizontal-tb;
}

/* + 新建按钮（折叠态） */
.bookmark-rail .bookmark-new {
  background: rgba(255, 252, 240, 0.7);
  color: var(--ink-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  height: 40px;
  margin: 4px 4px 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hand);
  font-size: 1.1rem;
  text-shadow: none;
  box-shadow: none;
}

.bookmark-rail .bookmark-new:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

/* 5 色书签 — 浅色 pastel，配深棕字。低饱和、不抢戏。 */
.tint-1 { background: linear-gradient(135deg, #fbe2cd 0%, #ecbf95 100%); }   /* 浅朱砂 */
.tint-2 { background: linear-gradient(135deg, #faecc5 0%, #e6cf90 100%); }   /* 浅暖金 */
.tint-3 { background: linear-gradient(135deg, #dfe9cd 0%, #b9cea0 100%); }   /* 浅草绿 */
.tint-4 { background: linear-gradient(135deg, #d8e3ed 0%, #b0c5d6 100%); }   /* 浅钢蓝 */
.tint-5 { background: linear-gradient(135deg, #f3d4d8 0%, #dfaab2 100%); }   /* 浅玫瑰 */

/* ---------- 展开态 sidebar 内部 ---------- */
.chat-sidebar .sidebar-head {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px dashed var(--line-strong);
  background: rgba(255, 252, 240, 0.55);
}

.chat-sidebar .sidebar-head h3 {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.35rem;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.chat-sidebar .sidebar-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.chat-sidebar .new-btn,
.chat-sidebar .fold-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(120, 60, 25, 0.35);
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff8e8;
  font-family: var(--font-hand);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(120,60,25,0.18);
}

.chat-sidebar .fold-btn {
  background: rgba(255, 252, 240, 0.7);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

.chat-sidebar .new-btn:hover,
.chat-sidebar .fold-btn:hover { filter: brightness(1.05); }

.session-list-full {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* —— session 完整条：左色带 + 标题 + 预览 —— */
.session-tab {
  position: relative;
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  padding: 9px 10px 9px 0;
  border-radius: 8px;
  background: rgba(255, 253, 244, 0.86);
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
  border: 1px solid transparent;
}

.session-tab::before {
  content: "";
  display: block;
  width: 6px;
  border-radius: 4px;
  margin: 2px 0 2px 4px;
  background: var(--tab-color, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

.session-tab:hover { background: rgba(255, 252, 232, 1); transform: translateX(1px); }

.session-tab.active {
  background: #fffaea;
  border-color: rgba(180, 140, 70, 0.35);
  box-shadow: 0 1px 2px rgba(80,40,10,0.08);
}

.session-tab .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 8px;
}

.session-tab .row-1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.session-tab .title {
  font-family: var(--font-hand);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.session-tab .date {
  font-family: var(--font-hand);
  font-size: 0.78rem;
  color: var(--ink-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.session-tab .preview {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  margin-top: 1px;
}

.session-tab .actions {
  display: none;
  position: absolute;
  top: 6px;
  right: 8px;
  gap: 4px;
}

.session-tab:hover .actions,
.session-tab.active .actions { display: flex; }

.session-tab .actions button {
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 240, 0.95);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.session-tab .actions button:hover {
  color: var(--accent-deep);
  border-color: var(--accent);
}

/* 移动端 */
.sidebar-toggle {
  display: none;
}

@media (max-width: 760px) {
  .chat-layout {
    --sidebar-w-open: calc(100vw - 24px);
    grid-template-columns: 28px 1fr;
    height: calc(100dvh - 70px);
    margin-top: 6px;
    gap: 6px;
  }
  .chat-layout.expanded {
    grid-template-columns: var(--sidebar-w-open) 0;
  }
  .chat-layout.expanded .chat-wrap { display: none; }
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 252, 240, 0.8);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    cursor: pointer;
    margin-right: 6px;
  }
}

/* —— / 命令面板 —— */
/* JS 设 position:fixed + left/width/bottom 跟随 textarea */
.slash-panel {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow-paper-hover);
  padding: 6px;
  z-index: 80;
}

.slash-panel .slash-head {
  padding: 6px 10px 4px;
  font-family: var(--font-hand);
  font-size: 0.95rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 4px;
}

.slash-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--ink);
}

.slash-item .cmd {
  font-family: ui-monospace, 'Crimson Pro', monospace;
  font-size: 0.92rem;
  color: var(--accent-deep);
  font-weight: 600;
}

.slash-item .desc {
  color: var(--ink-soft);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-item .usage {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.slash-item:hover,
.slash-item.selected {
  background: rgba(192, 139, 58, 0.16);
}

.slash-item.selected .cmd { color: var(--accent-deep); }

/* ============================================================
 * chat 主体：聊天像一张铺开的信纸
 * 边框柔化到几乎无；横线纸纹理 + 顶部"今日记事"标签
 * fyf 气泡 = 撕下的便条纸；user 气泡 = 朱砂渐变印戳
 * ============================================================ */
.chat-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  border-radius: 14px;
  background:
    radial-gradient(circle at 12% 12%, rgba(207, 161, 90, 0.06), transparent 38%),
    radial-gradient(circle at 88% 92%, rgba(122, 147, 98, 0.05), transparent 40%),
    linear-gradient(180deg, #fffdf6 0%, #fbf5e1 100%);
  box-shadow:
    0 1px 0 rgba(0,0,0,0.02),
    0 14px 30px -22px rgba(80,40,10,0.22);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: transparent;
  border-bottom: 1px dashed rgba(120, 80, 35, 0.18);
}

.chat-header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
}

.chat-header .name {
  font-family: var(--font-hand);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
}

.chat-header .status {
  margin-left: auto;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-family: var(--font-hand);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chat-header .status .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--leaf);
  box-shadow: 0 0 0 2px rgba(93, 122, 69, 0.22);
}

.chat-banner {
  padding: 6px 18px;
  background: rgba(192, 139, 58, 0.10);
  border-bottom: 1px dashed rgba(120, 80, 35, 0.18);
  color: var(--accent-deep);
  font-family: var(--font-hand);
  font-size: 1rem;
}

.chat-banner a {
  color: var(--accent-deep);
  font-weight: 700;
  text-decoration: underline wavy var(--accent);
  text-underline-offset: 2px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image: repeating-linear-gradient(
    180deg,
    transparent 0 28px,
    rgba(80, 50, 20, 0.05) 28px 29px
  );
}

.chat-time {
  align-self: center;
  color: var(--ink-faint);
  font-family: var(--font-hand);
  font-size: 0.9rem;
  margin: 10px 0 4px;
}

.bubble {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 88%;
}

.bubble.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bubble img.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(120, 80, 35, 0.32);
  background: var(--paper);
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(80, 40, 10, 0.08);
}

/* ============================================================
 * 气泡：fyf 撕下来的便条 + user 暖色信卡，都贴在信纸上
 * 不用 border。用多层 box-shadow + background-image 营造纸张感
 * ============================================================ */
.bubble .body {
  position: relative;
  padding: 11px 16px 12px;
  line-height: 1.6;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink);
  word-break: break-word;
  background-color: #fffaea;
  background-image:
    radial-gradient(circle at 25% 35%, rgba(120, 80, 35, 0.045) 0.7px, transparent 0.8px),
    radial-gradient(circle at 65% 70%, rgba(120, 80, 35, 0.035) 0.7px, transparent 0.8px);
  background-size: 8px 8px, 11px 11px;
  background-position: 0 0, 4px 5px;
  border-radius: 14px 14px 14px 14px;
  box-shadow:
    0 1px 0 rgba(80, 40, 10, 0.10),
    0 10px 18px -14px rgba(80, 40, 10, 0.28),
    inset 0 0 0 0.5px rgba(120, 80, 35, 0.10);
}

/* fyf：浅米白便条纸 — 左下圆角小（撕痕）+ 顶部胶带 + 左侧细笔迹边 + 轻旋 */
.bubble.fyf .body {
  background-color: #fffaea;
  border-bottom-left-radius: 4px;
  clip-path: polygon(
    0 7px,
    5px 0,
    calc(100% - 7px) 0,
    100% 6px,
    100% calc(100% - 8px),
    calc(100% - 6px) 100%,
    8px 100%,
    0 calc(100% - 5px)
  );
  transform: rotate(-0.55deg);
}

/* 顶部一条半透明胶带 */
.bubble.fyf .body::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 22px;
  width: 46px;
  height: 14px;
  background:
    linear-gradient(180deg, rgba(207, 161, 90, 0.45) 0%, rgba(189, 132, 60, 0.55) 100%);
  border-left: 1px dashed rgba(80, 40, 10, 0.18);
  border-right: 1px dashed rgba(80, 40, 10, 0.18);
  transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgba(80, 40, 10, 0.08);
  pointer-events: none;
}

/* 左侧细笔迹竖线，模拟笔记本边距 */
.bubble.fyf .body::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 8px;
  width: 1px;
  background: repeating-linear-gradient(180deg,
    rgba(180, 60, 50, 0.45) 0 4px,
    transparent 4px 7px);
  border-radius: 1px;
  pointer-events: none;
}

.bubble.fyf .body .msg-text { padding-left: 6px; }

/* user：浅奶油信卡 + 朱砂手写下划线 + 右上邮戳 */
.bubble.user .body {
  background-color: #fdf2dd;
  background-image:
    radial-gradient(circle at 25% 35%, rgba(150, 80, 30, 0.05) 0.7px, transparent 0.8px),
    radial-gradient(circle at 65% 70%, rgba(150, 80, 30, 0.04) 0.7px, transparent 0.8px);
  color: var(--ink);
  border-bottom-right-radius: 4px;
  transform: rotate(0.45deg);
  box-shadow:
    0 1px 0 rgba(80, 40, 10, 0.10),
    0 10px 18px -14px rgba(120, 60, 20, 0.34),
    inset 0 0 0 0.5px rgba(150, 80, 30, 0.18);
}

/* 文字下面一根朱砂手写下划线（用一根稍粗的 dashed 线 + 渐变更像笔迹） */
.bubble.user .body::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0,
    rgba(168, 90, 45, 0.45) 8%,
    rgba(168, 90, 45, 0.7) 50%,
    rgba(168, 90, 45, 0.45) 92%,
    transparent 100%);
  border-radius: 2px;
  pointer-events: none;
}

/* 右上邮票方块 */
.bubble.user .body::before {
  content: "邮";
  position: absolute;
  top: -7px;
  right: 12px;
  width: 22px;
  height: 16px;
  background: linear-gradient(160deg, #d18a55 0%, #a85a2d 100%);
  color: #fff8e8;
  font-family: var(--font-hand);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  border: 1px dashed rgba(255, 248, 232, 0.5);
  transform: rotate(4deg);
  box-shadow: 1px 1px 2px rgba(80, 30, 10, 0.18);
  text-shadow: 0 1px 0 rgba(80, 30, 10, 0.25);
  pointer-events: none;
}

.msg-text { margin: 0; white-space: pre-wrap; }

.msg-image img {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  display: block;
  border: 1px solid var(--line);
}

.typing {
  align-self: flex-start;
  margin-left: 46px;
  color: var(--ink-faint);
  font-family: var(--font-hand);
  font-size: 1rem;
  padding: 2px 8px;
}

/* —— composer —— */
.composer {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px 12px;
  border-top: 1px dashed rgba(120, 80, 35, 0.18);
  background: transparent;
}

.composer .icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 1px 2px rgba(80,40,10,0.05);
}

.composer .icon-btn:hover {
  background: var(--paper);
  border-color: var(--accent);
  color: var(--accent-deep);
}

.composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  resize: none;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(177, 90, 43, 0.16);
}

.composer .send {
  height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(120, 60, 25, 0.35);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff8e8;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(120,60,25,0.2);
}

.composer .send:hover {
  filter: brightness(1.04);
}

.composer .send:disabled { opacity: 0.5; cursor: not-allowed; }

/* —— 设置页：让外层正常滚动 —— */
.settings-wrap {
  max-width: 760px;
  margin: 28px auto 80px;
  padding: 0 8px;
}

.settings-wrap h2 {
  font-family: var(--font-hand);
  font-size: 2.6rem;
  font-weight: 700;
  margin: 0 0 18px;
  color: var(--ink);
}

/* —— 恐龙游戏画框 —— */
.dino-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 8px auto 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-paper);
  max-width: 860px;
}

.dino-frame canvas {
  width: 100%;
  max-width: 800px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.6), rgba(245, 236, 214, 0.4));
}

.dino-frame .hint {
  font-family: var(--font-hand);
  font-size: 1.15rem;
  color: var(--ink-soft);
  font-style: normal;
}

/* —— headings 全局 —— */
h1, h2, h3, h4 {
  font-family: var(--font-hand);
  color: var(--ink);
  font-weight: 700;
}

/* —— 移动端 —— */
@media (max-width: 760px) {
  .topnav { padding: 10px 16px; gap: 10px; }
  .topnav .brand span { font-size: 1.3rem; }
  .topnav .menu a, .topnav .menu button { padding: 4px 8px; font-size: 1.1rem; }
  .shell { width: min(100% - 20px, 1080px); padding-top: 18px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .headline h2 { font-size: clamp(2.4rem, 12vw, 4rem); }
  .actions a { font-size: 1.05rem; min-height: 44px; }
  .card-grid { grid-template-columns: 1fr; margin-top: 24px; }
  .chat-wrap {
    border-radius: 12px;
  }
  .settings-wrap { margin: 18px auto 64px; }
  .settings-wrap h2 { font-size: 2rem; }
}
