/* ============================================
   全局重置与变量
   ============================================ */
:root {
  --bg: #EDEDED;
  --card-bg: #F5F5F5;
  --card-border: #DDDDDD;
  --text: #333333;
  --text-dim: #666666;
  --red: #e74c3c;
  --red-bg: #ffeaea;
  --blue: #3498db;
  --blue-bg: #eaf4ff;
  --accent: #f39c12;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --brown: #8b5e3c;
  --black: #333;
  --header-h: 42px;
  --bottom-h: 50px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100%;
}
a { color: inherit; text-decoration: none; }

/* ============================================
   通用布局
   ============================================ */
.app {
  max-width: 480px;
  margin: 0 auto;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 15px;
  background: #7D0000;
  border-bottom: 1px solid #5a0000;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.header-title { font-size: 18px; font-weight: 600; text-align: center; flex: 1; color: #FFFFFF; }
.header-back { font-size: 16px; padding: 5px 8px 5px 0; color: var(--accent); cursor: pointer; flex-shrink: 0; }
.main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: auto;
  overscroll-behavior: contain;
  padding: 10px;
}

/* ============================================
   首页 - 彩种网格
   ============================================ */
.lottery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px 0;
}
.lottery-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 15px;
  text-align: center;
  transition: transform 0.1s;
}
.lottery-card:active { transform: scale(0.97); }
.card-icon { font-size: 28px; margin-bottom: 5px; }
.card-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.card-numbers { font-size: 12px; line-height: 1.6; }
.card-issue { font-size: 11px; color: var(--text-dim); margin-top: 5px; }

/* ============================================
   底部栏
   ============================================ */
.bottom-bar {
  height: var(--bottom-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #7D0000;
  border-top: 1px solid #5a0000;
  flex-shrink: 0;
}
.bottom-link { 
  color: #FFD700; 
  font-size: 14px; 
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 215, 0, 0.1);
}

/* AI 聊天入口卡片 */
.ai-chat-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 12px 12px;
  padding: 12px 14px;
  background: #7D0000;
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-chat-entry:hover {
  border-color: var(--accent);
  background: #8D0000;
}
.ai-chat-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.ai-chat-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-chat-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.ai-chat-desc {
  font-size: 10px;
  color: #FFD700;
}
.ai-chat-arrow {
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ============================================
   走势图页面
   ============================================ */
.trend-header { display: flex; align-items: center; gap: 4px; padding: 0 10px; overflow: hidden; }
.trend-header .current-num { text-align: center; flex: 1; color: #FFD700; font-weight: bold; }
.header-info { display: flex; align-items: center; white-space: nowrap; flex-shrink: 0; min-width: 0; }
.header-balls { display: flex; align-items: center; gap: 2px; flex: 1; overflow-x: auto; -webkit-overflow-scrolling: auto; padding: 2px 0; min-width: 0; }
.header-balls::-webkit-scrollbar { display: none; }
.header-update {
  flex-shrink: 0; width: 28px; height: 28px;
  border: 1px solid var(--card-border); border-radius: 50%;
  background: var(--card-bg); color: var(--accent);
  font-size: 14px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all .2s; margin-left: 4px;
}
.header-update:hover { background: var(--accent); color: #fff; }
.header-update:active { transform: rotate(180deg); }
.header-update.loading { animation: spin .8s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ball-row { display: flex; gap: 4px; justify-content: center; margin: 6px 0; flex-wrap: wrap; }
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
}
.ball-red { background: var(--red); color: #fff; }
.ball-blue { background: var(--blue); color: #fff; }

/* Tab 切换 */
.tab-bar {
  display: flex;
  overflow-x: auto;
  gap: 0;
  background: #7D0000;
  border-bottom: 1px solid #5a0000;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.tab-item {
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 12px;
  color: #FFFFFF;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.tab-item.active { color: #FFD700; border-bottom-color: #FFD700; }

/* 位置选择栏 */
.pos-bar {
  display: flex;
  gap: 4px;
  padding: 4px 10px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.pos-item {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text-dim);
  border: 1px solid var(--card-border);
  cursor: pointer;
  white-space: nowrap;
}
.pos-item.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* 走势图容器 */
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chart-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chart-table {
  border-collapse: collapse;
  font-size: 11px;
}
.chart-table th, .chart-table td {
  padding: 3px 4px;
  text-align: center;
  border: 1px solid #C7CBCB;
  min-width: 22px;
  white-space: nowrap;
}
.chart-table thead {
  position: sticky;
  top: 0;
  z-index: 3;
}
.chart-table thead th {
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 3;
}
.chart-table thead th.fixed-col {
  z-index: 5;
}
.chart-table .fixed-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card-bg);
  min-width: 55px;
}
.chart-table tbody .fixed-col {
  z-index: 2;
}
.chart-table .miss-0 { color: var(--red); font-weight: bold; }
.chart-table .miss-1 { color: var(--yellow); }
.chart-table .miss-high { color: var(--text-dim); }
.chart-table .row-even td { background: rgba(255,255,255,0.02); }
/* 号码走势分区背景 */
.chart-table td.zone-red-a, .chart-table th.zone-red-a { background: #FFECF5; color: #333; }
.chart-table td.zone-red-b, .chart-table th.zone-red-b { background: #FFD0E8; color: #333; }
.chart-table td.zone-blue-a, .chart-table th.zone-blue-a { background: #EEEEFF; color: #333; }
.chart-table td.zone-blue-b, .chart-table th.zone-blue-b { background: #D7D7FF; color: #333; }
/* 分区竖线 */
.chart-table td.zone-divider, .chart-table th.zone-divider { border-left: 1px solid #ccc; }
/* 底部统计行 */
.chart-table .stats-row {
  background: #F0F0F0;
}
.chart-table .stats-row td.fixed-col {
  background: #E0E0E0;
  font-weight: 600;
  color: #666;
}
.chart-table .stats-row td:not(.fixed-col) {
  cursor: pointer;
  transition: all 0.1s;
}
.chart-table .stats-row td:not(.fixed-col):hover {
  background: #E8E8E8;
}
/* 历史数据行禁止点击 */
.chart-table tbody tr:not(.stats-row) td:not(.fixed-col) {
  cursor: default;
}
.chart-table .empty-row td {
  border-top: 2px dashed var(--text-dim);
  opacity: 0.5;
}

/* AI 分析区 */
.ai-section {
  padding: 6px 10px;
  flex-shrink: 0;
}
.dim-ref {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  font-size: 10px;
  line-height: 1.4;
}
.dim-ref-label {
  font-weight: 600;
  color: var(--accent);
  margin-right: 4px;
  white-space: nowrap;
}
.dim-ref-item {
  color: var(--text-dim);
  white-space: nowrap;
}
.dim-ref-item b {
  color: var(--text);
  margin-right: 2px;
}
.ai-btn-row {
  display: flex;
  gap: 6px;
}
.ai-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.ai-btn:disabled { opacity: 0.5; }
.ai-btn-predict {
  background: linear-gradient(135deg, var(--accent), #e67e22);
}
.ai-btn-view {
  background: linear-gradient(135deg, #4A90D9, #357ABD);
  color: #fff;
}
.ai-clear {
  text-align: right;
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 2px 0;
  cursor: pointer;
  display: none;
}
.ai-clear:hover { color: var(--red); }

/* ============================================
   AI 结果浮动弹窗（脱离 flex 布局，独立滚动）
   ============================================ */
.ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-overlay-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.ai-overlay-box {
  position: relative;
  width: 92%;
  max-width: 480px;
  max-height: 80vh;
  background: var(--card-bg);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 30px rgba(0,0,0,0.4);
}
.ai-overlay-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #7D0000;
  flex-shrink: 0;
}
.ai-overlay-title {
  font-size: 14px;
  font-weight: 600;
  color: #FFD700;
}
.ai-overlay-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ai-overlay-close:active {
  background: rgba(255,255,255,0.3);
}
.ai-overlay-body {
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  flex: 1;
  min-height: 0;
}

/* 预测报告样式 */
.prediction-report {
  white-space: normal;
  font-size: 13px;
}
.prediction-report .report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 12px;
}
.prediction-report .report-table th {
  background: #7D0000;
  color: #FFD700;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
}
.prediction-report .report-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 12px;
}
.prediction-report .report-table tr:nth-child(even) td {
  background: #f9f9f9;
}
.prediction-report .rec-num {
  display: inline-block;
  background: #8410A5;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  margin: 1px 2px;
  font-weight: bold;
}
.prediction-report .exc-num {
  display: inline-block;
  background: #666;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  margin: 1px 2px;
}
.prediction-report .cross-stat {
  margin: 6px 0;
  padding: 6px 8px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 12px;
}
.prediction-report .stat-label {
  font-weight: 600;
  color: #333;
  margin-right: 6px;
  font-size: 11px;
}
.prediction-report .stat-num {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  margin: 1px 2px;
  font-weight: bold;
}
.prediction-report .stat-num.rec {
  background: #8410A5;
  color: #fff;
}
.prediction-report .stat-num.exc {
  background: #666;
  color: #fff;
}

/* 历史期号横向按钮 */
.ai-history-row {
  display: flex;
  gap: 4px;
  padding-bottom: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.ai-history-row::-webkit-scrollbar { display: none; }
.ai-history-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.ai-history-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.ai-history-btn:active {
  opacity: 0.7;
}

/* 选号面板 */
.panel-section {
  flex-shrink: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--card-border);
}
.panel-toggle {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  color: var(--accent);
  user-select: none;
}
.panel-section.collapsed .panel-body {
  display: none;
}
.panel-section.collapsed .panel-toggle::before {
  content: '▶';
  margin-right: 4px;
}
.panel-section:not(.collapsed) .panel-toggle::before {
  content: '▼';
  margin-right: 4px;
}
.panel-body {
  max-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: max-height 0.2s;
}
.panel-header {
  display: flex;
  align-items: center;
  padding: 4px 10px;
}
.panel-tools {
  display: flex;
  gap: 5px;
  padding: 0 10px 6px;
  flex-wrap: wrap;
}
.color-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.color-btn.active { border-color: #fff; }
.color-btn.c-red { background: var(--red); }
.color-btn.c-yellow { background: var(--yellow); }
.color-btn.c-green { background: var(--green); }
.color-btn.c-blue { background: var(--blue); }
.color-btn.c-black { background: var(--black); }
.color-btn.c-brown { background: var(--brown); }

.panel-rows {
  padding: 0 10px 8px;
  max-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel-row {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
  gap: 2px;
}
.panel-row-label {
  width: 26px;
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
  text-align: center;
}
.panel-ball {
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #DDDDDD;
  color: #333333;
  border: 1px solid #CCCCCC;
  transition: all 0.1s;
  flex-shrink: 0;
  user-select: none;
}
.panel-ball.s-red { background: var(--red); color: #fff; }
.panel-ball.s-yellow { background: var(--yellow); color: #000; }
.panel-ball.s-green { background: var(--green); color: #fff; }
.panel-ball.s-blue { background: var(--blue); color: #fff; }
.panel-ball.s-black { background: var(--black); color: #aaa; }
.panel-ball.s-brown { background: var(--brown); color: #fff; }

.panel-clear-btn {
  margin-left: auto;
  padding: 2px 6px;
  font-size: 10px;
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}

/* 浮动切换面板 */
.float-toggle {
  position: fixed;
  bottom: 70px;
  right: 15px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.float-menu {
  position: fixed;
  bottom: 115px;
  right: 15px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 0;
  z-index: 100;
  display: none;
  min-width: 120px;
}
.float-menu.show { display: block; }
.float-item {
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-dim);
}
.float-item.active { color: var(--accent); }

/* 设置页 */
.setting-section {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 12px;
}
.setting-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.setting-input {
  width: 100%;
  padding: 10px;
  background: #2a2a3a;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: #FFFFFF;
  font-size: 14px;
}
.setting-select {
  width: 100%;
  padding: 10px;
  background: #2a2a3a;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: #FFFFFF;
  font-size: 14px;
}
.setting-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  margin-right: 6px;
  margin-top: 8px;
}
.setting-btn.primary { background: var(--accent); color: #fff; }
.setting-btn.danger { background: var(--red); color: #fff; }
.setting-notice {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  border-left: 3px solid var(--accent);
}
.setting-notice strong { color: var(--accent); }

/* 位置栏高亮 */
.pos-highlight {
  background: rgba(255, 71, 87, 0.12) !important;
}
th.pos-highlight {
  background: var(--accent) !important;
  color: #fff !important;
}

/* 余数走势图：单个位置 */
.dim-num-col {
  min-width: 40px;
  text-align: center;
  font-size: 11px;
  font-weight: 400;
}
.dim-num-cell {
  text-align: center;
  padding: 2px;
}
.dim-col-val {
  min-width: 32px;
  text-align: center;
  font-size: 11px;
  font-weight: 400;
  color: #666;
}
.dim-cell {
  text-align: center;
  padding: 2px;
  line-height: 1.6;
}
.dim-cell.dim-hit {
  background: rgba(255, 71, 87, 0.08);
}
.dim-hit-label {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: #fff;
}
.dim-hit-label.color-val-0 { background: #2979ff; }
.dim-hit-label.color-val-1 { background: #ff1744; }
.dim-hit-label.color-val-2 { background: #00c853; }
.dim-hit-label.color-val-3 { background: #ff6d00; }
.dim-hit-label.color-val-4 { background: #aa00ff; }
.ball-mini {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.ball-mini.ball-num {
  background: #ffa500;
}
.ball-mini.ball-red {
  background: var(--red);
}
.ball-mini.ball-blue {
  background: var(--blue);
}

/* 开奖走势图样式 */
.draw-table {
  min-width: auto !important;
  width: 100%;
}
.draw-table th, .draw-table td {
  padding: 3px 6px !important;
  min-width: auto !important;
  font-size: 11px !important;
}
.draw-table .fixed-col {
  min-width: 0 !important;
  white-space: nowrap;
}
.draw-issue { font-weight: 600; margin-right: 8px; }
.draw-date { color: var(--text-dim); font-size: 10px; }
.draw-week { color: var(--text-dim); font-size: 10px; margin-left: 6px; }
.draw-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.draw-red {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.draw-blue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

/* 余数走势图：全部位置 */
.dim-labels {
  font-size: 8px;
  color: #999;
  font-weight: 400;
}
.dim-cell-all {
  text-align: center;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 2px 6px;
  white-space: nowrap;
  color: #ccc;
  font-weight: 400;
}
.dim-cell-all .dim-hit-char {
  color: var(--red);
  font-weight: 700;
}

/* 余数走势图：全部位置 - 紧凑数字 */
.all-pos-header {
  min-width: 30px;
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  color: #666;
  padding: 2px 4px;
}
.all-cell {
  text-align: center;
  font-size: 12px;
  padding: 2px 4px;
  font-weight: 600;
}
.all-cell.color-val-0 { color: #2979ff; }  /* 蓝 */
.all-cell.color-val-1 { color: #ff1744; }  /* 红 */
.all-cell.color-val-2 { color: #00c853; }  /* 绿 */
.all-cell.color-val-3 { color: #ff6d00; }  /* 橙 */
.all-cell.color-val-4 { color: #aa00ff; }  /* 紫 */

/* 滚动条样式 */

/* 筛选栏 */
.filter-bar {
  flex-shrink: 0;
  padding: 4px 10px 2px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
}
.filter-row {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.filter-label {
  font-size: 9px;
  color: var(--text-dim);
  margin-right: 2px;
  flex-shrink: 0;
}
.filter-item {
  padding: 1px 8px;
  font-size: 10px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 20px;
}
.filter-item.active {
  background: var(--accent);
  color: #fff;
}
.filter-divider {
  width: 1px;
  height: 14px;
  background: var(--card-border);
  margin: 0 4px;
  flex-shrink: 0;
}
.filter-sub {
  display: flex;
  gap: 4px;
  padding: 3px 0 2px 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.filter-sub .filter-item {
  font-size: 9px;
  padding: 1px 6px;
}

/* ============================================
   AI 聊天页面
   ============================================ */
.chat-config {
  flex-shrink: 0;
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
}
.config-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.config-body {
  padding: 0 12px 10px;
  display: none;
}
.config-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.config-label {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
  line-height: 30px;
  min-width: 48px;
}
.config-select {
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  color: var(--text);
  font-size: 12px;
  height: 30px;
}
.config-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.config-checks label {
  font-size: 11px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}
.config-checks input[type="checkbox"] {
  accent-color: var(--accent);
}
.config-btn {
  padding: 3px 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 22px;
  flex-shrink: 0;
}
.config-textarea {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  color: var(--text);
  font-size: 11px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

/* 警告提示 */
.chat-warn {
  padding: 6px 12px;
  font-size: 11px;
  background: rgba(231,76,60,0.1);
  flex-shrink: 0;
}

/* 聊天消息区域 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  -webkit-overflow-scrolling: touch;
}
.chat-msg {
  margin-bottom: 10px;
  max-width: 90%;
}
.chat-msg-user {
  margin-left: auto;
}
.chat-msg-assistant {
  margin-right: auto;
}
.chat-msg-header {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.chat-msg-user .chat-msg-header {
  text-align: right;
}
.chat-msg-body {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-user .chat-msg-body {
  background: var(--accent);
  color: #fff;
}
.chat-msg-assistant .chat-msg-body {
  background: #4a4a5a;
  color: #FFFFFF;
}
.chat-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 12px;
}
.chat-thinking {
  margin-right: auto;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* 输入区 */
.chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--card-border);
  background: var(--card-bg);
  padding: 8px 12px;
}
.chat-input-row {
  display: flex;
  gap: 8px;
}
.chat-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.chat-input:focus {
  border-color: var(--accent);
}
.chat-send {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-tips {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  min-height: 14px;
}

/* ============================================
   PC 端自适应（>= 1024px）
   ============================================ */
@media (min-width: 1024px) {
  .app { max-width: 100%; }
  .trend-header { padding: 0 16px; }
  .header-update { width: 32px; height: 32px; font-size: 16px; }
  .chart-table { font-size: 13px; }
  .chart-table th, .chart-table td { padding: 5px 7px; min-width: 30px; }
  .chart-table .fixed-col { min-width: 72px; }
  .ball-mini { width: 28px; height: 28px; line-height: 28px; font-size: 13px; }
  .ai-btn { padding: 12px; font-size: 15px; }
  .ai-overlay-body { font-size: 14px; padding: 18px; }
  .tab-item { font-size: 14px; padding: 6px 14px; }
  .filter-item { font-size: 11px; padding: 2px 10px; }
  .all-pos-header { min-width: 36px; font-size: 11px; }
  .all-cell { font-size: 13px; padding: 3px 6px; }
  .dim-col-val { min-width: 38px; font-size: 12px; }
  .dim-num-col { min-width: 48px; }
  .pos-item { font-size: 12px; padding: 4px 10px; }

  /* 聊天页 */
  .chat-msg-body { font-size: 14px; padding: 10px 14px; }
  .chat-input { font-size: 14px; padding: 10px 12px; }

  /* 首页卡片 */
  .lottery-card { padding: 20px; font-size: 16px; }
  .lottery-grid { gap: 14px; }
}

/* ============================================
   加载状态与错误提示
   ============================================ */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.loading-tip {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.error-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.error-text {
  font-size: 14px;
  color: var(--red);
  text-align: center;
  padding: 0 20px;
  margin-bottom: 16px;
}
.retry-btn {
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}
.retry-btn:hover {
  background: #e67e22;
}
.retry-btn:active {
  transform: scale(0.97);
}