:root {
  --red: #8E1F24;
  --red-deep: #6E1419;
  --red-soft: #B03A3F;
  --gold: #C6A15B;
  --ink: #1D222B;
  --muted: #6B7280;
  --line: #E9E5E0;
  --bg: #F5F3F0;
  --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 34, 43, .04), 0 8px 24px rgba(29, 34, 43, .06);
}

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

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  color: #fff;
  padding: 18px 0 20px;
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  height: 46px;
  width: auto;
  flex: none;
  background: #fff;
  border-radius: 8px;
  padding: 5px 7px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

.brand-text { flex: 1 1 auto; min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .12em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  opacity: .82;
  letter-spacing: .04em;
}

/* ---------- 主体 ---------- */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 8px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 18.5px;
  font-weight: 700;
  color: var(--red-deep);
  letter-spacing: .02em;
}

.card-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 17px;
  background: var(--gold);
  border-radius: 2px;
  margin-right: 9px;
  vertical-align: -2px;
}

.card-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

/* ---------- 表单 ---------- */
.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}

#nameInput {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  font-size: 16px;
  color: var(--ink);
  background: #FBFAF9;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .18s, background .18s, box-shadow .18s;
  font-family: inherit;
}

#nameInput::placeholder { color: #A9A29A; }

#nameInput:focus {
  border-color: var(--red-soft);
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(176, 58, 63, .1);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--red-soft) 0%, var(--red-deep) 100%);
  color: #fff;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: .06em;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(142, 31, 36, .22);
  transition: transform .12s, box-shadow .18s, opacity .18s;
}

.btn-primary:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(142, 31, 36, .2); }
.btn-primary[disabled], .btn-primary.is-loading { opacity: .62; pointer-events: none; }

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 48px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn-ghost:active { background: #F7F5F3; }

.tip {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

.tip.error { color: #B3261E; font-weight: 500; }

/* ---------- 结果 ---------- */
.result .card-sub { margin-bottom: 14px; }

.cert-frame {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-height: 120px;
}

.cert-frame img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: default;
}

.cert-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13.5px;
}

.cert-loading em { font-style: normal; }

.cert-loading[hidden] { display: none; }

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--red-soft);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.actions > .btn-primary,
.actions > .btn-ghost {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  white-space: nowrap;
}

.actions.center { justify-content: center; }
.actions.center .btn-ghost { flex: 0 0 auto; padding: 0 28px; }

/* ---------- 空状态 ---------- */
.empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #FDF3F2;
  color: var(--red-soft);
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#emptyCard { text-align: center; }
#emptyCard .card-sub { text-align: left; }

/* ---------- 页脚 ---------- */
.foot {
  padding: 18px 20px 30px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.8;
}

.foot p { margin: 0; }
.foot-sub { color: #9A938B; font-size: 11.5px; margin-top: 4px !important; }

@media (max-width: 380px) {
  .card { padding: 18px 16px; }
  .brand-logo { height: 40px; }
  .brand-text h1 { font-size: 18px; }
}
