/* 碎片化内容整理 - Lovable 配色 */
/* 字体：Noto Serif SC / Noto Sans SC | 色板：ink / terracotta / sage / sky / plum / amber / parchment */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600&display=swap');

:root {
  /* ========== Lovable 色板（HSL 数值，使用方式：hsl(var(--ink))） ========== */
  --parchment: 40 25% 97%;
  --parchment-deep: 40 18% 94%;
  --ink: 30 12% 18%;
  --ink-light: 30 8% 48%;
  --ink-lighter: 30 6% 65%;
  --terracotta: 15 48% 50%;
  --terracotta-light: 18 42% 94%;
  --sage: 140 22% 62%;
  --sage-light: 140 28% 94%;
  --sky: 200 55% 62%;
  --sky-light: 200 45% 94%;
  --plum: 280 32% 62%;
  --plum-light: 278 35% 94%;
  --amber: 38 68% 56%;
  --amber-light: 40 55% 94%;

  /* ========== 映射到页面用变量 ========== */
  --background: var(--parchment);
  --foreground: var(--ink);
  --bg-main: hsl(var(--parchment));
  --bg-card-1: hsl(var(--terracotta-light));
  --bg-card-2: hsl(var(--amber-light));
  --bg-card-3: hsl(var(--sky-light));
  --bg-card-4: hsl(var(--plum-light));
  --bg-card-5: hsl(var(--sage-light));
  --text-primary: hsl(var(--ink));
  --text-secondary: hsl(var(--ink-light));
  --text-muted: hsl(var(--ink-lighter));
  --accent-soft: hsl(var(--sage));
  --accent-warm: hsl(var(--terracotta));
  --accent-blue: hsl(var(--sky));
  --tag-green: hsl(var(--sage-light));
  --tag-orange: hsl(var(--amber-light));
  --tag-blue: hsl(var(--sky-light));
  --border-soft: hsl(var(--ink) / 0.08);
  --shadow-sm: 0 1px 3px hsl(var(--ink) / 0.06);
  --shadow-card: 0 1px 3px hsl(var(--ink) / 0.06);
  --shadow-hover: 0 4px 12px hsl(var(--ink) / 0.08);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== 主页布局：Bento 容器（max-width 1440px，宽阔左右边距） ========== */
.page-home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
  padding: 2.5rem 6rem 4rem;
}
@media (min-width: 1200px) {
  .page-home { padding-left: 8rem; padding-right: 8rem; }
}
@media (min-width: 1400px) {
  .page-home { padding-left: 10rem; padding-right: 10rem; }
}
@media (max-width: 768px) {
  .page-home { padding: 2rem 2rem 3rem; }
}
@media (max-width: 640px) {
  .page-home { padding: 1.5rem 1.25rem 2rem; }
}

/* 上层：slogan（衬线体 + 水墨装饰 + 下划线动画，对齐 Lovable SloganHeader） */
.slogan-block {
  position: relative;
  text-align: center;
  padding: 3rem 0 2rem;
}
@media (min-width: 768px) {
  .slogan-block { padding: 4rem 0 2.5rem; }
}

/* 装饰性水墨晕染块 */
.slogan-blobs {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.slogan-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
}
.slogan-blob-terracotta {
  left: -5rem;
  top: 0;
  width: 10rem;
  height: 10rem;
  background: hsl(var(--terracotta) / 0.05);
}
.slogan-blob-sage {
  right: -2.5rem;
  top: 2rem;
  width: 8rem;
  height: 8rem;
  background: hsl(var(--sage) / 0.08);
}
.slogan-blob-amber {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16rem;
  height: 6rem;
  background: hsl(var(--amber) / 0.05);
}

/* 主标语：入场动画 + 下划线 */
.slogan-block .slogan-title {
  position: relative;
  font-family: 'Noto Serif SC', 'Noto Serif', serif;
  font-size: 1.875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: hsl(var(--ink));
  margin: 0;
  opacity: 0;
  transform: translateY(-10px);
  animation: slogan-in 0.8s ease-out forwards;
}
@media (min-width: 768px) {
  .slogan-block .slogan-title { font-size: 2.25rem; }
}
@media (min-width: 1024px) {
  .slogan-block .slogan-title { font-size: 3rem; }
}
.slogan-block .slogan-line {
  position: relative;
  display: inline-block;
}
.slogan-block .slogan-comma {
  margin: 0;
  color: hsl(var(--terracotta) / 0.4);
}
.slogan-block .slogan-underline {
  position: absolute;
  left: 0;
  bottom: -0.5rem;
  height: 2px;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
}
.slogan-underline-terracotta {
  background: linear-gradient(to right, hsl(var(--terracotta) / 0.6), hsl(var(--terracotta) / 0.3), transparent);
  animation: underline-in 0.6s ease-out 0.8s forwards;
}
.slogan-underline-sage {
  background: linear-gradient(to right, hsl(var(--sage) / 0.5), hsl(var(--sage) / 0.25), transparent);
  animation: underline-in 0.6s ease-out 1s forwards;
}
.slogan-block .slogan-sub {
  position: relative;
  margin: 1.5rem 0 0;
  font-size: 14px;
  color: hsl(var(--ink-lighter));
  opacity: 0;
  animation: slogan-sub-in 0.6s ease-out 1.2s forwards;
}

@keyframes slogan-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes underline-in {
  to { transform: scaleX(1); }
}
@keyframes slogan-sub-in {
  to { opacity: 1; }
}

/* 中层：4 个圆形功能键（Lovable ActionButtons：竖排图标+文字、入场动画、悬停放大与描边环） */
.actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.25rem 0 2.5rem;
}
@media (min-width: 768px) {
  .actions-row { gap: 2.5rem; }
}

.action-btn {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  opacity: 0;
  transform: translateY(16px);
  animation: action-btn-in 0.5s ease-out forwards;
}
.action-btn:nth-child(1) { animation-delay: 0.3s; }
.action-btn:nth-child(2) { animation-delay: 0.4s; }
.action-btn:nth-child(3) { animation-delay: 0.5s; }
.action-btn:nth-child(4) { animation-delay: 0.6s; }
.action-btn:hover {
  transform: scale(1.08) translateY(-4px);
}
.action-btn:active {
  transform: scale(0.95) translateY(0);
}
.action-btn:hover .action-btn-circle {
  border-color: hsl(var(--terracotta-light));
  box-shadow: var(--shadow-hover);
}
.action-btn:hover .action-btn-ring {
  transform: scale(1.1);
  border-color: hsl(var(--terracotta) / 0.2);
}
.action-btn:hover .action-icon {
  color: hsl(var(--terracotta));
}
.action-btn:hover .label {
  color: hsl(var(--ink));
}

.action-btn-circle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: 1px solid hsl(var(--ink) / 0.08);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s, box-shadow 0.3s;
}
@media (min-width: 768px) {
  .action-btn-circle { width: 4rem; height: 4rem; }
}
.action-btn-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: transform 0.3s, border-color 0.3s;
}
.action-btn .action-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(var(--ink-light));
  transition: color 0.3s;
}
.action-btn .action-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}
@media (min-width: 768px) {
  .action-btn .action-icon svg { width: 1.5rem; height: 1.5rem; }
}
.action-btn .label {
  font-family: 'Noto Serif SC', 'Noto Serif', serif;
  font-size: 0.875rem;
  color: hsl(var(--ink-light));
  transition: color 0.3s;
}

@keyframes action-btn-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== 瀑布流（column-count：按列从上往下排，卡片高度随内容自然不一） ========== */

.cards-grid {
  column-count: 1;
  column-gap: 1rem;
  padding-bottom: 4rem;
}

@media (min-width: 640px) {
  .cards-grid {
    column-count: 2;
    column-gap: 1.25rem;
  }
}

@media (min-width: 1024px) {
  .cards-grid {
    column-count: 3;
    column-gap: 1.5rem;
  }
}

.cards-grid .card {
  break-inside: avoid;
  margin-bottom: 1rem;
  page-break-inside: avoid;
}

.cards-grid .card:last-child {
  margin-bottom: 0;
}

/* ========== 卡片容器（内容不溢出边框、统一 p-8） ========== */
.card {
  border-radius: 32px;
  border: 1px solid transparent;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 200px;
  height: auto;
  position: relative;
  transition: transform 0.5s ease, box-shadow 0.5s ease, border-color 0.2s ease;
  overflow: hidden;
  box-sizing: border-box;
}

.card:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 28px hsl(var(--ink) / 0.1);
  z-index: 10;
}

/* 卡片色系 tintMap：0=rose, 1=sky, 2=sage, 3=amber, 4=plum */
.card[data-bg-index="0"] {
  background: hsl(10 40% 95%);
  border-color: hsl(10 30% 88%);
}
.card[data-bg-index="0"]:hover { border-color: hsl(10 40% 78%); }

.card[data-bg-index="1"] {
  background: hsl(205 35% 94%);
  border-color: hsl(205 25% 88%);
}
.card[data-bg-index="1"]:hover { border-color: hsl(205 35% 78%); }

.card[data-bg-index="2"] {
  background: hsl(140 20% 94%);
  border-color: hsl(140 15% 88%);
}
.card[data-bg-index="2"]:hover { border-color: hsl(140 20% 78%); }

.card[data-bg-index="3"] {
  background: hsl(38 40% 94%);
  border-color: hsl(38 30% 88%);
}
.card[data-bg-index="3"]:hover { border-color: hsl(38 40% 78%); }

.card[data-bg-index="4"] {
  background: hsl(330 22% 95%);
  border-color: hsl(330 18% 88%);
}
.card[data-bg-index="4"]:hover { border-color: hsl(330 22% 78%); }

/* ========== 视觉层级 (Visual Hierarchy) ========== */

/* 辅助信息区 (Top)，防止子元素撑破宽度 */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  min-width: 0;
  flex-shrink: 0;
}

/* 标签区：强制横排、不换行、超出隐藏（仅展示能完整显示的部分） */
.card .tags {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow: hidden;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0.25rem;
}
.card .tags .card-tag-add {
  flex-shrink: 0;
}
.card .tag {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px; /* gap-1 */
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  font-size: 12px; /* text-xs */
  font-weight: 500; /* font-medium */
  padding: 2px 10px; /* py-0.5 px-2.5 */
  border-radius: 9999px; /* rounded-full */
  border: none;
}
/* 标签色系 tagColorMap：与卡片 tint 一一对应 */
.card[data-bg-index="0"] .tag {
  background: hsl(10 35% 90%);
  color: hsl(10 40% 40%);
}
.card[data-bg-index="1"] .tag {
  background: hsl(205 30% 88%);
  color: hsl(205 40% 35%);
}
.card[data-bg-index="2"] .tag {
  background: hsl(140 18% 88%);
  color: hsl(140 25% 35%);
}
.card[data-bg-index="3"] .tag {
  background: hsl(38 35% 88%);
  color: hsl(38 50% 35%);
}
.card[data-bg-index="4"] .tag {
  background: hsl(330 20% 88%);
  color: hsl(330 25% 38%);
}
.card .tag .tag-icon {
  width: 12px; /* h-3 */
  height: 12px; /* w-3 */
  flex-shrink: 0;
  color: currentColor;
}

/* 核心金句：衬线体、18px、左对齐、不溢出卡片；底部留白把分割线往下推 */
.card .core-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  margin-bottom: 2.25rem;
  text-align: left;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.card .core {
  font-family: 'Noto Serif SC', 'Noto Serif', serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: hsl(var(--ink));
  display: -webkit-box;
  -webkit-line-clamp: 12;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}

/* 底部日期区：分割线更靠下，日期紧贴卡片底边 */
.card-footer {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.25rem;
  border-top: 1px solid hsl(var(--ink) / 0.06);
  padding-top: 0.25rem;
  padding-bottom: 0.125rem;
  margin-top: auto;
  flex-shrink: 0;
}
.card-source-wrap {
  width: 100%;
  min-width: 0;
}
.card-source {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  font-size: 11px;
  color: hsl(var(--ink) / 0.5);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-source:hover {
  color: hsl(var(--ink));
  text-decoration: underline;
}
.card[data-bg-index="0"] .card-source:hover { color: hsl(10 40% 40%); }
.card[data-bg-index="1"] .card-source:hover { color: hsl(205 40% 35%); }
.card[data-bg-index="2"] .card-source:hover { color: hsl(140 25% 35%); }
.card[data-bg-index="3"] .card-source:hover { color: hsl(38 50% 35%); }
.card[data-bg-index="4"] .card-source:hover { color: hsl(330 25% 38%); }

/* 日期：左下角左对齐，使用 ink-lighter */
.card .date {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--ink-lighter));
  letter-spacing: 0.03em;
  text-align: left;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 操作按钮：悬浮显示 */
.card .quick-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card:hover .quick-actions { opacity: 1; }

.card .quick-actions button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid hsl(var(--ink) / 0.06);
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.card .quick-actions button:hover {
  background: hsl(var(--ink));
  color: #fff;
  transform: scale(1.05);
}

/* 展示容器：切换「按分类展示」时平滑过渡 */
.cards-view {
  transition: opacity 0.25s ease;
}
/* 按分类展示：分组标题 + 每组网格 */
.category-section {
  margin-bottom: 2.5rem;
  animation: categorySectionIn 0.35s ease forwards;
}
@keyframes categorySectionIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.category-title {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid hsl(var(--ink) / 0.08);
  letter-spacing: 0.02em;
}
/* 按分类展示时每个分组同样使用瀑布流 */
.category-section {
  margin-bottom: 2.5rem;
}
.category-section:last-child {
  margin-bottom: 0;
}

/* 卡片标签：删除按钮、添加按钮（轻盈半透明） */
.card .tag {
  position: relative;
  padding-right: 18px;
}
.card .tag .tag-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}
.card .tag:hover .tag-del {
  opacity: 1;
}
.card .tag .tag-del:hover {
  background: hsl(var(--ink) / 0.1);
  color: var(--text-primary);
}
.card .card-tag-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px; /* py-0.5 px-1.5 */
  min-width: 24px;
  height: 24px;
  font-size: 14px;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.card[data-bg-index="0"] .card-tag-add { background: hsl(10 35% 90%); color: hsl(10 40% 40%); }
.card[data-bg-index="1"] .card-tag-add { background: hsl(205 30% 88%); color: hsl(205 40% 35%); }
.card[data-bg-index="2"] .card-tag-add { background: hsl(140 18% 88%); color: hsl(140 25% 35%); }
.card[data-bg-index="3"] .card-tag-add { background: hsl(38 35% 88%); color: hsl(38 50% 35%); }
.card[data-bg-index="4"] .card-tag-add { background: hsl(330 20% 88%); color: hsl(330 25% 38%); }
.card .card-tag-add:hover {
  filter: brightness(0.94);
}

/* 排序栏（弱化，无纯黑） */
.cards-section .sort-bar {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 13px;
  color: var(--text-muted);
}
.cards-section .sort-btn {
  font-family: 'Inter', 'Noto Sans SC', sans-serif;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.cards-section .sort-btn:hover { color: var(--text-primary); }
.cards-section .sort-btn.active {
  color: var(--text-primary);
  font-weight: 500;
  background: rgba(45,45,45,0.06);
}

/* 空状态 */
.cards-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-size: 14px;
}

/* ========== 弹窗：链导入、文上传 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  width: 90%;
  max-width: 420px;
  padding: 1.5rem;
}
.modal h3 {
  font-size: 16px;
  margin-bottom: 1rem;
  color: var(--text-primary);
}
.modal .input-wrap {
  margin-bottom: 1rem;
}
.modal input[type="text"],
.modal input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
}
.modal .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.modal .upload-zone {
  border: 2px dashed var(--border-soft);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.modal .upload-zone:hover,
.modal .upload-zone.dragover {
  border-color: var(--accent-blue);
  background: rgba(158,200,224,0.08);
}
.modal .upload-zone .icon { font-size: 28px; margin-bottom: 8px; color: var(--text-muted); }
.modal .upload-zone .tip { font-size: 13px; color: var(--text-secondary); }
.modal .progress { margin-top: 0.75rem; height: 4px; background: #eee; border-radius: 2px; overflow: hidden; display: none; }
.modal .progress.show { display: block; }
.modal .progress .bar { height: 100%; background: var(--accent-blue); width: 0%; transition: width 0.3s; }

.modal .btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 1.25rem;
}
.modal .btns button {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
}
.modal .btns button.primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.modal .btns button:disabled { opacity: 0.6; cursor: not-allowed; }

/* 加载动画 */
.loader-wrap {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 13px;
}
.loader-wrap.show { display: flex; }
.loader {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 编辑页（版面整洁、Lovable 参考、主按钮美观） ========== */
.page-edit {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}
body .page-edit { margin: 0; }

/* 装饰背景 */
.edit-blobs {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.edit-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
}
.edit-blob-terracotta {
  left: -10rem;
  top: -10rem;
  width: 20rem;
  height: 20rem;
  background: hsl(var(--terracotta) / 0.05);
}
.edit-blob-sage {
  right: -5rem;
  top: 5rem;
  width: 15rem;
  height: 15rem;
  background: hsl(var(--sage) / 0.08);
}
.edit-blob-amber {
  bottom: -5rem;
  left: 33%;
  width: 24rem;
  height: 10rem;
  background: hsl(var(--amber) / 0.05);
}

/* 顶部栏：sticky、毛玻璃 */
.edit-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid hsl(var(--ink) / 0.08);
  background: hsl(var(--parchment) / 0.8);
  backdrop-filter: blur(12px);
}
.edit-header-inner {
  max-width: 56rem;
  margin: 0 auto;
  height: 4rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
}
@media (min-width: 640px) {
  .edit-header-inner { padding: 0 1.5rem; }
}
.edit-save-wrap { flex-shrink: 0; }
.edit-back {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid hsl(var(--ink) / 0.12);
  background: hsl(var(--parchment));
  color: hsl(var(--ink-light));
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.edit-back:hover {
  border-color: hsl(var(--terracotta) / 0.3);
  background: hsl(var(--terracotta) / 0.05);
  color: hsl(var(--terracotta));
}
.edit-header-title {
  flex-shrink: 0;
  font-family: 'Noto Serif SC', serif;
  font-size: 1.125rem;
  font-weight: 500;
  color: hsl(var(--ink-light));
  margin: 0;
}
.edit-save-btn {
  min-width: 6rem;
  height: 2.5rem;
  padding: 0 1.5rem;
  border-radius: 9999px;
  border: none;
  background: hsl(var(--terracotta));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 1px 3px hsl(var(--terracotta) / 0.25);
}
.edit-save-btn:hover:not(:disabled) {
  background: hsl(15 48% 45%);
  box-shadow: 0 4px 12px hsl(var(--terracotta) / 0.35);
}
.edit-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.edit-save-icon { flex-shrink: 0; }

/* 主内容区 */
.edit-content {
  flex: 1;
  position: relative;
}
.edit-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 6rem;
  width: 100%;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .edit-inner { padding: 1.5rem 1.5rem 6rem; }
}

/* 标题输入 + 渐变下划线 */
.edit-title-wrap {
  margin-bottom: 1rem;
}
.edit-title-input {
  width: 100%;
  border: none;
  background: transparent;
  font-family: 'Noto Serif SC', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: hsl(var(--ink));
  padding: 0;
  outline: none;
}
.edit-title-input::placeholder {
  color: hsl(var(--ink-lighter) / 0.6);
}
.edit-title-underline {
  margin-top: 0.5rem;
  height: 1px;
  background: linear-gradient(to right, hsl(var(--terracotta) / 0.3), hsl(var(--ink) / 0.08), transparent);
}

/* 原文链接卡片（标签下方、编辑区上方，参考图片：大标题+点击提示） */
.edit-source-wrap {
  margin-bottom: 1rem;
}
.edit-source-card {
  display: block;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  border: 1px solid hsl(var(--ink) / 0.12);
  background: hsl(var(--parchment) / 0.7);
  box-shadow: 0 1px 4px hsl(var(--ink) / 0.06);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.edit-source-card:hover {
  border-color: hsl(var(--terracotta) / 0.35);
  box-shadow: 0 2px 10px hsl(var(--ink) / 0.1);
  background: hsl(var(--parchment) / 0.9);
}
.edit-source-card-title {
  display: block;
  font-family: 'Noto Serif SC', 'Noto Sans SC', sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  color: hsl(var(--ink));
  line-height: 1.4;
  margin-bottom: 0.35rem;
  transition: color 0.2s;
  word-break: break-word;
}
.edit-source-card:hover .edit-source-card-title {
  color: hsl(var(--terracotta));
}
.edit-source-card-hint {
  display: block;
  font-size: 0.75rem;
  color: hsl(var(--ink-lighter));
  font-weight: 400;
}
.edit-source-card:hover .edit-source-card-hint {
  color: hsl(var(--terracotta) / 0.8);
}

/* 标签编辑区 */
.edit-tags-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}
.edit-tags-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: 4px;
}
.edit-tags-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.edit-tag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-primary);
  padding: 4px 10px;
  background: hsl(var(--ink) / 0.06);
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s;
}
.edit-tag-pill:hover {
  background: hsl(var(--ink) / 0.1);
}
.edit-tag-add {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed hsl(var(--ink) / 0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.edit-tag-add:hover {
  border-color: hsl(var(--terracotta));
  color: hsl(var(--terracotta));
}

/* 正文编辑区（卡片感） */
.edit-editor-wrap {
  position: relative;
}
.edit-body {
  min-height: 280px;
  width: 100%;
  padding: 1.5rem 1rem;
  border: 1px solid hsl(var(--ink) / 0.1);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  font-size: 1rem;
  line-height: 1.8;
  color: hsl(var(--ink));
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .edit-body { padding: 2rem; }
}
.edit-body:focus {
  border-color: hsl(var(--terracotta) / 0.3);
  box-shadow: 0 0 0 2px hsl(var(--terracotta) / 0.1);
}
.edit-body:empty::before {
  content: attr(data-placeholder);
  color: hsl(var(--ink-lighter) / 0.6);
}
.edit-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
}
.edit-body video {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px 0;
}

/* 底部工具栏：sticky、毛玻璃 */
.edit-toolbar {
  position: sticky;
  bottom: 0;
  z-index: 50;
  border-top: 1px solid hsl(var(--ink) / 0.08);
  background: hsl(var(--parchment) / 0.9);
  backdrop-filter: blur(12px);
}
.edit-toolbar-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 1rem;
}
@media (min-width: 640px) {
  .edit-toolbar-inner { padding: 0.75rem 1.5rem 1rem; }
}

/* AI 工具行（胶囊按钮） */
.edit-toolbar-ai {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.edit-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--ink));
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.edit-ai-pill svg { flex-shrink: 0; }
.edit-ai-pill-sage {
  border-color: hsl(var(--sage) / 0.4);
  background: hsl(var(--sage-light) / 0.5);
}
.edit-ai-pill-sage:hover {
  border-color: hsl(var(--sage));
  background: hsl(var(--sage) / 0.1);
}
.edit-ai-pill-sage svg { color: hsl(var(--sage)); }
.edit-ai-pill-terracotta {
  border-color: hsl(var(--terracotta) / 0.4);
  background: hsl(var(--terracotta-light) / 0.3);
}
.edit-ai-pill-terracotta:hover {
  border-color: hsl(var(--terracotta));
  background: hsl(var(--terracotta) / 0.1);
}
.edit-ai-pill-terracotta svg { color: hsl(var(--terracotta)); }

/* 格式工具行：分组 + 分隔线 */
.edit-toolbar-format {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}
.edit-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 8px;
  background: hsl(var(--ink) / 0.04);
}
.edit-toolbar-group button {
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--ink-light));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background 0.2s, color 0.2s;
}
.edit-toolbar-group button:hover {
  background: var(--bg-main);
  color: hsl(var(--ink));
}
.edit-toolbar-group button b,
.edit-toolbar-group button i,
.edit-toolbar-group button u,
.edit-toolbar-group button s {
  font-size: 12px;
  font-weight: 600;
}
.edit-toolbar-sep {
  width: 1px;
  height: 1.5rem;
  background: hsl(var(--ink) / 0.12);
  margin: 0 4px;
  flex-shrink: 0;
}

/* 图片/视频/链接/删除：统一为美观的次要/危险按钮 */
.edit-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.edit-toolbar-btn {
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 8px;
  border: 1px solid hsl(var(--ink) / 0.12);
  background: #fff;
  color: hsl(var(--ink-light));
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.edit-toolbar-btn-label { pointer-events: none; }
.edit-toolbar-btn-secondary:hover {
  border-color: hsl(var(--terracotta) / 0.4);
  background: hsl(var(--terracotta) / 0.06);
  color: hsl(var(--terracotta));
}
.edit-toolbar-btn-danger {
  border-color: hsl(0 50% 90%);
  background: hsl(0 50% 98%);
  color: hsl(0 55% 45%);
}
.edit-toolbar-btn-danger:hover {
  border-color: hsl(0 55% 75%);
  background: hsl(0 55% 94%);
  color: hsl(0 55% 38%);
}
.edit-toolbar-color,
.edit-toolbar-file {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 解析后的快捷按钮（与 AI 行风格一致） */
.parsed-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}
.parsed-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.parsed-btn-outline {
  border-color: hsl(var(--sage) / 0.4);
  background: hsl(var(--sage-light) / 0.5);
  color: hsl(var(--ink));
}
.parsed-btn-outline:hover { background: hsl(var(--sage) / 0.1); border-color: hsl(var(--sage)); }
.parsed-btn-core {
  border-color: hsl(var(--terracotta) / 0.4);
  background: hsl(var(--terracotta-light) / 0.3);
  color: hsl(var(--ink));
}
.parsed-btn-core:hover { background: hsl(var(--terracotta) / 0.1); border-color: hsl(var(--terracotta)); }

/* ========== AI 创作页 ========== */
.page-ai {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
}
.ai-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.ai-header .back {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-header .back:hover { background: #f5f5f5; }
.ai-header h1 { font-size: 16px; font-weight: 500; }

.ai-layout {
  flex: 1;
  display: flex;
  min-height: 0;
}
.ai-sidebar {
  width: 200px;
  border-right: 1px solid var(--border-soft);
  padding: 1rem;
  overflow-y: auto;
}
.ai-sidebar .new-chat {
  width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.ai-sidebar .new-chat:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.ai-sidebar .history-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.ai-sidebar .history-item:hover { background: #f5f5f5; color: var(--text-primary); }
.ai-sidebar .history-item .hist-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ai-sidebar .history-item .hist-del {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}
.ai-sidebar .history-item .hist-del:hover { background: #ffdddd; color: #c33; opacity: 1; }

.ai-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}
.ai-msg {
  margin-bottom: 1rem;
  max-width: 85%;
}
.ai-msg.user { margin-left: auto; }
.ai-msg .bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.5;
}
.ai-msg.user .bubble { background: var(--accent-blue); color: #fff; }
.ai-msg.assistant .bubble { background: #f5f5f5; color: var(--text-primary); }
.ai-msg .copy-btn,
.ai-msg .copy-to-note-btn {
  margin-top: 4px;
  margin-right: 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
}
.ai-msg .copy-btn:hover,
.ai-msg .copy-to-note-btn:hover { color: var(--accent-blue); }

.ai-input-wrap {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
}
.ai-input-wrap textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.ai-input-wrap textarea:focus { outline: none; border-color: var(--accent-blue); }
.ai-input-wrap .send-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.ai-input-wrap .send-btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-blue);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* ========== 通用 ========== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s, opacity 0.3s, visibility 0.3s;
  z-index: 200;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.confirm-overlay.open { opacity: 1; visibility: visible; }
.confirm-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 340px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}
.confirm-box .text { font-size: 14px; color: var(--text-primary); margin-bottom: 1rem; }
.confirm-box .btns { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-box .btns button {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}
.confirm-box .btns button.danger { background: #e8a0a0; border-color: #e8a0a0; color: #fff; }
