/* ========== 基础重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
  --primary: #FF6A00;
  --primary-light: #FF8A3D;
  --primary-dark: #E55D00;
  --accent: #F5A623;
  --bg: #FFF7ED;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
  /* 结果卡片暖橙渐变 */
  --result-grad: linear-gradient(135deg, #FF5722 0%, #FF8A3D 50%, #FFB74D 100%);
  --shadow-card: 0 4px 20px rgba(0,0,0,.08);
  --shadow-btn: 0 6px 16px rgba(255,106,0,.32);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(180deg, #FFF7ED 0%, #FFEDD5 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ========== 顶部导航 ========== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(255,106,0,.3);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
  margin: 0 auto;
  gap: 12px;
}
.back-btn {
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.header-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-placeholder { width: 32px; flex-shrink: 0; }

/* ========== 主内容 ========== */
.main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
}

/* ========== 标题区 ========== */
.title-section { text-align: center; margin-bottom: 20px; }
.title-en {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 3px;
  margin-bottom: 8px;
  font-weight: 600;
}
.title-cn {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.title-desc { font-size: 13px; color: var(--text-2); }

/* ========== 输入卡片 ========== */
.input-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.input-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.input-label { font-size: 14px; font-weight: 700; }
.tutorial-btn {
  padding: 4px 12px;
  border: 1px solid var(--primary);
  border-radius: 14px;
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 28px;
  transition: all .15s;
}
.tutorial-btn:active { background: #FFF7ED; transform: scale(.96); }

.input-textarea {
  width: 100%;
  min-height: 100px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
  color: var(--text);
}
.input-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,106,0,.12);
}
.input-textarea::placeholder { color: var(--text-3); }

/* 使用方法引导 */
.guide {
  margin-top: 14px;
  padding: 12px 14px;
  background: #FFF7ED;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.7;
}
.guide-title { font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.guide-item { display: flex; align-items: flex-start; gap: 8px; }
.guide-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 3px;
}

/* 状态条 */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: #f9fafb;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
  min-height: 40px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background .2s;
}
.status-dot.active { background: var(--success); }
.status-dot.loading {
  background: var(--primary);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .4; transform: scale(.8); }
}

/* 按钮组 */
.input-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.btn-submit, .btn-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform .1s, box-shadow .15s, opacity .15s;
  font-family: inherit;
}
.btn-submit {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--shadow-btn);
}
.btn-submit:active { transform: scale(.98); box-shadow: 0 3px 8px rgba(255,106,0,.25); }
.btn-submit:disabled { opacity: .7; cursor: not-allowed; }
.btn-clear {
  flex: 0 0 88px;
  background: #FFF7ED;
  color: var(--primary-dark);
  border: 1px solid #fed7aa;
}
.btn-clear:active { transform: scale(.98); background: #ffedd5; }

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

/* ========== 结果卡片 ========== */
.result-card {
  background: var(--result-grad);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 10px 28px rgba(255,87,34,.22);
  color: #fff;
  animation: slideUp .35s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.success-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.success-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  flex-shrink: 0;
}
.success-text { font-size: 17px; font-weight: 800; }

.shop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,.18);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.shop-icon {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(255,255,255,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  flex-shrink: 0;
  overflow: hidden;
}
.shop-icon img { width: 100%; height: 100%; object-fit: cover; }
.shop-info { flex: 1; min-width: 0; }
.shop-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coupon-amount { display: flex; align-items: baseline; gap: 4px; }
.amount-label { font-size: 13px; font-weight: 600; opacity: .9; }
.amount-num { font-size: 32px; font-weight: 900; line-height: 1; text-shadow: 0 2px 6px rgba(0,0,0,.12); }
.amount-unit { font-size: 16px; font-weight: 800; }
.coupon-badge {
  background: #fff;
  color: var(--primary-dark);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 领券按钮 */
.coupon-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.coupon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  background: #fff;
  color: #cc4115;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 5px 14px rgba(180,50,0,.18);
  transition: transform .1s, box-shadow .15s;
  padding: 0 8px;
}
.coupon-btn:active { transform: scale(.97); box-shadow: 0 2px 6px rgba(180,50,0,.15); }

/* 0元提示 */
.zero-tip {
  min-height: 48px;
  background: #fff;
  color: #cc4115;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-align: center;
  margin-bottom: 12px;
  box-shadow: 0 5px 14px rgba(180,50,0,.18);
}

.shop-id {
  font-size: 12px;
  color: rgba(255,255,255,.75);
  font-weight: 600;
  word-break: break-all;
  background: rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 8px 12px;
}
.shop-id span { font-family: 'SF Mono', Monaco, Consolas, monospace; font-weight: 700; }

/* ========== 错误卡片 ========== */
.error-card {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  animation: slideUp .3s ease;
}
.error-icon { font-size: 36px; margin-bottom: 10px; }
.error-title { font-size: 16px; font-weight: 700; color: var(--danger); margin-bottom: 6px; }
.error-msg { font-size: 14px; color: #ef4444; line-height: 1.6; font-weight: 600; }
.error-guide {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  text-align: left;
}
.error-guide-title { font-size: 13px; font-weight: 700; color: #c2410c; margin-bottom: 6px; }
.error-guide-step { font-size: 13px; color: #9a3412; line-height: 1.6; }

/* ========== 底部 ========== */
.footer {
  text-align: center;
  padding: 24px 16px calc(20px + var(--safe-bottom));
  font-size: 12px;
  color: var(--text-3);
}

/* ========== 使用教程弹窗 ========== */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15,23,42,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-dialog {
  width: 100%;
  max-width: 420px;
  max-height: 85dvh;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 16px 20px;
  font-size: 16px;
  font-weight: 800;
  border-bottom: 1px solid #f1f5f9;
}
.modal-close {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #f3f4f6;
  color: #64748b;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:active { background: #e5e7eb; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; max-height: calc(85dvh - 60px); }
.tutorial-step { display: flex; gap: 12px; margin-bottom: 16px; align-items: flex-start; }
.tutorial-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.tutorial-text { font-size: 14px; color: var(--text); line-height: 1.6; padding-top: 3px; }
.tutorial-tip {
  margin-top: 8px;
  padding: 12px;
  background: #FFF7ED;
  border-radius: 10px;
  font-size: 12px;
  color: var(--primary-dark);
  line-height: 1.6;
  font-weight: 600;
}

/* ========== 响应式 ========== */
@media (max-width: 380px) {
  .main { padding: 16px 12px calc(20px + var(--safe-bottom)); }
  .input-card, .result-card { padding: 16px; }
  .title-cn { font-size: 21px; }
  .amount-num { font-size: 28px; }
  .coupon-btn { font-size: 14px; }
  .btn-clear { flex: 0 0 76px; }
}

@media (min-width: 600px) {
  .title-cn { font-size: 28px; }
  .input-card, .result-card { padding: 24px; }
}
