/* ============================================================
   又见 · 组件与页面样式
   ------------------------------------------------------------
   所有取值（颜色 / 圆角 / 阴影 / 字号 / 间距）一律来自
   css/tokens.css 的 Design Tokens（var(--token)），禁止裸色值。
   本文件只负责组件与布局，不定义设计变量。
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; font-family: var(--font-sans); background: var(--bg-page); color: var(--ink); font-size: 14px; line-height: 1.5; }
#app { max-width: var(--app-max); margin: 0 auto; min-height: 100%; padding-bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom)); position: relative; }

/* 顶部导航已统一使用 components.css 的 .ui-header / .ui-header__btn（含 .btn-user 状态），旧 .topbar/.btn-icon/.btn-user 类已移除 */

/* 用户下拉菜单 */
.user-menu { position: absolute; top: 40px; right: 0; width: 132px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: 6px; z-index: var(--z-modal); }
.user-menu .um-name { font-size: 12px; color: var(--text-secondary); padding: 6px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu .um-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 9px 8px; border-radius: var(--radius-sm); font-size: 13px; color: var(--ink); cursor: pointer; }
.user-menu .um-item:active { background: var(--bg-soft); }

/* 登录弹窗 */
.login-body { text-align: center; padding: 26px 20px 22px; }
.login-title { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: 4px; color: var(--ink); }
.login-sub { font-size: 12px; color: var(--text-secondary); margin: 8px 0 18px; line-height: 1.5; }
.login-input { width: 100%; box-sizing: border-box; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 0 12px; font-size: 15px; color: var(--ink); outline: none; }
.login-input:focus { border-color: var(--brand-gold); }
.login-input + .login-input { margin-top: 10px; }
.login-btn { width: 100%; height: 44px; margin-top: 14px; font-size: 15px; border: none; border-radius: var(--radius-input); background: var(--ink); color: var(--text-inverse); font-weight: 600; letter-spacing: 2px; cursor: pointer; }
.login-btn:active { background: var(--ink-hover); }
.login-hint { font-size: 11px; color: var(--text-secondary); margin-top: 12px; line-height: 1.5; }

.tab-page { display: none; padding: 14px 14px 24px; }
.tab-page.active { display: block; }

/* 注：.card 旧类已弃用，统一使用 components.css 的 .ui-card */

/* 首页：即时局（当前时间卡片） */
.instant-bureau { position: relative; padding: 16px 44px 14px 16px; cursor: pointer; overflow: hidden; }
.ib-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ib-label { font-size: 11px; color: var(--text-secondary); letter-spacing: 1px; background: var(--bg-soft); padding: 4px 10px; border-radius: var(--radius-lg); }
.ib-time { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.ib-pillars { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.ib-col { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ib-col span { font-size: 10px; color: var(--text-secondary); }
.ib-col b { font-size: 22px; font-weight: 600; line-height: 1.05; }
/* 日柱（日主）适度强调：略大，不改五行色 */
.ib-col--day b { font-size: 24px; font-weight: 700; }
.ib-meta { margin-top: 10px; text-align: center; font-size: 11px; color: var(--text-secondary); line-height: 1.55; }
.ib-lunar, .ib-solar { font-variant-numeric: tabular-nums; }
.ib-solar { margin-top: 2px; }
.ib-arrow { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }

/* 五行文字色（仅用于天干/地支/五行统计/专业数据展示） */
.wx-wood { color: var(--wood) !important; }
.wx-fire { color: var(--fire) !important; }
.wx-earth { color: var(--earth) !important; }
.wx-metal { color: var(--metal) !important; }
.wx-water { color: var(--water) !important; }

/* 空亡括号：横向不折行 */
.kong-zhi { display: inline-flex; white-space: nowrap; align-items: center; }

/* 首页：模块间距统一 */
.home-section { margin-top: 22px; }

/* 快捷起盘：1×4 紧凑行（统一线性图标 + 浅金圆底） */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 62px;
  padding: 11px 4px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.quick-card:active { background: var(--bg-soft); }
.quick-card__icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-round);
  background: var(--brand-gold-soft);     /* 浅金圆底，统一 */
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);                       /* 深色线性图标 */
}
.quick-card__icon .ui-icon { width: 18px; height: 18px; stroke-width: 1.8; }
.quick-card__title { font-size: 11px; font-weight: var(--fw-medium); color: var(--ink); line-height: 1.2; }
.quick-card__arrow { display: none; }

/* 最近使用 */
.recent-list { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.recent-item:active { background: var(--bg-soft); }
.recent-item__icon {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: var(--radius-round);
  background: var(--brand-gold-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.recent-item__icon .ui-icon { width: 20px; height: 20px; stroke-width: 1.8; }
.recent-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.recent-item__type { font-size: 14px; font-weight: var(--fw-semibold); color: var(--ink); }
.recent-item__sub { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item__arrow { flex: 0 0 auto; color: var(--text-tertiary); }

/* 最近使用 · 空状态 */
.recent-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 8px; padding: 22px 16px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.recent-empty__title { font-size: 15px; font-weight: var(--fw-semibold); color: var(--ink); }
.recent-empty__desc { font-size: 12px; color: var(--text-secondary); line-height: 1.6; max-width: 240px; }
.recent-empty .ui-btn-secondary { margin-top: 6px; }

/* 更多工具 */
.more-list { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.more-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 14px;
  background: transparent; border: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.more-row + .more-row { border-top: 1px solid var(--border); }
.more-row:active { background: var(--bg-soft); }
.more-row__icon { width: 22px; height: 22px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.more-row__icon .ui-icon { width: 20px; height: 20px; stroke-width: 1.8; }
.more-row__label { flex: 1; font-size: 14px; color: var(--ink); }
.more-row__arrow { flex: 0 0 auto; color: var(--text-tertiary); }

/* 区块标题已由 components.css 的 .ui-section-title 统一；.home-section 间距见上方定义 */


/* 案例列表 */
.case-list { display: flex; flex-direction: column; gap: 8px; }
.case-item { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 11px 12px; display: flex; align-items: center; gap: 11px; cursor: pointer; transition: var(--dur-fast); }
.case-item:active { background: var(--bg-soft); }
.ci-avatar { width: 40px; height: 40px; border-radius: var(--radius-round); background: var(--bg-soft); border: 1px solid var(--border); flex: 0 0 auto; }
.ci-body { flex: 1; min-width: 0; }
.ci-main { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 3px; flex-wrap: wrap; }
.ci-gender { font-size: 10px; color: var(--text-secondary); background: var(--bg-soft); padding: 1px 7px; border-radius: var(--radius-lg); }
.ci-gz { font-size: 11px; color: var(--text-secondary); }
.ci-sub { font-size: 11px; color: var(--text-secondary); }

/* 表单卡片 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; letter-spacing: .5px; }
.field input[type="text"], .field select {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 0 12px; font-size: 15px; background: var(--bg-input); color: var(--ink); outline: none; appearance: none; -webkit-appearance: none;
}
.field select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236F6A62' stroke-width='1.5'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.field input:focus, .field select:focus { border-color: var(--brand-gold); }

/* 注：.seg-mode/.seg/.qimen-seg 旧类已弃用，分段控件统一使用 components.css 的 .ui-segmented */

/* 注：.datetime-display 旧类已弃用，时间选择行统一使用 .ui-input-row（id=datetime-display 仅作 DOM 钩子） */

/* 农历输入 */
.lunar-year-wrap, .lunar-month-wrap { display: flex; align-items: center; gap: 8px; }
.lunar-year-wrap input { flex: 1; min-width: 0; width: 100%; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 0 12px; font-size: 15px; background: var(--bg-input); color: var(--ink); outline: none; appearance: none; -webkit-appearance: none; }
.lunar-suffix { font-size: 13px; color: var(--text-secondary); flex: 0 0 auto; }
.lunar-month-wrap .seg-leap { flex: 0 0 88px; }
.lunar-month-wrap #inp-lmonth { flex: 1; min-width: 0; }

/* 四柱输入 */
.pillars-input { }
/* 四柱输入：横向 4 个圆 */
.pillars-input-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 6px; }
.pillar-circle {
  border: 1px solid var(--border); border-radius: 50%; aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; background: var(--bg-input); transition: var(--dur-fast);
}
.pillar-circle:active { transform: scale(0.96); background: var(--bg-soft); }
.pillar-circle span { font-size: 9px; color: var(--text-secondary); line-height: 1; margin-bottom: 3px; }
.pillar-gz { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1; }
.pillar-gz b { font-weight: 600; }
.pillar-gz .gan { font-size: 20px; }
.pillar-gz .zhi { font-size: 20px; }

/* 省市县 */
.city-row { display: flex; gap: 8px; }
.city-row select { flex: 1; min-width: 0; font-size: 13px; }

/* 注：.btn-primary/.btn-ghost/.btn-secondary/.btn-save 旧类已弃用，按钮统一使用 components.css 的 .ui-btn-* */

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-mask { position: absolute; inset: 0; background: var(--overlay-mask); }
.modal-body { position: relative; width: 100%; max-width: var(--app-max); background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 18px 14px calc(22px + env(safe-area-inset-bottom)); max-height: 80vh; overflow-y: auto; box-shadow: var(--shadow-modal); animation: modalUp .25s ease; }
@keyframes modalUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-title { text-align: center; font-size: 15px; font-weight: 600; margin-bottom: 16px; letter-spacing: 1px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .ui-btn-secondary { margin: 0; flex: 1; }
.modal-actions .ui-btn-primary { margin: 0; flex: 1; }

/* 三级地区选择器列表 */
.region-list { max-height: 52vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.region-item {
  display: block; width: 100%; text-align: left;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-input);
  padding: 14px 16px; font-size: 15px; color: var(--ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.region-item + .region-item { margin-top: 8px; }
.region-item.selected { border-color: var(--ink); font-weight: var(--fw-semibold); }
.region-item:active { background: var(--bg-soft); }

/* 时间滚轮 */
.time-wheel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
.tw-field { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tw-field span { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: var(--radius-round); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--text-secondary); }
.tw-field input { width: 100%; height: 40px; border: none; border-bottom: 1px solid var(--border); text-align: center; font-size: 18px; color: var(--ink); background: transparent; outline: none; }
.tw-field input:focus { border-bottom-color: var(--brand-gold); }

/* 天干地支选择器（底部弹窗） */
.modal-drag { width: 36px; height: 4px; border-radius: 999px; background: var(--border); margin: 2px auto 12px; }
.pp-current { text-align: center; font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; letter-spacing: .5px; }
.pp-section-label { font-size: 12px; color: var(--text-secondary); margin: 4px 0 10px; letter-spacing: .5px; }
.pp-section-label b { color: var(--ink); font-weight: 600; }

/* 天干：2 行 5 列；地支：3 行 4 列 */
.picker-gan { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.picker-zhi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }

.pp-cell {
  height: 48px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); font-size: 17px; color: var(--ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
/* 选中：品牌金底 + 白字 */
.pp-cell.active { background: var(--brand-gold); border-color: var(--brand-gold); color: var(--text-inverse); }
/* 不可选：无边框、透明底、浅灰字、禁点（禁用态用 --text-disabled，符合规范） */
.pp-cell.disabled { border-color: transparent; background: transparent; color: var(--text-disabled); pointer-events: none; }
.pp-hint { font-size: 13px; color: var(--text-disabled); text-align: center; padding: 20px 0; }

/* 注：.pp-confirm 旧类已弃用，四柱选择器「完成」按钮统一使用 .ui-btn-primary */

/* 打开弹窗时锁定页面背景滚动 */
body.no-scroll { overflow: hidden; }

/* 候选时间列表 */
.candidate-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.candidate-item { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-input); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: var(--dur-fast); }
.candidate-item:active { background: var(--bg-soft); }
.cand-date { font-size: 15px; color: var(--ink); }
.cand-gz { font-size: 13px; color: var(--text-secondary); }
.candidate-empty, .candidate-loading { text-align: center; padding: 24px; color: var(--text-secondary); font-size: 14px; }

/* 隐藏工具 */
.hidden { display: none !important; }

/* 案例删除 */
.ci-delete { width: 32px; height: 32px; border: none; border-radius: var(--radius-round); background: transparent; color: var(--text-secondary); font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ci-delete:active { background: var(--bg-soft); color: var(--danger); }

/* 结果 */
.result { margin-top: 8px; }
.result.hidden { display: none; }
.result-tabs { display: flex; align-items: center; gap: 6px; }
.result-tabs .rt-tab { flex: 1; height: 38px; border: none; border-radius: var(--radius-sm); background: transparent; font-size: 15px; color: var(--text-secondary); cursor: pointer; transition: var(--dur-fast); }
.result-tabs .rt-tab.active { background: var(--ink); color: var(--text-inverse); font-weight: 600; }
.rt-panel { display: none; }
.rt-panel.active { display: block; }

/* 结果卡片：按功能块分隔 */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  margin-bottom: 12px;
}
.result-card:last-child { margin-bottom: 0; }
.result-card__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
  margin-bottom: 12px;
}
.result-head { margin-bottom: 0; } /* head 已放入 result-card，自身不再加 margin */
.rh-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rh-name { font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--ink); }
.rh-gender, .rh-zodiac { font-size: 10px; color: var(--text-secondary); background: var(--bg-soft); padding: 2px 8px; border-radius: var(--radius-lg); }
.rh-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.rh-wx { font-size: 11px; color: var(--brand-gold); margin-top: 6px; font-weight: 600; letter-spacing: .5px; }
.rh-wx-unknown { font-size: 9px; color: var(--text-tertiary); font-weight: 400; }

/* 注：.mp-panel/.mp-title 兼容旧名已弃用，统一使用 .result-card/.result-card__title */

/* ===== 时间局：表格式四列（年/月/日/时） ===== */
.mingpan-card {
  padding: 12px;
}
.mingpan-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-soft);
}
.mingpan-table .mpt-row {
  display: grid;
  grid-template-columns: 40px repeat(4, 1fr);
  text-align: center;
  min-height: 48px;
}
.mingpan-table .mpt-row + .mpt-row {
  border-top: 1px solid var(--border);
}
.mingpan-table .mpt-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
}
.mingpan-table .mpt-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 2px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.1;
}
.mingpan-table .mpt-cell + .mpt-cell {
  border-left: 1px solid var(--border);
}
.mingpan-table .mpt-cell.mpt-head {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 2px;
  background: var(--bg-soft);
  padding: 10px 2px;
}
.mingpan-table .mpt-cell .zg {
  display: block;
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-top: 2px;
  letter-spacing: 0;
}
.mingpan-table .mpt-cell.cang-cell {
  font-size: 10px;
  font-weight: 400;
  gap: 1px;
}
.mingpan-table .mpt-cell.kong-cell {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: .5px;
}

/* 日元轻量标记 */
.dm-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-gold-soft);
}

/* ===== 细盘：地支点击长生交互 ===== */
.xcell.zhi {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.xcell.zhi:active,
.xcell.zhi.selected,
.xcell.selected {
  background: var(--brand-gold-soft);
}
.xcell.cs-day {
  position: relative;
}
.xcell.cs-day.cs-preview {
  background: var(--brand-gold-soft);
  color: var(--brand-gold);
  font-weight: 700;
}
.xcell.cs-day.cs-preview::after {
  content: "预览";
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 7px;
  color: var(--brand-gold);
  letter-spacing: 0;
  line-height: 1;
}
/* ===== 五行图例 ===== */
.wx-legend { display: flex; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.wx-legend .wx-i { flex: 1; text-align: center; }
.wx-legend .wx-dot { width: 7px; height: 7px; border-radius: var(--radius-round); display: inline-block; vertical-align: middle; margin-right: 4px; }
.wx-legend .wx-name { font-size: 10px; color: var(--text-secondary); display: inline; }
.wx-legend .wx-val { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 3px; }
.wx-legend .wx-val small { font-size: 9px; color: var(--text-secondary); font-weight: 400; margin-left: 2px; }

/* 神煞 */
.shensha { margin-top: 14px; }
.ss-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.ss-tag { font-size: 11px; color: var(--text-secondary); background: var(--bg-soft); padding: 4px 9px; border-radius: var(--radius-lg); }

/* ===== 细盘 7列网格（label+流年+大运+年+月+日+时） ===== */
.xipan-grid { display: grid; grid-template-columns: 44px repeat(6, 1fr); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-size: 11px; }
.xrow-label { background: var(--bg-soft); color: var(--text-secondary); font-size: 10px; display: flex; align-items: center; justify-content: center; padding: 6px 2px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.xcell-head { background: var(--bg-soft); color: var(--ink); font-weight: 600; font-size: 10px; padding: 8px 2px; text-align: center; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.xcell-head.sep { border-left: 2px solid var(--border); }
.xcell { background: var(--bg-card); padding: 6px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 38px; }
.xcell.sep { border-left: 2px solid var(--border); }
/* 时间组天干/地支铺暖砂底，命局组白底，靠 sep 竖线隔开 */
.xcell.gan.col-time, .xcell.zhi.col-time { background: var(--brand-gold-soft); }
.xcell.gan.col-life, .xcell.zhi.col-life { background: var(--bg-card); }
.xcell .zg { font-size: 9px; color: var(--text-secondary); }
.xcell.gan { font-size: 13px; font-weight: 600; }
.xcell.zhi { font-size: 13px; font-weight: 600; }
.xcell.cg-col { gap: 1px; }
.xcell.cg-col .cg2 { font-size: 10px; }
.cg2 .ss { font-style: normal; color: var(--text-secondary); font-weight: 400; margin-left: 1px; }

/* 大运：单排等宽卡片，不滚动 */
.yun-card-row { display: flex; gap: 4px; padding: 4px 0 12px; }
.yun-card { flex: 1 1 0; min-width: 0; padding: 5px 2px; border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--bg-card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; transition: var(--dur-fast); }
.yun-card .yc-meta { font-size: 8px; color: var(--text-secondary); white-space: nowrap; line-height: 1.2; }
.yun-card .yc-gz { display: flex; flex-direction: column; align-items: center; gap: 0; }
.yun-card .yc-gz b { font-size: 10px; font-weight: 600; line-height: 1.1; }
.yun-card .yc-year-range { font-size: 7px; color: var(--text-tertiary); }
.yun-card.yun-card--xiao { background: var(--brand-gold-soft); border-color: var(--brand-gold-line); }
.yun-card.yun-card--xiao .yc-meta { color: var(--brand-gold); font-weight: 600; }
.yun-card.active { background: var(--brand-gold-soft); border-color: var(--brand-gold); }
.yun-card.active .yc-meta { color: var(--brand-gold); }
.liunian-scroll { display: flex; flex-wrap: nowrap; gap: 8px; padding: 6px 2px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; scrollbar-width: none; }
.liunian-scroll::-webkit-scrollbar { display: none; }

.ln-pill { flex: 0 0 auto; min-width: 40px; min-height: 46px; padding: 5px 4px; border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--bg-card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; transition: var(--dur-fast); }
.ln-pill b { font-size: 12px; font-weight: 600; line-height: 1.1; }
.ln-pill span { font-size: 8px; color: var(--text-secondary); }
.ln-pill span.ln-age { font-size: 7px; color: var(--text-secondary); opacity: .85; margin-top: -1px; }
.ln-pill.active { background: var(--brand-gold-soft); border-color: var(--brand-gold); }
.ln-pill.active span { color: var(--brand-gold); opacity: .85; }

/* 提示与笔记 */
.hint-row { display: flex; gap: 6px; font-size: 12px; line-height: 1.7; }
.hint-row + .hint-row { margin-top: 4px; }
.hint-label { color: var(--text-secondary); flex: 0 0 auto; font-size: 11px; }
.hint-text { color: var(--ink); }
.hint-empty { font-size: 12px; color: var(--text-secondary); }

.notes-textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-input); padding: 10px 12px; font-size: 13px; color: var(--ink); background: var(--bg-input); resize: vertical; outline: none; font-family: inherit; line-height: 1.6; min-height: 76px; }
.notes-textarea:focus { border-color: var(--brand-gold); }
.notes-textarea[readonly] { background: var(--bg-soft); }
.notes-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.notes-count { font-size: 11px; color: var(--text-secondary); }
.notes-actions { display: flex; gap: 8px; }
.notes-actions .ui-btn-secondary--inline, .notes-actions .ui-btn-gold--inline { margin: 0; }

/* 万年历 */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; }
.cal-nav { width: 38px; height: 38px; border: none; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-input); font-size: 18px; color: var(--ink); }
.cal-title { font-size: 15px; font-weight: 600; letter-spacing: 1px; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--text-secondary); padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-day { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-input); text-align: center; padding: 8px 0; min-height: 46px; display: flex; flex-direction: column; justify-content: center; cursor: pointer; }
.cal-day.today { background: var(--ink); border-color: var(--ink); color: var(--text-inverse); }
.cd-s { font-size: 14px; }
.cd-l { font-size: 9px; color: var(--text-secondary); margin-top: 2px; }
.cd-term { color: var(--brand-gold); font-weight: 600; }
.cal-day.term-day { border-color: var(--brand-gold-line); }
.cal-day.today .cd-l { color: var(--text-inverse-dim); }
.cal-detail { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); line-height: 1.7; }

/* 罗盘 */
.compass-wrap { position: relative; width: 260px; height: 260px; margin: 18px auto; }
.compass { width: 100%; height: 100%; transform-origin: center; }
.compass-needle { position: absolute; top: 50%; left: 50%; width: 4px; height: 100px; margin-left: -2px; margin-top: -100px; background: linear-gradient(to top, var(--ink) 50%, var(--fire) 50%); border-radius: 2px; transform-origin: bottom center; }
.compass-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 13px; color: var(--ink); font-weight: 600; }
.compass-readout { text-align: center; font-size: 15px; margin-top: 10px; color: var(--ink); }
.hint { font-size: 11px; color: var(--text-secondary); text-align: center; margin: 10px 14px; line-height: 1.6; }

/* 奇门遁甲 · 起局页 */
#page-qimen { padding: 20px 20px 24px; }   /* 页面左右 20px */
.qimen-head { text-align: left; padding: 4px 0 18px; }
.qimen-title { font-size: 22px; font-weight: var(--fw-semibold); letter-spacing: 2px; color: var(--ink); line-height: 1.2; }
.qimen-sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; letter-spacing: 1px; }

/* 表单直接铺在页面背景上（去掉最外层大卡片），模块间距 20px */
.qimen-form { display: flex; flex-direction: column; gap: var(--space-form); }
#qimen-time-input, #qimen-pillars-input { display: flex; flex-direction: column; gap: var(--space-form); }
.qf-block { display: block; }
.qf-label { font-size: 13px; font-weight: var(--fw-semibold); color: var(--ink); margin-bottom: 10px; letter-spacing: .5px; }

/* 真太阳时校准设置行 */
.qf-setting { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 4px 2px; gap: 12px; }
.qf-setting__label { font-size: 15px; color: var(--ink); }

/* Switch 开关 */
.ui-switch {
  position: relative; width: 48px; height: 28px; flex: 0 0 auto;
  border: none; border-radius: 999px; background: var(--bg-soft);
  padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.ui-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--text-inverse); box-shadow: 0 1px 2px rgba(31,27,22,.25);
  transition: transform var(--dur-fast);
}
.ui-switch[aria-checked="true"] { background: var(--ink); }
.ui-switch[aria-checked="true"]::after { transform: translateX(20px); }

/* 四柱起局：局数输入 */
.qf-input {
  width: 100%; height: 44px; padding: 0 14px; font-size: 15px; color: var(--ink);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-input);
}

.qimen-result { padding: 8px 0 24px; margin: 0; }

/* 奇门宫格底色：仅空亡宫用极浅灰区分（值符/值使不靠颜色表达） */
:root {
  --qm-kong-bg: #F1F0ED;   /* 空亡宫：极浅灰 */
  --qm-cell-border: #DDD8CF;
  --qm-star: var(--ink);   /* 九星：墨 */
  --qm-men:  #B05A3C;      /* 八门：陶 */
  --qm-shen: #3F6E63;      /* 八神：青 */
}

/* ---------- 1) 局势摘要卡片 ---------- */
.qm-summary { margin: 0 10px 10px; background: var(--bg-card); border: 1px solid var(--qm-cell-border); border-radius: var(--radius-lg); padding: 12px; }
.qm-summary-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.qm-ju { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.qm-ju b { font-size: 20px; font-weight: 500; color: var(--ink); letter-spacing: 1px; }
.qm-ju-sub { font-size: 11px; color: var(--text-secondary); letter-spacing: 1px; }
.qm-summary-top .ui-btn-secondary--inline { flex: 0 0 auto; height: 30px; padding: 0 12px; font-size: 13px; }
.qm-gz { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; margin: 4px 0 8px; }
.qm-gz-pair { display: inline-flex; gap: 2px; font-size: 18px; line-height: 1; letter-spacing: 2px; }
.qm-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.qm-kv { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.qm-k { flex: 0 0 auto; font-size: 11px; color: var(--text-secondary); background: var(--bg-soft); border-radius: var(--radius-sm); padding: 1px 7px; letter-spacing: .5px; }
.qm-v { font-size: 13px; color: var(--ink); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 2/3/4) 九宫格 + 层级 ---------- */
.qimen-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 10px; border: 1px solid var(--qm-cell-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--qm-cell-border); }
.qg {
  position: relative;
  background: var(--bg-card);
  aspect-ratio: 1 / 1;
  padding: 5px 6px 4px;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}
/* 仅空亡宫用极浅灰区分 */
.qg--kong { background: var(--qm-kong-bg); }

/* 宫名与洛书数合并为「巽4」，右下角 */
.qg-name { position: absolute; right: 4px; bottom: 3px; font-size: 11px; color: var(--text-secondary); line-height: 1; }

/* 天盘 / 地盘 干：左列，左对齐，底部对齐 */
.qg-gans { display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; text-align: left; gap: 2px; min-width: 0; }
.qg-tianpan, .qg-dipan { font-size: clamp(12px, 3.8vw, 15px); font-weight: 400; line-height: 1.25; color: var(--ink); white-space: nowrap; }

/* 星 / 神 / 门：右列，从上到下竖排，字号一致，纤细，行间距增大 */
.qg-col { display: flex; flex-direction: column; gap: 6px; align-self: center; align-items: flex-end; text-align: right; min-width: 0; }
.qg-star { font-size: clamp(12px, 4vw, 15px); font-weight: 400; color: var(--qm-star); line-height: 1.15; white-space: nowrap; }
.qg-men  { font-size: clamp(12px, 4vw, 15px); font-weight: 400; color: var(--qm-men);  line-height: 1.15; white-space: nowrap; }
.qg-shen { font-size: clamp(12px, 4vw, 15px); font-weight: 400; color: var(--qm-shen); line-height: 1.15; white-space: nowrap; }

/* 单个干+角标：右下对齐 */
.qg-stem-unit { display: inline-flex; align-items: flex-end; gap: 1px; line-height: 1; }
.qg-stem-unit b { font-weight: 400; }

/* 驿马：右上角 */
.qg-horse { position: absolute; top: 3px; right: 4px; font-size: 10px; font-weight: 500; color: var(--text-secondary); line-height: 1; }
/* 墓 / 击刑：干字右下小角标 */
.mk { font-size: .42em; font-weight: 400; line-height: 1; margin: 0 0 .05em 1px; }
.mk-mu { color: var(--earth); }
.mk-ji { color: var(--danger); }
.qg-dash { color: var(--text-disabled); }

/* ---------- 5) 全屏查看 ---------- */
body.qm-fs-open .topbar,
body.qm-fs-open .ui-nav,
body.qm-fs-open .tabbar { display: none !important; }
body.qm-fs-open { overflow: hidden; }
.qm-fs { position: fixed; inset: 0; z-index: 3000; display: flex; }
.qm-fs.hidden { display: none; }
.qm-fs-mask { position: absolute; inset: 0; background: var(--bg-page); }
.qm-fs-panel { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
.qm-fs-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.qm-fs-title { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: 1px; }
.qm-fs-bar .ui-btn-secondary--inline { height: 32px; padding: 0 14px; font-size: 14px; }
.qm-fs-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.qm-fs-grid { width: min(96vw, calc(100vh - 120px)); max-width: 560px; margin: 0; }
.qm-fs-grid .qg-star, .qm-fs-grid .qg-men, .qm-fs-grid .qg-shen { font-size: clamp(14px, 3.6vh, 18px); }
.qm-fs-grid .qg-tianpan, .qm-fs-grid .qg-dipan { font-size: clamp(14px, 4.6vh, 22px); }
.qm-fs-grid .qg-name, .qm-fs-grid .qg-horse { font-size: clamp(11px, 2.6vh, 14px); }

/* ---------- 6) 九宫格下方内容 ---------- */
.qm-below { margin: 12px 10px 0; display: flex; flex-direction: column; gap: 10px; }
.qm-card { margin: 0; }
.qm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.qm-card-head .result-card__title { margin: 0; }
.qm-card-head .ui-btn-secondary--inline { flex: 0 0 auto; height: 30px; padding: 0 12px; font-size: 13px; }
.qm-hint-line { font-size: 12px; color: var(--text-secondary); line-height: 1.6; }
.qm-key-list { display: flex; flex-direction: column; gap: 6px; }
.qm-key-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.qm-key-k { flex: 0 0 auto; font-size: 11px; color: var(--text-secondary); background: var(--bg-soft); border-radius: var(--radius-sm); padding: 1px 8px; }
.qm-key-v { color: var(--ink); }
.qm-save-btn { width: 100%; }

/* 小屏进一步收敛（保证可读、不溢出） */
@media (max-width: 340px) {
  .qm-summary-grid { grid-template-columns: 1fr; }
  .qg { padding: 5px; }
}

/* 注：.tabbar/.tab 旧类已弃用，底部导航统一使用 components.css 的 .ui-nav */

/* 空提示 */
.home-section .hint { margin: 16px 0 0; }

/* ============================================================
   基础排版类（统一字号 / 字重，来源 tokens.css）
   使用方式：在元素上追加对应 class 即可，避免各处散写 font-size。
   当前存量页面保持原尺寸不动；新页面 / 重写页面请优先使用以下类。
   ============================================================ */
.t-page-title   { font-size: var(--fs-page);   font-weight: var(--fw-semibold); line-height: 1.3; }
.t-module-title { font-size: var(--fs-module); font-weight: var(--fw-semibold); line-height: 1.4; }
.t-card-title   { font-size: var(--fs-card);   font-weight: var(--fw-semibold); line-height: 1.4; }
.t-body         { font-size: var(--fs-body);   font-weight: var(--fw-regular);   line-height: 1.6; }
.t-aux          { font-size: var(--fs-aux);    font-weight: var(--fw-regular);   line-height: 1.5; }
.t-label        { font-size: var(--fs-label);  font-weight: var(--fw-medium);    line-height: 1.4; }
.t-stem         { font-size: var(--fs-stem);   font-weight: var(--fw-medium);    line-height: 1.1; letter-spacing: 1px; }
.t-stem-lg      { font-size: var(--fs-stem-lg);font-weight: var(--fw-medium);    line-height: 1.1; letter-spacing: 1px; }

/* ============================================================
   首页「案例」两列（时间局 / 奇门）—— 对齐小程序 home 体验
   ============================================================ */
.case-cols { display: flex; gap: 12px; align-items: flex-start; }
.case-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.case-col-hd { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.case-col-tag { font-size: 12px; color: var(--text-inverse); border-radius: 8px; padding: 2px 10px; line-height: 1.6; }
.case-col-tag.bazi { background: var(--brand-gold); }
.case-col-tag.qimen { background: var(--wood); }
.case-col-cnt { font-size: 12px; color: var(--text-tertiary); }
.case-chip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  text-align: left; width: 100%; cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.case-chip:active { background: var(--overlay-press); }
.case-chip--collapsed { display: none; }
.cc-title { font-size: 14px; color: var(--text-primary); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-sub { font-size: 12px; color: var(--text-secondary); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-col-empty { font-size: 13px; color: var(--text-tertiary); text-align: center; padding: 18px 0; }
.case-col-more {
  font-size: 12px; color: var(--brand-gold); background: transparent;
  border: none; padding: 6px 0; cursor: pointer; align-self: flex-start;
}
.case-more { margin-top: 14px; text-align: center; font-size: 13px; color: var(--brand-gold); cursor: pointer; }

/* ============================================================
   起盘浮动按钮（FAB）
   ============================================================ */
.home-fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 52px; height: 52px; border-radius: var(--radius-round);
  background: var(--brand-gold); color: var(--text-inverse);
  border: none; box-shadow: 0 4px 14px rgba(181,138,29,0.40);
  font-size: 30px; line-height: 1; font-weight: 300;
  display: flex; align-items: center; justify-content: center;
  z-index: 90; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.home-fab:active { transform: scale(0.92); }

/* ============================================================
   结果页底部「保存此时间局」居中全宽按钮
   ============================================================ */
.result-save-row { margin: 16px 0 4px; display: flex; justify-content: center; }
.btn-save-bottom {
  width: 100%;
  max-width: 460px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: var(--fw-medium, 500);
  letter-spacing: 2px;
  border-radius: var(--radius-pill, 999px);
}
.btn-save-bottom:active { transform: scale(0.985); }

/* ============================================================
   登录/注册 Tab
   ============================================================ */
.login-tabs { display: flex; gap: 8px; margin: 4px 0 4px; }
.login-tab {
  flex: 1; height: 38px; border: 1px solid var(--border); background: transparent;
  border-radius: var(--radius-input); font-size: 14px; color: var(--text-secondary); cursor: pointer;
}
.login-tab.active { background: var(--ink); color: var(--text-inverse); border-color: var(--ink); font-weight: 600; }
.login-tab:active { opacity: .85; }

/* ============================================================
   修改密码弹窗
   ============================================================ */
.pw-body { padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
.pw-title { text-align: center; font-size: 16px; font-weight: 600; letter-spacing: 2px; margin-bottom: 16px; color: var(--ink); }
.pw-msg { min-height: 18px; font-size: 12px; color: #d9534f; text-align: center; margin: 8px 0 2px; }
.pw-actions { display: flex; gap: 10px; margin-top: 12px; }
.pw-actions .ui-btn-secondary { flex: 1; }
.pw-actions .login-btn { flex: 1; margin-top: 0; }

/* ============================================================
   管理员后台（全屏面板）
   ============================================================ */
.admin-mask {
  position: fixed; inset: 0; z-index: 1200; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.admin-mask.hidden { display: none; }
.admin-panel {
  width: 100%; max-width: 760px; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-modal);
}
.admin-bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.admin-title { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: 1px; }
.admin-tabs { display: flex; gap: 8px; padding: 12px 16px 0; }
.admin-tab { flex: 1; height: 36px; border: 1px solid var(--border); background: transparent; border-radius: var(--radius-input); font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.admin-tab.active { background: var(--ink); color: var(--text-inverse); border-color: var(--ink); font-weight: 600; }
.admin-body { padding: 14px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.admin-loading, .admin-empty, .admin-error { padding: 30px 10px; text-align: center; font-size: 13px; color: var(--text-secondary); }
.admin-error { color: #d9534f; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); color: var(--ink); vertical-align: top; }
.admin-table th { color: var(--text-secondary); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--bg-card); }
.admin-table td.admin-note { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .admin-table { font-size: 11px; }
  .admin-table th, .admin-table td { padding: 6px 4px; }
  .admin-table td.admin-note { max-width: 120px; }
}
