/* ============================================================
   整合后 CSS · 全局美化 + 独立侧边栏（地图形式，多实例支持）
   已删除进度条 / 侧边栏 Tooltip / 优化加载动画 / 无棱角气泡 / 地图完整显示
   悬浮球紧挨侧边栏上方 / 地图亮度提升
   ============================================================ */

/* ---------- 1. 全局背景、文字、滚动条、选区、输入、按钮、链接 ---------- */
html, body {
  background-color: #08080a !important;
  color: #f0e6d2 !important;
}

body, article, main, .content, section,
.markdown-body, .post-content, .entry-content {
  background-color: #08080a !important;
  color: #f0e6d2 !important;
}

p, div, li, h1, h2, h3, h4, h5, h6, span, a:not(.special) {
  color: inherit !important;
}

::-webkit-scrollbar {
  width: 6px !important;
  height: 6px !important;
}
::-webkit-scrollbar-track {
  background: rgba(10, 14, 18, 0.6) !important;
  border-radius: 4px !important;
}
::-webkit-scrollbar-thumb {
  background: #1a6d9e !important;
  border-radius: 4px !important;
  box-shadow: 0 0 8px rgba(26, 109, 158, 0.45) !important;
}
::-webkit-scrollbar-thumb:hover {
  background: #3ba9d9 !important;
  box-shadow: 0 0 12px rgba(59, 169, 217, 0.65) !important;
}

::selection {
  background: #1a6d9e !important;
  color: #ffffff !important;
  text-shadow: none !important;
}

input[type="text"],
input[type="number"],
input[type="search"],
input[type="password"],
input[type="email"],
textarea,
select {
  background: rgba(10, 14, 18, 0.85) !important;
  border: 1px solid #1a6d9e !important;
  color: #e8f0f8 !important;
  padding: 8px 12px !important;
  border-radius: 6px !important;
  outline: none !important;
  font-family: inherit !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 0 10px rgba(26, 109, 158, 0.35),
              inset 0 0 8px rgba(26, 109, 158, 0.18) !important;
  caret-color: #3ba9d9 !important;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #3ba9d9 !important;
  box-shadow: 0 0 20px rgba(59, 169, 217, 0.55),
              0 0 40px rgba(26, 109, 158, 0.35),
              inset 0 0 10px rgba(26, 109, 158, 0.3) !important;
  animation: input-glow-pulse 2.5s ease-in-out infinite alternate !important;
}

input::placeholder,
textarea::placeholder {
  color: #3ba9d9 !important;
  opacity: 0.6 !important;
  text-shadow: 0 0 8px rgba(59, 169, 217, 0.35) !important;
}

button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn {
  background: linear-gradient(145deg, #0f1a24, #1a2d3d) !important;
  border: 1px solid #1a6d9e !important;
  color: #e8f0f8 !important;
  padding: 8px 20px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-weight: bold !important;
  text-shadow: 0 0 5px rgba(26, 109, 158, 0.6) !important;
  box-shadow: 0 0 12px rgba(26, 109, 158, 0.35),
              inset 0 0 6px rgba(26, 109, 158, 0.25) !important;
  transition: all 0.3s ease !important;
  outline: none !important;
}

button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
input[type="reset"]:hover,
.btn:hover {
  background: linear-gradient(145deg, #1a2d3d, #26587a) !important;
  border-color: #3ba9d9 !important;
  box-shadow: 0 0 22px rgba(59, 169, 217, 0.55),
              0 0 40px rgba(26, 109, 158, 0.35),
              inset 0 0 10px rgba(26, 109, 158, 0.4) !important;
  color: #a0e7ff !important;
  text-shadow: 0 0 12px #1a6d9e !important;
}

button:active,
input[type="button"]:active,
input[type="submit"]:active,
input[type="reset"]:active,
.btn:active {
  transform: scale(0.97) !important;
  box-shadow: 0 0 15px rgba(26, 109, 158, 0.55),
              inset 0 0 15px rgba(26, 109, 158, 0.45) !important;
}

button svg,
input[type="button"] svg,
input[type="submit"] svg {
  stroke: #3ba9d9 !important;
  fill: none !important;
  filter: drop-shadow(0 0 6px rgba(59, 169, 217, 0.7)) !important;
}

a {
  color: #3ba9d9 !important;
  text-decoration: underline dotted rgba(59, 169, 217, 0.4) !important;
  transition: all 0.2s ease !important;
}

a:hover {
  color: #a0e7ff !important;
  text-shadow: 0 0 8px #3ba9d9 !important;
}

/* ---------- 2. 聊天气泡及装饰（无棱角全圆角） ---------- */
.chat-container {
    background: #0a0e12;
    color: #e8f0f8;
}

.group.is-user > div:first-child,
.group.is-assistant > div:first-child {
  position: relative !important;
  z-index: 1 !important;
}

.group.is-user > div:first-child {
  background: #0f1a24 !important;
  border: 1px solid #1a6d9e !important;
  border-radius: 16px !important;
  padding: 16px !important;
  color: #dce8f0 !important;
  box-shadow: 0 0 18px rgba(26, 109, 158, 0.18), inset 0 0 18px rgba(26, 109, 158, 0.10) !important;
}

.group.is-assistant > div:first-child {
  background: #0d161e !important;
  border: 1px solid #1a6d9e !important;
  border-radius: 16px !important;
  padding: 16px !important;
  color: #f0e6d2 !important;
  box-shadow: 0 0 18px rgba(26, 109, 158, 0.18), inset 0 0 18px rgba(26, 109, 158, 0.10) !important;
}

.group.is-user > div:first-child::before,
.group.is-user > div:first-child::after,
.group.is-assistant > div:first-child::before,
.group.is-assistant > div:first-child::after {
  content: '' !important;
  position: absolute !important;
  width: 12px !important;
  height: 12px !important;
  border: 1.5px solid #3ba9d9 !important;
  opacity: 0.4 !important;
  pointer-events: none !important;
  z-index: 2 !important;
}

.group.is-user > div:first-child::before,
.group.is-assistant > div:first-child::before {
  top: -1px !important;
  left: -1px !important;
  border-right: none !important;
  border-bottom: none !important;
}

.group.is-user > div:first-child::after,
.group.is-assistant > div:first-child::after {
  bottom: -1px !important;
  right: -1px !important;
  border-left: none !important;
  border-top: none !important;
}

/* ---------- 3. 正文渲染、工具条、状态指示 ---------- */
.rili-markdown-renderer,
.rili-markdown-renderer * {
  color: #dce8f0 !important;
  caret-color: #3ba9d9 !important;
  text-shadow: 0 0 6px rgba(59, 169, 217, 0.15) !important;
}

.text-xs.font-mono.text-muted-foreground {
  color: #3ba9d9 !important;
  text-shadow: 0 0 8px rgba(59, 169, 217, 0.35) !important;
  border-top: 1px solid rgba(26, 109, 158, 0.2) !important;
  padding-top: 4px !important;
}

.text-xs.font-mono.text-muted-foreground .text-green-500 {
  color: #3ba9d9 !important;
  box-shadow: 0 0 12px #3ba9d9 !important;
  animation: camera-led-pulse 1.8s infinite !important;
}

.bg-muted.rounded.flex {
  background: rgba(10, 14, 18, 0.85) !important;
  border: 1px solid #1a6d9e !important;
  border-radius: 12px !important;
  box-shadow: 0 0 16px rgba(26, 109, 158, 0.2) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  padding: 6px 8px !important;
}

.bg-muted.rounded.flex button {
  background: #0f1a24 !important;
  border: 1px solid #1a6d9e !important;
  color: #3ba9d9 !important;
  border-radius: 8px !important;
  box-shadow: 0 0 10px rgba(26, 109, 158, 0.3) !important;
  transition: all 0.25s ease !important;
}

.bg-muted.rounded.flex button:hover {
  background: #1a2d3d !important;
  border-color: #3ba9d9 !important;
  box-shadow: 0 0 20px rgba(59, 169, 217, 0.45) !important;
}

.bg-muted.rounded.flex button svg {
  stroke: #3ba9d9 !important;
  fill: none !important;
  filter: drop-shadow(0 0 6px rgba(59, 169, 217, 0.7)) !important;
}

.group .md\:opacity-0 {
  opacity: 1 !important;
}

/* ---------- 4. 加载动画（仅中心星脉动，星环已移除） ---------- */
.flex.gap-2.w-full.h-full.items-center.justify-center {
  position: relative !important;
  min-height: 72px !important;
  background: transparent !important;
}

.flex.gap-2.w-full.h-full.items-center.justify-center > span {
  display: none !important;
}

.flex.gap-2.w-full.h-full.items-center.justify-center::after {
  content: "✦" !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  font-size: 30px !important;
  line-height: 1 !important;
  color: #5ec8f0 !important;
  text-shadow: 0 0 18px #3ba9d9,
               0 0 36px rgba(59, 169, 217, 0.6),
               0 0 60px rgba(59, 169, 217, 0.35) !important;
  animation: loader-core-pulse 1.8s ease-in-out infinite !important;
  pointer-events: none !important;
  z-index: 3 !important;
}

/* ---------- 5. 进度条样式已删除 ---------- */

/* ---------- 6. 折叠面板 ---------- */
details,
.cyber-details {
  background: rgba(10, 14, 18, 0.85) !important;
  backdrop-filter: blur(16px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.6) !important;
  border: 1.5px solid #1a6d9e !important;
  border-radius: 14px !important;
  box-shadow: 0 0 22px rgba(26, 109, 158, 0.4),
              inset 0 0 20px rgba(26, 109, 158, 0.12) !important;
  padding: 20px 22px !important;
  margin-top: 20px !important;
  color: #f0e6d2 !important;
  position: relative !important;
  overflow: visible !important;
  transition: box-shadow 0.3s ease !important;
}

details:hover,
.cyber-details:hover {
  box-shadow: 0 0 34px rgba(59, 169, 217, 0.65),
              inset 0 0 25px rgba(26, 109, 158, 0.2) !important;
}

details::before,
details::after {
  content: '' !important;
  position: absolute !important;
  width: 16px !important;
  height: 16px !important;
  border: 2px solid #3ba9d9 !important;
  opacity: 0.6 !important;
  pointer-events: none !important;
  z-index: 2 !important;
}

details::before {
  top: -1px !important;
  left: -1px !important;
  border-right: none !important;
  border-bottom: none !important;
  border-radius: 4px 0 0 0 !important;
  box-shadow: -3px -3px 14px rgba(59, 169, 217, 0.3) !important;
}

details::after {
  bottom: -1px !important;
  right: -1px !important;
  border-left: none !important;
  border-top: none !important;
  border-radius: 0 0 4px 0 !important;
  box-shadow: 3px 3px 14px rgba(59, 169, 217, 0.3) !important;
}

summary {
  color: #3ba9d9 !important;
  font-size: 1.1em !important;
  font-weight: bold !important;
  text-shadow: 0 0 8px rgba(59, 169, 217, 0.7),
               0 0 20px rgba(26, 109, 158, 0.4) !important;
  padding: 12px 20px !important;
  background: linear-gradient(145deg, #0b1a26, #172d3d) !important;
  border-radius: 10px !important;
  margin: -18px -18px 15px -18px !important;
  list-style: none !important;
  outline: none !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  position: relative !important;
  overflow: hidden !important;
}

summary::after {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: -100% !important;
  width: 100% !important;
  height: 100% !important;
  background: linear-gradient(90deg, transparent, rgba(59, 169, 217, 0.2), transparent) !important;
  animation: summary-sweep 3s infinite !important;
}

summary::-webkit-details-marker {
  display: none !important;
}

summary::before {
  content: "✧" !important;
  color: #3ba9d9 !important;
  margin-right: 14px !important;
  font-size: 1em !important;
  transition: transform 0.35s ease !important;
  filter: drop-shadow(0 0 5px #3ba9d9) !important;
}

details[open] summary::before {
  transform: rotate(90deg) !important;
}

summary:hover {
  background: linear-gradient(145deg, #172d3d, #26587a) !important;
  color: #5ec8f0 !important;
  text-shadow: 0 0 12px #1a6d9e !important;
}

details > :where(p, div, ul, ol, dl, blockquote, pre, h1, h2, h3, h4, h5, h6, table) {
  color: #f0e6d2 !important;
  padding: 10px 0 !important;
  margin-left: 12px !important;
  border-left: 3px solid transparent !important;
  padding-left: 15px !important;
  transition: all 0.25s ease !important;
}

details > :where(p, div, ul, ol, dl, blockquote, pre, h1, h2, h3, h4, h5, h6, table):hover {
  background-color: rgba(26, 109, 158, 0.12) !important;
  border-left: 3px solid #1a6d9e !important;
  box-shadow: 0 0 10px rgba(26, 109, 158, 0.3) !important;
}

details button,
details input {
  border-left: none !important;
  padding-left: initial !important;
  margin-left: 0 !important;
}

/* ---------- 7. 通用 Tooltip（全局 <t> 和 <ti>，保留） ---------- */
t {
  cursor: pointer !important;
  color: #5ec8f0 !important;
  font-weight: 700 !important;
  text-shadow: 0 0 8px rgba(94, 200, 240, 0.8), 0 0 16px rgba(59, 169, 217, 0.5) !important;
  text-decoration: underline dotted #5ec8f0 !important;
  text-underline-offset: 3px !important;
  position: relative !important;
  display: inline-block !important;
  outline: none !important;
  user-select: none !important;
  z-index: 99 !important;
}

t:hover {
  color: #a0e7ff !important;
  text-shadow: 0 0 12px #5ec8f0, 0 0 24px #3ba9d9 !important;
  text-decoration-color: #a0e7ff !important;
  z-index: 1001 !important;
  outline: 2px solid #3ba9d9 !important;
  outline-offset: 2px !important;
}

ti {
  display: none !important;
  position: absolute !important;
  bottom: calc(100% + 14px) !important;
  left: 0 !important;
  background: linear-gradient(145deg, #0b1a26, #172d3d) !important;
  border: 1.5px solid #1a6d9e !important;
  border-radius: 10px !important;
  box-shadow: 0 0 18px rgba(26, 109, 158, 0.7),
              inset 0 0 10px rgba(26, 109, 158, 0.3) !important;
  padding: 10px 16px !important;
  color: #e8f0f8 !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  width: 220px !important;
  max-width: 90vw !important;
  white-space: normal !important;
  word-wrap: break-word !important;
  z-index: 1000 !important;
  backdrop-filter: blur(16px) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  text-align: left !important;
  pointer-events: auto !important;
}

ti::before {
  content: '' !important;
  position: absolute !important;
  top: -1px !important;
  left: -1px !important;
  width: 10px !important;
  height: 10px !important;
  border: 1.5px solid #3ba9d9 !important;
  border-right: none !important;
  border-bottom: none !important;
  border-radius: 3px 0 0 0 !important;
  opacity: 0.5 !important;
}

ti::after {
  content: '' !important;
  position: absolute !important;
  top: 100% !important;
  left: 16px !important;
  border-width: 7px !important;
  border-style: solid !important;
  border-color: #1a6d9e transparent transparent transparent !important;
}

t:hover > ti,
t:active > ti,
t:focus > ti {
  display: block !important;
}

/* ---------- 8. 独立侧边栏（按钮触发，多实例支持，地图完整显示 4:3，悬浮球在上方） ---------- */
.sidebar-unit {
  position: relative;
}

/* 触发按钮（悬浮球 - 强制圆形，紧挨侧边栏上方） */
.sidebar-unit .sidebar-toggle-button {
  position: fixed;
  top: calc(15vh - 48px - 8px);   /* 位于侧边栏顶部上方 8px */
  right: 20px;                     /* 默认位置，侧边栏关闭时可见 */
  width: 48px;
  height: 48px;
  aspect-ratio: 1 / 1;
  min-width: 48px;
  min-height: 48px;
  background: rgba(10, 14, 18, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #1a6d9e;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #3ba9d9;
  cursor: pointer;
  z-index: 10001;
  box-shadow: 0 0 25px rgba(26, 109, 158, 0.25);
  transition: all 0.3s ease;
  user-select: none;
  outline: none;
  padding: 0;
  line-height: 1;
  box-sizing: border-box;
}

/* 侧边栏打开时，悬浮球移动到侧边栏上方中央 */
.sidebar-unit:has(.sidebar-container.active) .sidebar-toggle-button,
.sidebar-unit:focus-within .sidebar-toggle-button {
  right: calc(280px / 2 - 24px);   /* 侧边栏宽280px，悬浮球宽48px，水平居中 */
  top: calc(15vh - 48px - 8px);    /* 保持紧挨上方 */
}

.sidebar-unit .sidebar-toggle-button:hover,
.sidebar-unit .sidebar-toggle-button:focus {
  background: rgba(26, 109, 158, 0.25);
  border-color: #3ba9d9;
  box-shadow: 0 0 40px rgba(26, 109, 158, 0.4);
}

/* 侧边栏容器 - 地图形式，背景 contain 完整显示 4:3，亮度提升 */
.sidebar-unit .sidebar-container {
  position: fixed;
  top: 15vh;
  right: -320px;
  width: 280px;
  max-width: 85vw;
  height: 60vh;
  max-height: 70vh;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(10, 14, 18, 0.25), rgba(8, 10, 14, 0.45)),  /* 亮度提升：降低暗色遮罩透明度 */
    url("https://pic1.imgdb.cn/i/0349j7EBgWrdQcUNPwgG4M.jpg") center / contain no-repeat;
  background-color: #0a0e12;
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-left: 2px solid #1a6d9e;
  border-radius: 16px 0 0 16px;
  box-shadow: -4px 0 50px rgba(26, 109, 158, 0.2),
              inset 0 0 80px rgba(0, 0, 0, 0.3) !important;   /* 内阴影也降低 */
  padding: 0;
  z-index: 10000;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  color: #e8f0f8;
  font-family: 'Segoe UI', 'PingFang SC', sans-serif;
  box-sizing: border-box;
}

/* 隐藏旧侧边栏内容，只保留地图背景 */
.sidebar-unit .sidebar-container > *:not(.sidebar-map) {
  display: none !important;
}

.sidebar-unit .sidebar-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px 0 0 14px;
  border: none;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3);
}

/* 侧边栏打开状态 */
.sidebar-unit .sidebar-toggle-button:focus + .sidebar-container,
.sidebar-unit .sidebar-toggle-button:focus-within + .sidebar-container,
.sidebar-unit .sidebar-container.active,
.sidebar-unit .sidebar-container:focus-within {
  right: 0;
}

/* 当侧边栏内部获得焦点时，保持按钮高亮 */
.sidebar-unit .sidebar-container:focus-within + .sidebar-toggle-button,
.sidebar-unit .sidebar-toggle-button:focus {
  background: rgba(26, 109, 158, 0.25);
  border-color: #3ba9d9;
  box-shadow: 0 0 40px rgba(26, 109, 158, 0.4);
}

/* 角标装饰 */
.sidebar-unit .sidebar-container::before,
.sidebar-unit .sidebar-container::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #3ba9d9;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.4s, box-shadow 0.4s;
  z-index: 10;
}

.sidebar-unit .sidebar-container::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-radius: 4px 0 0 0;
  box-shadow: -3px -3px 14px rgba(59, 169, 217, 0.25);
}

.sidebar-unit .sidebar-container::after {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-radius: 0 0 4px 0;
  box-shadow: 3px 3px 14px rgba(59, 169, 217, 0.25);
}

.sidebar-unit .sidebar-container:hover::before,
.sidebar-unit .sidebar-container:hover::after {
  opacity: 0.9;
  box-shadow: 0 0 30px rgba(59, 169, 217, 0.5);
}

/* 滚动条 */
.sidebar-unit .sidebar-container::-webkit-scrollbar {
  width: 4px;
}
.sidebar-unit .sidebar-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}
.sidebar-unit .sidebar-container::-webkit-scrollbar-thumb {
  background: #1a6d9e;
  border-radius: 4px;
}

/* 响应式调整 */
@media (max-width: 640px) {
  .sidebar-unit .sidebar-toggle-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 20px;
    right: 12px;
    top: calc(12vh - 40px - 6px);   /* 紧挨侧边栏上方，侧边栏 top:12vh */
    border-radius: 50% !important;
  }
  .sidebar-unit:has(.sidebar-container.active) .sidebar-toggle-button,
  .sidebar-unit:focus-within .sidebar-toggle-button {
    right: calc(80vw / 2 - 20px);   /* 侧边栏宽80vw，悬浮球宽40px，水平居中 */
    top: calc(12vh - 40px - 6px);
  }
  .sidebar-unit .sidebar-container {
    width: 80vw;
    right: -80vw;
    top: 12vh;
    height: 55vh;
    max-height: 60vh;
    padding: 0;
    border-radius: 14px 0 0 14px;
  }
  .sidebar-unit .sidebar-map {
    min-height: 160px;
    border-radius: 12px 0 0 12px;
  }
}

/* ---------- 9. 关键帧（整合） ---------- */
@keyframes loader-core-pulse {
  0%, 100% {
    opacity: 0.65;
    text-shadow: 0 0 18px #3ba9d9,
                 0 0 36px rgba(59, 169, 217, 0.6),
                 0 0 60px rgba(59, 169, 217, 0.35);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 28px #5ec8f0,
                 0 0 56px rgba(94, 200, 240, 0.8),
                 0 0 90px rgba(59, 169, 217, 0.5);
  }
}

@keyframes summary-sweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes input-glow-pulse {
  from {
    box-shadow: 0 0 15px rgba(26, 109, 158, 0.45),
                0 0 30px rgba(26, 109, 158, 0.3),
                inset 0 0 5px rgba(26, 109, 158, 0.2);
  }
  to {
    box-shadow: 0 0 22px rgba(59, 169, 217, 0.7),
                0 0 45px rgba(26, 109, 158, 0.45),
                inset 0 0 12px rgba(26, 109, 158, 0.4);
  }
}

@keyframes camera-led-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}