* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #f5f5f5;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.main {
  width: 100%;
  max-width: 375px;
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: calc(env(safe-area-inset-top, 0px) + 90px) 45px 1fr 150px;
  background: #fff;
  position: relative;
}

/* Header */
.header {
  width: 100%;
  height: calc(env(safe-area-inset-top, 0px) + 90px);
  padding-top: env(safe-area-inset-top, 0px);
  display: flex;
  flex-direction: column;
  background-image: url("../assets/header-bg-Dlg22pac.jpeg");
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.header-img {
  width: 100%;
  height: 50px;
  object-fit: cover;
}

.header-title {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  font-size: 24px;
  font-weight: 700;
  color: #e51c26;
  font-family: "STSong", "SimSun", "Songti SC", serif;
  text-align: center;
  letter-spacing: 1px;
}

/* Tabs */
.tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 45px;
  background-color: #87cefa;
  padding: 6px 12px;
}

.tabs .query-nav-btn {
  width: calc(100% - 24px);
  max-width: 320px;
  height: 35px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background-color: #fff;
  color: #87cefa;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.tabs .query-nav-btn:active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* Content area */
.content-area {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Home / Index */
.index {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.swiper {
  width: 100%;
  height: 200px;
  background-color: #fff;
  position: relative;
  overflow: hidden;
}

.swiper-track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
}

.swiper-slide {
  min-width: 100%;
  height: 100%;
  flex-shrink: 0;
}

.swiper-slide img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  cursor: pointer;
}

.swiper-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.swiper-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background 0.3s;
}

.swiper-dot.active {
  background: #fff;
}

/* News */
.news {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.news-title {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.news-list {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.news-list-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 12px;
}

.news-item {
  width: 100%;
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: pointer;
}

.news-item:active {
  background: #f9f9f9;
}

.news-item-title {
  flex: 1;
  max-width: calc(100% - 90px);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-all;
  line-height: 1.4;
}

.news-item-time {
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
  margin-left: 8px;
}

.query-btn {
  width: calc(100% - 24px);
  height: 35px;
  background-color: #87cefa;
  border-radius: 6px;
  text-align: center;
  line-height: 35px;
  color: #fff;
  margin: 12px auto;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.query-btn:active {
  opacity: 0.85;
}

/* Footer */
.footer {
  width: 100%;
  height: 150px;
  background-color: #87cefa;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-item .img {
  width: 16px;
  height: 16px;
}

.footer-item .img1 {
  width: 24px;
}

.footer-item .img2 {
  height: 24px;
}

.footer-item-left,
.footer-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-size: 14px;
  color: #666;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #87cefa;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}

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

/* Toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

/* Login notice popup */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
}

.popup-overlay.show {
  display: flex;
}

.login-notice-popup {
  position: relative;
  width: 310px;
  max-height: 80vh;
  padding: 24px 16px 18px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 8px;
}

.login-notice-close {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  font-size: 20px;
  color: #999;
  z-index: 2;
  cursor: pointer;
}

.login-notice-address {
  width: 100%;
  max-height: 60vh;
  overflow-y: auto;
  font-size: 15px;
  line-height: 24px;
  color: #333;
  white-space: pre-wrap;
}

/* Hidden panels */
.panel {
  display: none;
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.panel.active {
  display: block;
}

.panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: #333;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  height: 40px;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.form-group input:focus {
  border-color: #87cefa;
}

.form-btn {
  width: 100%;
  height: 42px;
  background: #87cefa;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 8px;
}

.form-btn:active {
  opacity: 0.85;
}

/* Certificate result (inline under query form) */
.cert-result {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eee;
  background: #fff;
}

.cert-result[hidden] {
  display: none !important;
}

.cert-result-title {
  font-size: 16px;
  font-weight: 700;
  color: #333;
  text-align: center;
  margin-bottom: 12px;
}

.cert-stage {
  width: 100%;
  margin: 0 0 16px;
}

.cert-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2172 / 1416;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  container-type: inline-size;
  container-name: cert;
}

.cert-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.cert-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cert-media {
  position: absolute;
  top: 16.5%;
  left: 62.5%;
  width: 22%;
  display: flex;
  gap: 5%;
  align-items: flex-start;
}

.cert-photo-box,
.cert-qr-box {
  width: 46%;
  aspect-ratio: 1 / 1.15;
  border: 1px solid #888;
  background: #111;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cert-qr-box {
  aspect-ratio: 1 / 1;
  background: #fff;
}

.cert-photo-box img,
.cert-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.cert-qr-box img {
  object-fit: contain;
  background: #fff;
  padding: 4%;
  box-sizing: border-box;
}

.cert-media-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2.2cqw;
  font-weight: 600;
  z-index: 0;
}

.cert-qr-box .cert-media-fallback {
  color: #666;
}

.cert-val {
  position: absolute;
  font-family: "STSong", "SimSun", "Songti SC", "Noto Serif SC", "Microsoft YaHei", serif;
  color: #111;
  white-space: nowrap;
  line-height: 1.15;
  font-size: 1.45cqw;
  -webkit-font-smoothing: antialiased;
}

/* Values sit on the right-side underlines of c-bg.png */
.cert-val-name,
.cert-val-idtype,
.cert-val-idcard,
.cert-val-job,
.cert-val-level,
.cert-val-code {
  left: 70.5%;
  width: 20%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cert-val-name { top: 39.8%; }
.cert-val-idtype { top: 45.8%; }
.cert-val-idcard { top: 51.8%; }
.cert-val-job { top: 57.8%; }
.cert-val-level { top: 63.8%; }
.cert-val-code { top: 69.8%; }

.cert-val-serial {
  left: 10.2%;
  top: 89.6%;
  font-family: "Times New Roman", Times, serif;
  font-size: 1.35cqw;
}

/* Split date into slots before 年 / 月 / 日 on the background */
.cert-val-year,
.cert-val-month,
.cert-val-day {
  top: 85.2%;
  font-size: 1.35cqw;
  text-align: right;
}

.cert-val-year {
  left: 79.2%;
  width: 4.8%;
}

.cert-val-month {
  left: 84.9%;
  width: 2.8%;
}

.cert-val-day {
  left: 87.2%;
  width: 2.8%;
}

/* Seal watermark under date area */
.cert-yin {
  position: absolute;
  left: 78%;
  top: 75.5%;
  width: 14%;
  height: auto;
  pointer-events: none;
  user-select: none;
  mix-blend-mode: multiply;
  opacity: 0.92;
  z-index: 2;
}

/* High-res export mode: fixed px sizes matching 2172px canvas */
.cert-card.cert-exporting {
  width: 2172px !important;
  height: 1416px !important;
  aspect-ratio: auto;
}

.cert-card.cert-exporting .cert-val {
  font-size: 30px !important;
}

.cert-card.cert-exporting .cert-val-serial,
.cert-card.cert-exporting .cert-val-year,
.cert-card.cert-exporting .cert-val-month,
.cert-card.cert-exporting .cert-val-day {
  font-size: 28px !important;
}

.cert-card.cert-exporting .cert-media-fallback {
  font-size: 36px !important;
}

.cert-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  border: none;
  border-radius: 6px;
  background: #87cefa;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  margin-bottom: 8px;
}

.cert-download-btn:active {
  opacity: 0.85;
}

.cert-download-icon {
  width: 18px;
  height: 18px;
  border: 1.5px solid #fff;
  border-radius: 3px;
  position: relative;
  flex-shrink: 0;
}

.cert-download-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 1.5px;
  height: 7px;
  background: #fff;
  transform: translateX(-50%);
}

.cert-download-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #fff;
  transform: translateX(-50%);
}

/* Responsive */
@media (max-width: 375px) {
  .main {
    max-width: 100%;
  }
}

@media (min-width: 376px) {
  body {
    background: #e8e8e8;
  }

  .main {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  }
}
