/* ============================================================
   嗨培商城 · 三端共用基础样式
   无外部依赖、无 CDN、纯手写
   ============================================================ */

:root {
  --c-primary: #E4B815;
  --c-primary-d: #C1970A;
  --c-primary-l: #FFFADC;
  --c-accent: #ffb020;
  --c-blue: #2b5cff;
  --c-blue-l: #eef2ff;
  --c-green: #12b76a;
  --c-green-l: #ecfdf3;
  --c-red: #f04438;
  --c-red-l: #fef3f2;
  --c-gray: #667085;
  --c-gray-l: #f2f4f7;
  --c-border: #eaecf0;
  --c-text: #1d2939;
  --c-text-2: #475467;
  --c-text-3: #98a2b3;
  --c-bg: #FFFAE6;
  --c-white: #ffffff;

  --sh-1: 0 1px 2px rgba(16, 24, 40, .06);
  --sh-2: 0 4px 12px rgba(16, 24, 40, .08);
  --sh-3: 0 12px 32px rgba(16, 24, 40, .12);

  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-4: 22px;

  --fz-xs: 12px;
  --fz-sm: 13px;
  --fz-md: 14px;
  --fz-lg: 16px;
  --fz-xl: 18px;
  --fz-2xl: 22px;
  --fz-3xl: 28px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fz-md);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--r-2);
  font-size: var(--fz-md);
  font-weight: 600;
  background: var(--c-gray-l);
  color: var(--c-text-2);
  transition: transform .12s ease, opacity .12s ease, background .15s;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, #F5D321, var(--c-primary)); color: #4A3200; box-shadow: 0 4px 12px rgba(198, 152, 8, .28); }
.btn-blue { background: linear-gradient(135deg, #4d7bff, var(--c-blue)); color: #fff; box-shadow: 0 4px 12px rgba(43, 92, 255, .25); }
.btn-danger { background: var(--c-red); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--c-border); color: var(--c-text-2); }
.btn-sm { height: 30px; padding: 0 12px; font-size: var(--fz-sm); border-radius: var(--r-1); }
.btn-lg { height: 48px; font-size: var(--fz-lg); border-radius: var(--r-3); }
.btn-block { display: flex; width: 100%; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: var(--fz-sm);
  color: var(--c-text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
.field > label .req { color: var(--c-red); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--r-2);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(198, 152, 8, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); }
.hint { font-size: var(--fz-xs); color: var(--c-text-3); margin-top: 5px; line-height: 1.5; }
.hint.warn { color: var(--c-red); }

/* ---------------- 卡片 ---------------- */
.card {
  background: #fff;
  border-radius: var(--r-3);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card-pad { padding: 16px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 700;
  font-size: var(--fz-md);
}

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: var(--fz-xs);
  font-weight: 600;
  background: var(--c-gray-l);
  color: var(--c-gray);
  white-space: nowrap;
}
.badge-orange { background: var(--c-primary-l); color: var(--c-primary-d); }
.badge-blue { background: var(--c-blue-l); color: var(--c-blue); }
.badge-green { background: var(--c-green-l); color: var(--c-green); }
.badge-red { background: var(--c-red-l); color: var(--c-red); }
.badge-gold { background: #fff8e6; color: #b7791f; }

/* ---------------- 空状态 / 加载 ---------------- */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--c-text-3);
  font-size: var(--fz-sm);
}
.empty .emoji { font-size: 40px; display: block; margin-bottom: 10px; opacity: .6; }

.loading {
  padding: 40px;
  text-align: center;
  color: var(--c-text-3);
  font-size: var(--fz-sm);
}
.spinner {
  width: 22px; height: 22px;
  margin: 0 auto 10px;
  border: 2.5px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Toast ---------------- */
#toast-wrap {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 80vw;
}
.toast {
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(29, 41, 57, .92);
  color: #fff;
  font-size: var(--fz-sm);
  line-height: 1.5;
  text-align: center;
  animation: toastIn .22s ease;
  word-break: break-word;
}
.toast.ok { background: rgba(18, 183, 106, .95); }
.toast.err { background: rgba(240, 68, 56, .95); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Modal ---------------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.dialog {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: var(--r-3);
  overflow: hidden;
  animation: popIn .2s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.dialog-head { padding: 20px 20px 0; font-size: var(--fz-lg); font-weight: 700; text-align: center; }
.dialog-body { padding: 12px 20px 20px; color: var(--c-text-2); text-align: center; font-size: var(--fz-md); line-height: 1.6; }
.dialog-foot { display: flex; border-top: 1px solid var(--c-border); }
.dialog-foot button {
  flex: 1;
  height: 50px;
  font-size: var(--fz-lg);
  color: var(--c-text-2);
}
.dialog-foot button + button { border-left: 1px solid var(--c-border); }
.dialog-foot .primary { color: var(--c-primary); font-weight: 700; }

/* ---------------- 商品封面（无图时用渐变 + emoji） ---------------- */
.cover {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FAEFD2, #F2D69B);
  color: #b8491a;
  font-size: 34px;
  user-select: none;
  overflow: hidden;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.c1 { background: linear-gradient(135deg, #FAEFD2, #F2D69B); }
.cover.c2 { background: linear-gradient(135deg, #e3f0ff, #c3ddff); color: #1c4e8f; }
.cover.c3 { background: linear-gradient(135deg, #e6f9ee, #c4f0d8); color: #14734a; }
.cover.c4 { background: linear-gradient(135deg, #f3e8ff, #e0ccff); color: #5b2d9c; }
.cover.c5 { background: linear-gradient(135deg, #fff7d6, #ffe9a3); color: #8a6100; }

/* ---------------- 价格 ---------------- */
.price {
  color: var(--c-red);
  font-weight: 800;
  font-family: "DIN Alternate", "Helvetica Neue", Arial, sans-serif;
}
.price .unit { font-size: .62em; margin-right: 1px; font-weight: 700; }
.price-points { color: #b7791f; }
.price-points .coin { font-size: .8em; margin-right: 2px; }

/* ---------------- 工具类 ---------------- */
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap6 { gap: 6px; }
.gap10 { gap: 10px; }
.mt6 { margin-top: 6px; }
.mt10 { margin-top: 10px; }
.mt16 { margin-top: 16px; }
.flex1 { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.muted { color: var(--c-text-3); font-size: var(--fz-sm); }
.hide { display: none !important; }
.divider { height: 1px; background: var(--c-border); margin: 12px 0; }
