/* ===== 百宝箱 · 共享主题样式 ===== */
:root {
  --bg: #14141f;
  --card: #1e1e2e;
  --card-hi: #26263a;
  --gold: #f0c14b;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --text: #e8e8ee;
  --muted: #8888a0;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  min-height: 100vh;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  padding-top: calc(12px + env(safe-area-inset-top));
}

/* 顶部栏 */
.appbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.appbar h1 { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.appbar h1 .dot { color: var(--gold); }
.appbar h1 svg, .tool .icon svg { display: block; }
.appbar .right { display: flex; align-items: center; gap: 8px; }

/* 返回按钮（工具页用） */
.back {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card); color: var(--text); text-decoration: none;
  font-size: 14px; padding: 7px 12px; border-radius: 10px;
}
.back:active { background: var(--card-hi); }

/* 首页：工具网格 */
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool {
  background: var(--card); border-radius: 14px; padding: 16px 14px;
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-height: 104px;
  box-shadow: 0 2px 10px rgba(0,0,0,.2); transition: transform .12s, background .12s;
}
.tool:active { transform: scale(.97); background: var(--card-hi); }
.tool .icon { font-size: 30px; line-height: 1; }
.tool .name { font-size: 15px; font-weight: 600; }
.tool .desc { font-size: 11px; color: var(--muted); line-height: 1.4; }
.tool.soon { opacity: .45; pointer-events: none; }
.tool.soon .desc { color: var(--gold); }

/* 通用卡片 / 数值 */
.card {
  background: var(--card); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 4px; letter-spacing: .3px; }
.card .value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.card .value .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.card.gold .value { color: var(--gold); }
.card .sub { color: var(--muted); font-size: 10.5px; margin-top: 4px; line-height: 1.5; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid .card { margin-bottom: 0; }
.grid .value { font-size: 22px; }

.section-title { color: var(--muted); font-size: 12px; letter-spacing: .3px; margin: 12px 4px 6px; }
.badge { font-size: 10px; color: var(--bg); background: var(--gold); padding: 1px 6px; border-radius: 7px; margin-left: 6px; font-weight: 600; vertical-align: middle; }
.footer { text-align: center; color: var(--muted); font-size: 11px; margin-top: 12px; line-height: 1.6; }

/* 圆形操作按钮（如刷新） */
.iconbtn {
  background: var(--card); border: none; color: var(--text);
  width: 34px; height: 34px; border-radius: 10px; font-size: 16px;
  cursor: pointer; transition: transform .4s;
}
.iconbtn.spin { transform: rotate(360deg); }
.iconbtn:disabled { opacity: .45; cursor: default; }
.iconbtn.cooling { font-size: 13px; font-weight: 600; }

/* 可折叠说明 */
details.src { background: var(--card); border-radius: 12px; margin-top: 10px; overflow: hidden; }
details.src summary {
  list-style: none; cursor: pointer; padding: 11px 14px;
  color: var(--muted); font-size: 12.5px; display: flex; align-items: center; justify-content: space-between;
}
details.src summary::-webkit-details-marker { display: none; }
details.src summary .arrow { transition: transform .25s; font-size: 12px; }
details.src[open] summary .arrow { transform: rotate(180deg); }
details.src .body { padding: 0 14px 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
details.src .body b { color: var(--text); font-weight: 600; }
details.src .body code { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 5px; font-size: 11.5px; }
details.src .body hr { border: none; border-top: 1px solid rgba(255,255,255,.07); margin: 12px 0; }

/* 表单控件（下拉、输入框、交换按钮） */
.cur {
  width: 100%; background: var(--card-hi); color: var(--text);
  border: none; border-radius: 10px; padding: 10px 34px 10px 12px;
  font-size: 15px; margin-bottom: 8px; outline: none;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%238888a0' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
.amount {
  width: 100%; background: transparent; border: none; color: var(--text);
  font-size: 30px; font-weight: 700; outline: none; padding: 2px 0;
}
.amount::placeholder { color: var(--muted); }
.amount.result { color: var(--gold); }
.swap-wrap { display: flex; justify-content: center; margin: -2px 0 6px; }
.swapbtn {
  background: var(--card-hi); color: var(--gold); border: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 20px;
  cursor: pointer; transition: transform .15s;
}
.swapbtn:active { transform: scale(.88) rotate(180deg); }
.rateline { text-align: right; margin: -4px 4px 2px; }

/* 走势图 · K 线 */
.chart-card { padding-bottom: 10px; }
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center; justify-content: space-between; }
.seg { display: inline-flex; background: var(--card-hi); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  background: transparent; border: none; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 8px; cursor: pointer;
}
.seg button.active { background: var(--card); color: var(--gold); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.kline-head {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline;
  font-size: 11px; color: var(--muted); margin-bottom: 4px; line-height: 1.5;
}
.kline-head b { color: var(--text); font-weight: 600; font-size: 12px; }
.kline-head .kh-date { color: var(--text); font-weight: 600; min-width: 72px; }
.kline-head b.up { color: var(--red); }
.kline-head b.down { color: var(--green); }
.chart-wrap { position: relative; min-height: 260px; margin: 0 -6px; touch-action: none; }
.chart-wrap .uplot .u-over { touch-action: none; }
.chart-hint { font-size: 10px; color: var(--muted); text-align: center; margin-top: 4px; }
.chart-wrap .chart-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; z-index: 2;
}
.chart-wrap .chart-host { width: 100%; }
.chart-note { color: var(--muted); font-size: 10.5px; margin-top: 6px; line-height: 1.5; }

/* uPlot 深色 K 线主题 */
.uplot { font-family: inherit; }
.uplot .u-title { display: none; }
.uplot .u-legend { display: none; }
.uplot .u-over { background: transparent; }
.uplot .u-axis .u-label { color: var(--muted); }
.uplot .u-axis .u-value { color: var(--text); }

/* 随机抽号 */
.lucky-count {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  padding: 8px 0 4px;
}
.lucky-count .value { font-size: 36px; min-width: 48px; text-align: center; margin: 0; }
.lucky-step {
  width: 40px; height: 40px; border-radius: 12px; border: none;
  background: var(--card-hi); color: var(--gold); font-size: 22px; font-weight: 600;
  cursor: pointer;
}
.lucky-step:active { transform: scale(.92); }
.lucky-step:disabled { opacity: .35; cursor: default; }
.lucky-result { min-height: 88px; }
.lucky-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 0 8px; min-height: 180px;
}
.lucky-stage[hidden] { display: none; }
.lucky-cat {
  width: 150px; height: 150px; object-fit: contain;
  border-radius: 16px;
  transform-origin: 50% 85%;
}
.lucky-stage.running .lucky-cat {
  animation: catWalk 0.45s ease-in-out infinite;
}
.lucky-stage-tip {
  margin-top: 10px; color: var(--muted); font-size: 12px; font-weight: 500;
}
.lucky-stage.running .lucky-stage-tip {
  animation: pulse 1s ease-in-out infinite;
}
@keyframes catWalk {
  0%, 100% { transform: translateX(-10px) translateY(0) rotate(-4deg); }
  25% { transform: translateX(0) translateY(-8px) rotate(0deg); }
  50% { transform: translateX(10px) translateY(0) rotate(4deg); }
  75% { transform: translateX(0) translateY(-8px) rotate(0deg); }
}
.lucky-balls {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 8px 0 4px; min-height: 48px; align-items: center;
}
.lucky-ball {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(145deg, #ffe08a, #dca22a);
  color: #5c3d0a; font-size: 15px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  animation: luckyPop .25s ease-out;
}
.lucky-ball-wide {
  width: auto; min-width: 40px; padding: 0 12px; border-radius: 20px;
  font-size: 13px; max-width: 100%;
}

/* 自定义抽奖表单 */
.pick-ta, .pick-input, .pick-num {
  width: 100%; background: var(--card-hi); color: var(--text);
  border: none; border-radius: 10px; padding: 10px 12px;
  font-size: 15px; outline: none; font-family: inherit;
}
.pick-ta { resize: vertical; line-height: 1.5; min-height: 110px; }
.pick-row { display: flex; align-items: center; gap: 10px; }
.pick-num { text-align: center; font-weight: 700; font-size: 20px; }
.pick-sep { color: var(--muted); font-size: 16px; flex-shrink: 0; }

/* 每日时政 */
.news-tabs { width: 100%; margin-bottom: 10px; }
.news-tabs button { flex: 1; }
.news-meta {
  color: var(--muted); font-size: 11px; margin: 0 4px 10px; line-height: 1.5;
}
.news-list { display: flex; flex-direction: column; gap: 8px; }
.news-item {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--card); border-radius: 12px; padding: 12px 14px;
  text-decoration: none; color: var(--text);
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.news-item:active { background: var(--card-hi); transform: scale(.99); }
.news-idx {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 7px;
  background: rgba(240,193,75,.15); color: var(--gold);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.news-body { flex: 1; min-width: 0; }
.news-title { font-size: 14px; font-weight: 600; line-height: 1.45; }
.news-foot {
  display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 6px;
  color: var(--muted); font-size: 10.5px;
}
.lucky-empty { color: var(--muted); font-size: 13px; font-weight: 500; }
.lucky-draw {
  width: 100%; margin: 4px 0 10px; padding: 14px;
  border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(145deg, #ffe08a, #dca22a);
  color: #5c3d0a; font-size: 17px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(220,162,42,.35);
}
.lucky-draw:active { transform: scale(.98); }
.lucky-draw:disabled { opacity: .6; cursor: default; }
.lucky-hist-row { margin-bottom: 6px; color: var(--text); font-size: 12px; }
.lucky-hist-row:last-child { margin-bottom: 0; }
.lucky-hist-n { color: var(--muted); margin-right: 4px; }
@keyframes luckyPop {
  from { transform: scale(.6); opacity: .4; }
  to { transform: scale(1); opacity: 1; }
}

/* 状态 */
.loading { color: var(--muted); }
.err { color: var(--red); }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:.4 } 50% { opacity:1 } }
