*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background: var(--color-bg-app);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* 屏幕阅读器隐藏类（现代 Web 可访问性标准） */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* =========================================================
   原型演示控制栏（桌面默认显示，窄屏移动端收起为一细条）
   ========================================================= */
.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(2, 36, 102, 0.96);
  color: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.demo-bar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.demo-bar__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-gold-light);
}

.demo-bar__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.demo-bar__label {
  color: rgba(255, 255, 255, 0.72);
}

.demo-bar__select,
.demo-bar__btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  font-size: 12px;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.demo-bar__select option {
  color: var(--color-text-primary);
  background: #FFFFFF;
}

.demo-bar__btn:hover,
.demo-bar__select:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(226, 201, 143, 0.55);
}

@media (max-width: 519px) {
  .demo-bar {
    padding: 6px 12px;
  }
  .demo-bar__brand span:last-child,
  .demo-bar__label {
    display: none;
  }
}

/* =========================================================
   移动端视口容器：手机全屏，桌面居中优雅呈现
   ========================================================= */
.mobile-stage {
  width: 100%;
  min-height: calc(100dvh - 45px);
  display: flex;
  justify-content: center;
  align-items: stretch;
}

.app-shell {
  position: relative;
  width: 100%;
  min-height: calc(100dvh - 45px);
  background: var(--color-bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 520px) {
  body {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
      radial-gradient(circle at 20% 15%, rgba(3, 53, 146, 0.09), transparent 46%),
      radial-gradient(circle at 85% 85%, rgba(181, 142, 67, 0.07), transparent 48%),
      var(--color-bg-stage);
  }

  .mobile-stage {
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px 16px 18px;
    align-items: center;
  }

  .app-shell {
    width: 390px;
    height: min(812px, 100%);
    min-height: 0;
    border-radius: 34px;
    box-shadow: var(--shadow-device);
    border: 7px solid #1C2331;
    background: var(--color-bg-app);
  }
}

/* =========================================================
   视图切换系统（仅基于 opacity 与 transform）
   ========================================================= */
.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-app);
  overflow: hidden;
}

.view[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  .view.is-entering {
    animation: viewEnter 0.28s var(--ease-standard) both;
  }
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   顶部导航栏 & 滚动内容区 & 底部固定栏
   ========================================================= */
.topbar {
  flex: 0 0 auto;
  min-height: var(--topbar-height);
  padding: env(safe-area-inset-top, 0px) 14px 0;
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
}

.topbar--center-only {
  grid-template-columns: 1fr;
}

.topbar__back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 6px 2px;
  border: 0;
  background: transparent;
  color: var(--color-navy);
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
}

.topbar__back:hover {
  background: var(--color-navy-soft);
}

.topbar__title {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.02em;
}

.topbar__badge {
  justify-self: end;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-gold);
  background: var(--color-gold-soft);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(184, 146, 74, 0.3);
}

.view-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

.view-body--with-footer {
  padding-bottom: 24px;
}

.fixed-bottom-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -6px 20px rgba(20, 40, 75, 0.05);
  z-index: 15;
}

.fixed-bottom-bar[hidden] {
  display: none !important;
}

.fixed-bottom-bar--triple {
  grid-template-columns: 0.85fr 1fr 1.45fr;
  gap: 10px;
}

.fixed-bottom-bar--single {
  grid-template-columns: 1fr;
}

.fixed-bottom-bar--stacked {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
}

.fixed-bottom-bar__row {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
}

/* =========================================================
   通用基础组件：卡片、按钮、表单、状态标签、Toast
   ========================================================= */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 16px;
}

.card + .card,
.honor-card + .card {
  margin-top: 14px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--color-surface-muted);
}

.card__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* 按钮体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--md {
  height: 44px;
  padding: 0 14px;
  font-size: 14px;
}

.btn--lg {
  height: 48px;
  padding: 0 18px;
  font-size: 15px;
}

.btn--full {
  width: 100%;
}

.btn--primary {
  background: linear-gradient(180deg, var(--color-navy-hover) 0%, var(--color-navy) 100%);
  color: var(--color-text-on-navy);
  box-shadow: 0 5px 14px rgba(3, 53, 146, 0.26);
}

.btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #1350BE 0%, var(--color-navy-hover) 100%);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-navy);
  border-color: var(--color-border-strong);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--color-navy-soft);
  border-color: var(--color-navy);
}

.btn--gold-outline {
  background: var(--color-gold-soft);
  color: #7A5A1E;
  border-color: rgba(184, 146, 74, 0.55);
}

.btn--gold-outline:hover:not(:disabled) {
  background: #F6ECD6;
  border-color: var(--color-gold);
}

.btn--wechat {
  background: var(--color-wechat);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(7, 193, 96, 0.25);
}

.btn--wechat:hover:not(:disabled) {
  background: var(--color-wechat-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--color-surface-muted);
  color: var(--color-text-primary);
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--color-navy);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* 状态徽章 */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--color-navy-soft);
  color: var(--color-navy);
}

.status-pill--sm {
  justify-self: end;
  padding: 3px 8px;
  font-size: 11px;
}

.status-pill--warn {
  background: var(--color-warn-soft);
  color: var(--color-warn);
}

.status-pill--success {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.status-pill--danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.status-pill--muted {
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
}

.tag--gold {
  background: var(--color-gold-soft);
  color: #846224;
  border: 1px solid rgba(184, 146, 74, 0.35);
}

/* 表单与延迟交互校验（Modern Web Guidance: validate-input-after-interaction） */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 3px;
}

.field__hint {
  display: block;
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-bottom: 7px;
}

.field__input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border-strong);
  background: #FAFBFD;
  font-size: 15px;
  color: var(--color-text-primary);
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.field__input--mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.field__input:focus {
  outline: none;
  border-color: var(--color-navy);
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(3, 53, 146, 0.12);
}

.error-msg {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-danger);
  line-height: 1.4;
}

.error-msg span[role="img"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--color-danger);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  vertical-align: -1px;
}

:is(.field__input:user-invalid, .field__input.user-invalid-fallback) {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}

:is(.field__input:user-invalid, .field__input.user-invalid-fallback) + .error-msg,
.field:has(:is(.field__input:user-invalid, .field__input.user-invalid-fallback)) .error-msg {
  display: block;
}

:is(.field__input:user-valid, .field__input.user-valid-fallback) {
  border-color: var(--color-success);
}

/* 键值对信息列表 */
.kv-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.kv-list--subtle {
  background: var(--color-bg-app);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  margin: 16px 0;
}

.kv-list__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  font-size: 13.5px;
}

.kv-list__row dt {
  color: var(--color-text-secondary);
  flex-shrink: 0;
}

.kv-list__row dd {
  margin: 0;
  color: var(--color-text-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.kv-list__amount {
  font-size: 16px;
  font-weight: 700 !important;
  color: var(--color-navy) !important;
}

/* Toast 轻提示 */
.toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(2, 36, 102, 0.94);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  box-shadow: var(--shadow-elevated);
  z-index: 40;
  pointer-events: none;
}

/* =========================================================
   原生 <dialog> 底部抽屉（Modern Web Guidance: dialog & prevent-page-scroll）
   ========================================================= */
dialog.sheet-dialog {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 390px;
  max-height: 88dvh;
  background: transparent;
  overflow: visible;
}

dialog.sheet-dialog[open] {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

dialog.sheet-dialog:modal {
  overscroll-behavior: contain;
}

dialog.sheet-dialog::backdrop {
  background: rgba(13, 24, 46, 0.52);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.sheet-dialog__panel {
  background: var(--color-surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 36px rgba(13, 28, 55, 0.2);
  overflow-y: auto;
}

@media (prefers-reduced-motion: no-preference) {
  dialog.sheet-dialog[open] .sheet-dialog__panel {
    animation: sheetRise 0.24s var(--ease-standard) both;
  }
}

@keyframes sheetRise {
  from {
    opacity: 0.4;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheet-dialog__handle {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--color-border-strong);
  margin: 0 auto 14px;
}

.sheet-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.sheet-dialog__title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.sheet-dialog__sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--color-text-secondary);
}

.icon-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-close-btn:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
}

.sheet-dialog__actions {
  display: grid;
  grid-template-columns: 0.85fr 1.35fr;
  gap: 10px;
  margin-top: 6px;
}
