/* =====================================================
 * style.css — 知识库问答界面样式（浅色主题）
 * ===================================================== */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #8a919c;
  --accent: #2f6bff;
  --accent-weak: #eaf0ff;
  --user-bubble: #2f6bff;
  --danger: #e5484d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 通用隐藏：JS 切换 .hidden 类即可隐藏任意元素（!important 压过元素自身的 display 规则） */
.hidden { display: none !important; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo { font-size: 17px; font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 12px; }

.kb-status { font-size: 12px; color: var(--muted); }

.kb-status.ok { color: #1a7f37; }

.kb-status.err { color: var(--danger); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  width: 34px; height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background .15s;
}

.icon-btn:hover { background: var(--accent-weak); }

/* ---------- 主区域 ---------- */
main {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 12px;
}

/* 空态 */
#empty-state {
  max-width: 620px;
  margin: 9vh auto 0;
  text-align: center;
}

.empty-icon { font-size: 52px; margin-bottom: 12px; }

#empty-state h2 { font-size: 22px; margin-bottom: 8px; }

#empty-state p { color: var(--muted); font-size: 14px; }

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 24px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: all .15s;
}

.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }

/* 消息 */
#messages { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }

.msg { display: flex; }

.msg.user { justify-content: flex-end; flex-wrap: wrap; }   /* wrap：按钮条换行到气泡下方 */

.msg.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 14px 14px 14px 4px;
  background: var(--card);
  border: 1px solid var(--border);
  line-height: 1.7;
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.thinking { color: var(--muted); }

/* 撤回/编辑：气泡下方一行小灰字（右对齐），hover 加深变红（点击弹窗确认后整条撤回） */
.recall-bar {
  width: 100%;               /* 占满整行，把按钮挤到气泡下一行 */
  display: flex;
  justify-content: flex-end; /* 右对齐贴着气泡尾巴 */
  gap: 2px;
  padding: 0 2px 2px 0;
}
.recall-btn {
  flex-shrink: 0;
  padding: 1px 4px;
  border: none;
  background: none;
  font-size: 11px;
  color: var(--text);          /* 黑色字体（用户要求）；hover 变红提示危险操作 */
  opacity: 0.85;
  cursor: pointer;
}
.recall-btn:hover { opacity: 1; color: #d9534f; text-decoration: underline; }

/* ===== 登录/注册遮罩 + 账号额度 ===== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg, #f4f6fa);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-overlay.hidden { display: none; }
.auth-box {
  width: 340px; max-width: 96%;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e3e8f0);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.auth-logo { text-align: center; font-size: 20px; font-weight: 500; }
.auth-title { text-align: center; font-size: 14px; color: var(--muted, #7a8194); }
.auth-box input {
  padding: 11px 14px; border: 1px solid var(--border, #e3e8f0);
  border-radius: 10px; font-size: 14px; outline: none; background: var(--card, #fff); color: var(--text, #1c2333);
}
.auth-box input:focus { border-color: var(--accent, #3b7cff); }
.auth-btn { padding: 12px; border: none; border-radius: 10px; background: var(--accent, #3b7cff); color: #fff; font-size: 14.5px; cursor: pointer; }
.auth-btn:hover { opacity: .9; }
.auth-switch { border: none; background: none; color: var(--accent, #3b7cff); font-size: 12.5px; cursor: pointer; padding: 4px; }
.auth-note { font-size: 11.5px; color: var(--muted, #7a8194); text-align: center; margin: 0; line-height: 1.6; }
.auth-error { font-size: 12.5px; color: #d9534f; text-align: center; margin: 0; }

.user-chip {
  font-size: 12px; color: #fff; background: var(--accent, #3b7cff);
  border-radius: 999px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.set-divider { border: none; border-top: 1px solid var(--border, #e3e8f0); margin: 14px 0 10px; }
.acct-line { font-size: 13px; margin: 4px 0 10px; }
.card-row { display: flex; gap: 8px; }
.card-row input { flex: 1; padding: 9px 12px; border: 1px solid var(--border, #e3e8f0); border-radius: 8px; font-size: 13px; }
.card-row .primary { white-space: nowrap; }

/* 正文中的引用按钮 [1] */
.ref-link {
  border: none;
  background: var(--accent-weak);
  color: var(--accent);
  border-radius: 6px;
  padding: 1px 5px;
  margin: 0 2px;
  font-size: 12px;
  cursor: pointer;
  vertical-align: baseline;
  font-weight: 600;
}

.ref-link:hover { background: #d6e2ff; }

/* 来源区 */
.sources { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }

.src { margin-bottom: 8px; }

.src-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}

.src-title { color: var(--text); font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.src-file { font-size: 11px; color: var(--muted); flex-shrink: 0; }

.src-body {
  display: none;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  color: #4b5563;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
}

.src.open .src-body { display: block; }

.src.flash .src-head { animation: flashBg 1.2s ease; }

@keyframes flashBg {
  0%, 60% { background: #fff3cd; border-radius: 6px; }
  100% { background: transparent; }
}

/* 回答尾部元信息 */
.meta { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- 底栏 ---------- */
footer {
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 20px 10px;
}

#input-wrap {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-family: inherit;
  line-height: 1.5;
  height: 88px;        /* 默认两行高（单行约 44px × 2），与 app.js autoResize 的 88 下限保持一致 */
  max-height: 160px;
  outline: none;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s;
}

#input:focus { border-color: var(--accent); }

#btn-send {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 11px 22px;
  font-size: 14.5px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}

#btn-send:hover { opacity: .88; }

#btn-send:disabled { opacity: .5; cursor: not-allowed; }

.hint { max-width: 860px; margin: 6px auto 0; font-size: 11.5px; color: #b0b6bf; text-align: center; }

/* ---------- 设置弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal-card h3 { margin-bottom: 18px; font-size: 18px; }

.modal-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.modal-card input,
.modal-card select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  outline: none;
}

.modal-card input:focus,
.modal-card select:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 8px; margin-top: 6px; }

.modal-actions button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.modal-actions button:hover { background: var(--accent-weak); }

.modal-actions button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.modal-actions button.primary:hover { opacity: .88; background: var(--accent); }

.modal-card.wide { width: 760px; max-width: 94vw; max-height: 86vh; overflow-y: auto; }

.odds-section { margin-bottom: 18px; }

.odds-section h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

.odds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

.odds-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  margin-bottom: 0;
  color: var(--muted);
}

.odds-grid input {
  margin-top: 4px;
  padding: 7px 8px;
  font-size: 13px;
  text-align: right;
}

.tip { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 35, 41, .92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 99;
  animation: toastIn .2s ease;
}

.toast.hidden { display: none; }

@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 滚动条 */
main::-webkit-scrollbar { width: 8px; }
main::-webkit-scrollbar-thumb { background: #d4d8de; border-radius: 4px; }
main::-webkit-scrollbar-track { background: transparent; }

/* ---------- 开奖号码面板 ---------- */
#draw-panel {
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}

.draw-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.draw-title { font-size: 14px; font-weight: 600; }

.draw-tools { display: flex; align-items: center; gap: 12px; }

.auto-wrap {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.draw-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: all .15s;
}

.draw-btn:hover { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }

#draw-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.draw-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: #fafbfc;
}

.draw-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
  background: var(--card);
}

.draw-region { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

.draw-period {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

.draw-status { font-size: 13px; color: var(--muted); }

.draw-status.err { color: var(--danger); }

.draw-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.ball {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* 波色（真源 main.py RED/BLUE/GREEN_NUMBERS） */
.ball.red   { background: #d32f2f; border-color: #b71c1c; }
.ball.blue  { background: #1565c0; border-color: #0d47a1; }
.ball.green { background: #2e7d32; border-color: #1b5e20; }

.ball-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.ball-label {
  font-size: 10px;
  line-height: 1;
  color: #1a1a1a;   /* 生肖/五行用近黑色，灰色（--muted）在白底小球下不明显 */
  font-weight: 600;
  white-space: nowrap;
}

.ball-plus {
  align-self: center;
  font-weight: 700;
  color: var(--muted);
  margin: 0 2px;
}

.ball.tema {
  box-shadow: 0 0 0 2px rgba(255, 167, 38, .45);
  transform: scale(1.08);
}

.draw-meta { font-size: 12px; color: var(--muted); }

/* ---------- 兑奖气泡 ---------- */
.redeem {
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.7;
}

.redeem.hit {
  background: #eafaf0;
  border: 1px solid #9fe0b4;
  color: #1a7f37;
}

.redeem.miss {
  background: #fdecec;
  border: 1px solid #f3b4b6;
  color: var(--danger);
}

.redeem-head { font-weight: 600; margin-bottom: 4px; }

.redeem-body { color: var(--text); }

/* 投注原文中命中的特码号码标红 */
.win-num { color: #e5484d; font-weight: 700; }

/* ---------- 结算表格数字列防折行 ---------- */
/* 金额 / 退水 / 中奖 / 结算（第 3-6 列）必须一行显示，不能在长数字中间转行 */
.bubble table th:nth-child(n+3),
.bubble table td:nth-child(n+3) {
  white-space: nowrap;
  word-break: keep-all;
  min-width: 58px;
}

/* ---------- 投注错误行：提示 + 可修改卡片 ---------- */
.fix-card {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #f3d9a4;
  background: #fffaf0;
  border-radius: 10px;
  font-size: 13.5px;
}
.fix-card.done { opacity: 0.55; }
.fix-card.done .fix-msg::after { content: '（已修改，结果见下方新消息）'; color: #1a7f37; font-size: 12px; }
.fix-msg { color: #8a5a00; line-height: 1.55; word-break: break-all; }
.fix-actions { margin-top: 8px; display: flex; gap: 8px; }
.fix-btn {
  border: 1px solid #e6c26a;
  background: #fff;
  color: #8a5a00;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.fix-btn:hover { background: #fdf3dd; }
.fix-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.fix-btn.primary:hover { opacity: 0.88; }
.fix-editor { margin-top: 8px; }
.fix-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e0c78a;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fff;
  color: var(--text);
}
.fix-input:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

/* ---------- 表格行点击修改（点行号/原文 → 行内编辑 → 回车重算） ---------- */
#messages table tbody tr.row-editable td:first-child,
#messages table tbody tr.row-editable td:nth-child(2) { cursor: pointer; }
#messages table tbody tr.row-editable:hover td:first-child,
#messages table tbody tr.row-editable:hover td:nth-child(2) { background: var(--accent-weak); }
.row-edit-input {
  width: 100%;
  min-width: 160px;
  box-sizing: border-box;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.row-edit-input:focus { outline: 2px solid var(--accent-weak); }
.row-edit-wrap { display: flex; gap: 6px; align-items: center; }
.row-edit-btn {
  flex: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.row-edit-btn:hover { opacity: 0.88; }

/* =========================================================
 * 香港/澳门地区归属 + 兑奖归档面板
 * ========================================================= */
.region-tag {
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
  display: inline-block;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.msg.assistant .region-tag { background: #eef3fb; color: #4a6b9a; }
.region-tag.hk { background: rgba(255, 255, 255, 0.3); }
.region-tag.hk::after { content: ''; }

.redeem-sub { font-size: 12px; font-weight: normal; color: var(--muted, #888); }
.redeem-list { max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; overscroll-behavior: contain; }
.redeem-list > * { flex-shrink: 0; }   /* 单个巨型期组不许被 flex 压缩——否则内容溢出却不出滚动条 */
.redeem-list::-webkit-scrollbar { width: 8px; }
.redeem-list::-webkit-scrollbar-thumb { background: #c8d2e0; border-radius: 4px; }
.redeem-list::-webkit-scrollbar-thumb:hover { background: #a8b6c9; }
.redeem-list::-webkit-scrollbar-track { background: transparent; }
.redeem-empty { color: var(--muted, #888); text-align: center; padding: 24px 0; }
.redeem-period { border: 1px solid var(--border, #e3e8f0); border-radius: 10px; overflow: hidden; }
.redeem-period-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; cursor: pointer; user-select: none;
  background: var(--bg-soft, #f6f8fc); font-size: 14px;
}
.redeem-period-head:hover { background: #eef2f9; }
.redeem-tag {
  min-width: 20px; text-align: center;
  font-size: 12px; font-weight: bold;
  padding: 2px 6px; border-radius: 8px;
  background: #c94436; color: #fff;
}
.redeem-tag:empty { display: none; }
.redeem-count { margin-left: auto; color: var(--muted, #888); font-size: 12px; }
.redeem-rows { display: none; border-top: 1px solid var(--border, #e3e8f0); }
.redeem-period.open .redeem-rows { display: block; }
/* 总单表格：对齐消息框气泡的原表格形式（带边框、灰表头、数字居中、灰底加粗合计行） */
.redeem-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.redeem-table th, .redeem-table td { padding: 6px 10px; border: 1px solid #d9dee7; text-align: center; vertical-align: middle; }
.redeem-table thead th {
  font-size: 12px; color: #555; font-weight: 600;
  background: #f0f0f0;
  white-space: nowrap;
}
.redeem-table .rt-idx { width: 36px; color: var(--muted); }
.redeem-table .rt-region { width: 44px; }
.redeem-table .rt-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5; max-width: 300px; text-align: left; }
#redeem-modal .modal-card.wide { width: 880px; }
.redeem-table .rt-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.redeem-table thead th.rt-num { text-align: center; }
.redeem-table .rt-win { color: #d32f2f; font-weight: bold; }
.redeem-table .rt-neg { color: #2e7d32; font-weight: bold; }
.redeem-table .rt-op { width: 40px; }
/* 原文列可点击（弹出 改/删 菜单） */
.redeem-table .rt-act { cursor: pointer; }
.redeem-table tr:not(.rt-total) .rt-act:hover { background: #f2f6fd; }
.redeem-table tr.rt-total td { font-weight: bold; background: #f0f0f0; }
.redeem-table tr.rt-total .rt-text { color: var(--muted); font-weight: 400; }
.redeem-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px dashed var(--border, #eef1f6);
  font-size: 13px;
}
.redeem-row:last-child { border-bottom: none; }
.redeem-region {
  flex: none; width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 50%;
  background: #e8f1fd; color: #2f75b5; font-size: 12px; font-weight: bold;
}
.redeem-region.hk { background: #fdeaea; color: #c94436; }
/* 未兑徽章（中奖/结算列，开奖后点一键兑奖出结果） */
.rt-unsettled { font-size: 11px; color: #b08900; background: #fdf6e3; border: 1px solid #f0e0b0; border-radius: 8px; padding: 1px 7px; white-space: nowrap; }
/* 错误投注记录：整行红填充提示（原文红色，悬停菜单不受影响） */
.redeem-table tr.rt-err td { background: #fdecea; }
.redeem-table tr.rt-err .rt-text { color: #c62828; font-weight: 600; }
.redeem-table tr.rt-err .rt-act:hover { background: #f9d7d3; }
.redeem-region.mix { width: auto; padding: 0 7px; border-radius: 11px; background: #efe9fb; color: #6b46c1; white-space: nowrap; }
.redeem-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.redeem-total { flex: none; font-weight: bold; color: var(--primary, #2f75b5); min-width: 48px; text-align: right; }
.redeem-del {
  flex: none; border: none; background: transparent;
  color: var(--danger, #e5484d); cursor: pointer; font-size: 12px;
  padding: 2px 6px; border-radius: 6px;
  vertical-align: middle; line-height: 1.4;
}
.redeem-del:hover { background: #fdeaea; }
.redeem-edit {
  border: none; background: transparent;
  color: var(--primary, #2f75b5); cursor: pointer; font-size: 12px;
  padding: 2px 6px; border-radius: 6px;
  vertical-align: middle; line-height: 1.4;
}
.redeem-edit:hover { background: #e8f1fd; }
/* 总单「改」跳转：目标投注气泡高亮闪烁 */
.bubble.jump-flash { animation: jump-flash 1.6s ease; }
@keyframes jump-flash {
  0%, 55% { box-shadow: 0 0 0 3px rgba(47, 117, 181, 0.5); }
  100% { box-shadow: none; }
}
button.danger { background: var(--danger, #e5484d); color: #fff; }

/* =========================================================
 * 顶栏紧凑开奖条（替代原 draw-panel 大面板）
 * ========================================================= */
#draw-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 0 12px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.strip-region {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafbfc;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}

.strip-region.active {
  border-color: var(--accent);
  background: var(--accent-weak, #eef4ff);
}

.strip-head { font-size: 15px; font-weight: 600; white-space: nowrap; }

.strip-period { color: var(--muted); font-weight: 400; font-size: 14px; }

.strip-balls { display: flex; gap: 6px; align-items: flex-start; }

.strip-empty { font-size: 12px; color: var(--muted); white-space: nowrap; }
.strip-empty.err { color: var(--danger); }
.strip-empty.wait { color: #b08900; }   /* 开奖过渡期：等待开奖 */

/* 紧凑条里的小球（桌面端加大：手机端在媒体查询里用 !important 覆盖为小号） */
.ball.sm { width: 34px; height: 34px; font-size: 16px; font-weight: 700; }
.ball.sm.tema { transform: scale(1.12); box-shadow: 0 0 0 2px rgba(255, 167, 38, .5); }

.strip-balls .ball-label { font-size: 13px; }

.strip-balls .ball-plus { margin: 0 3px; font-size: 17px; line-height: 34px; }

/* ---------- TAB 页栏（一个客户一个统计页） ---------- */
#tab-bar {
  display: flex; align-items: center; gap: 8px;
  max-width: 860px; margin: 0 auto; padding: 8px 12px 0;
}
#tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab-chip {
  flex-shrink: 0; border: 1px solid var(--border, #e3e6ec); background: var(--bg-soft, #f6f8fc);
  color: var(--text); border-radius: 16px; padding: 4px 14px; font-size: 13px; cursor: pointer;
}
.tab-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
#tab-add {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  border: 1px dashed var(--border, #c8cdd6); background: #fff; color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer;
}
#tab-add:hover { color: var(--accent); border-color: var(--accent); }
#tab-menu {
  position: fixed; z-index: 1000; display: flex; flex-direction: column;
  background: #fff; border: 1px solid var(--border, #e3e6ec); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12); overflow: hidden; min-width: 132px;
}
#tab-menu button { border: 0; background: none; padding: 9px 14px; font-size: 13px; text-align: left; cursor: pointer; color: var(--text); }
#tab-menu button:hover { background: var(--accent-weak, #eef4ff); }

/* TAB 页面内自绘弹窗（新建/重命名/关闭确认） */
#tab-dialog {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 18, 25, .45); padding: 20px;
}
.tab-dialog-box {
  width: 100%; max-width: 320px; background: #fff; border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .22); padding: 16px 16px 12px;
  animation: tabDialogIn .16s ease-out;
}
@keyframes tabDialogIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.tab-dialog-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; line-height: 1.5; word-break: break-all; }
#tab-dialog-input {
  width: 100%; box-sizing: border-box; padding: 9px 10px; font-size: 14px;
  border: 1px solid var(--border, #e3e6ec); border-radius: 8px; outline: none; color: var(--text); background: #fff;
}
#tab-dialog-input:focus { border-color: var(--accent); }
.tab-dialog-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.tab-dialog-btns button {
  border: 1px solid var(--border, #e3e6ec); background: #fff; color: var(--text);
  padding: 7px 18px; font-size: 13px; border-radius: 8px; cursor: pointer;
}
.tab-dialog-btns button:hover { background: var(--accent-weak, #eef4ff); }
.tab-dialog-btns button.primary { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; }
.tab-dialog-btns button.primary:hover { filter: brightness(1.06); background: var(--accent, #2563eb); }
.tab-dialog-btns button.primary.danger { background: #e5484d; border-color: #e5484d; }

/* 移动端：顶栏换行，开奖条独占一行、横向滚动 */
@media (max-width: 768px) {
  header { flex-wrap: wrap; padding: 10px 12px; row-gap: 8px; }
  #draw-strip { order: 3; flex-basis: 100%; margin: 0; padding-bottom: 2px; }
  .kb-status { display: none; }

  /* 结果表格缩小：覆盖 worker.js 表格内联样式（min-width:540px 手机放不下） */
  .bubble { max-width: 96% !important; }
  .bubble table { min-width: 0 !important; width: 100% !important; font-size: 11.5px !important; }
  .bubble table th, .bubble table td { padding: 3px 5px !important; }
  .bubble table th:nth-child(n+3),
  .bubble table td:nth-child(n+3) { min-width: 0 !important; }
  .bubble .caption, .bubble .table-caption { font-size: 11px !important; }

  /* 顶栏开奖条缩小一号 */
  .strip-region { padding: 3px 8px !important; gap: 2px !important; }
  .strip-head, .strip-period { font-size: 10.5px !important; }
  .strip-balls { gap: 3px !important; }
  .ball.sm { width: 20px !important; height: 20px !important; font-size: 10px !important; }
  .strip-balls .ball-label { font-size: 8.5px !important; }
  .strip-balls .ball-plus { font-size: 11px !important; line-height: 20px !important; }

  /* 手机端 TAB 栏更紧凑 */
  #tab-bar { padding: 6px 10px 0; }
  .tab-chip { padding: 3px 11px; font-size: 12px; }

  /* 手机端兑奖总单表格缩小 */
  .redeem-table { font-size: 11px !important; }
  .redeem-table th, .redeem-table td { padding: 3px 4px !important; }
  .redeem-table .rt-text { min-width: 0 !important; }
  /* 手机端总单防溢出：固定布局让「投注详情」列吃满剩余宽度（省略号截断），数字列等分剩余空间 */
  .redeem-table { table-layout: fixed !important; }
  .redeem-table .rt-text { max-width: none !important; width: 46% !important; }
  #redeem-list { overflow-x: auto; }   /* 兜底：极端情况下允许横向滚动 */
  /* 弹窗整体加宽 + 压缩内边距，表格可用宽度更大 */
  #redeem-modal .modal-card.wide { max-width: 98vw !important; padding: 14px 10px; }
  #redeem-modal h3 { margin-bottom: 10px; font-size: 16px; }
  /* 压缩非原文列：# / 地区 收窄，未兑徽章变小，给原文列腾宽度 */
  .redeem-table .rt-idx { width: 22px !important; }
  .redeem-table .rt-region { width: 32px !important; }
  .redeem-table th, .redeem-table td { padding: 3px 2px !important; }
  #redeem-modal .rt-unsettled { font-size: 10px; padding: 1px 4px; border-radius: 6px; }
  .redeem-period-head { font-size: 12px !important; padding: 6px 8px !important; }
  .redeem-tag { padding: 2px 6px !important; font-size: 11px !important; }
  /* 操作按钮两行铺满，不再一列竖排占半屏 */
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { flex: 1 1 30%; }
  .redeem-sub { display: none; }       /* 副标题窄屏下省去换行 */
}

/* 自定义确认弹窗（替代原生 confirm） */
.confirm-card { width: 340px; max-width: 88vw; }
.confirm-card .confirm-text { margin: 0 0 16px; font-size: 14.5px; line-height: 1.7; color: var(--text); }
.modal-actions button.danger { background: #e5484d; border-color: #e5484d; color: #fff; }
.modal-actions button.danger:hover { background: #d63c41; border-color: #d63c41; }

/* 编辑原文弹窗 */
#orig-edit-text {
  width: 100%; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit; font-size: 13.5px; line-height: 1.7;
  resize: vertical; min-height: 160px;
  background: var(--card); color: var(--text); outline: none;
  transition: border-color .15s;
}
#orig-edit-text:focus { border-color: var(--accent); }

/* ===== 图片发送（AI 识别投注内容）===== */
/* 右侧按钮列：图片按钮在上、发送在下 */
#input-side {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
#btn-img {
  border: 1px solid var(--border, #ddd);
  background: #fff;
  color: #667;
  border-radius: 12px;
  padding: 6px 11px;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  display: flex;
  align-items: center;
  transition: border-color .15s, color .15s;
}
#btn-img:hover { border-color: var(--accent); color: var(--accent); }
#img-previews { display: none; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
#img-previews.has { display: flex; }
.img-chip { position: relative; }
.img-chip img {
  width: 54px; height: 54px; object-fit: cover;
  border-radius: 8px; border: 1px solid #e0e0e0; display: block;
}
.img-chip .rm {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  border: none; background: #e5484d; color: #fff;
  font-size: 11px; line-height: 18px; padding: 0; cursor: pointer;
}
/* 用户气泡里的图片缩略图（低分辨率副本，全尺寸不落存储） */
.msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-imgs img {
  max-width: 120px; max-height: 120px;
  border-radius: 8px; border: 1px solid rgba(0,0,0,.15); display: block;
}

/* ===== 警告条目可点修改 / 添加投注行 ===== */
.bet-warn-box .warn-item { cursor: pointer; border-radius: 4px; transition: background .12s; }
.bet-warn-box .warn-item:hover { background: rgba(198, 40, 40, .08); }
.add-row-entry, .bet-warn-box .warn-add {
  margin: 2px 0 4px; padding: 3px 8px; cursor: pointer;
  color: #888; font-size: 12px; display: inline-block;
  border-radius: 4px; transition: background .12s, color .12s;
}
.add-row-entry:hover, .bet-warn-box .warn-add:hover { background: #f0f3f8; color: var(--accent, #3a6ea5); }
.add-row-entry.editing, .bet-warn-box .warn-add.editing { display: none; }
.fix-editor textarea.fix-input { width: 100%; box-sizing: border-box; }

/* 警告框「确认无误」按钮 */
.bet-warn-box .warn-ok {
  margin-top: 5px; padding: 3px 10px; cursor: pointer;
  border: 1px solid #c62828; background: transparent; color: #c62828;
  font-size: 12px; border-radius: 5px; transition: background .12s, color .12s;
}
.bet-warn-box .warn-ok:hover { background: #c62828; color: #fff; }
