/* ============================================= */
/*  斗破苍穹·修罗宝典 v1.0 主题样式表             */
/*  Theme: Ancient Scroll × Dou Qi Aesthetic     */
/*  容器: .xuanhuo-scroll-theme                  */
/* ============================================= */

/* ====== 动画定义 ====== */
@keyframes scrollShimmer {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}
@keyframes pulseGlow {
  0%, 100% { text-shadow: 0 0 3px currentColor; }
  50% { text-shadow: 0 0 10px currentColor, 0 0 18px currentColor; }
}
@keyframes tipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes borderBreath {
  0%, 100% { box-shadow: 0 0 5px rgba(200, 90, 60, 0.1); }
  50%       { box-shadow: 0 0 14px rgba(200, 90, 60, 0.25); }
}

/* ====== 根容器 ====== */
.xuanhuo-scroll-theme {
  font-family: "Georgia", "Noto Serif SC", "SimSun", serif;
  color: #4a443d;
  line-height: 1.78;
  font-size: 15px;
  background-color: #f2efe8;
  background-image:
    url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4"%3E%3Cpath fill="%23ccc3b4" fill-opacity="0.18" d="M1 3h1v1H1V3zm2-2h1v1H3V1z"%3E%3C/path%3E%3C/svg%3E');
  padding: 18px 12px 22px;
  border: 1px solid #ccc3b4;
  border-radius: 8px;
  position: relative;
  overflow: visible;
  box-shadow:
    0 3px 20px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: borderBreath 6s ease-in-out infinite;
}

/* 顶部装饰线——丹焰赤 */
.xuanhuo-scroll-theme::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%, #d4956a 10%, #c85a3c 35%,
    #e87050 50%,
    #c85a3c 65%, #d4956a 90%, transparent 100%);
  border-radius: 8px 8px 0 0;
  animation: scrollShimmer 4s ease-in-out infinite;
  z-index: 10;
  pointer-events: none;
}

/* 底部收尾线 */
.xuanhuo-scroll-theme::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%, #ccc3b4 20%, #b0a898 50%, #ccc3b4 80%, transparent 100%);
  border-radius: 0 0 8px 8px;
  z-index: 10;
  pointer-events: none;
}

/* ====== 隐藏区域 ====== */
.xuanhuo-scroll-theme .wh,
.xuanhuo-scroll-theme .dm {
  display: none;
}

/* ====== 品质颜色系统 ====== */
.xuanhuo-scroll-theme .q-y {
  color: #b8941e;
}
.xuanhuo-scroll-theme .q-x {
  color: #3a8e7a;
  text-shadow: 0 0 2px rgba(58, 142, 122, 0.12);
}
.xuanhuo-scroll-theme .q-d {
  color: #8a5cc8;
  text-shadow: 0 0 4px rgba(138, 92, 200, 0.18);
}
.xuanhuo-scroll-theme .q-t {
  color: #d4681e;
  text-shadow: 0 0 5px rgba(212, 104, 30, 0.22);
  animation: pulseGlow 3s ease-in-out infinite;
}
.xuanhuo-scroll-theme .q-r {
  color: #c83030;
  text-shadow: 0 0 7px rgba(200, 48, 48, 0.35), 0 0 14px rgba(200, 48, 48, 0.15);
  animation: pulseGlow 2.4s ease-in-out infinite;
}

/* ====== 特质颜色系统 ====== */
.xuanhuo-scroll-theme .tr-p {
  color: #b87820;
  text-shadow: 0 0 3px rgba(184, 120, 32, 0.18);
}
.xuanhuo-scroll-theme .tr-t {
  color: #5a7a9a;
  text-shadow: 0 0 3px rgba(90, 122, 154, 0.15);
}

/* ====== 对话与内心独白 ====== */
/* 对话: 蓝调，无斜体 */
.xuanhuo-scroll-theme .dia {
  color: #4a6a9a;
  padding: 0 1px;
}
/* 内心: 红调，保留斜体（视觉区分必要设计） */
.xuanhuo-scroll-theme .tho {
  color: #9a5040;
  font-style: italic;
  border-left: 2px solid rgba(154, 80, 64, 0.28);
  padding-left: 5px;
  display: inline;
}

/* ====== 正文区 ====== */
.xuanhuo-scroll-theme .text {
  padding: 14px 8px;
  line-height: 1.92;
  font-size: 15.5px;
  background: linear-gradient(180deg,
    rgba(248, 245, 238, 0.6) 0%,
    rgba(242, 239, 232, 0.3) 50%,
    rgba(248, 245, 238, 0.6) 100%);
  border-radius: 4px;
  margin: 8px 0;
  position: relative;
}
.xuanhuo-scroll-theme .text::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: linear-gradient(180deg,
    transparent, rgba(200, 90, 60, 0.18), transparent);
  border-radius: 3px 0 0 3px;
}
.xuanhuo-scroll-theme .text p {
  margin: 0 0 13px 0;
  text-indent: 2em;
}

/* ====== 折叠面板 ====== */
/* overflow: visible 是悬浮窗不被裁切的核心 */
.xuanhuo-scroll-theme details {
  margin: 6px 0;
  border: 1px solid #ccc3b4;
  border-radius: 5px;
  background: #ede9e0;
  overflow: visible;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.xuanhuo-scroll-theme details[open] {
  border-color: #c85a3c;
  box-shadow: 0 2px 10px rgba(200, 90, 60, 0.1);
}
/* 嵌套details */
.xuanhuo-scroll-theme details details {
  margin: 5px 0;
  border-color: #d8d3c8;
  background: #f0ede6;
}
.xuanhuo-scroll-theme details details[open] {
  border-color: #c89a7a;
}

.xuanhuo-scroll-theme summary {
  padding: 9px 14px;
  cursor: pointer;
  font-weight: bold;
  color: #3d352e;
  background: linear-gradient(135deg,
    rgba(232, 226, 214, 0.9) 0%,
    rgba(220, 214, 202, 0.85) 100%);
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: all 0.25s ease;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  font-size: 0.95em;
  border-radius: 4px;
}
.xuanhuo-scroll-theme summary::-webkit-details-marker { display: none; }
.xuanhuo-scroll-theme summary::marker { display: none; content: ''; }
.xuanhuo-scroll-theme summary::before { display: none; }

/* 展开箭头：丹焰赤 */
.xuanhuo-scroll-theme summary::after {
  content: '▼';
  font-size: 0.75em;
  color: #c85a3c;
  transition: transform 0.3s ease, opacity 0.3s;
  opacity: 0.6;
  flex-shrink: 0;
}
.xuanhuo-scroll-theme details[open] > summary::after {
  transform: rotate(180deg);
  opacity: 0.9;
}
.xuanhuo-scroll-theme details[open] > summary {
  border-bottom-color: #ccc3b4;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(135deg,
    rgba(220, 210, 196, 0.95) 0%,
    rgba(210, 202, 188, 0.9) 100%);
}
.xuanhuo-scroll-theme summary:hover {
  background: linear-gradient(135deg,
    rgba(228, 218, 204, 0.95) 0%,
    rgba(216, 208, 194, 0.9) 100%);
  color: #c85a3c;
}
.xuanhuo-scroll-theme summary:hover::after {
  opacity: 0.85;
}
.xuanhuo-scroll-theme details > :not(summary) {
  padding: 0 10px;
}
.xuanhuo-scroll-theme details > p,
.xuanhuo-scroll-theme details > div {
  padding: 6px 12px;
}

/* ====== 悬浮窗交互系统 ====== */
.xuanhuo-scroll-theme .item {
  position: relative;
  display: inline;
  cursor: pointer;
  border-bottom: 1px dotted currentColor;
  font-weight: bold;
  transition: all 0.2s ease;
}
.xuanhuo-scroll-theme .item:hover {
  filter: brightness(1.15);
  border-bottom-style: solid;
}

/* tip 主体：向上弹出，z-index 9999 */
.xuanhuo-scroll-theme .tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  top: auto;
  left: 50%;
  transform: translateX(-50%);
  min-width: 240px;
  max-width: min(330px, calc(100vw - 32px));
  padding: 0;
  background: #f8f5ee;
  border: 1px solid #b8a898;
  border-radius: 6px;
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.15),
    0 0 1px rgba(200, 90, 60, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #4a443d;
  font-size: 0.875em;
  font-weight: normal;
  line-height: 1.55;
  z-index: 9999;
  white-space: normal;
  text-align: left;
  pointer-events: auto;
  overflow: visible;
}

/* 向下三角箭头 */
.xuanhuo-scroll-theme .tip::before {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: #b8a898;
  pointer-events: none;
  z-index: 2;
}

/* 透明桥接区——防止鼠标穿越间隙时 tip 消失（冰火核心技术） */
.xuanhuo-scroll-theme .tip::after {
  content: '';
  position: absolute;
  top: 100%; left: 0;
  width: 100%;
  height: 18px;
  background: transparent;
  z-index: 1;
}

/* focus / hover 触发 */
.xuanhuo-scroll-theme .item:focus { outline: none; z-index: 1000; }
.xuanhuo-scroll-theme .item:hover { z-index: 1000; }
.xuanhuo-scroll-theme .item:focus > .tip,
.xuanhuo-scroll-theme .item:hover > .tip {
  display: block;
  animation: tipIn 0.15s ease-out;
}

/* tip 内部区域 */
.xuanhuo-scroll-theme .tip-t {
  display: block;
  font-weight: bold;
  font-size: 1.05em;
  padding: 9px 13px 8px;
  margin: 0;
  border-bottom: 1px solid #d4cfc8;
  background: linear-gradient(180deg,
    rgba(220, 214, 202, 0.8) 0%, transparent 100%);
  border-radius: 5px 5px 0 0;
  position: relative;
}
/* tip 顶部品质色线 */
.xuanhuo-scroll-theme .tip-t::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: currentColor;
  opacity: 0.45;
  border-radius: 5px 5px 0 0;
}
/* 描述文字：不使用斜体（斗破古卷风格） */
.xuanhuo-scroll-theme .tip-d {
  display: block;
  color: #7a7068;
  padding: 8px 13px;
  font-size: 0.95em;
  border-bottom: 1px solid rgba(200, 195, 180, 0.4);
}
/* 属性行 */
.xuanhuo-scroll-theme .tip-s {
  display: block;
  color: #3a7a50;
  font-size: 0.95em;
  padding: 6px 13px;
}
/* 效果行 */
.xuanhuo-scroll-theme .tip-e {
  display: block;
  color: #b87820;
  font-size: 0.95em;
  padding: 6px 13px 10px;
  border-top: 1px dashed #d4cfc8;
  background: rgba(184, 120, 32, 0.03);
}

/* ====== 表格 ====== */
.xuanhuo-scroll-theme table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 0.86em;
  border: 1px solid #ccc3b4;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(240, 236, 228, 0.5);
}
.xuanhuo-scroll-theme th {
  background: linear-gradient(180deg,
    rgba(220, 212, 198, 0.95) 0%,
    rgba(208, 200, 186, 0.9) 100%);
  color: #3d352e;
  padding: 7px 10px;
  text-align: left;
  border-bottom: 2px solid #b0a898;
  font-weight: bold;
  font-size: 0.92em;
}
.xuanhuo-scroll-theme td {
  padding: 6px 10px;
  border-bottom: 1px solid #ddd8ce;
  color: #4a443d;
}
.xuanhuo-scroll-theme tr:nth-child(even) td {
  background: rgba(200, 90, 60, 0.03);
}
.xuanhuo-scroll-theme tr:hover td {
  background: rgba(200, 90, 60, 0.06);
}

/* ====== 选项 ====== */
.xuanhuo-scroll-theme .opt {
  display: block;
  padding: 5px 14px;
  margin: 0;
  color: #8a5a3a;
  border-left: 3px solid #d4cfc8;
  transition: all 0.25s ease;
  font-size: 0.95em;
  position: relative;
  border-radius: 0 4px 4px 0;
  line-height: 1.55;
}
.xuanhuo-scroll-theme .opt:hover {
  border-left-color: #c85a3c;
  padding-left: 20px;
  color: #c85a3c;
  background: linear-gradient(90deg,
    rgba(200, 90, 60, 0.05) 0%, transparent 100%);
}
.xuanhuo-scroll-theme .opt::after {
  content: '→';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%) translateX(5px);
  opacity: 0;
  color: #b8a898;
  transition: all 0.25s ease;
  font-size: 0.85em;
}
.xuanhuo-scroll-theme .opt:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ====== 模式标识 ====== */
.xuanhuo-scroll-theme .m-n {
  color: #4a7a60;
}
.xuanhuo-scroll-theme .m-c {
  color: #c84040;
  text-shadow: 0 0 5px rgba(200, 64, 64, 0.28);
  animation: pulseGlow 2s ease-in-out infinite;
}
.xuanhuo-scroll-theme .m-i {
  color: #c05080;
  text-shadow: 0 0 5px rgba(192, 80, 128, 0.25);
  animation: pulseGlow 2.2s ease-in-out infinite;
}

/* ====== 加粗 ====== */
.xuanhuo-scroll-theme strong,
.xuanhuo-scroll-theme b {
  color: #3d352e;
  font-weight: bold;
}

/* ====== 分隔线 ====== */
.xuanhuo-scroll-theme hr {
  border: none;
  height: 1px;
  margin: 10px 0;
  background: linear-gradient(90deg,
    transparent 0%, #ccc3b4 25%, #b0a898 50%, #ccc3b4 75%, transparent 100%);
}

/* ====== 列表 ====== */
.xuanhuo-scroll-theme li {
  margin: 3px 0;
  padding-left: 4px;
}
.xuanhuo-scroll-theme li::marker {
  color: #c85a3c;
}

/* ====== 代码块 ====== */
.xuanhuo-scroll-theme code {
  background: rgba(200, 90, 60, 0.07);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
  color: #a05030;
  border: 1px solid rgba(200, 90, 60, 0.12);
}

/* ====== 引用块 ====== */
.xuanhuo-scroll-theme blockquote {
  border-left: 3px solid #c8a898;
  margin: 8px 0;
  padding: 6px 12px;
  background: rgba(200, 168, 152, 0.06);
  color: #7a6a60;
  border-radius: 0 4px 4px 0;
}

/* ====== 滚动条 ====== */
.xuanhuo-scroll-theme ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.xuanhuo-scroll-theme ::-webkit-scrollbar-track {
  background: rgba(220, 214, 202, 0.5);
  border-radius: 3px;
}
.xuanhuo-scroll-theme ::-webkit-scrollbar-thumb {
  background: #b8a898;
  border-radius: 3px;
}
.xuanhuo-scroll-theme ::-webkit-scrollbar-thumb:hover {
  background: #9a8878;
}

/* ====== 移动端适配 ====== */
@media (max-width: 600px) {
  .xuanhuo-scroll-theme {
    font-size: 14px;
    padding: 12px 6px 16px;
    border-radius: 6px;
  }
  .xuanhuo-scroll-theme .text {
    font-size: 14.5px;
    padding: 10px 4px;
    line-height: 1.88;
  }
  .xuanhuo-scroll-theme .tip {
    min-width: 200px;
    max-width: min(272px, calc(100vw - 24px));
    font-size: 0.84em;
    left: 0;
    transform: translateX(0);
  }
  .xuanhuo-scroll-theme .tip::before {
    left: 20px;
    transform: none;
  }
  .xuanhuo-scroll-theme summary {
    padding: 7px 10px;
    font-size: 0.92em;
  }
  .xuanhuo-scroll-theme .opt {
    padding: 4px 10px;
    font-size: 0.93em;
  }
  .xuanhuo-scroll-theme th,
  .xuanhuo-scroll-theme td {
    padding: 5px 7px;
  }
  .xuanhuo-scroll-theme details > :not(summary) {
    padding: 0 6px;
  }
}
@media (max-width: 380px) {
  .xuanhuo-scroll-theme {
    font-size: 13px;
    padding: 10px 4px 14px;
  }
  .xuanhuo-scroll-theme .text {
    font-size: 13.5px;
  }
  .xuanhuo-scroll-theme .tip {
    min-width: 180px;
    max-width: min(234px, calc(100vw - 16px));
  }
}

/* ====== 低动效偏好 ====== */
@media (prefers-reduced-motion: reduce) {
  .xuanhuo-scroll-theme::before {
    animation-duration: 10s;
  }
  .xuanhuo-scroll-theme .q-t,
  .xuanhuo-scroll-theme .q-r,
  .xuanhuo-scroll-theme .m-c,
  .xuanhuo-scroll-theme .m-i {
    animation: none;
  }
}

/* ============================================= */
/*  修罗宝典 · Rili平台全局美化扩展                */
/* ============================================= */

/* ====== 宝典容器撑满AI气泡（采纳优化） ====== */
.rili-markdown-renderer:has(.xuanhuo-scroll-theme) {
  margin: -12px -16px;
}
.rili-markdown-renderer .xuanhuo-scroll-theme {
  margin: 0;
  border-radius: 8px;
}

/* ====== AI气泡：古卷质地 ====== */
.group.is-assistant > div:first-child {
  background: #f2efe8 !important;
  background-image:
    url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4"%3E%3Cpath fill="%23ccc3b4" fill-opacity="0.18" d="M1 3h1v1H1V3zm2-2h1v1H3V1z"%3E%3C/path%3E%3C/svg%3E') !important;
  border: 1px solid #ccc3b4 !important;
  color: #4a443d !important;
  box-shadow:
    0 3px 14px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6) !important;
  position: relative;
}
.group.is-assistant > div:first-child::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%, #d4956a 10%, #c85a3c 35%,
    #e87050 50%, #c85a3c 65%, #d4956a 90%, transparent 100%);
  border-radius: 8px 8px 0 0;
  animation: scrollShimmer 4s ease-in-out infinite;
  pointer-events: none;
}

/* ====== 用户气泡：浅赭印章纸 ====== */
.group.is-user > div:first-child {
  background: linear-gradient(135deg, #ede4d6 0%, #e6dccb 100%) !important;
  border: 1px solid #c8a898 !important;
  color: #4a3d35 !important;
  box-shadow:
    0 2px 8px rgba(154, 80, 64, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  position: relative;
}
.group.is-user > div:first-child::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 94%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c85a3c, transparent);
  border-radius: 8px;
  opacity: 0.5;
}

/* ====== 操作按钮组：青铜印鉴 ====== */
.bg-muted.rounded.flex.p-0\.5 {
  background: linear-gradient(135deg, #ede9e0, #ddd5c5) !important;
  border: 1px solid #ccc3b4 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4) !important;
  border-radius: 6px !important;
}
.bg-muted.rounded.flex.p-0\.5 button {
  transition: all 0.25s ease !important;
}
.bg-muted.rounded.flex.p-0\.5 button:hover {
  background: rgba(200, 90, 60, 0.12) !important;
}
.bg-muted.rounded.flex.p-0\.5 button:hover svg {
  stroke: #c85a3c !important;
}

/* ====== Token计数小标 ====== */
.font-mono.text-muted-foreground {
  background: rgba(200, 90, 60, 0.06) !important;
  border: 1px solid rgba(200, 90, 60, 0.15);
  border-radius: 4px !important;
  color: #8a6a5a !important;
}
.font-mono .bg-blue-500\/60 { background: #c85a3c !important; }
.font-mono .bg-green-500\/60 { background: #b8941e !important; }

/* ====== 加载中三点：丹焰跃动 ====== */
.bg-primary.rounded-full {
  background: linear-gradient(135deg, #e87050, #c85a3c) !important;
  box-shadow: 0 0 8px rgba(200, 90, 60, 0.4);
}

/* ====== 输入栏：古砚台 ====== */
textarea,
[contenteditable="true"] {
  background: #f8f5ee !important;
  border: 1px solid #ccc3b4 !important;
  color: #4a443d !important;
  font-family: "Georgia", "Noto Serif SC", "SimSun", serif !important;
  border-radius: 8px !important;
  transition: all 0.3s ease !important;
}
textarea:focus,
[contenteditable="true"]:focus {
  border-color: #c85a3c !important;
  box-shadow: 0 0 0 3px rgba(200, 90, 60, 0.12), inset 0 1px 0 rgba(255,255,255,0.5) !important;
  outline: none !important;
}

/* 输入栏外层容器 */
form, 
[class*="input"] [class*="border"] {
  border-radius: 10px;
}

/* ====== 发送按钮 / 主操作按钮：丹焰印章 ====== */
button[type="submit"],
button.bg-primary {
  background: linear-gradient(135deg, #d4956a 0%, #c85a3c 50%, #a04020 100%) !important;
  border: 1px solid #a04020 !important;
  color: #faf6e8 !important;
  box-shadow:
    0 2px 8px rgba(200, 90, 60, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
  transition: all 0.25s ease !important;
}
button[type="submit"]:hover,
button.bg-primary:hover {
  background: linear-gradient(135deg, #e8a578, #d86a4a, #b04828) !important;
  box-shadow:
    0 4px 14px rgba(200, 90, 60, 0.45),
    0 0 12px rgba(232, 112, 80, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.3) !important;
  transform: translateY(-1px);
}

/* ====== 全局滚动条 ====== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track {
  background: rgba(220, 214, 202, 0.4);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c8a898, #b08878);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #c85a3c, #a04020);
}

/* ====== 焦点环统一为丹焰色 ====== */
*:focus-visible {
  outline-color: #c85a3c !important;
}

/* ====== 移动端微调 ====== */
@media (max-width: 600px) {
  .group.is-assistant > div:first-child,
  .group.is-user > div:first-child {
    border-radius: 6px !important;
  }
}