/* 启宏八字 · 样式（参照从真的信息密度，iOS 风格） */
:root {
  --blue: #3A6BF0;
  --blue-weak: #EAF0FF;
  --red: #E5483C;
  --green: #34A853;
  --bg: #F2F3F5;
  --card: #FFFFFF;
  --text: #16181D;
  --sub: #8A8F99;
  --line: #EBEDF0;
  --line-strong: #DDE0E4;
  --tab-h: 54px;
  --wx-mu: #59A65C;
  --wx-huo: #E5483C;
  --wx-tu: #C68A4D;
  --wx-jin: #F3AD40;
  --wx-shui: #5484ED;
}
[data-theme="dark"] {
  --bg: #0F1115;
  --card: #191C22;
  --text: #EDEFF3;
  --sub: #8A9099;
  --line: #262A31;
  --line-strong: #333842;
  --blue-weak: #1B2437;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 6px;
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
}
.topbar .title { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .title b { font-weight: 600; }
.topbar .title .meta { color: var(--sub); font-size: 12px; margin-left: 4px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--sub); font-size: 17px;
}
.icon-btn:active { background: var(--bg); }

/* ---------- 页面 ---------- */
.page { display: none; }
.page.active { display: block; }
.pad { padding: 10px 12px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: 12px; margin: 0 0 10px; overflow: hidden; }
.card.hit { border: 1px solid var(--blue); }
.card-title { font-size: 13px; color: var(--sub); padding: 12px 14px 6px; display: flex; align-items: center; justify-content: space-between; }
.card-title .hint { font-size: 11px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; align-items: center; min-height: 46px; padding: 0 14px; border-top: 1px solid var(--line); }
.form-row:first-child { border-top: 0; }
.form-row > .label { width: 62px; color: var(--sub); font-size: 14px; flex: none; }
.form-row > .field { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.form-row input[type="text"], .form-row input[type="date"], .form-row input[type="time"],
.form-row input[type="number"], .form-row input[type="email"], .form-row input[type="password"] {
  border: 0; background: transparent; outline: none; min-width: 0; width: 100%; padding: 10px 0;
  -webkit-appearance: none; appearance: none;
}
.form-row .val { flex: 1; padding: 10px 0; }
.form-row .val.placeholder { color: #B9BDC3; }
.link { color: var(--blue); font-size: 14px; white-space: nowrap; }
.link.plain { background: var(--blue-weak); border-radius: 12px; padding: 3px 10px; font-size: 12px; }

/* 出生地：国家 / 省份 / 城市 三连选 */
.place-triple { gap: 3px; }
.place-triple select {
  flex: 1 1 0; min-width: 0;
  border: 0; background-color: transparent; outline: none;
  padding: 10px 14px 10px 0;
  font-size: 13px; color: var(--text); font-family: inherit;
  -webkit-appearance: none; appearance: none;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23A5AAB3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1px center;
  background-size: 7px 4.5px;
}
/* 省份名最长（如“加利福尼亚州”），给它多一点宽 */
.place-triple #fCountry { flex-grow: .92; }
.place-triple #fProv { flex-grow: 1.36; }
.place-triple #fCity { flex-grow: .92; }
.place-triple select:disabled { color: #C3C7CD; opacity: .7; }
.place-triple select:focus { color: var(--blue); }

/* 经度手填框 */
#fLng {
  background: var(--bg); border: 0; border-radius: 8px; padding: 6px 8px;
  width: 76px; text-align: right; outline: none;
}
#fLng::-webkit-outer-spin-button, #fLng::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.seg { display: flex; background: var(--bg); border-radius: 9px; padding: 2px; }
.seg button { padding: 5px 14px; border-radius: 7px; font-size: 13px; color: var(--sub); transition: .15s; }
.seg button.on { background: var(--blue); color: #fff; }
.seg.mini button { padding: 4px 9px; font-size: 12px; }

.chip-row { display: flex; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); border-radius: 14px; padding: 4px 12px; font-size: 12px; color: var(--sub); background: var(--card); }
.chip.on { border-color: var(--blue); color: var(--blue); background: var(--blue-weak); }

.btn-primary {
  display: block; width: calc(100% - 28px); margin: 12px 14px 14px;
  background: var(--blue); color: #fff; height: 44px; border-radius: 22px;
  font-size: 16px; font-weight: 500;
}
.btn-primary:active { opacity: .85; }
.btn-ghost {
  display: block; width: 100%; background: var(--card); color: var(--blue);
  height: 46px; border-radius: 12px; font-size: 15px; border: 1px solid var(--line);
}

/* ---------- 盘式 tabs ---------- */
.panshi-tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.panshi-tabs button {
  flex: 1; padding: 11px 0; font-size: 14px; color: var(--sub); position: relative;
}
.panshi-tabs button.on { color: var(--blue); font-weight: 500; }
.panshi-tabs button.on::after {
  content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 26px; height: 2.5px; background: var(--blue); border-radius: 2px;
}

/* ---------- 命盘表 ---------- */
.chart-wrap { background: var(--card); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart {
  display: grid;
  grid-template-columns: 42px repeat(4, 1fr) 1fr 1fr;
  font-size: 12px;
  min-width: 340px;
  padding-bottom: 4px;
}
.chart .cell { padding: 5px 1px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.35; }
.chart .row-label { font-size: 11px; color: var(--sub); text-align: center; justify-content: center; }
.chart .head { color: var(--sub); font-size: 11px; padding-top: 7px; }
.chart .ganzhi { font-size: 22px; font-weight: 500; letter-spacing: 1px; }
.chart .ganzhi.small { font-size: 17px; }
.chart .cz-line { display: flex; align-items: baseline; gap: 1px; font-size: 11px; justify-content: center; }
.chart .day-col { background: linear-gradient(180deg, rgba(58,107,240,.05), rgba(58,107,240,0)); }
.chart .yun-sep { border-left: 1px solid var(--line-strong); }
.chart .shensha { font-size: 10.5px; color: var(--sub); line-height: 1.5; padding: 3px 0 6px; }
.chart .shensha span { display: inline-block; margin: 0 1px; }
.chart .zan-row .cell { padding: 2px 1px 8px; }
.wx-木 { color: var(--wx-mu); }
.wx-火 { color: var(--wx-huo); }
.wx-土 { color: var(--wx-tu); }
.wx-金 { color: var(--wx-jin); }
.wx-水 { color: var(--wx-shui); }

/* 三柱信息（胎元等） */
.corner-row { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text); }
.corner-row .k { color: var(--sub); }
.corner-row .sep { color: var(--line-strong); }

/* ---------- 大运流年条 ---------- */
.yun-block { background: var(--card); border-top: 1px solid var(--line); }
.yun-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 4px; font-size: 12px; color: var(--sub); }
.yun-scroll { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 8px 10px; scrollbar-width: none; }
.yun-scroll::-webkit-scrollbar { display: none; }
.yun-item {
  flex: none; width: 62px; text-align: center; padding: 5px 0; border-radius: 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.yun-item .y { font-size: 10.5px; color: var(--sub); }
.yun-item .a { font-size: 10.5px; color: var(--sub); }
.yun-item .gz { font-size: 16px; font-weight: 500; letter-spacing: 1px; }
.yun-item.on { background: var(--blue-weak); }
.yun-item.on .y, .yun-item.on .a { color: var(--blue); }
.yun-item .ss { font-size: 9.5px; color: var(--sub); }

/* ---------- 节气条 ---------- */
.jq-strip { display: flex; overflow-x: auto; padding: 6px 8px 10px; gap: 2px; }
.jq-item { flex: none; width: 52px; text-align: center; font-size: 10px; color: var(--sub); line-height: 1.5; }
.jq-item .d { font-size: 10px; }
.jq-item .nm { font-size: 10.5px; color: var(--text); }
.jq-item .gz { font-size: 12px; }

/* ---------- 分析块 ---------- */
.an-row { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.7; }
.an-row:first-child { border-top: 0; }
.an-row .an-k { color: var(--sub); margin-right: 2px; }
.an-row .tags { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.wxbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 8px 0 6px; background: var(--bg); }
.wxbar i { display: block; height: 100%; }
.wx-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--sub); }

/* ---------- 列表 ---------- */
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--card); }
.list-item:first-child { border-top: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-t { font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.list-item .li-t .gz { font-size: 15px; letter-spacing: 2px; font-weight: 500; }
.list-item .li-s { font-size: 12px; color: var(--sub); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 10.5px; border-radius: 4px; padding: 1px 5px; background: var(--blue-weak); color: var(--blue); }
.badge.gray { background: var(--bg); color: var(--sub); }
.empty { text-align: center; color: var(--sub); font-size: 13px; padding: 60px 20px; }

/* ---------- 底部 tab ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex;
}
[data-theme="dark"] .tabbar { background: rgba(25,28,34,.94); }
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: #9AA0A8; font-size: 10.5px;
}
.tabbar button.on { color: var(--blue); }
.tabbar .ti { font-size: 19px; line-height: 1; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.mask.on { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--card); border-radius: 16px 16px 0 0;
  max-height: 88vh; overflow-y: auto;
  transform: translateY(102%); transition: transform .26s cubic-bezier(.3,.9,.3,1);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}
.sheet.on { transform: translateY(0); }
.sheet-head { position: sticky; top: 0; background: var(--card); display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-head .st { flex: 1; font-size: 15px; font-weight: 500; }
.sheet-head .close { color: var(--sub); font-size: 20px; }

/* 搜索 */
.search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--card); }
.search input {
  flex: 1; background: var(--bg); border: 0; border-radius: 9px; padding: 8px 12px; outline: none; font-size: 14px;
}

/* 复制提示 */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 10px);
  background: rgba(0,0,0,.82); color: #fff; font-size: 13px; padding: 9px 16px; border-radius: 18px;
  opacity: 0; pointer-events: none; transition: .22s; z-index: 99; max-width: 80vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 多盘 */
.duopan-item { margin-bottom: 10px; }
.multi-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; }
.multi-tabs .mt { border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 12px; font-size: 13px; color: var(--sub); flex: none; }
.multi-tabs .mt.on { border-color: var(--blue); color: var(--blue); background: var(--blue-weak); }

/* 断语编辑 */
.note-area {
  width: 100%; min-height: 180px; border: 0; outline: none; resize: vertical;
  padding: 12px 14px; background: var(--card); font-size: 14px; line-height: 1.75;
}
.footer-note { text-align: center; color: var(--sub); font-size: 11.5px; padding: 14px 20px 24px; line-height: 1.6; }
.row-between { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; background: #E2E5EA; border-radius: 14px; transition: .2s;
}
.switch i::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 23px; height: 23px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(19px); }
[data-theme="dark"] .switch i { background: #3A3F48; }

/* 十神简写颜色不在盘面行内做区分，统一灰 */
.chart .cz-line span:first-child { font-size: 12px; }

