/* ============================================================
   潮汐财经情报 · H5 移动端样式（独立文件，不依赖桌面端 style.css）
   设计基线：手机竖屏优先、单列、44px 触控目标、安全区适配、暗色默认
   ============================================================ */

:root {
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body[data-theme="dark"] {
  --bg: #080c14; --panel: #101725; --panel-2: #141d2d; --bar: #0d1523;
  --line: #1e2a3c; --line-soft: #182233; --text: #e7eefb; --text-2: #c3cfe2;
  --muted: #93a4bd; --faint: #70829c; --accent: #4c9dff; --cyan: #3ad0cf;
  --green: #23c58c; --orange: #ffab3d; --red: #ff5a6a; --purple: #a886ff;
}
body[data-theme="light"] {
  --bg: #f2f5fa; --panel: #ffffff; --panel-2: #f7f9fd; --bar: #e9eef6;
  --line: #dbe3ef; --line-soft: #e8edf5; --text: #16213a; --text-2: #33415d;
  --muted: #5b6d89; --faint: #8798b0; --accent: #1b6fd8; --cyan: #0e9b9a;
  --green: #0f9f6a; --orange: #d97b0a; --red: #d92e42; --purple: #7b52d6;
}

.h5-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- 顶部（固定） ---------- */
.h5-head {
  position: relative; z-index: 20; flex: none;
  padding: calc(var(--safe-top) + 9px) 12px 9px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.h5-head-row { display: flex; align-items: center; justify-content: space-between; }
.h5-brand { display: flex; align-items: center; gap: 7px; font-size: 17px; font-weight: 700; }
.h5-brand small { color: var(--faint); font-size: 11px; font-weight: 500; }
.h5-logo { color: var(--accent); font-size: 20px; }
.h5-head-actions { display: flex; align-items: center; gap: 10px; }
.h5-live { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.h5-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.h5-live.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(35,197,140,.15); }
.h5-live.off i { background: var(--red); }
.h5-icon {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text-2); font-size: 18px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.h5-icon.pc { width: 34px; font-size: 12px; font-weight: 600; }
.h5-searchbox {
  display: flex; align-items: center; gap: 7px; margin-top: 9px; padding: 0 11px;
  height: 42px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); color: var(--faint);
}
.h5-searchbox input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font-size: 15px;
}
.h5-searchbox input::placeholder { color: var(--faint); }
.h5-searchbox button { border: 0; background: transparent; color: var(--muted); font-size: 20px; padding: 0 4px; }
.h5-pull {
  position: absolute; left: 0; right: 0; top: 100%; text-align: center;
  color: var(--accent); font-size: 12px; height: 0; overflow: hidden; transition: height .15s;
}
.h5-pull.show { height: 30px; line-height: 30px; }

/* ---------- 主体滚动区 ---------- */
.h5-main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.h5-page { padding: 10px 12px calc(84px + var(--safe-bottom)); }
.h5-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.h5-chips::-webkit-scrollbar { display: none; }
.h5-chips button {
  flex: none; min-height: 34px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13.5px;
}
.h5-chips button.active { border-color: var(--accent); color: var(--accent); background: var(--panel-2); }
.h5-newpill {
  margin: 6px 0; padding: 8px; text-align: center; border-radius: 9px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--panel-2); font-size: 13px;
}
.h5-section-title { margin: 14px 2px 8px; color: var(--text-2); font-size: 15px; font-weight: 600; }

/* ---------- 消息卡片 ---------- */
.h5-feed { display: flex; flex-direction: column; gap: 9px; }
.h5-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 13px; cursor: pointer;
}
.h5-card:active { background: var(--panel-2); }
.h5-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.h5-badge { padding: 1px 7px; border-radius: 5px; font-size: 11px; border: 1px solid var(--line); color: var(--muted); }
.h5-badge.primary { border-color: var(--cyan); color: var(--cyan); }
.h5-badge.rumor { border-color: var(--orange); color: var(--orange); }
.h5-badge.important { border-color: var(--red); color: var(--red); }
.h5-time { margin-left: auto; color: var(--faint); font-size: 11.5px; font-family: var(--mono); }
.h5-card h3 { margin: 0 0 5px; font-size: 16.5px; line-height: 1.45; font-weight: 600; }
.h5-card p {
  margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.h5-card-foot { margin-top: 8px; color: var(--faint); font-size: 11.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.h5-more, .h5-empty {
  width: 100%; margin: 14px 0 4px; padding: 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 14px;
}
.h5-empty { text-align: center; }

/* ---------- 日历 ---------- */
.h5-cal-day { margin: 12px 0 6px; color: var(--accent); font-size: 14px; font-weight: 600; }
.h5-cal-row {
  display: grid; grid-template-columns: 46px minmax(0,1fr); gap: 9px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 10px 11px; margin-bottom: 7px;
}
.h5-cal-row time { color: var(--text-2); font-family: var(--mono); font-size: 13px; }
.h5-cal-row b { display: block; font-size: 14.5px; font-weight: 500; line-height: 1.45; }
.h5-cal-row small { color: var(--faint); font-size: 11.5px; }
.h5-star { color: var(--orange); }

/* ---------- 资金 ---------- */
.h5-flow { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.h5-flow-row { display: grid; grid-template-columns: 62px minmax(0,1fr) 82px; align-items: center; gap: 8px; margin: 9px 0; font-size: 13px; }
.h5-flow-track { height: 9px; border-radius: 5px; background: var(--bar); position: relative; overflow: hidden; }
.h5-flow-track i { position: absolute; top: 0; bottom: 0; left: 50%; background: var(--red); }
.h5-flow-track i.neg { background: var(--green); left: auto; right: 50%; }
.h5-flow-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--faint); }
.h5-flow-val { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.up { color: var(--red); } .down { color: var(--green); } .flat { color: var(--text-2); }
.h5-note { color: var(--faint); font-size: 12px; line-height: 1.7; padding: 10px 2px; }

/* ---------- 通用列表（龙虎榜 / 基金榜） ---------- */
.h5-list-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: 7px;
  text-decoration: none; color: inherit;
}
.h5-list-row:active { background: var(--panel-2); }
.h5-list-row .idx { width: 22px; color: var(--faint); font-family: var(--mono); font-size: 12px; }
.h5-list-row .main { flex: 1; min-width: 0; }
.h5-list-row .main b { display: block; font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h5-list-row .main small { color: var(--faint); font-size: 11.5px; }
.h5-list-row .val { font-family: var(--mono); font-size: 13px; text-align: right; white-space: nowrap; }
.h5-entry {
  display: flex; align-items: center; gap: 11px; padding: 14px; margin-bottom: 9px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: inherit;
}
.h5-entry-ico { font-size: 24px; }
.h5-entry b { display: block; font-size: 15px; }
.h5-entry small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.h5-arrow { margin-left: auto; color: var(--faint); font-size: 24px; }

/* ---------- 事件日历（H5） ---------- */
.ev-nav { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.ev-nav button {
  min-height: 36px; min-width: 38px; padding: 0 9px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text-2); font-size: 13px;
}
.ev-nav input[type="date"] {
  flex: 1; min-width: 0; min-height: 36px; padding: 0 7px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 13px;
}
.h5-events { display: flex; flex-direction: column; gap: 7px; }
.h5-ev-row {
  display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 8px;
  background: var(--panel); border: 1px solid var(--line-soft); border-left: 3px solid var(--line);
  border-radius: 10px; padding: 10px 11px;
}
.h5-ev-row.high { border-left-color: var(--red); }
.h5-ev-row.mid { border-left-color: var(--orange); }
.h5-ev-row time { color: var(--text-2); font-family: var(--mono); font-size: 12px; }
.h5-ev-row b { display: block; font-size: 14.5px; line-height: 1.45; font-weight: 600; }
.h5-ev-row small { display: block; color: var(--muted); font-size: 12px; line-height: 1.55; margin-top: 3px; }
.h5-ev-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.h5-ev-tags i { font-style: normal; font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.h5-ev-tags i.rule { border-color: var(--purple); color: var(--purple); }
.h5-ev-tags i.news { border-color: var(--cyan); color: var(--cyan); }
.h5-ev-tags a { color: var(--accent); font-size: 11px; text-decoration: none; }

/* ---------- 底部导航（固定） ---------- */
.h5-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.h5-nav button {
  min-height: 52px; border: 0; background: transparent; color: var(--muted);
  font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.h5-nav button span { font-size: 19px; line-height: 1; }
.h5-nav button.active { color: var(--accent); }

/* ---------- 详情浮层（底部抽屉） ---------- */
.h5-sheet-mask { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); }
.h5-sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 82vh;
  display: flex; flex-direction: column; padding-bottom: var(--safe-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0; animation: h5Up .22s ease both;
}
@keyframes h5Up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.h5-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-size: 15px;
}
.h5-sheet-head button { border: 0; background: transparent; color: var(--muted); font-size: 27px; line-height: 1; }
.h5-sheet-body { padding: 14px; overflow-y: auto; }
.h5-sheet-body h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.45; }
.h5-sheet-body .meta { color: var(--faint); font-size: 12.5px; margin-bottom: 12px; }
.h5-sheet-body .body-text { color: var(--text-2); font-size: 15px; line-height: 1.75; }
.h5-sheet-body .kv { display: flex; gap: 8px; margin-top: 10px; font-size: 13px; }
.h5-sheet-body .kv span { color: var(--faint); flex: none; width: 62px; }
.h5-sheet-body .link {
  display: block; margin-top: 15px; padding: 11px; text-align: center; border-radius: 9px;
  background: var(--accent); color: #fff; text-decoration: none; font-size: 14px;
}

/* ---------- 轻提示 ---------- */
.h5-toast {
  position: fixed; z-index: 50; left: 50%; bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%); padding: 8px 15px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text-2); font-size: 13px;
}

/* ---------- 平板：限制宽度居中，避免宽屏拉伸 ---------- */
@media (min-width: 720px) {
  .h5-app { max-width: 560px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .h5-nav { max-width: 560px; left: 50%; transform: translateX(-50%); }
}
