/* ===========================================================
   大唐人生 · 卷帙美化样式 v3
   优化：去除"叠纸感"，改为整卷统一底色 + 章节分隔
   字体：偏古文楷体
   =========================================================== */


/* ============ 〇、AI回复外层卡片（卷轴整体底色） ============ */

[class*="is-assistant"],
[class*="group-\\[\\.is-assistant\\]"],
div[class*="bg-card"] {
  background:
    radial-gradient(ellipse at 5% 0%, rgba(167, 76, 50, 0.07) 0%, transparent 30%),
    radial-gradient(ellipse at 95% 100%, rgba(143, 109, 70, 0.06) 0%, transparent 35%),
    linear-gradient(172deg, #f7eed8 0%, #f0e2c2 50%, #e8d6ad 100%) !important;
  border: 1px solid #a8884d !important;
  border-radius: 4px !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 225, 0.55),
    inset 0 0 40px rgba(139, 90, 43, 0.07),
    0 3px 14px rgba(89, 56, 30, 0.18) !important;
  color: #2c1810 !important;
  padding: 20px 24px !important;
  position: relative;
  font-family: "STKaiti", "KaiTi", "FangSong", "STFangsong", serif !important;
}

/* 用户消息卡片 */
[class*="is-user"],
[class*="group-\\[\\.is-user\\]"],
[class*="bg-secondary"] {
  background: linear-gradient(180deg, #f5d8a5 0%, #e8b87a 100%) !important;
  border: 1px solid #8b6b3d !important;
  border-radius: 4px !important;
  color: #3d1a10 !important;
  box-shadow: 0 1px 4px rgba(89, 56, 30, 0.15) !important;
  font-family: "STKaiti", "KaiTi", "FangSong", serif !important;
}

/* 嵌套元素透明化，避免白底穿透 */
[class*="is-assistant"] div,
[class*="is-assistant"] p,
[class*="bg-card"] div,
[class*="bg-card"] p {
  background-color: transparent !important;
}


/* ============ 一、top / bottom 容器（去外框，融入卷轴） ============ */

top, bottom {
  display: block;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  color: #3d2817;
  font-family: "STKaiti", "KaiTi", "FangSong", "STFangsong", serif;
  line-height: 1.95;
}


/* ============ 二、正文区 text（仿信笺，独立但不突兀） ============ */

text {
  display: block;
  margin: 18px 0;
  padding: 26px 30px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 34px,
      rgba(139, 90, 43, 0.04) 34px,
      rgba(139, 90, 43, 0.04) 35px
    ),
    linear-gradient(180deg, #fbf4e0 0%, #f3e6c2 100%);
  border-top: 2px solid #8b6b3d;
  border-bottom: 2px solid #8b6b3d;
  border-left: 1px solid rgba(139, 107, 61, 0.4);
  border-right: 1px solid rgba(139, 107, 61, 0.4);
  box-shadow:
    inset 0 0 24px rgba(139, 90, 43, 0.08),
    0 2px 8px rgba(89, 56, 30, 0.12);
  font-family: "STKaiti", "KaiTi", "FangSong", "STFangsong", serif;
  color: #2c1810;
  font-size: 16px;
  line-height: 2.05;
  letter-spacing: 0.06em;
  text-align: justify;
  position: relative;
}

/* 朱砂印章 */
text::after {
  content: "唐";
  position: absolute;
  top: 14px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #c1272d 0%, #8b1a1f 100%);
  color: #f7eed8;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 23px;
  font-weight: bold;
  border-radius: 3px;
  box-shadow:
    0 0 0 2px #c1272d,
    inset 0 0 4px rgba(255, 255, 255, 0.2),
    2px 2px 5px rgba(0, 0, 0, 0.3);
  transform: rotate(-5deg);
  opacity: 0.9;
  z-index: 2;
}


/* ============ 三、details 折叠区（去叠纸感，统一融入卷轴） ============ */

details {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: relative;
}

/* 用底部细虚线作章节分隔，而非每个独立边框 */
details + details {
  border-top: 1px dashed rgba(139, 107, 61, 0.45);
  margin-top: 4px;
  padding-top: 4px;
}

details summary {
  padding: 12px 4px 12px 22px;
  background: transparent;
  color: #6b1418;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.18em;
  cursor: pointer;
  list-style: none;
  user-select: none;
  position: relative;
  border: none;
  transition: color 0.25s ease, letter-spacing 0.25s ease;
}

details summary::-webkit-details-marker { display: none; }
details summary::marker { content: ""; }

/* 章首朱砂菱形点缀 */
details summary::before {
  content: "❖";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  color: #8b1a1f;
  font-size: 14px;
  transition: transform 0.3s ease, color 0.3s ease;
}

details[open] summary::before {
  color: #c1272d;
  transform: translateY(-50%) rotate(45deg);
}

details summary:hover {
  color: #8b1a1f;
  letter-spacing: 0.22em;
}

/* 折叠内容区：左侧朱砂细线引导 */
details > *:not(summary) {
  padding: 6px 8px 14px 22px;
  margin-left: 8px;
  border-left: 1px solid rgba(139, 26, 31, 0.25);
  color: #3d2817;
  font-size: 14.5px;
  line-height: 1.95;
  font-family: "STKaiti", "KaiTi", "FangSong", serif;
}

details:not([open]) > *:not(summary) {
  border-left: none;
}


/* ============ 四、表格（古籍栏目感） ============ */

details table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  background: rgba(255, 248, 225, 0.4);
  border-top: 2px solid #8b1a1f;
  border-bottom: 2px solid #8b1a1f;
  font-family: "STKaiti", "KaiTi", "FangSong", serif;
  font-size: 13.5px;
}

details table thead tr {
  background: transparent;
  border-bottom: 1px solid #8b1a1f;
}

details table th {
  padding: 9px 10px;
  text-align: left;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #6b1418;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 14px;
  border-right: 1px dashed rgba(139, 90, 43, 0.3);
}

details table th:last-child {
  border-right: none;
}

details table td {
  padding: 8px 10px;
  border-top: 1px dotted rgba(139, 90, 43, 0.25);
  border-right: 1px dashed rgba(139, 90, 43, 0.15);
  color: #3d2817;
}

details table td:last-child {
  border-right: none;
}

details table tbody tr:hover {
  background: rgba(193, 39, 45, 0.05);
}


/* ============ 五、文风状态标签 ============ */

hb-status, cq-status, fy-status {
  display: inline-block;
  padding: 2px 11px;
  margin: 0 3px;
  border-radius: 2px;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  border: 1px solid;
  transition: all 0.25s ease;
}

hb-status[status="on"],
cq-status[status="on"],
fy-status[status="on"] {
  background: linear-gradient(135deg, #c1272d 0%, #8b1a1f 100%);
  color: #f7eed8;
  border-color: #6b1418;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

hb-status[status="off"],
cq-status[status="off"],
fy-status[status="off"] {
  background: transparent;
  color: #8b6b3d;
  border-color: #b89968;
  border-style: dashed;
  opacity: 0.7;
}


/* ============ 六、顶部导航栏 ============ */

.app-header,
header[class*="header"],
nav[class*="nav"],
[class*="top-bar"],
[class*="navbar"] {
  background:
    linear-gradient(180deg, #6b1418 0%, #8b1a1f 50%, #6b1418 100%) !important;
  border-bottom: 2px solid #c89968 !important;
  box-shadow:
    0 1px 0 rgba(245, 236, 215, 0.3) inset,
    0 2px 8px rgba(0, 0, 0, 0.25) !important;
  color: #f7eed8 !important;
}

.app-header *,
header[class*="header"] *,
[class*="navbar"] * {
  color: #f7eed8 !important;
  font-family: "STKaiti", "KaiTi", serif !important;
  letter-spacing: 0.08em;
}


/* ============ 七、底部输入栏 ============ */

.input-container,
.chat-input-area,
[class*="input-bar"],
[class*="footer-input"],
[class*="chat-footer"] {
  background:
    linear-gradient(180deg, #f7eed8 0%, #ecddb8 100%) !important;
  border-top: 2px solid #8b6b3d !important;
  box-shadow: 0 -2px 8px rgba(89, 56, 30, 0.15) !important;
  padding: 10px 12px !important;
}

textarea,
input[type="text"],
[class*="chat-input"] textarea {
  background: rgba(255, 248, 225, 0.88) !important;
  border: 1px solid #b89968 !important;
  border-radius: 3px !important;
  color: #2c1810 !important;
  font-family: "STKaiti", "KaiTi", "FangSong", serif !important;
  font-size: 15px !important;
  line-height: 1.85 !important;
  padding: 9px 13px !important;
  box-shadow: inset 0 1px 3px rgba(139, 90, 43, 0.12) !important;
  transition: border-color 0.25s ease, box-shadow 0.25s ease !important;
}

textarea:focus,
input[type="text"]:focus {
  border-color: #8b1a1f !important;
  box-shadow:
    inset 0 1px 3px rgba(139, 90, 43, 0.12),
    0 0 0 2px rgba(193, 39, 45, 0.15) !important;
  outline: none !important;
}


/* ============ 八、按钮（Mod / 流式 / 发送等） ============ */

button,
[class*="btn"],
[class*="button"] {
  background: linear-gradient(180deg, #f0dfb4 0%, #d6b87a 100%) !important;
  border: 1px solid #8b6b3d !important;
  border-radius: 3px !important;
  color: #5a2a1a !important;
  font-family: "STKaiti", "KaiTi", serif !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  letter-spacing: 0.12em !important;
  padding: 6px 14px !important;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 1px 2px rgba(89, 56, 30, 0.2) !important;
  transition: all 0.25s ease !important;
  position: relative;
}

button:hover,
[class*="btn"]:hover,
[class*="button"]:hover {
  background: linear-gradient(180deg, #ecd699 0%, #c89968 100%) !important;
  border-color: #6b4423 !important;
  color: #3d1a10 !important;
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 3px 6px rgba(89, 56, 30, 0.25) !important;
}

button:active,
[class*="btn"]:active {
  transform: translateY(0);
  box-shadow: inset 0 1px 3px rgba(89, 56, 30, 0.25) !important;
}

button[type="submit"],
[class*="send-btn"],
[class*="submit"],
[class*="primary"] {
  background: linear-gradient(180deg, #c1272d 0%, #8b1a1f 100%) !important;
  border-color: #6b1418 !important;
  color: #f7eed8 !important;
}

button[type="submit"]:hover,
[class*="send-btn"]:hover,
[class*="primary"]:hover {
  background: linear-gradient(180deg, #d63333 0%, #a32026 100%) !important;
  color: #fff5e0 !important;
}


/* ============ 九、页码 ============ */

[class*="pagination"],
[class*="page-nav"] {
  display: flex !important;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 12px 0 !important;
  background: transparent !important;
}

[class*="pagination"] button,
[class*="pagination"] a,
[class*="page-item"] {
  min-width: 32px !important;
  height: 32px !important;
  padding: 0 10px !important;
  background: linear-gradient(180deg, #faf3df 0%, #e8d6b0 100%) !important;
  border: 1px solid #b89968 !important;
  color: #5a2a1a !important;
  font-family: "STKaiti", "KaiTi", serif !important;
  font-size: 13px !important;
  border-radius: 2px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

[class*="pagination"] [class*="active"],
[class*="page-item"][class*="active"] {
  background: linear-gradient(180deg, #c1272d 0%, #8b1a1f 100%) !important;
  border-color: #6b1418 !important;
  color: #f7eed8 !important;
  font-weight: 700;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}


/* ============ 十、评论区 ============ */

[class*="comment"],
[class*="comments-area"] {
  background:
    linear-gradient(180deg, rgba(247, 238, 216, 0.6) 0%, rgba(232, 214, 176, 0.4) 100%) !important;
  border: 1px solid #b89968 !important;
  border-radius: 3px !important;
  padding: 14px 16px !important;
  margin: 10px 0 !important;
  font-family: "STKaiti", "KaiTi", "FangSong", serif !important;
}

[class*="comment-item"],
[class*="comment-card"] {
  background: rgba(255, 248, 225, 0.45) !important;
  border-bottom: 1px dashed rgba(139, 90, 43, 0.3) !important;
  padding: 10px 4px !important;
  color: #3d2817 !important;
}

[class*="comment-item"]:last-child {
  border-bottom: none !important;
}

[class*="comment"] [class*="username"],
[class*="comment"] [class*="author"] {
  color: #8b1a1f !important;
  font-family: "STKaiti", "KaiTi", serif !important;
  font-weight: 700;
  letter-spacing: 0.08em;
}

[class*="comment"] [class*="time"],
[class*="comment"] [class*="date"] {
  color: #8b6b3d !important;
  font-size: 11px !important;
  font-family: "FangSong", serif !important;
}


/* ============ 十一、消息内嵌强调 ============ */

[class*="message"] strong,
[class*="msg-item"] strong,
[class*="is-assistant"] strong {
  color: #8b1a1f !important;
  font-weight: 700;
  letter-spacing: 0.04em;
}


/* ============ 十二、加载动画（墨滴节奏） ============ */

[class*="loading"],
[class*="spinner"],
[class*="loader"] {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  background: transparent !important;
}

[class*="loading"]::before,
[class*="spinner"]::before,
[class*="loader"]::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle at 35% 30%, #c1272d 0%, #6b1418 70%);
  border-radius: 50%;
  animation: ink-drop 1.4s ease-in-out infinite;
  box-shadow:
    18px 0 0 0 rgba(139, 26, 31, 0.85),
    36px 0 0 0 rgba(139, 26, 31, 0.85);
}

@keyframes ink-drop {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
    box-shadow:
      18px 0 0 0 rgba(139, 26, 31, 0.4),
      36px 0 0 0 rgba(139, 26, 31, 0.4);
  }
  40% {
    transform: scale(1);
    opacity: 1;
    box-shadow:
      18px 0 0 0 rgba(193, 39, 45, 1),
      36px 0 0 0 rgba(193, 39, 45, 0.7);
  }
}

[class*="streaming"]::after,
[class*="typing-cursor"] {
  content: "▌";
  display: inline-block;
  color: #8b1a1f;
  font-weight: bold;
  animation: brush-blink 1s steps(2) infinite;
  margin-left: 2px;
}

@keyframes brush-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}


/* ============ 十三、滚动条 ============ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(232, 214, 176, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #b89968 0%, #8b6b3d 100%);
  border-radius: 4px;
  border: 1px solid rgba(89, 56, 30, 0.2);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #c1272d 0%, #8b1a1f 100%);
}


/* ============ 十四、标签页 ============ */

[class*="tab-item"],
[class*="tabs"] [class*="item"] {
  background: linear-gradient(180deg, #ecddb8 0%, #d6b87a 100%) !important;
  border: 1px solid #b89968 !important;
  border-bottom: none !important;
  border-radius: 4px 4px 0 0 !important;
  color: #5a2a1a !important;
  font-family: "STKaiti", "KaiTi", serif !important;
  padding: 8px 16px !important;
  letter-spacing: 0.1em;
}

[class*="tab-item"][class*="active"],
[class*="tabs"] [class*="active"] {
  background: linear-gradient(180deg, #c1272d 0%, #8b1a1f 100%) !important;
  color: #f7eed8 !important;
  border-color: #6b1418 !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}


/* ============ 十五、移动端适配 ============ */

@media (max-width: 768px) {
  [class*="is-assistant"],
  [class*="bg-card"] {
    padding: 14px 14px !important;
  }

  text {
    padding: 20px 18px;
    font-size: 15px;
    line-height: 1.95;
  }

  text::after {
    width: 33px;
    height: 33px;
    font-size: 19px;
    top: 10px;
    right: 12px;
  }

  details summary {
    font-size: 15px;
    padding: 10px 4px 10px 20px;
    letter-spacing: 0.14em;
  }

  details > *:not(summary) {
    padding: 6px 6px 12px 18px;
    font-size: 13.5px;
  }

  details table {
    font-size: 12.5px;
  }

  details table th,
  details table td {
    padding: 6px 7px;
  }

  details table th {
    font-size: 13px;
  }
}