/* ============================================================
   Components · 可复用基础组件（顶栏 / 胶囊导航 / 卡片 / 表单 / 浮层）
   ============================================================ */

/* ---------- 顶部导航：半透明 + 背景模糊 ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--safe-top) + var(--topbar-h));
  padding-top: var(--safe-top);
  background: var(--top-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}
.topbar__inner {
  max-width: var(--content-max); height: var(--topbar-h); margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 calc(var(--page-x) + var(--safe-right)) 0 calc(var(--page-x) + var(--safe-left));
}
.topbar__brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.topbar__mark { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.topbar__sub { font-size: 12px; color: var(--text-tertiary); font-weight: 500; }
.topbar__action { min-width: var(--tap-min); min-height: var(--tap-min); display: grid; place-items: center; border-radius: 12px; color: var(--accent); transition: background var(--dur-fast) var(--ease); }
.topbar__action:active { background: var(--fill-soft); }

/* ---------- 底部悬浮胶囊玻璃导航 ---------- */
.tabbar {
  position: fixed; z-index: 45; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + var(--tabbar-gap));
  width: min(calc(100% - 40px), 400px); height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px;
  border-radius: var(--radius-pill); background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 0.5px solid var(--glass-stroke); box-shadow: var(--shadow-float);
  transition: opacity var(--dur) var(--ease);
}
.tabbar__item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-height: 44px; border-radius: var(--radius-pill); color: var(--text-tertiary);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.tabbar__item span { font-size: 10px; font-weight: 560; letter-spacing: 0.01em; }
.tabbar__item svg { width: 23px; height: 23px; transition: transform var(--dur-slow) var(--ease); }
.tabbar__item.is-active { color: var(--accent); background: var(--accent-soft); }
.tabbar__item.is-active svg { transform: translateY(-1px) scale(1.07); }
.tabbar__item:active { transform: scale(0.92); }
.tabbar__dot { position: absolute; top: 6px; right: calc(50% - 16px); width: 5px; height: 5px; border-radius: 50%; background: var(--danger); animation: dotPop var(--dur) var(--ease); }
@keyframes dotPop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 18px; border: 0.5px solid var(--hairline-highlight); }
.card--tight { padding: 14px; }
.card--flat { box-shadow: none; border: 0.5px solid var(--separator); }
.card--press { transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease); }
.card--press:active { transform: scale(0.985); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.stack { display: grid; gap: 12px; }
.stack--tight { gap: 8px; }

/* ---------- 分组列表 ---------- */
.list { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; border: 0.5px solid var(--hairline-highlight); }
.list__row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--tap-min); padding: 11px 16px; text-align: left; }
.list__row + .list__row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.list__row--tap { transition: background var(--dur-fast) var(--ease); }
.list__row--tap:active { background: var(--fill-softer); }
.list__row__icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.list__row__icon--warning { background: var(--warning-soft); color: var(--warning); }
.list__row__icon--danger { background: var(--danger-soft); color: var(--danger); }
.list__row__icon--success { background: var(--success-soft); color: var(--success); }
.list__row__body { flex: 1; min-width: 0; }
.list__row__title { font-size: 16px; font-weight: 500; }
.list__row__sub { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.list__row__value { font-size: 15px; color: var(--text-secondary); flex: none; }
.list__chevron { color: var(--text-tertiary); flex: none; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--btn-h); padding: 0 20px; border-radius: var(--radius-md); font-size: 16px; font-weight: 600; transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease); }
.btn:active { transform: scale(0.975); }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:active { background: var(--accent-press); }
.btn--secondary { background: var(--fill-soft); color: var(--text); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--ghost { background: transparent; color: var(--accent); }
.btn--block { width: 100%; }
.btn--sm { min-height: 44px; padding: 0 14px; font-size: 14px; border-radius: var(--radius-sm); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.icon-btn { width: var(--tap-min); height: var(--tap-min); display: grid; place-items: center; border-radius: 12px; color: var(--accent); transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.icon-btn:active { background: var(--fill-soft); transform: scale(0.92); }
.icon-btn--muted { color: var(--text-tertiary); }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: 13px; font-weight: 550; color: var(--text-secondary); margin: 0 0 6px 2px; }
.input {
  width: 100%; min-height: 48px; padding: 11px 14px; font-size: 16px;
  background: var(--card-inset); border: 0.5px solid var(--separator); border-radius: var(--radius-sm);
  outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.input { min-height: 84px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-tertiary); }
.input[readonly] { color: var(--text-secondary); }
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px; border-right: 1.8px solid var(--text-tertiary); border-bottom: 1.8px solid var(--text-tertiary); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select.input { padding-right: 34px; }
.field__hint { font-size: 12px; color: var(--text-tertiary); margin: 5px 2px 0; line-height: 1.45; }
.field__error { font-size: 12px; color: var(--danger); margin: 5px 2px 0; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.switch { position: relative; width: 51px; height: 31px; border-radius: var(--radius-pill); background: var(--fill-soft); transition: background var(--dur) var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform var(--dur) var(--ease); }
.switch.is-on { background: var(--success); }
.switch.is-on::after { transform: translateX(20px); }

/* ---------- 分段控件 / 筛选条 / 搜索 ---------- */
.segmented { display: flex; gap: 3px; padding: 3px; background: var(--fill-softer); border-radius: var(--radius-sm); }
.segmented__item { flex: 1; min-height: 36px; display: grid; place-items: center; font-size: 13px; font-weight: 550; color: var(--text-secondary); border-radius: 9px; transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.segmented__item.is-active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 34px; padding: 0 14px; border-radius: var(--radius-pill); background: var(--fill-softer); color: var(--text-secondary); font-size: 13px; font-weight: 550; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.chip.is-active { background: var(--accent); color: #fff; }
.chip:active { transform: scale(0.95); }
.search { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; background: var(--fill-softer); border-radius: var(--radius-sm); color: var(--text-tertiary); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 15px; min-height: 42px; color: var(--text); }

/* ---------- 底部弹层 ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); opacity: 0; transition: opacity var(--dur) var(--ease); }
.scrim.is-open { opacity: 1; }
.sheet {
  position: fixed; z-index: 61; left: 0; right: 0; bottom: 0; max-height: 90vh; max-height: 90dvh;
  display: flex; flex-direction: column; background: var(--sheet-bg);
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  border-radius: 26px 26px 0 0; border-top: 0.5px solid var(--glass-stroke); box-shadow: var(--shadow-float);
  transform: translateY(102%); transition: transform var(--dur-slow) var(--ease);
  padding-bottom: calc(var(--safe-bottom) + 12px);
}
.sheet.is-open { transform: translateY(0); }
.sheet__handle { width: 36px; height: 5px; border-radius: 3px; background: var(--separator-strong); margin: 8px auto 2px; flex: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px 12px; flex: none; }
.sheet__title { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.sheet__body { overflow-y: auto; padding: 0 20px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet__foot { padding: 12px 20px 4px; display: grid; gap: 10px; flex: none; border-top: 0.5px solid var(--separator); }
@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 560px; max-height: 84dvh; transform: translate(-50%, 102%); border-radius: 26px; margin-bottom: 20px; }
  .sheet.is-open { transform: translate(-50%, 0); }
}

/* ---------- 确认弹层 ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; }
.dialog { width: min(100%, 306px); background: var(--sheet-bg); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); border-radius: 20px; overflow: hidden; text-align: center; box-shadow: var(--shadow-float); animation: dialogIn var(--dur) var(--ease) both; }
@keyframes dialogIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.dialog__body { padding: 22px 20px 18px; }
.dialog__icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--danger-soft); color: var(--danger); }
.dialog__title { font-size: 17px; font-weight: 650; }
.dialog__msg { font-size: 13px; color: var(--text-secondary); margin-top: 6px; line-height: 1.55; white-space: pre-line; }
.dialog__actions { display: flex; border-top: 0.5px solid var(--separator); }
.dialog__btn { flex: 1; min-height: 48px; font-size: 16px; color: var(--accent); font-weight: 550; }
.dialog__btn + .dialog__btn { border-left: 0.5px solid var(--separator); }
.dialog__btn--danger { color: var(--danger); font-weight: 650; }
.dialog__btn:active { background: var(--fill-softer); }

/* ---------- Toast ---------- */
.toast-root { position: fixed; z-index: 80; top: calc(var(--safe-top) + 12px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; max-width: min(90vw, 420px); padding: 11px 16px; border-radius: var(--radius-pill); background: var(--nav-bg); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border: 0.5px solid var(--glass-stroke); box-shadow: var(--shadow-float); font-size: 14px; font-weight: 550; animation: toastIn var(--dur) var(--ease) both; }
.toast.is-out { animation: toastOut var(--dur-fast) var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(0.97); } }
.toast--success { color: var(--success); } .toast--error { color: var(--danger); }

/* ---------- 徽标 / 提示 / 空态 / 加载 ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; background: var(--fill-soft); color: var(--text-secondary); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--success { background: var(--success-soft); color: var(--success); }
.state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 20px; gap: 8px; }
.state__icon { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; background: var(--fill-softer); color: var(--text-tertiary); margin-bottom: 4px; }
.state__title { font-size: 17px; font-weight: 620; }
.state__desc { font-size: 13px; color: var(--text-secondary); max-width: 290px; line-height: 1.55; }
.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--fill-softer) 25%, var(--fill-soft) 50%, var(--fill-softer) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--separator-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 13px 14px; border-radius: var(--radius-md); background: var(--accent-soft); font-size: 13px; line-height: 1.55; }
.notice--warning { background: var(--warning-soft); }
.notice--danger { background: var(--danger-soft); }
.notice svg { flex: none; color: var(--accent); margin-top: 1px; }
.notice--warning svg { color: var(--warning); } .notice--danger svg { color: var(--danger); }
.notice strong { font-weight: 650; }
.divider { height: 0.5px; background: var(--separator); margin: 14px 0; }
.fab { position: fixed; z-index: 35; right: calc(var(--page-x) + var(--safe-right) + 4px); bottom: calc(var(--safe-bottom) + var(--tabbar-h) + var(--tabbar-gap) + 14px); width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(0, 122, 255, 0.34); transition: transform var(--dur) var(--ease); }
.fab:active { transform: scale(0.9); }
