*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background-color: #0b0e11; /* Binance 深色背景 */
  color: #eaecef;
}

body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* 防止任何元素在移动端横向溢出 */
}

/* SPA 根容器：让当前页面主体撑满剩余空间，保证页脚贴底 */
#spa-root {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#spa-root > [data-page] {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: flex-start;  /* PC 端标题 + 导航靠左 */
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #2b3139;
  background-color: #181a20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.1rem;  /* 缩小侧滑按钮与标题之间的间距 */
}

.header-left h1 {
  margin: 0;
}

.header-logo-wrap {
  display: flex;
  align-items: center;
}

.header-logo {
  display: block;
  height: 44px;
  width: auto;
}

.symbol-highlight {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0b90b; /* Binance 主题黄 */
  margin-right: 0.25rem;
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #9ca3af;
}

.header-nav {
  display: inline-flex;
  align-items: center;
  gap: 1.5rem;
}

.header-nav-link {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.9rem;
}

.header-nav-link:hover {
  color: #fcd535;
}

.header-nav-link--active {
  color: #f0b90b;
  font-weight: 600;
}

.header-menu-btn {
  display: none;
  border: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 1.1rem;
  cursor: pointer;
  margin-left: auto;
}

.nav-drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
  justify-content: flex-start; /* 侧滑面板固定在左侧 */
}

.nav-drawer--open {
  display: flex;
}

.nav-drawer-backdrop {
  flex: 1;
  background-color: rgba(0, 0, 0, 0.5);
}

.nav-drawer-panel {
  width: 220px;
  background-color: #181a20;
  border-right: 1px solid #2b3139;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transform: translateX(-100%);
  transition: transform 0.2s ease-out;
}

.nav-drawer--open .nav-drawer-panel {
  transform: translateX(0);
}

.nav-drawer-link {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-drawer-link:hover {
  color: #fcd535;
}

.nav-drawer-link--active {
  color: #f0b90b;
  font-weight: 600;
}

.nav-drawer-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #e5e7eb;
  text-align: left;      /* 标题居左显示 */
  width: 100%;
  margin-bottom: 0.5rem;
}

.nav-drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;         /* 增大导航项上下间距 */
  align-items: flex-start; /* 导航项整体居左 */
}

.nav-drawer-link {
  text-align: left;     /* 导航文字居左 */
  font-size: 1.05rem;   /* 导航文字略放大 */
}

/* PC 端：在保持按钮与标题紧凑的同时，拉开标题与导航的间距 */
@media (min-width: 769px) {
  .header-nav {
    margin-left: 4.8rem;  /* 加宽标题与导航之间的间距（仅 PC 端） */
  }
}

.status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background-color: #6b7280;
}

.status-dot--idle {
  background-color: #6b7280;
}

.status-dot--ok {
  background-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
}

.status-dot--error {
  background-color: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
}

.timestamp {
  display: flex;
  align-items: center;
  gap: 0.05rem; /* 减小“下次更新：”与倒计时之间的间距 */
}

.timestamp span:last-child {
  color: #9ca3af;
}

.timestamp #last-update {
  display: inline-block;
  width: 0.5ch;       /* 稍微缩短固定宽度，减少视觉空隙 */
  text-align: right;
}

.layout {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 1.25rem 2rem 1.75rem;
}

@media (max-width: 768px) {
  .layout {
    padding: 0.75rem 1rem 1.25rem;
  }
}

.panel {
  background-color: #181a20;
  border-radius: 0.75rem;
  padding: 0.9rem 1rem 0.9rem;
  border: 1px solid #2b3139;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 980px;
  width: 100%;
}

.index-panel {
  border-top: 2px solid #f0b90b; /* 顶部加一条 Binance 黄强调线 */
}

.analysis-layout {
  padding-top: 1.5rem;
}

.analysis-panel {
  max-width: 1120px;
}

.analysis-main {
  display: flex;
  gap: 0;               /* 分割线两侧间距由 padding 控制 */
  margin-top: 0.25rem;
}

.analysis-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid #2b3139;
  padding-right: 0.5rem;  /* 分割线左侧间距 */
  margin-right: 0;        /* 不额外增加外边距 */
}

.analysis-sidebar-header {
  font-size: 0.8rem;
  color: #848e9c;
  margin-bottom: 0.5rem;
}

.symbol-sidebar-search {
  width: 100%;
  margin-bottom: 0.4rem;
  padding: 0.3rem 0.45rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(75, 85, 99, 0.8);
  background-color: #181a20;
  color: #eaecef;
  font-size: 0.8rem;
}

.symbol-sidebar-search:focus {
  outline: none;
  border-color: #f0b90b;
}

.symbol-sidebar-list {
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.symbol-sidebar-item {
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: none;
  background: transparent;
  color: #eaecef;
  font-size: 0.82rem;
  cursor: pointer;
}

.symbol-sidebar-item:hover {
  background-color: #2b3139;
}

.symbol-sidebar-item.active {
  background-color: #2b3139;
  color: #f0b90b;
}

.analysis-content {
  flex: 1;
  min-width: 0;
  padding-left: 1rem;  /* 分割线右侧间距，与左侧保持一致 */
}

.panel h2 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 500;
  color: #eaecef;
  text-align: left;
}

.panel .subtitle-inline {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: #848e9c;
  text-align: left;
  max-width: 100%;
  word-break: break-word;
}

/* ---- 首页：ticker 详情展开区域 --------------------------------------------- */

.detail-row {
  background-color: #15171d;
}

.detail-cell {
  padding: 0.5rem 0.75rem 0.7rem;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.detail-line {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}

.detail-item {
  display: flex;
  align-items: baseline;
}

.detail-item--right {
  margin-left: auto;
  text-align: right;
}

.detail-item-label {
  display: inline;
  color: #848e9c;
  margin-right: 0.15rem;
}

.detail-item-value {
  display: inline;
  font-weight: 500;
}

/* Binance 风格的红跌绿涨配色 */
.detail-item-value--up {
  color: #0ecb81;
}

.detail-item-value--down {
  color: #f6465d;
}

.row-expand-icon {
  display: inline-block;
  margin-right: 0.3rem;
  font-size: 0.75rem;
  color: #9ca3af;
  cursor: pointer;
}

/* PC 端：四个 ticker 字段在一行等宽显示 */
@media (min-width: 769px) {
  .detail-content {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 1.75rem;
    row-gap: 0.25rem;
  }

  .detail-line {
    display: contents; /* 让内部的 detail-item 直接参与网格布局 */
  }

  .detail-item {
    justify-content: center;
    text-align: center;
  }

  /* PC 端：通过显式类控制左右对齐 */
  .detail-item--left {
    justify-content: flex-start;
    text-align: left;
  }

  .detail-item--right {
    justify-content: flex-end;
    text-align: right;
  }
}

/* 移动端：每行第二个 ticker 项目靠右，其余保持默认（靠左） */
@media (max-width: 768px) {
  .detail-line .detail-item:last-child {
    margin-left: auto;
    text-align: right;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0.75rem 0.25rem; /* 所有页面在移动端统一 header 左右内边距 */
  }

  /* 分析页移动端：主内容区左右内边距仅由 panel 控制，避免整体偏右 */
  .page-analysis .analysis-content {
    padding-left: 0;
  }

  .panel .subtitle-inline {
    font-size: 0.75rem;
    line-height: 1.4;
  }

  /* 首页移动端：隐藏顶部导航，使用侧滑菜单 */
  .header-nav {
    display: none;
  }

  .header-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .header-logo {
    height: 40px; /* 移动端放大 Logo 尺寸，提升品牌识别度 */
  }
}

.title-dropdown-icon {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.8rem;
  color: #9ca3af;
  cursor: pointer;
}

.symbol-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.75);
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  z-index: 1000;
}

.symbol-modal {
  width: 260px;
  max-width: 80%;
  height: 100%;
  background-color: #181a20;
  border-radius: 0 0.75rem 0.75rem 0;
  border: 1px solid rgba(148, 163, 184, 0.6);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.9);
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.symbol-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.symbol-modal-header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #e5e7eb;
}

.symbol-modal-close {
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 1.1rem;
  cursor: pointer;
}

.symbol-modal-close:hover {
  color: #e5e7eb;
}

.symbol-search-input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(75, 85, 99, 0.8);
  background-color: #020617;
  color: #e5e7eb;
  font-size: 0.85rem;
}

.symbol-search-input:focus {
  outline: none;
  border-color: #3b82f6;
}

.symbol-list {
  margin-top: 0.4rem;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.symbol-list-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: none;
  background: transparent;
  color: #e5e7eb;
  font-size: 0.85rem;
  cursor: pointer;
}

.symbol-list-item:hover {
  background-color: rgba(55, 65, 81, 0.85);
}

.symbol-list-empty {
  font-size: 0.8rem;
  color: #6b7280;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table thead {
  background-color: #1f2128;
}

.table th,
.table td {
  padding: 0.55rem 0.75rem;
  text-align: center;
}

.table td:first-child a {
  color: inherit;
  text-decoration: none;
}

.table td:first-child a:hover {
  text-decoration: underline;
}

.table th {
  font-weight: 500;
  color: #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table th.sortable {
  cursor: pointer;
  user-select: none;
}

.sort-indicator {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  color: #9ca3af;
}

.table th.sortable.active .sort-indicator {
  color: #fbbf24;
}

.table tbody tr:nth-child(even) {
  background-color: #181a20;
}

.table tbody tr:nth-child(odd) {
  background-color: #15171d;
}

.table tbody tr:hover {
  background-color: #2b3139;
}

.row-changed {
  animation: row-flash 0.8s ease-out;
  background-color: rgba(250, 204, 21, 0.4); /* 立即给予明显高亮底色 */
}

@keyframes row-flash {
  0% {
    background-color: rgba(250, 204, 21, 0.4); /* 柔和黄色高亮 */
  }
  100% {
    background-color: transparent;
  }
}

.table td.price--up {
  color: #22c55e;
}

.table td.price--down {
  color: #ef4444;
}

.table td.volume {
  color: #38bdf8;
}

.empty-row {
  text-align: center !important;
  color: #6b7280;
}

.actions-col {
  text-align: right;
  width: 5.25rem;
}

/* 调整排行榜各列宽度，让各列在 PC 端分布合理 */
.col-symbol {
  width: 26%;
}

.col-price {
  width: 24%;
}

.col-volume {
  width: 24%;
}

.col-actions {
  width: 5.25rem; /* 与 .actions-col 对齐，略微缩窄 */
}

/* 交易对列居左，操作列居右，其余保持居中 */
.table thead th:first-child,
.table tbody td:first-child {
  text-align: left;
}

.table thead th.actions-col,
.table tbody td:last-child {
  text-align: right;
}

.activity-score {
  font-weight: 600;
}

.activity-score--purple {
  color: #a855f7; /* ≥80 */
}

.activity-score--green {
  color: #22c55e; /* ≥60 */
}

.activity-score--yellow {
  color: #facc15; /* ≥40 */
}

.activity-score--gray {
  color: #9ca3af; /* <40 */
}

/* 移动端下进一步收紧排行榜表格，避免任何横向溢出 */
@media (max-width: 768px) {
  .panel.index-panel {
    max-width: 100%;
    padding: 0.75rem 0.75rem 0.75rem;
  }

  .panel.index-panel .table {
    table-layout: fixed;
  }

  .panel.index-panel .table th,
  .panel.index-panel .table td {
    padding: 0.4rem 0.4rem;
  }

  .panel.index-panel .col-symbol,
  .panel.index-panel .col-price,
  .panel.index-panel .col-volume,
  .panel.index-panel .col-actions {
    width: auto;
  }

  .panel.index-panel .actions-col {
    width: auto;
    white-space: nowrap;
  }

  /* 首页移动端：缩小“捕捉信号”按钮尺寸与文字 */
  .panel.index-panel .analyze-btn {
    padding: 0.18rem 0.6rem;
    font-size: 0.7rem;
  }

  /* 首页移动端：交易对名称过长时自动缩小字号，防止布局错乱 */
  .panel.index-panel .symbol-text--small {
    font-size: 0.5rem;
  }
}

.analyze-btn {
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #474d57;
  background: transparent;
  color: #eaecef;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.analyze-btn:hover {
  background-color: #2b3139;
  border-color: #848e9c;
}

.analyze-btn.primary {
  border-color: #f0b90b;
  background: #f0b90b;
  color: #181a20;
  font-weight: 600;
}

.analyze-btn.primary:hover {
  background-color: #fcd535;
  border-color: #fcd535;
  box-shadow: 0 0 12px rgba(252, 213, 53, 0.45);
}

.analysis-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem; /* 扩大“开始分析”和“行情”按钮之间的间距 */
}

.analysis-actions .analyze-btn {
  min-width: 5.5rem;  /* 统一按钮宽度 */
  text-align: center;
}

.analysis-header-right {
  display: none; /* 默认在桌面端隐藏右上角行情按钮容器 */
}

.symbol-menu-btn {
  display: none;
  border: none;
  background: transparent;
  color: #eaecef;
  font-size: 1.1rem;
  cursor: pointer;
}

/* 移动端：在标题栏右上角显示“行情”按钮，并隐藏内容区域中的按钮 */
@media (max-width: 768px) {
  .analysis-header-right {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-right: 0.0rem;
  }

  .analysis-header-right .header-market-btn {
    min-width: 5.5rem;
    text-align: center;
  }

  #btn-open-market {
    display: none;
  }

   .symbol-menu-btn {
     display: inline-flex;
     align-items: center;
     justify-content: center;
     margin-right: 0.25rem;
   }
}

.analysis-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: #e5e7eb;
}

.analysis-history {
  min-height: 3rem;
  border-radius: 0.5rem;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  padding: 0.75rem;
  font-size: 0.85rem;
  color: #9ca3af;
  overflow-x: hidden; /* 防止内部内容撑破虚线边框 */
}

.analysis-section {
  max-width: 100%;  /* 右侧内容区域在 PC 端占满可用宽度 */
  width: 100%;
  margin: 0;
}

.analysis-header-row {
  display: flex;
  justify-content: space-between; /* 左边标题，右边按钮 */
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .analysis-section {
    max-width: 100%; /* 移动端占满可用宽度 */
  }

  .analysis-main {
    flex-direction: column;
  }

  .analysis-sidebar {
    display: none; /* 移动端隐藏左侧固定交易对列表，仅通过侧滑菜单切换 */
  }
}

.analysis-history-item {
  padding: 0.4rem 0;
  border-bottom: 1px dashed rgba(55, 65, 81, 0.8);
}

.analysis-history-item:last-child {
  border-bottom: none;
}

.analysis-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.analysis-history-header:hover {
  color: #e5e7eb;
}

.analysis-history-summary {
  flex-shrink: 0;
  max-width: 50%;
  font-size: 0.8rem;
  color: #6b7280;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  text-align: right;
}

.analysis-history-body {
  margin: 0.25rem 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.9);
  font-family: inherit; /* 使用页面正文字体，便于阅读 markdown */
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: normal;
  word-break: break-word;     /* 防止长单词或长行撑破布局 */
  overflow-wrap: break-word;  /* 兼容性更好的换行控制 */
  overflow-x: hidden;         /* 不允许横向内容溢出边框 */
  max-width: 100%;            /* 绝不超过卡片宽度/屏幕宽度 */
  box-sizing: border-box;     /* 包含内边距在内计算宽度 */
}

.analysis-history-body h1,
.analysis-history-body h2,
.analysis-history-body h3,
.analysis-history-body p {
  margin: 0 0 0.35rem;
}

.toast {
  position: fixed;
  left: 50%;
  top: 50%;  /* 垂直居中 */
  transform: translateX(-50%) translateY(-40%);
  background-color: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.8rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease-out,
    transform 0.2s ease-out;
  z-index: 2000;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-50%);
}

.footer {
  padding: 0.5rem 2rem 0.75rem;
  border-top: 1px solid rgba(31, 41, 55, 0.85);
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  justify-content: center;  /* 默认居中（分析页等） */
  align-items: center;
  gap: 0.5rem;
}

.footer-index {
  justify-content: space-between; /* 左侧数据源，右侧下次更新 */
}

.footer-index .footer-timestamp {
  margin-left: auto;
}

@media (max-width: 768px) {
  .footer {
    flex-direction: column;
    gap: 0.25rem;
  }

  /* 首页在移动端仍保持左右分布的页脚布局 */
  .footer-index {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

