/* ============================================================
   又见 · 统一基础组件库（ui-*）
   ------------------------------------------------------------
   所有取值一律来自 css/tokens.css 的 Design Tokens（var(--token)）。
   本文件是「基础组件」的唯一来源，与具体业务页面解耦。
   规则：
   - 不引入任何 UI 框架。
   - 图标统一使用线性 SVG（见 js/components.js 的 UI.icon），禁止 emoji。
   - 卡片阴影只允许 --shadow-card（轻），弹窗用 --shadow-modal。
   - 选中态用 --ink，重要确认用 --brand-gold，未选中透明/白。
   全站替换时，原 style.css 中的 .topbar/.tabbar/.btn-* 等旧类将统一迁移到本文件。
   ============================================================ */

/* —— 线性图标基础 —— */
.ui-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
  vertical-align: middle;
}
.ui-icon svg { width: 100%; height: 100%; display: block; }
.ui-icon-wrap { display: inline-flex; align-items: center; justify-content: center; }

/* ============================================================
   1. AppHeader  顶部导航条
   - 左：菜单按钮  中：标题  右：用户入口（可选搜索）
   - 统一高度，适配 iPhone safe-area（顶部）
   ============================================================ */
.ui-header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  min-height: 56px;
  background: var(--surface-blur);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.ui-header__side {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 56px;
  flex: 0 0 auto;
}
.ui-header__side--right { justify-content: flex-end; position: relative; }
.ui-header__title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 60%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--ink);
  pointer-events: none;
}
.ui-header__title-main {
  font-size: 20px;
  font-weight: var(--fw-semibold);
  letter-spacing: 1px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ui-header__title-sub {
  font-size: 11px;
  line-height: 1.3;
  margin-top: 2px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ui-header__title-sub[hidden] { display: none; }

/* —— 「又见」图片 logo 样式 —— */
.brand-lockup { display: flex; align-items: center; gap: 6px; }
.brand-wordmark {
  height: 26px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.brand-wordmark[hidden] { display: none; }
.brand-seal { width: 26px; height: 26px; flex: 0 0 auto; display: block; }
.brand-seal--lg { width: 60px; height: 60px; }
.brand-seal--login {
  width: 72px;
  height: auto;
  max-height: 110px;
  object-fit: contain;
  display: block;
}
.brand-wordmark--login {
  height: 30px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  display: block;
  margin-top: 14px;
}
.seal-frame { fill: none; stroke: var(--brand-gold); stroke-width: 4.5; }
.seal-char {
  fill: none; stroke: var(--brand-gold); stroke-width: 2.4;
  stroke-linejoin: round; stroke-linecap: round;
  font-family: "Songti SC","STSong","Noto Serif CJK SC","KaiTi","STKaiti",serif;
  font-size: 30px; text-anchor: middle; dominant-baseline: central;
}
.ui-header__btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ui-header__btn:active { background: var(--overlay-press); }
.ui-header__btn .ui-icon { width: 22px; height: 22px; }
/* 用户入口：默认统一 User 线性图标；登录后图标转品牌金作为状态提示；
   有真实头像时由 JS 注入 <img class="ui-header__avatar"> 覆盖图标 */
.ui-header__btn.on { color: var(--brand-gold); }
.ui-header__avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-round);
  object-fit: cover;
  display: block;
}

/* ============================================================
   2. BottomNav  底部导航
   - 统一线性图标 + 文字
   - 选中态用品牌金；点击区 ≥ 44×44；适配 safe-area-inset-bottom
   ============================================================ */
.ui-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: var(--app-max);
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  background: var(--nav-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--nav-divider);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: var(--z-nav);
  /* 不使用阴影（或仅极轻）；此处不加 box-shadow */
}
.ui-nav__item {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;            /* 点击区 ≥44×44 */
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;                    /* 图标↔文字间距 */
  color: var(--nav-inactive);  /* 未选中 #9A968E */
  font-size: 11px;             /* 文字字号 */
  font-weight: var(--fw-regular); /* 恒定字重，避免选中态引起布局跳动 */
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-fast);
}
.ui-nav__item .ui-icon {
  width: 22px;                 /* 图标尺寸 22px */
  height: 22px;
  stroke-width: 1.75;          /* 线宽 1.75px */
}
.ui-nav__item.active { color: var(--brand-gold); } /* 选中 #B58A1D，仅变色不变字重 */
.ui-nav__item:active { opacity: .7; }

/* ============================================================
   3. AppCard  标准卡片
   - 可配 padding（默认 --space-card）
   - 不允许过重阴影（仅 --shadow-card）
   ============================================================ */
.ui-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-card);
  box-shadow: var(--shadow-card);
}
.ui-card--flush { padding: 0; }                 /* 无内边距（用于列表/网格满铺） */
.ui-card--soft  { background: var(--bg-soft); border-color: transparent; } /* 次级层次 */
.ui-card__title {
  font-size: var(--fs-card);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: .5px;
}
.ui-card__sub {
  font-size: var(--fs-aux);
  color: var(--text-secondary);
  margin: -6px 0 10px;
}

/* ============================================================
   4. PrimaryButton  主按钮
   - 高 54 / 圆角 14 / 背景 --ink / 白字
   - 支持 loading / disabled / success
   ============================================================ */
.ui-btn-primary {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--ink);
  color: var(--text-inverse);
  font-size: 15px;
  font-weight: var(--fw-semibold);
  letter-spacing: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
  position: relative;
}
.ui-btn-primary:active { background: var(--ink-hover); }
.ui-btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.ui-btn-primary.is-loading { color: transparent; pointer-events: none; }
.ui-btn-primary.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ui-spin .6s linear infinite;
}
.ui-btn-primary.is-success { background: var(--success); }
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* 内联/小尺寸变体（用于行内，不强制满宽） */
.ui-btn-primary--inline { width: auto; height: 44px; padding: 0 20px; letter-spacing: 1px; }

/* ============================================================
   5. SecondaryButton  次要按钮
   - 白底 / 浅边框 / 深色文字 / 高 ≥44
   ============================================================ */
.ui-btn-secondary {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.ui-btn-secondary:active { background: var(--bg-soft); }
.ui-btn-secondary:disabled { color: var(--text-disabled); background: var(--bg-soft); cursor: not-allowed; }
.ui-btn-secondary--inline { width: auto; height: 36px; padding: 0 16px; font-size: 13px; letter-spacing: 0; }

/* ============================================================
   6. GoldButton  金色按钮（仅保存/重要确认）
   - 背景 --brand-gold / 白字
   ============================================================ */
.ui-btn-gold {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--brand-gold);
  color: var(--text-inverse);
  font-size: 15px;
  font-weight: var(--fw-semibold);
  letter-spacing: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.ui-btn-gold:active { background: var(--brand-gold-hover); }
.ui-btn-gold:disabled { opacity: .6; cursor: not-allowed; }
.ui-btn-gold .ui-icon { width: 20px; height: 20px; }
.ui-btn-gold--inline { width: auto; height: 36px; padding: 0 16px; font-size: 13px; letter-spacing: 1px; }

/* ============================================================
   7. SegmentedControl  分段控件
   - 选中态 --ink；未选中透明/白；不使用渐变
   - 用于「时间 / 四柱」「时间局 / 细盘」等互斥切换
   ============================================================ */
.ui-segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  overflow: hidden;
  background: var(--bg-input);
  padding: 3px;
  gap: 3px;
}
.ui-segmented__opt {
  flex: 1 1 0;
  min-height: 40px;
  border: none;
  background: transparent;
  border-radius: 11px;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.ui-segmented__opt.active {
  background: var(--ink);
  color: var(--text-inverse);
  font-weight: var(--fw-semibold);
}

/* ============================================================
   8. InputRow  输入行（标题 + 当前值 + 右箭头）
   - 整行可点；高度 ≥54；点击区覆盖整行
   ============================================================ */
.ui-input-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast);
}
.ui-input-row + .ui-input-row { margin-top: 10px; }
.ui-input-row:active { background: var(--bg-soft); }
.ui-input-row__label { font-size: 15px; color: var(--ink); flex: 0 0 auto; }
.ui-input-row__value {
  margin-left: auto;
  font-size: 15px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 12px;
}
.ui-input-row__value .ui-icon { width: 18px; height: 18px; color: var(--text-secondary); }

/* ============================================================
   9. SelectSheet  底部弹窗（选择器）
   - 标题 / 选项（含不可选）/ 完成按钮
   - 打开时锁定背景滚动
   ============================================================ */
.ui-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ui-sheet[hidden] { display: none; }
.ui-sheet__mask { position: absolute; inset: 0; background: var(--overlay-mask); }
.ui-sheet__panel {
  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(20px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: ui-sheet-up .25s var(--ease);
}
@keyframes ui-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.ui-sheet__close {
  position: absolute;
  top: 14px; right: 12px;
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.ui-sheet__close .ui-icon { width: 18px; height: 18px; }
.ui-sheet__title {
  text-align: center;
  font-size: 15px;
  font-weight: var(--fw-semibold);
  margin-bottom: 14px;
  letter-spacing: 1px;
  color: var(--ink);
}
.ui-sheet__list { display: flex; flex-direction: column; }
.ui-sheet__opt {
  min-height: 50px;
  border: none;
  background: transparent;
  border-radius: var(--radius-input);
  font-size: 16px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ui-sheet__opt + .ui-sheet__opt { margin-top: 4px; }
.ui-sheet__opt.selected { color: var(--brand-gold); font-weight: var(--fw-semibold); }
.ui-sheet__opt.disabled { color: var(--text-disabled); cursor: not-allowed; }
.ui-sheet__done {
  width: 100%;
  height: 50px;
  margin-top: 14px;
  border: none;
  border-radius: var(--radius-input);
  background: var(--ink);
  color: var(--text-inverse);
  font-size: 15px;
  font-weight: var(--fw-semibold);
  letter-spacing: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ui-sheet__done:active { background: var(--ink-hover); }

/* ============================================================
   10. StatusTag  状态标签
   - default 普通 / gold 金色强调 / muted 灰色辅助 / outline 描边
   ============================================================ */
.ui-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-lg);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.ui-tag--default { background: var(--bg-soft); color: var(--text-secondary); }
.ui-tag--gold    { background: var(--brand-gold-soft); color: var(--brand-gold); font-weight: var(--fw-semibold); }
.ui-tag--muted   { background: transparent; color: var(--text-tertiary); }
.ui-tag--outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

/* ============================================================
   11. SectionTitle  模块标题（可选左侧短金线）
   ============================================================ */
.ui-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: var(--fw-semibold);
  color: var(--ink);
  margin: 0 0 10px;
  letter-spacing: 1px;
}
.ui-section-title::before {
  content: "";
  width: 3px;
  height: 14px;
  background: var(--brand-gold);
  border-radius: 2px;
  flex: 0 0 auto;
}
.ui-section-title--plain::before { display: none; }   /* 无左侧金线变体 */
.ui-section-title__more {
  margin-left: auto;
  border: none;
  background: transparent;
  padding: 4px 2px 4px 8px;
  font-size: 12px;
  font-weight: var(--fw-regular);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ui-section-title__more .ui-icon { width: 14px; height: 14px; }
.ui-section-title__more:active { color: var(--ink); }

/* ============================================================
   12. EmptyState  空状态（图标 + 标题 + 说明 + 行动按钮）
   ============================================================ */
.ui-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  gap: 10px;
}
.ui-empty__icon { width: 56px; height: 56px; color: var(--text-tertiary); }
.ui-empty__icon .ui-icon { width: 56px; height: 56px; }
.ui-empty__title { font-size: 15px; font-weight: var(--fw-semibold); color: var(--ink); }
.ui-empty__desc { font-size: 13px; color: var(--text-secondary); line-height: 1.6; max-width: 240px; }
.ui-empty__action { margin-top: 8px; }

/* ============================================================
   附加：FAB  悬浮主操作（审计 P0：原 #fab-paipan 缺样式）
   - 2026-07-14 重构首页：移除悬浮「+」，改由「最近使用·空状态」按钮触发新增。
   ============================================================ */
