/* 组件：按钮 / 卡片 / 表单 / 徽章 / 弹层 / 提示 / 头像 / 分段控件 / 等级选择 */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: var(--c-line-soft);
  color: var(--c-text);
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s ease;
  user-select: none;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:active:not(:disabled) { background: var(--c-primary-dark); }
.btn--danger { background: var(--c-danger); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--c-line); }
.btn--text { background: none; min-height: 36px; padding: 0 8px; color: var(--c-primary); font-size: 14px; }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: 17px; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* ---------- 卡片 ---------- */
.card {
  padding: 16px;
  border-radius: var(--r-card);
  background: var(--c-card);
  box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; border: 1px solid var(--c-line); }
.card--tap { cursor: pointer; transition: transform .08s ease; }
.card--tap:active { transform: scale(.99); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--c-text-2); }
.field__error { font-size: 12px; color: var(--c-danger); }
.field__hint { font-size: 12px; color: var(--c-text-3); }
/* 预留提示高度：避免提示出现/消失时把下方按钮顶走，导致手机点击落空 */
.field__msg { min-height: 19px; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--c-text);
  font-size: 16px; /* 16px 可避免 iOS 自动放大 */
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
}
.input:focus { border-color: var(--c-primary); }
.input--error { border-color: var(--c-danger); }
.input::placeholder { color: var(--c-text-3); }

/* ---------- 分段控件 / Tab ---------- */
.segmented {
  display: flex;
  padding: 3px;
  border-radius: var(--r-btn);
  background: var(--c-line-soft);
  gap: 3px;
}
.segmented__item {
  flex: 1;
  min-height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--c-text-2);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segmented__item.is-active {
  background: #fff;
  color: var(--c-text);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--c-line-soft);
  color: var(--c-text-2);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}
.badge--primary { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.badge--accent { background: var(--c-accent-soft); color: #c2410c; }
.badge--danger { background: var(--c-danger-soft); color: var(--c-danger); }
.badge--warn { background: var(--c-warn-soft); color: #b45309; }

/* ---------- 头像 ---------- */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--c-line-soft);
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  overflow: hidden;
}
.avatar--xs { width: 24px; height: 24px; font-size: 11px; }
.avatar--sm { width: 32px; height: 32px; font-size: 13px; }
.avatar--md { width: 48px; height: 48px; font-size: 18px; }
.avatar--lg { width: 72px; height: 72px; font-size: 28px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 20px 16px calc(20px + var(--safe-bottom));
  border-radius: 18px 18px 0 0;
  background: #fff;
  animation: modal-up .22s ease;
}
@keyframes modal-up { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal__title { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.modal__desc { font-size: 13px; color: var(--c-text-2); margin-bottom: 14px; }
.modal__actions { display: flex; gap: 10px; margin-top: 18px; }
.modal__actions > * { flex: 1; }

/* ---------- 顶部提示条 ---------- */
.toast-host {
  position: fixed;
  top: calc(var(--header-h) + 8px);
  left: 0; right: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 90%;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: rgba(17, 24, 39, .9);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
}
.toast--success { background: rgba(21, 128, 61, .95); }
.toast--error { background: rgba(185, 28, 28, .95); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 提示条 ---------- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-btn);
  font-size: 13px;
  line-height: 1.5;
}
.notice--warn { background: var(--c-warn-soft); color: #92400e; }
.notice--info { background: var(--c-info-soft); color: #1e40af; }
.notice--danger { background: var(--c-danger-soft); color: #991b1b; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--c-text-3);
  font-size: 14px;
}
.empty__icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- 中羽等级选择 ---------- */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.level-grid__item {
  min-height: 44px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: #fff;
  color: var(--c-text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.level-grid__item.is-active {
  border-color: var(--c-primary);
  background: var(--c-primary-soft);
  color: var(--c-primary-dark);
  font-weight: 600;
}

/* ---------- 列表行 ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--c-line-soft);
}
.list-row:last-child { border-bottom: none; }

/* ---------- 加载 ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 添加到主屏幕引导 ---------- */
.install-hint {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(78px + var(--safe-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 496px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: var(--r-card);
  background: #fff;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease;
}
.install-hint__icon { width: 26px; height: 26px; color: var(--c-primary); flex: none; }
.install-hint__title { font-size: 14px; font-weight: 600; }
.install-hint__desc { font-size: 12px; color: var(--c-text-2); }
