:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --text-sub: #6b7280;
  --line: #e8eaf0;
  --brand: #f59e0b;
  --brand-dark: #d97706;
  --brand-soft: #fff7e6;
  --green: #10b981;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(31, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(1200px 500px at 50% -180px, #fff3d6 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

/* ---------------- 顶部 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ffcf6b, var(--brand));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
}

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-sub);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.beans-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: var(--shadow);
}

.beans-icon {
  color: var(--brand);
  font-size: 13px;
}

.beans-label {
  font-size: 12px;
  color: var(--text-sub);
}

.beans-box strong {
  font-size: 20px;
  color: var(--brand-dark);
  min-width: 28px;
  text-align: right;
}

/* ---------------- Tabs ---------------- */
.tabs {
  display: flex;
  gap: 8px;
  background: #eceef5;
  border-radius: 999px;
  padding: 4px;
  width: fit-content;
  margin-bottom: 20px;
}

.tab {
  border: none;
  background: transparent;
  padding: 8px 22px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(31, 36, 48, 0.08);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ---------------- 商品 ---------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.product-img {
  height: 150px;
  background: linear-gradient(135deg, #fff1cf, #ffe0a3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(217, 119, 6, 0.55);
  font-size: 42px;
  font-weight: 700;
  overflow: hidden;
}

.product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
}

.product-desc {
  font-size: 13px;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.product-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.price {
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 17px;
}

.price small {
  font-size: 12px;
  font-weight: 500;
  margin-left: 2px;
}

.stock {
  font-size: 12px;
  color: var(--text-sub);
}

.status-chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  white-space: nowrap;
}

.status-chip.warn {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* ---------------- 按钮 ---------------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn.primary {
  background: linear-gradient(135deg, #ffb347, var(--brand));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.28);
}

.btn.primary:hover {
  filter: brightness(1.04);
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.ghost:hover {
  border-color: #d5d8e2;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------------- 状态提示 ---------------- */
.state-hint {
  padding: 48px 0;
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
}

/* ---------------- 兑换记录 ---------------- */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
}

.order-main {
  min-width: 0;
}

.order-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
}

.order-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-sub);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.order-addr {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-sub);
  word-break: break-all;
}

.order-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status-tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.status-tag.s0 {
  background: #fff4e5;
  color: #b45309;
}

.status-tag.s1 {
  background: #e8f3ff;
  color: #1d4ed8;
}

.status-tag.s2 {
  background: #e7f8f1;
  color: #047857;
}

.status-tag.s3 {
  background: #f1f2f5;
  color: #6b7280;
}

.order-cost {
  font-size: 13px;
  color: var(--brand-dark);
  font-weight: 600;
}

.load-more {
  text-align: center;
  padding: 18px 0 0;
}

/* ---------------- 弹窗 ---------------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.dialog {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.25);
  overflow: hidden;
  animation: pop 0.18s ease;
}

.dialog.small {
  max-width: 380px;
}

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

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 17px;
}

.close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-sub);
  cursor: pointer;
}

.dialog-body {
  padding: 18px 20px;
  max-height: 62vh;
  overflow-y: auto;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
}

.product-brief {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: #fafbfe;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 16px;
}

.brief-img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fff1cf, #ffe0a3);
  color: var(--brand-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}

.brief-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brief-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brief-price {
  font-size: 13px;
  color: var(--brand-dark);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-sub);
}

.field > span i {
  color: var(--red);
  font-style: normal;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14);
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
}

.qty button {
  width: 38px;
  height: 36px;
  border: none;
  background: #f7f8fc;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
}

.qty button:hover {
  background: #eef0f7;
}

.qty input {
  width: 64px;
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  padding: 8px 0;
  -moz-appearance: textfield;
}

.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.total-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--text-sub);
}

.total-line strong {
  color: var(--brand-dark);
  font-size: 17px;
}

.error {
  margin: 10px 0 0;
  color: var(--red);
  font-size: 13px;
}

.auth-desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.8;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translate(-50%, -16px);
  background: rgba(31, 36, 48, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 80;
  max-width: 86vw;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: rgba(220, 38, 38, 0.95);
}

/* ---------------- 底部 ---------------- */
.footer {
  margin-top: 36px;
  text-align: center;
  font-size: 12px;
  color: #9aa1ae;
}

.footer .dot {
  margin: 0 8px;
}

@media (max-width: 560px) {
  .page {
    padding: 18px 14px 32px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
  }

  .order-card {
    grid-template-columns: 1fr;
  }

  .order-side {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }
}

/* ---------------- 操作手册 ---------------- */
.guide-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.guide-tips {
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #ffe2b0;
  font-size: 14px;
}

.guide-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.guide-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.guide-card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.guide-index {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffcf6b, var(--brand));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-desc {
  margin: 0 0 12px;
  color: var(--text-sub);
  font-size: 14px;
}

.guide-steps {
  margin: 0 0 14px;
  padding-left: 22px;
  color: var(--text);
  font-size: 14px;
}

.guide-steps li {
  margin: 6px 0;
}

.guide-video {
  margin-top: 6px;
  border-radius: 12px;
  overflow: hidden;
  background: #0b0d12;
}

.guide-video video {
  display: block;
  width: 100%;
  max-height: 62vh;
  background: #0b0d12;
}

.guide-video-actions,
.guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.guide-video-actions {
  background: var(--card);
  padding: 10px;
}

@media (max-width: 640px) {
  .guide-card {
    padding: 16px 14px;
  }
}
